@salesforce/sdk-chat 1.114.0 → 1.116.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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -16
- package/dist/singleton.d.ts +32 -0
- package/dist/singleton.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ export interface ChatSDKOptions extends SDKOptions {
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function createChatSDK(options?: ChatSDKOptions): Promise<ChatSDK>;
|
|
19
19
|
export { MCPAppsChatSDK } from './mcpapps';
|
|
20
|
+
export { getChatSDK, getChatSDKSync, resetChatSDK } from './singleton';
|
|
20
21
|
export type { HostContext, ChatMessage, ChatSDK, DeviceCapabilities, DisplayMode, ResourceRequest, SafeAreaInsets, SDKOptions, ToolCall, ToolState, } from '@salesforce/sdk-core';
|
|
21
22
|
//# 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":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAKvF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,iEAAiE;IACjE,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAyB9E;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAKvF;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,iEAAiE;IACjE,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAyB9E;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvE,YAAY,EACX,WAAW,EACX,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,EACd,UAAU,EACV,QAAQ,EACR,SAAS,GACT,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getSurface as
|
|
2
|
-
class
|
|
1
|
+
import { getSurface as c, Surface as n, McpAppsSession as d } from "@salesforce/sdk-core";
|
|
2
|
+
class p {
|
|
3
3
|
constructor(t) {
|
|
4
4
|
this.session = t;
|
|
5
5
|
const e = t.getHostContext();
|
|
@@ -43,7 +43,7 @@ class c {
|
|
|
43
43
|
*/
|
|
44
44
|
handleToolCancelled(t) {
|
|
45
45
|
const o = t.reason ?? "";
|
|
46
|
-
this.canceledCallbacks.forEach((
|
|
46
|
+
this.canceledCallbacks.forEach((u) => u(o));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Request display mode change from host
|
|
@@ -133,8 +133,8 @@ class c {
|
|
|
133
133
|
this.subscriptions.forEach((t) => t());
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
class
|
|
136
|
+
const r = "openai:set_globals";
|
|
137
|
+
class l {
|
|
138
138
|
sendMessageToHost(t) {
|
|
139
139
|
return window.openai.sendFollowUpMessage({ prompt: t.content });
|
|
140
140
|
}
|
|
@@ -169,12 +169,12 @@ class a {
|
|
|
169
169
|
}
|
|
170
170
|
subscribe(t) {
|
|
171
171
|
const e = () => t();
|
|
172
|
-
return window.addEventListener(
|
|
173
|
-
window.removeEventListener(
|
|
172
|
+
return window.addEventListener(r, e), () => {
|
|
173
|
+
window.removeEventListener(r, e);
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
class
|
|
177
|
+
class f {
|
|
178
178
|
async sendMessageToHost(t) {
|
|
179
179
|
throw console.warn("SalesforceACCChatSDK.sendMessageToHost: stub implementation", t), new Error("SalesforceACCChatSDK.sendMessageToHost not yet implemented");
|
|
180
180
|
}
|
|
@@ -182,24 +182,37 @@ class d {
|
|
|
182
182
|
return console.warn("SalesforceACCChatSDK.followUpActions: stub implementation"), [];
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
let i = null, a = null;
|
|
186
|
+
function w(s) {
|
|
187
|
+
return i || (i = h(s).then((t) => (a = t, t))), i;
|
|
188
|
+
}
|
|
189
|
+
function b() {
|
|
190
|
+
return a;
|
|
191
|
+
}
|
|
192
|
+
function S() {
|
|
193
|
+
i = null, a = null;
|
|
194
|
+
}
|
|
195
|
+
async function h(s) {
|
|
196
|
+
switch (c(s?.surface)) {
|
|
187
197
|
case n.OpenAI:
|
|
188
|
-
return new
|
|
198
|
+
return new l();
|
|
189
199
|
case n.WebApp:
|
|
190
200
|
case n.MicroFrontend:
|
|
191
201
|
return {};
|
|
192
202
|
case n.SalesforceACC:
|
|
193
|
-
return new
|
|
203
|
+
return new f();
|
|
194
204
|
case n.MCPApps: {
|
|
195
|
-
const e = await
|
|
196
|
-
return e.handshakeSucceeded ? new
|
|
205
|
+
const e = await d.getInstance(s?.mcpApps);
|
|
206
|
+
return e.handshakeSucceeded ? new p(e) : window.openai ? new l() : {};
|
|
197
207
|
}
|
|
198
208
|
default:
|
|
199
209
|
return {};
|
|
200
210
|
}
|
|
201
211
|
}
|
|
202
212
|
export {
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
p as MCPAppsChatSDK,
|
|
214
|
+
h as createChatSDK,
|
|
215
|
+
w as getChatSDK,
|
|
216
|
+
b as getChatSDKSync,
|
|
217
|
+
S as resetChatSDK
|
|
205
218
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ChatSDK } from '@salesforce/sdk-core';
|
|
2
|
+
import { ChatSDKOptions } from './index';
|
|
3
|
+
/**
|
|
4
|
+
* Get or create a singleton ChatSDK instance.
|
|
5
|
+
*
|
|
6
|
+
* The first caller may provide options (e.g. surface-specific configuration).
|
|
7
|
+
* Subsequent callers receive the same cached Promise regardless of arguments.
|
|
8
|
+
*
|
|
9
|
+
* The Promise itself is cached (not the resolved value) so concurrent callers
|
|
10
|
+
* do not race to create multiple instances.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Optional configuration (only used on first call)
|
|
13
|
+
* @returns Promise resolving to the shared ChatSDK instance
|
|
14
|
+
*/
|
|
15
|
+
export declare function getChatSDK(options?: ChatSDKOptions): Promise<ChatSDK>;
|
|
16
|
+
/**
|
|
17
|
+
* Synchronously get the singleton ChatSDK instance.
|
|
18
|
+
*
|
|
19
|
+
* Returns the resolved instance if {@link getChatSDK} has already been
|
|
20
|
+
* called and completed, or `null` if not yet initialized. Use this in
|
|
21
|
+
* contexts where async is not available (e.g., imperative mosaic components).
|
|
22
|
+
*
|
|
23
|
+
* @returns The singleton ChatSDK instance, or null if not yet ready
|
|
24
|
+
*/
|
|
25
|
+
export declare function getChatSDKSync(): ChatSDK | null;
|
|
26
|
+
/**
|
|
27
|
+
* Reset the singleton ChatSDK cache.
|
|
28
|
+
*
|
|
29
|
+
* Useful for testing and session reset scenarios.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resetChatSDK(): void;
|
|
32
|
+
//# sourceMappingURL=singleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../src/singleton.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAQrE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,OAAO,GAAG,IAAI,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAGnC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/sdk-chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.116.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test:coverage": "vitest run --coverage"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@salesforce/sdk-core": "^1.
|
|
29
|
+
"@salesforce/sdk-core": "^1.116.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"vite": "^7.3.1",
|