@serene-pub/core-catalog 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 (276) hide show
  1. package/README.md +1 -1
  2. package/components/genres/story/authors-note/AuthorsNote.svelte +2 -1
  3. package/components/genres/story/authors-note/AuthorsNoteWidget.svelte +177 -58
  4. package/components/shared/WidgetBoundary.svelte +37 -0
  5. package/components/shared/actions/Actions.svelte +2 -1
  6. package/components/shared/actions/ActionsWidget.svelte +31 -38
  7. package/components/shared/album/Album.svelte +2 -1
  8. package/components/shared/album/AlbumWidget.svelte +1 -7
  9. package/components/shared/annex/Annex.svelte +2 -1
  10. package/components/shared/annex/AnnexWidget.svelte +1 -1
  11. package/components/shared/attendance/Attendance.svelte +2 -1
  12. package/components/shared/attendance/AttendanceWidget.svelte +5 -8
  13. package/components/shared/backdrop/Backdrop.svelte +2 -1
  14. package/components/shared/backdrop/BackdropWidget.svelte +28 -22
  15. package/components/shared/chronicle/Chronicle.svelte +2 -1
  16. package/components/shared/chronicle/ChronicleWidget.svelte +211 -99
  17. package/components/shared/composer/Composer.svelte +25 -0
  18. package/components/shared/composer/ComposerWidget.svelte +146 -0
  19. package/components/shared/composer/composer.ts +10 -0
  20. package/components/shared/composer/settings.ts +59 -0
  21. package/components/shared/composer/target.ts +79 -0
  22. package/components/shared/dialogue-box/DialogueBoxMount.svelte +25 -0
  23. package/components/shared/dialogue-box/DialogueBoxWidget.svelte +207 -0
  24. package/components/shared/dialogue-box/dialogue-box.ts +10 -0
  25. package/components/shared/dialogue-box/settings.ts +25 -0
  26. package/components/shared/lore-entries/LoreEntries.svelte +2 -1
  27. package/components/shared/lore-entries/LoreEntriesWidget.svelte +44 -41
  28. package/components/shared/messages/MessageBlocksView.svelte +1 -1
  29. package/components/shared/messages/MessageControls.svelte +23 -5
  30. package/components/shared/messages/Messages.svelte +2 -1
  31. package/components/shared/messages/MessagesWidget.svelte +82 -191
  32. package/components/shared/messages/NextCharacterBlock.svelte +35 -20
  33. package/components/shared/messages/SceneDivider.svelte +40 -14
  34. package/components/shared/messages/SessionComposer.svelte +178 -123
  35. package/components/shared/messages/SessionContainer.svelte +89 -38
  36. package/components/shared/messages/SessionMessage.svelte +157 -54
  37. package/components/shared/messages/SpokenLine.svelte +57 -16
  38. package/components/shared/messages/StateProposalList.svelte +30 -20
  39. package/components/shared/messages/TurnLine.svelte +258 -66
  40. package/components/shared/messages/conversation.svelte.ts +83 -5
  41. package/components/shared/messages/readingPace.ts +101 -0
  42. package/components/shared/messages/rowFacts.ts +44 -0
  43. package/components/shared/messages/sceneMarks.ts +54 -0
  44. package/components/shared/messages/spokenLine.ts +63 -14
  45. package/components/shared/places/Places.svelte +2 -1
  46. package/components/shared/places/PlacesWidget.svelte +42 -33
  47. package/components/shared/routine-log/RoutineLog.svelte +2 -1
  48. package/components/shared/routine-log/RoutineLogWidget.svelte +0 -4
  49. package/components/shared/routine-log/routineLog.ts +5 -21
  50. package/components/shared/scene-portraits/ScenePortraits.svelte +2 -1
  51. package/components/shared/scene-portraits/ScenePortraitsWidget.svelte +54 -32
  52. package/components/shared/session-runs/SessionRuns.svelte +26 -0
  53. package/components/shared/session-runs/SessionRunsWidget.svelte +270 -0
  54. package/components/shared/session-runs/session-runs.ts +11 -0
  55. package/components/shared/state/PieceCard.svelte +36 -25
  56. package/components/shared/state/SlotControl.svelte +18 -5
  57. package/components/shared/stats/Stats.svelte +2 -1
  58. package/components/shared/stats/StatsWidget.svelte +104 -72
  59. package/components/shared/turn-line/TurnLineMount.svelte +25 -0
  60. package/components/shared/turn-line/TurnLineWidget.svelte +25 -0
  61. package/components/shared/turn-line/settings.ts +31 -0
  62. package/components/shared/turn-line/turn-line.ts +10 -0
  63. package/components/shared/turn-order/TurnOrder.svelte +2 -1
  64. package/components/shared/turn-order/TurnOrderWidget.svelte +1 -6
  65. package/dist/components/actions.js +71 -88
  66. package/dist/components/actions.source.json +1 -1
  67. package/dist/components/album.js +39 -44
  68. package/dist/components/album.source.json +1 -1
  69. package/dist/components/annex.js +17 -8
  70. package/dist/components/annex.source.json +1 -1
  71. package/dist/components/attendance.js +39 -48
  72. package/dist/components/attendance.source.json +1 -1
  73. package/dist/components/authors-note.js +329 -162
  74. package/dist/components/authors-note.source.json +1 -1
  75. package/dist/components/backdrop.js +52 -55
  76. package/dist/components/backdrop.source.json +1 -1
  77. package/dist/components/chronicle.js +798 -559
  78. package/dist/components/chronicle.source.json +1 -1
  79. package/dist/components/composer.js +1639 -0
  80. package/dist/components/composer.source.json +1 -0
  81. package/dist/components/core-ui.json +1 -1
  82. package/dist/components/dialogue-box.js +373 -0
  83. package/dist/components/dialogue-box.source.json +1 -0
  84. package/dist/components/lore-entries.js +134 -122
  85. package/dist/components/lore-entries.source.json +1 -1
  86. package/dist/components/messages.js +1517 -8930
  87. package/dist/components/messages.source.json +1 -1
  88. package/dist/components/places.js +267 -244
  89. package/dist/components/places.source.json +1 -1
  90. package/dist/components/routine-log.js +35 -51
  91. package/dist/components/routine-log.source.json +1 -1
  92. package/dist/components/scene-portraits.js +118 -59
  93. package/dist/components/scene-portraits.source.json +1 -1
  94. package/dist/components/session-runs.js +488 -0
  95. package/dist/components/session-runs.source.json +1 -0
  96. package/dist/components/{shared-7VDIXYAL.js → shared-47J4TNSF.js} +1 -1
  97. package/dist/components/{shared-W3XS5FEL.js → shared-5E4RQYRX.js} +3 -2
  98. package/dist/components/{shared-YDS7HYL6.js → shared-EFMMT76D.js} +57 -4
  99. package/dist/components/{shared-BIWKZFUU.js → shared-FOVKPMSK.js} +3 -3
  100. package/dist/components/{shared-JPG5DQO7.js → shared-HEAKNNZB.js} +92 -17
  101. package/dist/components/shared-JXP6SHKF.js +159 -0
  102. package/dist/components/{shared-XBDUENRA.js → shared-JXYPKSTQ.js} +1 -1
  103. package/dist/components/shared-KJIOSSE3.js +257 -0
  104. package/dist/components/{shared-WV3QTKZT.js → shared-KLURQFWI.js} +13 -9
  105. package/dist/components/shared-MHCNUDUT.js +1680 -0
  106. package/dist/components/{shared-QXF5CJVN.js → shared-NICRJ4Z2.js} +1 -1
  107. package/dist/components/{shared-BBF64YGL.js → shared-W2BBJCNE.js} +22 -16
  108. package/dist/components/shared-YYYXFDZU.js +4354 -0
  109. package/dist/components/stats.js +828 -678
  110. package/dist/components/stats.source.json +1 -1
  111. package/dist/components/turn-line.js +856 -0
  112. package/dist/components/turn-line.source.json +1 -0
  113. package/dist/components/turn-order.js +62 -67
  114. package/dist/components/turn-order.source.json +1 -1
  115. package/dist/factories/answerForm.d.ts +6 -0
  116. package/dist/factories/answerForm.js +104 -96
  117. package/dist/factories/turnOrder.d.ts +98 -105
  118. package/dist/factories/turnOrder.js +120 -136
  119. package/dist/functions/pieces.js +1 -0
  120. package/dist/functions/time.js +2 -0
  121. package/dist/genres/chat/create.js +2 -0
  122. package/dist/genres/chat/memory.js +64 -43
  123. package/dist/genres/chat/respond.d.ts +7 -6
  124. package/dist/genres/chat/respond.js +13 -4
  125. package/dist/genres/chat/turnOrder.d.ts +2 -2
  126. package/dist/genres/chat/turnOrder.js +28 -12
  127. package/dist/genres/defaults.d.ts +28 -6
  128. package/dist/genres/defaults.js +84 -26
  129. package/dist/genres/dungeon-crawler/calls.d.ts +3 -1
  130. package/dist/genres/dungeon-crawler/calls.js +5 -0
  131. package/dist/genres/dungeon-crawler/create.d.ts +9 -6
  132. package/dist/genres/dungeon-crawler/create.js +18 -8
  133. package/dist/genres/dungeon-crawler/death.d.ts +13 -6
  134. package/dist/genres/dungeon-crawler/death.js +26 -12
  135. package/dist/genres/dungeon-crawler/index.d.ts +1 -0
  136. package/dist/genres/dungeon-crawler/index.js +1 -0
  137. package/dist/genres/dungeon-crawler/journal.d.ts +1 -1
  138. package/dist/genres/dungeon-crawler/journal.js +1 -1
  139. package/dist/genres/dungeon-crawler/lore.d.ts +13 -12
  140. package/dist/genres/dungeon-crawler/lore.js +16 -25
  141. package/dist/genres/dungeon-crawler/names.d.ts +10 -3
  142. package/dist/genres/dungeon-crawler/names.js +10 -3
  143. package/dist/genres/dungeon-crawler/preamble.d.ts +5 -4
  144. package/dist/genres/dungeon-crawler/preamble.js +75 -33
  145. package/dist/genres/dungeon-crawler/respond.js +4 -2
  146. package/dist/genres/dungeon-crawler/rest.d.ts +8 -7
  147. package/dist/genres/dungeon-crawler/rest.js +39 -15
  148. package/dist/genres/dungeon-crawler/reveal.js +2 -2
  149. package/dist/genres/dungeon-crawler/roundScript.d.ts +2 -1
  150. package/dist/genres/dungeon-crawler/roundScript.js +23 -5
  151. package/dist/genres/dungeon-crawler/scripts.js +4 -5
  152. package/dist/genres/dungeon-crawler/shape.d.ts +16 -0
  153. package/dist/genres/dungeon-crawler/shape.js +5 -1
  154. package/dist/genres/dungeon-crawler/sheet.d.ts +20 -20
  155. package/dist/genres/dungeon-crawler/story.d.ts +27 -16
  156. package/dist/genres/dungeon-crawler/story.js +175 -46
  157. package/dist/genres/dungeon-crawler/storyScripts.d.ts +2 -2
  158. package/dist/genres/dungeon-crawler/storyScripts.js +109 -14
  159. package/dist/genres/dungeon-crawler/summarizeScene.d.ts +13 -0
  160. package/dist/genres/dungeon-crawler/summarizeScene.js +21 -0
  161. package/dist/genres/dungeon-crawler/turnOrder.d.ts +8 -9
  162. package/dist/genres/dungeon-crawler/turnOrder.js +33 -23
  163. package/dist/genres/guide/create.js +2 -0
  164. package/dist/genres/guide/turnOrder.d.ts +3 -3
  165. package/dist/genres/guide/turnOrder.js +29 -13
  166. package/dist/genres/lair/answerForm.js +4 -1
  167. package/dist/genres/lair/buildRoom.js +4 -3
  168. package/dist/genres/lair/castellanAction.js +160 -154
  169. package/dist/genres/lair/create.js +2 -0
  170. package/dist/genres/lair/fileCurrentRoom.js +13 -10
  171. package/dist/genres/lair/fileRoom.js +4 -3
  172. package/dist/genres/lair/keeper.js +6 -2
  173. package/dist/genres/lair/names.d.ts +2 -0
  174. package/dist/genres/lair/names.js +2 -0
  175. package/dist/genres/lair/reply.js +16 -6
  176. package/dist/genres/lair/roomAnswer.js +4 -3
  177. package/dist/genres/lair/scratchpad.js +9 -7
  178. package/dist/genres/lair/scripts.js +8 -6
  179. package/dist/genres/lair/turnOrder.d.ts +3 -2
  180. package/dist/genres/lair/turnOrder.js +45 -16
  181. package/dist/genres/story/ask.d.ts +4 -0
  182. package/dist/genres/story/ask.js +4 -0
  183. package/dist/genres/story/create.js +15 -0
  184. package/dist/genres/story/index.d.ts +1 -1
  185. package/dist/genres/story/index.js +1 -1
  186. package/dist/genres/story/narrate.js +8 -0
  187. package/dist/genres/story/narrateCharacter.js +8 -0
  188. package/dist/genres/story/reckon.d.ts +5 -19
  189. package/dist/genres/story/reckon.js +53 -40
  190. package/dist/genres/story/reckoning.js +3 -0
  191. package/dist/genres/story/respond.js +17 -28
  192. package/dist/genres/story/sweep.d.ts +1 -1
  193. package/dist/genres/story/sweep.js +1 -1
  194. package/dist/genres/story/turnOrder.d.ts +21 -3
  195. package/dist/genres/story/turnOrder.js +87 -21
  196. package/dist/index.d.ts +3 -0
  197. package/dist/index.js +23 -9
  198. package/dist/loadouts.d.ts +1 -0
  199. package/dist/loadouts.js +17 -1
  200. package/dist/primers/ninth-mile.d.ts +3 -4
  201. package/dist/registry/entries.d.ts +2 -0
  202. package/dist/registry/entries.js +18 -5
  203. package/dist/registry/genres.d.ts +146 -40
  204. package/dist/registry/genres.js +373 -101
  205. package/dist/registry/hostState.d.ts +1 -2
  206. package/dist/registry/hostState.js +2 -4
  207. package/dist/registry/layouts.d.ts +141 -111
  208. package/dist/registry/layouts.js +302 -141
  209. package/dist/registry/slots.d.ts +4 -3
  210. package/dist/registry/slots.js +4 -3
  211. package/dist/registry/widgets.d.ts +12 -2
  212. package/dist/registry/widgets.js +259 -106
  213. package/dist/rulesets/vis-itineris/ruleset.js +8 -5
  214. package/dist/rulesets/wherewithal/ruleset.js +2 -1
  215. package/dist/seed/presets.js +15 -9
  216. package/dist/seed/prompts.js +24 -5
  217. package/dist/seed/scripts.js +3 -0
  218. package/dist/shared/annexField.js +23 -3
  219. package/dist/shared/illustrateScene.d.ts +1 -0
  220. package/dist/shared/illustrateScene.js +29 -1
  221. package/dist/shared/lore.d.ts +13 -0
  222. package/dist/shared/lore.js +37 -1
  223. package/dist/shared/portrait.js +13 -4
  224. package/dist/shared/reckoning.d.ts +8 -2
  225. package/dist/shared/reckoning.js +47 -30
  226. package/dist/shared/roundTick.d.ts +20 -0
  227. package/dist/shared/roundTick.js +76 -0
  228. package/dist/shared/sceneBoundaries.d.ts +7 -0
  229. package/dist/shared/sceneBoundaries.js +62 -0
  230. package/dist/shared/sceneSummaries.d.ts +7 -0
  231. package/dist/shared/sceneSummaries.js +49 -0
  232. package/dist/shared/speakMessage.d.ts +9 -2
  233. package/dist/shared/speakMessage.js +32 -9
  234. package/dist/shared/speechFields.js +4 -0
  235. package/dist/shared/summarize/character.d.ts +1 -1
  236. package/dist/shared/summarize/history.d.ts +1 -1
  237. package/dist/shared/summarize/scene.d.ts +1 -1
  238. package/dist/shared/summarize/summarizeScene.js +1 -0
  239. package/dist/shared/summarize/summarizeSpec.d.ts +1 -1
  240. package/dist/shared/summarize/world.d.ts +1 -1
  241. package/dist/shared/ui/attendance/index.d.ts +3 -2
  242. package/dist/shared/ui/attendance/index.js +3 -7
  243. package/dist/shared/ui/chronicle/index.d.ts +24 -2
  244. package/dist/shared/ui/chronicle/index.js +58 -29
  245. package/dist/shared/ui/conversation/formAnswer.d.ts +16 -2
  246. package/dist/shared/ui/conversation/formAnswer.js +23 -9
  247. package/dist/shared/ui/conversation/index.d.ts +2 -0
  248. package/dist/shared/ui/conversation/index.js +4 -0
  249. package/dist/shared/ui/conversation/itemValues.d.ts +16 -3
  250. package/dist/shared/ui/conversation/itemValues.js +15 -5
  251. package/dist/shared/ui/conversation/messageVerbState.d.ts +17 -2
  252. package/dist/shared/ui/conversation/messageVerbState.js +5 -4
  253. package/dist/shared/ui/conversation/readingPlace.d.ts +40 -0
  254. package/dist/shared/ui/conversation/readingPlace.js +119 -0
  255. package/dist/shared/ui/conversation/rewindStrip.d.ts +13 -4
  256. package/dist/shared/ui/conversation/rewindStrip.js +29 -7
  257. package/dist/shared/ui/conversation/runsInProgress.d.ts +30 -0
  258. package/dist/shared/ui/conversation/runsInProgress.js +47 -0
  259. package/dist/shared/ui/conversation/storyDays.d.ts +7 -1
  260. package/dist/shared/ui/conversation/storyDays.js +8 -0
  261. package/dist/shared/ui/conversation/tableChannel.d.ts +8 -11
  262. package/dist/shared/ui/conversation/tableChannel.js +8 -9
  263. package/dist/shared/ui/places/index.d.ts +3 -2
  264. package/dist/shared/ui/places/index.js +4 -5
  265. package/dist/shared/ui/routine-log/index.d.ts +3 -0
  266. package/dist/shared/ui/routine-log/index.js +22 -0
  267. package/dist/shared/ui/scene-portraits/portraits.d.ts +50 -16
  268. package/dist/shared/ui/scene-portraits/portraits.js +84 -21
  269. package/dist/shared/ui/session-runs/index.d.ts +90 -0
  270. package/dist/shared/ui/session-runs/index.js +143 -0
  271. package/dist/shared/ui/session-state/stateView.d.ts +18 -5
  272. package/dist/shared/ui/session-state/stateView.js +29 -8
  273. package/dist/shared/ui/turn-order/index.d.ts +0 -9
  274. package/dist/shared/ui/turn-order/index.js +1 -2
  275. package/package.json +12 -8
  276. /package/dist/components/{shared-4ME6NFDK.js → shared-LUIF6DW7.js} +0 -0
