@microsoft/agents-copilotstudio-client 1.4.0-beta.6.g725ba9fc33 → 1.4.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/dist/package.json +2 -2
- package/dist/src/browser.mjs +5 -5
- package/dist/src/browser.mjs.map +4 -4
- package/dist/src/connectionSettings.d.ts +2 -0
- package/dist/src/connectionSettings.js +5 -2
- package/dist/src/connectionSettings.js.map +1 -1
- package/dist/src/copilotStudioClient.d.ts +61 -6
- package/dist/src/copilotStudioClient.js +176 -38
- package/dist/src/copilotStudioClient.js.map +1 -1
- package/dist/src/copilotStudioConnectionSettings.d.ts +6 -0
- package/dist/src/copilotStudioWebChat.d.ts +30 -0
- package/dist/src/copilotStudioWebChat.js +38 -11
- package/dist/src/copilotStudioWebChat.js.map +1 -1
- package/dist/src/executeTurnRequest.d.ts +5 -2
- package/dist/src/executeTurnRequest.js +4 -2
- package/dist/src/executeTurnRequest.js.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/powerPlatformEnvironment.d.ts +8 -0
- package/dist/src/powerPlatformEnvironment.js +21 -6
- package/dist/src/powerPlatformEnvironment.js.map +1 -1
- package/dist/src/responses.d.ts +50 -0
- package/dist/src/responses.js +35 -0
- package/dist/src/responses.js.map +1 -0
- package/dist/src/scopeHelper.d.ts +17 -0
- package/dist/src/scopeHelper.js +24 -0
- package/dist/src/scopeHelper.js.map +1 -0
- package/dist/src/startRequest.d.ts +34 -0
- package/dist/src/startRequest.js +22 -0
- package/dist/src/startRequest.js.map +1 -0
- package/dist/src/strategies/prebuiltBotStrategy.d.ts +2 -1
- package/dist/src/strategies/publishedBotStrategy.d.ts +2 -1
- package/dist/src/subscribeEvent.d.ts +33 -0
- package/dist/src/subscribeEvent.js +7 -0
- package/dist/src/subscribeEvent.js.map +1 -0
- package/dist/src/userAgentHelper.d.ts +26 -0
- package/dist/src/userAgentHelper.js +52 -0
- package/dist/src/userAgentHelper.js.map +1 -0
- package/package.json +2 -2
- package/src/connectionSettings.ts +4 -1
- package/src/copilotStudioClient.ts +238 -32
- package/src/copilotStudioConnectionSettings.ts +7 -0
- package/src/copilotStudioWebChat.ts +75 -12
- package/src/executeTurnRequest.ts +7 -2
- package/src/index.ts +5 -0
- package/src/powerPlatformEnvironment.ts +26 -7
- package/src/responses.ts +75 -0
- package/src/scopeHelper.ts +22 -0
- package/src/startRequest.ts +48 -0
- package/src/strategies/prebuiltBotStrategy.ts +1 -1
- package/src/strategies/publishedBotStrategy.ts +1 -1
- package/src/subscribeEvent.ts +38 -0
- package/src/userAgentHelper.ts +49 -0
|
@@ -42,6 +42,8 @@ declare abstract class ConnectionOptions implements Omit<CopilotStudioConnection
|
|
|
42
42
|
directConnectUrl?: string;
|
|
43
43
|
/** Flag to use the experimental endpoint if available */
|
|
44
44
|
useExperimentalEndpoint?: boolean;
|
|
45
|
+
/** Flag to enable diagnostic logging. Default is false. */
|
|
46
|
+
enableDiagnostics?: boolean;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
47
49
|
* Represents the settings required to establish a connection to Copilot Studio.
|
|
@@ -14,6 +14,8 @@ class ConnectionOptions {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
/** Flag to use the experimental endpoint if available */
|
|
16
16
|
this.useExperimentalEndpoint = false;
|
|
17
|
+
/** Flag to enable diagnostic logging. Default is false. */
|
|
18
|
+
this.enableDiagnostics = false;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
@@ -47,7 +49,7 @@ exports.ConnectionSettings = ConnectionSettings;
|
|
|
47
49
|
* @returns The connection settings.
|
|
48
50
|
*/
|
|
49
51
|
const loadCopilotStudioConnectionSettingsFromEnv = () => {
|
|
50
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
51
53
|
return new ConnectionSettings({
|
|
52
54
|
appClientId: (_a = process.env.appClientId) !== null && _a !== void 0 ? _a : '',
|
|
53
55
|
tenantId: (_b = process.env.tenantId) !== null && _b !== void 0 ? _b : '',
|
|
@@ -59,7 +61,8 @@ const loadCopilotStudioConnectionSettingsFromEnv = () => {
|
|
|
59
61
|
customPowerPlatformCloud: process.env.customPowerPlatformCloud,
|
|
60
62
|
copilotAgentType: process.env.copilotAgentType,
|
|
61
63
|
directConnectUrl: process.env.directConnectUrl,
|
|
62
|
-
useExperimentalEndpoint: ((_g = process.env.useExperimentalEndpoint) === null || _g === void 0 ? void 0 : _g.toLowerCase()) === 'true'
|
|
64
|
+
useExperimentalEndpoint: ((_g = process.env.useExperimentalEndpoint) === null || _g === void 0 ? void 0 : _g.toLowerCase()) === 'true',
|
|
65
|
+
enableDiagnostics: ((_h = process.env.enableDiagnostics) === null || _h === void 0 ? void 0 : _h.toLowerCase()) === 'true'
|
|
63
66
|
});
|
|
64
67
|
};
|
|
65
68
|
exports.loadCopilotStudioConnectionSettingsFromEnv = loadCopilotStudioConnectionSettingsFromEnv;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionSettings.js","sourceRoot":"","sources":["../../src/connectionSettings.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAuC;AAEvC,6DAAyD;AAEzD;;GAEG;AACH,MAAe,iBAAiB;IAAhC;QAgCE,yDAAyD;QAClD,4BAAuB,GAAa,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"connectionSettings.js","sourceRoot":"","sources":["../../src/connectionSettings.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2CAAuC;AAEvC,6DAAyD;AAEzD;;GAEG;AACH,MAAe,iBAAiB;IAAhC;QAgCE,yDAAyD;QAClD,4BAAuB,GAAa,KAAK,CAAA;QAChD,2DAA2D;QACpD,sBAAiB,GAAa,KAAK,CAAA;IAC5C,CAAC;CAAA;AAED;;GAEG;AACH,MAAa,kBAAmB,SAAQ,iBAAiB;IAiBvD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1C,QAAQ,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,EAAE;QACpC,SAAS,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,iBAAiB,mCAAI,mCAAmC;QAC/E,aAAa,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,aAAa,mCAAI,EAAE;QAC9C,eAAe,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,eAAe,mCAAI,EAAE;QAClD,UAAU,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,UAAU,mCAAI,EAAE;QACxC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,KAA2B;QAC9C,wBAAwB,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;QAC9D,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAA6B;QAC3D,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,gBAAgB;QAC9C,uBAAuB,EAAE,CAAA,MAAA,OAAO,CAAC,GAAG,CAAC,uBAAuB,0CAAE,WAAW,EAAE,MAAK,MAAM;QACtF,iBAAiB,EAAE,CAAA,MAAA,OAAO,CAAC,GAAG,CAAC,iBAAiB,0CAAE,WAAW,EAAE,MAAK,MAAM;KAC3E,CAAC,CAAA;AACJ,CAAC,CAAA;AAfY,QAAA,0CAA0C,8CAetD"}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ConnectionSettings } from './connectionSettings';
|
|
6
6
|
import { Activity } from '@microsoft/agents-activity';
|
|
7
|
+
import { StartRequest } from './startRequest';
|
|
8
|
+
import { StartResponse, ExecuteTurnResponse } from './responses';
|
|
9
|
+
import { SubscribeEvent } from './subscribeEvent';
|
|
7
10
|
/**
|
|
8
11
|
* Client for interacting with Microsoft Copilot Studio services.
|
|
9
12
|
* Provides functionality to start conversations and send messages to Copilot Studio bots.
|
|
@@ -24,6 +27,7 @@ export declare class CopilotStudioClient {
|
|
|
24
27
|
* This is used for authentication token audience configuration.
|
|
25
28
|
* @param settings Copilot Studio connection settings.
|
|
26
29
|
* @returns The scope URL for token audience.
|
|
30
|
+
* @deprecated Use ScopeHelper.getScopeFromSettings instead.
|
|
27
31
|
*/
|
|
28
32
|
static scopeFromSettings: (settings: ConnectionSettings) => string;
|
|
29
33
|
/**
|
|
@@ -32,6 +36,12 @@ export declare class CopilotStudioClient {
|
|
|
32
36
|
* @param token The authentication token.
|
|
33
37
|
*/
|
|
34
38
|
constructor(settings: ConnectionSettings, token: string);
|
|
39
|
+
/**
|
|
40
|
+
* Logs a diagnostic message if diagnostics are enabled.
|
|
41
|
+
* @param message The message to log.
|
|
42
|
+
* @param args Additional arguments to log.
|
|
43
|
+
*/
|
|
44
|
+
private logDiagnostic;
|
|
35
45
|
/**
|
|
36
46
|
* Streams activities from the Copilot Studio service using eventsource-client.
|
|
37
47
|
* @param url The connection URL for Copilot Studio.
|
|
@@ -40,14 +50,13 @@ export declare class CopilotStudioClient {
|
|
|
40
50
|
* @returns An async generator yielding the Agent's Activities.
|
|
41
51
|
*/
|
|
42
52
|
private postRequestAsync;
|
|
53
|
+
private processResponseHeaders;
|
|
43
54
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @returns A string containing the product information, including version and user agent.
|
|
55
|
+
* Starts a new conversation with the Copilot Studio service using a StartRequest.
|
|
56
|
+
* @param request The request parameters for starting the conversation.
|
|
57
|
+
* @returns An async generator yielding the Agent's Activities.
|
|
48
58
|
*/
|
|
49
|
-
|
|
50
|
-
private processResponseHeaders;
|
|
59
|
+
startConversationStreaming(request: StartRequest): AsyncGenerator<Activity>;
|
|
51
60
|
/**
|
|
52
61
|
* Starts a new conversation with the Copilot Studio service.
|
|
53
62
|
* @param emitStartConversationEvent Whether to emit a start conversation event. Defaults to true.
|
|
@@ -61,6 +70,31 @@ export declare class CopilotStudioClient {
|
|
|
61
70
|
* @returns An async generator yielding the Agent's Activities.
|
|
62
71
|
*/
|
|
63
72
|
sendActivityStreaming(activity: Activity, conversationId?: string): AsyncGenerator<Activity>;
|
|
73
|
+
/**
|
|
74
|
+
* Executes a turn in an existing conversation by sending an activity.
|
|
75
|
+
* This method provides explicit control over the conversation ID.
|
|
76
|
+
* @param activity The activity to send.
|
|
77
|
+
* @param conversationId The ID of the conversation. Required.
|
|
78
|
+
* @returns An async generator yielding the Agent's Activities.
|
|
79
|
+
* @throws Error if conversationId is not provided.
|
|
80
|
+
*/
|
|
81
|
+
executeStreaming(activity: Activity, conversationId: string): AsyncGenerator<Activity>;
|
|
82
|
+
/**
|
|
83
|
+
* Executes a turn in an existing conversation by sending an activity.
|
|
84
|
+
* @param activity The activity to send.
|
|
85
|
+
* @param conversationId The ID of the conversation. Required.
|
|
86
|
+
* @returns A promise yielding an array of activities.
|
|
87
|
+
* @throws Error if conversationId is not provided.
|
|
88
|
+
* @deprecated Use executeStreaming instead.
|
|
89
|
+
*/
|
|
90
|
+
execute(activity: Activity, conversationId: string): Promise<Activity[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Starts a new conversation with the Copilot Studio service using a StartRequest.
|
|
93
|
+
* @param request The request parameters for starting the conversation.
|
|
94
|
+
* @returns A promise yielding an array of activities.
|
|
95
|
+
* @deprecated Use startConversationStreaming instead.
|
|
96
|
+
*/
|
|
97
|
+
startConversationAsync(request: StartRequest): Promise<Activity[]>;
|
|
64
98
|
/**
|
|
65
99
|
* Starts a new conversation with the Copilot Studio service.
|
|
66
100
|
* @param emitStartConversationEvent Whether to emit a start conversation event. Defaults to true.
|
|
@@ -84,4 +118,25 @@ export declare class CopilotStudioClient {
|
|
|
84
118
|
* @deprecated Use sendActivityStreaming instead.
|
|
85
119
|
*/
|
|
86
120
|
sendActivity(activity: Activity, conversationId?: string): Promise<Activity[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Starts a new conversation and returns a typed response.
|
|
123
|
+
* @param request The request parameters for starting the conversation.
|
|
124
|
+
* @returns A promise yielding a StartResponse with activities and conversation metadata.
|
|
125
|
+
*/
|
|
126
|
+
startConversationWithResponse(request?: StartRequest | boolean): Promise<StartResponse>;
|
|
127
|
+
/**
|
|
128
|
+
* Executes a turn and returns a typed response.
|
|
129
|
+
* @param activity The activity to send.
|
|
130
|
+
* @param conversationId The conversation ID.
|
|
131
|
+
* @returns A promise yielding an ExecuteTurnResponse with activities and metadata.
|
|
132
|
+
*/
|
|
133
|
+
executeWithResponse(activity: Activity, conversationId: string): Promise<ExecuteTurnResponse>;
|
|
134
|
+
/**
|
|
135
|
+
* Subscribes to a conversation to receive events via Server-Sent Events (SSE).
|
|
136
|
+
* This method allows resumption from a specific event ID.
|
|
137
|
+
* @param conversationId The ID of the conversation to subscribe to.
|
|
138
|
+
* @param lastReceivedEventId Optional. The last received event ID for resumption.
|
|
139
|
+
* @returns An async generator yielding SubscribeEvent objects containing activities and event IDs.
|
|
140
|
+
*/
|
|
141
|
+
subscribeAsync(conversationId: string, lastReceivedEventId?: string): AsyncGenerator<SubscribeEvent>;
|
|
87
142
|
}
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
7
|
exports.CopilotStudioClient = void 0;
|
|
11
8
|
const eventsource_client_1 = require("eventsource-client");
|
|
@@ -13,8 +10,9 @@ const powerPlatformEnvironment_1 = require("./powerPlatformEnvironment");
|
|
|
13
10
|
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
14
11
|
const executeTurnRequest_1 = require("./executeTurnRequest");
|
|
15
12
|
const logger_1 = require("@microsoft/agents-activity/logger");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
13
|
+
const userAgentHelper_1 = require("./userAgentHelper");
|
|
14
|
+
const scopeHelper_1 = require("./scopeHelper");
|
|
15
|
+
const responses_1 = require("./responses");
|
|
18
16
|
const logger = (0, logger_1.debug)('copilot-studio:client');
|
|
19
17
|
/**
|
|
20
18
|
* Client for interacting with Microsoft Copilot Studio services.
|
|
@@ -32,6 +30,16 @@ class CopilotStudioClient {
|
|
|
32
30
|
this.settings = settings;
|
|
33
31
|
this.token = token;
|
|
34
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Logs a diagnostic message if diagnostics are enabled.
|
|
35
|
+
* @param message The message to log.
|
|
36
|
+
* @param args Additional arguments to log.
|
|
37
|
+
*/
|
|
38
|
+
logDiagnostic(message, ...args) {
|
|
39
|
+
if (this.settings.enableDiagnostics) {
|
|
40
|
+
logger.info(`[DIAGNOSTICS] ${message}`, ...args);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
35
43
|
/**
|
|
36
44
|
* Streams activities from the Copilot Studio service using eventsource-client.
|
|
37
45
|
* @param url The connection URL for Copilot Studio.
|
|
@@ -41,13 +49,16 @@ class CopilotStudioClient {
|
|
|
41
49
|
*/
|
|
42
50
|
async *postRequestAsync(url, body, method = 'POST') {
|
|
43
51
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
52
|
+
this.logDiagnostic(`Request URL: ${url}`);
|
|
53
|
+
this.logDiagnostic(`Request Method: ${method}`);
|
|
54
|
+
this.logDiagnostic('Request Body:', body ? JSON.stringify(body, null, 2) : 'none');
|
|
44
55
|
logger.debug(`>>> SEND TO ${url}`);
|
|
45
56
|
const streamMap = new Map();
|
|
46
57
|
const eventSource = (0, eventsource_client_1.createEventSource)({
|
|
47
58
|
url,
|
|
48
59
|
headers: {
|
|
49
60
|
Authorization: `Bearer ${this.token}`,
|
|
50
|
-
'User-Agent':
|
|
61
|
+
'User-Agent': userAgentHelper_1.UserAgentHelper.getProductInfo(),
|
|
51
62
|
'Content-Type': 'application/json',
|
|
52
63
|
Accept: 'text/event-stream'
|
|
53
64
|
},
|
|
@@ -121,24 +132,6 @@ class CopilotStudioClient {
|
|
|
121
132
|
eventSource.close();
|
|
122
133
|
}
|
|
123
134
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Appends this package.json version to the User-Agent header.
|
|
126
|
-
* - For browser environments, it includes the user agent of the browser.
|
|
127
|
-
* - For Node.js environments, it includes the Node.js version, platform, architecture, and release.
|
|
128
|
-
* @returns A string containing the product information, including version and user agent.
|
|
129
|
-
*/
|
|
130
|
-
static getProductInfo() {
|
|
131
|
-
const versionString = `CopilotStudioClient.agents-sdk-js/${package_json_1.version}`;
|
|
132
|
-
let userAgent;
|
|
133
|
-
if (typeof window !== 'undefined' && window.navigator) {
|
|
134
|
-
userAgent = `${versionString} ${navigator.userAgent}`;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
userAgent = `${versionString} nodejs/${process.version} ${os_1.default.platform()}-${os_1.default.arch()}/${os_1.default.release()}`;
|
|
138
|
-
}
|
|
139
|
-
logger.debug(`User-Agent: ${userAgent}`);
|
|
140
|
-
return userAgent;
|
|
141
|
-
}
|
|
142
135
|
processResponseHeaders(responseHeaders) {
|
|
143
136
|
var _a, _b;
|
|
144
137
|
if (this.settings.useExperimentalEndpoint && !((_a = this.settings.directConnectUrl) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
@@ -158,17 +151,35 @@ class CopilotStudioClient {
|
|
|
158
151
|
sanitizedHeaders.set(key, value);
|
|
159
152
|
}
|
|
160
153
|
});
|
|
161
|
-
|
|
154
|
+
this.logDiagnostic('Response Headers:', sanitizedHeaders);
|
|
162
155
|
}
|
|
163
156
|
/**
|
|
164
|
-
*
|
|
165
|
-
* @param emitStartConversationEvent Whether to emit a start conversation event. Defaults to true.
|
|
166
|
-
* @returns An async generator yielding the Agent's Activities.
|
|
157
|
+
* Implementation of startConversationStreaming with overloads.
|
|
167
158
|
*/
|
|
168
|
-
async *startConversationStreaming(
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
159
|
+
async *startConversationStreaming(requestOrFlag) {
|
|
160
|
+
var _a;
|
|
161
|
+
// Normalize input to StartRequest
|
|
162
|
+
let request;
|
|
163
|
+
if (typeof requestOrFlag === 'boolean' || requestOrFlag === undefined) {
|
|
164
|
+
// Legacy call: startConversationStreaming(true/false)
|
|
165
|
+
request = {
|
|
166
|
+
emitStartConversationEvent: requestOrFlag !== null && requestOrFlag !== void 0 ? requestOrFlag : true
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
// New call: startConversationStreaming({ locale: 'en-US', ... })
|
|
171
|
+
request = requestOrFlag;
|
|
172
|
+
}
|
|
173
|
+
const uriStart = (0, powerPlatformEnvironment_1.getCopilotStudioConnectionUrl)(this.settings, request.conversationId);
|
|
174
|
+
const body = {
|
|
175
|
+
emitStartConversationEvent: (_a = request.emitStartConversationEvent) !== null && _a !== void 0 ? _a : true
|
|
176
|
+
};
|
|
177
|
+
// Add locale to body if provided
|
|
178
|
+
if (request.locale) {
|
|
179
|
+
body.locale = request.locale;
|
|
180
|
+
}
|
|
181
|
+
logger.info('Starting conversation ...', request);
|
|
182
|
+
this.logDiagnostic('Start conversation request:', body);
|
|
172
183
|
yield* this.postRequestAsync(uriStart, body, 'POST');
|
|
173
184
|
}
|
|
174
185
|
/**
|
|
@@ -186,14 +197,48 @@ class CopilotStudioClient {
|
|
|
186
197
|
yield* this.postRequestAsync(uriExecute, qbody, 'POST');
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
189
|
-
*
|
|
190
|
-
*
|
|
200
|
+
* Executes a turn in an existing conversation by sending an activity.
|
|
201
|
+
* This method provides explicit control over the conversation ID.
|
|
202
|
+
* @param activity The activity to send.
|
|
203
|
+
* @param conversationId The ID of the conversation. Required.
|
|
204
|
+
* @returns An async generator yielding the Agent's Activities.
|
|
205
|
+
* @throws Error if conversationId is not provided.
|
|
206
|
+
*/
|
|
207
|
+
async *executeStreaming(activity, conversationId) {
|
|
208
|
+
if (!conversationId || !conversationId.trim()) {
|
|
209
|
+
throw new Error('conversationId is required for executeStreaming');
|
|
210
|
+
}
|
|
211
|
+
const uriExecute = (0, powerPlatformEnvironment_1.getCopilotStudioConnectionUrl)(this.settings, conversationId);
|
|
212
|
+
const request = new executeTurnRequest_1.ExecuteTurnRequest(activity, conversationId);
|
|
213
|
+
logger.info('Executing turn with conversation ID:', conversationId);
|
|
214
|
+
this.logDiagnostic('Execute turn request:', {
|
|
215
|
+
conversationId,
|
|
216
|
+
activityType: activity.type,
|
|
217
|
+
activityText: activity.text
|
|
218
|
+
});
|
|
219
|
+
yield* this.postRequestAsync(uriExecute, request, 'POST');
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Executes a turn in an existing conversation by sending an activity.
|
|
223
|
+
* @param activity The activity to send.
|
|
224
|
+
* @param conversationId The ID of the conversation. Required.
|
|
191
225
|
* @returns A promise yielding an array of activities.
|
|
192
|
-
* @
|
|
226
|
+
* @throws Error if conversationId is not provided.
|
|
227
|
+
* @deprecated Use executeStreaming instead.
|
|
193
228
|
*/
|
|
194
|
-
async
|
|
229
|
+
async execute(activity, conversationId) {
|
|
195
230
|
const result = [];
|
|
196
|
-
for await (const value of this.
|
|
231
|
+
for await (const value of this.executeStreaming(activity, conversationId)) {
|
|
232
|
+
result.push(value);
|
|
233
|
+
}
|
|
234
|
+
return result;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Implementation of startConversationAsync with overloads.
|
|
238
|
+
*/
|
|
239
|
+
async startConversationAsync(requestOrFlag) {
|
|
240
|
+
const result = [];
|
|
241
|
+
for await (const value of this.startConversationStreaming(requestOrFlag)) {
|
|
197
242
|
result.push(value);
|
|
198
243
|
}
|
|
199
244
|
return result;
|
|
@@ -236,6 +281,98 @@ class CopilotStudioClient {
|
|
|
236
281
|
}
|
|
237
282
|
return result;
|
|
238
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Starts a new conversation and returns a typed response.
|
|
286
|
+
* @param request The request parameters for starting the conversation.
|
|
287
|
+
* @returns A promise yielding a StartResponse with activities and conversation metadata.
|
|
288
|
+
*/
|
|
289
|
+
async startConversationWithResponse(request) {
|
|
290
|
+
var _a;
|
|
291
|
+
const activities = [];
|
|
292
|
+
let finalConversationId = '';
|
|
293
|
+
for await (const activity of this.startConversationStreaming(request)) {
|
|
294
|
+
activities.push(activity);
|
|
295
|
+
if ((_a = activity.conversation) === null || _a === void 0 ? void 0 : _a.id) {
|
|
296
|
+
finalConversationId = activity.conversation.id;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
// Fall back to instance conversationId if not found in activities
|
|
300
|
+
finalConversationId = finalConversationId || this.conversationId;
|
|
301
|
+
return (0, responses_1.createStartResponse)(activities, finalConversationId);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Executes a turn and returns a typed response.
|
|
305
|
+
* @param activity The activity to send.
|
|
306
|
+
* @param conversationId The conversation ID.
|
|
307
|
+
* @returns A promise yielding an ExecuteTurnResponse with activities and metadata.
|
|
308
|
+
*/
|
|
309
|
+
async executeWithResponse(activity, conversationId) {
|
|
310
|
+
const activities = [];
|
|
311
|
+
for await (const value of this.executeStreaming(activity, conversationId)) {
|
|
312
|
+
activities.push(value);
|
|
313
|
+
}
|
|
314
|
+
return (0, responses_1.createExecuteTurnResponse)(activities, conversationId);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Subscribes to a conversation to receive events via Server-Sent Events (SSE).
|
|
318
|
+
* This method allows resumption from a specific event ID.
|
|
319
|
+
* @param conversationId The ID of the conversation to subscribe to.
|
|
320
|
+
* @param lastReceivedEventId Optional. The last received event ID for resumption.
|
|
321
|
+
* @returns An async generator yielding SubscribeEvent objects containing activities and event IDs.
|
|
322
|
+
*/
|
|
323
|
+
async *subscribeAsync(conversationId, lastReceivedEventId) {
|
|
324
|
+
if (!conversationId || !conversationId.trim()) {
|
|
325
|
+
throw new Error('conversationId is required for subscribeAsync');
|
|
326
|
+
}
|
|
327
|
+
const url = (0, powerPlatformEnvironment_1.getCopilotStudioSubscribeUrl)(this.settings, conversationId);
|
|
328
|
+
logger.info('Subscribing to conversation:', conversationId);
|
|
329
|
+
this.logDiagnostic('Subscribe request:', { conversationId, lastReceivedEventId, url });
|
|
330
|
+
const eventSource = (0, eventsource_client_1.createEventSource)({
|
|
331
|
+
url,
|
|
332
|
+
headers: {
|
|
333
|
+
Authorization: `Bearer ${this.token}`,
|
|
334
|
+
'User-Agent': userAgentHelper_1.UserAgentHelper.getProductInfo(),
|
|
335
|
+
Accept: 'text/event-stream',
|
|
336
|
+
...(lastReceivedEventId && { 'Last-Event-ID': lastReceivedEventId })
|
|
337
|
+
},
|
|
338
|
+
method: 'GET',
|
|
339
|
+
fetch: async (url, init) => {
|
|
340
|
+
const response = await fetch(url, init);
|
|
341
|
+
this.processResponseHeaders(response.headers);
|
|
342
|
+
return response;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
try {
|
|
346
|
+
for await (const { data, event, id } of eventSource) {
|
|
347
|
+
if (data && event === 'activity') {
|
|
348
|
+
try {
|
|
349
|
+
const activity = agents_activity_1.Activity.fromJson(data);
|
|
350
|
+
const subscribeEvent = {
|
|
351
|
+
activity,
|
|
352
|
+
eventId: id
|
|
353
|
+
};
|
|
354
|
+
logger.debug(`Received activity via subscription, event ID: ${id}`);
|
|
355
|
+
this.logDiagnostic('Subscribe event received:', { eventId: id, activityType: activity.type });
|
|
356
|
+
yield subscribeEvent;
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
logger.error('Failed to parse activity in subscription:', error);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
else if (event === 'end') {
|
|
363
|
+
logger.debug('Subscription stream complete');
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
if (eventSource.readyState === 'closed') {
|
|
367
|
+
logger.debug('Subscription connection closed');
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
finally {
|
|
373
|
+
eventSource.close();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
239
376
|
}
|
|
240
377
|
exports.CopilotStudioClient = CopilotStudioClient;
|
|
241
378
|
/** Header key for conversation ID. */
|
|
@@ -247,6 +384,7 @@ CopilotStudioClient.islandExperimentalUrlHeaderKey = 'x-ms-d2e-experimental';
|
|
|
247
384
|
* This is used for authentication token audience configuration.
|
|
248
385
|
* @param settings Copilot Studio connection settings.
|
|
249
386
|
* @returns The scope URL for token audience.
|
|
387
|
+
* @deprecated Use ScopeHelper.getScopeFromSettings instead.
|
|
250
388
|
*/
|
|
251
|
-
CopilotStudioClient.scopeFromSettings =
|
|
389
|
+
CopilotStudioClient.scopeFromSettings = scopeHelper_1.ScopeHelper.getScopeFromSettings;
|
|
252
390
|
//# sourceMappingURL=copilotStudioClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilotStudioClient.js","sourceRoot":"","sources":["../../src/copilotStudioClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAyE;AAEzE,yEAA4F;AAC5F,gEAAyF;AACzF,6DAAyD;AACzD,8DAAyD;AACzD,kDAAyC;AACzC,4CAAmB;AAEnB,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,uBAAuB,CAAC,CAAA;AAE7C;;;GAGG;AACH,MAAa,mBAAmB;IAqB9B;;;;OAIG;IACH,YAAa,QAA4B,EAAE,KAAa;QApBxD,0CAA0C;QAClC,mBAAc,GAAW,EAAE,CAAA;QAoBjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,CAAE,gBAAgB,CAAE,GAAW,EAAE,IAAU,EAAE,SAAiB,MAAM;;QAChF,MAAM,CAAC,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,CAAA;QAElC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAgD,CAAA;QAEzE,MAAM,WAA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AC;oBAC3B,MAAM,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;oBAC5C,MAAK;gBACP,CAAC;gBAED,IAAI,WAAW,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;oBACxC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;oBAC9C,MAAK;gBACP,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,WAAW,CAAC,KAAK,EAAE,CAAA;QACrB,CAAC;IACH,CAAC;;AAjcH,kDAkcC;AAjcC,sCAAsC;AACd,2CAAuB,GAAW,qBAAqB,AAAhC,CAAgC;AAC/E,wBAAwB;AACA,kDAA8B,GAAW,uBAAuB,AAAlC,CAAkC;AASxF;;;;;;GAMG;AACI,qCAAiB,GAA6C,yBAAW,CAAC,oBAAoB,AAA7E,CAA6E"}
|
|
@@ -27,6 +27,12 @@ export interface CopilotStudioConnectionSettings {
|
|
|
27
27
|
directConnectUrl?: string;
|
|
28
28
|
/** Directs Copilot Studio Client to use the experimental endpoint if available. Default value is false. */
|
|
29
29
|
useExperimentalEndpoint?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Enables diagnostic logging for debugging purposes.
|
|
32
|
+
* When enabled, detailed logs about requests, responses, and connection status will be emitted.
|
|
33
|
+
* Default value is false.
|
|
34
|
+
*/
|
|
35
|
+
enableDiagnostics?: boolean;
|
|
30
36
|
/**
|
|
31
37
|
* The login authority to use for the connection.
|
|
32
38
|
* @deprecated This property will not be supported in future versions. Handle the auth properties in the agent.
|
|
@@ -18,6 +18,30 @@ export interface CopilotStudioWebChatSettings {
|
|
|
18
18
|
* @default false
|
|
19
19
|
*/
|
|
20
20
|
showTyping?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* An existing conversation ID to resume. When provided, the connection will
|
|
23
|
+
* send subsequent messages to this conversation instead of starting a new one.
|
|
24
|
+
*
|
|
25
|
+
* By default, providing a conversationId will skip the initial
|
|
26
|
+
* `startConversationStreaming()` call. Override this with the
|
|
27
|
+
* `startConversation` setting.
|
|
28
|
+
*
|
|
29
|
+
* **Note:** The server does not validate conversation IDs. A non-existent
|
|
30
|
+
* GUID will silently create a new conversation under that ID, while a
|
|
31
|
+
* non-GUID string may cause the server to return no response. Only pass
|
|
32
|
+
* IDs that were previously captured from a real conversation.
|
|
33
|
+
*/
|
|
34
|
+
conversationId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Controls whether `startConversationStreaming()` is called when the
|
|
37
|
+
* connection is first subscribed to.
|
|
38
|
+
*
|
|
39
|
+
* - `undefined` (default): starts a new conversation only when no
|
|
40
|
+
* `conversationId` is provided (`!conversationId`).
|
|
41
|
+
* - `true`: always starts a conversation, even when resuming.
|
|
42
|
+
* - `false`: never starts a conversation, even for new connections.
|
|
43
|
+
*/
|
|
44
|
+
startConversation?: boolean;
|
|
21
45
|
}
|
|
22
46
|
/**
|
|
23
47
|
* Represents a connection interface for integrating Copilot Studio with WebChat.
|
|
@@ -50,6 +74,12 @@ export interface CopilotStudioWebChatConnection {
|
|
|
50
74
|
* - Standard Bot Framework Activity properties (type, text, attachments, etc.)
|
|
51
75
|
*/
|
|
52
76
|
activity$: Observable<Partial<Activity>>;
|
|
77
|
+
/**
|
|
78
|
+
* The active conversation ID. Set from `CopilotStudioWebChatSettings.conversationId`
|
|
79
|
+
* when resuming, or captured from the first response activity for new conversations.
|
|
80
|
+
* Returns `undefined` until a conversation has been established.
|
|
81
|
+
*/
|
|
82
|
+
readonly conversationId: string | undefined;
|
|
53
83
|
/**
|
|
54
84
|
* Posts a user activity to the Copilot Studio service and returns an observable
|
|
55
85
|
* that emits the activity ID once the message is successfully sent.
|
|
@@ -140,31 +140,47 @@ class CopilotStudioWebChat {
|
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
142
|
static createConnection(client, settings) {
|
|
143
|
+
var _a;
|
|
143
144
|
logger.info('--> Creating connection between Copilot Studio and WebChat ...');
|
|
145
|
+
const normalizedConversationId = (settings === null || settings === void 0 ? void 0 : settings.conversationId) && settings.conversationId.trim() !== ''
|
|
146
|
+
? settings.conversationId.trim()
|
|
147
|
+
: undefined;
|
|
148
|
+
const shouldStart = (_a = settings === null || settings === void 0 ? void 0 : settings.startConversation) !== null && _a !== void 0 ? _a : !normalizedConversationId;
|
|
144
149
|
let sequence = 0;
|
|
145
150
|
let activitySubscriber;
|
|
146
151
|
let conversation;
|
|
152
|
+
let activeConversationId = normalizedConversationId;
|
|
153
|
+
let ended = false;
|
|
154
|
+
let started = false;
|
|
147
155
|
const connectionStatus$ = new rxjs_1.BehaviorSubject(0);
|
|
148
156
|
const activity$ = createObservable(async (subscriber) => {
|
|
157
|
+
var _a;
|
|
149
158
|
activitySubscriber = subscriber;
|
|
150
159
|
const handleAcknowledgementOnce = once(async () => {
|
|
151
160
|
connectionStatus$.next(2);
|
|
152
161
|
await Promise.resolve(); // Webchat requires an extra tick to process the connection status change
|
|
153
162
|
});
|
|
163
|
+
// When resuming (shouldStart === false), transition straight to connected
|
|
164
|
+
if (!shouldStart || started) {
|
|
165
|
+
await handleAcknowledgementOnce();
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
started = true;
|
|
154
169
|
logger.debug('--> Connection established.');
|
|
155
170
|
notifyTyping();
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
notifyActivity(activity);
|
|
171
|
+
for await (const activity of client.startConversationStreaming()) {
|
|
172
|
+
delete activity.replyToId;
|
|
173
|
+
if (!conversation && activity.conversation) {
|
|
174
|
+
conversation = activity.conversation;
|
|
175
|
+
}
|
|
176
|
+
if ((_a = activity.conversation) === null || _a === void 0 ? void 0 : _a.id) {
|
|
177
|
+
activeConversationId = activity.conversation.id;
|
|
164
178
|
}
|
|
165
|
-
// If no activities received from bot, we should still acknowledge.
|
|
166
179
|
await handleAcknowledgementOnce();
|
|
180
|
+
notifyActivity(activity);
|
|
167
181
|
}
|
|
182
|
+
// If no activities received from bot, we should still acknowledge.
|
|
183
|
+
await handleAcknowledgementOnce();
|
|
168
184
|
});
|
|
169
185
|
const notifyActivity = (activity) => {
|
|
170
186
|
const newActivity = {
|
|
@@ -191,15 +207,22 @@ class CopilotStudioWebChat {
|
|
|
191
207
|
return {
|
|
192
208
|
connectionStatus$,
|
|
193
209
|
activity$,
|
|
210
|
+
get conversationId() {
|
|
211
|
+
return activeConversationId;
|
|
212
|
+
},
|
|
194
213
|
postActivity(activity) {
|
|
195
214
|
logger.info('--> Preparing to send activity to Copilot Studio ...');
|
|
196
215
|
if (!activity) {
|
|
197
216
|
throw new Error('Activity cannot be null.');
|
|
198
217
|
}
|
|
218
|
+
if (ended) {
|
|
219
|
+
throw new Error('Connection has been ended.');
|
|
220
|
+
}
|
|
199
221
|
if (!activitySubscriber) {
|
|
200
222
|
throw new Error('Activity subscriber is not initialized.');
|
|
201
223
|
}
|
|
202
224
|
return createObservable(async (subscriber) => {
|
|
225
|
+
var _a;
|
|
203
226
|
try {
|
|
204
227
|
logger.info('--> Sending activity to Copilot Studio ...');
|
|
205
228
|
const newActivity = agents_activity_1.Activity.fromObject({
|
|
@@ -211,8 +234,11 @@ class CopilotStudioWebChat {
|
|
|
211
234
|
notifyTyping();
|
|
212
235
|
// Notify WebChat immediately that the message was sent
|
|
213
236
|
subscriber.next(newActivity.id);
|
|
214
|
-
// Stream the agent's response,
|
|
215
|
-
for await (const responseActivity of client.sendActivityStreaming(newActivity)) {
|
|
237
|
+
// Stream the agent's response, passing activeConversationId for URL routing
|
|
238
|
+
for await (const responseActivity of client.sendActivityStreaming(newActivity, activeConversationId)) {
|
|
239
|
+
if (!activeConversationId && ((_a = responseActivity.conversation) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
240
|
+
activeConversationId = responseActivity.conversation.id;
|
|
241
|
+
}
|
|
216
242
|
notifyActivity(responseActivity);
|
|
217
243
|
logger.info('<-- Activity received correctly from Copilot Studio.');
|
|
218
244
|
}
|
|
@@ -226,6 +252,7 @@ class CopilotStudioWebChat {
|
|
|
226
252
|
},
|
|
227
253
|
end() {
|
|
228
254
|
logger.info('--> Ending connection between Copilot Studio and WebChat ...');
|
|
255
|
+
ended = true;
|
|
229
256
|
connectionStatus$.complete();
|
|
230
257
|
if (activitySubscriber) {
|
|
231
258
|
activitySubscriber.complete();
|