rpg-engine 0.7.0 → 0.9.0

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 (397) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.js +13 -13
  4. package/dist/campaign/create-campaign.js +10 -1
  5. package/dist/campaign/host-files.d.ts +2 -1
  6. package/dist/campaign/host-files.js +11 -11
  7. package/dist/campaign/index.d.ts +1 -1
  8. package/dist/campaign/index.js +1 -1
  9. package/dist/campaign/settings.d.ts +55 -64
  10. package/dist/campaign/settings.js +171 -174
  11. package/dist/{cli.js → cli/cli.js} +3 -3
  12. package/dist/{command-line.d.ts → cli/command-line.d.ts} +1 -1
  13. package/dist/{command-line.js → cli/command-line.js} +21 -20
  14. package/dist/commands/advance.d.ts +1 -1
  15. package/dist/commands/advance.js +7 -7
  16. package/dist/commands/ask.d.ts +1 -8
  17. package/dist/commands/ask.js +16 -29
  18. package/dist/commands/{change.d.ts → change/change.d.ts} +2 -2
  19. package/dist/commands/{change.js → change/change.js} +46 -52
  20. package/dist/commands/{game-damage.d.ts → change/damage.d.ts} +2 -2
  21. package/dist/commands/{game-damage.js → change/damage.js} +3 -3
  22. package/dist/commands/{game-recipe-pace.d.ts → change/recipe-pace.d.ts} +2 -2
  23. package/dist/commands/{game-recipe-pace.js → change/recipe-pace.js} +4 -4
  24. package/dist/commands/config.d.ts +4 -4
  25. package/dist/commands/config.js +142 -138
  26. package/dist/commands/effect.d.ts +1 -1
  27. package/dist/commands/effect.js +11 -12
  28. package/dist/commands/find.d.ts +4 -4
  29. package/dist/commands/find.js +2 -2
  30. package/dist/commands/image.js +6 -6
  31. package/dist/commands/{import.d.ts → import/import.d.ts} +2 -2
  32. package/dist/commands/{import.js → import/import.js} +101 -101
  33. package/dist/commands/{game-import.d.ts → import/run.d.ts} +3 -3
  34. package/dist/commands/{game-import.js → import/run.js} +13 -12
  35. package/dist/commands/index.js +7 -7
  36. package/dist/commands/init.js +3 -3
  37. package/dist/commands/install.js +1 -1
  38. package/dist/commands/instructions.js +6 -6
  39. package/dist/commands/mode.d.ts +2 -2
  40. package/dist/commands/mode.js +8 -8
  41. package/dist/commands/mood.js +4 -4
  42. package/dist/commands/move.js +13 -20
  43. package/dist/commands/package.d.ts +2 -2
  44. package/dist/commands/package.js +138 -93
  45. package/dist/commands/rename.js +3 -3
  46. package/dist/commands/reveal.js +29 -18
  47. package/dist/commands/{roll.d.ts → roll/roll.d.ts} +4 -4
  48. package/dist/commands/{roll.js → roll/roll.js} +69 -69
  49. package/dist/commands/{game-tables.d.ts → roll/tables.d.ts} +2 -2
  50. package/dist/commands/{game-tables.js → roll/tables.js} +4 -4
  51. package/dist/commands/rules.d.ts +2 -2
  52. package/dist/commands/rules.js +17 -9
  53. package/dist/commands/save.d.ts +1 -1
  54. package/dist/commands/save.js +18 -18
  55. package/dist/commands/scene.d.ts +4 -4
  56. package/dist/commands/scene.js +31 -28
  57. package/dist/commands/{game-advance.d.ts → shared/advance.d.ts} +4 -4
  58. package/dist/commands/{game-advance.js → shared/advance.js} +27 -27
  59. package/dist/commands/{game-adventures.d.ts → shared/adventures.d.ts} +3 -3
  60. package/dist/commands/{game-adventures.js → shared/adventures.js} +20 -27
  61. package/dist/commands/{game-bonds.d.ts → shared/bonds.d.ts} +3 -3
  62. package/dist/commands/{game-bonds.js → shared/bonds.js} +2 -2
  63. package/dist/commands/{game-checks.d.ts → shared/checks.d.ts} +3 -3
  64. package/dist/commands/{game-checks.js → shared/checks.js} +7 -7
  65. package/dist/commands/{game-dice-pool.d.ts → shared/dice-pool.d.ts} +3 -3
  66. package/dist/commands/{game-dice-pool.js → shared/dice-pool.js} +19 -12
  67. package/dist/commands/{effect-layer.d.ts → shared/effect-layer.d.ts} +2 -2
  68. package/dist/commands/{effect-layer.js → shared/effect-layer.js} +12 -12
  69. package/dist/commands/{game-effects.d.ts → shared/effects.d.ts} +7 -7
  70. package/dist/commands/{game-effects.js → shared/effects.js} +19 -19
  71. package/dist/commands/{game-environment.d.ts → shared/environment.d.ts} +1 -1
  72. package/dist/commands/{game-environment.js → shared/environment.js} +3 -3
  73. package/dist/commands/{game-events.d.ts → shared/events.d.ts} +5 -5
  74. package/dist/commands/{game-events.js → shared/events.js} +20 -22
  75. package/dist/commands/{game-examples.d.ts → shared/examples.d.ts} +4 -8
  76. package/dist/commands/{game-examples.js → shared/examples.js} +23 -23
  77. package/dist/commands/{game-experience.d.ts → shared/experience.d.ts} +2 -2
  78. package/dist/commands/{game-experience.js → shared/experience.js} +8 -11
  79. package/dist/commands/{game-grid-moves.d.ts → shared/grid-moves.d.ts} +6 -6
  80. package/dist/commands/{game-grid-moves.js → shared/grid-moves.js} +5 -5
  81. package/dist/commands/{game-grids.d.ts → shared/grids.d.ts} +4 -9
  82. package/dist/commands/{game-grids.js → shared/grids.js} +20 -19
  83. package/dist/commands/{game-images.d.ts → shared/images.d.ts} +3 -3
  84. package/dist/commands/{game-images.js → shared/images.js} +7 -6
  85. package/dist/commands/shared/inputs.d.ts +9 -0
  86. package/dist/commands/shared/inputs.js +12 -0
  87. package/dist/commands/{game-journey.d.ts → shared/journey.d.ts} +4 -6
  88. package/dist/commands/{game-journey.js → shared/journey.js} +13 -15
  89. package/dist/commands/{game-knowledge.d.ts → shared/knowledge.d.ts} +15 -8
  90. package/dist/commands/{game-knowledge.js → shared/knowledge.js} +56 -44
  91. package/dist/{library-reader.js → commands/shared/library-reader.js} +4 -4
  92. package/dist/commands/{game-library.d.ts → shared/library.d.ts} +7 -4
  93. package/dist/commands/{game-library.js → shared/library.js} +70 -50
  94. package/dist/commands/{game-limits.d.ts → shared/limits.d.ts} +3 -3
  95. package/dist/commands/{game-limits.js → shared/limits.js} +3 -3
  96. package/dist/commands/{game-loot.d.ts → shared/loot.d.ts} +2 -2
  97. package/dist/commands/{game-loot.js → shared/loot.js} +3 -3
  98. package/dist/commands/{game-master-rolls.d.ts → shared/master-rolls.d.ts} +2 -2
  99. package/dist/commands/{game-master-rolls.js → shared/master-rolls.js} +6 -6
  100. package/dist/commands/{game-mode.d.ts → shared/mode.d.ts} +4 -6
  101. package/dist/commands/{game-mode.js → shared/mode.js} +10 -10
  102. package/dist/commands/{game-money.d.ts → shared/money.d.ts} +3 -3
  103. package/dist/commands/{game-money.js → shared/money.js} +4 -4
  104. package/dist/commands/{game-moods.d.ts → shared/moods.d.ts} +3 -3
  105. package/dist/commands/{game-moods.js → shared/moods.js} +3 -3
  106. package/dist/commands/{game-moves.d.ts → shared/moves.d.ts} +2 -2
  107. package/dist/commands/{game-moves.js → shared/moves.js} +5 -5
  108. package/dist/commands/{game-offers.d.ts → shared/offers.d.ts} +3 -3
  109. package/dist/commands/{game-offers.js → shared/offers.js} +9 -12
  110. package/dist/commands/{game-outside.d.ts → shared/outside.d.ts} +3 -3
  111. package/dist/commands/{game-outside.js → shared/outside.js} +9 -9
  112. package/dist/commands/{game-catalog.d.ts → shared/packages/catalog.d.ts} +1 -3
  113. package/dist/commands/{game-catalog.js → shared/packages/catalog.js} +17 -22
  114. package/dist/commands/{game-package-code.d.ts → shared/packages/code.d.ts} +10 -14
  115. package/dist/commands/{game-package-code.js → shared/packages/code.js} +156 -59
  116. package/dist/commands/{game-extension-list.d.ts → shared/packages/extensions.d.ts} +6 -6
  117. package/dist/commands/{game-extension-list.js → shared/packages/extensions.js} +43 -22
  118. package/dist/commands/{game-package-hooks.d.ts → shared/packages/hooks.d.ts} +3 -3
  119. package/dist/commands/{game-package-hooks.js → shared/packages/hooks.js} +3 -3
  120. package/dist/commands/{game-widgets.d.ts → shared/packages/widgets.d.ts} +6 -10
  121. package/dist/commands/{game-widgets.js → shared/packages/widgets.js} +57 -57
  122. package/dist/commands/{page-counters.d.ts → shared/page-counters.d.ts} +3 -3
  123. package/dist/commands/{page-counters.js → shared/page-counters.js} +5 -5
  124. package/dist/{page-words.d.ts → commands/shared/page-words.d.ts} +2 -2
  125. package/dist/{page-words.js → commands/shared/page-words.js} +5 -4
  126. package/dist/commands/{parts.d.ts → shared/parts.d.ts} +3 -3
  127. package/dist/commands/{parts.js → shared/parts.js} +4 -4
  128. package/dist/commands/{game-positions.d.ts → shared/positions.d.ts} +3 -5
  129. package/dist/commands/{game-positions.js → shared/positions.js} +6 -7
  130. package/dist/commands/{problems.d.ts → shared/problems.d.ts} +3 -3
  131. package/dist/commands/{problems.js → shared/problems.js} +21 -22
  132. package/dist/commands/{progression.d.ts → shared/progression.d.ts} +2 -2
  133. package/dist/commands/{progression.js → shared/progression.js} +4 -4
  134. package/dist/commands/{game-quests.d.ts → shared/quests.d.ts} +4 -4
  135. package/dist/commands/{game-quests.js → shared/quests.js} +6 -6
  136. package/dist/commands/{game-recipes.d.ts → shared/recipes.d.ts} +3 -3
  137. package/dist/commands/{game-recipes.js → shared/recipes.js} +3 -3
  138. package/dist/commands/{game-reminders.d.ts → shared/reminders.d.ts} +4 -4
  139. package/dist/commands/{game-reminders.js → shared/reminders.js} +4 -4
  140. package/dist/commands/{game-roads.d.ts → shared/roads.d.ts} +5 -5
  141. package/dist/commands/{game-roads.js → shared/roads.js} +43 -44
  142. package/dist/commands/{game-rules.d.ts → shared/rules.d.ts} +13 -5
  143. package/dist/commands/shared/rules.js +66 -0
  144. package/dist/commands/{game-saves.d.ts → shared/saves.d.ts} +4 -4
  145. package/dist/commands/{game-saves.js → shared/saves.js} +51 -51
  146. package/dist/commands/{game-scene.d.ts → shared/scene.d.ts} +13 -3
  147. package/dist/commands/{game-scene.js → shared/scene.js} +41 -13
  148. package/dist/commands/{sheet.d.ts → shared/sheet.d.ts} +5 -5
  149. package/dist/commands/{sheet.js → shared/sheet.js} +76 -76
  150. package/dist/commands/{game-stacks.d.ts → shared/stacks.d.ts} +2 -9
  151. package/dist/commands/{game-stacks.js → shared/stacks.js} +22 -22
  152. package/dist/commands/{game-theme.d.ts → shared/theme.d.ts} +3 -3
  153. package/dist/commands/{game-theme.js → shared/theme.js} +2 -2
  154. package/dist/commands/{game-thoughts.d.ts → shared/thoughts.d.ts} +2 -4
  155. package/dist/commands/{game-thoughts.js → shared/thoughts.js} +6 -8
  156. package/dist/commands/{game-thresholds.d.ts → shared/thresholds.d.ts} +1 -1
  157. package/dist/commands/{game-thresholds.js → shared/thresholds.js} +4 -4
  158. package/dist/commands/{game-time.d.ts → shared/time.d.ts} +4 -4
  159. package/dist/commands/{game-time.js → shared/time.js} +6 -6
  160. package/dist/commands/{game-turn-uses.d.ts → shared/turn-uses.d.ts} +3 -3
  161. package/dist/commands/{game-turn-uses.js → shared/turn-uses.js} +12 -15
  162. package/dist/commands/{game-upkeep.d.ts → shared/upkeep.d.ts} +3 -3
  163. package/dist/commands/{game-upkeep.js → shared/upkeep.js} +69 -57
  164. package/dist/commands/{game-voices.d.ts → shared/voices.d.ts} +1 -1
  165. package/dist/commands/{game-voices.js → shared/voices.js} +2 -2
  166. package/dist/commands/{worked-out.d.ts → shared/worked-out.d.ts} +3 -8
  167. package/dist/commands/{worked-out.js → shared/worked-out.js} +238 -238
  168. package/dist/commands/{game-world.d.ts → shared/world.d.ts} +5 -14
  169. package/dist/commands/{game-world.js → shared/world.js} +72 -76
  170. package/dist/commands/show.d.ts +4 -1
  171. package/dist/commands/show.js +36 -18
  172. package/dist/commands/status.d.ts +1 -1
  173. package/dist/commands/status.js +28 -28
  174. package/dist/commands/thoughts.js +3 -3
  175. package/dist/commands/trade.js +9 -10
  176. package/dist/commands/translate.d.ts +1 -1
  177. package/dist/commands/translate.js +3 -3
  178. package/dist/commands/{game-open.d.ts → travel/open.d.ts} +3 -3
  179. package/dist/commands/{game-open.js → travel/open.js} +4 -5
  180. package/dist/commands/{route.d.ts → travel/route.d.ts} +1 -1
  181. package/dist/commands/{route.js → travel/route.js} +9 -10
  182. package/dist/commands/{travel.d.ts → travel/travel.d.ts} +2 -2
  183. package/dist/commands/{travel.js → travel/travel.js} +19 -21
  184. package/dist/commands/validate.js +5 -5
  185. package/dist/commands/{game-view-journal.d.ts → view/journal.d.ts} +5 -5
  186. package/dist/commands/{game-view-journal.js → view/journal.js} +5 -5
  187. package/dist/commands/{game-view-map.d.ts → view/map.d.ts} +3 -3
  188. package/dist/commands/{game-view-map.js → view/map.js} +15 -16
  189. package/dist/commands/{game-view-place.d.ts → view/place.d.ts} +6 -6
  190. package/dist/commands/{game-view-place.js → view/place.js} +108 -108
  191. package/dist/commands/{view.d.ts → view/view.d.ts} +16 -16
  192. package/dist/commands/{view.js → view/view.js} +41 -36
  193. package/dist/commands/{game-view-world.d.ts → view/world.d.ts} +4 -4
  194. package/dist/commands/{game-view-world.js → view/world.js} +7 -7
  195. package/dist/commands/{game-here.d.ts → write/here.d.ts} +5 -3
  196. package/dist/commands/{game-here.js → write/here.js} +18 -12
  197. package/dist/commands/{write.d.ts → write/write.d.ts} +6 -6
  198. package/dist/commands/{write.js → write/write.js} +44 -41
  199. package/dist/confirm/confirm.d.ts +2 -0
  200. package/dist/confirm/confirm.js +15 -5
  201. package/dist/core/consents.d.ts +3 -2
  202. package/dist/core/consents.js +43 -4
  203. package/dist/core/context.d.ts +8 -6
  204. package/dist/core/context.js +4 -2
  205. package/dist/core/download.js +16 -5
  206. package/dist/core/files.d.ts +8 -1
  207. package/dist/core/files.js +53 -21
  208. package/dist/core/formula.d.ts +7 -2
  209. package/dist/core/formula.js +63 -66
  210. package/dist/core/instruction-parts.js +1 -1
  211. package/dist/core/mood.d.ts +0 -1
  212. package/dist/core/mood.js +3 -3
  213. package/dist/core/package-api.d.ts +11 -0
  214. package/dist/core/package-api.js +2 -1
  215. package/dist/core/package-declarations.d.ts +9 -9
  216. package/dist/core/package-declarations.js +3 -3
  217. package/dist/core/process-mark.d.ts +8 -0
  218. package/dist/core/process-mark.js +72 -0
  219. package/dist/core/registry.d.ts +5 -0
  220. package/dist/core/registry.js +10 -0
  221. package/dist/core/session-store.d.ts +0 -1
  222. package/dist/core/session-store.js +11 -14
  223. package/dist/core/store.d.ts +4 -0
  224. package/dist/core/store.js +29 -8
  225. package/dist/core/text.d.ts +4 -0
  226. package/dist/core/text.js +11 -2
  227. package/dist/core/yaml-file.js +2 -2
  228. package/dist/dashboard/{acts.js → acts/acts.js} +2 -2
  229. package/dist/dashboard/{act-names.js → acts/names.js} +1 -1
  230. package/dist/dashboard/{act-sheet.js → acts/sheet.js} +3 -3
  231. package/dist/dashboard/{act-strip.js → acts/strip.js} +2 -2
  232. package/dist/dashboard/app.js +13 -13
  233. package/dist/dashboard/asked.js +1 -1
  234. package/dist/dashboard/dice/burn.js +1 -1
  235. package/dist/dashboard/dice/stage.js +1 -1
  236. package/dist/dashboard/game-words.js +4 -4
  237. package/dist/dashboard/{guide-blocks.js → help/blocks.js} +1 -1
  238. package/dist/dashboard/{help.js → help/help.js} +6 -6
  239. package/dist/dashboard/journal.js +1 -1
  240. package/dist/dashboard/kit.js +6 -5
  241. package/dist/dashboard/labels.js +7 -3
  242. package/dist/dashboard/markdown.js +1 -1
  243. package/dist/dashboard/{ask-card.js → packages/ask-card.js} +6 -6
  244. package/dist/dashboard/{package-page.js → packages/package-page.js} +3 -3
  245. package/dist/dashboard/{packages.js → packages/packages.js} +12 -12
  246. package/dist/dashboard/{page-code.js → packages/page-code.js} +4 -4
  247. package/dist/dashboard/{extension-widgets.js → packages/widgets.js} +5 -5
  248. package/dist/dashboard/party.js +1 -1
  249. package/dist/dashboard/person-panel.js +2 -13
  250. package/dist/dashboard/{map-sheet.js → place/map-sheet.js} +4 -4
  251. package/dist/dashboard/{place-map-view.js → place/map-view.js} +11 -11
  252. package/dist/dashboard/scene.js +4 -4
  253. package/dist/dashboard/settings.js +1 -1
  254. package/dist/dashboard/sheet.js +4 -4
  255. package/dist/dashboard/text.js +6 -0
  256. package/dist/dashboard/top.js +2 -2
  257. package/dist/dashboard/turns.js +2 -2
  258. package/dist/dashboard/widgets.js +1 -1
  259. package/dist/dashboard/{world-calendar.js → world/calendar.js} +7 -7
  260. package/dist/dashboard/{lore.js → world/known.js} +1 -1
  261. package/dist/dashboard/{world-lore.js → world/lore.js} +9 -9
  262. package/dist/dashboard/{world-map.js → world/map.js} +1 -1
  263. package/dist/dashboard/{world.js → world/world.js} +14 -14
  264. package/dist/dice/evaluate.js +1 -1
  265. package/dist/dice/index.d.ts +2 -2
  266. package/dist/dice/index.js +2 -2
  267. package/dist/dice/notation.d.ts +2 -0
  268. package/dist/dice/notation.js +22 -4
  269. package/dist/documents/markup.js +2 -2
  270. package/dist/documents/read.js +29 -13
  271. package/dist/effects/effect.js +2 -5
  272. package/dist/extensions/extension.js +6 -8
  273. package/dist/extensions/index.d.ts +1 -4
  274. package/dist/extensions/index.js +1 -4
  275. package/dist/extensions/words.js +2 -1
  276. package/dist/{pictures → helpers}/briefs.js +17 -14
  277. package/dist/{pictures → helpers}/claude.js +8 -18
  278. package/dist/{pictures → helpers}/codex.js +3 -15
  279. package/dist/helpers/index.d.ts +7 -0
  280. package/dist/helpers/index.js +9 -0
  281. package/dist/{pictures/helpers.d.ts → helpers/programs.d.ts} +6 -1
  282. package/dist/{pictures/helpers.js → helpers/programs.js} +16 -2
  283. package/dist/images/images.js +7 -5
  284. package/dist/images/index.d.ts +1 -1
  285. package/dist/images/index.js +1 -1
  286. package/dist/importer/index.d.ts +1 -1
  287. package/dist/importer/index.js +1 -1
  288. package/dist/importer/work.d.ts +0 -2
  289. package/dist/importer/work.js +9 -30
  290. package/dist/instructions/index.d.ts +2 -0
  291. package/dist/instructions/index.js +10 -0
  292. package/dist/languages/index.d.ts +1 -1
  293. package/dist/languages/index.js +1 -1
  294. package/dist/languages/language-pack.js +15 -3
  295. package/dist/library/books.js +29 -83
  296. package/dist/{extensions → packages}/engine.d.ts +1 -1
  297. package/dist/{extensions → packages}/engine.js +1 -1
  298. package/dist/packages/index.d.ts +3 -0
  299. package/dist/packages/index.js +4 -0
  300. package/dist/{extensions/packages.d.ts → packages/npm.d.ts} +2 -0
  301. package/dist/{extensions/packages.js → packages/npm.js} +74 -45
  302. package/dist/page.d.ts +9 -11
  303. package/dist/page.js +1 -2
  304. package/dist/pages/check.js +31 -40
  305. package/dist/pages/containers.js +20 -20
  306. package/dist/pages/environment.js +15 -15
  307. package/dist/pages/index.d.ts +9 -9
  308. package/dist/pages/index.js +9 -9
  309. package/dist/pages/inheritance.d.ts +2 -1
  310. package/dist/pages/inheritance.js +24 -24
  311. package/dist/pages/load.js +7 -7
  312. package/dist/pages/maps.d.ts +20 -0
  313. package/dist/pages/maps.js +51 -1
  314. package/dist/pages/markdown.d.ts +2 -0
  315. package/dist/pages/markdown.js +110 -79
  316. package/dist/pages/page-file.d.ts +2 -1
  317. package/dist/pages/page-file.js +31 -29
  318. package/dist/pages/rename-page.d.ts +4 -1
  319. package/dist/pages/rename-page.js +7 -3
  320. package/dist/pages/{stack-entry.d.ts → stacks/entry.d.ts} +0 -2
  321. package/dist/pages/{stack-entry.js → stacks/entry.js} +2 -6
  322. package/dist/pages/{stacks.d.ts → stacks/kinds.d.ts} +8 -1
  323. package/dist/pages/{stacks.js → stacks/kinds.js} +36 -41
  324. package/dist/pages/{stack-writes.d.ts → stacks/writes.d.ts} +2 -2
  325. package/dist/pages/{stack-writes.js → stacks/writes.js} +32 -32
  326. package/dist/pages/system-pages.js +15 -15
  327. package/dist/pages/world.d.ts +4 -0
  328. package/dist/pages/world.js +52 -20
  329. package/dist/pages/write-page.js +35 -34
  330. package/dist/player-notes/index.d.ts +1 -1
  331. package/dist/player-notes/index.js +1 -1
  332. package/dist/rules/page-search.js +3 -4
  333. package/dist/rules/rule-book.js +1 -1
  334. package/dist/rules/search.js +21 -21
  335. package/dist/rules/shown.js +1 -3
  336. package/dist/saves/saves.d.ts +2 -2
  337. package/dist/saves/saves.js +15 -3
  338. package/dist/{bell-listener.js → server/bell-listener.js} +3 -3
  339. package/dist/server/dashboard/files.d.ts +59 -0
  340. package/dist/server/dashboard/files.js +326 -0
  341. package/dist/server/dashboard/index.d.ts +114 -0
  342. package/dist/server/dashboard/index.js +419 -0
  343. package/dist/server/dashboard/news.d.ts +39 -0
  344. package/dist/server/dashboard/news.js +390 -0
  345. package/dist/server/dashboard/player.d.ts +48 -0
  346. package/dist/server/dashboard/player.js +242 -0
  347. package/dist/server/dashboard/ports.d.ts +10 -0
  348. package/dist/server/dashboard/ports.js +15 -0
  349. package/dist/server/dashboard/writes.d.ts +58 -0
  350. package/dist/server/dashboard/writes.js +492 -0
  351. package/dist/{mcp-server.d.ts → server/mcp.d.ts} +2 -2
  352. package/dist/{mcp-server.js → server/mcp.js} +57 -42
  353. package/dist/systems/game-system.d.ts +5 -3
  354. package/dist/systems/game-system.js +178 -149
  355. package/dist/systems/index.d.ts +1 -1
  356. package/dist/systems/index.js +1 -1
  357. package/dist/{testing.d.ts → testing/index.d.ts} +6 -6
  358. package/dist/{testing.js → testing/index.js} +32 -18
  359. package/dist/{system-checks.js → testing/system-checks.js} +18 -12
  360. package/dist/themes/theme.d.ts +3 -3
  361. package/dist/themes/theme.js +14 -14
  362. package/dist/time/calendar.js +5 -2
  363. package/dist/triggers/trigger.js +5 -8
  364. package/instructions/dashboard-guide.md +2 -1
  365. package/instructions/play.md +1 -1
  366. package/package.json +5 -5
  367. package/dist/commands/game-maps.d.ts +0 -20
  368. package/dist/commands/game-maps.js +0 -51
  369. package/dist/commands/game-rules.js +0 -36
  370. package/dist/dashboard-server.d.ts +0 -47
  371. package/dist/dashboard-server.js +0 -1830
  372. package/dist/pictures/index.d.ts +0 -7
  373. package/dist/pictures/index.js +0 -9
  374. /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
  375. /package/dist/{library-reader.d.ts → commands/shared/library-reader.d.ts} +0 -0
  376. /package/dist/commands/{notes.d.ts → shared/notes.d.ts} +0 -0
  377. /package/dist/commands/{notes.js → shared/notes.js} +0 -0
  378. /package/dist/dashboard/{guide-markdown.js → help/markdown.js} +0 -0
  379. /package/dist/dashboard/{pack-card.js → packages/card.js} +0 -0
  380. /package/dist/dashboard/{people.js → packages/people.js} +0 -0
  381. /package/dist/dashboard/{place-map.js → place/map.js} +0 -0
  382. /package/dist/dashboard/{calendar.js → world/days.js} +0 -0
  383. /package/dist/{pictures → helpers}/briefs.d.ts +0 -0
  384. /package/dist/{pictures → helpers}/chosen.d.ts +0 -0
  385. /package/dist/{pictures → helpers}/chosen.js +0 -0
  386. /package/dist/{pictures → helpers}/claude.d.ts +0 -0
  387. /package/dist/{pictures → helpers}/codex.d.ts +0 -0
  388. /package/dist/{pictures → helpers}/stop.d.ts +0 -0
  389. /package/dist/{pictures → helpers}/stop.js +0 -0
  390. /package/dist/{pictures → helpers}/svg.d.ts +0 -0
  391. /package/dist/{pictures → helpers}/svg.js +0 -0
  392. /package/dist/{extensions → packages}/tarball.d.ts +0 -0
  393. /package/dist/{extensions → packages}/tarball.js +0 -0
  394. /package/dist/{bell-listener.d.ts → server/bell-listener.d.ts} +0 -0
  395. /package/dist/{player-acts.d.ts → server/player-acts.d.ts} +0 -0
  396. /package/dist/{player-acts.js → server/player-acts.js} +0 -0
  397. /package/dist/{system-checks.d.ts → testing/system-checks.d.ts} +0 -0
