@salesforce/sdk-core 1.80.1 → 1.82.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.
@@ -1,9 +1,4 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- import { Surface } from "./surface.js";
1
+ import { Surface } from './surface';
7
2
  /**
8
3
  * Static capability map for each surface.
9
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAEnC,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IAGnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAElB,MAAM,EAAE,OAAO,CAAC;CAChB;AAoED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAY5E"}
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAEnC,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;IAGnB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAElB,MAAM,EAAE,OAAO,CAAC;CAChB;AAoED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAY5E"}
package/dist/chat.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- import type { ThemeMode } from "./view.js";
1
+ import { ThemeMode } from './view';
7
2
  /**
8
3
  * Message payload for chat stream
9
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO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OAIG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAEhD;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IAE/B;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC,CAAC;IAEvE;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,WAAW,CAAC;IAEnC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACjD"}
package/dist/index.d.ts CHANGED
@@ -3,18 +3,18 @@
3
3
  * All rights reserved.
4
4
  * For full license text, see the LICENSE.txt file
5
5
  */
6
- export { Surface, getSurface } from "./surface.js";
7
- export type { SDKOptions } from "./options.js";
8
- export type { HostContext, ChatMessage, ChatSDK, DeviceCapabilities, DisplayMode, ResourceRequest, SafeAreaInsets, ToolCall, ToolState, } from "./chat.js";
9
- export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, ViewSDK, } from "./view.js";
10
- export type { DataSDK, GraphQLResponse } from "./data.js";
11
- export type { LightningSDK, LMSMessage, LMSSubscription, MessageChannel } from "./lightning.js";
12
- export type { OpenAISDK, SalesforceACCSDK } from "./platforms.js";
13
- export type { JsonRpcBase, JsonRpcRequest, JsonRpcError, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcResponse, JsonRpcNotification, JsonRpcMessage, JsonRpcPendingRequest, JsonRpcPendingRequestMap, } from "./jsonrpc.js";
14
- export { isJsonRpcBase, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, isJsonRpcResponse, isJsonRpcNotification, isJsonRpcRequest, } from "./jsonrpc.js";
15
- export { JsonRpcClient } from "./jsonrpc-client.js";
16
- export { McpAppsSession } from "./mcpapps-session.js";
17
- export type { McpAppsHostContext, McpAppsSessionOptions } from "./mcpapps-session.js";
18
- export { getSurfaceCapabilities } from "./capabilities.js";
19
- export type { SurfaceCapabilities } from "./capabilities.js";
6
+ export { Surface, getSurface } from './surface';
7
+ export type { SDKOptions } from './options';
8
+ export type { HostContext, ChatMessage, ChatSDK, DeviceCapabilities, DisplayMode, ResourceRequest, SafeAreaInsets, ToolCall, ToolState, } from './chat';
9
+ export type { AlertOptions, MessageLevel, ModalOptions, ToastOptions, Theme, ThemeMode, ViewSDK, } from './view';
10
+ export type { DataSDK, GraphQLResponse } from './data';
11
+ export type { LightningSDK, LMSMessage, LMSSubscription, MessageChannel } from './lightning';
12
+ export type { OpenAISDK, SalesforceACCSDK } from './platforms';
13
+ export type { JsonRpcBase, JsonRpcRequest, JsonRpcError, JsonRpcSuccessResponse, JsonRpcErrorResponse, JsonRpcResponse, JsonRpcNotification, JsonRpcMessage, JsonRpcPendingRequest, JsonRpcPendingRequestMap, } from './jsonrpc';
14
+ export { isJsonRpcBase, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, isJsonRpcResponse, isJsonRpcNotification, isJsonRpcRequest, } from './jsonrpc';
15
+ export { JsonRpcClient } from './jsonrpc-client';
16
+ export { McpAppsSession } from './mcpapps-session';
17
+ export type { McpAppsHostContext, McpAppsSessionOptions } from './mcpapps-session';
18
+ export { getSurfaceCapabilities } from './capabilities';
19
+ export type { SurfaceCapabilities } from './capabilities';
20
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGnD,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,YAAY,EACX,WAAW,EACX,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,eAAe,EAC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,EACd,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,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGvD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7F,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/D,YAAY,EACX,WAAW,EACX,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GAChB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,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"}
package/dist/index.js CHANGED
@@ -1,13 +1,291 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- // Surface detection
7
- export { Surface, getSurface } from "./surface.js";
8
- export { isJsonRpcBase, isJsonRpcSuccessResponse, isJsonRpcErrorResponse, isJsonRpcResponse, isJsonRpcNotification, isJsonRpcRequest, } from "./jsonrpc.js";
9
- export { JsonRpcClient } from "./jsonrpc-client.js";
10
- // MCP Apps shared session
11
- export { McpAppsSession } from "./mcpapps-session.js";
12
- // Surface capabilities
13
- export { getSurfaceCapabilities } from "./capabilities.js";
1
+ var o = /* @__PURE__ */ ((e) => (e.WebApp = "WebApp", e.MicroFrontend = "Micro-Frontend", e.OpenAI = "OpenAI", e.SalesforceACC = "Salesforce-ACC", e.MCPApps = "MCP-Apps", e))(o || {});
2
+ const d = p();
3
+ function p() {
4
+ try {
5
+ if (window.self !== window.top)
6
+ return "MCP-Apps";
7
+ } catch {
8
+ return "MCP-Apps";
9
+ }
10
+ return window.openai ? "OpenAI" : "WebApp";
11
+ }
12
+ function y(e) {
13
+ return e ?? d;
14
+ }
15
+ function u(e) {
16
+ return typeof e == "object" && e !== null && "jsonrpc" in e && e.jsonrpc === "2.0";
17
+ }
18
+ function f(e) {
19
+ return u(e) && "id" in e && typeof e.id == "number" && "result" in e;
20
+ }
21
+ function l(e) {
22
+ return u(e) && "id" in e && typeof e.id == "number" && "error" in e;
23
+ }
24
+ function h(e) {
25
+ return f(e) || l(e);
26
+ }
27
+ function g(e) {
28
+ return u(e) && "method" in e && typeof e.method == "string" && !("id" in e);
29
+ }
30
+ function w(e) {
31
+ return u(e) && "id" in e && typeof e.id == "number" && "method" in e && typeof e.method == "string";
32
+ }
33
+ class T {
34
+ nextRequestId = 1;
35
+ pending = /* @__PURE__ */ new Map();
36
+ notificationHandlers = /* @__PURE__ */ new Map();
37
+ constructor() {
38
+ window.addEventListener("message", this.onMessage);
39
+ }
40
+ /**
41
+ * Register a handler for a specific JSON-RPC notification method
42
+ *
43
+ * Subclasses can register handlers to process specific notification types.
44
+ * When a notification with the registered method is received, the handler
45
+ * will be invoked with the notification params.
46
+ *
47
+ * @param method - The notification method to handle (e.g., "ui/notifications/host-context-changed")
48
+ * @param handler - Callback function to process the notification params
49
+ *
50
+ * @example
51
+ * this.registerNotificationHandler("ui/notifications/host-context-changed", (params) => {
52
+ * this.handleHostContextChanged(params);
53
+ * });
54
+ */
55
+ registerNotificationHandler(s, t) {
56
+ this.notificationHandlers.has(s) || this.notificationHandlers.set(s, /* @__PURE__ */ new Set()), this.notificationHandlers.get(s).add(t);
57
+ }
58
+ /**
59
+ * Handle incoming JSON-RPC messages from parent window
60
+ * Processes both responses (for requests) and notifications
61
+ */
62
+ onMessage = (s) => {
63
+ const t = s.data;
64
+ if (h(t)) {
65
+ const n = this.pending.get(t.id);
66
+ if (!n)
67
+ return;
68
+ this.pending.delete(t.id), l(t) ? n.reject(new Error(t.error.message || "Request failed")) : n.resolve(t.result);
69
+ return;
70
+ }
71
+ if (g(t)) {
72
+ const n = this.notificationHandlers.get(t.method);
73
+ n && n.forEach((i) => i(t.params));
74
+ }
75
+ };
76
+ /**
77
+ * Send a JSON-RPC request to the parent window
78
+ *
79
+ * @param method - The JSON-RPC method name
80
+ * @param params - The method parameters
81
+ * @returns Promise that resolves with the result or rejects with error
82
+ *
83
+ * @example
84
+ * const result = await this.request("ui/message", {
85
+ * role: "user",
86
+ * content: { type: "text", text: "Hello" }
87
+ * });
88
+ */
89
+ request(s, t) {
90
+ const n = this.nextRequestId++, i = {
91
+ jsonrpc: "2.0",
92
+ id: n,
93
+ method: s,
94
+ params: t
95
+ };
96
+ return new Promise((c, a) => {
97
+ this.pending.set(n, {
98
+ resolve: c,
99
+ reject: a
100
+ }), window.parent?.postMessage(i, "*");
101
+ });
102
+ }
103
+ /**
104
+ * Send a JSON-RPC notification to the parent window
105
+ *
106
+ * Notifications are one-way messages that do not expect a response.
107
+ * Use notifications for:
108
+ * - Informing the host of state changes
109
+ * - Fire-and-forget operations
110
+ * - Events that don't require confirmation
111
+ *
112
+ * Use request() instead when you need:
113
+ * - A response from the host
114
+ * - Confirmation of success/failure
115
+ * - Return values from the operation
116
+ *
117
+ * @param method - The JSON-RPC method name
118
+ * @param params - Optional method parameters
119
+ *
120
+ * @example
121
+ * this.sendNotification("ui/notifications/size-changed", {
122
+ * width: 800,
123
+ * height: 600
124
+ * });
125
+ */
126
+ sendNotification(s, t) {
127
+ const n = {
128
+ jsonrpc: "2.0",
129
+ method: s,
130
+ params: t
131
+ };
132
+ window.parent?.postMessage(n, "*");
133
+ }
134
+ }
135
+ const C = 5e3, m = "2026-01-26";
136
+ class r extends T {
137
+ static initPromise = null;
138
+ hostCtx = {};
139
+ _handshakeSucceeded = !1;
140
+ /**
141
+ * Get or create the shared session singleton.
142
+ *
143
+ * The first call performs the SEP-1865 handshake. Concurrent and subsequent
144
+ * calls reuse the same session and handshake result.
145
+ */
146
+ static async getInstance(s) {
147
+ return r.initPromise || (r.initPromise = (async () => {
148
+ const t = new r();
149
+ return await t.handshake(s), t;
150
+ })()), r.initPromise;
151
+ }
152
+ /**
153
+ * Reset the singleton (for testing only).
154
+ * @internal
155
+ */
156
+ static resetInstance() {
157
+ r.initPromise = null;
158
+ }
159
+ /**
160
+ * Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
161
+ *
162
+ * On success, stores the host context and sends the initialized notification.
163
+ * On timeout or error, falls back to an empty host context so the app can
164
+ * still render (graceful degradation for non-SEP-1865 hosts).
165
+ */
166
+ async handshake(s) {
167
+ const t = s?.handshakeTimeoutMs ?? C, n = s?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
168
+ try {
169
+ const i = /* @__PURE__ */ Symbol("timeout"), c = await Promise.race([
170
+ this.request("ui/initialize", {
171
+ protocolVersion: m,
172
+ appInfo: n,
173
+ appCapabilities: {}
174
+ }),
175
+ new Promise((a) => setTimeout(() => a(i), t))
176
+ ]);
177
+ c !== i && (this.hostCtx = c.hostContext ?? {}, this._handshakeSucceeded = !0, this.registerNotificationHandler("ui/notifications/host-context-changed", (a) => {
178
+ this.hostCtx = {
179
+ ...this.hostCtx,
180
+ ...a
181
+ };
182
+ }), this.sendNotification("ui/notifications/initialized"));
183
+ } catch {
184
+ }
185
+ }
186
+ /** Returns the current host context (handshake + notification updates). */
187
+ getHostContext() {
188
+ return this.hostCtx;
189
+ }
190
+ /** Whether the ui/initialize handshake completed successfully (not timed out). */
191
+ get handshakeSucceeded() {
192
+ return this._handshakeSucceeded;
193
+ }
194
+ // ── Public wrappers ──────────────────────────────────────────────────
195
+ // Widen access from protected to public so SDK classes can use the
196
+ // shared transport without extending JsonRpcClient themselves.
197
+ request(s, t) {
198
+ return super.request(s, t);
199
+ }
200
+ sendNotification(s, t) {
201
+ super.sendNotification(s, t);
202
+ }
203
+ registerNotificationHandler(s, t) {
204
+ super.registerNotificationHandler(s, t);
205
+ }
206
+ }
207
+ const M = {
208
+ callTool: !0,
209
+ sendMessageToHost: !0,
210
+ readResource: !0,
211
+ openLink: !0,
212
+ accessToolInput: !0,
213
+ accessToolOutput: !0,
214
+ accessToolMetadata: !0,
215
+ getWidgetState: !1,
216
+ setWidgetState: !1,
217
+ onToolCanceled: !0,
218
+ setDisplayMode: !0,
219
+ getHostContext: !0,
220
+ subscribe: !0,
221
+ displayAlert: !0,
222
+ displayToast: !0,
223
+ displayModal: !1,
224
+ // TODO
225
+ getTheme: !0,
226
+ resize: !0
227
+ }, A = {
228
+ callTool: !0,
229
+ sendMessageToHost: !0,
230
+ readResource: !1,
231
+ openLink: !1,
232
+ accessToolInput: !0,
233
+ accessToolOutput: !0,
234
+ accessToolMetadata: !0,
235
+ getWidgetState: !0,
236
+ setWidgetState: !0,
237
+ onToolCanceled: !1,
238
+ setDisplayMode: !0,
239
+ getHostContext: !1,
240
+ subscribe: !0,
241
+ displayAlert: !0,
242
+ displayToast: !0,
243
+ displayModal: !0,
244
+ getTheme: !0,
245
+ resize: !1
246
+ }, I = {
247
+ callTool: !1,
248
+ sendMessageToHost: !1,
249
+ readResource: !1,
250
+ openLink: !1,
251
+ accessToolInput: !1,
252
+ accessToolOutput: !1,
253
+ accessToolMetadata: !1,
254
+ getWidgetState: !1,
255
+ setWidgetState: !1,
256
+ onToolCanceled: !1,
257
+ setDisplayMode: !1,
258
+ getHostContext: !1,
259
+ subscribe: !1,
260
+ displayAlert: !1,
261
+ displayToast: !1,
262
+ displayModal: !1,
263
+ getTheme: !1,
264
+ resize: !1
265
+ };
266
+ function P(e) {
267
+ switch (e) {
268
+ case o.MCPApps:
269
+ return { ...M };
270
+ case o.OpenAI:
271
+ return { ...A };
272
+ case o.WebApp:
273
+ case o.MicroFrontend:
274
+ case o.SalesforceACC:
275
+ default:
276
+ return { ...I };
277
+ }
278
+ }
279
+ export {
280
+ T as JsonRpcClient,
281
+ r as McpAppsSession,
282
+ o as Surface,
283
+ y as getSurface,
284
+ P as getSurfaceCapabilities,
285
+ u as isJsonRpcBase,
286
+ l as isJsonRpcErrorResponse,
287
+ g as isJsonRpcNotification,
288
+ w as isJsonRpcRequest,
289
+ h as isJsonRpcResponse,
290
+ f as isJsonRpcSuccessResponse
291
+ };
@@ -1,11 +1,6 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- import type { DisplayMode } from "./chat.js";
7
- import { JsonRpcClient } from "./jsonrpc-client.js";
8
- import type { ThemeMode } from "./view.js";
1
+ import { DisplayMode } from './chat';
2
+ import { JsonRpcClient } from './jsonrpc-client';
3
+ import { ThemeMode } from './view';
9
4
  /**
10
5
  * Host context returned by the ui/initialize handshake.
11
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"mcpapps-session.d.ts","sourceRoot":"","sources":["../src/mcpapps-session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IAClC,sCAAsC;IACtC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,iCAAiC;IACjC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,2BAA2B;IAC3B,mBAAmB,CAAC,EAAE;QACrB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CAAC,EAAE,OAAO,GAAG,IAAI;IAI3E,2BAA2B,CAC1C,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,GAChC,IAAI;CAGP"}
package/dist/options.d.ts CHANGED
@@ -1,9 +1,4 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- import type { Surface } from "./surface.js";
1
+ import { Surface } from './surface';
7
2
  /**
8
3
  * Base options bag for all SDK factory functions.
9
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB"}
@@ -1,13 +1,5 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- /**
7
- * OpenAI SDK interface exposed on window
8
- */
9
- import type { DisplayMode } from "./chat.js";
10
- import type { Theme } from "./view.js";
1
+ import { DisplayMode } from './chat';
2
+ import { Theme } from './view';
11
3
  export interface OpenAISDK {
12
4
  sendFollowUpMessage: (options: {
13
5
  prompt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"platforms.d.ts","sourceRoot":"","sources":["../src/platforms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAE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AAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB;;;;;OAKG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;;OAKG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD;;;;OAIG;IACH,QAAQ,IAAI,KAAK,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,OAAO;IACvB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,CAAC,KACT,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACrB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,CAAC,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;KAChB,EAAE,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sdk-core",
3
- "version": "1.80.1",
3
+ "version": "1.82.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -18,14 +18,16 @@
18
18
  "dist"
19
19
  ],
20
20
  "scripts": {
21
- "build": "tsc --build",
22
- "clean": "rm -rf dist tsconfig.tsbuildinfo",
23
- "dev": "tsc --build --watch",
21
+ "build": "vite build",
22
+ "clean": "rm -rf dist",
23
+ "dev": "vite build --watch",
24
24
  "test": "vitest run",
25
25
  "test:watch": "vitest",
26
26
  "test:coverage": "vitest run --coverage"
27
27
  },
28
28
  "devDependencies": {
29
+ "vite": "^7.3.1",
30
+ "vite-plugin-dts": "^4.5.4",
29
31
  "vitest": "^4.0.6"
30
32
  },
31
33
  "publishConfig": {
@@ -1,90 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- import { Surface } from "./surface.js";
7
- const MCPAPPS_CAPABILITIES = {
8
- callTool: true,
9
- sendMessageToHost: true,
10
- readResource: true,
11
- openLink: true,
12
- accessToolInput: true,
13
- accessToolOutput: true,
14
- accessToolMetadata: true,
15
- getWidgetState: false,
16
- setWidgetState: false,
17
- onToolCanceled: true,
18
- setDisplayMode: true,
19
- getHostContext: true,
20
- subscribe: true,
21
- displayAlert: true,
22
- displayToast: true,
23
- displayModal: false, // TODO
24
- getTheme: true,
25
- resize: true,
26
- };
27
- const OPENAI_CAPABILITIES = {
28
- callTool: true,
29
- sendMessageToHost: true,
30
- readResource: false,
31
- openLink: false,
32
- accessToolInput: true,
33
- accessToolOutput: true,
34
- accessToolMetadata: true,
35
- getWidgetState: true,
36
- setWidgetState: true,
37
- onToolCanceled: false,
38
- setDisplayMode: true,
39
- getHostContext: false,
40
- subscribe: true,
41
- displayAlert: true,
42
- displayToast: true,
43
- displayModal: true,
44
- getTheme: true,
45
- resize: false,
46
- };
47
- const EMPTY_CAPABILITIES = {
48
- callTool: false,
49
- sendMessageToHost: false,
50
- readResource: false,
51
- openLink: false,
52
- accessToolInput: false,
53
- accessToolOutput: false,
54
- accessToolMetadata: false,
55
- getWidgetState: false,
56
- setWidgetState: false,
57
- onToolCanceled: false,
58
- setDisplayMode: false,
59
- getHostContext: false,
60
- subscribe: false,
61
- displayAlert: false,
62
- displayToast: false,
63
- displayModal: false,
64
- getTheme: false,
65
- resize: false,
66
- };
67
- /**
68
- * Returns the static capability map for a given surface.
69
- *
70
- * @example
71
- * ```typescript
72
- * const caps = getSurfaceCapabilities(Surface.MCPApps);
73
- * if (caps.displayAlert) {
74
- * viewSdk.displayAlert?.({ message: "Hello", level: "info" });
75
- * }
76
- * ```
77
- */
78
- export function getSurfaceCapabilities(surface) {
79
- switch (surface) {
80
- case Surface.MCPApps:
81
- return { ...MCPAPPS_CAPABILITIES };
82
- case Surface.OpenAI:
83
- return { ...OPENAI_CAPABILITIES };
84
- case Surface.WebApp:
85
- case Surface.MicroFrontend:
86
- case Surface.SalesforceACC:
87
- default:
88
- return { ...EMPTY_CAPABILITIES };
89
- }
90
- }
package/dist/chat.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/data.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- export {};
@@ -1,140 +0,0 @@
1
- import { isJsonRpcResponse, isJsonRpcErrorResponse, isJsonRpcNotification } from "./jsonrpc.js";
2
- /**
3
- * Base class for JSON-RPC 2.0 clients using postMessage
4
- *
5
- * This class provides core JSON-RPC client functionality for MCP Apps implementations.
6
- * It handles request/response correlation, message validation, and error handling.
7
- *
8
- * Subclasses should extend this class and use the protected `request()` method
9
- * to send JSON-RPC requests to the parent window.
10
- *
11
- * @example
12
- * export class MCPAppsViewSDK extends JsonRpcClient implements ViewSDK {
13
- * async displayAlert(options: AlertOptions): Promise<void> {
14
- * await this.request("ui/message", {
15
- * role: "user",
16
- * content: { type: "text", text: options.message }
17
- * });
18
- * }
19
- * }
20
- */
21
- export class JsonRpcClient {
22
- nextRequestId = 1;
23
- pending = new Map();
24
- notificationHandlers = new Map();
25
- constructor() {
26
- // Listen for JSON-RPC messages from parent window
27
- window.addEventListener("message", this.onMessage);
28
- }
29
- /**
30
- * Register a handler for a specific JSON-RPC notification method
31
- *
32
- * Subclasses can register handlers to process specific notification types.
33
- * When a notification with the registered method is received, the handler
34
- * will be invoked with the notification params.
35
- *
36
- * @param method - The notification method to handle (e.g., "ui/notifications/host-context-changed")
37
- * @param handler - Callback function to process the notification params
38
- *
39
- * @example
40
- * this.registerNotificationHandler("ui/notifications/host-context-changed", (params) => {
41
- * this.handleHostContextChanged(params);
42
- * });
43
- */
44
- registerNotificationHandler(method, handler) {
45
- if (!this.notificationHandlers.has(method)) {
46
- this.notificationHandlers.set(method, new Set());
47
- }
48
- this.notificationHandlers.get(method).add(handler);
49
- }
50
- /**
51
- * Handle incoming JSON-RPC messages from parent window
52
- * Processes both responses (for requests) and notifications
53
- */
54
- onMessage = (event) => {
55
- const data = event.data;
56
- // Handle JSON-RPC responses
57
- if (isJsonRpcResponse(data)) {
58
- const slot = this.pending.get(data.id);
59
- if (!slot) {
60
- return;
61
- }
62
- this.pending.delete(data.id);
63
- // Type guard provides proper type narrowing
64
- if (isJsonRpcErrorResponse(data)) {
65
- slot.reject(new Error(data.error.message || "Request failed"));
66
- }
67
- else {
68
- slot.resolve(data.result);
69
- }
70
- return;
71
- }
72
- // Handle JSON-RPC notifications
73
- if (isJsonRpcNotification(data)) {
74
- const handlers = this.notificationHandlers.get(data.method);
75
- if (handlers) {
76
- handlers.forEach((handler) => handler(data.params));
77
- }
78
- }
79
- };
80
- /**
81
- * Send a JSON-RPC request to the parent window
82
- *
83
- * @param method - The JSON-RPC method name
84
- * @param params - The method parameters
85
- * @returns Promise that resolves with the result or rejects with error
86
- *
87
- * @example
88
- * const result = await this.request("ui/message", {
89
- * role: "user",
90
- * content: { type: "text", text: "Hello" }
91
- * });
92
- */
93
- request(method, params) {
94
- const id = this.nextRequestId++;
95
- const message = {
96
- jsonrpc: "2.0",
97
- id,
98
- method,
99
- params,
100
- };
101
- return new Promise((resolve, reject) => {
102
- this.pending.set(id, {
103
- resolve: resolve,
104
- reject,
105
- });
106
- window.parent?.postMessage(message, "*");
107
- });
108
- }
109
- /**
110
- * Send a JSON-RPC notification to the parent window
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(method, params) {
133
- const message = {
134
- jsonrpc: "2.0",
135
- method,
136
- params,
137
- };
138
- window.parent?.postMessage(message, "*");
139
- }
140
- }
package/dist/jsonrpc.js DELETED
@@ -1,57 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- /**
7
- * Type guard to check if message is valid JSON-RPC 2.0 base
8
- */
9
- export function isJsonRpcBase(data) {
10
- return (typeof data === "object" &&
11
- data !== null &&
12
- "jsonrpc" in data &&
13
- data.jsonrpc === "2.0");
14
- }
15
- /**
16
- * Type guard for JSON-RPC success response
17
- */
18
- export function isJsonRpcSuccessResponse(data) {
19
- return (isJsonRpcBase(data) &&
20
- "id" in data &&
21
- typeof data.id === "number" &&
22
- "result" in data);
23
- }
24
- /**
25
- * Type guard for JSON-RPC error response
26
- */
27
- export function isJsonRpcErrorResponse(data) {
28
- return (isJsonRpcBase(data) &&
29
- "id" in data &&
30
- typeof data.id === "number" &&
31
- "error" in data);
32
- }
33
- /**
34
- * Type guard for any JSON-RPC response (success or error)
35
- */
36
- export function isJsonRpcResponse(data) {
37
- return isJsonRpcSuccessResponse(data) || isJsonRpcErrorResponse(data);
38
- }
39
- /**
40
- * Type guard for JSON-RPC notification
41
- */
42
- export function isJsonRpcNotification(data) {
43
- return (isJsonRpcBase(data) &&
44
- "method" in data &&
45
- typeof data.method === "string" &&
46
- !("id" in data));
47
- }
48
- /**
49
- * Type guard for JSON-RPC request
50
- */
51
- export function isJsonRpcRequest(data) {
52
- return (isJsonRpcBase(data) &&
53
- "id" in data &&
54
- typeof data.id === "number" &&
55
- "method" in data &&
56
- typeof data.method === "string");
57
- }
package/dist/lightning.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- export {};
@@ -1,100 +0,0 @@
1
- import { JsonRpcClient } from "./jsonrpc-client.js";
2
- /** Default handshake timeout */
3
- const DEFAULT_HANDSHAKE_TIMEOUT_MS = 5000;
4
- /** SEP-1865 protocol version */
5
- const PROTOCOL_VERSION = "2026-01-26";
6
- /**
7
- * Shared MCP Apps session singleton.
8
- *
9
- * Provides a single JSON-RPC transport (one postMessage listener, one ID counter)
10
- * shared by both MCPAppsChatSDK and MCPAppsViewSDK. Performs the SEP-1865
11
- * ui/initialize handshake once and exposes the resulting host context.
12
- *
13
- * Use {@link McpAppsSession.getInstance} to obtain the singleton. The first call
14
- * triggers the handshake; subsequent calls return the same initialized instance.
15
- */
16
- export class McpAppsSession extends JsonRpcClient {
17
- static initPromise = null;
18
- hostCtx = {};
19
- _handshakeSucceeded = false;
20
- /**
21
- * Get or create the shared session singleton.
22
- *
23
- * The first call performs the SEP-1865 handshake. Concurrent and subsequent
24
- * calls reuse the same session and handshake result.
25
- */
26
- static async getInstance(options) {
27
- if (!McpAppsSession.initPromise) {
28
- McpAppsSession.initPromise = (async () => {
29
- const session = new McpAppsSession();
30
- await session.handshake(options);
31
- return session;
32
- })();
33
- }
34
- return McpAppsSession.initPromise;
35
- }
36
- /**
37
- * Reset the singleton (for testing only).
38
- * @internal
39
- */
40
- static resetInstance() {
41
- McpAppsSession.initPromise = null;
42
- }
43
- /**
44
- * Perform the ui/initialize → hostContext → ui/notifications/initialized handshake.
45
- *
46
- * On success, stores the host context and sends the initialized notification.
47
- * On timeout or error, falls back to an empty host context so the app can
48
- * still render (graceful degradation for non-SEP-1865 hosts).
49
- */
50
- async handshake(options) {
51
- const timeoutMs = options?.handshakeTimeoutMs ?? DEFAULT_HANDSHAKE_TIMEOUT_MS;
52
- const appInfo = options?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
53
- try {
54
- const sentinel = Symbol("timeout");
55
- const result = await Promise.race([
56
- this.request("ui/initialize", {
57
- protocolVersion: PROTOCOL_VERSION,
58
- appInfo,
59
- appCapabilities: {},
60
- }),
61
- new Promise((resolve) => setTimeout(() => resolve(sentinel), timeoutMs)),
62
- ]);
63
- if (result !== sentinel) {
64
- this.hostCtx = result.hostContext ?? {};
65
- this._handshakeSucceeded = true;
66
- this.registerNotificationHandler("ui/notifications/host-context-changed", (params) => {
67
- this.hostCtx = {
68
- ...this.hostCtx,
69
- ...params,
70
- };
71
- });
72
- this.sendNotification("ui/notifications/initialized");
73
- }
74
- // On timeout, hostContext stays empty and we skip the initialized notification.
75
- }
76
- catch {
77
- // Handshake error — continue with empty context for graceful degradation.
78
- }
79
- }
80
- /** Returns the current host context (handshake + notification updates). */
81
- getHostContext() {
82
- return this.hostCtx;
83
- }
84
- /** Whether the ui/initialize handshake completed successfully (not timed out). */
85
- get handshakeSucceeded() {
86
- return this._handshakeSucceeded;
87
- }
88
- // ── Public wrappers ──────────────────────────────────────────────────
89
- // Widen access from protected to public so SDK classes can use the
90
- // shared transport without extending JsonRpcClient themselves.
91
- request(method, params) {
92
- return super.request(method, params);
93
- }
94
- sendNotification(method, params) {
95
- super.sendNotification(method, params);
96
- }
97
- registerNotificationHandler(method, handler) {
98
- super.registerNotificationHandler(method, handler);
99
- }
100
- }
package/dist/options.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/platforms.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- export {};
package/dist/surface.js DELETED
@@ -1,54 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- /**
7
- * Enumeration of possible runtime surfaces
8
- */
9
- export var Surface;
10
- (function (Surface) {
11
- Surface["WebApp"] = "WebApp";
12
- Surface["MicroFrontend"] = "Micro-Frontend";
13
- Surface["OpenAI"] = "OpenAI";
14
- Surface["SalesforceACC"] = "Salesforce-ACC";
15
- Surface["MCPApps"] = "MCP-Apps";
16
- })(Surface || (Surface = {}));
17
- const surface = detectSurface();
18
- /**
19
- * Determines the surface.
20
- *
21
- * Detection heuristics (in priority order):
22
- * 1. iframe check → MCPApps (SEP-1865 hosts load apps in iframes)
23
- * 2. window.openai → OpenAI (ChatGPT injects this — but so do some MCP hosts)
24
- * 3. fallback → WebApp
25
- *
26
- * The iframe check takes priority because some MCP Apps hosts (e.g. MCPJam)
27
- * inject `window.openai` into the iframe. The factory functions resolve the
28
- * ambiguity: they attempt the SEP-1865 handshake first, and only fall back to
29
- * the OpenAI SDK when the handshake times out and `window.openai` is present.
30
- */
31
- function detectSurface() {
32
- try {
33
- if (window.self !== window.top) {
34
- return Surface.MCPApps;
35
- }
36
- }
37
- catch {
38
- // Cross-origin iframe access throws — that's still an iframe
39
- return Surface.MCPApps;
40
- }
41
- if (window.openai) {
42
- return Surface.OpenAI;
43
- }
44
- return Surface.WebApp;
45
- }
46
- /**
47
- * Returns the surface to use for SDK initialization.
48
- *
49
- * Returns the override surface if provided, otherwise falls back
50
- * to the auto-detected surface.
51
- */
52
- export function getSurface(override) {
53
- return override ?? surface;
54
- }
package/dist/view.js DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Copyright (c) 2026, Salesforce, Inc.,
3
- * All rights reserved.
4
- * For full license text, see the LICENSE.txt file
5
- */
6
- export {};