rpg-engine 0.21.0 → 0.23.1

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 (165) hide show
  1. package/README.md +5 -5
  2. package/dist/campaign/create-campaign.d.ts +5 -0
  3. package/dist/campaign/create-campaign.js +40 -12
  4. package/dist/campaign/find-campaign.d.ts +5 -0
  5. package/dist/campaign/find-campaign.js +10 -5
  6. package/dist/campaign/host-files.d.ts +15 -4
  7. package/dist/campaign/host-files.js +134 -14
  8. package/dist/campaign/index.d.ts +4 -3
  9. package/dist/campaign/index.js +4 -3
  10. package/dist/campaign/port.d.ts +6 -0
  11. package/dist/campaign/port.js +24 -0
  12. package/dist/campaign/settings.d.ts +17 -0
  13. package/dist/campaign/settings.js +24 -1
  14. package/dist/cli/cli.js +33 -6
  15. package/dist/commands/config/config.js +15 -1
  16. package/dist/commands/config/dashboard.d.ts +4 -0
  17. package/dist/commands/config/dashboard.js +43 -7
  18. package/dist/commands/config/shown.js +4 -0
  19. package/dist/commands/config/words.d.ts +3 -1
  20. package/dist/commands/config/words.js +29 -2
  21. package/dist/commands/image.d.ts +3 -0
  22. package/dist/commands/image.js +31 -4
  23. package/dist/commands/import/import.d.ts +1 -1
  24. package/dist/commands/import/import.js +5 -0
  25. package/dist/commands/init.d.ts +2 -0
  26. package/dist/commands/init.js +21 -3
  27. package/dist/commands/mode.d.ts +1 -1
  28. package/dist/commands/package/data.js +27 -0
  29. package/dist/commands/package/theme.js +2 -1
  30. package/dist/commands/scene/scene.js +6 -1
  31. package/dist/commands/shared/books/adventures.d.ts +1 -0
  32. package/dist/commands/shared/books/adventures.js +1 -1
  33. package/dist/commands/shared/campaign/git.d.ts +25 -0
  34. package/dist/commands/shared/campaign/git.js +104 -0
  35. package/dist/commands/shared/campaign/images.js +5 -3
  36. package/dist/commands/shared/campaign/saves.js +5 -1
  37. package/dist/commands/shared/characters/voices.d.ts +2 -2
  38. package/dist/commands/shared/characters/voices.js +8 -5
  39. package/dist/commands/shared/packages/catalog.js +24 -5
  40. package/dist/commands/status.d.ts +1 -0
  41. package/dist/commands/status.js +8 -4
  42. package/dist/core/context.d.ts +17 -6
  43. package/dist/core/context.js +2 -1
  44. package/dist/core/version.d.ts +2 -0
  45. package/dist/core/version.js +5 -0
  46. package/dist/dashboard/guide/ar.md +12 -7
  47. package/dist/dashboard/guide/cs.md +11 -6
  48. package/dist/dashboard/guide/da.md +11 -6
  49. package/dist/dashboard/guide/de.md +13 -8
  50. package/dist/dashboard/guide/el.md +11 -6
  51. package/dist/dashboard/guide/en.md +10 -5
  52. package/dist/dashboard/guide/es.md +11 -6
  53. package/dist/dashboard/guide/fi.md +11 -6
  54. package/dist/dashboard/guide/fr.md +12 -7
  55. package/dist/dashboard/guide/he.md +11 -6
  56. package/dist/dashboard/guide/hi.md +11 -6
  57. package/dist/dashboard/guide/hu.md +11 -6
  58. package/dist/dashboard/guide/is.md +11 -6
  59. package/dist/dashboard/guide/it.md +42 -37
  60. package/dist/dashboard/guide/ja.md +12 -7
  61. package/dist/dashboard/guide/ko.md +11 -6
  62. package/dist/dashboard/guide/nb.md +12 -7
  63. package/dist/dashboard/guide/nl.md +13 -8
  64. package/dist/dashboard/guide/pl.md +11 -6
  65. package/dist/dashboard/guide/pt.md +11 -6
  66. package/dist/dashboard/guide/ro.md +11 -6
  67. package/dist/dashboard/guide/ru.md +12 -7
  68. package/dist/dashboard/guide/sv.md +11 -6
  69. package/dist/dashboard/guide/tr.md +12 -7
  70. package/dist/dashboard/guide/uk.md +12 -7
  71. package/dist/dashboard/guide/zh.md +11 -6
  72. package/dist/dashboard/i18n/ar.json +30 -2
  73. package/dist/dashboard/i18n/cs.json +30 -2
  74. package/dist/dashboard/i18n/da.json +30 -2
  75. package/dist/dashboard/i18n/de.json +30 -2
  76. package/dist/dashboard/i18n/el.json +30 -2
  77. package/dist/dashboard/i18n/es.json +30 -2
  78. package/dist/dashboard/i18n/fi.json +30 -2
  79. package/dist/dashboard/i18n/fr.json +30 -2
  80. package/dist/dashboard/i18n/he.json +30 -2
  81. package/dist/dashboard/i18n/hi.json +30 -2
  82. package/dist/dashboard/i18n/hu.json +30 -2
  83. package/dist/dashboard/i18n/is.json +30 -2
  84. package/dist/dashboard/i18n/it.json +30 -2
  85. package/dist/dashboard/i18n/ja.json +30 -2
  86. package/dist/dashboard/i18n/ko.json +30 -2
  87. package/dist/dashboard/i18n/nb.json +30 -2
  88. package/dist/dashboard/i18n/nl.json +30 -2
  89. package/dist/dashboard/i18n/pl.json +30 -2
  90. package/dist/dashboard/i18n/pt.json +30 -2
  91. package/dist/dashboard/i18n/ro.json +30 -2
  92. package/dist/dashboard/i18n/ru.json +30 -2
  93. package/dist/dashboard/i18n/sv.json +30 -2
  94. package/dist/dashboard/i18n/tr.json +30 -2
  95. package/dist/dashboard/i18n/uk.json +30 -2
  96. package/dist/dashboard/i18n/zh.json +30 -2
  97. package/dist/dashboard/packages/installed.js +2 -2
  98. package/dist/dashboard/packages/packages.js +1 -1
  99. package/dist/dashboard/parts/labels.js +7 -0
  100. package/dist/dashboard/settings/settings.js +45 -9
  101. package/dist/dashboard/shell/notices.js +1 -1
  102. package/dist/dashboard/shell/system-style.js +89 -5
  103. package/dist/dashboard/shell/tooltip.js +5 -4
  104. package/dist/dashboard/style.css +245 -84
  105. package/dist/git/git.d.ts +12 -0
  106. package/dist/git/git.js +175 -0
  107. package/dist/git/ignore.d.ts +2 -0
  108. package/dist/git/ignore.js +16 -0
  109. package/dist/git/index.d.ts +2 -0
  110. package/dist/git/index.js +2 -0
  111. package/dist/helpers/briefs.d.ts +4 -0
  112. package/dist/helpers/briefs.js +13 -0
  113. package/dist/helpers/chosen.d.ts +8 -4
  114. package/dist/helpers/chosen.js +38 -14
  115. package/dist/helpers/index.d.ts +3 -2
  116. package/dist/helpers/index.js +5 -3
  117. package/dist/helpers/opencode.d.ts +13 -0
  118. package/dist/helpers/opencode.js +202 -0
  119. package/dist/importer/index.d.ts +1 -1
  120. package/dist/importer/index.js +1 -1
  121. package/dist/instructions/index.d.ts +2 -2
  122. package/dist/instructions/index.js +3 -3
  123. package/dist/languages/pack.js +2 -1
  124. package/dist/server/approver.d.ts +4 -2
  125. package/dist/server/approver.js +27 -7
  126. package/dist/server/bell/antigravity.d.ts +10 -0
  127. package/dist/server/bell/antigravity.js +95 -0
  128. package/dist/server/bell/index.d.ts +2 -0
  129. package/dist/server/bell/index.js +2 -0
  130. package/dist/server/bell/listener.d.ts +43 -0
  131. package/dist/server/bell/listener.js +149 -0
  132. package/dist/server/dashboard/files.d.ts +3 -2
  133. package/dist/server/dashboard/files.js +44 -15
  134. package/dist/server/dashboard/index.d.ts +25 -3
  135. package/dist/server/dashboard/index.js +58 -23
  136. package/dist/server/dashboard/news.d.ts +5 -2
  137. package/dist/server/dashboard/news.js +82 -14
  138. package/dist/server/dashboard/ports.d.ts +17 -2
  139. package/dist/server/dashboard/ports.js +60 -4
  140. package/dist/server/mcp.d.ts +6 -4
  141. package/dist/server/mcp.js +66 -18
  142. package/dist/server/player-acts.d.ts +21 -1
  143. package/dist/server/player-acts.js +38 -2
  144. package/dist/server/route/front.d.ts +3 -0
  145. package/dist/server/route/front.js +97 -0
  146. package/dist/server/route/index.d.ts +3 -0
  147. package/dist/server/route/index.js +3 -0
  148. package/dist/server/route/notes.d.ts +8 -0
  149. package/dist/server/route/notes.js +50 -0
  150. package/dist/server/route/router.d.ts +31 -0
  151. package/dist/server/route/router.js +215 -0
  152. package/dist/themes/css.d.ts +1 -1
  153. package/dist/themes/css.js +101 -2
  154. package/dist/themes/index.d.ts +1 -1
  155. package/dist/themes/index.js +1 -1
  156. package/dist/themes/theme.d.ts +34 -3
  157. package/dist/themes/theme.js +176 -19
  158. package/instructions/core.md +1 -0
  159. package/instructions/dashboard-guide.md +1 -1
  160. package/instructions/start.md +1 -1
  161. package/instructions/voices-opencode.md +1 -0
  162. package/package.json +3 -2
  163. package/plugins/opencode.js +174 -0
  164. package/dist/server/bell-listener.d.ts +0 -9
  165. package/dist/server/bell-listener.js +0 -83