@@ -4,58 +4,52 @@
4
4
  *
5
5
  * ## What this spec is
6
6
  *
7
- * One pipeline, bound to every session event a genre cares about, that
7
+ * **One option among a genre's turn order options** on Turn order asked. It
8
8
  * answers the question "whose turn is it" by **writing it down**:
9
9
  *
10
10
  * ```
11
11
  * event ─► history ─► pool ─► mentioned ─► strategy ─► set-turn-order
12
12
  * ```
13
13
  *
14
- * On the rules path it calls no model, writes no message and costs no token
15
- * — five reads and a `jsonb_set`. A genre may add the optional model path
16
- * (R41, `advise`), which asks a model once per recompute when the session's
17
- * `turnMode` is `model`. What it produces is the session's stored turn order:
18
- * the prepared turns, the candidates they were drawn from, and what the
19
- * order answers. Every surface that used to ask "who is next" by running a
20
- * decider now renders that state, and the reply run fires an entry out of
21
- * it (§4.6).
14
+ * On a rules strategy it calls no model, writes no message and costs no token
15
+ * — five reads and a `jsonb_set`. The model option (`modelTurnOrder`) seats an
16
+ * oracle in place of `strategy`, which asks a model once per recompute. What
17
+ * it produces is the session's stored turn order: the prepared turns, the
18
+ * candidates they were drawn from, and what the order answers. Every surface
19
+ * that asks "who is next" renders that state, and the reply run fires an
20
+ * entry out of it (§4.6).
22
21
  *
