briyah 2.0.10 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/data/common/config/image_models.json +85 -6
  2. package/data/common/config/model_prices.json +30170 -32794
  3. package/dist-sdk/server/src/ai/LLM/anthropic.service.js +1 -1
  4. package/dist-sdk/server/src/ai/LLM/comfyui.service.js +1 -1
  5. package/dist-sdk/server/src/ai/LLM/deepseek.service.d.ts +1 -1
  6. package/dist-sdk/server/src/ai/LLM/deepseek.service.js +3 -2
  7. package/dist-sdk/server/src/ai/LLM/fal.service.d.ts +1 -1
  8. package/dist-sdk/server/src/ai/LLM/fal.service.js +4 -3
  9. package/dist-sdk/server/src/ai/LLM/googleai.service.d.ts +1 -1
  10. package/dist-sdk/server/src/ai/LLM/googleai.service.js +5 -4
  11. package/dist-sdk/server/src/ai/LLM/grok.service.d.ts +1 -1
  12. package/dist-sdk/server/src/ai/LLM/grok.service.js +3 -2
  13. package/dist-sdk/server/src/ai/LLM/mock.service.d.ts +1 -1
  14. package/dist-sdk/server/src/ai/LLM/mock.service.js +3 -2
  15. package/dist-sdk/server/src/ai/LLM/openai.service.js +2 -2
  16. package/dist-sdk/server/src/ai/LLM/self-hosted.service.js +1 -1
  17. package/dist-sdk/server/src/ai/LLM/together.service.d.ts +1 -1
  18. package/dist-sdk/server/src/ai/LLM/together.service.js +5 -4
  19. package/dist-sdk/server/src/ai/agent-config.d.ts +4 -0
  20. package/dist-sdk/server/src/ai/agent-store.service.js +3 -0
  21. package/dist-sdk/server/src/ai/agent.d.ts +7 -0
  22. package/dist-sdk/server/src/ai/agent.js +6 -0
  23. package/dist-sdk/server/src/app/balance.service.d.ts +155 -27
  24. package/dist-sdk/server/src/app/balance.service.js +290 -97
  25. package/dist-sdk/server/src/app/usage-context.d.ts +24 -0
  26. package/dist-sdk/server/src/app/usage-context.js +35 -0
  27. package/dist-sdk/server/src/app.controller.d.ts +5 -0
  28. package/dist-sdk/server/src/app.controller.js +13 -2
  29. package/dist-sdk/server/src/app.service.d.ts +39 -4
  30. package/dist-sdk/server/src/app.service.js +40 -3
  31. package/dist-sdk/server/src/common/errors.d.ts +13 -1
  32. package/dist-sdk/server/src/common/errors.js +21 -1
  33. package/dist-sdk/server/src/packs/pack-instantiation.service.js +1 -0
  34. package/dist-sdk/server/src/packs/pack-manifest.d.ts +3 -1
  35. package/dist-sdk/server/src/packs/pack-manifest.js +2 -0
  36. package/dist-sdk/server/src/room/illustration/illustration.service.d.ts +17 -2
  37. package/dist-sdk/server/src/room/illustration/illustration.service.js +35 -9
  38. package/dist-sdk/server/src/room/illustration/illustration.types.d.ts +6 -0
  39. package/dist-sdk/server/src/room/room-config.d.ts +11 -1
  40. package/dist-sdk/server/src/room/room-store.service.js +4 -0
  41. package/dist-sdk/server/src/room/room.d.ts +9 -1
  42. package/dist-sdk/server/src/room/room.js +16 -1
  43. package/dist-sdk/server/src/sdk/index.d.ts +5 -1
  44. package/dist-sdk/server/src/sdk/index.js +12 -1
  45. package/dist-sdk/server/src/tools/core/illustrate.tool.js +10 -1
  46. package/dist-sdk/server/src/tools/native-tool.types.d.ts +3 -2
  47. package/dist-sdk/shared/types/app.types.d.ts +27 -0
  48. package/dist-sdk/shared/types/app.types.js +6 -1
  49. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomMessage = exports.Room = exports.Agent = exports.PackInstantiationService = exports.PackService = exports.queryRows = 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.MAX_ATTACHED_IMAGE_BYTES = exports.ATTACHMENT_IMAGE_TYPES = exports.isAttachmentImage = exports.detectAttachmentMimeType = exports.UnsupportedDocumentError = exports.convertLocalDocument = exports.detectDocumentType = exports.BriyahConfigService = exports.Briyah = void 0;
