beeai-framework 0.1.8 → 0.1.9

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 (234) hide show
  1. package/README.md +21 -14
  2. package/dist/adapters/amazon-bedrock/backend/chat.d.cts +1 -1
  3. package/dist/adapters/amazon-bedrock/backend/chat.d.ts +1 -1
  4. package/dist/adapters/amazon-bedrock/backend/embedding.d.cts +1 -1
  5. package/dist/adapters/amazon-bedrock/backend/embedding.d.ts +1 -1
  6. package/dist/adapters/anthropic/backend/chat.d.cts +1 -1
  7. package/dist/adapters/anthropic/backend/chat.d.ts +1 -1
  8. package/dist/adapters/anthropic/backend/embedding.d.cts +1 -1
  9. package/dist/adapters/anthropic/backend/embedding.d.ts +1 -1
  10. package/dist/adapters/azure-openai/backend/chat.d.cts +1 -1
  11. package/dist/adapters/azure-openai/backend/chat.d.ts +1 -1
  12. package/dist/adapters/azure-openai/backend/embedding.d.cts +1 -1
  13. package/dist/adapters/azure-openai/backend/embedding.d.ts +1 -1
  14. package/dist/adapters/dummy/backend/chat.d.cts +1 -1
  15. package/dist/adapters/dummy/backend/chat.d.ts +1 -1
  16. package/dist/adapters/dummy/backend/embedding.d.cts +1 -1
  17. package/dist/adapters/dummy/backend/embedding.d.ts +1 -1
  18. package/dist/adapters/google-vertex/backend/chat.d.cts +1 -1
  19. package/dist/adapters/google-vertex/backend/chat.d.ts +1 -1
  20. package/dist/adapters/google-vertex/backend/embedding.d.cts +1 -1
  21. package/dist/adapters/google-vertex/backend/embedding.d.ts +1 -1
  22. package/dist/adapters/groq/backend/chat.d.cts +1 -1
  23. package/dist/adapters/groq/backend/chat.d.ts +1 -1
  24. package/dist/adapters/groq/backend/embedding.d.cts +1 -1
  25. package/dist/adapters/groq/backend/embedding.d.ts +1 -1
  26. package/dist/adapters/langchain/backend/chat.d.cts +1 -1
  27. package/dist/adapters/langchain/backend/chat.d.ts +1 -1
  28. package/dist/adapters/langchain/backend/embedding.d.cts +1 -1
  29. package/dist/adapters/langchain/backend/embedding.d.ts +1 -1
  30. package/dist/adapters/langchain/tools.d.cts +1 -1
  31. package/dist/adapters/langchain/tools.d.ts +1 -1
  32. package/dist/adapters/ollama/backend/chat.d.cts +1 -1
  33. package/dist/adapters/ollama/backend/chat.d.ts +1 -1
  34. package/dist/adapters/ollama/backend/embedding.d.cts +1 -1
  35. package/dist/adapters/ollama/backend/embedding.d.ts +1 -1
  36. package/dist/adapters/openai/backend/chat.d.cts +1 -1
  37. package/dist/adapters/openai/backend/chat.d.ts +1 -1
  38. package/dist/adapters/openai/backend/embedding.d.cts +1 -1
  39. package/dist/adapters/openai/backend/embedding.d.ts +1 -1
  40. package/dist/adapters/vercel/backend/chat.d.cts +1 -1
  41. package/dist/adapters/vercel/backend/chat.d.ts +1 -1
  42. package/dist/adapters/vercel/backend/embedding.d.cts +1 -1
  43. package/dist/adapters/vercel/backend/embedding.d.ts +1 -1
  44. package/dist/adapters/watsonx/backend/chat.d.cts +1 -1
  45. package/dist/adapters/watsonx/backend/chat.d.ts +1 -1
  46. package/dist/adapters/watsonx/backend/embedding.d.cts +1 -1
  47. package/dist/adapters/watsonx/backend/embedding.d.ts +1 -1
  48. package/dist/{agent-Dv5YSk8H.d.ts → agent-Bf2FaCKy.d.ts} +2 -2
  49. package/dist/{agent-COg8SPbf.d.cts → agent-Bpt7IFa_.d.cts} +2 -2
  50. package/dist/agents/base.cjs +1 -4
  51. package/dist/agents/base.cjs.map +1 -1
  52. package/dist/agents/base.d.cts +2 -2
  53. package/dist/agents/base.d.ts +2 -2
  54. package/dist/agents/base.js +1 -4
  55. package/dist/agents/base.js.map +1 -1
  56. package/dist/agents/experimental/remote/agent.d.cts +2 -2
  57. package/dist/agents/experimental/remote/agent.d.ts +2 -2
  58. package/dist/agents/experimental/replan/agent.d.cts +2 -2
  59. package/dist/agents/experimental/replan/agent.d.ts +2 -2
  60. package/dist/agents/experimental/replan/prompts.d.cts +1 -1
  61. package/dist/agents/experimental/replan/prompts.d.ts +1 -1
  62. package/dist/agents/experimental/streamlit/agent.d.cts +2 -2
  63. package/dist/agents/experimental/streamlit/agent.d.ts +2 -2
  64. package/dist/agents/react/agent.d.cts +3 -3
  65. package/dist/agents/react/agent.d.ts +3 -3
  66. package/dist/agents/react/prompts.d.cts +4 -4
  67. package/dist/agents/react/prompts.d.ts +4 -4
  68. package/dist/agents/react/runners/base.d.cts +3 -3
  69. package/dist/agents/react/runners/base.d.ts +3 -3
  70. package/dist/agents/react/runners/deep-think/prompts.d.cts +4 -4
  71. package/dist/agents/react/runners/deep-think/prompts.d.ts +4 -4
  72. package/dist/agents/react/runners/deep-think/runner.d.cts +7 -7
  73. package/dist/agents/react/runners/deep-think/runner.d.ts +7 -7
  74. package/dist/agents/react/runners/default/runner.d.cts +7 -7
  75. package/dist/agents/react/runners/default/runner.d.ts +7 -7
  76. package/dist/agents/react/runners/granite/prompts.d.cts +4 -4
  77. package/dist/agents/react/runners/granite/prompts.d.ts +4 -4
  78. package/dist/agents/react/runners/granite/runner.d.cts +8 -8
  79. package/dist/agents/react/runners/granite/runner.d.ts +8 -8
  80. package/dist/agents/react/types.d.cts +1 -1
  81. package/dist/agents/react/types.d.ts +1 -1
  82. package/dist/agents/toolCalling/agent.d.cts +2 -2
  83. package/dist/agents/toolCalling/agent.d.ts +2 -2
  84. package/dist/agents/toolCalling/types.d.cts +1 -1
  85. package/dist/agents/toolCalling/types.d.ts +1 -1
  86. package/dist/agents/types.d.cts +2 -2
  87. package/dist/agents/types.d.ts +2 -2
  88. package/dist/backend/backend.d.cts +1 -1
  89. package/dist/backend/backend.d.ts +1 -1
  90. package/dist/backend/chat.cjs +1 -3
  91. package/dist/backend/chat.cjs.map +1 -1
  92. package/dist/backend/chat.d.cts +1 -1
  93. package/dist/backend/chat.d.ts +1 -1
  94. package/dist/backend/chat.js +2 -4
  95. package/dist/backend/chat.js.map +1 -1
  96. package/dist/backend/core.d.cts +1 -1
  97. package/dist/backend/core.d.ts +1 -1
  98. package/dist/backend/embedding.d.cts +1 -1
  99. package/dist/backend/embedding.d.ts +1 -1
  100. package/dist/{base-Csr9guq2.d.cts → base-daM6fHUP.d.cts} +1 -1
  101. package/dist/{base-DHhpWHQm.d.ts → base-mmG-8Pk9.d.ts} +1 -1
  102. package/dist/context.d.cts +1 -1
  103. package/dist/context.d.ts +1 -1
  104. package/dist/emitter/emitter.d.cts +1 -1
  105. package/dist/emitter/emitter.d.ts +1 -1
  106. package/dist/emitter/types.d.cts +1 -1
  107. package/dist/emitter/types.d.ts +1 -1
  108. package/dist/index.d.cts +2 -2
  109. package/dist/index.d.ts +2 -2
  110. package/dist/internals/fetcher.d.cts +1 -1
  111. package/dist/internals/fetcher.d.ts +1 -1
  112. package/dist/memory/summarizeMemory.d.cts +1 -1
  113. package/dist/memory/summarizeMemory.d.ts +1 -1
  114. package/dist/parsers/linePrefix.d.cts +1 -1
  115. package/dist/parsers/linePrefix.d.ts +1 -1
  116. package/dist/tools/arxiv.d.cts +1 -1
  117. package/dist/tools/arxiv.d.ts +1 -1
  118. package/dist/tools/base.cjs +1 -3
  119. package/dist/tools/base.cjs.map +1 -1
  120. package/dist/tools/base.d.cts +1 -1
  121. package/dist/tools/base.d.ts +1 -1
  122. package/dist/tools/base.js +2 -4
  123. package/dist/tools/base.js.map +1 -1
  124. package/dist/tools/calculator.d.cts +1 -1
  125. package/dist/tools/calculator.d.ts +1 -1
  126. package/dist/tools/custom.d.cts +1 -1
  127. package/dist/tools/custom.d.ts +1 -1
  128. package/dist/tools/database/elasticsearch.d.cts +1 -1
  129. package/dist/tools/database/elasticsearch.d.ts +1 -1
  130. package/dist/tools/database/milvus.d.cts +3 -3
  131. package/dist/tools/database/milvus.d.ts +3 -3
  132. package/dist/tools/database/sql.d.cts +1 -1
  133. package/dist/tools/database/sql.d.ts +1 -1
  134. package/dist/tools/llm.d.cts +1 -1
  135. package/dist/tools/llm.d.ts +1 -1
  136. package/dist/tools/mcp.d.cts +1 -1
  137. package/dist/tools/mcp.d.ts +1 -1
  138. package/dist/tools/openapi.d.cts +1 -1
  139. package/dist/tools/openapi.d.ts +1 -1
  140. package/dist/tools/python/output.d.cts +1 -1
  141. package/dist/tools/python/output.d.ts +1 -1
  142. package/dist/tools/python/python.d.cts +1 -1
  143. package/dist/tools/python/python.d.ts +1 -1
  144. package/dist/tools/search/base.d.cts +1 -1
  145. package/dist/tools/search/base.d.ts +1 -1
  146. package/dist/tools/search/duckDuckGoSearch.d.cts +1 -1
  147. package/dist/tools/search/duckDuckGoSearch.d.ts +1 -1
  148. package/dist/tools/search/googleSearch.d.cts +1 -1
  149. package/dist/tools/search/googleSearch.d.ts +1 -1
  150. package/dist/tools/search/searXNGSearch.d.cts +1 -1
  151. package/dist/tools/search/searXNGSearch.d.ts +1 -1
  152. package/dist/tools/search/wikipedia.d.cts +1 -1
  153. package/dist/tools/search/wikipedia.d.ts +1 -1
  154. package/dist/tools/similarity.d.cts +1 -1
  155. package/dist/tools/similarity.d.ts +1 -1
  156. package/dist/tools/weather/openMeteo.d.cts +1 -1
  157. package/dist/tools/weather/openMeteo.d.ts +1 -1
  158. package/dist/tools/web/webCrawler.d.cts +1 -1
  159. package/dist/tools/web/webCrawler.d.ts +1 -1
  160. package/dist/version.cjs +1 -1
  161. package/dist/version.js +1 -1
  162. package/dist/workflows/agent.d.cts +10 -10
  163. package/dist/workflows/agent.d.ts +10 -10
  164. package/dist/workflows/workflow.d.cts +1 -1
  165. package/dist/workflows/workflow.d.ts +1 -1
  166. package/package.json +1 -8
  167. package/dist/instrumentation/config.cjs +0 -12
  168. package/dist/instrumentation/config.cjs.map +0 -1
  169. package/dist/instrumentation/config.d.cts +0 -19
  170. package/dist/instrumentation/config.d.ts +0 -19
  171. package/dist/instrumentation/config.js +0 -9
  172. package/dist/instrumentation/config.js.map +0 -1
  173. package/dist/instrumentation/create-telemetry-middleware.cjs +0 -239
  174. package/dist/instrumentation/create-telemetry-middleware.cjs.map +0 -1
  175. package/dist/instrumentation/create-telemetry-middleware.d.cts +0 -26
  176. package/dist/instrumentation/create-telemetry-middleware.d.ts +0 -26
  177. package/dist/instrumentation/create-telemetry-middleware.js +0 -237
  178. package/dist/instrumentation/create-telemetry-middleware.js.map +0 -1
  179. package/dist/instrumentation/helpers/create-span.cjs +0 -36
  180. package/dist/instrumentation/helpers/create-span.cjs.map +0 -1
  181. package/dist/instrumentation/helpers/create-span.d.cts +0 -34
  182. package/dist/instrumentation/helpers/create-span.d.ts +0 -34
  183. package/dist/instrumentation/helpers/create-span.js +0 -34
  184. package/dist/instrumentation/helpers/create-span.js.map +0 -1
  185. package/dist/instrumentation/helpers/get-error-safe.cjs +0 -20
  186. package/dist/instrumentation/helpers/get-error-safe.cjs.map +0 -1
  187. package/dist/instrumentation/helpers/get-error-safe.d.cts +0 -18
  188. package/dist/instrumentation/helpers/get-error-safe.d.ts +0 -18
  189. package/dist/instrumentation/helpers/get-error-safe.js +0 -18
  190. package/dist/instrumentation/helpers/get-error-safe.js.map +0 -1
  191. package/dist/instrumentation/helpers/get-serialized-object-safe.cjs +0 -27
  192. package/dist/instrumentation/helpers/get-serialized-object-safe.cjs.map +0 -1
  193. package/dist/instrumentation/helpers/get-serialized-object-safe.d.cts +0 -18
  194. package/dist/instrumentation/helpers/get-serialized-object-safe.d.ts +0 -18
  195. package/dist/instrumentation/helpers/get-serialized-object-safe.js +0 -25
  196. package/dist/instrumentation/helpers/get-serialized-object-safe.js.map +0 -1
  197. package/dist/instrumentation/helpers/id-name-manager.cjs +0 -34
  198. package/dist/instrumentation/helpers/id-name-manager.cjs.map +0 -1
  199. package/dist/instrumentation/helpers/id-name-manager.d.cts +0 -31
  200. package/dist/instrumentation/helpers/id-name-manager.d.ts +0 -31
  201. package/dist/instrumentation/helpers/id-name-manager.js +0 -32
  202. package/dist/instrumentation/helpers/id-name-manager.js.map +0 -1
  203. package/dist/instrumentation/helpers/trace-serializer.cjs +0 -30
  204. package/dist/instrumentation/helpers/trace-serializer.cjs.map +0 -1
  205. package/dist/instrumentation/helpers/trace-serializer.d.cts +0 -20
  206. package/dist/instrumentation/helpers/trace-serializer.d.ts +0 -20
  207. package/dist/instrumentation/helpers/trace-serializer.js +0 -28
  208. package/dist/instrumentation/helpers/trace-serializer.js.map +0 -1
  209. package/dist/instrumentation/helpers/utils.cjs +0 -14
  210. package/dist/instrumentation/helpers/utils.cjs.map +0 -1
  211. package/dist/instrumentation/helpers/utils.d.cts +0 -40
  212. package/dist/instrumentation/helpers/utils.d.ts +0 -40
  213. package/dist/instrumentation/helpers/utils.js +0 -12
  214. package/dist/instrumentation/helpers/utils.js.map +0 -1
  215. package/dist/instrumentation/logger.cjs +0 -12
  216. package/dist/instrumentation/logger.cjs.map +0 -1
  217. package/dist/instrumentation/logger.d.cts +0 -26
  218. package/dist/instrumentation/logger.d.ts +0 -26
  219. package/dist/instrumentation/logger.js +0 -10
  220. package/dist/instrumentation/logger.js.map +0 -1
  221. package/dist/instrumentation/tracer.cjs +0 -84
  222. package/dist/instrumentation/tracer.cjs.map +0 -1
  223. package/dist/instrumentation/tracer.d.cts +0 -36
  224. package/dist/instrumentation/tracer.d.ts +0 -36
  225. package/dist/instrumentation/tracer.js +0 -76
  226. package/dist/instrumentation/tracer.js.map +0 -1
  227. package/dist/instrumentation/types.cjs +0 -4
  228. package/dist/instrumentation/types.cjs.map +0 -1
  229. package/dist/instrumentation/types.d.cts +0 -39
  230. package/dist/instrumentation/types.d.ts +0 -39
  231. package/dist/instrumentation/types.js +0 -3
  232. package/dist/instrumentation/types.js.map +0 -1
  233. package/dist/{emitter-l0W9gC1A.d.ts → emitter-BxVxGBbJ.d.ts} +1 -1
  234. package/dist/{emitter-BWtGHYn0.d.cts → emitter-C9EN5B0j.d.cts} +1 -1