23
- * ## Why it replaced the decider
22
+ * ## Options, not swaps
24
23
  *
25
- * Until 2026-09-21 the respond spec ran up to a `speaker` node and halted
26
- * when nobody was due. Three things were wrong with that and all three go
27
- * away here: the answer existed only inside a run, so a person could not
28
- * see whose turn it was without starting one; "nobody is due" was a halt,
29
- * which is an error shape for an ordinary state; and the trigger had to
30
- * know about turn-taking to read the halt as quiet. Now the order is a
31
- * document, an empty order is an answer, and the trigger decides nothing.
24
+ * A genre registers one pipeline per option on Turn order asked (R24); the
25
+ * session's choice picks which one runs, and the one marked `default` runs
26
+ * when it chose none. The causes an option answers are its registration's
27
+ * `when` over `event.asked`, never part of the document. A strategy is not
28
+ * swapped into a node: each option pins its own, and keeps its own pool and
29
+ * mention settings.
32
30
  *
33
- * ## One spec per genre (R27, the modder pass, 2026-09-23)
31
+ * ## One document per option (R27)
34
32
  *
35
- * `turnOrderSpec()` below is the **public** builder: core calls it four
36
- * times, one per genre (`core:spec/<genre>-turn-order`), and a plugin genre
37
- * calls the same function. One document serves one genre — the preset check
38
- * refuses a preset binding a spec whose lock names another genre (24 §4) —
39
- * so the two shared slugs this file shipped at A6 (`core:spec/turn-order`,
40
- * `core:spec/turn-order-narrator`) are retired.
41
- *
42
- * A cast genre pins round robin; a planner genre (Adventure, the Lair)
43
- * pins `turn-narrator`, so it gets exactly one narrator turn per send —
44
- * Adventure's pool admits nobody; the Lair's admits its delvers, for the
45
- * character turns a standing turn plan names. What a session may pick instead is
46
- * the `strategy` node's `expose.swaps` (R28) — chat lists the other five
47
- * core strategies; the rest list none, so they render no control.
33
+ * `turnOrderSpec()` below is the **public** builder, with one ready-made
34
+ * builder per core strategy: `roundRobinTurnOrder`, `byUserTurnOrder`,
35
+ * `randomTurnOrder`, `narratorTurnOrder` and `modelTurnOrder`. One document
36
+ * serves one genre — the preset check refuses a preset binding a spec whose
37
+ * lock names another genre (24 §4) — so an option's id is taken, never derived.
48
38
  */
49
- import { compile, slot, spec, sessionEvents } from '@serene-pub/sdk';
39
+ import { compile, coreEvents, slot, spec } from '@serene-pub/sdk';
50
40
  import * as C from '@serene-pub/contracts';
41
+ import { applyWiring, jsonPart, wiring } from '../shared/calls.js';
51
42
  import { chainIf } from '../shared/chains.js';
