@microsoft/agents-hosting 1.7.0-beta.1.g8bcd4f11a7 → 1.7.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/README.md +16 -0
- package/dist/package.json +3 -3
- package/dist/src/agent-client/agentClient.js +4 -3
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.d.ts +25 -6
- package/dist/src/agent-client/agentResponseHandler.js +16 -55
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/agent-client/createAgentResponseHandler.d.ts +48 -0
- package/dist/src/agent-client/createAgentResponseHandler.js +92 -0
- package/dist/src/agent-client/createAgentResponseHandler.js.map +1 -0
- package/dist/src/agent-client/index.d.ts +1 -0
- package/dist/src/agent-client/index.js +1 -0
- package/dist/src/agent-client/index.js.map +1 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.js +2 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +13 -12
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/agentApplication.js +8 -8
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.js +2 -2
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/turnState.d.ts +0 -1
- package/dist/src/app/turnState.js +15 -14
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/app/turnStateProperty.js +4 -2
- package/dist/src/app/turnStateProperty.js.map +1 -1
- package/dist/src/auth/authConfiguration.js +5 -3
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/jwt-middleware.d.ts +2 -2
- package/dist/src/auth/jwt-middleware.js +84 -6
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msal/msalTokenProvider.js +16 -16
- package/dist/src/auth/msal/msalTokenProvider.js.map +1 -1
- package/dist/src/baseAdapter.js +3 -1
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cloudAdapter.d.ts +2 -2
- package/dist/src/cloudAdapter.js +10 -10
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/createCloudAdapter.d.ts +40 -0
- package/dist/src/createCloudAdapter.js +44 -0
- package/dist/src/createCloudAdapter.js.map +1 -0
- package/dist/src/errorHelper.js +206 -79
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/headerPropagation.js +3 -1
- package/dist/src/headerPropagation.js.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/interfaces/index.d.ts +5 -0
- package/dist/src/interfaces/index.js +22 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/webResponse.d.ts +41 -0
- package/dist/src/interfaces/webResponse.js +7 -0
- package/dist/src/interfaces/webResponse.js.map +1 -0
- package/dist/src/middlewareSet.d.ts +0 -1
- package/dist/src/middlewareSet.js +4 -1
- package/dist/src/middlewareSet.js.map +1 -1
- package/dist/src/oauth/userTokenClient.js +2 -1
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/state/conversationState.js +4 -2
- package/dist/src/state/conversationState.js.map +1 -1
- package/dist/src/state/userState.js +4 -2
- package/dist/src/state/userState.js.map +1 -1
- package/dist/src/storage/memoryStorage.js +5 -3
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/transcript/consoleTranscriptLogger.js +3 -1
- package/dist/src/transcript/consoleTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/fileTranscriptLogger.js +5 -4
- package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
- package/dist/src/turnContext.js +2 -1
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +3 -3
- package/src/agent-client/agentClient.ts +5 -4
- package/src/agent-client/agentResponseHandler.ts +43 -67
- package/src/agent-client/createAgentResponseHandler.ts +133 -0
- package/src/agent-client/index.ts +1 -0
- package/src/app/adaptiveCards/activityValueParsers.ts +3 -2
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +5 -5
- package/src/app/agentApplication.ts +8 -16
- package/src/app/streaming/streamingResponse.ts +2 -2
- package/src/app/turnState.ts +15 -14
- package/src/app/turnStateProperty.ts +4 -2
- package/src/auth/authConfiguration.ts +5 -3
- package/src/auth/jwt-middleware.ts +87 -8
- package/src/auth/msal/msalTokenProvider.ts +16 -16
- package/src/baseAdapter.ts +3 -2
- package/src/cloudAdapter.ts +12 -12
- package/src/createCloudAdapter.ts +56 -0
- package/src/errorHelper.ts +244 -89
- package/src/headerPropagation.ts +4 -1
- package/src/index.ts +2 -0
- package/src/interfaces/index.ts +6 -0
- package/src/interfaces/webResponse.ts +44 -0
- package/src/middlewareSet.ts +3 -1
- package/src/oauth/userTokenClient.ts +3 -2
- package/src/state/conversationState.ts +4 -3
- package/src/state/userState.ts +4 -3
- package/src/storage/memoryStorage.ts +5 -3
- package/src/transcript/consoleTranscriptLogger.ts +3 -2
- package/src/transcript/fileTranscriptLogger.ts +6 -5
- package/src/transcript/transcriptLoggerMiddleware.ts +3 -2
- package/src/turnContext.ts +3 -2
package/src/errorHelper.ts
CHANGED
|
@@ -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 -
|
|
231
|
+
// Attachment Errors (-120250 to -120291)
|
|
217
232
|
// ============================================================================
|
|
218
233
|
|
|
219
234
|
/**
|
|
@@ -273,7 +288,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
273
288
|
},
|
|
274
289
|
|
|
275
290
|
// ============================================================================
|
|
276
|
-
// Connection and Authentication Errors (-120300 to -
|
|
291
|
+
// Connection and Authentication Errors (-120300 to -120599)
|
|
277
292
|
// ============================================================================
|
|
278
293
|
|
|
279
294
|
/**
|
|
@@ -281,7 +296,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
281
296
|
*/
|
|
282
297
|
ConnectionNotFoundInEnvironment: {
|
|
283
298
|
code: -120300,
|
|
284
|
-
description: 'Connection "{connectionName}" not found in environment.'
|
|
299
|
+
description: 'Connection "{connectionName}" not found in environment connections.'
|
|
285
300
|
},
|
|
286
301
|
|
|
287
302
|
/**
|
|
@@ -348,6 +363,51 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
348
363
|
description: 'Connection settings must be provided for this operation.'
|
|
349
364
|
},
|
|
350
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
|
+
|
|
351
411
|
/**
|
|
352
412
|
* Error thrown when identity is required to get token provider.
|
|
353
413
|
*/
|
|
@@ -356,6 +416,31 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
356
416
|
description: 'Identity is required to get the token provider.'
|
|
357
417
|
},
|
|
358
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
|
+
|
|
359
444
|
/**
|
|
360
445
|
* Error thrown when audience and service URL are required for token provider.
|
|
361
446
|
*/
|
|
@@ -726,6 +811,11 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
726
811
|
description: 'Agent name contains invalid characters: {agentName}'
|
|
727
812
|
},
|
|
728
813
|
|
|
814
|
+
ContinueConversationBotAppIdOrIdentityRequired: {
|
|
815
|
+
code: -120631,
|
|
816
|
+
description: 'continueConversation: botAppIdOrIdentity is required'
|
|
817
|
+
},
|
|
818
|
+
|
|
729
819
|
/**
|
|
730
820
|
* Error thrown when failed to post activity to agent.
|
|
731
821
|
*/
|
|
@@ -743,7 +833,7 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
743
833
|
},
|
|
744
834
|
|
|
745
835
|
// ============================================================================
|
|
746
|
-
// Storage and State Errors (-120700 to -
|
|
836
|
+
// Storage and State Errors (-120700 to -120732)
|
|
747
837
|
// ============================================================================
|
|
748
838
|
|
|
749
839
|
/**
|
|
@@ -754,6 +844,22 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
754
844
|
description: 'Storage: error writing "{key}" due to eTag conflict.'
|
|
755
845
|
},
|
|
756
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
|
+
|
|
757
863
|
/**
|
|
758
864
|
* Error thrown when storage option is not available in app options.
|
|
759
865
|
*/
|
|
@@ -778,96 +884,18 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
778
884
|
description: 'Invalid state scope: {scope}'
|
|
779
885
|
},
|
|
780
886
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
/**
|
|
786
|
-
* Error thrown when longRunningMessages property is unavailable.
|
|
787
|
-
*/
|
|
788
|
-
LongRunningMessagesPropertyUnavailable: {
|
|
789
|
-
code: -120850,
|
|
790
|
-
description: 'The Application.longRunningMessages property is unavailable because no adapter was configured in the app.'
|
|
791
|
-
},
|
|
792
|
-
|
|
793
|
-
/**
|
|
794
|
-
* Error thrown when transcriptLogger property is unavailable.
|
|
795
|
-
*/
|
|
796
|
-
TranscriptLoggerPropertyUnavailable: {
|
|
797
|
-
code: -120860,
|
|
798
|
-
description: 'The Application.transcriptLogger property is unavailable because no adapter was configured in the app.'
|
|
799
|
-
},
|
|
800
|
-
|
|
801
|
-
/**
|
|
802
|
-
* Error thrown when TranscriptLoggerMiddleware requires a TranscriptLogger instance.
|
|
803
|
-
*/
|
|
804
|
-
TranscriptLoggerInstanceRequired: {
|
|
805
|
-
code: -120870,
|
|
806
|
-
description: 'TranscriptLoggerMiddleware requires a TranscriptLogger instance.'
|
|
807
|
-
},
|
|
808
|
-
|
|
809
|
-
/**
|
|
810
|
-
* Error thrown when extension is already registered.
|
|
811
|
-
*/
|
|
812
|
-
ExtensionAlreadyRegistered: {
|
|
813
|
-
code: -120880,
|
|
814
|
-
description: 'Extension already registered'
|
|
815
|
-
},
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* Error thrown when invalid plugin type is added to MiddlewareSet.
|
|
819
|
-
*/
|
|
820
|
-
InvalidMiddlewarePluginType: {
|
|
821
|
-
code: -120890,
|
|
822
|
-
description: 'MiddlewareSet.use(): invalid plugin type being added.'
|
|
823
|
-
},
|
|
824
|
-
|
|
825
|
-
/**
|
|
826
|
-
* Error thrown when the stream has already ended.
|
|
827
|
-
*/
|
|
828
|
-
StreamAlreadyEnded: {
|
|
829
|
-
code: -120900,
|
|
830
|
-
description: 'The stream has already ended.'
|
|
831
|
-
},
|
|
832
|
-
|
|
833
|
-
// ============================================================================
|
|
834
|
-
// Adaptive Cards Errors (-120950 to -120980)
|
|
835
|
-
// ============================================================================
|
|
836
|
-
|
|
837
|
-
/**
|
|
838
|
-
* Error thrown when unexpected AdaptiveCards.actionExecute() is triggered.
|
|
839
|
-
*/
|
|
840
|
-
UnexpectedActionExecute: {
|
|
841
|
-
code: -120950,
|
|
842
|
-
description: 'Unexpected AdaptiveCards.actionExecute() triggered for activity type: {activityType}'
|
|
843
|
-
},
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Error thrown when unexpected AdaptiveCards.actionSubmit() is triggered.
|
|
847
|
-
*/
|
|
848
|
-
UnexpectedActionSubmit: {
|
|
849
|
-
code: -120960,
|
|
850
|
-
description: 'Unexpected AdaptiveCards.actionSubmit() triggered for activity type: {activityType}'
|
|
851
|
-
},
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Error thrown when unexpected AdaptiveCards.search() is triggered.
|
|
855
|
-
*/
|
|
856
|
-
UnexpectedSearchAction: {
|
|
857
|
-
code: -120970,
|
|
858
|
-
description: 'Unexpected AdaptiveCards.search() triggered for activity type: {activityType}'
|
|
887
|
+
InvalidStatePath: {
|
|
888
|
+
code: -120731,
|
|
889
|
+
description: 'Invalid state path: {path}'
|
|
859
890
|
},
|
|
860
891
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
InvalidActionValue: {
|
|
865
|
-
code: -120980,
|
|
866
|
-
description: 'Invalid action value: {error}'
|
|
892
|
+
TurnStateMissingStateScope: {
|
|
893
|
+
code: -120732,
|
|
894
|
+
description: 'TurnState missing state scope named "{scope}".'
|
|
867
895
|
},
|
|
868
896
|
|
|
869
897
|
// ============================================================================
|
|
870
|
-
// Proactive Messaging Errors (-120740 to -
|
|
898
|
+
// Proactive Messaging Errors (-120740 to -120753)
|
|
871
899
|
// ============================================================================
|
|
872
900
|
|
|
873
901
|
/**
|
|
@@ -983,6 +1011,133 @@ export const Errors: { [key: string]: AgentErrorDefinition } = {
|
|
|
983
1011
|
description: 'CreateConversationOptionsBuilder: Teams channel conversations require an initial activity. Call withActivity() before build().'
|
|
984
1012
|
},
|
|
985
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
|
+
|
|
986
1141
|
// ============================================================================
|
|
987
1142
|
// General Errors (-120990)
|
|
988
1143
|
// ============================================================================
|
package/src/headerPropagation.ts
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { ExceptionHelper } from '@microsoft/agents-activity'
|
|
7
|
+
import { Errors } from './errorHelper'
|
|
8
|
+
|
|
6
9
|
/**
|
|
7
10
|
* A class that implements the HeaderPropagationCollection interface.
|
|
8
11
|
* It filters the incoming request headers based on the definition provided and loads them into the outgoing headers collection.
|
|
@@ -24,7 +27,7 @@ export class HeaderPropagation implements HeaderPropagationCollection {
|
|
|
24
27
|
|
|
25
28
|
constructor (headers: Record<string, string | string[] | undefined>) {
|
|
26
29
|
if (!headers) {
|
|
27
|
-
throw
|
|
30
|
+
throw ExceptionHelper.generateException(Error, Errors.HeadersRequired)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
this._incomingRequests = this.normalizeHeaders(headers)
|
package/src/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './baseAdapter'
|
|
|
22
22
|
// test-only internals (e.g., the per-process warning dedup set) do not leak
|
|
23
23
|
// into the package's public API.
|
|
24
24
|
export { CloudAdapter, type CloudAdapterOptions } from './cloudAdapter'
|
|
25
|
+
export * from './createCloudAdapter'
|
|
25
26
|
export * from './middlewareSet'
|
|
26
27
|
export * from './messageFactory'
|
|
27
28
|
export * from './statusCodes'
|
|
@@ -29,6 +30,7 @@ export * from './turnContext'
|
|
|
29
30
|
export * from './turnContextStateCollection'
|
|
30
31
|
export * from './storage/storage'
|
|
31
32
|
export * from './headerPropagation'
|
|
33
|
+
export * from './interfaces'
|
|
32
34
|
export * from './httpClient'
|
|
33
35
|
|
|
34
36
|
export * from './agent-client'
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Framework-agnostic response surface used by the hosting layer.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This interface describes the minimal subset of an HTTP response object that
|
|
11
|
+
* `CloudAdapter.process` and `authorizeJWT` need at runtime. Any framework whose
|
|
12
|
+
* response object structurally satisfies this shape is compatible — including
|
|
13
|
+
* Express's `Response`, and adapter classes such as `FastifyReplyAdapter` from
|
|
14
|
+
* `@microsoft/agents-hosting-fastify`.
|
|
15
|
+
*
|
|
16
|
+
* Keeping this contract in the core hosting package means the hosting layer no
|
|
17
|
+
* longer needs to import types from `express` at compile time.
|
|
18
|
+
*/
|
|
19
|
+
export interface WebResponse {
|
|
20
|
+
status (code: number): this
|
|
21
|
+
setHeader (name: string, value: string): this
|
|
22
|
+
send (body?: unknown): this
|
|
23
|
+
end (): this
|
|
24
|
+
headersSent: boolean
|
|
25
|
+
writableEnded: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Framework-agnostic `next` callback used by middleware-style functions in the
|
|
30
|
+
* hosting layer (notably `authorizeJWT`). Mirrors the shape of Express's
|
|
31
|
+
* `NextFunction` so existing Express middleware continues to work unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export type NextFunction = (err?: any) => void
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Minimal HTTP request shape used by framework-agnostic route handlers.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Augments {@link WebRequestParamsCarrier} so handlers can read URL params
|
|
40
|
+
* (`req.params.conversationId`) without coupling to Express's `Request` type.
|
|
41
|
+
*/
|
|
42
|
+
export interface WebRequestParamsCarrier {
|
|
43
|
+
params?: Record<string, string | undefined>
|
|
44
|
+
}
|
package/src/middlewareSet.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */
|
|
2
|
+
import { ExceptionHelper } from '@microsoft/agents-activity'
|
|
2
3
|
import { TurnContext } from './turnContext'
|
|
3
4
|
import { debug } from '@microsoft/agents-telemetry'
|
|
5
|
+
import { Errors } from './errorHelper'
|
|
4
6
|
|
|
5
7
|
const logger = debug('agents:middleware')
|
|
6
8
|
|
|
@@ -52,7 +54,7 @@ export class MiddlewareSet implements Middleware {
|
|
|
52
54
|
typeof plugin === 'function' ? plugin : async (context, next) => await plugin.onTurn(context, next)
|
|
53
55
|
)
|
|
54
56
|
} else {
|
|
55
|
-
throw
|
|
57
|
+
throw ExceptionHelper.generateException(Error, Errors.InvalidMiddlewarePluginType)
|
|
56
58
|
}
|
|
57
59
|
})
|
|
58
60
|
return this
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
4
|
import { HttpClient, HttpError } from '../httpClient'
|
|
5
|
-
import { Activity, ConversationReference } from '@microsoft/agents-activity'
|
|
5
|
+
import { Activity, ConversationReference, ExceptionHelper } from '@microsoft/agents-activity'
|
|
6
6
|
import { debug } from '@microsoft/agents-telemetry'
|
|
7
7
|
import { normalizeTokenExchangeState } from '../activityWireCompat'
|
|
8
8
|
import { AadResourceUrls, SignInResource, TokenExchangeRequest, TokenOrSinginResourceResponse, TokenResponse, TokenStatus } from './userTokenClient.types'
|
|
@@ -12,6 +12,7 @@ import { HeaderPropagation, HeaderPropagationCollection } from '../headerPropaga
|
|
|
12
12
|
import { getTokenServiceEndpoint } from './customUserTokenAPI'
|
|
13
13
|
import { trace } from '@microsoft/agents-telemetry'
|
|
14
14
|
import { UserTokenClientTraceDefinitions } from '../observability'
|
|
15
|
+
import { Errors } from '../errorHelper'
|
|
15
16
|
|
|
16
17
|
const logger = debug('agents:user-token-client')
|
|
17
18
|
|
|
@@ -150,7 +151,7 @@ export class UserTokenClient {
|
|
|
150
151
|
const response = await this.executeRequest('delete', '/api/usertoken/SignOut', undefined, { params })
|
|
151
152
|
record({ userId, connectionName, channelId, httpStatusCode: response.status?.toString() })
|
|
152
153
|
if (response.status !== 200) {
|
|
153
|
-
throw
|
|
154
|
+
throw ExceptionHelper.generateException(Error, Errors.FailedToSignOut)
|
|
154
155
|
}
|
|
155
156
|
})
|
|
156
157
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { AgentState } from './agentState'
|
|
7
7
|
import { Storage } from '../storage/storage'
|
|
8
8
|
import { TurnContext } from '../turnContext'
|
|
9
|
-
import { Activity } from '@microsoft/agents-activity'
|
|
9
|
+
import { Activity, ExceptionHelper } from '@microsoft/agents-activity'
|
|
10
|
+
import { Errors } from '../errorHelper'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Manages the state of a conversation.
|
|
@@ -30,11 +31,11 @@ export class ConversationState extends AgentState {
|
|
|
30
31
|
const conversationId = activity && (activity.conversation != null) && activity.conversation.id ? activity.conversation.id : undefined
|
|
31
32
|
|
|
32
33
|
if (!channelId) {
|
|
33
|
-
throw
|
|
34
|
+
throw ExceptionHelper.generateException(Error, Errors.MissingActivityChannelId)
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
if (!conversationId) {
|
|
37
|
-
throw
|
|
38
|
+
throw ExceptionHelper.generateException(Error, Errors.MissingActivityConversationId)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
return `${channelId}/conversations/${conversationId}/${this.namespace}`
|
package/src/state/userState.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
import { AgentState } from './agentState'
|
|
7
7
|
import { Storage } from '../storage/storage'
|
|
8
8
|
import { TurnContext } from '../turnContext'
|
|
9
|
-
import { Activity } from '@microsoft/agents-activity'
|
|
9
|
+
import { Activity, ExceptionHelper } from '@microsoft/agents-activity'
|
|
10
|
+
import { Errors } from '../errorHelper'
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Manages the state of a user.
|
|
@@ -31,11 +32,11 @@ export class UserState extends AgentState {
|
|
|
31
32
|
const userId = activity && (activity.from != null) && activity.from.id ? activity.from.id : undefined
|
|
32
33
|
|
|
33
34
|
if (!channelId) {
|
|
34
|
-
throw
|
|
35
|
+
throw ExceptionHelper.generateException(Error, Errors.MissingActivityChannelId)
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
if (!userId) {
|
|
38
|
-
throw
|
|
39
|
+
throw ExceptionHelper.generateException(Error, Errors.MissingActivityFromId)
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
return `${channelId}/users/${userId}/${this.namespace}`
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { trace } from '@microsoft/agents-telemetry'
|
|
7
|
+
import { ExceptionHelper } from '@microsoft/agents-activity'
|
|
7
8
|
import { StorageTraceDefinitions } from '../observability'
|
|
8
9
|
import { Storage, StoreItem } from './storage'
|
|
9
10
|
import { debug } from '@microsoft/agents-telemetry'
|
|
11
|
+
import { Errors } from '../errorHelper'
|
|
10
12
|
|
|
11
13
|
const logger = debug('agents:memory-storage')
|
|
12
14
|
|
|
@@ -66,7 +68,7 @@ export class MemoryStorage implements Storage {
|
|
|
66
68
|
return trace(StorageTraceDefinitions.read, async ({ record }) => {
|
|
67
69
|
record({ keyCount: keys?.length })
|
|
68
70
|
if (!keys || keys.length === 0) {
|
|
69
|
-
throw
|
|
71
|
+
throw ExceptionHelper.generateException(ReferenceError, Errors.StorageReadKeysRequired)
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
const data: StoreItem = {}
|
|
@@ -98,7 +100,7 @@ export class MemoryStorage implements Storage {
|
|
|
98
100
|
async write (changes: StoreItem): Promise<void> {
|
|
99
101
|
return trace(StorageTraceDefinitions.write, async ({ record }) => {
|
|
100
102
|
if (!changes || changes.length === 0) {
|
|
101
|
-
throw
|
|
103
|
+
throw ExceptionHelper.generateException(ReferenceError, Errors.StorageWriteChangesRequired)
|
|
102
104
|
}
|
|
103
105
|
record({ keyCount: changes.length })
|
|
104
106
|
|
|
@@ -112,7 +114,7 @@ export class MemoryStorage implements Storage {
|
|
|
112
114
|
if (newItem.eTag === oldItem.eTag) {
|
|
113
115
|
this.saveItem(key, newItem)
|
|
114
116
|
} else {
|
|
115
|
-
throw
|
|
117
|
+
throw ExceptionHelper.generateException(Error, Errors.StorageETagConflict, undefined, { key })
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Activity } from '@microsoft/agents-activity'
|
|
1
|
+
import { Activity, ExceptionHelper } from '@microsoft/agents-activity'
|
|
2
2
|
import { TranscriptLogger } from './transcriptLogger'
|
|
3
|
+
import { Errors } from '../errorHelper'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* A transcript logger that logs activities to the console.
|
|
@@ -12,7 +13,7 @@ export class ConsoleTranscriptLogger implements TranscriptLogger {
|
|
|
12
13
|
*/
|
|
13
14
|
logActivity (activity: Activity): void | Promise<void> {
|
|
14
15
|
if (!activity) {
|
|
15
|
-
throw
|
|
16
|
+
throw ExceptionHelper.generateException(Error, Errors.ActivityRequired)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
console.log('Activity Log:', activity)
|