@microsoft/agents-copilotstudio-client 0.6.1 → 0.6.16-gc874f0c9d8

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.
@@ -7,38 +7,128 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.CopilotStudioWebChat = void 0;
8
8
  const uuid_1 = require("uuid");
9
9
  const rxjs_1 = require("rxjs");
10
+ const logger_1 = require("@microsoft/agents-activity/logger");
11
+ const logger = (0, logger_1.debug)('copilot-studio:webchat');
10
12
  /**
11
- * This class is intended to be used in WebChat applications to connect to the Copilot Studio service.
13
+ * A utility class that provides WebChat integration capabilities for Copilot Studio services.
14
+ * This class acts as a bridge between Microsoft Bot Framework WebChat and Copilot Studio,
15
+ * enabling seamless communication through a DirectLine-compatible interface.
12
16
  *
13
- * example usage:
14
- * ```javascript
15
- * const client = new CopilotStudioClient(...)
17
+ * ## Key Features:
18
+ * - DirectLine protocol compatibility for easy WebChat integration
19
+ * - Real-time bidirectional messaging with Copilot Studio agents
20
+ * - Automatic conversation management and message sequencing
21
+ * - Optional typing indicators for enhanced user experience
22
+ * - Observable-based architecture for reactive programming patterns
23
+ *
24
+ * ## Usage Scenarios:
25
+ * - Embedding Copilot Studio agents in web applications
26
+ * - Creating custom chat interfaces with WebChat components
27
+ * - Building conversational AI experiences with Microsoft's bot ecosystem
28
+ *
29
+ * @example Basic WebChat Integration
30
+ * ```typescript
31
+ * import { CopilotStudioClient } from '@microsoft/agents-copilotstudio-client';
32
+ * import { CopilotStudioWebChat } from '@microsoft/agents-copilotstudio-client';
33
+ *
34
+ * // Initialize the Copilot Studio client
35
+ * const client = new CopilotStudioClient({
36
+ * botId: 'your-bot-id',
37
+ * tenantId: 'your-tenant-id'
38
+ * });
39
+ *
40
+ * // Create a WebChat-compatible connection
41
+ * const directLine = CopilotStudioWebChat.createConnection(client, {
42
+ * showTyping: true
43
+ * });
44
+ *
45
+ * // Integrate with WebChat
16
46
  * window.WebChat.renderWebChat({
17
- * directLine: CopilotStudioWebChat.createConnection(client)
18
- * })
47
+ * directLine: directLine,
48
+ * // ... other WebChat options
49
+ * }, document.getElementById('webchat'));
50
+ * ```
51
+ *
52
+ * @example Advanced Usage with Connection Monitoring
53
+ * ```typescript
54
+ * const connection = CopilotStudioWebChat.createConnection(client);
55
+ *
56
+ * // Monitor connection status
57
+ * connection.connectionStatus$.subscribe(status => {
58
+ * switch (status) {
59
+ * case 0: console.log('Disconnected'); break;
60
+ * case 1: console.log('Connecting...'); break;
61
+ * case 2: console.log('Connected and ready'); break;
62
+ * }
63
+ * });
64
+ *
65
+ * // Listen for incoming activities
66
+ * connection.activity$.subscribe(activity => {
67
+ * console.log('Received activity:', activity);
68
+ * });
19
69
  * ```
20
70
  */
