rpg-engine 0.19.1 → 0.21.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 (229) hide show
  1. package/README.md +9 -6
  2. package/dist/adventures/index.d.ts +1 -1
  3. package/dist/adventures/index.js +1 -1
  4. package/dist/adventures/source.d.ts +3 -0
  5. package/dist/adventures/source.js +11 -49
  6. package/dist/campaign/create-campaign.d.ts +1 -1
  7. package/dist/campaign/create-campaign.js +4 -3
  8. package/dist/campaign/find-campaign.d.ts +6 -0
  9. package/dist/campaign/find-campaign.js +7 -1
  10. package/dist/campaign/host-files.js +22 -0
  11. package/dist/campaign/index.d.ts +2 -2
  12. package/dist/campaign/index.js +2 -2
  13. package/dist/campaign/last-choices.d.ts +10 -4
  14. package/dist/campaign/last-choices.js +43 -17
  15. package/dist/campaign/settings.d.ts +10 -2
  16. package/dist/campaign/settings.js +32 -8
  17. package/dist/chats/chat.d.ts +33 -0
  18. package/dist/chats/chat.js +50 -0
  19. package/dist/chats/claude-code.d.ts +5 -0
  20. package/dist/chats/claude-code.js +39 -0
  21. package/dist/chats/codex.d.ts +3 -0
  22. package/dist/chats/codex.js +42 -0
  23. package/dist/chats/index.d.ts +5 -0
  24. package/dist/chats/index.js +12 -0
  25. package/dist/chats/keep.d.ts +10 -0
  26. package/dist/chats/keep.js +50 -0
  27. package/dist/chats/read.d.ts +8 -0
  28. package/dist/chats/read.js +46 -0
  29. package/dist/cli/cli.js +6 -1
  30. package/dist/cli/command-line.js +3 -2
  31. package/dist/commands/book.d.ts +36 -0
  32. package/dist/commands/book.js +129 -0
  33. package/dist/commands/chats.d.ts +38 -0
  34. package/dist/commands/chats.js +93 -0
  35. package/dist/commands/config/config.js +2 -2
  36. package/dist/commands/config/dashboard.d.ts +8 -1
  37. package/dist/commands/config/dashboard.js +70 -16
  38. package/dist/commands/config/words.d.ts +1 -1
  39. package/dist/commands/config/words.js +18 -5
  40. package/dist/commands/find.js +1 -1
  41. package/dist/commands/image.d.ts +14 -0
  42. package/dist/commands/image.js +100 -20
  43. package/dist/commands/index.js +4 -0
  44. package/dist/commands/init.js +3 -3
  45. package/dist/commands/package/data.d.ts +35 -0
  46. package/dist/commands/package/data.js +117 -0
  47. package/dist/commands/package/here.d.ts +7 -2
  48. package/dist/commands/package/here.js +23 -11
  49. package/dist/commands/package/install.js +14 -15
  50. package/dist/commands/package/language.d.ts +15 -0
  51. package/dist/commands/package/language.js +109 -0
  52. package/dist/commands/package/package.js +20 -10
  53. package/dist/commands/package/result.d.ts +19 -0
  54. package/dist/commands/package/theme.d.ts +13 -0
  55. package/dist/commands/package/theme.js +66 -0
  56. package/dist/commands/package/uninstall.d.ts +4 -1
  57. package/dist/commands/package/uninstall.js +29 -9
  58. package/dist/commands/scene/close.d.ts +2 -0
  59. package/dist/commands/scene/close.js +20 -2
  60. package/dist/commands/scene/result.d.ts +2 -0
  61. package/dist/commands/scene/scene.d.ts +2 -0
  62. package/dist/commands/shared/books/adventures.d.ts +0 -4
  63. package/dist/commands/shared/books/adventures.js +2 -31
  64. package/dist/commands/shared/books/words.js +3 -2
  65. package/dist/commands/shared/campaign/book.d.ts +42 -0
  66. package/dist/commands/shared/campaign/book.js +118 -0
  67. package/dist/commands/shared/campaign/chats.d.ts +11 -0
  68. package/dist/commands/shared/campaign/chats.js +29 -0
  69. package/dist/commands/shared/campaign/images.js +7 -1
  70. package/dist/commands/shared/campaign/mode.js +3 -1
  71. package/dist/commands/shared/campaign/saves.js +13 -5
  72. package/dist/commands/shared/campaign/world.js +2 -1
  73. package/dist/commands/shared/packages/catalog.d.ts +3 -3
  74. package/dist/commands/shared/packages/catalog.js +98 -42
  75. package/dist/commands/shared/packages/unpacked.d.ts +50 -0
  76. package/dist/commands/shared/packages/unpacked.js +146 -0
  77. package/dist/commands/shared/sheet/sheet.d.ts +7 -0
  78. package/dist/commands/shared/sheet/sheet.js +27 -0
  79. package/dist/commands/status.d.ts +1 -0
  80. package/dist/commands/status.js +4 -0
  81. package/dist/commands/view/page.js +4 -3
  82. package/dist/commands/view/result.d.ts +2 -0
  83. package/dist/commands/view/view.d.ts +1 -0
  84. package/dist/commands/view/view.js +4 -0
  85. package/dist/core/archive.d.ts +13 -0
  86. package/dist/core/archive.js +76 -0
  87. package/dist/core/consents.d.ts +2 -2
  88. package/dist/core/consents.js +3 -3
  89. package/dist/core/context.d.ts +40 -2
  90. package/dist/core/context.js +1 -0
  91. package/dist/core/download.js +1 -1
  92. package/dist/core/store.d.ts +5 -1
  93. package/dist/core/store.js +15 -2
  94. package/dist/dashboard/acts/names.js +10 -5
  95. package/dist/dashboard/acts/sending.js +5 -2
  96. package/dist/dashboard/acts/sheet.js +66 -15
  97. package/dist/dashboard/api.js +27 -4
  98. package/dist/dashboard/app.js +9 -4
  99. package/dist/dashboard/guide/ar.md +16 -15
  100. package/dist/dashboard/guide/cs.md +15 -14
  101. package/dist/dashboard/guide/da.md +17 -16
  102. package/dist/dashboard/guide/de.md +17 -16
  103. package/dist/dashboard/guide/el.md +17 -16
  104. package/dist/dashboard/guide/en.md +14 -13
  105. package/dist/dashboard/guide/es.md +15 -14
  106. package/dist/dashboard/guide/fi.md +15 -14
  107. package/dist/dashboard/guide/fr.md +20 -19
  108. package/dist/dashboard/guide/he.md +15 -14
  109. package/dist/dashboard/guide/hi.md +15 -14
  110. package/dist/dashboard/guide/hu.md +19 -18
  111. package/dist/dashboard/guide/is.md +15 -14
  112. package/dist/dashboard/guide/it.md +18 -17
  113. package/dist/dashboard/guide/ja.md +15 -14
  114. package/dist/dashboard/guide/ko.md +16 -15
  115. package/dist/dashboard/guide/nb.md +17 -16
  116. package/dist/dashboard/guide/nl.md +15 -14
  117. package/dist/dashboard/guide/pl.md +16 -15
  118. package/dist/dashboard/guide/pt.md +16 -15
  119. package/dist/dashboard/guide/ro.md +15 -14
  120. package/dist/dashboard/guide/ru.md +16 -15
  121. package/dist/dashboard/guide/sv.md +15 -14
  122. package/dist/dashboard/guide/tr.md +18 -17
  123. package/dist/dashboard/guide/uk.md +19 -18
  124. package/dist/dashboard/guide/zh.md +16 -15
  125. package/dist/dashboard/i18n/ar.json +63 -9
  126. package/dist/dashboard/i18n/cs.json +63 -9
  127. package/dist/dashboard/i18n/da.json +63 -9
  128. package/dist/dashboard/i18n/de.json +63 -9
  129. package/dist/dashboard/i18n/el.json +63 -9
  130. package/dist/dashboard/i18n/es.json +63 -9
  131. package/dist/dashboard/i18n/fi.json +63 -9
  132. package/dist/dashboard/i18n/fr.json +63 -9
  133. package/dist/dashboard/i18n/he.json +63 -9
  134. package/dist/dashboard/i18n/hi.json +63 -9
  135. package/dist/dashboard/i18n/hu.json +63 -9
  136. package/dist/dashboard/i18n/is.json +63 -9
  137. package/dist/dashboard/i18n/it.json +64 -10
  138. package/dist/dashboard/i18n/ja.json +63 -9
  139. package/dist/dashboard/i18n/ko.json +63 -9
  140. package/dist/dashboard/i18n/nb.json +63 -9
  141. package/dist/dashboard/i18n/nl.json +63 -9
  142. package/dist/dashboard/i18n/pl.json +63 -9
  143. package/dist/dashboard/i18n/pt.json +63 -9
  144. package/dist/dashboard/i18n/ro.json +63 -9
  145. package/dist/dashboard/i18n/ru.json +63 -9
  146. package/dist/dashboard/i18n/sv.json +63 -9
  147. package/dist/dashboard/i18n/tr.json +63 -9
  148. package/dist/dashboard/i18n/uk.json +63 -9
  149. package/dist/dashboard/i18n/zh.json +63 -9
  150. package/dist/dashboard/journal/book.js +107 -0
  151. package/dist/dashboard/journal/journal.js +16 -12
  152. package/dist/dashboard/kit.js +1 -1
  153. package/dist/dashboard/packages/catalog.js +31 -14
  154. package/dist/dashboard/packages/engine.js +46 -2
  155. package/dist/dashboard/packages/installed.js +13 -0
  156. package/dist/dashboard/packages/outcomes.js +21 -0
  157. package/dist/dashboard/packages/packages.js +41 -18
  158. package/dist/dashboard/packages/rows.js +3 -1
  159. package/dist/dashboard/parts/icons.js +3 -0
  160. package/dist/dashboard/parts/labels.js +6 -0
  161. package/dist/dashboard/parts/picture.js +89 -0
  162. package/dist/dashboard/parts/refusals.js +8 -1
  163. package/dist/dashboard/parts/widgets.js +3 -2
  164. package/dist/dashboard/place/view.js +1 -1
  165. package/dist/dashboard/play/scene.js +8 -5
  166. package/dist/dashboard/settings/settings.js +32 -16
  167. package/dist/dashboard/settings/setup.js +5 -3
  168. package/dist/dashboard/sheet/party.js +5 -2
  169. package/dist/dashboard/sheet/sheet.js +10 -6
  170. package/dist/dashboard/shell/notices.js +2 -2
  171. package/dist/dashboard/shell/system-style.js +45 -12
  172. package/dist/dashboard/shell/tooltip.js +223 -0
  173. package/dist/dashboard/style.css +775 -261
  174. package/dist/dashboard/world/calendar.js +1 -1
  175. package/dist/dashboard/world/lore.js +5 -4
  176. package/dist/dashboard/world/place-card.js +2 -1
  177. package/dist/helpers/briefs.d.ts +5 -0
  178. package/dist/helpers/briefs.js +8 -0
  179. package/dist/helpers/chosen.d.ts +8 -2
  180. package/dist/helpers/chosen.js +110 -6
  181. package/dist/helpers/codex.js +2 -1
  182. package/dist/helpers/index.d.ts +2 -2
  183. package/dist/helpers/index.js +2 -2
  184. package/dist/images/images.d.ts +2 -0
  185. package/dist/images/images.js +16 -2
  186. package/dist/images/index.d.ts +1 -1
  187. package/dist/images/index.js +1 -1
  188. package/dist/languages/index.d.ts +1 -1
  189. package/dist/languages/index.js +1 -1
  190. package/dist/languages/pack.d.ts +4 -1
  191. package/dist/languages/pack.js +16 -5
  192. package/dist/packages/engine.d.ts +7 -0
  193. package/dist/packages/engine.js +32 -1
  194. package/dist/packages/index.d.ts +1 -1
  195. package/dist/packages/index.js +1 -1
  196. package/dist/server/approver.d.ts +6 -0
  197. package/dist/server/approver.js +28 -0
  198. package/dist/server/chats.d.ts +3 -0
  199. package/dist/server/chats.js +27 -0
  200. package/dist/server/dashboard/engine.d.ts +18 -0
  201. package/dist/server/dashboard/engine.js +31 -0
  202. package/dist/server/dashboard/files.d.ts +8 -1
  203. package/dist/server/dashboard/files.js +30 -10
  204. package/dist/server/dashboard/index.d.ts +3 -0
  205. package/dist/server/dashboard/index.js +10 -1
  206. package/dist/server/dashboard/news.js +36 -5
  207. package/dist/server/dashboard/pictures.d.ts +7 -0
  208. package/dist/server/dashboard/pictures.js +62 -0
  209. package/dist/server/dashboard/writes.d.ts +5 -3
  210. package/dist/server/dashboard/writes.js +45 -14
  211. package/dist/server/mcp.js +37 -6
  212. package/dist/server/player-acts.d.ts +7 -2
  213. package/dist/server/player-acts.js +10 -3
  214. package/dist/testing/index.js +1 -0
  215. package/dist/themes/index.d.ts +2 -1
  216. package/dist/themes/index.js +4 -2
  217. package/dist/themes/installed.d.ts +14 -0
  218. package/dist/themes/installed.js +28 -0
  219. package/dist/themes/theme.d.ts +7 -0
  220. package/dist/themes/theme.js +22 -0
  221. package/instructions/core.md +3 -3
  222. package/instructions/dashboard-guide.md +1 -0
  223. package/instructions/mentor-hints.md +1 -1
  224. package/instructions/mentor-tutorial.md +1 -1
  225. package/instructions/party.md +1 -1
  226. package/instructions/play.md +2 -2
  227. package/instructions/start.md +1 -1
  228. package/package.json +2 -2
  229. package/systems/free/instructions/outcomes-told.md +1 -1
