@microsoft/agents-hosting 1.5.0-beta.6.ga236d9a19c → 1.5.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 (157) hide show
  1. package/dist/package.json +10 -9
  2. package/dist/src/activityHandler.js +2 -2
  3. package/dist/src/activityHandler.js.map +1 -1
  4. package/dist/src/agent-client/agentClient.js +49 -40
  5. package/dist/src/agent-client/agentClient.js.map +1 -1
  6. package/dist/src/agent-client/agentResponseHandler.js +2 -2
  7. package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
  8. package/dist/src/app/agentApplication.d.ts +36 -10
  9. package/dist/src/app/agentApplication.js +169 -99
  10. package/dist/src/app/agentApplication.js.map +1 -1
  11. package/dist/src/app/agentApplicationBuilder.d.ts +15 -0
  12. package/dist/src/app/agentApplicationBuilder.js +22 -4
  13. package/dist/src/app/agentApplicationBuilder.js.map +1 -1
  14. package/dist/src/app/agentApplicationOptions.d.ts +38 -0
  15. package/dist/src/app/attachmentDownloader.js +2 -2
  16. package/dist/src/app/attachmentDownloader.js.map +1 -1
  17. package/dist/src/app/auth/authorization.js +12 -9
  18. package/dist/src/app/auth/authorization.js.map +1 -1
  19. package/dist/src/app/auth/authorizationManager.d.ts +18 -5
  20. package/dist/src/app/auth/authorizationManager.js +258 -45
  21. package/dist/src/app/auth/authorizationManager.js.map +1 -1
  22. package/dist/src/app/auth/handlerStorage.js +3 -1
  23. package/dist/src/app/auth/handlerStorage.js.map +1 -1
  24. package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +19 -16
  25. package/dist/src/app/auth/handlers/agenticAuthorization.js +46 -52
  26. package/dist/src/app/auth/handlers/agenticAuthorization.js.map +1 -1
  27. package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +51 -75
  28. package/dist/src/app/auth/handlers/azureBotAuthorization.js +217 -192
  29. package/dist/src/app/auth/handlers/azureBotAuthorization.js.map +1 -1
  30. package/dist/src/app/auth/types.d.ts +100 -1
  31. package/dist/src/app/auth/utils.d.ts +10 -0
  32. package/dist/src/app/auth/utils.js +21 -0
  33. package/dist/src/app/auth/utils.js.map +1 -0
  34. package/dist/src/app/index.d.ts +1 -0
  35. package/dist/src/app/index.js +1 -0
  36. package/dist/src/app/index.js.map +1 -1
  37. package/dist/src/app/proactive/conversation.d.ts +43 -0
  38. package/dist/src/app/proactive/conversation.js +67 -0
  39. package/dist/src/app/proactive/conversation.js.map +1 -0
  40. package/dist/src/app/proactive/conversationBuilder.d.ts +54 -0
  41. package/dist/src/app/proactive/conversationBuilder.js +110 -0
  42. package/dist/src/app/proactive/conversationBuilder.js.map +1 -0
  43. package/dist/src/app/proactive/conversationReferenceBuilder.d.ts +68 -0
  44. package/dist/src/app/proactive/conversationReferenceBuilder.js +125 -0
  45. package/dist/src/app/proactive/conversationReferenceBuilder.js.map +1 -0
  46. package/dist/src/app/proactive/createConversationOptions.d.ts +30 -0
  47. package/dist/src/app/proactive/createConversationOptions.js +10 -0
  48. package/dist/src/app/proactive/createConversationOptions.js.map +1 -0
  49. package/dist/src/app/proactive/createConversationOptionsBuilder.d.ts +69 -0
  50. package/dist/src/app/proactive/createConversationOptionsBuilder.js +141 -0
  51. package/dist/src/app/proactive/createConversationOptionsBuilder.js.map +1 -0
  52. package/dist/src/app/proactive/index.d.ts +7 -0
  53. package/dist/src/app/proactive/index.js +26 -0
  54. package/dist/src/app/proactive/index.js.map +1 -0
  55. package/dist/src/app/proactive/proactive.d.ts +248 -0
  56. package/dist/src/app/proactive/proactive.js +310 -0
  57. package/dist/src/app/proactive/proactive.js.map +1 -0
  58. package/dist/src/app/proactive/proactiveOptions.d.ts +19 -0
  59. package/dist/src/app/proactive/proactiveOptions.js +5 -0
  60. package/dist/src/app/proactive/proactiveOptions.js.map +1 -0
  61. package/dist/src/app/streaming/streamingResponse.js +2 -2
  62. package/dist/src/app/streaming/streamingResponse.js.map +1 -1
  63. package/dist/src/app/teamsAttachmentDownloader.js +2 -2
  64. package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
  65. package/dist/src/app/turnState.js +2 -2
  66. package/dist/src/app/turnState.js.map +1 -1
  67. package/dist/src/auth/authConfiguration.d.ts +61 -0
  68. package/dist/src/auth/authConfiguration.js +52 -3
  69. package/dist/src/auth/authConfiguration.js.map +1 -1
  70. package/dist/src/auth/jwt-middleware.js +2 -2
  71. package/dist/src/auth/jwt-middleware.js.map +1 -1
  72. package/dist/src/auth/msalConnectionManager.js +20 -0
  73. package/dist/src/auth/msalConnectionManager.js.map +1 -1
  74. package/dist/src/auth/msalTokenCredential.js +3 -0
  75. package/dist/src/auth/msalTokenCredential.js.map +1 -1
  76. package/dist/src/auth/msalTokenProvider.js +136 -110
  77. package/dist/src/auth/msalTokenProvider.js.map +1 -1
  78. package/dist/src/baseAdapter.js +2 -2
  79. package/dist/src/baseAdapter.js.map +1 -1
  80. package/dist/src/cloudAdapter.js +201 -154
  81. package/dist/src/cloudAdapter.js.map +1 -1
  82. package/dist/src/connector-client/connectorClient.js +176 -127
  83. package/dist/src/connector-client/connectorClient.js.map +1 -1
  84. package/dist/src/errorHelper.js +108 -0
  85. package/dist/src/errorHelper.js.map +1 -1
  86. package/dist/src/middlewareSet.js +2 -2
  87. package/dist/src/middlewareSet.js.map +1 -1
  88. package/dist/src/oauth/userTokenClient.js +78 -48
  89. package/dist/src/oauth/userTokenClient.js.map +1 -1
  90. package/dist/src/observability/index.d.ts +2 -0
  91. package/dist/src/observability/index.js +21 -0
  92. package/dist/src/observability/index.js.map +1 -0
  93. package/dist/src/observability/metrics.d.ts +21 -0
  94. package/dist/src/observability/metrics.js +87 -0
  95. package/dist/src/observability/metrics.js.map +1 -0
  96. package/dist/src/observability/traces.d.ts +234 -0
  97. package/dist/src/observability/traces.js +962 -0
  98. package/dist/src/observability/traces.js.map +1 -0
  99. package/dist/src/state/agentState.js +2 -2
  100. package/dist/src/state/agentState.js.map +1 -1
  101. package/dist/src/storage/fileStorage.js +38 -28
  102. package/dist/src/storage/fileStorage.js.map +1 -1
  103. package/dist/src/storage/memoryStorage.js +41 -30
  104. package/dist/src/storage/memoryStorage.js.map +1 -1
  105. package/dist/src/transcript/fileTranscriptLogger.js +2 -2
  106. package/dist/src/transcript/fileTranscriptLogger.js.map +1 -1
  107. package/dist/src/transcript/transcriptLoggerMiddleware.js +2 -2
  108. package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -1
  109. package/dist/src/turnContext.js +48 -42
  110. package/dist/src/turnContext.js.map +1 -1
  111. package/package.json +10 -9
  112. package/src/activityHandler.ts +1 -1
  113. package/src/agent-client/agentClient.ts +53 -42
  114. package/src/agent-client/agentResponseHandler.ts +1 -1
  115. package/src/app/agentApplication.ts +212 -86
  116. package/src/app/agentApplicationBuilder.ts +26 -4
  117. package/src/app/agentApplicationOptions.ts +43 -0
  118. package/src/app/attachmentDownloader.ts +1 -1
  119. package/src/app/auth/authorization.ts +11 -8
  120. package/src/app/auth/authorizationManager.ts +297 -45
  121. package/src/app/auth/handlerStorage.ts +3 -1
  122. package/src/app/auth/handlers/agenticAuthorization.ts +68 -72
  123. package/src/app/auth/handlers/azureBotAuthorization.ts +260 -264
  124. package/src/app/auth/types.ts +102 -1
  125. package/src/app/auth/utils.ts +22 -0
  126. package/src/app/index.ts +1 -0
  127. package/src/app/proactive/conversation.ts +87 -0
  128. package/src/app/proactive/conversationBuilder.ts +139 -0
  129. package/src/app/proactive/conversationReferenceBuilder.ts +161 -0
  130. package/src/app/proactive/createConversationOptions.ts +35 -0
  131. package/src/app/proactive/createConversationOptionsBuilder.ts +181 -0
  132. package/src/app/proactive/index.ts +10 -0
  133. package/src/app/proactive/proactive.ts +524 -0
  134. package/src/app/proactive/proactiveOptions.ts +24 -0
  135. package/src/app/streaming/streamingResponse.ts +1 -1
  136. package/src/app/teamsAttachmentDownloader.ts +1 -1
  137. package/src/app/turnState.ts +1 -1
  138. package/src/auth/authConfiguration.ts +58 -1
  139. package/src/auth/jwt-middleware.ts +1 -1
  140. package/src/auth/msalConnectionManager.ts +22 -0
  141. package/src/auth/msalTokenCredential.ts +4 -0
  142. package/src/auth/msalTokenProvider.ts +138 -107
  143. package/src/baseAdapter.ts +1 -1
  144. package/src/cloudAdapter.ts +239 -184
  145. package/src/connector-client/connectorClient.ts +169 -126
  146. package/src/errorHelper.ts +124 -0
  147. package/src/middlewareSet.ts +1 -1
  148. package/src/oauth/userTokenClient.ts +70 -46
  149. package/src/observability/index.ts +5 -0
  150. package/src/observability/metrics.ts +103 -0
  151. package/src/observability/traces.ts +988 -0
  152. package/src/state/agentState.ts +1 -1
  153. package/src/storage/fileStorage.ts +36 -26
  154. package/src/storage/memoryStorage.ts +40 -29
  155. package/src/transcript/fileTranscriptLogger.ts +1 -1
  156. package/src/transcript/transcriptLoggerMiddleware.ts +1 -1
  157. package/src/turnContext.ts +47 -41
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.ConversationReferenceBuilder = exports.TeamsServiceEndpoints = void 0;
6
+ const agents_activity_1 = require("@microsoft/agents-activity");
7
+ const agents_telemetry_1 = require("@microsoft/agents-telemetry");
8
+ const logger = (0, agents_telemetry_1.debug)('agents:conversation-reference-builder');
9
+ /** Set of all channel IDs defined in the Channels enum, used for validation. */
10
+ const knownChannelIds = new Set(Object.values(agents_activity_1.Channels));
11
+ /**
12
+ * Well-known Teams service URLs for proactive messaging.
13
+ *
14
+ * Use only when the incoming `serviceUrl` from a real conversation is unavailable.
15
+ * Once you have received a `serviceUrl` from a real turn, cache and prefer that value.
16
+ */
17
+ exports.TeamsServiceEndpoints = {
18
+ /** Standard public cloud Teams endpoint. */
19
+ publicGlobal: 'https://smba.trafficmanager.net/teams/',
20
+ /** US Government Community Cloud (GCC). */
21
+ gcc: 'https://smba.infra.gcc.teams.microsoft.com/teams',
22
+ /** US Government Community Cloud High (GCC-High). */
23
+ gccHigh: 'https://smba.infra.gov.teams.microsoft.us/teams',
24
+ /** US Department of Defense (DoD). */
25
+ dod: 'https://smba.infra.dod.teams.microsoft.us/teams',
26
+ };
27
+ /**
28
+ * Fluent builder for `ConversationReference`.
29
+ */
30
+ class ConversationReferenceBuilder {
31
+ constructor(channelId, serviceUrl, agent) {
32
+ this._channelId = channelId;
33
+ this._serviceUrl = serviceUrl;
34
+ this._agent = agent;
35
+ }
36
+ /**
37
+ * Creates a new builder seeded with the agent identity and channel.
38
+ * On Teams, the agent id is prefixed with `28:` automatically.
39
+ * @param agentClientId The agent's client (app) ID.
40
+ * @param channelId The target channel (e.g. `'msteams'`, `'webchat'`).
41
+ * @param serviceUrl Optional override. If omitted, `build()` fills in the
42
+ * channel default via `serviceUrlForChannel()`.
43
+ */
44
+ static create(agentClientId, channelId, serviceUrl) {
45
+ return new ConversationReferenceBuilder(channelId, serviceUrl !== null && serviceUrl !== void 0 ? serviceUrl : '', ConversationReferenceBuilder.agentForChannel(channelId, agentClientId));
46
+ }
47
+ /**
48
+ * Returns the default service URL for a channel.
49
+ * Teams returns the public global endpoint; all other channels use the
50
+ * `https://{channelId}.botframework.com/` pattern (matching C# behavior).
51
+ */
52
+ static serviceUrlForChannel(channelId) {
53
+ if (!channelId)
54
+ return '';
55
+ if (channelId === agents_activity_1.Channels.Msteams)
56
+ return exports.TeamsServiceEndpoints.publicGlobal;
57
+ if (!knownChannelIds.has(channelId)) {
58
+ logger.warn(`serviceUrlForChannel: unrecognized channelId '${channelId}' — constructing fallback URL ` +
59
+ 'https://<channelId>.botframework.com/. Provide an explicit serviceUrl to suppress this warning.');
60
+ }
61
+ return `https://${channelId}.botframework.com/`;
62
+ }
63
+ withUser(userIdOrAccount, userName) {
64
+ this._user = typeof userIdOrAccount === 'string'
65
+ ? { id: userIdOrAccount, name: userName, role: agents_activity_1.RoleTypes.User }
66
+ : userIdOrAccount;
67
+ return this;
68
+ }
69
+ withAgent(agentIdOrAccount, agentName) {
70
+ this._agent = typeof agentIdOrAccount === 'string'
71
+ ? ConversationReferenceBuilder.agentForChannel(this._channelId, agentIdOrAccount, agentName)
72
+ : agentIdOrAccount;
73
+ return this;
74
+ }
75
+ /** Sets `reference.serviceUrl`. */
76
+ withServiceUrl(serviceUrl) {
77
+ this._serviceUrl = serviceUrl;
78
+ return this;
79
+ }
80
+ /** Sets `reference.conversation.id`. */
81
+ withConversationId(id) {
82
+ this._conversationId = id;
83
+ return this;
84
+ }
85
+ /** Sets `reference.activityId`. */
86
+ withActivityId(activityId) {
87
+ this._activityId = activityId;
88
+ return this;
89
+ }
90
+ /** Sets `reference.locale`. */
91
+ withLocale(locale) {
92
+ this._locale = locale;
93
+ return this;
94
+ }
95
+ /** Builds and returns the `ConversationReference`. */
96
+ build() {
97
+ var _a, _b;
98
+ const serviceUrl = this._serviceUrl || ConversationReferenceBuilder.serviceUrlForChannel(this._channelId);
99
+ const ref = {
100
+ channelId: this._channelId,
101
+ serviceUrl,
102
+ conversation: { id: (_a = this._conversationId) !== null && _a !== void 0 ? _a : '', isGroup: false },
103
+ agent: this._agent,
104
+ user: (_b = this._user) !== null && _b !== void 0 ? _b : { role: agents_activity_1.RoleTypes.User },
105
+ };
106
+ if (this._activityId !== undefined)
107
+ ref.activityId = this._activityId;
108
+ if (this._locale !== undefined)
109
+ ref.locale = this._locale;
110
+ return ref;
111
+ }
112
+ /**
113
+ * Builds a `ChannelAccount` for the agent, applying the Teams `28:` id prefix
114
+ * when the channel is `msteams`.
115
+ */
116
+ static agentForChannel(channelId, agentClientId, agentName) {
117
+ return {
118
+ id: channelId === agents_activity_1.Channels.Msteams ? `28:${agentClientId}` : agentClientId,
119
+ name: agentName,
120
+ role: agents_activity_1.RoleTypes.Agent,
121
+ };
122
+ }
123
+ }
124
+ exports.ConversationReferenceBuilder = ConversationReferenceBuilder;
125
+ //# sourceMappingURL=conversationReferenceBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversationReferenceBuilder.js","sourceRoot":"","sources":["../../../../src/app/proactive/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C,UAAU,CAAC,CAAA;QAExF,MAAM,GAAG,GAA0B;YACjC,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,UAAU;YACV,YAAY,EAAE,EAAE,EAAE,EAAE,MAAA,IAAI,CAAC,eAAe,mCAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;YAChE,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,IAAI,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE,IAAI,EAAE,2BAAS,CAAC,IAAI,EAAE;SAC7C,CAAA;QAED,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;YAAE,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAA;QACrE,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAA;QAEzD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,eAAe,CAAE,SAAiB,EAAE,aAAqB,EAAE,SAAkB;QAC1F,OAAO;YACL,EAAE,EAAE,SAAS,KAAK,0BAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,aAAa,EAAE,CAAC,CAAC,CAAC,aAAa;YAC1E,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,2BAAS,CAAC,KAAK;SACtB,CAAA;IACH,CAAC;CACF;AAhID,oEAgIC"}
@@ -0,0 +1,30 @@
1
+ import type { ConversationParameters } from '@microsoft/agents-activity';
2
+ import type { ConversationClaims } from './conversation';
3
+ /**
4
+ * Default OAuth scope for Azure Bot Service authentication.
5
+ */
6
+ export declare const AzureBotScope = "https://api.botframework.com";
7
+ /**
8
+ * Options passed to `Proactive.createConversation()`.
9
+ * Flattened — no nested Conversation wrapper.
10
+ */
11
+ export interface CreateConversationOptions {
12
+ /** JWT claims for the agent identity. `aud` must be the agent's client ID. */
13
+ identity: ConversationClaims;
14
+ /** The target channel (e.g. `'msteams'`). */
15
+ channelId: string;
16
+ /** The service URL for the channel. */
17
+ serviceUrl: string;
18
+ /**
19
+ * OAuth scope for token acquisition.
20
+ * Defaults to `AzureBotScope` when not set by the builder.
21
+ */
22
+ scope: string;
23
+ /**
24
+ * When `true`, the resulting `Conversation` is stored automatically after
25
+ * creation. Defaults to `false`.
26
+ */
27
+ storeConversation?: boolean;
28
+ /** Conversation configuration passed to `adapter.createConversationAsync()`. */
29
+ parameters: Partial<ConversationParameters>;
30
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.AzureBotScope = void 0;
6
+ /**
7
+ * Default OAuth scope for Azure Bot Service authentication.
8
+ */
9
+ exports.AzureBotScope = 'https://api.botframework.com';
10
+ //# sourceMappingURL=createConversationOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createConversationOptions.js","sourceRoot":"","sources":["../../../../src/app/proactive/createConversationOptions.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAKlC;;GAEG;AACU,QAAA,aAAa,GAAG,8BAA8B,CAAA"}
@@ -0,0 +1,69 @@
1
+ import type { Activity, ChannelAccount, ConversationParameters } from '@microsoft/agents-activity';
2
+ import { type CreateConversationOptions } from './createConversationOptions';
3
+ import type { ConversationClaims } from './conversation';
4
+ /**
5
+ * Fluent builder for `CreateConversationOptions`.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * const opts = CreateConversationOptionsBuilder
10
+ * .create('my-client-id', 'msteams')
11
+ * .withUser('user-aad-id')
12
+ * .withTenantId('tenant-id')
13
+ * .build()
14
+ * ```
15
+ */
16
+ export declare class CreateConversationOptionsBuilder {
17
+ private readonly _claims;
18
+ private readonly _channelId;
19
+ private readonly _serviceUrl;
20
+ private _scope;
21
+ private _storeConversation;
22
+ private _parameters;
23
+ private _activity;
24
+ private constructor();
25
+ /**
26
+ * Creates a new builder from an agent client ID string.
27
+ * @param agentClientId The agent's client (app) ID.
28
+ * @param channelId The target channel (e.g. `'msteams'`).
29
+ * @param serviceUrl Optional service URL override.
30
+ */
31
+ static create(agentClientId: string, channelId: string, serviceUrl?: string, parameters?: Partial<ConversationParameters>): CreateConversationOptionsBuilder;
32
+ /**
33
+ * Creates a new builder from an existing claims object (e.g. from a stored `Conversation`).
34
+ * @param claims JWT claims — `aud` must be the agent's client ID.
35
+ * @param channelId The target channel (e.g. `'msteams'`).
36
+ * @param serviceUrl Optional service URL override.
37
+ */
38
+ static create(claims: ConversationClaims, channelId: string, serviceUrl?: string, parameters?: Partial<ConversationParameters>): CreateConversationOptionsBuilder;
39
+ /** Adds a member (the target user) to `parameters.members`. */
40
+ withUser(userId: string, userName?: string): this;
41
+ withUser(account: ChannelAccount): this;
42
+ /** Sets `parameters.activity`. Defaults `activity.type` to `'message'` if not provided. */
43
+ withActivity(activity: Partial<Activity>): this;
44
+ /** Merges additional channel-specific data into `parameters.channelData`. */
45
+ withChannelData(data: object): this;
46
+ /**
47
+ * Sets `parameters.tenantId`.
48
+ * On `msteams` channels, also sets `channelData.tenant.id`.
49
+ */
50
+ withTenantId(tenantId: string): this;
51
+ /**
52
+ * Sets `parameters.isGroup = true` and `channelData.channel.id`.
53
+ * Only has effect on `msteams` channels.
54
+ */
55
+ withTeamsChannelId(teamsChannelId: string): this;
56
+ /** Sets `parameters.topicName`. */
57
+ withTopicName(name: string): this;
58
+ /** Sets `parameters.isGroup`. */
59
+ isGroup(value: boolean): this;
60
+ /** Overrides the default `AzureBotScope` OAuth scope. */
61
+ withScope(scope: string): this;
62
+ /** Controls whether the resulting conversation is stored after creation. */
63
+ storeConversation(value: boolean): this;
64
+ /**
65
+ * Builds and returns `CreateConversationOptions`.
66
+ * @throws if no members were added via `withUser()`.
67
+ */
68
+ build(): CreateConversationOptions;
69
+ }
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.CreateConversationOptionsBuilder = void 0;
6
+ const agents_activity_1 = require("@microsoft/agents-activity");
7
+ const errorHelper_1 = require("../../errorHelper");
8
+ const createConversationOptions_1 = require("./createConversationOptions");
9
+ const conversationReferenceBuilder_1 = require("./conversationReferenceBuilder");
10
+ /**
11
+ * Fluent builder for `CreateConversationOptions`.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const opts = CreateConversationOptionsBuilder
16
+ * .create('my-client-id', 'msteams')
17
+ * .withUser('user-aad-id')
18
+ * .withTenantId('tenant-id')
19
+ * .build()
20
+ * ```
21
+ */
22
+ class CreateConversationOptionsBuilder {
23
+ constructor(claims, channelId, serviceUrl) {
24
+ this._scope = createConversationOptions_1.AzureBotScope;
25
+ this._storeConversation = false;
26
+ this._parameters = {
27
+ channelData: {},
28
+ };
29
+ this._claims = claims;
30
+ this._channelId = channelId;
31
+ this._serviceUrl =
32
+ serviceUrl !== null && serviceUrl !== void 0 ? serviceUrl : conversationReferenceBuilder_1.ConversationReferenceBuilder.serviceUrlForChannel(channelId);
33
+ }
34
+ static create(agentClientIdOrClaims, channelId, serviceUrl, parameters) {
35
+ const claims = typeof agentClientIdOrClaims === 'string'
36
+ ? { aud: agentClientIdOrClaims }
37
+ : agentClientIdOrClaims;
38
+ const builder = new CreateConversationOptionsBuilder(claims, channelId, serviceUrl);
39
+ if (parameters) {
40
+ builder._parameters = { ...builder._parameters, ...parameters };
41
+ }
42
+ // Set parameters.agent if not already provided — matches C# behavior
43
+ if (!builder._parameters.agent) {
44
+ builder._parameters.agent = { id: claims.aud, role: agents_activity_1.RoleTypes.Agent };
45
+ }
46
+ return builder;
47
+ }
48
+ withUser(userIdOrAccount, userName) {
49
+ var _a;
50
+ const account = typeof userIdOrAccount === 'string'
51
+ ? { id: userIdOrAccount, name: userName }
52
+ : userIdOrAccount;
53
+ const members = (_a = this._parameters.members) !== null && _a !== void 0 ? _a : [];
54
+ members.push(account);
55
+ this._parameters = { ...this._parameters, members };
56
+ return this;
57
+ }
58
+ /** Sets `parameters.activity`. Defaults `activity.type` to `'message'` if not provided. */
59
+ withActivity(activity) {
60
+ this._activity = activity;
61
+ return this;
62
+ }
63
+ /** Merges additional channel-specific data into `parameters.channelData`. */
64
+ withChannelData(data) {
65
+ var _a;
66
+ this._parameters = {
67
+ ...this._parameters,
68
+ channelData: { ...((_a = this._parameters.channelData) !== null && _a !== void 0 ? _a : {}), ...data },
69
+ };
70
+ return this;
71
+ }
72
+ /**
73
+ * Sets `parameters.tenantId`.
74
+ * On `msteams` channels, also sets `channelData.tenant.id`.
75
+ */
76
+ withTenantId(tenantId) {
77
+ this._parameters = { ...this._parameters, tenantId };
78
+ if (this._channelId === agents_activity_1.Channels.Msteams) {
79
+ this.withChannelData({ tenant: { id: tenantId } });
80
+ }
81
+ return this;
82
+ }
83
+ /**
84
+ * Sets `parameters.isGroup = true` and `channelData.channel.id`.
85
+ * Only has effect on `msteams` channels.
86
+ */
87
+ withTeamsChannelId(teamsChannelId) {
88
+ if (this._channelId !== agents_activity_1.Channels.Msteams)
89
+ return this;
90
+ this._parameters = { ...this._parameters, isGroup: true };
91
+ this.withChannelData({ channel: { id: teamsChannelId } });
92
+ return this;
93
+ }
94
+ /** Sets `parameters.topicName`. */
95
+ withTopicName(name) {
96
+ this._parameters = { ...this._parameters, topicName: name };
97
+ return this;
98
+ }
99
+ /** Sets `parameters.isGroup`. */
100
+ isGroup(value) {
101
+ this._parameters = { ...this._parameters, isGroup: value };
102
+ return this;
103
+ }
104
+ /** Overrides the default `AzureBotScope` OAuth scope. */
105
+ withScope(scope) {
106
+ this._scope = scope;
107
+ return this;
108
+ }
109
+ /** Controls whether the resulting conversation is stored after creation. */
110
+ storeConversation(value) {
111
+ this._storeConversation = value;
112
+ return this;
113
+ }
114
+ /**
115
+ * Builds and returns `CreateConversationOptions`.
116
+ * @throws if no members were added via `withUser()`.
117
+ */
118
+ build() {
119
+ var _a;
120
+ if (!((_a = this._parameters.members) === null || _a === void 0 ? void 0 : _a.length)) {
121
+ throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.CreateConversationBuilderMembersRequired);
122
+ }
123
+ const activity = {
124
+ type: 'message',
125
+ ...this._activity,
126
+ };
127
+ return {
128
+ identity: this._claims,
129
+ channelId: this._channelId,
130
+ serviceUrl: this._serviceUrl,
131
+ scope: this._scope,
132
+ storeConversation: this._storeConversation,
133
+ parameters: {
134
+ ...this._parameters,
135
+ activity: activity,
136
+ },
137
+ };
138
+ }
139
+ }
140
+ exports.CreateConversationOptionsBuilder = CreateConversationOptionsBuilder;
141
+ //# sourceMappingURL=createConversationOptionsBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createConversationOptionsBuilder.js","sourceRoot":"","sources":["../../../../src/app/proactive/createConversationOptionsBuilder.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;AAGlC,gEAAiF;AACjF,mDAA0C;AAC1C,2EAA2F;AAE3F,iFAA6E;AAE7E;;;;;;;;;;;GAWG;AACH,MAAa,gCAAgC;IAY3C,YAAqB,MAA0B,EAAE,SAAiB,EAAE,UAAmB;QAR/E,WAAM,GAAW,yCAAa,CAAA;QAC9B,uBAAkB,GAAY,KAAK,CAAA;QACnC,gBAAW,GAAoC;YACrD,WAAW,EAAE,EAAE;SAChB,CAAA;QAKC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAAI,CAAC,WAAW;YACd,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,2DAA4B,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;IAC9E,CAAC;IAgBD,MAAM,CAAC,MAAM,CACX,qBAAkD,EAClD,SAAiB,EACjB,UAAmB,EACnB,UAA4C;QAE5C,MAAM,MAAM,GAAuB,OAAO,qBAAqB,KAAK,QAAQ;YAC1E,CAAC,CAAC,EAA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O,IAAI,CAAA;IACb,CAAC;IAED,4EAA4E;IAC5E,iBAAiB,CAAE,KAAc;QAC/B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;OAGG;IACH,KAAK;;QACH,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,CAAC,OAAO,0CAAE,MAAM,CAAA,EAAE,CAAC;YACtC,MAAM,iCAAe,CAAC,iBAAiB,CAAC,KAAK,EAAE,oBAAM,CAAC,wCAAwC,CAAC,CAAA;QACjG,CAAC;QAED,MAAM,QAAQ,GAAsB;YAClC,IAAI,EAAE,SAAS;YACf,GAAG,IAAI,CAAC,SAAS;SAClB,CAAA;QAED,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,OAAO;YACtB,SAAS,EAAE,IAAI,CAAC,UAAU;YAC1B,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,iBAAiB,EAAE,IAAI,CAAC,kBAAkB;YAC1C,UAAU,EAAE;gBACV,GAAG,IAAI,CAAC,WAAW;gBACnB,QAAQ,EAAE,QAAoB;aAC/B;SACF,CAAA;IACH,CAAC;CACF;AA9JD,4EA8JC"}
@@ -0,0 +1,7 @@
1
+ export * from './conversation';
2
+ export * from './conversationBuilder';
3
+ export * from './conversationReferenceBuilder';
4
+ export * from './createConversationOptions';
5
+ export * from './createConversationOptionsBuilder';
6
+ export * from './proactiveOptions';
7
+ export * from './proactive';
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation. All rights reserved.
3
+ // Licensed under the MIT License.
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ __exportStar(require("./conversation"), exports);
20
+ __exportStar(require("./conversationBuilder"), exports);
21
+ __exportStar(require("./conversationReferenceBuilder"), exports);
22
+ __exportStar(require("./createConversationOptions"), exports);
23
+ __exportStar(require("./createConversationOptionsBuilder"), exports);
24
+ __exportStar(require("./proactiveOptions"), exports);
25
+ __exportStar(require("./proactive"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/app/proactive/index.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,kCAAkC;;;;;;;;;;;;;;;;AAElC,iDAA8B;AAC9B,wDAAqC;AACrC,iEAA8C;AAC9C,8DAA2C;AAC3C,qEAAkD;AAClD,qDAAkC;AAClC,8CAA2B"}