@serene-pub/core-catalog 0.6.0-pr-1 → 0.6.0-pr-4

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 (243) hide show
  1. package/README.md +21 -1
  2. package/components/{sessions → genres/chat}/authors-note/AuthorsNote.svelte +1 -1
  3. package/components/{sessions → genres/chat}/authors-note/AuthorsNoteWidget.svelte +1 -1
  4. package/components/{sessions → shared}/lore-entries/LoreEntries.svelte +1 -1
  5. package/components/{sessions → shared}/lore-entries/LoreEntriesWidget.svelte +1 -1
  6. package/components/{sessions → shared}/messages/MessageComposer.svelte +1 -1
  7. package/components/{sessions → shared}/messages/Messages.svelte +1 -1
  8. package/components/{sessions → shared}/messages/MessagesWidget.svelte +1 -1
  9. package/components/{sessions → shared}/messages/SessionComposer.svelte +1 -1
  10. package/components/{sessions → shared}/messages/SessionMessage.svelte +1 -1
  11. package/components/{sessions → shared}/messages/conversation.svelte.ts +1 -1
  12. package/components/{sessions → shared}/scene-portraits/ScenePortraits.svelte +1 -1
  13. package/components/{sessions → shared}/scene-portraits/ScenePortraitsWidget.svelte +1 -1
  14. package/components/{sessions → shared}/stats/Stats.svelte +1 -1
  15. package/components/{sessions → shared}/stats/StatsWidget.svelte +1 -1
  16. package/components/{sessions → shared}/world-state/WorldState.svelte +1 -1
  17. package/components/{sessions → shared}/world-state/WorldStateWidget.svelte +1 -1
  18. package/dist/components/authors-note.js +5 -5
  19. package/dist/components/authors-note.source.json +1 -1
  20. package/dist/components/core-ui.json +1 -1
  21. package/dist/components/lore-entries.js +5 -5
  22. package/dist/components/lore-entries.source.json +1 -1
  23. package/dist/components/messages.js +26 -26
  24. package/dist/components/messages.source.json +1 -1
  25. package/dist/components/scene-portraits.js +7 -7
  26. package/dist/components/scene-portraits.source.json +1 -1
  27. package/dist/components/{shared-TCQZXBE3.js → shared-3FGURYVS.js} +2 -2
  28. package/dist/components/{shared-AINANAIA.js → shared-FXYLABGF.js} +6 -6
  29. package/dist/components/{shared-UAQVMZZK.js → shared-U3UU5V7L.js} +3 -3
  30. package/dist/components/stats.js +6 -6
  31. package/dist/components/stats.source.json +1 -1
  32. package/dist/components/world-state.js +6 -6
  33. package/dist/components/world-state.source.json +1 -1
  34. package/dist/{answerForm.d.ts → factories/answerForm.d.ts} +4 -30
  35. package/dist/{answerForm.js → factories/answerForm.js} +4 -37
  36. package/dist/factories/once.d.ts +7 -0
  37. package/dist/factories/once.js +9 -0
  38. package/dist/{turnOrder.d.ts → factories/turnOrder.d.ts} +0 -22
  39. package/dist/{turnOrder.js → factories/turnOrder.js} +4 -104
  40. package/dist/genres/adventure/advanceTime.d.ts +11 -0
  41. package/dist/genres/adventure/advanceTime.js +17 -0
  42. package/dist/genres/adventure/answer.d.ts +23 -0
  43. package/dist/genres/adventure/answer.js +59 -0
  44. package/dist/genres/adventure/answerForm.d.ts +9 -0
  45. package/dist/genres/adventure/answerForm.js +11 -0
  46. package/dist/genres/adventure/ask.d.ts +73 -0
  47. package/dist/genres/adventure/ask.js +157 -0
  48. package/dist/genres/adventure/create.d.ts +36 -0
  49. package/dist/genres/adventure/create.js +62 -0
  50. package/dist/genres/adventure/index.d.ts +43 -0
  51. package/dist/genres/adventure/index.js +43 -0
  52. package/dist/genres/adventure/keeperAction.d.ts +24 -0
  53. package/dist/genres/adventure/keeperAction.js +150 -0
  54. package/dist/genres/adventure/look.d.ts +45 -0
  55. package/dist/genres/adventure/look.js +209 -0
  56. package/dist/{adventure.d.ts → genres/adventure/respond.d.ts} +10 -34
  57. package/dist/{adventure.js → genres/adventure/respond.js} +34 -60
  58. package/dist/genres/adventure/rest.d.ts +10 -0
  59. package/dist/genres/adventure/rest.js +16 -0
  60. package/dist/genres/adventure/turnOrder.d.ts +10 -0
  61. package/dist/genres/adventure/turnOrder.js +27 -0
  62. package/dist/genres/chat/answerForm.d.ts +9 -0
  63. package/dist/genres/chat/answerForm.js +11 -0
  64. package/dist/genres/chat/create.d.ts +7 -0
  65. package/dist/{createChat.js → genres/chat/create.js} +6 -6
  66. package/dist/genres/chat/generateImage.d.ts +7 -0
  67. package/dist/{generateImage.js → genres/chat/generateImage.js} +5 -5
  68. package/dist/genres/chat/index.d.ts +15 -0
  69. package/dist/genres/chat/index.js +15 -0
  70. package/dist/{narrate.d.ts → genres/chat/narrate.d.ts} +3 -3
  71. package/dist/{narrate.js → genres/chat/narrate.js} +34 -12
  72. package/dist/{narrateCharacter.d.ts → genres/chat/narrateCharacter.d.ts} +2 -2
  73. package/dist/{narrateCharacter.js → genres/chat/narrateCharacter.js} +35 -16
  74. package/dist/genres/chat/respond.d.ts +25 -0
  75. package/dist/{respond.js → genres/chat/respond.js} +48 -22
  76. package/dist/genres/chat/turnOrder.d.ts +9 -0
  77. package/dist/genres/chat/turnOrder.js +28 -0
  78. package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.d.ts +1 -1
  79. package/dist/genres/guide/answerForm.d.ts +9 -0
  80. package/dist/genres/guide/answerForm.js +11 -0
  81. package/dist/genres/guide/create.d.ts +24 -0
  82. package/dist/genres/guide/create.js +58 -0
  83. package/dist/genres/guide/index.d.ts +9 -0
  84. package/dist/genres/guide/index.js +9 -0
  85. package/dist/{guide.d.ts → genres/guide/respond.d.ts} +1 -20
  86. package/dist/{guide.js → genres/guide/respond.js} +29 -60
  87. package/dist/genres/guide/turnOrder.d.ts +10 -0
  88. package/dist/genres/guide/turnOrder.js +27 -0
  89. package/dist/genres/index.d.ts +14 -0
  90. package/dist/genres/index.js +41 -0
  91. package/dist/genres/lair/answerForm.d.ts +17 -0
  92. package/dist/genres/lair/answerForm.js +19 -0
  93. package/dist/genres/lair/buildRoom.d.ts +64 -0
  94. package/dist/genres/lair/buildRoom.js +244 -0
  95. package/dist/genres/lair/castellanAction.d.ts +27 -0
  96. package/dist/genres/lair/castellanAction.js +177 -0
  97. package/dist/genres/lair/create.d.ts +28 -0
  98. package/dist/genres/lair/create.js +69 -0
  99. package/dist/genres/lair/fileRoom.d.ts +53 -0
  100. package/dist/genres/lair/fileRoom.js +288 -0
  101. package/dist/genres/lair/index.d.ts +60 -0
  102. package/dist/genres/lair/index.js +60 -0
  103. package/dist/genres/lair/nudge.d.ts +25 -0
  104. package/dist/genres/lair/nudge.js +78 -0
  105. package/dist/{lair.d.ts → genres/lair/respond.d.ts} +15 -28
  106. package/dist/{lair.js → genres/lair/respond.js} +45 -76
  107. package/dist/genres/lair/reveal.d.ts +10 -0
  108. package/dist/genres/lair/reveal.js +18 -0
  109. package/dist/genres/lair/roomAnswer.d.ts +86 -0
  110. package/dist/genres/lair/roomAnswer.js +378 -0
  111. package/dist/genres/lair/trap.d.ts +11 -0
  112. package/dist/genres/lair/trap.js +24 -0
  113. package/dist/genres/lair/turnOrder.d.ts +9 -0
  114. package/dist/genres/lair/turnOrder.js +36 -0
  115. package/dist/genres/lair/whisper.d.ts +35 -0
  116. package/dist/genres/lair/whisper.js +90 -0
  117. package/dist/index.d.ts +47 -29
  118. package/dist/index.js +117 -88
  119. package/dist/{genres.js → registry/genres.js} +4 -4
  120. package/dist/{ui/sessions → registry}/widgets.js +6 -6
  121. package/dist/{presets.js → seed/presets.js} +28 -13
  122. package/dist/{prompts.js → seed/prompts.js} +27 -56
  123. package/dist/{annexField.d.ts → shared/annexField.d.ts} +3 -2
  124. package/dist/{annexField.js → shared/annexField.js} +6 -8
  125. package/dist/shared/builtins/branch.d.ts +8 -0
  126. package/dist/shared/builtins/branch.js +13 -0
  127. package/dist/{builtins.d.ts → shared/builtins/builtIn.d.ts} +16 -21
  128. package/dist/{builtins.js → shared/builtins/builtIn.js} +3 -37
  129. package/dist/shared/builtins/delete.d.ts +8 -0
  130. package/dist/shared/builtins/delete.js +13 -0
  131. package/dist/shared/builtins/edit.d.ts +8 -0
  132. package/dist/shared/builtins/edit.js +13 -0
  133. package/dist/shared/builtins/hide.d.ts +8 -0
  134. package/dist/shared/builtins/hide.js +13 -0
  135. package/dist/shared/builtins/index.d.ts +11 -0
  136. package/dist/shared/builtins/index.js +11 -0
  137. package/dist/shared/builtins/swipe.d.ts +8 -0
  138. package/dist/shared/builtins/swipe.js +17 -0
  139. package/dist/shared/sprites.d.ts +34 -0
  140. package/dist/shared/sprites.js +98 -0
  141. package/dist/shared/summarize/character.d.ts +9 -0
  142. package/dist/shared/summarize/character.js +10 -0
  143. package/dist/shared/summarize/history.d.ts +9 -0
  144. package/dist/shared/summarize/history.js +10 -0
  145. package/dist/shared/summarize/index.d.ts +10 -0
  146. package/dist/shared/summarize/index.js +10 -0
  147. package/dist/shared/summarize/scene.d.ts +38 -0
  148. package/dist/shared/summarize/scene.js +42 -0
  149. package/dist/shared/summarize/summarizeSpec.d.ts +54 -0
  150. package/dist/{summarize.js → shared/summarize/summarizeSpec.js} +8 -53
  151. package/dist/shared/summarize/world.d.ts +8 -0
  152. package/dist/shared/summarize/world.js +9 -0
  153. package/dist/{toolLoop.d.ts → shared/toolLoop.d.ts} +25 -3
  154. package/dist/{toolLoop.js → shared/toolLoop.js} +67 -14
  155. package/dist/{ui/sessions → shared/ui}/conversation/index.d.ts +1 -1
  156. package/dist/{ui/sessions → shared/ui}/conversation/index.js +1 -1
  157. package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.d.ts +1 -1
  158. package/dist/{ui/sessions → shared/ui}/coreWidgetsEntry.js +1 -1
  159. package/dist/{ui/sessions → shared/ui}/lore-entries/index.d.ts +1 -1
  160. package/dist/{ui/sessions → shared/ui}/scene-portraits/index.d.ts +1 -1
  161. package/dist/{ui/sessions → shared/ui}/scene-portraits/index.js +1 -1
  162. package/dist/{ui/sessions → shared/ui}/session-state/index.d.ts +1 -1
  163. package/dist/{ui/sessions → shared/ui}/session-state/index.js +1 -1
  164. package/package.json +28 -28
  165. package/dist/adventureActions.d.ts +0 -169
  166. package/dist/adventureActions.js +0 -599
  167. package/dist/createChat.d.ts +0 -7
  168. package/dist/generateImage.d.ts +0 -7
  169. package/dist/lairActions.d.ts +0 -296
  170. package/dist/lairActions.js +0 -1287
  171. package/dist/respond.d.ts +0 -24
  172. package/dist/sprites.d.ts +0 -24
  173. package/dist/sprites.js +0 -102
  174. package/dist/summarize.d.ts +0 -76
  175. /package/components/{sessions → genres/chat}/authors-note/authors-note.ts +0 -0
  176. /package/components/{sessions/shared → shared}/context.ts +0 -0
  177. /package/components/{sessions → shared}/lore-entries/lore-entries.ts +0 -0
  178. /package/components/{sessions → shared}/messages/MessageBlocksView.svelte +0 -0
  179. /package/components/{sessions → shared}/messages/MessageControls.svelte +0 -0
  180. /package/components/{sessions → shared}/messages/MessageMediaStrip.svelte +0 -0
  181. /package/components/{sessions → shared}/messages/MessagePartsView.svelte +0 -0
  182. /package/components/{sessions → shared}/messages/MessageStateLedger.svelte +0 -0
  183. /package/components/{sessions → shared}/messages/NextCharacterBlock.svelte +0 -0
  184. /package/components/{sessions → shared}/messages/SessionContainer.svelte +0 -0
  185. /package/components/{sessions → shared}/messages/StateProposalList.svelte +0 -0
  186. /package/components/{sessions → shared}/messages/mediaStrip.ts +0 -0
  187. /package/components/{sessions → shared}/messages/messages.ts +0 -0
  188. /package/components/{sessions → shared}/scene-portraits/StatBars.svelte +0 -0
  189. /package/components/{sessions → shared}/scene-portraits/scene-portraits.ts +0 -0
  190. /package/components/{sessions → shared}/state/SlotControl.svelte +0 -0
  191. /package/components/{sessions → shared}/state/entryFinder.ts +0 -0
  192. /package/components/{sessions → shared}/state/slotWriter.svelte.ts +0 -0
  193. /package/components/{sessions → shared}/stats/stats.ts +0 -0
  194. /package/components/{sessions/shared → shared}/widgetRef.svelte.ts +0 -0
  195. /package/components/{sessions → shared}/world-state/world-state.ts +0 -0
  196. /package/dist/{ui/sessions → genres/chat/ui}/authors-note/index.js +0 -0
  197. /package/dist/{entries.d.ts → registry/entries.d.ts} +0 -0
  198. /package/dist/{entries.js → registry/entries.js} +0 -0
  199. /package/dist/{genres.d.ts → registry/genres.d.ts} +0 -0
  200. /package/dist/{ui/sessions → registry}/layouts.d.ts +0 -0
  201. /package/dist/{ui/sessions → registry}/layouts.js +0 -0
  202. /package/dist/{slots.d.ts → registry/slots.d.ts} +0 -0
  203. /package/dist/{slots.js → registry/slots.js} +0 -0
  204. /package/dist/{statShapes.d.ts → registry/statShapes.d.ts} +0 -0
  205. /package/dist/{statShapes.js → registry/statShapes.js} +0 -0
  206. /package/dist/{ui/sessions → registry}/widgets.d.ts +0 -0
  207. /package/dist/{guideMascotImage.d.ts → seed/guideMascotImage.d.ts} +0 -0
  208. /package/dist/{guideMascotImage.js → seed/guideMascotImage.js} +0 -0
  209. /package/dist/{presets.d.ts → seed/presets.d.ts} +0 -0
  210. /package/dist/{prompts.d.ts → seed/prompts.d.ts} +0 -0
  211. /package/dist/{graphBuild.d.ts → shared/graphBuild.d.ts} +0 -0
  212. /package/dist/{graphBuild.js → shared/graphBuild.js} +0 -0
  213. /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.d.ts +0 -0
  214. /package/dist/{ui/sessions → shared/ui}/conversation/actionsDisclosure.js +0 -0
  215. /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.d.ts +0 -0
  216. /package/dist/{ui/sessions → shared/ui}/conversation/composerTray.js +0 -0
  217. /package/dist/{ui/sessions → shared/ui}/conversation/dossier.d.ts +0 -0
  218. /package/dist/{ui/sessions → shared/ui}/conversation/dossier.js +0 -0
  219. /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.d.ts +0 -0
  220. /package/dist/{ui/sessions → shared/ui}/conversation/formAnswer.js +0 -0
  221. /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.d.ts +0 -0
  222. /package/dist/{ui/sessions → shared/ui}/conversation/itemValues.js +0 -0
  223. /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.d.ts +0 -0
  224. /package/dist/{ui/sessions → shared/ui}/conversation/messageOrder.js +0 -0
  225. /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.d.ts +0 -0
  226. /package/dist/{ui/sessions → shared/ui}/conversation/messageSpeaker.js +0 -0
  227. /package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.d.ts +0 -0
  228. /package/dist/{ui/sessions → shared/ui}/conversation/messageVerbState.js +0 -0
  229. /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.d.ts +0 -0
  230. /package/dist/{ui/sessions → shared/ui}/conversation/slashPalette.js +0 -0
  231. /package/dist/{ui/sessions → shared/ui}/conversation/text.d.ts +0 -0
  232. /package/dist/{ui/sessions → shared/ui}/conversation/text.js +0 -0
  233. /package/dist/{ui/sessions → shared/ui}/lore-entries/index.js +0 -0
  234. /package/dist/{ui/sessions → shared/ui}/scene-portraits/portraits.d.ts +0 -0
  235. /package/dist/{ui/sessions → shared/ui}/scene-portraits/portraits.js +0 -0
  236. /package/dist/{ui/sessions → shared/ui}/session-state/barMath.d.ts +0 -0
  237. /package/dist/{ui/sessions → shared/ui}/session-state/barMath.js +0 -0
  238. /package/dist/{ui/sessions → shared/ui}/session-state/shapes.d.ts +0 -0
  239. /package/dist/{ui/sessions → shared/ui}/session-state/shapes.js +0 -0
  240. /package/dist/{ui/sessions → shared/ui}/session-state/stateView.d.ts +0 -0
  241. /package/dist/{ui/sessions → shared/ui}/session-state/stateView.js +0 -0
  242. /package/dist/{ui/sessions → shared/ui}/widgetContext.d.ts +0 -0
  243. /package/dist/{ui/sessions → shared/ui}/widgetContext.js +0 -0