@@ -83,7 +83,7 @@ function DayCell({ calendar, day, label, chosen, focusable, onChoose }) {
83
83
  function DayDetails({ calendar, day }) {
84
84
  const marks = dayMarks(calendar, day);
85
85
  const empty = marks.scenes.length === 0 && marks.deadlines.length === 0;
86
- return (_jsxs("div", { class: "calendar-chosen", children: [_jsxs("h4", { class: "calendar-chosen-title", children: [capitalized(dayName(calendar, day)), marks.today && _jsx("span", { class: "eyebrow accent calendar-chosen-now", children: t("Today") })] }), empty && _jsx("p", { class: "browse-none", children: day > (calendar.today ?? 1) ? t("Nothing your character knows of is due on this day.") : t("No scene of the story on this day.") }), !empty && (_jsxs("ul", { class: "calendar-chosen-list", children: [marks.deadlines.map((deadline) => (_jsx("li", { children: _jsxs("a", { class: "calendar-line", href: sectionAddress("journal", "quests"), children: [_jsx(Icon, { name: "hourglass" }), _jsx("span", { children: t("Deadline of {quest}", { quest: isolated(deadline.quest) }) })] }) }, deadline.quest))), marks.scenes.map((scene) => (_jsx("li", { children: _jsxs("a", { class: "calendar-line", href: sectionAddress("journal", "story", String(scene.number)), children: [_jsx(Icon, { name: "journal" }), _jsxs("span", { class: "calendar-scene", children: [_jsxs("span", { children: [_jsx("span", { class: "calendar-chapter", children: t("Chapter {number}", { number: scene.number }) }), ` ${scene.title}`] }), scene.place !== undefined && _jsx("span", { class: "calendar-scene-place", children: scene.place })] })] }) }, scene.number)))] }))] }));
86
+ return (_jsxs("div", { class: "calendar-chosen", children: [_jsxs("h4", { class: "calendar-chosen-title", children: [capitalized(dayName(calendar, day)), marks.today && _jsx("span", { class: "eyebrow accent calendar-chosen-now", children: t("Today") })] }), empty && _jsx("p", { class: "browse-none", children: day > (calendar.today ?? 1) ? t("Nothing your character knows of is due on this day.") : t("No scene of the story on this day.") }), !empty && (_jsxs("ul", { class: "calendar-chosen-list", children: [marks.deadlines.map((deadline) => (_jsx("li", { children: _jsxs("a", { class: "calendar-line", href: sectionAddress("journal", "quests"), children: [_jsx(Icon, { name: "hourglass" }), _jsx("span", { children: t("Deadline of {quest}", { quest: isolated(deadline.quest) }) })] }) }, deadline.quest))), marks.scenes.map((scene) => (_jsx("li", { children: _jsxs("a", { class: "calendar-line", href: sectionAddress("journal", "timeline", String(scene.number)), children: [_jsx(Icon, { name: "journal" }), _jsxs("span", { class: "calendar-scene", children: [_jsxs("span", { children: [_jsx("span", { class: "calendar-chapter", children: t("Chapter {number}", { number: scene.number }) }), ` ${scene.title}`] }), scene.place !== undefined && _jsx("span", { class: "calendar-scene-place", children: scene.place })] })] }) }, scene.number)))] }))] }));
87
87
  }
88
88
  /** A season by its word, after a dot of its colour. */
89
89
  function Season({ season }) {
@@ -7,6 +7,7 @@ import { ChangedLine } from "../parts/changed.js";
7
7
  import { Icon } from "../parts/icons.js";
8
8
  import { placeKindLabel, placeKinds } from "../parts/map-symbols.js";
9
9
  import { knowersOf, Markdown, plainLine } from "../parts/markdown.js";
10
+ import { PictureButton, PictureSpot } from "../parts/picture.js";
10
11
  import { Token } from "../sheet/party.js";
11
12
  import { arrowStep, capitalized, foldedText, t } from "../text.js";
12
13
  import { documentLook, foundLore, groupedLore, knownTo, loreGroupOf } from "./known.js";
@@ -38,7 +39,7 @@ export function LoreTab({ world, version, open, onMap, players = [], kinds = new
38
39
  return (_jsxs(Browse, { open: entry?.name, explicit: asked !== undefined, back: sectionAddress("world", "lore"), backLabel: t("All you know"), children: [_jsxs("div", { class: "browse-list", children: [open !== undefined && asked === undefined && _jsx("p", { class: "browse-none", role: "status", children: t("Your character knows nothing called “{name}”.", { name: open }) }), _jsx("div", { class: "browse-find", children: _jsxs("span", { class: "search", children: [_jsx(Icon, { name: "search" }), _jsx("input", { type: "search", value: search, placeholder: t("Search"), "aria-label": t("Search what your character knows"), onInput: (event) => setSearch(event.currentTarget.value) })] }) }), (groupedLore(world.known).length > 1 || each.length > 0) && (_jsx(FilterChips, { label: t("Kinds"), chosen: shownFilter, onChoose: setFilter, all: found.length, options: [
39
40
  ...groupedLore(found).map((part) => ({ key: part.group, name: groupLabel(part.group), count: part.entries.length })),
40
41
  ...each.map((member) => ({ key: `@${member.name}`, name: member.name, count: found.filter((entry) => knownTo(entry, member.name)).length, member })),
41
- ] })), found.length === 0 && (_jsxs("p", { class: "browse-none", role: "status", children: [t("Nothing your character knows matches “{search}”.", { search }), " ", _jsx("button", { type: "button", class: "button quiet", onClick: () => setSearch(""), children: t("Clear the search") })] })), groups.map((part) => (_jsxs("section", { class: "browse-group", "aria-labelledby": `lore-${part.group}`, children: [_jsxs("h3", { class: "eyebrow", id: `lore-${part.group}`, children: [groupLabel(part.group), _jsx("span", { class: "browse-count num", children: part.entries.length })] }), _jsx("ul", { class: "browse-rows", children: part.entries.map((one, index) => (_jsx("li", { children: _jsxs("a", { class: "browse-row", href: sectionAddress("world", "lore", one.name), "aria-current": one.name === entry?.name ? "true" : undefined, "aria-labelledby": `lore-name-${part.group}-${index}`, "aria-describedby": `lore-${part.group}-${index}`, "data-name": one.name, children: [_jsx(LoreThumb, { entry: one }), _jsxs("span", { class: "browse-words", children: [_jsx("span", { class: "browse-name", id: `lore-name-${part.group}-${index}`, children: one.name }), _jsx("span", { class: "browse-meta", id: `lore-${part.group}-${index}`, children: _jsx(MetaLine, { kind: entryKind(one, kinds), text: plainLine(one.summary) ?? one.within?.[0] }) })] })] }) }, one.name))) })] }, part.group)))] }), entry !== undefined && (_jsx(LoreReader, { entry: entry, version: version, link: link, several: each.length > 0, kinds: kinds, onMap: entry.type === "place" ? onMap([entry.name, ...entry.within ?? []]) : undefined, focus: asked !== undefined }, entry.name))] }));
42
+ ] })), found.length === 0 && (_jsxs("p", { class: "browse-none", role: "status", children: [t("Nothing your character knows matches “{search}”.", { search }), " ", _jsx("button", { type: "button", class: "button quiet", onClick: () => setSearch(""), children: t("Clear the search") })] })), groups.map((part) => (_jsxs("section", { class: "browse-group", "aria-labelledby": `lore-${part.group}`, children: [_jsxs("h3", { class: "eyebrow", id: `lore-${part.group}`, children: [groupLabel(part.group), _jsx("span", { class: "browse-count num", children: part.entries.length })] }), _jsx("ul", { class: "browse-rows", children: part.entries.map((one, index) => (_jsxs("li", { class: "picture-host", children: [_jsxs("a", { class: "browse-row", href: sectionAddress("world", "lore", one.name), "aria-current": one.name === entry?.name ? "true" : undefined, "aria-labelledby": `lore-name-${part.group}-${index}`, "aria-describedby": `lore-${part.group}-${index}`, "data-name": one.name, children: [_jsx(LoreThumb, { entry: one }), _jsxs("span", { class: "browse-words", children: [_jsx("span", { class: "browse-name", id: `lore-name-${part.group}-${index}`, children: one.name }), _jsx("span", { class: "browse-meta", id: `lore-${part.group}-${index}`, children: _jsx(MetaLine, { kind: entryKind(one, kinds), text: plainLine(one.summary) ?? one.within?.[0] }) })] })] }), _jsx(PictureButton, { page: one.name, has: one.picture !== undefined, icon: true, row: true })] }, one.name))) })] }, part.group)))] }), entry !== undefined && (_jsx(LoreReader, { entry: entry, version: version, link: link, several: each.length > 0, kinds: kinds, onMap: entry.type === "place" ? onMap([entry.name, ...entry.within ?? []]) : undefined, focus: asked !== undefined }, entry.name))] }));
42
43
  }
