@microsoft/agents-hosting 0.4.3 → 0.5.4-ga4d0401645
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/src/activityWireCompat.js +1 -1
- package/dist/src/activityWireCompat.js.map +1 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.d.ts +115 -0
- package/dist/src/app/adaptiveCards/activityValueParsers.js +224 -0
- package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.d.ts +21 -0
- package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.js +26 -0
- package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +57 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +272 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsOptions.d.ts +20 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsOptions.js +7 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsOptions.js.map +1 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.d.ts +31 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js +16 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js.map +1 -0
- package/dist/src/app/adaptiveCards/index.d.ts +3 -0
- package/dist/src/app/adaptiveCards/index.js +20 -0
- package/dist/src/app/adaptiveCards/index.js.map +1 -0
- package/dist/src/app/adaptiveCards/query.d.ts +22 -0
- package/dist/src/app/adaptiveCards/query.js +7 -0
- package/dist/src/app/adaptiveCards/query.js.map +1 -0
- package/dist/src/app/agentApplication.d.ts +56 -8
- package/dist/src/app/agentApplication.js +88 -11
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +2 -2
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +17 -2
- package/dist/src/app/appRoute.d.ts +5 -0
- package/dist/src/app/attachmentDownloader.js +1 -0
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/extensions.d.ts +9 -0
- package/dist/src/app/extensions.js +16 -0
- package/dist/src/app/extensions.js.map +1 -0
- package/dist/src/app/index.d.ts +2 -0
- package/dist/src/app/index.js +2 -0
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/streaming/AIEntity.d.ts +36 -0
- package/dist/src/app/streaming/AIEntity.js +7 -0
- package/dist/src/app/streaming/AIEntity.js.map +1 -0
- package/dist/src/app/streaming/actionCall.d.ts +33 -0
- package/dist/src/app/streaming/actionCall.js +7 -0
- package/dist/src/app/streaming/actionCall.js.map +1 -0
- package/dist/src/app/streaming/clientCitation.d.ts +68 -0
- package/dist/src/app/streaming/clientCitation.js +10 -0
- package/dist/src/app/streaming/clientCitation.js.map +1 -0
- package/dist/src/app/streaming/message.d.ts +106 -0
- package/dist/src/app/streaming/message.js +7 -0
- package/dist/src/app/streaming/message.js.map +1 -0
- package/dist/src/app/streaming/sensitivityUsageInfo.d.ts +40 -0
- package/dist/src/app/streaming/sensitivityUsageInfo.js +3 -0
- package/dist/src/app/streaming/sensitivityUsageInfo.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.d.ts +141 -0
- package/dist/src/app/streaming/streamingResponse.js +331 -0
- package/dist/src/app/streaming/streamingResponse.js.map +1 -0
- package/dist/src/app/streaming/utilities.d.ts +31 -0
- package/dist/src/app/streaming/utilities.js +101 -0
- package/dist/src/app/streaming/utilities.js.map +1 -0
- package/dist/src/auth/jwt-middleware.js +1 -0
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/baseAdapter.js +1 -1
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cards/adaptiveCard.d.ts +15 -0
- package/dist/src/cards/adaptiveCard.js +7 -0
- package/dist/src/cards/adaptiveCard.js.map +1 -0
- package/dist/src/cards/index.d.ts +1 -0
- package/dist/src/cards/index.js +1 -0
- package/dist/src/cards/index.js.map +1 -1
- package/dist/src/cloudAdapter.js +6 -7
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.d.ts +6 -4
- package/dist/src/connector-client/connectorClient.js +34 -17
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/turnContext.d.ts +3 -0
- package/dist/src/turnContext.js +5 -0
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +2 -2
- package/src/activityWireCompat.ts +1 -1
- package/src/app/adaptiveCards/activityValueParsers.ts +249 -0
- package/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.ts +24 -0
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +320 -0
- package/src/app/adaptiveCards/adaptiveCardsOptions.ts +23 -0
- package/src/app/adaptiveCards/adaptiveCardsSearchParams.ts +28 -0
- package/src/app/adaptiveCards/index.ts +3 -0
- package/src/app/adaptiveCards/query.ts +25 -0
- package/src/app/agentApplication.ts +109 -29
- package/src/app/agentApplicationBuilder.ts +2 -2
- package/src/app/agentApplicationOptions.ts +20 -2
- package/src/app/appRoute.ts +6 -0
- package/src/app/attachmentDownloader.ts +1 -0
- package/src/app/extensions.ts +19 -0
- package/src/app/index.ts +2 -0
- package/src/app/streaming/AIEntity.ts +44 -0
- package/src/app/streaming/actionCall.ts +37 -0
- package/src/app/streaming/clientCitation.ts +102 -0
- package/src/app/streaming/message.ts +125 -0
- package/src/app/streaming/sensitivityUsageInfo.ts +48 -0
- package/src/app/streaming/streamingResponse.ts +406 -0
- package/src/app/streaming/utilities.ts +108 -0
- package/src/auth/jwt-middleware.ts +1 -1
- package/src/baseAdapter.ts +2 -2
- package/src/cards/adaptiveCard.ts +16 -0
- package/src/cards/index.ts +1 -0
- package/src/cloudAdapter.ts +5 -7
- package/src/connector-client/connectorClient.ts +38 -19
- package/src/turnContext.ts +7 -1
|
@@ -3,7 +3,7 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
|
3
3
|
import { AuthConfiguration } from '../auth/authConfiguration'
|
|
4
4
|
import { AuthProvider } from '../auth/authProvider'
|
|
5
5
|
import { debug } from '../logger'
|
|
6
|
-
import { Activity, ConversationParameters } from '@microsoft/agents-activity'
|
|
6
|
+
import { Activity, ChannelAccount, ConversationParameters } from '@microsoft/agents-activity'
|
|
7
7
|
import { ConversationsResult } from './conversationsResult'
|
|
8
8
|
import { ConversationResourceResponse } from './conversationResourceResponse'
|
|
9
9
|
import { ResourceResponse } from './resourceResponse'
|
|
@@ -19,21 +19,21 @@ export { getProductInfo }
|
|
|
19
19
|
* ConnectorClient is a client for interacting with the Microsoft Connector API.
|
|
20
20
|
*/
|
|
21
21
|
export class ConnectorClient {
|
|
22
|
-
protected readonly
|
|
22
|
+
protected readonly _axiosInstance: AxiosInstance
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Private constructor for the ConnectorClient.
|
|
26
|
-
* @param
|
|
26
|
+
* @param axInstance - The AxiosInstance to use for HTTP requests.
|
|
27
27
|
*/
|
|
28
|
-
protected constructor (
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
28
|
+
protected constructor (axInstance: AxiosInstance) {
|
|
29
|
+
this._axiosInstance = axInstance
|
|
30
|
+
this._axiosInstance.interceptors.response.use(
|
|
31
31
|
(config) => {
|
|
32
32
|
const { status, statusText, config: requestConfig } = config
|
|
33
33
|
logger.debug('Response: ', {
|
|
34
34
|
status,
|
|
35
35
|
statusText,
|
|
36
|
-
host: this.
|
|
36
|
+
host: this._axiosInstance.getUri(),
|
|
37
37
|
url: requestConfig?.url,
|
|
38
38
|
data: config.config.data,
|
|
39
39
|
method: requestConfig?.method,
|
|
@@ -41,14 +41,14 @@ export class ConnectorClient {
|
|
|
41
41
|
return config
|
|
42
42
|
},
|
|
43
43
|
(error) => {
|
|
44
|
-
const { code, message, stack } = error
|
|
44
|
+
const { code, message, stack, response } = error
|
|
45
45
|
const errorDetails = {
|
|
46
46
|
code,
|
|
47
|
-
host: this.
|
|
47
|
+
host: this._axiosInstance.getUri(),
|
|
48
48
|
url: error.config.url,
|
|
49
49
|
method: error.config.method,
|
|
50
50
|
data: error.config.data,
|
|
51
|
-
message,
|
|
51
|
+
message: message + JSON.stringify(response?.data),
|
|
52
52
|
stack,
|
|
53
53
|
}
|
|
54
54
|
return Promise.reject(errorDetails)
|
|
@@ -56,6 +56,10 @@ export class ConnectorClient {
|
|
|
56
56
|
)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
public get axiosInstance (): AxiosInstance {
|
|
60
|
+
return this._axiosInstance
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
/**
|
|
60
64
|
* Creates a new instance of ConnectorClient with authentication.
|
|
61
65
|
* @param baseURL - The base URL for the API.
|
|
@@ -100,7 +104,22 @@ export class ConnectorClient {
|
|
|
100
104
|
url: '/v3/conversations',
|
|
101
105
|
params: continuationToken ? { continuationToken } : undefined
|
|
102
106
|
}
|
|
103
|
-
const response = await this.
|
|
107
|
+
const response = await this._axiosInstance(config)
|
|
108
|
+
return response.data
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public async getConversationMember (userId: string, conversationId: string): Promise<ChannelAccount> {
|
|
112
|
+
if (!userId || !conversationId) {
|
|
113
|
+
throw new Error('userId and conversationId are required')
|
|
114
|
+
}
|
|
115
|
+
const config: AxiosRequestConfig = {
|
|
116
|
+
method: 'get',
|
|
117
|
+
url: `v3/conversations/${conversationId}/members/${userId}`,
|
|
118
|
+
headers: {
|
|
119
|
+
'Content-Type': 'application/json'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const response = await this._axiosInstance(config)
|
|
104
123
|
return response.data
|
|
105
124
|
}
|
|
106
125
|
|
|
@@ -119,7 +138,7 @@ export class ConnectorClient {
|
|
|
119
138
|
},
|
|
120
139
|
data: body
|
|
121
140
|
}
|
|
122
|
-
const response: AxiosResponse = await this.
|
|
141
|
+
const response: AxiosResponse = await this._axiosInstance(config)
|
|
123
142
|
return response.data
|
|
124
143
|
}
|
|
125
144
|
|
|
@@ -147,7 +166,7 @@ export class ConnectorClient {
|
|
|
147
166
|
},
|
|
148
167
|
data: body
|
|
149
168
|
}
|
|
150
|
-
const response = await this.
|
|
169
|
+
const response = await this._axiosInstance(config)
|
|
151
170
|
logger.info('Reply to conversation/activity: ', response.data.id!, activityId)
|
|
152
171
|
return response.data
|
|
153
172
|
}
|
|
@@ -174,7 +193,7 @@ export class ConnectorClient {
|
|
|
174
193
|
},
|
|
175
194
|
data: body
|
|
176
195
|
}
|
|
177
|
-
const response = await this.
|
|
196
|
+
const response = await this._axiosInstance(config)
|
|
178
197
|
return response.data
|
|
179
198
|
}
|
|
180
199
|
|
|
@@ -201,7 +220,7 @@ export class ConnectorClient {
|
|
|
201
220
|
},
|
|
202
221
|
data: body
|
|
203
222
|
}
|
|
204
|
-
const response = await this.
|
|
223
|
+
const response = await this._axiosInstance(config)
|
|
205
224
|
return response.data
|
|
206
225
|
}
|
|
207
226
|
|
|
@@ -225,7 +244,7 @@ export class ConnectorClient {
|
|
|
225
244
|
'Content-Type': 'application/json'
|
|
226
245
|
}
|
|
227
246
|
}
|
|
228
|
-
const response = await this.
|
|
247
|
+
const response = await this._axiosInstance(config)
|
|
229
248
|
return response.data
|
|
230
249
|
}
|
|
231
250
|
|
|
@@ -250,7 +269,7 @@ export class ConnectorClient {
|
|
|
250
269
|
},
|
|
251
270
|
data: body
|
|
252
271
|
}
|
|
253
|
-
const response = await this.
|
|
272
|
+
const response = await this._axiosInstance(config)
|
|
254
273
|
return response.data
|
|
255
274
|
}
|
|
256
275
|
|
|
@@ -272,7 +291,7 @@ export class ConnectorClient {
|
|
|
272
291
|
'Content-Type': 'application/json'
|
|
273
292
|
}
|
|
274
293
|
}
|
|
275
|
-
const response = await this.
|
|
294
|
+
const response = await this._axiosInstance(config)
|
|
276
295
|
return response.data
|
|
277
296
|
}
|
|
278
297
|
|
|
@@ -299,7 +318,7 @@ export class ConnectorClient {
|
|
|
299
318
|
'Content-Type': 'application/json'
|
|
300
319
|
}
|
|
301
320
|
}
|
|
302
|
-
const response = await this.
|
|
321
|
+
const response = await this._axiosInstance(config)
|
|
303
322
|
return response.data
|
|
304
323
|
}
|
|
305
324
|
}
|
package/src/turnContext.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ResourceResponse } from './connector-client/resourceResponse'
|
|
|
6
6
|
import { TurnContextStateCollection } from './turnContextStateCollection'
|
|
7
7
|
import { AttachmentInfo } from './connector-client/attachmentInfo'
|
|
8
8
|
import { AttachmentData } from './connector-client/attachmentData'
|
|
9
|
+
import { StreamingResponse } from './app/streaming/streamingResponse'
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Defines a handler for processing and sending activities.
|
|
@@ -73,7 +74,7 @@ export class TurnContext {
|
|
|
73
74
|
private readonly _onDeleteActivity: DeleteActivityHandler[] = []
|
|
74
75
|
private readonly _turn = 'turn'
|
|
75
76
|
private readonly _locale = 'locale'
|
|
76
|
-
|
|
77
|
+
private readonly _streamingResponse: StreamingResponse
|
|
77
78
|
/**
|
|
78
79
|
* Initializes a new instance of the TurnContext class.
|
|
79
80
|
*
|
|
@@ -89,6 +90,7 @@ export class TurnContext {
|
|
|
89
90
|
this._adapter = adapterOrContext
|
|
90
91
|
this._activity = request as Activity
|
|
91
92
|
}
|
|
93
|
+
this._streamingResponse = new StreamingResponse(this)
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
/**
|
|
@@ -395,6 +397,10 @@ export class TurnContext {
|
|
|
395
397
|
return this._turnState
|
|
396
398
|
}
|
|
397
399
|
|
|
400
|
+
get streamingResponse (): StreamingResponse {
|
|
401
|
+
return this._streamingResponse
|
|
402
|
+
}
|
|
403
|
+
|
|
398
404
|
/**
|
|
399
405
|
* Emits events to registered middleware handlers.
|
|
400
406
|
*
|