package/README.md CHANGED
@@ -6,7 +6,7 @@ components Serene Pub ships, as a package. Serene Pub seeds from it at boot,
6
6
  references:
7
7
 
8
8
  ```ts
9
- import { respond, chatGenre } from '@serene-pub/core-catalog'
9
+ import { chatGenre, chatTurnOrder } from '@serene-pub/core-catalog'
10
10
  ```
11
11
 
12
12
  Core is the first consumer of the announce path rather than a special case — one
@@ -24,3 +24,23 @@ stylesheet build can scan it for class names; it is not imported at runtime.
24
24
 
25
25
  Importing the package registers its declarations, so it lists those modules in
26
26
  `sideEffects` — a bundler must not drop them.
27
+
28
+ ## Where things live
29
+
30
+ `src/` is laid out by genre (ruled 2026-10-05):
31
+
32
+ | folder | holds |
33
+ | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
34
+ | `src/genres/<genre>/` | one genre's pipelines, one spec per file (create, reply, actions, answer form, turn order), and its own widgets (`genres/chat/ui/authors-note/`) |
35
+ | `src/shared/` | what more than one genre uses: the built-in message verbs, summarize, the annex field, sprites, the story graph build, the tool-loop example, and the shared widgets (`shared/ui/`) |
36
+ | `src/factories/` | `answerFormSpec()` and `turnOrderSpec()`, which a plugin genre calls too |
37
+ | `src/registry/` | genres, slots, stat shapes, entry types, widget declarations and layouts |
38
+ | `src/seed/` | the shipped prompts, presets and the guide mascot |
39
+ | `components/` | the Svelte sources, mirrored the same way (`components/shared/*`, `components/genres/chat/authors-note`) |
40
+
41
+ `CORE_SPECS` (`src/index.ts`) lists every pipeline core seeds, with its display name. A genre's
42
+ pipeline id is `core:spec/<genre>-<what>` (`core:spec/chat-respond`); one every genre uses is
43
+ `core:spec/<what>` (`core:spec/summarize-scene`). A name says what the pipeline does and never
44
+ which genre it serves (_Reply_, _Turn order_): wherever several genres' pipelines are listed, the
45
+ genre is shown beside it. `core:spec/tool-loop` is exported as an example and is not in
46
+ `CORE_SPECS`.
@@ -9,7 +9,7 @@
9
9
  import type { ComponentContext } from "@serene-pub/sdk/component"