3
+ exports.RoomMessage = exports.Room = exports.Agent = exports.PackInstantiationService = exports.PackService = exports.queryRows = 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.insufficientBalanceMessage = exports.setInsufficientBalanceMessage = exports.InsufficientBalanceError = exports.currentUsageTags = exports.runWithUsageTags = exports.MAX_ATTACHED_IMAGE_BYTES = exports.ATTACHMENT_IMAGE_TYPES = exports.isAttachmentImage = exports.detectAttachmentMimeType = 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; } });
@@ -20,6 +20,17 @@ Object.defineProperty(exports, "detectAttachmentMimeType", { enumerable: true, g
20
20
  Object.defineProperty(exports, "isAttachmentImage", { enumerable: true, get: function () { return attachment_type_1.isAttachmentImage; } });
21
21
  Object.defineProperty(exports, "ATTACHMENT_IMAGE_TYPES", { enumerable: true, get: function () { return attachment_type_1.ATTACHMENT_IMAGE_TYPES; } });
22
22
  Object.defineProperty(exports, "MAX_ATTACHED_IMAGE_BYTES", { enumerable: true, get: function () { return attachment_type_1.MAX_ATTACHED_IMAGE_BYTES; } });
23
+ // AI credit: the allowance a host grants each period, purchased credit, and the
24
+ // usage ledger every charge is recorded in, tagged with who and what it was for.
25
+ var usage_context_1 = require("../app/usage-context");
26
+ Object.defineProperty(exports, "runWithUsageTags", { enumerable: true, get: function () { return usage_context_1.runWithUsageTags; } });
27
+ Object.defineProperty(exports, "currentUsageTags", { enumerable: true, get: function () { return usage_context_1.currentUsageTags; } });
28
+ // What an AI call throws once the credit is gone. Its message is the host's when
29
+ // one is set, so the host's wording (and where to buy more) is what users read.
30
+ var errors_1 = require("../common/errors");
31
+ Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return errors_1.InsufficientBalanceError; } });
32
+ Object.defineProperty(exports, "setInsufficientBalanceMessage", { enumerable: true, get: function () { return errors_1.setInsufficientBalanceMessage; } });
33
+ Object.defineProperty(exports, "insufficientBalanceMessage", { enumerable: true, get: function () { return errors_1.insufficientBalanceMessage; } });
23
34
  var document_registry_1 = require("../documents/library/document-registry");
24
35
  Object.defineProperty(exports, "registerDocumentSource", { enumerable: true, get: function () { return document_registry_1.registerDocumentSource; } });
25
36
  Object.defineProperty(exports, "unregisterDocumentSource", { enumerable: true, get: function () { return document_registry_1.unregisterDocumentSource; } });
@@ -32,6 +32,13 @@ exports.illustrateTool = {
32
32
  description: 'Who or what appears, by the names the room uses. Optional — the artist reads the scene either way.',
33
33
  required: false,
34
34
  },
35
+ {
36
+ name: 'aspect',
37
+ type: 'string',
38
+ description: 'The shape of the picture: "landscape" (wider than tall) suits a sweeping vista or a crowd, "portrait" (taller than wide) a single standing figure or a tower, "square" anything else. Optional — leave it out to use the usual shape for this room, which is right most of the time.',
39
+ required: false,
40
+ enum: ['square', 'landscape', 'portrait'],
41
+ },
35
42
  ],
