briyah 1.5.0 → 2.0.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.
- package/README.md +1092 -994
- package/data/common/config/markup +1 -1
- package/data/common/prompts/character/progress_character.json +5 -5
- package/data/common/prompts/illustrator/describe_scene.json +11 -3
- package/data/common/prompts/perceive.json +2 -2
- package/data/common/prompts/room_moderator/moderate.json +34 -34
- package/data/common/prompts/story_moderator/moderate.json +62 -62
- package/data/packs/dnd5e/agents/battle-master.json +6 -0
- package/data/packs/dnd5e/agents/campaign-designer.json +6 -0
- package/data/packs/dnd5e/agents/character-creator.json +6 -0
- package/data/packs/dnd5e/agents/dungeon-master.json +6 -0
- package/data/packs/dnd5e/agents/player.json +13 -0
- package/data/packs/dnd5e/agents/table-moderator.json +6 -0
- package/data/{common/artifacts/dnd5e/dungeon_master-procedure.md → packs/dnd5e/artifacts/battle_master-combat.md} +31 -131
- package/data/packs/dnd5e/artifacts/dungeon_master-procedure.md +192 -0
- package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/manifest.json +8 -2
- package/data/packs/dnd5e/pack.json +6 -0
- package/data/packs/dnd5e/prompts/battle_master/defaults_config.json +23 -0
- package/data/packs/dnd5e/prompts/battle_master/perceive.json +33 -0
- package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +378 -0
- package/data/{common → packs/dnd5e}/prompts/character_creator/defaults_config.json +1 -1
- package/data/{common → packs/dnd5e}/prompts/character_creator/perceive.prompt +29 -0
- package/data/{common → packs/dnd5e}/prompts/dnd_player/perceive.prompt +40 -22
- package/data/{common → packs/dnd5e}/prompts/dnd_room_moderator/moderate.json +34 -34
- package/data/{common → packs/dnd5e}/prompts/dnd_room_moderator/moderate.prompt +14 -3
- package/data/{common → packs/dnd5e}/prompts/dungeon_master/defaults_config.json +1 -0
- package/data/{common → packs/dnd5e}/prompts/dungeon_master/perceive.prompt +122 -115
- package/data/packs/dnd5e/prompts/dungeon_master/system_instruction.prompt +0 -0
- package/data/packs/dnd5e/rooms/table.json +16 -0
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +4 -13
- package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +2 -1
- package/dist-sdk/server/src/ai/LLM/deepseek.service.js +65 -77
- package/dist-sdk/server/src/ai/agent-config.d.ts +2 -0
- package/dist-sdk/server/src/ai/agent-store.service.js +8 -0
- package/dist-sdk/server/src/ai/agent.d.ts +6 -0
- package/dist-sdk/server/src/ai/agent.js +25 -2
- package/dist-sdk/server/src/ai/artifact.service.d.ts +3 -1
- package/dist-sdk/server/src/ai/artifact.service.js +12 -5
- package/dist-sdk/server/src/ai/pack-artifacts.d.ts +3 -3
- package/dist-sdk/server/src/ai/pack-artifacts.js +21 -15
- package/dist-sdk/server/src/app/user-service-factory.js +9 -1
- package/dist-sdk/server/src/app.controller.d.ts +11 -11
- package/dist-sdk/server/src/app.controller.js +178 -88
- package/dist-sdk/server/src/app.service.d.ts +28 -7
- package/dist-sdk/server/src/app.service.js +121 -91
- package/dist-sdk/server/src/common/errors.d.ts +0 -3
- package/dist-sdk/server/src/common/errors.js +1 -11
- package/dist-sdk/server/src/config/prompt-resolver.d.ts +39 -0
- package/dist-sdk/server/src/config/prompt-resolver.js +189 -0
- package/dist-sdk/server/src/config/user-config.service.d.ts +17 -0
- package/dist-sdk/server/src/config/user-config.service.js +103 -0
- package/dist-sdk/server/src/config/user-paths.service.d.ts +4 -4
- package/dist-sdk/server/src/config/user-paths.service.js +12 -16
- package/dist-sdk/server/src/packs/pack-instantiation.service.d.ts +35 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.js +154 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +52 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +256 -0
- package/dist-sdk/server/src/packs/pack.service.d.ts +24 -0
- package/dist-sdk/server/src/packs/pack.service.js +151 -0
- package/dist-sdk/server/src/room/room-config.d.ts +5 -0
- package/dist-sdk/server/src/room/room-store.service.d.ts +3 -0
- package/dist-sdk/server/src/room/room-store.service.js +41 -5
- package/dist-sdk/server/src/room/room.d.ts +7 -0
- package/dist-sdk/server/src/room/room.js +29 -1
- package/dist-sdk/server/src/sdk/briyah.d.ts +2 -0
- package/dist-sdk/server/src/sdk/briyah.js +45 -8
- package/dist-sdk/server/src/sdk/index.d.ts +6 -1
- package/dist-sdk/server/src/sdk/index.js +6 -2
- package/dist-sdk/server/src/shared/shared.module.js +0 -3
- package/dist-sdk/server/src/story/story.service.d.ts +2 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.d.ts +17 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/kits.js +54 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.d.ts +3 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/races.js +6 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.d.ts +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/data/srd.js +4 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.d.ts +1 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/backgrounds.js +6 -3
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.d.ts +3 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/character.js +45 -5
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.d.ts +27 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/encounter.js +103 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.d.ts +7 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/foes.js +83 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.d.ts +19 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/kits.js +130 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.d.ts +2 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/races.js +13 -2
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.d.ts +6 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/rules.js +16 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +10 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +82 -1
- package/dist-sdk/server/src/tools/packs/dnd5e/index.js +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/check.tool.js +51 -6
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/dice.tools.js +19 -9
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.d.ts +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/encounter.tool.js +134 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/monster.tool.js +31 -13
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +2 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +25 -8
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +70 -4
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/world.tools.js +27 -0
- package/dist-sdk/server/src/tools/packs/index.d.ts +1 -2
- package/dist-sdk/server/src/tools/packs/index.js +5 -11
- package/dist-sdk/shared/types/app.types.d.ts +72 -13
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/highlight.css +8 -1
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +4 -4
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +18 -3
- package/docs/classes/Agent.html +702 -37
- package/docs/classes/Briyah.html +250 -33
- package/docs/classes/BriyahConfigService.html +117 -10
- package/docs/classes/NativeToolRegistry.html +156 -11
- package/docs/classes/PackInstantiationService.html +146 -0
- package/docs/classes/PackService.html +247 -0
- package/docs/classes/Room.html +1190 -77
- package/docs/classes/RoomMessage.html +260 -29
- package/docs/enums/MessageAction.html +123 -3
- package/docs/functions/availableToolPacks.html +41 -2
- package/docs/functions/dnd5eTools.html +42 -3
- package/docs/functions/installToolPacks.html +48 -0
- package/docs/functions/registerToolPacks.html +54 -6
- package/docs/hierarchy.html +42 -1
- package/docs/index.html +158 -25
- package/docs/interfaces/AgentCreationOptions.html +110 -11
- package/docs/interfaces/AgentInfo.html +188 -3
- package/docs/interfaces/AgentMessagesResponse.html +71 -2
- package/docs/interfaces/AppService.html +2775 -474
- package/docs/interfaces/Artifact.html +81 -4
- package/docs/interfaces/ArtifactMetadata.html +104 -3
- package/docs/interfaces/ArtifactWriteOptions.html +75 -6
- package/docs/interfaces/AttachDocumentResponse.html +61 -2
- package/docs/interfaces/BriyahConfigOptions.html +107 -10
- package/docs/interfaces/ChapterInfo.html +61 -2
- package/docs/interfaces/Character.html +81 -2
- package/docs/interfaces/CreateAgentResponse.html +56 -2
- package/docs/interfaces/CreateRoomResponse.html +61 -2
- package/docs/interfaces/CreateStoryResponse.html +56 -2
- package/docs/interfaces/FileList.html +56 -2
- package/docs/interfaces/FileMetadata.html +84 -3
- package/docs/interfaces/IConfigService.html +76 -3
- package/docs/interfaces/InstantiateModels.html +64 -0
- package/docs/interfaces/InstantiateRoomResult.html +70 -0
- package/docs/interfaces/LoadedPack.html +131 -0
- package/docs/interfaces/LoggingOptions.html +86 -7
- package/docs/interfaces/Message.html +80 -2
- package/docs/interfaces/ModelChoice.html +73 -0
- package/docs/interfaces/ModelInfo.html +71 -2
- package/docs/interfaces/NativeToolDefinition.html +96 -9
- package/docs/interfaces/PackAgentTemplate.html +101 -0
- package/docs/interfaces/PackRoomTemplate.html +108 -0
- package/docs/interfaces/PackView.html +172 -0
- package/docs/interfaces/PreparedPromptResponse.html +61 -2
- package/docs/interfaces/ProcessTextResponse.html +81 -2
- package/docs/interfaces/PromptFile.html +69 -2
- package/docs/interfaces/PromptFileContent.html +75 -2
- package/docs/interfaces/PromptFilesResponse.html +56 -2
- package/docs/interfaces/PromptFolder.html +79 -2
- package/docs/interfaces/PromptFolderDefaults.html +136 -5
- package/docs/interfaces/PromptFolderDefaultsResponse.html +65 -4
- package/docs/interfaces/PromptFoldersResponse.html +56 -2
- package/docs/interfaces/RoomDetails.html +133 -4
- package/docs/interfaces/RoomInfo.html +84 -2
- package/docs/interfaces/RoomMessageUpdate.html +91 -2
- package/docs/interfaces/RoomMessagesResponse.html +61 -2
- package/docs/interfaces/SendMessageResult.html +61 -2
- package/docs/interfaces/StoryErrorEvent.html +76 -4
- package/docs/interfaces/StoryIdea.html +71 -2
- package/docs/interfaces/StoryInfo.html +173 -3
- package/docs/interfaces/StoryIntroduceCharacterEvent.html +71 -4
- package/docs/interfaces/StoryProgressChapterEvent.html +64 -3
- package/docs/interfaces/StoryState.html +99 -6
- package/docs/interfaces/StoryStateEvent.html +69 -3
- package/docs/interfaces/ToolArtifact.html +81 -4
- package/docs/interfaces/ToolCaller.html +75 -6
- package/docs/interfaces/ToolDefinition.html +76 -2
- package/docs/interfaces/ToolHelpers.html +91 -6
- package/docs/interfaces/ToolParameter.html +71 -2
- package/docs/interfaces/ToolRoomAccess.html +200 -24
- package/docs/interfaces/ToolSummary.html +71 -2
- package/docs/interfaces/ToolsResponse.html +66 -2
- package/docs/interfaces/Transaction.html +96 -2
- package/docs/interfaces/TransactionHistoryResponse.html +61 -2
- package/docs/modules.html +53 -1
- package/docs/types/PackOrigin.html +34 -0
- package/docs/types/PromptScope.html +34 -1
- package/docs/types/RoomTurnMode.html +36 -2
- package/docs/types/ToolContext.html +36 -2
- package/docs/types/ToolRunResult.html +34 -1
- package/package.json +139 -139
- package/src/tools/packs/dnd5e/README.md +149 -26
- package/dist-sdk/server/src/library/library.service.d.ts +0 -14
- package/dist-sdk/server/src/library/library.service.js +0 -165
- package/docs/functions/enabledToolPacks.html +0 -2
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/campaign_designer-setting.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/character_creator-basics.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-barbarian.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-bard.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-cleric.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-druid.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-fighter.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-monk.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-paladin.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-ranger.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-rogue.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-sorcerer.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-warlock.md +0 -0
- /package/data/{common/artifacts/dnd5e → packs/dnd5e/artifacts}/class-wizard.md +0 -0
- /package/data/{common/prompts/campaign_designer → packs/dnd5e/prompts/battle_master}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/campaign_designer/defaults_config.json +0 -0
- /package/data/{common → packs/dnd5e}/prompts/campaign_designer/perceive.json +0 -0
- /package/data/{common → packs/dnd5e}/prompts/campaign_designer/perceive.prompt +0 -0
- /package/data/{common/prompts/character_creator → packs/dnd5e/prompts/campaign_designer}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/character_creator/perceive.json +0 -0
- /package/data/{common/prompts/dnd_player → packs/dnd5e/prompts/character_creator}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dnd_player/defaults_config.json +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dnd_player/perceive.json +0 -0
- /package/data/{common/prompts/dnd_room_moderator → packs/dnd5e/prompts/dnd_player}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dnd_room_moderator/defaults_config.json +0 -0
- /package/data/{common/prompts/dungeon_master → packs/dnd5e/prompts/dnd_room_moderator}/system_instruction.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dungeon_master/compact_agent.prompt +0 -0
- /package/data/{common → packs/dnd5e}/prompts/dungeon_master/perceive.json +0 -0
|
@@ -76,11 +76,20 @@ Everyone hears what you say, but only the character you name responds.
|
|
|
76
76
|
recorded where the person running this game can read it.
|
|
77
77
|
- **REQUIRED**: Batch every roll a single resolution needs into **one** call. You may
|
|
78
78
|
chain at most 5 tool calls in a turn and each one costs real money, so three party
|
|
79
|
-
members saving is one batched `check`,
|
|
80
|
-
with six labelled expressions — not six calls.
|
|
79
|
+
members saving is one batched `check`, not three calls.
|
|
81
80
|
- **Which tool depends on who is rolling.** `check` reads modifiers off a character sheet,
|
|
82
|
-
so it rolls for **characters only**.
|
|
83
|
-
|
|
81
|
+
so it rolls for **characters only**. Anything without a sheet rolls through `roll_dice`
|
|
82
|
+
with numbers from its `stat_block` entry. In a fight this is the Battle Master's problem,
|
|
83
|
+
not yours — see "Combat" below.
|
|
84
|
+
- **A job done with a tool is `check` with `kind: "tool"`**, not a bare ability check —
|
|
85
|
+
picking a lock, disarming a trap, forging a paper, brewing a remedy. Name the tool in
|
|
86
|
+
`subject` and the tool adds the character's proficiency only if they actually have it,
|
|
87
|
+
doubling it for expertise. It uses Dexterity unless you say otherwise, so pass
|
|
88
|
+
`"ability"` when the job is not a Dexterity one: identifying a poison with a poisoner's
|
|
89
|
+
kit is Intelligence. **The ability is yours to choose** — the rules give tools no fixed
|
|
90
|
+
one — and the result names the ability it used so you can see what you asked for.
|
|
91
|
+
A character with no proficiency still rolls; they simply add nothing, and the result
|
|
92
|
+
says so.
|
|
84
93
|
- Say what you are testing against **before** you roll — put the DC or AC in your
|
|
85
94
|
`situation` — so the roll cannot look like it was fitted to the result afterwards.
|
|
86
95
|
- **REQUIRED**: You roll for everyone. **No player can roll dice** — not the human, not
|
|
@@ -95,8 +104,8 @@ Everyone hears what you say, but only the character you name responds.
|
|
|
95
104
|
armour class, not the DC you set, not its hit points, not "it's down to about fifteen",
|
|
96
105
|
not "it has half left". Those are yours, and a player who can read them is playing a
|
|
97
106
|
spreadsheet. Describe what the character can *see* instead: it staggers, sap runs from
|
|
98
|
-
the wound, it moves slower than it did.
|
|
99
|
-
your own notes,
|
|
107
|
+
the wound, it moves slower than it did. During a fight those numbers are the Battle
|
|
108
|
+
Master's to hold; outside one they are in your own notes. Either way, not in narration.
|
|
100
109
|
- Announcing a DC before the roll is different, and still right: "this is a hard climb,
|
|
101
110
|
DC 15" is the player deciding whether to try. Revealing what a *creature* has left,
|
|
102
111
|
after the fact, is not.
|
|
@@ -127,7 +136,7 @@ Everyone hears what you say, but only the character you name responds.
|
|
|
127
136
|
|
|
128
137
|
Your tools already know every creature, magic item and spell in the book, so reach for
|
|
129
138
|
`stat_block`, `magic_item` and `spell` first — a specialist is slower and costs a whole
|
|
130
|
-
exchange.
|
|
139
|
+
exchange. Three other agents hold what the tools do not, and the only way that material reaches
|
|
131
140
|
you is by asking them. **You cannot look anything up that is not in this prompt, in your tools,
|
|
132
141
|
or in the documents attached to you.**
|
|
133
142
|
|
|
@@ -135,9 +144,14 @@ or in the documents attached to you.**
|
|
|
135
144
|
|---|---|---|
|
|
136
145
|
| Campaign designer | Adventure design, and anything the campaign invented | The world, factions, places, and a creature or item that should be theirs to design |
|
|
137
146
|
| Character creator | The class features your own documents do not cover | Building a character, and applying a level-up |
|
|
147
|
+
| Battle Master | The combat rules, which are no longer in your documents | Running a whole fight, start to finish |
|
|
138
148
|
|
|
139
|
-
**REQUIRED**: Talk to
|
|
140
|
-
per handover — naming two things means one gets forgotten.
|
|
149
|
+
**REQUIRED**: Talk to the designer and the creator by `whisper`, never in front of the table.
|
|
150
|
+
**REQUIRED**: One task per handover — naming two things means one gets forgotten.
|
|
151
|
+
|
|
152
|
+
The Battle Master is the exception: hand a fight over with `speak`, not `whisper`, because the
|
|
153
|
+
whole table needs to know the fight has started and who is now calling on them. See "Combat"
|
|
154
|
+
below.
|
|
141
155
|
|
|
142
156
|
### Before the first session
|
|
143
157
|
Do these in order, and do not narrate anything until both are done:
|
|
@@ -299,68 +313,50 @@ the whole sheet.
|
|
|
299
313
|
- **REQUIRED**: Never guess at a character's hit points, armour class, spell slots or
|
|
300
314
|
equipment. Read the sheet. Players notice when you get their character wrong.
|
|
301
315
|
|
|
302
|
-
## Combat
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
it
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
narrate. If neither happened, you did not take its turn.
|
|
347
|
-
|
|
348
|
-
### Damage to a monster is arithmetic you have to do
|
|
349
|
-
No tool subtracts it for you — `apply_hp` writes to character sheets only.
|
|
350
|
-
|
|
351
|
-
- **REQUIRED**: Apply the creature's **resistances, immunities and vulnerabilities** from
|
|
352
|
-
its `stat_block` before you subtract. Resistance halves the damage, rounding down. A
|
|
353
|
-
creature resistant to piercing takes 2 from a 5-point arrow, not 5, and a fight where
|
|
354
|
-
that is ignored is roughly twice as easy as it was written to be.
|
|
355
|
-
- **REQUIRED**: Carry the running total in `situation` after every hit, as subtraction you
|
|
356
|
-
can check: `Blight 26-2-6-1 = 17`. Not "about 15". Not "badly wounded".
|
|
357
|
-
- **REQUIRED**: A creature is dead when the total reaches **0 or less**, and not before.
|
|
358
|
-
Do the subtraction before you say it dies. Ending a fight early costs the party the
|
|
359
|
-
encounter they earned, and the players cannot tell it happened — which is why it is
|
|
360
|
-
yours to get right.
|
|
361
|
-
- If you told the party something about a creature after a successful knowledge check,
|
|
362
|
-
it has to match its `stat_block`. Read the entry before you describe it; a check that
|
|
363
|
-
rewards the player with the opposite of the truth is worse than no check at all.
|
|
316
|
+
## Combat — hand it to the Battle Master
|
|
317
|
+
|
|
318
|
+
**REQUIRED**: When a fight starts, you do not run it. At the moment you would have called
|
|
319
|
+
`roll_initiative`, `speak` to the Battle Master instead and stop.
|
|
320
|
+
|
|
321
|
+
Running a fight means a dozen tool calls of bookkeeping, and every one of them re-sends this
|
|
322
|
+
whole prompt and your entire campaign history. The Battle Master carries the combat rules and
|
|
323
|
+
almost no history, which is why the fight is theirs and the story stays yours.
|
|
324
|
+
|
|
325
|
+
The handoff message is one `speak` targeting the Battle Master, and it must carry everything
|
|
326
|
+
they cannot see:
|
|
327
|
+
|
|
328
|
+
- **what is attacking** — creature names as `stat_block` would know them, and how many;
|
|
329
|
+
- **the terrain** — cover, light, difficult ground, anything that changes a move;
|
|
330
|
+
- **who is surprised**, and why;
|
|
331
|
+
- **where everyone started** — the party's marching order and the distance between the sides.
|
|
332
|
+
|
|
333
|
+
Then stop. Do not roll initiative, do not resolve a turn, do not narrate the fighting, and do
|
|
334
|
+
not answer a player who is mid-combat. The Battle Master calls on each combatant by name and the
|
|
335
|
+
players answer them, not you.
|
|
336
|
+
|
|
337
|
+
### Taking the story back
|
|
338
|
+
The Battle Master ends the fight with one message to you: who is standing, everyone's hit points,
|
|
339
|
+
what conditions outlasted the fight, what was spent, and what is on the field. That message is
|
|
340
|
+
your cue.
|
|
341
|
+
|
|
342
|
+
- Narrate the aftermath from what they reported. Do not re-roll anything and do not contradict
|
|
343
|
+
their numbers — the sheets already say what they say.
|
|
344
|
+
- Everything after the fight is yours again: `award_xp`, the loot, `rest`, and where the party
|
|
345
|
+
goes next.
|
|
346
|
+
- If the report is missing something you need, `whisper` them once and ask. Do not reconstruct
|
|
347
|
+
it from what you overheard.
|
|
348
|
+
|
|
349
|
+
### When there is no Battle Master
|
|
350
|
+
Check "The Party" above. If nobody there runs fights, run it yourself — you still hold every
|
|
351
|
+
tool. You will need the combat rules, which are **not** in your attached document any more:
|
|
352
|
+
tell the room plainly that the operator should either add a Battle Master or attach
|
|
353
|
+
`5e · battle_master — combat mechanics` to you, and lean on `rules_lookup` in the meantime.
|
|
354
|
+
|
|
355
|
+
### Describing a creature the party asks about
|
|
356
|
+
If you told the party something about a creature after a successful knowledge check, it has
|
|
357
|
+
to match its `stat_block`. Read the entry before you describe it; a check that rewards the
|
|
358
|
+
player with the opposite of the truth is worse than no check at all. This stays yours even
|
|
359
|
+
during a fight — the Battle Master runs the mechanics, not the lore.
|
|
364
360
|
|
|
365
361
|
## Scene State — the `situation` field
|
|
366
362
|
**REQUIRED on every single response.** Under 500 characters. This is the only state
|
|
@@ -369,10 +365,12 @@ every player can see, and it costs nothing to update, so keep it current.
|
|
|
369
365
|
Always include:
|
|
370
366
|
- where the party is;
|
|
371
367
|
- before play starts: the sheet count, `sheets 2/4`;
|
|
372
|
-
- if fighting: `Round N`, the initiative order with each combatant marked done or next,
|
|
373
|
-
and every monster's hit points as running subtraction — `Blight 26-2-6-1 = 17`;
|
|
374
368
|
- a party hit point line: `HP: Thorin 18/26, Lyra 9/20, Sable 14/14`.
|
|
375
369
|
|
|
370
|
+
While a fight is running the Battle Master owns this field and keeps the round, the initiative
|
|
371
|
+
order and the monsters' hit points in it. You are not acting during the fight, so you are not
|
|
372
|
+
writing it — pick it back up from their outcome report when they hand back.
|
|
373
|
+
|
|
376
374
|
Character sheets are **not** where the players read their hit points from turn to turn —
|
|
377
375
|
this line is. Keep it honest.
|
|
378
376
|
|
|
@@ -534,73 +532,78 @@ Correct response:
|
|
|
534
532
|
- The turn is handed to the human and the response **ends there**. No guess at what they do.
|
|
535
533
|
- The question is specific enough to answer in one line.
|
|
536
534
|
|
|
537
|
-
**Example 5:
|
|
535
|
+
**Example 5: A fight starts — hand it to the Battle Master**
|
|
538
536
|
> {{humanCharacterName}} speaks to {{agentNickname}}: I take the letter and ask who sent it.
|
|
539
537
|
|
|
540
538
|
Correct response:
|
|
541
539
|
```
|
|
542
540
|
{
|
|
543
|
-
"action": "
|
|
544
|
-
"targets": [],
|
|
545
|
-
"name": "
|
|
546
|
-
"content": "
|
|
547
|
-
"situation": "Alley behind the Drowned Lantern.
|
|
541
|
+
"action": "speak",
|
|
542
|
+
"targets": ["Marshal"],
|
|
543
|
+
"name": "",
|
|
544
|
+
"content": "Steel on the rooftop — two cutthroats drop into the alley behind the party and a third blocks the mouth of it with a knife already out. Marshal: two Cutthroats and one Bandit Captain as the knifeman. Alley behind the Drowned Lantern, wet cobbles, one lantern at the far end so the near half is dim light. Nobody is surprised — {{humanCharacterName}} heard the roof tile go. The party is strung out along twenty feet with {{humanCharacterName}} nearest the knifeman and Lyra at the back. It is yours.",
|
|
545
|
+
"situation": "Alley behind the Drowned Lantern. Fight handed to Marshal. HP: Thorin 26/26, Lyra 20/20, Sable 14/14"
|
|
548
546
|
}
|
|
549
547
|
```
|
|
550
|
-
-
|
|
551
|
-
|
|
548
|
+
- `speak`, not `whisper` — the whole table has to know a fight has started and who is now
|
|
549
|
+
calling on them.
|
|
550
|
+
- Creature names as `stat_block` knows them, the light, the ground, surprise and positions.
|
|
551
|
+
Everything the Battle Master cannot see, in one message.
|
|
552
|
+
- **No `roll_initiative`.** That call is theirs now. This turn ends here.
|
|
552
553
|
|
|
553
|
-
**Example 6: A
|
|
554
|
-
>
|
|
554
|
+
**Example 6: A player tries to act while the fight is running**
|
|
555
|
+
> Thorin speaks to {{agentNickname}}: Thorin puts his shoulder into the nearest one and drives him at the wall.
|
|
555
556
|
|
|
556
557
|
Correct response:
|
|
557
558
|
```
|
|
558
559
|
{
|
|
559
|
-
"action": "
|
|
560
|
+
"action": "think",
|
|
560
561
|
"targets": [],
|
|
561
|
-
"name": "
|
|
562
|
-
"content": "
|
|
563
|
-
"situation": "Alley
|
|
562
|
+
"name": "",
|
|
563
|
+
"content": "Thorin is answering me instead of Marshal. Marshal has the fight and is walking the order; if I resolve this the round breaks in two. Marshal will call on him when it is his turn.",
|
|
564
|
+
"situation": "Alley behind the Drowned Lantern. Fight running under Marshal. HP: Thorin 26/26, Lyra 20/20, Sable 14/14"
|
|
564
565
|
}
|
|
565
566
|
```
|
|
566
|
-
-
|
|
567
|
+
- **Do not resolve it.** Rolling for Thorin here takes his turn out of the initiative order and
|
|
568
|
+
the Battle Master has no way to know it happened.
|
|
569
|
+
- `think` and nothing else. A correction spoken aloud costs a turn and interrupts a fight that
|
|
570
|
+
is running perfectly well without you.
|
|
567
571
|
|
|
568
|
-
**Example 7:
|
|
569
|
-
>
|
|
572
|
+
**Example 7: The Battle Master hands the fight back**
|
|
573
|
+
> Marshal speaks to {{agentNickname}}: All three are down — the knifeman ran at half and bled out at the alley mouth. Thorin 14/26, Lyra 11/20, {{humanCharacterName}} 9/14, nobody unconscious, nobody conditioned. Spent: Lyra two first-level slots, Thorin one hit die. The knifeman was carrying a sealed letter and a purse with 22 gp.
|
|
570
574
|
|
|
571
575
|
Correct response:
|
|
572
576
|
```
|
|
573
577
|
{
|
|
574
|
-
"action": "
|
|
575
|
-
"targets": [],
|
|
576
|
-
"name": "
|
|
577
|
-
"content": "
|
|
578
|
-
"situation": "Alley,
|
|
578
|
+
"action": "speak",
|
|
579
|
+
"targets": ["{{humanCharacterName}}"],
|
|
580
|
+
"name": "",
|
|
581
|
+
"content": "It goes quiet fast. The knifeman makes it four steps toward the street before he folds against the wall and stops moving, and the rain starts washing the alley clean around him. There is a letter inside his coat, still sealed, and a purse heavy enough to hear. {{humanCharacterName}} — the letter, or the street he was trying to reach?",
|
|
582
|
+
"situation": "Alley behind the Drowned Lantern, fight over. Sealed letter + 22 gp on the knifeman. HP: Thorin 14/26, Lyra 11/20, Sable 9/14"
|
|
579
583
|
}
|
|
580
584
|
```
|
|
581
|
-
-
|
|
585
|
+
- The story is back. Narrated from their report without re-rolling anything or contradicting a
|
|
586
|
+
number — the sheets already say what they say.
|
|
587
|
+
- The loot they named is now yours to hand out, and so is the experience.
|
|
588
|
+
- Ends with a concrete question to exactly one character, the way every other turn does.
|
|
582
589
|
|
|
583
|
-
**Example 8:
|
|
584
|
-
>
|
|
590
|
+
**Example 8: You have no Battle Master at this table**
|
|
591
|
+
> Sable speaks to {{agentNickname}}: Sable draws on the thing in the water and looses.
|
|
585
592
|
|
|
586
593
|
Correct response:
|
|
587
594
|
```
|
|
588
595
|
{
|
|
589
596
|
"action": "execute",
|
|
590
597
|
"targets": [],
|
|
591
|
-
"name": "
|
|
592
|
-
"content": "{\"
|
|
593
|
-
"situation": "
|
|
598
|
+
"name": "roll_initiative",
|
|
599
|
+
"content": "{\"combatants\": \"Thorin; Lyra; Sable; Ghoul A+2; Ghoul B+2; Ghoul C+2\", \"encounter_name\": \"The flooded level\"}",
|
|
600
|
+
"situation": "Flooded lower level, waist-deep. No Battle Master at this table — running it myself. HP: Thorin 18/26, Lyra 11/20, Sable 14/14"
|
|
594
601
|
}
|
|
595
602
|
```
|
|
596
|
-
- The
|
|
597
|
-
|
|
598
|
-
-
|
|
599
|
-
|
|
600
|
-
labelled with `=`, and the target's armour class in `reason` so the log shows what it beat.
|
|
601
|
-
- Kess's arrow did 5 piercing and the blight resists piercing, so `26-2`, not `26-5`. The
|
|
602
|
-
subtraction is written out where it cannot drift.
|
|
603
|
-
- The narration that follows this will say what Achilles feels, not that the blight has 18 left.
|
|
603
|
+
- Check "The Party" first. Nobody there runs fights, so it falls back to you and you still hold
|
|
604
|
+
every tool.
|
|
605
|
+
- You do **not** have the combat rules attached any more. Lean on `rules_lookup`, and tell the
|
|
606
|
+
room the operator should add a Battle Master or attach the combat document to you.
|
|
604
607
|
|
|
605
608
|
**Example 9: The wrong player answered**
|
|
606
609
|
> From: Player1
|
|
@@ -687,7 +690,7 @@ Correct response:
|
|
|
687
690
|
- It asked for **the world**, not for stat blocks. Ordinary creatures are a `stat_block` call
|
|
688
691
|
away; the designer's time is for places, factions and the creatures that carry the campaign.
|
|
689
692
|
|
|
690
|
-
**Example 14:
|
|
693
|
+
**Example 14: The thing about to attack is one you invented**
|
|
691
694
|
> Sable speaks to {{agentNickname}}: Sable draws on the thing in the water and looses.
|
|
692
695
|
|
|
693
696
|
Correct response:
|
|
@@ -696,13 +699,15 @@ Correct response:
|
|
|
696
699
|
"action": "execute",
|
|
697
700
|
"targets": [],
|
|
698
701
|
"name": "stat_block",
|
|
699
|
-
"content": "{\"creature\": \"
|
|
700
|
-
"situation": "Flooded lower level, waist-deep water. Three shapes rising —
|
|
702
|
+
"content": "{\"creature\": \"drowned thrall\"}",
|
|
703
|
+
"situation": "Flooded lower level, waist-deep water. Three shapes rising — checking they are statted before handing over. HP: Thorin 18/26, Lyra 11/20, Sable 14/14"
|
|
701
704
|
}
|
|
702
705
|
```
|
|
703
|
-
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
+
- A creature the campaign invented has to exist in the bestiary **before** the fight is handed
|
|
707
|
+
over. The Battle Master can look one up, but it cannot invent one, and it does not know what
|
|
708
|
+
you had in mind.
|
|
709
|
+
- A creature that is in the book needs none of this — hand the fight over and let them look it
|
|
710
|
+
up. This step is only for something of your own.
|
|
706
711
|
|
|
707
712
|
**Example 12b: The creature is not in the book either**
|
|
708
713
|
> From system: Result of tool "stat_block": {"ok":true,"result":{"found":false,"creature":"drowned thrall","options":["Define it with the \"define\" parameter","Ask the campaign designer to stat it"],"note":"Do not invent the numbers."}}
|
|
@@ -721,6 +726,8 @@ Correct response:
|
|
|
721
726
|
now it is in the bestiary for the rest of the campaign.
|
|
722
727
|
- The designer was not involved, because this is scenery rather than a centrepiece. Save them
|
|
723
728
|
for creatures that carry the campaign.
|
|
729
|
+
- **Next turn hands the fight over.** The thrall now resolves for the Battle Master by name,
|
|
730
|
+
because a campaign creature is in the bestiary the moment it is defined.
|
|
724
731
|
|
|
725
732
|
**Example 15: Handing a level-up over after the fight**
|
|
726
733
|
> From system: Result of tool "award_xp": {"ok":true,"result":{"applied":true,"levelUpsAvailable":[{"character":"Sable Quick","fromLevel":3,"toLevel":4,"choices":["Hit point increase: roll the class hit die (d8) and add the Constitution modifier, or take the fixed average","Ability score improvement: +2 to one ability or +1 to two, or a feat instead"]}]}}
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "table",
|
|
3
|
+
"name": "D&D Table",
|
|
4
|
+
"goal": "Play a fifth-edition campaign: the Dungeon Master runs the world, the Battle Master runs fights, and the players play their characters.",
|
|
5
|
+
"turnMode": "directed",
|
|
6
|
+
"agents": [
|
|
7
|
+
"table_moderator",
|
|
8
|
+
"dungeon_master",
|
|
9
|
+
"battle_master",
|
|
10
|
+
"character_creator",
|
|
11
|
+
"campaign_designer",
|
|
12
|
+
"player"
|
|
13
|
+
],
|
|
14
|
+
"roomLeader": "dungeon_master",
|
|
15
|
+
"moderator": "table_moderator"
|
|
16
|
+
}
|
|
@@ -45,9 +45,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.BaseAiService = void 0;
|
|
46
46
|
const common_1 = require("@nestjs/common");
|
|
47
47
|
const agent_1 = require("../agent");
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
48
|
const fs_1 = require("fs");
|
|
50
49
|
const fs = __importStar(require("fs"));
|
|
50
|
+
const prompt_resolver_1 = require("../../config/prompt-resolver");
|
|
51
51
|
const handlebars_1 = require("handlebars");
|
|
52
52
|
const errors_1 = require("../../common/errors");
|
|
53
53
|
const logger_1 = require("../../common/logger");
|
|
@@ -87,18 +87,9 @@ let BaseAiService = class BaseAiService {
|
|
|
87
87
|
if (!userPaths) {
|
|
88
88
|
throw new Error('Agent userPaths is not set');
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
path.join(userPaths.getCommonPromptsDir(), agent.promptFolder, `${fileName}${extension}`),
|
|
94
|
-
path.join(userPaths.getCommonPromptsDir(), `${fileName}${extension}`),
|
|
95
|
-
];
|
|
96
|
-
for (const filePath of searchPaths) {
|
|
97
|
-
if (fs.existsSync(filePath)) {
|
|
98
|
-
return filePath;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
90
|
+
return ((0, prompt_resolver_1.resolvePromptFile)(userPaths, agent.promptFolder, fileName, extension, {
|
|
91
|
+
enabledPacks: agent.enabledPacks,
|
|
92
|
+
})?.absolutePath ?? null);
|
|
102
93
|
}
|
|
103
94
|
hasPromptFile(agent, fileName, extension = '.prompt') {
|
|
104
95
|
return this.findPromptFile(agent, fileName, extension) !== null;
|
|
@@ -9,7 +9,8 @@ export declare class DeepSeekAiService extends BaseAiService {
|
|
|
9
9
|
getModelPricePrefix(): string;
|
|
10
10
|
fetchModelsFromApi(): Promise<ModelInfo[]>;
|
|
11
11
|
addToConversationHistory(agent: Agent, message: string, fromSelf?: boolean): void;
|
|
12
|
-
private
|
|
12
|
+
private recoverUnvalidatedObject;
|
|
13
|
+
private static describeValidationFailure;
|
|
13
14
|
textPrompt(agent: Agent, prompt: string, jsonSchema?: any, saveResponse?: boolean, promptInstructions?: string, _cacheConfig?: any, maxOutputChars?: number): Promise<any>;
|
|
14
15
|
attachDocument(agent: Agent, fileName: string, fileData: Uint8Array): Promise<string>;
|
|
15
16
|
private computeMessageCost;
|
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var DeepSeekAiService_1;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
13
|
exports.DeepSeekAiService = void 0;
|
|
13
14
|
const common_1 = require("@nestjs/common");
|
|
@@ -15,11 +16,10 @@ const deepseek_1 = require("@ai-sdk/deepseek");
|
|
|
15
16
|
const ai_1 = require("ai");
|
|
16
17
|
const jsonrepair_1 = require("jsonrepair");
|
|
17
18
|
const base_ai_service_1 = require("./base-ai.service");
|
|
18
|
-
const zod_1 = require("zod");
|
|
19
19
|
const model_prices_1 = require("../model_prices");
|
|
20
20
|
const errors_1 = require("../../common/errors");
|
|
21
21
|
const logger_1 = require("../../common/logger");
|
|
22
|
-
let DeepSeekAiService = class DeepSeekAiService extends base_ai_service_1.BaseAiService {
|
|
22
|
+
let DeepSeekAiService = DeepSeekAiService_1 = class DeepSeekAiService extends base_ai_service_1.BaseAiService {
|
|
23
23
|
deepseekClient;
|
|
24
24
|
constructor() {
|
|
25
25
|
super();
|
|
@@ -88,59 +88,34 @@ let DeepSeekAiService = class DeepSeekAiService extends base_ai_service_1.BaseAi
|
|
|
88
88
|
});
|
|
89
89
|
agent.trimHistoryIfNeeded();
|
|
90
90
|
}
|
|
91
|
-
|
|
92
|
-
if (!
|
|
93
|
-
return
|
|
91
|
+
recoverUnvalidatedObject(agent, error) {
|
|
92
|
+
if (!ai_1.NoObjectGeneratedError.isInstance(error))
|
|
93
|
+
return null;
|
|
94
|
+
let object = error.value;
|
|
95
|
+
if (object === undefined && error.text) {
|
|
96
|
+
try {
|
|
97
|
+
object = JSON.parse((0, jsonrepair_1.jsonrepair)(error.text));
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
94
102
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (jsonSchema.items) {
|
|
109
|
-
return zod_1.z.array(this.jsonSchemaToZod(jsonSchema.items));
|
|
110
|
-
}
|
|
111
|
-
return zod_1.z.array(zod_1.z.any());
|
|
112
|
-
case 'string':
|
|
113
|
-
let stringSchema = zod_1.z.string();
|
|
114
|
-
if (jsonSchema.minLength !== undefined) {
|
|
115
|
-
stringSchema = stringSchema.min(jsonSchema.minLength);
|
|
116
|
-
}
|
|
117
|
-
if (jsonSchema.maxLength !== undefined) {
|
|
118
|
-
stringSchema = stringSchema.max(jsonSchema.maxLength);
|
|
119
|
-
}
|
|
120
|
-
if (jsonSchema.pattern) {
|
|
121
|
-
stringSchema = stringSchema.regex(new RegExp(jsonSchema.pattern));
|
|
122
|
-
}
|
|
123
|
-
if (jsonSchema.enum) {
|
|
124
|
-
return zod_1.z.enum(jsonSchema.enum);
|
|
125
|
-
}
|
|
126
|
-
return stringSchema;
|
|
127
|
-
case 'number':
|
|
128
|
-
case 'integer':
|
|
129
|
-
let numberSchema = jsonSchema.type === 'integer' ? zod_1.z.number().int() : zod_1.z.number();
|
|
130
|
-
if (jsonSchema.minimum !== undefined) {
|
|
131
|
-
numberSchema = numberSchema.min(jsonSchema.minimum);
|
|
132
|
-
}
|
|
133
|
-
if (jsonSchema.maximum !== undefined) {
|
|
134
|
-
numberSchema = numberSchema.max(jsonSchema.maximum);
|
|
135
|
-
}
|
|
136
|
-
return numberSchema;
|
|
137
|
-
case 'boolean':
|
|
138
|
-
return zod_1.z.boolean();
|
|
139
|
-
case 'null':
|
|
140
|
-
return zod_1.z.null();
|
|
141
|
-
default:
|
|
142
|
-
return zod_1.z.any();
|
|
103
|
+
if (!object || typeof object !== 'object' || Array.isArray(object))
|
|
104
|
+
return null;
|
|
105
|
+
logger_1.logger.warn(`DeepSeek response for ${agent.agentName} did not match the prompt schema; using it anyway. ` +
|
|
106
|
+
`Keys returned: ${Object.keys(object).join(', ')}. ${DeepSeekAiService_1.describeValidationFailure(error)}`);
|
|
107
|
+
return { object, usage: error.usage };
|
|
108
|
+
}
|
|
109
|
+
static describeValidationFailure(error) {
|
|
110
|
+
let current = error;
|
|
111
|
+
let message = '';
|
|
112
|
+
while (current) {
|
|
113
|
+
if (typeof current.message === 'string' && current.message)
|
|
114
|
+
message = current.message;
|
|
115
|
+
current = current.cause;
|
|
143
116
|
}
|
|
117
|
+
const flattened = message.replace(/\s+/g, ' ').trim();
|
|
118
|
+
return flattened.length > 300 ? `${flattened.slice(0, 300)}…` : flattened;
|
|
144
119
|
}
|
|
145
120
|
async textPrompt(agent, prompt, jsonSchema = null, saveResponse = true, promptInstructions = null, _cacheConfig = null, maxOutputChars = 0) {
|
|
146
121
|
if (agent.balanceService && !agent.disableBalanceCheck) {
|
|
@@ -197,34 +172,47 @@ let DeepSeekAiService = class DeepSeekAiService extends base_ai_service_1.BaseAi
|
|
|
197
172
|
this.debugLogRequest(agent.agentName, requestParams);
|
|
198
173
|
try {
|
|
199
174
|
if (jsonSchema) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
reasoningEffort: reasoningEffort,
|
|
175
|
+
let object;
|
|
176
|
+
let usage;
|
|
177
|
+
try {
|
|
178
|
+
const result = await (0, ai_1.generateObject)({
|
|
179
|
+
model: this.deepseekClient(agent.modelName),
|
|
180
|
+
messages: messages,
|
|
181
|
+
temperature: 0,
|
|
182
|
+
schema: (0, ai_1.jsonSchema)(jsonSchema),
|
|
183
|
+
experimental_repairText: async ({ text }) => {
|
|
184
|
+
try {
|
|
185
|
+
return (0, jsonrepair_1.jsonrepair)(text);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
216
190
|
},
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
191
|
+
providerOptions: {
|
|
192
|
+
deepseek: {
|
|
193
|
+
reasoningEffort: reasoningEffort,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
object = result.object;
|
|
198
|
+
usage = result.usage;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
const recovered = this.recoverUnvalidatedObject(agent, error);
|
|
202
|
+
if (!recovered)
|
|
203
|
+
throw error;
|
|
204
|
+
object = recovered.object;
|
|
205
|
+
usage = recovered.usage;
|
|
206
|
+
}
|
|
207
|
+
if (usage) {
|
|
208
|
+
this.computeMessageCost(agent, usage);
|
|
221
209
|
}
|
|
222
|
-
this.debugLogResponse(agent.agentName, JSON.stringify(
|
|
210
|
+
this.debugLogResponse(agent.agentName, JSON.stringify(object, null, 2));
|
|
223
211
|
if (saveResponse) {
|
|
224
212
|
this.addToConversationHistory(agent, prompt, false);
|
|
225
|
-
this.addToConversationHistory(agent, JSON.stringify(
|
|
213
|
+
this.addToConversationHistory(agent, JSON.stringify(object), true);
|
|
226
214
|
}
|
|
227
|
-
return
|
|
215
|
+
return object;
|
|
228
216
|
}
|
|
229
217
|
else {
|
|
230
218
|
const result = await (0, ai_1.generateText)({
|
|
@@ -293,7 +281,7 @@ let DeepSeekAiService = class DeepSeekAiService extends base_ai_service_1.BaseAi
|
|
|
293
281
|
}
|
|
294
282
|
};
|
|
295
283
|
exports.DeepSeekAiService = DeepSeekAiService;
|
|
296
|
-
exports.DeepSeekAiService = DeepSeekAiService = __decorate([
|
|
284
|
+
exports.DeepSeekAiService = DeepSeekAiService = DeepSeekAiService_1 = __decorate([
|
|
297
285
|
(0, common_1.Injectable)(),
|
|
298
286
|
__metadata("design:paramtypes", [])
|
|
299
287
|
], DeepSeekAiService);
|