10
10
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
11
11
  import AuthorsNoteWidget from "./AuthorsNoteWidget.svelte"
12
- import { widgetRefFromComponent } from "../shared/widgetRef.svelte"
12
+ import { widgetRefFromComponent } from "../../../shared/widgetRef.svelte"
13
13
 
14
14
  let { ctx }: { ctx: ComponentContext } = $props()
15
15
 
@@ -31,7 +31,7 @@
31
31
  authorsNoteLastReplyLine,
32
32
  readAuthorsNote
33
33
  } from "@serene-pub/core-catalog/authors-note"
34
- import { useWidgetContext } from "../shared/context"
34
+ import { useWidgetContext } from "../../../shared/context"
35
35
 
36
36
  const widget = useWidgetContext()
37
37
  const t = (source: string): string => widget?.current?.t(source) ?? source
@@ -12,7 +12,7 @@
12
12
  import type { ComponentContext } from "@serene-pub/sdk/component"
13
13
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
14
14
  import LoreEntriesWidget from "./LoreEntriesWidget.svelte"
15
- import { widgetRefFromComponent } from "../shared/widgetRef.svelte"
15
+ import { widgetRefFromComponent } from "../widgetRef.svelte"
16
16
 
17
17
  let { ctx }: { ctx: ComponentContext } = $props()
18
18
 
@@ -41,7 +41,7 @@
41
41
  type LoreEntriesFilter,
42
42
  type LoreEntriesSort
43
43
  } from "@serene-pub/core-catalog/lore-entries"
44
- import { useWidgetContext } from "../shared/context"
44
+ import { useWidgetContext } from "../context"
45
45
 
46
46
  type Answer = WidgetRequests["session-entries"]["result"]
47
47
  type Ask = WidgetRequests["session-entries"]["params"]
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from "svelte"
3
- import { useWidgetContext } from "../shared/context"
3
+ import { useWidgetContext } from "../context"
4
4
 
5
5
  interface Props {
6
6
  markdown: string
@@ -8,7 +8,7 @@
8
8
  import type { ComponentContext } from "@serene-pub/sdk/component"
9
9
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/conversation"
10
10
  import MessagesWidget from "./MessagesWidget.svelte"
11
- import { widgetRefFromComponent } from "../shared/widgetRef.svelte"
11
+ import { widgetRefFromComponent } from "../widgetRef.svelte"
12
12
 
13
13
  let { ctx }: { ctx: ComponentContext } = $props()
14
14
 
@@ -134,7 +134,7 @@
134
134
  * them back to those snippets, writes them onto the root as data
135
135
  * attributes, and decides which end the composer sits at.
136
136
  */
137
- import { useWidgetContext } from "../shared/context"
137
+ import { useWidgetContext } from "../context"
138
138
  import SessionContainer from "./SessionContainer.svelte"
139
139
  import SessionComposer from "./SessionComposer.svelte"
140
140
  import NextCharacterBlock from "./NextCharacterBlock.svelte"
@@ -522,7 +522,7 @@
522
522
  }