36
43
  async handler(args, helpers) {
37
44
  if (!helpers?.illustration) {
@@ -39,7 +46,9 @@ exports.illustrateTool = {
39
46
  }
40
47
  const brief = (0, coerce_1.str)(args.brief, 'brief');
41
48
  const subjects = args.subjects ? (0, coerce_1.list)(args.subjects) : undefined;
42
- const ticket = helpers.illustration.request(brief, subjects);
49
+ // Already checked against the enum before the handler runs.
50
+ const aspect = args.aspect ? (0, coerce_1.str)(args.aspect, 'aspect') : undefined;
51
+ const ticket = helpers.illustration.request(brief, subjects, aspect);
43
52
  if (ticket.accepted === true) {
44
53
  return {
45
54
  requested: true,
@@ -1,4 +1,4 @@
1
- import { ToolParameter } from '../../../shared/types/app.types';
1
+ import { ImageAspect, ToolParameter } from '../../../shared/types/app.types';
2
2
  /** Identifies the agent whose EXECUTE triggered this tool call. */
3
3
  export interface ToolCaller {
4
4
  /** The calling agent's nickname — the identity used for artifact creator/viewers. */
@@ -240,8 +240,9 @@ export interface ToolIllustration {
240
240
  /**
241
241
  * @param brief What the picture should show
242
242
  * @param subjects Who or what appears, by the names the room uses
243
+ * @param aspect The shape to draw it in. Absent takes the room's default.
243
244
  */
244
- request(brief: string, subjects?: string[]): IllustrationTicket;
245
+ request(brief: string, subjects?: string[], aspect?: ImageAspect): IllustrationTicket;
245
246
  /**
246
247
  * Draws one character's portrait and reports where it ended up.
247
248
  *
@@ -180,6 +180,28 @@ export type RoomTurnMode = 'broadcast' | 'directed';
180
180
  * would otherwise buy an image on every tool call.
181
181
  */
182
182
  export type RoomIllustrationMode = 'off' | 'on-request' | 'auto';
183
+ /**
184
+ * The shape of a picture, in words every image model can be given.
185
+ *
186
+ * Providers disagree on how a shape is asked for -- OpenAI takes a pixel size from
187
+ * a short list, Fal an `aspect_ratio`, Together a width and height -- so this is
188
+ * deliberately not any of them. Each `image_models.json` entry translates it into
189
+ * its own arguments, along with what that shape costs, because a larger canvas is
190
+ * more tokens on a token-billed model.
191
+ *
192
+ * - 'square': 1:1, and what every entry draws when nothing asks otherwise.
193
+ * - 'landscape': wider than tall, 3:2 where the model offers it.
194
+ * - 'portrait': taller than wide, 2:3. A shape, unrelated to character portraits.
195
+ *
196
+ * Asking for it in the prompt does not work: the canvas is an API argument, and a
197
+ * "wide shot" requested of a square canvas comes back square.
198
+ */
199
+ export type ImageAspect = 'square' | 'landscape' | 'portrait';
200
+ /**
201
+ * Every {@link ImageAspect}, for validating input against. Server-side only: the
202
+ * client spells its options out, for the reason given on {@link NO_IMAGES}.
203
+ */
204
+ export declare const IMAGE_ASPECTS: readonly ImageAspect[];
183
205
  /**
184
206
  * The `image_models.json` entry that means "draw nothing".
185
207
  *
@@ -209,6 +231,11 @@ export interface RoomDetails {
209
231
  imageModel?: string;
210
232
  /** Absent means 'on-request'. See {@link RoomIllustrationMode}. */
211
233
  illustrationMode?: RoomIllustrationMode;
234
+ /**
235
+ * The shape this room's pictures are drawn in unless the `illustrate` call asks
236
+ * for another. Absent means 'square'. See {@link ImageAspect}.
237
+ */
238
+ imageAspect?: ImageAspect;
212
239
  /**
213
240
  * Nickname of the agent that places messages it cannot route mechanically.
214
241
  * Only consulted in 'moderated' mode. Absent falls back to the first agent in
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageAction = exports.NO_IMAGES = exports.BRIYAH_MODES = void 0;
3
+ exports.MessageAction = exports.NO_IMAGES = exports.IMAGE_ASPECTS = exports.BRIYAH_MODES = void 0;
4
4
  exports.BRIYAH_MODES = ['agents', 'stories', 'rpg'];
5
+ /**
6
+ * Every {@link ImageAspect}, for validating input against. Server-side only: the
7
+ * client spells its options out, for the reason given on {@link NO_IMAGES}.
8
+ */
9
+ exports.IMAGE_ASPECTS = ['square', 'landscape', 'portrait'];
5
10
  /**
6
11
  * The `image_models.json` entry that means "draw nothing".
7
12
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "briyah",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "SDK for AI agents, multi-agent rooms, interactive stories, and role-playing games with per-user data isolation and cost tracking",
5
5
  "private": false,
6
6
  "license": "Apache-2.0",