briyah 2.0.2 → 2.0.3

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 (225) hide show
  1. package/LICENSE +216 -0
  2. package/data/common/config/markup +1 -1
  3. package/data/packs/dnd5e/agents/player.json +11 -11
  4. package/data/packs/dnd5e/prompts/character_creator/defaults_config.json +21 -20
  5. package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +19 -12
  6. package/data/packs/dnd5e/prompts/dnd_player/perceive.prompt +10 -6
  7. package/dist-sdk/server/src/app.service.d.ts +1 -0
  8. package/dist-sdk/server/src/app.service.js +26 -3
  9. package/dist-sdk/server/src/room/nickname.d.ts +1 -0
  10. package/dist-sdk/server/src/room/nickname.js +15 -0
  11. package/dist-sdk/server/src/room/room-store.service.d.ts +1 -0
  12. package/dist-sdk/server/src/room/room-store.service.js +4 -0
  13. package/dist-sdk/server/src/room/room.d.ts +28 -1
  14. package/dist-sdk/server/src/room/room.js +235 -12
  15. package/dist-sdk/server/src/rpg/rpg-roster.d.ts +1 -3
  16. package/dist-sdk/server/src/rpg/rpg-roster.js +12 -49
  17. package/dist-sdk/server/src/rpg/rpg.service.js +5 -5
  18. package/dist-sdk/server/src/sdk/index.d.ts +0 -1
  19. package/dist-sdk/server/src/sdk/index.js +1 -3
  20. package/dist-sdk/server/src/tools/core/index.d.ts +3 -0
  21. package/dist-sdk/server/src/tools/core/index.js +9 -0
  22. package/dist-sdk/server/src/tools/core/rename.tool.d.ts +2 -0
  23. package/dist-sdk/server/src/tools/core/rename.tool.js +61 -0
  24. package/dist-sdk/server/src/tools/native-tool.types.d.ts +10 -0
  25. package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +9 -1
  26. package/dist-sdk/server/src/tools/packs/index.d.ts +3 -2
  27. package/dist-sdk/server/src/tools/packs/index.js +17 -9
  28. package/dist-sdk/shared/types/app.types.d.ts +0 -1
  29. package/docs/assets/hierarchy.js +1 -1
  30. package/docs/assets/navigation.js +1 -1
  31. package/docs/assets/search.js +1 -1
  32. package/docs/classes/Agent.html +73 -73
  33. package/docs/classes/Briyah.html +16 -16
  34. package/docs/classes/BriyahConfigService.html +7 -7
  35. package/docs/classes/NativeToolRegistry.html +10 -10
  36. package/docs/classes/PackInstantiationService.html +7 -7
  37. package/docs/classes/PackService.html +13 -13
  38. package/docs/classes/Room.html +190 -94
  39. package/docs/classes/RoomMessage.html +22 -22
  40. package/docs/enums/MessageAction.html +18 -18
  41. package/docs/functions/availableToolPacks.html +5 -5
  42. package/docs/functions/buildMarkdown.html +4 -4
  43. package/docs/functions/dnd5eTools.html +4 -4
  44. package/docs/functions/installToolPacks.html +8 -5
  45. package/docs/functions/pageMarker.html +4 -4
  46. package/docs/functions/registerToolPacks.html +4 -4
  47. package/docs/functions/splitMarkdownIntoPages.html +4 -4
  48. package/docs/functions/stripWrappingFence.html +4 -4
  49. package/docs/hierarchy.html +11 -11
  50. package/docs/index.html +4 -4
  51. package/docs/interfaces/AgentCreationOptions.html +12 -12
  52. package/docs/interfaces/AgentInfo.html +30 -30
  53. package/docs/interfaces/AgentMessagesResponse.html +8 -8
  54. package/docs/interfaces/AppService.html +140 -137
  55. package/docs/interfaces/Artifact.html +9 -9
  56. package/docs/interfaces/ArtifactMetadata.html +13 -13
  57. package/docs/interfaces/ArtifactWriteOptions.html +7 -7
  58. package/docs/interfaces/AttachDocumentResponse.html +6 -6
  59. package/docs/interfaces/BriyahConfigOptions.html +12 -12
  60. package/docs/interfaces/ChapterInfo.html +6 -6
  61. package/docs/interfaces/Character.html +10 -10
  62. package/docs/interfaces/ConversionAgent.html +6 -6
  63. package/docs/interfaces/CreateAgentResponse.html +5 -5
  64. package/docs/interfaces/CreateRoomResponse.html +6 -6
  65. package/docs/interfaces/CreateStoryResponse.html +5 -5
  66. package/docs/interfaces/FileList.html +5 -5
  67. package/docs/interfaces/FileMetadata.html +10 -10
  68. package/docs/interfaces/IConfigService.html +5 -5
  69. package/docs/interfaces/InstantiateModels.html +6 -6
  70. package/docs/interfaces/InstantiateRoomResult.html +7 -7
  71. package/docs/interfaces/LoadedPack.html +16 -16
  72. package/docs/interfaces/LoggingOptions.html +9 -9
  73. package/docs/interfaces/Message.html +9 -9
  74. package/docs/interfaces/ModelChoice.html +7 -7
  75. package/docs/interfaces/ModelInfo.html +8 -8
  76. package/docs/interfaces/NativeToolDefinition.html +10 -10
  77. package/docs/interfaces/PackAgentTemplate.html +9 -9
  78. package/docs/interfaces/PackRoomTemplate.html +11 -11
  79. package/docs/interfaces/PackView.html +20 -20
  80. package/docs/interfaces/PdfConversionOptions.html +10 -10
  81. package/docs/interfaces/PdfConversionResult.html +10 -10
  82. package/docs/interfaces/PdfMarkdownOptions.html +21 -21
  83. package/docs/interfaces/PdfMarkdownResult.html +11 -11
  84. package/docs/interfaces/PdfPageMarkdown.html +9 -9
  85. package/docs/interfaces/PreparedPromptResponse.html +6 -6
  86. package/docs/interfaces/ProcessTextResponse.html +10 -10
  87. package/docs/interfaces/PromptFile.html +7 -7
  88. package/docs/interfaces/PromptFileContent.html +8 -8
  89. package/docs/interfaces/PromptFilesResponse.html +5 -5
  90. package/docs/interfaces/PromptFolder.html +8 -8
  91. package/docs/interfaces/PromptFolderDefaults.html +19 -19
  92. package/docs/interfaces/PromptFolderDefaultsResponse.html +7 -7
  93. package/docs/interfaces/PromptFoldersResponse.html +5 -5
  94. package/docs/interfaces/RoomDetails.html +19 -19
  95. package/docs/interfaces/RoomErrorUpdate.html +8 -8
  96. package/docs/interfaces/RoomInfo.html +10 -10
  97. package/docs/interfaces/RoomMessageUpdate.html +13 -13
  98. package/docs/interfaces/RoomMessagesResponse.html +6 -6
  99. package/docs/interfaces/SendMessageResult.html +6 -6
  100. package/docs/interfaces/StoryErrorEvent.html +8 -8
  101. package/docs/interfaces/StoryIdea.html +8 -8
  102. package/docs/interfaces/StoryInfo.html +28 -28
  103. package/docs/interfaces/StoryIntroduceCharacterEvent.html +7 -7
  104. package/docs/interfaces/StoryProgressChapterEvent.html +6 -6
  105. package/docs/interfaces/StoryState.html +12 -12
  106. package/docs/interfaces/StoryStateEvent.html +7 -7
  107. package/docs/interfaces/ToolArtifact.html +9 -9
  108. package/docs/interfaces/ToolCaller.html +7 -7
  109. package/docs/interfaces/ToolDefinition.html +9 -9
  110. package/docs/interfaces/ToolHelpers.html +7 -7
  111. package/docs/interfaces/ToolPackDocuments.html +6 -6
  112. package/docs/interfaces/ToolParameter.html +8 -8
  113. package/docs/interfaces/ToolRoomAccess.html +49 -16
  114. package/docs/interfaces/ToolSummary.html +8 -8
  115. package/docs/interfaces/ToolsResponse.html +7 -7
  116. package/docs/interfaces/Transaction.html +13 -13
  117. package/docs/interfaces/TransactionHistoryResponse.html +6 -6
  118. package/docs/modules.html +6 -6
  119. package/docs/types/PackOrigin.html +4 -4
  120. package/docs/types/PromptScope.html +4 -4
  121. package/docs/types/RoomTurnMode.html +4 -4
  122. package/docs/types/RoomUpdate.html +4 -4
  123. package/docs/types/RosterOverrides.html +4 -4
  124. package/docs/types/ToolContext.html +4 -4
  125. package/docs/types/ToolRunResult.html +4 -4
  126. package/package.json +32 -3
  127. package/data/packs/acts/agents/character-guide.json +0 -6
  128. package/data/packs/acts/agents/discipleship-mentor.json +0 -6
  129. package/data/packs/acts/agents/mentor-coach.json +0 -6
  130. package/data/packs/acts/agents/student.json +0 -13
  131. package/data/packs/acts/agents/table-moderator.json +0 -6
  132. package/data/packs/acts/artifacts/chapter-01-acts-1.md +0 -405
  133. package/data/packs/acts/artifacts/chapter-02-acts-2.md +0 -443
  134. package/data/packs/acts/artifacts/chapter-03-acts-3.md +0 -409
  135. package/data/packs/acts/artifacts/chapter-04-acts-4.md +0 -438
  136. package/data/packs/acts/artifacts/chapter-05-acts-5.md +0 -434
  137. package/data/packs/acts/artifacts/chapter-06-acts-6.md +0 -441
  138. package/data/packs/acts/artifacts/chapter-07-acts-7.md +0 -472
  139. package/data/packs/acts/artifacts/chapter-08-acts-8.md +0 -512
  140. package/data/packs/acts/artifacts/chapter-09-acts-9.md +0 -346
  141. package/data/packs/acts/artifacts/chapter-10-acts-10.md +0 -367
  142. package/data/packs/acts/artifacts/chapter-11-acts-11.md +0 -391
  143. package/data/packs/acts/artifacts/chapter-12-acts-12.md +0 -390
  144. package/data/packs/acts/artifacts/chapter-13-acts-13.md +0 -388
  145. package/data/packs/acts/artifacts/chapter-14-acts-14.md +0 -466
  146. package/data/packs/acts/artifacts/chapter-15-acts-15.md +0 -413
  147. package/data/packs/acts/artifacts/chapter-16-acts-16.md +0 -585
  148. package/data/packs/acts/artifacts/chapter-17-acts-17.md +0 -428
  149. package/data/packs/acts/artifacts/chapter-18-acts-18.md +0 -486
  150. package/data/packs/acts/artifacts/chapter-19-acts-19.md +0 -461
  151. package/data/packs/acts/artifacts/chapter-20-acts-20.md +0 -389
  152. package/data/packs/acts/artifacts/chapter-21-acts-21.md +0 -452
  153. package/data/packs/acts/artifacts/chapter-22-acts-22.md +0 -424
  154. package/data/packs/acts/artifacts/chapter-23-acts-23.md +0 -395
  155. package/data/packs/acts/artifacts/chapter-24-acts-24.md +0 -446
  156. package/data/packs/acts/artifacts/chapter-25-acts-25.md +0 -391
  157. package/data/packs/acts/artifacts/chapter-26-acts-26.md +0 -431
  158. package/data/packs/acts/artifacts/chapter-27-acts-27.md +0 -530
  159. package/data/packs/acts/artifacts/chapter-28-acts-28.md +0 -1871
  160. package/data/packs/acts/artifacts/chapters.manifest.json +0 -170
  161. package/data/packs/acts/artifacts/character_guide-creation.md +0 -112
  162. package/data/packs/acts/artifacts/discipleship_mentor-procedure.md +0 -154
  163. package/data/packs/acts/artifacts/discipleship_mentor-systems.md +0 -72
  164. package/data/packs/acts/artifacts/manifest.json +0 -197
  165. package/data/packs/acts/artifacts/stage-guide.md +0 -94
  166. package/data/packs/acts/pack.json +0 -6
  167. package/data/packs/acts/prompts/acts_player/defaults_config.json +0 -5
  168. package/data/packs/acts/prompts/acts_player/perceive.json +0 -29
  169. package/data/packs/acts/prompts/acts_player/perceive.prompt +0 -87
  170. package/data/packs/acts/prompts/acts_player/system_instruction.prompt +0 -0
  171. package/data/packs/acts/prompts/acts_room_moderator/defaults_config.json +0 -9
  172. package/data/packs/acts/prompts/acts_room_moderator/moderate.json +0 -34
  173. package/data/packs/acts/prompts/acts_room_moderator/moderate.prompt +0 -70
  174. package/data/packs/acts/prompts/acts_room_moderator/system_instruction.prompt +0 -0
  175. package/data/packs/acts/prompts/character_guide/defaults_config.json +0 -18
  176. package/data/packs/acts/prompts/character_guide/perceive.json +0 -29
  177. package/data/packs/acts/prompts/character_guide/perceive.prompt +0 -140
  178. package/data/packs/acts/prompts/character_guide/system_instruction.prompt +0 -0
  179. package/data/packs/acts/prompts/discipleship_mentor/defaults_config.json +0 -23
  180. package/data/packs/acts/prompts/discipleship_mentor/perceive.json +0 -33
  181. package/data/packs/acts/prompts/discipleship_mentor/perceive.prompt +0 -245
  182. package/data/packs/acts/prompts/discipleship_mentor/system_instruction.prompt +0 -0
  183. package/data/packs/acts/prompts/mentor_coach/defaults_config.json +0 -13
  184. package/data/packs/acts/prompts/mentor_coach/perceive.json +0 -29
  185. package/data/packs/acts/prompts/mentor_coach/perceive.prompt +0 -87
  186. package/data/packs/acts/prompts/mentor_coach/system_instruction.prompt +0 -0
  187. package/data/packs/acts/rooms/session.json +0 -14
  188. package/data/packs/acts/rooms/training.json +0 -58
  189. package/dist-sdk/server/src/tools/packs/acts/data/cards.d.ts +0 -53
  190. package/dist-sdk/server/src/tools/packs/acts/data/cards.js +0 -54
  191. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.d.ts +0 -2
  192. package/dist-sdk/server/src/tools/packs/acts/data/character-cards.generated.js +0 -185
  193. package/dist-sdk/server/src/tools/packs/acts/data/encounters.d.ts +0 -12
  194. package/dist-sdk/server/src/tools/packs/acts/data/encounters.js +0 -102
  195. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.d.ts +0 -2
  196. package/dist-sdk/server/src/tools/packs/acts/data/event-cards.generated.js +0 -196
  197. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.d.ts +0 -2
  198. package/dist-sdk/server/src/tools/packs/acts/data/item-cards.generated.js +0 -1311
  199. package/dist-sdk/server/src/tools/packs/acts/engine/cards.d.ts +0 -5
  200. package/dist-sdk/server/src/tools/packs/acts/engine/cards.js +0 -27
  201. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.d.ts +0 -37
  202. package/dist-sdk/server/src/tools/packs/acts/engine/challenge.js +0 -120
  203. package/dist-sdk/server/src/tools/packs/acts/engine/dice.d.ts +0 -20
  204. package/dist-sdk/server/src/tools/packs/acts/engine/dice.js +0 -41
  205. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.d.ts +0 -54
  206. package/dist-sdk/server/src/tools/packs/acts/engine/sheet.js +0 -200
  207. package/dist-sdk/server/src/tools/packs/acts/index.d.ts +0 -2
  208. package/dist-sdk/server/src/tools/packs/acts/index.js +0 -24
  209. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.d.ts +0 -2
  210. package/dist-sdk/server/src/tools/packs/acts/tools/award.tool.js +0 -184
  211. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.d.ts +0 -2
  212. package/dist-sdk/server/src/tools/packs/acts/tools/challenge.tool.js +0 -107
  213. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.d.ts +0 -3
  214. package/dist-sdk/server/src/tools/packs/acts/tools/chapter.tool.js +0 -146
  215. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.d.ts +0 -4
  216. package/dist-sdk/server/src/tools/packs/acts/tools/check.tool.js +0 -241
  217. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.d.ts +0 -3
  218. package/dist-sdk/server/src/tools/packs/acts/tools/encounter.tool.js +0 -72
  219. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.d.ts +0 -2
  220. package/dist-sdk/server/src/tools/packs/acts/tools/faith.tool.js +0 -75
  221. package/dist-sdk/server/src/tools/packs/acts/tools/shared.d.ts +0 -20
  222. package/dist-sdk/server/src/tools/packs/acts/tools/shared.js +0 -70
  223. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.d.ts +0 -4
  224. package/dist-sdk/server/src/tools/packs/acts/tools/sheet.tools.js +0 -215
  225. package/docs/functions/actsTools.html +0 -44