52
43
  /**
53
44
  * 🚧 `core:script/unprompted-modes` (2026-10-20): the genre's voices settings
54
45
  * — its fields `sideCast` and `narratorInterjections`, read off the settings
55
46
  * document a turn-order spec's inlet carries — as `core:task/turn-unprompted@1`
56
47
  * reads them: `{ 'side-cast', 'narrator-interjections' }`, each `full` or
57
- * `off`. A field set `true` (or a stored `full` / `review`) is on. Seeded by
58
- * core (`CORE_SCRIPTS`); a turn-order spec with `unprompted` runs it.
48
+ * `off`, plus `narrator-every` (1, 2 or 3; present only when the narrator is
49
+ * on). `sideCast` set `true` (or a stored `full` / `review`) is on.
50
+ * `narratorInterjections` reads `true`, `full`, `review` and `every-round` as
51
+ * every round, `every-2nd-round` as 2, `every-3rd-round` as 3; anything else
52
+ * is off (2026-11-04, playtest ruling item 7). Seeded by core (`CORE_SCRIPTS`); a turn-order spec with `unprompted` runs it.
59
53
  * @experimental
60
54
  */
61
55
  export const UNPROMPTED_MODES_SCRIPT = Object.freeze({
@@ -66,135 +60,100 @@ export const UNPROMPTED_MODES_SCRIPT = Object.freeze({
66
60
  'var doc = value && typeof value === "object" ? value.session : null;',
67
61
  'var f = doc && typeof doc === "object" && doc.fields && typeof doc.fields === "object" ? doc.fields : {};',
68
62
  'function on(x) { return x === true || x === "full" || x === "review"; }',
69
- 'return { "side-cast": on(f.sideCast) ? "full" : "off", "narrator-interjections": on(f.narratorInterjections) ? "full" : "off" };',
63
+ 'var n = f.narratorInterjections;',
64
+ 'var every = n === "every-2nd-round" ? 2 : n === "every-3rd-round" ? 3 : n === true || n === "full" || n === "review" || n === "every-round" ? 1 : 0;',
65
+ 'var out = { "side-cast": on(f.sideCast) ? "full" : "off", "narrator-interjections": every ? "full" : "off" };',
66
+ 'if (every) out["narrator-every"] = every;',
67
+ 'return out;',
70
68
  ].join('\n'),
71
69
  varsIn: Object.freeze(['value']),
72
70
  varsOut: Object.freeze(['value']),
73
71
  });
74
72
  /** @experimental */
75
73
  export const TURN_ORDER_VERSION = '1.0.0';
76
- /**
77
- * The nine events a cast genre recomputes on (§4.5).
78
- *
79
- * Every one of them can change who should speak next: a row landing, a row
80
- * leaving, a seat being switched off, a setting moving, a branch being
81
- * born. There is no gating (R1) — the list is what the genre declares and
82
- * the inlet locks, and a genre that wants fewer binds fewer.
83
- * @public
84
- */
85
- export const TURN_ORDER_EVENTS = [
86
- sessionEvents.messageCompleted,
87
- sessionEvents.messageEdited,
88
- sessionEvents.messageDeleted,
89
- sessionEvents.messageHidden,
90
- sessionEvents.memberAdded,
91
- sessionEvents.memberRemoved,
92
- sessionEvents.castChanged,
93
- sessionEvents.sessionUpdated,
94
- sessionEvents.sessionBranched,
95
- ];
96
- /**
97
- * The four events a planner genre recomputes on: a row landing, a row
98
- * leaving (deleted, or hidden and shown again), and a branch's birth. Its
99
- * order is one narrator entry or none — decided by whether the newest
100
- * visible row is a person's — so exactly the events that change which row
101
- * is newest move it. A cast change or a settings save cannot, and
102
- * recomputing on them would be reads for a document that cannot differ.
103
- *
104
- * Delete and hide are here (lair pass F6/B9, 2026-09-27) so the order stays
105
- * honest after a person removes the narrator's last reply: the line they
106
- * wrote is newest again, and the narrator is ready. Both carry an `edit`
107
- * cause, which auto-advance never fires on.
108
- * @experimental
109
- */
110
- export const TURN_ORDER_NARRATOR_EVENTS = [
111
- sessionEvents.messageCompleted,
112
- sessionEvents.messageDeleted,
113
- sessionEvents.messageHidden,
114
- sessionEvents.sessionBranched,
115
- ];
74
+ /** An oracle pin asks a model; a task pin is a rule. */
75
+ const isAdvise = (pin) => pin.descriptor.kind === 'oracle';
116
76
  /** The node an advise pin seats, whatever its type version. */
117
77
  const adviseNode = (advise, config) => ({ __node: true, descriptor: advise.descriptor, config });
118
78
  /** The node a strategy pin seats, whatever its type version. */
119
79
  const strategyNode = (strategy, config) => ({ __node: true, descriptor: strategy.descriptor, config });
120
80
  /**
121
- * **The turn-order spec for one genre** (R27). Core's four and every plugin
122
- * genre's come from this one call:
81
+ * **One turn order option for one genre** (R27). Core's and every plugin
82
+ * genre's come from this one call, or from the ready-made builder of the
83
+ * strategy:
123
84
  *
124
85
  * ```ts
125
- * const tavernTurnOrder = turnOrderSpec({
126
- * id: 'acme.rp:spec/tavern-turn-order',
127
- * genre: tavern,
128
- * events: [...TURN_ORDER_EVENTS, sessionEvents.annexChanged],
129
- * strategy: C.turnRoundRobin,
130
- * swaps: [C.turnRandom, myStrategy],
86
+ * const tavernRoundRobin = roundRobinTurnOrder(tavern, { id: 'acme.rp:spec/tavern-turn-order' })
87
+ * register(coreEvents.turnOrderAsked, tavernRoundRobin, {
88
+ * label: 'Round robin',
89
+ * when: { on: 'event.asked', in: [sessionEvents.messageCompleted] },
90
+ * default: true,
131
91
  * })
132
92
  * ```
133
93
  *
134
- * `id` is taken, never derived (R26). `strategy` is the pin — the default
135
- * the Turn order control shows, offered first; `swaps` is what a session may
136
- * pick instead, and none means no control. `pool` is the author preset on
137
- * the pool node, the one road configuration takes: declared default, the
138
- * author's preset over it, an administrator's deviation, a session's
139
- * override last. A preset binds the result like any spec: `bindings: [tavernTurnOrder, …]`.
94
+ * `id` is taken, never derived (R26). `strategy` is the pin — a task pin is a
95
+ * rule (node key `strategy`), an oracle pin asks a model (node key `advise`).
96
+ * `pool` is the author preset on the pool node, the one road configuration
97
+ * takes: declared default, the author's preset over it, an administrator's
98
+ * deviation, a session's override last. A preset binds the result like any
99
+ * spec: `bindings: [tavernRoundRobin, …]`.
140
100
  *
141
- * With `swaps`, `pool`, `mentioned` and `strategy` are marked for session
142
- * settings (§4.11, R42): who is eligible, the mention rule's lookback, and
143
- * the strategy. Without, the spec shows no turn control at all.
101
+ * With `sessionSettings`, `pool` and `mentioned` are marked for session
102
+ * settings (§4.11, R42): who is eligible and the mention rule's lookback.
103
+ * Without, the spec shows no turn control at all.
144
104
  * @public
145
105
  */
146
106
  export function turnOrderSpec(opts) {
147
- const { id, genre, events, strategy, swaps = [], pool = {}, historyChannel, advise, scripts, unprompted, version = TURN_ORDER_VERSION } = opts;
148
- // The model path branches on the genre field `turnMode`; a genre that
149
- // does not declare it could never take it (R26, M4 review).
150
- if (advise && !genre.shape?.fields?.turnMode)
151
- throw new Error(`turnOrderSpec('${id}'): advise needs genre '${genre.id}' to declare the field turnMode ` +
152
- `(TURN_MODE_FIELD) — without it the model path can never fire`);
107
+ const { id, genre, strategy, pool = {}, historyChannel, scripts, unprompted, emptyCast, sessionSettings, outcomeNumbersFrom, version = TURN_ORDER_VERSION, } = opts;
108
+ const outcomes = wiring();
153
109
  // The voices read the genre's two fields; a genre that does not declare
154
110
  // them could never turn an unprompted voice on (R26).
155
111
  const fields = (genre.shape?.fields ?? {});
156
112
  if (unprompted && (!fields.sideCast || !fields.narratorInterjections))
157
113
  throw new Error(`turnOrderSpec('${id}'): unprompted needs genre '${genre.id}' to declare the fields sideCast and ` +
158
114
  `narratorInterjections (SIDE_CAST_FIELD, NARRATOR_INTERJECTIONS_FIELD) — the voices are its settings`);
159
- // R42: a spec that offers swaps shows its turn controls — who may be
160
- // seated, the mention rule, the strategy; one that offers none shows none.
161
- const controls = swaps.length ? { expose: { session: true } } : undefined;
162
- // Only with something to choose: no swaps, no control (R28).
163
- const strategyExpose = swaps.length ? { expose: { swaps } } : undefined;
115
+ const advise = isAdvise(strategy) ? strategy : undefined;
116
+ const rule = isAdvise(strategy) ? undefined : strategy;
117
+ // R42: with `sessionSettings`, who may be seated and the mention rule show as turn controls.
118
+ const controls = sessionSettings ? { expose: { session: true } } : undefined;
164
119
  /**
165
- * Locked over every event this genre recomputes on (§4.1): one document,
166
- * N binding rows. The visible history is what every rule reads to decide
167
- * who has already spoken; the cast rides on the inlet in the settings
168
- * document (§4.12), resolved after the write that caused this event.
169
- * `pool` decides who may be seated at all; `mentioned` (R8) moves whoever
170
- * was named to the front without changing who is in. `maintenance`
171
- * because it is a background lane (ruled 2026-10-05): it runs after the
172
- * turn, off its critical path, and carries no turn of its own.
120
+ * The inlet suits Turn order asked (§4.1): one document per option. The
121
+ * visible history is what every rule reads to decide who has already
122
+ * spoken; the cast rides on the inlet in the settings document (§4.12),
123
+ * resolved after the write that caused this event. `pool` decides who may
124
+ * be seated at all; `mentioned` (R8) moves whoever was named to the front
125
+ * without changing who is in. `maintenance` because it is a background
126
+ * lane (ruled 2026-10-05): it runs after the turn, off its critical path,
127
+ * and carries no turn of its own.
173
128
  */
174
- const upToMentioned = spec(id, { version, taxonomy: { role: 'maintenance' } })
175
- .inlet('event', C.sessionEvent.v1(), { suits: [...events] })
176
- .query('history', ($) => C.sessionHistory.v1({ scope: $.event.sessionScope, params: slot.params() }))
129
+ const opened = spec(id, { version, taxonomy: { role: 'maintenance' } }).inlet('event', C.sessionEvent.v1(), {
130
+ suits: [coreEvents.turnOrderAsked],
131
+ });
132
+ /** The genre's Show outcomes field, read off the settings document; with no `outcomeNumbersFrom` the step is not added. */
133
+ const shown = chainIf(!!outcomeNumbersFrom, opened, (o) => jsonPart(o, outcomes, 'showOutcomes', ($) => $.event.session, 'fields.' + outcomeNumbersFrom, 'Show outcomes'));
134
+ const upToMentioned = shown
135
+ .query('history', ($) => C.sessionHistory.v1({
136
+ scope: $.event.sessionScope,
137
+ ...(outcomeNumbersFrom ? { outcomeNumbers: $.showOutcomes.main } : {}),
138
+ params: slot.params(),
139
+ }))
177
140
  .task('pool', ($) => C.turnPool.v1({ cast: $.event.cast, messages: $.history.main, params: slot.params() }), controls)
178
141
  .task('mentioned', ($) => C.turnMentioned.v1({ candidates: $.pool.main, messages: $.history.main, params: slot.params() }), controls);
179
- /** The strategy — turns candidates into entries, never halts (an empty order is an answer). */
180
- const strategyOf = ($) => strategyNode(strategy, { candidates: $.mentioned.main, messages: $.history.main });
181
142
  /**
182
- * The two paths (R41): the junction reads the settings document on the
183
- * inlet, so `turnMode` cascades like any genre field (§4.13). `advise` is
184
- * in session settings so a plugin's model strategy can be contributed to
185
- * it (R29, M4). Its result port `order` is what the write reads.
186
- * Built as one or the other, typed as both: what follows reads
187
- * `$.decide.order` with a model path, `$.strategy.order` without.
143
+ * The strategy — turns candidates into entries, never halts (an empty
144
+ * order is an answer). A rule is the task `strategy`; a model is the
145
+ * oracle `advise`, whose connection, sampling and prompts are session
146
+ * settings. Built as one or the other, typed as both: what follows reads
147
+ * `$.advise.order` for a model, `$.strategy.order` for a rule.
188
148
  */
189
- const decided = chainIf(!advise, chainIf(!!advise, upToMentioned, (u) => u.junction('decide', { on: ($) => $.event.session }, (j) => j
190
- .when('model', { path: (v) => v.fields.turnMode, equals: 'model' }, (c) => c.oracle('advise', ($) => adviseNode(advise, {
149
+ const decided = chainIf(!advise, chainIf(!!advise, upToMentioned, (u) => u.oracle('advise', ($) => adviseNode(advise, {
191
150
  candidates: $.mentioned.main,
192
151
  messages: $.history.main,
193
152
  connection: slot.connection(),
194
153
  sampling: slot.sampling(),
195
154
  prompts: slot.prompts(),
196
- }), { expose: { session: true } }))
197
- .otherwise('rules', (c) => c.task('strategy', strategyOf, strategyExpose)))), (u) => u.task('strategy', strategyOf, strategyExpose));
155
+ }), { expose: { session: true } })), (u) => u.task('strategy', ($) => strategyNode(rule, { candidates: $.mentioned.main, messages: $.history.main })));
156
+ const orderOf = ($) => (advise ? $.advise.order : $.strategy.order);
198
157
  /**
199
158
  * 🚧 The voices (lane 2; genre settings since 2026-10-20): the genre's
200
159
  * two voices fields read off the settings document, then at most one
@@ -203,30 +162,47 @@ export function turnOrderSpec(opts) {
203
162
  const voiced = chainIf(!!unprompted, decided, (d) => d
204
163
  .task('voices', ($) => C.runScript.v1({ input: { session: $.event.session }, params: slot.params() }), { expose: { label: 'Who may speak up unprompted' } })
205
164
  .task('unprompted', ($) => C.turnUnprompted.v1({
206
- order: advise ? $.decide.order : $.strategy.order,
165
+ order: orderOf($),
207
166
  candidates: $.pool.main,
208
167
  messages: $.history.main,
209
168
  modes: $.voices.main,
210
169
  params: slot.params(),
211
170
  })));
212
- return compile(voiced
171
+ const written = voiced
213
172
  /**
214
173
  * The one write path (§4.2). `basedOnAt` is the answered event's
215
174
  * instant, so an order computed from an older event is dropped
216
175
  * rather than landing on top of a newer one; `cause` travels on into
217
176
  * `turn-order-changed`, which is how auto-advance can tell a
218
177
  * person's send from a migration's backfill. `order` is the
219
- * strategy's — or, with a model path, the `decide` junction's own
220
- * result port, whichever path fired (M4) — or, with unprompted
221
- * turns, theirs over it.
178
+ * strategy's, or, with unprompted turns, theirs over it.
222
179
  */
223
180
  .outlet('write', ($) => C.setTurnOrder.v1({
224
- order: unprompted ? $.unprompted.order : advise ? $.decide.order : $.strategy.order,
181
+ order: unprompted ? $.unprompted.order : orderOf($),
225
182
  candidates: $.pool.main,
226
183
  basedOnAt: $.event.at,
227
184
  event: $.event.event,
228
185
  cause: $.event.cause,
229
- }))
186
+ }));
187
+ /**
188
+ * The composer gate (`emptyCast`): a side branch after the write, on the
189
+ * pool's candidates. Nobody: close (idempotent — the same closure written
190
+ * again — and only on a seat or session event, since no line can be sent
191
+ * while it stands). Somebody: open ONLY the closure this gate set, read off
192
+ * the settings document's `composerStates` (`main`, everyone, this reason),
193
+ * so a closure another pipeline put on `main` is never lifted here.
194
+ *
195
+ * ⚠ Every branch carries a node: a branch with none is not stored (a
196
+ * clause's chains are derived from its members on load), so an empty
197
+ * `otherwise` made the published document drift from this one.
198
+ */
199
+ const OURS = { path: 'composerStates.main.*.reason', equals: emptyCast?.reason };
200
+ const gated = chainIf(!!emptyCast, written, (w) => w.junction('seats', { on: ($) => $.pool.main }, (j) => j
201
+ .when('nobody', { path: 'length', equals: 0 }, (n) => n.outlet('close', () => C.setComposerState.v1({ channel: 'main', open: false, reason: emptyCast.reason }), { expose: { label: 'Close the composer while nobody can reply' } }))
202
+ .otherwise('somebody', (o) => o.junction('closed', { on: ($) => $.event.session }, (c) => c.when('ours', OURS, (k) => k.outlet('open', () => C.setComposerState.v1({ channel: 'main', open: true }), {
203
+ expose: { label: 'Open the composer once someone can reply' },
204
+ }))))));
205
+ return compile(gated
230
206
  // The author preset on `pool`, only when the genre pins anything:
231
207
  // an empty value would be a preset that changes nothing.
232
208
  .defaults((p) => {
@@ -234,10 +210,18 @@ export function turnOrderSpec(opts) {
234
210
  const read = historyChannel ? pooled.params('history', { channel: historyChannel }) : pooled;
235
211
  const narrated = unprompted?.narrate ? read.params('unprompted', { narrate: unprompted.narrate }) : read;
236
212
  const voices = unprompted ? narrated.scripts('voices', [{ seedKey: UNPROMPTED_MODES_SCRIPT.seedKey }]) : narrated;
237
- return scripts ? voices.scripts(turnStrategyNode({ advise }), scripts) : voices;
213
+ return applyWiring(scripts ? voices.scripts(advise ? 'advise' : 'strategy', scripts) : voices, outcomes);
238
214
  })
239
215
  .build());
240
216
  }
