@microsoft/agents-copilotstudio-client 0.6.16-gc874f0c9d8 → 0.6.21-g3c2261b2fc

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.
@@ -10,69 +10,69 @@ export enum PowerPlatformCloud {
10
10
  /**
11
11
  * Unknown cloud environment.
12
12
  */
13
- Unknown = -1,
13
+ Unknown = 'Unknown',
14
14
  /**
15
15
  * Experimental cloud environment.
16
16
  */
17
- Exp = 0,
17
+ Exp = 'Exp',
18
18
  /**
19
19
  * Development cloud environment.
20
20
  */
21
- Dev = 1,
21
+ Dev = 'Dev',
22
22
  /**
23
23
  * Test cloud environment.
24
24
  */
25
- Test = 2,
25
+ Test = 'Test',
26
26
  /**
27
27
  * Pre-production cloud environment.
28
28
  */
29
- Preprod = 3,
29
+ Preprod = 'Preprod',
30
30
  /**
31
31
  * First release cloud environment.
32
32
  */
33
- FirstRelease = 4,
33
+ FirstRelease = 'FirstRelease',
34
34
  /**
35
35
  * Production cloud environment.
36
36
  */
37
- Prod = 5,
37
+ Prod = 'Prod',
38
38
  /**
39
39
  * Government cloud environment.
40
40
  */
41
- Gov = 6,
41
+ Gov = 'Gov',
42
42
  /**
43
43
  * High security cloud environment.
44
44
  */
45
- High = 7,
45
+ High = 'High',
46
46
  /**
47
47
  * Department of Defense cloud environment.
48
48
  */
49
- DoD = 8,
49
+ DoD = 'DoD',
50
50
  /**
51
51
  * Mooncake cloud environment.
52
52
  */
53
- Mooncake = 9,
53
+ Mooncake = 'Mooncake',
54
54
  /**
55
55
  * Ex cloud environment.
56
56
  */
57
- Ex = 10,
57
+ Ex = 'Ex',
58
58
  /**
59
59
  * Rx cloud environment.
60
60
  */
61
- Rx = 11,
61
+ Rx = 'Rx',
62
62
  /**
63
63
  * Private cloud environment.
64
64
  */
65
- Prv = 12,
65
+ Prv = 'Prv',
66
66
  /**
67
67
  * Local cloud environment.
68
68
  */
69
- Local = 13,
69
+ Local = 'Local',
70
70
  /**
71
71
  * French government cloud environment.
72
72
  */
73
- GovFR = 14,
73
+ GovFR = 'GovFR',
74
74
  /**
75
75
  * Other cloud environment.
76
76
  */
77
- Other = 100
77
+ Other = 'Other',
78
78
  }
@@ -23,8 +23,6 @@ export function getCopilotStudioConnectionUrl (
23
23
  settings: ConnectionSettings,
24
24
  conversationId?: string
25
25
  ): string {
26
- let cloudValue: PowerPlatformCloud = PowerPlatformCloud.Prod
27
-
28
26
  if (settings.directConnectUrl?.trim()) {
29
27
  logger.debug(`Using direct connection: ${settings.directConnectUrl}`)
30
28
  if (!isValidUri(settings.directConnectUrl)) {
@@ -41,36 +39,25 @@ export function getCopilotStudioConnectionUrl (
41
39
  return createURL(settings.directConnectUrl, conversationId).href
42
40
  }
43
41
 
44
- const isNotEmptyCloud = settings.cloud && settings.cloud.toString().trim() !== ''
45
- const isNotEmptyCustomPowerPlatformCloud = settings.customPowerPlatformCloud !== undefined && settings.customPowerPlatformCloud.trim() !== ''
46
-
47
- if (isNotEmptyCloud && !Object.values(PowerPlatformCloud).includes(settings.cloud!)) {
48
- throw new Error('Invalid PowerPlatformCloud enum key')
49
- }
42
+ const cloudSetting = settings.cloud ?? PowerPlatformCloud.Prod
43
+ const agentType = settings.copilotAgentType ?? AgentType.Published
50
44
 
51
- const cloudSetting = isNotEmptyCloud ? settings.cloud! : PowerPlatformCloud.Unknown
52
-
53
- if (cloudSetting === PowerPlatformCloud.Other && isNotEmptyCustomPowerPlatformCloud) {
54
- throw new Error('customPowerPlatformCloud must be provided when PowerPlatformCloud is Other')
55
- }
45
+ logger.debug(`Using cloud setting: ${cloudSetting}`)
46
+ logger.debug(`Using agent type: ${agentType}`)
56
47
 
57
48
  if (!settings.environmentId?.trim()) {
58
49
  throw new Error('EnvironmentId must be provided')
59
50
  }
60
51
 
61
- if (settings.agentIdentifier === undefined || settings.agentIdentifier.trim() === '') {
52
+ if (!settings.agentIdentifier?.trim()) {
62
53
  throw new Error('AgentIdentifier must be provided')
63
54
  }
64
55
 
65
- if (cloudSetting !== PowerPlatformCloud.Unknown) {
66
- logger.debug(`Using specified cloud setting: ${cloudSetting}`)
67
- cloudValue = cloudSetting
68
- }
69
-
70
56
  if (cloudSetting === PowerPlatformCloud.Other) {
71
- if (isNotEmptyCustomPowerPlatformCloud && isValidUri(settings.customPowerPlatformCloud!)) {
57
+ if (!settings.customPowerPlatformCloud?.trim()) {
58
+ throw new Error('customPowerPlatformCloud must be provided when PowerPlatformCloud is Other')
59
+ } else if (isValidUri(settings.customPowerPlatformCloud)) {
72
60
  logger.debug(`Using custom Power Platform cloud: ${settings.customPowerPlatformCloud}`)
73
- cloudValue = PowerPlatformCloud.Other
74
61
  } else {
75
62
  throw new Error(
76
63
  'customPowerPlatformCloud must be a valid URL'
@@ -78,23 +65,7 @@ export function getCopilotStudioConnectionUrl (
78
65
  }
79
66
  }
80
67
 
81
- let agentType: AgentType
82
-
83
- if (settings.copilotAgentType && settings.copilotAgentType.toString().trim() !== '') {
84
- if (!Object.values(AgentType).includes(settings.copilotAgentType)) {
85
- throw new Error('Invalid AgentType enum key')
86
- } else {
87
- logger.debug(`Using specified agent type: ${settings.copilotAgentType}`)
88
- agentType = settings.copilotAgentType
89
- }
90
- } else {
91
- logger.debug('Using default agent type: Published')
92
- agentType = AgentType.Published
93
- }
94
-
95
- settings.customPowerPlatformCloud = isNotEmptyCustomPowerPlatformCloud ? settings.customPowerPlatformCloud : 'api.unknown.powerplatform.com'
96
-
97
- const host = getEnvironmentEndpoint(cloudValue, settings.environmentId, settings.customPowerPlatformCloud)
68
+ const host = getEnvironmentEndpoint(cloudSetting, settings.environmentId, settings.customPowerPlatformCloud)
98
69
 
99
70
  const strategy = {
100
71
  [AgentType.Published]: () => new PublishedBotStrategy({