43
44
  /**
44
45
  * The documents the character has or read: those it carries, then the others; the one open on its paper, as what it is. With more than one player character
@@ -133,14 +134,14 @@ function LoreReader({ entry, version, link, onMap, focus, several, kinds }) {
133
134
  useOpened(title, focus);
134
135
  const person = entry.type === "character" || entry.type === "creature";
135
136
  const banner = entry.picture !== undefined && !person;
136
- return (_jsxs("article", { class: "browse-reader", "aria-labelledby": "reader-title", children: [banner && _jsx("img", { class: "reader-banner", src: pictureAddress(entry.picture), alt: "" }), _jsxs("header", { class: "reader-head", children: [person && _jsx(Token, { member: { name: entry.name, image: entry.picture, role: entry.companion ? "companion" : "other" }, large: true, ...(entry.companion ? { side: "ally" } : {}) }), _jsxs("div", { children: [_jsx("p", { class: "eyebrow", children: entryKind(entry, kinds) }), _jsx("h3", { id: "reader-title", tabIndex: -1, ref: title, children: entry.name }), entry.within !== undefined && (_jsxs("p", { class: "reader-where", children: [_jsx(Icon, { name: "place" }), _jsx("span", { class: "reader-path", children: entry.within.toReversed().map((place, index) => (_jsxs("span", { children: [index > 0 && _jsx("span", { class: "reader-step", "aria-hidden": "true" }), _jsx("a", { class: "md-link", href: sectionAddress("world", "lore", place), children: place })] }, place))) })] })), changed && _jsx(ChangedLine, {})] })] }), (onMap !== undefined || entry.companion) && (_jsxs("p", { class: "reader-actions", children: [onMap !== undefined && (_jsxs("a", { class: "button package-button", href: onMap, children: [_jsx(Icon, { name: "world" }), t("Show on the map")] })), entry.companion && (_jsxs("a", { class: "button package-button", href: `#/party/${encodeURIComponent(entry.name)}`, children: [_jsx(Icon, { name: "party" }), t("Open the sheet")] }))] })), _jsxs("div", { class: "reader-text", children: [text === undefined && !problem && entry.summary !== "" && _jsx(Markdown, { text: entry.summary, link: link }), text !== undefined && text.trim() !== "" && _jsx(Markdown, { text: text, link: link, secretKnowers: several ? knowersOf(knowers) : undefined }), ((text !== undefined && text.trim() === "") || (text === undefined && entry.summary === "")) && !problem && (_jsx("p", { class: "browse-none", children: text === undefined ? t("Reading…") : t("Your character knows its name, and nothing more yet.") })), problem && _jsx("p", { class: "browse-none", children: t("This page could not be read now: try again in a moment.") })] })] }));
137
+ return (_jsxs("article", { class: "browse-reader", "aria-labelledby": "reader-title", children: [banner && (_jsxs("div", { class: "picture-host", children: [_jsx("img", { class: "reader-banner", src: pictureAddress(entry.picture), alt: "" }), _jsx(PictureButton, { page: entry.name, has: true, icon: true })] })), _jsxs("header", { class: "reader-head", children: [person && (_jsx(PictureSpot, { page: entry.name, has: entry.picture !== undefined, children: _jsx(Token, { member: { name: entry.name, image: entry.picture, role: entry.companion ? "companion" : "other" }, large: true, ...(entry.companion ? { side: "ally" } : {}) }) })), _jsxs("div", { children: [_jsx("p", { class: "eyebrow", children: entryKind(entry, kinds) }), _jsx("h3", { id: "reader-title", tabIndex: -1, ref: title, children: entry.name }), entry.within !== undefined && (_jsxs("p", { class: "reader-where", children: [_jsx(Icon, { name: "place" }), _jsx("span", { class: "reader-path", children: entry.within.toReversed().map((place, index) => (_jsxs("span", { children: [index > 0 && _jsx("span", { class: "reader-step", "aria-hidden": "true" }), _jsx("a", { class: "md-link", href: sectionAddress("world", "lore", place), children: place })] }, place))) })] })), changed && _jsx(ChangedLine, {})] })] }), _jsxs("p", { class: "reader-actions", children: [onMap !== undefined && (_jsxs("a", { class: "button package-button", href: onMap, children: [_jsx(Icon, { name: "world" }), t("Show on the map")] })), entry.companion && (_jsxs("a", { class: "button package-button", href: `#/party/${encodeURIComponent(entry.name)}`, children: [_jsx(Icon, { name: "party" }), t("Open the sheet")] })), _jsx(PictureButton, { page: entry.name, has: entry.picture !== undefined })] }), _jsxs("div", { class: "reader-text", children: [text === undefined && !problem && entry.summary !== "" && _jsx(Markdown, { text: entry.summary, link: link }), text !== undefined && text.trim() !== "" && _jsx(Markdown, { text: text, link: link, secretKnowers: several ? knowersOf(knowers) : undefined }), ((text !== undefined && text.trim() === "") || (text === undefined && entry.summary === "")) && !problem && (_jsx("p", { class: "browse-none", children: text === undefined ? t("Reading…") : t("Your character knows its name, and nothing more yet.") })), problem && _jsx("p", { class: "browse-none", children: t("This page could not be read now: try again in a moment.") })] })] }));
137
138
  }
138
139
  /** A document on its paper, as what it is: a letter, a notice, a torn page; its picture first, larger at a click, for a map above all. */