523
523
 
524
524
  // The row is a disclosure, not a menu: it closes on its toggle and on
525
- // Escape, never because focus left it — `src/ui/sessions/conversation/actionsDisclosure.ts` has the
525
+ // Escape, never because focus left it — `src/shared/ui/conversation/actionsDisclosure.ts` has the
526
526
  // table and the reason. There is deliberately no `onfocusout` here.
527
527
  /** Escape closes the actions row (natively; a remote hears no keys). */
528
528
  function handleKeyDown(e: KeyboardEvent) {
@@ -12,7 +12,7 @@
12
12
  import MessageMediaStrip from "./MessageMediaStrip.svelte"
13
13
  import { mediaStripItems, viewImageParams } from "./mediaStrip"
14
14
  import MessageStateLedger from "./MessageStateLedger.svelte"
15
- import { useWidgetContext } from "../shared/context"
15
+ import { useWidgetContext } from "../context"
16
16
  import { staleOf } from "@serene-pub/core-catalog/conversation"
17
17
  import { untrack } from "svelte"
18
18
  import { useConversation } from "./conversation.svelte"
@@ -12,7 +12,7 @@
12
12
  */
13
13
  import { getContext, setContext } from "svelte"
14
14
  import { SvelteSet } from "svelte/reactivity"
15
- import { useWidgetContext } from "../shared/context"
15
+ import { useWidgetContext } from "../context"
16
16
  import type { WidgetContextRef } from "@serene-pub/core-catalog/conversation"
17
17
  import {
18
18
  NO_LINE,
@@ -8,7 +8,7 @@
8
8
  import type { ComponentContext } from "@serene-pub/sdk/component"
9
9
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
10
10
  import ScenePortraitsWidget from "./ScenePortraitsWidget.svelte"
11
- import { widgetRefFromComponent } from "../shared/widgetRef.svelte"
11
+ import { widgetRefFromComponent } from "../widgetRef.svelte"
12
12
 
13
13
  let { ctx }: { ctx: ComponentContext } = $props()
14
14
 
@@ -33,7 +33,7 @@
33
33
  statBarsOf
34
34
  } from "@serene-pub/core-catalog/scene-portraits"
35
35
  import { scopeNotGranted } from "@serene-pub/core-catalog/widgets"
36
- import { useWidgetContext } from "../shared/context"
36
+ import { useWidgetContext } from "../context"
37
37
  import StatBars from "./StatBars.svelte"
38
38
 
39
39
  const w = useWidgetContext()
@@ -7,7 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import StatsWidget from "./StatsWidget.svelte"
10
- import { widgetRefFromComponent } from "../shared/widgetRef.svelte"
10
+ import { widgetRefFromComponent } from "../widgetRef.svelte"
11
11
 
12
12
  let { ctx }: { ctx: ComponentContext } = $props()
13
13
 
@@ -21,7 +21,7 @@
21
21
  * (STYLE-GUIDE §6.16).
22
22
  */
23
23
  import { statsView } from "@serene-pub/core-catalog/session-state"
24
- import { useWidgetContext } from "../shared/context"
24
+ import { useWidgetContext } from "../context"
25
25
  import SlotControl from "../state/SlotControl.svelte"
26
26
  import { createSlotWriter } from "../state/slotWriter.svelte"
27
27
  import { createEntryFinder } from "../state/entryFinder"
@@ -7,7 +7,7 @@
7
7
  import type { ComponentContext } from "@serene-pub/sdk/component"
8
8
  import { WIDGET_CONTEXT_KEY } from "@serene-pub/core-catalog/widgets"
9
9
  import WorldStateWidget from "./WorldStateWidget.svelte"
10
- import { widgetRefFromComponent } from "../shared/widgetRef.svelte"
10
+ import { widgetRefFromComponent } from "../widgetRef.svelte"
11
11
 
12
12
  let { ctx }: { ctx: ComponentContext } = $props()
13
13
 
@@ -22,7 +22,7 @@
22
22
  * (STYLE-GUIDE §6.16).
23
23
  */
24
24
  import { worldStateView } from "@serene-pub/core-catalog/session-state"
25
- import { useWidgetContext } from "../shared/context"
25
+ import { useWidgetContext } from "../context"
26
26
  import SlotControl from "../state/SlotControl.svelte"
27
27
  import { createSlotWriter } from "../state/slotWriter.svelte"
28
28
  import { createEntryFinder } from "../state/entryFinder"
@@ -31,9 +31,9 @@ import {
31
31
  user_derived,
32
32
  user_effect,
33
33
  widgetRefFromComponent
34
- } from "./shared-UAQVMZZK.js";
34
+ } from "./shared-U3UU5V7L.js";
35
35
 
