@dexto/core 1.8.4 → 1.8.5

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.
@@ -28,36 +28,37 @@ async function recordOperationSpan(options, operation, logger) {
28
28
  if (skipIfNoTelemetry && !(0, import_utils.hasActiveTelemetry)(logger)) {
29
29
  return operation();
30
30
  }
31
- const span = import_api.trace.getTracer(options.tracerName ?? "dexto").startSpan(options.name, { kind: import_api.SpanKind.INTERNAL });
32
- const spanContext = import_api.trace.setSpan(import_api.context.active(), span);
33
- (0, import_utils.addBaggageAttributesToSpan)(span, spanContext, logger);
34
- if (options.componentName !== void 0) {
35
- span.setAttribute("componentName", options.componentName);
36
- }
37
- setOperationSpanAttributes(span, options.attributes);
38
- try {
39
- const result = await import_api.context.with(spanContext, operation);
31
+ return import_api.trace.getTracer(options.tracerName ?? "dexto").startActiveSpan(options.name, { kind: import_api.SpanKind.INTERNAL }, async (span) => {
32
+ const spanContext = import_api.trace.setSpan(import_api.context.active(), span);
33
+ (0, import_utils.addBaggageAttributesToSpan)(span, spanContext, logger);
34
+ if (options.componentName !== void 0) {
35
+ span.setAttribute("componentName", options.componentName);
36
+ }
37
+ setOperationSpanAttributes(span, options.attributes);
40
38
  try {
41
- setOperationSpanAttributes(span, options.resultAttributes?.(result));
39
+ const result = await operation();
40
+ try {
41
+ setOperationSpanAttributes(span, options.resultAttributes?.(result));
42
+ } catch (error) {
43
+ logger?.debug("Failed to set OpenTelemetry result attributes", {
44
+ error: error instanceof Error ? error.message : String(error),
45
+ span: options.name
46
+ });
47
+ }
48
+ span.setStatus({ code: import_api.SpanStatusCode.OK });
49
+ return result;
42
50
  } catch (error) {
43
- logger?.debug("Failed to set OpenTelemetry result attributes", {
44
- error: error instanceof Error ? error.message : String(error),
45
- span: options.name
46
- });
51
+ if (error instanceof Error) {
52
+ span.recordException(error);
53
+ span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: error.message });
54
+ } else {
55
+ span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: String(error) });
56
+ }
57
+ throw error;
58
+ } finally {
59
+ span.end();
47
60
  }
48
- span.setStatus({ code: import_api.SpanStatusCode.OK });
49
- return result;
50
- } catch (error) {
51
- if (error instanceof Error) {
52
- span.recordException(error);
53
- span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: error.message });
54
- } else {
55
- span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: String(error) });
56
- }
57
- throw error;
58
- } finally {
59
- span.end();
60
- }
61
+ });
61
62
  }
