@microsoft/agents-hosting 1.5.0-beta.5.g18f3420031 → 1.5.1

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 (157) hide show
  1. package/dist/package.json +10 -9
  2. package/dist/src/activityHandler.js +2 -2
  3. package/dist/src/activityHandler.js.map +1 -1
  4. package/dist/src/agent-client/agentClient.js +49 -40
  5. package/dist/src/agent-client/agentClient.js.map +1 -1
  6. package/dist/src/agent-client/agentResponseHandler.js +2 -2
  7. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  8. package/dist/src/app/agentApplication.d.ts +36 -10
  9. package/dist/src/app/agentApplication.js +169 -99
  10. package/dist/src/app/agentApplication.js.map +1 -1
  11. package/dist/src/app/agentApplicationBuilder.d.ts +15 -0
  12. package/dist/src/app/agentApplicationBuilder.js +22 -4
  13. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  14. package/dist/src/app/agentApplicationOptions.d.ts +38 -0
  15. package/dist/src/app/attachmentDownloader.js +2 -2
  16. package/dist/src/app/attachmentDownloader.js.map +1 -1
  17. package/dist/src/app/auth/authorization.js +12 -9
  18. package/dist/src/app/auth/authorization.js.map +1 -1
  19. package/dist/src/app/auth/authorizationManager.d.ts +18 -5
  20. package/dist/src/app/auth/authorizationManager.js +258 -45
  21. package/dist/src/app/auth/authorizationManager.js.map +1 -1
  22. package/dist/src/app/auth/handlerStorage.js +3 -1
  23. package/dist/src/app/auth/handlerStorage.js.map +1 -1
  24. package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +19 -16
  25. package/dist/src/app/auth/handlers/agenticAuthorization.js +46 -52
  26. package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
  27. package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +51 -75
  28. package/dist/src/app/auth/handlers/azureBotAuthorization.js +217 -192
  29. package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
  30. package/dist/src/app/auth/types.d.ts +100 -1
  31. package/dist/src/app/auth/utils.d.ts +10 -0
  32. package/dist/src/app/auth/utils.js +21 -0
  33. package/dist/src/app/auth/utils.js.map +1 -0
  34. package/dist/src/app/index.d.ts +1 -0
  35. package/dist/src/app/index.js +1 -0
  36. package/dist/src/app/index.js.map +1 -1
  37. package/dist/src/app/proactive/conversation.d.ts +43 -0
  38. package/dist/src/app/proactive/conversation.js +67 -0
  39. package/dist/src/app/proactive/conversation.js.map +1 -0
  40. package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
  41. package/dist/src/app/proactive/conversationBuilder.js +110 -0
  42. package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
  43. package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
  44. package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
  45. package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
  46. package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
  47. package/dist/src/app/proactive/createConversationOptions.js +10 -0
  48. package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
  49. package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
  50. package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
  51. package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
  52. package/dist/src/app/proactive/index.d.ts +7 -0
  53. package/dist/src/app/proactive/index.js +26 -0
  54. package/dist/src/app/proactive/index.js.map +1 -0
  55. package/dist/src/app/proactive/proactive.d.ts +248 -0
  56. package/dist/src/app/proactive/proactive.js +310 -0
  57. package/dist/src/app/proactive/proactive.js.map +1 -0
  58. package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
  59. package/dist/src/app/proactive/proactiveOptions.js +5 -0
  60. package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
  61. package/dist/src/app/streaming/streamingResponse.js +2 -2
  62. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  63. package/dist/src/app/teamsAttachmentDownloader.js +2 -2
  64. package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
  65. package/dist/src/app/turnState.js +2 -2
  66. package/dist/src/app/turnState.js.map +1 -1
  67. package/dist/src/auth/authConfiguration.d.ts +61 -0
  68. package/dist/src/auth/authConfiguration.js +52 -3
  69. package/dist/src/auth/authConfiguration.js.map +1 -1
  70. package/dist/src/auth/jwt-middleware.js +2 -2
  71. package/dist/src/auth/jwt-middleware.js.map +1 -1
  72. package/dist/src/auth/msalConnectionManager.js +20 -0
  73. package/dist/src/auth/msalConnectionManager.js.map +1 -1
  74. package/dist/src/auth/msalTokenCredential.js +3 -0
  75. package/dist/src/auth/msalTokenCredential.js.map +1 -1
  76. package/dist/src/auth/msalTokenProvider.js +136 -110
  77. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  78. package/dist/src/baseAdapter.js +2 -2
  79. package/dist/src/baseAdapter.js.map +1 -1
  80. package/dist/src/cloudAdapter.js +201 -154
  81. package/dist/src/cloudAdapter.js.map +1 -1
  82. package/dist/src/connector-client/connectorClient.js +176 -127
  83. package/dist/src/connector-client/connectorClient.js.map +1 -1
  84. package/dist/src/errorHelper.js +108 -0
  85. package/dist/src/errorHelper.js.map +1 -1
  86. package/dist/src/middlewareSet.js +2 -2
  87. package/dist/src/middlewareSet.js.map +1 -1
  88. package/dist/src/oauth/userTokenClient.js +78 -48
  89. package/dist/src/oauth/userTokenClient.js.map +1 -1
  90. package/dist/src/observability/index.d.ts +2 -0
  91. package/dist/src/observability/index.js +21 -0
  92. package/dist/src/observability/index.js.map +1 -0
  93. package/dist/src/observability/metrics.d.ts +21 -0
  94. package/dist/src/observability/metrics.js +87 -0
  95. package/dist/src/observability/metrics.js.map +1 -0
  96. package/dist/src/observability/traces.d.ts +234 -0
  97. package/dist/src/observability/traces.js +962 -0
  98. package/dist/src/observability/traces.js.map +1 -0
  99. package/dist/src/state/agentState.js +2 -2
  100. package/dist/src/state/agentState.js.map +1 -1
  101. package/dist/src/storage/fileStorage.js +38 -28
  102. package/dist/src/storage/fileStorage.js.map +1 -1
  103. package/dist/src/storage/memoryStorage.js +41 -30
  104. package/dist/src/storage/memoryStorage.js.map +1 -1
  105. package/dist/src/transcript/fileTranscriptLogger.js +2 -2
  106. package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
  107. package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -2
  108. package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
  109. package/dist/src/turnContext.js +48 -42
  110. package/dist/src/turnContext.js.map +1 -1
  111. package/package.json +10 -9
  112. package/src/activityHandler.ts +1 -1
  113. package/src/agent-client/agentClient.ts +53 -42
  114. package/src/agent-client/agentResponseHandler.ts +1 -1
  115. package/src/app/agentApplication.ts +212 -86
  116. package/src/app/agentApplicationBuilder.ts +26 -4
  117. package/src/app/agentApplicationOptions.ts +43 -0
  118. package/src/app/attachmentDownloader.ts +1 -1
  119. package/src/app/auth/authorization.ts +11 -8
  120. package/src/app/auth/authorizationManager.ts +297 -45
  121. package/src/app/auth/handlerStorage.ts +3 -1
  122. package/src/app/auth/handlers/agenticAuthorization.ts +68 -72
  123. package/src/app/auth/handlers/azureBotAuthorization.ts +260 -264
  124. package/src/app/auth/types.ts +102 -1
  125. package/src/app/auth/utils.ts +22 -0
  126. package/src/app/index.ts +1 -0
  127. package/src/app/proactive/conversation.ts +87 -0
  128. package/src/app/proactive/conversationBuilder.ts +139 -0
  129. package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
  130. package/src/app/proactive/createConversationOptions.ts +35 -0
  131. package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
  132. package/src/app/proactive/index.ts +10 -0
  133. package/src/app/proactive/proactive.ts +524 -0
  134. package/src/app/proactive/proactiveOptions.ts +24 -0
  135. package/src/app/streaming/streamingResponse.ts +1 -1
  136. package/src/app/teamsAttachmentDownloader.ts +1 -1
  137. package/src/app/turnState.ts +1 -1
  138. package/src/auth/authConfiguration.ts +58 -1
  139. package/src/auth/jwt-middleware.ts +1 -1
  140. package/src/auth/msalConnectionManager.ts +22 -0
  141. package/src/auth/msalTokenCredential.ts +4 -0
  142. package/src/auth/msalTokenProvider.ts +138 -107
  143. package/src/baseAdapter.ts +1 -1
  144. package/src/cloudAdapter.ts +239 -184
  145. package/src/connector-client/connectorClient.ts +169 -126
  146. package/src/errorHelper.ts +124 -0
  147. package/src/middlewareSet.ts +1 -1
  148. package/src/oauth/userTokenClient.ts +70 -46
  149. package/src/observability/index.ts +5 -0
  150. package/src/observability/metrics.ts +103 -0
  151. package/src/observability/traces.ts +988 -0
  152. package/src/state/agentState.ts +1 -1
  153. package/src/storage/fileStorage.ts +36 -26
  154. package/src/storage/memoryStorage.ts +40 -29
  155. package/src/transcript/fileTranscriptLogger.ts +1 -1
  156. package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
  157. package/src/turnContext.ts +47 -41