36
- // dist/ui/sessions/authors-note/index.js
36
+ // dist/genres/chat/ui/authors-note/index.js
37
37
  var AUTHORS_NOTE_DEFAULTS = Object.freeze({
38
38
  text: "",
39
39
  depth: 0,
@@ -74,7 +74,7 @@ function authorsNoteLastReplyLine(lastReply, t) {
74
74
  return t("Last reply: nothing added \u2014 the note was empty.");
75
75
  }
76
76
 
77
- // components/sessions/authors-note/AuthorsNoteWidget.svelte
77
+ // components/genres/chat/authors-note/AuthorsNoteWidget.svelte
78
78
  var root = from_html(`<p data-widget-part="authors-note.alert" role="alert"> </p>`);
79
79
  var root_1 = from_html(`<p data-widget-part="authors-note.note"> </p>`);
80
80
  var root_2 = from_html(`<sp-option> </sp-option>`, 2);
@@ -388,7 +388,7 @@ function AuthorsNoteWidget($$anchor, $$props) {
388
388
  }
389
389
  delegate(["input", "change", "click"]);
390
390
 
391
- // components/sessions/authors-note/AuthorsNote.svelte
391
+ // components/genres/chat/authors-note/AuthorsNote.svelte
392
392
  function AuthorsNote($$anchor, $$props) {
393
393
  push($$props, true);
394
394
  setContext(WIDGET_CONTEXT_KEY, widgetRefFromComponent(untrack(() => $$props.ctx), {
@@ -400,7 +400,7 @@ function AuthorsNote($$anchor, $$props) {
400
400
  pop();
401
401
  }
402
402
 
403
- // components/sessions/authors-note/authors-note.ts
403
+ // components/genres/chat/authors-note/authors-note.ts
404
404
  var authors_note_default = svelteComponent(AuthorsNote);
405
405
  export {
406
406
  authors_note_default as default
@@ -1 +1 @@
1
- {"slug":"authors-note","framework":"svelte","entry":"sessions/authors-note/authors-note.ts","files":{"sessions/authors-note/AuthorsNote.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Author's note widget as a remote component (2026-10-02, AN1):\n\t * the component context, as the native widget context, around\n\t * `AuthorsNoteWidget`. It reads no section at all — everything is asked\n\t * of the page — so it asks as soon as it mounts.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AuthorsNoteWidget from \"./AuthorsNoteWidget.svelte\"\n\timport { widgetRefFromComponent } from \"../shared/widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"authors-note\", instanceId: \"authors-note\", title: \"Author's note\" }\n\t\t)\n\t)\n</script>\n\n<AuthorsNoteWidget />\n","sessions/authors-note/AuthorsNoteWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * The author's note (2026-10-02, AN1; Chat only, owner ruling): the\n\t * session's own note to the model — what is true now, where the story\n\t * should lean — placed `depth` messages before the reply on every\n\t * `interval`-th reply. Not the post-history reminder, which is the\n\t * pipeline's and the card's; this widget never shows or edits that.\n\t *\n\t * Everything is asked of the page: `authors-note` reads the note, whether\n\t * the viewer may change it (the session's owner), and what the newest\n\t * reply's prompt did with it; `set-authors-note` saves it, whole. It asks\n\t * again when a generation ends, so the last-reply line follows the\n\t * conversation, and when the session's genre fields change\n\t * (`genreFields:changed`), so a note saved in Edit Session or another tab\n\t * shows here.\n\t *\n\t * Saved explicitly (STYLE-GUIDE §6.14): edits wait for **Save**; dirty is\n\t * derived (the draft differs from what is saved, never \"touched\"); a\n\t * re-read moves the saved snapshot and keeps what is being typed.\n\t * What goes wrong is said here, in this widget (R77) — never a toast.\n\t *\n\t * The markup carries no look: its elements carry `authors-note.*` widget\n\t * parts and the default widget stylesheet draws them (STYLE-GUIDE §6.16).\n\t */\n\timport { untrack } from \"svelte\"\n\timport type { AuthorsNoteV1, AuthorsNoteValueV1 } from \"@serene-pub/sdk/component\"\n\timport {\n\t\tAUTHORS_NOTE_DEFAULTS,\n\t\tAUTHORS_NOTE_ROLES,\n\t\tauthorsNoteDirty,\n\t\tauthorsNoteLastReplyLine,\n\t\treadAuthorsNote\n\t} from \"@serene-pub/core-catalog/authors-note\"\n\timport { useWidgetContext } from \"../shared/context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current?.t(source) ?? source\n\n\t/** What the page last answered. */\n\tlet answer = $state<AuthorsNoteV1 | null>(null)\n\t/** The form's own copy; Save sends it whole. */\n\tlet draft = $state<AuthorsNoteValueV1>({ ...AUTHORS_NOTE_DEFAULTS })\n\tlet readError = $state<string | null>(null)\n\tlet saveError = $state<string | null>(null)\n\tlet saving = $state(false)\n\n\tconst saved = $derived(answer ? readAuthorsNote(answer.note) : AUTHORS_NOTE_DEFAULTS)\n\tconst dirty = $derived(answer ? authorsNoteDirty(draft, saved) : false)\n\tconst canEdit = $derived(answer?.canEdit === true)\n\tconst lastLine = $derived(answer ? authorsNoteLastReplyLine(answer.lastReply, t) : null)\n\n\tconst reason = (e: unknown) => (e instanceof Error ? e.message : String(e))\n\n\t/**\n\t * Take the page's answer as the saved snapshot. A clean form follows it;\n\t * an edited one keeps the person's edits (§6.14 — a push never lies).\n\t */\n\tfunction adopt(next: AuthorsNoteV1) {\n\t\tconst wasDirty = answer ? authorsNoteDirty(draft, readAuthorsNote(answer.note)) : false\n\t\tanswer = next\n\t\tif (!wasDirty) draft = readAuthorsNote(next.note)\n\t}\n\n\tlet asked = 0\n\tfunction ask() {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx) return\n\t\tconst ticket = ++asked\n\t\tctx.request(\"authors-note\", {}).then(\n\t\t\t(res) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\treadError = null\n\t\t\t\tadopt(res)\n\t\t\t},\n\t\t\t(e) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\treadError = reason(e)\n\t\t\t}\n\t\t)\n\t}\n\n\t$effect(() => untrack(() => ask()))\n\n\t// A reply finished: what it did with the note is on its receipt now.\n\t$effect(() =>\n\t\tuntrack(() =>\n\t\t\twidget?.current?.on(\"generation:end\", (e) => {\n\t\t\t\tif (e.kind === \"generation:end\") ask()\n\t\t\t})\n\t\t)\n\t)\n\n\t// The note was saved somewhere else — Edit Session, or this widget in\n\t// another tab: read it again (a clean form follows it, an edited one\n\t// keeps the person's edits).\n\t$effect(() =>\n\t\tuntrack(() =>\n\t\t\twidget?.current?.on(\"genreFields:changed\", (e) => {\n\t\t\t\tif (e.kind === \"genreFields:changed\") ask()\n\t\t\t})\n\t\t)\n\t)\n\n\tasync function save() {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx || !canEdit || !dirty || saving) return\n\t\tsaving = true\n\t\tsaveError = null\n\t\tconst sent = readAuthorsNote(draft)\n\t\ttry {\n\t\t\tconst now = await ctx.request(\"set-authors-note\", { note: sent })\n\t\t\t// The saved row is what the page answered; the form is clean against it.\n\t\t\tanswer = now\n\t\t\tdraft = readAuthorsNote(now.note)\n\t\t} catch (e) {\n\t\t\tsaveError = t(\"Not saved: {reason}\").replace(\"{reason}\", reason(e))\n\t\t} finally {\n\t\t\tsaving = false\n\t\t}\n\t}\n\n\tfunction discard() {\n\t\tdraft = { ...saved }\n\t\tsaveError = null\n\t}\n\n\tconst setNumber = (key: \"depth\" | \"interval\", raw: string) => {\n\t\tconst n = raw.trim() === \"\" ? NaN : Number(raw)\n\t\tdraft = { ...draft, [key]: Number.isFinite(n) ? n : draft[key] }\n\t}\n</script>\n\n<div data-widget-part=\"authors-note.root\" data-widget=\"authors-note\" data-dirty={dirty ? \"\" : undefined}>\n\t{#if readError}\n\t\t<p data-widget-part=\"authors-note.alert\" role=\"alert\">\n\t\t\t{t(\"Could not read the author's note: {reason}\").replace(\"{reason}\", readError)}\n\t\t</p>\n\t{/if}\n\t{#if !answer}\n\t\t{#if !readError}\n\t\t\t<p data-widget-part=\"authors-note.note\">{t(\"Reading the author's note…\")}</p>\n\t\t{/if}\n\t{:else if !answer.offered}\n\t\t<p data-widget-part=\"authors-note.note\">\n\t\t\t{t(\"This kind of session has no author's note.\")}\n\t\t</p>\n\t{:else}\n\t\t{#if !canEdit}\n\t\t\t<p data-widget-part=\"authors-note.note\">\n\t\t\t\t{t(\"Only the session's owner can change the author's note.\")}\n\t\t\t</p>\n\t\t{/if}\n\t\t<label data-widget-part=\"authors-note.field\">\n\t\t\t<span data-widget-part=\"authors-note.label label\">{t(\"Note\")}</span>\n\t\t\t<textarea\n\t\t\t\tdata-widget-part=\"authors-note.text\"\n\t\t\t\trows=\"5\"\n\t\t\t\tplaceholder={t(\"What is true now, or where the story should go.\")}\n\t\t\t\tdisabled={!canEdit}\n\t\t\t\tvalue={draft.text}\n\t\t\t\toninput={(e) => (draft = { ...draft, text: e.currentTarget.value })}\n\t\t\t></textarea>\n\t\t</label>\n\t\t<div data-widget-part=\"authors-note.numbers\">\n\t\t\t<label data-widget-part=\"authors-note.field\">\n\t\t\t\t<span data-widget-part=\"authors-note.label label\">{t(\"Messages from the end\")}</span>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tdata-widget-part=\"authors-note.number\"\n\t\t\t\t\tmin=\"0\"\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tdisabled={!canEdit}\n\t\t\t\t\tvalue={String(draft.depth)}\n\t\t\t\t\toninput={(e) => setNumber(\"depth\", e.currentTarget.value)}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t\t<label data-widget-part=\"authors-note.field\">\n\t\t\t\t<span data-widget-part=\"authors-note.label label\">{t(\"Every how many replies\")}</span>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tdata-widget-part=\"authors-note.number\"\n\t\t\t\t\tmin=\"1\"\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tdisabled={!canEdit}\n\t\t\t\t\tvalue={String(draft.interval)}\n\t\t\t\t\toninput={(e) => setNumber(\"interval\", e.currentTarget.value)}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t</div>\n\t\t<p data-widget-part=\"authors-note.help\">\n\t\t\t{t(\"0 messages puts it right before the reply. Every 1 reply adds it each time.\")}\n\t\t</p>\n\t\t<sp-accordion data-widget-part=\"authors-note.advanced\">\n\t\t\t<sp-accordion-item value=\"advanced\" heading={t(\"Advanced\")} level=\"4\">\n\t\t\t\t<span data-widget-part=\"authors-note.role\">\n\t\t\t\t\t<sp-combobox\n\t\t\t\t\t\tdata-widget-part=\"authors-note.role-field\"\n\t\t\t\t\t\tlabel={t(\"Sent as\")}\n\t\t\t\t\t\tvalue={draft.role}\n\t\t\t\t\t\tdisabled={!canEdit}\n\t\t\t\t\t\tonchange={(e: CustomEvent<{ value: string }>) => {\n\t\t\t\t\t\t\tconst next = AUTHORS_NOTE_ROLES.find((r) => r.value === e.detail.value)\n\t\t\t\t\t\t\tif (next) draft = { ...draft, role: next.value }\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{#each AUTHORS_NOTE_ROLES as r (r.value)}\n\t\t\t\t\t\t\t<sp-option value={r.value}>{t(r.label)}</sp-option>\n\t\t\t\t\t\t{/each}\n\t\t\t\t\t</sp-combobox>\n\t\t\t\t</span>\n\t\t\t</sp-accordion-item>\n\t\t</sp-accordion>\n\t\t{#if saveError}\n\t\t\t<p data-widget-part=\"authors-note.alert\" role=\"alert\">{saveError}</p>\n\t\t{/if}\n\t\t{#if canEdit}\n\t\t\t<div data-widget-part=\"authors-note.actions toolbar\">\n\t\t\t\t{#if dirty}\n\t\t\t\t\t<span data-widget-part=\"authors-note.unsaved\">{t(\"Unsaved changes\")}</span>\n\t\t\t\t\t<button type=\"button\" data-widget-part=\"authors-note.discard\" disabled={saving} onclick={discard}>\n\t\t\t\t\t\t{t(\"Discard\")}\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"authors-note.save\"\n\t\t\t\t\tdisabled={!dirty || saving}\n\t\t\t\t\tonclick={save}\n\t\t\t\t>\n\t\t\t\t\t{saving ? t(\"Saving…\") : t(\"Save\")}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t{/if}\n\t\t{#if lastLine}\n\t\t\t<p data-widget-part=\"authors-note.last-reply\" data-applied={answer.lastReply?.included ? \"\" : undefined}>\n\t\t\t\t{lastLine}\n\t\t\t</p>\n\t\t{/if}\n\t{/if}\n</div>\n","sessions/authors-note/authors-note.ts":"/**\n * Core's `authors-note` component (2026-10-02, AN1): the session's author's\n * note — its text, how far back it goes, how often it repeats — saved\n * explicitly, and what the newest reply did with it. `npm run build`\n * compiles it with the CLI's component bundler to\n * `dist/components/authors-note.js`, the module the app serves at\n * `/core-ui/authors-note`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport AuthorsNote from './AuthorsNote.svelte'\n\nexport default svelteComponent(AuthorsNote)\n","sessions/shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","sessions/shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// No host menu across the port yet: dismissed, as a native host without one answers.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"5458d5b55cf30d2fac49eb52bb87a1e343084172a1cb40dc392da3710299116f","catalogVersion":"0.6.0-pr-1"}
1
+ {"slug":"authors-note","framework":"svelte","entry":"genres/chat/authors-note/authors-note.ts","files":{"genres/chat/authors-note/AuthorsNote.svelte":"<script lang=\"ts\">\n\t/**\n\t * Core's Author's note widget as a remote component (2026-10-02, AN1):\n\t * the component context, as the native widget context, around\n\t * `AuthorsNoteWidget`. It reads no section at all — everything is asked\n\t * of the page — so it asks as soon as it mounts.\n\t */\n\timport { setContext, untrack } from \"svelte\"\n\timport type { ComponentContext } from \"@serene-pub/sdk/component\"\n\timport { WIDGET_CONTEXT_KEY } from \"@serene-pub/core-catalog/widgets\"\n\timport AuthorsNoteWidget from \"./AuthorsNoteWidget.svelte\"\n\timport { widgetRefFromComponent } from \"../../../shared/widgetRef.svelte\"\n\n\tlet { ctx }: { ctx: ComponentContext } = $props()\n\n\t// The context is the mount's, handed once: its sections move, it does not.\n\tsetContext(\n\t\tWIDGET_CONTEXT_KEY,\n\t\twidgetRefFromComponent(\n\t\t\tuntrack(() => ctx),\n\t\t\t{ id: \"authors-note\", instanceId: \"authors-note\", title: \"Author's note\" }\n\t\t)\n\t)\n</script>\n\n<AuthorsNoteWidget />\n","genres/chat/authors-note/AuthorsNoteWidget.svelte":"<script lang=\"ts\">\n\t/**\n\t * The author's note (2026-10-02, AN1; Chat only, owner ruling): the\n\t * session's own note to the model — what is true now, where the story\n\t * should lean — placed `depth` messages before the reply on every\n\t * `interval`-th reply. Not the post-history reminder, which is the\n\t * pipeline's and the card's; this widget never shows or edits that.\n\t *\n\t * Everything is asked of the page: `authors-note` reads the note, whether\n\t * the viewer may change it (the session's owner), and what the newest\n\t * reply's prompt did with it; `set-authors-note` saves it, whole. It asks\n\t * again when a generation ends, so the last-reply line follows the\n\t * conversation, and when the session's genre fields change\n\t * (`genreFields:changed`), so a note saved in Edit Session or another tab\n\t * shows here.\n\t *\n\t * Saved explicitly (STYLE-GUIDE §6.14): edits wait for **Save**; dirty is\n\t * derived (the draft differs from what is saved, never \"touched\"); a\n\t * re-read moves the saved snapshot and keeps what is being typed.\n\t * What goes wrong is said here, in this widget (R77) — never a toast.\n\t *\n\t * The markup carries no look: its elements carry `authors-note.*` widget\n\t * parts and the default widget stylesheet draws them (STYLE-GUIDE §6.16).\n\t */\n\timport { untrack } from \"svelte\"\n\timport type { AuthorsNoteV1, AuthorsNoteValueV1 } from \"@serene-pub/sdk/component\"\n\timport {\n\t\tAUTHORS_NOTE_DEFAULTS,\n\t\tAUTHORS_NOTE_ROLES,\n\t\tauthorsNoteDirty,\n\t\tauthorsNoteLastReplyLine,\n\t\treadAuthorsNote\n\t} from \"@serene-pub/core-catalog/authors-note\"\n\timport { useWidgetContext } from \"../../../shared/context\"\n\n\tconst widget = useWidgetContext()\n\tconst t = (source: string): string => widget?.current?.t(source) ?? source\n\n\t/** What the page last answered. */\n\tlet answer = $state<AuthorsNoteV1 | null>(null)\n\t/** The form's own copy; Save sends it whole. */\n\tlet draft = $state<AuthorsNoteValueV1>({ ...AUTHORS_NOTE_DEFAULTS })\n\tlet readError = $state<string | null>(null)\n\tlet saveError = $state<string | null>(null)\n\tlet saving = $state(false)\n\n\tconst saved = $derived(answer ? readAuthorsNote(answer.note) : AUTHORS_NOTE_DEFAULTS)\n\tconst dirty = $derived(answer ? authorsNoteDirty(draft, saved) : false)\n\tconst canEdit = $derived(answer?.canEdit === true)\n\tconst lastLine = $derived(answer ? authorsNoteLastReplyLine(answer.lastReply, t) : null)\n\n\tconst reason = (e: unknown) => (e instanceof Error ? e.message : String(e))\n\n\t/**\n\t * Take the page's answer as the saved snapshot. A clean form follows it;\n\t * an edited one keeps the person's edits (§6.14 — a push never lies).\n\t */\n\tfunction adopt(next: AuthorsNoteV1) {\n\t\tconst wasDirty = answer ? authorsNoteDirty(draft, readAuthorsNote(answer.note)) : false\n\t\tanswer = next\n\t\tif (!wasDirty) draft = readAuthorsNote(next.note)\n\t}\n\n\tlet asked = 0\n\tfunction ask() {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx) return\n\t\tconst ticket = ++asked\n\t\tctx.request(\"authors-note\", {}).then(\n\t\t\t(res) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\treadError = null\n\t\t\t\tadopt(res)\n\t\t\t},\n\t\t\t(e) => {\n\t\t\t\tif (ticket !== asked) return\n\t\t\t\treadError = reason(e)\n\t\t\t}\n\t\t)\n\t}\n\n\t$effect(() => untrack(() => ask()))\n\n\t// A reply finished: what it did with the note is on its receipt now.\n\t$effect(() =>\n\t\tuntrack(() =>\n\t\t\twidget?.current?.on(\"generation:end\", (e) => {\n\t\t\t\tif (e.kind === \"generation:end\") ask()\n\t\t\t})\n\t\t)\n\t)\n\n\t// The note was saved somewhere else — Edit Session, or this widget in\n\t// another tab: read it again (a clean form follows it, an edited one\n\t// keeps the person's edits).\n\t$effect(() =>\n\t\tuntrack(() =>\n\t\t\twidget?.current?.on(\"genreFields:changed\", (e) => {\n\t\t\t\tif (e.kind === \"genreFields:changed\") ask()\n\t\t\t})\n\t\t)\n\t)\n\n\tasync function save() {\n\t\tconst ctx = untrack(() => widget?.current)\n\t\tif (!ctx || !canEdit || !dirty || saving) return\n\t\tsaving = true\n\t\tsaveError = null\n\t\tconst sent = readAuthorsNote(draft)\n\t\ttry {\n\t\t\tconst now = await ctx.request(\"set-authors-note\", { note: sent })\n\t\t\t// The saved row is what the page answered; the form is clean against it.\n\t\t\tanswer = now\n\t\t\tdraft = readAuthorsNote(now.note)\n\t\t} catch (e) {\n\t\t\tsaveError = t(\"Not saved: {reason}\").replace(\"{reason}\", reason(e))\n\t\t} finally {\n\t\t\tsaving = false\n\t\t}\n\t}\n\n\tfunction discard() {\n\t\tdraft = { ...saved }\n\t\tsaveError = null\n\t}\n\n\tconst setNumber = (key: \"depth\" | \"interval\", raw: string) => {\n\t\tconst n = raw.trim() === \"\" ? NaN : Number(raw)\n\t\tdraft = { ...draft, [key]: Number.isFinite(n) ? n : draft[key] }\n\t}\n</script>\n\n<div data-widget-part=\"authors-note.root\" data-widget=\"authors-note\" data-dirty={dirty ? \"\" : undefined}>\n\t{#if readError}\n\t\t<p data-widget-part=\"authors-note.alert\" role=\"alert\">\n\t\t\t{t(\"Could not read the author's note: {reason}\").replace(\"{reason}\", readError)}\n\t\t</p>\n\t{/if}\n\t{#if !answer}\n\t\t{#if !readError}\n\t\t\t<p data-widget-part=\"authors-note.note\">{t(\"Reading the author's note…\")}</p>\n\t\t{/if}\n\t{:else if !answer.offered}\n\t\t<p data-widget-part=\"authors-note.note\">\n\t\t\t{t(\"This kind of session has no author's note.\")}\n\t\t</p>\n\t{:else}\n\t\t{#if !canEdit}\n\t\t\t<p data-widget-part=\"authors-note.note\">\n\t\t\t\t{t(\"Only the session's owner can change the author's note.\")}\n\t\t\t</p>\n\t\t{/if}\n\t\t<label data-widget-part=\"authors-note.field\">\n\t\t\t<span data-widget-part=\"authors-note.label label\">{t(\"Note\")}</span>\n\t\t\t<textarea\n\t\t\t\tdata-widget-part=\"authors-note.text\"\n\t\t\t\trows=\"5\"\n\t\t\t\tplaceholder={t(\"What is true now, or where the story should go.\")}\n\t\t\t\tdisabled={!canEdit}\n\t\t\t\tvalue={draft.text}\n\t\t\t\toninput={(e) => (draft = { ...draft, text: e.currentTarget.value })}\n\t\t\t></textarea>\n\t\t</label>\n\t\t<div data-widget-part=\"authors-note.numbers\">\n\t\t\t<label data-widget-part=\"authors-note.field\">\n\t\t\t\t<span data-widget-part=\"authors-note.label label\">{t(\"Messages from the end\")}</span>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tdata-widget-part=\"authors-note.number\"\n\t\t\t\t\tmin=\"0\"\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tdisabled={!canEdit}\n\t\t\t\t\tvalue={String(draft.depth)}\n\t\t\t\t\toninput={(e) => setNumber(\"depth\", e.currentTarget.value)}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t\t<label data-widget-part=\"authors-note.field\">\n\t\t\t\t<span data-widget-part=\"authors-note.label label\">{t(\"Every how many replies\")}</span>\n\t\t\t\t<input\n\t\t\t\t\ttype=\"number\"\n\t\t\t\t\tdata-widget-part=\"authors-note.number\"\n\t\t\t\t\tmin=\"1\"\n\t\t\t\t\tstep=\"1\"\n\t\t\t\t\tdisabled={!canEdit}\n\t\t\t\t\tvalue={String(draft.interval)}\n\t\t\t\t\toninput={(e) => setNumber(\"interval\", e.currentTarget.value)}\n\t\t\t\t/>\n\t\t\t</label>\n\t\t</div>\n\t\t<p data-widget-part=\"authors-note.help\">\n\t\t\t{t(\"0 messages puts it right before the reply. Every 1 reply adds it each time.\")}\n\t\t</p>\n\t\t<sp-accordion data-widget-part=\"authors-note.advanced\">\n\t\t\t<sp-accordion-item value=\"advanced\" heading={t(\"Advanced\")} level=\"4\">\n\t\t\t\t<span data-widget-part=\"authors-note.role\">\n\t\t\t\t\t<sp-combobox\n\t\t\t\t\t\tdata-widget-part=\"authors-note.role-field\"\n\t\t\t\t\t\tlabel={t(\"Sent as\")}\n\t\t\t\t\t\tvalue={draft.role}\n\t\t\t\t\t\tdisabled={!canEdit}\n\t\t\t\t\t\tonchange={(e: CustomEvent<{ value: string }>) => {\n\t\t\t\t\t\t\tconst next = AUTHORS_NOTE_ROLES.find((r) => r.value === e.detail.value)\n\t\t\t\t\t\t\tif (next) draft = { ...draft, role: next.value }\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t{#each AUTHORS_NOTE_ROLES as r (r.value)}\n\t\t\t\t\t\t\t<sp-option value={r.value}>{t(r.label)}</sp-option>\n\t\t\t\t\t\t{/each}\n\t\t\t\t\t</sp-combobox>\n\t\t\t\t</span>\n\t\t\t</sp-accordion-item>\n\t\t</sp-accordion>\n\t\t{#if saveError}\n\t\t\t<p data-widget-part=\"authors-note.alert\" role=\"alert\">{saveError}</p>\n\t\t{/if}\n\t\t{#if canEdit}\n\t\t\t<div data-widget-part=\"authors-note.actions toolbar\">\n\t\t\t\t{#if dirty}\n\t\t\t\t\t<span data-widget-part=\"authors-note.unsaved\">{t(\"Unsaved changes\")}</span>\n\t\t\t\t\t<button type=\"button\" data-widget-part=\"authors-note.discard\" disabled={saving} onclick={discard}>\n\t\t\t\t\t\t{t(\"Discard\")}\n\t\t\t\t\t</button>\n\t\t\t\t{/if}\n\t\t\t\t<button\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\tdata-widget-part=\"authors-note.save\"\n\t\t\t\t\tdisabled={!dirty || saving}\n\t\t\t\t\tonclick={save}\n\t\t\t\t>\n\t\t\t\t\t{saving ? t(\"Saving…\") : t(\"Save\")}\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t{/if}\n\t\t{#if lastLine}\n\t\t\t<p data-widget-part=\"authors-note.last-reply\" data-applied={answer.lastReply?.included ? \"\" : undefined}>\n\t\t\t\t{lastLine}\n\t\t\t</p>\n\t\t{/if}\n\t{/if}\n</div>\n","genres/chat/authors-note/authors-note.ts":"/**\n * Core's `authors-note` component (2026-10-02, AN1): the session's author's\n * note — its text, how far back it goes, how often it repeats — saved\n * explicitly, and what the newest reply did with it. `npm run build`\n * compiles it with the CLI's component bundler to\n * `dist/components/authors-note.js`, the module the app serves at\n * `/core-ui/authors-note`.\n */\nimport { svelteComponent } from '@serene-pub/component-client/svelte'\nimport AuthorsNote from './AuthorsNote.svelte'\n\nexport default svelteComponent(AuthorsNote)\n","shared/context.ts":"/**\n * Core's widgets read their widget context with their own `getContext`, so\n * the lookup resolves in whichever Svelte runtime renders them — the\n * component's, in the page's UI worker. The key and the context's shape are\n * the host's contract (`@serene-pub/core-catalog/widgets`). Shared by every\n * core widget (R21); the conversation was the first.\n */\nimport { getContext } from 'svelte'\nimport { WIDGET_CONTEXT_KEY, type WidgetContextRef } from '@serene-pub/core-catalog/widgets'\n\n/** The widget context, if a host provides one; undefined outside a host (tests, a bare mount). */\nexport function useWidgetContext(): WidgetContextRef | undefined {\n\treturn getContext<WidgetContextRef | undefined>(WIDGET_CONTEXT_KEY)\n}\n","shared/widgetRef.svelte.ts":"/**\n * A remote's widget context (C0b): the component context a UI worker hands\n * a component, as the native `WidgetContext` core's widgets read\n * (`useWidgetContext`). So a core widget — written against the native\n * context — runs in a worker with no change to its source: the same\n * sections, the same verbs, reaching the host over the component's port.\n * Shared by every core widget (R21); the conversation was the first.\n */\nimport {\n\tEMPTY_TURN_ORDER,\n\tWIDGET_PROTOCOL,\n\ttype ComponentContext,\n\ttype LayoutV1,\n\ttype ViewerV1,\n\ttype WidgetEvent,\n\ttype WidgetEventKind\n} from \"@serene-pub/sdk/component\"\nimport {\n\tWIDGET_SCOPED_SECTIONS,\n\ttype WidgetContext,\n\ttype WidgetContextRef,\n\ttype WidgetScopedData\n} from \"@serene-pub/core-catalog/widgets\"\n\n/** Every scoped section's posted name — the SDK's one table, read once. */\nconst SCOPED_NAMES = Object.values(WIDGET_SCOPED_SECTIONS)\n\nconst NOBODY: ViewerV1 = { userId: null, isAdmin: false, isGuest: false }\n\n/**\n * A remote's context carries its saved view state besides: what it saved\n * last mount (`state`) and the host's save-state channel (`saveState`) —\n * read by core's widgets off the context where a remote has them.\n */\ntype RemoteWidgetContext = WidgetContext & {\n\tstate: unknown\n\tsaveState: (state: unknown) => void\n}\n\n/** The granted scoped sections as the envelope carries them: `{ <name>: { v1 } }`, absent when not granted. */\nfunction scopedData(scoped: ComponentContext[\"scoped\"]): WidgetScopedData {\n\tconst out: Record<string, { v1: unknown }> = {}\n\tfor (const name of SCOPED_NAMES) if (scoped[name] !== undefined) out[name] = { v1: scoped[name] }\n\treturn out as WidgetScopedData\n}\n\nexport function widgetRefFromComponent(\n\tctx: ComponentContext,\n\twidget: WidgetContext[\"widget\"]\n): WidgetContextRef {\n\t// Any section the host pushes re-projects the context, as a native\n\t// host's re-projection does.\n\tlet version = $state(0)\n\tctx.subscribe(() => version++)\n\n\tconst current = $derived.by((): RemoteWidgetContext => {\n\t\tvoid version\n\t\tconst scoped = ctx.scoped ?? {}\n\t\treturn {\n\t\t\tprotocol: WIDGET_PROTOCOL,\n\t\t\twidget,\n\t\t\tlayout: { v1: (ctx.layout ?? {}) as LayoutV1 },\n\t\t\tsession: { v1: (ctx.session ?? { id: 0, name: null }) as WidgetContext[\"session\"][\"v1\"] },\n\t\t\tchannels: { v1: Object.keys(ctx.channels ?? {}) },\n\t\t\tmessages: { v1: (ctx.messages ?? []) as WidgetContext[\"messages\"][\"v1\"] },\n\t\t\tprops: { v1: ctx.props ?? {} },\n\t\t\tactions: { v1: (ctx.actions ?? {}) as WidgetContext[\"actions\"][\"v1\"] },\n\t\t\tsettings: { v1: ctx.settings ?? {} },\n\t\t\tannex: { v1: (ctx.annex ?? {}) as WidgetContext[\"annex\"][\"v1\"] },\n\t\t\tlocale: { v1: ctx.locale ?? \"en\" },\n\t\t\tviewer: { v1: ctx.viewer ?? NOBODY },\n\t\t\tturnOrder: { v1: ctx.turnOrder ?? EMPTY_TURN_ORDER },\n\t\t\t// What the host said this widget holds — absent until it has — so a\n\t\t\t// widget can tell a scope never granted apart from a section not yet posted.\n\t\t\tgrants: ctx.grants,\n\t\t\t// The scoped sections the host granted, each as its `{ v1 }` bag — by\n\t\t\t// the table, so a section the SDK adds arrives with no change here.\n\t\t\t...scopedData(scoped),\n\t\t\taction: (fn, messageId, payload, action, blockId) => ctx.action(fn, messageId, payload, action, blockId),\n\t\t\tinvoke: (key, args) => ctx.invoke(key, args),\n\t\t\trequest: ((kind, params) => ctx.request(kind, params)) as WidgetContext[\"request\"],\n\t\t\t// No host menu across the port yet: dismissed, as a native host without one answers.\n\t\t\tmenu: async () => null,\n\t\t\ton: (kind: WidgetEventKind | \"*\", cb: (e: WidgetEvent) => void) =>\n\t\t\t\tctx.onEvent((e) => {\n\t\t\t\t\tconst ev = e as WidgetEvent\n\t\t\t\t\tif (kind === \"*\" || ev.kind === kind) cb(ev)\n\t\t\t\t}),\n\t\t\tt: (source) => ctx.t(source),\n\t\t\tstate: ctx.state,\n\t\t\tsaveState: (state) => ctx.saveState(state)\n\t\t}\n\t})\n\n\treturn {\n\t\tget current() {\n\t\t\treturn current\n\t\t}\n\t}\n}\n"},"sourceHash":"0b94fa261342dfa9d93d32406624f3f139b01aa8caedd3e3837d3860ed06bb81","catalogVersion":"0.6.0-pr-4"}