@salesforce/agentforce-conversation-client 11.67.0 → 11.68.0
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/README.md +219 -46
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +16 -0
- package/dist/embed.d.ts +17 -0
- package/dist/embed.d.ts.map +1 -0
- package/dist/embed.js +105 -0
- package/dist/frame.d.ts +7 -0
- package/dist/frame.d.ts.map +1 -0
- package/dist/frame.js +92 -0
- package/dist/index.d.ts +4 -83
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -296
- package/dist/index.spec.js +300 -6
- package/dist/session-keepalive.d.ts +17 -0
- package/dist/session-keepalive.d.ts.map +1 -0
- package/dist/session-keepalive.js +183 -0
- package/dist/styles.d.ts +7 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +105 -0
- package/dist/types.d.ts +118 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,87 +3,8 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export declare const AGENTFORCE_LO_APP_DATA_ATTR = "data-lo";
|
|
11
|
-
export declare const AGENTFORCE_CLIENT_COMPONENT_NAME_ALIAS = "runtime_copilot/accSdkWrapper as runtime_copilot-acc-sdk-wrapper";
|
|
12
|
-
export declare const RenderingMode: Readonly<{
|
|
13
|
-
readonly INLINE: "inline";
|
|
14
|
-
readonly FLOATING: "floating";
|
|
15
|
-
}>;
|
|
16
|
-
export type RenderingModeValue = (typeof RenderingMode)[keyof typeof RenderingMode];
|
|
17
|
-
export type StyleTokens = Record<string, string>;
|
|
18
|
-
export interface TypewriterConfig {
|
|
19
|
-
charsPerFrame?: number;
|
|
20
|
-
charsPerFrameMarkdown?: number;
|
|
21
|
-
queueThresholdMedium?: number;
|
|
22
|
-
queueThresholdHigh?: number;
|
|
23
|
-
queueThresholdCritical?: number;
|
|
24
|
-
frameDelayMs?: number;
|
|
25
|
-
idleCursorTimeoutMs?: number;
|
|
26
|
-
rushToEndMs?: number;
|
|
27
|
-
}
|
|
28
|
-
export interface AgentforceClientConfig {
|
|
29
|
-
styleTokens?: StyleTokens;
|
|
30
|
-
agentId?: string;
|
|
31
|
-
agentLabel?: string;
|
|
32
|
-
renderingConfig?: {
|
|
33
|
-
mode?: RenderingModeValue;
|
|
34
|
-
width?: string | number;
|
|
35
|
-
height?: string | number;
|
|
36
|
-
headerEnabled?: boolean;
|
|
37
|
-
showHeaderIcon?: boolean;
|
|
38
|
-
showAvatar?: boolean;
|
|
39
|
-
agentAvatarUrl?: string;
|
|
40
|
-
agentAvatarAltText?: string;
|
|
41
|
-
headerIconName?: string;
|
|
42
|
-
headerIconSize?: string;
|
|
43
|
-
headerImageUrl?: string;
|
|
44
|
-
headerImageAlt?: string;
|
|
45
|
-
};
|
|
46
|
-
channel?: string;
|
|
47
|
-
messageInputPlaceholderText?: string;
|
|
48
|
-
isHistoryIntroNeeded?: boolean;
|
|
49
|
-
isFileBased?: boolean;
|
|
50
|
-
typewriterConfig?: TypewriterConfig;
|
|
51
|
-
floatingButtonLabel?: string;
|
|
52
|
-
floatingButtonIcon?: string;
|
|
53
|
-
floatingButtonImage?: string;
|
|
54
|
-
floatingButtonImageAlt?: string;
|
|
55
|
-
iconPosition?: "left" | "right";
|
|
56
|
-
}
|
|
57
|
-
export interface AgentforceLoErrorEvent {
|
|
58
|
-
type: "lo.application.error" | "lo.iframe.error";
|
|
59
|
-
detail: unknown;
|
|
60
|
-
}
|
|
61
|
-
export type AgentforceErrorHandler = (error: AgentforceLoErrorEvent) => void;
|
|
62
|
-
export type AgentforceReadyHandler = (detail: unknown) => void;
|
|
63
|
-
export interface EmbedAgentforceClientOptions {
|
|
64
|
-
container: string | HTMLElement;
|
|
65
|
-
salesforceOrigin?: string;
|
|
66
|
-
appId?: string;
|
|
67
|
-
frontdoorUrl?: string;
|
|
68
|
-
sitePrefix?: string;
|
|
69
|
-
agentforceClientConfig?: AgentforceClientConfig;
|
|
70
|
-
onError?: AgentforceErrorHandler;
|
|
71
|
-
onReady?: AgentforceReadyHandler;
|
|
72
|
-
}
|
|
73
|
-
export interface EmbedAgentforceClientResult {
|
|
74
|
-
loApp: LightningOutApplication;
|
|
75
|
-
chatClientComponent: HTMLElement;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Embeds the Agentforce Conversation Client into a DOM container.
|
|
79
|
-
* Embed is hidden (opacity 0) until the frame receives the "accready" event.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* const { loApp, chatClientComponent } = embedAgentforceClient({
|
|
83
|
-
* container: '#agentforce-container',
|
|
84
|
-
* salesforceOrigin: 'https://myorg.my.salesforce.com',
|
|
85
|
-
* agentforceClientConfig: { renderingConfig: { mode: 'floating' } }
|
|
86
|
-
* });
|
|
87
|
-
*/
|
|
88
|
-
export declare function embedAgentforceClient(options?: EmbedAgentforceClientOptions | null): EmbedAgentforceClientResult;
|
|
6
|
+
export { AGENTFORCE_CLIENT_ELEMENT_TAG, AGENTFORCE_CLIENT_NAMESPACE, AGENTFORCE_CLIENT_COMPONENT_NAME, AGENTFORCE_LO_APP_DATA_ATTR, AGENTFORCE_CLIENT_COMPONENT_NAME_ALIAS, AGENTFORCE_FRONTDOOR_URL_REQUIRED_EVENT, RenderingMode, } from "./constants.js";
|
|
7
|
+
export type { RenderingModeValue } from "./constants.js";
|
|
8
|
+
export type { StyleTokens, TypewriterConfig, AgentforceClientConfig, AgentforceLoErrorEvent, AgentforceErrorHandler, AgentforceReadyHandler, AgentforceSessionRecoveryRequest, AgentforceSessionManagementConfig, EmbedAgentforceClientOptions, AgentforceLightningOutApplication, EmbedAgentforceClientResult, } from "./types.js";
|
|
9
|
+
export { embedAgentforceClient } from "./embed.js";
|
|
89
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,6BAA6B,EAC7B,2BAA2B,EAC3B,gCAAgC,EAChC,2BAA2B,EAC3B,sCAAsC,EACtC,uCAAuC,EACvC,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,YAAY,EACX,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,gCAAgC,EAChC,iCAAiC,EACjC,4BAA4B,EAC5B,iCAAiC,EACjC,2BAA2B,GAC3B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,299 +3,5 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// PUBLIC CONSTANTS (API surface)
|
|
9
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
10
|
-
export const AGENTFORCE_CLIENT_ELEMENT_TAG = "runtime_copilot-acc-sdk-wrapper";
|
|
11
|
-
export const AGENTFORCE_CLIENT_NAMESPACE = "runtime_copilot";
|
|
12
|
-
export const AGENTFORCE_CLIENT_COMPONENT_NAME = "accSdkWrapper";
|
|
13
|
-
export const AGENTFORCE_LO_APP_DATA_ATTR = "data-lo";
|
|
14
|
-
export const AGENTFORCE_CLIENT_COMPONENT_NAME_ALIAS = `${AGENTFORCE_CLIENT_NAMESPACE}/${AGENTFORCE_CLIENT_COMPONENT_NAME} as ${AGENTFORCE_CLIENT_ELEMENT_TAG}`;
|
|
15
|
-
export const RenderingMode = Object.freeze({
|
|
16
|
-
INLINE: "inline",
|
|
17
|
-
FLOATING: "floating",
|
|
18
|
-
});
|
|
19
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
20
|
-
// INTERNAL CONSTANTS
|
|
21
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
22
|
-
const EVENTS = Object.freeze({
|
|
23
|
-
ACC_MAXIMIZE: "accmaximize",
|
|
24
|
-
ACC_MINIMIZE: "accminimize",
|
|
25
|
-
ACC_READY: "accready",
|
|
26
|
-
});
|
|
27
|
-
const STYLE_ID = "agentforce-client-injected-styles";
|
|
28
|
-
const FLOATING_DIMENSIONS = Object.freeze({
|
|
29
|
-
MINIMIZED_HEIGHT: "56px",
|
|
30
|
-
MAXIMIZED_HEIGHT: "742px",
|
|
31
|
-
});
|
|
32
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
33
|
-
// STYLES – Injected CSS (overrides acc-sdk-wrapper inline width/height via !important)
|
|
34
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
35
|
-
const AGENTFORCE_CLIENT_CSS = `
|
|
36
|
-
:root {
|
|
37
|
-
--minimized-iframe-width: 180px !important;
|
|
38
|
-
--minimized-iframe-height: 70px !important;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.acc-container:has(> .acc-frame.inline) {
|
|
42
|
-
height: 100%;
|
|
43
|
-
width: 100%;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.sds-overrides {
|
|
47
|
-
width: auto;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.acc-container > .acc-frame {
|
|
51
|
-
display: block;
|
|
52
|
-
position: fixed;
|
|
53
|
-
background: transparent;
|
|
54
|
-
border: none;
|
|
55
|
-
outline: none;
|
|
56
|
-
border-radius: 20px;
|
|
57
|
-
bottom: 24px;
|
|
58
|
-
right: 24px;
|
|
59
|
-
height: 0 !important;
|
|
60
|
-
width: 0 !important;
|
|
61
|
-
max-width: calc(100vw - 4rem);
|
|
62
|
-
max-height: calc(100dvh - 4rem);
|
|
63
|
-
z-index: 999;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.acc-container > .acc-frame.inline,
|
|
67
|
-
.acc-container > .acc-frame.inline.maximize {
|
|
68
|
-
height: 100% !important;
|
|
69
|
-
width: 100% !important;
|
|
70
|
-
position: static;
|
|
71
|
-
bottom: 0;
|
|
72
|
-
right: 0;
|
|
73
|
-
max-height: 100%;
|
|
74
|
-
max-width: 100%;
|
|
75
|
-
box-shadow: none;
|
|
76
|
-
border-radius: 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.acc-container > .acc-frame.inline:not(.maximize) {
|
|
80
|
-
width: var(--acc-width, auto) !important;
|
|
81
|
-
height: var(--acc-height, auto) !important;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.acc-container > .acc-frame.initial {
|
|
85
|
-
height: var(--minimized-iframe-height, 56px) !important;
|
|
86
|
-
width: var(--minimized-iframe-width, 145px) !important;
|
|
87
|
-
transition: all 0s ease;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.acc-container > .acc-frame.minimize {
|
|
91
|
-
height: var(--minimized-iframe-height, 56px) !important;
|
|
92
|
-
width: var(--minimized-iframe-width, 145px) !important;
|
|
93
|
-
transition: width 0.25s ease-in-out, height 0.25s ease-in-out;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.acc-container > .acc-frame.maximize {
|
|
97
|
-
width: 450px !important;
|
|
98
|
-
height: 700px !important;
|
|
99
|
-
background: #ffffff;
|
|
100
|
-
box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.05),
|
|
101
|
-
0 0 2px 0 rgba(0, 0, 0, 0.05), 0 20px 45px -5px rgba(0, 0, 0, 0.08);
|
|
102
|
-
transition: all 0.3s ease;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.acc-container > lightning-out-application {
|
|
106
|
-
background: transparent;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@media (max-width: 639px) {
|
|
110
|
-
.acc-container > .acc-frame.maximize {
|
|
111
|
-
bottom: 0;
|
|
112
|
-
right: 0;
|
|
113
|
-
width: 100% !important;
|
|
114
|
-
height: 100vh !important;
|
|
115
|
-
height: 100dvh !important;
|
|
116
|
-
border-radius: 0;
|
|
117
|
-
max-width: 100%;
|
|
118
|
-
max-height: 100vh;
|
|
119
|
-
overflow-y: auto;
|
|
120
|
-
overflow-x: hidden;
|
|
121
|
-
-webkit-overflow-scrolling: touch;
|
|
122
|
-
transition: height 0.2s ease-in-out;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
`;
|
|
126
|
-
function injectStyles(additionalCss = "") {
|
|
127
|
-
if (document.getElementById(STYLE_ID))
|
|
128
|
-
return;
|
|
129
|
-
const style = document.createElement("style");
|
|
130
|
-
style.id = STYLE_ID;
|
|
131
|
-
style.textContent = AGENTFORCE_CLIENT_CSS + (additionalCss ? "\n" + additionalCss : "");
|
|
132
|
-
document.head.appendChild(style);
|
|
133
|
-
}
|
|
134
|
-
function toCssLength(value) {
|
|
135
|
-
return typeof value === "number" ? `${value}px` : value;
|
|
136
|
-
}
|
|
137
|
-
function normalizeRenderingMode(value) {
|
|
138
|
-
if (value === RenderingMode.INLINE || value === RenderingMode.FLOATING)
|
|
139
|
-
return value;
|
|
140
|
-
return undefined;
|
|
141
|
-
}
|
|
142
|
-
function getRenderingContext(clientConfig) {
|
|
143
|
-
const renderingConfig = clientConfig?.renderingConfig ?? {};
|
|
144
|
-
const mode = normalizeRenderingMode(renderingConfig.mode) ?? RenderingMode.FLOATING;
|
|
145
|
-
const isFloating = mode !== RenderingMode.INLINE;
|
|
146
|
-
return { mode, isFloating, renderingConfig };
|
|
147
|
-
}
|
|
148
|
-
function applyInlineSizing(container, { width, height }) {
|
|
149
|
-
if (width != null)
|
|
150
|
-
container.style.setProperty("--acc-width", toCssLength(width));
|
|
151
|
-
if (height != null) {
|
|
152
|
-
const h = toCssLength(height);
|
|
153
|
-
container.style.setProperty("--acc-height", h);
|
|
154
|
-
container.style.setProperty("--agentic-chat-container-height", h);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function createFrameElement() {
|
|
158
|
-
const el = document.createElement(AGENTFORCE_CLIENT_ELEMENT_TAG);
|
|
159
|
-
el.classList.add("acc-frame");
|
|
160
|
-
return el;
|
|
161
|
-
}
|
|
162
|
-
function applyFrameInitialState(el, context, container) {
|
|
163
|
-
el.style.opacity = "0";
|
|
164
|
-
el.style.pointerEvents = "none";
|
|
165
|
-
el.style.setProperty("--agentic-chat-container-height", "100vh");
|
|
166
|
-
if (context.isFloating) {
|
|
167
|
-
el.classList.add("floating");
|
|
168
|
-
el.classList.remove("maximize", "minimize");
|
|
169
|
-
el.classList.add("initial");
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
el.classList.add("inline");
|
|
173
|
-
applyInlineSizing(container, context.renderingConfig);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function attachFrameResizeHandlers(el, container, isFloating, loApp) {
|
|
177
|
-
const onAccReady = () => {
|
|
178
|
-
el.style.opacity = "";
|
|
179
|
-
el.style.pointerEvents = "";
|
|
180
|
-
if (loApp) {
|
|
181
|
-
loApp.style.opacity = "";
|
|
182
|
-
loApp.style.pointerEvents = "";
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
el.addEventListener(EVENTS.ACC_READY, onAccReady);
|
|
186
|
-
if (!isFloating)
|
|
187
|
-
return;
|
|
188
|
-
const onMaximize = () => {
|
|
189
|
-
el.classList.remove("initial", "minimize");
|
|
190
|
-
el.classList.add("maximize");
|
|
191
|
-
};
|
|
192
|
-
const onMinimize = () => {
|
|
193
|
-
el.classList.remove("maximize");
|
|
194
|
-
el.classList.add("minimize");
|
|
195
|
-
container.style.setProperty("--agentic-chat-container-height", FLOATING_DIMENSIONS.MINIMIZED_HEIGHT);
|
|
196
|
-
};
|
|
197
|
-
el.addEventListener(EVENTS.ACC_MAXIMIZE, onMaximize);
|
|
198
|
-
el.addEventListener(EVENTS.ACC_MINIMIZE, onMinimize);
|
|
199
|
-
}
|
|
200
|
-
function createAndMountFrame(container, clientConfig, loApp) {
|
|
201
|
-
injectStyles();
|
|
202
|
-
const config = { ...(clientConfig ?? {}) };
|
|
203
|
-
const context = getRenderingContext(config);
|
|
204
|
-
const el = createFrameElement();
|
|
205
|
-
el.configuration = config;
|
|
206
|
-
applyFrameInitialState(el, context, container);
|
|
207
|
-
attachFrameResizeHandlers(el, container, context.isFloating, loApp);
|
|
208
|
-
container.appendChild(el);
|
|
209
|
-
return el;
|
|
210
|
-
}
|
|
211
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
212
|
-
// LIGHTNING OUT – LO app creation and error handling
|
|
213
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
214
|
-
function createAndMountLoApp(container, salesforceOrigin, appId, frontdoorUrl, sitePrefix, onError, onReady) {
|
|
215
|
-
const loApp = new LightningOutApplication();
|
|
216
|
-
if (salesforceOrigin)
|
|
217
|
-
loApp.setAttribute("org-url", salesforceOrigin);
|
|
218
|
-
loApp.setAttribute("components", AGENTFORCE_CLIENT_COMPONENT_NAME_ALIAS);
|
|
219
|
-
loApp.setAttribute(AGENTFORCE_LO_APP_DATA_ATTR, `acc`);
|
|
220
|
-
if (appId)
|
|
221
|
-
loApp.setAttribute("app-id", appId);
|
|
222
|
-
if (frontdoorUrl)
|
|
223
|
-
loApp.setAttribute("frontdoor-url", frontdoorUrl);
|
|
224
|
-
if (sitePrefix)
|
|
225
|
-
loApp.setAttribute("site-prefix", sitePrefix);
|
|
226
|
-
loApp.style.opacity = "0";
|
|
227
|
-
loApp.style.pointerEvents = "none";
|
|
228
|
-
attachLoEventHandlers(loApp, onError, onReady);
|
|
229
|
-
container.appendChild(loApp);
|
|
230
|
-
return loApp;
|
|
231
|
-
}
|
|
232
|
-
function attachLoEventHandlers(loApp, onError, onReady) {
|
|
233
|
-
loApp.addEventListener("lo.application.ready", (e) => {
|
|
234
|
-
const detail = e.detail;
|
|
235
|
-
console.log("Agentforce Conversation Client: Lightning Out ready", detail != null ? detail : "");
|
|
236
|
-
onReady?.(detail);
|
|
237
|
-
});
|
|
238
|
-
loApp.addEventListener("lo.application.error", (e) => {
|
|
239
|
-
const detail = e.detail;
|
|
240
|
-
console.error("Agentforce Conversation Client: Lightning Out error:", detail);
|
|
241
|
-
onError?.({ type: "lo.application.error", detail });
|
|
242
|
-
});
|
|
243
|
-
loApp.addEventListener("lo.iframe.error", (e) => {
|
|
244
|
-
const detail = e.detail;
|
|
245
|
-
console.error("Agentforce Conversation Client: Lightning Out iframe error:", detail);
|
|
246
|
-
onError?.({ type: "lo.iframe.error", detail });
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
250
|
-
// CONTAINER & EMBED
|
|
251
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
252
|
-
function resolveContainer(container) {
|
|
253
|
-
if (container instanceof HTMLElement)
|
|
254
|
-
return container;
|
|
255
|
-
if (typeof container === "string")
|
|
256
|
-
return document.querySelector(container);
|
|
257
|
-
return null;
|
|
258
|
-
}
|
|
259
|
-
function embedIntoContainer(containerElement, options) {
|
|
260
|
-
const { salesforceOrigin, appId, frontdoorUrl, sitePrefix, agentforceClientConfig = {}, onError, onReady, } = options;
|
|
261
|
-
containerElement.classList.add("acc-container");
|
|
262
|
-
const loApp = createAndMountLoApp(containerElement, salesforceOrigin, appId, frontdoorUrl, sitePrefix, onError, onReady);
|
|
263
|
-
const chatClientComponent = createAndMountFrame(containerElement, agentforceClientConfig, loApp);
|
|
264
|
-
return { loApp, chatClientComponent };
|
|
265
|
-
}
|
|
266
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
267
|
-
// PUBLIC API
|
|
268
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
269
|
-
/**
|
|
270
|
-
* Embeds the Agentforce Conversation Client into a DOM container.
|
|
271
|
-
* Embed is hidden (opacity 0) until the frame receives the "accready" event.
|
|
272
|
-
*
|
|
273
|
-
* @example
|
|
274
|
-
* const { loApp, chatClientComponent } = embedAgentforceClient({
|
|
275
|
-
* container: '#agentforce-container',
|
|
276
|
-
* salesforceOrigin: 'https://myorg.my.salesforce.com',
|
|
277
|
-
* agentforceClientConfig: { renderingConfig: { mode: 'floating' } }
|
|
278
|
-
* });
|
|
279
|
-
*/
|
|
280
|
-
export function embedAgentforceClient(options) {
|
|
281
|
-
const { container, salesforceOrigin, appId, frontdoorUrl, sitePrefix, agentforceClientConfig = {}, onError, onReady, } = options ?? {};
|
|
282
|
-
if (!container)
|
|
283
|
-
throw new Error("Agentforce Conversation Client: container is required");
|
|
284
|
-
if (!salesforceOrigin && !frontdoorUrl) {
|
|
285
|
-
throw new Error("Agentforce Conversation Client: salesforceOrigin or frontdoorUrl is required");
|
|
286
|
-
}
|
|
287
|
-
const containerElement = resolveContainer(container);
|
|
288
|
-
if (!containerElement) {
|
|
289
|
-
throw new Error(`Agentforce Conversation Client: container not found: ${container}`);
|
|
290
|
-
}
|
|
291
|
-
return embedIntoContainer(containerElement, {
|
|
292
|
-
container,
|
|
293
|
-
salesforceOrigin,
|
|
294
|
-
appId,
|
|
295
|
-
frontdoorUrl,
|
|
296
|
-
sitePrefix,
|
|
297
|
-
agentforceClientConfig,
|
|
298
|
-
onError,
|
|
299
|
-
onReady,
|
|
300
|
-
});
|
|
301
|
-
}
|
|
6
|
+
export { AGENTFORCE_CLIENT_ELEMENT_TAG, AGENTFORCE_CLIENT_NAMESPACE, AGENTFORCE_CLIENT_COMPONENT_NAME, AGENTFORCE_LO_APP_DATA_ATTR, AGENTFORCE_CLIENT_COMPONENT_NAME_ALIAS, AGENTFORCE_FRONTDOOR_URL_REQUIRED_EVENT, RenderingMode, } from "./constants.js";
|
|
7
|
+
export { embedAgentforceClient } from "./embed.js";
|