@microsoft/agents-hosting 1.6.1 → 1.7.0-beta.5.g67b2005119

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 (163) hide show
  1. package/README.md +16 -0
  2. package/dist/package.json +3 -3
  3. package/dist/src/agent-client/agentClient.js +4 -3
  4. package/dist/src/agent-client/agentClient.js.map +1 -1
  5. package/dist/src/agent-client/agentResponseHandler.d.ts +25 -6
  6. package/dist/src/agent-client/agentResponseHandler.js +16 -55
  7. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  8. package/dist/src/agent-client/createAgentResponseHandler.d.ts +48 -0
  9. package/dist/src/agent-client/createAgentResponseHandler.js +92 -0
  10. package/dist/src/agent-client/createAgentResponseHandler.js.map +1 -0
  11. package/dist/src/agent-client/index.d.ts +1 -0
  12. package/dist/src/agent-client/index.js +1 -0
  13. package/dist/src/agent-client/index.js.map +1 -1
  14. package/dist/src/app/adaptiveCards/activityValueParsers.js +2 -1
  15. package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -1
  16. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +13 -12
  17. package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
  18. package/dist/src/app/agentApplication.js +8 -8
  19. package/dist/src/app/agentApplication.js.map +1 -1
  20. package/dist/src/app/streaming/streamingResponse.d.ts +11 -0
  21. package/dist/src/app/streaming/streamingResponse.js +23 -2
  22. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  23. package/dist/src/app/turnState.d.ts +0 -1
  24. package/dist/src/app/turnState.js +15 -14
  25. package/dist/src/app/turnState.js.map +1 -1
  26. package/dist/src/app/turnStateProperty.js +4 -2
  27. package/dist/src/app/turnStateProperty.js.map +1 -1
  28. package/dist/src/auth/MemoryCache.d.ts +2 -1
  29. package/dist/src/auth/MemoryCache.js +7 -1
  30. package/dist/src/auth/MemoryCache.js.map +1 -1
  31. package/dist/src/auth/authConfiguration.d.ts +1 -1
  32. package/dist/src/auth/authConfiguration.js +41 -4
  33. package/dist/src/auth/authConfiguration.js.map +1 -1
  34. package/dist/src/auth/authConstants.d.ts +7 -7
  35. package/dist/src/auth/authConstants.js.map +1 -1
  36. package/dist/src/auth/connectionManager.d.ts +92 -0
  37. package/dist/src/auth/{msalConnectionManager.js → connectionManager.js} +50 -48
  38. package/dist/src/auth/connectionManager.js.map +1 -0
  39. package/dist/src/auth/index.d.ts +5 -3
  40. package/dist/src/auth/index.js +5 -3
  41. package/dist/src/auth/index.js.map +1 -1
  42. package/dist/src/auth/jwt-middleware.d.ts +8 -2
  43. package/dist/src/auth/jwt-middleware.js +116 -7
  44. package/dist/src/auth/jwt-middleware.js.map +1 -1
  45. package/dist/src/auth/msal/msalConnectionManager.d.ts +17 -0
  46. package/dist/src/auth/msal/msalConnectionManager.js +50 -0
  47. package/dist/src/auth/msal/msalConnectionManager.js.map +1 -0
  48. package/dist/src/auth/msal/msalConnectionSettings.d.ts +68 -0
  49. package/dist/src/auth/msal/msalConnectionSettings.js +7 -0
  50. package/dist/src/auth/msal/msalConnectionSettings.js.map +1 -0
  51. package/dist/src/auth/{msalTokenCredential.d.ts → msal/msalTokenCredential.d.ts} +1 -1
  52. package/dist/src/auth/{msalTokenCredential.js → msal/msalTokenCredential.js} +2 -2
  53. package/dist/src/auth/msal/msalTokenCredential.js.map +1 -0
  54. package/dist/src/auth/{msalTokenProvider.d.ts → msal/msalTokenProvider.d.ts} +23 -3
  55. package/dist/src/auth/{msalTokenProvider.js → msal/msalTokenProvider.js} +280 -176
  56. package/dist/src/auth/msal/msalTokenProvider.js.map +1 -0
  57. package/dist/src/auth/settings.d.ts +142 -133
  58. package/dist/src/auth/settings.js +49 -5
  59. package/dist/src/auth/settings.js.map +1 -1
  60. package/dist/src/auth/sidecar/sidecarAuthProvider.d.ts +74 -0
  61. package/dist/src/auth/sidecar/sidecarAuthProvider.js +181 -0
  62. package/dist/src/auth/sidecar/sidecarAuthProvider.js.map +1 -0
  63. package/dist/src/auth/sidecar/sidecarConnectionSettings.d.ts +65 -0
  64. package/dist/src/auth/sidecar/sidecarConnectionSettings.js +7 -0
  65. package/dist/src/auth/sidecar/sidecarConnectionSettings.js.map +1 -0
  66. package/dist/src/auth/sidecar/sidecarHttpClient.d.ts +95 -0
  67. package/dist/src/auth/sidecar/sidecarHttpClient.js +406 -0
  68. package/dist/src/auth/sidecar/sidecarHttpClient.js.map +1 -0
  69. package/dist/src/auth/sidecar/sidecarModels.d.ts +110 -0
  70. package/dist/src/auth/sidecar/sidecarModels.js +48 -0
  71. package/dist/src/auth/sidecar/sidecarModels.js.map +1 -0
  72. package/dist/src/auth/sidecar/sidecarTokenExpiry.d.ts +13 -0
  73. package/dist/src/auth/sidecar/sidecarTokenExpiry.js +39 -0
  74. package/dist/src/auth/sidecar/sidecarTokenExpiry.js.map +1 -0
  75. package/dist/src/baseAdapter.js +3 -1
  76. package/dist/src/baseAdapter.js.map +1 -1
  77. package/dist/src/cloudAdapter.d.ts +2 -2
  78. package/dist/src/cloudAdapter.js +11 -11
  79. package/dist/src/cloudAdapter.js.map +1 -1
  80. package/dist/src/createCloudAdapter.d.ts +40 -0
  81. package/dist/src/createCloudAdapter.js +44 -0
  82. package/dist/src/createCloudAdapter.js.map +1 -0
  83. package/dist/src/errorHelper.js +302 -79
  84. package/dist/src/errorHelper.js.map +1 -1
  85. package/dist/src/headerPropagation.js +3 -1
  86. package/dist/src/headerPropagation.js.map +1 -1
  87. package/dist/src/index.d.ts +3 -1
  88. package/dist/src/index.js +4 -1
  89. package/dist/src/index.js.map +1 -1
  90. package/dist/src/interfaces/index.d.ts +5 -0
  91. package/dist/src/interfaces/index.js +22 -0
  92. package/dist/src/interfaces/index.js.map +1 -0
  93. package/dist/src/interfaces/webResponse.d.ts +41 -0
  94. package/dist/src/interfaces/webResponse.js +7 -0
  95. package/dist/src/interfaces/webResponse.js.map +1 -0
  96. package/dist/src/middlewareSet.d.ts +0 -1
  97. package/dist/src/middlewareSet.js +4 -1
  98. package/dist/src/middlewareSet.js.map +1 -1
  99. package/dist/src/oauth/userTokenClient.d.ts +12 -0
  100. package/dist/src/oauth/userTokenClient.js +30 -9
  101. package/dist/src/oauth/userTokenClient.js.map +1 -1
  102. package/dist/src/state/conversationState.js +4 -2
  103. package/dist/src/state/conversationState.js.map +1 -1
  104. package/dist/src/state/userState.js +4 -2
  105. package/dist/src/state/userState.js.map +1 -1
  106. package/dist/src/storage/memoryStorage.js +5 -3
  107. package/dist/src/storage/memoryStorage.js.map +1 -1
  108. package/dist/src/transcript/consoleTranscriptLogger.js +3 -1
  109. package/dist/src/transcript/consoleTranscriptLogger.js.map +1 -1
  110. package/dist/src/transcript/fileTranscriptLogger.js +5 -4
  111. package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
  112. package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -1
  113. package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
  114. package/dist/src/turnContext.js +2 -1
  115. package/dist/src/turnContext.js.map +1 -1
  116. package/package.json +3 -3
  117. package/src/agent-client/agentClient.ts +5 -4
  118. package/src/agent-client/agentResponseHandler.ts +43 -67
  119. package/src/agent-client/createAgentResponseHandler.ts +133 -0
  120. package/src/agent-client/index.ts +1 -0
  121. package/src/app/adaptiveCards/activityValueParsers.ts +3 -2
  122. package/src/app/adaptiveCards/adaptiveCardsActions.ts +5 -5
  123. package/src/app/agentApplication.ts +8 -16
  124. package/src/app/streaming/streamingResponse.ts +26 -3
  125. package/src/app/turnState.ts +15 -14
  126. package/src/app/turnStateProperty.ts +4 -2
  127. package/src/auth/MemoryCache.ts +7 -1
  128. package/src/auth/authConfiguration.ts +41 -6
  129. package/src/auth/authConstants.ts +7 -7
  130. package/src/auth/{msalConnectionManager.ts → connectionManager.ts} +65 -61
  131. package/src/auth/index.ts +5 -3
  132. package/src/auth/jwt-middleware.ts +118 -9
  133. package/src/auth/msal/msalConnectionManager.ts +55 -0
  134. package/src/auth/msal/msalConnectionSettings.ts +79 -0
  135. package/src/auth/{msalTokenCredential.ts → msal/msalTokenCredential.ts} +2 -1
  136. package/src/auth/{msalTokenProvider.ts → msal/msalTokenProvider.ts} +353 -172
  137. package/src/auth/settings.ts +131 -76
  138. package/src/auth/sidecar/sidecarAuthProvider.ts +234 -0
  139. package/src/auth/sidecar/sidecarConnectionSettings.ts +72 -0
  140. package/src/auth/sidecar/sidecarHttpClient.ts +443 -0
  141. package/src/auth/sidecar/sidecarModels.ts +153 -0
  142. package/src/auth/sidecar/sidecarTokenExpiry.ts +35 -0
  143. package/src/baseAdapter.ts +3 -2
  144. package/src/cloudAdapter.ts +13 -13
  145. package/src/createCloudAdapter.ts +56 -0
  146. package/src/errorHelper.ts +354 -89
  147. package/src/headerPropagation.ts +4 -1
  148. package/src/index.ts +3 -1
  149. package/src/interfaces/index.ts +6 -0
  150. package/src/interfaces/webResponse.ts +44 -0
  151. package/src/middlewareSet.ts +3 -1
  152. package/src/oauth/userTokenClient.ts +46 -11
  153. package/src/state/conversationState.ts +4 -3
  154. package/src/state/userState.ts +4 -3
  155. package/src/storage/memoryStorage.ts +5 -3
  156. package/src/transcript/consoleTranscriptLogger.ts +3 -2
  157. package/src/transcript/fileTranscriptLogger.ts +6 -5
  158. package/src/transcript/transcriptLoggerMiddleware.ts +3 -2
  159. package/src/turnContext.ts +3 -2
  160. package/dist/src/auth/msalConnectionManager.d.ts +0 -64
  161. package/dist/src/auth/msalConnectionManager.js.map +0 -1
  162. package/dist/src/auth/msalTokenCredential.js.map +0 -1
  163. package/dist/src/auth/msalTokenProvider.js.map +0 -1