241
- /** The key of the node a turn-order spec's Turn order control swaps (M4): `strategy`, or `decide.rules.strategy` with a model path. @experimental */
242
- export const turnStrategyNode = (opts) => opts.advise ? 'decide.rules.strategy' : 'strategy';
217
+ /** **Round robin** option: each in the pool speaks in turn. @experimental */
218
+ export const roundRobinTurnOrder = (genre, opts) => turnOrderSpec({ ...opts, genre, strategy: C.turnRoundRobin });
219
+ /** **By user** option: round robin split by the person each seat belongs to. @experimental */
220
+ export const byUserTurnOrder = (genre, opts) => turnOrderSpec({ ...opts, genre, strategy: C.turnUserSplit });
221
+ /** **Random** option: the next speaker is drawn at random from the pool. @experimental */
222
+ export const randomTurnOrder = (genre, opts) => turnOrderSpec({ ...opts, genre, strategy: C.turnRandom });
223
+ /** **Narrator replies** option: one narrator turn per person's line. @experimental */
224
+ export const narratorTurnOrder = (genre, opts) => turnOrderSpec({ ...opts, genre, strategy: C.turnNarrator });
225
+ /** **Model** option: a model decides who speaks (R41); its node key is `advise`. @experimental */
226
+ export const modelTurnOrder = (genre, opts) => turnOrderSpec({ ...opts, genre, strategy: C.turnAdvise });
243
227
  //# sourceMappingURL=turnOrder.js.map