21
71
  class CopilotStudioWebChat {
22
72
  /**
23
- * Creates a new DirectLine-Like connection to WebChat.
24
- * When an activity is posted in WebChat, the connection will send it to the Copilot Studio service, awaiting response.
25
- * After a response is received, it will emit the incoming activity back to WebChat.
73
+ * Creates a DirectLine-compatible connection for integrating Copilot Studio with WebChat.
74
+ *
75
+ * This method establishes a real-time communication channel between WebChat and the
76
+ * Copilot Studio service. The returned connection object implements the DirectLine
77
+ * protocol, making it fully compatible with Microsoft Bot Framework WebChat components.
78
+ *
79
+ * ## Connection Lifecycle:
80
+ * 1. **Initialization**: Creates observables for connection status and activity streaming
81
+ * 2. **Conversation Start**: Automatically initiates conversation when first activity is posted
82
+ * 3. **Message Flow**: Handles bidirectional message exchange with proper sequencing
83
+ * 4. **Cleanup**: Provides graceful connection termination
84
+ *
85
+ * ## Message Processing:
86
+ * - User messages are validated and sent to Copilot Studio
87
+ * - Agent responses are received and formatted for WebChat
88
+ * - All activities include timestamps and sequence IDs for proper ordering
89
+ * - Optional typing indicators provide visual feedback during processing
90
+ *
91
+ * @param client - A configured CopilotStudioClient instance that handles the underlying
92
+ * communication with the Copilot Studio service. This client should be
93
+ * properly authenticated and configured with the target bot details.
26
94
  *
27
- * @param client - The Copilot Studio client instance.
28
- * @param settings - Optional settings for the WebChat connection.
29
- * @returns A new instance of CopilotStudioWebChatConnection.
95
+ * @param settings - Optional configuration settings that control the behavior of the
96
+ * WebChat connection. These settings allow customization of features
97
+ * like typing indicators and other user experience enhancements.
98
+ *
99
+ * @returns A new CopilotStudioWebChatConnection instance that can be passed directly
100
+ * to WebChat's renderWebChat function as the directLine parameter. The
101
+ * connection is immediately ready for use and will automatically manage
102
+ * the conversation lifecycle.
103
+ *
104
+ * @throws Error if the provided client is not properly configured or if there are
105
+ * issues establishing the initial connection to the Copilot Studio service.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * const connection = CopilotStudioWebChat.createConnection(client, {
110
+ * showTyping: true
111
+ * });
112
+ *
113
+ * // Use with WebChat
114
+ * window.WebChat.renderWebChat({
115
+ * directLine: connection
116
+ * }, document.getElementById('webchat'));
117
+ * ```
30
118
  */
31
119
  static createConnection(client, settings) {
120
+ logger.info('--> Creating connection between Copilot Studio and WebChat ...');
32
121
  let sequence = 0;
33
- let activityObserver;
122
+ let activitySubscriber;
34
123
  let conversation;
35
124
  const connectionStatus$ = new rxjs_1.BehaviorSubject(0);
36
- const activity$ = rxjs_1.Observable.create(async (observer) => {
37
- activityObserver = observer;
125
+ const activity$ = createObservable(async (subscriber) => {
126
+ activitySubscriber = subscriber;
38
127
  if (connectionStatus$.value < 2) {
39
128
  connectionStatus$.next(2);
40
129
  return;
41
130
  }
131
+ logger.debug('--> Connection established.');
42
132
  notifyTyping();
43
133
  const activity = await client.startConversationAsync();
44
134
  conversation = activity.conversation;
@@ -46,14 +136,16 @@ class CopilotStudioWebChat {
46
136
  notifyActivity(activity);
47
137
  });
48
138
  const notifyActivity = (activity) => {
49
- activityObserver === null || activityObserver === void 0 ? void 0 : activityObserver.next({
139
+ const newActivity = {
50
140
  ...activity,
51
141
  timestamp: new Date().toISOString(),
52
142
  channelData: {
53
143
  ...activity.channelData,
54
144
  'webchat:sequence-id': sequence++,
55
145
  },
56
- });
146
+ };
147
+ logger.debug(`Notify '${newActivity.type}' activity to WebChat:`, newActivity);
148
+ activitySubscriber === null || activitySubscriber === void 0 ? void 0 : activitySubscriber.next(newActivity);
57
149
  };
58
150
  const notifyTyping = () => {
59
151
  if (!(settings === null || settings === void 0 ? void 0 : settings.showTyping)) {
@@ -69,39 +161,77 @@ class CopilotStudioWebChat {
69
161
  activity$,
70
162
  postActivity(activity) {
71
163
  var _a;
164
+ logger.info('--> Preparing to send activity to Copilot Studio ...');
72
165
  if (!((_a = activity.text) === null || _a === void 0 ? void 0 : _a.trim())) {
73
166
  throw new Error('Activity text cannot be empty.');
74
167
  }
75
- if (!activityObserver) {
76
- throw new Error('Activity observer is not initialized.');
168
+ if (!activitySubscriber) {
169
+ throw new Error('Activity subscriber is not initialized.');
77
170
  }
78
- return rxjs_1.Observable.create(async (observer) => {
171
+ return createObservable(async (subscriber) => {
79
172
  try {
80
173
  const id = (0, uuid_1.v4)();
174
+ logger.info('--> Sending activity to Copilot Studio ...');
81
175
  notifyActivity({ ...activity, id });
82
176
  notifyTyping();
83
177
  const activities = await client.askQuestionAsync(activity.text);
84
178
  for (const responseActivity of activities) {
85
179
  notifyActivity(responseActivity);
86
180
  }
87
- observer.next(id);
88
- observer.complete();
181
+ subscriber.next(id);
182
+ subscriber.complete();
183
+ logger.info('--> Activity received correctly from Copilot Studio.');
89
184
  }
90
185
  catch (error) {
91
- observer.error(error);
186
+ logger.error('Error sending Activity to Copilot Studio:', error);
187
+ subscriber.error(error);
92
188
  }
93
189
  });
94
190
  },
95
191
  end() {
192
+ logger.info('--> Ending connection between Copilot Studio and WebChat ...');
96
193
  connectionStatus$.complete();
97
- activity$.complete();
98
- if (activityObserver) {
99
- activityObserver.complete();
100
- activityObserver = undefined;
194
+ if (activitySubscriber) {
195
+ activitySubscriber.complete();
196
+ activitySubscriber = undefined;
101
197
  }
102
198
  },
103
199
  };
104
200
  }
105
201
  }
106
202
  exports.CopilotStudioWebChat = CopilotStudioWebChat;
203
+ /**
204
+ * Creates an RxJS Observable that wraps an asynchronous function execution.
205
+ *
206
+ * This utility function provides a clean way to convert async/await patterns
207
+ * into Observable streams, enabling integration with reactive programming patterns
208
+ * used throughout the WebChat connection implementation.
209
+ *
210
+ * The created Observable handles promise resolution and rejection automatically,
211
+ * converting them to appropriate next/error signals for subscribers.
212
+ *
213
+ * @template T - The type of value that the observable will emit
214
+ * @param fn - An asynchronous function that receives a Subscriber and performs
215
+ * the desired async operation. The function should call subscriber.next()
216
+ * with results and subscriber.complete() when finished.
217
+ * @returns A new Observable that executes the provided function and emits its results
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const dataObservable = createObservable<string>(async (subscriber) => {
222
+ * try {
223
+ * const result = await fetchData();
224
+ * subscriber.next(result);
225
+ * subscriber.complete();
226
+ * } catch (error) {
227
+ * subscriber.error(error);
228
+ * }
229
+ * });
230
+ * ```
231
+ */
232
+ function createObservable(fn) {
233
+ return new rxjs_1.Observable((subscriber) => {
234
+ Promise.resolve(fn(subscriber)).catch((error) => subscriber.error(error));
235
+ });
236
+ }
107
237
  //# sourceMappingURL=copilotStudioWebChat.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copilotStudioWebChat.js","sourceRoot":"","sources":["../../src/copilotStudioWebChat.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAiC;AAGjC,+BAAiE;AA4CjE;;;;;;;;;;GAUG;AACH,MAAa,oBAAoB;IAC/B;;;;;;;;OAQG;IACH,MAAM,CAAC,gBAAgB,CACrB,MAA2B,EAC3B,QAAuC;QAEvC,IAAI,QAAQ,GAAG,CAAC,CAAA;QAChB,IAAI,gBAAyD,CAAA;QAC7D,IAAI,YAA6C,CAAA;QAEjD,MAAM,iBAAiB,GAAG,IAAI,sBAAe,CAAC,CAAC,CAAC,CAAA;QAChD,MAAM,SAAS,GAAG,iBAAU,CAAC,MAAM,CACjC,KAAK,EAAE,QAAqC,EAAE,EAAE;YAC9C,gBAAgB,GAAG,QAAQ,CAA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AA;IAC3E,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -7,9 +7,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getCopilotStudioConnectionUrl = getCopilotStudioConnectionUrl;
8
8
  exports.getTokenAudience = getTokenAudience;
9
9
  const agentType_1 = require("./agentType");
10
+ const logger_1 = require("@microsoft/agents-activity/logger");
10
11
  const powerPlatformCloud_1 = require("./powerPlatformCloud");
11
12
  const prebuiltBotStrategy_1 = require("./strategies/prebuiltBotStrategy");
12
13
  const publishedBotStrategy_1 = require("./strategies/publishedBotStrategy");
14
+ const logger = (0, logger_1.debug)('copilot-studio:power-platform');
13
15
  /**
14
16
  * Generates the connection URL for Copilot Studio.
15
17
  * @param settings - The connection settings.
@@ -21,11 +23,13 @@ function getCopilotStudioConnectionUrl(settings, conversationId) {
21
23
  var _a, _b;
22
24
  let cloudValue = powerPlatformCloud_1.PowerPlatformCloud.Prod;
23
25
  if ((_a = settings.directConnectUrl) === null || _a === void 0 ? void 0 : _a.trim()) {
26
+ logger.debug(`Using direct connection: ${settings.directConnectUrl}`);
24
27
  if (!isValidUri(settings.directConnectUrl)) {
25
28
  throw new Error('directConnectUrl must be a valid URL');
26
29
  }
27
30
  // FIX for Missing Tenant ID
28
- if (settings.directConnectUrl.toLocaleLowerCase().includes('tenants/00000000-0000-0000-0000-000000000000')) {
31
+ if (settings.directConnectUrl.toLowerCase().includes('tenants/00000000-0000-0000-0000-000000000000')) {
32
+ logger.debug(`Direct connection cannot be used, forcing default settings flow. Tenant ID is missing in the URL: ${settings.directConnectUrl}`);
29
33
  // Direct connection cannot be used, ejecting and forcing the normal settings flow:
30
34
  return getCopilotStudioConnectionUrl({ ...settings, directConnectUrl: '' }, conversationId);
31
35
  }
@@ -47,14 +51,16 @@ function getCopilotStudioConnectionUrl(settings, conversationId) {
47
51
  throw new Error('AgentIdentifier must be provided');
48
52
  }
49
53
  if (cloudSetting !== powerPlatformCloud_1.PowerPlatformCloud.Unknown) {
54
+ logger.debug(`Using specified cloud setting: ${cloudSetting}`);
50
55
  cloudValue = cloudSetting;
51
56
  }
52
57
  if (cloudSetting === powerPlatformCloud_1.PowerPlatformCloud.Other) {
53
58
  if (isNotEmptyCustomPowerPlatformCloud && isValidUri(settings.customPowerPlatformCloud)) {
59
+ logger.debug(`Using custom Power Platform cloud: ${settings.customPowerPlatformCloud}`);
54
60
  cloudValue = powerPlatformCloud_1.PowerPlatformCloud.Other;
55
61
  }
56
62
  else {
57
- throw new Error('customPowerPlatformCloud must be provided when PowerPlatformCloud is Other');
63
+ throw new Error('customPowerPlatformCloud must be a valid URL');
58
64
  }
59
65
  }
60
66
  let agentType;
@@ -63,10 +69,12 @@ function getCopilotStudioConnectionUrl(settings, conversationId) {
63
69
  throw new Error('Invalid AgentType enum key');
64
70
  }
65
71
  else {
72
+ logger.debug(`Using specified agent type: ${settings.copilotAgentType}`);
66
73
  agentType = settings.copilotAgentType;
67
74
  }
68
75
  }
69
76
  else {
77
+ logger.debug('Using default agent type: Published');
70
78
  agentType = agentType_1.AgentType.Published;
71
79
  }
72
80
  settings.customPowerPlatformCloud = isNotEmptyCustomPowerPlatformCloud ? settings.customPowerPlatformCloud : 'api.unknown.powerplatform.com';
@@ -81,7 +89,9 @@ function getCopilotStudioConnectionUrl(settings, conversationId) {
81
89
  identifier: settings.agentIdentifier,
82
90
  }),
83
91
  }[agentType]();
84
- return strategy.getConversationUrl(conversationId);
92
+ const url = strategy.getConversationUrl(conversationId);
93
+ logger.debug(`Generated Copilot Studio connection URL: ${url}`);
94
+ return url;
85
95
  }
86
96
  /**
87
97
  * Returns the Power Platform API Audience.
@@ -1 +1 @@
1
- {"version":3,"file":"powerPlatformEnvironment.js","sourceRoot":"","sources":["../../src/powerPlatformEnvironment.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAeH,sEAmFC;AAWD,4CAiDC;AA5JD,2CAAuC;AAEvC,6DAAyD;AACzD,0EAAsE;AACtE,4EAAwE;AAExE;;;;;;GAMG;AAC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uCAAkB,CAAC,KAAK,CAAA;QACjC,KAAK,2BAA2B;YAC9B,OAAO,uCAAkB,CAAC,GAAG,CAAA;QAC/B,KAAK,2BAA2B;YAC9B,OAAO,uCAAkB,CAAC,GAAG,CAAA;QAC/B,KAAK,2BAA2B;YAC9B,OAAO,uCAAkB,CAAC,GAAG,CAAA;QAC/B,KAAK,4BAA4B;YAC/B,OAAO,uCAAkB,CAAC,IAAI,CAAA;QAChC,KAAK,+BAA+B;YAClC,OAAO,uCAAkB,CAAC,OAAO,CAAA;QACnC,KAAK,uBAAuB;YAC1B,OAAO,uCAAkB,CAAC,IAAI,CAAA;QAChC,KAAK,oCAAoC;YACvC,OAAO,uCAAkB,CAAC,KAAK,CAAA;QACjC,KAAK,qCAAqC;YACxC,OAAO,uCAAkB,CAAC,IAAI,CAAA;QAChC,KAAK,qBAAqB;YACxB,OAAO,uCAAkB,CAAC,GAAG,CAAA;QAC/B,KAAK,8CAA8C;YACjD,OAAO,uCAAkB,CAAC,QAAQ,CAAA;QACpC;YACE,OAAO,uCAAkB,CAAC,OAAO,CAAA;IACrC,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/agents-copilotstudio-client",
3
- "version": "0.6.1",
3
+ "version": "0.6.16-gc874f0c9d8",
4
4
  "homepage": "https://github.com/microsoft/Agents-for-js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,10 +27,9 @@
27
27
  "build:browser": "esbuild --platform=browser --target=es2019 --format=esm --bundle --sourcemap --minify --outfile=dist/src/browser.mjs src/index.ts"
28
28
  },
29
29
  "dependencies": {
30
- "@microsoft/agents-activity": "0.6.1",
30
+ "@microsoft/agents-activity": "0.6.16-gc874f0c9d8",
31
31
  "axios": "^1.9.0",
32
- "debug": "^4.3.7",
33
- "rxjs": "5.5.12",
32
+ "rxjs": "7.8.2",
34
33
  "uuid": "^11.1.0"
35
34
  },
36
35
  "license": "MIT",
@@ -8,15 +8,21 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'
8
8
  import { getCopilotStudioConnectionUrl, getTokenAudience } from './powerPlatformEnvironment'
9
9
  import { Activity, ActivityTypes, ConversationAccount } from '@microsoft/agents-activity'
10
10
  import { ExecuteTurnRequest } from './executeTurnRequest'
11
- import createDebug, { Debugger } from 'debug'
12
- import pjson from '@microsoft/agents-copilotstudio-client/package.json'
11
+ import { debug } from '@microsoft/agents-activity/logger'
12
+ import { version } from '../package.json'
13
13
  import os from 'os'
14
14
 
15
+ const logger = debug('copilot-studio:client')
16
+
15
17
  interface streamRead {
16
18
  done: boolean,
17
19
  value: string
18
20
  }
19
21
 
22
+ /**
23
+ * Client for interacting with Microsoft Copilot Studio services.
24
+ * Provides functionality to start conversations and send messages to Copilot Studio bots.
25
+ */
20
26
  export class CopilotStudioClient {
21
27
  /** Header key for conversation ID. */
22
28
  private static readonly conversationIdHeaderKey: string = 'x-ms-conversationid'
@@ -29,12 +35,12 @@ export class CopilotStudioClient {
29
35
  private readonly settings: ConnectionSettings
30
36
  /** The Axios instance used for HTTP requests. */
31
37
  private readonly client: AxiosInstance
32
- /** The logger for debugging. */
33
- private readonly logger: Debugger
34
38
 
35
39
  /**
36
- * Returns the Scope URL needed to connect to Copilot Studio from the Connection Settings.
37
- * @param settings Copilot Studio Connection Settings.
40
+ * Returns the scope URL needed to connect to Copilot Studio from the connection settings.
41
+ * This is used for authentication token audience configuration.
42
+ * @param settings Copilot Studio connection settings.
43
+ * @returns The scope URL for token audience.
38
44
  */
39
45
  static scopeFromSettings: (settings: ConnectionSettings) => string = getTokenAudience
40
46
 
@@ -48,13 +54,12 @@ export class CopilotStudioClient {
48
54
  this.client = axios.create()
49
55
  this.client.defaults.headers.common.Authorization = `Bearer ${token}`
50
56
  this.client.defaults.headers.common['User-Agent'] = CopilotStudioClient.getProductInfo()
51
- this.logger = createDebug('copilot-studio-client')
52
57
  }
53
58
 
54
59
  private async postRequestAsync (axiosConfig: AxiosRequestConfig): Promise<Activity[]> {
55
60
  const activities: Activity[] = []
56
61
 
57
- this.logger(`>>> SEND TO ${axiosConfig.url}`)
62
+ logger.debug(`>>> SEND TO ${axiosConfig.url}`)
58
63
 
59
64
  const response = await this.client(axiosConfig)
60
65
 
@@ -62,18 +67,19 @@ export class CopilotStudioClient {
62
67
  const islandExperimentalUrl = response.headers?.[CopilotStudioClient.islandExperimentalUrlHeaderKey]
63
68
  if (islandExperimentalUrl) {
64
69
  this.settings.directConnectUrl = islandExperimentalUrl
65
- this.logger(`Island Experimental URL: ${islandExperimentalUrl}`)
70
+ logger.debug(`Island Experimental URL: ${islandExperimentalUrl}`)
66
71
  }
67
72
  }
68
73
 
69
74
  this.conversationId = response.headers?.[CopilotStudioClient.conversationIdHeaderKey] ?? ''
70
75
  if (this.conversationId) {
71
- this.logger(`Conversation ID: ${this.conversationId}`)
76
+ logger.debug(`Conversation ID: ${this.conversationId}`)
72
77
  }
73
78
 
74
- this.logger('=====================================================')
75
- this.logger(`Headers: ${JSON.stringify(response.headers, null, 2)}`)
76
- this.logger('=====================================================')
79
+ const sanitizedHeaders = { ...response.headers }
80
+ delete sanitizedHeaders['Authorization']
81
+ delete sanitizedHeaders[CopilotStudioClient.conversationIdHeaderKey]
82
+ logger.debug('Headers received:', sanitizedHeaders)
77
83
 
78
84
  const stream = response.data
79
85
  const reader = stream.pipeThrough(new TextDecoderStream()).getReader()
@@ -82,12 +88,12 @@ export class CopilotStudioClient {
82
88
 
83
89
  const processEvents = async ({ done, value }: streamRead): Promise<string[]> => {
84
90
  if (done) {
85
- this.logger('Stream complete')
91
+ logger.debug('Stream complete')
86
92
  result += value
87
93
  results.push(result)
88
94
  return results
89
95
  }
90
- this.logger('Agent is typing...')
96
+ logger.info('Agent is typing ...')
91
97
  result += value
92
98
 
93
99
  return await processEvents(await reader.read())
@@ -106,13 +112,13 @@ export class CopilotStudioClient {
106
112
  if (!this.conversationId.trim()) {
107
113
  // Did not get it from the header.
108
114
  this.conversationId = act.conversation?.id ?? ''
109
- this.logger(`Conversation ID: ${this.conversationId}`)
115
+ logger.debug(`Conversation ID: ${this.conversationId}`)
110
116
  }
111
117
  } else {
112
- this.logger('Activity type: ', act.type)
118
+ logger.debug(`Activity type: ${act.type}`)
113
119
  }
114
120
  } catch (e) {
115
- this.logger('Error: ', e)
121
+ logger.error('Error: ', e)
116
122
  throw e
117
123
  }
118
124
  })
@@ -127,13 +133,17 @@ export class CopilotStudioClient {
127
133
  * @returns A string containing the product information, including version and user agent.
128
134
  */
129
135
  private static getProductInfo (): string {
130
- const version = `CopilotStudioClient.agents-sdk-js/${pjson.version}`
136
+ const versionString = `CopilotStudioClient.agents-sdk-js/${version}`
137
+ let userAgent: string
131
138
 
132
139
  if (typeof window !== 'undefined' && window.navigator) {
133
- return `${version} ${navigator.userAgent}`
140
+ userAgent = `${versionString} ${navigator.userAgent}`
141
+ } else {
142
+ userAgent = `${versionString} nodejs/${process.version} ${os.platform()}-${os.arch()}/${os.release()}`
134
143
  }
135
144
 
136
- return `${version} nodejs/${process.version} ${os.platform()}-${os.arch()}/${os.release()}`
145
+ logger.debug(`User-Agent: ${userAgent}`)
146
+ return userAgent
137
147
  }
138
148
 
139
149
  /**
@@ -157,8 +167,10 @@ export class CopilotStudioClient {
157
167
  adapter: 'fetch'
158
168
  }
159
169
 
170
+ logger.info('Starting conversation ...')
160
171
  const values = await this.postRequestAsync(config)
161
172
  const act = values[0]
173
+ logger.info(`Conversation '${act.conversation?.id}' started. Received ${values.length} activities.`, values)
162
174
  return act
163
175
  }
164
176
 
@@ -194,7 +206,9 @@ export class CopilotStudioClient {
194
206
  responseType: 'stream',
195
207
  adapter: 'fetch'
196
208
  }
209
+ logger.info(`Asking question: ${question} ...`)
197
210
  const values = await this.postRequestAsync(config)
211
+ logger.info(`Received ${values.length} activities.`, values)
198
212
  return values
199
213
  }
200
214
  }