@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.
Files changed (107) hide show
  1. package/dist/src/activityWireCompat.js +1 -1
  2. package/dist/src/activityWireCompat.js.map +1 -1
  3. package/dist/src/app/adaptiveCards/activityValueParsers.d.ts +115 -0
  4. package/dist/src/app/adaptiveCards/activityValueParsers.js +224 -0
  5. package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -0
  6. package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.d.ts +21 -0
  7. package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.js +26 -0
  8. package/dist/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.js.map +1 -0
  9. package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +57 -0
  10. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +272 -0
  11. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -0
  12. package/dist/src/app/adaptiveCards/adaptiveCardsOptions.d.ts +20 -0
  13. package/dist/src/app/adaptiveCards/adaptiveCardsOptions.js +7 -0
  14. package/dist/src/app/adaptiveCards/adaptiveCardsOptions.js.map +1 -0
  15. package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.d.ts +31 -0
  16. package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js +16 -0
  17. package/dist/src/app/adaptiveCards/adaptiveCardsSearchParams.js.map +1 -0
  18. package/dist/src/app/adaptiveCards/index.d.ts +3 -0
  19. package/dist/src/app/adaptiveCards/index.js +20 -0
  20. package/dist/src/app/adaptiveCards/index.js.map +1 -0
  21. package/dist/src/app/adaptiveCards/query.d.ts +22 -0
  22. package/dist/src/app/adaptiveCards/query.js +7 -0
  23. package/dist/src/app/adaptiveCards/query.js.map +1 -0
  24. package/dist/src/app/agentApplication.d.ts +56 -8
  25. package/dist/src/app/agentApplication.js +88 -11
  26. package/dist/src/app/agentApplication.js.map +1 -1
  27. package/dist/src/app/agentApplicationBuilder.d.ts +2 -2
  28. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  29. package/dist/src/app/agentApplicationOptions.d.ts +17 -2
  30. package/dist/src/app/appRoute.d.ts +5 -0
  31. package/dist/src/app/attachmentDownloader.js +1 -0
  32. package/dist/src/app/attachmentDownloader.js.map +1 -1
  33. package/dist/src/app/extensions.d.ts +9 -0
  34. package/dist/src/app/extensions.js +16 -0
  35. package/dist/src/app/extensions.js.map +1 -0
  36. package/dist/src/app/index.d.ts +2 -0
  37. package/dist/src/app/index.js +2 -0
  38. package/dist/src/app/index.js.map +1 -1
  39. package/dist/src/app/streaming/AIEntity.d.ts +36 -0
  40. package/dist/src/app/streaming/AIEntity.js +7 -0
  41. package/dist/src/app/streaming/AIEntity.js.map +1 -0
  42. package/dist/src/app/streaming/actionCall.d.ts +33 -0
  43. package/dist/src/app/streaming/actionCall.js +7 -0
  44. package/dist/src/app/streaming/actionCall.js.map +1 -0
  45. package/dist/src/app/streaming/clientCitation.d.ts +68 -0
  46. package/dist/src/app/streaming/clientCitation.js +10 -0
  47. package/dist/src/app/streaming/clientCitation.js.map +1 -0
  48. package/dist/src/app/streaming/message.d.ts +106 -0
  49. package/dist/src/app/streaming/message.js +7 -0
  50. package/dist/src/app/streaming/message.js.map +1 -0
  51. package/dist/src/app/streaming/sensitivityUsageInfo.d.ts +40 -0
  52. package/dist/src/app/streaming/sensitivityUsageInfo.js +3 -0
  53. package/dist/src/app/streaming/sensitivityUsageInfo.js.map +1 -0
  54. package/dist/src/app/streaming/streamingResponse.d.ts +141 -0
  55. package/dist/src/app/streaming/streamingResponse.js +331 -0
  56. package/dist/src/app/streaming/streamingResponse.js.map +1 -0
  57. package/dist/src/app/streaming/utilities.d.ts +31 -0
  58. package/dist/src/app/streaming/utilities.js +101 -0
  59. package/dist/src/app/streaming/utilities.js.map +1 -0
  60. package/dist/src/auth/jwt-middleware.js +1 -0
  61. package/dist/src/auth/jwt-middleware.js.map +1 -1
  62. package/dist/src/baseAdapter.js +1 -1
  63. package/dist/src/baseAdapter.js.map +1 -1
  64. package/dist/src/cards/adaptiveCard.d.ts +15 -0
  65. package/dist/src/cards/adaptiveCard.js +7 -0
  66. package/dist/src/cards/adaptiveCard.js.map +1 -0
  67. package/dist/src/cards/index.d.ts +1 -0
  68. package/dist/src/cards/index.js +1 -0
  69. package/dist/src/cards/index.js.map +1 -1
  70. package/dist/src/cloudAdapter.js +6 -7
  71. package/dist/src/cloudAdapter.js.map +1 -1
  72. package/dist/src/connector-client/connectorClient.d.ts +6 -4
  73. package/dist/src/connector-client/connectorClient.js +34 -17
  74. package/dist/src/connector-client/connectorClient.js.map +1 -1
  75. package/dist/src/turnContext.d.ts +3 -0
  76. package/dist/src/turnContext.js +5 -0
  77. package/dist/src/turnContext.js.map +1 -1
  78. package/package.json +2 -2
  79. package/src/activityWireCompat.ts +1 -1
  80. package/src/app/adaptiveCards/activityValueParsers.ts +249 -0
  81. package/src/app/adaptiveCards/adaptiveCardActionExecuteResponseType.ts +24 -0
  82. package/src/app/adaptiveCards/adaptiveCardsActions.ts +320 -0
  83. package/src/app/adaptiveCards/adaptiveCardsOptions.ts +23 -0
  84. package/src/app/adaptiveCards/adaptiveCardsSearchParams.ts +28 -0
  85. package/src/app/adaptiveCards/index.ts +3 -0
  86. package/src/app/adaptiveCards/query.ts +25 -0
  87. package/src/app/agentApplication.ts +109 -29
  88. package/src/app/agentApplicationBuilder.ts +2 -2
  89. package/src/app/agentApplicationOptions.ts +20 -2
  90. package/src/app/appRoute.ts +6 -0
  91. package/src/app/attachmentDownloader.ts +1 -0
  92. package/src/app/extensions.ts +19 -0
  93. package/src/app/index.ts +2 -0
  94. package/src/app/streaming/AIEntity.ts +44 -0
  95. package/src/app/streaming/actionCall.ts +37 -0
  96. package/src/app/streaming/clientCitation.ts +102 -0
  97. package/src/app/streaming/message.ts +125 -0
  98. package/src/app/streaming/sensitivityUsageInfo.ts +48 -0
  99. package/src/app/streaming/streamingResponse.ts +406 -0
  100. package/src/app/streaming/utilities.ts +108 -0
  101. package/src/auth/jwt-middleware.ts +1 -1
  102. package/src/baseAdapter.ts +2 -2
  103. package/src/cards/adaptiveCard.ts +16 -0
  104. package/src/cards/index.ts +1 -0
  105. package/src/cloudAdapter.ts +5 -7
  106. package/src/connector-client/connectorClient.ts +38 -19
  107. 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 client: AxiosInstance
22
+ protected readonly _axiosInstance: AxiosInstance
23
23
 
24
24
  /**
25
25
  * Private constructor for the ConnectorClient.
26
- * @param client - The AxiosInstance to use for HTTP requests.
26
+ * @param axInstance - The AxiosInstance to use for HTTP requests.
27
27
  */
28
- protected constructor (client: AxiosInstance) {
29
- this.client = client
30
- this.client.interceptors.response.use(
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.client.getUri(),
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.client.getUri(),
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.client(config)
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.client(config)
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.client(config)
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.client(config)
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.client(config)
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.client(config)
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.client(config)
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.client(config)
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.client(config)
321
+ const response = await this._axiosInstance(config)
303
322
  return response.data
304
323
  }
305
324
  }
@@ -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
  *