@@ -86,6 +86,7 @@ export const obligationFunction = defineFunction("core:function/obligation@1", {
86
86
  name: { en: "An obligation with a deadline" },
87
87
  meaning: { en: "Something owed by a certain time — a debt, a promise, a delivery — comes due when the time passes." },
88
88
  kind: "pieces",
89
+ countsTime: "story",
89
90
  bindings: { owed: { to: "entry-type", label: { en: "Owed" } } },
90
91
  adds: { events: [{ id: CAME_DUE, name: { en: "An obligation came due" }, description: { en: "The story clock passed what an obligation was owed by." } }] },
91
92
  prose: "{{owed}} are owed by a certain time; when the time passes they have come due, and that has consequences.",
@@ -112,6 +112,7 @@ export const scheduledFunction = defineFunction("core:function/scheduled@1", {
112
112
  name: { en: "At a set story time" },
113
113
  meaning: { en: "When the story clock reaches a set moment — the festival at dawn on the third — it happens." },
114
114
  kind: "time",
115
+ countsTime: "story",
115
116
  adds: { events: [{ id: SCHEDULED_EVENT, name: { en: "A scheduled moment was reached" } }] },
116
117
  prose: "Some things happen at a set time, whatever anyone is doing; when the moment comes, it comes.",
117
118
  form: {
@@ -140,6 +141,7 @@ export const deadlineFunction = defineFunction("core:function/deadline@1", {
140
141
  name: { en: "A deadline" },
141
142
  meaning: { en: "Something must be done by a set time — the ransom gathered by the new moon — or the chance is gone." },
142
143
  kind: "time",
144
+ countsTime: "story",
143
145
  bindings: { goal: { to: "attribute", kinds: NUMBER_ATTRIBUTE_KINDS, label: { en: "Must reach" } } },
144
146
  adds: { events: [{ id: DEADLINE_EVENT, name: { en: "A deadline passed" }, description: { en: "The story clock passed a deadline with its goal unmet." } }] },
145
147
  prose: "{{goal}} has to reach its mark in time; once the time is past, it is too late.",
@@ -25,6 +25,8 @@ export const createAssistantSpec = () => compile(spec(ASSISTANT_CREATE_SPEC_ID,
25
25
  family: chatGenre.family,
26
26
  description: chatGenre.description,
27
27
  shape: chatGenre.shape,
28
+ // The genre's pinned settings ride the row (how far Auto-advance runs).
29
+ settings: chatGenre.settings,
28
30
  // The event surface rides the row (24 §5): the dashboard and
29
31
  // the preset editor SELECT it, never re-derive it.
30
32
  events: chatGenre.events,
@@ -18,10 +18,10 @@
18
18
  import { compile, slot, spec, coreEvents } from '@serene-pub/sdk';
19
19
  import * as C from '@serene-pub/contracts';
20
20
  import { CORE_LOADOUT } from '../../loadouts.js';
21
- import { applyWiring, heldForReview, modelCall, wiring, } from '../../shared/calls.js';
22
- import { fileLore } from '../../shared/lore.js';
21
+ import { applyWiring, heldForReview, modelCall, on, scriptStep, textPart, wiring, } from '../../shared/calls.js';
22
+ import { ENTRIES_NAMED_BRIEF_SCRIPT, fileLore } from '../../shared/lore.js';
23
23
  import { ASSISTANT_PROMPT_KEYS } from '../../seed/prompts.js';
24
- import { worldLoreEntryType } from '../../registry/entries.js';
24
+ import { bareEntryTypeId, worldLoreEntryType } from '../../registry/entries.js';
25
25
  /** @experimental */
26
26
  export const ASSISTANT_MEMORY_SPEC_ID = 'core:spec/assistant-memory';
27
27
  /** @internal */
@@ -46,46 +46,67 @@ export const assistantMemorySpec = () => {
46
46
  })
47
47
  .junction('memory', { on: ($) => $.input.routine }, (j) =>
48
48
  // Every firing (the host never fires a routine that is Off); the notes junction reads the mode.
49
- j.when('due', { path: (v) => v.mode, truthy: true }, (m) =>
50
- /**
51
- * *Remember things* — `memory.due.*`: one JSON call over the conversation,
52
- * then each note filed (`create-lore-entry@1`, world lore) — on Full as it
53
- * is, on Review held at the review gate. The host routes the write: the
54
- * attached lorebook when the session may write it, else the session's own
55
- * notes, made on first use.
56
- */
57
- modelCall(m, w, 'memory', {
58
- prompt: ASSISTANT_PROMPT_KEYS.memory,
59
- brief: () => MEMORY_BRIEF,
60
- cast: ($) => $.cast.cast,
61
- history: ($) => $.history.messages,
62
- schema: ASSISTANT_MEMORY_SCHEMA,
63
- briefTurn: true,
64
- expose: {
65
- status: 'Taking notes',
66
- label: 'Remember things',
67
- purpose: 'Every few turns, notes what you told the Assistant, so it remembers next time.',
68
- },
69
- }).junction('notes', { on: ($) => $.input.routine }, (n) => {
70
- const arm = (b, mode) => {
71
- return fileLore(b, w, {
72
- from: ($) => $.memory.due.memoryWrite.json,
73
- member: 'notes',
74
- listLabel: 'The notes',
75
- each: 'note',
76
- noun: 'note',
77
- nameLabel: "The note's title",
78
- max: 4,
79
- entryType: worldLoreEntryType,
80
- writeLabel: mode === 'full' ? 'File the note' : 'Hold the note for review',
81
- review: mode === 'review' ? review : undefined,
82
- });
83
- };
84
- return (n
85
- // The routine's mode (R37): Full files each note, Review holds it.
86
- .when('full', { path: (v) => v.mode, equals: 'full' }, (b) => arm(b, 'full'))
87
- .when('review', { path: (v) => v.mode, equals: 'review' }, (b) => arm(b, 'review')));
88
- })))
49
+ j.when('due', { path: (v) => v.mode, truthy: true }, (m) => {
50
+ /** The memory write, sized: the entries the lines name are shown within its share of the window. */
51
+ const budgeted = m.task('contextBudget', ($) => C.contextBudget.v1({
52
+ sampling: slot.samplingOf('memory.due.memoryWrite'),
53
+ connection: slot.connectionOf('memory.due.memoryWrite'),
54
+ params: slot.params(),
55
+ }));
56
+ const read = budgeted.query('named', ($) => C.entriesNamed.v1({
57
+ scope: $.input.sessionScope,
58
+ messages: $.history.messages,
59
+ budget: $.contextBudget.available,
60
+ params: slot.params(),
61
+ }), { expose: { label: 'What is already kept', status: 'Taking notes' } });
62
+ w.params.push([on(read, 'named'), { entryTypes: [bareEntryTypeId(worldLoreEntryType)] }]);
63
+ /** The brief is a literal handed to the script; its answer is read back as text. */
64
+ const shown = textPart(scriptStep(read, w, 'briefShown', ENTRIES_NAMED_BRIEF_SCRIPT.seedKey, ($) => ({
65
+ brief: MEMORY_BRIEF,
66
+ entries: $.named.main,
67
+ }), 'What to look for, and what is kept', 'Taking notes'), w, 'briefText', ($) => $.briefShown.main, 'brief', 'What to look for, and what is kept');
68
+ /**
69
+ * *Remember things* — `memory.due.*`: one JSON call over the conversation,
70
+ * then each note filed (`create-lore-entry@1`, world lore) — on Full as it
71
+ * is, on Review held at the review gate. The host routes the write: the
72
+ * attached lorebook when the session may write it, else the session's own
73
+ * notes, made on first use.
74
+ */
75
+ return modelCall(shown, w, 'memory', {
76
+ prompt: ASSISTANT_PROMPT_KEYS.memory,
77
+ brief: ($) => $.briefText.text,
78
+ cast: ($) => $.cast.cast,
79
+ history: ($) => $.history.messages,
80
+ schema: ASSISTANT_MEMORY_SCHEMA,
81
+ briefTurn: true,
82
+ expose: {
83
+ status: 'Taking notes',
84
+ label: 'Remember things',
85
+ purpose: 'Every few turns, notes what you told the Assistant, so it remembers next time.',
86
+ },
87
+ }).junction('notes', { on: ($) => $.input.routine }, (n) => {
88
+ const arm = (b, mode) => {
89
+ return fileLore(b, w, {
90
+ from: ($) => $.memory.due.memoryWrite.json,
91
+ member: 'notes',
92
+ listLabel: 'The notes',
93
+ each: 'note',
94
+ noun: 'note',
95
+ nameLabel: "The note's title",
96
+ max: 4,
97
+ entryType: worldLoreEntryType,
98
+ writeLabel: mode === 'full' ? 'File the note' : 'Hold the note for review',
99
+ review: mode === 'review' ? review : undefined,
100
+ matchByName: true,
101
+ shown: ($) => $.memory.due.named.ids,
102
+ });
103
+ };
104
+ return (n
105
+ // The routine's mode (R37): Full files each note, Review holds it.
106
+ .when('full', { path: (v) => v.mode, equals: 'full' }, (b) => arm(b, 'full'))
107
+ .when('review', { path: (v) => v.mode, equals: 'review' }, (b) => arm(b, 'review')));
108
+ });
109
+ }))
89
110
  /** On Extraction (I12); its prompt row; every Review note behind the review gate. */
90
111
  .defaults((p) => heldForReview(applyWiring(p.loadout('memory.due.memoryWrite', slot.loadout(CORE_LOADOUT.extraction)), w), review))
91
112
  .build());
@@ -35,20 +35,21 @@ export declare const ASSISTANT_RESPOND_VERSION = "1.0.0";
35
35
  /** The most tool passes one turn may take (★D, ruled 2026-10-19). @experimental */
36
36
  export declare const ASSISTANT_TOOL_PASSES = 4;
37
37
  /**
38
- * 🚧 Basic's assembly template: the Assistant's instructions, the lorebook
39
- * excerpts when any were retrieved, then the conversation — the Guide's
38
+ * 🚧 Basic's assembly template: the Assistant's instructions, the scenario
39
+ * when there is one, the lorebook excerpts when any were retrieved, then the
40
+ * conversation — the Guide's
40
41
  * layout without the docs. Triple-stashed: prose going to a model.
41
42
  * @experimental
42
43
  */
43
- export declare const ASSISTANT_RESPOND_TEMPLATE = "{{#systemBlock}}\n{{#if instructions}}\n{{{instructions}}}\n{{/if}}\n{{#if worldLore}}\n\nFrom the lorebook attached to this session: the person's own reference notes, retrieved for their latest message. Each key is the entry's name. When you answer from one, say which entry you used.\n{{{worldLore}}}\n{{/if}}\n{{/systemBlock}}\n\n{{#each sessionMessages as |sessionMessage msgIndex|}}\n{{#each (lookup ../injectionsByIndex msgIndex)}}\n{{#if (eq this.role \"assistant\")}}\n{{#assistantBlock}}\n{{{this.content}}}\n{{/assistantBlock}}\n{{else if (eq this.role \"user\")}}\n{{#userBlock}}\n{{{this.content}}}\n{{/userBlock}}\n{{else}}\n{{#systemBlock}}\n{{{this.content}}}\n{{/systemBlock}}\n{{/if}}\n{{/each}}\n{{#with ../postHistory}}\n{{#if (and (eq msgIndex targetIndex) hasContent)}}\n{{#systemBlock}}\n{{#if instructions}}\n{{{instructions}}}\n{{/if}}\n{{/systemBlock}}\n{{/if}}\n{{/with}}\n{{#if (eq role \"assistant\")}}\n{{#assistantBlock}}\n{{{message}}}{{{attachments}}}\n{{/assistantBlock}}\n{{/if}}\n{{#if (eq role \"user\")}}\n{{#userBlock}}\n{{{message}}}{{{attachments}}}\n{{/userBlock}}\n{{/if}}\n{{/each}}";
44
+ export declare const ASSISTANT_RESPOND_TEMPLATE = "{{#systemBlock}}\n{{#if instructions}}\n{{{instructions}}}\n{{/if}}\n{{#if scenario}}\n\n{{{scenario}}}\n{{/if}}\n{{#if worldLore}}\n\nFrom the lorebook attached to this session: the person's own reference notes, retrieved for their latest message. Each key is the entry's name. When you answer from one, say which entry you used.\n{{{worldLore}}}\n{{/if}}\n{{/systemBlock}}\n\n{{#each sessionMessages as |sessionMessage msgIndex|}}\n{{#each (lookup ../injectionsByIndex msgIndex)}}\n{{#if (eq this.role \"assistant\")}}\n{{#assistantBlock}}\n{{{this.content}}}\n{{/assistantBlock}}\n{{else if (eq this.role \"user\")}}\n{{#userBlock}}\n{{{this.content}}}\n{{/userBlock}}\n{{else}}\n{{#systemBlock}}\n{{{this.content}}}\n{{/systemBlock}}\n{{/if}}\n{{/each}}\n{{#with ../postHistory}}\n{{#if (and (eq msgIndex targetIndex) hasContent)}}\n{{#systemBlock}}\n{{#if instructions}}\n{{{instructions}}}\n{{/if}}\n{{/systemBlock}}\n{{/if}}\n{{/with}}\n{{#if (eq role \"assistant\")}}\n{{#assistantBlock}}\n{{{message}}}{{{attachments}}}\n{{/assistantBlock}}\n{{/if}}\n{{#if (eq role \"user\")}}\n{{#userBlock}}\n{{{message}}}{{{attachments}}}\n{{/userBlock}}\n{{/if}}\n{{/each}}";
44
45
  /**
45
46
  * 🚧 Agentic's assembly template: the loop's own opening text (`system`, the
46
- * `assistant-agentic` row), the tools advertised, the lorebook excerpts, the
47
- * tools' results so far, the conversation, and the closing reminder
47
+ * `assistant-agentic` row), the scenario when there is one, the tools
48
+ * advertised, the lorebook excerpts, the tools' results so far, the conversation, and the closing reminder
48
49
  * (`postHistory`). Triple-stashed, as every shipped context template.
49
50
  * @experimental
50
51
  */
51
- export declare const ASSISTANT_AGENTIC_TEMPLATE = "{{#systemBlock}}\n{{{system}}}\n\n{{{advertisement}}}\n{{#if worldLore}}\n\nFrom the lorebook attached to this session: the person's own reference notes, retrieved for their latest message. Each key is the entry's name.\n{{{worldLore}}}\n{{/if}}\n{{#if results}}\n\nWhat your tools have returned so far:\n{{{results}}}\n{{/if}}\n{{/systemBlock}}\n\n{{#each sessionMessages}}\n{{#if (eq role \"assistant\")}}\n{{#assistantBlock}}\n{{{message}}}{{{attachments}}}\n{{/assistantBlock}}\n{{/if}}\n{{#if (eq role \"user\")}}\n{{#userBlock}}\n{{{message}}}{{{attachments}}}\n{{/userBlock}}\n{{/if}}\n{{/each}}\n\n{{#if postHistory}}\n{{#systemBlock}}\n{{{postHistory}}}\n{{/systemBlock}}\n{{/if}}";
52
+ export declare const ASSISTANT_AGENTIC_TEMPLATE = "{{#systemBlock}}\n{{{system}}}\n{{#if scenario}}\n\n{{{scenario}}}\n{{/if}}\n\n{{{advertisement}}}\n{{#if worldLore}}\n\nFrom the lorebook attached to this session: the person's own reference notes, retrieved for their latest message. Each key is the entry's name.\n{{{worldLore}}}\n{{/if}}\n{{#if results}}\n\nWhat your tools have returned so far:\n{{{results}}}\n{{/if}}\n{{/systemBlock}}\n\n{{#each sessionMessages}}\n{{#if (eq role \"assistant\")}}\n{{#assistantBlock}}\n{{{message}}}{{{attachments}}}\n{{/assistantBlock}}\n{{/if}}\n{{#if (eq role \"user\")}}\n{{#userBlock}}\n{{{message}}}{{{attachments}}}\n{{/userBlock}}\n{{/if}}\n{{/each}}\n\n{{#if postHistory}}\n{{#systemBlock}}\n{{{postHistory}}}\n{{/systemBlock}}\n{{/if}}";
52
53
  /** @experimental */
53
54
  export declare const assistantRespondSpec: () => import("@serene-pub/sdk").CompiledSpec<string>;
54
55
  //# sourceMappingURL=respond.d.ts.map
@@ -44,8 +44,9 @@ export const ASSISTANT_RESPOND_VERSION = '1.0.0';
44
44
  /** The most tool passes one turn may take (★D, ruled 2026-10-19). @experimental */
45
45
  export const ASSISTANT_TOOL_PASSES = 4;
46
46
  /**
47
- * 🚧 Basic's assembly template: the Assistant's instructions, the lorebook
48
- * excerpts when any were retrieved, then the conversation — the Guide's
47
+ * 🚧 Basic's assembly template: the Assistant's instructions, the scenario
48
+ * when there is one, the lorebook excerpts when any were retrieved, then the
49
+ * conversation — the Guide's
49
50
  * layout without the docs. Triple-stashed: prose going to a model.
50
51
  * @experimental
51
52
  */
@@ -53,6 +54,10 @@ export const ASSISTANT_RESPOND_TEMPLATE = `{{#systemBlock}}
53
54
  {{#if instructions}}
54
55
  {{{instructions}}}
55
56
  {{/if}}
57
+ {{#if scenario}}
58
+
59
+ {{{scenario}}}
60
+ {{/if}}
56
61
  {{#if worldLore}}
57
62
 
58
63
  From the lorebook attached to this session: the person's own reference notes, retrieved for their latest message. Each key is the entry's name. When you answer from one, say which entry you used.
@@ -98,13 +103,17 @@ From the lorebook attached to this session: the person's own reference notes, re
98
103
  {{/each}}`;
99
104
  /**
100
105
  * 🚧 Agentic's assembly template: the loop's own opening text (`system`, the
101
- * `assistant-agentic` row), the tools advertised, the lorebook excerpts, the
102
- * tools' results so far, the conversation, and the closing reminder
106
+ * `assistant-agentic` row), the scenario when there is one, the tools
107
+ * advertised, the lorebook excerpts, the tools' results so far, the conversation, and the closing reminder
103
108
  * (`postHistory`). Triple-stashed, as every shipped context template.
104
109
  * @experimental
105
110
  */
106
111
  export const ASSISTANT_AGENTIC_TEMPLATE = `{{#systemBlock}}
107
112
  {{{system}}}
113
+ {{#if scenario}}
114
+
115
+ {{{scenario}}}
116
+ {{/if}}
108
117
 
109
118
  {{{advertisement}}}
110
119
  {{#if worldLore}}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * 🚧 Chat's turn order — `core:spec/assistant-turn-order` (2026-10-19):
3
- * `turnOrderSpec` (`factories/turnOrder.ts`) over a pool of the genre's one
2
+ * 🚧 Chat's turn order — `core:spec/assistant-turn-order` (2026-10-19): one
3
+ * round robin option on Turn order asked, over a pool of the genre's one
4
4
  * in-turn envoy, the Assistant, and no characters — the Guide's shape. One
5
5
  * speaker: the order is written once and kept (canon A9), never re-decided.
6
6
  */