@@ -0,0 +1,419 @@
1
+ // The player's dashboard (D-270, D-272): the MCP server of the chat serves it on localhost. It gives the page what the player may see through the same commands,
2
+ // and tells it when a file of the campaign changes, by whoever, so that it reads again: nothing else goes through the notice, so no secret can.
3
+ import { createServer } from "node:http";
4
+ import { connect } from "node:net";
5
+ import { z } from "zod";
6
+ import { findCampaign } from "../../campaign/index.js";
7
+ import { importShown } from "../../commands/import/import.js";
8
+ import { loadCampaignCode } from "../../commands/shared/packages/code.js";
9
+ import { campaignWidgets, packageWidget } from "../../commands/shared/packages/widgets.js";
10
+ import { pageTranslator } from "../../commands/shared/page-words.js";
11
+ import { view } from "../../commands/view/view.js";
12
+ import { isBoolean } from "../../core/registry.js";
13
+ import { withFiles } from "../../core/store.js";
14
+ import { notationParts } from "../../dice/index.js";
15
+ import { helperCommand, queueInCodex } from "../../helpers/index.js";
16
+ import { loadSystemCode } from "../../systems/index.js";
17
+ import { newActs } from "../player-acts.js";
18
+ import { builtPage, packagePageFile, pageFile, pageHtml, pageModulesOf, pagePolicy, pageWords, securityHeaders, send, sendFile, sendImage, sendJson, sendPacked, sendThemeFile, themeAddress, themeNow, vendorModule } from "./files.js";
19
+ import { act, deliverActs, keepProblems, listenForBell, notes, pageNews, setupWord, story } from "./news.js";
20
+ import { answerAsked, closeCard, listenForChanges, pagePlayer, pageSeen, rollNamesOf, spendShown } from "./player.js";
21
+ import { campaignPorts } from "./ports.js";
22
+ import { addPackage, catalogNow, changeLibrary, changePackage, changeSaves, changeSetting, engineNow, exportCampaign, exportedFile, libraryNow, packagesNow, runForPlayer } from "./writes.js";
23
+ export { campaignPorts, dashboardPorts } from "./ports.js";
24
+ // The commands the page may run: what the player may see, never the master's (VIEW-1). Roles will say more (phase 2).
25
+ const playerCommands = [view];
26
+ // What the page may never ask of these commands: another character's view, which is the character agent's (VIEW-10).
27
+ const masterParameters = ["as"];
28
+ // Changes that come together, as a command writing a page and the log, make one notice.
29
+ const noticeDelay = 100;
30
+ // After the last page closed, how long a question waits for one to come back, as after a reload, before it goes to the form or to words (ASK-1).
31
+ const pageReturn = 5000;
32
+ // How long a question waits on pages that are open but that no one sees, as one in a tab behind, before it goes to the form or to words (D-455).
33
+ const pageHidden = 5000;
34
+ // How often the server looks at an import under way, for the pages to tell how far it is (D-491 (11)).
35
+ const importLookEvery = 2000;
36
+ /** Serves the dashboard of the campaign of context.folder, on 127.0.0.1 only, at the first of the ports that is free; undefined when none is. */
37
+ export async function startDashboard(context, session, options = {}) {
38
+ // The systems' code, when no MCP server loaded it first, as the dashboard served alone (D-448).
39
+ context.systemCode ??= await loadSystemCode(context.systemFolders);
40
+ // And the campaign's extensions', whose hooks are called at once too (D-514).
41
+ await withFiles(session, () => loadCampaignCode(context));
42
+ const root = withFiles(session, () => findCampaign(context.folder)) ?? context.folder;
43
+ for (const port of options.ports ?? campaignPorts(root)) {
44
+ // A port another program answers at, even on ::1 or on every address, is its: a browser asking localhost could reach it instead (D-277).
45
+ if (port !== 0 && await answers(port)) {
46
+ continue;
47
+ }
48
+ const server = createServer();
49
+ const listening = await listen(server, port);
50
+ if (listening !== undefined) {
51
+ const served = {
52
+ port: listening,
53
+ context,
54
+ session,
55
+ page: options.page ?? builtPage,
56
+ pages: new Set(),
57
+ pageReturn: options.pageReturn ?? pageReturn,
58
+ pageHidden: options.pageHidden ?? pageHidden,
59
+ pageIds: new Map(),
60
+ seen: new Map(),
61
+ declined: new Set(),
62
+ changed: new Map(),
63
+ events: [],
64
+ left: new Set(),
65
+ stories: new Map(),
66
+ shared: new Map(),
67
+ notify: () => undefined,
68
+ words: pageTranslator(context, options.page ?? builtPage, () => served.notify()),
69
+ acts: newActs(),
70
+ queue: options.queue ?? codexQueue(),
71
+ };
72
+ return serve(server, served);
73
+ }
74
+ }
75
+ return undefined;
76
+ }
77
+ /** Codex's own queue on this computer, the command looked for once. */
78
+ function codexQueue() {
79
+ let found;
80
+ return { ready: () => (found ??= helperCommand("codex") !== undefined), send: queueInCodex };
81
+ }
82
+ /** Whether a program answers at a port of this machine, on 127.0.0.1 or on ::1. */
83
+ async function answers(port) {
84
+ const answersAt = (host) => new Promise((done) => {
85
+ const socket = connect({ host, port });
86
+ const end = (answered) => {
87
+ socket.destroy();
88
+ done(answered);
89
+ };
90
+ socket.setTimeout(300, () => end(false));
91
+ socket.once("connect", () => end(true));
92
+ socket.once("error", () => end(false));
93
+ });
94
+ return (await Promise.all(["127.0.0.1", "::1"].map(answersAt))).some((answer) => answer);
95
+ }
96
+ /** The port the server listens on, or undefined when it cannot have this one, as when another program has it. */
97
+ function listen(server, port) {
98
+ return new Promise((done) => {
99
+ server.once("error", () => done(undefined));
100
+ server.listen(port, "127.0.0.1", () => {
101
+ const address = server.address();
102
+ done(typeof address === "object" && address !== null ? address.port : port);
103
+ });
104
+ });
105
+ }
106
+ function serve(server, served) {
107
+ let notice;
108
+ served.notify = () => {
109
+ notice ??= setTimeout(() => {
110
+ notice = undefined;
111
+ served.pages.forEach((page) => page.write("event: changed\ndata: {}\n\n"));
112
+ }, noticeDelay).unref();
113
+ };
114
+ const stopListening = served.session.onChange(() => served.notify());
115
+ // A call of the master that ends leaves the player's sentences said meanwhile for the doorbell, or for Codex's queue (D-495).
116
+ const chat = served.context.chat;
117
+ if (chat !== undefined) {
118
+ chat.afterCall = () => deliverActs(served);
119
+ }
120
+ // An import works in another process, or in the call the master waits on, writing where the session does not watch: its state is looked at now and then,
121
+ // and the pages hear when it changes (D-491 (11)).
122
+ let importSeen = importNow(served);
123
+ const importLook = setInterval(() => {
124
+ const now = importNow(served);
125
+ if (now !== importSeen) {
126
+ importSeen = now;
127
+ served.notify();
128
+ }
129
+ }, importLookEvery);
130
+ importLook.unref();
131
+ server.on("request", (request, response) => {
132
+ answer(request, response, served).catch((error) => {
133
+ send(response, 500, "text/plain; charset=utf-8", error instanceof Error ? error.message : String(error));
134
+ });
135
+ });
136
+ // The server never keeps the process alive, nor does a page that stays open: it ends with the chat (D-270).
137
+ server.unref();
138
+ server.on("connection", (socket) => socket.unref());
139
+ return {
140
+ url: `http://127.0.0.1:${served.port}`,
141
+ player: pagePlayer(served),
142
+ news: (told) => pageNews(served, told),
143
+ close: () => new Promise((done) => {
144
+ stopListening();
145
+ clearInterval(importLook);
146
+ clearTimeout(notice);
147
+ served.asked?.settle("absent");
148
+ served.bell?.end("gone");
149
+ if (chat !== undefined) {
150
+ chat.afterCall = undefined;
151
+ }
152
+ served.pages.forEach((page) => page.end());
153
+ server.close(() => done());
154
+ }),
155
+ };
156
+ }
157
+ /** The import under way as the page tells it, as text to compare; empty without a campaign. */
158
+ function importNow(served) {
159
+ try {
160
+ const root = withFiles(served.session, () => findCampaign(served.context.folder));
161
+ return root === undefined ? "" : JSON.stringify(importShown(root) ?? null);
162
+ }
163
+ catch {
164
+ return "";
165
+ }
166
+ }
167
+ async function answer(request, response, served) {
168
+ // Only the dashboard's own page, at its own address: no other site may read what the player sees, nor a name that leads elsewhere (D-272).
169
+ const own = [`http://localhost:${served.port}`, `http://127.0.0.1:${served.port}`];
170
+ const origin = request.headers.origin;
171
+ // A request another site makes the browser send, as an image's, which carries no origin, says so in Sec-Fetch-Site: never ours, nor the hook's, which sends none.
172
+ const crossSite = request.headers["sec-fetch-site"] === "cross-site";
173
+ if (!own.includes(`http://${request.headers.host ?? ""}`) || (origin !== undefined && !own.includes(origin)) || crossSite) {
174
+ send(response, 403, "text/plain; charset=utf-8", `The dashboard answers only its own page, at http://localhost:${served.port}.`);
175
+ return;
176
+ }
177
+ const url = new URL(request.url ?? "/", own[0]);
178
+ const path = url.pathname;
179
+ // The page answers the master's question with a click, and changes the player's settings: what it sends, and only from itself (D-279, D-341).
180
+ if (request.method === "POST" && path === "/api/run" && origin !== undefined) {
181
+ await runForPlayer(request, response, served);
182
+ return;
183
+ }
184
+ if (request.method === "POST" && path === "/api/answer" && origin !== undefined) {
185
+ await answerAsked(request, response, served);
186
+ return;
187
+ }
188
+ if (path === "/api/act" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
189
+ await act(request, response, served);
190
+ return;
191
+ }
192
+ // Claude Code's hook waits here for the player's next sentence, from this computer (D-495).
193
+ if (request.method === "GET" && path === "/api/bell") {
194
+ listenForBell(request, response, served, url.searchParams.has("probe"));
195
+ return;
196
+ }
197
+ if (request.method === "POST" && path === "/api/card" && origin !== undefined) {
198
+ await closeCard(request, response, served);
199
+ return;
200
+ }
201
+ if (request.method === "POST" && path === "/api/seen" && origin !== undefined) {
202
+ await pageSeen(request, response, served);
203
+ return;
204
+ }
205
+ if (request.method === "POST" && path === "/api/package" && origin !== undefined) {
206
+ await changePackage(request, response, served);
207
+ return;
208
+ }
209
+ if (request.method === "POST" && path === "/api/library" && origin !== undefined) {
210
+ await changeLibrary(request, response, served);
211
+ return;
212
+ }
213
+ // An adventure the player adds from a .zip of their computer, and the campaign exported as one (D-483): files, never code.
214
+ if (request.method === "POST" && path === "/api/add" && origin !== undefined) {
215
+ await addPackage(request, response, served);
216
+ return;
217
+ }
218
+ if (request.method === "POST" && path === "/api/export" && origin !== undefined) {
219
+ await exportCampaign(request, response, served);
220
+ return;
221
+ }
222
+ if (request.method === "POST" && path === "/api/config" && origin !== undefined) {
223
+ await changeSetting(request, response, served);
224
+ return;
225
+ }
226
+ if (path === "/api/notes" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
227
+ await notes(request, response, served);
228
+ return;
229
+ }
230
+ if (path === "/api/story" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
231
+ await story(request, response, served);
232
+ return;
233
+ }
234
+ if (request.method === "POST" && path === "/api/setup" && origin !== undefined) {
235
+ await setupWord(request, response, served);
236
+ return;
237
+ }
238
+ if (request.method === "POST" && path === "/api/saves" && origin !== undefined) {
239
+ await changeSaves(request, response, served);
240
+ return;
241
+ }
242
+ if (path === "/api/words" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
243
+ await pageWords(request, response, served, url);
244
+ return;
245
+ }
246
+ // rpg-engine itself (D-515 (3)): what it is and what npm has, for the page; its update, from the page alone, never by the master.
247
+ if (path === "/api/engine" && (request.method === "GET" || (request.method === "POST" && origin !== undefined))) {
248
+ await engineNow(request, response, served);
249
+ return;
250
+ }
251
+ if (request.method !== "GET" && request.method !== "HEAD") {
252
+ send(response, 405, "text/plain; charset=utf-8", "The dashboard only gives what the player may see, and takes a click on what the master asks, the player's settings and their saves.");
253
+ return;
254
+ }
255
+ if (path === "/api/asked") {
256
+ const asked = served.asked;
257
+ // Each button's dice, for the page to say in words in its tooltip: the notation at a check's end, as "(2d20kh1+5)" (D-297).
258
+ const words = asked?.labels.map((label) => notationParts(/\(([^()]+)\)$/.exec(label)?.[1] ?? "") ?? null);
259
+ // And the name the game gives its roll, in the campaign's language, as "with advantage" (D-399).
260
+ const names = asked === undefined ? undefined : rollNamesOf(asked.labels, served);
261
+ // Whose roll it is, always, for the page to show who is asked (D-480 (7)); the fields of the sheet only when a check rolls one.
262
+ const rows = asked?.rows === undefined ? {} : { who: asked.rows.who, ...(asked.rows.fields.some((field) => field !== null) ? { fields: asked.rows.fields } : {}) };
263
+ // The dice of a rest as they are now, read again at each look (ASK-14).
264
+ const spend = asked?.spending === undefined ? undefined : spendShown(asked.spending, served);
265
+ sendJson(response, 200, {
266
+ // How the card of a package's last question was left, while no other question is asked (D-507).
267
+ ...(asked === undefined && served.card !== undefined ? { card: served.card } : {}),
268
+ asked: asked === undefined
269
+ ? null
270
+ : {
271
+ id: asked.id,
272
+ question: asked.question,
273
+ title: asked.title,
274
+ labels: asked.labels,
275
+ words,
276
+ names,
277
+ ...rows,
278
+ ...(asked.rows?.forced === true ? { forced: true } : {}),
279
+ ...(asked.rows?.toss === true ? { toss: true } : {}),
280
+ ...(asked.rows?.buttons === undefined ? {} : { buttons: asked.rows.buttons }),
281
+ ...(asked.rows?.rule === undefined ? {} : { rule: asked.rows.rule }),
282
+ // Its card, or that one comes, until its widget answers: the page waits for it rather than show the question twice (D-507).
283
+ ...(asked.card !== undefined ? { card: asked.card } : asked.rows?.card === undefined ? {} : { card: { widget: asked.rows.card.widget, key: asked.rows.card.key, coming: true } }),
284
+ ...(asked.square ? { square: true } : {}),
285
+ ...(spend === undefined ? {} : { who: spend.who, spend }),
286
+ },
287
+ });
288
+ return;
289
+ }
290
+ if (path === "/api/packages") {
291
+ await packagesNow(response, served, url.searchParams.get("npm") === "true");
292
+ return;
293
+ }
294
+ if (path === "/api/theme") {
295
+ await themeNow(response, served);
296
+ return;
297
+ }
298
+ if (path === "/api/modules") {
299
+ const root = findCampaign(served.context.folder);
300
+ await served.session.ready();
301
+ const modules = root === undefined ? [] : withFiles(served.session, () => pageModulesOf(root, served));
302
+ sendJson(response, 200, { modules: modules.map((one) => ({ package: one.package, kind: one.kind, version: one.version, address: one.address, figures: one.figures, ...(one.words === undefined ? {} : { words: one.words }) })) });
303
+ return;
304
+ }
305
+ if (path === "/api/widgets") {
306
+ await widgetsNow(response, served);
307
+ return;
308
+ }
309
+ if (path === "/api/widget") {
310
+ await widgetForCard(response, served, url.searchParams);
311
+ return;
312
+ }
313
+ if (path === "/api/library") {
314
+ await libraryNow(response, served);
315
+ return;
316
+ }
317
+ if (path === "/api/catalog") {
318
+ await catalogNow(response, served, url.searchParams.get("fresh") === "true");
319
+ return;
320
+ }
321
+ if (path === "/api/export") {
322
+ exportedFile(response, served, url.searchParams.get("file") ?? "");
323
+ return;
324
+ }
325
+ if (path === "/") {
326
+ send(response, 200, "text/html; charset=utf-8", pageHtml, pagePolicy);
327
+ }
328
+ else if (path === "/favicon.ico") {
329
+ // Browsers ask for it by themselves; the page's icon comes with its logo.
330
+ response.writeHead(204, securityHeaders).end();
331
+ }
332
+ else if (path === "/events") {
333
+ listenForChanges(request, response, served);
334
+ }
335
+ else if (path.startsWith("/api/")) {
336
+ await runCommand(path.slice("/api/".length), url.searchParams, response, served);
337
+ }
338
+ else if (path.startsWith("/images/")) {
339
+ sendImage(path.slice("/images/".length), request, response, served);
340
+ }
341
+ else if (sendPacked(path, response, served)) {
342
+ // A language package's phrases or Guide, before the page's own (D-485 (3)).
343
+ }
344
+ else if (path.startsWith(`${themeAddress}/`)) {
345
+ await sendThemeFile(path.slice(themeAddress.length + 1), url.searchParams, request, response, served);
346
+ }
347
+ else if (path.startsWith("/vendor/")) {
348
+ sendFile(vendorModule(path.slice("/vendor/".length)), path, request, response, served);
349
+ }
350
+ else if (path.startsWith("/pkg/")) {
351
+ sendFile(packagePageFile(path.slice("/pkg/".length), served), path, request, response, served);
352
+ }
353
+ else {
354
+ sendFile(pageFile(served.page, path), path, request, response, served);
355
+ }
356
+ }
357
+ /** Runs a command the page may run, with its parameters from the query, as the MCP server runs a tool; its result, or the error, in JSON. */
358
+ async function runCommand(name, parameters, response, served) {
359
+ const command = playerCommands.find((candidate) => candidate.name === name);
360
+ if (command === undefined) {
361
+ sendJson(response, 404, { error: `The dashboard has no command ${name}: it has ${playerCommands.map((candidate) => candidate.name).join(", ")}.` });
362
+ return;
363
+ }
364
+ const masters = [...parameters.keys()].filter((key) => masterParameters.includes(key));
365
+ if (masters.length > 0) {
366
+ sendJson(response, 400, { error: `The dashboard gives only what the player may see: ${masters.join(", ")} is the master's.` });
367
+ return;
368
+ }
369
+ // A flag of the command comes in the address as true or false, as view's map.
370
+ const shape = command.input.shape;
371
+ const given = [...parameters].map(([name, value]) => [name, shape[name] !== undefined && isBoolean(shape[name]) ? value === "true" : value]);
372
+ const parsed = command.input.strict().safeParse(Object.fromEntries(given));
373
+ if (!parsed.success) {
374
+ sendJson(response, 400, { error: z.prettifyError(parsed.error) });
375
+ return;
376
+ }
377
+ try {
378
+ await served.session.ready();
379
+ const result = await command.run(parsed.data, served.context);
380
+ keepProblems(served, result);
381
+ sendJson(response, 200, isSetup(result) ? { ...result, left: result.questions.filter((question) => served.left.has(question.name) && question.value === undefined && question.items === undefined).map((question) => question.name) } : result);
382
+ }
383
+ catch (error) {
384
+ sendJson(response, 400, { error: error instanceof Error ? error.message : String(error) });
385
+ }
386
+ }
387
+ /** Whether a command's result is the setup, as view gives it with setup. */
388
+ function isSetup(result) {
389
+ return typeof result === "object" && result !== null && result.kind === "setup";
390
+ }
391
+ /** What one widget of a package shows for a card or a page of its page code, for the character it shows (D-514): its data, or nothing. */
392
+ async function widgetForCard(response, served, query) {
393
+ const [owner, name, who] = [query.get("package") ?? "", query.get("widget") ?? "", query.get("who") ?? undefined];
394
+ try {
395
+ await served.session.ready();
396
+ const shows = await withFiles(served.session, async () => {
397
+ const root = findCampaign(served.context.folder);
398
+ return root === undefined ? undefined : await packageWidget(root, served.context, owner, name, who === "" ? undefined : who);
399
+ });
400
+ sendJson(response, 200, shows === undefined ? {} : { shows });
401
+ }
402
+ catch (error) {
403
+ sendJson(response, 400, { error: error instanceof Error ? error.message : String(error) });
404
+ }
405
+ }
406
+ /** The widgets of the campaign's extensions as the page shows them (D-502): where each stands, and what it shows now; none without a campaign. */
407
+ async function widgetsNow(response, served) {
408
+ try {
409
+ await served.session.ready();
410
+ const widgets = await withFiles(served.session, async () => {
411
+ const root = findCampaign(served.context.folder);
412
+ return root === undefined ? [] : await campaignWidgets(root, served.context);
413
+ });
414
+ sendJson(response, 200, { widgets });
415
+ }
416
+ catch (error) {
417
+ sendJson(response, 400, { error: error instanceof Error ? error.message : String(error) });
418
+ }
419
+ }
@@ -0,0 +1,39 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { Served } from "./index.ts";
3
+ /** What the master hears of what the player did on the page since their last call: the saves, in order, then the settings; all given back when the call never answers. */
4
+ export declare function pageNews(served: Served, told?: Set<string>): {
5
+ lines: string[];
6
+ restore(): void;
7
+ };
8
+ /**
9
+ * The player's notes (D-371): read, written, taken away, shared with the master, or taken back while the master has not heard it yet (D-381); they stay outside
10
+ * the game, and the master's tools never read them. A note written again or taken away is no longer shared.
11
+ */
12
+ export declare function notes(request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
13
+ /**
14
+ * The player character's story in the player's words, as a proposal (D-373, D-386): the master hears it quoted at their next call and writes it in the page in
15
+ * their own words, with the player's yes; until then the page shows it as sent. GET gives the proposal still waiting, none once the master wrote the story.
16
+ */
17
+ export declare function story(request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
18
+ /**
19
+ * The player's word in the setup (D-370): a choice they leave to the master, or that they made their choices and are ready; the master hears it at their next
20
+ * call, and nothing is written.
21
+ */
22
+ export declare function setupWord(request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
23
+ /**
24
+ * A sentence the player says on the page, in their own words (D-493 (1), D-495): it waits for the master's next call, at once with the doorbell or Codex's queue,
25
+ * or is taken back while the master has not heard it. GET gives those waiting, those heard lately, and whether this chat has a doorbell.
26
+ */
27
+ export declare function act(request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
28
+ /**
29
+ * Brings the sentences waiting to the master while no call of theirs runs, which would take them at its head (D-495): into Codex's queue, as the player's own
30
+ * messages, else by Claude Code's doorbell. Every ring comes from a sentence the player said, never from time.
31
+ */
32
+ export declare function deliverActs(served: Served): void;
33
+ /**
34
+ * Claude Code's doorbell (D-495): the hook of the chat that ended its turn waits here, one at a time, and hears "ring" when the player says a sentence, or one
35
+ * already waits. With probe, the chat's session and campaign, for the hook to find its own server.
36
+ */
37
+ export declare function listenForBell(request: IncomingMessage, response: ServerResponse, served: Served, probe: boolean): void;
38
+ /** How many problems the page shows the player, as view's overview counts them: the master hears of them at their next call. */
39
+ export declare function keepProblems(served: Served, result: unknown): void;