139
140
  function DocumentReader({ document, link, focus, several }) {
140
141
  const title = useRef(null);
141
142
  const look = documentLook(document.document);
142
143
  useOpened(title, focus);
143
- return (_jsxs("article", { class: "browse-reader", "aria-labelledby": "reader-title", children: [_jsx("header", { class: "reader-head", children: _jsxs("div", { children: [_jsx("p", { class: "eyebrow", children: [documentLabel(document.document), carriedWords(document, several)].filter((part) => part !== undefined).join(" · ") }), _jsx("h3", { id: "reader-title", tabIndex: -1, ref: title, children: document.name })] }) }), _jsxs("div", { class: `paper look-${look}`, children: [_jsx("span", { class: "paper-mark", "aria-hidden": "true" }), document.picture !== undefined && (_jsx("a", { class: "paper-picture", href: pictureAddress(document.picture), target: "_blank", rel: "noreferrer", children: _jsx("img", { src: pictureAddress(document.picture), alt: t("{name}, as drawn", { name: document.name }) }) })), document.text.trim() !== "" && _jsx(Markdown, { text: document.text, link: link })] })] }));
144
+ return (_jsxs("article", { class: "browse-reader", "aria-labelledby": "reader-title", children: [_jsx("header", { class: "reader-head", children: _jsxs("div", { children: [_jsx("p", { class: "eyebrow", children: [documentLabel(document.document), carriedWords(document, several)].filter((part) => part !== undefined).join(" · ") }), _jsx("h3", { id: "reader-title", tabIndex: -1, ref: title, children: document.name })] }) }), _jsx("p", { class: "reader-actions", children: _jsx(PictureButton, { page: document.name, has: document.picture !== undefined }) }), _jsxs("div", { class: `paper look-${look}`, children: [_jsx("span", { class: "paper-mark", "aria-hidden": "true" }), document.picture !== undefined && (_jsxs("div", { class: "picture-host", children: [_jsx("a", { class: "paper-picture", href: pictureAddress(document.picture), target: "_blank", rel: "noreferrer", children: _jsx("img", { src: pictureAddress(document.picture), alt: t("{name}, as drawn", { name: document.name }) }) }), _jsx(PictureButton, { page: document.name, has: true, icon: true })] })), document.text.trim() !== "" && _jsx(Markdown, { text: document.text, link: link })] })] }));
144
145
  }
145
146
  /** A row of filter chips: All, then each option with its count; one stop of Tab, the arrows along it. */
146
147
  function FilterChips({ label, options, chosen, all, onChoose }) {
@@ -168,7 +169,7 @@ function LoreThumb({ entry }) {
168
169
  return (_jsx("span", { class: "browse-thumb", "aria-hidden": "true", children: _jsx("img", { src: pictureAddress(entry.picture), alt: "", loading: "lazy" }) }));
169
170
  }
170
171
  const kind = entry.kind === undefined ? undefined : placeKinds[entry.kind];
171
- return (_jsx("span", { class: `browse-thumb mark ${loreGroupOf(entry)}`, "aria-hidden": "true", children: kind === undefined ? _jsx("span", { class: "browse-letter", children: [...entry.name][0]?.toUpperCase() }) : (_jsx("svg", { viewBox: "0 0 24 24", children: _jsx("path", { d: kind.glyph }) })) }));
172
+ return (_jsx("span", { class: "browse-thumb", "aria-hidden": "true", children: kind === undefined ? _jsx("span", { class: "browse-letter", children: [...entry.name][0]?.toUpperCase() }) : (_jsx("svg", { viewBox: "0 0 24 24", children: _jsx("path", { d: kind.glyph }) })) }));
172
173
  }
173
174
  /** A document's drawing in its row: an envelope, a nailed sheet, an open book, a map… */
174
175
  function DocumentGlyph({ look }) {
@@ -7,6 +7,7 @@ import { fromLabel } from "../parts/game-words.js";
7
7
  import { Icon } from "../parts/icons.js";
8
8
  import { placeKindLabel } from "../parts/map-symbols.js";
9
9
  import { plainLine } from "../parts/markdown.js";
10
+ import { PictureButton } from "../parts/picture.js";
10
11
  import { t } from "../text.js";
11
12
  import { lengthText, waysOf } from "./map.js";
12
13
  /** The card of a place: its picture, what it is and where, its text as the character knows it, what it holds, its ways, the scene when the party is there. */
@@ -29,7 +30,7 @@ export function PlaceCard({ place, map, layout, narrow, onClose, onGo, readMore
29
30
  };
30
31
  }, [place.name]);
31
32
  const eyebrow = [placeKindLabel(place.kind) ?? t("Place"), region?.name, here || place.from?.direction === undefined ? undefined : t("{distance} from you", { distance: fromLabel(place.from, (km) => lengthText(km, map.unit)) })].filter((part) => part !== undefined);
