@microsoft/opentelemetry 0.1.0-alpha.2 → 0.1.0-alpha.4

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 (347) hide show
  1. package/README.md +69 -4
  2. package/dist/commonjs/a365/configuration/A365Configuration.d.ts +42 -0
  3. package/dist/commonjs/a365/configuration/A365Configuration.d.ts.map +1 -0
  4. package/dist/commonjs/a365/configuration/A365Configuration.js +162 -0
  5. package/dist/commonjs/a365/configuration/A365Configuration.js.map +1 -0
  6. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.d.ts +53 -0
  7. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.d.ts.map +1 -0
  8. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.js +5 -0
  9. package/dist/commonjs/a365/configuration/A365ConfigurationOptions.js.map +1 -0
  10. package/dist/commonjs/a365/configuration/index.d.ts +3 -0
  11. package/dist/commonjs/a365/configuration/index.d.ts.map +1 -0
  12. package/dist/commonjs/a365/configuration/index.js +9 -0
  13. package/dist/commonjs/a365/configuration/index.js.map +1 -0
  14. package/dist/commonjs/a365/constants.d.ts +93 -0
  15. package/dist/commonjs/a365/constants.d.ts.map +1 -0
  16. package/dist/commonjs/a365/constants.js +120 -0
  17. package/dist/commonjs/a365/constants.js.map +1 -0
  18. package/dist/commonjs/a365/context/tokenContext.d.ts +25 -0
  19. package/dist/commonjs/a365/context/tokenContext.d.ts.map +1 -0
  20. package/dist/commonjs/a365/context/tokenContext.js +67 -0
  21. package/dist/commonjs/a365/context/tokenContext.js.map +1 -0
  22. package/dist/commonjs/a365/context.d.ts +31 -0
  23. package/dist/commonjs/a365/context.d.ts.map +1 -0
  24. package/dist/commonjs/a365/context.js +109 -0
  25. package/dist/commonjs/a365/context.js.map +1 -0
  26. package/dist/commonjs/a365/contracts.d.ts +250 -0
  27. package/dist/commonjs/a365/contracts.d.ts.map +1 -0
  28. package/dist/commonjs/a365/contracts.js +52 -0
  29. package/dist/commonjs/a365/contracts.js.map +1 -0
  30. package/dist/commonjs/a365/exporter/Agent365Exporter.d.ts +25 -0
  31. package/dist/commonjs/a365/exporter/Agent365Exporter.d.ts.map +1 -0
  32. package/dist/commonjs/a365/exporter/Agent365Exporter.js +219 -0
  33. package/dist/commonjs/a365/exporter/Agent365Exporter.js.map +1 -0
  34. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.d.ts +43 -0
  35. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.d.ts.map +1 -0
  36. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.js +30 -0
  37. package/dist/commonjs/a365/exporter/Agent365ExporterOptions.js.map +1 -0
  38. package/dist/commonjs/a365/exporter/ExporterEventNames.d.ts +9 -0
  39. package/dist/commonjs/a365/exporter/ExporterEventNames.d.ts.map +1 -0
  40. package/dist/commonjs/a365/exporter/ExporterEventNames.js +15 -0
  41. package/dist/commonjs/a365/exporter/ExporterEventNames.js.map +1 -0
  42. package/dist/commonjs/a365/exporter/index.d.ts +6 -0
  43. package/dist/commonjs/a365/exporter/index.d.ts.map +1 -0
  44. package/dist/commonjs/a365/exporter/index.js +15 -0
  45. package/dist/commonjs/a365/exporter/index.js.map +1 -0
  46. package/dist/commonjs/a365/exporter/utils.d.ts +41 -0
  47. package/dist/commonjs/a365/exporter/utils.d.ts.map +1 -0
  48. package/dist/commonjs/a365/exporter/utils.js +410 -0
  49. package/dist/commonjs/a365/exporter/utils.js.map +1 -0
  50. package/dist/commonjs/a365/hosting/baggageBuilderUtils.d.ts +22 -0
  51. package/dist/commonjs/a365/hosting/baggageBuilderUtils.d.ts.map +1 -0
  52. package/dist/commonjs/a365/hosting/baggageBuilderUtils.js +47 -0
  53. package/dist/commonjs/a365/hosting/baggageBuilderUtils.js.map +1 -0
  54. package/dist/commonjs/a365/hosting/baggageMiddleware.d.ts +9 -0
  55. package/dist/commonjs/a365/hosting/baggageMiddleware.d.ts.map +1 -0
  56. package/dist/commonjs/a365/hosting/baggageMiddleware.js +38 -0
  57. package/dist/commonjs/a365/hosting/baggageMiddleware.js.map +1 -0
  58. package/dist/commonjs/a365/hosting/index.d.ts +9 -0
  59. package/dist/commonjs/a365/hosting/index.d.ts.map +1 -0
  60. package/dist/commonjs/a365/hosting/index.js +25 -0
  61. package/dist/commonjs/a365/hosting/index.js.map +1 -0
  62. package/dist/commonjs/a365/hosting/observabilityHostingManager.d.ts +30 -0
  63. package/dist/commonjs/a365/hosting/observabilityHostingManager.d.ts.map +1 -0
  64. package/dist/commonjs/a365/hosting/observabilityHostingManager.js +49 -0
  65. package/dist/commonjs/a365/hosting/observabilityHostingManager.js.map +1 -0
  66. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.d.ts +24 -0
  67. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.d.ts.map +1 -0
  68. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.js +82 -0
  69. package/dist/commonjs/a365/hosting/outputLoggingMiddleware.js.map +1 -0
  70. package/dist/commonjs/a365/hosting/scopeUtils.d.ts +56 -0
  71. package/dist/commonjs/a365/hosting/scopeUtils.d.ts.map +1 -0
  72. package/dist/commonjs/a365/hosting/scopeUtils.js +161 -0
  73. package/dist/commonjs/a365/hosting/scopeUtils.js.map +1 -0
  74. package/dist/commonjs/a365/hosting/turnContextUtils.d.ts +32 -0
  75. package/dist/commonjs/a365/hosting/turnContextUtils.d.ts.map +1 -0
  76. package/dist/commonjs/a365/hosting/turnContextUtils.js +141 -0
  77. package/dist/commonjs/a365/hosting/turnContextUtils.js.map +1 -0
  78. package/dist/commonjs/a365/hosting/types.d.ts +52 -0
  79. package/dist/commonjs/a365/hosting/types.d.ts.map +1 -0
  80. package/dist/commonjs/a365/hosting/types.js +5 -0
  81. package/dist/commonjs/a365/hosting/types.js.map +1 -0
  82. package/dist/commonjs/a365/index.d.ts +18 -0
  83. package/dist/commonjs/a365/index.d.ts.map +1 -0
  84. package/dist/commonjs/a365/index.js +69 -0
  85. package/dist/commonjs/a365/index.js.map +1 -0
  86. package/dist/commonjs/a365/message-utils.d.ts +42 -0
  87. package/dist/commonjs/a365/message-utils.d.ts.map +1 -0
  88. package/dist/commonjs/a365/message-utils.js +116 -0
  89. package/dist/commonjs/a365/message-utils.js.map +1 -0
  90. package/dist/commonjs/a365/middleware/BaggageBuilder.d.ts +112 -0
  91. package/dist/commonjs/a365/middleware/BaggageBuilder.d.ts.map +1 -0
  92. package/dist/commonjs/a365/middleware/BaggageBuilder.js +248 -0
  93. package/dist/commonjs/a365/middleware/BaggageBuilder.js.map +1 -0
  94. package/dist/commonjs/a365/middleware/index.d.ts +2 -0
  95. package/dist/commonjs/a365/middleware/index.d.ts.map +1 -0
  96. package/dist/commonjs/a365/middleware/index.js +9 -0
  97. package/dist/commonjs/a365/middleware/index.js.map +1 -0
  98. package/dist/commonjs/a365/processors/A365SpanProcessor.d.ts +32 -0
  99. package/dist/commonjs/a365/processors/A365SpanProcessor.d.ts.map +1 -0
  100. package/dist/commonjs/a365/processors/A365SpanProcessor.js +104 -0
  101. package/dist/commonjs/a365/processors/A365SpanProcessor.js.map +1 -0
  102. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.d.ts +44 -0
  103. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.d.ts.map +1 -0
  104. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.js +260 -0
  105. package/dist/commonjs/a365/processors/PerRequestSpanProcessor.js.map +1 -0
  106. package/dist/commonjs/a365/processors/index.d.ts +5 -0
  107. package/dist/commonjs/a365/processors/index.d.ts.map +1 -0
  108. package/dist/commonjs/a365/processors/index.js +13 -0
  109. package/dist/commonjs/a365/processors/index.js.map +1 -0
  110. package/dist/commonjs/a365/processors/util.d.ts +10 -0
  111. package/dist/commonjs/a365/processors/util.d.ts.map +1 -0
  112. package/dist/commonjs/a365/processors/util.js +56 -0
  113. package/dist/commonjs/a365/processors/util.js.map +1 -0
  114. package/dist/commonjs/a365/scopes/ExecuteToolScope.d.ts +24 -0
  115. package/dist/commonjs/a365/scopes/ExecuteToolScope.d.ts.map +1 -0
  116. package/dist/commonjs/a365/scopes/ExecuteToolScope.js +60 -0
  117. package/dist/commonjs/a365/scopes/ExecuteToolScope.js.map +1 -0
  118. package/dist/commonjs/a365/scopes/InferenceScope.d.ts +29 -0
  119. package/dist/commonjs/a365/scopes/InferenceScope.d.ts.map +1 -0
  120. package/dist/commonjs/a365/scopes/InferenceScope.js +75 -0
  121. package/dist/commonjs/a365/scopes/InferenceScope.js.map +1 -0
  122. package/dist/commonjs/a365/scopes/InvokeAgentScope.d.ts +25 -0
  123. package/dist/commonjs/a365/scopes/InvokeAgentScope.d.ts.map +1 -0
  124. package/dist/commonjs/a365/scopes/InvokeAgentScope.js +84 -0
  125. package/dist/commonjs/a365/scopes/InvokeAgentScope.js.map +1 -0
  126. package/dist/commonjs/a365/scopes/OpenTelemetryScope.d.ts +69 -0
  127. package/dist/commonjs/a365/scopes/OpenTelemetryScope.d.ts.map +1 -0
  128. package/dist/commonjs/a365/scopes/OpenTelemetryScope.js +211 -0
  129. package/dist/commonjs/a365/scopes/OpenTelemetryScope.js.map +1 -0
  130. package/dist/commonjs/a365/scopes/OutputScope.d.ts +26 -0
  131. package/dist/commonjs/a365/scopes/OutputScope.d.ts.map +1 -0
  132. package/dist/commonjs/a365/scopes/OutputScope.js +73 -0
  133. package/dist/commonjs/a365/scopes/OutputScope.js.map +1 -0
  134. package/dist/commonjs/a365/scopes/index.d.ts +6 -0
  135. package/dist/commonjs/a365/scopes/index.d.ts.map +1 -0
  136. package/dist/commonjs/a365/scopes/index.js +16 -0
  137. package/dist/commonjs/a365/scopes/index.js.map +1 -0
  138. package/dist/commonjs/a365/utils/utils.d.ts +6 -0
  139. package/dist/commonjs/a365/utils/utils.d.ts.map +1 -0
  140. package/dist/commonjs/a365/utils/utils.js +14 -0
  141. package/dist/commonjs/a365/utils/utils.js.map +1 -0
  142. package/dist/commonjs/azureMonitor/index.d.ts +14 -0
  143. package/dist/commonjs/azureMonitor/index.d.ts.map +1 -1
  144. package/dist/commonjs/azureMonitor/index.js +29 -0
  145. package/dist/commonjs/azureMonitor/index.js.map +1 -1
  146. package/dist/commonjs/azureMonitor/metrics/handler.js +2 -2
  147. package/dist/commonjs/azureMonitor/metrics/handler.js.map +1 -1
  148. package/dist/commonjs/azureMonitor/metrics/quickpulse/types.d.ts +1 -1
  149. package/dist/commonjs/azureMonitor/traces/handler.d.ts +0 -3
  150. package/dist/commonjs/azureMonitor/traces/handler.d.ts.map +1 -1
  151. package/dist/commonjs/azureMonitor/traces/handler.js +8 -19
  152. package/dist/commonjs/azureMonitor/traces/handler.js.map +1 -1
  153. package/dist/commonjs/distro/distro.d.ts +3 -1
  154. package/dist/commonjs/distro/distro.d.ts.map +1 -1
  155. package/dist/commonjs/distro/distro.js +88 -92
  156. package/dist/commonjs/distro/distro.js.map +1 -1
  157. package/dist/commonjs/distro/instrumentations.d.ts +31 -0
  158. package/dist/commonjs/distro/instrumentations.d.ts.map +1 -0
  159. package/dist/commonjs/distro/instrumentations.js +131 -0
  160. package/dist/commonjs/distro/instrumentations.js.map +1 -0
  161. package/dist/commonjs/distro/types.d.ts +2 -1
  162. package/dist/commonjs/distro/types.d.ts.map +1 -1
  163. package/dist/commonjs/index.d.ts +8 -12
  164. package/dist/commonjs/index.d.ts.map +1 -1
  165. package/dist/commonjs/index.js +48 -20
  166. package/dist/commonjs/index.js.map +1 -1
  167. package/dist/commonjs/package.json +1 -0
  168. package/dist/commonjs/shared/jsonConfig.d.ts +2 -1
  169. package/dist/commonjs/shared/jsonConfig.d.ts.map +1 -1
  170. package/dist/commonjs/shared/module.js +15 -11
  171. package/dist/commonjs/shared/module.js.map +1 -1
  172. package/dist/commonjs/types.d.ts +8 -32
  173. package/dist/commonjs/types.d.ts.map +1 -1
  174. package/dist/commonjs/types.js +1 -1
  175. package/dist/commonjs/types.js.map +1 -1
  176. package/dist/esm/a365/configuration/A365Configuration.d.ts +42 -0
  177. package/dist/esm/a365/configuration/A365Configuration.d.ts.map +1 -0
  178. package/dist/esm/a365/configuration/A365Configuration.js +158 -0
  179. package/dist/esm/a365/configuration/A365Configuration.js.map +1 -0
  180. package/dist/esm/a365/configuration/A365ConfigurationOptions.d.ts +53 -0
  181. package/dist/esm/a365/configuration/A365ConfigurationOptions.d.ts.map +1 -0
  182. package/dist/esm/a365/configuration/A365ConfigurationOptions.js +4 -0
  183. package/dist/esm/a365/configuration/A365ConfigurationOptions.js.map +1 -0
  184. package/dist/esm/a365/configuration/index.d.ts +3 -0
  185. package/dist/esm/a365/configuration/index.d.ts.map +1 -0
  186. package/dist/esm/a365/configuration/index.js +4 -0
  187. package/dist/esm/a365/configuration/index.js.map +1 -0
  188. package/dist/esm/a365/constants.d.ts +93 -0
  189. package/dist/esm/a365/constants.d.ts.map +1 -0
  190. package/dist/esm/a365/constants.js +116 -0
  191. package/dist/esm/a365/constants.js.map +1 -0
  192. package/dist/esm/a365/context/tokenContext.d.ts +25 -0
  193. package/dist/esm/a365/context/tokenContext.d.ts.map +1 -0
  194. package/dist/esm/a365/context/tokenContext.js +62 -0
  195. package/dist/esm/a365/context/tokenContext.js.map +1 -0
  196. package/dist/esm/a365/context.d.ts +31 -0
  197. package/dist/esm/a365/context.d.ts.map +1 -0
  198. package/dist/esm/a365/context.js +101 -0
  199. package/dist/esm/a365/context.js.map +1 -0
  200. package/dist/esm/a365/contracts.d.ts +250 -0
  201. package/dist/esm/a365/contracts.d.ts.map +1 -0
  202. package/dist/esm/a365/contracts.js +49 -0
  203. package/dist/esm/a365/contracts.js.map +1 -0
  204. package/dist/esm/a365/exporter/Agent365Exporter.d.ts +25 -0
  205. package/dist/esm/a365/exporter/Agent365Exporter.d.ts.map +1 -0
  206. package/dist/esm/a365/exporter/Agent365Exporter.js +215 -0
  207. package/dist/esm/a365/exporter/Agent365Exporter.js.map +1 -0
  208. package/dist/esm/a365/exporter/Agent365ExporterOptions.d.ts +43 -0
  209. package/dist/esm/a365/exporter/Agent365ExporterOptions.d.ts.map +1 -0
  210. package/dist/esm/a365/exporter/Agent365ExporterOptions.js +26 -0
  211. package/dist/esm/a365/exporter/Agent365ExporterOptions.js.map +1 -0
  212. package/dist/esm/a365/exporter/ExporterEventNames.d.ts +9 -0
  213. package/dist/esm/a365/exporter/ExporterEventNames.d.ts.map +1 -0
  214. package/dist/esm/a365/exporter/ExporterEventNames.js +12 -0
  215. package/dist/esm/a365/exporter/ExporterEventNames.js.map +1 -0
  216. package/dist/esm/a365/exporter/index.d.ts +6 -0
  217. package/dist/esm/a365/exporter/index.d.ts.map +1 -0
  218. package/dist/esm/a365/exporter/index.js +7 -0
  219. package/dist/esm/a365/exporter/index.js.map +1 -0
  220. package/dist/esm/a365/exporter/utils.d.ts +41 -0
  221. package/dist/esm/a365/exporter/utils.d.ts.map +1 -0
  222. package/dist/esm/a365/exporter/utils.js +398 -0
  223. package/dist/esm/a365/exporter/utils.js.map +1 -0
  224. package/dist/esm/a365/hosting/baggageBuilderUtils.d.ts +22 -0
  225. package/dist/esm/a365/hosting/baggageBuilderUtils.d.ts.map +1 -0
  226. package/dist/esm/a365/hosting/baggageBuilderUtils.js +43 -0
  227. package/dist/esm/a365/hosting/baggageBuilderUtils.js.map +1 -0
  228. package/dist/esm/a365/hosting/baggageMiddleware.d.ts +9 -0
  229. package/dist/esm/a365/hosting/baggageMiddleware.d.ts.map +1 -0
  230. package/dist/esm/a365/hosting/baggageMiddleware.js +34 -0
  231. package/dist/esm/a365/hosting/baggageMiddleware.js.map +1 -0
  232. package/dist/esm/a365/hosting/index.d.ts +9 -0
  233. package/dist/esm/a365/hosting/index.d.ts.map +1 -0
  234. package/dist/esm/a365/hosting/index.js +9 -0
  235. package/dist/esm/a365/hosting/index.js.map +1 -0
  236. package/dist/esm/a365/hosting/observabilityHostingManager.d.ts +30 -0
  237. package/dist/esm/a365/hosting/observabilityHostingManager.d.ts.map +1 -0
  238. package/dist/esm/a365/hosting/observabilityHostingManager.js +45 -0
  239. package/dist/esm/a365/hosting/observabilityHostingManager.js.map +1 -0
  240. package/dist/esm/a365/hosting/outputLoggingMiddleware.d.ts +24 -0
  241. package/dist/esm/a365/hosting/outputLoggingMiddleware.d.ts.map +1 -0
  242. package/dist/esm/a365/hosting/outputLoggingMiddleware.js +78 -0
  243. package/dist/esm/a365/hosting/outputLoggingMiddleware.js.map +1 -0
  244. package/dist/esm/a365/hosting/scopeUtils.d.ts +56 -0
  245. package/dist/esm/a365/hosting/scopeUtils.d.ts.map +1 -0
  246. package/dist/esm/a365/hosting/scopeUtils.js +157 -0
  247. package/dist/esm/a365/hosting/scopeUtils.js.map +1 -0
  248. package/dist/esm/a365/hosting/turnContextUtils.d.ts +32 -0
  249. package/dist/esm/a365/hosting/turnContextUtils.d.ts.map +1 -0
  250. package/dist/esm/a365/hosting/turnContextUtils.js +133 -0
  251. package/dist/esm/a365/hosting/turnContextUtils.js.map +1 -0
  252. package/dist/esm/a365/hosting/types.d.ts +52 -0
  253. package/dist/esm/a365/hosting/types.d.ts.map +1 -0
  254. package/dist/esm/a365/hosting/types.js +4 -0
  255. package/dist/esm/a365/hosting/types.js.map +1 -0
  256. package/dist/esm/a365/index.d.ts +18 -0
  257. package/dist/esm/a365/index.d.ts.map +1 -0
  258. package/dist/esm/a365/index.js +22 -0
  259. package/dist/esm/a365/index.js.map +1 -0
  260. package/dist/esm/a365/message-utils.d.ts +42 -0
  261. package/dist/esm/a365/message-utils.d.ts.map +1 -0
  262. package/dist/esm/a365/message-utils.js +107 -0
  263. package/dist/esm/a365/message-utils.js.map +1 -0
  264. package/dist/esm/a365/middleware/BaggageBuilder.d.ts +112 -0
  265. package/dist/esm/a365/middleware/BaggageBuilder.d.ts.map +1 -0
  266. package/dist/esm/a365/middleware/BaggageBuilder.js +243 -0
  267. package/dist/esm/a365/middleware/BaggageBuilder.js.map +1 -0
  268. package/dist/esm/a365/middleware/index.d.ts +2 -0
  269. package/dist/esm/a365/middleware/index.d.ts.map +1 -0
  270. package/dist/esm/a365/middleware/index.js +4 -0
  271. package/dist/esm/a365/middleware/index.js.map +1 -0
  272. package/dist/esm/a365/processors/A365SpanProcessor.d.ts +32 -0
  273. package/dist/esm/a365/processors/A365SpanProcessor.d.ts.map +1 -0
  274. package/dist/esm/a365/processors/A365SpanProcessor.js +100 -0
  275. package/dist/esm/a365/processors/A365SpanProcessor.js.map +1 -0
  276. package/dist/esm/a365/processors/PerRequestSpanProcessor.d.ts +44 -0
  277. package/dist/esm/a365/processors/PerRequestSpanProcessor.d.ts.map +1 -0
  278. package/dist/esm/a365/processors/PerRequestSpanProcessor.js +256 -0
  279. package/dist/esm/a365/processors/PerRequestSpanProcessor.js.map +1 -0
  280. package/dist/esm/a365/processors/index.d.ts +5 -0
  281. package/dist/esm/a365/processors/index.d.ts.map +1 -0
  282. package/dist/esm/a365/processors/index.js +6 -0
  283. package/dist/esm/a365/processors/index.js.map +1 -0
  284. package/dist/esm/a365/processors/util.d.ts +10 -0
  285. package/dist/esm/a365/processors/util.d.ts.map +1 -0
  286. package/dist/esm/a365/processors/util.js +53 -0
  287. package/dist/esm/a365/processors/util.js.map +1 -0
  288. package/dist/esm/a365/scopes/ExecuteToolScope.d.ts +24 -0
  289. package/dist/esm/a365/scopes/ExecuteToolScope.d.ts.map +1 -0
  290. package/dist/esm/a365/scopes/ExecuteToolScope.js +56 -0
  291. package/dist/esm/a365/scopes/ExecuteToolScope.js.map +1 -0
  292. package/dist/esm/a365/scopes/InferenceScope.d.ts +29 -0
  293. package/dist/esm/a365/scopes/InferenceScope.d.ts.map +1 -0
  294. package/dist/esm/a365/scopes/InferenceScope.js +71 -0
  295. package/dist/esm/a365/scopes/InferenceScope.js.map +1 -0
  296. package/dist/esm/a365/scopes/InvokeAgentScope.d.ts +25 -0
  297. package/dist/esm/a365/scopes/InvokeAgentScope.d.ts.map +1 -0
  298. package/dist/esm/a365/scopes/InvokeAgentScope.js +80 -0
  299. package/dist/esm/a365/scopes/InvokeAgentScope.js.map +1 -0
  300. package/dist/esm/a365/scopes/OpenTelemetryScope.d.ts +69 -0
  301. package/dist/esm/a365/scopes/OpenTelemetryScope.d.ts.map +1 -0
  302. package/dist/esm/a365/scopes/OpenTelemetryScope.js +207 -0
  303. package/dist/esm/a365/scopes/OpenTelemetryScope.js.map +1 -0
  304. package/dist/esm/a365/scopes/OutputScope.d.ts +26 -0
  305. package/dist/esm/a365/scopes/OutputScope.d.ts.map +1 -0
  306. package/dist/esm/a365/scopes/OutputScope.js +69 -0
  307. package/dist/esm/a365/scopes/OutputScope.js.map +1 -0
  308. package/dist/esm/a365/scopes/index.d.ts +6 -0
  309. package/dist/esm/a365/scopes/index.d.ts.map +1 -0
  310. package/dist/esm/a365/scopes/index.js +8 -0
  311. package/dist/esm/a365/scopes/index.js.map +1 -0
  312. package/dist/esm/a365/utils/utils.d.ts +6 -0
  313. package/dist/esm/a365/utils/utils.d.ts.map +1 -0
  314. package/dist/esm/a365/utils/utils.js +11 -0
  315. package/dist/esm/a365/utils/utils.js.map +1 -0
  316. package/dist/esm/azureMonitor/index.d.ts +14 -0
  317. package/dist/esm/azureMonitor/index.d.ts.map +1 -1
  318. package/dist/esm/azureMonitor/index.js +27 -0
  319. package/dist/esm/azureMonitor/index.js.map +1 -1
  320. package/dist/esm/azureMonitor/metrics/handler.js +2 -2
  321. package/dist/esm/azureMonitor/metrics/handler.js.map +1 -1
  322. package/dist/esm/azureMonitor/metrics/quickpulse/types.d.ts +1 -1
  323. package/dist/esm/azureMonitor/traces/handler.d.ts +0 -3
  324. package/dist/esm/azureMonitor/traces/handler.d.ts.map +1 -1
  325. package/dist/esm/azureMonitor/traces/handler.js +6 -19
  326. package/dist/esm/azureMonitor/traces/handler.js.map +1 -1
  327. package/dist/esm/distro/distro.d.ts +3 -1
  328. package/dist/esm/distro/distro.d.ts.map +1 -1
  329. package/dist/esm/distro/distro.js +89 -93
  330. package/dist/esm/distro/distro.js.map +1 -1
  331. package/dist/esm/distro/instrumentations.d.ts +31 -0
  332. package/dist/esm/distro/instrumentations.d.ts.map +1 -0
  333. package/dist/esm/distro/instrumentations.js +126 -0
  334. package/dist/esm/distro/instrumentations.js.map +1 -0
  335. package/dist/esm/distro/types.d.ts +2 -1
  336. package/dist/esm/distro/types.d.ts.map +1 -1
  337. package/dist/esm/index.d.ts +8 -12
  338. package/dist/esm/index.d.ts.map +1 -1
  339. package/dist/esm/index.js +6 -17
  340. package/dist/esm/index.js.map +1 -1
  341. package/dist/esm/shared/jsonConfig.d.ts +2 -1
  342. package/dist/esm/shared/jsonConfig.d.ts.map +1 -1
  343. package/dist/esm/types.d.ts +8 -32
  344. package/dist/esm/types.d.ts.map +1 -1
  345. package/dist/esm/types.js +1 -1
  346. package/dist/esm/types.js.map +1 -1
  347. package/package.json +7 -8
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/a365/hosting/types.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC"}
@@ -0,0 +1,18 @@
1
+ export { A365Configuration, A365_ENV_VARS } from "./configuration/index.js";
2
+ export type { A365Options, ClusterCategory, A365BaggageOptions, A365HostingOptions, } from "./configuration/index.js";
3
+ export { Agent365Exporter } from "./exporter/index.js";
4
+ export type { Agent365ExporterOptions, TokenResolver } from "./exporter/index.js";
5
+ export { ResolvedExporterOptions } from "./exporter/index.js";
6
+ export { OpenTelemetryScope, InvokeAgentScope, ExecuteToolScope, InferenceScope, OutputScope, } from "./scopes/index.js";
7
+ export { OpenTelemetryConstants } from "./constants.js";
8
+ export { MessageRole, FinishReason, Modality, InvocationRole, InferenceOperationType, A365_MESSAGE_SCHEMA_VERSION, } from "./contracts.js";
9
+ export type { ChatMessage, InputMessages, OutputMessage, OutputMessages, InputMessagesParam, OutputMessagesParam, ResponseMessagesParam, MessagePart, TextPart, ToolCallRequestPart, ToolCallResponsePart, ReasoningPart, AgentDetails, UserDetails, CallerDetails, Request, Channel, ServiceEndpoint, InvokeAgentScopeDetails, ToolCallDetails, InferenceDetails, InferenceResponse, OutputResponse, SpanDetails, ParentSpanRef, ParentContext, } from "./contracts.js";
10
+ export { isParentSpanRef, createContextWithParentSpanRef, runWithParentSpanRef, injectContextToHeaders, extractContextFromHeaders, runWithExtractedTraceContext, } from "./context.js";
11
+ export type { HeadersCarrier } from "./context.js";
12
+ export { BaggageBuilder, BaggageScope } from "./middleware/index.js";
13
+ export { A365SpanProcessor, PerRequestSpanProcessor, GENERIC_ATTRIBUTES, INVOKE_AGENT_ATTRIBUTES, } from "./processors/index.js";
14
+ export type { PerRequestSpanProcessorOptions } from "./processors/index.js";
15
+ export { runWithExportToken, updateExportToken, getExportToken } from "./context/tokenContext.js";
16
+ export { BaggageBuilderUtils, ScopeUtils, getCallerBaggagePairs, getTargetAgentBaggagePairs, getTenantIdPair, getChannelBaggagePairs, getConversationIdAndItemLinkPairs, resolveEmbodiedAgentIds, BaggageMiddleware, OutputLoggingMiddleware, A365_PARENT_SPAN_KEY, A365_AUTH_TOKEN_KEY, ObservabilityHostingManager, } from "./hosting/index.js";
17
+ export type { ObservabilityHostingOptions, TurnContextLike, ActivityLike, MiddlewareLike, SendActivitiesHandler, } from "./hosting/index.js";
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/a365/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC5E,YAAY,EACV,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,YAAY,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,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vB,iBAAiB,EACjB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,2BAA2B,EAC3B,eAAe,EACf,YAAY,EACZ,cAAc,EACd,qBAAqB,GACtB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.ObservabilityHostingManager = exports.A365_AUTH_TOKEN_KEY = exports.A365_PARENT_SPAN_KEY = exports.OutputLoggingMiddleware = exports.BaggageMiddleware = exports.resolveEmbodiedAgentIds = exports.getConversationIdAndItemLinkPairs = exports.getChannelBaggagePairs = exports.getTenantIdPair = exports.getTargetAgentBaggagePairs = exports.getCallerBaggagePairs = exports.ScopeUtils = exports.BaggageBuilderUtils = exports.getExportToken = exports.updateExportToken = exports.runWithExportToken = exports.INVOKE_AGENT_ATTRIBUTES = exports.GENERIC_ATTRIBUTES = exports.PerRequestSpanProcessor = exports.A365SpanProcessor = exports.BaggageScope = exports.BaggageBuilder = exports.runWithExtractedTraceContext = exports.extractContextFromHeaders = exports.injectContextToHeaders = exports.runWithParentSpanRef = exports.createContextWithParentSpanRef = exports.isParentSpanRef = exports.A365_MESSAGE_SCHEMA_VERSION = exports.InferenceOperationType = exports.InvocationRole = exports.Modality = exports.FinishReason = exports.MessageRole = exports.OpenTelemetryConstants = exports.OutputScope = exports.InferenceScope = exports.ExecuteToolScope = exports.InvokeAgentScope = exports.OpenTelemetryScope = exports.ResolvedExporterOptions = exports.Agent365Exporter = exports.A365_ENV_VARS = exports.A365Configuration = void 0;
6
+ var index_js_1 = require("./configuration/index.js");
7
+ Object.defineProperty(exports, "A365Configuration", { enumerable: true, get: function () { return index_js_1.A365Configuration; } });
8
+ Object.defineProperty(exports, "A365_ENV_VARS", { enumerable: true, get: function () { return index_js_1.A365_ENV_VARS; } });
9
+ var index_js_2 = require("./exporter/index.js");
10
+ Object.defineProperty(exports, "Agent365Exporter", { enumerable: true, get: function () { return index_js_2.Agent365Exporter; } });
11
+ var index_js_3 = require("./exporter/index.js");
12
+ Object.defineProperty(exports, "ResolvedExporterOptions", { enumerable: true, get: function () { return index_js_3.ResolvedExporterOptions; } });
13
+ // ── Scopes (manual telemetry API) ───────────────────────────────────────────
14
+ var index_js_4 = require("./scopes/index.js");
15
+ Object.defineProperty(exports, "OpenTelemetryScope", { enumerable: true, get: function () { return index_js_4.OpenTelemetryScope; } });
16
+ Object.defineProperty(exports, "InvokeAgentScope", { enumerable: true, get: function () { return index_js_4.InvokeAgentScope; } });
17
+ Object.defineProperty(exports, "ExecuteToolScope", { enumerable: true, get: function () { return index_js_4.ExecuteToolScope; } });
18
+ Object.defineProperty(exports, "InferenceScope", { enumerable: true, get: function () { return index_js_4.InferenceScope; } });
19
+ Object.defineProperty(exports, "OutputScope", { enumerable: true, get: function () { return index_js_4.OutputScope; } });
20
+ // ── Constants ───────────────────────────────────────────────────────────────
21
+ var constants_js_1 = require("./constants.js");
22
+ Object.defineProperty(exports, "OpenTelemetryConstants", { enumerable: true, get: function () { return constants_js_1.OpenTelemetryConstants; } });
23
+ // ── Contracts (types & enums) ───────────────────────────────────────────────
24
+ var contracts_js_1 = require("./contracts.js");
25
+ Object.defineProperty(exports, "MessageRole", { enumerable: true, get: function () { return contracts_js_1.MessageRole; } });
26
+ Object.defineProperty(exports, "FinishReason", { enumerable: true, get: function () { return contracts_js_1.FinishReason; } });
27
+ Object.defineProperty(exports, "Modality", { enumerable: true, get: function () { return contracts_js_1.Modality; } });
28
+ Object.defineProperty(exports, "InvocationRole", { enumerable: true, get: function () { return contracts_js_1.InvocationRole; } });
29
+ Object.defineProperty(exports, "InferenceOperationType", { enumerable: true, get: function () { return contracts_js_1.InferenceOperationType; } });
30
+ Object.defineProperty(exports, "A365_MESSAGE_SCHEMA_VERSION", { enumerable: true, get: function () { return contracts_js_1.A365_MESSAGE_SCHEMA_VERSION; } });
31
+ // ── Context propagation ─────────────────────────────────────────────────────
32
+ var context_js_1 = require("./context.js");
33
+ Object.defineProperty(exports, "isParentSpanRef", { enumerable: true, get: function () { return context_js_1.isParentSpanRef; } });
34
+ Object.defineProperty(exports, "createContextWithParentSpanRef", { enumerable: true, get: function () { return context_js_1.createContextWithParentSpanRef; } });
35
+ Object.defineProperty(exports, "runWithParentSpanRef", { enumerable: true, get: function () { return context_js_1.runWithParentSpanRef; } });
36
+ Object.defineProperty(exports, "injectContextToHeaders", { enumerable: true, get: function () { return context_js_1.injectContextToHeaders; } });
37
+ Object.defineProperty(exports, "extractContextFromHeaders", { enumerable: true, get: function () { return context_js_1.extractContextFromHeaders; } });
38
+ Object.defineProperty(exports, "runWithExtractedTraceContext", { enumerable: true, get: function () { return context_js_1.runWithExtractedTraceContext; } });
39
+ // ── Middleware (BaggageBuilder) ──────────────────────────────────────────────
40
+ var index_js_5 = require("./middleware/index.js");
41
+ Object.defineProperty(exports, "BaggageBuilder", { enumerable: true, get: function () { return index_js_5.BaggageBuilder; } });
42
+ Object.defineProperty(exports, "BaggageScope", { enumerable: true, get: function () { return index_js_5.BaggageScope; } });
43
+ // ── Processors ──────────────────────────────────────────────────────────────
44
+ var index_js_6 = require("./processors/index.js");
45
+ Object.defineProperty(exports, "A365SpanProcessor", { enumerable: true, get: function () { return index_js_6.A365SpanProcessor; } });
46
+ Object.defineProperty(exports, "PerRequestSpanProcessor", { enumerable: true, get: function () { return index_js_6.PerRequestSpanProcessor; } });
47
+ Object.defineProperty(exports, "GENERIC_ATTRIBUTES", { enumerable: true, get: function () { return index_js_6.GENERIC_ATTRIBUTES; } });
48
+ Object.defineProperty(exports, "INVOKE_AGENT_ATTRIBUTES", { enumerable: true, get: function () { return index_js_6.INVOKE_AGENT_ATTRIBUTES; } });
49
+ // ── Token context ───────────────────────────────────────────────────────────
50
+ var tokenContext_js_1 = require("./context/tokenContext.js");
51
+ Object.defineProperty(exports, "runWithExportToken", { enumerable: true, get: function () { return tokenContext_js_1.runWithExportToken; } });
52
+ Object.defineProperty(exports, "updateExportToken", { enumerable: true, get: function () { return tokenContext_js_1.updateExportToken; } });
53
+ Object.defineProperty(exports, "getExportToken", { enumerable: true, get: function () { return tokenContext_js_1.getExportToken; } });
54
+ // ── Hosting utilities ───────────────────────────────────────────────────────
55
+ var index_js_7 = require("./hosting/index.js");
56
+ Object.defineProperty(exports, "BaggageBuilderUtils", { enumerable: true, get: function () { return index_js_7.BaggageBuilderUtils; } });
57
+ Object.defineProperty(exports, "ScopeUtils", { enumerable: true, get: function () { return index_js_7.ScopeUtils; } });
58
+ Object.defineProperty(exports, "getCallerBaggagePairs", { enumerable: true, get: function () { return index_js_7.getCallerBaggagePairs; } });
59
+ Object.defineProperty(exports, "getTargetAgentBaggagePairs", { enumerable: true, get: function () { return index_js_7.getTargetAgentBaggagePairs; } });
60
+ Object.defineProperty(exports, "getTenantIdPair", { enumerable: true, get: function () { return index_js_7.getTenantIdPair; } });
61
+ Object.defineProperty(exports, "getChannelBaggagePairs", { enumerable: true, get: function () { return index_js_7.getChannelBaggagePairs; } });
62
+ Object.defineProperty(exports, "getConversationIdAndItemLinkPairs", { enumerable: true, get: function () { return index_js_7.getConversationIdAndItemLinkPairs; } });
63
+ Object.defineProperty(exports, "resolveEmbodiedAgentIds", { enumerable: true, get: function () { return index_js_7.resolveEmbodiedAgentIds; } });
64
+ Object.defineProperty(exports, "BaggageMiddleware", { enumerable: true, get: function () { return index_js_7.BaggageMiddleware; } });
65
+ Object.defineProperty(exports, "OutputLoggingMiddleware", { enumerable: true, get: function () { return index_js_7.OutputLoggingMiddleware; } });
66
+ Object.defineProperty(exports, "A365_PARENT_SPAN_KEY", { enumerable: true, get: function () { return index_js_7.A365_PARENT_SPAN_KEY; } });
67
+ Object.defineProperty(exports, "A365_AUTH_TOKEN_KEY", { enumerable: true, get: function () { return index_js_7.A365_AUTH_TOKEN_KEY; } });
68
+ Object.defineProperty(exports, "ObservabilityHostingManager", { enumerable: true, get: function () { return index_js_7.ObservabilityHostingManager; } });
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/a365/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,qDAA4E;AAAnE,6GAAA,iBAAiB,OAAA;AAAE,yGAAA,aAAa,OAAA;AAQzC,gDAAuD;AAA9C,4GAAA,gBAAgB,OAAA;AAEzB,gDAA8D;AAArD,mHAAA,uBAAuB,OAAA;AAEhC,+EAA+E;AAC/E,8CAM2B;AALzB,8GAAA,kBAAkB,OAAA;AAClB,4GAAA,gBAAgB,OAAA;AAChB,4GAAA,gBAAgB,OAAA;AAChB,0GAAA,cAAc,OAAA;AACd,uGAAA,WAAW,OAAA;AAGb,+EAA+E;AAC/E,+CAAwD;AAA/C,sHAAA,sBAAsB,OAAA;AAE/B,+EAA+E;AAC/E,+CAOwB;AANtB,2GAAA,WAAW,OAAA;AACX,4GAAA,YAAY,OAAA;AACZ,wGAAA,QAAQ,OAAA;AACR,8GAAA,cAAc,OAAA;AACd,sHAAA,sBAAsB,OAAA;AACtB,2HAAA,2BAA2B,OAAA;AA+B7B,+EAA+E;AAC/E,2CAOsB;AANpB,6GAAA,eAAe,OAAA;AACf,4HAAA,8BAA8B,OAAA;AAC9B,kHAAA,oBAAoB,OAAA;AACpB,oHAAA,sBAAsB,OAAA;AACtB,uHAAA,yBAAyB,OAAA;AACzB,0HAAA,4BAA4B,OAAA;AAI9B,gFAAgF;AAChF,kDAAqE;AAA5D,0GAAA,cAAc,OAAA;AAAE,wGAAA,YAAY,OAAA;AAErC,+EAA+E;AAC/E,kDAK+B;AAJ7B,6GAAA,iBAAiB,OAAA;AACjB,mHAAA,uBAAuB,OAAA;AACvB,8GAAA,kBAAkB,OAAA;AAClB,mHAAA,uBAAuB,OAAA;AAIzB,+EAA+E;AAC/E,6DAAkG;AAAzF,qHAAA,kBAAkB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAAE,iHAAA,cAAc,OAAA;AAE9D,+EAA+E;AAC/E,+CAc4B;AAb1B,+GAAA,mBAAmB,OAAA;AACnB,sGAAA,UAAU,OAAA;AACV,iHAAA,qBAAqB,OAAA;AACrB,sHAAA,0BAA0B,OAAA;AAC1B,2GAAA,eAAe,OAAA;AACf,kHAAA,sBAAsB,OAAA;AACtB,6HAAA,iCAAiC,OAAA;AACjC,mHAAA,uBAAuB,OAAA;AACvB,6GAAA,iBAAiB,OAAA;AACjB,mHAAA,uBAAuB,OAAA;AACvB,gHAAA,oBAAoB,OAAA;AACpB,+GAAA,mBAAmB,OAAA;AACnB,uHAAA,2BAA2B,OAAA"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Utilities for normalizing and serializing gen-ai messages.
3
+ *
4
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/message-utils.ts
5
+ */
6
+ import type { ChatMessage, OutputMessage, InputMessages, OutputMessages, InputMessagesParam, OutputMessagesParam } from "./contracts.js";
7
+ /**
8
+ * Type guard that returns `true` when the input is a versioned wrapper
9
+ * object (`InputMessages` or `OutputMessages`).
10
+ */
11
+ export declare function isWrappedMessages(input: InputMessagesParam | OutputMessagesParam): input is InputMessages | OutputMessages;
12
+ /** Converts plain input strings into OTEL input messages. */
13
+ export declare function toInputMessages(messages: string[]): ChatMessage[];
14
+ /** Converts plain output strings into OTEL output messages. */
15
+ export declare function toOutputMessages(messages: string[]): OutputMessage[];
16
+ /**
17
+ * Normalizes an `InputMessagesParam` to a versioned `InputMessages` wrapper.
18
+ * - `string` / `string[]` → converted to `ChatMessage[]` and wrapped
19
+ * - `InputMessages` → returned as-is
20
+ */
21
+ export declare function normalizeInputMessages(param: InputMessagesParam): InputMessages;
22
+ /**
23
+ * Normalizes an `OutputMessagesParam` to a versioned `OutputMessages` wrapper.
24
+ * - `string` / `string[]` → converted to `OutputMessage[]` and wrapped
25
+ * - `OutputMessages` → returned as-is
26
+ */
27
+ export declare function normalizeOutputMessages(param: OutputMessagesParam): OutputMessages;
28
+ /**
29
+ * Serializes a versioned message wrapper to JSON.
30
+ *
31
+ * The try/catch ensures telemetry recording is non-throwing even when
32
+ * message parts contain non-JSON-serializable values.
33
+ */
34
+ export declare function serializeMessages(wrapper: InputMessages | OutputMessages): string;
35
+ /**
36
+ * Ensures the value is always a JSON-parseable string.
37
+ * - Objects are serialized via JSON.stringify.
38
+ * - Strings that are already valid JSON objects/arrays are passed through.
39
+ * - All other strings are wrapped: `{ [key]: value }`.
40
+ */
41
+ export declare function safeSerializeToJson(value: Record<string, unknown> | string, key: string): string;
42
+ //# sourceMappingURL=message-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-utils.d.ts","sourceRoot":"","sources":["../../../src/a365/message-utils.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAGxB;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,kBAAkB,GAAG,mBAAmB,GAC9C,KAAK,IAAI,aAAa,GAAG,cAAc,CAQzC;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAKjE;AAED,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAKpE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAM/E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc,CAMlF;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,GAAG,MAAM,CAmBjF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBhG"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.isWrappedMessages = isWrappedMessages;
6
+ exports.toInputMessages = toInputMessages;
7
+ exports.toOutputMessages = toOutputMessages;
8
+ exports.normalizeInputMessages = normalizeInputMessages;
9
+ exports.normalizeOutputMessages = normalizeOutputMessages;
10
+ exports.serializeMessages = serializeMessages;
11
+ exports.safeSerializeToJson = safeSerializeToJson;
12
+ const contracts_js_1 = require("./contracts.js");
13
+ /**
14
+ * Type guard that returns `true` when the input is a versioned wrapper
15
+ * object (`InputMessages` or `OutputMessages`).
16
+ */
17
+ function isWrappedMessages(input) {
18
+ return (!Array.isArray(input) &&
19
+ typeof input === "object" &&
20
+ input !== null &&
21
+ "version" in input &&
22
+ "messages" in input);
23
+ }
24
+ /** Converts plain input strings into OTEL input messages. */
25
+ function toInputMessages(messages) {
26
+ return messages.map((content) => ({
27
+ role: contracts_js_1.MessageRole.USER,
28
+ parts: [{ type: "text", content }],
29
+ }));
30
+ }
31
+ /** Converts plain output strings into OTEL output messages. */
32
+ function toOutputMessages(messages) {
33
+ return messages.map((content) => ({
34
+ role: contracts_js_1.MessageRole.ASSISTANT,
35
+ parts: [{ type: "text", content }],
36
+ }));
37
+ }
38
+ /**
39
+ * Normalizes an `InputMessagesParam` to a versioned `InputMessages` wrapper.
40
+ * - `string` / `string[]` → converted to `ChatMessage[]` and wrapped
41
+ * - `InputMessages` → returned as-is
42
+ */
43
+ function normalizeInputMessages(param) {
44
+ if (typeof param === "string" || Array.isArray(param)) {
45
+ const arr = typeof param === "string" ? [param] : param;
46
+ return { version: contracts_js_1.A365_MESSAGE_SCHEMA_VERSION, messages: toInputMessages(arr) };
47
+ }
48
+ return param;
49
+ }
50
+ /**
51
+ * Normalizes an `OutputMessagesParam` to a versioned `OutputMessages` wrapper.
52
+ * - `string` / `string[]` → converted to `OutputMessage[]` and wrapped
53
+ * - `OutputMessages` → returned as-is
54
+ */
55
+ function normalizeOutputMessages(param) {
56
+ if (typeof param === "string" || Array.isArray(param)) {
57
+ const arr = typeof param === "string" ? [param] : param;
58
+ return { version: contracts_js_1.A365_MESSAGE_SCHEMA_VERSION, messages: toOutputMessages(arr) };
59
+ }
60
+ return param;
61
+ }
62
+ /**
63
+ * Serializes a versioned message wrapper to JSON.
64
+ *
65
+ * The try/catch ensures telemetry recording is non-throwing even when
66
+ * message parts contain non-JSON-serializable values.
67
+ */
68
+ function serializeMessages(wrapper) {
69
+ try {
70
+ return JSON.stringify(wrapper);
71
+ }
72
+ catch {
73
+ return JSON.stringify({
74
+ version: contracts_js_1.A365_MESSAGE_SCHEMA_VERSION,
75
+ messages: [
76
+ {
77
+ role: contracts_js_1.MessageRole.SYSTEM,
78
+ parts: [
79
+ {
80
+ type: "text",
81
+ content: `[serialization failed: ${wrapper.messages.length} ${wrapper.messages.length === 1 ? "message" : "messages"}]`,
82
+ },
83
+ ],
84
+ },
85
+ ],
86
+ });
87
+ }
88
+ }
89
+ /**
90
+ * Ensures the value is always a JSON-parseable string.
91
+ * - Objects are serialized via JSON.stringify.
92
+ * - Strings that are already valid JSON objects/arrays are passed through.
93
+ * - All other strings are wrapped: `{ [key]: value }`.
94
+ */
95
+ function safeSerializeToJson(value, key) {
96
+ if (typeof value === "object" && value !== null) {
97
+ try {
98
+ return JSON.stringify(value);
99
+ }
100
+ catch {
101
+ return JSON.stringify({ error: "serialization failed" });
102
+ }
103
+ }
104
+ const str = value;
105
+ try {
106
+ const parsed = JSON.parse(str);
107
+ if (parsed !== null && typeof parsed === "object") {
108
+ return str;
109
+ }
110
+ }
111
+ catch {
112
+ // not valid JSON — fall through to wrap
113
+ }
114
+ return JSON.stringify({ [key]: str });
115
+ }
116
+ //# sourceMappingURL=message-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-utils.js","sourceRoot":"","sources":["../../../src/a365/message-utils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAsBlC,8CAUC;AAGD,0CAKC;AAGD,4CAKC;AAOD,wDAMC;AAOD,0DAMC;AAQD,8CAmBC;AAQD,kDAkBC;AA/GD,iDAA0E;AAE1E;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,KAA+C;IAE/C,OAAO,CACL,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,UAAU,IAAI,KAAK,CACpB,CAAC;AACJ,CAAC;AAED,6DAA6D;AAC7D,SAAgB,eAAe,CAAC,QAAkB;IAChD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,0BAAW,CAAC,IAAI;QACtB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,CAAC;KAC5C,CAAC,CAAC,CAAC;AACN,CAAC;AAED,+DAA+D;AAC/D,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,0BAAW,CAAC,SAAS;QAC3B,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,OAAO,EAAE,CAAC;KAC5C,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,KAAyB;IAC9D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,GAAG,GAAG,OAAO,KAAK,K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AAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IACD,MAAM,GAAG,GAAG,KAAe,CAAC;IAC5B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;QAC1C,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAClD,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wCAAwC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import type { Context } from "@opentelemetry/api";
2
+ /**
3
+ * Fluent builder for setting OpenTelemetry baggage values.
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * const scope = new BaggageBuilder()
8
+ * .tenantId("tenant-123")
9
+ * .agentId("agent-456")
10
+ * .build();
11
+ *
12
+ * scope.run(() => {
13
+ * // Baggage is active in this context
14
+ * });
15
+ * ```
16
+ */
17
+ export declare class BaggageBuilder {
18
+ private pairs;
19
+ /** Set the operation source baggage value (e.g., ATG, ACF). */
20
+ operationSource(value: string | null | undefined): BaggageBuilder;
21
+ /** Set the tenant ID baggage value. */
22
+ tenantId(value: string | null | undefined): BaggageBuilder;
23
+ /** Set the agent ID baggage value. */
24
+ agentId(value: string | null | undefined): BaggageBuilder;
25
+ /** Set the agent AUID baggage value. */
26
+ agentAuid(value: string | null | undefined): BaggageBuilder;
27
+ /** Set the agent email baggage value. */
28
+ agentEmail(value: string | null | undefined): BaggageBuilder;
29
+ /** Set the agent blueprint ID baggage value. */
30
+ agentBlueprintId(value: string | null | undefined): BaggageBuilder;
31
+ /** Set the session ID baggage value. */
32
+ sessionId(value: string): BaggageBuilder;
33
+ /** Set the user ID baggage value. */
34
+ userId(value: string | null | undefined): BaggageBuilder;
35
+ /** Set the agent name baggage value. */
36
+ agentName(value: string | null | undefined): BaggageBuilder;
37
+ /** Set the agent description baggage value. */
38
+ agentDescription(value: string | null | undefined): BaggageBuilder;
39
+ /** Set the agent platform ID baggage value. */
40
+ agentPlatformId(value: string | null | undefined): BaggageBuilder;
41
+ /** Set the agent version baggage value. */
42
+ agentVersion(value: string | null | undefined): BaggageBuilder;
43
+ /** Set the session description baggage value. */
44
+ sessionDescription(value: string | null | undefined): BaggageBuilder;
45
+ /** Set the user name baggage value. */
46
+ userName(value: string | null | undefined): BaggageBuilder;
47
+ /** Set the user email baggage value. */
48
+ userEmail(value: string | null | undefined): BaggageBuilder;
49
+ /** Set the caller client IP baggage value. */
50
+ callerClientIp(value: string | null | undefined): BaggageBuilder;
51
+ /** Set the caller agent platform ID baggage value. */
52
+ callerAgentPlatformId(value: string | null | undefined): BaggageBuilder;
53
+ /** Set the conversation ID baggage value. */
54
+ conversationId(value: string | null | undefined): BaggageBuilder;
55
+ /** Set the conversation item link baggage value. */
56
+ conversationItemLink(value: string | null | undefined): BaggageBuilder;
57
+ /** Set the channel name (e.g., Teams, Slack). */
58
+ channelName(value: string | null | undefined): BaggageBuilder;
59
+ /** Set the channel link/URL. */
60
+ channelLink(value: string | null | undefined): BaggageBuilder;
61
+ /**
62
+ * Sets the invoke agent server address and port baggage values.
63
+ * @param address The server address (hostname) of the target agent service.
64
+ * @param port Optional server port. Only recorded when different from 443.
65
+ */
66
+ invokeAgentServer(address: string | null | undefined, port?: number): BaggageBuilder;
67
+ /**
68
+ * Set multiple baggage pairs from a dictionary or iterable.
69
+ * @param pairs Dictionary or iterable of key-value pairs
70
+ */
71
+ setPairs(pairs: Record<string, any> | Iterable<[string, any]> | null | undefined): BaggageBuilder;
72
+ /**
73
+ * Apply the collected baggage to the current context.
74
+ * @returns A BaggageScope that can run callbacks under the baggage context
75
+ */
76
+ build(): BaggageScope;
77
+ /**
78
+ * Add a baggage key/value if the value is not null or whitespace.
79
+ */
80
+ private set;
81
+ /**
82
+ * Convenience method to begin a request baggage scope with common fields.
83
+ * @param tenantId The tenant ID
84
+ * @param agentId The agent ID
85
+ * @returns A BaggageScope with tenant and agent ID set
86
+ */
87
+ static setRequestContext(tenantId?: string | null, agentId?: string | null): BaggageScope;
88
+ }
89
+ /**
90
+ * Context manager for baggage scope.
91
+ *
92
+ * Manages the lifecycle of baggage values, setting them in the OTel context
93
+ * and restoring the previous context when the scope ends.
94
+ */
95
+ export declare class BaggageScope {
96
+ /** @internal Exposed for testing. */
97
+ readonly contextWithBaggage: Context;
98
+ constructor(pairs: Map<string, string>);
99
+ /**
100
+ * Execute a synchronous function under this baggage scope.
101
+ * Automatically restores previous context afterward.
102
+ */
103
+ run<T>(fn: () => T): T;
104
+ /**
105
+ * Dispose is a no-op because OpenTelemetry JS automatically restores
106
+ * the previous context after `context.with()` completes.
107
+ */
108
+ [Symbol.dispose](): void;
109
+ /** Manual cleanup alternative if caller isn't using `using`. */
110
+ dispose(): void;
111
+ }
112
+ //# sourceMappingURL=BaggageBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaggageBuilder.d.ts","sourceRoot":"","sources":["../../../../src/a365/middleware/BaggageBuilder.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAkC;IAE/C,+DAA+D;IAC/D,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc;IAKjE,uCAAuC;IACvC,QAAQ,CAAC,KAA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AItB;;;OAGG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,gEAAgE;IAChE,OAAO,IAAI,IAAI;CAGhB"}
@@ -0,0 +1,248 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.BaggageScope = exports.BaggageBuilder = void 0;
6
+ /**
7
+ * Per-request baggage builder for OpenTelemetry context propagation.
8
+ *
9
+ * Provides a fluent API for setting baggage values that will be propagated
10
+ * in the OpenTelemetry context and stamped onto spans by the SpanProcessor.
11
+ *
12
+ * Adapted from microsoft/Agent365-nodejs agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts
13
+ */
14
+ const api_1 = require("@opentelemetry/api");
15
+ const constants_js_1 = require("../constants.js");
16
+ /**
17
+ * Fluent builder for setting OpenTelemetry baggage values.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const scope = new BaggageBuilder()
22
+ * .tenantId("tenant-123")
23
+ * .agentId("agent-456")
24
+ * .build();
25
+ *
26
+ * scope.run(() => {
27
+ * // Baggage is active in this context
28
+ * });
29
+ * ```
30
+ */
31
+ class BaggageBuilder {
32
+ pairs = new Map();
33
+ /** Set the operation source baggage value (e.g., ATG, ACF). */
34
+ operationSource(value) {
35
+ this.set(constants_js_1.OpenTelemetryConstants.SERVICE_NAME_KEY, value);
36
+ return this;
37
+ }
38
+ /** Set the tenant ID baggage value. */
39
+ tenantId(value) {
40
+ this.set(constants_js_1.OpenTelemetryConstants.TENANT_ID_KEY, value);
41
+ return this;
42
+ }
43
+ /** Set the agent ID baggage value. */
44
+ agentId(value) {
45
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_ID_KEY, value);
46
+ return this;
47
+ }
48
+ /** Set the agent AUID baggage value. */
49
+ agentAuid(value) {
50
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_AUID_KEY, value);
51
+ return this;
52
+ }
53
+ /** Set the agent email baggage value. */
54
+ agentEmail(value) {
55
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_EMAIL_KEY, value);
56
+ return this;
57
+ }
58
+ /** Set the agent blueprint ID baggage value. */
59
+ agentBlueprintId(value) {
60
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_BLUEPRINT_ID_KEY, value);
61
+ return this;
62
+ }
63
+ /** Set the session ID baggage value. */
64
+ sessionId(value) {
65
+ this.set(constants_js_1.OpenTelemetryConstants.SESSION_ID_KEY, value);
66
+ return this;
67
+ }
68
+ /** Set the user ID baggage value. */
69
+ userId(value) {
70
+ this.set(constants_js_1.OpenTelemetryConstants.USER_ID_KEY, value);
71
+ return this;
72
+ }
73
+ /** Set the agent name baggage value. */
74
+ agentName(value) {
75
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_NAME_KEY, value);
76
+ return this;
77
+ }
78
+ /** Set the agent description baggage value. */
79
+ agentDescription(value) {
80
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_DESCRIPTION_KEY, value);
81
+ return this;
82
+ }
83
+ /** Set the agent platform ID baggage value. */
84
+ agentPlatformId(value) {
85
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_PLATFORM_ID_KEY, value);
86
+ return this;
87
+ }
88
+ /** Set the agent version baggage value. */
89
+ agentVersion(value) {
90
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_AGENT_VERSION_KEY, value);
91
+ return this;
92
+ }
93
+ /** Set the session description baggage value. */
94
+ sessionDescription(value) {
95
+ this.set(constants_js_1.OpenTelemetryConstants.SESSION_DESCRIPTION_KEY, value);
96
+ return this;
97
+ }
98
+ /** Set the user name baggage value. */
99
+ userName(value) {
100
+ this.set(constants_js_1.OpenTelemetryConstants.USER_NAME_KEY, value);
101
+ return this;
102
+ }
103
+ /** Set the user email baggage value. */
104
+ userEmail(value) {
105
+ this.set(constants_js_1.OpenTelemetryConstants.USER_EMAIL_KEY, value);
106
+ return this;
107
+ }
108
+ /** Set the caller client IP baggage value. */
109
+ callerClientIp(value) {
110
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_CALLER_CLIENT_IP_KEY, value);
111
+ return this;
112
+ }
113
+ /** Set the caller agent platform ID baggage value. */
114
+ callerAgentPlatformId(value) {
115
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_CALLER_AGENT_PLATFORM_ID_KEY, value);
116
+ return this;
117
+ }
118
+ /** Set the conversation ID baggage value. */
119
+ conversationId(value) {
120
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_CONVERSATION_ID_KEY, value);
121
+ return this;
122
+ }
123
+ /** Set the conversation item link baggage value. */
124
+ conversationItemLink(value) {
125
+ this.set(constants_js_1.OpenTelemetryConstants.GEN_AI_CONVERSATION_ITEM_LINK_KEY, value);
126
+ return this;
127
+ }
128
+ /** Set the channel name (e.g., Teams, Slack). */
129
+ channelName(value) {
130
+ this.set(constants_js_1.OpenTelemetryConstants.CHANNEL_NAME_KEY, value);
131
+ return this;
132
+ }
133
+ /** Set the channel link/URL. */
134
+ channelLink(value) {
135
+ this.set(constants_js_1.OpenTelemetryConstants.CHANNEL_LINK_KEY, value);
136
+ return this;
137
+ }
138
+ /**
139
+ * Sets the invoke agent server address and port baggage values.
140
+ * @param address The server address (hostname) of the target agent service.
141
+ * @param port Optional server port. Only recorded when different from 443.
142
+ */
143
+ invokeAgentServer(address, port) {
144
+ this.set(constants_js_1.OpenTelemetryConstants.SERVER_ADDRESS_KEY, address);
145
+ if (port !== undefined && port !== 443) {
146
+ this.set(constants_js_1.OpenTelemetryConstants.SERVER_PORT_KEY, port.toString());
147
+ }
148
+ else {
149
+ this.pairs.delete(constants_js_1.OpenTelemetryConstants.SERVER_PORT_KEY);
150
+ }
151
+ return this;
152
+ }
153
+ /**
154
+ * Set multiple baggage pairs from a dictionary or iterable.
155
+ * @param pairs Dictionary or iterable of key-value pairs
156
+ */
157
+ setPairs(pairs) {
158
+ if (!pairs) {
159
+ return this;
160
+ }
161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
162
+ let entries;
163
+ if (Symbol.iterator in Object(pairs)) {
164
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
+ entries = pairs;
166
+ }
167
+ else {
168
+ entries = Object.entries(pairs);
169
+ }
170
+ for (const [key, value] of entries) {
171
+ if (value !== null && value !== undefined) {
172
+ this.set(key, String(value));
173
+ }
174
+ }
175
+ return this;
176
+ }
177
+ /**
178
+ * Apply the collected baggage to the current context.
179
+ * @returns A BaggageScope that can run callbacks under the baggage context
180
+ */
181
+ build() {
182
+ return new BaggageScope(this.pairs);
183
+ }
184
+ /**
185
+ * Add a baggage key/value if the value is not null or whitespace.
186
+ */
187
+ set(key, value) {
188
+ if (value !== null && value !== undefined) {
189
+ const trimmed = value.trim();
190
+ if (trimmed) {
191
+ this.pairs.set(key, trimmed);
192
+ }
193
+ }
194
+ }
195
+ /**
196
+ * Convenience method to begin a request baggage scope with common fields.
197
+ * @param tenantId The tenant ID
198
+ * @param agentId The agent ID
199
+ * @returns A BaggageScope with tenant and agent ID set
200
+ */
201
+ static setRequestContext(tenantId, agentId) {
202
+ return new BaggageBuilder().tenantId(tenantId).agentId(agentId).build();
203
+ }
204
+ }
205
+ exports.BaggageBuilder = BaggageBuilder;
206
+ /**
207
+ * Context manager for baggage scope.
208
+ *
209
+ * Manages the lifecycle of baggage values, setting them in the OTel context
210
+ * and restoring the previous context when the scope ends.
211
+ */
212
+ class BaggageScope {
213
+ /** @internal Exposed for testing. */
214
+ contextWithBaggage;
215
+ constructor(pairs) {
216
+ // 1. Start from current active context
217
+ const currentCtx = api_1.context.active();
218
+ // 2. Build merged baggage
219
+ let bag = api_1.propagation.getBaggage(currentCtx) ?? api_1.propagation.createBaggage({});
220
+ for (const [key, value] of pairs.entries()) {
221
+ if (value && value.trim()) {
222
+ bag = bag.setEntry(key, { value });
223
+ }
224
+ }
225
+ // 3. Create a new context that carries that baggage
226
+ this.contextWithBaggage = api_1.propagation.setBaggage(currentCtx, bag);
227
+ }
228
+ /**
229
+ * Execute a synchronous function under this baggage scope.
230
+ * Automatically restores previous context afterward.
231
+ */
232
+ run(fn) {
233
+ return api_1.context.with(this.contextWithBaggage, fn);
234
+ }
235
+ /**
236
+ * Dispose is a no-op because OpenTelemetry JS automatically restores
237
+ * the previous context after `context.with()` completes.
238
+ */
239
+ [Symbol.dispose]() {
240
+ // Nothing to detach manually; context restoration happens automatically.
241
+ }
242
+ /** Manual cleanup alternative if caller isn't using `using`. */
243
+ dispose() {
244
+ this[Symbol.dispose]();
245
+ }
246
+ }
247
+ exports.BaggageScope = BaggageScope;
248
+ //# sourceMappingURL=BaggageBuilder.js.map