@microsoft/agents-hosting 1.5.0-beta.6.ga236d9a19c → 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.
- package/dist/package.json +10 -9
- package/dist/src/activityHandler.js +2 -2
- package/dist/src/activityHandler.js.map +1 -1
- package/dist/src/agent-client/agentClient.js +49 -40
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.js +2 -2
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +36 -10
- package/dist/src/app/agentApplication.js +169 -99
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +15 -0
- package/dist/src/app/agentApplicationBuilder.js +22 -4
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +38 -0
- package/dist/src/app/attachmentDownloader.js +2 -2
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/auth/authorization.js +12 -9
- package/dist/src/app/auth/authorization.js.map +1 -1
- package/dist/src/app/auth/authorizationManager.d.ts +18 -5
- package/dist/src/app/auth/authorizationManager.js +258 -45
- package/dist/src/app/auth/authorizationManager.js.map +1 -1
- package/dist/src/app/auth/handlerStorage.js +3 -1
- package/dist/src/app/auth/handlerStorage.js.map +1 -1
- package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +19 -16
- package/dist/src/app/auth/handlers/agenticAuthorization.js +46 -52
- package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +51 -75
- package/dist/src/app/auth/handlers/azureBotAuthorization.js +217 -192
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
- package/dist/src/app/auth/types.d.ts +100 -1
- package/dist/src/app/auth/utils.d.ts +10 -0
- package/dist/src/app/auth/utils.js +21 -0
- package/dist/src/app/auth/utils.js.map +1 -0
- package/dist/src/app/index.d.ts +1 -0
- package/dist/src/app/index.js +1 -0
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/proactive/conversation.d.ts +43 -0
- package/dist/src/app/proactive/conversation.js +67 -0
- package/dist/src/app/proactive/conversation.js.map +1 -0
- package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
- package/dist/src/app/proactive/conversationBuilder.js +110 -0
- package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
- package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
- package/dist/src/app/proactive/createConversationOptions.js +10 -0
- package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
- package/dist/src/app/proactive/index.d.ts +7 -0
- package/dist/src/app/proactive/index.js +26 -0
- package/dist/src/app/proactive/index.js.map +1 -0
- package/dist/src/app/proactive/proactive.d.ts +248 -0
- package/dist/src/app/proactive/proactive.js +310 -0
- package/dist/src/app/proactive/proactive.js.map +1 -0
- package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
- package/dist/src/app/proactive/proactiveOptions.js +5 -0
- package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.js +2 -2
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/teamsAttachmentDownloader.js +2 -2
- package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
- package/dist/src/app/turnState.js +2 -2
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +61 -0
- package/dist/src/auth/authConfiguration.js +52 -3
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js +2 -2
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalConnectionManager.js +20 -0
- package/dist/src/auth/msalConnectionManager.js.map +1 -1
- package/dist/src/auth/msalTokenCredential.js +3 -0
- package/dist/src/auth/msalTokenCredential.js.map +1 -1
- package/dist/src/auth/msalTokenProvider.js +136 -110
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/baseAdapter.js +2 -2
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cloudAdapter.js +201 -154
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.js +176 -127
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/errorHelper.js +108 -0
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/middlewareSet.js +2 -2
- package/dist/src/middlewareSet.js.map +1 -1
- package/dist/src/oauth/userTokenClient.js +78 -48
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/observability/index.d.ts +2 -0
- package/dist/src/observability/index.js +21 -0
- package/dist/src/observability/index.js.map +1 -0
- package/dist/src/observability/metrics.d.ts +21 -0
- package/dist/src/observability/metrics.js +87 -0
- package/dist/src/observability/metrics.js.map +1 -0
- package/dist/src/observability/traces.d.ts +234 -0
- package/dist/src/observability/traces.js +962 -0
- package/dist/src/observability/traces.js.map +1 -0
- package/dist/src/state/agentState.js +2 -2
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/storage/fileStorage.js +38 -28
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/memoryStorage.js +41 -30
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/transcript/fileTranscriptLogger.js +2 -2
- package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -2
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
- package/dist/src/turnContext.js +48 -42
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +10 -9
- package/src/activityHandler.ts +1 -1
- package/src/agent-client/agentClient.ts +53 -42
- package/src/agent-client/agentResponseHandler.ts +1 -1
- package/src/app/agentApplication.ts +212 -86
- package/src/app/agentApplicationBuilder.ts +26 -4
- package/src/app/agentApplicationOptions.ts +43 -0
- package/src/app/attachmentDownloader.ts +1 -1
- package/src/app/auth/authorization.ts +11 -8
- package/src/app/auth/authorizationManager.ts +297 -45
- package/src/app/auth/handlerStorage.ts +3 -1
- package/src/app/auth/handlers/agenticAuthorization.ts +68 -72
- package/src/app/auth/handlers/azureBotAuthorization.ts +260 -264
- package/src/app/auth/types.ts +102 -1
- package/src/app/auth/utils.ts +22 -0
- package/src/app/index.ts +1 -0
- package/src/app/proactive/conversation.ts +87 -0
- package/src/app/proactive/conversationBuilder.ts +139 -0
- package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
- package/src/app/proactive/createConversationOptions.ts +35 -0
- package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
- package/src/app/proactive/index.ts +10 -0
- package/src/app/proactive/proactive.ts +524 -0
- package/src/app/proactive/proactiveOptions.ts +24 -0
- package/src/app/streaming/streamingResponse.ts +1 -1
- package/src/app/teamsAttachmentDownloader.ts +1 -1
- package/src/app/turnState.ts +1 -1
- package/src/auth/authConfiguration.ts +58 -1
- package/src/auth/jwt-middleware.ts +1 -1
- package/src/auth/msalConnectionManager.ts +22 -0
- package/src/auth/msalTokenCredential.ts +4 -0
- package/src/auth/msalTokenProvider.ts +138 -107
- package/src/baseAdapter.ts +1 -1
- package/src/cloudAdapter.ts +239 -184
- package/src/connector-client/connectorClient.ts +169 -126
- package/src/errorHelper.ts +124 -0
- package/src/middlewareSet.ts +1 -1
- package/src/oauth/userTokenClient.ts +70 -46
- package/src/observability/index.ts +5 -0
- package/src/observability/metrics.ts +103 -0
- package/src/observability/traces.ts +988 -0
- package/src/state/agentState.ts +1 -1
- package/src/storage/fileStorage.ts +36 -26
- package/src/storage/memoryStorage.ts +40 -29
- package/src/transcript/fileTranscriptLogger.ts +1 -1
- package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
- package/src/turnContext.ts +47 -41
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
3
3
|
import { AuthConfiguration } from '../auth/authConfiguration'
|
|
4
4
|
import { AuthProvider } from '../auth/authProvider'
|
|
5
|
-
import { debug } from '@microsoft/agents-
|
|
5
|
+
import { debug } from '@microsoft/agents-telemetry'
|
|
6
6
|
import { Activity, ChannelAccount, ConversationParameters, RoleTypes, Channels, ExceptionHelper } from '@microsoft/agents-activity'
|
|
7
7
|
import { Errors } from '../errorHelper'
|
|
8
8
|
import { ConversationsResult } from './conversationsResult'
|
|
@@ -13,6 +13,9 @@ import { AttachmentData } from './attachmentData'
|
|
|
13
13
|
import { normalizeOutgoingActivity } from '../activityWireCompat'
|
|
14
14
|
import { getProductInfo } from '../getProductInfo'
|
|
15
15
|
import { HeaderPropagation, HeaderPropagationCollection } from '../headerPropagation'
|
|
16
|
+
import { trace } from '@microsoft/agents-telemetry'
|
|
17
|
+
import { ConnectorClientTraceDefinitions } from '../observability'
|
|
18
|
+
|
|
16
19
|
const logger = debug('agents:connector-client')
|
|
17
20
|
|
|
18
21
|
export { getProductInfo }
|
|
@@ -139,28 +142,34 @@ export class ConnectorClient {
|
|
|
139
142
|
* @returns A list of conversations.
|
|
140
143
|
*/
|
|
141
144
|
public async getConversations (continuationToken?: string): Promise<ConversationsResult> {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
return trace(ConnectorClientTraceDefinitions.getConversations, async ({ record }) => {
|
|
146
|
+
const config: AxiosRequestConfig = {
|
|
147
|
+
method: 'get',
|
|
148
|
+
url: '/v3/conversations',
|
|
149
|
+
params: continuationToken ? { continuationToken } : undefined
|
|
150
|
+
}
|
|
151
|
+
const response = await this._axiosInstance(config)
|
|
152
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
153
|
+
return response.data
|
|
154
|
+
})
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
public async getConversationMember (userId: string, conversationId: string): Promise<ChannelAccount> {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const config: AxiosRequestConfig = {
|
|
156
|
-
method: 'get',
|
|
157
|
-
url: `v3/conversations/${conversationId}/members/${userId}`,
|
|
158
|
-
headers: {
|
|
159
|
-
'Content-Type': 'application/json'
|
|
158
|
+
return trace(ConnectorClientTraceDefinitions.getConversationMember, async ({ record }) => {
|
|
159
|
+
if (!userId || !conversationId) {
|
|
160
|
+
throw ExceptionHelper.generateException(Error, Errors.UserIdAndConversationIdRequired)
|
|
160
161
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
const config: AxiosRequestConfig = {
|
|
163
|
+
method: 'get',
|
|
164
|
+
url: `v3/conversations/${conversationId}/members/${userId}`,
|
|
165
|
+
headers: {
|
|
166
|
+
'Content-Type': 'application/json'
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const response = await this._axiosInstance(config)
|
|
170
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
171
|
+
return response.data
|
|
172
|
+
})
|
|
164
173
|
}
|
|
165
174
|
|
|
166
175
|
/**
|
|
@@ -169,20 +178,23 @@ export class ConnectorClient {
|
|
|
169
178
|
* @returns The conversation resource response.
|
|
170
179
|
*/
|
|
171
180
|
public async createConversation (body: ConversationParameters): Promise<ConversationResourceResponse> {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
return trace(ConnectorClientTraceDefinitions.createConversation, async ({ record }) => {
|
|
182
|
+
const payload = {
|
|
183
|
+
...body,
|
|
184
|
+
activity: normalizeOutgoingActivity(body.activity)
|
|
185
|
+
}
|
|
186
|
+
const config: AxiosRequestConfig = {
|
|
187
|
+
method: 'post',
|
|
188
|
+
url: '/v3/conversations',
|
|
189
|
+
headers: {
|
|
190
|
+
'Content-Type': 'application/json'
|
|
191
|
+
},
|
|
192
|
+
data: payload
|
|
193
|
+
}
|
|
194
|
+
const response: AxiosResponse = await this._axiosInstance(config)
|
|
195
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
196
|
+
return response.data
|
|
197
|
+
})
|
|
186
198
|
}
|
|
187
199
|
|
|
188
200
|
/**
|
|
@@ -197,24 +209,29 @@ export class ConnectorClient {
|
|
|
197
209
|
activityId: string,
|
|
198
210
|
body: Activity
|
|
199
211
|
): Promise<ResourceResponse> {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
212
|
+
return trace(ConnectorClientTraceDefinitions.replyToActivity, async ({ record }) => {
|
|
213
|
+
logger.debug(`Replying to activity: ${activityId} in conversation: ${conversationId}`)
|
|
214
|
+
record({ conversationId, activityId })
|
|
204
215
|
|
|
205
|
-
|
|
216
|
+
if (!conversationId || !activityId) {
|
|
217
|
+
throw ExceptionHelper.generateException(Error, Errors.ConversationIdAndActivityIdRequired)
|
|
218
|
+
}
|
|
206
219
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
const trimmedConversationId: string = this.conditionallyTruncateConversationId(conversationId, body)
|
|
221
|
+
|
|
222
|
+
const config: AxiosRequestConfig = {
|
|
223
|
+
method: 'post',
|
|
224
|
+
url: `v3/conversations/${trimmedConversationId}/activities/${encodeURIComponent(activityId)}`,
|
|
225
|
+
headers: {
|
|
226
|
+
'Content-Type': 'application/json'
|
|
227
|
+
},
|
|
228
|
+
data: normalizeOutgoingActivity(body)
|
|
229
|
+
}
|
|
230
|
+
const response = await this._axiosInstance(config)
|
|
231
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
232
|
+
logger.info('Reply to conversation/activity: ', response.data.id!, activityId)
|
|
233
|
+
return response.data
|
|
234
|
+
})
|
|
218
235
|
}
|
|
219
236
|
|
|
220
237
|
/**
|
|
@@ -247,23 +264,28 @@ export class ConnectorClient {
|
|
|
247
264
|
conversationId: string,
|
|
248
265
|
body: Activity
|
|
249
266
|
): Promise<ResourceResponse> {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
267
|
+
return trace(ConnectorClientTraceDefinitions.sendToConversation, async ({ record }) => {
|
|
268
|
+
logger.debug(`Send to conversation: ${conversationId} activity: ${body.id}`)
|
|
269
|
+
if (!conversationId) {
|
|
270
|
+
throw ExceptionHelper.generateException(Error, Errors.ConversationIdRequired)
|
|
271
|
+
}
|
|
254
272
|
|
|
255
|
-
|
|
273
|
+
record({ conversationId })
|
|
256
274
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
275
|
+
const trimmedConversationId: string = this.conditionallyTruncateConversationId(conversationId, body)
|
|
276
|
+
|
|
277
|
+
const config: AxiosRequestConfig = {
|
|
278
|
+
method: 'post',
|
|
279
|
+
url: `v3/conversations/${trimmedConversationId}/activities`,
|
|
280
|
+
headers: {
|
|
281
|
+
'Content-Type': 'application/json'
|
|
282
|
+
},
|
|
283
|
+
data: normalizeOutgoingActivity(body)
|
|
284
|
+
}
|
|
285
|
+
const response = await this._axiosInstance(config)
|
|
286
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
287
|
+
return response.data
|
|
288
|
+
})
|
|
267
289
|
}
|
|
268
290
|
|
|
269
291
|
/**
|
|
@@ -278,19 +300,23 @@ export class ConnectorClient {
|
|
|
278
300
|
activityId: string,
|
|
279
301
|
body: Activity
|
|
280
302
|
): Promise<ResourceResponse> {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
303
|
+
return trace(ConnectorClientTraceDefinitions.updateActivity, async ({ record }) => {
|
|
304
|
+
if (!conversationId || !activityId) {
|
|
305
|
+
throw ExceptionHelper.generateException(Error, Errors.ConversationIdAndActivityIdRequired)
|
|
306
|
+
}
|
|
307
|
+
record({ conversationId, activityId })
|
|
308
|
+
const config: AxiosRequestConfig = {
|
|
309
|
+
method: 'put',
|
|
310
|
+
url: `v3/conversations/${conversationId}/activities/${activityId}`,
|
|
311
|
+
headers: {
|
|
312
|
+
'Content-Type': 'application/json'
|
|
313
|
+
},
|
|
314
|
+
data: normalizeOutgoingActivity(body)
|
|
315
|
+
}
|
|
316
|
+
const response = await this._axiosInstance(config)
|
|
317
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
318
|
+
return response.data
|
|
319
|
+
})
|
|
294
320
|
}
|
|
295
321
|
|
|
296
322
|
/**
|
|
@@ -303,18 +329,23 @@ export class ConnectorClient {
|
|
|
303
329
|
conversationId: string,
|
|
304
330
|
activityId: string
|
|
305
331
|
): Promise<void> {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
url: `v3/conversations/${conversationId}/activities/${activityId}`,
|
|
312
|
-
headers: {
|
|
313
|
-
'Content-Type': 'application/json'
|
|
332
|
+
return trace(ConnectorClientTraceDefinitions.deleteActivity, async ({ record }) => {
|
|
333
|
+
record({ conversationId, activityId })
|
|
334
|
+
|
|
335
|
+
if (!conversationId || !activityId) {
|
|
336
|
+
throw ExceptionHelper.generateException(Error, Errors.ConversationIdAndActivityIdRequired)
|
|
314
337
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
338
|
+
const config: AxiosRequestConfig = {
|
|
339
|
+
method: 'delete',
|
|
340
|
+
url: `v3/conversations/${conversationId}/activities/${activityId}`,
|
|
341
|
+
headers: {
|
|
342
|
+
'Content-Type': 'application/json'
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const response = await this._axiosInstance(config)
|
|
346
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
347
|
+
return response.data
|
|
348
|
+
})
|
|
318
349
|
}
|
|
319
350
|
|
|
320
351
|
/**
|
|
@@ -327,19 +358,23 @@ export class ConnectorClient {
|
|
|
327
358
|
conversationId: string,
|
|
328
359
|
body: AttachmentData
|
|
329
360
|
): Promise<ResourceResponse> {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
361
|
+
return trace(ConnectorClientTraceDefinitions.uploadAttachment, async ({ record }) => {
|
|
362
|
+
record({ conversationId })
|
|
363
|
+
if (conversationId === undefined) {
|
|
364
|
+
throw ExceptionHelper.generateException(Error, Errors.ConversationIdRequired)
|
|
365
|
+
}
|
|
366
|
+
const config: AxiosRequestConfig = {
|
|
367
|
+
method: 'post',
|
|
368
|
+
url: `v3/conversations/${conversationId}/attachments`,
|
|
369
|
+
headers: {
|
|
370
|
+
'Content-Type': 'application/json'
|
|
371
|
+
},
|
|
372
|
+
data: body
|
|
373
|
+
}
|
|
374
|
+
const response = await this._axiosInstance(config)
|
|
375
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
376
|
+
return response.data
|
|
377
|
+
})
|
|
343
378
|
}
|
|
344
379
|
|
|
345
380
|
/**
|
|
@@ -350,18 +385,22 @@ export class ConnectorClient {
|
|
|
350
385
|
public async getAttachmentInfo (
|
|
351
386
|
attachmentId: string
|
|
352
387
|
): Promise<AttachmentInfo> {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
method: 'get',
|
|
358
|
-
url: `v3/attachments/${attachmentId}`,
|
|
359
|
-
headers: {
|
|
360
|
-
'Content-Type': 'application/json'
|
|
388
|
+
return trace(ConnectorClientTraceDefinitions.getAttachmentInfo, async ({ record }) => {
|
|
389
|
+
record({ attachmentId })
|
|
390
|
+
if (attachmentId === undefined) {
|
|
391
|
+
throw ExceptionHelper.generateException(Error, Errors.AttachmentIdRequired)
|
|
361
392
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
393
|
+
const config: AxiosRequestConfig = {
|
|
394
|
+
method: 'get',
|
|
395
|
+
url: `v3/attachments/${attachmentId}`,
|
|
396
|
+
headers: {
|
|
397
|
+
'Content-Type': 'application/json'
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const response = await this._axiosInstance(config)
|
|
401
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
402
|
+
return response.data
|
|
403
|
+
})
|
|
365
404
|
}
|
|
366
405
|
|
|
367
406
|
/**
|
|
@@ -374,20 +413,24 @@ export class ConnectorClient {
|
|
|
374
413
|
attachmentId: string,
|
|
375
414
|
viewId: string
|
|
376
415
|
): Promise<NodeJS.ReadableStream> {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
throw ExceptionHelper.generateException(Error, Errors.ViewIdRequired)
|
|
382
|
-
}
|
|
383
|
-
const config: AxiosRequestConfig = {
|
|
384
|
-
method: 'get',
|
|
385
|
-
url: `v3/attachments/${attachmentId}/views/${viewId}`,
|
|
386
|
-
headers: {
|
|
387
|
-
'Content-Type': 'application/json'
|
|
416
|
+
return trace(ConnectorClientTraceDefinitions.getAttachment, async ({ record }) => {
|
|
417
|
+
record({ attachmentId, viewId })
|
|
418
|
+
if (attachmentId === undefined) {
|
|
419
|
+
throw ExceptionHelper.generateException(Error, Errors.AttachmentIdRequired)
|
|
388
420
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
421
|
+
if (viewId === undefined) {
|
|
422
|
+
throw ExceptionHelper.generateException(Error, Errors.ViewIdRequired)
|
|
423
|
+
}
|
|
424
|
+
const config: AxiosRequestConfig = {
|
|
425
|
+
method: 'get',
|
|
426
|
+
url: `v3/attachments/${attachmentId}/views/${viewId}`,
|
|
427
|
+
headers: {
|
|
428
|
+
'Content-Type': 'application/json'
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
const response = await this._axiosInstance(config)
|
|
432
|
+
record({ httpStatusCode: response.status?.toString() })
|
|
433
|
+
return response.data
|
|
434
|
+
})
|
|
392
435
|
}
|
|
393
436
|
}
|
package/src/errorHelper.ts
CHANGED
|
@@ -500,6 +500,22 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
500
500
|
description: 'Storage is required for Authorization. Ensure that a storage provider is configured in the app options.'
|
|
501
501
|
},
|
|
502
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Error thrown when the azureBotOAuthConnectionName option is missing for AzureBot authorization.
|
|
505
|
+
*/
|
|
506
|
+
AzureBotOAuthConnectionNameRequired: {
|
|
507
|
+
code: -120591,
|
|
508
|
+
description: "The 'azureBotOAuthConnectionName' option is not available in the app options. Ensure that the app is properly configured."
|
|
509
|
+
},
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Error thrown when the AzureBot connection token is not exchangeable for an OBO flow.
|
|
513
|
+
*/
|
|
514
|
+
AzureBotConnectionTokenNotExchangeable: {
|
|
515
|
+
code: -120592,
|
|
516
|
+
description: "The current token for the '{connectionName}' AzureBot connection is not exchangeable for an on-behalf-of flow. Ensure the base token audience is for the bot/resource app, such as an App ID URI like 'api://...' or otherwise includes the app's client id."
|
|
517
|
+
},
|
|
518
|
+
|
|
503
519
|
// ============================================================================
|
|
504
520
|
// Agent and Client Errors (-120600 to -120630)
|
|
505
521
|
// ============================================================================
|
|
@@ -660,6 +676,114 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
660
676
|
description: 'Invalid action value: {error}'
|
|
661
677
|
},
|
|
662
678
|
|
|
679
|
+
// ============================================================================
|
|
680
|
+
// Proactive Messaging Errors (-120740 to -120799)
|
|
681
|
+
// ============================================================================
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Error thrown when Application.proactive is accessed but no storage was configured.
|
|
685
|
+
*/
|
|
686
|
+
ProactivePropertyUnavailable: {
|
|
687
|
+
code: -120740,
|
|
688
|
+
description: 'The Application.proactive property is unavailable because no storage was configured. Set options.storage or options.proactive.storage.'
|
|
689
|
+
},
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Error thrown when a proactive storage operation is attempted without a storage backend.
|
|
693
|
+
*/
|
|
694
|
+
ProactiveStorageRequired: {
|
|
695
|
+
code: -120741,
|
|
696
|
+
description: 'This proactive operation requires a storage backend. Set options.storage or options.proactive.storage.'
|
|
697
|
+
},
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Error thrown when a conversation is not found in proactive storage.
|
|
701
|
+
*/
|
|
702
|
+
ProactiveConversationNotFound: {
|
|
703
|
+
code: -120742,
|
|
704
|
+
description: "Conversation '{conversationId}' was not found in proactive storage."
|
|
705
|
+
},
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Error thrown when sendActivity does not receive a ResourceResponse from the adapter.
|
|
709
|
+
*/
|
|
710
|
+
ProactiveSendActivityNoResponse: {
|
|
711
|
+
code: -120743,
|
|
712
|
+
description: 'sendActivity: adapter did not return a ResourceResponse.'
|
|
713
|
+
},
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Error thrown when not all token handlers have a signed-in user for proactive continuation.
|
|
717
|
+
*/
|
|
718
|
+
ProactiveNotAllTokensAcquired: {
|
|
719
|
+
code: -120744,
|
|
720
|
+
description: 'Not all token handlers have a signed-in user.'
|
|
721
|
+
},
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Error thrown when createConversation is called without any members.
|
|
725
|
+
*/
|
|
726
|
+
ProactiveMembersRequired: {
|
|
727
|
+
code: -120745,
|
|
728
|
+
description: 'createConversation: at least one member must be specified in parameters.members.'
|
|
729
|
+
},
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Error thrown when the adapter passed to createConversation does not support createConversationAsync.
|
|
733
|
+
*/
|
|
734
|
+
ProactiveCloudAdapterRequired: {
|
|
735
|
+
code: -120746,
|
|
736
|
+
description: 'createConversation requires a CloudAdapter. The provided adapter does not implement createConversationAsync().'
|
|
737
|
+
},
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Error thrown when createConversationAsync completes without invoking its callback.
|
|
741
|
+
*/
|
|
742
|
+
ProactiveCallbackNotInvoked: {
|
|
743
|
+
code: -120747,
|
|
744
|
+
description: 'createConversation: createConversationAsync completed without invoking its callback.'
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* Error thrown when a Conversation reference is missing conversation.id.
|
|
749
|
+
*/
|
|
750
|
+
ConversationInvalidId: {
|
|
751
|
+
code: -120748,
|
|
752
|
+
description: 'Conversation is invalid: reference.conversation.id is required.'
|
|
753
|
+
},
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Error thrown when a Conversation reference is missing serviceUrl.
|
|
757
|
+
*/
|
|
758
|
+
ConversationInvalidServiceUrl: {
|
|
759
|
+
code: -120749,
|
|
760
|
+
description: 'Conversation is invalid: reference.serviceUrl is required.'
|
|
761
|
+
},
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Error thrown when a Conversation reference is missing claims.aud.
|
|
765
|
+
*/
|
|
766
|
+
ConversationInvalidAud: {
|
|
767
|
+
code: -120750,
|
|
768
|
+
description: 'Conversation is invalid: claims.aud (agent client ID) is required.'
|
|
769
|
+
},
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Error thrown when CreateConversationOptionsBuilder.build() is called without any members.
|
|
773
|
+
*/
|
|
774
|
+
CreateConversationBuilderMembersRequired: {
|
|
775
|
+
code: -120751,
|
|
776
|
+
description: 'CreateConversationOptionsBuilder: at least one members entry must be added via withUser().'
|
|
777
|
+
},
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Error thrown when a proactive operation that requires TurnState load/save is called without app storage.
|
|
781
|
+
*/
|
|
782
|
+
ProactiveAppStorageRequired: {
|
|
783
|
+
code: -120752,
|
|
784
|
+
description: 'This proactive operation requires app storage to load and save TurnState. Set options.storage on AgentApplication.'
|
|
785
|
+
},
|
|
786
|
+
|
|
663
787
|
// ============================================================================
|
|
664
788
|
// General Errors (-120990)
|
|
665
789
|
// ============================================================================
|
package/src/middlewareSet.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */
|
|
2
2
|
import { TurnContext } from './turnContext'
|
|
3
|
-
import { debug } from '@microsoft/agents-
|
|
3
|
+
import { debug } from '@microsoft/agents-telemetry'
|
|
4
4
|
|
|
5
5
|
const logger = debug('agents:middleware')
|
|
6
6
|
|