@salesforce/agentforce-conversation-client 0.5.2
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/LICENSE.txt +82 -0
- package/README.md +139 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/package.json +35 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Terms of Use
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Salesforce, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
These Terms of Use govern the download, installation, and/or use of this
|
|
6
|
+
software provided by Salesforce, Inc. ("Salesforce") (the "Software"), were
|
|
7
|
+
last updated on April 15, 2025, and constitute a legally binding
|
|
8
|
+
agreement between you and Salesforce. If you do not agree to these Terms of
|
|
9
|
+
Use, do not install or use the Software.
|
|
10
|
+
|
|
11
|
+
Salesforce grants you a worldwide, non-exclusive, no-charge, royalty-free
|
|
12
|
+
copyright license to reproduce, prepare derivative works of, publicly
|
|
13
|
+
display, publicly perform, sublicense, and distribute the Software and
|
|
14
|
+
derivative works subject to these Terms. These Terms shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
Subject to the limited rights expressly granted hereunder, Salesforce
|
|
18
|
+
reserves all rights, title, and interest in and to all intellectual
|
|
19
|
+
property subsisting in the Software. No rights are granted to you hereunder
|
|
20
|
+
other than as expressly set forth herein. Users residing in countries on
|
|
21
|
+
the United States Office of Foreign Assets Control sanction list, or which
|
|
22
|
+
are otherwise subject to a US export embargo, may not use the Software.
|
|
23
|
+
|
|
24
|
+
Implementation of the Software may require development work, for which you
|
|
25
|
+
are responsible. The Software may contain bugs, errors and
|
|
26
|
+
incompatibilities and is made available on an AS IS basis without support,
|
|
27
|
+
updates, or service level commitments.
|
|
28
|
+
|
|
29
|
+
Salesforce reserves the right at any time to modify, suspend, or
|
|
30
|
+
discontinue, the Software (or any part thereof) with or without notice. You
|
|
31
|
+
agree that Salesforce shall not be liable to you or to any third party for
|
|
32
|
+
any modification, suspension, or discontinuance.
|
|
33
|
+
|
|
34
|
+
You agree to defend Salesforce against any claim, demand, suit or
|
|
35
|
+
proceeding made or brought against Salesforce by a third party arising out
|
|
36
|
+
of or accruing from (a) your use of the Software, and (b) any application
|
|
37
|
+
you develop with the Software that infringes any copyright, trademark,
|
|
38
|
+
trade secret, trade dress, patent, or other intellectual property right of
|
|
39
|
+
any person or defames any person or violates their rights of publicity or
|
|
40
|
+
privacy (each a "Claim Against Salesforce"), and will indemnify Salesforce
|
|
41
|
+
from any damages, attorney fees, and costs finally awarded against
|
|
42
|
+
Salesforce as a result of, or for any amounts paid by Salesforce under a
|
|
43
|
+
settlement approved by you in writing of, a Claim Against Salesforce,
|
|
44
|
+
provided Salesforce (x) promptly gives you written notice of the Claim
|
|
45
|
+
Against Salesforce, (y) gives you sole control of the defense and
|
|
46
|
+
settlement of the Claim Against Salesforce (except that you may not settle
|
|
47
|
+
any Claim Against Salesforce unless it unconditionally releases Salesforce
|
|
48
|
+
of all liability), and (z) gives you all reasonable assistance, at your
|
|
49
|
+
expense.
|
|
50
|
+
|
|
51
|
+
WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE SOFTWARE IS NOT
|
|
52
|
+
SUPPORTED AND IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
53
|
+
IMPLIED. IN NO EVENT SHALL SALESFORCE HAVE ANY LIABILITY FOR ANY DAMAGES,
|
|
54
|
+
INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
|
|
55
|
+
PUNITIVE, OR CONSEQUENTIAL DAMAGES, OR DAMAGES BASED ON LOST PROFITS, DATA,
|
|
56
|
+
OR USE, IN CONNECTION WITH THE SOFTWARE, HOWEVER CAUSED AND WHETHER IN
|
|
57
|
+
CONTRACT, TORT, OR UNDER ANY OTHER THEORY OF LIABILITY, WHETHER OR NOT YOU
|
|
58
|
+
HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
59
|
+
|
|
60
|
+
These Terms of Use shall be governed exclusively by the internal laws of
|
|
61
|
+
the State of California, without regard to its conflicts of laws
|
|
62
|
+
rules. Each party hereby consents to the exclusive jurisdiction of the
|
|
63
|
+
state and federal courts located in San Francisco County, California to
|
|
64
|
+
adjudicate any dispute arising out of or relating to these Terms of Use and
|
|
65
|
+
the download, installation, and/or use of the Software. Except as expressly
|
|
66
|
+
stated herein, these Terms of Use constitute the entire agreement between
|
|
67
|
+
the parties, and supersede all prior and contemporaneous agreements,
|
|
68
|
+
proposals, or representations, written or oral, concerning their subject
|
|
69
|
+
matter. No modification, amendment, or waiver of any provision of these
|
|
70
|
+
Terms of Use shall be effective unless it is by an update to these Terms of
|
|
71
|
+
Use that Salesforce makes available, or is in writing and signed by the
|
|
72
|
+
party against whom the modification, amendment, or waiver is to be
|
|
73
|
+
asserted.
|
|
74
|
+
|
|
75
|
+
Data Privacy: Salesforce may collect, process, and store device,
|
|
76
|
+
system, and other information related to your use of the Software. This
|
|
77
|
+
information includes, but is not limited to, IP address, user metrics, and
|
|
78
|
+
other data ("Usage Data"). Salesforce may use Usage Data for analytics,
|
|
79
|
+
product development, and marketing purposes. You acknowledge that files
|
|
80
|
+
generated in conjunction with the Software may contain sensitive or
|
|
81
|
+
confidential data, and you are solely responsible for anonymizing and
|
|
82
|
+
protecting such data.
|
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @salesforce/agentforce-conversation-client
|
|
2
|
+
|
|
3
|
+
Agentforce Conversation Client SDK for embedding the Agentforce chat experience into external applications. By default, Lightning Out 2.0 is embedded within the target container.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This library embeds the Agentforce Conversation Client using Lightning Out 2.0. The `salesforceOrigin` option is passed to the Lightning Out application as the `org-url` attribute.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- The hosting application must already have a valid Salesforce session established (for example, via SSO or an existing authenticated Salesforce context).
|
|
12
|
+
- Lightning Out uses the existing session to initialize; without it, the embed will fail to start.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @salesforce/agentforce-conversation-client
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Basic Embedding
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
|
|
26
|
+
|
|
27
|
+
const { loApp, chatClientComponent } = embedAgentforceClient({
|
|
28
|
+
container: "#agentforce-container",
|
|
29
|
+
salesforceOrigin: "https://myorg.my.salesforce.com",
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### With Configuration
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
|
|
37
|
+
|
|
38
|
+
const { loApp, chatClientComponent } = embedAgentforceClient({
|
|
39
|
+
container: "#agentforce-container",
|
|
40
|
+
salesforceOrigin: "https://myorg.my.salesforce.com",
|
|
41
|
+
agentforceClientConfig: {
|
|
42
|
+
styleProperties: {
|
|
43
|
+
MessageBlockInboundColor: "#0176d3",
|
|
44
|
+
},
|
|
45
|
+
mode: "Inline", // or "Floating"
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Listening for Events
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
const { loApp } = embedAgentforceClient({
|
|
54
|
+
container: "#agentforce-container",
|
|
55
|
+
salesforceOrigin: "https://myorg.my.salesforce.com",
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
loApp.addEventListener("lo.application.ready", () => {
|
|
59
|
+
console.log("Lightning Out is ready");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
loApp.addEventListener("lo.component.ready", (event) => {
|
|
63
|
+
console.log("Component ready:", event.detail.componentName);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
loApp.addEventListener("lo.application.error", (event) => {
|
|
67
|
+
console.error("Error:", event.detail);
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## API
|
|
72
|
+
|
|
73
|
+
### `embedAgentforceClient(options)`
|
|
74
|
+
|
|
75
|
+
Embeds the Agentforce Conversation Client into a specified DOM container. By default, Lightning Out is embedded within the target container.
|
|
76
|
+
|
|
77
|
+
#### Parameters
|
|
78
|
+
|
|
79
|
+
| Parameter | Type | Required | Description |
|
|
80
|
+
| -------------------------------- | ------------------------ | -------- | ----------------------------------------- |
|
|
81
|
+
| `options.container` | `string \| HTMLElement` | Yes | CSS selector or HTMLElement to embed into |
|
|
82
|
+
| `options.salesforceOrigin` | `string` | Yes | Salesforce org origin URL |
|
|
83
|
+
| `options.frontdoorUrl` | `string` | No | Frontdoor URL for authentication |
|
|
84
|
+
| `options.agentforceClientConfig` | `AgentforceClientConfig` | No | Configuration for the Agentforce client |
|
|
85
|
+
|
|
86
|
+
#### Returns
|
|
87
|
+
|
|
88
|
+
| Property | Type | Description |
|
|
89
|
+
| --------------------- | ------------------------- | --------------------------------- |
|
|
90
|
+
| `loApp` | `LightningOutApplication` | The Lightning Out application |
|
|
91
|
+
| `chatClientComponent` | `HTMLElement` | The chat client component element |
|
|
92
|
+
|
|
93
|
+
### Component Constants
|
|
94
|
+
|
|
95
|
+
These constants define the Lightning Out component tag and namespace.
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
export const AGENTFORCE_CLIENT_ELEMENT_TAG = "runtime_copilot-acc-sdk-wrapper";
|
|
99
|
+
export const AGENTFORCE_CLIENT_NAMESPACE = "runtime_copilot";
|
|
100
|
+
export const AGENTFORCE_CLIENT_COMPONENT_NAME = "accSdkWrapper";
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Types
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Accepts any style property key-value pairs
|
|
107
|
+
type StyleProperties = Record<string, string>;
|
|
108
|
+
|
|
109
|
+
interface AgentforceClientConfig {
|
|
110
|
+
styleProperties?: StyleProperties;
|
|
111
|
+
mode?: "Inline" | "Floating";
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface EmbedAgentforceClientOptions {
|
|
115
|
+
container: string | HTMLElement;
|
|
116
|
+
salesforceOrigin: string;
|
|
117
|
+
frontdoorUrl?: string;
|
|
118
|
+
agentforceClientConfig?: AgentforceClientConfig;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface EmbedAgentforceClientResult {
|
|
122
|
+
loApp: LightningOutApplication;
|
|
123
|
+
chatClientComponent: HTMLElement;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Development
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Build the package
|
|
131
|
+
npm run build
|
|
132
|
+
|
|
133
|
+
# Watch mode for development
|
|
134
|
+
npm run dev
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
See LICENSE file in the repository root.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
import { LightningOutApplication } from "@lightning-out/application";
|
|
7
|
+
/**
|
|
8
|
+
* The ACC wrapper component name used by Lightning Out
|
|
9
|
+
*/
|
|
10
|
+
export declare const AGENTFORCE_CLIENT_ELEMENT_TAG = "runtime_copilot-acc-sdk-wrapper";
|
|
11
|
+
/**
|
|
12
|
+
* The namespace used by Lightning Out
|
|
13
|
+
*/
|
|
14
|
+
export declare const AGENTFORCE_CLIENT_NAMESPACE = "runtime_copilot";
|
|
15
|
+
/**
|
|
16
|
+
* The component name used by Lightning Out
|
|
17
|
+
*/
|
|
18
|
+
export declare const AGENTFORCE_CLIENT_COMPONENT_NAME = "accSdkWrapper";
|
|
19
|
+
/**
|
|
20
|
+
* Styling options for the Agentforce client
|
|
21
|
+
* Accepts any style property key-value pairs
|
|
22
|
+
*/
|
|
23
|
+
export type StyleTokens = Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* Agentforce client configuration options
|
|
26
|
+
*/
|
|
27
|
+
export interface AgentforceClientConfig {
|
|
28
|
+
/** Styling options */
|
|
29
|
+
styleTokens?: StyleTokens;
|
|
30
|
+
/** Display mode - Inline or Floating */
|
|
31
|
+
mode?: "Inline" | "Floating";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for embedding the Agentforce client
|
|
35
|
+
*/
|
|
36
|
+
export interface EmbedAgentforceClientOptions {
|
|
37
|
+
/** CSS selector or HTMLElement */
|
|
38
|
+
container: string | HTMLElement;
|
|
39
|
+
/** Salesforce org origin URL (used as endpoint for component resolution) */
|
|
40
|
+
salesforceOrigin: string;
|
|
41
|
+
/** Frontdoor URL for authentication */
|
|
42
|
+
frontdoorUrl?: string;
|
|
43
|
+
/** Agentforce client configuration */
|
|
44
|
+
agentforceClientConfig?: AgentforceClientConfig;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Result of embedding the Agentforce client
|
|
48
|
+
*/
|
|
49
|
+
export interface EmbedAgentforceClientResult {
|
|
50
|
+
/** The Lightning Out application element */
|
|
51
|
+
loApp: LightningOutApplication;
|
|
52
|
+
/** The chat client component element */
|
|
53
|
+
chatClientComponent: HTMLElement;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Embeds the Agentforce Conversation Client into a specified DOM container.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Configuration options
|
|
59
|
+
* @returns The created elements
|
|
60
|
+
* @throws Error if required options are missing
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* embedAgentforceClient({
|
|
65
|
+
* container: '#agentforce-conversation-client-container',
|
|
66
|
+
* salesforceOrigin: 'https://myorg.my.salesforce.com',
|
|
67
|
+
* agentforceClientConfig: { styleTokens: { MessageBlockInboundColor: '#0176d3' } }
|
|
68
|
+
* });
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* // Listen for Lightning Out events after embedding
|
|
74
|
+
* const { loApp } = embedAgentforceClient({ ... });
|
|
75
|
+
*
|
|
76
|
+
* loApp.addEventListener('lo.application.ready', () => {
|
|
77
|
+
* console.log('Lightning Out is ready');
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* loApp.addEventListener('lo.component.ready', (event) => {
|
|
81
|
+
* console.log('Component ready:', event.detail.componentName);
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function embedAgentforceClient(options?: EmbedAgentforceClientOptions | null): EmbedAgentforceClientResult;
|
|
86
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,6BAA6B,oCAAoC,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gCAAgC,kBAAkB,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC,sBAAsB;IACtB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C,kCAAkC;IAClC,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAChC,4EAA4E;IAC5E,gBAAgB,EAAE,MAAM,CAAC;IACzB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sCAAsC;IACtC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C,4CAA4C;IAC5C,KAAK,EAAE,uBAAuB,CAAC;IAC/B,wCAAwC;IACxC,mBAAmB,EAAE,WAAW,CAAC;CACjC;AAmDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,qBAAqB,CACpC,OAAO,CAAC,EAAE,4BAA4B,GAAG,IAAI,GAC3C,2BAA2B,CAkB7B"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
import { LightningOutApplication } from "@lightning-out/application";
|
|
7
|
+
/**
|
|
8
|
+
* The ACC wrapper component name used by Lightning Out
|
|
9
|
+
*/
|
|
10
|
+
export const AGENTFORCE_CLIENT_ELEMENT_TAG = "runtime_copilot-acc-sdk-wrapper";
|
|
11
|
+
/**
|
|
12
|
+
* The namespace used by Lightning Out
|
|
13
|
+
*/
|
|
14
|
+
export const AGENTFORCE_CLIENT_NAMESPACE = "runtime_copilot";
|
|
15
|
+
/**
|
|
16
|
+
* The component name used by Lightning Out
|
|
17
|
+
*/
|
|
18
|
+
export const AGENTFORCE_CLIENT_COMPONENT_NAME = "accSdkWrapper";
|
|
19
|
+
/**
|
|
20
|
+
* Resolves a container parameter to an HTMLElement
|
|
21
|
+
* @param container - CSS selector or HTMLElement
|
|
22
|
+
* @returns The resolved HTMLElement or null if not found
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
function resolveContainer(container) {
|
|
26
|
+
if (container instanceof HTMLElement)
|
|
27
|
+
return container;
|
|
28
|
+
if (typeof container === "string")
|
|
29
|
+
return document.querySelector(container);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create and configure the Lightning Out application and chat client component
|
|
34
|
+
* @param container - The container element
|
|
35
|
+
* @param salesforceOrigin - The Salesforce origin URL
|
|
36
|
+
* @param agentforceClientConfig - Configuration for the Agentforce client
|
|
37
|
+
* @returns The created Lightning Out app and chat client component
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
function createLightningOutApp(container, salesforceOrigin, frontdoorUrl, agentforceClientConfig) {
|
|
41
|
+
const loApp = new LightningOutApplication();
|
|
42
|
+
loApp.setAttribute("org-url", salesforceOrigin);
|
|
43
|
+
loApp.setAttribute("components", `${AGENTFORCE_CLIENT_NAMESPACE}/${AGENTFORCE_CLIENT_COMPONENT_NAME}`);
|
|
44
|
+
if (frontdoorUrl) {
|
|
45
|
+
loApp.setAttribute("frontdoor-url", frontdoorUrl);
|
|
46
|
+
}
|
|
47
|
+
container.appendChild(loApp);
|
|
48
|
+
const chatClientComponent = document.createElement(AGENTFORCE_CLIENT_ELEMENT_TAG);
|
|
49
|
+
chatClientComponent.configuration =
|
|
50
|
+
agentforceClientConfig;
|
|
51
|
+
container.appendChild(chatClientComponent);
|
|
52
|
+
loApp.addEventListener("lo.application.error", (event) => {
|
|
53
|
+
console.error("Agentforce Conversation Client: Lightning Out error:", event.detail);
|
|
54
|
+
});
|
|
55
|
+
return { loApp, chatClientComponent };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Embeds the Agentforce Conversation Client into a specified DOM container.
|
|
59
|
+
*
|
|
60
|
+
* @param options - Configuration options
|
|
61
|
+
* @returns The created elements
|
|
62
|
+
* @throws Error if required options are missing
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* embedAgentforceClient({
|
|
67
|
+
* container: '#agentforce-conversation-client-container',
|
|
68
|
+
* salesforceOrigin: 'https://myorg.my.salesforce.com',
|
|
69
|
+
* agentforceClientConfig: { styleTokens: { MessageBlockInboundColor: '#0176d3' } }
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* // Listen for Lightning Out events after embedding
|
|
76
|
+
* const { loApp } = embedAgentforceClient({ ... });
|
|
77
|
+
*
|
|
78
|
+
* loApp.addEventListener('lo.application.ready', () => {
|
|
79
|
+
* console.log('Lightning Out is ready');
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* loApp.addEventListener('lo.component.ready', (event) => {
|
|
83
|
+
* console.log('Component ready:', event.detail.componentName);
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function embedAgentforceClient(options) {
|
|
88
|
+
const { container, salesforceOrigin, frontdoorUrl, agentforceClientConfig = {} } = options ?? {};
|
|
89
|
+
if (!container)
|
|
90
|
+
throw new Error("Agentforce Conversation Client: container is required");
|
|
91
|
+
if (!salesforceOrigin)
|
|
92
|
+
throw new Error("Agentforce Conversation Client: salesforceOrigin is required");
|
|
93
|
+
const containerElement = resolveContainer(container);
|
|
94
|
+
if (!containerElement) {
|
|
95
|
+
throw new Error(`Agentforce Conversation Client: container not found: ${container}`);
|
|
96
|
+
}
|
|
97
|
+
return createLightningOutApp(containerElement, salesforceOrigin, frontdoorUrl, agentforceClientConfig);
|
|
98
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salesforce/agentforce-conversation-client",
|
|
3
|
+
"description": "Agentforce Conversation Client SDK for embedding via Lightning Out 2.0",
|
|
4
|
+
"version": "0.5.2",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc --build",
|
|
22
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
23
|
+
"dev": "tsc --build --watch"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@lightning-out/application": "2.1.1-rc.2"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"vitest": "^4.0.6"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.0.0"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "c85ca502ecb32ebdee7563a3477060f7ed529c9d"
|
|
35
|
+
}
|