rpg-engine 0.19.0 → 0.20.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 (152) hide show
  1. package/README.md +9 -6
  2. package/dist/campaign/create-campaign.js +2 -2
  3. package/dist/campaign/find-campaign.d.ts +4 -0
  4. package/dist/campaign/find-campaign.js +5 -1
  5. package/dist/campaign/host-files.js +22 -0
  6. package/dist/campaign/index.d.ts +2 -2
  7. package/dist/campaign/index.js +2 -2
  8. package/dist/campaign/last-choices.d.ts +10 -4
  9. package/dist/campaign/last-choices.js +43 -17
  10. package/dist/campaign/settings.d.ts +10 -2
  11. package/dist/campaign/settings.js +30 -6
  12. package/dist/chats/chat.d.ts +33 -0
  13. package/dist/chats/chat.js +50 -0
  14. package/dist/chats/claude-code.d.ts +5 -0
  15. package/dist/chats/claude-code.js +39 -0
  16. package/dist/chats/codex.d.ts +3 -0
  17. package/dist/chats/codex.js +42 -0
  18. package/dist/chats/index.d.ts +5 -0
  19. package/dist/chats/index.js +12 -0
  20. package/dist/chats/keep.d.ts +10 -0
  21. package/dist/chats/keep.js +50 -0
  22. package/dist/chats/read.d.ts +8 -0
  23. package/dist/chats/read.js +46 -0
  24. package/dist/cli/cli.js +6 -1
  25. package/dist/cli/command-line.js +3 -2
  26. package/dist/commands/book.d.ts +55 -0
  27. package/dist/commands/book.js +105 -0
  28. package/dist/commands/chats.d.ts +38 -0
  29. package/dist/commands/chats.js +93 -0
  30. package/dist/commands/config/config.js +1 -1
  31. package/dist/commands/config/dashboard.d.ts +8 -1
  32. package/dist/commands/config/dashboard.js +63 -15
  33. package/dist/commands/config/words.d.ts +1 -1
  34. package/dist/commands/config/words.js +17 -4
  35. package/dist/commands/find.js +1 -1
  36. package/dist/commands/image.d.ts +9 -0
  37. package/dist/commands/image.js +95 -18
  38. package/dist/commands/index.js +4 -0
  39. package/dist/commands/init.js +3 -3
  40. package/dist/commands/scene/close.d.ts +2 -0
  41. package/dist/commands/scene/close.js +13 -2
  42. package/dist/commands/scene/result.d.ts +2 -0
  43. package/dist/commands/scene/scene.d.ts +2 -0
  44. package/dist/commands/shared/campaign/book.d.ts +29 -0
  45. package/dist/commands/shared/campaign/book.js +95 -0
  46. package/dist/commands/shared/campaign/chats.d.ts +11 -0
  47. package/dist/commands/shared/campaign/chats.js +29 -0
  48. package/dist/commands/shared/campaign/images.js +7 -1
  49. package/dist/commands/shared/campaign/mode.js +3 -1
  50. package/dist/commands/shared/campaign/saves.js +13 -5
  51. package/dist/commands/shared/sheet/sheet.d.ts +7 -0
  52. package/dist/commands/shared/sheet/sheet.js +27 -0
  53. package/dist/commands/shared/time/dawn.d.ts +1 -1
  54. package/dist/commands/shared/time/dawn.js +19 -7
  55. package/dist/commands/status.d.ts +1 -0
  56. package/dist/commands/status.js +4 -0
  57. package/dist/commands/view/page.js +4 -3
  58. package/dist/commands/view/result.d.ts +2 -0
  59. package/dist/commands/view/view.d.ts +1 -0
  60. package/dist/commands/view/view.js +4 -0
  61. package/dist/core/consents.d.ts +2 -2
  62. package/dist/core/consents.js +3 -3
  63. package/dist/core/context.d.ts +38 -2
  64. package/dist/core/download.js +1 -1
  65. package/dist/dashboard/acts/names.js +10 -5
  66. package/dist/dashboard/acts/sending.js +5 -2
  67. package/dist/dashboard/acts/sheet.js +66 -15
  68. package/dist/dashboard/api.js +3 -3
  69. package/dist/dashboard/app.js +2 -2
  70. package/dist/dashboard/guide/ar.md +11 -10
  71. package/dist/dashboard/guide/cs.md +10 -9
  72. package/dist/dashboard/guide/da.md +12 -11
  73. package/dist/dashboard/guide/de.md +12 -11
  74. package/dist/dashboard/guide/el.md +12 -11
  75. package/dist/dashboard/guide/en.md +9 -8
  76. package/dist/dashboard/guide/es.md +10 -9
  77. package/dist/dashboard/guide/fi.md +10 -9
  78. package/dist/dashboard/guide/fr.md +16 -15
  79. package/dist/dashboard/guide/he.md +11 -10
  80. package/dist/dashboard/guide/hi.md +10 -9
  81. package/dist/dashboard/guide/hu.md +14 -13
  82. package/dist/dashboard/guide/is.md +10 -9
  83. package/dist/dashboard/guide/it.md +13 -12
  84. package/dist/dashboard/guide/ja.md +10 -9
  85. package/dist/dashboard/guide/ko.md +11 -10
  86. package/dist/dashboard/guide/nb.md +12 -11
  87. package/dist/dashboard/guide/nl.md +10 -9
  88. package/dist/dashboard/guide/pl.md +11 -10
  89. package/dist/dashboard/guide/pt.md +12 -11
  90. package/dist/dashboard/guide/ro.md +10 -9
  91. package/dist/dashboard/guide/ru.md +12 -11
  92. package/dist/dashboard/guide/sv.md +10 -9
  93. package/dist/dashboard/guide/tr.md +13 -12
  94. package/dist/dashboard/guide/uk.md +13 -12
  95. package/dist/dashboard/guide/zh.md +11 -10
  96. package/dist/dashboard/i18n/ar.json +31 -5
  97. package/dist/dashboard/i18n/cs.json +31 -5
  98. package/dist/dashboard/i18n/da.json +31 -5
  99. package/dist/dashboard/i18n/de.json +31 -5
  100. package/dist/dashboard/i18n/el.json +31 -5
  101. package/dist/dashboard/i18n/es.json +31 -5
  102. package/dist/dashboard/i18n/fi.json +31 -5
  103. package/dist/dashboard/i18n/fr.json +31 -5
  104. package/dist/dashboard/i18n/he.json +31 -5
  105. package/dist/dashboard/i18n/hi.json +31 -5
  106. package/dist/dashboard/i18n/hu.json +31 -5
  107. package/dist/dashboard/i18n/is.json +31 -5
  108. package/dist/dashboard/i18n/it.json +32 -6
  109. package/dist/dashboard/i18n/ja.json +31 -5
  110. package/dist/dashboard/i18n/ko.json +31 -5
  111. package/dist/dashboard/i18n/nb.json +31 -5
  112. package/dist/dashboard/i18n/nl.json +31 -5
  113. package/dist/dashboard/i18n/pl.json +31 -5
  114. package/dist/dashboard/i18n/pt.json +31 -5
  115. package/dist/dashboard/i18n/ro.json +31 -5
  116. package/dist/dashboard/i18n/ru.json +31 -5
  117. package/dist/dashboard/i18n/sv.json +31 -5
  118. package/dist/dashboard/i18n/tr.json +31 -5
  119. package/dist/dashboard/i18n/uk.json +31 -5
  120. package/dist/dashboard/i18n/zh.json +31 -5
  121. package/dist/dashboard/journal/book.js +106 -0
  122. package/dist/dashboard/journal/journal.js +9 -8
  123. package/dist/dashboard/parts/labels.js +6 -0
  124. package/dist/dashboard/parts/widgets.js +1 -1
  125. package/dist/dashboard/place/view.js +1 -1
  126. package/dist/dashboard/settings/settings.js +10 -4
  127. package/dist/dashboard/settings/setup.js +5 -3
  128. package/dist/dashboard/sheet/sheet.js +8 -5
  129. package/dist/dashboard/style.css +459 -96
  130. package/dist/dashboard/world/calendar.js +1 -1
  131. package/dist/dashboard/world/lore.js +1 -1
  132. package/dist/helpers/briefs.d.ts +5 -0
  133. package/dist/helpers/briefs.js +8 -0
  134. package/dist/helpers/chosen.d.ts +8 -2
  135. package/dist/helpers/chosen.js +110 -6
  136. package/dist/helpers/codex.js +2 -1
  137. package/dist/helpers/index.d.ts +2 -2
  138. package/dist/helpers/index.js +2 -2
  139. package/dist/images/images.d.ts +2 -0
  140. package/dist/images/images.js +16 -2
  141. package/dist/images/index.d.ts +1 -1
  142. package/dist/images/index.js +1 -1
  143. package/dist/server/approver.d.ts +6 -0
  144. package/dist/server/approver.js +28 -0
  145. package/dist/server/chats.d.ts +3 -0
  146. package/dist/server/chats.js +27 -0
  147. package/dist/server/dashboard/news.js +36 -5
  148. package/dist/server/mcp.js +37 -6
  149. package/dist/server/player-acts.d.ts +7 -2
  150. package/dist/server/player-acts.js +10 -3
  151. package/instructions/start.md +1 -1
  152. package/package.json +2 -2
