@salesforce/platform-sdk 10.24.0 → 11.1.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/analytics.d.ts.map +1 -1
- package/dist/analytics/index.js +1 -1
- package/dist/analytics-ygoSv0Cj.js +157 -0
- package/dist/{capabilities-DtUMG0oZ.js → capabilities-CBmOyHnc.js} +1 -1
- package/dist/chat/index.d.ts +13 -6
- package/dist/chat/index.d.ts.map +1 -1
- package/dist/chat/index.js +24 -25
- package/dist/core/index.d.ts +3 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -9
- package/dist/core/mcpapps-session.d.ts +15 -1
- package/dist/core/mcpapps-session.d.ts.map +1 -1
- package/dist/core/surface.d.ts +79 -4
- package/dist/core/surface.d.ts.map +1 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/index.js +22 -18
- package/dist/index.js +36 -34
- package/dist/lightning/index.d.ts.map +1 -1
- package/dist/lightning/index.js +22 -16
- package/dist/sf-embedding/index.js +1 -1
- package/dist/surface-CEErnCgI.js +144 -0
- package/dist/view/index.d.ts +13 -6
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +53 -50
- package/package.json +2 -2
- package/dist/analytics-Cgt83u0I.js +0 -146
- package/dist/mcpapps-session-BThDrfRw.js +0 -83
- package/dist/surface-DX5JCZPQ.js +0 -24
package/dist/lightning/index.js
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { w as
|
|
1
|
+
import { g as a, S as r } from "../surface-CEErnCgI.js";
|
|
2
|
+
import { w as n } from "../sdk-promise-D0sy7OW1.js";
|
|
3
3
|
import { requireSharedSession as c } from "../sf-embedding/index.js";
|
|
4
|
-
class
|
|
4
|
+
class t {
|
|
5
5
|
// @ts-expect-error TS6138: `session` is unread until the first method body lands
|
|
6
|
-
constructor(
|
|
7
|
-
this.session =
|
|
6
|
+
constructor(e) {
|
|
7
|
+
this.session = e;
|
|
8
8
|
}
|
|
9
9
|
static async create() {
|
|
10
|
-
const
|
|
11
|
-
return new
|
|
10
|
+
const e = await c("EmbeddingLightningSDK");
|
|
11
|
+
return new t(e);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
function f(
|
|
15
|
-
return
|
|
14
|
+
function f(s) {
|
|
15
|
+
return n(
|
|
16
16
|
(async () => {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
let e;
|
|
18
|
+
try {
|
|
19
|
+
e = await a(s?.surface);
|
|
20
|
+
} catch {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
switch (e) {
|
|
24
|
+
case r.OpenAI:
|
|
19
25
|
return {};
|
|
20
|
-
case
|
|
26
|
+
case r.WebApp:
|
|
21
27
|
return {};
|
|
22
|
-
case
|
|
23
|
-
return
|
|
24
|
-
case
|
|
28
|
+
case r.MicroFrontend:
|
|
29
|
+
return t.create();
|
|
30
|
+
case r.MCPApps:
|
|
25
31
|
return {};
|
|
26
|
-
case
|
|
32
|
+
case r.Mosaic:
|
|
27
33
|
return {};
|
|
28
34
|
default:
|
|
29
35
|
return {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { readHostMetaData as p } from "@sf-embedding/sf-embedding-bridge";
|
|
2
|
+
import { JsonRpcClient as d, WindowPostMessageTransport as f } from "@salesforce/jsonrpc";
|
|
3
|
+
class h extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(
|
|
6
|
+
"MCPApps surface requires a completed SEP-1865 handshake, but it has not succeeded. This usually means `{ surface: Surface.MCPApps }` was forced outside a real MCP Apps host, or the handshake timed out. Omit the surface override to let detection fall back gracefully."
|
|
7
|
+
), this.name = "McpAppsNotAvailableError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const l = 500, m = "2026-01-26";
|
|
11
|
+
class s extends d {
|
|
12
|
+
static initPromise = null;
|
|
13
|
+
hostCtx = {};
|
|
14
|
+
_handshakeSucceeded = !1;
|
|
15
|
+
/**
|
|
16
|
+
* Get or create the shared session singleton.
|
|
17
|
+
*
|
|
18
|
+
* The first call performs the SEP-1865 handshake. Concurrent and subsequent
|
|
19
|
+
* calls reuse the same session and handshake result.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Optional configuration. `targetOrigin` defaults to `"*"`
|
|
22
|
+
* when omitted; pin to the concrete MCP host origin whenever known.
|
|
23
|
+
*/
|
|
24
|
+
static async getInstance(t) {
|
|
25
|
+
if (!s.initPromise) {
|
|
26
|
+
const n = t?.targetOrigin ?? "*";
|
|
27
|
+
s.initPromise = (async () => {
|
|
28
|
+
const i = new s(new f(n));
|
|
29
|
+
return await i.handshake(t), i;
|
|
30
|
+
})();
|
|
31
|
+
}
|
|
32
|
+
return s.initPromise;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reset the singleton (for testing only).
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
static resetInstance() {
|
|
39
|
+
s.initPromise = null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
|
|
43
|
+
*
|
|
44
|
+
* On success, stores the host context and sends the initialized notification.
|
|
45
|
+
* On timeout or error, falls back to an empty host context so the app can
|
|
46
|
+
* still render (graceful degradation for non-SEP-1865 hosts).
|
|
47
|
+
*/
|
|
48
|
+
async handshake(t) {
|
|
49
|
+
const n = t?.handshakeTimeoutMs ?? l, i = t?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
|
|
50
|
+
try {
|
|
51
|
+
const c = /* @__PURE__ */ Symbol("timeout"), u = await Promise.race([
|
|
52
|
+
this.request("ui/initialize", {
|
|
53
|
+
protocolVersion: m,
|
|
54
|
+
appInfo: i,
|
|
55
|
+
appCapabilities: {}
|
|
56
|
+
}),
|
|
57
|
+
new Promise((o) => setTimeout(() => o(c), n))
|
|
58
|
+
]);
|
|
59
|
+
u !== c && (this.hostCtx = u.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (o) => {
|
|
60
|
+
this.hostCtx = {
|
|
61
|
+
...this.hostCtx,
|
|
62
|
+
...o
|
|
63
|
+
};
|
|
64
|
+
}), this.sendNotification("ui/notifications/initialized"));
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Returns the current host context (handshake + notification updates). */
|
|
69
|
+
getHostContext() {
|
|
70
|
+
return this.hostCtx;
|
|
71
|
+
}
|
|
72
|
+
/** Whether the ui/initialize handshake completed successfully (not timed out). */
|
|
73
|
+
get handshakeSucceeded() {
|
|
74
|
+
return this._handshakeSucceeded;
|
|
75
|
+
}
|
|
76
|
+
// ── Public wrappers ──────────────────────────────────────────────────
|
|
77
|
+
// Widen access from protected to public so SDK classes can use the
|
|
78
|
+
// shared transport without extending JsonRpcClient themselves.
|
|
79
|
+
request(t, n) {
|
|
80
|
+
return super.request(t, n);
|
|
81
|
+
}
|
|
82
|
+
sendNotification(t, n) {
|
|
83
|
+
super.sendNotification(t, n);
|
|
84
|
+
}
|
|
85
|
+
registerNotificationHandler(t, n) {
|
|
86
|
+
super.registerNotificationHandler(t, n);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
var w = /* @__PURE__ */ ((e) => (e.WebApp = "WebApp", e.MicroFrontend = "Micro-Frontend", e.OpenAI = "OpenAI", e.MCPApps = "MCP-Apps", e.Mosaic = "Mosaic", e))(w || {});
|
|
90
|
+
let r = null, a;
|
|
91
|
+
function g(e, t) {
|
|
92
|
+
const n = e ?? {}, i = t ?? {};
|
|
93
|
+
return n.targetOrigin === i.targetOrigin && n.handshakeTimeoutMs === i.handshakeTimeoutMs && n.appInfo?.name === i.appInfo?.name && n.appInfo?.version === i.appInfo?.version;
|
|
94
|
+
}
|
|
95
|
+
async function A() {
|
|
96
|
+
return typeof window > "u" ? "Mosaic" : window.openai ? "OpenAI" : y() ? P() ? "Micro-Frontend" : (await s.getInstance(a)).handshakeSucceeded ? "MCP-Apps" : "WebApp" : "WebApp";
|
|
97
|
+
}
|
|
98
|
+
async function M(e) {
|
|
99
|
+
if (!r)
|
|
100
|
+
a = e?.mcpApps, r = A();
|
|
101
|
+
else if (e?.mcpApps && !g(e.mcpApps, a))
|
|
102
|
+
throw new Error(
|
|
103
|
+
"initialize() was already called with different MCP Apps options. The MCP Apps session is per-page and configured once: call initialize() with your options before creating any SDK (SDK factories auto-initialize with defaults, which can pre-empt a later call)."
|
|
104
|
+
);
|
|
105
|
+
return r;
|
|
106
|
+
}
|
|
107
|
+
function y() {
|
|
108
|
+
if (typeof window > "u") return !1;
|
|
109
|
+
try {
|
|
110
|
+
return window.parent !== window;
|
|
111
|
+
} catch {
|
|
112
|
+
return !0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function P() {
|
|
116
|
+
if (typeof window > "u") return !1;
|
|
117
|
+
try {
|
|
118
|
+
if (window.parent === window) return !1;
|
|
119
|
+
} catch {
|
|
120
|
+
return !1;
|
|
121
|
+
}
|
|
122
|
+
const e = window.location?.search;
|
|
123
|
+
return typeof e != "string" ? !1 : p(e) !== null;
|
|
124
|
+
}
|
|
125
|
+
async function O(e) {
|
|
126
|
+
const t = await M();
|
|
127
|
+
if (e == null)
|
|
128
|
+
return t;
|
|
129
|
+
if (e === "MCP-Apps" && !(await s.getInstance(a)).handshakeSucceeded)
|
|
130
|
+
throw new h();
|
|
131
|
+
return e;
|
|
132
|
+
}
|
|
133
|
+
function k() {
|
|
134
|
+
r = null, a = void 0, s.resetInstance();
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
h as M,
|
|
138
|
+
w as S,
|
|
139
|
+
s as a,
|
|
140
|
+
P as b,
|
|
141
|
+
O as g,
|
|
142
|
+
M as i,
|
|
143
|
+
k as r
|
|
144
|
+
};
|
package/dist/view/index.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { SDKOptions, ViewSDK
|
|
1
|
+
import { SDKOptions, ViewSDK } from '../core';
|
|
2
2
|
/**
|
|
3
3
|
* Options for creating a ViewSDK instance.
|
|
4
|
+
*
|
|
5
|
+
* MCP Apps session configuration (target origin, app identity, handshake
|
|
6
|
+
* timeout) lives on {@link initialize}, not here — it is a per-page setting,
|
|
7
|
+
* not a per-SDK one.
|
|
4
8
|
*/
|
|
5
9
|
export interface ViewSDKOptions extends SDKOptions {
|
|
6
|
-
/** MCP Apps session options (app identity, handshake timeout) */
|
|
7
|
-
mcpApps?: McpAppsSessionOptions;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
|
-
* Create and initialize a ViewSDK instance based on the detected surface
|
|
12
|
+
* Create and initialize a ViewSDK instance based on the detected surface.
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Never rejects on an unusable surface: every surface degrades to an empty SDK
|
|
15
|
+
* so an embedding host always renders. This covers both the central liveness
|
|
16
|
+
* check in {@link getVerifiedSurface} (e.g. MCPApps forced via `options.surface`
|
|
17
|
+
* without a successful SEP-1865 handshake) and a surface-specific construction
|
|
18
|
+
* failure such as the MicroFrontend branch's {@link SfEmbeddingNotAvailableError}
|
|
19
|
+
* (no active sf-embedding session) — both are caught and degrade rather than
|
|
20
|
+
* propagate.
|
|
14
21
|
*
|
|
15
22
|
* @param options - Optional configuration including surface override
|
|
16
23
|
* @returns Promise resolving to an initialized ViewSDK instance
|
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKnD;;;;;;GAMG;AAEH,MAAM,WAAW,cAAe,SAAQ,UAAU;CAAG;AAErD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAgCxE;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,19 +1,18 @@
|
|
|
1
|
-
import { g as d, S as a } from "../surface-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { requireSharedSession as w } from "../sf-embedding/index.js";
|
|
1
|
+
import { g as d, S as a, a as p } from "../surface-CEErnCgI.js";
|
|
2
|
+
import { w } from "../sdk-promise-D0sy7OW1.js";
|
|
3
|
+
import { requireSharedSession as f } from "../sf-embedding/index.js";
|
|
5
4
|
class u {
|
|
6
5
|
// @ts-expect-error TS6138: `session` is unread until the first method body lands
|
|
7
6
|
constructor(e) {
|
|
8
7
|
this.session = e;
|
|
9
8
|
}
|
|
10
9
|
static async create() {
|
|
11
|
-
const e = await
|
|
10
|
+
const e = await f("EmbeddingViewSDK");
|
|
12
11
|
return new u(e);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
|
-
function h(
|
|
16
|
-
switch (
|
|
14
|
+
function h(t) {
|
|
15
|
+
switch (t) {
|
|
17
16
|
case "info":
|
|
18
17
|
return "ℹ️";
|
|
19
18
|
case "success":
|
|
@@ -26,23 +25,23 @@ function h(s) {
|
|
|
26
25
|
return "ℹ️";
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
function c(
|
|
30
|
-
return `${h(e)} ${
|
|
28
|
+
function c(t, e) {
|
|
29
|
+
return `${h(e)} ${t}`;
|
|
31
30
|
}
|
|
32
|
-
function m(
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
31
|
+
function m(t, e) {
|
|
32
|
+
const r = t.trim();
|
|
33
|
+
if (r === "")
|
|
35
34
|
return { success: !0, value: void 0 };
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
35
|
+
const s = r.match(/^(\d+(?:\.\d+)?)(px)?$/);
|
|
36
|
+
if (!s || !s[1])
|
|
38
37
|
return {
|
|
39
38
|
success: !1,
|
|
40
|
-
error: `Invalid ${e}: "${
|
|
39
|
+
error: `Invalid ${e}: "${t}". Only pixel values are supported (e.g., "800px" or "800").`
|
|
41
40
|
};
|
|
42
|
-
const n = parseFloat(
|
|
41
|
+
const n = parseFloat(s[1]);
|
|
43
42
|
return n < 0 || !isFinite(n) ? {
|
|
44
43
|
success: !1,
|
|
45
|
-
error: `Invalid ${e}: "${
|
|
44
|
+
error: `Invalid ${e}: "${t}". Value must be a positive number.`
|
|
46
45
|
} : { success: !0, value: n };
|
|
47
46
|
}
|
|
48
47
|
class g {
|
|
@@ -54,14 +53,14 @@ class g {
|
|
|
54
53
|
* @param message - The message text
|
|
55
54
|
* @param level - The message severity level (defaults to "info")
|
|
56
55
|
*/
|
|
57
|
-
async sendMessage(e,
|
|
58
|
-
const
|
|
56
|
+
async sendMessage(e, r = "info") {
|
|
57
|
+
const s = c(e, r);
|
|
59
58
|
await this.session.request("ui/message", {
|
|
60
59
|
role: "user",
|
|
61
60
|
content: [
|
|
62
61
|
{
|
|
63
62
|
type: "text",
|
|
64
|
-
text:
|
|
63
|
+
text: s
|
|
65
64
|
}
|
|
66
65
|
]
|
|
67
66
|
});
|
|
@@ -79,25 +78,25 @@ class g {
|
|
|
79
78
|
const e = this.session.getHostContext().theme;
|
|
80
79
|
return e ? { mode: e } : null;
|
|
81
80
|
}
|
|
82
|
-
async resize(e,
|
|
83
|
-
const
|
|
84
|
-
if (!
|
|
85
|
-
return Promise.reject(new Error(
|
|
86
|
-
const n = m(
|
|
81
|
+
async resize(e, r) {
|
|
82
|
+
const s = m(e, "width");
|
|
83
|
+
if (!s.success)
|
|
84
|
+
return Promise.reject(new Error(s.error));
|
|
85
|
+
const n = m(r, "height");
|
|
87
86
|
if (!n.success)
|
|
88
87
|
return Promise.reject(new Error(n.error));
|
|
89
88
|
const o = {};
|
|
90
|
-
return
|
|
89
|
+
return s.value !== void 0 && (o.width = s.value), n.value !== void 0 && (o.height = n.value), this.session.sendNotification("ui/notifications/size-changed", o), Promise.resolve();
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
class v {
|
|
94
93
|
async displayAlert(e) {
|
|
95
|
-
const
|
|
96
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
94
|
+
const r = e.level || "info", s = c(e.message, r);
|
|
95
|
+
await window.openai.sendFollowUpMessage({ prompt: s });
|
|
97
96
|
}
|
|
98
97
|
async displayToast(e) {
|
|
99
|
-
const
|
|
100
|
-
await window.openai.sendFollowUpMessage({ prompt:
|
|
98
|
+
const r = e.level || "info", s = c(e.message, r);
|
|
99
|
+
await window.openai.sendFollowUpMessage({ prompt: s });
|
|
101
100
|
}
|
|
102
101
|
async displayModal(e) {
|
|
103
102
|
await window.openai.requestModal({
|
|
@@ -111,32 +110,36 @@ class v {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
let i = null, l = null;
|
|
114
|
-
function
|
|
115
|
-
return i || (i = y(
|
|
113
|
+
function D(t) {
|
|
114
|
+
return i || (i = y(t).then((e) => (l = e, e))), i;
|
|
116
115
|
}
|
|
117
116
|
function K() {
|
|
118
117
|
return l;
|
|
119
118
|
}
|
|
120
|
-
function
|
|
119
|
+
function A() {
|
|
121
120
|
i = null, l = null;
|
|
122
121
|
}
|
|
123
|
-
function y(
|
|
124
|
-
return
|
|
122
|
+
function y(t) {
|
|
123
|
+
return w(
|
|
125
124
|
(async () => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
125
|
+
try {
|
|
126
|
+
switch (await d(t?.surface)) {
|
|
127
|
+
case a.OpenAI:
|
|
128
|
+
return new v();
|
|
129
|
+
case a.WebApp:
|
|
130
|
+
case a.Mosaic:
|
|
131
|
+
return {};
|
|
132
|
+
case a.MicroFrontend:
|
|
133
|
+
return await u.create();
|
|
134
|
+
case a.MCPApps: {
|
|
135
|
+
const r = await p.getInstance();
|
|
136
|
+
return new g(r);
|
|
137
|
+
}
|
|
138
|
+
default:
|
|
139
|
+
return {};
|
|
137
140
|
}
|
|
138
|
-
|
|
139
|
-
|
|
141
|
+
} catch {
|
|
142
|
+
return {};
|
|
140
143
|
}
|
|
141
144
|
})(),
|
|
142
145
|
"createViewSDK"
|
|
@@ -145,7 +148,7 @@ function y(s) {
|
|
|
145
148
|
export {
|
|
146
149
|
g as MCPAppsViewSDK,
|
|
147
150
|
y as createViewSDK,
|
|
148
|
-
|
|
151
|
+
D as getViewSDK,
|
|
149
152
|
K as getViewSDKSync,
|
|
150
|
-
|
|
153
|
+
A as resetViewSDK
|
|
151
154
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/platform-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@conduit-client/service-pubsub": "3.19.6",
|
|
108
108
|
"@conduit-client/service-retry": "3.19.6",
|
|
109
109
|
"@conduit-client/utils": "3.19.6",
|
|
110
|
-
"@salesforce/jsonrpc": "^
|
|
110
|
+
"@salesforce/jsonrpc": "^11.1.0",
|
|
111
111
|
"@sf-embedding/sf-embedding-bridge": "2.2.1-rc.4"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { registerInstrumentedApp as h } from "o11y/client";
|
|
2
|
-
import { g as A } from "./surface-DX5JCZPQ.js";
|
|
3
|
-
import { getChatSDK as T } from "./chat/index.js";
|
|
4
|
-
import { r as x } from "./TelemetryUploader-DKkdppe9.js";
|
|
5
|
-
import { analyticsContextSchema as v, sessionSchema as _, pageViewSchema as C, errorContextSchema as k, interactionSchema as L, customEventSchema as N } from "o11y_schema/sf_mcpanalytics";
|
|
6
|
-
function F(e) {
|
|
7
|
-
const r = (n, c, m, o, l) => {
|
|
8
|
-
e.error(l ?? n);
|
|
9
|
-
}, a = (n) => {
|
|
10
|
-
e.error(n.reason);
|
|
11
|
-
};
|
|
12
|
-
return window.addEventListener("error", r), window.addEventListener("unhandledrejection", a), () => {
|
|
13
|
-
window.removeEventListener("error", r), window.removeEventListener("unhandledrejection", a);
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const D = "aJC", V = "sfdc.pftId", b = "sfdc.internalSession", O = "aJCEE000000FgYP4A0", w = /* @__PURE__ */ new Set(), J = /^aJC[0-9A-Za-z]{12}(?:[0-9A-Za-z]{3})?$/;
|
|
17
|
-
function E(e) {
|
|
18
|
-
return typeof e != "string" || e.length === 0 ? !1 : e.length !== 15 && e.length !== 18 ? (S(e, "Expected a 15- or 18-character Salesforce ID"), !1) : J.test(e) ? !0 : (S(e, `Expected a Product Feature Id (prefix "${D}", base62).`), !1);
|
|
19
|
-
}
|
|
20
|
-
function S(e, r) {
|
|
21
|
-
w.has(e) || (w.add(e), console.debug(`[platform-sdk:analytics] Ignoring invalid PFT Id "${e}". ${r}`));
|
|
22
|
-
}
|
|
23
|
-
function p(e, r) {
|
|
24
|
-
return { surface: r };
|
|
25
|
-
}
|
|
26
|
-
const K = {
|
|
27
|
-
callTool: {
|
|
28
|
-
isAsync: !0,
|
|
29
|
-
extractTags: (e, r) => ({ toolName: e[0]?.toolName ?? "unknown", surface: r })
|
|
30
|
-
},
|
|
31
|
-
setWidgetState: {
|
|
32
|
-
isAsync: !1,
|
|
33
|
-
extractTags: p
|
|
34
|
-
},
|
|
35
|
-
sendMessageToHost: {
|
|
36
|
-
isAsync: !0,
|
|
37
|
-
extractTags: p
|
|
38
|
-
},
|
|
39
|
-
openLink: {
|
|
40
|
-
isAsync: !0,
|
|
41
|
-
extractTags: p
|
|
42
|
-
},
|
|
43
|
-
readResource: {
|
|
44
|
-
isAsync: !0,
|
|
45
|
-
extractTags: (e, r) => {
|
|
46
|
-
const n = e[0]?.uri ?? "", c = n.indexOf("://");
|
|
47
|
-
return { scheme: c > 0 ? n.slice(0, c).toLowerCase() : "unknown", surface: r };
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
setDisplayMode: {
|
|
51
|
-
isAsync: !0,
|
|
52
|
-
extractTags: (e, r) => ({ mode: e[0] ?? "unknown", surface: r })
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
function M(e, r, a) {
|
|
56
|
-
return new Proxy(e, {
|
|
57
|
-
get(n, c, m) {
|
|
58
|
-
const o = Reflect.get(n, c, m), l = K[c];
|
|
59
|
-
return !l || typeof o != "function" ? o : (...d) => {
|
|
60
|
-
const f = l.extractTags(d, a), s = `sdk.${String(c)}`;
|
|
61
|
-
return l.isAsync ? r.activityAsync(s, async () => {
|
|
62
|
-
try {
|
|
63
|
-
const g = await o.apply(n, d);
|
|
64
|
-
return r.incrementCounter(s, 1, !1, f), g;
|
|
65
|
-
} catch (g) {
|
|
66
|
-
throw r.incrementCounter(s, 1, !0, f), g;
|
|
67
|
-
}
|
|
68
|
-
}) : (r.incrementCounter(s, 1, !1, f), o.apply(n, d));
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
async function z(e) {
|
|
74
|
-
const { appId: r, clientSessionId: a } = e, n = A(), c = Date.now(), m = e.sdk ?? await T();
|
|
75
|
-
let o = null;
|
|
76
|
-
e.pftId !== void 0 && E(e.pftId) && (o = e.pftId);
|
|
77
|
-
const l = e.enforceInternalGate === !0;
|
|
78
|
-
let d = !1;
|
|
79
|
-
const f = h("mcp-widget", {
|
|
80
|
-
appPayloadProvider: {
|
|
81
|
-
getPayload: () => {
|
|
82
|
-
const t = !l || d;
|
|
83
|
-
return {
|
|
84
|
-
schema: v,
|
|
85
|
-
payload: {
|
|
86
|
-
appId: r,
|
|
87
|
-
surface: n,
|
|
88
|
-
...t ? { axlPftId: O } : {},
|
|
89
|
-
...t && o !== null ? { pftId: o } : {}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
clientSessionId: a
|
|
95
|
-
}), s = f, g = M(m, s, n), P = F(s);
|
|
96
|
-
let y;
|
|
97
|
-
e.transport && (y = x(f, {
|
|
98
|
-
onEnvelope: (t) => {
|
|
99
|
-
e.transport.enqueue(t);
|
|
100
|
-
}
|
|
101
|
-
}));
|
|
102
|
-
let I, i = !1;
|
|
103
|
-
return {
|
|
104
|
-
instrumentedSDK: g,
|
|
105
|
-
app: f,
|
|
106
|
-
trackEvent(t, u) {
|
|
107
|
-
i || s.log(N, {
|
|
108
|
-
eventName: t,
|
|
109
|
-
properties: u ? JSON.stringify(u) : ""
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
trackInteraction(t, u) {
|
|
113
|
-
i || s.log(L, {
|
|
114
|
-
elementId: t,
|
|
115
|
-
properties: u ? JSON.stringify(u) : ""
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
trackError(t, u) {
|
|
119
|
-
i || s.error(t, k, {
|
|
120
|
-
properties: u ? JSON.stringify(u) : ""
|
|
121
|
-
});
|
|
122
|
-
},
|
|
123
|
-
trackPageView(t) {
|
|
124
|
-
i || t !== I && (I = t, s.log(C, { componentRef: t }));
|
|
125
|
-
},
|
|
126
|
-
setPftId(t) {
|
|
127
|
-
i || E(t) && (o = t);
|
|
128
|
-
},
|
|
129
|
-
setInternalSession(t) {
|
|
130
|
-
i || (d = t === !0);
|
|
131
|
-
},
|
|
132
|
-
dispose() {
|
|
133
|
-
if (i) return;
|
|
134
|
-
i = !0, P();
|
|
135
|
-
const t = Date.now() - c;
|
|
136
|
-
s.log(_, { durationMs: t }), y?.dispose();
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
export {
|
|
141
|
-
O as A,
|
|
142
|
-
b as I,
|
|
143
|
-
V as P,
|
|
144
|
-
z as c,
|
|
145
|
-
E as v
|
|
146
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
};
|