briyah 2.0.6 → 2.0.7
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 +105 -0
- package/data/packs/dnd5e/pack.json +7 -1
- package/dist-sdk/server/src/ai/agent.d.ts +27 -0
- package/dist-sdk/server/src/ai/agent.js +54 -13
- package/dist-sdk/server/src/app/user-service-factory.js +3 -0
- package/dist-sdk/server/src/app.controller.d.ts +7 -1
- package/dist-sdk/server/src/app.controller.js +55 -0
- package/dist-sdk/server/src/app.service.d.ts +114 -2
- package/dist-sdk/server/src/app.service.js +181 -4
- package/dist-sdk/server/src/documents/document-conversion.d.ts +70 -0
- package/dist-sdk/server/src/documents/document-conversion.js +341 -0
- package/dist-sdk/server/src/documents/library/chunking.d.ts +65 -0
- package/dist-sdk/server/src/documents/library/chunking.js +263 -0
- package/dist-sdk/server/src/documents/library/document-guide.builder.d.ts +2 -0
- package/dist-sdk/server/src/documents/library/document-guide.builder.js +58 -0
- package/dist-sdk/server/src/documents/library/document-registry.d.ts +22 -0
- package/dist-sdk/server/src/documents/library/document-registry.js +44 -0
- package/dist-sdk/server/src/documents/library/document.types.d.ts +108 -0
- package/dist-sdk/server/src/documents/library/document.types.js +20 -0
- package/dist-sdk/server/src/documents/library/embedding.d.ts +57 -0
- package/dist-sdk/server/src/documents/library/embedding.js +151 -0
- package/dist-sdk/server/src/packs/pack-manifest.d.ts +46 -0
- package/dist-sdk/server/src/packs/pack-manifest.js +46 -1
- package/dist-sdk/server/src/room/artifact-store.service.js +44 -11
- package/dist-sdk/server/src/room/artifact.d.ts +8 -0
- package/dist-sdk/server/src/room/room.js +7 -1
- package/dist-sdk/server/src/rpg/rpg-roster.d.ts +70 -29
- package/dist-sdk/server/src/rpg/rpg-roster.js +152 -41
- package/dist-sdk/server/src/rpg/rpg.service.d.ts +66 -29
- package/dist-sdk/server/src/rpg/rpg.service.js +140 -65
- package/dist-sdk/server/src/sdk/index.d.ts +12 -2
- package/dist-sdk/server/src/sdk/index.js +27 -1
- package/dist-sdk/server/src/tools/core/document.tools.d.ts +39 -0
- package/dist-sdk/server/src/tools/core/document.tools.js +391 -0
- package/dist-sdk/server/src/tools/core/index.js +2 -1
- package/dist-sdk/server/src/tools/native-tool.types.d.ts +37 -0
- package/dist-sdk/server/src/tools/tool-execution.service.d.ts +23 -2
- package/dist-sdk/server/src/tools/tool-execution.service.js +30 -6
- package/dist-sdk/shared/types/app.types.d.ts +39 -5
- package/package.json +172 -167
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Campaigns: a streamlined way to start and hold a
|
|
3
|
+
* Campaigns: a streamlined way to start and hold a game.
|
|
4
4
|
*
|
|
5
|
-
* A campaign is not a new kind of thing. It is an ordinary room built from
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* A campaign is not a new kind of thing. It is an ordinary room built from a pack's
|
|
6
|
+
* table template — the crew that runs the game — with a party seated on top and the
|
|
7
|
+
* whole thing published, so the link the party plays through exists from the first
|
|
8
|
+
* moment.
|
|
9
|
+
*
|
|
10
|
+
* ## Which games exist
|
|
11
|
+
*
|
|
12
|
+
* Whichever installed packs say so. A pack declares a `table` block naming the room to
|
|
13
|
+
* build and the agent template to seat a party from, and {@link RpgTable} resolves that
|
|
14
|
+
* against its templates; this service asks for the list and never names a pack itself.
|
|
15
|
+
* That is what lets a host drop in a second ruleset — the dnd5e pack seats six players
|
|
16
|
+
* behind five crew agents, the acts pack four students behind three — without the RPG
|
|
17
|
+
* page learning anything about either.
|
|
9
18
|
*
|
|
10
19
|
* ## Why there is no campaign store
|
|
11
20
|
*
|
|
12
21
|
* Everything a campaign is, a room already holds: its roster, its turn mode, its
|
|
13
|
-
* leader and moderator, its artifacts, its transcript and its cost. Which
|
|
14
|
-
* player is `
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
22
|
+
* leader and moderator, its artifacts, its transcript and its cost. Which pack it plays
|
|
23
|
+
* by is `pack`; which agent is a player is `packAgentKey`; a character's personality is
|
|
24
|
+
* `privateContext`. A store would be a second copy of all of that, and it would drift
|
|
25
|
+
* the moment somebody renamed an agent from the Agents page. So a campaign is
|
|
26
|
+
* discovered by filtering rooms, and its details are derived per request.
|
|
18
27
|
*
|
|
19
28
|
* ## Why every write goes through AppService
|
|
20
29
|
*
|
|
@@ -46,6 +55,18 @@ class RpgService {
|
|
|
46
55
|
listModels() {
|
|
47
56
|
return (0, rpg_models_1.listRpgModelOptions)(this.userPaths.getCommonConfigDir());
|
|
48
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The games a campaign may be built from, as the client is offered them.
|
|
60
|
+
*
|
|
61
|
+
* Installed rather than enabled, because {@link ensurePackEnabled} turns the chosen
|
|
62
|
+
* one on: a user on the RPG surface has no Packs page, so offering only what they
|
|
63
|
+
* had already enabled would offer them nothing at all on their first visit.
|
|
64
|
+
*/
|
|
65
|
+
listPacks() {
|
|
66
|
+
const tables = this.tables();
|
|
67
|
+
const preferred = (0, rpg_roster_1.pickDefaultTable)(tables);
|
|
68
|
+
return tables.map((table) => (0, rpg_roster_1.toRpgPackOption)(table, table.pack === preferred?.pack));
|
|
69
|
+
}
|
|
49
70
|
/**
|
|
50
71
|
* Builds a campaign and publishes it.
|
|
51
72
|
*
|
|
@@ -53,14 +74,14 @@ class RpgService {
|
|
|
53
74
|
* before the first side effect; then the crew; then the party and the publish. Any
|
|
54
75
|
* failure past the first agent deletes the room, which takes its agents with it.
|
|
55
76
|
*
|
|
56
|
-
* Synchronous throughout, unlike story creation:
|
|
57
|
-
*
|
|
58
|
-
*
|
|
77
|
+
* Synchronous throughout, unlike story creation: no pack fires a prompt at
|
|
78
|
+
* instantiation, so this is file I/O for a dozen agents. It either returns a
|
|
79
|
+
* campaign that can be played or leaves nothing behind.
|
|
59
80
|
*
|
|
60
|
-
* @param request The campaign's name, quality tier and party
|
|
81
|
+
* @param request The campaign's name, game, quality tier and party
|
|
61
82
|
* @returns The campaign, its public link, and anything that did not go to plan
|
|
62
|
-
* @throws {ValidationError} If the party or the quality tier is not acceptable
|
|
63
|
-
* @throws {NotFoundError} If this deployment
|
|
83
|
+
* @throws {ValidationError} If the game, the party or the quality tier is not acceptable
|
|
84
|
+
* @throws {NotFoundError} If this deployment ships no game pack at all
|
|
64
85
|
*/
|
|
65
86
|
async createCampaign(request) {
|
|
66
87
|
const name = request.name?.trim();
|
|
@@ -72,12 +93,13 @@ class RpgService {
|
|
|
72
93
|
}
|
|
73
94
|
// Phase 0: nothing here has an effect, so a typo in the fourth player's model
|
|
74
95
|
// surfaces before three agents exist.
|
|
75
|
-
|
|
76
|
-
|
|
96
|
+
const table = this.requireTable(request.pack);
|
|
97
|
+
(0, rpg_roster_1.assertSeatable)(request.players, table);
|
|
98
|
+
const seats = this.resolveSeats(request.players, table);
|
|
77
99
|
const crewModels = (0, rpg_models_1.resolveCrewModels)(this.userPaths.getCommonConfigDir(), request.quality);
|
|
78
|
-
this.
|
|
100
|
+
this.ensurePackEnabled(table.pack);
|
|
79
101
|
// Phase 1: the crew. This rolls itself back on failure.
|
|
80
|
-
const built = await this.app.packInstantiation.instantiateRoom(
|
|
102
|
+
const built = await this.app.packInstantiation.instantiateRoom(table.pack, table.roomKey, crewModels, name);
|
|
81
103
|
const campaignId = built.roomId;
|
|
82
104
|
const warnings = [...built.warnings];
|
|
83
105
|
// Phase 2: the party, then the link. From here the room exists, so a failure
|
|
@@ -86,28 +108,31 @@ class RpgService {
|
|
|
86
108
|
const players = [];
|
|
87
109
|
for (const seat of seats) {
|
|
88
110
|
const created = await this.app.createRoomAgentFromFolder(campaignId, {
|
|
89
|
-
folder:
|
|
111
|
+
folder: table.playerFolder,
|
|
90
112
|
aiServiceName: seat.model?.service ?? crewModels.primary.aiServiceName,
|
|
91
113
|
aiModel: seat.model?.model ?? this.economyModel(crewModels),
|
|
92
114
|
smallModelName: seat.model?.small_model ?? crewModels.primary.smallModelName,
|
|
93
115
|
overrides: {
|
|
116
|
+
// The pack's own seat settings first, so anything it asks for
|
|
117
|
+
// that is none of this service's business survives. Everything
|
|
118
|
+
// below is a decision the RPG page made, and has to win.
|
|
119
|
+
...table.playerOverrides,
|
|
94
120
|
agentName: seat.seatName,
|
|
95
|
-
// A placeholder, and unique by construction. The
|
|
96
|
-
//
|
|
97
|
-
// invents, which is what gives the table one name per
|
|
98
|
-
// instead of a seat name and a character name for each.
|
|
121
|
+
// A placeholder, and unique by construction. The pack's
|
|
122
|
+
// character builder renames the agent to whatever character the
|
|
123
|
+
// player invents, which is what gives the table one name per
|
|
124
|
+
// person instead of a seat name and a character name for each.
|
|
99
125
|
agentNickname: seat.seatName.replace(/\s+/g, ''),
|
|
100
|
-
description: `${seat.seatName}, a player at the table. Renamed to their character once their sheet is built.`,
|
|
101
126
|
controlledByHuman: seat.isHuman,
|
|
102
127
|
// AI players only. A person at the table keeps the action and
|
|
103
128
|
// target pickers, so they can whisper to another player or
|
|
104
|
-
// address the
|
|
105
|
-
// decide both from their text.
|
|
129
|
+
// address the game's leader directly rather than having the
|
|
130
|
+
// moderator decide both from their text.
|
|
106
131
|
useModerator: !seat.isHuman,
|
|
107
132
|
...(seat.isHuman ? {} : { privateContext: seat.personality }),
|
|
108
133
|
},
|
|
109
|
-
pack:
|
|
110
|
-
packAgentKey:
|
|
134
|
+
pack: table.pack,
|
|
135
|
+
packAgentKey: table.playerAgentKey,
|
|
111
136
|
});
|
|
112
137
|
players.push({
|
|
113
138
|
agentId: created.agentId,
|
|
@@ -131,7 +156,7 @@ class RpgService {
|
|
|
131
156
|
};
|
|
132
157
|
}
|
|
133
158
|
catch (error) {
|
|
134
|
-
// A campaign short a player is a table where the
|
|
159
|
+
// A campaign short a player is a table where the game's leader addresses
|
|
135
160
|
// somebody who is not there, and a campaign with no link has nothing to
|
|
136
161
|
// play in. Neither is a state the UI has a screen for, so there is no
|
|
137
162
|
// partial success worth keeping. deleteRoom also takes the agents the room
|
|
@@ -145,13 +170,18 @@ class RpgService {
|
|
|
145
170
|
}
|
|
146
171
|
/** Every campaign this user has, newest first. */
|
|
147
172
|
async listCampaigns() {
|
|
173
|
+
// Resolved once for the whole listing: reading the tables means reading every
|
|
174
|
+
// installed pack's directory, and a user with a dozen campaigns would otherwise
|
|
175
|
+
// do it a dozen times to answer the same question.
|
|
176
|
+
const tables = this.tables();
|
|
148
177
|
const rooms = await this.app.listRooms();
|
|
149
178
|
const campaigns = [];
|
|
150
179
|
for (const summary of rooms) {
|
|
151
180
|
const room = await this.app.getRoomById(summary.id);
|
|
152
|
-
|
|
181
|
+
const table = room && this.tableFor(room, tables);
|
|
182
|
+
if (!room || !table)
|
|
153
183
|
continue;
|
|
154
|
-
campaigns.push(await this.summarize(room));
|
|
184
|
+
campaigns.push(await this.summarize(room, table));
|
|
155
185
|
}
|
|
156
186
|
return campaigns.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
157
187
|
}
|
|
@@ -164,9 +194,9 @@ class RpgService {
|
|
|
164
194
|
* @throws {NotFoundError} If there is no such campaign
|
|
165
195
|
*/
|
|
166
196
|
async getCampaign(campaignId) {
|
|
167
|
-
const room = await this.requireCampaign(campaignId);
|
|
168
|
-
const summary = await this.summarize(room);
|
|
169
|
-
const { players, crew } = this.splitRoster(room);
|
|
197
|
+
const { room, table } = await this.requireCampaign(campaignId);
|
|
198
|
+
const summary = await this.summarize(room, table);
|
|
199
|
+
const { players, crew } = this.splitRoster(room, table);
|
|
170
200
|
return {
|
|
171
201
|
...summary,
|
|
172
202
|
goal: room.getGoal(),
|
|
@@ -184,7 +214,7 @@ class RpgService {
|
|
|
184
214
|
* @throws {ValidationError} If the campaign already has a link
|
|
185
215
|
*/
|
|
186
216
|
async republishCampaign(campaignId) {
|
|
187
|
-
const room = await this.requireCampaign(campaignId);
|
|
217
|
+
const { room } = await this.requireCampaign(campaignId);
|
|
188
218
|
const existing = await this.app.getPublishedRoomInstances(campaignId);
|
|
189
219
|
if (existing.length > 0) {
|
|
190
220
|
throw new errors_1.ValidationError('This campaign already has a link.');
|
|
@@ -193,10 +223,10 @@ class RpgService {
|
|
|
193
223
|
return { instanceId, publicPath: `/public/rooms/${instanceId}` };
|
|
194
224
|
}
|
|
195
225
|
/** Each seat with its model resolved up front. @throws {ValidationError} */
|
|
196
|
-
resolveSeats(players) {
|
|
226
|
+
resolveSeats(players, table) {
|
|
197
227
|
const configDir = this.userPaths.getCommonConfigDir();
|
|
198
228
|
return players.map((player, index) => ({
|
|
199
|
-
seatName:
|
|
229
|
+
seatName: table.seatNames[index],
|
|
200
230
|
isHuman: player.isHuman,
|
|
201
231
|
personality: player.personality?.trim() ?? '',
|
|
202
232
|
model: player.isHuman
|
|
@@ -209,51 +239,96 @@ class RpgService {
|
|
|
209
239
|
return (models.economy ?? models.primary).aiModel;
|
|
210
240
|
}
|
|
211
241
|
/**
|
|
212
|
-
*
|
|
242
|
+
* Every game this deployment ships, in the order the client is offered them.
|
|
213
243
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
|
|
217
|
-
|
|
244
|
+
* Read from disk on every call, as `rpg_models.json` is, so a host who drops a pack
|
|
245
|
+
* in does not have to restart the server for it to appear.
|
|
246
|
+
*/
|
|
247
|
+
tables() {
|
|
248
|
+
return this.packs
|
|
249
|
+
.listPacks()
|
|
250
|
+
.map((pack) => (0, rpg_roster_1.resolveRpgTable)(pack))
|
|
251
|
+
.filter((table) => table !== null);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The table a request asked for, or the default.
|
|
218
255
|
*
|
|
219
|
-
*
|
|
256
|
+
* An unknown name is refused rather than falling back, for `resolveRpgModel`'s
|
|
257
|
+
* reason: a name this deployment does not have means the client and the packs
|
|
258
|
+
* directory disagree, and quietly building some other game is worse than saying so.
|
|
259
|
+
*
|
|
260
|
+
* @param packName A pack name, or absent to take the default
|
|
261
|
+
* @throws {NotFoundError} If this deployment ships no game pack at all
|
|
262
|
+
* @throws {ValidationError} If it ships some, but not that one
|
|
220
263
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
264
|
+
requireTable(packName) {
|
|
265
|
+
const tables = this.tables();
|
|
266
|
+
if (tables.length === 0) {
|
|
267
|
+
throw new errors_1.NotFoundError('This deployment does not ship a game to play.');
|
|
268
|
+
}
|
|
269
|
+
const wanted = packName?.trim();
|
|
270
|
+
if (!wanted) {
|
|
271
|
+
return (0, rpg_roster_1.pickDefaultTable)(tables);
|
|
224
272
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
273
|
+
const match = tables.find((table) => table.pack === wanted) ??
|
|
274
|
+
tables.find((table) => table.pack.toLowerCase() === wanted.toLowerCase());
|
|
275
|
+
if (!match) {
|
|
276
|
+
throw new errors_1.ValidationError(`"${packName}" is not a game this deployment offers. Choose one of: ` +
|
|
277
|
+
tables.map((table) => table.pack).join(', '));
|
|
278
|
+
}
|
|
279
|
+
return match;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Turns the chosen pack on if it is not already.
|
|
283
|
+
*
|
|
284
|
+
* Here rather than in `PackInstantiationService`: self-enabling instantiation would
|
|
285
|
+
* change behaviour for every pack to suit one feature. A user on the RPG surface
|
|
286
|
+
* who picked a game has unambiguously asked for that pack's content, and has no
|
|
287
|
+
* Packs page to be sent to.
|
|
288
|
+
*/
|
|
289
|
+
ensurePackEnabled(packName) {
|
|
290
|
+
if (!this.packs.enabledPacks().includes(packName)) {
|
|
291
|
+
logger_1.logger.log(`Enabling the ${packName} pack for ${this.userId}: they asked for a campaign.`);
|
|
292
|
+
this.userConfig.setPackEnabled(packName, true);
|
|
228
293
|
}
|
|
229
294
|
}
|
|
230
295
|
/**
|
|
231
|
-
*
|
|
296
|
+
* The table a room is a campaign of, or null when it is not one.
|
|
297
|
+
*
|
|
298
|
+
* Both halves matter: the pack alone would also match a game built by hand from the
|
|
299
|
+
* Packs page, which seats a player the RPG page did not create and does not know
|
|
300
|
+
* how to show.
|
|
232
301
|
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
* know how to show.
|
|
302
|
+
* @param room Any room
|
|
303
|
+
* @param tables The tables to match against, resolved by the caller
|
|
236
304
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
305
|
+
tableFor(room, tables) {
|
|
306
|
+
const pack = room.getPack();
|
|
307
|
+
const roomKey = room.getPackRoomKey();
|
|
308
|
+
if (!pack || !roomKey)
|
|
309
|
+
return null;
|
|
310
|
+
return tables.find((table) => table.pack === pack && table.roomKey === roomKey) ?? null;
|
|
239
311
|
}
|
|
240
312
|
/** @throws {NotFoundError} If the room is missing or is not a campaign */
|
|
241
313
|
async requireCampaign(campaignId) {
|
|
242
314
|
const room = await this.app.getRoomById(campaignId);
|
|
243
|
-
|
|
315
|
+
const table = room && this.tableFor(room, this.tables());
|
|
316
|
+
if (!room || !table) {
|
|
244
317
|
throw new errors_1.NotFoundError('Campaign not found');
|
|
245
318
|
}
|
|
246
|
-
return room;
|
|
319
|
+
return { room, table };
|
|
247
320
|
}
|
|
248
321
|
/** The listing shape, including the published link the party plays through. */
|
|
249
|
-
async summarize(room) {
|
|
322
|
+
async summarize(room, table) {
|
|
250
323
|
const instances = await this.app.getPublishedRoomInstances(room.getId());
|
|
251
324
|
const instance = instances[0];
|
|
252
325
|
const agents = room.getAgents();
|
|
253
|
-
const players = agents.filter((agent) => this.isPlayer(agent));
|
|
326
|
+
const players = agents.filter((agent) => this.isPlayer(agent, table));
|
|
254
327
|
return {
|
|
255
328
|
campaignId: room.getId(),
|
|
256
329
|
name: room.getName(),
|
|
330
|
+
pack: table.pack,
|
|
331
|
+
packTitle: table.title,
|
|
257
332
|
instanceId: instance?.id,
|
|
258
333
|
playerCount: players.length,
|
|
259
334
|
playerNames: players.map((agent) => agent.agentNickname),
|
|
@@ -272,12 +347,12 @@ class RpgService {
|
|
|
272
347
|
* AI player is a player too — it is seated from the same template and shown in the
|
|
273
348
|
* same roster.
|
|
274
349
|
*/
|
|
275
|
-
splitRoster(room) {
|
|
350
|
+
splitRoster(room, table) {
|
|
276
351
|
const configDir = this.userPaths.getCommonConfigDir();
|
|
277
352
|
const players = [];
|
|
278
353
|
const crew = [];
|
|
279
354
|
for (const agent of room.getAgents()) {
|
|
280
|
-
if (this.isPlayer(agent)) {
|
|
355
|
+
if (this.isPlayer(agent, table)) {
|
|
281
356
|
players.push({
|
|
282
357
|
agentId: agent.id,
|
|
283
358
|
nickname: agent.agentNickname,
|
|
@@ -299,8 +374,8 @@ class RpgService {
|
|
|
299
374
|
}
|
|
300
375
|
return { players, crew };
|
|
301
376
|
}
|
|
302
|
-
isPlayer(agent) {
|
|
303
|
-
return agent.packAgentKey ===
|
|
377
|
+
isPlayer(agent, table) {
|
|
378
|
+
return agent.packAgentKey === table.playerAgentKey;
|
|
304
379
|
}
|
|
305
380
|
}
|
|
306
381
|
exports.RpgService = RpgService;
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
export { Briyah } from './briyah';
|
|
2
2
|
export { BriyahConfigService, BriyahConfigOptions } from './briyah-config';
|
|
3
|
-
export type { AppService, AgentCreationOptions, PdfMarkdownOptions, PdfMarkdownResult, } from '../app.service';
|
|
3
|
+
export type { AppService, AgentCreationOptions, PdfMarkdownOptions, PdfMarkdownResult, DocumentMarkdownOptions, DocumentMarkdownResult, } from '../app.service';
|
|
4
|
+
export { detectDocumentType, convertLocalDocument, UnsupportedDocumentError, } from '../documents/document-conversion';
|
|
5
|
+
export type { DocumentFileType, DocumentTypeDetection, DocumentPage as ConvertedDocumentPage, LocalDocumentConversion, LocalConversionOptions, } from '../documents/document-conversion';
|
|
6
|
+
export type { DocumentSource, DocumentSummary, DocumentSearchRequest, DocumentHit, DocumentPages, DocumentPage, DocumentText, PageRange, } from '../documents/library/document.types';
|
|
7
|
+
export { registerDocumentSource, unregisterDocumentSource, listDocumentSources, } from '../documents/library/document-registry';
|
|
8
|
+
export { buildDocumentGuideMarkdown } from '../documents/library/document-guide.builder';
|
|
9
|
+
export { chunkPages, embeddingInput, DEFAULT_CHUNK_MAX_CHARS, DEFAULT_CHUNK_OVERLAP_CHARS, } from '../documents/library/chunking';
|
|
10
|
+
export type { ChunkablePage, DocumentChunk, ChunkOptions } from '../documents/library/chunking';
|
|
11
|
+
export { embedTexts, EMBEDDING_DIMENSIONS, DEFAULT_EMBEDDING_MODEL, } from '../documents/library/embedding';
|
|
12
|
+
export type { EmbeddingProvider, EmbeddingOptions, EmbeddingResult } from '../documents/library/embedding';
|
|
13
|
+
export { libraryAttachmentName, isLibraryAttachment, libraryDocumentIdOf, } from '../tools/core/document.tools';
|
|
4
14
|
export { splitMarkdownIntoPages, stripWrappingFence, pageMarker, buildMarkdown, } from '../documents/pdf-conversion';
|
|
5
15
|
export type { PdfPageMarkdown, PdfConversionOptions, PdfConversionResult, ConversionAgent, } from '../documents/pdf-conversion';
|
|
6
16
|
export type { AgentInfo, CreateAgentResponse, RoomInfo, RoomDetails, CreateRoomResponse, StoryInfo, CreateStoryResponse, ProcessTextResponse, FileList, PromptFileContent, AttachDocumentResponse, AgentMessagesResponse, RoomMessagesResponse, RoomMessageUpdate, RoomErrorUpdate, RoomUpdate, RoomTurnMode, SendMessageResult, StoryState, Message, MessageAction, ModelInfo, ArtifactMetadata, PreparedPromptResponse, PromptScope, PromptFolder, PromptFoldersResponse, PromptFolderDefaults, PromptFolderDefaultsResponse, PromptFile, PromptFilesResponse, StoryIdea, Transaction, TransactionHistoryResponse, ToolDefinition, ToolParameter, ToolSummary, ToolsResponse, ToolRunResult, StoryStateEvent, StoryIntroduceCharacterEvent, StoryProgressChapterEvent, StoryErrorEvent, Character, ChapterInfo, } from '../../../shared/types/app.types';
|
|
7
17
|
export type { LoggingOptions } from './briyah-config';
|
|
8
|
-
export type { NativeToolDefinition, ToolHelpers, ToolContext, ToolCaller, ToolArtifact, ToolRoomAccess, ToolPackDocuments, ArtifactWriteOptions, } from '../tools/native-tool.types';
|
|
18
|
+
export type { NativeToolDefinition, ToolHelpers, ToolContext, ToolCaller, ToolArtifact, ToolRoomAccess, ToolPackDocuments, ToolAgentDocuments, ToolHeldDocument, ArtifactWriteOptions, } from '../tools/native-tool.types';
|
|
9
19
|
export { dnd5eTools } from '../tools/packs/dnd5e';
|
|
10
20
|
export { installToolPacks, registerToolPacks, availableToolPacks } from '../tools/packs';
|
|
11
21
|
export { NativeToolRegistry } from '../tools/native-tool-registry.service';
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoomMessage = exports.Room = exports.Agent = exports.PackInstantiationService = exports.PackService = exports.buildDataGuideMarkdown = exports.listDatasets = exports.listDataSources = exports.unregisterDataSource = exports.registerDataSource = exports.MAX_ROW_LIMIT = exports.DEFAULT_ROW_LIMIT = exports.NativeToolRegistry = exports.availableToolPacks = exports.registerToolPacks = exports.installToolPacks = exports.dnd5eTools = exports.buildMarkdown = exports.pageMarker = exports.stripWrappingFence = exports.splitMarkdownIntoPages = exports.BriyahConfigService = exports.Briyah = void 0;
|
|
3
|
+
exports.RoomMessage = exports.Room = exports.Agent = exports.PackInstantiationService = exports.PackService = exports.buildDataGuideMarkdown = exports.listDatasets = exports.listDataSources = exports.unregisterDataSource = exports.registerDataSource = exports.MAX_ROW_LIMIT = exports.DEFAULT_ROW_LIMIT = exports.NativeToolRegistry = exports.availableToolPacks = exports.registerToolPacks = exports.installToolPacks = exports.dnd5eTools = exports.buildMarkdown = exports.pageMarker = exports.stripWrappingFence = exports.splitMarkdownIntoPages = exports.libraryDocumentIdOf = exports.isLibraryAttachment = exports.libraryAttachmentName = exports.DEFAULT_EMBEDDING_MODEL = exports.EMBEDDING_DIMENSIONS = exports.embedTexts = exports.DEFAULT_CHUNK_OVERLAP_CHARS = exports.DEFAULT_CHUNK_MAX_CHARS = exports.embeddingInput = exports.chunkPages = exports.buildDocumentGuideMarkdown = exports.listDocumentSources = exports.unregisterDocumentSource = exports.registerDocumentSource = exports.UnsupportedDocumentError = exports.convertLocalDocument = exports.detectDocumentType = exports.BriyahConfigService = exports.Briyah = void 0;
|
|
4
4
|
// Main SDK exports
|
|
5
5
|
var briyah_1 = require("./briyah");
|
|
6
6
|
Object.defineProperty(exports, "Briyah", { enumerable: true, get: function () { return briyah_1.Briyah; } });
|
|
7
7
|
var briyah_config_1 = require("./briyah-config");
|
|
8
8
|
Object.defineProperty(exports, "BriyahConfigService", { enumerable: true, get: function () { return briyah_config_1.BriyahConfigService; } });
|
|
9
|
+
// Any upload → Markdown. `appService.convertDocumentToMarkdown` is the entry point
|
|
10
|
+
// and handles PDF, Word, Excel and text alike; these are exported for a host that
|
|
11
|
+
// wants to check a file before accepting it, or to catch the refusal by type.
|
|
12
|
+
var document_conversion_1 = require("../documents/document-conversion");
|
|
13
|
+
Object.defineProperty(exports, "detectDocumentType", { enumerable: true, get: function () { return document_conversion_1.detectDocumentType; } });
|
|
14
|
+
Object.defineProperty(exports, "convertLocalDocument", { enumerable: true, get: function () { return document_conversion_1.convertLocalDocument; } });
|
|
15
|
+
Object.defineProperty(exports, "UnsupportedDocumentError", { enumerable: true, get: function () { return document_conversion_1.UnsupportedDocumentError; } });
|
|
16
|
+
var document_registry_1 = require("../documents/library/document-registry");
|
|
17
|
+
Object.defineProperty(exports, "registerDocumentSource", { enumerable: true, get: function () { return document_registry_1.registerDocumentSource; } });
|
|
18
|
+
Object.defineProperty(exports, "unregisterDocumentSource", { enumerable: true, get: function () { return document_registry_1.unregisterDocumentSource; } });
|
|
19
|
+
Object.defineProperty(exports, "listDocumentSources", { enumerable: true, get: function () { return document_registry_1.listDocumentSources; } });
|
|
20
|
+
var document_guide_builder_1 = require("../documents/library/document-guide.builder");
|
|
21
|
+
Object.defineProperty(exports, "buildDocumentGuideMarkdown", { enumerable: true, get: function () { return document_guide_builder_1.buildDocumentGuideMarkdown; } });
|
|
22
|
+
var chunking_1 = require("../documents/library/chunking");
|
|
23
|
+
Object.defineProperty(exports, "chunkPages", { enumerable: true, get: function () { return chunking_1.chunkPages; } });
|
|
24
|
+
Object.defineProperty(exports, "embeddingInput", { enumerable: true, get: function () { return chunking_1.embeddingInput; } });
|
|
25
|
+
Object.defineProperty(exports, "DEFAULT_CHUNK_MAX_CHARS", { enumerable: true, get: function () { return chunking_1.DEFAULT_CHUNK_MAX_CHARS; } });
|
|
26
|
+
Object.defineProperty(exports, "DEFAULT_CHUNK_OVERLAP_CHARS", { enumerable: true, get: function () { return chunking_1.DEFAULT_CHUNK_OVERLAP_CHARS; } });
|
|
27
|
+
var embedding_1 = require("../documents/library/embedding");
|
|
28
|
+
Object.defineProperty(exports, "embedTexts", { enumerable: true, get: function () { return embedding_1.embedTexts; } });
|
|
29
|
+
Object.defineProperty(exports, "EMBEDDING_DIMENSIONS", { enumerable: true, get: function () { return embedding_1.EMBEDDING_DIMENSIONS; } });
|
|
30
|
+
Object.defineProperty(exports, "DEFAULT_EMBEDDING_MODEL", { enumerable: true, get: function () { return embedding_1.DEFAULT_EMBEDDING_MODEL; } });
|
|
31
|
+
var document_tools_1 = require("../tools/core/document.tools");
|
|
32
|
+
Object.defineProperty(exports, "libraryAttachmentName", { enumerable: true, get: function () { return document_tools_1.libraryAttachmentName; } });
|
|
33
|
+
Object.defineProperty(exports, "isLibraryAttachment", { enumerable: true, get: function () { return document_tools_1.isLibraryAttachment; } });
|
|
34
|
+
Object.defineProperty(exports, "libraryDocumentIdOf", { enumerable: true, get: function () { return document_tools_1.libraryDocumentIdOf; } });
|
|
9
35
|
// PDF → Markdown conversion.
|
|
10
36
|
//
|
|
11
37
|
// `appService.convertPdfToMarkdownPages` is the entry point; these are exported for
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding, reading and holding a host's documents.
|
|
3
|
+
*
|
|
4
|
+
* There are two ways for an agent to use a document, and they cost very
|
|
5
|
+
* different amounts. It can look things up — search for a passage, read the
|
|
6
|
+
* pages around it — which puts only what it read into its history. Or it can
|
|
7
|
+
* hold the whole document, which puts every page into every request it makes
|
|
8
|
+
* until it lets go. Looking up is right for "what does the contract say about
|
|
9
|
+
* termination". Holding is right for "review this contract" or "compare these
|
|
10
|
+
* two", where no amount of searching substitutes for having read the thing.
|
|
11
|
+
*
|
|
12
|
+
* So looking up is the default and cheap, and holding is an explicit step with
|
|
13
|
+
* a size check in front of it: past a threshold the agent has to confirm it
|
|
14
|
+
* means to, and is told what it will cost; past a ceiling it cannot, and is told
|
|
15
|
+
* to read in pages instead.
|
|
16
|
+
*
|
|
17
|
+
* A document id from the agent is only ever used after it is found in what the
|
|
18
|
+
* host lists for this call's context — never passed through on trust.
|
|
19
|
+
*/
|
|
20
|
+
import { NativeToolDefinition } from '../native-tool.types';
|
|
21
|
+
/**
|
|
22
|
+
* The file name a held library document is attached under.
|
|
23
|
+
*
|
|
24
|
+
* It carries the document id so a held document can be found again, released,
|
|
25
|
+
* and told apart from the documents an agent's own configuration attached — a
|
|
26
|
+
* host resetting a conversation releases these and keeps those.
|
|
27
|
+
*/
|
|
28
|
+
export declare function libraryAttachmentName(documentId: string, name: string): string;
|
|
29
|
+
/** Whether an attachment is a library document an agent chose to hold. */
|
|
30
|
+
export declare function isLibraryAttachment(fileName: string): boolean;
|
|
31
|
+
/** The library document id an attachment holds, or undefined for any other attachment. */
|
|
32
|
+
export declare function libraryDocumentIdOf(fileName: string): string | undefined;
|
|
33
|
+
export declare const listDocumentsTool: NativeToolDefinition;
|
|
34
|
+
export declare const findInDocumentsTool: NativeToolDefinition;
|
|
35
|
+
export declare const readDocumentTool: NativeToolDefinition;
|
|
36
|
+
export declare const loadDocumentTool: NativeToolDefinition;
|
|
37
|
+
export declare const unloadDocumentTool: NativeToolDefinition;
|
|
38
|
+
/** Every document tool, in the order an agent would reach for them. */
|
|
39
|
+
export declare const documentTools: NativeToolDefinition[];
|