@microsoft/agents-hosting 1.5.0-beta.2.gf6783d691c → 1.5.0-beta.26.gaab35a7b76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +10 -9
- package/dist/src/activityHandler.js +2 -2
- package/dist/src/activityHandler.js.map +1 -1
- package/dist/src/agent-client/agentClient.js +49 -40
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.js +2 -2
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +53 -19
- package/dist/src/app/agentApplication.js +201 -117
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/agentApplicationBuilder.d.ts +15 -0
- package/dist/src/app/agentApplicationBuilder.js +22 -4
- package/dist/src/app/agentApplicationBuilder.js.map +1 -1
- package/dist/src/app/agentApplicationOptions.d.ts +38 -0
- package/dist/src/app/attachmentDownloader.js +2 -2
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/auth/authorization.js +12 -9
- package/dist/src/app/auth/authorization.js.map +1 -1
- package/dist/src/app/auth/authorizationManager.d.ts +22 -5
- package/dist/src/app/auth/authorizationManager.js +268 -54
- package/dist/src/app/auth/authorizationManager.js.map +1 -1
- package/dist/src/app/auth/handlerStorage.js +3 -1
- package/dist/src/app/auth/handlerStorage.js.map +1 -1
- package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +19 -16
- package/dist/src/app/auth/handlers/agenticAuthorization.js +46 -52
- package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +51 -75
- package/dist/src/app/auth/handlers/azureBotAuthorization.js +217 -192
- package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
- package/dist/src/app/auth/types.d.ts +100 -1
- package/dist/src/app/auth/utils.d.ts +10 -0
- package/dist/src/app/auth/utils.js +21 -0
- package/dist/src/app/auth/utils.js.map +1 -0
- package/dist/src/app/index.d.ts +1 -0
- package/dist/src/app/index.js +1 -0
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/proactive/conversation.d.ts +43 -0
- package/dist/src/app/proactive/conversation.js +67 -0
- package/dist/src/app/proactive/conversation.js.map +1 -0
- package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
- package/dist/src/app/proactive/conversationBuilder.js +110 -0
- package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
- package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
- package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
- package/dist/src/app/proactive/createConversationOptions.js +10 -0
- package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
- package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
- package/dist/src/app/proactive/index.d.ts +7 -0
- package/dist/src/app/proactive/index.js +26 -0
- package/dist/src/app/proactive/index.js.map +1 -0
- package/dist/src/app/proactive/proactive.d.ts +248 -0
- package/dist/src/app/proactive/proactive.js +310 -0
- package/dist/src/app/proactive/proactive.js.map +1 -0
- package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
- package/dist/src/app/proactive/proactiveOptions.js +5 -0
- package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
- package/dist/src/app/streaming/streamingResponse.js +2 -2
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/teamsAttachmentDownloader.js +2 -2
- package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
- package/dist/src/app/turnState.js +2 -2
- package/dist/src/app/turnState.js.map +1 -1
- package/dist/src/auth/authConfiguration.d.ts +61 -0
- package/dist/src/auth/authConfiguration.js +52 -3
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/jwt-middleware.js +2 -2
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msalConnectionManager.js +20 -0
- package/dist/src/auth/msalConnectionManager.js.map +1 -1
- package/dist/src/auth/msalTokenCredential.js +3 -0
- package/dist/src/auth/msalTokenCredential.js.map +1 -1
- package/dist/src/auth/msalTokenProvider.js +136 -110
- package/dist/src/auth/msalTokenProvider.js.map +1 -1
- package/dist/src/baseAdapter.js +2 -2
- package/dist/src/baseAdapter.js.map +1 -1
- package/dist/src/cloudAdapter.js +201 -154
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/connector-client/connectorClient.js +176 -127
- package/dist/src/connector-client/connectorClient.js.map +1 -1
- package/dist/src/errorHelper.js +108 -0
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/middlewareSet.js +2 -2
- package/dist/src/middlewareSet.js.map +1 -1
- package/dist/src/oauth/userTokenClient.js +78 -48
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/observability/index.d.ts +2 -0
- package/dist/src/observability/index.js +21 -0
- package/dist/src/observability/index.js.map +1 -0
- package/dist/src/observability/metrics.d.ts +21 -0
- package/dist/src/observability/metrics.js +87 -0
- package/dist/src/observability/metrics.js.map +1 -0
- package/dist/src/observability/traces.d.ts +234 -0
- package/dist/src/observability/traces.js +962 -0
- package/dist/src/observability/traces.js.map +1 -0
- package/dist/src/state/agentState.js +2 -2
- package/dist/src/state/agentState.js.map +1 -1
- package/dist/src/storage/fileStorage.js +38 -28
- package/dist/src/storage/fileStorage.js.map +1 -1
- package/dist/src/storage/memoryStorage.js +41 -30
- package/dist/src/storage/memoryStorage.js.map +1 -1
- package/dist/src/transcript/fileTranscriptLogger.js +2 -2
- package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
- package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -2
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
- package/dist/src/turnContext.js +55 -43
- package/dist/src/turnContext.js.map +1 -1
- package/package.json +10 -9
- package/src/activityHandler.ts +1 -1
- package/src/agent-client/agentClient.ts +53 -42
- package/src/agent-client/agentResponseHandler.ts +1 -1
- package/src/app/agentApplication.ts +248 -104
- package/src/app/agentApplicationBuilder.ts +26 -4
- package/src/app/agentApplicationOptions.ts +43 -0
- package/src/app/attachmentDownloader.ts +1 -1
- package/src/app/auth/authorization.ts +11 -8
- package/src/app/auth/authorizationManager.ts +311 -54
- package/src/app/auth/handlerStorage.ts +3 -1
- package/src/app/auth/handlers/agenticAuthorization.ts +68 -72
- package/src/app/auth/handlers/azureBotAuthorization.ts +260 -264
- package/src/app/auth/types.ts +102 -1
- package/src/app/auth/utils.ts +22 -0
- package/src/app/index.ts +1 -0
- package/src/app/proactive/conversation.ts +87 -0
- package/src/app/proactive/conversationBuilder.ts +139 -0
- package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
- package/src/app/proactive/createConversationOptions.ts +35 -0
- package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
- package/src/app/proactive/index.ts +10 -0
- package/src/app/proactive/proactive.ts +524 -0
- package/src/app/proactive/proactiveOptions.ts +24 -0
- package/src/app/streaming/streamingResponse.ts +1 -1
- package/src/app/teamsAttachmentDownloader.ts +1 -1
- package/src/app/turnState.ts +1 -1
- package/src/auth/authConfiguration.ts +58 -1
- package/src/auth/jwt-middleware.ts +1 -1
- package/src/auth/msalConnectionManager.ts +22 -0
- package/src/auth/msalTokenCredential.ts +4 -0
- package/src/auth/msalTokenProvider.ts +138 -107
- package/src/baseAdapter.ts +1 -1
- package/src/cloudAdapter.ts +239 -184
- package/src/connector-client/connectorClient.ts +169 -126
- package/src/errorHelper.ts +124 -0
- package/src/middlewareSet.ts +1 -1
- package/src/oauth/userTokenClient.ts +70 -46
- package/src/observability/index.ts +5 -0
- package/src/observability/metrics.ts +103 -0
- package/src/observability/traces.ts +988 -0
- package/src/state/agentState.ts +1 -1
- package/src/storage/fileStorage.ts +36 -26
- package/src/storage/memoryStorage.ts +40 -29
- package/src/transcript/fileTranscriptLogger.ts +1 -1
- package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
- package/src/turnContext.ts +53 -42
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@microsoft/agents-hosting",
|
|
4
|
-
"version": "1.5.0-beta.
|
|
4
|
+
"version": "1.5.0-beta.26.gaab35a7b76",
|
|
5
5
|
"homepage": "https://github.com/microsoft/Agents-for-js",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"main": "dist/src/index.js",
|
|
20
20
|
"types": "dist/src/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@azure/core-auth": "
|
|
23
|
-
"@azure/msal-node": "
|
|
24
|
-
"@microsoft/agents-activity": "1.5.0-beta.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
22
|
+
"@azure/core-auth": "1.10.1",
|
|
23
|
+
"@azure/msal-node": "5.0.6",
|
|
24
|
+
"@microsoft/agents-activity": "1.5.0-beta.26.gaab35a7b76",
|
|
25
|
+
"@microsoft/agents-telemetry": "1.5.0-beta.26.gaab35a7b76",
|
|
26
|
+
"axios": "1.15.0",
|
|
27
|
+
"jsonwebtoken": "9.0.3",
|
|
28
|
+
"jwks-rsa": "4.0.1",
|
|
29
|
+
"object-path": "0.11.8",
|
|
29
30
|
"zod": "3.25.75"
|
|
30
31
|
},
|
|
31
32
|
"license": "MIT",
|
|
@@ -47,6 +48,6 @@
|
|
|
47
48
|
"node": ">=20.0.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@types/object-path": "
|
|
51
|
+
"@types/object-path": "0.11.4"
|
|
51
52
|
}
|
|
52
53
|
}
|
package/src/activityHandler.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { debug } from '@microsoft/agents-
|
|
5
|
+
import { debug } from '@microsoft/agents-telemetry'
|
|
6
6
|
import { TurnContext } from './turnContext'
|
|
7
7
|
import { Activity, ActivityTypes, Channels, ExceptionHelper } from '@microsoft/agents-activity'
|
|
8
8
|
import { Errors } from './errorHelper'
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AuthConfiguration, MsalTokenProvider } from '../auth'
|
|
2
2
|
import { Activity, ConversationReference, RoleTypes } from '@microsoft/agents-activity'
|
|
3
3
|
import { v4 } from 'uuid'
|
|
4
|
-
import { debug } from '@microsoft/agents-
|
|
4
|
+
import { debug } from '@microsoft/agents-telemetry'
|
|
5
5
|
import { ConversationState } from '../state'
|
|
6
6
|
import { TurnContext } from '../turnContext'
|
|
7
|
+
import { trace } from '@microsoft/agents-telemetry'
|
|
8
|
+
import { AgentClientTraceDefinitions } from '../observability'
|
|
7
9
|
|
|
8
10
|
const logger = debug('agents:agent-client')
|
|
9
11
|
|
|
@@ -68,56 +70,65 @@ export class AgentClient {
|
|
|
68
70
|
* @throws Error if the request to the agent endpoint fails
|
|
69
71
|
*/
|
|
70
72
|
public async postActivity (activity: Activity, authConfig: AuthConfiguration, conversationState: ConversationState, context: TurnContext): Promise<string> {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
return trace(AgentClientTraceDefinitions.postActivity, async ({ record }) => {
|
|
74
|
+
record({
|
|
75
|
+
endpoint: this.agentClientConfig.endPoint,
|
|
76
|
+
clientId: this.agentClientConfig.clientId,
|
|
77
|
+
})
|
|
78
|
+
const activityCopy = activity.clone()
|
|
79
|
+
activityCopy.serviceUrl = this.agentClientConfig.serviceUrl
|
|
80
|
+
activityCopy.recipient = { ...activityCopy.recipient, role: RoleTypes.Skill }
|
|
81
|
+
activityCopy.relatesTo = {
|
|
82
|
+
serviceUrl: activity.serviceUrl,
|
|
83
|
+
activityId: activityCopy.id,
|
|
84
|
+
channelId: activityCopy.channelId!,
|
|
85
|
+
locale: activityCopy.locale,
|
|
86
|
+
conversation: {
|
|
87
|
+
id: activity.conversation!.id,
|
|
88
|
+
...activityCopy.conversation
|
|
89
|
+
}
|
|
82
90
|
}
|
|
83
|
-
|
|
84
|
-
activityCopy.conversation!.id = v4()
|
|
91
|
+
activityCopy.conversation!.id = v4()
|
|
85
92
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
const conversationDataAccessor = conversationState.createProperty<ConversationData>(activityCopy.conversation!.id)
|
|
94
|
+
const convRef = await conversationDataAccessor.set(context,
|
|
95
|
+
{ conversationReference: activity.getConversationReference(), nameRequested: false },
|
|
96
|
+
{ channelId: activityCopy.channelId!, conversationId: activityCopy.conversation!.id }
|
|
97
|
+
)
|
|
91
98
|
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
const stateChanges = JSON.stringify(convRef)
|
|
100
|
+
logger.debug('stateChanges: ', stateChanges)
|
|
94
101
|
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
const authProvider = new MsalTokenProvider(authConfig)
|
|
103
|
+
const token = await authProvider.getAccessToken(this.agentClientConfig.clientId)
|
|
97
104
|
|
|
98
|
-
|
|
105
|
+
logger.debug('agent request: ', activityCopy)
|
|
99
106
|
|
|
100
|
-
|
|
107
|
+
let authHeader = '' // Allow anonymous auth.
|
|
101
108
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
109
|
+
if (token.trim().length > 0) {
|
|
110
|
+
authHeader = `Bearer ${token}`
|
|
111
|
+
}
|
|
105
112
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
await conversationState.saveChanges(context, false, { channelId: activityCopy.channelId!, conversationId: activityCopy.conversation!.id })
|
|
114
|
+
const response = await fetch(this.agentClientConfig.endPoint, {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
headers: {
|
|
117
|
+
'Content-Type': 'application/json',
|
|
118
|
+
Authorization: authHeader,
|
|
119
|
+
'x-ms-conversation-id': activityCopy.conversation!.id
|
|
120
|
+
},
|
|
121
|
+
body: JSON.stringify(activityCopy)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
record({ httpStatusCode: response.status.toString() })
|
|
125
|
+
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
await conversationDataAccessor.delete(context, { channelId: activityCopy.channelId!, conversationId: activityCopy.conversation!.id })
|
|
128
|
+
throw new Error(`Failed to post activity to agent: ${response.statusText}`)
|
|
129
|
+
}
|
|
130
|
+
return response.statusText
|
|
115
131
|
})
|
|
116
|
-
if (!response.ok) {
|
|
117
|
-
await conversationDataAccessor.delete(context, { channelId: activityCopy.channelId!, conversationId: activityCopy.conversation!.id })
|
|
118
|
-
throw new Error(`Failed to post activity to agent: ${response.statusText}`)
|
|
119
|
-
}
|
|
120
|
-
return response.statusText
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
/**
|
|
@@ -5,7 +5,7 @@ import { Request, Response, Application } from 'express'
|
|
|
5
5
|
import { TurnContext } from '../turnContext'
|
|
6
6
|
import { v4 } from 'uuid'
|
|
7
7
|
import { normalizeIncomingActivity } from '../activityWireCompat'
|
|
8
|
-
import { debug } from '@microsoft/agents-
|
|
8
|
+
import { debug } from '@microsoft/agents-telemetry'
|
|
9
9
|
import { ConversationState } from '../state'
|
|
10
10
|
|
|
11
11
|
const logger = debug('agents:agent-client')
|