@@ -1 +1 @@
1
- export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, type ImportedText, importFile, importFolder, importPiece, type ImportStart, importStarts, type ImportState, importStyle, isOwnOpening, markOpening, openImport, type OpeningImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, writeImportState, } from "./work.ts";
1
+ export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, type ImportedText, importFile, importFolder, importPiece, importsFolderName, type ImportStart, importStarts, type ImportState, importStyle, isOwnOpening, markOpening, openImport, type OpeningImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, writeImportState, } from "./work.ts";
@@ -1,3 +1,3 @@
1
1
  // The importer's folder (D-489): the player's document in pieces, how far the import is, and the adventure the helper writes. Depends on nothing else in
2
2
  // rpg-engine.
3
- export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, importFile, importFolder, importPiece, importStarts, importStyle, isOwnOpening, markOpening, openImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, writeImportState, } from "./work.js";
3
+ export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, importFile, importFolder, importPiece, importsFolderName, importStarts, importStyle, isOwnOpening, markOpening, openImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, writeImportState, } from "./work.js";
@@ -10,8 +10,8 @@ export declare function hostInstructions(): {
10
10
  start: string;
11
11
  character: string;
12
12
  };
13
- /** When and how the master calls the character agent, in play, where the host has it (D-490). */
14
- export declare function voicesInstructions(way: string): string;
13
+ /** When and how the master calls the character agent, in play, where the host has it (D-490); in OpenCode, how its subagent answers. */
14
+ export declare function voicesInstructions(way: string, openCode?: boolean): string;
15
15
  /** The line that sends the master to the buttons, where the player sees them (D-148, D-279); for choices alone when the player rolls their own dice (ASK-8). */
16
16
  export declare function buttonsInstructions(physicalDice: boolean): string;
17
17
  /** The dashboard at its link, which the game is played with, and how the player uses it, for the master to offer it and help them (D-404). */
