@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.
Files changed (54) hide show
  1. package/dist/package.json +2 -2
  2. package/dist/src/browser.mjs +5 -5
  3. package/dist/src/browser.mjs.map +4 -4
  4. package/dist/src/connectionSettings.d.ts +2 -0
  5. package/dist/src/connectionSettings.js +5 -2
  6. package/dist/src/connectionSettings.js.map +1 -1
  7. package/dist/src/copilotStudioClient.d.ts +61 -6
  8. package/dist/src/copilotStudioClient.js +176 -38
  9. package/dist/src/copilotStudioClient.js.map +1 -1
  10. package/dist/src/copilotStudioConnectionSettings.d.ts +6 -0
  11. package/dist/src/copilotStudioWebChat.d.ts +30 -0
  12. package/dist/src/copilotStudioWebChat.js +38 -11
  13. package/dist/src/copilotStudioWebChat.js.map +1 -1
  14. package/dist/src/executeTurnRequest.d.ts +5 -2
  15. package/dist/src/executeTurnRequest.js +4 -2
  16. package/dist/src/executeTurnRequest.js.map +1 -1
  17. package/dist/src/index.d.ts +5 -0
  18. package/dist/src/index.js +5 -0
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/powerPlatformEnvironment.d.ts +8 -0
  21. package/dist/src/powerPlatformEnvironment.js +21 -6
  22. package/dist/src/powerPlatformEnvironment.js.map +1 -1
  23. package/dist/src/responses.d.ts +50 -0
  24. package/dist/src/responses.js +35 -0
  25. package/dist/src/responses.js.map +1 -0
  26. package/dist/src/scopeHelper.d.ts +17 -0
  27. package/dist/src/scopeHelper.js +24 -0
  28. package/dist/src/scopeHelper.js.map +1 -0
  29. package/dist/src/startRequest.d.ts +34 -0
  30. package/dist/src/startRequest.js +22 -0
  31. package/dist/src/startRequest.js.map +1 -0
  32. package/dist/src/strategies/prebuiltBotStrategy.d.ts +2 -1
  33. package/dist/src/strategies/publishedBotStrategy.d.ts +2 -1
  34. package/dist/src/subscribeEvent.d.ts +33 -0
  35. package/dist/src/subscribeEvent.js +7 -0
  36. package/dist/src/subscribeEvent.js.map +1 -0
  37. package/dist/src/userAgentHelper.d.ts +26 -0
  38. package/dist/src/userAgentHelper.js +52 -0
  39. package/dist/src/userAgentHelper.js.map +1 -0
  40. package/package.json +2 -2
  41. package/src/connectionSettings.ts +4 -1
  42. package/src/copilotStudioClient.ts +238 -32
  43. package/src/copilotStudioConnectionSettings.ts +7 -0
  44. package/src/copilotStudioWebChat.ts +75 -12
  45. package/src/executeTurnRequest.ts +7 -2
  46. package/src/index.ts +5 -0
  47. package/src/powerPlatformEnvironment.ts +26 -7
  48. package/src/responses.ts +75 -0
  49. package/src/scopeHelper.ts +22 -0
  50. package/src/startRequest.ts +48 -0
  51. package/src/strategies/prebuiltBotStrategy.ts +1 -1
  52. package/src/strategies/publishedBotStrategy.ts +1 -1
  53. package/src/subscribeEvent.ts +38 -0
  54. package/src/userAgentHelper.ts +49 -0
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ /**
7
+ * Represents a request to start a new conversation with a Copilot Studio agent.
8
+ * This request encapsulates all parameters needed to initiate a conversation.
9
+ */
10
+ export interface StartRequest {
11
+ /**
12
+ * Optional locale code (e.g., 'en-US', 'fr-FR') for the conversation.
13
+ * If not specified, the agent's default locale will be used.
14
+ */
15
+ locale?: string
16
+
17
+ /**
18
+ * Whether to emit a start conversation event.
19
+ * When true, the agent will be notified that this is the beginning of a new conversation.
20
+ * Default is true.
21
+ */
22
+ emitStartConversationEvent?: boolean
23
+
24
+ /**
25
+ * Optional conversation ID to use for this conversation.
26
+ * If not specified, a new conversation ID will be generated by the service.
27
+ */
28
+ conversationId?: string
29
+ }
30
+
31
+ /**
32
+ * Creates a StartRequest with default values.
33
+ * @param emitStartConversationEvent Whether to emit a start conversation event. Defaults to true.
34
+ * @param locale Optional locale for the conversation.
35
+ * @param conversationId Optional conversation ID.
36
+ * @returns A new StartRequest object.
37
+ */
38
+ export function createStartRequest (
39
+ emitStartConversationEvent: boolean = true,
40
+ locale?: string,
41
+ conversationId?: string
42
+ ): StartRequest {
43
+ return {
44
+ emitStartConversationEvent,
45
+ locale,
46
+ conversationId
47
+ }
48
+ }
@@ -6,7 +6,7 @@
6
6
  import type { Strategy, StrategySettings } from './strategy'
