briyah 2.0.16 → 2.0.18

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Turns a Briyah response schema into one Anthropic's structured outputs accept.
3
+ *
4
+ * Every other provider already constrains its reply to the schema it is given
5
+ * (OpenAI `json_schema`, Gemini `responseSchema`, Together `json_schema`); the
6
+ * Anthropic path used to paste the schema into the prompt and only check that the
7
+ * reply parsed. Valid JSON in the wrong shape went straight through: an agent that
8
+ * answered with a tool's bare arguments — `{"dataset": …}` with no `action` — was
9
+ * accepted, routed to the moderator, and stalled its room. Sent as
10
+ * `output_config.format`, the schema is enforced while the reply is generated, so
11
+ * that shape cannot be produced.
12
+ *
13
+ * Anthropic's schema dialect is narrower than JSON Schema. Every object must say
14
+ * `additionalProperties: false`, and some keywords are refused. This returns a
15
+ * copy that meets those rules, or null when the schema needs something the dialect
16
+ * cannot express — the caller then sends no format and falls back to the prompt
17
+ * contract alone, which is what every call did before.
18
+ */
19
+ /**
20
+ * The schema to send as `output_config.format.schema`, or null when it cannot be sent.
21
+ * @param jsonSchema A Briyah response schema, as loaded from a prompt folder's `.json`
22
+ * @returns A converted copy (the input is never modified), or null
23
+ */
24
+ export declare function toAnthropicOutputSchema(jsonSchema: unknown): Record<string, unknown> | null;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ /**
3
+ * Turns a Briyah response schema into one Anthropic's structured outputs accept.
4
+ *
5
+ * Every other provider already constrains its reply to the schema it is given
6
+ * (OpenAI `json_schema`, Gemini `responseSchema`, Together `json_schema`); the
7
+ * Anthropic path used to paste the schema into the prompt and only check that the
8
+ * reply parsed. Valid JSON in the wrong shape went straight through: an agent that
9
+ * answered with a tool's bare arguments — `{"dataset": …}` with no `action` — was
10
+ * accepted, routed to the moderator, and stalled its room. Sent as
11
+ * `output_config.format`, the schema is enforced while the reply is generated, so
12
+ * that shape cannot be produced.
13
+ *
14
+ * Anthropic's schema dialect is narrower than JSON Schema. Every object must say
15
+ * `additionalProperties: false`, and some keywords are refused. This returns a
16
+ * copy that meets those rules, or null when the schema needs something the dialect
17
+ * cannot express — the caller then sends no format and falls back to the prompt
18
+ * contract alone, which is what every call did before.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.toAnthropicOutputSchema = toAnthropicOutputSchema;
22
+ /** Keywords Anthropic's structured outputs refuse. Dropping one loosens nothing the reply relies on. */
23
+ const UNSUPPORTED_KEYWORDS = [
24
+ 'minimum',
25
+ 'maximum',
26
+ 'exclusiveMinimum',
27
+ 'exclusiveMaximum',
28
+ 'multipleOf',
29
+ 'minLength',
30
+ 'maxLength',
31
+ 'maxItems',
32
+ 'uniqueItems',
33
+ 'minProperties',
34
+ 'maxProperties',
35
+ 'patternProperties',
36
+ ];
37
+ /** String formats Anthropic validates; any other `format` is dropped. */
38
+ const SUPPORTED_FORMATS = new Set([
39
+ 'date-time', 'time', 'date', 'duration', 'email', 'hostname', 'uri', 'ipv4', 'ipv6', 'uuid',
40
+ ]);
41
+ /** Keywords whose value is one subschema. */
42
+ const SUBSCHEMA_KEYS = ['items', 'not'];
43
+ /** Keywords whose value is a list of subschemas. */
44
+ const SUBSCHEMA_LIST_KEYS = ['anyOf', 'allOf', 'oneOf', 'prefixItems'];
45
+ /** Keywords whose value maps names to subschemas. */
46
+ const SUBSCHEMA_MAP_KEYS = ['properties', '$defs', 'definitions'];
47
+ /** Thrown inside the walk when a schema cannot be expressed; caught by the entry point. */
48
+ class Inexpressible extends Error {
49
+ }
50
+ function isObjectSchema(schema) {
51
+ const type = schema.type;
52
+ return type === 'object' || (Array.isArray(type) && type.includes('object')) || 'properties' in schema;
53
+ }
54
+ function convert(schema) {
55
+ if (Array.isArray(schema))
56
+ return schema.map(convert);
57
+ if (!schema || typeof schema !== 'object')
58
+ return schema;
59
+ const out = {};
60
+ for (const [key, value] of Object.entries(schema)) {
61
+ if (UNSUPPORTED_KEYWORDS.includes(key))
62
+ continue;
63
+ if (key === 'format' && !SUPPORTED_FORMATS.has(String(value)))
64
+ continue;
65
+ // Only 0 or 1 is accepted as a minimum item count.
66
+ if (key === 'minItems' && Number(value) > 1)
67
+ continue;
68
+ if (SUBSCHEMA_KEYS.includes(key)) {
69
+ out[key] = convert(value);
70
+ }
71
+ else if (SUBSCHEMA_LIST_KEYS.includes(key) && Array.isArray(value)) {
72
+ out[key] = value.map(convert);
73
+ }
74
+ else if (SUBSCHEMA_MAP_KEYS.includes(key) && value && typeof value === 'object') {
75
+ out[key] = Object.fromEntries(Object.entries(value).map(([name, sub]) => [name, convert(sub)]));
76
+ }
77
+ else {
78
+ out[key] = value;
79
+ }
80
+ }
81
+ if (isObjectSchema(out)) {
82
+ // An open object — a map of arbitrary keys — is not expressible at all.
83
+ if (out.additionalProperties !== undefined && out.additionalProperties !== false) {
84
+ throw new Inexpressible('additionalProperties other than false');
85
+ }
86
+ out.additionalProperties = false;
87
+ }
88
+ return out;
89
+ }
90
+ /**
91
+ * The schema to send as `output_config.format.schema`, or null when it cannot be sent.
92
+ * @param jsonSchema A Briyah response schema, as loaded from a prompt folder's `.json`
93
+ * @returns A converted copy (the input is never modified), or null
94
+ */
95
+ function toAnthropicOutputSchema(jsonSchema) {
96
+ if (!jsonSchema || typeof jsonSchema !== 'object' || Array.isArray(jsonSchema))
97
+ return null;
98
+ // `name` labels the schema for OpenAI's response_format; it is not a JSON Schema keyword.
99
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
100
+ const { name: _name, ...schema } = jsonSchema;
101
+ try {
102
+ const converted = convert(schema);
103
+ // Structured outputs describe an object reply; anything else stays on the prompt contract.
104
+ return isObjectSchema(converted) ? converted : null;
105
+ }
106
+ catch (error) {
107
+ if (error instanceof Inexpressible)
108
+ return null;
109
+ throw error;
110
+ }
111
+ }
@@ -76,6 +76,35 @@ export declare class AnthropicAiService extends BaseAiService {
76
76
  */
77
77
  private static trimHeadroom;
78
78
  textPrompt(agent: Agent, prompt: string, jsonSchema?: any, saveResponse?: boolean, promptInstructions?: string, cacheConfig?: any, maxOutputChars?: number): Promise<any>;
79
+ /**
80
+ * Model and schema pairs the API refused a format for. Later calls with the same
81
+ * pair go out on the prompt contract alone rather than failing first every time.
82
+ * Process-lifetime: a model that gains support is picked up on restart.
83
+ */
84
+ private static readonly unconstrained;
85
+ /**
86
+ * The schema to enforce on this call, or null to rely on the prompt contract.
87
+ * @param agent The agent being prompted
88
+ * @param jsonSchema The response schema, if the call has one
89
+ * @returns The converted schema and the key it is remembered under, or null
90
+ */
91
+ private outputFormatFor;
92
+ /**
93
+ * Sends a request, and when the API refuses its output format, sends it again
94
+ * without one.
95
+ *
96
+ * Not every model supports structured outputs, and the model table cannot say
97
+ * which: litellm's `supports_response_schema` is set on models the API refuses a
98
+ * format for. So the API decides. The pair is only remembered as refused when the
99
+ * same request then succeeds without the format; a 400 for any other reason
100
+ * fails again, the format is put back, and the error goes to the caller's retry
101
+ * loop as it always did.
102
+ * @param params The request, mutated to drop the format once it is refused, so the
103
+ * caller's retries and a paused-turn resume do not send it again
104
+ * @param formatKey The key from outputFormatFor, when a format was attached
105
+ * @returns The API's response
106
+ */
107
+ private createConstrained;
79
108
  /**
80
109
  * Appends "here is what you said, now correct it" to a local messages array
81
110
  * for a retry.
@@ -19,6 +19,7 @@ const errors_1 = require("../../common/errors");
19
19
  const logger_1 = require("../../common/logger");
20
20
  const ai_debug_logger_1 = require("../ai-debug-logger");
21
21
  const attachment_type_1 = require("./attachment-type");
22
+ const anthropic_output_schema_1 = require("./anthropic-output-schema");
22
23
  let AnthropicAiService = class AnthropicAiService extends base_ai_service_1.BaseAiService {
23
24
  static { AnthropicAiService_1 = this; }
24
25
  anthropic;
@@ -322,10 +323,20 @@ let AnthropicAiService = class AnthropicAiService extends base_ai_service_1.Base
322
323
  createParams.thinking = { type: 'disabled' };
323
324
  createParams.temperature = 0;
324
325
  }
326
+ // Enforce the schema while the reply is generated, where the API can (see
327
+ // anthropic-output-schema.ts). The prompt keeps its copy of the schema: its
328
+ // descriptions still tell the model what each field is for.
329
+ const format = this.outputFormatFor(agent, jsonSchema);
330
+ if (format) {
331
+ createParams.output_config = {
332
+ ...(createParams.output_config ?? {}),
333
+ format: { type: 'json_schema', schema: format.schema },
334
+ };
335
+ }
325
336
  this.debugLogRequest(agent.agentName, createParams);
326
337
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
327
338
  try {
328
- let response = await this.anthropic.messages.create(createParams);
339
+ let response = await this.createConstrained(createParams, format?.key);
329
340
  if (response.usage) {
330
341
  this.computeMessageCost(agent, response.usage);
331
342
  }
@@ -434,6 +445,71 @@ let AnthropicAiService = class AnthropicAiService extends base_ai_service_1.Base
434
445
  // If we get here, all retries failed
435
446
  throw new Error(`Failed to get valid response after ${maxRetries} attempts. Last error: ${lastError?.message || 'Unknown error'}`);
436
447
  }
448
+ /**
449
+ * Model and schema pairs the API refused a format for. Later calls with the same
450
+ * pair go out on the prompt contract alone rather than failing first every time.
451
+ * Process-lifetime: a model that gains support is picked up on restart.
452
+ */
453
+ static unconstrained = new Set();
454
+ /**
455
+ * The schema to enforce on this call, or null to rely on the prompt contract.
456
+ * @param agent The agent being prompted
457
+ * @param jsonSchema The response schema, if the call has one
458
+ * @returns The converted schema and the key it is remembered under, or null
459
+ */
460
+ outputFormatFor(agent, jsonSchema) {
461
+ if (!jsonSchema)
462
+ return null;
463
+ // A web search answer carries citations, and structured outputs refuse citations.
464
+ if (agent.allowSearch)
465
+ return null;
466
+ const schema = (0, anthropic_output_schema_1.toAnthropicOutputSchema)(jsonSchema);
467
+ if (!schema)
468
+ return null;
469
+ const key = `${agent.modelName}|${JSON.stringify(schema)}`;
470
+ return AnthropicAiService_1.unconstrained.has(key) ? null : { schema, key };
471
+ }
472
+ /**
473
+ * Sends a request, and when the API refuses its output format, sends it again
474
+ * without one.
475
+ *
476
+ * Not every model supports structured outputs, and the model table cannot say
477
+ * which: litellm's `supports_response_schema` is set on models the API refuses a
478
+ * format for. So the API decides. The pair is only remembered as refused when the
479
+ * same request then succeeds without the format; a 400 for any other reason
480
+ * fails again, the format is put back, and the error goes to the caller's retry
481
+ * loop as it always did.
482
+ * @param params The request, mutated to drop the format once it is refused, so the
483
+ * caller's retries and a paused-turn resume do not send it again
484
+ * @param formatKey The key from outputFormatFor, when a format was attached
485
+ * @returns The API's response
486
+ */
487
+ async createConstrained(params, formatKey) {
488
+ try {
489
+ return await this.anthropic.messages.create(params);
490
+ }
491
+ catch (error) {
492
+ const config = params.output_config;
493
+ if (!formatKey || error?.status !== 400 || !config?.format)
494
+ throw error;
495
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
496
+ const { format: _format, ...rest } = config;
497
+ if (Object.keys(rest).length)
498
+ params.output_config = rest;
499
+ else
500
+ delete params.output_config;
501
+ try {
502
+ const response = await this.anthropic.messages.create(params);
503
+ AnthropicAiService_1.unconstrained.add(formatKey);
504
+ logger_1.logger.warn(`Structured output refused for ${params.model}; this schema goes out unconstrained from now on: ${error.message}`);
505
+ return response;
506
+ }
507
+ catch (second) {
508
+ params.output_config = config;
509
+ throw second;
510
+ }
511
+ }
512
+ }
437
513
  /**
438
514
  * Appends "here is what you said, now correct it" to a local messages array
439
515
  * for a retry.
@@ -36,6 +36,8 @@ export interface AgentConfig {
36
36
  usageTags?: {
37
37
  user?: string;
38
38
  feature?: string;
39
+ activity?: string;
40
+ detail?: string;
39
41
  };
40
42
  toolNames?: string[];
41
43
  useModerator?: boolean;
@@ -134,7 +134,7 @@ class BalanceService {
134
134
  ...(source?.agentName ? { agentName: source.agentName } : {}),
135
135
  ...(source?.serviceName ? { serviceName: source.serviceName } : {}),
136
136
  ...(source?.modelName ? { modelName: source.modelName } : {}),
137
- ...(tags.user || tags.feature ? { tags } : {}),
137
+ ...(Object.keys(tags).length ? { tags } : {}),
138
138
  });
139
139
  }
140
140
  /**
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Who and what an AI charge is for, recorded with it in the user's usage ledger
3
- * (see BalanceService). Both are the host's own labels: Briyah stores and
3
+ * (see BalanceService). All are the host's own labels: Briyah stores and
4
4
  * groups by them but never interprets them.
5
5
  */
6
6
  export interface UsageTags {
@@ -8,6 +8,15 @@ export interface UsageTags {
8
8
  user?: string;
9
9
  /** What the work was, e.g. "Loss run import" or "AI Assistant". */
10
10
  feature?: string;
11
+ /**
12
+ * One piece of work the charges belong to, e.g. a request id. A single user
13
+ * action — an import, a question — makes many AI calls, each its own charge;
14
+ * charges sharing an activity are that one action, so a host can show "what was
15
+ * done" as one line with its total rather than as every call behind it.
16
+ */
17
+ activity?: string;
18
+ /** What that piece of work was, in the host's words, e.g. "Imported mvrs.pdf". */
19
+ detail?: string;
11
20
  }
12
21
  /**
13
22
  * Runs `fn` with these usage tags in force: every AI charge made while it runs,
@@ -18,6 +27,15 @@ export interface UsageTags {
18
27
  * Tags set on an agent (`agent.usageTags`) win over these.
19
28
  */
20
29
  export declare function runWithUsageTags<T>(tags: UsageTags, fn: () => T): T;
30
+ /**
31
+ * Adds or replaces tags on the context already in force, for every charge made in
32
+ * it from now on — including by work it has already started, which shares that
33
+ * context. For a tag only known partway through: a host that tags each request as it
34
+ * arrives learns what the request was about (the file it uploaded, say) only once
35
+ * the request has been read. Outside any `runWithUsageTags` it does nothing, and a
36
+ * context nested inside this one keeps the tags it copied when it began.
37
+ */
38
+ export declare function updateUsageTags(tags: UsageTags): void;
21
39
  /** The usage tags in force here, or an empty object. */
22
40
  export declare function currentUsageTags(): UsageTags;
23
41
  /** The tags a charge is recorded with: the context's, then the agent's own on top. */
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runWithUsageTags = runWithUsageTags;
4
+ exports.updateUsageTags = updateUsageTags;
4
5
  exports.currentUsageTags = currentUsageTags;
5
6
  exports.resolveUsageTags = resolveUsageTags;
6
7
  const async_hooks_1 = require("async_hooks");
8
+ /** The tag keys a charge records. */
9
+ const TAG_KEYS = ['user', 'feature', 'activity', 'detail'];
7
10
  const storage = new async_hooks_1.AsyncLocalStorage();
8
11
  /**
9
12
  * Runs `fn` with these usage tags in force: every AI charge made while it runs,
@@ -17,6 +20,19 @@ function runWithUsageTags(tags, fn) {
17
20
  const outer = storage.getStore();
18
21
  return storage.run({ ...outer, ...clean(tags) }, fn);
19
22
  }
23
+ /**
24
+ * Adds or replaces tags on the context already in force, for every charge made in
25
+ * it from now on — including by work it has already started, which shares that
26
+ * context. For a tag only known partway through: a host that tags each request as it
27
+ * arrives learns what the request was about (the file it uploaded, say) only once
28
+ * the request has been read. Outside any `runWithUsageTags` it does nothing, and a
29
+ * context nested inside this one keeps the tags it copied when it began.
30
+ */
31
+ function updateUsageTags(tags) {
32
+ const store = storage.getStore();
33
+ if (store)
34
+ Object.assign(store, clean(tags));
35
+ }
20
36
  /** The usage tags in force here, or an empty object. */
21
37
  function currentUsageTags() {
22
38
  return { ...storage.getStore() };
@@ -27,9 +43,10 @@ function resolveUsageTags(agentTags) {
27
43
  }
28
44
  function clean(tags) {
29
45
  const out = {};
30
- if (typeof tags.user === 'string' && tags.user.trim())
31
- out.user = tags.user.trim();
32
- if (typeof tags.feature === 'string' && tags.feature.trim())
33
- out.feature = tags.feature.trim();
46
+ for (const key of TAG_KEYS) {
47
+ const value = tags[key];
48
+ if (typeof value === 'string' && value.trim())
49
+ out[key] = value.trim();
50
+ }
34
51
  return out;
35
52
  }
@@ -5,7 +5,7 @@ export { detectDocumentType, convertLocalDocument, UnsupportedDocumentError, } f
5
5
  export type { DocumentFileType, DocumentTypeDetection, DocumentPage as ConvertedDocumentPage, LocalDocumentConversion, LocalConversionOptions, } from '../documents/document-conversion';
6
6
  export { detectAttachmentMimeType, isAttachmentImage, ATTACHMENT_IMAGE_TYPES, MAX_ATTACHED_IMAGE_BYTES, } from '../ai/LLM/attachment-type';
7
7
  export type { AttachmentImageType } from '../ai/LLM/attachment-type';
8
- export { runWithUsageTags, currentUsageTags } from '../app/usage-context';
8
+ export { runWithUsageTags, currentUsageTags, updateUsageTags } from '../app/usage-context';
9
9
  export type { UsageTags } from '../app/usage-context';
10
10
  export { InsufficientBalanceError, setInsufficientBalanceMessage, insufficientBalanceMessage, } from '../common/errors';
11
11
  export type { AllowanceState, CreditSummary, UsageEntry, UsageReport, UsageTotal, UsageSource, } from '../app/balance.service';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatChartValue = exports.renderChartSvg = exports.validateChart = exports.CHART_TYPES = exports.CHART_BLOCK_LANGUAGE = 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
- exports.RoomMessage = exports.Room = exports.Agent = exports.PackInstantiationService = exports.PackService = void 0;
3
+ exports.renderChartSvg = exports.validateChart = exports.CHART_TYPES = exports.CHART_BLOCK_LANGUAGE = 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.updateUsageTags = 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
+ exports.RoomMessage = exports.Room = exports.Agent = exports.PackInstantiationService = exports.PackService = exports.formatChartValue = void 0;
5
5
  // Main SDK exports
6
6
  var briyah_1 = require("./briyah");
7
7
  Object.defineProperty(exports, "Briyah", { enumerable: true, get: function () { return briyah_1.Briyah; } });
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "MAX_ATTACHED_IMAGE_BYTES", { enumerable: true, g
26
26
  var usage_context_1 = require("../app/usage-context");
27
27
  Object.defineProperty(exports, "runWithUsageTags", { enumerable: true, get: function () { return usage_context_1.runWithUsageTags; } });
28
28
  Object.defineProperty(exports, "currentUsageTags", { enumerable: true, get: function () { return usage_context_1.currentUsageTags; } });
29
+ Object.defineProperty(exports, "updateUsageTags", { enumerable: true, get: function () { return usage_context_1.updateUsageTags; } });
29
30
  // What an AI call throws once the credit is gone. Its message is the host's when
30
31
  // one is set, so the host's wording (and where to buy more) is what users read.
31
32
  var errors_1 = require("../common/errors");
@@ -74,7 +74,11 @@ class ToolExecutionService {
74
74
  */
75
75
  async runForAgent(name, contentJson, grantedNames, context, room, illustration, callerAgentId) {
76
76
  if (!grantedNames.includes(name)) {
77
- return { ok: false, error: `Tool "${name}" is not available to you` };
77
+ // Name the tools it does have. A model that put a tool's argument in the
78
+ // tool's place — `execute` with name "wc_experience_mods", a dataset of
79
+ // query_data — corrects itself in one step when it can see the right name.
80
+ const granted = grantedNames.length ? grantedNames.join(', ') : 'none';
81
+ return { ok: false, error: `Tool "${name}" is not available to you. Your tools: ${granted}.` };
78
82
  }
79
83
  let args = {};
80
84
  if (contentJson && contentJson.trim()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "briyah",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
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",