@@ -1,5 +0,0 @@
1
- import { CharacterCard, ItemCard } from '../data/cards';
2
- import { AbilityEntry, HeldCard } from './sheet';
3
- export declare function heldFromCard(card: ItemCard): HeldCard;
4
- export declare function heldFromText(name: string, effect: string): HeldCard;
5
- export declare function abilityFromCharacterCard(card: CharacterCard): AbilityEntry;
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.heldFromCard = heldFromCard;
4
- exports.heldFromText = heldFromText;
5
- exports.abilityFromCharacterCard = abilityFromCharacterCard;
6
- function heldFromCard(card) {
7
- return {
8
- n: card.name,
9
- id: card.id,
10
- e: card.effect,
11
- ...(card.bonus
12
- ? { b: { a: card.bonus.attribute, v: card.bonus.value, w: card.bonus.when } }
13
- : {}),
14
- ...(card.limit ? { lim: card.limit } : {}),
15
- };
16
- }
17
- function heldFromText(name, effect) {
18
- return { n: name.trim(), e: effect.trim() };
19
- }
20
- function abilityFromCharacterCard(card) {
21
- const oncePerSession = /once per session/i.test(card.ability);
22
- return {
23
- n: card.name,
24
- e: card.ability,
25
- ...(oncePerSession ? { lim: 'session' } : {}),
26
- };
27
- }
@@ -1,37 +0,0 @@
1
- import { AttrKey } from '../data/cards';
2
- import { CHALLENGE_ARTIFACT } from './sheet';
3
- export { CHALLENGE_ARTIFACT };
4
- export type ChallengeOutcome = 'succeeded' | 'failed' | 'running';
5
- export interface ChallengeRoll {
6
- who: string;
7
- attribute: AttrKey;
8
- total: number;
9
- passed: boolean;
10
- stage?: string;
11
- }
12
- export interface ChallengeState {
13
- name: string;
14
- dc: number;
15
- needed: number;
16
- allowed: number;
17
- attributes: AttrKey[];
18
- stages: string[];
19
- rolls: ChallengeRoll[];
20
- successes: number;
21
- failures: number;
22
- outcome: ChallengeOutcome;
23
- }
24
- export interface ChallengeSpec {
25
- name: string;
26
- dc: number;
27
- needed: number;
28
- allowed?: number;
29
- attributes?: string[];
30
- stages?: string[];
31
- }
32
- export declare function newChallenge(spec: ChallengeSpec): ChallengeState;
33
- export declare function recordRoll(state: ChallengeState, roll: ChallengeRoll): ChallengeState;
34
- export declare function remaining(state: ChallengeState): string;
35
- export declare function currentStage(state: ChallengeState): string | undefined;
36
- export declare function renderChallenge(state: ChallengeState): string;
37
- export declare function parseChallenge(body: string | undefined): ChallengeState | undefined;
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHALLENGE_ARTIFACT = void 0;
4
- exports.newChallenge = newChallenge;
5
- exports.recordRoll = recordRoll;
6
- exports.remaining = remaining;
7
- exports.currentStage = currentStage;
8
- exports.renderChallenge = renderChallenge;
9
- exports.parseChallenge = parseChallenge;
10
- const cards_1 = require("../data/cards");
11
- const sheet_1 = require("./sheet");
12
- Object.defineProperty(exports, "CHALLENGE_ARTIFACT", { enumerable: true, get: function () { return sheet_1.CHALLENGE_ARTIFACT; } });
13
- function newChallenge(spec) {
14
- const needed = Math.trunc(spec.needed);
15
- if (!Number.isFinite(needed) || needed < 1) {
16
- throw new Error(`A challenge needs at least one success to be worth rolling; "${spec.name}" asks for ${spec.needed}.`);
17
- }
18
- const attributes = (spec.attributes || [])
19
- .map((name) => String(name).toLowerCase().trim())
20
- .filter((name) => cards_1.ATTRIBUTES.includes(name));
21
- return {
22
- name: spec.name.trim() || 'Challenge',
23
- dc: Math.trunc(spec.dc),
24
- needed,
25
- allowed: Math.max(0, Math.trunc(spec.allowed ?? 0)),
26
- attributes,
27
- stages: (spec.stages || []).map((stage) => String(stage).trim()).filter(Boolean),
28
- rolls: [],
29
- successes: 0,
30
- failures: 0,
31
- outcome: 'running',
32
- };
33
- }
34
- function recordRoll(state, roll) {
35
- if (state.outcome !== 'running')
36
- return state;
37
- const stage = roll.stage ?? currentStage(state);
38
- state.rolls.push(stage ? { ...roll, stage } : roll);
39
- if (roll.passed)
40
- state.successes++;
41
- else
42
- state.failures++;
43
- if (state.successes >= state.needed) {
44
- state.outcome = 'succeeded';
45
- }
46
- else if (state.allowed > 0 && state.failures >= state.allowed) {
47
- state.outcome = 'failed';
48
- }
49
- else if (state.stages.length > 0 && state.rolls.length >= state.stages.length) {
50
- state.outcome = state.successes >= state.needed ? 'succeeded' : 'failed';
51
- }
52
- return state;
53
- }
54
- function remaining(state) {
55
- if (state.outcome === 'succeeded')
56
- return 'won';
57
- if (state.outcome === 'failed')
58
- return 'lost';
59
- const successesLeft = state.needed - state.successes;
60
- const failuresLeft = state.allowed > 0 ? state.allowed - state.failures : 0;
61
- const parts = [`${successesLeft} more success${successesLeft === 1 ? '' : 'es'}`];
62
- if (state.allowed > 0) {
63
- parts.push(`${failuresLeft} failure${failuresLeft === 1 ? '' : 's'} left`);
64
- }
65
- if (state.stages.length > 0) {
66
- const next = state.stages[state.rolls.length];
67
- if (next)
68
- parts.push(`next: ${next}`);
69
- }
70
- return parts.join(', ');
71
- }
72
- function currentStage(state) {
73
- return state.stages[state.rolls.length];
74
- }
75
- const FENCE_TAG = 'briyah-challenge';
76
- function renderChallenge(state) {
77
- const lines = [`# ${state.name}`, ''];
78
- lines.push(`**${state.successes}** success${state.successes === 1 ? '' : 'es'} · ` +
79
- `**${state.failures}** failure${state.failures === 1 ? '' : 's'} · ` +
80
- `goal ${state.needed}${state.allowed > 0 ? ` before ${state.allowed}` : ''} · DC ${state.dc}`);
81
- lines.push('');
82
- if (state.attributes.length > 0) {
83
- lines.push(`Allowed attributes: ${state.attributes.map(titleCaseAttr).join(', ')}`);
84
- lines.push('');
85
- }
86
- if (state.rolls.length > 0) {
87
- lines.push('| # | Who | Attribute | Total | Result |');
88
- lines.push('|---|---|---|---|---|');
89
- state.rolls.forEach((roll, index) => {
90
- lines.push(`| ${index + 1}${roll.stage ? ` ${roll.stage}` : ''} | ${roll.who} | ` +
91
- `${titleCaseAttr(roll.attribute)} | ${roll.total} | ${roll.passed ? 'success' : 'failure'} |`);
92
- });
93
- lines.push('');
94
- }
95
- lines.push(state.outcome === 'running'
96
- ? `**Running** — ${remaining(state)}.`
97
- : `**${state.outcome === 'succeeded' ? 'Succeeded' : 'Failed'}.**`);
98
- lines.push('');
99
- lines.push('```' + FENCE_TAG);
100
- lines.push(JSON.stringify(state, null, 2));
101
- lines.push('```');
102
- return lines.join('\n');
103
- }
104
- function parseChallenge(body) {
105
- if (!body)
106
- return undefined;
107
- const fence = new RegExp('```' + FENCE_TAG + '\\s*\\n([\\s\\S]*?)\\n```');
108
- const match = fence.exec(body);
109
- if (!match)
110
- return undefined;
111
- try {
112
- return JSON.parse(match[1]);
113
- }
114
- catch {
115
- return undefined;
116
- }
117
- }
118
- function titleCaseAttr(attribute) {
119
- return attribute ? attribute[0].toUpperCase() + attribute.slice(1) : attribute;
120
- }
@@ -1,20 +0,0 @@
1
- export type Rng = () => number;
2
- export declare const defaultRng: Rng;
3
- export declare function rollDie(sides: number, rng?: Rng): number;
4
- export interface Modifier {
5
- source: string;
6
- value: number;
7
- }
8
- export interface CheckResult {
9
- die: number;
10
- modifiers: Modifier[];
11
- total: number;
12
- dc: number;
13
- passed: boolean;
14
- natural20: boolean;
15
- natural1: boolean;
16
- }
17
- export declare function rollCheck(dc: number, modifiers: Modifier[], rng?: Rng): CheckResult;
18
- export declare function describeCheck(result: CheckResult): string;
19
- export declare const DIFFICULTY_BANDS: Record<string, number>;
20
- export declare function dcForBand(band: string): number | undefined;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DIFFICULTY_BANDS = exports.defaultRng = void 0;
4
- exports.rollDie = rollDie;
5
- exports.rollCheck = rollCheck;
6
- exports.describeCheck = describeCheck;
7
- exports.dcForBand = dcForBand;
8
- exports.defaultRng = Math.random;
9
- function rollDie(sides, rng = exports.defaultRng) {
10
- return Math.floor(rng() * sides) + 1;
11
- }
12
- function rollCheck(dc, modifiers, rng = exports.defaultRng) {
13
- const die = rollDie(20, rng);
14
- const total = modifiers.reduce((sum, modifier) => sum + modifier.value, die);
15
- return {
16
- die,
17
- modifiers,
18
- total,
19
- dc,
20
- passed: total >= dc,
21
- natural20: die === 20,
22
- natural1: die === 1,
23
- };
24
- }
25
- function describeCheck(result) {
26
- const parts = result.modifiers
27
- .filter((modifier) => modifier.value !== 0)
28
- .map((modifier) => `${modifier.value >= 0 ? '+' : ''}${modifier.value} ${modifier.source}`);
29
- const sum = [`d20 ${result.die}`, ...parts].join(' ');
30
- return `${sum} = ${result.total} vs DC ${result.dc} — ${result.passed ? 'success' : 'failure'}`;
31
- }
32
- exports.DIFFICULTY_BANDS = {
33
- easy: 10,
34
- normal: 12,
35
- standard: 12,
36
- hard: 14,
37
- very_hard: 16,
38
- };
39
- function dcForBand(band) {
40
- return exports.DIFFICULTY_BANDS[(band || '').toLowerCase().replace(/[\s-]+/g, '_')];
41
- }
@@ -1,54 +0,0 @@
1
- import { AttrKey, CardLimit } from '../data/cards';
2
- export declare const SHEET_STATE_VERSION = 1;
3
- export declare const SHEET_NAME_PREFIX = "Sheet: ";
4
- export declare const PARTY_STATUS_ARTIFACT = "Party Status";
5
- export declare const CHALLENGE_ARTIFACT = "Challenge";
6
- export declare const SESSION_PROGRESS_ARTIFACT = "Session Progress";
7
- export declare const MAX_FAITH_POINTS = 10;
8
- export declare const ATTRIBUTE_ARRAY: number[];
9
- export interface AbilityEntry {
10
- n: string;
11
- e: string;
12
- lim?: CardLimit;
13
- sp?: boolean;
14
- }
15
- export interface HeldCard {
16
- n: string;
17
- id?: string;
18
- e: string;
19
- b?: {
20
- a: AttrKey;
21
- v: number;
22
- w: string;
23
- };
24
- lim?: CardLimit;
25
- sp?: boolean;
26
- }
27
- export interface ActsSheetState {
28
- v: number;
29
- name: string;
30
- player?: string;
31
- background: string;
32
- attr: Record<AttrKey, number>;
33
- fp: number;
34
- abilities: AbilityEntry[];
35
- items: HeldCard[];
36
- events: string[];
37
- allies: string[];
38
- chapters: number[];
39
- }
40
- export declare class SheetError extends Error {
41
- constructor(message: string);
42
- }
43
- export declare function sheetArtifactName(characterName: string): string;
44
- export declare function characterNameFromArtifact(artifactName: string): string;
45
- export declare function isSheetArtifact(artifactName: string): boolean;
46
- export declare function emptyAttributes(): Record<AttrKey, number>;
47
- export declare function parseSheet(body: string): ActsSheetState;
48
- export declare function normalizeState(raw: any): ActsSheetState;
49
- export declare function clamp(value: number, min: number, max: number): number;
50
- export declare function extractNotes(body: string): string;
51
- export declare function renderSheet(state: ActsSheetState, notes: string): string;
52
- export declare function titleCase(text: string): string;
53
- export declare function partyLine(state: ActsSheetState): string;
54
- export declare function renderPartyStatus(states: readonly ActsSheetState[]): string;
@@ -1,200 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SheetError = exports.ATTRIBUTE_ARRAY = exports.MAX_FAITH_POINTS = exports.SESSION_PROGRESS_ARTIFACT = exports.CHALLENGE_ARTIFACT = exports.PARTY_STATUS_ARTIFACT = exports.SHEET_NAME_PREFIX = exports.SHEET_STATE_VERSION = void 0;
4
- exports.sheetArtifactName = sheetArtifactName;
5
- exports.characterNameFromArtifact = characterNameFromArtifact;
6
- exports.isSheetArtifact = isSheetArtifact;
7
- exports.emptyAttributes = emptyAttributes;
8
- exports.parseSheet = parseSheet;
9
- exports.normalizeState = normalizeState;
10
- exports.clamp = clamp;
11
- exports.extractNotes = extractNotes;
12
- exports.renderSheet = renderSheet;
13
- exports.titleCase = titleCase;
14
- exports.partyLine = partyLine;
15
- exports.renderPartyStatus = renderPartyStatus;
16
- const cards_1 = require("../data/cards");
17
- exports.SHEET_STATE_VERSION = 1;
18
- exports.SHEET_NAME_PREFIX = 'Sheet: ';
19
- exports.PARTY_STATUS_ARTIFACT = 'Party Status';
20
- exports.CHALLENGE_ARTIFACT = 'Challenge';
21
- exports.SESSION_PROGRESS_ARTIFACT = 'Session Progress';
22
- const STATE_FENCE_TAG = 'briyah-state';
23
- const NOTES_OPEN = '<!-- briyah:notes -->';
24
- const NOTES_CLOSE = '<!-- /briyah:notes -->';
25
- const MAX_NOTES_CHARS = 1500;
26
- exports.MAX_FAITH_POINTS = 10;
27
- exports.ATTRIBUTE_ARRAY = [3, 2, 2, 1, 1];
28
- class SheetError extends Error {
29
- constructor(message) {
30
- super(message);
31
- this.name = 'SheetError';
32
- }
33
- }
34
- exports.SheetError = SheetError;
35
- function sheetArtifactName(characterName) {
36
- return `${exports.SHEET_NAME_PREFIX}${characterName.trim()}`;
37
- }
38
- function characterNameFromArtifact(artifactName) {
39
- return artifactName.slice(exports.SHEET_NAME_PREFIX.length).trim();
40
- }
41
- function isSheetArtifact(artifactName) {
42
- return artifactName.startsWith(exports.SHEET_NAME_PREFIX);
43
- }
44
- function emptyAttributes() {
45
- return { faith: 0, compassion: 0, knowledge: 0, wisdom: 0, courage: 0 };
46
- }
47
- function parseSheet(body) {
48
- const fence = new RegExp('```' + STATE_FENCE_TAG + '\\s*\\n([\\s\\S]*?)\\n```');
49
- const match = fence.exec(body || '');
50
- if (!match) {
51
- throw new SheetError(`This sheet has no \`\`\`${STATE_FENCE_TAG} block, so its data cannot be read. ` +
52
- 'Do not overwrite it — the character\'s items and Faith Points are only in that block. ' +
53
- 'Recover the last good copy from the Artifacts tab, or rebuild the character with create_character ' +
54
- 'only if the sheet is genuinely empty.');
55
- }
56
- let raw;
57
- try {
58
- raw = JSON.parse(match[1]);
59
- }
60
- catch (error) {
61
- throw new SheetError(`This sheet's \`\`\`${STATE_FENCE_TAG} block is not valid JSON (${error.message}), so its data ` +
62
- 'cannot be read. Do not overwrite it — fix the block in the Artifacts tab instead.');
63
- }
64
- return normalizeState(raw);
65
- }
66
- function normalizeState(raw) {
67
- const attr = emptyAttributes();
68
- for (const key of cards_1.ATTRIBUTES) {
69
- const value = Number(raw?.attr?.[key]);
70
- attr[key] = Number.isFinite(value) ? Math.trunc(value) : 0;
71
- }
72
- return {
73
- v: Number(raw?.v) || exports.SHEET_STATE_VERSION,
74
- name: String(raw?.name || '').trim(),
75
- ...(raw?.player ? { player: String(raw.player).trim() } : {}),
76
- background: String(raw?.background || '').trim(),
77
- attr,
78
- fp: clamp(Number(raw?.fp) || 0, 0, exports.MAX_FAITH_POINTS),
79
- abilities: Array.isArray(raw?.abilities) ? raw.abilities.filter(hasName) : [],
80
- items: Array.isArray(raw?.items) ? raw.items.filter(hasName) : [],
81
- events: Array.isArray(raw?.events) ? raw.events.map(String) : [],
82
- allies: Array.isArray(raw?.allies) ? raw.allies.map(String) : [],
83
- chapters: Array.isArray(raw?.chapters) ? normalizeChapters(raw.chapters) : [],
84
- };
85
- }
86
- function hasName(entry) {
87
- return entry && typeof entry.n === 'string' && entry.n.trim().length > 0;
88
- }
89
- function normalizeChapters(raw) {
90
- const chapters = raw.map((value) => Number(value)).filter((value) => Number.isInteger(value));
91
- return [...new Set(chapters)].sort((a, b) => a - b);
92
- }
93
- function clamp(value, min, max) {
94
- return Math.max(min, Math.min(max, value));
95
- }
96
- function extractNotes(body) {
97
- const open = (body || '').indexOf(NOTES_OPEN);
98
- const close = (body || '').indexOf(NOTES_CLOSE);
99
- if (open === -1 || close === -1 || close < open)
100
- return '';
101
- return body.slice(open + NOTES_OPEN.length, close).trim();
102
- }
103
- function signed(value) {
104
- return value >= 0 ? `+${value}` : `${value}`;
105
- }
106
- function faithBoxes(points) {
107
- const held = clamp(points, 0, exports.MAX_FAITH_POINTS);
108
- return '▣'.repeat(held) + '☐'.repeat(exports.MAX_FAITH_POINTS - held);
109
- }
110
- function renderSheet(state, notes) {
111
- const lines = [];
112
- lines.push(`# ${state.name || 'Unnamed character'}`);
113
- const who = [state.background, state.player ? `played by ${state.player}` : '']
114
- .filter(Boolean)
115
- .join(' · ');
116
- if (who)
117
- lines.push(`*${who}*`);
118
- lines.push('');
119
- lines.push('## Attributes');
120
- lines.push('');
121
- lines.push(cards_1.ATTRIBUTES.map((key) => `**${titleCase(key)}** ${signed(state.attr[key])}`).join(' · '));
122
- lines.push('');
123
- lines.push(`## Faith Points — ${state.fp}/${exports.MAX_FAITH_POINTS}`);
124
- lines.push('');
125
- lines.push(faithBoxes(state.fp));
126
- lines.push('');
127
- lines.push('*Spend one to reroll a failed roll, or to add +2 to a roll.*');
128
- lines.push('');
129
- lines.push('## Abilities');
130
- lines.push('');
131
- if (state.abilities.length === 0) {
132
- lines.push('*None yet.*');
133
- }
134
- else {
135
- for (const ability of state.abilities) {
136
- const spent = ability.sp ? ' — **used**' : '';
137
- const limit = ability.lim ? ` *(once per ${ability.lim})*` : '';
138
- lines.push(`- **${ability.n}**${limit} — ${ability.e}${spent}`);
139
- }
140
- }
141
- lines.push('');
142
- lines.push('## Inventory');
143
- lines.push('');
144
- if (state.items.length === 0) {
145
- lines.push('*Nothing yet.*');
146
- }
147
- else {
148
- for (const item of state.items) {
149
- const spent = item.sp ? ' — **used**' : '';
150
- const limit = item.lim ? ` *(once per ${item.lim})*` : '';
151
- lines.push(`- **${item.n}**${limit} — ${item.e}${spent}`);
152
- }
153
- }
154
- lines.push('');
155
- if (state.events.length > 0) {
156
- lines.push('## Event Cards');
157
- lines.push('');
158
- lines.push(state.events.map((name) => `- ${name}`).join('\n'));
159
- lines.push('');
160
- }
161
- if (state.allies.length > 0) {
162
- lines.push('## Character Cards');
163
- lines.push('');
164
- lines.push(state.allies.map((name) => `- ${name}`).join('\n'));
165
- lines.push('');
166
- }
167
- lines.push('## Chapters played');
168
- lines.push('');
169
- lines.push(state.chapters.length > 0
170
- ? state.chapters.map((chapter) => `Acts ${chapter}`).join(', ')
171
- : '*None yet.*');
172
- lines.push('');
173
- lines.push('## Notes');
174
- lines.push('');
175
- lines.push(NOTES_OPEN);
176
- lines.push(notes ? notes.slice(0, MAX_NOTES_CHARS) : '');
177
- lines.push(NOTES_CLOSE);
178
- lines.push('');
179
- lines.push('<!-- Canonical state. Do not hand-edit: every tool reads and rewrites this block. -->');
180
- lines.push('```' + STATE_FENCE_TAG);
181
- lines.push(JSON.stringify(state, null, 2));
182
- lines.push('```');
183
- return lines.join('\n');
184
- }
185
- function titleCase(text) {
186
- return (text || '')
187
- .split(/\s+/)
188
- .map((word) => (word ? word[0].toUpperCase() + word.slice(1).toLowerCase() : word))
189
- .join(' ');
190
- }
191
- function partyLine(state) {
192
- const attrs = cards_1.ATTRIBUTES.map((key) => `${titleCase(key).slice(0, 3)} ${signed(state.attr[key])}`).join(' ');
193
- const items = state.items.length === 1 ? '1 item' : `${state.items.length} items`;
194
- return `**${state.name}** — ${state.background || 'role unrecorded'} · ${attrs} · Faith Points ${state.fp}/${exports.MAX_FAITH_POINTS} · ${items}`;
195
- }
196
- function renderPartyStatus(states) {
197
- if (states.length === 0)
198
- return '# Party Status\n\n*No characters yet.*';
199
- return ['# Party Status', '', ...states.map((state) => `- ${partyLine(state)}`)].join('\n');
200
- }
@@ -1,2 +0,0 @@
1
- import { NativeToolDefinition } from '../../native-tool.types';
2
- export declare function actsTools(): NativeToolDefinition[];
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.actsTools = actsTools;
4
- const check_tool_1 = require("./tools/check.tool");
5
- const faith_tool_1 = require("./tools/faith.tool");
6
- const challenge_tool_1 = require("./tools/challenge.tool");
7
- const award_tool_1 = require("./tools/award.tool");
8
- const chapter_tool_1 = require("./tools/chapter.tool");
9
- const encounter_tool_1 = require("./tools/encounter.tool");
10
- const sheet_tools_1 = require("./tools/sheet.tools");
11
- function actsTools() {
12
- return [
13
- check_tool_1.checkTool,
14
- encounter_tool_1.rollDiceTool,
15
- faith_tool_1.faithPointsTool,
16
- challenge_tool_1.challengeTool,
17
- sheet_tools_1.createSheetTool,
18
- sheet_tools_1.readSheetTool,
19
- sheet_tools_1.patchSheetTool,
20
- award_tool_1.awardTool,
21
- chapter_tool_1.chapterTool,
22
- encounter_tool_1.encounterTool,
23
- ];
24
- }
@@ -1,2 +0,0 @@
1
- import { NativeToolDefinition } from '../../../native-tool.types';
2
- export declare const awardTool: NativeToolDefinition;