62
63
  function setOperationSpanAttributes(span, attributes) {
63
64
  if (span === void 0 || attributes === void 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"operation-span.d.ts","sourceRoot":"","sources":["../../src/telemetry/operation-span.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,KAAK,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEzE,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IAClC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,uBAAuB,GAAG,SAAS,CAAC;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,mBAAmB,CAAC,CAAC,EACvC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC/B,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CAyCZ"}
1
+ {"version":3,"file":"operation-span.d.ts","sourceRoot":"","sources":["../../src/telemetry/operation-span.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,KAAK,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;AAEzE,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IAClC,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,uBAAuB,GAAG,SAAS,CAAC;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAsB,mBAAmB,CAAC,CAAC,EACvC,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC/B,MAAM,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CA0CZ"}
@@ -6,36 +6,37 @@ async function recordOperationSpan(options, operation, logger) {
6
6
  if (skipIfNoTelemetry && !hasActiveTelemetry(logger)) {
7
7
  return operation();
8
8
  }
9
- const span = trace.getTracer(options.tracerName ?? "dexto").startSpan(options.name, { kind: SpanKind.INTERNAL });
10
- const spanContext = trace.setSpan(context.active(), span);
11
- addBaggageAttributesToSpan(span, spanContext, logger);
12
- if (options.componentName !== void 0) {
13
- span.setAttribute("componentName", options.componentName);
14
- }
15
- setOperationSpanAttributes(span, options.attributes);
16
- try {
17
- const result = await context.with(spanContext, operation);
9
+ return trace.getTracer(options.tracerName ?? "dexto").startActiveSpan(options.name, { kind: SpanKind.INTERNAL }, async (span) => {
10
+ const spanContext = trace.setSpan(context.active(), span);
11
+ addBaggageAttributesToSpan(span, spanContext, logger);
12
+ if (options.componentName !== void 0) {
13
+ span.setAttribute("componentName", options.componentName);
14
+ }
15
+ setOperationSpanAttributes(span, options.attributes);
18
16
  try {
19
- setOperationSpanAttributes(span, options.resultAttributes?.(result));
17
+ const result = await operation();
18
+ try {
19
+ setOperationSpanAttributes(span, options.resultAttributes?.(result));
20
+ } catch (error) {
21
+ logger?.debug("Failed to set OpenTelemetry result attributes", {
22
+ error: error instanceof Error ? error.message : String(error),
23
+ span: options.name
24
+ });
25
+ }
26
+ span.setStatus({ code: SpanStatusCode.OK });
27
+ return result;
20
28
  } catch (error) {
21
- logger?.debug("Failed to set OpenTelemetry result attributes", {
22
- error: error instanceof Error ? error.message : String(error),
23
- span: options.name
24
- });
29
+ if (error instanceof Error) {
30
+ span.recordException(error);
31
+ span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
32
+ } else {
33
+ span.setStatus({ code: SpanStatusCode.ERROR, message: String(error) });
34
+ }
35
+ throw error;
36
+ } finally {
37
+ span.end();
25
38
  }
26
- span.setStatus({ code: SpanStatusCode.OK });
27
- return result;
28
- } catch (error) {
29
- if (error instanceof Error) {
30
- span.recordException(error);
31
- span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
32
- } else {
33
- span.setStatus({ code: SpanStatusCode.ERROR, message: String(error) });
34
- }
35
- throw error;
36
- } finally {
37
- span.end();
38
- }
39
+ });
39
40
  }
40
41
  function setOperationSpanAttributes(span, attributes) {
41
42
  if (span === void 0 || attributes === void 0) {
@@ -109,10 +109,13 @@ function mergePropertySchema(current, next) {
109
109
  if (valuesEqual(current, next)) {
110
110
  return current;
111
111
  }
112
- const currentEnum = readEnumValues(current);
113
- const nextEnum = readEnumValues(next);
114
- if (currentEnum !== void 0 && nextEnum !== void 0) {
115
- return { enum: mergeEnumValues([...currentEnum, ...nextEnum]) };
112
+ const currentEnumValues = readEnumValues(current);
113
+ const nextEnumValues = readEnumValues(next);
114
+ if (currentEnumValues !== void 0 && nextEnumValues !== void 0) {
115
+ return { enum: mergeEnumValues([...currentEnumValues, ...nextEnumValues]) };
116
+ }
117
+ if (currentEnumValues !== void 0 || nextEnumValues !== void 0) {
118
+ return {};
116
119
  }
117
120
  if (current.type !== void 0 && valuesEqual(current.type, next.type)) {
118
121
  return { type: current.type };
@@ -1 +1 @@
1
- {"version":3,"file":"tool-call-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/tool-call-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA0KF,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAkB7E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAChE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAQA"}
1
+ {"version":3,"file":"tool-call-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/tool-call-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA8KF,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAkB7E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAChE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAQA"}
@@ -86,10 +86,13 @@ function mergePropertySchema(current, next) {
86
86
  if (valuesEqual(current, next)) {
87
87
  return current;
88
88
  }
89
- const currentEnum = readEnumValues(current);
90
- const nextEnum = readEnumValues(next);
91
- if (currentEnum !== void 0 && nextEnum !== void 0) {
92
- return { enum: mergeEnumValues([...currentEnum, ...nextEnum]) };
89
+ const currentEnumValues = readEnumValues(current);
90
+ const nextEnumValues = readEnumValues(next);
91
+ if (currentEnumValues !== void 0 && nextEnumValues !== void 0) {
92
+ return { enum: mergeEnumValues([...currentEnumValues, ...nextEnumValues]) };
93
+ }
94
+ if (currentEnumValues !== void 0 || nextEnumValues !== void 0) {
95
+ return {};
93
96
  }
94
97
  if (current.type !== void 0 && valuesEqual(current.type, next.type)) {
95
98
  return { type: current.type };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/core",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -157,9 +157,10 @@
157
157
  "nanoid": "^5.1.6",
158
158
  "winston": "^3.17.0",
159
159
  "yaml": "^2.8.3",
160
- "@dexto/llm": "1.8.4"
160
+ "@dexto/llm": "1.8.5"
161
161
  },
162
162
  "devDependencies": {
163
+ "@opentelemetry/context-async-hooks": "^1.28.0",
163
164
  "@opentelemetry/instrumentation-http": "^0.210.0",
164
165
  "@opentelemetry/instrumentation-undici": "^0.20.0",
165
166
  "@opentelemetry/resources": "^1.28.0",