@glassflow-ai/rius 0.2.2 → 0.2.3

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
@@ -550,6 +550,11 @@ var instrumentationMcp_exports = {};
550
550
  __export(instrumentationMcp_exports, {
551
551
  instrumentMcpClient: () => instrumentMcpClient
552
552
  });
553
+ function resultIsError(result) {
554
+ if (typeof result !== "object" || result === null) return false;
555
+ const record = result;
556
+ return Boolean(record.is_error ?? record.isError);
557
+ }
553
558
  function recordResult(observation, result) {
554
559
  const resultType = typeof result === "object" && result !== null ? result.result_type ?? result.resultType : void 0;
555
560
  if (resultType === INPUT_REQUIRED) {
@@ -557,6 +562,12 @@ function recordResult(observation, result) {
557
562
  return;
558
563
  }
559
564
  observation.setOutput(result);
565
+ if (resultIsError(result)) {
566
+ observation.span.setStatus({
567
+ code: import_api2.SpanStatusCode.ERROR,
568
+ message: "tool returned an error result"
569
+ });
570
+ }
560
571
  }
561
572
  function instrumentMcpClient(ClientClass) {
562
573
  const current = ClientClass.prototype.callTool;
@@ -569,7 +580,7 @@ function instrumentMcpClient(ClientClass) {
569
580
  const original = ClientClass.prototype.callTool;
570
581
  const instrumented = function instrumentedCallTool(params, ...rest) {
571
582
  return startAsCurrentSpan(
572
- params.name,
583
+ `execute_tool ${params.name}`,
573
584
  { kind: "TOOL" /* TOOL */, input: params.arguments },
574
585
  async (observation) => {
575
586
  observation.setAttribute(GEN_AI_TOOL_NAME, params.name);
@@ -585,11 +596,12 @@ function instrumentMcpClient(ClientClass) {
585
596
  ClientClass.prototype.callTool = original;
586
597
  };
587
598
  }
588
- var INPUT_REQUIRED;
599
+ var import_api2, INPUT_REQUIRED;
589
600
  var init_instrumentationMcp = __esm({
590
601
  "src/instrumentationMcp.ts"() {
591
602
  "use strict";
592
603
  init_cjs_shims();
604
+ import_api2 = require("@opentelemetry/api");
593
605
  init_semconv();
594
606
  init_spans();
595
607
  INPUT_REQUIRED = "input_required";
@@ -802,12 +814,12 @@ function isContentKey(key) {
802
814
  if (CONTENT_ATTRIBUTE_PREFIXES.some((p) => key.startsWith(p))) return true;
803
815
  return CONTENT_ATTRIBUTE_SUFFIXES.some((s) => key.endsWith(s));
804
816
  }
805
- var import_api2, EXCEPTION_EVENT_NAME, EXCEPTION_CONTENT_KEYS, MaskingSpanExporter;
817
+ var import_api3, EXCEPTION_EVENT_NAME, EXCEPTION_CONTENT_KEYS, MaskingSpanExporter;
806
818
  var init_masking = __esm({
807
819
  "src/masking.ts"() {
808
820
  "use strict";
809
821
  init_cjs_shims();
810
- import_api2 = require("@opentelemetry/api");
822
+ import_api3 = require("@opentelemetry/api");
811
823
  init_semconv();
812
824
  init_serde();
813
825
  EXCEPTION_EVENT_NAME = "exception";
@@ -837,7 +849,7 @@ var init_masking = __esm({
837
849
  for (const link of span.links ?? []) {
838
850
  this.sanitizeAttributes(link.attributes);
839
851
  }
840
- if (!this.opts.captureContent && span.status?.code === import_api2.SpanStatusCode.ERROR) {
852
+ if (!this.opts.captureContent && span.status?.code === import_api3.SpanStatusCode.ERROR) {
841
853
  span.status.message = void 0;
842
854
  }
843
855
  return span;
@@ -891,7 +903,7 @@ function buildSnapshot(span) {
891
903
  startTime: span.startTime,
892
904
  endTime: span.startTime,
893
905
  duration: [0, 0],
894
- status: { code: import_api3.SpanStatusCode.UNSET },
906
+ status: { code: import_api4.SpanStatusCode.UNSET },
895
907
  attributes,
896
908
  links: [],
897
909
  events: [],
@@ -906,12 +918,12 @@ function buildSnapshot(span) {
906
918
  function spanKey(context) {
907
919
  return `${context.traceId}:${context.spanId}`;
908
920
  }
909
- var import_api3, PendingSpanProcessor;
921
+ var import_api4, PendingSpanProcessor;
910
922
  var init_pending = __esm({
911
923
  "src/pending.ts"() {
912
924
  "use strict";
913
925
  init_cjs_shims();
914
- import_api3 = require("@opentelemetry/api");
926
+ import_api4 = require("@opentelemetry/api");
915
927
  init_semconv();
916
928
  PendingSpanProcessor = class {
917
929
  delegate;
@@ -1019,14 +1031,14 @@ function init(options = {}) {
1019
1031
  return globalClient;
1020
1032
  }
1021
1033
  function getTracer() {
1022
- return import_api4.trace.getTracer(TRACER_NAME);
1034
+ return import_api5.trace.getTracer(TRACER_NAME);
1023
1035
  }
1024
- var import_api4, import_exporter_trace_otlp_http, import_resources, import_sdk_trace_base, import_sdk_trace_node, import_semantic_conventions, sinks, heartbeats, createClient, RiusClient, globalClient;
1036
+ var import_api5, import_exporter_trace_otlp_http, import_resources, import_sdk_trace_base, import_sdk_trace_node, import_semantic_conventions, sinks, heartbeats, createClient, RiusClient, globalClient;
1025
1037
  var init_client = __esm({
1026
1038
  "src/client.ts"() {
1027
1039
  "use strict";
1028
1040
  init_cjs_shims();
1029
- import_api4 = require("@opentelemetry/api");
1041
+ import_api5 = require("@opentelemetry/api");
1030
1042
  import_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
1031
1043
  import_resources = require("@opentelemetry/resources");
1032
1044
  import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
@@ -1083,7 +1095,7 @@ var init_client = __esm({
1083
1095
  } finally {
1084
1096
  if (globalClient === this) {
1085
1097
  globalClient = void 0;
1086
- import_api4.trace.disable();
1098
+ import_api5.trace.disable();
1087
1099
  }
1088
1100
  }
1089
1101
  }
@@ -1222,7 +1234,7 @@ function observe(fn, options = {}) {
1222
1234
  // src/index.ts
1223
1235
  init_semconv();
1224
1236
  init_spans();
1225
- var VERSION = "0.2.2";
1237
+ var VERSION = "0.2.3";
1226
1238
  // Annotate the CommonJS export names for ESM import in node:
1227
1239
  0 && (module.exports = {
1228
1240
  Generation,
package/dist/index.d.cts CHANGED
@@ -203,6 +203,6 @@ interface ObserveOptions {
203
203
  */
204
204
  declare function observe<F extends (...args: never[]) => unknown>(fn: F, options?: ObserveOptions): (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>>;
205
205
 
206
- declare const VERSION = "0.2.2";
206
+ declare const VERSION = "0.2.3";
207
207
 
208
208
  export { Generation, type GenerationBody, type GenerationOptions, type InitOptions, type Mask, Observation, type ObserveOptions, RiusClient, type RiusOptions, type SpanBody, SpanKind, type SpanOptions, VERSION, getTracer, init, observe, startAsCurrentGeneration, startAsCurrentSpan, startGeneration, startSpan };
package/dist/index.d.ts CHANGED
@@ -203,6 +203,6 @@ interface ObserveOptions {
203
203
  */
204
204
  declare function observe<F extends (...args: never[]) => unknown>(fn: F, options?: ObserveOptions): (...args: Parameters<F>) => Promise<Awaited<ReturnType<F>>>;
205
205
 
206
- declare const VERSION = "0.2.2";
206
+ declare const VERSION = "0.2.3";
207
207
 
208
208
  export { Generation, type GenerationBody, type GenerationOptions, type InitOptions, type Mask, Observation, type ObserveOptions, RiusClient, type RiusOptions, type SpanBody, SpanKind, type SpanOptions, VERSION, getTracer, init, observe, startAsCurrentGeneration, startAsCurrentSpan, startGeneration, startSpan };
package/dist/index.js CHANGED
@@ -537,6 +537,12 @@ var instrumentationMcp_exports = {};
537
537
  __export(instrumentationMcp_exports, {
538
538
  instrumentMcpClient: () => instrumentMcpClient
539
539
  });
540
+ import { SpanStatusCode as SpanStatusCode2 } from "@opentelemetry/api";
541
+ function resultIsError(result) {
542
+ if (typeof result !== "object" || result === null) return false;
543
+ const record = result;
544
+ return Boolean(record.is_error ?? record.isError);
545
+ }
540
546
  function recordResult(observation, result) {
541
547
  const resultType = typeof result === "object" && result !== null ? result.result_type ?? result.resultType : void 0;
542
548
  if (resultType === INPUT_REQUIRED) {
@@ -544,6 +550,12 @@ function recordResult(observation, result) {
544
550
  return;
545
551
  }
546
552
  observation.setOutput(result);
553
+ if (resultIsError(result)) {
554
+ observation.span.setStatus({
555
+ code: SpanStatusCode2.ERROR,
556
+ message: "tool returned an error result"
557
+ });
558
+ }
547
559
  }
548
560
  function instrumentMcpClient(ClientClass) {
549
561
  const current = ClientClass.prototype.callTool;
@@ -556,7 +568,7 @@ function instrumentMcpClient(ClientClass) {
556
568
  const original = ClientClass.prototype.callTool;
557
569
  const instrumented = function instrumentedCallTool(params, ...rest) {
558
570
  return startAsCurrentSpan(
559
- params.name,
571
+ `execute_tool ${params.name}`,
560
572
  { kind: "TOOL" /* TOOL */, input: params.arguments },
561
573
  async (observation) => {
562
574
  observation.setAttribute(GEN_AI_TOOL_NAME, params.name);
@@ -784,7 +796,7 @@ var init_instrumentation = __esm({
784
796
  });
785
797
 
786
798
  // src/masking.ts
787
- import { SpanStatusCode as SpanStatusCode2 } from "@opentelemetry/api";
799
+ import { SpanStatusCode as SpanStatusCode3 } from "@opentelemetry/api";
788
800
  function isContentKey(key) {
789
801
  if (CONTENT_ATTRIBUTES.has(key)) return true;
790
802
  if (CONTENT_ATTRIBUTE_PREFIXES.some((p) => key.startsWith(p))) return true;
@@ -824,7 +836,7 @@ var init_masking = __esm({
824
836
  for (const link of span.links ?? []) {
825
837
  this.sanitizeAttributes(link.attributes);
826
838
  }
827
- if (!this.opts.captureContent && span.status?.code === SpanStatusCode2.ERROR) {
839
+ if (!this.opts.captureContent && span.status?.code === SpanStatusCode3.ERROR) {
828
840
  span.status.message = void 0;
829
841
  }
830
842
  return span;
@@ -857,7 +869,7 @@ var init_masking = __esm({
857
869
  });
858
870
 
859
871
  // src/pending.ts
860
- import { SpanStatusCode as SpanStatusCode3 } from "@opentelemetry/api";
872
+ import { SpanStatusCode as SpanStatusCode4 } from "@opentelemetry/api";
861
873
  function identityAttributes(attributes) {
862
874
  if (!attributes) return {};
863
875
  const result = {};
@@ -879,7 +891,7 @@ function buildSnapshot(span) {
879
891
  startTime: span.startTime,
880
892
  endTime: span.startTime,
881
893
  duration: [0, 0],
882
- status: { code: SpanStatusCode3.UNSET },
894
+ status: { code: SpanStatusCode4.UNSET },
883
895
  attributes,
884
896
  links: [],
885
897
  events: [],
@@ -1197,7 +1209,7 @@ function observe(fn, options = {}) {
1197
1209
  // src/index.ts
1198
1210
  init_semconv();
1199
1211
  init_spans();
1200
- var VERSION = "0.2.2";
1212
+ var VERSION = "0.2.3";
1201
1213
  export {
1202
1214
  Generation,
1203
1215
  Observation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glassflow-ai/rius",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "OpenTelemetry-native tracing for AI agents and LLM applications",
5
5
  "keywords": [
6
6
  "opentelemetry",