32
- return (_jsxs("div", { class: narrow ? "place-card sheet" : "place-card", role: "dialog", "aria-labelledby": "place-card-title", onPointerDown: (event) => event.stopPropagation(), onPointerUp: (event) => event.stopPropagation(), children: [place.image !== undefined && _jsx("img", { class: "pc-image", src: pictureAddress(place.image), alt: "" }), _jsx("button", { ref: closer, type: "button", class: "pc-close icon-button", "aria-label": t("Close"), onClick: onClose, children: _jsx(Icon, { name: "close" }) }), _jsxs("div", { class: "pc-body", children: [_jsx("p", { class: "eyebrow pc-eyebrow", children: eyebrow.join(" · ") }), _jsx("h3", { id: "place-card-title", children: place.name }), here && (_jsxs("p", { class: "pc-here", children: [_jsx("span", { class: "here-dot", "aria-hidden": "true" }), t("Your party is here")] })), text !== undefined && _jsx("p", { class: "pc-text", children: text }), readMore !== undefined && _jsx("a", { class: "pc-more md-link", href: readMore, children: t("Read all you know") }), inside.length > 0 && (_jsxs(_Fragment, { children: [_jsx("h4", { class: "eyebrow pc-sub", children: t("Inside") }), _jsx("ul", { class: "in-chips", children: inside.flatMap((child) => [
33
+ return (_jsxs("div", { class: narrow ? "place-card sheet" : "place-card", role: "dialog", "aria-labelledby": "place-card-title", onPointerDown: (event) => event.stopPropagation(), onPointerUp: (event) => event.stopPropagation(), children: [place.image !== undefined && (_jsxs("div", { class: "picture-host", children: [_jsx("img", { class: "pc-image", src: pictureAddress(place.image), alt: "" }), _jsx(PictureButton, { page: place.name, has: true, icon: true })] })), _jsx("button", { ref: closer, type: "button", class: "pc-close icon-button", "aria-label": t("Close"), onClick: onClose, children: _jsx(Icon, { name: "close" }) }), _jsxs("div", { class: "pc-body", children: [_jsx("p", { class: "eyebrow pc-eyebrow", children: eyebrow.join(" · ") }), _jsx("h3", { id: "place-card-title", children: place.name }), here && (_jsxs("p", { class: "pc-here", children: [_jsx("span", { class: "here-dot", "aria-hidden": "true" }), t("Your party is here")] })), text !== undefined && _jsx("p", { class: "pc-text", children: text }), readMore !== undefined && _jsx("a", { class: "pc-more md-link", href: readMore, children: t("Read all you know") }), inside.length > 0 && (_jsxs(_Fragment, { children: [_jsx("h4", { class: "eyebrow pc-sub", children: t("Inside") }), _jsx("ul", { class: "in-chips", children: inside.flatMap((child) => [
33
34
  _jsx("li", { class: "in-chip", children: child.name }, child.name),
34
35
  ...layout.inside(child.name).map((grandchild) => (_jsxs("li", { class: "in-chip", children: [_jsx("span", { class: "in-path", children: "\u203A" }), " ", grandchild.name] }, grandchild.name))),
35
36
  ]) })] })), ways.length > 0 && (_jsxs(_Fragment, { children: [_jsx("h4", { class: "eyebrow pc-sub", children: t("Ways") }), _jsx("ul", { class: "pc-ways", children: ways.map((way, index) => (_jsxs("li", { children: [_jsx(Icon, { name: wayIcon(way.kind) }), _jsxs("span", { children: [_jsx("b", { children: way.road }), ` ${t("to")} `, way.map === undefined || way.to === undefined ? way.to ?? t("somewhere you do not know") : (_jsx("button", { type: "button", class: "way-to-map", onClick: () => onGo(way.map, way.to), children: t("{place}, on {map}", { place: way.to, map: way.map }) })), way.km !== undefined && " · ", way.km !== undefined && _jsx("span", { class: "way-km num", children: lengthText(way.km, map.unit) })] })] }, index))) })] })), here && (_jsxs("a", { class: "pc-scene", href: sectionAddress("scene"), children: [_jsx(Icon, { name: "scene" }), _jsx("span", { children: t("Scene") })] }))] })] }));
@@ -1,4 +1,9 @@
1
1
  import type { PictureSubject } from "../core/context.ts";
2
+ /**
3
+ * The painted brief as the chat makes the picture itself with its own tool (D-390), as Antigravity: saved by the chat, a place 16:9, the widest its tool makes,
4
+ * which the page crops.
5
+ */
6
+ export declare function chatBrief(subject: PictureSubject): string;
2
7
  /** The painted brief of a place's or a quest's picture, a portrait or a creature's head, as Codex makes it. */
3
8
  export declare function paintedBrief(subject: PictureSubject): string;
4
9
  /**
@@ -1,3 +1,10 @@
1
+ /**
2
+ * The painted brief as the chat makes the picture itself with its own tool (D-390), as Antigravity: saved by the chat, a place 16:9, the widest its tool makes,
3
+ * which the page crops.
4
+ */
5
+ export function chatBrief(subject) {
6
+ return paintedBrief(subject).replace(imageAsk, chatAsk).replace("landscape, 21:9", "landscape, 16:9");
7
+ }
1
8
  /** The painted brief of a place's or a quest's picture, a portrait or a creature's head, as Codex makes it. */
2
9
  export function paintedBrief(subject) {
3
10
  if (subject.kind === "portrait") {
@@ -79,6 +86,7 @@ export function creatureBrief(name, seen, unseen = [], who) {
79
86
  // What every brief asks of the helper first, and the style every picture is painted in.
80
87
  const imageAsk = "Use your built-in image generation tool to make exactly one new image from the brief below. Do not copy, save or edit any file and run no commands: "
81
88
  + 'the caller collects the image itself. If you cannot make it, reply with one line saying why; otherwise reply with only "done".';
89
+ const chatAsk = "Make exactly one new image from the brief below with your own image generation tool, as a PNG file.";
82
90
  const paintedStyle = "Style/medium: painterly digital illustration, fantasy concept art, muted natural colours, soft brushwork";
83
91
  // A portrait, a person's or a creature's, as a circle crops it.
84
92
  const faceFraming = "a close-up of the face, centred, from the top of the head to the chin and only a hint of the shoulders, the face filling most of the picture; "
@@ -1,8 +1,14 @@
1
1
  import type { DocumentReader, PictureMaker, TextWriter } from "../core/context.ts";
2
2
  /** The chat whose own pictures are Codex's, as its MCP client names itself. */
3
3
  export declare const codexClient = "codex-mcp-client";
4
- /** The pictures of this computer for the chat `host` names, read when a picture is asked, as the MCP client said it at its start; Codex first, then Claude. */
5
- export declare function hostPictures(host: () => string | undefined, codex?: PictureMaker, claude?: PictureMaker): PictureMaker;
4
+ /** Antigravity's chat, as its MCP client names itself: it makes its pictures itself. */
5
+ export declare const antigravityClient = "antigravity-client";
6
+ /**
7
+ * The pictures of this computer, by the campaign's choice, which `choice` reads when a picture is asked: unset or chat, the chat `host` names, by its own
8
+ * means; codex; elevenlabs, or the name of another image tool of the master's, from the brief. Codex, where it cannot or refuses, leaves the picture to the chat
9
+ * in use; once it refused, it is not asked again while the server lives, until the choice changes.
10
+ */
11
+ export declare function hostPictures(host: () => string | undefined, choice?: () => string | undefined, codex?: PictureMaker, claude?: PictureMaker): PictureMaker;
6
12
  /** The writer of text of this computer for the chat `host` names (D-406), chosen as the pictures are: Codex first, then Claude. */
7
13
  export declare function hostWriter(host: () => string | undefined, codex?: TextWriter, claude?: TextWriter): TextWriter;
8
14
  /** The importer of this computer for the chat `host` names (D-489 (1)): Codex in Codex, else Claude first, which Elena's probe measured, then Codex. */
@@ -1,14 +1,118 @@
1
+ import { chatBrief } from "./briefs.js";
1
2
  import { claudePictures, claudeReader, claudeWriter } from "./claude.js";
2
3
  import { codexPictures, codexReader, codexWriter } from "./codex.js";
3
4
  /** The chat whose own pictures are Codex's, as its MCP client names itself. */
4
5
  export const codexClient = "codex-mcp-client";
5
- /** The pictures of this computer for the chat `host` names, read when a picture is asked, as the MCP client said it at its start; Codex first, then Claude. */
6
- export function hostPictures(host, codex = codexPictures(), claude = claudePictures()) {
7
- const makers = () => (host() === codexClient ? [codex] : [codex, claude]);
8
- const chosen = (again) => makers().find((maker) => maker.ready(again).ready);
6
+ /** Antigravity's chat, as its MCP client names itself: it makes its pictures itself. */
7
+ export const antigravityClient = "antigravity-client";
8
+ /**
9
+ * The pictures of this computer, by the campaign's choice, which `choice` reads when a picture is asked: unset or chat, the chat `host` names, by its own
10
+ * means; codex; elevenlabs, or the name of another image tool of the master's, from the brief. Codex, where it cannot or refuses, leaves the picture to the chat
11
+ * in use; once it refused, it is not asked again while the server lives, until the choice changes.
12
+ */
13
+ export function hostPictures(host, choice = () => undefined, codex = codexPictures(), claude = claudePictures()) {
14
+ let refused;
15
+ let lastChoice;
16
+ // The chat in use, by its own means.
17
+ const chat = () => (host() === codexClient ? codex : host() === antigravityClient ? antigravityPictures : claude);
18
+ // The maker the campaign chose, and whether it is Codex apart from the chat in use, which leaves the picture to it where it cannot.
19
+ const chosen = () => {
20
+ const said = choice()?.trim();
21
+ // The player chose again: Codex is asked again.
22
+ if (said !== lastChoice) {
23
+ refused = undefined;
24
+ lastChoice = said;
25
+ }
26
+ const key = said?.toLowerCase();
27
+ if (key === undefined || key === "" || key === chatChoice) {
28
+ return { maker: chat(), codexApart: false };
29
+ }
30
+ if (key === codexChoice) {
31
+ return { maker: codex, codexApart: chat() !== codex };
32
+ }
33
+ return { maker: key === otherChoice ? unnamedTool : masterTool(key === elevenlabsChoice ? "ElevenLabs" : said ?? ""), codexApart: false };
34
+ };
35
+ // Codex's own answer, or its refusal remembered; in Codex, the chat's own.
36
+ const codexReady = (again) => (refused === undefined ? codex.ready(again) : { ready: false, why: refused });
37
+ const madeInstead = async (subject, instead) => {
38
+ const other = chat();
39
+ if (!other.ready().ready) {
40
+ return { refused: instead.why };
41
+ }
42
+ // A chat that paints itself gets no picture to make after its call answered: the next ones are its own.
43
+ if (other.brief !== undefined) {
44
+ return { refused: `${instead.why}; the next pictures are yours to make with your own image tool` };
45
+ }
46
+ const made = await other.make(subject);
47
+ return "refused" in made ? { refused: `${instead.why}; ${instead.by} made none either: ${made.refused}` } : { ...made, instead };
48
+ };
49
+ const fallbackOf = (said, refusedPicture = refused !== undefined) => {
50
+ const other = chat().ready();
51
+ const by = other.ready ? other.maker : undefined;
52
+ return by === undefined ? undefined : { maker: "Codex", by, why: said.why, ...(said.fix === undefined ? {} : { fix: said.fix }), ...(refusedPicture ? { refused: true } : {}) };
53
+ };
54
+ return {
55
+ ready: (again) => {
56
+ const { maker, codexApart } = chosen();
57
+ if (!codexApart) {
58
+ return maker === codex ? codexReady(again) : maker.ready(again);
59
+ }
60
+ const said = codexReady(again);
61
+ const instead = said.ready ? undefined : fallbackOf(said);
62
+ return said.ready || instead === undefined ? said : { ready: true, maker: instead.by, instead };
63
+ },
64
+ make: async (subject) => {
65
+ const { maker, codexApart } = chosen();
66
+ const said = maker === codex ? codexReady() : maker.ready();
67
+ if (!said.ready) {
68
+ const instead = codexApart ? fallbackOf(said) : undefined;
69
+ return instead === undefined ? { refused: said.why } : madeInstead(subject, instead);
70
+ }
71
+ const made = await maker.make(subject);
72
+ if (!("refused" in made) || maker !== codex) {
73
+ return made;
74
+ }
75
+ // A refusal of this one picture, as the safety check's, leaves Codex asked for the next.
76
+ if (made.onlyThis !== true) {
77
+ refused = made.refused;
78
+ }
79
+ const instead = codexApart ? fallbackOf({ why: made.refused }, true) : undefined;
80
+ return instead === undefined ? made : madeInstead(subject, instead);
81
+ },
82
+ brief: (subject) => {
83
+ const { maker, codexApart } = chosen();
84
+ if (!codexApart) {
85
+ return maker.ready().ready ? maker.brief?.(subject) : undefined;
86
+ }
87
+ // Codex not ready: a chat that paints itself makes it in its place.
88
+ return codexReady().ready ? undefined : chat().brief?.(subject);
89
+ },
90
+ };
91
+ }
92
+ // The values of the campaign's pictures-by setting the engine knows: the chat in use, Codex, ElevenLabs, another tool not named yet; any other names an
93
+ // image tool of the master's.
94
+ const chatChoice = "chat";
95
+ const codexChoice = "codex";
96
+ const elevenlabsChoice = "elevenlabs";
97
+ const otherChoice = "other";
98
+ // Another image tool of the master's, which the player has not named yet: the master asks them which, from the same brief.
99
+ const unnamedTool = {
100
+ ready: () => ({ ready: true, maker: "another tool", askTool: true }),
101
+ make: () => Promise.resolve({ refused: "the master makes the pictures with another tool, which the player has not named yet" }),
102
+ brief: chatBrief,
103
+ };
104
+ // Antigravity paints in its own chat, from the brief the image command gives it: the engine starts nothing.
105
+ const antigravityPictures = {
106
+ ready: () => ({ ready: true, maker: "Antigravity" }),
107
+ make: () => Promise.resolve({ refused: "Antigravity makes its pictures in its own chat" }),
108
+ brief: chatBrief,
109
+ };
110
+ // An image tool of the master's own, by its name, as ElevenLabs's: the same brief, and the engine starts nothing.
111
+ function masterTool(name) {
9
112
  return {
10
- ready: (again) => chosen(again)?.ready(again) ?? codex.ready(again),
11
- make: (subject) => (chosen() ?? codex).make(subject),
113
+ ready: () => ({ ready: true, maker: name, tool: name }),
114
+ make: () => Promise.resolve({ refused: `the master makes the pictures with ${name}` }),
115
+ brief: chatBrief,
12
116
  };
13
117
  }
14
118
  /** The writer of text of this computer for the chat `host` names (D-406), chosen as the pictures are: Codex first, then Claude. */
@@ -102,7 +102,8 @@ function make(subject) {
102
102
  const failed = events.find((event) => event.type === "turn.failed");
103
103
  const said = existsSync(last) ? lastLine(last) : "";
104
104
  clean();
105
- done({ refused: refusal(errors, failed, said) });
105
+ const onlyThis = /moderation_blocked/.test(errors) || (failed === undefined && said === "");
106
+ done({ refused: refusal(errors, failed, said), ...(onlyThis ? { onlyThis: true } : {}) });
106
107
  });
107
108
  child.stdin.end(paintedBrief(subject));
108
109
  });
@@ -1,5 +1,5 @@
1
- export { paintedBrief, svgBrief } from "./briefs.ts";
2
- export { codexClient, hostPictures, hostReader, hostWriter } from "./chosen.ts";
1
+ export { chatBrief, paintedBrief, svgBrief } from "./briefs.ts";
2
+ export { antigravityClient, codexClient, hostPictures, hostReader, hostWriter } from "./chosen.ts";
3
3
  export { claudeSays } from "./claude.ts";
4
4
  export { codexPictures, codexSays } from "./codex.ts";
5
5
  export { computerHelpers, helperChanges, helperCommand, queueInCodex } from "./programs.ts";
@@ -1,7 +1,7 @@
1
1
  // Codex and Claude Code on the player's computer, found, installed and signed in with the player's yes (D-424), and what they do for the game: pictures made
2
2
  // from words (D-308, D-390), Codex's painted else Claude's SVG, the importer's reading and the page's words; injected through Context, so that tests never spend.
3
- export { paintedBrief, svgBrief } from "./briefs.js";
4
- export { codexClient, hostPictures, hostReader, hostWriter } from "./chosen.js";
3
+ export { chatBrief, paintedBrief, svgBrief } from "./briefs.js";
4
+ export { antigravityClient, codexClient, hostPictures, hostReader, hostWriter } from "./chosen.js";
5
5
  export { claudeSays } from "./claude.js";
6
6
  export { codexPictures, codexSays } from "./codex.js";
7
7
  export { computerHelpers, helperChanges, helperCommand, queueInCodex } from "./programs.js";
@@ -14,6 +14,8 @@ export type ReadImage = {
14
14
  };
15
15
  /** Reads the picture at `path`, by what its bytes are rather than by its extension: PNG, JPEG, WebP or SVG, up to largestImage. */
16
16
  export declare function readImage(path: string): ReadImage;
17
+ /** The picture in `bytes`, as a download gives them, by what they are as readImage does; `name` names them in a problem. */
18
+ export declare function imageOfBytes(bytes: Uint8Array, name: string): ReadImage;
17
19
  /** The file named `name` in the images folder of the first of `folders` that has one, looked for in the folders inside it too; undefined when none has it. */
18
20
  export declare function findImage(folders: string[], name: string): string | undefined;
19
21
  /** The file name a page's image field links, such as ettore.webp for [[ettore.webp]]; undefined when the value is not a link. */
@@ -17,14 +17,22 @@ export function readImage(path) {
17
17
  }
18
18
  const extension = imageExtensions.find((candidate) => isFormat[candidate](head));
19
19
  if (extension === undefined) {
20
- return { problem: `${basename(path)} is not a PNG, JPEG, WebP or SVG picture: convert it to one of those, or give another file.` };
20
+ return { problem: notPicture(basename(path)) };
21
21
  }
22
22
  if (size !== undefined && size > largestImage) {
23
- return { problem: `${basename(path)} is ${megabytes(size)} MB, and a picture can be ${megabytes(largestImage)} MB at most: make it smaller (512 pixels a side are enough).` };
23
+ return { problem: tooLarge(basename(path), size) };
24
24
  }
25
25
  const bytes = files().bytes(path);
26
26
  return bytes === undefined ? { problem: `There is no file at ${path}: give the full path of the picture.` } : { bytes, extension };
27
27
  }
28
+ /** The picture in `bytes`, as a download gives them, by what they are as readImage does; `name` names them in a problem. */
29
+ export function imageOfBytes(bytes, name) {
30
+ const extension = imageExtensions.find((candidate) => isFormat[candidate](bytes));
31
+ if (extension === undefined) {
32
+ return { problem: notPicture(name) };
33
+ }
34
+ return bytes.length > largestImage ? { problem: tooLarge(name, bytes.length) } : { bytes, extension };
35
+ }
28
36
  /** The file named `name` in the images folder of the first of `folders` that has one, looked for in the folders inside it too; undefined when none has it. */
29
37
  export function findImage(folders, name) {
30
38
  const wanted = name.toLowerCase();
@@ -74,6 +82,12 @@ function startsWith(bytes, prefix) {
74
82
  function ascii(bytes, start, end) {
75
83
  return String.fromCharCode(...bytes.subarray(start, end));
76
84
  }
85
+ function notPicture(name) {
86
+ return `${name} is not a PNG, JPEG, WebP or SVG picture: convert it to one of those, or give another file.`;
87
+ }
88
+ function tooLarge(name, size) {
89
+ return `${name} is ${megabytes(size)} MB, and a picture can be ${megabytes(largestImage)} MB at most: make it smaller (512 pixels a side are enough).`;
90
+ }
77
91
  function megabytes(size) {
78
92
  return (size / 1024 / 1024).toFixed(1).replace(/\.0$/, "");
79
93
  }
@@ -1 +1 @@
1
- export { findHiddenImage, findImage, hiddenImageName, type ImageExtension, imageFileName, imageLink, imagesFolderName, largestImage, type ReadImage, readImage } from "./images.ts";
1
+ export { findHiddenImage, findImage, hiddenImageName, type ImageExtension, imageFileName, imageLink, imageOfBytes, imagesFolderName, largestImage, type ReadImage, readImage } from "./images.ts";
@@ -1,2 +1,2 @@
1
1
  // Pictures of pages: the formats a picture can have, and where the file a page links is (D-267). It knows no game.
2
- export { findHiddenImage, findImage, hiddenImageName, imageFileName, imageLink, imagesFolderName, largestImage, readImage } from "./images.js";
2
+ export { findHiddenImage, findImage, hiddenImageName, imageFileName, imageLink, imageOfBytes, imagesFolderName, largestImage, readImage } from "./images.js";
@@ -1 +1 @@
1
- export { installedLanguages, type LanguagePack, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./pack.ts";
1
+ export { installedLanguages, languageFileName, type LanguagePack, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./pack.ts";
@@ -1,3 +1,3 @@
1
1
  // Languages as packages (D-485 (3)): a translation made by hand of the dashboard's phrases, its Guide and a game system's words, which comes before the
2
2
  // translation on the fly. Depends on nothing else in rpg-engine but the core.
3
- export { installedLanguages, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./pack.js";
3
+ export { installedLanguages, languageFileName, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./pack.js";
@@ -14,7 +14,10 @@ export interface LanguagePack {
14
14
  export declare function installedLanguages(folders: string[]): LanguagePack[];
15
15
  /** The package for a language: its own code, else its base language's (pt for pt-BR); undefined when none is installed. */
16
16
  export declare function languagePackFor(folders: string[], code: string): LanguagePack | undefined;
17
- /** A language package from its folder; it throws, saying what is wrong, when it does not read. */
17
+ /**
18
+ * A language package from its folder; it throws, saying what is wrong, when it does not read. One of data alone, without a package.json, is named by its
19
+ * code, language-de, with the version its language.yaml gives.
20
+ */
18
21
  export declare function readLanguagePack(folder: string): LanguagePack;
19
22
  /** The dashboard's phrases the package translates, by their English; none when it has none that reads. */
20
23
  export declare function packPhrases(pack: LanguagePack): Record<string, string>;
@@ -1,4 +1,4 @@
1
- import { join } from "node:path";
1
+ import { basename, join } from "node:path";
2
2
  import { z } from "zod";
3
3
  import { packageFoldersIn } from "../core/files.js";
4
4
  import { codeAndBase } from "../core/language.js";
@@ -11,6 +11,8 @@ const languageSchema = z.object({
11
11
  code: z.string().regex(codePattern, "a language's code, such as de or pt-PT").refine((code) => code.split("-")[0] !== "en", "English is the page's own"),
12
12
  name: z.string().trim().min(1),
13
13
  engine: z.string().optional(),
14
+ // Its version, for a package of data alone, which has no package.json to say it.
15
+ version: z.union([z.string(), z.number()]).transform(String).optional(),
14
16
  }).strict();
15
17
  const phrasesSchema = z.record(z.string(), z.string());
16
18
  // Characters that turn the order of a text, which could make it read otherwise than it is.
@@ -36,14 +38,23 @@ export function languagePackFor(folders, code) {
36
38
  const packs = installedLanguages(folders);
37
39
  return codeAndBase(code).map((wanted) => packs.find((pack) => pack.code.toLowerCase() === wanted)).find((pack) => pack !== undefined);
38
40
  }
39
- /** A language package from its folder; it throws, saying what is wrong, when it does not read. */
41
+ /**
42
+ * A language package from its folder; it throws, saying what is wrong, when it does not read. One of data alone, without a package.json, is named by its
43
+ * code, language-de, with the version its language.yaml gives.
44
+ */
40
45
  export function readLanguagePack(folder) {
41
46
  const manifest = JSON.parse(files().text(join(folder, "package.json")) ?? "{}");
42
47
  const read = languageSchema.safeParse(readYamlValues(join(folder, languageFileName), 'a language package\'s code and name, such as "code: de"'));
43
48
  if (!read.success) {
44
49
  throw new Error(`${join(folder, languageFileName)}: ${read.error.issues.map((issue) => `${issue.path.join(".")}: ${issue.message}`).join("; ")}.`);
45
50
  }
46
- return { package: String(manifest.name ?? ""), version: String(manifest.version ?? ""), folder, code: read.data.code, name: read.data.name };
51
+ return {
52
+ package: String(manifest.name ?? `language-${read.data.code}`),
53
+ version: String(manifest.version ?? read.data.version ?? ""),
54
+ folder,
55
+ code: read.data.code,
56
+ name: read.data.name,
57
+ };
47
58
  }
48
59
  /** The dashboard's phrases the package translates, by their English; none when it has none that reads. */
49
60
  export function packPhrases(pack) {
@@ -83,9 +94,9 @@ export function languagePackProblems(pack, english) {
83
94
  }
84
95
  return { problems: problems.slice(0, 10), missing: english.filter((phrase) => !(phrase in phrases)).length };
85
96
  }
86
- /** The folders of packages with a language.yaml in these folders, and in their scopes' folders. */
97
+ /** The folders of packages with a language.yaml in these folders, and in their scopes' folders; never one being unpacked, whose name starts with a dot. */
87
98
  function packageFolders(folders) {
88
- return packageFoldersIn(folders).filter((candidate) => files().exists(join(candidate, languageFileName)));
99
+ return packageFoldersIn(folders).filter((candidate) => !basename(candidate).startsWith(".") && files().exists(join(candidate, languageFileName)));
89
100
  }
90
101
  /** The package's phrases.json as JSON: undefined when it has none, the error when it does not read. */
91
102
  function phrasesJson(pack) {
@@ -2,3 +2,10 @@ import type { EngineUpdater } from "../core/context.ts";
2
2
  import { type NpmRun } from "./npm.ts";
3
3
  /** rpg-engine on npm, for the engine in this folder, from src/ and dist/ alike its package's own; `run` runs npm, a fake in tests. */
4
4
  export declare function npmEngine(folder?: string, run?: (args: string) => Promise<NpmRun>): EngineUpdater;
5
+ /** npm's latest rpg-engine as checked today and kept in the player's folder; none when older, from the future or unreadable. */
6
+ export declare function keptLatestEngine(home: string | undefined, now: number): {
7
+ checked: number;
8
+ version: string;
9
+ } | undefined;
10
+ /** Keeps npm's latest rpg-engine in the player's folder; a folder that cannot be written only means npm is asked again next time. */
11
+ export declare function keepLatestEngine(home: string | undefined, now: number, version: string): void;
@@ -1,10 +1,13 @@
1
1
  // rpg-engine itself on npm (D-515 (3)): its latest version, how this one is installed, and its update with npm, globally as it was installed; a development
2
2
  // link, or any other install, is told and never touched.
3
- import { lstatSync, readFileSync, realpathSync } from "node:fs";
3
+ import { lstatSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
4
4
  import { join } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { npmError, npmErrorCode, runNpm } from "./npm.js";
7
7
  const registry = "https://registry.npmjs.org";
8
+ // npm's latest rpg-engine, kept in the player's folder for a day (T-219).
9
+ const latestFile = "engine-update.json";
10
+ const latestHolds = 24 * 60 * 60 * 1000;
8
11
  /** rpg-engine on npm, for the engine in this folder, from src/ and dist/ alike its package's own; `run` runs npm, a fake in tests. */
9
12
  export function npmEngine(folder = fileURLToPath(new URL("../../", import.meta.url)), run = runNpm) {
10
13
  return {
@@ -36,6 +39,34 @@ export function npmEngine(folder = fileURLToPath(new URL("../../", import.meta.u
36
39
  },
37
40
  };
38
41
  }
42
+ /** npm's latest rpg-engine as checked today and kept in the player's folder; none when older, from the future or unreadable. */
43
+ export function keptLatestEngine(home, now) {
44
+ if (home === undefined) {
45
+ return undefined;
46
+ }
47
+ try {
48
+ const read = JSON.parse(readFileSync(join(home, latestFile), "utf8"));
49
+ const checked = typeof read.checked === "string" ? Date.parse(read.checked) : Number.NaN;
50
+ const fresh = !Number.isNaN(checked) && now - checked >= 0 && now - checked < latestHolds;
51
+ return fresh && typeof read.latest === "string" ? { checked, version: read.latest } : undefined;
52
+ }
53
+ catch {
54
+ return undefined;
55
+ }
56
+ }
57
+ /** Keeps npm's latest rpg-engine in the player's folder; a folder that cannot be written only means npm is asked again next time. */
58
+ export function keepLatestEngine(home, now, version) {
59
+ if (home === undefined) {
60
+ return;
61
+ }
62
+ try {
63
+ mkdirSync(home, { recursive: true });
64
+ writeFileSync(join(home, latestFile), `${JSON.stringify({ checked: new Date(now).toISOString(), latest: version }, null, 2)}\n`);
65
+ }
66
+ catch {
67
+ // Nothing to keep is no reason to stop.
68
+ }
69
+ }
39
70
  /** How the engine in this folder is installed, by npm's global folder: the package there, a link to this folder, or neither. */
40
71
  function engineInstall(folder, root) {
41
72
  const own = realFolder(folder);
@@ -1,3 +1,3 @@
1
- export { npmEngine } from "./engine.ts";
1
+ export { keepLatestEngine, keptLatestEngine, npmEngine } from "./engine.ts";
2
2
  export { isLocalSpec, isPackageName, issuesPage, isVerified, npmPackages, verifiedScope } from "./npm.ts";
3
3
  export { isTarball } from "./tarball.ts";
@@ -1,4 +1,4 @@
1
1
  // npm for every package, game systems and rpg-engine itself included (D-436, D-452, D-515): installed, updated, a .tgz read. Depends on nothing else in rpg-engine.
2
- export { npmEngine } from "./engine.js";
2
+ export { keepLatestEngine, keptLatestEngine, npmEngine } from "./engine.js";
3
3
  export { isLocalSpec, isPackageName, issuesPage, isVerified, npmPackages, verifiedScope } from "./npm.js";
4
4
  export { isTarball } from "./tarball.js";
@@ -0,0 +1,6 @@
1
+ /** Reads the hook's input and answers it on its output. */
2
+ export declare function approveHere(): Promise<void>;
3
+ /** Antigravity's decision for a tool call, as its hook gives it: auto_approve for the rpg server's tools and their descriptions, else ask. */
4
+ export declare function approval(input: string): {
5
+ decision: "auto_approve" | "ask";
6
+ };
@@ -0,0 +1,28 @@
1
+ // Antigravity's approval of the rpg tools: `rpg --approve`, the hook init writes before each tool, lets the rpg server's tools run without asking, and the
2
+ // reading of their descriptions, which Antigravity keeps in its own folder; every other tool asks the player, as the app would.
3
+ /** Reads the hook's input and answers it on its output. */
4
+ export async function approveHere() {
5
+ let input = "";
6
+ for await (const chunk of process.stdin) {
7
+ input += String(chunk);
8
+ }
9
+ process.stdout.write(JSON.stringify(approval(input)));
10
+ }
11
+ /** Antigravity's decision for a tool call, as its hook gives it: auto_approve for the rpg server's tools and their descriptions, else ask. */
12
+ export function approval(input) {
13
+ const call = toolCall(input);
14
+ const args = call.args ?? {};
15
+ const rpgTool = call.name === "call_mcp_tool" && args.ServerName === "rpg";
16
+ // The description of an rpg tool, which Antigravity reads before it calls one.
17
+ const rpgDescription = call.name === "read_file" && typeof args.Path === "string" && /[\\/]antigravity-cli[\\/]mcp[\\/]rpg[\\/][\w-]+\.(?:json|md)$/i.test(args.Path);
18
+ return { decision: rpgTool || rpgDescription ? "auto_approve" : "ask" };
19
+ }
20
+ function toolCall(input) {
21
+ try {
22
+ const call = JSON.parse(input).toolCall;
23
+ return call !== null && typeof call === "object" ? call : {};
24
+ }
25
+ catch {
26
+ return {};
27
+ }
28
+ }
@@ -0,0 +1,3 @@
1
+ import type { Context } from "../core/context.ts";
2
+ /** What copies the chats, called after every call: it copies them now and then, never in the call's way; nothing where the context has no chat folders. */
3
+ export declare function chatKeeper(context: Context): () => void;
@@ -0,0 +1,27 @@
1
+ // The campaign's chats copied as text into its sessions folder (T-225): as the server starts, then at most every few minutes, after a call and apart from it.
2
+ import { findCampaign } from "../campaign/index.js";
3
+ import { copyChats } from "../commands/shared/campaign/chats.js";
4
+ // How often the chats are copied while the game goes on: the chat going on is the master's own, so a few minutes behind is enough; chats copies them at once.
5
+ const keepEvery = 5 * 60_000;
6
+ /** What copies the chats, called after every call: it copies them now and then, never in the call's way; nothing where the context has no chat folders. */
7
+ export function chatKeeper(context) {
8
+ let last;
9
+ return () => {
10
+ const now = context.now().getTime();
11
+ if (context.chatFolders === undefined || (last !== undefined && now - last < keepEvery)) {
12
+ return;
13
+ }
14
+ last = now;
15
+ setTimeout(() => {
16
+ try {
17
+ const root = findCampaign(context.folder);
18
+ if (root !== undefined) {
19
+ copyChats(root, context);
20
+ }
21
+ }
22
+ catch {
23
+ // The chats are copied again the next time.
24
+ }
25
+ }, 0);
26
+ };
27
+ }