@salesforce/platform-sdk 10.7.0 → 10.9.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/analytics/index.js +1 -1
- package/dist/{analytics-C0LcuEnM.js → analytics-BIpcEJQq.js} +1 -1
- package/dist/capabilities-DtUMG0oZ.js +79 -0
- package/dist/chat/embedding.d.ts +7 -0
- package/dist/chat/embedding.d.ts.map +1 -0
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/index.js +37 -24
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +9 -82
- package/dist/core/surface.d.ts +8 -5
- package/dist/core/surface.d.ts.map +1 -1
- package/dist/data/index.js +9 -8
- package/dist/index.js +32 -30
- package/dist/lightning/embedding.d.ts +7 -0
- package/dist/lightning/embedding.d.ts.map +1 -0
- package/dist/lightning/index.d.ts.map +1 -1
- package/dist/lightning/index.js +17 -5
- package/dist/mcpapps-session-BThDrfRw.js +83 -0
- package/dist/sdk-promise-D0sy7OW1.js +18 -0
- package/dist/sf-embedding/index.d.ts +8 -0
- package/dist/sf-embedding/index.d.ts.map +1 -0
- package/dist/sf-embedding/index.js +48 -0
- package/dist/surface-DX5JCZPQ.js +24 -0
- package/dist/view/embedding.d.ts +7 -0
- package/dist/view/embedding.d.ts.map +1 -0
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +39 -26
- package/package.json +15 -3
- package/dist/mcpapps-session-BOT5CvWa.js +0 -241
- package/dist/sdk-promise-BMDSCpcq.js +0 -38
package/dist/analytics/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { registerInstrumentedApp as I } from "o11y/client";
|
|
2
|
-
import { g as x } from "./
|
|
2
|
+
import { g as x } from "./surface-DX5JCZPQ.js";
|
|
3
3
|
import { getChatSDK as P } from "./chat/index.js";
|
|
4
4
|
import { r as E } from "./TelemetryUploader-DKkdppe9.js";
|
|
5
5
|
import { analyticsContextSchema as h, sessionSchema as S, pageViewSchema as v, errorContextSchema as k, interactionSchema as _, customEventSchema as C } from "o11y_schema/sf_mcpanalytics";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { S as e } from "./surface-DX5JCZPQ.js";
|
|
2
|
+
const s = {
|
|
3
|
+
callTool: !0,
|
|
4
|
+
sendMessageToHost: !0,
|
|
5
|
+
readResource: !0,
|
|
6
|
+
openLink: !0,
|
|
7
|
+
accessToolInput: !0,
|
|
8
|
+
accessToolOutput: !0,
|
|
9
|
+
accessToolMetadata: !0,
|
|
10
|
+
getWidgetState: !0,
|
|
11
|
+
setWidgetState: !0,
|
|
12
|
+
setWidgetStateModelContext: !0,
|
|
13
|
+
onToolCanceled: !0,
|
|
14
|
+
setDisplayMode: !0,
|
|
15
|
+
getHostContext: !0,
|
|
16
|
+
subscribe: !0,
|
|
17
|
+
displayAlert: !0,
|
|
18
|
+
displayToast: !0,
|
|
19
|
+
displayModal: !1,
|
|
20
|
+
// TODO
|
|
21
|
+
getTheme: !0,
|
|
22
|
+
resize: !0
|
|
23
|
+
}, a = {
|
|
24
|
+
callTool: !0,
|
|
25
|
+
sendMessageToHost: !0,
|
|
26
|
+
readResource: !1,
|
|
27
|
+
openLink: !0,
|
|
28
|
+
accessToolInput: !0,
|
|
29
|
+
accessToolOutput: !0,
|
|
30
|
+
accessToolMetadata: !0,
|
|
31
|
+
getWidgetState: !0,
|
|
32
|
+
setWidgetState: !0,
|
|
33
|
+
setWidgetStateModelContext: !1,
|
|
34
|
+
onToolCanceled: !1,
|
|
35
|
+
setDisplayMode: !0,
|
|
36
|
+
getHostContext: !1,
|
|
37
|
+
subscribe: !0,
|
|
38
|
+
displayAlert: !0,
|
|
39
|
+
displayToast: !0,
|
|
40
|
+
displayModal: !0,
|
|
41
|
+
getTheme: !0,
|
|
42
|
+
resize: !1
|
|
43
|
+
}, o = {
|
|
44
|
+
callTool: !1,
|
|
45
|
+
sendMessageToHost: !1,
|
|
46
|
+
readResource: !1,
|
|
47
|
+
openLink: !1,
|
|
48
|
+
accessToolInput: !1,
|
|
49
|
+
accessToolOutput: !1,
|
|
50
|
+
accessToolMetadata: !1,
|
|
51
|
+
getWidgetState: !1,
|
|
52
|
+
setWidgetState: !1,
|
|
53
|
+
setWidgetStateModelContext: !1,
|
|
54
|
+
onToolCanceled: !1,
|
|
55
|
+
setDisplayMode: !1,
|
|
56
|
+
getHostContext: !1,
|
|
57
|
+
subscribe: !1,
|
|
58
|
+
displayAlert: !1,
|
|
59
|
+
displayToast: !1,
|
|
60
|
+
displayModal: !1,
|
|
61
|
+
getTheme: !1,
|
|
62
|
+
resize: !1
|
|
63
|
+
};
|
|
64
|
+
function r(t) {
|
|
65
|
+
switch (t) {
|
|
66
|
+
case e.MCPApps:
|
|
67
|
+
return { ...s };
|
|
68
|
+
case e.OpenAI:
|
|
69
|
+
return { ...a };
|
|
70
|
+
case e.Mosaic:
|
|
71
|
+
case e.WebApp:
|
|
72
|
+
case e.MicroFrontend:
|
|
73
|
+
default:
|
|
74
|
+
return { ...o };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
r as g
|
|
79
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/chat/embedding.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,YAAW,OAAO;IAO3B,OAAO,CAAC,QAAQ,CAAC,OAAO;WAN/B,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAMhD,OAAO;CACP"}
|
package/dist/chat/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/chat/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAK1E;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,iEAAiE;IACjE,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BxE;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,SAAS,CAAC"}
|
package/dist/chat/index.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { M as d } from "../mcpapps-session-
|
|
3
|
-
|
|
1
|
+
import { g as c, S as n } from "../surface-DX5JCZPQ.js";
|
|
2
|
+
import { M as d } from "../mcpapps-session-BThDrfRw.js";
|
|
3
|
+
import { w as p } from "../sdk-promise-D0sy7OW1.js";
|
|
4
|
+
import { requireSharedSession as h } from "../sf-embedding/index.js";
|
|
5
|
+
class a {
|
|
6
|
+
// @ts-expect-error TS6138: `session` is unread until the first method body lands
|
|
7
|
+
constructor(t) {
|
|
8
|
+
this.session = t;
|
|
9
|
+
}
|
|
10
|
+
static async create() {
|
|
11
|
+
const t = await h("EmbeddingChatSDK");
|
|
12
|
+
return new a(t);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
class f {
|
|
4
16
|
constructor(t) {
|
|
5
17
|
this.session = t;
|
|
6
18
|
const e = t.getHostContext();
|
|
@@ -44,7 +56,7 @@ class p {
|
|
|
44
56
|
*/
|
|
45
57
|
handleToolCancelled(t) {
|
|
46
58
|
const o = t.reason ?? "";
|
|
47
|
-
this.canceledCallbacks.forEach((
|
|
59
|
+
this.canceledCallbacks.forEach((u) => u(o));
|
|
48
60
|
}
|
|
49
61
|
/**
|
|
50
62
|
* Request display mode change from host
|
|
@@ -136,8 +148,8 @@ class p {
|
|
|
136
148
|
this.subscriptions.forEach((t) => t());
|
|
137
149
|
}
|
|
138
150
|
}
|
|
139
|
-
const
|
|
140
|
-
class
|
|
151
|
+
const l = "openai:set_globals";
|
|
152
|
+
class g {
|
|
141
153
|
sendMessageToHost(t) {
|
|
142
154
|
return window.openai.sendFollowUpMessage({ prompt: t.content });
|
|
143
155
|
}
|
|
@@ -172,34 +184,35 @@ class h {
|
|
|
172
184
|
}
|
|
173
185
|
subscribe(t) {
|
|
174
186
|
const e = () => t();
|
|
175
|
-
return window.addEventListener(
|
|
176
|
-
window.removeEventListener(
|
|
187
|
+
return window.addEventListener(l, e), () => {
|
|
188
|
+
window.removeEventListener(l, e);
|
|
177
189
|
};
|
|
178
190
|
}
|
|
179
191
|
}
|
|
180
|
-
let i = null,
|
|
181
|
-
function
|
|
182
|
-
return i || (i =
|
|
192
|
+
let i = null, r = null;
|
|
193
|
+
function y(s) {
|
|
194
|
+
return i || (i = w(s).then((t) => (r = t, t))), i;
|
|
183
195
|
}
|
|
184
|
-
function
|
|
185
|
-
return
|
|
196
|
+
function v() {
|
|
197
|
+
return r;
|
|
186
198
|
}
|
|
187
|
-
function
|
|
188
|
-
i = null,
|
|
199
|
+
function M() {
|
|
200
|
+
i = null, r = null;
|
|
189
201
|
}
|
|
190
|
-
function
|
|
191
|
-
return
|
|
202
|
+
function w(s) {
|
|
203
|
+
return p(
|
|
192
204
|
(async () => {
|
|
193
205
|
switch (c(s?.surface)) {
|
|
194
206
|
case n.OpenAI:
|
|
195
|
-
return new
|
|
207
|
+
return new g();
|
|
196
208
|
case n.WebApp:
|
|
197
209
|
case n.Mosaic:
|
|
198
210
|
return {};
|
|
199
211
|
case n.MicroFrontend:
|
|
212
|
+
return a.create();
|
|
200
213
|
case n.MCPApps: {
|
|
201
214
|
const e = await d.getInstance(s?.mcpApps);
|
|
202
|
-
return e.handshakeSucceeded ? new
|
|
215
|
+
return e.handshakeSucceeded ? new f(e) : {};
|
|
203
216
|
}
|
|
204
217
|
default:
|
|
205
218
|
return {};
|
|
@@ -209,9 +222,9 @@ function f(s) {
|
|
|
209
222
|
);
|
|
210
223
|
}
|
|
211
224
|
export {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
225
|
+
f as MCPAppsChatSDK,
|
|
226
|
+
w as createChatSDK,
|
|
227
|
+
y as getChatSDK,
|
|
228
|
+
v as getChatSDKSync,
|
|
229
|
+
M as resetChatSDK
|
|
217
230
|
};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* All rights reserved.
|
|
4
4
|
* For full license text, see the LICENSE.txt file
|
|
5
5
|
*/
|
|
6
|
-
export { Surface, getSurface } from './surface';
|
|
6
|
+
export { Surface, getSurface, isSfEmbeddingIframe } from './surface';
|
|
7
7
|
export type { SDKOptions } from './options';
|
|
8
8
|
export type { HostContext, HostStyles, ChatMessage, ChatSDK, ContentBlock, DeviceCapabilities, DisplayMode, ResourceRequest, SafeAreaInsets, SetWidgetStateOptions, ToolCall, ToolState, } from './chat';
|
|
9
9
|
export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, ViewSDK, } from './view';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5C,YAAY,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,QAAQ,EACR,SAAS,GACT,MAAM,QAAQ,CAAC;AAGhB,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,SAAS,EACT,OAAO,GACP,MAAM,QAAQ,CAAC;AAGhB,YAAY,EACX,YAAY,EACZ,OAAO,EACP,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,aAAa,EACb,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,WAAW,GACX,MAAM,QAAQ,CAAC;AAGhB,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7F,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -1,85 +1,12 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
callTool: !0,
|
|
6
|
-
sendMessageToHost: !0,
|
|
7
|
-
readResource: !0,
|
|
8
|
-
openLink: !0,
|
|
9
|
-
accessToolInput: !0,
|
|
10
|
-
accessToolOutput: !0,
|
|
11
|
-
accessToolMetadata: !0,
|
|
12
|
-
getWidgetState: !0,
|
|
13
|
-
setWidgetState: !0,
|
|
14
|
-
setWidgetStateModelContext: !0,
|
|
15
|
-
onToolCanceled: !0,
|
|
16
|
-
setDisplayMode: !0,
|
|
17
|
-
getHostContext: !0,
|
|
18
|
-
subscribe: !0,
|
|
19
|
-
displayAlert: !0,
|
|
20
|
-
displayToast: !0,
|
|
21
|
-
displayModal: !1,
|
|
22
|
-
// TODO
|
|
23
|
-
getTheme: !0,
|
|
24
|
-
resize: !0
|
|
25
|
-
}, a = {
|
|
26
|
-
callTool: !0,
|
|
27
|
-
sendMessageToHost: !0,
|
|
28
|
-
readResource: !1,
|
|
29
|
-
openLink: !0,
|
|
30
|
-
accessToolInput: !0,
|
|
31
|
-
accessToolOutput: !0,
|
|
32
|
-
accessToolMetadata: !0,
|
|
33
|
-
getWidgetState: !0,
|
|
34
|
-
setWidgetState: !0,
|
|
35
|
-
setWidgetStateModelContext: !1,
|
|
36
|
-
onToolCanceled: !1,
|
|
37
|
-
setDisplayMode: !0,
|
|
38
|
-
getHostContext: !1,
|
|
39
|
-
subscribe: !0,
|
|
40
|
-
displayAlert: !0,
|
|
41
|
-
displayToast: !0,
|
|
42
|
-
displayModal: !0,
|
|
43
|
-
getTheme: !0,
|
|
44
|
-
resize: !1
|
|
45
|
-
}, o = {
|
|
46
|
-
callTool: !1,
|
|
47
|
-
sendMessageToHost: !1,
|
|
48
|
-
readResource: !1,
|
|
49
|
-
openLink: !1,
|
|
50
|
-
accessToolInput: !1,
|
|
51
|
-
accessToolOutput: !1,
|
|
52
|
-
accessToolMetadata: !1,
|
|
53
|
-
getWidgetState: !1,
|
|
54
|
-
setWidgetState: !1,
|
|
55
|
-
setWidgetStateModelContext: !1,
|
|
56
|
-
onToolCanceled: !1,
|
|
57
|
-
setDisplayMode: !1,
|
|
58
|
-
getHostContext: !1,
|
|
59
|
-
subscribe: !1,
|
|
60
|
-
displayAlert: !1,
|
|
61
|
-
displayToast: !1,
|
|
62
|
-
displayModal: !1,
|
|
63
|
-
getTheme: !1,
|
|
64
|
-
resize: !1
|
|
65
|
-
};
|
|
66
|
-
function r(t) {
|
|
67
|
-
switch (t) {
|
|
68
|
-
case e.MCPApps:
|
|
69
|
-
return { ...s };
|
|
70
|
-
case e.OpenAI:
|
|
71
|
-
return { ...a };
|
|
72
|
-
case e.Mosaic:
|
|
73
|
-
case e.WebApp:
|
|
74
|
-
case e.MicroFrontend:
|
|
75
|
-
default:
|
|
76
|
-
return { ...o };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
1
|
+
import { S as a, g as s, i as o } from "../surface-DX5JCZPQ.js";
|
|
2
|
+
import { M as p } from "../mcpapps-session-BThDrfRw.js";
|
|
3
|
+
import { g as m } from "../capabilities-DtUMG0oZ.js";
|
|
4
|
+
import { w as S } from "../sdk-promise-D0sy7OW1.js";
|
|
79
5
|
export {
|
|
80
6
|
p as McpAppsSession,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
7
|
+
a as Surface,
|
|
8
|
+
s as getSurface,
|
|
9
|
+
m as getSurfaceCapabilities,
|
|
10
|
+
o as isSfEmbeddingIframe,
|
|
11
|
+
S as wrapSDKPromise
|
|
85
12
|
};
|
package/dist/core/surface.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* For full license text, see the LICENSE.txt file
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Enumeration of possible runtime surfaces
|
|
8
3
|
*/
|
|
@@ -13,6 +8,14 @@ export declare enum Surface {
|
|
|
13
8
|
MCPApps = "MCP-Apps",
|
|
14
9
|
Mosaic = "Mosaic"
|
|
15
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* True iff the current document is an iframe whose URL carries a valid
|
|
13
|
+
* `hostMetaData` query parameter — i.e., the host LWC populated it during
|
|
14
|
+
* iframe creation. `readHostMetaData` enforces the required `hostAppOrigin`
|
|
15
|
+
* and `instanceId` fields. Cross-origin `window.parent` access throws in
|
|
16
|
+
* some browsers; treat that as not-an-MFE-iframe.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isSfEmbeddingIframe(): boolean;
|
|
16
19
|
/**
|
|
17
20
|
* Returns the surface to use for SDK initialization.
|
|
18
21
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../src/core/surface.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../../src/core/surface.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,oBAAY,OAAO;IAClB,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,MAAM,WAAW;IACjB,OAAO,aAAa;IACpB,MAAM,WAAW;CACjB;AA2BD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAU7C;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAEtD"}
|
package/dist/data/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as L, S as m } from "../surface-DX5JCZPQ.js";
|
|
2
|
+
import { w as x } from "../sdk-promise-D0sy7OW1.js";
|
|
2
3
|
import { buildServiceDescriptor as _, setHeader as y } from "@conduit-client/service-fetch-network/v1";
|
|
3
4
|
import { resolvedPromiseLike as u, ok as w, err as C, stableJSONStringify as V, DataNotFoundError as Q, UserVisibleError as H, deepFreeze as b, isUserVisibleError as G } from "@conduit-client/utils";
|
|
4
5
|
import { print as D, parse as K } from "@conduit-client/onestore-graphql-parser/v1";
|
|
@@ -195,7 +196,7 @@ class ie {
|
|
|
195
196
|
})).structuredContent;
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "10.
|
|
199
|
+
const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "10.9.0", de = (t) => {
|
|
199
200
|
let e = y(ce, he, t);
|
|
200
201
|
return e = y(ue, le, e), u(e);
|
|
201
202
|
}, pe = "X-CSRF-Token";
|
|
@@ -595,16 +596,16 @@ function Me(t) {
|
|
|
595
596
|
let e = t;
|
|
596
597
|
return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
597
598
|
}
|
|
598
|
-
function
|
|
599
|
+
function ze(t, ...e) {
|
|
599
600
|
let r = t[0] ?? "";
|
|
600
601
|
for (let n = 0; n < e.length; n += 1)
|
|
601
602
|
r += String(e[n]) + (t[n + 1] ?? "");
|
|
602
603
|
return r;
|
|
603
604
|
}
|
|
604
|
-
function
|
|
605
|
-
return
|
|
605
|
+
function We(t) {
|
|
606
|
+
return x(
|
|
606
607
|
(async () => {
|
|
607
|
-
switch (
|
|
608
|
+
switch (L(t?.surface)) {
|
|
608
609
|
case m.OpenAI:
|
|
609
610
|
return new ie();
|
|
610
611
|
case m.WebApp:
|
|
@@ -622,6 +623,6 @@ function ze(t) {
|
|
|
622
623
|
);
|
|
623
624
|
}
|
|
624
625
|
export {
|
|
625
|
-
|
|
626
|
-
|
|
626
|
+
We as createDataSDK,
|
|
627
|
+
ze as gql
|
|
627
628
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import { S as t, g as a,
|
|
2
|
-
import { M as p } from "./mcpapps-session-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
1
|
+
import { S as t, g as a, i as o } from "./surface-DX5JCZPQ.js";
|
|
2
|
+
import { M as p } from "./mcpapps-session-BThDrfRw.js";
|
|
3
|
+
import { g as i } from "./capabilities-DtUMG0oZ.js";
|
|
4
|
+
import { w as m } from "./sdk-promise-D0sy7OW1.js";
|
|
5
|
+
import { MCPAppsChatSDK as D, createChatSDK as K, getChatSDK as g, getChatSDKSync as x, resetChatSDK as l } from "./chat/index.js";
|
|
6
|
+
import { MCPAppsViewSDK as C, createViewSDK as T, getViewSDK as w, getViewSDKSync as A, resetViewSDK as P } from "./view/index.js";
|
|
7
|
+
import { createDataSDK as h, gql as y } from "./data/index.js";
|
|
8
|
+
import { createLightningSDK as V } from "./lightning/index.js";
|
|
9
|
+
import { c as u } from "./transport-D8xgRy7y.js";
|
|
10
|
+
import { T as I, r as b } from "./TelemetryUploader-DKkdppe9.js";
|
|
11
|
+
import { A as F, P as L, c as U, v as q } from "./analytics-BIpcEJQq.js";
|
|
11
12
|
export {
|
|
12
13
|
F as AXL_PFT_ID,
|
|
13
14
|
D as MCPAppsChatSDK,
|
|
14
|
-
|
|
15
|
+
C as MCPAppsViewSDK,
|
|
15
16
|
p as McpAppsSession,
|
|
16
|
-
|
|
17
|
+
L as PFT_META_KEY,
|
|
17
18
|
t as Surface,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
I as TelemetryUploader,
|
|
20
|
+
U as createAnalytics,
|
|
21
|
+
K as createChatSDK,
|
|
22
|
+
h as createDataSDK,
|
|
23
|
+
V as createLightningSDK,
|
|
24
|
+
u as createTelemetryTransport,
|
|
25
|
+
T as createViewSDK,
|
|
26
|
+
g as getChatSDK,
|
|
27
|
+
x as getChatSDKSync,
|
|
27
28
|
a as getSurface,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
i as getSurfaceCapabilities,
|
|
30
|
+
w as getViewSDK,
|
|
31
|
+
A as getViewSDKSync,
|
|
32
|
+
y as gql,
|
|
33
|
+
o as isSfEmbeddingIframe,
|
|
34
|
+
b as registerTelemetryUploader,
|
|
35
|
+
l as resetChatSDK,
|
|
36
|
+
P as resetViewSDK,
|
|
37
|
+
q as validatePftId,
|
|
38
|
+
m as wrapSDKPromise
|
|
37
39
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/lightning/embedding.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM5C,qBAAa,qBAAsB,YAAW,YAAY;IAOrC,OAAO,CAAC,QAAQ,CAAC,OAAO;WAN/B,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAMrD,OAAO;CACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lightning/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lightning/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGxD;;GAEG;AAEH,MAAM,WAAW,mBAAoB,SAAQ,UAAU;CAAG;AAE1D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAqBvF;AAED,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/lightning/index.js
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { g as n, S as e } from "../surface-DX5JCZPQ.js";
|
|
2
|
+
import { w as a } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { requireSharedSession as c } from "../sf-embedding/index.js";
|
|
4
|
+
class s {
|
|
5
|
+
// @ts-expect-error TS6138: `session` is unread until the first method body lands
|
|
6
|
+
constructor(r) {
|
|
7
|
+
this.session = r;
|
|
8
|
+
}
|
|
9
|
+
static async create() {
|
|
10
|
+
const r = await c("EmbeddingLightningSDK");
|
|
11
|
+
return new s(r);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function f(t) {
|
|
3
15
|
return a(
|
|
4
16
|
(async () => {
|
|
5
|
-
switch (t
|
|
17
|
+
switch (n(t?.surface)) {
|
|
6
18
|
case e.OpenAI:
|
|
7
19
|
return {};
|
|
8
20
|
case e.WebApp:
|
|
9
21
|
return {};
|
|
10
22
|
case e.MicroFrontend:
|
|
11
|
-
return
|
|
23
|
+
return s.create();
|
|
12
24
|
case e.MCPApps:
|
|
13
25
|
return {};
|
|
14
26
|
case e.Mosaic:
|
|
@@ -21,5 +33,5 @@ function s(r) {
|
|
|
21
33
|
);
|
|
22
34
|
}
|
|
23
35
|
export {
|
|
24
|
-
|
|
36
|
+
f as createLightningSDK
|
|
25
37
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { JsonRpcClient as r, WindowPostMessageTransport as c } from "@salesforce/jsonrpc";
|
|
2
|
+
const h = 500, u = "2026-01-26";
|
|
3
|
+
class i extends r {
|
|
4
|
+
static initPromise = null;
|
|
5
|
+
hostCtx = {};
|
|
6
|
+
_handshakeSucceeded = !1;
|
|
7
|
+
/**
|
|
8
|
+
* Get or create the shared session singleton.
|
|
9
|
+
*
|
|
10
|
+
* The first call performs the SEP-1865 handshake. Concurrent and subsequent
|
|
11
|
+
* calls reuse the same session and handshake result.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Optional configuration. `targetOrigin` defaults to `"*"`
|
|
14
|
+
* when omitted; pin to the concrete MCP host origin whenever known.
|
|
15
|
+
*/
|
|
16
|
+
static async getInstance(t) {
|
|
17
|
+
if (!i.initPromise) {
|
|
18
|
+
const e = t?.targetOrigin ?? "*";
|
|
19
|
+
i.initPromise = (async () => {
|
|
20
|
+
const s = new i(new c(e));
|
|
21
|
+
return await s.handshake(t), s;
|
|
22
|
+
})();
|
|
23
|
+
}
|
|
24
|
+
return i.initPromise;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reset the singleton (for testing only).
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
static resetInstance() {
|
|
31
|
+
i.initPromise = null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
|
|
35
|
+
*
|
|
36
|
+
* On success, stores the host context and sends the initialized notification.
|
|
37
|
+
* On timeout or error, falls back to an empty host context so the app can
|
|
38
|
+
* still render (graceful degradation for non-SEP-1865 hosts).
|
|
39
|
+
*/
|
|
40
|
+
async handshake(t) {
|
|
41
|
+
const e = t?.handshakeTimeoutMs ?? h, s = t?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
|
|
42
|
+
try {
|
|
43
|
+
const a = /* @__PURE__ */ Symbol("timeout"), o = await Promise.race([
|
|
44
|
+
this.request("ui/initialize", {
|
|
45
|
+
protocolVersion: u,
|
|
46
|
+
appInfo: s,
|
|
47
|
+
appCapabilities: {}
|
|
48
|
+
}),
|
|
49
|
+
new Promise((n) => setTimeout(() => n(a), e))
|
|
50
|
+
]);
|
|
51
|
+
o !== a && (this.hostCtx = o.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (n) => {
|
|
52
|
+
this.hostCtx = {
|
|
53
|
+
...this.hostCtx,
|
|
54
|
+
...n
|
|
55
|
+
};
|
|
56
|
+
}), this.sendNotification("ui/notifications/initialized"));
|
|
57
|
+
} catch {
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Returns the current host context (handshake + notification updates). */
|
|
61
|
+
getHostContext() {
|
|
62
|
+
return this.hostCtx;
|
|
63
|
+
}
|
|
64
|
+
/** Whether the ui/initialize handshake completed successfully (not timed out). */
|
|
65
|
+
get handshakeSucceeded() {
|
|
66
|
+
return this._handshakeSucceeded;
|
|
67
|
+
}
|
|
68
|
+
// ── Public wrappers ──────────────────────────────────────────────────
|
|
69
|
+
// Widen access from protected to public so SDK classes can use the
|
|
70
|
+
// shared transport without extending JsonRpcClient themselves.
|
|
71
|
+
request(t, e) {
|
|
72
|
+
return super.request(t, e);
|
|
73
|
+
}
|
|
74
|
+
sendNotification(t, e) {
|
|
75
|
+
super.sendNotification(t, e);
|
|
76
|
+
}
|
|
77
|
+
registerNotificationHandler(t, e) {
|
|
78
|
+
super.registerNotificationHandler(t, e);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
i as M
|
|
83
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const i = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
|
|
2
|
+
function a(s, n) {
|
|
3
|
+
return new Proxy(s, {
|
|
4
|
+
get(o, e, r) {
|
|
5
|
+
if (typeof e == "symbol" || i.has(e)) {
|
|
6
|
+
const t = Reflect.get(o, e, r);
|
|
7
|
+
return typeof t == "function" ? t.bind(o) : t;
|
|
8
|
+
}
|
|
9
|
+
throw new TypeError(
|
|
10
|
+
`\`${n}()\` returns a Promise — did you forget to await it?
|
|
11
|
+
Use \`const sdk = await ${n}();\` before accessing SDK methods.`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
a as w
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SessionHandle } from '@sf-embedding/sf-embedding-bridge';
|
|
2
|
+
/** Thrown when a host-mediated SDK is requested but no session is available. */
|
|
3
|
+
export declare class SfEmbeddingNotAvailableError extends Error {
|
|
4
|
+
constructor(factoryName: string, cause?: Error);
|
|
5
|
+
}
|
|
6
|
+
/** Resolves to the shared session for host-mediated SDKs; rejects if no session is available. */
|
|
7
|
+
export declare function requireSharedSession(factoryName: string): Promise<SessionHandle>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sf-embedding/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,mCAAmC,CAAC;AA+BzF,gFAAgF;AAChF,qBAAa,4BAA6B,SAAQ,KAAK;gBAC1C,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAc9C;AAED,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAoBhF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { bootstrapSession as t } from "@sf-embedding/sf-embedding-bridge";
|
|
2
|
+
import { i } from "../surface-DX5JCZPQ.js";
|
|
3
|
+
let r;
|
|
4
|
+
if (i()) {
|
|
5
|
+
const s = t();
|
|
6
|
+
r = { type: "bootstrapping", promise: s }, s.then(
|
|
7
|
+
(e) => {
|
|
8
|
+
r = { type: "ready", session: e };
|
|
9
|
+
},
|
|
10
|
+
(e) => {
|
|
11
|
+
r = {
|
|
12
|
+
type: "error",
|
|
13
|
+
error: e instanceof Error ? e : new Error(String(e))
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
} else
|
|
18
|
+
r = { type: "non-mfe-env" };
|
|
19
|
+
class o extends Error {
|
|
20
|
+
constructor(e, n) {
|
|
21
|
+
super(
|
|
22
|
+
`${e}: MicroFrontend surface requires an active sf-embedding session. Import "@salesforce/platform-sdk/sf-embedding" at app entry and run inside an sf-embedding iframe.` + (n ? ` Bootstrap failed with: ${n.message}` : "")
|
|
23
|
+
), this.name = "SfEmbeddingNotAvailableError", n && (this.cause = n);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function m(s) {
|
|
27
|
+
switch (r.type) {
|
|
28
|
+
case "non-mfe-env":
|
|
29
|
+
return Promise.reject(new o(s));
|
|
30
|
+
case "error":
|
|
31
|
+
return Promise.reject(
|
|
32
|
+
new o(s, r.error)
|
|
33
|
+
);
|
|
34
|
+
case "bootstrapping":
|
|
35
|
+
return r.promise.catch((e) => {
|
|
36
|
+
throw new o(
|
|
37
|
+
s,
|
|
38
|
+
e instanceof Error ? e : new Error(String(e))
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
case "ready":
|
|
42
|
+
return Promise.resolve(r.session);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
o as SfEmbeddingNotAvailableError,
|
|
47
|
+
m as requireSharedSession
|
|
48
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readHostMetaData as e } from "@sf-embedding/sf-embedding-bridge";
|
|
2
|
+
var r = /* @__PURE__ */ ((n) => (n.WebApp = "WebApp", n.MicroFrontend = "Micro-Frontend", n.OpenAI = "OpenAI", n.MCPApps = "MCP-Apps", n.Mosaic = "Mosaic", n))(r || {});
|
|
3
|
+
const t = i();
|
|
4
|
+
function i() {
|
|
5
|
+
return typeof window > "u" ? "Mosaic" : window.openai ? "OpenAI" : o() ? "Micro-Frontend" : "WebApp";
|
|
6
|
+
}
|
|
7
|
+
function o() {
|
|
8
|
+
if (typeof window > "u") return !1;
|
|
9
|
+
try {
|
|
10
|
+
if (window.parent === window) return !1;
|
|
11
|
+
} catch {
|
|
12
|
+
return !1;
|
|
13
|
+
}
|
|
14
|
+
const n = window.location?.search;
|
|
15
|
+
return typeof n != "string" ? !1 : e(n) !== null;
|
|
16
|
+
}
|
|
17
|
+
function f(n) {
|
|
18
|
+
return n ?? t;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
r as S,
|
|
22
|
+
f as g,
|
|
23
|
+
o as i
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../src/view/embedding.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC,qBAAa,gBAAiB,YAAW,OAAO;IAO3B,OAAO,CAAC,QAAQ,CAAC,OAAO;WAN/B,MAAM,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAMhD,OAAO;CACP"}
|
package/dist/view/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAK1E;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,UAAU;IACjD,iEAAiE;IACjE,OAAO,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BxE;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEvE,YAAY,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,KAAK,EACL,SAAS,EACT,YAAY,EACZ,OAAO,GACP,MAAM,SAAS,CAAC"}
|
package/dist/view/index.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { M as
|
|
3
|
-
|
|
1
|
+
import { g as d, S as a } from "../surface-DX5JCZPQ.js";
|
|
2
|
+
import { M as p } from "../mcpapps-session-BThDrfRw.js";
|
|
3
|
+
import { w as f } from "../sdk-promise-D0sy7OW1.js";
|
|
4
|
+
import { requireSharedSession as w } from "../sf-embedding/index.js";
|
|
5
|
+
class u {
|
|
6
|
+
// @ts-expect-error TS6138: `session` is unread until the first method body lands
|
|
7
|
+
constructor(e) {
|
|
8
|
+
this.session = e;
|
|
9
|
+
}
|
|
10
|
+
static async create() {
|
|
11
|
+
const e = await w("EmbeddingViewSDK");
|
|
12
|
+
return new u(e);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function h(s) {
|
|
4
16
|
switch (s) {
|
|
5
17
|
case "info":
|
|
6
18
|
return "ℹ️";
|
|
@@ -15,9 +27,9 @@ function f(s) {
|
|
|
15
27
|
}
|
|
16
28
|
}
|
|
17
29
|
function c(s, e) {
|
|
18
|
-
return `${
|
|
30
|
+
return `${h(e)} ${s}`;
|
|
19
31
|
}
|
|
20
|
-
function
|
|
32
|
+
function m(s, e) {
|
|
21
33
|
const t = s.trim();
|
|
22
34
|
if (t === "")
|
|
23
35
|
return { success: !0, value: void 0 };
|
|
@@ -33,7 +45,7 @@ function l(s, e) {
|
|
|
33
45
|
error: `Invalid ${e}: "${s}". Value must be a positive number.`
|
|
34
46
|
} : { success: !0, value: n };
|
|
35
47
|
}
|
|
36
|
-
class
|
|
48
|
+
class g {
|
|
37
49
|
constructor(e) {
|
|
38
50
|
this.session = e;
|
|
39
51
|
}
|
|
@@ -68,17 +80,17 @@ class w {
|
|
|
68
80
|
return e ? { mode: e } : null;
|
|
69
81
|
}
|
|
70
82
|
async resize(e, t) {
|
|
71
|
-
const r =
|
|
83
|
+
const r = m(e, "width");
|
|
72
84
|
if (!r.success)
|
|
73
85
|
return Promise.reject(new Error(r.error));
|
|
74
|
-
const n =
|
|
86
|
+
const n = m(t, "height");
|
|
75
87
|
if (!n.success)
|
|
76
88
|
return Promise.reject(new Error(n.error));
|
|
77
89
|
const o = {};
|
|
78
90
|
return r.value !== void 0 && (o.width = r.value), n.value !== void 0 && (o.height = n.value), this.session.sendNotification("ui/notifications/size-changed", o), Promise.resolve();
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
|
-
class
|
|
93
|
+
class v {
|
|
82
94
|
async displayAlert(e) {
|
|
83
95
|
const t = e.level || "info", r = c(e.message, t);
|
|
84
96
|
await window.openai.sendFollowUpMessage({ prompt: r });
|
|
@@ -98,29 +110,30 @@ class h {
|
|
|
98
110
|
return e ? { mode: e } : null;
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
|
-
let i = null,
|
|
102
|
-
function
|
|
103
|
-
return i || (i =
|
|
113
|
+
let i = null, l = null;
|
|
114
|
+
function A(s) {
|
|
115
|
+
return i || (i = y(s).then((e) => (l = e, e))), i;
|
|
104
116
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
117
|
+
function K() {
|
|
118
|
+
return l;
|
|
107
119
|
}
|
|
108
|
-
function
|
|
109
|
-
i = null,
|
|
120
|
+
function P() {
|
|
121
|
+
i = null, l = null;
|
|
110
122
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
123
|
+
function y(s) {
|
|
124
|
+
return f(
|
|
113
125
|
(async () => {
|
|
114
126
|
switch (d(s?.surface)) {
|
|
115
127
|
case a.OpenAI:
|
|
116
|
-
return new
|
|
128
|
+
return new v();
|
|
117
129
|
case a.WebApp:
|
|
118
130
|
case a.Mosaic:
|
|
119
131
|
return {};
|
|
120
132
|
case a.MicroFrontend:
|
|
133
|
+
return u.create();
|
|
121
134
|
case a.MCPApps: {
|
|
122
|
-
const t = await
|
|
123
|
-
return t.handshakeSucceeded ? new
|
|
135
|
+
const t = await p.getInstance(s?.mcpApps);
|
|
136
|
+
return t.handshakeSucceeded ? new g(t) : {};
|
|
124
137
|
}
|
|
125
138
|
default:
|
|
126
139
|
return {};
|
|
@@ -130,9 +143,9 @@ function g(s) {
|
|
|
130
143
|
);
|
|
131
144
|
}
|
|
132
145
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
g as MCPAppsViewSDK,
|
|
147
|
+
y as createViewSDK,
|
|
148
|
+
A as getViewSDK,
|
|
149
|
+
K as getViewSDKSync,
|
|
150
|
+
P as resetViewSDK
|
|
138
151
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.9.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
|
-
"sideEffects":
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/sf-embedding/index.js",
|
|
11
|
+
"./src/sf-embedding/index.ts"
|
|
12
|
+
],
|
|
10
13
|
"typesVersions": {
|
|
11
14
|
"*": {
|
|
12
15
|
"core": [
|
|
@@ -29,6 +32,9 @@
|
|
|
29
32
|
],
|
|
30
33
|
"analytics": [
|
|
31
34
|
"./dist/analytics/index.d.ts"
|
|
35
|
+
],
|
|
36
|
+
"sf-embedding": [
|
|
37
|
+
"./dist/sf-embedding/index.d.ts"
|
|
32
38
|
]
|
|
33
39
|
}
|
|
34
40
|
},
|
|
@@ -73,6 +79,11 @@
|
|
|
73
79
|
"import": "./dist/analytics/index.js",
|
|
74
80
|
"default": "./dist/analytics/index.js"
|
|
75
81
|
},
|
|
82
|
+
"./sf-embedding": {
|
|
83
|
+
"types": "./dist/sf-embedding/index.d.ts",
|
|
84
|
+
"import": "./dist/sf-embedding/index.js",
|
|
85
|
+
"default": "./dist/sf-embedding/index.js"
|
|
86
|
+
},
|
|
76
87
|
"./package.json": "./package.json"
|
|
77
88
|
},
|
|
78
89
|
"files": [
|
|
@@ -96,7 +107,8 @@
|
|
|
96
107
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
97
108
|
"@conduit-client/service-retry": "3.19.6",
|
|
98
109
|
"@conduit-client/utils": "3.19.6",
|
|
99
|
-
"@salesforce/jsonrpc": "^10.
|
|
110
|
+
"@salesforce/jsonrpc": "^10.9.0",
|
|
111
|
+
"@sf-embedding/sf-embedding-bridge": "2.2.1-rc.4"
|
|
100
112
|
},
|
|
101
113
|
"peerDependencies": {
|
|
102
114
|
"o11y": ">=260.0.0",
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
function d(n) {
|
|
2
|
-
return typeof n == "object" && n !== null && !Array.isArray(n);
|
|
3
|
-
}
|
|
4
|
-
function u(n) {
|
|
5
|
-
return typeof n.id == "number" && Number.isInteger(n.id) && n.id >= 0;
|
|
6
|
-
}
|
|
7
|
-
function c(n) {
|
|
8
|
-
return d(n) && n.jsonrpc === "2.0";
|
|
9
|
-
}
|
|
10
|
-
function f(n) {
|
|
11
|
-
if (!c(n)) return !1;
|
|
12
|
-
const t = n;
|
|
13
|
-
return !("id" in t) && typeof t.method == "string";
|
|
14
|
-
}
|
|
15
|
-
function l(n) {
|
|
16
|
-
if (!c(n)) return !1;
|
|
17
|
-
const t = n;
|
|
18
|
-
return u(t) && "result" in t && !("error" in t) && !("method" in t);
|
|
19
|
-
}
|
|
20
|
-
function h(n) {
|
|
21
|
-
if (!c(n)) return !1;
|
|
22
|
-
const t = n;
|
|
23
|
-
if (!u(t) || "result" in t || "method" in t) return !1;
|
|
24
|
-
const e = t.error;
|
|
25
|
-
return d(e) && typeof e.code == "number";
|
|
26
|
-
}
|
|
27
|
-
function g(n) {
|
|
28
|
-
return l(n) || h(n);
|
|
29
|
-
}
|
|
30
|
-
class m {
|
|
31
|
-
nextRequestId = 1;
|
|
32
|
-
pending = /* @__PURE__ */ new Map();
|
|
33
|
-
notificationHandlers = /* @__PURE__ */ new Map();
|
|
34
|
-
transport;
|
|
35
|
-
/**
|
|
36
|
-
* Construct a JSON-RPC client bound to the given transport.
|
|
37
|
-
*
|
|
38
|
-
* @param transport - the transport to use.
|
|
39
|
-
*/
|
|
40
|
-
constructor(t) {
|
|
41
|
-
this.transport = t, this.transport.onMessage(this.onMessage);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Register a handler for a specific JSON-RPC notification method.
|
|
45
|
-
*
|
|
46
|
-
* Subclasses can register handlers to process specific notification
|
|
47
|
-
* types. When a notification with the registered method is received,
|
|
48
|
-
* the handler will be invoked with the notification params.
|
|
49
|
-
*
|
|
50
|
-
* @param method - The notification method to handle (e.g.
|
|
51
|
-
* "ui/notifications/host-context-changed")
|
|
52
|
-
* @param handler - Callback function to process the notification params
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* this.registerNotificationHandler("ui/notifications/host-context-changed", (params) => {
|
|
56
|
-
* this.handleHostContextChanged(params);
|
|
57
|
-
* });
|
|
58
|
-
*/
|
|
59
|
-
registerNotificationHandler(t, e) {
|
|
60
|
-
this.notificationHandlers.has(t) || this.notificationHandlers.set(t, /* @__PURE__ */ new Set()), this.notificationHandlers.get(t).add(e);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Handle inbound JSON-RPC messages from the transport.
|
|
64
|
-
*
|
|
65
|
-
* Processes both responses (for requests) and notifications.
|
|
66
|
-
* Non-JSON-RPC payloads are silently ignored so that a shared transport
|
|
67
|
-
* can be used for multiple protocols without cross-talk.
|
|
68
|
-
*/
|
|
69
|
-
onMessage = (t) => {
|
|
70
|
-
if (g(t)) {
|
|
71
|
-
const e = this.pending.get(t.id);
|
|
72
|
-
if (!e)
|
|
73
|
-
return;
|
|
74
|
-
this.pending.delete(t.id), h(t) ? e.reject(new Error(t.error.message || "Request failed")) : e.resolve(t.result);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (f(t)) {
|
|
78
|
-
const e = this.notificationHandlers.get(t.method);
|
|
79
|
-
e && e.forEach((i) => i(t.params));
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Send a JSON-RPC request to the peer.
|
|
84
|
-
*
|
|
85
|
-
* @param method - The JSON-RPC method name
|
|
86
|
-
* @param params - The method parameters
|
|
87
|
-
* @returns Promise that resolves with the result or rejects with error
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* const result = await this.request("ui/message", {
|
|
91
|
-
* role: "user",
|
|
92
|
-
* content: { type: "text", text: "Hello" }
|
|
93
|
-
* });
|
|
94
|
-
*/
|
|
95
|
-
request(t, e) {
|
|
96
|
-
const i = this.nextRequestId++, o = {
|
|
97
|
-
jsonrpc: "2.0",
|
|
98
|
-
id: i,
|
|
99
|
-
method: t,
|
|
100
|
-
params: e
|
|
101
|
-
};
|
|
102
|
-
return new Promise((a, s) => {
|
|
103
|
-
this.pending.set(i, {
|
|
104
|
-
resolve: a,
|
|
105
|
-
reject: s
|
|
106
|
-
}), this.transport.post(o);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Send a JSON-RPC notification to the peer.
|
|
111
|
-
*
|
|
112
|
-
* Notifications are one-way messages that do not expect a response.
|
|
113
|
-
* Use notifications for:
|
|
114
|
-
* - Informing the host of state changes
|
|
115
|
-
* - Fire-and-forget operations
|
|
116
|
-
* - Events that don't require confirmation
|
|
117
|
-
*
|
|
118
|
-
* Use request() instead when you need:
|
|
119
|
-
* - A response from the host
|
|
120
|
-
* - Confirmation of success/failure
|
|
121
|
-
* - Return values from the operation
|
|
122
|
-
*
|
|
123
|
-
* @param method - The JSON-RPC method name
|
|
124
|
-
* @param params - Optional method parameters
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* this.sendNotification("ui/notifications/size-changed", {
|
|
128
|
-
* width: 800,
|
|
129
|
-
* height: 600
|
|
130
|
-
* });
|
|
131
|
-
*/
|
|
132
|
-
sendNotification(t, e) {
|
|
133
|
-
const i = {
|
|
134
|
-
jsonrpc: "2.0",
|
|
135
|
-
method: t,
|
|
136
|
-
params: e
|
|
137
|
-
};
|
|
138
|
-
this.transport.post(i);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
class p {
|
|
142
|
-
targetOrigin;
|
|
143
|
-
/**
|
|
144
|
-
* @param targetOrigin - origin passed as the second argument to
|
|
145
|
-
* `window.parent.postMessage`.
|
|
146
|
-
*/
|
|
147
|
-
constructor(t) {
|
|
148
|
-
this.targetOrigin = t;
|
|
149
|
-
}
|
|
150
|
-
post(t) {
|
|
151
|
-
window.parent?.postMessage(t, this.targetOrigin);
|
|
152
|
-
}
|
|
153
|
-
onMessage(t) {
|
|
154
|
-
const e = (i) => {
|
|
155
|
-
t(i.data);
|
|
156
|
-
};
|
|
157
|
-
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const w = 500, x = "2026-01-26";
|
|
161
|
-
class r extends m {
|
|
162
|
-
static initPromise = null;
|
|
163
|
-
hostCtx = {};
|
|
164
|
-
_handshakeSucceeded = !1;
|
|
165
|
-
/**
|
|
166
|
-
* Get or create the shared session singleton.
|
|
167
|
-
*
|
|
168
|
-
* The first call performs the SEP-1865 handshake. Concurrent and subsequent
|
|
169
|
-
* calls reuse the same session and handshake result.
|
|
170
|
-
*
|
|
171
|
-
* @param options - Optional configuration. `targetOrigin` defaults to `"*"`
|
|
172
|
-
* when omitted; pin to the concrete MCP host origin whenever known.
|
|
173
|
-
*/
|
|
174
|
-
static async getInstance(t) {
|
|
175
|
-
if (!r.initPromise) {
|
|
176
|
-
const e = t?.targetOrigin ?? "*";
|
|
177
|
-
r.initPromise = (async () => {
|
|
178
|
-
const i = new r(new p(e));
|
|
179
|
-
return await i.handshake(t), i;
|
|
180
|
-
})();
|
|
181
|
-
}
|
|
182
|
-
return r.initPromise;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Reset the singleton (for testing only).
|
|
186
|
-
* @internal
|
|
187
|
-
*/
|
|
188
|
-
static resetInstance() {
|
|
189
|
-
r.initPromise = null;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
|
|
193
|
-
*
|
|
194
|
-
* On success, stores the host context and sends the initialized notification.
|
|
195
|
-
* On timeout or error, falls back to an empty host context so the app can
|
|
196
|
-
* still render (graceful degradation for non-SEP-1865 hosts).
|
|
197
|
-
*/
|
|
198
|
-
async handshake(t) {
|
|
199
|
-
const e = t?.handshakeTimeoutMs ?? w, i = t?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
|
|
200
|
-
try {
|
|
201
|
-
const o = /* @__PURE__ */ Symbol("timeout"), a = await Promise.race([
|
|
202
|
-
this.request("ui/initialize", {
|
|
203
|
-
protocolVersion: x,
|
|
204
|
-
appInfo: i,
|
|
205
|
-
appCapabilities: {}
|
|
206
|
-
}),
|
|
207
|
-
new Promise((s) => setTimeout(() => s(o), e))
|
|
208
|
-
]);
|
|
209
|
-
a !== o && (this.hostCtx = a.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (s) => {
|
|
210
|
-
this.hostCtx = {
|
|
211
|
-
...this.hostCtx,
|
|
212
|
-
...s
|
|
213
|
-
};
|
|
214
|
-
}), this.sendNotification("ui/notifications/initialized"));
|
|
215
|
-
} catch {
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/** Returns the current host context (handshake + notification updates). */
|
|
219
|
-
getHostContext() {
|
|
220
|
-
return this.hostCtx;
|
|
221
|
-
}
|
|
222
|
-
/** Whether the ui/initialize handshake completed successfully (not timed out). */
|
|
223
|
-
get handshakeSucceeded() {
|
|
224
|
-
return this._handshakeSucceeded;
|
|
225
|
-
}
|
|
226
|
-
// ── Public wrappers ──────────────────────────────────────────────────
|
|
227
|
-
// Widen access from protected to public so SDK classes can use the
|
|
228
|
-
// shared transport without extending JsonRpcClient themselves.
|
|
229
|
-
request(t, e) {
|
|
230
|
-
return super.request(t, e);
|
|
231
|
-
}
|
|
232
|
-
sendNotification(t, e) {
|
|
233
|
-
super.sendNotification(t, e);
|
|
234
|
-
}
|
|
235
|
-
registerNotificationHandler(t, e) {
|
|
236
|
-
super.registerNotificationHandler(t, e);
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export {
|
|
240
|
-
r as M
|
|
241
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var s = /* @__PURE__ */ ((e) => (e.WebApp = "WebApp", e.MicroFrontend = "Micro-Frontend", e.OpenAI = "OpenAI", e.MCPApps = "MCP-Apps", e.Mosaic = "Mosaic", e))(s || {});
|
|
2
|
-
const c = p();
|
|
3
|
-
function p() {
|
|
4
|
-
if (typeof window > "u")
|
|
5
|
-
return "Mosaic";
|
|
6
|
-
if (window.openai)
|
|
7
|
-
return "OpenAI";
|
|
8
|
-
try {
|
|
9
|
-
if (window.self !== window.top)
|
|
10
|
-
return "Micro-Frontend";
|
|
11
|
-
} catch {
|
|
12
|
-
return "Micro-Frontend";
|
|
13
|
-
}
|
|
14
|
-
return "WebApp";
|
|
15
|
-
}
|
|
16
|
-
function d(e) {
|
|
17
|
-
return e ?? c;
|
|
18
|
-
}
|
|
19
|
-
const a = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
|
|
20
|
-
function u(e, o) {
|
|
21
|
-
return new Proxy(e, {
|
|
22
|
-
get(r, n, i) {
|
|
23
|
-
if (typeof n == "symbol" || a.has(n)) {
|
|
24
|
-
const t = Reflect.get(r, n, i);
|
|
25
|
-
return typeof t == "function" ? t.bind(r) : t;
|
|
26
|
-
}
|
|
27
|
-
throw new TypeError(
|
|
28
|
-
`\`${o}()\` returns a Promise — did you forget to await it?
|
|
29
|
-
Use \`const sdk = await ${o}();\` before accessing SDK methods.`
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
export {
|
|
35
|
-
s as S,
|
|
36
|
-
d as g,
|
|
37
|
-
u as w
|
|
38
|
-
};
|