@@ -8,11 +8,11 @@ export function startInstructions() {
8
8
  export function hostInstructions() {
9
9
  return { start: startInstructions(), character: readInstructions("character.md") };
10
10
  }
11
- /** When and how the master calls the character agent, in play, where the host has it (D-490). */
12
- export function voicesInstructions(way) {
11
+ /** When and how the master calls the character agent, in play, where the host has it (D-490); in OpenCode, how its subagent answers. */
12
+ export function voicesInstructions(way, openCode = false) {
13
13
  // Always for the main characters, or for everyone, as the player chose, on top of the key moments (D-490).
14
14
  const more = way === "important" || way === "always" ? `\n\n${readInstructions(`voices-${way}.md`)}` : "";
15
- return `${readInstructions("voices.md")}${more}`;
15
+ return `${readInstructions("voices.md")}${openCode ? `\n\n${readInstructions("voices-opencode.md")}` : ""}${more}`;
16
16
  }
17
17
  /** The line that sends the master to the buttons, where the player sees them (D-148, D-279); for choices alone when the player rolls their own dice (ASK-8). */
18
18
  export function buttonsInstructions(physicalDice) {
@@ -10,7 +10,8 @@ const codePattern = /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/;
10
10
  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
- engine: z.string().optional(),
13
+ // The lowest rpg-engine that reads it, such as "0.22": checked as one of data alone is installed.
14
+ engine: z.string({ error: 'engine is written in quotes, as engine: "0.22": without them YAML reads 0.30 as the number 0.3' }).regex(/^\d+(\.\d+){0,2}$/, 'engine is the lowest rpg-engine version, such as "0.22", not a range').optional(),
14
15
  // Its version, for a package of data alone, which has no package.json to say it.
15
16
  version: z.union([z.string(), z.number()]).transform(String).optional(),
16
17
  }).strict();
@@ -1,6 +1,8 @@
1
- /** Reads the hook's input and answers it on its output. */
2
- export declare function approveHere(): Promise<void>;
1
+ /** Reads the hook's input and answers it on its output, then notes the conversation's campaign. */
2
+ export declare function approveHere(home?: string): Promise<void>;
3
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
4
  export declare function approval(input: string): {
5
5
  decision: "auto_approve" | "ask";
6
6
  };
7
+ /** For a call of an rpg tool, notes in `home` the campaign of the hook's folder as the one its conversation plays; nothing outside a campaign. */
8
+ export declare function noteCampaign(input: string, home: string): void;
@@ -1,26 +1,46 @@
1
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() {
2
+ // reading of their descriptions, which Antigravity keeps in its own folder; every other tool asks the player, as the app would. As it approves an rpg tool,
3
+ // it notes which campaign the conversation plays, for the router of Antigravity's app (D-578).
4
+ import { findCampaign } from "../campaign/index.js";
5
+ import { userDataFolder } from "../core/context.js";
6
+ import { noteConversation } from "./route/index.js";
7
+ /** Reads the hook's input and answers it on its output, then notes the conversation's campaign. */
8
+ export async function approveHere(home = userDataFolder()) {
5
9
  let input = "";
6
10
  for await (const chunk of process.stdin) {
7
11
  input += String(chunk);
8
12
  }
9
13
  process.stdout.write(JSON.stringify(approval(input)));
14
+ noteCampaign(input, home);
10
15
  }
11
16
  /** 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
17
  export function approval(input) {
13
18
  const call = toolCall(input);
14
19
  const args = call.args ?? {};
15
- const rpgTool = call.name === "call_mcp_tool" && args.ServerName === "rpg";
16
20
  // The description of an rpg tool, which Antigravity reads before it calls one.
17
21
  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" };
22
+ return { decision: isRpgTool(input) || rpgDescription ? "auto_approve" : "ask" };
23
+ }
24
+ /** For a call of an rpg tool, notes in `home` the campaign of the hook's folder as the one its conversation plays; nothing outside a campaign. */
25
+ export function noteCampaign(input, home) {
26
+ const { conversationId, cwd } = hookFields(input);
27
+ const root = isRpgTool(input) && typeof conversationId === "string" ? findCampaign(typeof cwd === "string" ? cwd : process.cwd()) : undefined;
28
+ if (root !== undefined && typeof conversationId === "string") {
29
+ noteConversation(home, conversationId, root);
30
+ }
31
+ }
32
+ function isRpgTool(input) {
33
+ const call = toolCall(input);
34
+ return call.name === "call_mcp_tool" && call.args?.ServerName === "rpg";
19
35
  }
20
36
  function toolCall(input) {
37
+ const call = hookFields(input).toolCall;
38
+ return call !== null && typeof call === "object" ? call : {};
39
+ }
40
+ function hookFields(input) {
21
41
  try {
22
- const call = JSON.parse(input).toolCall;
23
- return call !== null && typeof call === "object" ? call : {};
42
+ const parsed = JSON.parse(input);
43
+ return parsed !== null && typeof parsed === "object" ? parsed : {};
24
44
  }
25
45
  catch {
26
46
  return {};
@@ -0,0 +1,10 @@
1
+ /** Antigravity's own folder, where its command line keeps its history and its log. */
2
+ export declare function antigravityFolder(userHome?: string): string;
3
+ /**
4
+ * Watches, from now on, whether the player starts a new turn in the conversation: writes in the chat, or stops it with Esc. `started` resolves then, never
5
+ * otherwise; `stop` ends the watch.
6
+ */
7
+ export declare function watchNewTurn(conversation: string, folder?: string, every?: number, appFolder?: string): {
8
+ started: Promise<void>;
9
+ stop: () => void;
10
+ };
@@ -0,0 +1,95 @@
1
+ // Antigravity's Stop hook holds the chat until it ends: a message the player writes meanwhile waits behind it, and Esc leaves it running. Antigravity's own
2
+ // files tell either: the history of what the player typed, with the conversation it went to, and its log, which notes the conversation stopped; in its app,
3
+ // the messages it keeps to send once the turn ends.
4
+ import { closeSync, openSync, readdirSync, readSync, statSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
7
+ /** Antigravity's own folder, where its command line keeps its history and its log. */
8
+ export function antigravityFolder(userHome = homedir()) {
9
+ return join(userHome, ".gemini", "antigravity-cli");
10
+ }
11
+ /**
12
+ * Watches, from now on, whether the player starts a new turn in the conversation: writes in the chat, or stops it with Esc. `started` resolves then, never
13
+ * otherwise; `stop` ends the watch.
14
+ */
15
+ export function watchNewTurn(conversation, folder = antigravityFolder(), every = 500, appFolder = join(folder, "..", "antigravity")) {
16
+ const history = join(folder, "history.jsonl");
17
+ const log = join(folder, "cli.log");
18
+ const read = { [history]: placeOf(history), [log]: placeOf(log) };
19
+ let timer;
20
+ const started = new Promise((done) => {
21
+ timer = setInterval(() => {
22
+ if (wrote(newText(history, read), conversation) || stopped(newText(log, read), conversation) || queued(appFolder, conversation)) {
23
+ clearInterval(timer);
24
+ done();
25
+ }
26
+ }, every);
27
+ timer.unref();
28
+ });
29
+ return { started, stop: () => clearInterval(timer) };
30
+ }
31
+ /**
32
+ * Whether Antigravity's app holds a message the player wrote in the conversation while its turn has not ended: the app keeps one file for each in the
33
+ * conversation's own folder, and sends them once the turn ends.
34
+ */
35
+ function queued(appFolder, conversation) {
36
+ try {
37
+ return readdirSync(join(appFolder, "brain", conversation, ".system_generated", "messages", "undelivered")).length > 0;
38
+ }
39
+ catch {
40
+ return false;
41
+ }
42
+ }
43
+ /** Whether these lines of Antigravity's history hold something the player typed in the conversation: a message, or a command such as /clear. */
44
+ function wrote(lines, conversation) {
45
+ return lines.split("\n").some((line) => {
46
+ try {
47
+ return JSON.parse(line).conversationId === conversation;
48
+ }
49
+ catch {
50
+ return false;
51
+ }
52
+ });
53
+ }
54
+ /** Whether these lines of Antigravity's log say the conversation was stopped, as Esc does. */
55
+ function stopped(lines, conversation) {
56
+ return lines.includes(`Cancelling conversation ${conversation}`);
57
+ }
58
+ /**
59
+ * The whole lines a file gained since it was last read, as `read` keeps its place: what follows its last line's end waits for the next read, as a line written
60
+ * in two parts. A file that shrank, or was written anew in its place, is read from its start.
61
+ */
62
+ function newText(file, read) {
63
+ const now = placeOf(file);
64
+ const before = read[file];
65
+ const from = before === undefined || now.offset < before.offset || now.identity !== before.identity ? 0 : before.offset;
66
+ if (now.offset <= from) {
67
+ read[file] = { offset: now.offset, identity: now.identity };
68
+ return "";
69
+ }
70
+ try {
71
+ const descriptor = openSync(file, "r");
72
+ try {
73
+ const buffer = Buffer.alloc(now.offset - from);
74
+ const length = readSync(descriptor, buffer, 0, buffer.length, from);
75
+ const whole = buffer.subarray(0, buffer.subarray(0, length).lastIndexOf(10) + 1);
76
+ read[file] = { offset: from + whole.length, identity: now.identity };
77
+ return whole.toString("utf8");
78
+ }
79
+ finally {
80
+ closeSync(descriptor);
81
+ }
82
+ }
83
+ catch {
84
+ return "";
85
+ }
86
+ }
87
+ function placeOf(file) {
88
+ try {
89
+ const stats = statSync(file);
90
+ return { offset: stats.size, identity: stats.ino };
91
+ }
92
+ catch {
93
+ return { offset: 0, identity: 0 };
94
+ }
95
+ }
@@ -0,0 +1,2 @@
1
+ export { antigravityFolder, watchNewTurn } from "./antigravity.ts";
2
+ export { bellHeard, bellLine, type Heard, hookAnswer, listen, type ListeningHost, listeningHosts, waitForBell } from "./listener.ts";
@@ -0,0 +1,2 @@
1
+ export { antigravityFolder, watchNewTurn } from "./antigravity.js";
2
+ export { bellHeard, bellLine, hookAnswer, listen, listeningHosts, waitForBell } from "./listener.js";
@@ -0,0 +1,43 @@
1
+ /** What the chat hears from the doorbell: never the player's words, only where to read them. */
2
+ export declare const bellLine = "The player acted on the dashboard: call status to read what they did.";
3
+ /** The hosts whose hook runs `rpg --listen`, as its argument names them: Claude Code with none; OpenCode through the campaign's plugin. */
4
+ export declare const listeningHosts: readonly ["claude", "codex", "antigravity", "opencode"];
5
+ export type ListeningHost = (typeof listeningHosts)[number];
6
+ /**
7
+ * Reads the hook's input, waits for the doorbell, and ends the process as the host reads it: for Claude Code's asyncRewake, 2 with the line on stderr; for
8
+ * Codex's and Antigravity's Stop hooks, 0 with their answer on stdout; for OpenCode's plugin, 0 with the player's words, or the line, on stdout, which it sends to the chat. Else 0.
9
+ * Antigravity's hook holds the chat: it lets it go, without the bell, as soon as the player writes in the chat or stops it; OpenCode's, once OpenCode is gone.
10
+ */
11
+ export declare function listen(host?: ListeningHost): Promise<void>;
12
+ /**
13
+ * What the hook says as it ends, by its host: the doorbell's line, or the answer that carries it, when it rang, and for OpenCode the player's `words` when the
14
+ * page gave them; else nothing, but Antigravity's empty answer.
15
+ */
16
+ export declare function hookAnswer(host: ListeningHost, rang: boolean, words?: string): string | undefined;
17
+ /** What the hook heard at its chat's dashboard: whether it rang, and the player's words when it asked for them and the page gave some. */
18
+ export interface Heard {
19
+ rang: boolean;
20
+ words?: string;
21
+ }
22
+ /**
23
+ * Waits at the dashboard of the hook's chat until the player says a sentence: true then; false when there is none to wait at, or it goes away. The chat's own
24
+ * server is the one with its session; after /clear, which gives the hook a new one, and in hosts whose server does not know its session, the only server of
25
+ * its campaign, while no other chat waits there for the page (D-577): better no ring than one in a chat that cannot read the page. The hook may come before its
26
+ * chat's page answers, as in Antigravity: while the campaign has none, it looks again `looks.times` times, every `looks.every` ms.
27
+ */
28
+ export declare function waitForBell(input: string, ports?: number[], looks?: {
29
+ every: number;
30
+ times: number;
31
+ }): Promise<boolean>;
32
+ /**
33
+ * Waits as waitForBell does, at `ports` or the campaign's, looking again as `looks` says, and says what it heard; with `words`, it asks the page for the
34
+ * player's sentences themselves, which the page holds for the master's next call (D-578).
35
+ */
36
+ export declare function bellHeard(input: string, options?: {
37
+ ports?: number[];
38
+ looks?: {
39
+ every: number;
40
+ times: number;
41
+ };
42
+ words?: boolean;
43
+ }): Promise<Heard>;
@@ -0,0 +1,149 @@
1
+ // The doorbell for the player's sentences on the dashboard (D-495, D-578): `rpg --listen`, the Stop hook init writes for Claude Code and Antigravity, which
2
+ // OpenCode's plugin runs too, waits at the dashboard of its own chat and, when the player says a sentence, tells the chat to call status, the sentence
3
+ // reaching the master in that call; in OpenCode, whose plugin speaks as the player, it brings the sentence itself, as Codex's queue does.
4
+ import { findCampaign } from "../../campaign/index.js";
5
+ import { samePath } from "../../library/index.js";
6
+ import { askDashboard, campaignPorts, dashboardAt } from "../dashboard/ports.js";
7
+ import { watchNewTurn } from "./antigravity.js";
8
+ /** What the chat hears from the doorbell: never the player's words, only where to read them. */
9
+ export const bellLine = "The player acted on the dashboard: call status to read what they did.";
10
+ /** The hosts whose hook runs `rpg --listen`, as its argument names them: Claude Code with none; OpenCode through the campaign's plugin. */
11
+ export const listeningHosts = ["claude", "codex", "antigravity", "opencode"];
12
+ /**
13
+ * Reads the hook's input, waits for the doorbell, and ends the process as the host reads it: for Claude Code's asyncRewake, 2 with the line on stderr; for
14
+ * Codex's and Antigravity's Stop hooks, 0 with their answer on stdout; for OpenCode's plugin, 0 with the player's words, or the line, on stdout, which it sends to the chat. Else 0.
15
+ * Antigravity's hook holds the chat: it lets it go, without the bell, as soon as the player writes in the chat or stops it; OpenCode's, once OpenCode is gone.
16
+ */
17
+ export async function listen(host = "claude") {
18
+ let input = "";
19
+ for await (const chunk of process.stdin) {
20
+ input += String(chunk);
21
+ }
22
+ const hook = hookInput(input);
23
+ const turn = host === "antigravity" && hook.session !== undefined ? watchNewTurn(hook.session) : undefined;
24
+ const opener = hook.hostPid === undefined ? undefined : watchProcessEnd(hook.hostPid);
25
+ const unheard = { rang: false };
26
+ const heard = await Promise.race([
27
+ bellHeard(input, { words: host === "opencode" }).catch(() => unheard),
28
+ ...(turn === undefined ? [] : [turn.started.then(() => unheard)]),
29
+ ...(opener === undefined ? [] : [opener.ended.then(() => unheard)]),
30
+ ]);
31
+ turn?.stop();
32
+ opener?.stop();
33
+ const answer = hookAnswer(host, heard.rang, heard.words);
34
+ // It ends as soon as it knows, whatever else the process holds: the chat hears the hook only once it ends, and the dashboard sees its wait gone.
35
+ if (answer === undefined) {
36
+ process.exit(0);
37
+ }
38
+ else if (host === "claude") {
39
+ process.stderr.write(`${answer}\n`, () => process.exit(2));
40
+ }
41
+ else {
42
+ process.stdout.write(`${answer}\n`, () => process.exit(0));
43
+ }
44
+ }
45
+ /**
46
+ * What the hook says as it ends, by its host: the doorbell's line, or the answer that carries it, when it rang, and for OpenCode the player's `words` when the
47
+ * page gave them; else nothing, but Antigravity's empty answer.
48
+ */
49
+ export function hookAnswer(host, rang, words) {
50
+ if (host === "antigravity") {
51
+ return rang ? JSON.stringify({ decision: "continue", reason: bellLine }) : "{}";
52
+ }
53
+ if (!rang) {
54
+ return undefined;
55
+ }
56
+ if (host === "opencode") {
57
+ return words ?? bellLine;
58
+ }
59
+ return host === "codex" ? JSON.stringify({ decision: "block", reason: bellLine }) : bellLine;
60
+ }
61
+ /**
62
+ * Waits at the dashboard of the hook's chat until the player says a sentence: true then; false when there is none to wait at, or it goes away. The chat's own
63
+ * server is the one with its session; after /clear, which gives the hook a new one, and in hosts whose server does not know its session, the only server of
64
+ * its campaign, while no other chat waits there for the page (D-577): better no ring than one in a chat that cannot read the page. The hook may come before its
65
+ * chat's page answers, as in Antigravity: while the campaign has none, it looks again `looks.times` times, every `looks.every` ms.
66
+ */
67
+ export async function waitForBell(input, ports, looks = { every: 500, times: 10 }) {
68
+ return (await bellHeard(input, { ports, looks })).rang;
69
+ }
70
+ /**
71
+ * Waits as waitForBell does, at `ports` or the campaign's, looking again as `looks` says, and says what it heard; with `words`, it asks the page for the
72
+ * player's sentences themselves, which the page holds for the master's next call (D-578).
73
+ */
74
+ export async function bellHeard(input, options = {}) {
75
+ const { ports, looks = { every: 500, times: 10 }, words = false } = options;
76
+ const hook = hookInput(input);
77
+ // Antigravity runs its hooks in .agents: the campaign is found upwards.
78
+ const root = findCampaign(hook.cwd ?? process.cwd());
79
+ if (root === undefined) {
80
+ return { rang: false };
81
+ }
82
+ let ours = await campaignPages(root, ports ?? campaignPorts(root));
83
+ for (let look = 1; ours.length === 0 && look <= looks.times; look++) {
84
+ await new Promise((done) => setTimeout(done, looks.every));
85
+ ours = await campaignPages(root, ports ?? campaignPorts(root));
86
+ }
87
+ // The only page of the campaign, once nobody else waits for it: a chat that does could be this one, and a wrong chat cannot read the page. An older
88
+ // engine's page does not say who waits, so it is never taken as this chat's.
89
+ const only = ours.length === 1 && ours[0].said.others?.length === 0 ? ours[0] : undefined;
90
+ const port = (ours.find((one) => hook.session !== undefined && one.said.session === hook.session) ?? only)?.port;
91
+ const said = port === undefined ? undefined : await askDashboard(port, words ? "/api/bell?words" : "/api/bell");
92
+ // An older engine's page, or one with no words to give, rings alone.
93
+ if (said === "ring") {
94
+ return { rang: true };
95
+ }
96
+ // The words, after a first line with their ids: the page hears they were taken before the chat is given them.
97
+ const head = said?.match(/^ring(?: ([\w,-]*))?\n/);
98
+ if (said === undefined || head === null || head === undefined) {
99
+ return { rang: false };
100
+ }
101
+ if (port !== undefined && head[1] !== undefined && head[1] !== "") {
102
+ await askDashboard(port, `/api/bell?took=${encodeURIComponent(head[1])}`, 2000);
103
+ }
104
+ const text = said.slice(head[0].length).trim();
105
+ return { rang: true, ...(text === "" ? {} : { words: text }) };
106
+ }
107
+ /** The campaign's dashboards that answer at these ports, with what each says of itself. */
108
+ async function campaignPages(root, ports) {
109
+ const probes = await Promise.all(ports.filter((port) => port !== 0).map(async (port) => ({ port, said: await dashboardAt(port) })));
110
+ return probes.flatMap((one) => (one.said !== undefined && one.said.root !== null && samePath(one.said.root, root) ? [{ port: one.port, said: one.said }] : []));
111
+ }
112
+ /** What the hook reads of its host's input: the chat's session, Antigravity's conversation; its folder; the process of OpenCode, which its plugin names. */
113
+ function hookInput(input) {
114
+ try {
115
+ const parsed = JSON.parse(input);
116
+ const session = typeof parsed.session_id === "string" ? parsed.session_id : parsed.conversationId;
117
+ return {
118
+ ...(typeof session === "string" ? { session } : {}),
119
+ ...(typeof parsed.cwd === "string" ? { cwd: parsed.cwd } : {}),
120
+ ...(Number.isInteger(parsed.host_pid) && parsed.host_pid > 0 ? { hostPid: parsed.host_pid } : {}),
121
+ };
122
+ }
123
+ catch {
124
+ return {};
125
+ }
126
+ }
127
+ /** Looks every `every` ms whether the process `pid` still runs: `ended` once it does not. On macOS and Linux a closed terminal does not end the hook. */
128
+ function watchProcessEnd(pid, every = 2000) {
129
+ let timer;
130
+ const ended = new Promise((done) => {
131
+ timer = setInterval(() => {
132
+ if (!processRuns(pid)) {
133
+ done();
134
+ }
135
+ }, every);
136
+ timer.unref();
137
+ });
138
+ return { ended, stop: () => clearInterval(timer) };
139
+ }
140
+ // A process another user runs answers EPERM: it runs.
141
+ function processRuns(pid) {
142
+ try {
143
+ process.kill(pid, 0);
144
+ return true;
145
+ }
146
+ catch (error) {
147
+ return error.code === "EPERM";
148
+ }
149
+ }
@@ -37,8 +37,9 @@ export declare function pageModulesOf(root: string, served: Served): PageModule[
37
37
  */
38
38
  export declare function themeNow(response: ServerResponse, served: Served): Promise<void>;
39
39
  /**
40
- * A file of the theme of the campaign's game system, at theme/<path>, only from its folder, by real paths, and only while the theme passes its checks: a face
41
- * or a picture. Its ornament comes in the colour asked, ?ink=#rrggbb, and turned for a page that reads right to left, &mirrored.
40
+ * A file of the theme of the campaign's game system, at theme/<path>, only from its folder, by real paths, and only while the theme passes its checks: a face,
41
+ * a picture or its style sheet. Its ornament comes in the colour asked, ?ink=#rrggbb, and turned for a page that reads right to left, &mirrored; its cards'
42
+ * texture in the colour asked, &texture.
42
43
  */
43
44
  export declare function sendThemeFile(name: string, query: URLSearchParams, request: IncomingMessage, response: ServerResponse, served: Served): Promise<void>;
44
45
  /**
@@ -16,7 +16,7 @@ import { realPath } from "../../core/files.js";
16
16
  import { files, isInside, withFiles } from "../../core/store.js";
17
17
  import { findHiddenImage, findImage } from "../../images/index.js";
18
18
  import { languagePackFor, packGuide, packPhrases } from "../../languages/index.js";
19
- import { drawnOrnament, isThemeId, readTheme, themeCss, themeFile } from "../../themes/index.js";
19
+ import { drawnOrnament, drawnTexture, isThemeId, readTheme, themeCss, themeFile } from "../../themes/index.js";
20
20
  const imageTypes = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp", ".svg": "image/svg+xml" };
21
21
  const pageTypes = {
22
22
  ".js": "text/javascript; charset=utf-8",
@@ -34,6 +34,8 @@ const pageTypes = {
34
34
  export const themeAddress = "/theme";
35
35
  export const themesAddress = "/themes";
36
36
  const themeTypes = { ...imageTypes, ".woff2": "font/woff2", ".woff": "font/woff", ".ttf": "font/ttf", ".otf": "font/otf" };
37
+ // A theme's own style sheet, served only as the one its theme.yaml names.
38
+ const styleType = "text/css; charset=utf-8";
37
39
  // A picture runs nothing, even an SVG opened by itself.
38
40
  const picturePolicy = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
39
41
  // From src/ and from dist/ alike, the built page is in dist/dashboard, one level up.
@@ -161,6 +163,20 @@ export function packagePageFile(path, served) {
161
163
  export function pageModulesOf(root, served) {
162
164
  return campaignPageModules(root, served.context, campaignSystem(root, served.context));
163
165
  }
166
+ /**
167
+ * A theme's own style sheet, when it names one: the address of a sheet of one line, which the page links and which brings the theme's into the layer
168
+ * theme-style, so that none of its braces leaves that layer and its url() come from its own folder; it changes with what the sheet holds.
169
+ */
170
+ function styleOf(theme, address) {
171
+ const sheet = sheetAddress(theme, address);
172
+ return sheet === undefined ? {} : { style: `${sheet}&layer` };
173
+ }
174
+ /** The address of a theme's own style sheet, which changes with what it holds; undefined when it names none. */
175
+ function sheetAddress(theme, address) {
176
+ const bytes = theme.style === undefined ? undefined : files().bytes(join(theme.folder, theme.style));
177
+ const at = `${address}/${(theme.style ?? "").split("/").map(encodeURIComponent).join("/")}`;
178
+ return bytes === undefined ? undefined : `${at}?v=${createHash("sha1").update(bytes).digest("base64url").slice(0, 12)}`;
179
+ }
164
180
  /**
165
181
  * The theme of the campaign's game system (D-528): its CSS of custom properties, its icons and its name, which the page uses while the player keeps the game's
166
182
  * style on; refused when it does not pass its checks, which validate says; the system's name alone when it names none. Beside it, the themes installed on
@@ -171,7 +187,7 @@ export async function themeNow(response, served) {
171
187
  await served.session.ready();
172
188
  const system = root === undefined ? undefined : withFiles(served.session, () => campaignSystem(root, served.context));
173
189
  const reading = root === undefined ? undefined : withFiles(served.session, () => campaignTheme(root, served.context));
174
- const installed = withFiles(served.session, () => themesHere(served.context)).flatMap(({ id, theme }) => theme === undefined ? [] : [{ id, name: theme.name, css: themeCss(theme, `${themesAddress}/${id}`), icons: theme.icons }]);
190
+ const installed = withFiles(served.session, () => themesHere(served.context).flatMap(({ id, theme }) => theme === undefined ? [] : [{ id, name: theme.name, css: themeCss(theme, `${themesAddress}/${id}`), icons: theme.icons, ...styleOf(theme, `${themesAddress}/${id}`) }]));
175
191
  const themes = installed.length === 0 ? {} : { themes: installed };
176
192
  if (system === undefined) {
177
193
  sendJson(response, 200, themes);
@@ -184,18 +200,20 @@ export async function themeNow(response, served) {
184
200
  sendJson(response, 200, { system: reading.system, refused: true, ...themes });
185
201
  }
186
202
  else {
187
- sendJson(response, 200, { system: reading.system, name: reading.theme.name, css: themeCss(reading.theme, themeAddress), icons: reading.theme.icons, ...themes });
203
+ const style = withFiles(served.session, () => (reading.theme === undefined ? {} : styleOf(reading.theme, themeAddress)));
204
+ sendJson(response, 200, { system: reading.system, name: reading.theme.name, css: themeCss(reading.theme, themeAddress), icons: reading.theme.icons, ...style, ...themes });
188
205
  }
189
206
  }
190
207
  /**
191
- * A file of the theme of the campaign's game system, at theme/<path>, only from its folder, by real paths, and only while the theme passes its checks: a face
192
- * or a picture. Its ornament comes in the colour asked, ?ink=#rrggbb, and turned for a page that reads right to left, &mirrored.
208
+ * A file of the theme of the campaign's game system, at theme/<path>, only from its folder, by real paths, and only while the theme passes its checks: a face,
209
+ * a picture or its style sheet. Its ornament comes in the colour asked, ?ink=#rrggbb, and turned for a page that reads right to left, &mirrored; its cards'
210
+ * texture in the colour asked, &texture.
193
211
  */
194
212
  export async function sendThemeFile(name, query, request, response, served) {
195
213
  const root = findCampaign(served.context.folder);
196
214
  await served.session.ready();
197
- const folder = root === undefined ? undefined : withFiles(served.session, () => campaignTheme(root, served.context))?.theme?.folder;
198
- sendFileOfTheme(folder, name, `${themeAddress}/${name}`, query, request, response, served);
215
+ const theme = root === undefined ? undefined : withFiles(served.session, () => campaignTheme(root, served.context))?.theme;
216
+ sendFileOfTheme(theme, name, themeAddress, query, request, response, served);
199
217
  }
200
218
  /**
201
219
  * A file of a theme installed on its own, at themes/<id>/<path>, as the system's theme sends its files: only from its folder, by real paths, and only while it
@@ -205,21 +223,32 @@ export async function sendInstalledThemeFile(path, query, request, response, ser
205
223
  const [id, ...rest] = path.split("/");
206
224
  const themes = themesFolder(served.context);
207
225
  await served.session.ready();
208
- const folder = themes === undefined || !isThemeId(id) ? undefined : withFiles(served.session, () => readTheme(join(themes, id)).theme?.folder);
209
- sendFileOfTheme(folder, rest.join("/"), `${themesAddress}/${path}`, query, request, response, served);
226
+ const theme = themes === undefined || !isThemeId(id) ? undefined : withFiles(served.session, () => readTheme(join(themes, id)).theme);
227
+ sendFileOfTheme(theme, rest.join("/"), `${themesAddress}/${id}`, query, request, response, served);
210
228
  }
211
- /** A face or a picture of the theme in this folder, by its name in the address; its ornament in the colour asked, ?ink=#rrggbb, and turned, &mirrored. */
212
- function sendFileOfTheme(folder, name, address, query, request, response, served) {
213
- const given = decoded(name);
214
- const file = folder === undefined || given === undefined ? undefined : themeFile(folder, given);
215
- const type = file === undefined ? undefined : themeTypes[extname(file).toLowerCase()];
229
+ /**
230
+ * A face or a picture of this theme, by its name in the address after the theme's, or the style sheet it names, &layer the line that brings it into its
231
+ * layer; its ornament in the colour asked, ?ink=#rrggbb, and turned, &mirrored; its cards' texture, &texture, all it fills in that colour.
232
+ */
233
+ function sendFileOfTheme(theme, name, base, query, request, response, served) {
234
+ const address = `${base}/${name}`;
235
+ const given = decoded(name)?.replaceAll("\\", "/");
236
+ const file = theme === undefined || given === undefined ? undefined : themeFile(theme.folder, given);
237
+ const style = theme !== undefined && given === theme.style;
238
+ const type = file === undefined ? undefined : style ? styleType : themeTypes[extname(file).toLowerCase()];
216
239
  if (file === undefined || type === undefined) {
217
240
  send(response, 404, "text/plain; charset=utf-8", `Nothing at ${address}.`);
218
241
  return;
219
242
  }
243
+ const sheet = theme !== undefined && style && query.has("layer") ? withFiles(served.session, () => sheetAddress(theme, base)) : undefined;
244
+ if (sheet !== undefined) {
245
+ sendTagged(request, response, Buffer.from(`@import url("${sheet}") layer(theme-style);\n`), { "Content-Type": styleType, "Content-Security-Policy": securityHeaders["Content-Security-Policy"] });
246
+ return;
247
+ }
220
248
  const ink = query.get("ink");
221
249
  const tinted = type === imageTypes[".svg"] && ink !== null && /^#[0-9a-f]{6}$/i.test(ink);
222
- const bytes = withFiles(served.session, () => (tinted ? Buffer.from(drawnOrnament(files().text(file) ?? "", ink, query.has("mirrored"))) : files().bytes(file)));
250
+ const drawn = (svg, colour) => (query.has("texture") ? drawnTexture(svg, colour) : drawnOrnament(svg, colour, query.has("mirrored")));
251
+ const bytes = withFiles(served.session, () => (tinted ? Buffer.from(drawn(files().text(file) ?? "", ink)) : files().bytes(file)));
223
252
  if (bytes === undefined) {
224
253
  send(response, 404, "text/plain; charset=utf-8", `Nothing at ${address}.`);
225
254
  return;
@@ -7,8 +7,9 @@ import type { SessionStore } from "../../core/session-store.ts";
7
7
  import { type Acts } from "../player-acts.ts";
8
8
  import type { EngineAsked } from "./engine.ts";
9
9
  import { type Asked, type ShownCard } from "./player.ts";
10
+ import { type DashboardAt } from "./ports.ts";
10
11
  import { type PackageAction, type PackagePhase } from "./writes.ts";
11
- export { campaignPorts, dashboardPorts } from "./ports.ts";
12
+ export { answers, campaignPorts, dashboardAt, dashboardPorts } from "./ports.ts";
12
13
  /** A dashboard that is running: its link, and how to stop it. */
13
14
  export interface Dashboard {
14
15
  url: string;
@@ -36,14 +37,26 @@ export interface DashboardOptions {
36
37
  pageHidden?: number;
37
38
  /** Codex's queue for the player's sentences (D-495): Codex's own command, else a fake in the tests. */
38
39
  queue?: CodexQueue;
40
+ /** How long sentences given to a hook that speaks them wait for the master's next call before they are given back, in ms (D-578). */
41
+ heldFor?: number;
39
42
  }
40
43
  /** Codex's queue: whether this computer has the command, and a message queued in a thread, as the player's own (D-495). */
41
44
  export interface CodexQueue {
42
45
  ready(): boolean;
43
46
  send(thread: string, text: string): Promise<boolean>;
44
47
  }
45
- /** Serves the dashboard of the campaign of context.folder, on 127.0.0.1 only, at the first of the ports that is free; undefined when none is. */
48
+ /**
49
+ * Serves the dashboard of the campaign of context.folder, on 127.0.0.1 only, at the first of the ports that is free, which campaign.yaml then keeps; undefined
50
+ * when none is, or when another chat of the campaign serves its page already: one page for each campaign (D-577).
51
+ */
46
52
  export declare function startDashboard(context: Context, session: SessionStore, options?: DashboardOptions): Promise<Dashboard | undefined>;
53
+ /** The link of the campaign's page where another chat serves it (D-577); undefined when none does. */
54
+ export declare function campaignPageElsewhere(root: string, ports?: number[]): Promise<{
55
+ url: string;
56
+ port: number;
57
+ } | undefined>;
58
+ /** Whether what answers at a port is the page of this campaign. */
59
+ export declare function isCampaignPage(there: DashboardAt | undefined, root: string): boolean;
47
60
  /** What the server keeps while it runs, shared by the files beside it: the pages open, the question asked, what the master has not heard yet. */
48
61
  export interface Served {
49
62
  port: number;
@@ -105,9 +118,18 @@ export interface Served {
105
118
  engineLatest?: EngineAsked;
106
119
  /** The player's sentences said on the page, waiting for the master or heard lately (D-495). */
107
120
  acts: Acts;
108
- /** The doorbell of Claude Code's hook, waiting for a sentence; and whether one ever came, so that this chat has one (D-495). */
121
+ /** The other chats of the campaign that wait for its page, by session, with when each last asked (D-577). */
122
+ others: Map<string, number>;
123
+ /**
124
+ * The doorbell's hook, waiting for a sentence; whether it asked for the player's words, as OpenCode's does (D-578); whether one ever came, so that this chat
125
+ * has one (D-495); and whether the last went away without a ring, as when the chat was stopped, until a hook or a call of the master comes again.
126
+ */
109
127
  bell?: ServerResponse;
128
+ bellWords?: boolean;
110
129
  belled?: boolean;
130
+ bellGone?: boolean;
131
+ /** How long sentences given to a hook wait for the master's next call, in ms (D-578). */
132
+ heldFor: number;
111
133
  /** Codex's queue, and the sentences being put in it now (D-495). */
112
134
  queue: CodexQueue;
113
135
  queueing?: Promise<void>;