@@ -1,237 +0,0 @@
1
- import { getSerializedObjectSafe } from './helpers/get-serialized-object-safe.js';
2
- import { createSpan } from './helpers/create-span.js';
3
- import { IdNameManager } from './helpers/id-name-manager.js';
4
- import { getErrorSafe } from './helpers/get-error-safe.js';
5
- import { findLast, isEmpty, isDeepEqual } from 'remeda';
6
- import { FrameworkError } from '../errors.js';
7
- import { Version } from '../version.js';
8
- import { activeTracesMap, buildTraceTree } from './tracer.js';
9
- import { traceSerializer } from './helpers/trace-serializer.js';
10
- import { INSTRUMENTATION_IGNORED_KEYS } from './config.js';
11
- import { createFullPath } from '../emitter/utils.js';
12
- import { instrumentationLogger } from './logger.js';
13
- import { BaseAgent } from '../agents/base.js';
14
- import { assertLLMWithMessagesToPromptFn } from './helpers/utils.js';
15
- import { Role } from '../backend/message.js';
16
-
17
- var __defProp = Object.defineProperty;
18
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
19
- function createTelemetryMiddleware() {
20
- return (context) => {
21
- if (!context.emitter?.trace?.id) {
22
- throw new FrameworkError(`Fatal error. Missing traceId`, [], {
23
- context
24
- });
25
- }
26
- const traceId = context.emitter?.trace?.id;
27
- if (activeTracesMap.has(traceId)) {
28
- return;
29
- }
30
- activeTracesMap.set(traceId, context.instance.constructor.name);
31
- instrumentationLogger.debug({
32
- source: context.instance.constructor.name,
33
- traceId
34
- }, "createTelemetryMiddleware");
35
- const { emitter, runParams, instance } = context;
36
- const basePath = createFullPath(emitter.namespace, "");
37
- let prompt = null;
38
- if (instance instanceof BaseAgent) {
39
- prompt = runParams[0].prompt;
40
- }
41
- const spansMap = /* @__PURE__ */ new Map();
42
- const parentIdsMap = /* @__PURE__ */ new Map();
43
- const spansToDeleteMap = /* @__PURE__ */ new Map();
44
- let generatedMessage = void 0;
45
- let history = void 0;
46
- const groupIterations = [];
47
- const idNameManager = new IdNameManager();
48
- const newTokenEventName = `newToken`;
49
- const partialUpdateEventName = "partialUpdate";
50
- const successEventName = `success`;
51
- const finishEventName = `finish`;
52
- const startEventName = `start`;
53
- const errorEventName = `error`;
54
- const eventsIterationsMap = /* @__PURE__ */ new Map();
55
- const startTimeDate = (/* @__PURE__ */ new Date()).getTime();
56
- const startTimePerf = performance.now();
57
- function convertDateToPerformance(date) {
58
- return date.getTime() - startTimeDate + startTimePerf;
59
- }
60
- __name(convertDateToPerformance, "convertDateToPerformance");
61
- const serializer = traceSerializer({
62
- ignored_keys: INSTRUMENTATION_IGNORED_KEYS
63
- });
64
- function cleanSpanSources({ spanId }) {
65
- const parentId = spansMap.get(spanId)?.parent_id;
66
- if (!parentId) {
67
- return;
68
- }
69
- const spanCount = parentIdsMap.get(parentId);
70
- if (!spanCount) {
71
- return;
72
- }
73
- if (spanCount > 1) {
74
- parentIdsMap.set(parentId, spanCount - 1);
75
- } else if (spanCount === 1) {
76
- parentIdsMap.delete(parentId);
77
- if (spansToDeleteMap.has(parentId)) {
78
- spansMap.delete(parentId);
79
- spansToDeleteMap.delete(parentId);
80
- }
81
- }
82
- }
83
- __name(cleanSpanSources, "cleanSpanSources");
84
- emitter.match((event) => event.path === `${basePath}.run.${finishEventName}`, async (_, meta) => {
85
- try {
86
- instrumentationLogger.debug({
87
- path: meta.path,
88
- traceId
89
- }, "run finish event");
90
- if (!prompt && instance instanceof BaseAgent) {
91
- prompt = findLast(instance.memory.messages, (message) => message.role === Role.USER)?.text;
92
- if (!prompt) {
93
- throw new FrameworkError("The prompt must be defined for the agent's run", [], {
94
- context
95
- });
96
- }
97
- }
98
- buildTraceTree({
99
- prompt,
100
- history,
101
- generatedMessage,
102
- spans: JSON.parse(serializer(Array.from(spansMap.values()))),
103
- traceId,
104
- version: Version,
105
- runErrorSpanKey: `${basePath}.run.${errorEventName}`,
106
- startTime: startTimePerf,
107
- endTime: performance.now(),
108
- source: activeTracesMap.get(traceId)
109
- });
110
- } catch (e) {
111
- instrumentationLogger.warn(e, "Instrumentation error");
112
- } finally {
113
- activeTracesMap.delete(traceId);
114
- }
115
- });
116
- emitter.match("*.*", (data, meta) => {
117
- if (meta.path.includes(".run.") && meta.path !== `${basePath}.run.${errorEventName}`) {
118
- return;
119
- }
120
- if (!meta.trace?.runId) {
121
- throw new FrameworkError(`Fatal error. Missing runId for event: ${meta.path}`, [], {
122
- context
123
- });
124
- }
125
- if (meta.groupId && !meta.trace.parentRunId && !groupIterations.includes(meta.groupId)) {
126
- spansMap.set(meta.groupId, createSpan({
127
- id: meta.groupId,
128
- name: meta.groupId,
129
- target: "groupId",
130
- startedAt: convertDateToPerformance(meta.createdAt)
131
- }));
132
- groupIterations.push(meta.groupId);
133
- }
134
- const { spanId, parentSpanId } = idNameManager.getIds({
135
- path: meta.path,
136
- id: meta.id,
137
- runId: meta.trace.runId,
138
- parentRunId: meta.trace.parentRunId,
139
- groupId: meta.groupId
140
- });
141
- const serializedData = getSerializedObjectSafe(data);
142
- if (meta.name === partialUpdateEventName && isEmpty(serializedData)) {
143
- return;
144
- }
145
- const span = createSpan({
146
- id: spanId,
147
- name: meta.name,
148
- target: meta.path,
149
- ...parentSpanId && {
150
- parent: {
151
- id: parentSpanId
152
- }
153
- },
154
- ctx: getSerializedObjectSafe(meta.context),
155
- data: serializedData,
156
- error: getErrorSafe(data),
157
- startedAt: convertDateToPerformance(meta.createdAt)
158
- });
159
- const lastIteration = groupIterations[groupIterations.length - 1];
160
- const lastIterationOnNewTokenSpanId = eventsIterationsMap.get(lastIteration)?.get(meta.name);
161
- if (lastIterationOnNewTokenSpanId && meta.name === newTokenEventName) {
162
- cleanSpanSources({
163
- spanId: lastIterationOnNewTokenSpanId
164
- });
165
- spansMap.delete(lastIterationOnNewTokenSpanId);
166
- }
167
- const lastIterationEventSpanId = eventsIterationsMap.get(lastIteration)?.get(meta.name);
168
- if (lastIterationEventSpanId && partialUpdateEventName === meta.name && spansMap.has(lastIterationEventSpanId)) {
169
- const { attributes, context: context2 } = spansMap.get(lastIterationEventSpanId);
170
- if (isDeepEqual(serializedData, attributes.data)) {
171
- if (parentIdsMap.has(context2.span_id)) {
172
- spansToDeleteMap.set(lastIterationEventSpanId, void 0);
173
- } else {
174
- cleanSpanSources({
175
- spanId: lastIterationEventSpanId
176
- });
177
- spansMap.delete(lastIterationEventSpanId);
178
- }
179
- }
180
- }
181
- spansMap.set(span.context.span_id, span);
182
- if (span.parent_id) {
183
- parentIdsMap.set(span.parent_id, (parentIdsMap.get(span.parent_id) || 0) + 1);
184
- }
185
- if (groupIterations.length > 0) {
186
- if (eventsIterationsMap.has(lastIteration)) {
187
- eventsIterationsMap.get(lastIteration).set(meta.name, span.context.span_id);
188
- } else {
189
- eventsIterationsMap.set(lastIteration, (/* @__PURE__ */ new Map()).set(meta.name, span.context.span_id));
190
- }
191
- }
192
- });
193
- emitter.match((event) => event.name === successEventName && event.creator instanceof BaseAgent, (data) => {
194
- const { data: dataObject, memory } = data;
195
- generatedMessage = {
196
- role: dataObject.role,
197
- text: dataObject.text
198
- };
199
- history = memory.messages.map((msg) => ({
200
- text: msg.text,
201
- role: msg.role
202
- }));
203
- });
204
- emitter.match((event) => assertLLMWithMessagesToPromptFn(event.creator) && event.name === startEventName, (_, meta) => {
205
- if (assertLLMWithMessagesToPromptFn(meta.creator) && meta.trace) {
206
- const path = `${meta.path}.custom`;
207
- const { spanId, parentSpanId } = idNameManager.getIds({
208
- path,
209
- id: meta.id,
210
- runId: meta.trace.runId,
211
- parentRunId: meta.trace.parentRunId,
212
- groupId: meta.groupId
213
- });
214
- spansMap.set(spanId, createSpan({
215
- id: spanId,
216
- name: `${meta.name}Custom`,
217
- target: path,
218
- startedAt: convertDateToPerformance(meta.createdAt),
219
- ...parentSpanId && {
220
- parent: {
221
- id: parentSpanId
222
- }
223
- },
224
- data: {
225
- rawPrompt: void 0,
226
- creator: meta.creator.createSnapshot()
227
- }
228
- }));
229
- }
230
- });
231
- };
232
- }
233
- __name(createTelemetryMiddleware, "createTelemetryMiddleware");
234
-
235
- export { createTelemetryMiddleware };
236
- //# sourceMappingURL=create-telemetry-middleware.js.map
237
- //# sourceMappingURL=create-telemetry-middleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["create-telemetry-middleware.ts"],"names":["createTelemetryMiddleware","context","emitter","trace","id","FrameworkError","traceId","activeTracesMap","has","set","instance","constructor","name","instrumentationLogger","debug","source","runParams","basePath","createFullPath","namespace","prompt","BaseAgent","spansMap","Map","parentIdsMap","spansToDeleteMap","generatedMessage","undefined","history","groupIterations","idNameManager","IdNameManager","newTokenEventName","partialUpdateEventName","successEventName","finishEventName","startEventName","errorEventName","eventsIterationsMap","startTimeDate","Date","getTime","startTimePerf","performance","now","convertDateToPerformance","date","serializer","traceSerializer","ignored_keys","INSTRUMENTATION_IGNORED_KEYS","cleanSpanSources","spanId","parentId","get","parent_id","spanCount","delete","match","event","path","_","meta","findLast","memory","messages","message","role","Role","USER","text","buildTraceTree","spans","JSON","parse","Array","from","values","version","Version","runErrorSpanKey","startTime","endTime","e","warn","data","includes","runId","groupId","parentRunId","createSpan","target","startedAt","createdAt","push","parentSpanId","getIds","serializedData","getSerializedObjectSafe","isEmpty","span","parent","ctx","error","getErrorSafe","lastIteration","length","lastIterationOnNewTokenSpanId","lastIterationEventSpanId","attributes","isDeepEqual","span_id","creator","dataObject","map","msg","assertLLMWithMessagesToPromptFn","rawPrompt","createSnapshot"],"mappings":";;;;;;;;;;;;;;;;;;AAsCO,SAASA,yBAAAA,GAAAA;AACd,EAAA,OAAO,CAACC,OAAAA,KAAAA;AACN,IAAA,IAAI,CAACA,OAAAA,CAAQC,OAASC,EAAAA,KAAAA,EAAOC,EAAI,EAAA;AAC/B,MAAA,MAAM,IAAIC,cAAAA,CAAe,CAAgC,4BAAA,CAAA,EAAA,EAAI,EAAA;AAAEJ,QAAAA;OAAQ,CAAA;AACzE;AAEA,IAAMK,MAAAA,OAAAA,GAAUL,OAAQC,CAAAA,OAAAA,EAASC,KAAOC,EAAAA,EAAAA;AACxC,IAAIG,IAAAA,eAAAA,CAAgBC,GAAIF,CAAAA,OAAAA,CAAU,EAAA;AAChC,MAAA;AACF;AACAC,IAAAA,eAAAA,CAAgBE,GAAIH,CAAAA,OAAAA,EAASL,OAAQS,CAAAA,QAAAA,CAASC,YAAYC,IAAI,CAAA;AAE9DC,IAAAA,qBAAAA,CAAsBC,KACpB,CAAA;MACEC,MAAQd,EAAAA,O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AACF,MAAA,IAAIsD,+BAAgCtD,CAAAA,IAAAA,CAAKkD,OAAO,CAAA,IAAKlD,KAAK3D,KAAO,EAAA;AAE/D,QAAMyD,MAAAA,IAAAA,GAAO,CAAGE,EAAAA,IAAAA,CAAKF,IAAI,CAAA,OAAA,CAAA;AAEzB,QAAA,MAAM,EAAER,MAAAA,EAAQ2C,YAAY,EAAA,GAAKjE,cAAckE,MAAO,CAAA;AACpDpC,UAAAA,IAAAA;AACAxD,UAAAA,EAAAA,EAAI0D,IAAK1D,CAAAA,EAAAA;AACTmF,UAAAA,KAAAA,EAAOzB,KAAK3D,KAAMoF,CAAAA,KAAAA;AAClBE,UAAAA,WAAAA,EAAa3B,KAAK3D,KAAMsF,CAAAA,WAAAA;AACxBD,UAAAA,OAAAA,EAAS1B,IAAK0B,CAAAA;SAChB,CAAA;AAEAlE,QAASb,QAAAA,CAAAA,GAAAA,CACP2C,QACAsC,UAAW,CAAA;UACTtF,EAAIgD,EAAAA,MAAAA;UACJxC,IAAM,EAAA,CAAA,EAAGkD,KAAKlD,IAAI,CAAA,MAAA,CAAA;UAClB+E,MAAQ/B,EAAAA,IAAAA;UACRgC,SAAW/C,EAAAA,wBAAAA,CAAyBiB,KAAK+B,SAAS,CAAA;AAClD,UAAA,GAAIE,YAAgB,IAAA;YAAEM,MAAQ,EAAA;cAAEjG,EAAI2F,EAAAA;AAAa;AAAE,WAAA;UACnDV,IAAM,EAAA;YACJgC,SAAW1F,EAAAA,MAAAA;YACXqF,OAASlD,EAAAA,IAAAA,CAAKkD,QAAQM,cAAc;AACtC;AACF,SAAA,CAAA,CAAA;AAEJ;KACF,CAAA;AAEJ,GAAA;AACF;AApRgBtH,MAAAA,CAAAA,yBAAAA,EAAAA,2BAAAA,CAAAA","file":"create-telemetry-middleware.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getSerializedObjectSafe } from \"./helpers/get-serialized-object-safe.js\";\nimport { createSpan } from \"./helpers/create-span.js\";\nimport { IdNameManager } from \"./helpers/id-name-manager.js\";\nimport { getErrorSafe } from \"./helpers/get-error-safe.js\";\nimport { findLast, isDeepEqual, isEmpty } from \"remeda\";\nimport type { ReActAgentCallbacks } from \"@/agents/react/types.js\";\nimport type { InferCallbackValue } from \"@/emitter/types.js\";\nimport { FrameworkError } from \"@/errors.js\";\nimport { Version } from \"@/version.js\";\nimport type { GetRunContext, RunInstance } from \"@/context.js\";\nimport type { GeneratedResponse, FrameworkSpan } from \"./types.js\";\nimport { activeTracesMap, buildTraceTree } from \"./tracer.js\";\nimport { traceSerializer } from \"./helpers/trace-serializer.js\";\nimport { INSTRUMENTATION_IGNORED_KEYS } from \"./config.js\";\nimport { createFullPath } from \"@/emitter/utils.js\";\nimport type { ReActAgent } from \"@/agents/react/agent.js\";\nimport { instrumentationLogger } from \"./logger.js\";\nimport { BaseAgent } from \"@/agents/base.js\";\nimport { assertLLMWithMessagesToPromptFn } from \"./helpers/utils.js\";\nimport { Role } from \"@/backend/message.js\";\nimport { ChatModelEvents } from \"@/backend/chat.js\";\n\nexport function createTelemetryMiddleware() {\n return (context: GetRunContext<RunInstance, unknown>) => {\n if (!context.emitter?.trace?.id) {\n throw new FrameworkError(`Fatal error. Missing traceId`, [], { context });\n }\n\n const traceId = context.emitter?.trace?.id;\n if (activeTracesMap.has(traceId)) {\n return;\n }\n activeTracesMap.set(traceId, context.instance.constructor.name);\n\n instrumentationLogger.debug(\n {\n source: context.instance.constructor.name,\n traceId: traceId,\n },\n \"createTelemetryMiddleware\",\n );\n const { emitter, runParams, instance } = context;\n const basePath = createFullPath(emitter.namespace, \"\");\n\n let prompt: string | undefined | null = null;\n if (instance instanceof BaseAgent) {\n prompt = (runParams as Parameters<ReActAgent[\"run\"]>)[0].prompt;\n }\n\n const spansMap = new Map<string, FrameworkSpan>();\n const parentIdsMap = new Map<string, number>();\n const spansToDeleteMap = new Map<string, undefined>();\n\n let generatedMessage: GeneratedResponse | undefined = undefined;\n let history: GeneratedResponse[] | undefined = undefined;\n const groupIterations: string[] = [];\n\n const idNameManager = new IdNameManager();\n\n const newTokenEventName: keyof ChatModelEvents = `newToken`;\n const partialUpdateEventName: keyof ReActAgentCallbacks = \"partialUpdate\";\n const successEventName: keyof ChatModelEvents = `success`;\n const finishEventName: keyof ChatModelEvents = `finish`;\n const startEventName: keyof ChatModelEvents = `start`;\n const errorEventName: keyof ChatModelEvents = `error`;\n\n const eventsIterationsMap = new Map<string, Map<string, string>>();\n\n const startTimeDate = new Date().getTime();\n const startTimePerf = performance.now();\n function convertDateToPerformance(date: Date) {\n return date.getTime() - startTimeDate + startTimePerf;\n }\n\n const serializer = traceSerializer({ ignored_keys: INSTRUMENTATION_IGNORED_KEYS });\n\n function cleanSpanSources({ spanId }: { spanId: string }) {\n const parentId = spansMap.get(spanId)?.parent_id;\n if (!parentId) {\n return;\n }\n\n const spanCount = parentIdsMap.get(parentId);\n if (!spanCount) {\n return;\n }\n\n if (spanCount > 1) {\n // increase the span count for the parentId\n parentIdsMap.set(parentId, spanCount - 1);\n } else if (spanCount === 1) {\n parentIdsMap.delete(parentId);\n // check the `spansToDelete` if the span should be deleted when it has no children's\n if (spansToDeleteMap.has(parentId)) {\n spansMap.delete(parentId);\n spansToDeleteMap.delete(parentId);\n }\n }\n }\n\n /**\n * Create OpenTelemetry spans from collected data\n */\n emitter.match(\n (event) => event.path === `${basePath}.run.${finishEventName}`,\n async (_, meta) => {\n try {\n instrumentationLogger.debug({ path: meta.path, traceId: traceId }, \"run finish event\");\n\n if (!prompt && instance instanceof BaseAgent) {\n prompt = findLast(\n instance.memory.messages,\n (message) => message.role === Role.USER,\n )?.text;\n\n if (!prompt) {\n throw new FrameworkError(\"The prompt must be defined for the agent's run\", [], {\n context,\n });\n }\n }\n\n // create tracer spans from collected data\n buildTraceTree({\n prompt: prompt,\n history,\n generatedMessage,\n spans: JSON.parse(serializer(Array.from(spansMap.values()))),\n traceId,\n version: Version,\n runErrorSpanKey: `${basePath}.run.${errorEventName}`,\n startTime: startTimePerf,\n endTime: performance.now(),\n source: activeTracesMap.get(traceId)!,\n });\n } catch (e) {\n instrumentationLogger.warn(e, \"Instrumentation error\");\n } finally {\n activeTracesMap.delete(traceId);\n }\n },\n );\n\n /**\n * This block collects all \"not run category\" events with their data and prepares spans for the OpenTelemetry.\n * The huge number of `newToken` events are skipped and only the last one for each parent event is saved because of `generated_token_count` information\n * The framework event tree structure is different from the open-telemetry tree structure and must be transformed from groupId and parentGroupId pattern via idNameManager\n * The artificial \"iteration\" main tree level is computed from the `meta.groupId`\n */\n emitter.match(\"*.*\", (data, meta) => {\n // allow `run.error` event due to the runtime error information\n if (meta.path.includes(\".run.\") && meta.path !== `${basePath}.run.${errorEventName}`) {\n return;\n }\n if (!meta.trace?.runId) {\n throw new FrameworkError(`Fatal error. Missing runId for event: ${meta.path}`, [], {\n context,\n });\n }\n\n /**\n * create groupId span level (id does not exist)\n * I use only the top-level groups like iterations other nested groups like tokens would introduce unuseful complexity\n */\n if (meta.groupId && !meta.trace.parentRunId && !groupIterations.includes(meta.groupId)) {\n spansMap.set(\n meta.groupId,\n createSpan({\n id: meta.groupId,\n name: meta.groupId,\n target: \"groupId\",\n startedAt: convertDateToPerformance(meta.createdAt),\n }),\n );\n groupIterations.push(meta.groupId);\n }\n\n const { spanId, parentSpanId } = idNameManager.getIds({\n path: meta.path,\n id: meta.id,\n runId: meta.trace.runId,\n parentRunId: meta.trace.parentRunId,\n groupId: meta.groupId,\n });\n\n const serializedData = getSerializedObjectSafe(data);\n\n // skip partialUpdate events with no data\n if (meta.name === partialUpdateEventName && isEmpty(serializedData)) {\n return;\n }\n\n const span = createSpan({\n id: spanId,\n name: meta.name,\n target: meta.path,\n ...(parentSpanId && { parent: { id: parentSpanId } }),\n ctx: getSerializedObjectSafe(meta.context),\n data: serializedData,\n error: getErrorSafe(data),\n startedAt: convertDateToPerformance(meta.createdAt),\n });\n\n const lastIteration = groupIterations[groupIterations.length - 1];\n\n // delete the `newToken` event if exists and create the new one\n const lastIterationOnNewTokenSpanId = eventsIterationsMap.get(lastIteration)?.get(meta.name);\n if (lastIterationOnNewTokenSpanId && meta.name === newTokenEventName) {\n // delete span\n cleanSpanSources({ spanId: lastIterationOnNewTokenSpanId });\n spansMap.delete(lastIterationOnNewTokenSpanId);\n }\n\n // delete the last `partialUpdate` event if the new one has same data and the original one does not have nested spans\n const lastIterationEventSpanId = eventsIterationsMap.get(lastIteration)?.get(meta.name);\n if (\n lastIterationEventSpanId &&\n partialUpdateEventName === meta.name &&\n spansMap.has(lastIterationEventSpanId)\n ) {\n const { attributes, context } = spansMap.get(lastIterationEventSpanId)!;\n\n if (isDeepEqual(serializedData, attributes.data)) {\n if (parentIdsMap.has(context.span_id)) {\n spansToDeleteMap.set(lastIterationEventSpanId, undefined);\n } else {\n // delete span\n cleanSpanSources({ spanId: lastIterationEventSpanId });\n spansMap.delete(lastIterationEventSpanId);\n }\n }\n }\n\n // create new span\n spansMap.set(span.context.span_id, span);\n // update number of nested spans for parent_id if exists\n if (span.parent_id) {\n parentIdsMap.set(span.parent_id, (parentIdsMap.get(span.parent_id) || 0) + 1);\n }\n\n // save the last event for each iteration\n if (groupIterations.length > 0) {\n if (eventsIterationsMap.has(lastIteration)) {\n eventsIterationsMap.get(lastIteration)!.set(meta.name, span.context.span_id);\n } else {\n eventsIterationsMap.set(lastIteration, new Map().set(meta.name, span.context.span_id));\n }\n }\n });\n\n // The generated response and message history are collected from the `success` agent's event\n emitter.match(\n (event) => event.name === successEventName && event.creator instanceof BaseAgent,\n (data: InferCallbackValue<ReActAgentCallbacks[typeof successEventName]>) => {\n const { data: dataObject, memory } = data;\n\n generatedMessage = {\n role: dataObject.role,\n text: dataObject.text,\n };\n history = memory.messages.map((msg) => ({ text: msg.text, role: msg.role }));\n },\n );\n\n // Read rawPrompt from llm input only for supported adapters and create the custom event with it\n emitter.match(\n (event) => assertLLMWithMessagesToPromptFn(event.creator) && event.name === startEventName,\n (_, meta) => {\n if (assertLLMWithMessagesToPromptFn(meta.creator) && meta.trace) {\n // create a custom path to prevent event duplication\n const path = `${meta.path}.custom`;\n\n const { spanId, parentSpanId } = idNameManager.getIds({\n path,\n id: meta.id,\n runId: meta.trace.runId,\n parentRunId: meta.trace.parentRunId,\n groupId: meta.groupId,\n });\n\n spansMap.set(\n spanId,\n createSpan({\n id: spanId,\n name: `${meta.name}Custom`,\n target: path,\n startedAt: convertDateToPerformance(meta.createdAt),\n ...(parentSpanId && { parent: { id: parentSpanId } }),\n data: {\n rawPrompt: undefined,\n creator: meta.creator.createSnapshot(),\n },\n }),\n );\n }\n },\n );\n };\n}\n"]}
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- var api = require('@opentelemetry/api');
4
- var remeda = require('remeda');
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- function createSpan({ target, name, data, error, ctx, parent, id, startedAt }) {
9
- return {
10
- name,
11
- attributes: {
12
- target,
13
- data: data && !remeda.isEmpty(data) ? {
14
- ...data
15
- } : null,
16
- ctx: ctx && !remeda.isEmpty(ctx) ? {
17
- ...ctx
18
- } : null
19
- },
20
- context: {
21
- span_id: id
22
- },
23
- parent_id: parent?.id,
24
- status: {
25
- code: error ? api.SpanStatusCode.ERROR : api.SpanStatusCode.OK,
26
- message: error ? error : ""
27
- },
28
- start_time: startedAt,
29
- end_time: performance.now()
30
- };
31
- }
32
- __name(createSpan, "createSpan");
33
-
34
- exports.createSpan = createSpan;
35
- //# sourceMappingURL=create-span.cjs.map
36
- //# sourceMappingURL=create-span.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["create-span.ts"],"names":["createSpan","target","name","data","error","ctx","parent","id","startedAt","attributes","isEmpty","context","span_id","parent_id","status","code","SpanStatusCode","ERROR","OK","message","start_time","end_time","performance","now"],"mappings":";;;;;;;AA+BO,SAASA,UAAAA,CAAW,EACzBC,MAAAA,EACAC,IACAC,EAAAA,IAAAA,EACAC,OACAC,GACAC,EAAAA,MAAAA,EACAC,EACAC,EAAAA,SAAAA,EACgB,EAAA;AAChB,EAAO,OAAA;AACLN,IAAAA,IAAAA;IACAO,UAAY,EAAA;AACVR,MAAAA,MAAAA;AACAE,MAAAA,IAAAA,EAAMA,IAAQ,IAAA,CAACO,cAAQP,CAAAA,IAAAA,CAAQ,GAAA;QAAE,GAAGA;OAAS,GAAA,IAAA;AAC7CE,MAAAA,GAAAA,EAAKA,GAAO,IAAA,CAACK,cAAQL,CAAAA,GAAAA,CAAO,GAAA;QAAE,GAAGA;OAAQ,GAAA;AAC3C,KAAA;IACAM,OAAS,EAAA;MACPC,OAASL,EAAAA;AACX,KAAA;AACAM,IAAAA,SAAAA,EAAWP,MAAQC,EAAAA,EAAAA;IACnBO,MAAQ,EAAA;MACNC,IAAMX,EAAAA,KAAAA,GAAQY,kBAAeC,CAAAA,KAAAA,GAAQD,kBAAeE,CAAAA,EAAAA;AACpDC,MAAAA,OAAAA,EAASf,QAAQA,KAAQ,GAAA;AAC3B,KAAA;IACAgB,UAAYZ,EAAAA,SAAAA;AACZa,IAAAA,QAAAA,EAAUC,YAAYC,GAAG;AAC3B,GAAA;AACF;AA5BgBvB,MAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA","file":"create-span.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SpanStatusCode, TimeInput } from \"@opentelemetry/api\";\nimport { FrameworkSpan } from \"@/instrumentation/types.js\";\nimport { isEmpty } from \"remeda\";\n\ninterface CreateSpanProps {\n id: string;\n name: string;\n target: string;\n startedAt: TimeInput;\n ctx?: any;\n data?: any;\n error?: string;\n parent?: { id: string };\n}\n\nexport function createSpan({\n target,\n name,\n data,\n error,\n ctx,\n parent,\n id,\n startedAt,\n}: CreateSpanProps): FrameworkSpan {\n return {\n name: name,\n attributes: {\n target,\n data: data && !isEmpty(data) ? { ...data } : null,\n ctx: ctx && !isEmpty(ctx) ? { ...ctx } : null,\n },\n context: {\n span_id: id,\n },\n parent_id: parent?.id,\n status: {\n code: error ? SpanStatusCode.ERROR : SpanStatusCode.OK,\n message: error ? error : \"\",\n },\n start_time: startedAt,\n end_time: performance.now(),\n };\n}\n"]}
@@ -1,34 +0,0 @@
1
- import { TimeInput } from '@opentelemetry/api';
2
- import { FrameworkSpan } from '../types.cjs';
3
-
4
- /**
5
- * Copyright 2025 IBM Corp.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
-
20
- interface CreateSpanProps {
21
- id: string;
22
- name: string;
23
- target: string;
24
- startedAt: TimeInput;
25
- ctx?: any;
26
- data?: any;
27
- error?: string;
28
- parent?: {
29
- id: string;
30
- };
31
- }
32
- declare function createSpan({ target, name, data, error, ctx, parent, id, startedAt, }: CreateSpanProps): FrameworkSpan;
33
-
34
- export { createSpan };
@@ -1,34 +0,0 @@
1
- import { TimeInput } from '@opentelemetry/api';
2
- import { FrameworkSpan } from '../types.js';
3
-
4
- /**
5
- * Copyright 2025 IBM Corp.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
-
20
- interface CreateSpanProps {
21
- id: string;
22
- name: string;
23
- target: string;
24
- startedAt: TimeInput;
25
- ctx?: any;
26
- data?: any;
27
- error?: string;
28
- parent?: {
29
- id: string;
30
- };
31
- }
32
- declare function createSpan({ target, name, data, error, ctx, parent, id, startedAt, }: CreateSpanProps): FrameworkSpan;
33
-
34
- export { createSpan };
@@ -1,34 +0,0 @@
1
- import { SpanStatusCode } from '@opentelemetry/api';
2
- import { isEmpty } from 'remeda';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- function createSpan({ target, name, data, error, ctx, parent, id, startedAt }) {
7
- return {
8
- name,
9
- attributes: {
10
- target,
11
- data: data && !isEmpty(data) ? {
12
- ...data
13
- } : null,
14
- ctx: ctx && !isEmpty(ctx) ? {
15
- ...ctx
16
- } : null
17
- },
18
- context: {
19
- span_id: id
20
- },
21
- parent_id: parent?.id,
22
- status: {
23
- code: error ? SpanStatusCode.ERROR : SpanStatusCode.OK,
24
- message: error ? error : ""
25
- },
26
- start_time: startedAt,
27
- end_time: performance.now()
28
- };
29
- }
30
- __name(createSpan, "createSpan");
31
-
32
- export { createSpan };
33
- //# sourceMappingURL=create-span.js.map
34
- //# sourceMappingURL=create-span.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["create-span.ts"],"names":["createSpan","target","name","data","error","ctx","parent","id","startedAt","attributes","isEmpty","context","span_id","parent_id","status","code","SpanStatusCode","ERROR","OK","message","start_time","end_time","performance","now"],"mappings":";;;;;AA+BO,SAASA,UAAAA,CAAW,EACzBC,MAAAA,EACAC,IACAC,EAAAA,IAAAA,EACAC,OACAC,GACAC,EAAAA,MAAAA,EACAC,EACAC,EAAAA,SAAAA,EACgB,EAAA;AAChB,EAAO,OAAA;AACLN,IAAAA,IAAAA;IACAO,UAAY,EAAA;AACVR,MAAAA,MAAAA;AACAE,MAAAA,IAAAA,EAAMA,IAAQ,IAAA,CAACO,OAAQP,CAAAA,IAAAA,CAAQ,GAAA;QAAE,GAAGA;OAAS,GAAA,IAAA;AAC7CE,MAAAA,GAAAA,EAAKA,GAAO,IAAA,CAACK,OAAQL,CAAAA,GAAAA,CAAO,GAAA;QAAE,GAAGA;OAAQ,GAAA;AAC3C,KAAA;IACAM,OAAS,EAAA;MACPC,OAASL,EAAAA;AACX,KAAA;AACAM,IAAAA,SAAAA,EAAWP,MAAQC,EAAAA,EAAAA;IACnBO,MAAQ,EAAA;MACNC,IAAMX,EAAAA,KAAAA,GAAQY,cAAeC,CAAAA,KAAAA,GAAQD,cAAeE,CAAAA,EAAAA;AACpDC,MAAAA,OAAAA,EAASf,QAAQA,KAAQ,GAAA;AAC3B,KAAA;IACAgB,UAAYZ,EAAAA,SAAAA;AACZa,IAAAA,QAAAA,EAAUC,YAAYC,GAAG;AAC3B,GAAA;AACF;AA5BgBvB,MAAAA,CAAAA,UAAAA,EAAAA,YAAAA,CAAAA","file":"create-span.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SpanStatusCode, TimeInput } from \"@opentelemetry/api\";\nimport { FrameworkSpan } from \"@/instrumentation/types.js\";\nimport { isEmpty } from \"remeda\";\n\ninterface CreateSpanProps {\n id: string;\n name: string;\n target: string;\n startedAt: TimeInput;\n ctx?: any;\n data?: any;\n error?: string;\n parent?: { id: string };\n}\n\nexport function createSpan({\n target,\n name,\n data,\n error,\n ctx,\n parent,\n id,\n startedAt,\n}: CreateSpanProps): FrameworkSpan {\n return {\n name: name,\n attributes: {\n target,\n data: data && !isEmpty(data) ? { ...data } : null,\n ctx: ctx && !isEmpty(ctx) ? { ...ctx } : null,\n },\n context: {\n span_id: id,\n },\n parent_id: parent?.id,\n status: {\n code: error ? SpanStatusCode.ERROR : SpanStatusCode.OK,\n message: error ? error : \"\",\n },\n start_time: startedAt,\n end_time: performance.now(),\n };\n}\n"]}
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- var errors_cjs = require('../../errors.cjs');
4
- var object_cjs = require('../../internals/helpers/object.cjs');
5
-
6
- var __defProp = Object.defineProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- function getErrorSafe(data) {
9
- const error = object_cjs.getProp(data, [
10
- "error"
11
- ], data);
12
- if (error instanceof errors_cjs.FrameworkError) {
13
- return errors_cjs.FrameworkError.ensure(error).explain();
14
- }
15
- }
16
- __name(getErrorSafe, "getErrorSafe");
17
-
18
- exports.getErrorSafe = getErrorSafe;
19
- //# sourceMappingURL=get-error-safe.cjs.map
20
- //# sourceMappingURL=get-error-safe.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["get-error-safe.ts"],"names":["getErrorSafe","data","error","getProp","FrameworkError","ensure","explain"],"mappings":";;;;;;;AAmBO,SAASA,aAAaC,IAAa,EAAA;AACxC,EAAMC,MAAAA,KAAAA,GAAQC,mBAAQF,IAAM,EAAA;AAAC,IAAA;KAAUA,IAAAA,CAAAA;AAEvC,EAAA,IAAIC,iBAAiBE,yBAAgB,EAAA;AACnC,IAAA,OAAOA,yBAAeC,CAAAA,MAAAA,CAAOH,KAAAA,CAAAA,CAAOI,OAAO,EAAA;AAC7C;AACF;AANgBN,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"get-error-safe.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FrameworkError } from \"@/errors.js\";\nimport { getProp } from \"@/internals/helpers/object.js\";\n\nexport function getErrorSafe(data: unknown): string | undefined {\n const error = getProp(data, [\"error\"], data);\n\n if (error instanceof FrameworkError) {\n return FrameworkError.ensure(error).explain();\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2025 IBM Corp.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- declare function getErrorSafe(data: unknown): string | undefined;
17
-
18
- export { getErrorSafe };
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2025 IBM Corp.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- declare function getErrorSafe(data: unknown): string | undefined;
17
-
18
- export { getErrorSafe };
@@ -1,18 +0,0 @@
1
- import { FrameworkError } from '../../errors.js';
2
- import { getProp } from '../../internals/helpers/object.js';
3
-
4
- var __defProp = Object.defineProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- function getErrorSafe(data) {
7
- const error = getProp(data, [
8
- "error"
9
- ], data);
10
- if (error instanceof FrameworkError) {
11
- return FrameworkError.ensure(error).explain();
12
- }
13
- }
14
- __name(getErrorSafe, "getErrorSafe");
15
-
16
- export { getErrorSafe };
17
- //# sourceMappingURL=get-error-safe.js.map
18
- //# sourceMappingURL=get-error-safe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["get-error-safe.ts"],"names":["getErrorSafe","data","error","getProp","FrameworkError","ensure","explain"],"mappings":";;;;;AAmBO,SAASA,aAAaC,IAAa,EAAA;AACxC,EAAMC,MAAAA,KAAAA,GAAQC,QAAQF,IAAM,EAAA;AAAC,IAAA;KAAUA,IAAAA,CAAAA;AAEvC,EAAA,IAAIC,iBAAiBE,cAAgB,EAAA;AACnC,IAAA,OAAOA,cAAeC,CAAAA,MAAAA,CAAOH,KAAAA,CAAAA,CAAOI,OAAO,EAAA;AAC7C;AACF;AANgBN,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"get-error-safe.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FrameworkError } from \"@/errors.js\";\nimport { getProp } from \"@/internals/helpers/object.js\";\n\nexport function getErrorSafe(data: unknown): string | undefined {\n const error = getProp(data, [\"error\"], data);\n\n if (error instanceof FrameworkError) {\n return FrameworkError.ensure(error).explain();\n }\n}\n"]}
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var serializable_cjs = require('../../internals/serializable.cjs');
4
- var logger_cjs = require('../logger.cjs');
5
- var object_cjs = require('../../internals/helpers/object.cjs');
6
-
7
- var __defProp = Object.defineProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- function getSerializedObjectSafe(dataObject) {
10
- const data = object_cjs.getProp(dataObject, [
11
- "data"
12
- ], dataObject);
13
- if (data instanceof serializable_cjs.Serializable) {
14
- try {
15
- return data.createSnapshot();
16
- } catch (e) {
17
- logger_cjs.instrumentationLogger.warn(e, "Invalid createSnapshot method in the Serializable class");
18
- return null;
19
- }
20
- }
21
- return data;
22
- }
23
- __name(getSerializedObjectSafe, "getSerializedObjectSafe");
24
-
25
- exports.getSerializedObjectSafe = getSerializedObjectSafe;
26
- //# sourceMappingURL=get-serialized-object-safe.cjs.map
27
- //# sourceMappingURL=get-serialized-object-safe.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["get-serialized-object-safe.ts"],"names":["getSerializedObjectSafe","dataObject","data","getProp","Serializable","createSnapshot","e","instrumentationLogger","warn"],"mappings":";;;;;;;;AAoBO,SAASA,wBAAwBC,UAAe,EAAA;AACrD,EAAMC,MAAAA,IAAAA,GAAOC,mBAAQF,UAAY,EAAA;AAAC,IAAA;KAASA,UAAAA,CAAAA;AAE3C,EAAA,IAAIC,gBAAgBE,6BAAc,EAAA;AAChC,IAAI,IAAA;AACF,MAAA,OAAOF,KAAKG,cAAc,EAAA;AAC5B,KAAA,CAAA,OAASC,CAAG,EAAA;AACVC,MAAsBC,gCAAAA,CAAAA,IAAAA,CAAKF,GAAG,yDAAA,CAAA;AAC9B,MAAO,OAAA,IAAA;AACT;AACF;AACA,EAAOJ,OAAAA,IAAAA;AACT;AAZgBF,MAAAA,CAAAA,uBAAAA,EAAAA,yBAAAA,CAAAA","file":"get-serialized-object-safe.cjs","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Serializable } from \"@/internals/serializable.js\";\nimport { instrumentationLogger } from \"@/instrumentation/logger.js\";\nimport { getProp } from \"@/internals/helpers/object.js\";\n\nexport function getSerializedObjectSafe(dataObject: any) {\n const data = getProp(dataObject, [\"data\"], dataObject);\n\n if (data instanceof Serializable) {\n try {\n return data.createSnapshot();\n } catch (e) {\n instrumentationLogger.warn(e, \"Invalid createSnapshot method in the Serializable class\");\n return null;\n }\n }\n return data;\n}\n"]}
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2025 IBM Corp.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- declare function getSerializedObjectSafe(dataObject: any): any;
17
-
18
- export { getSerializedObjectSafe };
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright 2025 IBM Corp.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- declare function getSerializedObjectSafe(dataObject: any): any;
17
-
18
- export { getSerializedObjectSafe };
@@ -1,25 +0,0 @@
1
- import { Serializable } from '../../internals/serializable.js';
2
- import { instrumentationLogger } from '../logger.js';
3
- import { getProp } from '../../internals/helpers/object.js';
4
-
5
- var __defProp = Object.defineProperty;
6
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
- function getSerializedObjectSafe(dataObject) {
8
- const data = getProp(dataObject, [
9
- "data"
10
- ], dataObject);
11
- if (data instanceof Serializable) {
12
- try {
13
- return data.createSnapshot();
14
- } catch (e) {
15
- instrumentationLogger.warn(e, "Invalid createSnapshot method in the Serializable class");
16
- return null;
17
- }
18
- }
19
- return data;
20
- }
21
- __name(getSerializedObjectSafe, "getSerializedObjectSafe");
22
-
23
- export { getSerializedObjectSafe };
24
- //# sourceMappingURL=get-serialized-object-safe.js.map
25
- //# sourceMappingURL=get-serialized-object-safe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["get-serialized-object-safe.ts"],"names":["getSerializedObjectSafe","dataObject","data","getProp","Serializable","createSnapshot","e","instrumentationLogger","warn"],"mappings":";;;;;;AAoBO,SAASA,wBAAwBC,UAAe,EAAA;AACrD,EAAMC,MAAAA,IAAAA,GAAOC,QAAQF,UAAY,EAAA;AAAC,IAAA;KAASA,UAAAA,CAAAA;AAE3C,EAAA,IAAIC,gBAAgBE,YAAc,EAAA;AAChC,IAAI,IAAA;AACF,MAAA,OAAOF,KAAKG,cAAc,EAAA;AAC5B,KAAA,CAAA,OAASC,CAAG,EAAA;AACVC,MAAsBC,qBAAAA,CAAAA,IAAAA,CAAKF,GAAG,yDAAA,CAAA;AAC9B,MAAO,OAAA,IAAA;AACT;AACF;AACA,EAAOJ,OAAAA,IAAAA;AACT;AAZgBF,MAAAA,CAAAA,uBAAAA,EAAAA,yBAAAA,CAAAA","file":"get-serialized-object-safe.js","sourcesContent":["/**\n * Copyright 2025 IBM Corp.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Serializable } from \"@/internals/serializable.js\";\nimport { instrumentationLogger } from \"@/instrumentation/logger.js\";\nimport { getProp } from \"@/internals/helpers/object.js\";\n\nexport function getSerializedObjectSafe(dataObject: any) {\n const data = getProp(dataObject, [\"data\"], dataObject);\n\n if (data instanceof Serializable) {\n try {\n return data.createSnapshot();\n } catch (e) {\n instrumentationLogger.warn(e, \"Invalid createSnapshot method in the Serializable class\");\n return null;\n }\n }\n return data;\n}\n"]}