@@ -6,13 +6,13 @@
6
6
  import { AgentHandler, INVOKE_RESPONSE_KEY } from './activityHandler'
7
7
  import { BaseAdapter } from './baseAdapter'
8
8
  import { TurnContext } from './turnContext'
9
- import { Response } from 'express'
10
9
  import { Request } from './auth/request'
10
+ import { WebResponse } from './interfaces/webResponse'
11
11
  import { ConnectorClient } from './connector-client/connectorClient'
12
12
  import { AuthConfiguration, getAuthConfigWithDefaults } from './auth/authConfiguration'
13
13
  import { AuthProvider } from './auth/authProvider'
14
14
  import { ApxProductionScope } from './auth/authConstants'
15
- import { MsalConnectionManager } from './auth/msalConnectionManager'
15
+ import { MsalConnectionManager } from './auth/msal/msalConnectionManager'
16
16
  import { Activity, ActivityEventNames, ActivityTypes, Channels, ConversationReference, DeliveryModes, ConversationParameters, RoleTypes, ExceptionHelper } from '@microsoft/agents-activity'
17
17
  import { Errors } from './errorHelper'
18
18
  import { ResourceResponse } from './connector-client/resourceResponse'
@@ -289,7 +289,7 @@ export class CloudAdapter extends BaseAdapter {
289
289
  */
290
290
  protected resolveIfConnectorClientIsNeeded (activity: Activity): boolean {
291
291
  if (!activity) {
292
- throw new TypeError('`activity` parameter required')
292
+ throw ExceptionHelper.generateException(TypeError, Errors.ActivityParameterRequired)
293
293
  }
294
294
 
295
295
  switch (activity.deliveryMode) {
@@ -392,7 +392,7 @@ export class CloudAdapter extends BaseAdapter {
392
392
  headers
393
393
  )
394
394
  } else {
395
- throw new Error('Could not create connector client for agentic user')
395
+ throw ExceptionHelper.generateException(Error, Errors.CannotCreateConnectorClientForAgenticUser)
396
396
  }
397
397
  } else {
398
398
  // ABS tokens will not have an azp/appid so use the botframework scope.
@@ -580,7 +580,7 @@ export class CloudAdapter extends BaseAdapter {
580
580
  */
581
581
  public async process (
582
582
  request: Request,
583
- res: Response,
583
+ res: WebResponse,
584
584
  logic: (context: TurnContext) => Promise<void>,
585
585
  headerPropagation?: HeaderPropagationDefinition): Promise<void> {
586
586
  return trace(AdapterTraceDefinitions.process, async ({ record }) => {
@@ -609,7 +609,7 @@ export class CloudAdapter extends BaseAdapter {
609
609
  res.end()
610
610
  }
611
611
  if (!request.body) {
612
- throw new TypeError('`request.body` parameter required, make sure express.json() is used as middleware')
612
+ throw ExceptionHelper.generateException(TypeError, Errors.MissingRequestBody)
613
613
  }
614
614
  const incoming = normalizeIncomingActivity(request.body!)
615
615
  const activity = Activity.fromObject(incoming)
@@ -726,11 +726,11 @@ export class CloudAdapter extends BaseAdapter {
726
726
  async updateActivity (context: TurnContext, activity: Activity): Promise<ResourceResponse | void> {
727
727
  return trace(AdapterTraceDefinitions.updateActivity, async ({ record }) => {
728
728
  if (!context) {
729
- throw new TypeError('`context` parameter required')
729
+ throw ExceptionHelper.generateException(TypeError, Errors.ContextParameterRequired)
730
730
  }
731
731
 
732
732
  if (!activity) {
733
- throw new TypeError('`activity` parameter required')
733
+ throw ExceptionHelper.generateException(TypeError, Errors.ActivityParameterRequired)
734
734
  }
735
735
 
736
736
  record({ activity })
@@ -758,7 +758,7 @@ export class CloudAdapter extends BaseAdapter {
758
758
  async deleteActivity (context: TurnContext, reference: Partial<ConversationReference>): Promise<void> {
759
759
  return trace(AdapterTraceDefinitions.deleteActivity, async ({ record }) => {
760
760
  if (!context) {
761
- throw new TypeError('`context` parameter required')
761
+ throw ExceptionHelper.generateException(TypeError, Errors.ContextParameterRequired)
762
762
  }
763
763
 
764
764
  if (!reference || !reference.serviceUrl || (reference.conversation == null) || !reference.conversation.id || !reference.activityId) {
@@ -791,7 +791,7 @@ export class CloudAdapter extends BaseAdapter {
791
791
  }
792
792
 
793
793
  if (!botAppIdOrIdentity) {
794
- throw new TypeError('continueConversation: botAppIdOrIdentity is required')
794
+ throw ExceptionHelper.generateException(TypeError, Errors.ContinueConversationBotAppIdOrIdentityRequired)
795
795
  }
796
796
  const botAppId = typeof botAppIdOrIdentity === 'string' ? botAppIdOrIdentity : botAppIdOrIdentity.aud as string
797
797
 
@@ -911,10 +911,10 @@ export class CloudAdapter extends BaseAdapter {
911
911
  logic: (context: TurnContext) => Promise<void>
912
912
  ): Promise<void> {
913
913
  if (typeof serviceUrl !== 'string' || !serviceUrl) {
914
- throw new TypeError('`serviceUrl` must be a non-empty string')
914
+ throw ExceptionHelper.generateException(TypeError, Errors.ServiceUrlRequired)
915
915
  }
916
- if (!conversationParameters) throw new TypeError('`conversationParameters` must be defined')
917
- if (!logic) throw new TypeError('`logic` must be defined')
916
+ if (!conversationParameters) throw ExceptionHelper.generateException(TypeError, Errors.ConversationParametersRequired)
917
+ if (!logic) throw ExceptionHelper.generateException(TypeError, Errors.LogicParameterRequired)
918
918
 
919
919
  const identity = CloudAdapter.createIdentity(audience)
920
920
  const restClient = await this.createConnectorClient(serviceUrl, audience, identity)
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { ActivityHandler } from './activityHandler'
7
+ import { AgentApplication } from './app/agentApplication'
8
+ import { AuthConfiguration } from './auth/authConfiguration'
9
+ import { CloudAdapter } from './cloudAdapter'
10
+ import { HeaderPropagationDefinition } from './headerPropagation'
11
+ import { TurnState } from './app/turnState'
12
+
13
+ /**
14
+ * Result of creating a CloudAdapter from an agent.
15
+ */
16
+ export interface CloudAdapterResult {
17
+ adapter: CloudAdapter
18
+ headerPropagation: HeaderPropagationDefinition | undefined
19
+ }
20
+
21
+ /**
22
+ * Creates a CloudAdapter for the given agent.
23
+ *
24
+ * If the agent is an AgentApplication with a pre-configured adapter, that adapter is reused.
25
+ * Otherwise, a new CloudAdapter is created.
26
+ *
27
+ * @param agent - The AgentApplication or ActivityHandler instance.
28
+ * @param authConfig - Optional auth configuration used when creating a new CloudAdapter.
29
+ * If the agent already has an adapter, that adapter is reused and this value is ignored.
30
+ * @returns An object containing the CloudAdapter and optional header propagation configuration.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * import { AgentApplication, TurnState, createCloudAdapter } from '@microsoft/agents-hosting';
35
+ *
36
+ * const app = new AgentApplication<TurnState>();
37
+ * const { adapter, headerPropagation } = createCloudAdapter(app, { clientId: process.env.CLIENT_ID });
38
+ *
39
+ * // Use the adapter directly with request/response objects compatible with CloudAdapter.process
40
+ * adapter.process(req, res, (context) => app.run(context), headerPropagation);
41
+ * ```
42
+ */
43
+ export const createCloudAdapter = (
44
+ agent: AgentApplication<TurnState<any, any>> | ActivityHandler,
45
+ authConfig?: AuthConfiguration
46
+ ): CloudAdapterResult => {
47
+ if (agent instanceof ActivityHandler) {
48
+ return { adapter: new CloudAdapter(authConfig), headerPropagation: undefined }
49
+ }
50
+
51
+ // AgentApplication: reuse its pre-configured adapter when present, otherwise create one.
52
+ // headerPropagation is an application-level option, so read it regardless of adapter source.
53
+ const headerPropagation = agent.options?.headerPropagation
54
+ const adapter = agent.adapter ?? new CloudAdapter(authConfig)
55
+ return { adapter, headerPropagation }
56
+ }
@@ -196,6 +196,21 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
196
196
  description: 'missing context.activity.channelId'
197
197
  },
198
198
 
199
+ MissingContextActivityRecipientId: {
200
+ code: -120221,
201
+ description: 'missing context.activity.recipient.id'
202
+ },
203
+
204
+ MissingContextActivityConversationId: {
205
+ code: -120222,
206
+ description: 'missing context.activity.conversation.id'
207
+ },
208
+
209
+ MissingContextActivityFromId: {
210
+ code: -120223,
211
+ description: 'missing context.activity.from.id'
212
+ },
213
+
199
214
  /**
200
215
  * Error thrown when both channelId and from.id are required for operation.
201
216
  */
@@ -213,7 +228,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
213
228
  },
214
229
 
215
230
  // ============================================================================
216
- // Attachment Errors (-120250 to -120290)
231
+ // Attachment Errors (-120250 to -120291)
217
232
  // ============================================================================
218
233
 
219
234
  /**
@@ -232,6 +247,14 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
232
247
  description: 'attachmentId is required'
233
248
  },
234
249
 
250
+ /**
251
+ * Error thrown when attachment is null or undefined.
252
+ */
253
+ AttachmentNullOrUndefined: {
254
+ code: -120265,
255
+ description: 'attachment cannot be null or undefined.'
256
+ },
257
+
235
258
  /**
236
259
  * Error thrown when viewId is required but missing.
237
260
  */
@@ -265,7 +288,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
265
288
  },
266
289
 
267
290
  // ============================================================================
268
- // Connection and Authentication Errors (-120300 to -120590)
291
+ // Connection and Authentication Errors (-120300 to -120599)
269
292
  // ============================================================================
270
293
 
271
294
  /**
@@ -273,7 +296,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
273
296
  */
274
297
  ConnectionNotFoundInEnvironment: {
275
298
  code: -120300,
276
- description: 'Connection "{connectionName}" not found in environment.'
299
+ description: 'Connection "{connectionName}" not found in environment connections.'
277
300
  },
278
301
 
279
302
  /**
@@ -340,6 +363,51 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
340
363
  description: 'Connection settings must be provided for this operation.'
341
364
  },
342
365
 
366
+ ConnectionSettingsRequiredForGetAccessTokenScope: {
367
+ code: -120381,
368
+ description: 'Connection settings must be provided to constructor when calling getAccessToken(scope)'
369
+ },
370
+
371
+ ConnectionSettingsRequiredForAcquireTokenOnBehalfOf: {
372
+ code: -120382,
373
+ description: 'Connection settings must be provided to constructor when calling acquireTokenOnBehalfOf(scopes, oboAssertion)'
374
+ },
375
+
376
+ FailedToAcquireTokenOnBehalfOf: {
377
+ code: -120383,
378
+ description: 'Failed to acquire token on behalf of user'
379
+ },
380
+
381
+ ConnectionSettingsRequiredForGetAgenticInstanceToken: {
382
+ code: -120384,
383
+ description: 'Connection settings must be provided when calling getAgenticInstanceToken'
384
+ },
385
+
386
+ FailedToAcquireInstanceTokenForAgentInstance: {
387
+ code: -120385,
388
+ description: 'Failed to acquire instance token for agent instance: {agentAppInstanceId}'
389
+ },
390
+
391
+ FailedToAcquireInstanceTokenForUserToken: {
392
+ code: -120386,
393
+ description: 'Failed to acquire instance token for user token: {agentAppInstanceId}'
394
+ },
395
+
396
+ ConnectionSettingsRequiredForGetAgenticApplicationToken: {
397
+ code: -120387,
398
+ description: 'Connection settings must be provided when calling getAgenticApplicationToken'
399
+ },
400
+
401
+ IdpmResourceAbsoluteUriRequired: {
402
+ code: -120388,
403
+ description: 'idpmResource must be a valid absolute URI'
404
+ },
405
+
406
+ FailedToAcquireTokenViaIdentityProxyManagerForAgentInstance: {
407
+ code: -120389,
408
+ description: 'Failed to acquire token via IdentityProxyManager for agent instance: {agentAppInstanceId}'
409
+ },
410
+
343
411
  /**
344
412
  * Error thrown when identity is required to get token provider.
345
413
  */
@@ -348,6 +416,31 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
348
416
  description: 'Identity is required to get the token provider.'
349
417
  },
350
418
 
419
+ FailedToAcquireTokenUsingCertificate: {
420
+ code: -120395,
421
+ description: 'Failed to acquire token using certificate'
422
+ },
423
+
424
+ FailedToAcquireTokenUsingClientSecret: {
425
+ code: -120396,
426
+ description: 'Failed to acquire token using client secret'
427
+ },
428
+
429
+ FailedToAcquireTokenUsingFICClientAssertion: {
430
+ code: -120397,
431
+ description: 'Failed to acquire token using FIC client assertion'
432
+ },
433
+
434
+ FailedToAcquireTokenUsingWIDClientAssertion: {
435
+ code: -120398,
436
+ description: 'Failed to acquire token using WID client assertion'
437
+ },
438
+
439
+ FailedToAcquireExternalTokenForFICClientAssertion: {
440
+ code: -120399,
441
+ description: 'Failed to acquire external token for FIC client assertion'
442
+ },
443
+
351
444
  /**
352
445
  * Error thrown when audience and service URL are required for token provider.
353
446
  */
@@ -580,6 +673,108 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
580
673
  description: 'Token request timed out after {timeoutMs} ms'
581
674
  },
582
675
 
676
+ // ============================================================================
677
+ // Entra Agent ID Sidecar Authentication Errors (-120800 to -120849)
678
+ // ============================================================================
679
+
680
+ /**
681
+ * Error thrown when the Entra sidecar auth provider is used without connection settings.
682
+ */
683
+ SidecarConnectionSettingsRequired: {
684
+ code: -120800,
685
+ description: 'Connection settings must be provided when using the Entra sidecar auth provider'
686
+ },
687
+
688
+ /**
689
+ * Error thrown when the resolved sidecar base URL is not a valid absolute URL.
690
+ */
691
+ SidecarBaseUrlInvalid: {
692
+ code: -120801,
693
+ description: 'The resolved sidecar base URL `{url}` is not a valid absolute URL'
694
+ },
695
+
696
+ /**
697
+ * Error thrown when the resolved sidecar base URL does not use the http or https scheme.
698
+ */
699
+ SidecarBaseUrlInsecureScheme: {
700
+ code: -120802,
701
+ description: 'The resolved sidecar base URL `{url}` must use the http or https scheme'
702
+ },
703
+
704
+ /**
705
+ * Error thrown when the resolved sidecar base URL contains userinfo (credentials).
706
+ */
707
+ SidecarBaseUrlUserInfo: {
708
+ code: -120803,
709
+ description: 'The resolved sidecar base URL `{url}` must not contain userinfo (credentials)'
710
+ },
711
+
712
+ /**
713
+ * Error thrown when the resolved sidecar base URL points to a non-loopback, non-private address.
714
+ */
715
+ SidecarBaseUrlNotLocal: {
716
+ code: -120804,
717
+ description: 'The resolved sidecar base URL `{url}` points to a non-loopback, non-private address. The Entra Agent ID sidecar (agent container) must be reachable only from within the agent\'s network boundary. Set `bypassLocalNetworkRestriction` to true in the connection configuration to override this safety check (UNSAFE: only for carefully validated private-network configurations)'
718
+ },
719
+
720
+ /**
721
+ * Error thrown when both AgentUsername and AgentUserId are supplied on a sidecar request (mutually exclusive).
722
+ */
723
+ SidecarUserIdentityMutuallyExclusive: {
724
+ code: -120805,
725
+ description: 'AgentUsername and AgentUserId are mutually exclusive; set only one on the sidecar request options'
726
+ },
727
+
728
+ /**
729
+ * Error thrown when a sidecar request fails after exhausting all retry attempts.
730
+ */
731
+ SidecarRequestFailed: {
732
+ code: -120806,
733
+ description: 'Sidecar request failed after {attempts} attempt(s): {message}'
734
+ },
735
+
736
+ /**
737
+ * Error thrown when the sidecar responds with a non-success status code.
738
+ */
739
+ SidecarErrorResponse: {
740
+ code: -120807,
741
+ description: 'Sidecar returned error status {status}: {message}'
742
+ },
743
+
744
+ /**
745
+ * Error thrown when the sidecar response is missing the authorizationHeader field.
746
+ */
747
+ SidecarResponseMissingAuthorizationHeader: {
748
+ code: -120808,
749
+ description: 'Sidecar response missing `authorizationHeader` field'
750
+ },
751
+
752
+ /**
753
+ * Error thrown when the sidecar response body cannot be parsed.
754
+ */
755
+ SidecarResponseUnparsable: {
756
+ code: -120809,
757
+ description: 'Sidecar returned an unparsable response body'
758
+ },
759
+
760
+ /**
761
+ * Error thrown when acquireTokenOnBehalfOf is called on the sidecar provider, which does not support OBO in Phase 1.
762
+ */
763
+ OnBehalfOfNotSupportedBySidecar: {
764
+ code: -120810,
765
+ description: 'acquireTokenOnBehalfOf is not supported by the Entra sidecar auth provider in Phase 1'
766
+ },
767
+
768
+ /**
769
+ * Error thrown when the sidecar returns a token with an authorization scheme other than Bearer.
770
+ * The hosting stack always transmits tokens as `Bearer {token}`, so a non-Bearer scheme cannot be
771
+ * honored and is rejected rather than silently sent as an invalid Authorization header.
772
+ */
773
+ SidecarUnsupportedAuthScheme: {
774
+ code: -120811,
775
+ description: 'The Entra Agent ID sidecar returned an unsupported authorization scheme `{scheme}`. Only the Bearer scheme is supported'
776
+ },
777
+
583
778
  // ============================================================================
584
779
  // Agent and Client Errors (-120600 to -120650)
585
780
  // ============================================================================
@@ -616,6 +811,11 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
616
811
  description: 'Agent name contains invalid characters: {agentName}'
617
812
  },
618
813
 
814
+ ContinueConversationBotAppIdOrIdentityRequired: {
815
+ code: -120631,
816
+ description: 'continueConversation: botAppIdOrIdentity is required'
817
+ },
818
+
619
819
  /**
620
820
  * Error thrown when failed to post activity to agent.
621
821
  */
@@ -633,7 +833,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
633
833
  },
634
834
 
635
835
  // ============================================================================
636
- // Storage and State Errors (-120700 to -120730)
836
+ // Storage and State Errors (-120700 to -120732)
637
837
  // ============================================================================
638
838
 
639
839
  /**
@@ -644,6 +844,22 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
644
844
  description: 'Storage: error writing "{key}" due to eTag conflict.'
645
845
  },
646
846
 
847
+ /**
848
+ * Error thrown when keys are required for storage read operations.
849
+ */
850
+ StorageReadKeysRequired: {
851
+ code: -120701,
852
+ description: 'Keys are required when reading.'
853
+ },
854
+
855
+ /**
856
+ * Error thrown when changes are required for storage write operations.
857
+ */
858
+ StorageWriteChangesRequired: {
859
+ code: -120702,
860
+ description: 'Changes are required when writing.'
861
+ },
862
+
647
863
  /**
648
864
  * Error thrown when storage option is not available in app options.
649
865
  */
@@ -668,96 +884,18 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
668
884
  description: 'Invalid state scope: {scope}'
669
885
  },
670
886
 
671
- // ============================================================================
672
- // Application Configuration Errors (-120850 to -120900)
673
- // ============================================================================
674
-
675
- /**
676
- * Error thrown when longRunningMessages property is unavailable.
677
- */
678
- LongRunningMessagesPropertyUnavailable: {
679
- code: -120850,
680
- description: 'The Application.longRunningMessages property is unavailable because no adapter was configured in the app.'
681
- },
682
-
683
- /**
684
- * Error thrown when transcriptLogger property is unavailable.
685
- */
686
- TranscriptLoggerPropertyUnavailable: {
687
- code: -120860,
688
- description: 'The Application.transcriptLogger property is unavailable because no adapter was configured in the app.'
689
- },
690
-
691
- /**
692
- * Error thrown when TranscriptLoggerMiddleware requires a TranscriptLogger instance.
693
- */
694
- TranscriptLoggerInstanceRequired: {
695
- code: -120870,
696
- description: 'TranscriptLoggerMiddleware requires a TranscriptLogger instance.'
697
- },
698
-
699
- /**
700
- * Error thrown when extension is already registered.
701
- */
702
- ExtensionAlreadyRegistered: {
703
- code: -120880,
704
- description: 'Extension already registered'
887
+ InvalidStatePath: {
888
+ code: -120731,
889
+ description: 'Invalid state path: {path}'
705
890
  },
706
891
 
707
- /**
708
- * Error thrown when invalid plugin type is added to MiddlewareSet.
709
- */
710
- InvalidMiddlewarePluginType: {
711
- code: -120890,
712
- description: 'MiddlewareSet.use(): invalid plugin type being added.'
713
- },
714
-
715
- /**
716
- * Error thrown when the stream has already ended.
717
- */
718
- StreamAlreadyEnded: {
719
- code: -120900,
720
- description: 'The stream has already ended.'
721
- },
722
-
723
- // ============================================================================
724
- // Adaptive Cards Errors (-120950 to -120980)
725
- // ============================================================================
726
-
727
- /**
728
- * Error thrown when unexpected AdaptiveCards.actionExecute() is triggered.
729
- */
730
- UnexpectedActionExecute: {
731
- code: -120950,
732
- description: 'Unexpected AdaptiveCards.actionExecute() triggered for activity type: {activityType}'
733
- },
734
-
735
- /**
736
- * Error thrown when unexpected AdaptiveCards.actionSubmit() is triggered.
737
- */
738
- UnexpectedActionSubmit: {
739
- code: -120960,
740
- description: 'Unexpected AdaptiveCards.actionSubmit() triggered for activity type: {activityType}'
741
- },
742
-
743
- /**
744
- * Error thrown when unexpected AdaptiveCards.search() is triggered.
745
- */
746
- UnexpectedSearchAction: {
747
- code: -120970,
748
- description: 'Unexpected AdaptiveCards.search() triggered for activity type: {activityType}'
749
- },
750
-
751
- /**
752
- * Error thrown when invalid action value is provided.
753
- */
754
- InvalidActionValue: {
755
- code: -120980,
756
- description: 'Invalid action value: {error}'
892
+ TurnStateMissingStateScope: {
893
+ code: -120732,
894
+ description: 'TurnState missing state scope named "{scope}".'
757
895
  },
758
896
 
759
897
  // ============================================================================
760
- // Proactive Messaging Errors (-120740 to -120799)
898
+ // Proactive Messaging Errors (-120740 to -120753)
761
899
  // ============================================================================
762
900
 
763
901
  /**
@@ -873,6 +1011,133 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
873
1011
  description: 'CreateConversationOptionsBuilder: Teams channel conversations require an initial activity. Call withActivity() before build().'
874
1012
  },
875
1013
 
1014
+ // ============================================================================
1015
+ // Hosting / Web layer errors (-120800 to -120840)
1016
+ // ============================================================================
1017
+
1018
+ /**
1019
+ * Error thrown by CloudAdapter.process when the incoming request lacks a parsed body.
1020
+ * Indicates the hosting layer (e.g. express.json() or Fastify's JSON parser) was not configured.
1021
+ */
1022
+ MissingRequestBody: {
1023
+ code: -120800,
1024
+ description: '`request.body` parameter required; ensure your hosting layer parses JSON request bodies before invoking the adapter (e.g., express.json() with Express or Fastify\'s built-in JSON parser).'
1025
+ },
1026
+
1027
+ /**
1028
+ * Error thrown by verifyToken when the provided JWT cannot be decoded.
1029
+ */
1030
+ InvalidJwtToken: {
1031
+ code: -120810,
1032
+ description: 'invalid token'
1033
+ },
1034
+
1035
+ /**
1036
+ * Error thrown by verifyToken when the token audience does not match any configured connection clientId.
1037
+ */
1038
+ JwtAudienceMismatch: {
1039
+ code: -120820,
1040
+ description: 'Audience mismatch'
1041
+ },
1042
+
1043
+ // ============================================================================
1044
+ // Application Configuration Errors (-120850 to -120902)
1045
+ // ============================================================================
1046
+
1047
+ /**
1048
+ * Error thrown when longRunningMessages property is unavailable.
1049
+ */
1050
+ LongRunningMessagesPropertyUnavailable: {
1051
+ code: -120850,
1052
+ description: 'The Application.longRunningMessages property is unavailable because no adapter was configured in the app.'
1053
+ },
1054
+
1055
+ /**
1056
+ * Error thrown when transcriptLogger property is unavailable.
1057
+ */
1058
+ TranscriptLoggerPropertyUnavailable: {
1059
+ code: -120860,
1060
+ description: 'The Application.transcriptLogger property is unavailable because no adapter was configured in the app.'
1061
+ },
1062
+
1063
+ /**
1064
+ * Error thrown when TranscriptLoggerMiddleware requires a TranscriptLogger instance.
1065
+ */
1066
+ TranscriptLoggerInstanceRequired: {
1067
+ code: -120870,
1068
+ description: 'TranscriptLoggerMiddleware requires a TranscriptLogger instance.'
1069
+ },
1070
+
1071
+ /**
1072
+ * Error thrown when extension is already registered.
1073
+ */
1074
+ ExtensionAlreadyRegistered: {
1075
+ code: -120880,
1076
+ description: 'Extension already registered'
1077
+ },
1078
+
1079
+ /**
1080
+ * Error thrown when invalid plugin type is added to MiddlewareSet.
1081
+ */
1082
+ InvalidMiddlewarePluginType: {
1083
+ code: -120890,
1084
+ description: 'MiddlewareSet.use(): invalid plugin type being added.'
1085
+ },
1086
+
1087
+ /**
1088
+ * Error thrown when the stream has already ended.
1089
+ */
1090
+ StreamAlreadyEnded: {
1091
+ code: -120900,
1092
+ description: 'The stream has already ended.'
1093
+ },
1094
+
1095
+ ConversationUpdateHandlerMustBeFunction: {
1096
+ code: -120901,
1097
+ description: "ConversationUpdate 'handler' for {event} is {handlerType}. Type of 'handler' must be a function."
1098
+ },
1099
+
1100
+ ContinueConversationAdapterRequired: {
1101
+ code: -120902,
1102
+ description: "You must configure the Application with an 'adapter' before calling Application.continueConversationAsync()"
1103
+ },
1104
+
1105
+ // ============================================================================
1106
+ // Adaptive Cards Errors (-120950 to -120980)
1107
+ // ============================================================================
1108
+
1109
+ /**
1110
+ * Error thrown when unexpected AdaptiveCards.actionExecute() is triggered.
1111
+ */
1112
+ UnexpectedActionExecute: {
1113
+ code: -120950,
1114
+ description: 'Unexpected AdaptiveCards.actionExecute() triggered for activity type: {activityType}'
1115
+ },
1116
+
1117
+ /**
1118
+ * Error thrown when unexpected AdaptiveCards.actionSubmit() is triggered.
1119
+ */
1120
+ UnexpectedActionSubmit: {
1121
+ code: -120960,
1122
+ description: 'Unexpected AdaptiveCards.actionSubmit() triggered for activity type: {activityType}'
1123
+ },
1124
+
1125
+ /**
1126
+ * Error thrown when unexpected AdaptiveCards.search() is triggered.
1127
+ */
1128
+ UnexpectedSearchAction: {
1129
+ code: -120970,
1130
+ description: 'Unexpected AdaptiveCards.search() triggered for activity type: {activityType}'
1131
+ },
1132
+
1133
+ /**
1134
+ * Error thrown when invalid action value is provided.
1135
+ */
1136
+ InvalidActionValue: {
1137
+ code: -120980,
1138
+ description: 'Invalid action value: {error}'
1139
+ },
1140
+
876
1141
  // ============================================================================
877
1142
  // General Errors (-120990)
878
1143
  // ============================================================================