briyah 2.0.4 → 2.0.6
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 +12 -1
- package/data/common/config/markup +1 -1
- package/data/common/config/story_models.json +3 -3
- package/data/common/prompts/illustrator/describe_scene.prompt +4 -4
- package/data/common/prompts/moderate.json +34 -0
- package/data/common/prompts/moderate.prompt +136 -0
- package/data/common/prompts/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/battle_master/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/campaign_designer/perceive.prompt +1 -1
- package/data/packs/dnd5e/prompts/character_creator/perceive.prompt +795 -787
- package/data/packs/dnd5e/prompts/dungeon_master/defaults_config.json +2 -1
- package/data/packs/dnd5e/prompts/dungeon_master/perceive.prompt +1 -1
- package/data/packs/dnd5e/rooms/campaign.json +18 -15
- package/data/packs/dnd5e/rooms/table.json +17 -16
- package/dist-sdk/server/src/ai/LLM/anthropic.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/base-ai.service.d.ts +38 -0
- package/dist-sdk/server/src/ai/LLM/base-ai.service.js +83 -16
- package/dist-sdk/server/src/ai/LLM/blank-image.d.ts +36 -0
- package/dist-sdk/server/src/ai/LLM/blank-image.js +80 -0
- package/dist-sdk/server/src/ai/LLM/deepseek.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/fal.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/googleai.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/grok.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/openai.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +1 -1
- package/dist-sdk/server/src/ai/LLM/together.service.js +1 -1
- package/dist-sdk/server/src/ai/agent-config.d.ts +0 -1
- package/dist-sdk/server/src/ai/agent-store.service.js +2 -4
- package/dist-sdk/server/src/ai/agent.d.ts +7 -2
- package/dist-sdk/server/src/ai/agent.js +11 -3
- package/dist-sdk/server/src/app/user-service-factory.js +8 -2
- package/dist-sdk/server/src/app.controller.d.ts +33 -0
- package/dist-sdk/server/src/app.controller.js +93 -2
- package/dist-sdk/server/src/app.service.d.ts +49 -4
- package/dist-sdk/server/src/app.service.js +101 -16
- package/dist-sdk/server/src/auth/jwt-auth.guard.js +26 -0
- package/dist-sdk/server/src/data/data-guide.builder.d.ts +2 -0
- package/dist-sdk/server/src/data/data-guide.builder.js +90 -0
- package/dist-sdk/server/src/data/data-registry.d.ts +32 -0
- package/dist-sdk/server/src/data/data-registry.js +61 -0
- package/dist-sdk/server/src/data/data.types.d.ts +158 -0
- package/dist-sdk/server/src/data/data.types.js +24 -0
- package/dist-sdk/server/src/data/query-validation.d.ts +45 -0
- package/dist-sdk/server/src/data/query-validation.js +245 -0
- package/dist-sdk/server/src/packs/pack-instantiation.service.js +5 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +14 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +11 -0
- package/dist-sdk/server/src/room/illustration/illustration.service.d.ts +211 -0
- package/dist-sdk/server/src/room/illustration/illustration.service.js +771 -0
- package/dist-sdk/server/src/room/illustration/illustration.types.d.ts +101 -0
- package/dist-sdk/server/src/room/illustration/illustration.types.js +2 -0
- package/dist-sdk/server/src/room/room-config.d.ts +58 -1
- package/dist-sdk/server/src/room/room-config.js +19 -0
- package/dist-sdk/server/src/room/room-factory.d.ts +8 -0
- package/dist-sdk/server/src/room/room-factory.js +11 -0
- package/dist-sdk/server/src/room/room-store.service.d.ts +8 -0
- package/dist-sdk/server/src/room/room-store.service.js +43 -2
- package/dist-sdk/server/src/room/room.d.ts +110 -6
- package/dist-sdk/server/src/room/room.js +277 -10
- package/dist-sdk/server/src/rpg/rpg.service.js +5 -1
- package/dist-sdk/server/src/sdk/index.d.ts +4 -0
- package/dist-sdk/server/src/sdk/index.js +11 -1
- package/dist-sdk/server/src/story/story.service.d.ts +24 -65
- package/dist-sdk/server/src/story/story.service.js +105 -458
- package/dist-sdk/server/src/tools/core/data.tools.d.ts +17 -0
- package/dist-sdk/server/src/tools/core/data.tools.js +165 -0
- package/dist-sdk/server/src/tools/core/illustrate.tool.d.ts +14 -0
- package/dist-sdk/server/src/tools/core/illustrate.tool.js +80 -0
- package/dist-sdk/server/src/tools/core/index.js +3 -1
- package/dist-sdk/server/src/tools/native-tool.types.d.ts +90 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.d.ts +9 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/engine/sheet.js +5 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.d.ts +30 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/shared.js +75 -0
- package/dist-sdk/server/src/tools/packs/dnd5e/tools/sheet.tools.js +11 -2
- package/dist-sdk/server/src/tools/tool-execution.service.d.ts +36 -5
- package/dist-sdk/server/src/tools/tool-execution.service.js +91 -21
- package/dist-sdk/shared/types/app.types.d.ts +43 -0
- package/dist-sdk/shared/types/app.types.js +15 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -302,13 +302,17 @@ await appService.compactAgentConversation(agentId); // Summarize history into a
|
|
|
302
302
|
// agent a message names ('broadcast', the default, asks every agent every time);
|
|
303
303
|
// moderator is only needed when no agent leads the turn order.
|
|
304
304
|
const room = await appService.createRoom(
|
|
305
|
-
name, goal, agentIds, roomLeader?, turnMode?, moderator?,
|
|
305
|
+
name, goal, agentIds, roomLeader?, turnMode?, moderator?, beginInstruction?,
|
|
306
306
|
);
|
|
307
307
|
const rooms = await appService.listRooms();
|
|
308
308
|
const details = await appService.getRoomDetails(roomId);
|
|
309
309
|
// action defaults to 'moderate'. Returns {accepted, reason} — a message sent out of
|
|
310
310
|
// turn is refused, not thrown. `sender` must be an agentNickname.
|
|
311
311
|
await appService.sendRoomMessage(roomId, content, sender, action?, targets?);
|
|
312
|
+
// Opens a room that nobody has spoken in: sends its beginInstruction as a 'System'
|
|
313
|
+
// 'speak' addressed to the leader. Throws if the room has no instruction, has no
|
|
314
|
+
// agents, or has already begun. See "Starting a room" below.
|
|
315
|
+
await appService.beginRoom(roomId);
|
|
312
316
|
// Required before subscribing to a room this process did not create.
|
|
313
317
|
await appService.ensureRoomStateCallback(roomId);
|
|
314
318
|
const emitter = appService.getRoomMessageEmitter(roomId); // 'update' events
|
|
@@ -965,6 +969,13 @@ it and then stops rather than generating a reply, which is what yields the floor
|
|
|
965
969
|
**The room message emitter** — the only way to see the conversation as it happens. It fires on
|
|
966
970
|
every change with the newest message and the room's state.
|
|
967
971
|
|
|
972
|
+
**Starting a room.** A room is pull-driven: an agent is prompted only when a message arrives,
|
|
973
|
+
so a room nobody has spoken in never moves however complete its configuration. Give the room a
|
|
974
|
+
`beginInstruction` and call `beginRoom(roomId)`, and it goes to the leader as a `'System'`
|
|
975
|
+
`'speak'` — which is how a leader opens a turn-based table without the person having to tell it
|
|
976
|
+
to. The web client offers it as a **Begin** button while the transcript is empty. It refuses a
|
|
977
|
+
room that has already begun, so it is safe to call from several places at once.
|
|
978
|
+
|
|
968
979
|
```typescript
|
|
969
980
|
import { Briyah } from 'briyah';
|
|
970
981
|
import type { RoomUpdate } from 'briyah';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
25.0112284
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"cost": "3000"
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
|
-
"name": "Grok 4.
|
|
43
|
+
"name": "Grok 4.6",
|
|
44
44
|
"description": "",
|
|
45
45
|
"service": "Grok",
|
|
46
|
-
"model": "grok-4.
|
|
46
|
+
"model": "grok-4.6",
|
|
47
47
|
"moderator_service": "Grok",
|
|
48
|
-
"moderator_model": "grok-4.
|
|
48
|
+
"moderator_model": "grok-4.6",
|
|
49
49
|
"cost": "300"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Describe Scene
|
|
2
2
|
|
|
3
3
|
**Role:**
|
|
4
|
-
You are a participant in a storytelling project whose role is to determine what pictures to produce to go along with the story.
|
|
4
|
+
You are a participant in {{#if narrator}}a storytelling project{{else}}an ongoing conversation{{/if}} whose role is to determine what pictures to produce to go along with {{#if narrator}}the story{{else}}it{{/if}}.
|
|
5
5
|
You are responsible for describing the pictures that another AI model will render.
|
|
6
6
|
You are to describe one of two types of images:
|
|
7
7
|
- A reference scene with just a setting and no characters so that subsequent story images can be based on them
|
|
8
8
|
- A story image showing the characters interacting within one of the previous described reference scenes
|
|
9
|
-
Images are only created when the scene changes or something significant happens, so you must decide if a new image is appropriate at this point in the story.
|
|
9
|
+
Images are only created when the scene changes or something significant happens, so you must decide if a new image is appropriate at this point{{#if narrator}} in the story{{/if}}.
|
|
10
10
|
|
|
11
11
|
**Context:**
|
|
12
|
-
- Your message history contains a few of the most recent paragraphs from the story to help you understand the context.
|
|
12
|
+
- Your message history contains a few of the most recent {{#if narrator}}paragraphs from the story{{else}}messages from the room{{/if}} to help you understand the context.
|
|
13
13
|
- You are also given a **Current Situation**, a list of **Existing Scenes**, and a list of **Characters** that could possibly appear in the scenes.
|
|
14
14
|
|
|
15
15
|
**Characters:**
|
|
@@ -18,7 +18,7 @@ Images are only created when the scene changes or something significant happens,
|
|
|
18
18
|
{{/each}}
|
|
19
19
|
|
|
20
20
|
**Task:**
|
|
21
|
-
- Based on the **Current Situation** and the most recent narration from the narrator, determine the current setting of the story (where the action is happening).
|
|
21
|
+
- Based on the **Current Situation** and the most recent {{#if narrator}}narration from the narrator{{else}}messages in the room{{/if}}, determine the current setting of {{#if narrator}}the story{{else}}the scene{{/if}} (where the action is happening).
|
|
22
22
|
- If the **Existing Scenes** list already contains such a scene, use the name of that scene (the part before the colon) as the sceneName.
|
|
23
23
|
- If the scene does not exist, you are to create a new reference scene with a descriptive name describing the new setting in the story.
|
|
24
24
|
- When creating a new reference scene, you will describe the setting without any characters (so they can be added later).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "moderate",
|
|
3
|
+
"description": "Route a message to the agents that should receive and answer it",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"action": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"enum": ["relay", "relay_silent"],
|
|
9
|
+
"description": "Use 'relay' to pass the message on and log it in the room transcript. Use 'relay_silent' for an internal handoff that should not appear in the transcript"
|
|
10
|
+
},
|
|
11
|
+
"content": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"description": "The word 'relay' to pass the message on unchanged, or the rewritten message"
|
|
14
|
+
},
|
|
15
|
+
"name": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "The name of the one agent expected to answer next, or an empty string when it cannot be determined"
|
|
18
|
+
},
|
|
19
|
+
"targets": {
|
|
20
|
+
"type": "array",
|
|
21
|
+
"description": "The names of every agent that should receive the message",
|
|
22
|
+
"items": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"relayAs": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": ["speak", "whisper", "shout"],
|
|
29
|
+
"description": "The action the relayed message carries in the room. Use 'whisper' when the targets are only some of the agents present, 'speak' when everyone present is a target, and 'shout' only when the message must reach the whole room."
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": ["action", "content", "name", "targets", "relayAs"],
|
|
33
|
+
"additionalProperties": false
|
|
34
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Moderator instructions
|
|
2
|
+
|
|
3
|
+
## Your Identity
|
|
4
|
+
- **Your Name**: {{agentNickname}}
|
|
5
|
+
- **Full Title**: {{agentName}}
|
|
6
|
+
- **Description**: {{agentDescription}}
|
|
7
|
+
|
|
8
|
+
Besides your own role, you are placing a message that this room could not route
|
|
9
|
+
on its own. Decide who should receive it and who should answer it.
|
|
10
|
+
|
|
11
|
+
## Room Context
|
|
12
|
+
|
|
13
|
+
### Goal
|
|
14
|
+
{{roomGoal}}
|
|
15
|
+
|
|
16
|
+
### Available Agents
|
|
17
|
+
{{#each otherAgents}}
|
|
18
|
+
- {{this.agentNickname}}: {{this.description}}
|
|
19
|
+
{{/each}}
|
|
20
|
+
|
|
21
|
+
### Room Leader
|
|
22
|
+
{{roomLeader}}
|
|
23
|
+
|
|
24
|
+
{{#if humanAgentList}}
|
|
25
|
+
### People
|
|
26
|
+
{{humanAgentList}}
|
|
27
|
+
|
|
28
|
+
These are human participants. Name one as the responder only when the message
|
|
29
|
+
genuinely needs a person — an answer only they have, or a decision only they can
|
|
30
|
+
make. A person cannot be prompted, so the room waits until they type.
|
|
31
|
+
{{/if}}
|
|
32
|
+
|
|
33
|
+
## Your Task
|
|
34
|
+
Read the Sender and the Recent Message below, then decide:
|
|
35
|
+
1. Which agents should receive the message.
|
|
36
|
+
2. Which single agent should answer it next.
|
|
37
|
+
|
|
38
|
+
Work from what each agent's description says it does. The usual reason a message
|
|
39
|
+
reaches you is that its sender addressed a name that is not in the Available
|
|
40
|
+
Agents list — a colleague it assumed was here, or a role it invented. When that
|
|
41
|
+
happens, do not guess at a near match: hand the message to the room leader, who
|
|
42
|
+
can answer it or redirect the sender.
|
|
43
|
+
|
|
44
|
+
## How to respond
|
|
45
|
+
1. **action**: "relay" to log the message in the room's transcript, or
|
|
46
|
+
"relay_silent" to pass it along without logging. Prefer "relay" — the
|
|
47
|
+
transcript is what a person reads to follow the room. Use "relay_silent" for
|
|
48
|
+
internal handoffs a reader would find noise, such as a request routed to a
|
|
49
|
+
specialist whose own reply will be the visible answer.
|
|
50
|
+
2. **content**: The literal word "relay" to pass the message on unchanged, which
|
|
51
|
+
is almost always right. Only write something else to genuinely rewrite it.
|
|
52
|
+
3. **name**: The one agent expected to answer next. It must be a name from the
|
|
53
|
+
Available Agents list. Leave it empty ("") when you cannot tell, and the room
|
|
54
|
+
leader will take the turn.
|
|
55
|
+
4. **targets**: Every agent that should receive the message, including the one
|
|
56
|
+
named in "name". Include the room leader ({{roomLeader}}) whenever they are
|
|
57
|
+
not the sender, unless you are deliberately keeping this exchange private —
|
|
58
|
+
the leader directs what happens next and can only do that from what it has
|
|
59
|
+
been told. Do not include a name that is not in the Available Agents list.
|
|
60
|
+
5. **relayAs**: The action the message carries in the room.
|
|
61
|
+
- "whisper" when the targets are only some of the agents present.
|
|
62
|
+
- "speak" when every agent present is a target.
|
|
63
|
+
- "shout" only when the message must reach the whole room regardless.
|
|
64
|
+
Getting this wrong misreports the conversation: a "speak" that only two of
|
|
65
|
+
six agents heard is logged as though the whole room heard it.
|
|
66
|
+
|
|
67
|
+
## Response Format
|
|
68
|
+
Respond with a valid JSON object and nothing else:
|
|
69
|
+
{
|
|
70
|
+
"action": "relay",
|
|
71
|
+
"content": "relay",
|
|
72
|
+
"name": "AgentName",
|
|
73
|
+
"targets": ["AgentName", "AnotherAgent"],
|
|
74
|
+
"relayAs": "speak"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
## Rules
|
|
78
|
+
- Never name the sender as the responder. An agent asked to answer its own
|
|
79
|
+
message talks to itself and the room stalls.
|
|
80
|
+
- Route a request for an action to the one agent whose description covers that
|
|
81
|
+
action, rather than to everyone who might have an opinion about it.
|
|
82
|
+
- Leave out any agent that would not realistically be aware of the message. An
|
|
83
|
+
agent that hears everything cannot hold anything in confidence.
|
|
84
|
+
- When no agent is a good fit, name the room leader rather than picking one at
|
|
85
|
+
random. A wrong specialist answers confidently from the wrong role.
|
|
86
|
+
|
|
87
|
+
## Examples
|
|
88
|
+
|
|
89
|
+
Assume these Available Agents: Analyst (answers questions about the data),
|
|
90
|
+
Navigator (finds pages and explains where things are), and a room leader named
|
|
91
|
+
Lisa.
|
|
92
|
+
|
|
93
|
+
### Example 1: A request only one agent can serve
|
|
94
|
+
Sender: Lisa
|
|
95
|
+
Recent Message: How many drivers were active last month?
|
|
96
|
+
Correct response:
|
|
97
|
+
{
|
|
98
|
+
"action": "relay",
|
|
99
|
+
"content": "relay",
|
|
100
|
+
"name": "Analyst",
|
|
101
|
+
"targets": ["Analyst", "Lisa"],
|
|
102
|
+
"relayAs": "speak"
|
|
103
|
+
}
|
|
104
|
+
- The description of Analyst covers questions about the data.
|
|
105
|
+
- Lisa is the room leader and is the sender, so she is in the targets as the
|
|
106
|
+
agent directing the work.
|
|
107
|
+
|
|
108
|
+
### Example 2: The sender addressed somebody who is not here
|
|
109
|
+
Sender: Lisa
|
|
110
|
+
Recent Message: Reporter, can you put together a summary of last quarter?
|
|
111
|
+
Correct response:
|
|
112
|
+
{
|
|
113
|
+
"action": "relay",
|
|
114
|
+
"content": "relay",
|
|
115
|
+
"name": "",
|
|
116
|
+
"targets": [],
|
|
117
|
+
"relayAs": "whisper"
|
|
118
|
+
}
|
|
119
|
+
- There is no agent named Reporter in the Available Agents list.
|
|
120
|
+
- Leave "name" empty and the targets empty. The message goes to the room leader,
|
|
121
|
+
who can answer it or tell the sender that no such agent is here.
|
|
122
|
+
|
|
123
|
+
### Example 3: Information the whole room should have
|
|
124
|
+
Sender: Analyst
|
|
125
|
+
Recent Message: The figures for last month are final now.
|
|
126
|
+
Correct response:
|
|
127
|
+
{
|
|
128
|
+
"action": "relay",
|
|
129
|
+
"content": "relay",
|
|
130
|
+
"name": "Lisa",
|
|
131
|
+
"targets": ["Lisa", "Navigator"],
|
|
132
|
+
"relayAs": "speak"
|
|
133
|
+
}
|
|
134
|
+
- This is information rather than a request, so everyone present is a target.
|
|
135
|
+
- Nobody was addressed, so the room leader takes the turn and decides what
|
|
136
|
+
happens next.
|
|
@@ -115,7 +115,7 @@ You must choose ONE of these actions:
|
|
|
115
115
|
{{#each availableTools}}
|
|
116
116
|
- **{{this.name}}**: {{this.description}}
|
|
117
117
|
{{#each this.parameters}}
|
|
118
|
-
- {{this.name}} ({{this.type}}{{#if this.required}}, required{{/if}}): {{this.description}}
|
|
118
|
+
- {{this.name}} ({{this.type}}{{#if this.required}}, required{{/if}}): {{this.description}}{{#if this.enumText}} Must be exactly one of: {{this.enumText}}.{{/if}}
|
|
119
119
|
{{/each}}
|
|
120
120
|
{{/each}}
|
|
121
121
|
{{/if}}
|
|
@@ -178,7 +178,7 @@ the round structure, the action economy, movement and the attack rules.
|
|
|
178
178
|
{{#each availableTools}}
|
|
179
179
|
- **{{this.name}}**: {{this.description}}
|
|
180
180
|
{{#each this.parameters}}
|
|
181
|
-
- {{this.name}} ({{this.type}}{{#if this.required}}, required{{/if}}): {{this.description}}
|
|
181
|
+
- {{this.name}} ({{this.type}}{{#if this.required}}, required{{/if}}): {{this.description}}{{#if this.enumText}} Must be exactly one of: {{this.enumText}}.{{/if}}
|
|
182
182
|
{{/each}}
|
|
183
183
|
{{/each}}
|
|
184
184
|
{{else}}
|
|
@@ -78,7 +78,7 @@ Cover, in roughly this order, and stop early if they are giving you enough:
|
|
|
78
78
|
{{#each availableTools}}
|
|
79
79
|
- **{{this.name}}**: {{this.description}}
|
|
80
80
|
{{#each this.parameters}}
|
|
81
|
-
- {{this.name}} ({{this.type}}{{#if this.required}}, required{{/if}}): {{this.description}}
|
|
81
|
+
- {{this.name}} ({{this.type}}{{#if this.required}}, required{{/if}}): {{this.description}}{{#if this.enumText}} Must be exactly one of: {{this.enumText}}.{{/if}}
|
|
82
82
|
{{/each}}
|
|
83
83
|
{{/each}}
|
|
84
84
|
{{/if}}
|