@@ -0,0 +1,962 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.UserTokenClientTraceDefinitions = exports.AuthorizationTraceDefinitions = exports.AuthenticationTraceDefinitions = exports.StorageTraceDefinitions = exports.ConnectorClientTraceDefinitions = exports.ProactiveTraceDefinitions = exports.AdapterTraceDefinitions = exports.AgentClientTraceDefinitions = exports.TurnContextTraceDefinitions = exports.AgentApplicationTraceDefinitions = void 0;
6
+ const agents_telemetry_1 = require("@microsoft/agents-telemetry");
7
+ const metrics_1 = require("./metrics");
8
+ const agents_activity_1 = require("@microsoft/agents-activity");
9
+ exports.AgentApplicationTraceDefinitions = {
10
+ run: agents_telemetry_1.trace.define({
11
+ name: agents_telemetry_1.SpanNames.AGENTS_APP_RUN,
12
+ record: {
13
+ authorized: false,
14
+ activity: agents_activity_1.Activity.fromObject({ type: 'unknown' }),
15
+ routeMatched: false,
16
+ },
17
+ end({ span, record, duration, error }) {
18
+ var _a, _b;
19
+ const { activity } = record;
20
+ const attributes = {
21
+ 'activity.type': (_a = activity.type) !== null && _a !== void 0 ? _a : 'unknown',
22
+ 'activity.channel_id': (_b = activity.channelId) !== null && _b !== void 0 ? _b : 'unknown'
23
+ };
24
+ span.setAttributes({
25
+ 'route.authorized': record.authorized,
26
+ 'route.matched': record.routeMatched,
27
+ ...attributes
28
+ });
29
+ metrics_1.HostingMetrics.turnsTotalCounter.add(1, attributes);
30
+ metrics_1.HostingMetrics.turnDuration.record(duration, attributes);
31
+ if (error) {
32
+ metrics_1.HostingMetrics.turnsErrorsCounter.add(1, {
33
+ 'error.type': error instanceof Error ? error.constructor.name : typeof error
34
+ });
35
+ }
36
+ }
37
+ }),
38
+ downloadFiles: agents_telemetry_1.trace.define({
39
+ name: agents_telemetry_1.SpanNames.AGENTS_APP_DOWNLOAD_FILES,
40
+ record: {
41
+ attachmentsCount: 0,
42
+ },
43
+ end({ span, record }) {
44
+ var _a;
45
+ span.setAttribute('agents.attachments.count', (_a = record.attachmentsCount) !== null && _a !== void 0 ? _a : 0);
46
+ }
47
+ }),
48
+ beforeTurn: agents_telemetry_1.trace.define({
49
+ name: agents_telemetry_1.SpanNames.AGENTS_APP_BEFORE_TURN,
50
+ record: {},
51
+ end() { }
52
+ }),
53
+ routeHandler: agents_telemetry_1.trace.define({
54
+ name: agents_telemetry_1.SpanNames.AGENTS_APP_ROUTE_HANDLER,
55
+ record: {
56
+ isInvoke: false,
57
+ isAgentic: false,
58
+ },
59
+ end({ span, record }) {
60
+ span.setAttributes({
61
+ 'route.is_invoke': record.isInvoke,
62
+ 'route.is_agentic': record.isAgentic,
63
+ });
64
+ }
65
+ }),
66
+ afterTurn: agents_telemetry_1.trace.define({
67
+ name: agents_telemetry_1.SpanNames.AGENTS_APP_AFTER_TURN,
68
+ record: {},
69
+ end() { }
70
+ }),
71
+ };
72
+ exports.TurnContextTraceDefinitions = {
73
+ sendActivities: agents_telemetry_1.trace.define({
74
+ name: agents_telemetry_1.SpanNames.TURN_SEND_ACTIVITIES,
75
+ record: {
76
+ activityCount: 0
77
+ },
78
+ actions: ({ span }) => ({
79
+ recordActivity(activity) {
80
+ var _a, _b, _c;
81
+ span.addEvent('activity.sent', {
82
+ 'activity.id': (_a = activity.id) !== null && _a !== void 0 ? _a : 'unknown',
83
+ 'activity.type': (_b = activity.type) !== null && _b !== void 0 ? _b : 'unknown',
84
+ 'activity.delivery_mode': (_c = activity.deliveryMode) !== null && _c !== void 0 ? _c : 'unknown'
85
+ });
86
+ }
87
+ }),
88
+ end({ span, record }) {
89
+ span.setAttribute('activity.count', record.activityCount);
90
+ }
91
+ }),
92
+ };
93
+ exports.AgentClientTraceDefinitions = {
94
+ postActivity: agents_telemetry_1.trace.define({
95
+ name: agents_telemetry_1.SpanNames.AGENT_CLIENT_POST_ACTIVITY,
96
+ record: {
97
+ endpoint: '',
98
+ clientId: '',
99
+ httpStatusCode: 'unknown',
100
+ },
101
+ end({ span, record, duration }) {
102
+ var _a, _b, _c;
103
+ const attributes = {
104
+ 'target.endpoint': (_a = record.endpoint) !== null && _a !== void 0 ? _a : 'unknown',
105
+ 'target.client_id': (_b = record.clientId) !== null && _b !== void 0 ? _b : 'unknown',
106
+ 'http.status_code': (_c = record.httpStatusCode) !== null && _c !== void 0 ? _c : 'unknown'
107
+ };
108
+ span.setAttributes(attributes);
109
+ metrics_1.HostingMetrics.agentClientRequestsCounter.add(1, attributes);
110
+ metrics_1.HostingMetrics.agentClientRequestDuration.record(duration, attributes);
111
+ }
112
+ }),
113
+ };
114
+ exports.AdapterTraceDefinitions = {
115
+ createConnectorClient: agents_telemetry_1.trace.define({
116
+ name: agents_telemetry_1.SpanNames.ADAPTER_CREATE_CONNECTOR_CLIENT,
117
+ record: {
118
+ serviceUrl: '',
119
+ scope: '',
120
+ activityIsAgentic: false,
121
+ },
122
+ end({ span, record }) {
123
+ var _a, _b;
124
+ span.setAttributes({
125
+ service_url: (_a = record.serviceUrl) !== null && _a !== void 0 ? _a : 'unknown',
126
+ 'auth.scope': (_b = record.scope) !== null && _b !== void 0 ? _b : 'unknown',
127
+ });
128
+ if (record.activityIsAgentic !== undefined) {
129
+ span.setAttribute('activity.is_agentic', record.activityIsAgentic);
130
+ }
131
+ }
132
+ }),
133
+ createUserTokenClient: agents_telemetry_1.trace.define({
134
+ name: agents_telemetry_1.SpanNames.ADAPTER_CREATE_USER_TOKEN_CLIENT,
135
+ record: {
136
+ tokenServiceEndpoint: '',
137
+ authScope: '',
138
+ },
139
+ end({ span, record }) {
140
+ var _a, _b;
141
+ span.setAttributes({
142
+ 'token.service.endpoint': (_a = record.tokenServiceEndpoint) !== null && _a !== void 0 ? _a : 'unknown',
143
+ 'auth.scope': (_b = record.authScope) !== null && _b !== void 0 ? _b : 'unknown',
144
+ });
145
+ }
146
+ }),
147
+ sendActivities: agents_telemetry_1.trace.define({
148
+ name: agents_telemetry_1.SpanNames.ADAPTER_SEND_ACTIVITIES,
149
+ record: {
150
+ activityCount: 0,
151
+ },
152
+ actions: ({ span }) => ({
153
+ recordActivity(activity) {
154
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
155
+ span.addEvent('activity.sent', {
156
+ 'activity.id': (_a = activity.id) !== null && _a !== void 0 ? _a : 'unknown',
157
+ 'activity.type': (_b = activity.type) !== null && _b !== void 0 ? _b : 'unknown',
158
+ 'activity.channel_id': (_c = activity.channelId) !== null && _c !== void 0 ? _c : 'unknown',
159
+ 'activity.conversation_id': (_e = (_d = activity.conversation) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : 'unknown',
160
+ });
161
+ metrics_1.HostingMetrics.activitiesSentCounter.add(1, {
162
+ 'activity.type': (_f = activity.type) !== null && _f !== void 0 ? _f : 'unknown',
163
+ 'activity.channel_id': (_g = activity.channelId) !== null && _g !== void 0 ? _g : 'unknown',
164
+ 'activity.conversation_id': (_j = (_h = activity.conversation) === null || _h === void 0 ? void 0 : _h.id) !== null && _j !== void 0 ? _j : 'unknown',
165
+ });
166
+ }
167
+ }),
168
+ end({ span, record }) {
169
+ span.setAttributes({
170
+ 'activity.count': record.activityCount,
171
+ });
172
+ }
173
+ }),
174
+ process: agents_telemetry_1.trace.define({
175
+ name: agents_telemetry_1.SpanNames.ADAPTER_PROCESS,
176
+ record: {
177
+ activity: agents_activity_1.Activity.fromObject({ type: 'unknown' }),
178
+ },
179
+ end({ span, record, duration }) {
180
+ var _a, _b, _c, _d, _e;
181
+ const { activity } = record;
182
+ const attributes = {
183
+ 'activity.type': (_a = activity.type) !== null && _a !== void 0 ? _a : 'unknown',
184
+ 'activity.channel_id': (_b = activity.channelId) !== null && _b !== void 0 ? _b : 'unknown',
185
+ 'activity.delivery_mode': (_c = activity.deliveryMode) !== null && _c !== void 0 ? _c : 'unknown',
186
+ 'activity.conversation_id': (_e = (_d = activity.conversation) === null || _d === void 0 ? void 0 : _d.id) !== null && _e !== void 0 ? _e : 'unknown',
187
+ };
188
+ span.setAttributes({
189
+ ...attributes,
190
+ 'activity.is_agentic': activity.isAgenticRequest(),
191
+ });
192
+ metrics_1.HostingMetrics.adapterProcessDuration.record(duration, {
193
+ 'activity.type': attributes['activity.type'],
194
+ });
195
+ metrics_1.HostingMetrics.activitiesReceivedCounter.add(1, {
196
+ 'activity.type': attributes['activity.type'],
197
+ 'activity.channel_id': attributes['activity.channel_id']
198
+ });
199
+ }
200
+ }),
201
+ updateActivity: agents_telemetry_1.trace.define({
202
+ name: agents_telemetry_1.SpanNames.ADAPTER_UPDATE_ACTIVITY,
203
+ record: {
204
+ activity: agents_activity_1.Activity.fromObject({ type: 'unknown' }),
205
+ },
206
+ end({ span, record }) {
207
+ var _a, _b, _c, _d;
208
+ span.setAttributes({
209
+ 'activity.id': (_a = record.activity.id) !== null && _a !== void 0 ? _a : 'unknown',
210
+ 'activity.conversation_id': (_c = (_b = record.activity.conversation) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : 'unknown',
211
+ });
212
+ metrics_1.HostingMetrics.activitiesUpdatedCounter.add(1, {
213
+ 'activity.channel_id': (_d = record.activity.channelId) !== null && _d !== void 0 ? _d : 'unknown'
214
+ });
215
+ }
216
+ }),
217
+ deleteActivity: agents_telemetry_1.trace.define({
218
+ name: agents_telemetry_1.SpanNames.ADAPTER_DELETE_ACTIVITY,
219
+ record: {
220
+ reference: {},
221
+ },
222
+ end({ span, record }) {
223
+ var _a, _b, _c, _d;
224
+ const { reference } = record;
225
+ span.setAttributes({
226
+ 'activity.id': (_a = reference.activityId) !== null && _a !== void 0 ? _a : 'unknown',
227
+ 'activity.conversation_id': (_c = (_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : 'unknown',
228
+ });
229
+ metrics_1.HostingMetrics.activitiesDeletedCounter.add(1, {
230
+ 'activity.channel_id': (_d = reference.channelId) !== null && _d !== void 0 ? _d : 'unknown'
231
+ });
232
+ }
233
+ }),
234
+ continueConversation: agents_telemetry_1.trace.define({
235
+ name: agents_telemetry_1.SpanNames.ADAPTER_CONTINUE_CONVERSATION,
236
+ record: {
237
+ botAppId: '',
238
+ conversationId: '',
239
+ isAgentic: false,
240
+ },
241
+ end({ span, record }) {
242
+ var _a, _b;
243
+ span.setAttributes({
244
+ 'bot.app_id': (_a = record.botAppId) !== null && _a !== void 0 ? _a : 'unknown',
245
+ 'activity.conversation_id': (_b = record.conversationId) !== null && _b !== void 0 ? _b : 'unknown',
246
+ 'activity.is_agentic': record.isAgentic,
247
+ });
248
+ }
249
+ }),
250
+ };
251
+ exports.ProactiveTraceDefinitions = {
252
+ storeConversation: agents_telemetry_1.trace.define({
253
+ name: agents_telemetry_1.SpanNames.PROACTIVE_STORE_CONVERSATION,
254
+ record: {
255
+ conversationId: '',
256
+ },
257
+ end({ span, record }) {
258
+ var _a;
259
+ span.setAttributes({
260
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
261
+ });
262
+ }
263
+ }),
264
+ getConversation: agents_telemetry_1.trace.define({
265
+ name: agents_telemetry_1.SpanNames.PROACTIVE_GET_CONVERSATION,
266
+ record: {
267
+ conversationId: '',
268
+ found: false,
269
+ },
270
+ end({ span, record }) {
271
+ var _a;
272
+ span.setAttributes({
273
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
274
+ 'proactive.conversation_found': record.found,
275
+ });
276
+ }
277
+ }),
278
+ getConversationOrThrow: agents_telemetry_1.trace.define({
279
+ name: agents_telemetry_1.SpanNames.PROACTIVE_GET_CONVERSATION_OR_THROW,
280
+ record: {
281
+ conversationId: '',
282
+ },
283
+ end({ span, record }) {
284
+ var _a;
285
+ span.setAttributes({
286
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
287
+ });
288
+ }
289
+ }),
290
+ deleteConversation: agents_telemetry_1.trace.define({
291
+ name: agents_telemetry_1.SpanNames.PROACTIVE_DELETE_CONVERSATION,
292
+ record: {
293
+ conversationId: '',
294
+ },
295
+ end({ span, record }) {
296
+ var _a;
297
+ span.setAttributes({
298
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
299
+ });
300
+ }
301
+ }),
302
+ sendActivity: agents_telemetry_1.trace.define({
303
+ name: agents_telemetry_1.SpanNames.PROACTIVE_SEND_ACTIVITY,
304
+ record: {
305
+ conversationId: '',
306
+ channelId: '',
307
+ activityType: '',
308
+ },
309
+ end({ span, record, duration, error }) {
310
+ var _a, _b, _c;
311
+ const attributes = {
312
+ 'activity.channel_id': (_a = record.channelId) !== null && _a !== void 0 ? _a : 'unknown',
313
+ 'activity.type': (_b = record.activityType) !== null && _b !== void 0 ? _b : 'unknown'
314
+ };
315
+ span.setAttributes({
316
+ ...attributes,
317
+ 'activity.conversation_id': (_c = record.conversationId) !== null && _c !== void 0 ? _c : 'unknown',
318
+ });
319
+ const metricsAttributes = {
320
+ ...attributes,
321
+ operation: 'send.activity',
322
+ 'operation.success': error === undefined,
323
+ };
324
+ metrics_1.HostingMetrics.proactiveOperationCounter.add(1, metricsAttributes);
325
+ metrics_1.HostingMetrics.proactiveOperationDuration.record(duration, metricsAttributes);
326
+ }
327
+ }),
328
+ continueConversation: agents_telemetry_1.trace.define({
329
+ name: agents_telemetry_1.SpanNames.PROACTIVE_CONTINUE_CONVERSATION,
330
+ record: {
331
+ conversationId: '',
332
+ channelId: '',
333
+ hasAutoSignIn: false,
334
+ },
335
+ end({ span, record, duration, error }) {
336
+ var _a, _b;
337
+ const attributes = {
338
+ 'activity.channel_id': (_a = record.channelId) !== null && _a !== void 0 ? _a : 'unknown',
339
+ 'proactive.has_auto_sign_in': record.hasAutoSignIn,
340
+ };
341
+ span.setAttributes({
342
+ ...attributes,
343
+ 'activity.conversation_id': (_b = record.conversationId) !== null && _b !== void 0 ? _b : 'unknown',
344
+ });
345
+ const metricsAttributes = {
346
+ ...attributes,
347
+ operation: 'continue.conversation',
348
+ 'operation.success': error === undefined,
349
+ };
350
+ metrics_1.HostingMetrics.proactiveOperationCounter.add(1, metricsAttributes);
351
+ metrics_1.HostingMetrics.proactiveOperationDuration.record(duration, metricsAttributes);
352
+ }
353
+ }),
354
+ createConversation: agents_telemetry_1.trace.define({
355
+ name: agents_telemetry_1.SpanNames.PROACTIVE_CREATE_CONVERSATION,
356
+ record: {
357
+ channelId: '',
358
+ membersCount: 0,
359
+ storeConversation: false,
360
+ hasHandler: false,
361
+ },
362
+ end({ span, record, duration, error }) {
363
+ var _a;
364
+ const attributes = {
365
+ 'activity.channel_id': (_a = record.channelId) !== null && _a !== void 0 ? _a : 'unknown',
366
+ 'proactive.store_conversation': record.storeConversation,
367
+ 'proactive.has_handler': record.hasHandler,
368
+ };
369
+ span.setAttributes({
370
+ ...attributes,
371
+ 'proactive.members_count': record.membersCount,
372
+ });
373
+ const metricsAttributes = {
374
+ ...attributes,
375
+ operation: 'create.conversation',
376
+ 'operation.success': error === undefined,
377
+ };
378
+ metrics_1.HostingMetrics.proactiveOperationCounter.add(1, metricsAttributes);
379
+ metrics_1.HostingMetrics.proactiveOperationDuration.record(duration, metricsAttributes);
380
+ }
381
+ }),
382
+ };
383
+ exports.ConnectorClientTraceDefinitions = {
384
+ getConversations: agents_telemetry_1.trace.define({
385
+ name: agents_telemetry_1.SpanNames.CONNECTOR_GET_CONVERSATIONS,
386
+ record: {
387
+ httpStatusCode: 'unknown',
388
+ },
389
+ end({ record, duration }) {
390
+ var _a;
391
+ const attributes = {
392
+ operation: 'get.conversations',
393
+ 'http.method': 'GET',
394
+ 'http.status_code': (_a = record.httpStatusCode) !== null && _a !== void 0 ? _a : 'unknown'
395
+ };
396
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
397
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
398
+ }
399
+ }),
400
+ getConversationMember: agents_telemetry_1.trace.define({
401
+ name: agents_telemetry_1.SpanNames.CONNECTOR_GET_CONVERSATION_MEMBER,
402
+ record: {
403
+ httpStatusCode: 'unknown',
404
+ },
405
+ end({ record, duration }) {
406
+ var _a;
407
+ const attributes = {
408
+ operation: 'get.conversation.member',
409
+ 'http.method': 'GET',
410
+ 'http.status_code': (_a = record.httpStatusCode) !== null && _a !== void 0 ? _a : 'unknown'
411
+ };
412
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
413
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
414
+ }
415
+ }),
416
+ createConversation: agents_telemetry_1.trace.define({
417
+ name: agents_telemetry_1.SpanNames.CONNECTOR_CREATE_CONVERSATION,
418
+ record: {
419
+ httpStatusCode: 'unknown',
420
+ },
421
+ end({ record, duration }) {
422
+ var _a;
423
+ const attributes = {
424
+ operation: 'create.conversation',
425
+ 'http.method': 'POST',
426
+ 'http.status_code': (_a = record.httpStatusCode) !== null && _a !== void 0 ? _a : 'unknown'
427
+ };
428
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
429
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
430
+ }
431
+ }),
432
+ replyToActivity: agents_telemetry_1.trace.define({
433
+ name: agents_telemetry_1.SpanNames.CONNECTOR_REPLY_TO_ACTIVITY,
434
+ record: {
435
+ conversationId: '',
436
+ activityId: '',
437
+ httpStatusCode: 'unknown',
438
+ },
439
+ end({ span, record, duration }) {
440
+ var _a, _b, _c;
441
+ span.setAttributes({
442
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
443
+ 'activity.id': (_b = record.activityId) !== null && _b !== void 0 ? _b : 'unknown',
444
+ });
445
+ const attributes = {
446
+ operation: 'reply.to.activity',
447
+ 'http.method': 'POST',
448
+ 'http.status_code': (_c = record.httpStatusCode) !== null && _c !== void 0 ? _c : 'unknown'
449
+ };
450
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
451
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
452
+ }
453
+ }),
454
+ sendToConversation: agents_telemetry_1.trace.define({
455
+ name: agents_telemetry_1.SpanNames.CONNECTOR_SEND_TO_CONVERSATION,
456
+ record: {
457
+ conversationId: '',
458
+ httpStatusCode: 'unknown',
459
+ },
460
+ end({ span, record, duration }) {
461
+ var _a, _b;
462
+ span.setAttribute('activity.conversation_id', (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown');
463
+ const attributes = {
464
+ operation: 'send.to.conversation',
465
+ 'http.method': 'POST',
466
+ 'http.status_code': (_b = record.httpStatusCode) !== null && _b !== void 0 ? _b : 'unknown'
467
+ };
468
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
469
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
470
+ }
471
+ }),
472
+ updateActivity: agents_telemetry_1.trace.define({
473
+ name: agents_telemetry_1.SpanNames.CONNECTOR_UPDATE_ACTIVITY,
474
+ record: {
475
+ conversationId: '',
476
+ activityId: '',
477
+ httpStatusCode: 'unknown',
478
+ },
479
+ end({ span, record, duration }) {
480
+ var _a, _b, _c;
481
+ span.setAttributes({
482
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
483
+ 'activity.id': (_b = record.activityId) !== null && _b !== void 0 ? _b : 'unknown',
484
+ });
485
+ const attributes = {
486
+ operation: 'update.activity',
487
+ 'http.method': 'PUT',
488
+ 'http.status_code': (_c = record.httpStatusCode) !== null && _c !== void 0 ? _c : 'unknown'
489
+ };
490
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
491
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
492
+ }
493
+ }),
494
+ deleteActivity: agents_telemetry_1.trace.define({
495
+ name: agents_telemetry_1.SpanNames.CONNECTOR_DELETE_ACTIVITY,
496
+ record: {
497
+ conversationId: '',
498
+ activityId: '',
499
+ httpStatusCode: 'unknown',
500
+ },
501
+ end({ span, record, duration }) {
502
+ var _a, _b, _c;
503
+ span.setAttributes({
504
+ 'activity.conversation_id': (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown',
505
+ 'activity.id': (_b = record.activityId) !== null && _b !== void 0 ? _b : 'unknown',
506
+ });
507
+ const attributes = {
508
+ operation: 'delete.activity',
509
+ 'http.method': 'DELETE',
510
+ 'http.status_code': (_c = record.httpStatusCode) !== null && _c !== void 0 ? _c : 'unknown'
511
+ };
512
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
513
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
514
+ }
515
+ }),
516
+ uploadAttachment: agents_telemetry_1.trace.define({
517
+ name: agents_telemetry_1.SpanNames.CONNECTOR_UPLOAD_ATTACHMENT,
518
+ record: {
519
+ conversationId: '',
520
+ httpStatusCode: 'unknown',
521
+ },
522
+ end({ span, record, duration }) {
523
+ var _a, _b;
524
+ span.setAttribute('activity.conversation_id', (_a = record.conversationId) !== null && _a !== void 0 ? _a : 'unknown');
525
+ const attributes = {
526
+ operation: 'upload.attachment',
527
+ 'http.method': 'POST',
528
+ 'http.status_code': (_b = record.httpStatusCode) !== null && _b !== void 0 ? _b : 'unknown'
529
+ };
530
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
531
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
532
+ }
533
+ }),
534
+ getAttachmentInfo: agents_telemetry_1.trace.define({
535
+ name: agents_telemetry_1.SpanNames.CONNECTOR_GET_ATTACHMENT_INFO,
536
+ record: {
537
+ attachmentId: '',
538
+ httpStatusCode: 'unknown',
539
+ },
540
+ end({ span, record, duration }) {
541
+ var _a, _b;
542
+ span.setAttribute('attachment.id', (_a = record.attachmentId) !== null && _a !== void 0 ? _a : 'unknown');
543
+ const attributes = {
544
+ operation: 'get.attachment.info',
545
+ 'http.method': 'GET',
546
+ 'http.status_code': (_b = record.httpStatusCode) !== null && _b !== void 0 ? _b : 'unknown'
547
+ };
548
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
549
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
550
+ }
551
+ }),
552
+ getAttachment: agents_telemetry_1.trace.define({
553
+ name: agents_telemetry_1.SpanNames.CONNECTOR_GET_ATTACHMENT,
554
+ record: {
555
+ attachmentId: '',
556
+ viewId: '',
557
+ httpStatusCode: 'unknown',
558
+ },
559
+ end({ span, record, duration }) {
560
+ var _a, _b, _c;
561
+ span.setAttributes({
562
+ 'attachment.id': (_a = record.attachmentId) !== null && _a !== void 0 ? _a : 'unknown',
563
+ 'view.id': (_b = record.viewId) !== null && _b !== void 0 ? _b : 'unknown',
564
+ });
565
+ const attributes = {
566
+ operation: 'get.attachment',
567
+ 'http.method': 'GET',
568
+ 'http.status_code': (_c = record.httpStatusCode) !== null && _c !== void 0 ? _c : 'unknown'
569
+ };
570
+ metrics_1.HostingMetrics.connectorRequestsCounter.add(1, attributes);
571
+ metrics_1.HostingMetrics.connectorRequestDuration.record(duration, attributes);
572
+ }
573
+ }),
574
+ };
575
+ exports.StorageTraceDefinitions = {
576
+ read: agents_telemetry_1.trace.define({
577
+ name: agents_telemetry_1.SpanNames.STORAGE_READ,
578
+ record: {
579
+ keyCount: 0,
580
+ },
581
+ end({ span, record, duration }) {
582
+ var _a;
583
+ const attributes = {
584
+ 'storage.operation': 'read',
585
+ 'storage.key.count': (_a = record.keyCount) !== null && _a !== void 0 ? _a : 0
586
+ };
587
+ span.setAttributes(attributes);
588
+ metrics_1.HostingMetrics.storageOperationDuration.record(duration, attributes);
589
+ }
590
+ }),
591
+ write: agents_telemetry_1.trace.define({
592
+ name: agents_telemetry_1.SpanNames.STORAGE_WRITE,
593
+ record: {
594
+ keyCount: 0,
595
+ },
596
+ end({ span, record, duration }) {
597
+ var _a;
598
+ const attributes = {
599
+ 'storage.operation': 'write',
600
+ 'storage.key.count': (_a = record.keyCount) !== null && _a !== void 0 ? _a : 0
601
+ };
602
+ span.setAttributes(attributes);
603
+ metrics_1.HostingMetrics.storageOperationDuration.record(duration, attributes);
604
+ }
605
+ }),
606
+ delete: agents_telemetry_1.trace.define({
607
+ name: agents_telemetry_1.SpanNames.STORAGE_DELETE,
608
+ record: {
609
+ keyCount: 0,
610
+ },
611
+ end({ span, record, duration }) {
612
+ var _a;
613
+ const attributes = {
614
+ 'storage.operation': 'delete',
615
+ 'storage.key.count': (_a = record.keyCount) !== null && _a !== void 0 ? _a : 0
616
+ };
617
+ span.setAttributes(attributes);
618
+ metrics_1.HostingMetrics.storageOperationDuration.record(duration, attributes);
619
+ }
620
+ }),
621
+ };
622
+ exports.AuthenticationTraceDefinitions = {
623
+ getAccessToken: agents_telemetry_1.trace.define({
624
+ name: agents_telemetry_1.SpanNames.AUTHENTICATION_GET_ACCESS_TOKEN,
625
+ record: {
626
+ scope: '',
627
+ method: 'unknown',
628
+ },
629
+ end({ span, record, duration, error }) {
630
+ var _a, _b;
631
+ const attributes = {
632
+ 'auth.scope': (_a = record.scope) !== null && _a !== void 0 ? _a : 'unknown',
633
+ 'auth.method': (_b = record.method) !== null && _b !== void 0 ? _b : 'unknown',
634
+ };
635
+ span.setAttributes(attributes);
636
+ metrics_1.HostingMetrics.authTokenRequestsCounter.add(1, {
637
+ 'auth.method': attributes['auth.method'],
638
+ 'auth.success': error === undefined
639
+ });
640
+ metrics_1.HostingMetrics.authTokenDuration.record(duration, {
641
+ 'auth.method': attributes['auth.method']
642
+ });
643
+ }
644
+ }),
645
+ acquireTokenOnBehalfOf: agents_telemetry_1.trace.define({
646
+ name: agents_telemetry_1.SpanNames.AUTHENTICATION_ACQUIRE_TOKEN_ON_BEHALF_OF,
647
+ record: {
648
+ scopes: [],
649
+ },
650
+ end({ span, record, duration, error }) {
651
+ const method = 'obo';
652
+ span.setAttribute('auth.scopes', record.scopes);
653
+ metrics_1.HostingMetrics.authTokenRequestsCounter.add(1, {
654
+ 'auth.method': method,
655
+ 'auth.success': error === undefined
656
+ });
657
+ metrics_1.HostingMetrics.authTokenDuration.record(duration, {
658
+ 'auth.method': method
659
+ });
660
+ }
661
+ }),
662
+ getAgenticInstanceToken: agents_telemetry_1.trace.define({
663
+ name: agents_telemetry_1.SpanNames.AUTHENTICATION_GET_AGENTIC_INSTANCE_TOKEN,
664
+ record: {
665
+ agenticInstanceId: '',
666
+ },
667
+ end({ span, record, duration, error }) {
668
+ var _a;
669
+ const method = 'agentic_instance';
670
+ span.setAttribute('agentic.instance_id', (_a = record.agenticInstanceId) !== null && _a !== void 0 ? _a : 'unknown');
671
+ metrics_1.HostingMetrics.authTokenRequestsCounter.add(1, {
672
+ 'auth.method': method,
673
+ 'auth.success': error === undefined
674
+ });
675
+ metrics_1.HostingMetrics.authTokenDuration.record(duration, {
676
+ 'auth.method': method
677
+ });
678
+ }
679
+ }),
680
+ getAgenticUserToken: agents_telemetry_1.trace.define({
681
+ name: agents_telemetry_1.SpanNames.AUTHENTICATION_GET_AGENTIC_USER_TOKEN,
682
+ record: {
683
+ agenticInstanceId: '',
684
+ agenticUserId: '',
685
+ scopes: [],
686
+ },
687
+ end({ span, record, duration, error }) {
688
+ var _a, _b;
689
+ const method = 'agentic_user';
690
+ span.setAttributes({
691
+ 'agentic.instance_id': (_a = record.agenticInstanceId) !== null && _a !== void 0 ? _a : 'unknown',
692
+ 'agentic.user_id': (_b = record.agenticUserId) !== null && _b !== void 0 ? _b : 'unknown',
693
+ 'auth.scopes': record.scopes
694
+ });
695
+ metrics_1.HostingMetrics.authTokenRequestsCounter.add(1, {
696
+ 'auth.method': method,
697
+ 'auth.success': error === undefined
698
+ });
699
+ metrics_1.HostingMetrics.authTokenDuration.record(duration, {
700
+ 'auth.method': method
701
+ });
702
+ }
703
+ }),
704
+ };
705
+ exports.AuthorizationTraceDefinitions = {
706
+ azureBotToken: agents_telemetry_1.trace.define({
707
+ name: agents_telemetry_1.SpanNames.AUTHORIZATION_AZURE_BOT_TOKEN,
708
+ record: {
709
+ handlerId: '',
710
+ connectionName: '',
711
+ },
712
+ end({ span, record }) {
713
+ var _a, _b;
714
+ span.setAttributes({
715
+ 'auth.handler.id': (_a = record.handlerId) !== null && _a !== void 0 ? _a : 'unknown',
716
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
717
+ });
718
+ }
719
+ }),
720
+ azureBotOBOToken: agents_telemetry_1.trace.define({
721
+ name: agents_telemetry_1.SpanNames.AUTHORIZATION_AZURE_BOT_OBO_TOKEN,
722
+ record: {
723
+ handlerId: '',
724
+ connectionName: '',
725
+ authScopes: [],
726
+ },
727
+ end({ span, record }) {
728
+ var _a, _b;
729
+ span.setAttributes({
730
+ 'auth.handler.id': (_a = record.handlerId) !== null && _a !== void 0 ? _a : 'unknown',
731
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
732
+ 'auth.scopes': record.authScopes
733
+ });
734
+ }
735
+ }),
736
+ azureBotSignout: agents_telemetry_1.trace.define({
737
+ name: agents_telemetry_1.SpanNames.AUTHORIZATION_AZURE_BOT_SIGNOUT,
738
+ record: {
739
+ handlerId: '',
740
+ connectionName: '',
741
+ channelId: '',
742
+ },
743
+ end({ span, record }) {
744
+ var _a, _b, _c;
745
+ span.setAttributes({
746
+ 'auth.handler.id': (_a = record.handlerId) !== null && _a !== void 0 ? _a : 'unknown',
747
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
748
+ 'activity.channel_id': (_c = record.channelId) !== null && _c !== void 0 ? _c : 'unknown',
749
+ });
750
+ }
751
+ }),
752
+ azureBotSignin: agents_telemetry_1.trace.define({
753
+ name: agents_telemetry_1.SpanNames.AUTHORIZATION_AZURE_BOT_SIGNIN,
754
+ record: {
755
+ handlerId: '',
756
+ status: 'unknown',
757
+ statusReason: '',
758
+ connectionName: '',
759
+ },
760
+ actions: ({ span }) => ({
761
+ async link(storage) {
762
+ const active = await storage.read();
763
+ if (!active) {
764
+ return;
765
+ }
766
+ if (active.__link) {
767
+ span.addLink({ context: active.__link });
768
+ }
769
+ active.__link = span.spanContext();
770
+ await storage.write(active);
771
+ }
772
+ }),
773
+ end({ span, record }) {
774
+ var _a, _b, _c, _d;
775
+ span.setAttributes({
776
+ 'auth.handler.id': (_a = record.handlerId) !== null && _a !== void 0 ? _a : 'unknown',
777
+ 'auth.handler.status': (_b = record.status) !== null && _b !== void 0 ? _b : 'unknown',
778
+ 'auth.handler.status.reason': (_c = record.statusReason) !== null && _c !== void 0 ? _c : '',
779
+ 'auth.connection.name': (_d = record.connectionName) !== null && _d !== void 0 ? _d : 'unknown',
780
+ });
781
+ }
782
+ }),
783
+ agenticToken: agents_telemetry_1.trace.define({
784
+ name: agents_telemetry_1.SpanNames.AUTHORIZATION_AGENTIC_TOKEN,
785
+ record: {
786
+ handlerId: '',
787
+ connectionName: '',
788
+ authScopes: [],
789
+ },
790
+ end({ span, record }) {
791
+ var _a, _b;
792
+ span.setAttributes({
793
+ 'auth.handler.id': (_a = record.handlerId) !== null && _a !== void 0 ? _a : 'unknown',
794
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
795
+ 'auth.scopes': record.authScopes
796
+ });
797
+ }
798
+ }),
799
+ };
800
+ exports.UserTokenClientTraceDefinitions = {
801
+ getUserToken: agents_telemetry_1.trace.define({
802
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_GET_USER_TOKEN,
803
+ record: {
804
+ userId: '',
805
+ connectionName: '',
806
+ channelId: '',
807
+ httpStatusCode: 'unknown',
808
+ },
809
+ end({ span, record, duration }) {
810
+ var _a, _b, _c, _d;
811
+ span.setAttributes({
812
+ 'user.id': (_a = record.userId) !== null && _a !== void 0 ? _a : 'unknown',
813
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
814
+ 'activity.channel_id': (_c = record.channelId) !== null && _c !== void 0 ? _c : 'unknown',
815
+ });
816
+ const attributes = {
817
+ operation: 'get.user.token',
818
+ 'http.method': 'GET',
819
+ 'http.status_code': (_d = record.httpStatusCode) !== null && _d !== void 0 ? _d : 'unknown'
820
+ };
821
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
822
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
823
+ }
824
+ }),
825
+ signOut: agents_telemetry_1.trace.define({
826
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_SIGN_OUT,
827
+ record: {
828
+ userId: '',
829
+ connectionName: '',
830
+ channelId: '',
831
+ httpStatusCode: 'unknown',
832
+ },
833
+ end({ span, record, duration }) {
834
+ var _a, _b, _c, _d;
835
+ span.setAttributes({
836
+ 'user.id': (_a = record.userId) !== null && _a !== void 0 ? _a : 'unknown',
837
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
838
+ 'activity.channel_id': (_c = record.channelId) !== null && _c !== void 0 ? _c : 'unknown',
839
+ });
840
+ const attributes = {
841
+ operation: 'sign.out',
842
+ 'http.method': 'DELETE',
843
+ 'http.status_code': (_d = record.httpStatusCode) !== null && _d !== void 0 ? _d : 'unknown'
844
+ };
845
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
846
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
847
+ }
848
+ }),
849
+ getSignInResource: agents_telemetry_1.trace.define({
850
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_GET_SIGN_IN_RESOURCE,
851
+ record: {
852
+ connectionName: '',
853
+ httpStatusCode: 'unknown',
854
+ },
855
+ end({ span, record, duration }) {
856
+ var _a, _b;
857
+ span.setAttribute('auth.connection.name', (_a = record.connectionName) !== null && _a !== void 0 ? _a : 'unknown');
858
+ const attributes = {
859
+ operation: 'get.sign.in.resource',
860
+ 'http.method': 'GET',
861
+ 'http.status_code': (_b = record.httpStatusCode) !== null && _b !== void 0 ? _b : 'unknown'
862
+ };
863
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
864
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
865
+ }
866
+ }),
867
+ exchangeToken: agents_telemetry_1.trace.define({
868
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_EXCHANGE_TOKEN,
869
+ record: {
870
+ userId: '',
871
+ connectionName: '',
872
+ channelId: '',
873
+ httpStatusCode: 'unknown',
874
+ },
875
+ end({ span, record, duration }) {
876
+ var _a, _b, _c, _d;
877
+ span.setAttributes({
878
+ 'user.id': (_a = record.userId) !== null && _a !== void 0 ? _a : 'unknown',
879
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
880
+ 'activity.channel_id': (_c = record.channelId) !== null && _c !== void 0 ? _c : 'unknown',
881
+ });
882
+ const attributes = {
883
+ operation: 'exchange.token',
884
+ 'http.method': 'POST',
885
+ 'http.status_code': (_d = record.httpStatusCode) !== null && _d !== void 0 ? _d : 'unknown'
886
+ };
887
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
888
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
889
+ }
890
+ }),
891
+ getTokenOrSignInResource: agents_telemetry_1.trace.define({
892
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_GET_TOKEN_OR_SIGN_IN_RESOURCE,
893
+ record: {
894
+ userId: '',
895
+ connectionName: '',
896
+ channelId: '',
897
+ httpStatusCode: 'unknown',
898
+ },
899
+ end({ span, record, duration }) {
900
+ var _a, _b, _c, _d;
901
+ span.setAttributes({
902
+ 'user.id': (_a = record.userId) !== null && _a !== void 0 ? _a : 'unknown',
903
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
904
+ 'activity.channel_id': (_c = record.channelId) !== null && _c !== void 0 ? _c : 'unknown',
905
+ });
906
+ const attributes = {
907
+ operation: 'get.token.or.sign.in.resource',
908
+ 'http.method': 'GET',
909
+ 'http.status_code': (_d = record.httpStatusCode) !== null && _d !== void 0 ? _d : 'unknown'
910
+ };
911
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
912
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
913
+ }
914
+ }),
915
+ getTokenStatus: agents_telemetry_1.trace.define({
916
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_GET_TOKEN_STATUS,
917
+ record: {
918
+ userId: '',
919
+ channelId: '',
920
+ httpStatusCode: 'unknown',
921
+ },
922
+ end({ span, record, duration }) {
923
+ var _a, _b, _c;
924
+ span.setAttributes({
925
+ 'user.id': (_a = record.userId) !== null && _a !== void 0 ? _a : 'unknown',
926
+ 'activity.channel_id': (_b = record.channelId) !== null && _b !== void 0 ? _b : 'unknown',
927
+ });
928
+ const attributes = {
929
+ operation: 'get.token.status',
930
+ 'http.method': 'GET',
931
+ 'http.status_code': (_c = record.httpStatusCode) !== null && _c !== void 0 ? _c : 'unknown'
932
+ };
933
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
934
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
935
+ }
936
+ }),
937
+ getAadTokens: agents_telemetry_1.trace.define({
938
+ name: agents_telemetry_1.SpanNames.USER_TOKEN_CLIENT_GET_AAD_TOKENS,
939
+ record: {
940
+ userId: '',
941
+ connectionName: '',
942
+ channelId: '',
943
+ httpStatusCode: 'unknown',
944
+ },
945
+ end({ span, record, duration }) {
946
+ var _a, _b, _c, _d;
947
+ span.setAttributes({
948
+ 'user.id': (_a = record.userId) !== null && _a !== void 0 ? _a : 'unknown',
949
+ 'auth.connection.name': (_b = record.connectionName) !== null && _b !== void 0 ? _b : 'unknown',
950
+ 'activity.channel_id': (_c = record.channelId) !== null && _c !== void 0 ? _c : 'unknown',
951
+ });
952
+ const attributes = {
953
+ operation: 'get.aad.tokens',
954
+ 'http.method': 'POST',
955
+ 'http.status_code': (_d = record.httpStatusCode) !== null && _d !== void 0 ? _d : 'unknown'
956
+ };
957
+ metrics_1.HostingMetrics.userTokenClientRequestsCounter.add(1, attributes);
958
+ metrics_1.HostingMetrics.userTokenClientRequestDuration.record(duration, attributes);
959
+ }
960
+ }),
961
+ };
962
+ //# sourceMappingURL=traces.js.map