7
7
 
8
8
  /** @deprecated This interface will not be supported in future versions. Use StrategySettings instead. */
9
- export interface PrebuiltBotStrategySettings {
9
+ interface PrebuiltBotStrategySettings {
10
10
  readonly host: URL;
11
11
  readonly identifier: string;
12
12
  }
@@ -6,7 +6,7 @@
6
6
  import type { Strategy, StrategySettings } from './strategy'
7
7
 
8
8
  /** @deprecated This interface will not be supported in future versions. Use StrategySettings instead. */
9
- export interface PublishedBotStrategySettings {
9
+ interface PublishedBotStrategySettings {
10
10
  readonly host: URL;
11
11
  readonly schema: string;
12
12
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { Activity } from '@microsoft/agents-activity'
7
+
8
+ /**
9
+ * Represents an event received from a subscription to a Copilot Studio conversation.
10
+ */
11
+ export interface SubscribeEvent {
12
+ /**
13
+ * The activity from the copilot.
14
+ */
15
+ activity: Activity
16
+
17
+ /**
18
+ * The SSE event ID for resumption.
19
+ * Can be used to resume subscription from a specific point.
20
+ */
21
+ eventId?: string
22
+ }
23
+
24
+ /**
25
+ * Represents a request to subscribe to a conversation.
26
+ */
27
+ export interface SubscribeRequest {
28
+ /**
29
+ * The conversation ID to subscribe to.
30
+ */
31
+ conversationId: string
32
+
33
+ /**
34
+ * The last received event ID for resumption.
35
+ * If provided, subscription will resume from this point.
36
+ */
37
+ lastReceivedEventId?: string
38
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { version } from '../package.json'
7
+ import os from 'os'
8
+
9
+ /**
10
+ * Utility class for generating user agent strings for Copilot Studio client requests.
11
+ */
12
+ export class UserAgentHelper {
13
+ /**
14
+ * Generates a user agent string appropriate for the current environment.
15
+ * - For browser environments, includes the browser's user agent.
16
+ * - For Node.js environments, includes Node version, platform, architecture, and release.
17
+ * @returns A user agent string for HTTP headers.
18
+ */
19
+ static getProductInfo (): string {
20
+ const versionString = `CopilotStudioClient.agents-sdk-js/${version}`
21
+ let userAgent: string
22
+
23
+ if (typeof window !== 'undefined' && window.navigator) {
24
+ // Browser environment
25
+ userAgent = `${versionString} ${navigator.userAgent}`
26
+ } else {
27
+ // Node.js environment
28
+ userAgent = `${versionString} nodejs/${process.version} ${os.platform()}-${os.arch()}/${os.release()}`
29
+ }
30
+
31
+ return userAgent
32
+ }
33
+
34
+ /**
35
+ * Gets just the version string without environment details.
36
+ * @returns The version string (e.g., "CopilotStudioClient.agents-sdk-js/0.1.0")
37
+ */
38
+ static getVersionString (): string {
39
+ return `CopilotStudioClient.agents-sdk-js/${version}`
40
+ }
41
+
42
+ /**
43
+ * Gets the SDK version number.
44
+ * @returns The version number (e.g., "0.1.0")
45
+ */
46
+ static getVersion (): string {
47
+ return version
48
+ }
49
+ }