@glassflow-ai/rius 0.4.0 → 0.5.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/dist/index.cjs CHANGED
@@ -356,7 +356,7 @@ function kindAttributes(kind) {
356
356
  if (operation !== void 0) attributes[GEN_AI_OPERATION_NAME] = operation;
357
357
  return attributes;
358
358
  }
359
- var TRACER_NAME, SERVICE_INSTANCE_ID, OPENINFERENCE_SPAN_KIND, INPUT_VALUE, OUTPUT_VALUE, SESSION_ID, WORKSPACE_ROUTE, GEN_AI_OPERATION_NAME, GEN_AI_PROVIDER_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_RESPONSE_MODEL, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES, GEN_AI_RESPONSE_FINISH_REASONS, GEN_AI_TOOL_NAME, GEN_AI_REQUEST_PREFIX, MCP_RESULT_TYPE, GEN_AI_FIRST_TOKEN_EVENT, SpanKind, OPERATION_BY_KIND, CONTENT_ATTRIBUTES, CONTENT_ATTRIBUTE_PREFIXES, CONTENT_ATTRIBUTE_SUFFIXES, GLASSFLOW_SPAN_PENDING, PENDING_IDENTITY_ATTRIBUTES, PENDING_IDENTITY_PREFIXES;
359
+ var TRACER_NAME, SERVICE_INSTANCE_ID, OPENINFERENCE_SPAN_KIND, INPUT_VALUE, OUTPUT_VALUE, SESSION_ID, WORKSPACE_ROUTE, GEN_AI_OPERATION_NAME, GEN_AI_PROVIDER_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_REQUEST_REASONING_LEVEL, GEN_AI_RESPONSE_MODEL, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES, GEN_AI_RESPONSE_FINISH_REASONS, GEN_AI_TOOL_NAME, GEN_AI_REQUEST_PREFIX, MCP_RESULT_TYPE, GEN_AI_FIRST_TOKEN_EVENT, SpanKind, OPERATION_BY_KIND, CONTENT_ATTRIBUTES, CONTENT_ATTRIBUTE_PREFIXES, CONTENT_ATTRIBUTE_SUFFIXES, GLASSFLOW_SPAN_PENDING, PENDING_IDENTITY_ATTRIBUTES, PENDING_IDENTITY_PREFIXES;
360
360
  var init_semconv = __esm({
361
361
  "src/semconv.ts"() {
362
362
  "use strict";
@@ -371,11 +371,13 @@ var init_semconv = __esm({
371
371
  GEN_AI_OPERATION_NAME = "gen_ai.operation.name";
372
372
  GEN_AI_PROVIDER_NAME = "gen_ai.provider.name";
373
373
  GEN_AI_REQUEST_MODEL = "gen_ai.request.model";
374
+ GEN_AI_REQUEST_REASONING_LEVEL = "gen_ai.request.reasoning.level";
374
375
  GEN_AI_RESPONSE_MODEL = "gen_ai.response.model";
375
376
  GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens";
376
377
  GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens";
377
378
  GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS = "gen_ai.usage.cache_read.input_tokens";
378
379
  GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS = "gen_ai.usage.cache_write.input_tokens";
380
+ GEN_AI_USAGE_REASONING_OUTPUT_TOKENS = "gen_ai.usage.reasoning.output_tokens";
379
381
  GEN_AI_INPUT_MESSAGES = "gen_ai.input.messages";
380
382
  GEN_AI_OUTPUT_MESSAGES = "gen_ai.output.messages";
381
383
  GEN_AI_RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons";
@@ -1332,6 +1334,15 @@ init_semconv();
1332
1334
  init_serde();
1333
1335
  init_spans();
1334
1336
  var Generation = class extends Observation {
1337
+ /**
1338
+ * The provider passed at creation; drives the Anthropic input-token summing
1339
+ * in {@link setUsage}. A bare `new Generation(span)` has none and never sums.
1340
+ */
1341
+ constructor(span, provider) {
1342
+ super(span);
1343
+ this.provider = provider;
1344
+ }
1345
+ provider;
1335
1346
  firstTokenRecorded = false;
1336
1347
  setInput(value) {
1337
1348
  this.span.setAttribute(GEN_AI_INPUT_MESSAGES, toAttributeValue(value));
@@ -1346,15 +1357,20 @@ var Generation = class extends Observation {
1346
1357
  return this;
1347
1358
  }
1348
1359
  /**
1349
- * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is.
1350
- * Per the GenAI conventions, `inputTokens` is the total including cached
1351
- * tokens (the cache counts are subsets of it); providers that report an
1352
- * exclusive `inputTokens` (e.g. Anthropic) are detected and normalized by
1353
- * the backend, so no client-side arithmetic is needed.
1360
+ * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is;
1361
+ * never pre-add anything. Per the GenAI conventions, `inputTokens` is the
1362
+ * total including cached tokens (the cache counts are subsets of it).
1363
+ * Anthropic's API reports `input_tokens` excluding the cache counts, and
1364
+ * the conventions require the instrumentation to do the summing, so when
1365
+ * the generation's provider is `"anthropic"` the emitted total is
1366
+ * `inputTokens` plus both cache counts. Every other provider is recorded
1367
+ * verbatim.
1354
1368
  */
1355
1369
  setUsage(usage) {
1356
1370
  if (usage.inputTokens !== void 0) {
1357
- this.span.setAttribute(GEN_AI_USAGE_INPUT_TOKENS, usage.inputTokens);
1371
+ const sums = this.provider?.toLowerCase() === "anthropic";
1372
+ const total = sums ? usage.inputTokens + (usage.cacheReadInputTokens ?? 0) + (usage.cacheWriteInputTokens ?? 0) : usage.inputTokens;
1373
+ this.span.setAttribute(GEN_AI_USAGE_INPUT_TOKENS, total);
1358
1374
  }
1359
1375
  if (usage.outputTokens !== void 0) {
1360
1376
  this.span.setAttribute(GEN_AI_USAGE_OUTPUT_TOKENS, usage.outputTokens);
@@ -1365,6 +1381,9 @@ var Generation = class extends Observation {
1365
1381
  if (usage.cacheWriteInputTokens !== void 0) {
1366
1382
  this.span.setAttribute(GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, usage.cacheWriteInputTokens);
1367
1383
  }
1384
+ if (usage.reasoningOutputTokens !== void 0) {
1385
+ this.span.setAttribute(GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, usage.reasoningOutputTokens);
1386
+ }
1368
1387
  return this;
1369
1388
  }
1370
1389
  /**
@@ -1404,17 +1423,20 @@ function configure2(generation, options) {
1404
1423
  for (const [key, value] of Object.entries(options.modelParameters ?? {})) {
1405
1424
  generation.setAttribute(`${GEN_AI_REQUEST_PREFIX}${key}`, value);
1406
1425
  }
1426
+ if (options.reasoningLevel !== void 0) {
1427
+ generation.setAttribute(GEN_AI_REQUEST_REASONING_LEVEL, options.reasoningLevel);
1428
+ }
1407
1429
  if (options.input !== void 0) generation.setInput(options.input);
1408
1430
  return generation;
1409
1431
  }
1410
1432
  function startGeneration(name, options = {}) {
1411
1433
  const span = getTracer().startSpan(name, { attributes: attributesFor(options) });
1412
- return configure2(new Generation(span), options);
1434
+ return configure2(new Generation(span, options.provider), options);
1413
1435
  }
1414
1436
  function startAsCurrentGeneration(name, optionsOrFn, maybeFn) {
1415
1437
  const [options, fn] = typeof optionsOrFn === "function" ? [{}, optionsOrFn] : [optionsOrFn, maybeFn];
1416
1438
  return getTracer().startActiveSpan(name, { attributes: attributesFor(options) }, async (span) => {
1417
- const generation = configure2(new Generation(span), options);
1439
+ const generation = configure2(new Generation(span, options.provider), options);
1418
1440
  try {
1419
1441
  return await fn(generation);
1420
1442
  } catch (error) {
@@ -1451,7 +1473,7 @@ init_semconv();
1451
1473
  init_session();
1452
1474
  init_spans();
1453
1475
  init_workspace();
1454
- var VERSION = "0.4.0";
1476
+ var VERSION = "0.5.0";
1455
1477
  // Annotate the CommonJS export names for ESM import in node:
1456
1478
  0 && (module.exports = {
1457
1479
  Generation,
package/dist/index.d.cts CHANGED
@@ -223,19 +223,36 @@ interface GenerationOptions {
223
223
  * so use the provider's own parameter names.
224
224
  */
225
225
  modelParameters?: Record<string, unknown>;
226
+ /**
227
+ * Requested reasoning/thinking effort level
228
+ * (`gen_ai.request.reasoning.level`), e.g. OpenAI's `reasoning.effort`
229
+ * values. Provider-defined string, recorded verbatim. A first-class option
230
+ * because the `modelParameters` pass-through would spell the key
231
+ * `gen_ai.request.reasoning_level`, which is not the convention's name.
232
+ */
233
+ reasoningLevel?: string;
226
234
  }
227
235
  /** An LLM call. Content uses gen_ai message keys, never input.value. */
228
236
  declare class Generation extends Observation {
237
+ private readonly provider?;
229
238
  private firstTokenRecorded;
239
+ /**
240
+ * The provider passed at creation; drives the Anthropic input-token summing
241
+ * in {@link setUsage}. A bare `new Generation(span)` has none and never sums.
242
+ */
243
+ constructor(span: ConstructorParameters<typeof Observation>[0], provider?: string | undefined);
230
244
  setInput(value: unknown): this;
231
245
  setOutput(value: unknown): this;
232
246
  setModel(model: string): this;
233
247
  /**
234
- * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is.
235
- * Per the GenAI conventions, `inputTokens` is the total including cached
236
- * tokens (the cache counts are subsets of it); providers that report an
237
- * exclusive `inputTokens` (e.g. Anthropic) are detected and normalized by
238
- * the backend, so no client-side arithmetic is needed.
248
+ * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is;
249
+ * never pre-add anything. Per the GenAI conventions, `inputTokens` is the
250
+ * total including cached tokens (the cache counts are subsets of it).
251
+ * Anthropic's API reports `input_tokens` excluding the cache counts, and
252
+ * the conventions require the instrumentation to do the summing, so when
253
+ * the generation's provider is `"anthropic"` the emitted total is
254
+ * `inputTokens` plus both cache counts. Every other provider is recorded
255
+ * verbatim.
239
256
  */
240
257
  setUsage(usage: {
241
258
  inputTokens?: number;
@@ -247,6 +264,13 @@ declare class Generation extends Observation {
247
264
  * (called "cache creation" by Anthropic).
248
265
  */
249
266
  cacheWriteInputTokens?: number;
267
+ /**
268
+ * Output tokens spent on reasoning / extended thinking. A subset of
269
+ * `outputTokens`, never in addition to it: providers already include
270
+ * reasoning tokens in the output total, so pass both as reported and
271
+ * do no arithmetic.
272
+ */
273
+ reasoningOutputTokens?: number;
250
274
  }): this;
251
275
  /**
252
276
  * Why generation stopped (`gen_ai.response.finish_reasons`), e.g. `"stop"`,
@@ -315,6 +339,6 @@ declare function observe<F extends (...args: never[]) => unknown>(fn: F, options
315
339
  declare function withSession<T>(fn: (sessionId: string) => T): T;
316
340
  declare function withSession<T>(sessionId: string, fn: (sessionId: string) => T): T;
317
341
 
318
- declare const VERSION = "0.4.0";
342
+ declare const VERSION = "0.5.0";
319
343
 
320
344
  export { Generation, type GenerationBody, type GenerationOptions, type InitOptions, type Mask, Observation, type ObserveOptions, RiusClient, type RiusOptions, type SpanBody, SpanKind, type SpanOptions, VERSION, type WorkspaceExporterFactory, getTracer, init, observe, registerWorkspace, startAsCurrentGeneration, startAsCurrentSpan, startGeneration, startSpan, withSession, withWorkspace };
package/dist/index.d.ts CHANGED
@@ -223,19 +223,36 @@ interface GenerationOptions {
223
223
  * so use the provider's own parameter names.
224
224
  */
225
225
  modelParameters?: Record<string, unknown>;
226
+ /**
227
+ * Requested reasoning/thinking effort level
228
+ * (`gen_ai.request.reasoning.level`), e.g. OpenAI's `reasoning.effort`
229
+ * values. Provider-defined string, recorded verbatim. A first-class option
230
+ * because the `modelParameters` pass-through would spell the key
231
+ * `gen_ai.request.reasoning_level`, which is not the convention's name.
232
+ */
233
+ reasoningLevel?: string;
226
234
  }
227
235
  /** An LLM call. Content uses gen_ai message keys, never input.value. */
228
236
  declare class Generation extends Observation {
237
+ private readonly provider?;
229
238
  private firstTokenRecorded;
239
+ /**
240
+ * The provider passed at creation; drives the Anthropic input-token summing
241
+ * in {@link setUsage}. A bare `new Generation(span)` has none and never sums.
242
+ */
243
+ constructor(span: ConstructorParameters<typeof Observation>[0], provider?: string | undefined);
230
244
  setInput(value: unknown): this;
231
245
  setOutput(value: unknown): this;
232
246
  setModel(model: string): this;
233
247
  /**
234
- * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is.
235
- * Per the GenAI conventions, `inputTokens` is the total including cached
236
- * tokens (the cache counts are subsets of it); providers that report an
237
- * exclusive `inputTokens` (e.g. Anthropic) are detected and normalized by
238
- * the backend, so no client-side arithmetic is needed.
248
+ * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is;
249
+ * never pre-add anything. Per the GenAI conventions, `inputTokens` is the
250
+ * total including cached tokens (the cache counts are subsets of it).
251
+ * Anthropic's API reports `input_tokens` excluding the cache counts, and
252
+ * the conventions require the instrumentation to do the summing, so when
253
+ * the generation's provider is `"anthropic"` the emitted total is
254
+ * `inputTokens` plus both cache counts. Every other provider is recorded
255
+ * verbatim.
239
256
  */
240
257
  setUsage(usage: {
241
258
  inputTokens?: number;
@@ -247,6 +264,13 @@ declare class Generation extends Observation {
247
264
  * (called "cache creation" by Anthropic).
248
265
  */
249
266
  cacheWriteInputTokens?: number;
267
+ /**
268
+ * Output tokens spent on reasoning / extended thinking. A subset of
269
+ * `outputTokens`, never in addition to it: providers already include
270
+ * reasoning tokens in the output total, so pass both as reported and
271
+ * do no arithmetic.
272
+ */
273
+ reasoningOutputTokens?: number;
250
274
  }): this;
251
275
  /**
252
276
  * Why generation stopped (`gen_ai.response.finish_reasons`), e.g. `"stop"`,
@@ -315,6 +339,6 @@ declare function observe<F extends (...args: never[]) => unknown>(fn: F, options
315
339
  declare function withSession<T>(fn: (sessionId: string) => T): T;
316
340
  declare function withSession<T>(sessionId: string, fn: (sessionId: string) => T): T;
317
341
 
318
- declare const VERSION = "0.4.0";
342
+ declare const VERSION = "0.5.0";
319
343
 
320
344
  export { Generation, type GenerationBody, type GenerationOptions, type InitOptions, type Mask, Observation, type ObserveOptions, RiusClient, type RiusOptions, type SpanBody, SpanKind, type SpanOptions, VERSION, type WorkspaceExporterFactory, getTracer, init, observe, registerWorkspace, startAsCurrentGeneration, startAsCurrentSpan, startGeneration, startSpan, withSession, withWorkspace };
package/dist/index.js CHANGED
@@ -343,7 +343,7 @@ function kindAttributes(kind) {
343
343
  if (operation !== void 0) attributes[GEN_AI_OPERATION_NAME] = operation;
344
344
  return attributes;
345
345
  }
346
- var TRACER_NAME, SERVICE_INSTANCE_ID, OPENINFERENCE_SPAN_KIND, INPUT_VALUE, OUTPUT_VALUE, SESSION_ID, WORKSPACE_ROUTE, GEN_AI_OPERATION_NAME, GEN_AI_PROVIDER_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_RESPONSE_MODEL, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES, GEN_AI_RESPONSE_FINISH_REASONS, GEN_AI_TOOL_NAME, GEN_AI_REQUEST_PREFIX, MCP_RESULT_TYPE, GEN_AI_FIRST_TOKEN_EVENT, SpanKind, OPERATION_BY_KIND, CONTENT_ATTRIBUTES, CONTENT_ATTRIBUTE_PREFIXES, CONTENT_ATTRIBUTE_SUFFIXES, GLASSFLOW_SPAN_PENDING, PENDING_IDENTITY_ATTRIBUTES, PENDING_IDENTITY_PREFIXES;
346
+ var TRACER_NAME, SERVICE_INSTANCE_ID, OPENINFERENCE_SPAN_KIND, INPUT_VALUE, OUTPUT_VALUE, SESSION_ID, WORKSPACE_ROUTE, GEN_AI_OPERATION_NAME, GEN_AI_PROVIDER_NAME, GEN_AI_REQUEST_MODEL, GEN_AI_REQUEST_REASONING_LEVEL, GEN_AI_RESPONSE_MODEL, GEN_AI_USAGE_INPUT_TOKENS, GEN_AI_USAGE_OUTPUT_TOKENS, GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES, GEN_AI_RESPONSE_FINISH_REASONS, GEN_AI_TOOL_NAME, GEN_AI_REQUEST_PREFIX, MCP_RESULT_TYPE, GEN_AI_FIRST_TOKEN_EVENT, SpanKind, OPERATION_BY_KIND, CONTENT_ATTRIBUTES, CONTENT_ATTRIBUTE_PREFIXES, CONTENT_ATTRIBUTE_SUFFIXES, GLASSFLOW_SPAN_PENDING, PENDING_IDENTITY_ATTRIBUTES, PENDING_IDENTITY_PREFIXES;
347
347
  var init_semconv = __esm({
348
348
  "src/semconv.ts"() {
349
349
  "use strict";
@@ -358,11 +358,13 @@ var init_semconv = __esm({
358
358
  GEN_AI_OPERATION_NAME = "gen_ai.operation.name";
359
359
  GEN_AI_PROVIDER_NAME = "gen_ai.provider.name";
360
360
  GEN_AI_REQUEST_MODEL = "gen_ai.request.model";
361
+ GEN_AI_REQUEST_REASONING_LEVEL = "gen_ai.request.reasoning.level";
361
362
  GEN_AI_RESPONSE_MODEL = "gen_ai.response.model";
362
363
  GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens";
363
364
  GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens";
364
365
  GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS = "gen_ai.usage.cache_read.input_tokens";
365
366
  GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS = "gen_ai.usage.cache_write.input_tokens";
367
+ GEN_AI_USAGE_REASONING_OUTPUT_TOKENS = "gen_ai.usage.reasoning.output_tokens";
366
368
  GEN_AI_INPUT_MESSAGES = "gen_ai.input.messages";
367
369
  GEN_AI_OUTPUT_MESSAGES = "gen_ai.output.messages";
368
370
  GEN_AI_RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons";
@@ -1304,6 +1306,15 @@ init_semconv();
1304
1306
  init_serde();
1305
1307
  init_spans();
1306
1308
  var Generation = class extends Observation {
1309
+ /**
1310
+ * The provider passed at creation; drives the Anthropic input-token summing
1311
+ * in {@link setUsage}. A bare `new Generation(span)` has none and never sums.
1312
+ */
1313
+ constructor(span, provider) {
1314
+ super(span);
1315
+ this.provider = provider;
1316
+ }
1317
+ provider;
1307
1318
  firstTokenRecorded = false;
1308
1319
  setInput(value) {
1309
1320
  this.span.setAttribute(GEN_AI_INPUT_MESSAGES, toAttributeValue(value));
@@ -1318,15 +1329,20 @@ var Generation = class extends Observation {
1318
1329
  return this;
1319
1330
  }
1320
1331
  /**
1321
- * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is.
1322
- * Per the GenAI conventions, `inputTokens` is the total including cached
1323
- * tokens (the cache counts are subsets of it); providers that report an
1324
- * exclusive `inputTokens` (e.g. Anthropic) are detected and normalized by
1325
- * the backend, so no client-side arithmetic is needed.
1332
+ * Token usage (`gen_ai.usage.*`). Pass provider-reported values as-is;
1333
+ * never pre-add anything. Per the GenAI conventions, `inputTokens` is the
1334
+ * total including cached tokens (the cache counts are subsets of it).
1335
+ * Anthropic's API reports `input_tokens` excluding the cache counts, and
1336
+ * the conventions require the instrumentation to do the summing, so when
1337
+ * the generation's provider is `"anthropic"` the emitted total is
1338
+ * `inputTokens` plus both cache counts. Every other provider is recorded
1339
+ * verbatim.
1326
1340
  */
1327
1341
  setUsage(usage) {
1328
1342
  if (usage.inputTokens !== void 0) {
1329
- this.span.setAttribute(GEN_AI_USAGE_INPUT_TOKENS, usage.inputTokens);
1343
+ const sums = this.provider?.toLowerCase() === "anthropic";
1344
+ const total = sums ? usage.inputTokens + (usage.cacheReadInputTokens ?? 0) + (usage.cacheWriteInputTokens ?? 0) : usage.inputTokens;
1345
+ this.span.setAttribute(GEN_AI_USAGE_INPUT_TOKENS, total);
1330
1346
  }
1331
1347
  if (usage.outputTokens !== void 0) {
1332
1348
  this.span.setAttribute(GEN_AI_USAGE_OUTPUT_TOKENS, usage.outputTokens);
@@ -1337,6 +1353,9 @@ var Generation = class extends Observation {
1337
1353
  if (usage.cacheWriteInputTokens !== void 0) {
1338
1354
  this.span.setAttribute(GEN_AI_USAGE_CACHE_WRITE_INPUT_TOKENS, usage.cacheWriteInputTokens);
1339
1355
  }
1356
+ if (usage.reasoningOutputTokens !== void 0) {
1357
+ this.span.setAttribute(GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, usage.reasoningOutputTokens);
1358
+ }
1340
1359
  return this;
1341
1360
  }
1342
1361
  /**
@@ -1376,17 +1395,20 @@ function configure2(generation, options) {
1376
1395
  for (const [key, value] of Object.entries(options.modelParameters ?? {})) {
1377
1396
  generation.setAttribute(`${GEN_AI_REQUEST_PREFIX}${key}`, value);
1378
1397
  }
1398
+ if (options.reasoningLevel !== void 0) {
1399
+ generation.setAttribute(GEN_AI_REQUEST_REASONING_LEVEL, options.reasoningLevel);
1400
+ }
1379
1401
  if (options.input !== void 0) generation.setInput(options.input);
1380
1402
  return generation;
1381
1403
  }
1382
1404
  function startGeneration(name, options = {}) {
1383
1405
  const span = getTracer().startSpan(name, { attributes: attributesFor(options) });
1384
- return configure2(new Generation(span), options);
1406
+ return configure2(new Generation(span, options.provider), options);
1385
1407
  }
1386
1408
  function startAsCurrentGeneration(name, optionsOrFn, maybeFn) {
1387
1409
  const [options, fn] = typeof optionsOrFn === "function" ? [{}, optionsOrFn] : [optionsOrFn, maybeFn];
1388
1410
  return getTracer().startActiveSpan(name, { attributes: attributesFor(options) }, async (span) => {
1389
- const generation = configure2(new Generation(span), options);
1411
+ const generation = configure2(new Generation(span, options.provider), options);
1390
1412
  try {
1391
1413
  return await fn(generation);
1392
1414
  } catch (error) {
@@ -1423,7 +1445,7 @@ init_semconv();
1423
1445
  init_session();
1424
1446
  init_spans();
1425
1447
  init_workspace();
1426
- var VERSION = "0.4.0";
1448
+ var VERSION = "0.5.0";
1427
1449
  export {
1428
1450
  Generation,
1429
1451
  Observation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassflow-ai/rius",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "OpenTelemetry-native tracing for AI agents and LLM applications",
5
5
  "keywords": [
6
6
  "opentelemetry",