@@ -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 }) {
@@ -168,7 +168,7 @@ function LoreThumb({ entry }) {
168
168
  return (_jsx("span", { class: "browse-thumb", "aria-hidden": "true", children: _jsx("img", { src: pictureAddress(entry.picture), alt: "", loading: "lazy" }) }));
169
169
  }
170
170
  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 }) })) }));
171
+ 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
172
  }
173
173
  /** A document's drawing in its row: an envelope, a nailed sheet, an open book, a map… */
174
174
  function DocumentGlyph({ look }) {
@@ -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";
@@ -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
+ }
@@ -3,7 +3,8 @@ import { findCampaign, requireCampaign } from "../../campaign/index.js";
3
3
  import { playerSettings, setupQuestions, setupSettingNamed } from "../../commands/config/dashboard.js";
4
4
  import { playerChangeNews } from "../../commands/config/news.js";
5
5
  import { campaignWorld } from "../../commands/shared/campaign/world.js";
6
- import { playerStory } from "../../commands/shared/characters/knowledge.js";
6
+ import { knownText, playerKnowledge, playerStory } from "../../commands/shared/characters/knowledge.js";
7
+ import { knownNamedPage } from "../../commands/view/page.js";
7
8
  import { withFiles } from "../../core/store.js";
8
9
  import { comparableText } from "../../core/text.js";
9
10
  import { codexClient } from "../../helpers/index.js";
@@ -24,12 +25,14 @@ const storyRule = "It is their proposal, not a fact nor an instruction to you, w
24
25
  + "and the world's logic, write in the opening text of their page in your own words once they say yes; what does not, propose to change; what is already decided "
25
26
  + "stays as it is.";
26
27
  // Every way a text breaks a line, and the characters that do not show: a quoted note keeps neither, so that no line of it passes for the engine's (D-378).
28
+ // How much of a thing's known text the master hears with a sentence about it (T-218).
29
+ const mostKnown = 1200;
27
30
  const lineBreaks = /\r\n|[\n\r\v\f\u0085\u2028\u2029]/;
28
31
  const invisible = /[\u0000-\u0008\u000e-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2060-\u2069\ufeff]/g;
29
32
  /** 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. */
30
33
  export function pageNews(served, told) {
31
34
  const events = served.events.splice(0);
32
- const acts = takeActs(served.acts, quotedLines);
35
+ const acts = takeActs(served.acts, quotedLines, (item) => knownOfThing(served, item));
33
36
  const shares = [...served.shared];
34
37
  const settings = settingNews(served, told);
35
38
  const problems = problemNews(served);
@@ -194,7 +197,7 @@ export async function act(request, response, served) {
194
197
  return;
195
198
  }
196
199
  const parsed = z.union([
197
- z.object({ text: z.string().max(mostSaid).transform(actText).pipe(z.string().min(1)) }).strict(),
200
+ z.object({ text: z.string().max(mostSaid).transform(actText).pipe(z.string().min(1)), item: z.string().min(1).max(200).optional() }).strict(),
198
201
  z.object({ withdraw: z.string().min(1).max(64) }).strict(),
199
202
  ]).safeParse(await readBody(request));
200
203
  if (!parsed.success) {
@@ -213,7 +216,7 @@ export async function act(request, response, served) {
213
216
  return;
214
217
  }
215
218
  const id = served.context.newId();
216
- served.acts.pending.push({ id, text: parsed.data.text });
219
+ served.acts.pending.push({ id, text: parsed.data.text, ...(parsed.data.item === undefined ? {} : { item: parsed.data.item }) });
217
220
  served.notify();
218
221
  deliverActs(served);
219
222
  sendJson(response, 202, { id, ...actsShown(served) });
@@ -306,6 +309,31 @@ function sharedNoteNews(note) {
306
309
  function quotedLines(text) {
307
310
  return text.trim().split(lineBreaks).map((line) => line.replace(invisible, "")).map((line) => (line.trim() === "" ? ">" : `> ${line}`)).join("\n");
308
311
  }
312
+ /**
313
+ * What the player character already knows of the thing a sentence starts from, read when the master hears it (T-218): its page's text as the character knows
314
+ * it, never a secret it did not discover, quoted and cut short; undefined for a thing it knows no page of, or one with no text.
315
+ */
316
+ function knownOfThing(served, item) {
317
+ try {
318
+ return withFiles(served.session, () => {
319
+ const root = requireCampaign(served.context.folder);
320
+ const world = campaignWorld(root, served.context);
321
+ const knowledge = playerKnowledge(root, world);
322
+ const page = knowledge === undefined ? undefined : knownNamedPage(world, knowledge, item);
323
+ const text = knowledge === undefined || page === undefined ? "" : knownText(world, knowledge, page).trim();
324
+ if (knowledge === undefined || page === undefined || text === "") {
325
+ return undefined;
326
+ }
327
+ const shown = text.length > mostKnown ? `${text.slice(0, mostKnown).trimEnd()}…` : text;
328
+ return `What ${knowledge.pc.name} already knows of ${page.name}, from its page:
329
+ ${quotedLines(shown)}
330
+ Narrate as found only what this does not say.`;
331
+ });
332
+ }
333
+ catch {
334
+ return undefined;
335
+ }
336
+ }
309
337
  function actsShown(served) {
310
338
  return { pending: served.acts.pending, heard: served.acts.heard, bell: hasBell(served) };
311
339
  }
@@ -326,7 +354,10 @@ async function queueActs(served, thread) {
326
354
  // Heard as it goes, so that it is no longer taken back nor told at a call's head.
327
355
  markHeard(served.acts, [one.id]);
328
356
  served.notify();
329
- if (!(await served.queue.send(thread, one.text).catch(() => false))) {
357
+ const known = one.item === undefined ? undefined : knownOfThing(served, one.item);
358
+ if (!(await served.queue.send(thread, known === undefined ? one.text : `${one.text}
359
+
360
+ ${known}`).catch(() => false))) {
330
361
  giveBackAct(served.acts, one);
331
362
  served.queueBroken = true;
332
363
  served.notify();
@@ -1,9 +1,11 @@
1
1
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  import { spawn } from "node:child_process";
4
+ import { homedir } from "node:os";
4
5
  import { join } from "node:path";
5
6
  import { z } from "zod";
6
- import { findCampaign, hasCharacterAgent, readTextSetting, refreshHostFiles } from "../campaign/index.js";
7
+ import { chosenPictureMaker, findCampaign, hasCharacterAgent, readTextSetting, refreshHostFiles } from "../campaign/index.js";
8
+ import { chatFolders } from "../chats/index.js";
7
9
  import { commands } from "../commands/index.js";
8
10
  import { installCampaignSystem } from "../commands/package/install.js";
9
11
  import { libraryRunner } from "../commands/shared/books/library-reader.js";
@@ -25,6 +27,7 @@ import { computerHelpers, hostPictures, hostReader, hostWriter } from "../helper
25
27
  import { hostInstructions, startInstructions } from "../instructions/index.js";
26
28
  import { npmEngine, npmPackages } from "../packages/index.js";
27
29
  import { loadSystemCode } from "../systems/index.js";
30
+ import { chatKeeper } from "./chats.js";
28
31
  import { startDashboard } from "./dashboard/index.js";
29
32
  // While the player decides, the call reports progress this often, so that a host does not take it for a call that hangs.
30
33
  const progressEvery = 20 * 1000;
@@ -50,6 +53,8 @@ export function createMcpServer(context = defaultContext(), environment = proces
50
53
  // A server lives as long as its chat: it gives each part of the instructions once (D-97).
51
54
  context.told ??= new Set();
52
55
  context.chat ??= { calls: 0 };
56
+ // What came after a call answered, as a picture made in its place or none, for the next (D-572).
57
+ context.later ??= laterLines();
53
58
  // What changed outside the chat's commands, at the head of each call (OUT-1–OUT-4).
54
59
  const outside = context.files instanceof SessionStore ? watchOutside(context, context.files) : { take: () => [], giveBack: () => undefined };
55
60
  // The campaign's game system, one of ours, installed by itself when it is not on this computer, and said once (SYS-10).
@@ -66,8 +71,11 @@ export function createMcpServer(context = defaultContext(), environment = proces
66
71
  // The examples of the descriptions in the names of the campaign's system, read without the session's store before the host asks for the tools (D-518).
67
72
  const examples = { shown: examplesFor(context, new FileStore(context.systemFolders)) };
68
73
  const coreTools = new Map();
74
+ // The chats copied into the campaign, the first time as the server starts, once its world is read (T-225).
75
+ const keepChats = chatKeeper(context);
69
76
  // After every call the descriptions follow the campaign's system, as after init or config system, and the extensions' tools follow campaign.yaml.
70
77
  const afterCall = () => {
78
+ keepChats();
71
79
  refreshExamples(coreTools, examples, examplesFor(context, context.files ?? new FileStore(context.systemFolders)));
72
80
  return extensions();
73
81
  };
@@ -113,12 +121,12 @@ export async function startMcpServer() {
113
121
  const leave = () => process.exit(0);
114
122
  process.stdin.on("end", leave);
115
123
  process.stdin.on("close", leave);
116
- // The pictures, by the chat in use, which names itself as the session starts (D-308, D-390).
124
+ // The pictures, by the campaign's choice, else by the chat in use, which names itself as the session starts (D-308, D-572).
117
125
  let server;
118
126
  const host = () => server?.server.getClientVersion()?.name;
119
127
  const context = {
120
128
  ...defaultContext(),
121
- pictures: hostPictures(host),
129
+ pictures: hostPictures(host, () => chosenPictureMaker(context.folder)),
122
130
  writer: hostWriter(host),
123
131
  reader: hostReader(host),
124
132
  // The command line that started this server runs the import apart, `rpg import` in the campaign's folder, with the chat's own helper.
@@ -132,6 +140,7 @@ export async function startMcpServer() {
132
140
  download: downloadBytes,
133
141
  host,
134
142
  chat: { calls: 0 },
143
+ chatFolders: chatFolders(process.env, homedir()),
135
144
  };
136
145
  // The systems' code, loaded once for the session, as the engine's own: a system changed since needs the server started again (D-448).
137
146
  context.systemCode = await loadSystemCode(context.systemFolders);
@@ -317,6 +326,7 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
317
326
  let news;
318
327
  let changedOutside = [];
319
328
  let installed = [];
329
+ let later = [];
320
330
  // The call tells its parts on a copy of what the chat was told, given back at its end: an answer that never goes tells nothing, so its parts are told again
321
331
  // (D-97), and what a call beside it told stays told.
322
332
  const before = new Set(context.told);
@@ -337,11 +347,13 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
337
347
  await prepare();
338
348
  // The campaign's system installed by itself, said first (SYS-10); a call stopped while it installed leaves the line to the next.
339
349
  installed = extra.signal.aborted ? [] : installer.take();
350
+ // What came after the last calls answered, as a picture Claude drew in another's place, right after (D-572).
351
+ later = extra.signal.aborted ? [] : (context.later?.take() ?? []);
340
352
  // After a load the chat going on remembers what is gone: nothing runs in it, until a new chat begins with instructions (D-361).
341
353
  const back = chatAfterLoad(context, command.name, input);
342
354
  if (back.refused !== undefined) {
343
355
  news = context.news?.(told);
344
- return { content: [{ type: "text", text: [...installed, ...(news?.lines ?? []), back.refused].join("\n\n") }, masterOnly(context)], isError: true };
356
+ return { content: [{ type: "text", text: [...installed, ...later, ...(news?.lines ?? []), back.refused].join("\n\n") }, masterOnly(context)], isError: true };
345
357
  }
346
358
  const checked = checkedInput(command, input, examples.shown);
347
359
  // Stopped while the call was made ready, as while the system installed: the command never runs, so that calling it again does it once.
@@ -354,11 +366,12 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
354
366
  const text = command.format(await command.run(checked, { ...context, told, signal: extra.signal }));
355
367
  // What the player changed on the dashboard comes first, once, what they changed while the call waited included (D-341).
356
368
  news = context.news?.(told);
357
- return { content: [{ type: "text", text: [...installed, ...(news?.lines ?? []), ...changedOutside, ...back.begun, text].join("\n\n") }, masterOnly(context)] };
369
+ return { content: [{ type: "text", text: [...installed, ...later, ...(news?.lines ?? []), ...changedOutside, ...back.begun, text].join("\n\n") }, masterOnly(context)] };
358
370
  }
359
371
  catch (error) {
360
372
  news ??= context.news?.(told);
361
- return { content: [{ type: "text", text: [...installed, ...(news?.lines ?? []), ...changedOutside, error instanceof Error ? error.message : String(error)].join("\n\n") }, masterOnly(context)], isError: true };
373
+ const said = error instanceof Error ? error.message : String(error);
374
+ return { content: [{ type: "text", text: [...installed, ...later, ...(news?.lines ?? []), ...changedOutside, said].join("\n\n") }, masterOnly(context)], isError: true };
362
375
  }
363
376
  finally {
364
377
  clearInterval(keepAlive);
@@ -367,6 +380,7 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
367
380
  if (extra.signal.aborted) {
368
381
  news?.restore();
369
382
  installer.giveBack(installed);
383
+ context.later?.giveBack(later);
370
384
  outside.giveBack(changedOutside);
371
385
  if (chat !== undefined) {
372
386
  chat.dashboardOffered = offered;
@@ -412,6 +426,23 @@ function systemInstaller(context) {
412
426
  },
413
427
  };
414
428
  }
429
+ /** Lines a command leaves for the master's next call, as of a picture that came after its call answered (D-572). */
430
+ function laterLines() {
431
+ let untold = [];
432
+ return {
433
+ add: (line) => {
434
+ untold = [...untold, line];
435
+ },
436
+ take: () => {
437
+ const lines = untold;
438
+ untold = [];
439
+ return lines;
440
+ },
441
+ giveBack: (lines) => {
442
+ untold = [...lines, ...untold];
443
+ },
444
+ };
445
+ }
415
446
  /**
416
447
  * What changed outside the chat's commands since its last call (OUT-1–OUT-4): the world as it was is read before the session lets the changes in, so that the
417
448
  * events they set off fire; at the server's first call, the files changed while no chat was open.
@@ -2,6 +2,8 @@
2
2
  export interface Act {
3
3
  id: string;
4
4
  text: string;
5
+ /** The thing of the sheet it starts from, by its page, whose known text the master hears with it (T-218). */
6
+ item?: string;
5
7
  rung?: boolean;
6
8
  }
7
9
  /** The sentences said and not yet heard, in order, and the ids of those heard lately, for the page to tell. */
@@ -20,8 +22,11 @@ export declare function markRung(acts: Acts): void;
20
22
  export declare function markHeard(acts: Acts, ids: string[]): void;
21
23
  /** Gives a sentence back to the head of those waiting, as one Codex never took. */
22
24
  export declare function giveBackAct(acts: Acts, act: Act): void;
23
- /** The sentences for the head of the master's call, marked heard; given back, in order, when that call never answers. */
24
- export declare function takeActs(acts: Acts, quoted: (text: string) => string): {
25
+ /**
26
+ * The sentences for the head of the master's call, marked heard; given back, in order, when that call never answers. `known` gives what the player character
27
+ * already knows of a sentence's thing, for the master to tell only what is new (T-218).
28
+ */
29
+ export declare function takeActs(acts: Acts, quoted: (text: string) => string, known?: (item: string) => string | undefined): {
25
30
  lines: string[];
26
31
  restore(): void;
27
32
  };
@@ -38,12 +38,19 @@ export function giveBackAct(acts, act) {
38
38
  acts.pending.unshift(act);
39
39
  acts.heard = acts.heard.filter((id) => id !== act.id);
40
40
  }
41
- /** The sentences for the head of the master's call, marked heard; given back, in order, when that call never answers. */
42
- export function takeActs(acts, quoted) {
41
+ /**
42
+ * The sentences for the head of the master's call, marked heard; given back, in order, when that call never answers. `known` gives what the player character
43
+ * already knows of a sentence's thing, for the master to tell only what is new (T-218).
44
+ */
45
+ export function takeActs(acts, quoted, known = () => undefined) {
43
46
  const taken = [...acts.pending];
44
47
  markHeard(acts, taken.map((act) => act.id));
45
48
  return {
46
- lines: taken.map((act) => actNews(act.text, quoted)),
49
+ lines: taken.map((act) => {
50
+ const already = act.item === undefined ? undefined : known(act.item);
51
+ return already === undefined ? actNews(act.text, quoted) : `${actNews(act.text, quoted)}
52
+ ${already}`;
53
+ }),
47
54
  restore: () => {
48
55
  acts.pending = [...taken, ...acts.pending];
49
56
  acts.heard = acts.heard.filter((id) => !taken.some((act) => act.id === id));