@salesforce/platform-sdk 9.1.0 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { buildServiceDescriptor as K, setHeader as _ } from "@conduit-client/service-fetch-network/v1";
2
2
  import { resolvedPromiseLike as w, ok as k, err as D, stableJSONStringify as Y, DataNotFoundError as Z, UserVisibleError as ee, deepFreeze as z } from "@conduit-client/utils";
3
- import { print as R, parse as te } from "@conduit-client/onestore-graphql-parser/v1";
3
+ import { print as x, parse as te } from "@conduit-client/onestore-graphql-parser/v1";
4
4
  import { RetryPolicy as se, buildServiceDescriptor as re } from "@conduit-client/service-retry/v1";
5
5
  import { buildServiceDescriptor as ne } from "@conduit-client/service-cache/v1";
6
6
  import { buildServiceDescriptor as ie } from "@conduit-client/service-cache-control/v1";
@@ -10,10 +10,10 @@ import { HttpCacheControlCommand as ce } from "@conduit-client/command-http-cach
10
10
  import { encodeCoreEnvelopeContentsRaw as le } from "o11y/collectors";
11
11
  import { SimpleCollector as ue } from "o11y/simple_collector";
12
12
  import { registerInstrumentedApp as de } from "o11y/client";
13
- import { analyticsContextSchema as he, sessionSchema as fe, pageViewSchema as pe, errorContextSchema as me, interactionSchema as ge, customEventSchema as ye } from "o11y_schema/sf_mcpanalytics";
13
+ import { analyticsContextSchema as he, sessionSchema as fe, pageViewSchema as pe, errorContextSchema as ge, interactionSchema as me, customEventSchema as ye } from "o11y_schema/sf_mcpanalytics";
14
14
  var c = /* @__PURE__ */ ((s) => (s.WebApp = "WebApp", s.MicroFrontend = "Micro-Frontend", s.OpenAI = "OpenAI", s.SalesforceACC = "Salesforce-ACC", s.MCPApps = "MCP-Apps", s.Mosaic = "Mosaic", s))(c || {});
15
- const we = be();
16
- function be() {
15
+ const we = ve();
16
+ function ve() {
17
17
  if (typeof window > "u")
18
18
  return "Mosaic";
19
19
  if (window.openai)
@@ -30,23 +30,23 @@ function be() {
30
30
  function C(s) {
31
31
  return s ?? we;
32
32
  }
33
- function A(s) {
33
+ function M(s) {
34
34
  return typeof s == "object" && s !== null && "jsonrpc" in s && s.jsonrpc === "2.0";
35
35
  }
36
- function ve(s) {
37
- return A(s) && "id" in s && typeof s.id == "number" && "result" in s;
36
+ function be(s) {
37
+ return M(s) && "id" in s && typeof s.id == "number" && "result" in s;
38
38
  }
39
39
  function B(s) {
40
- return A(s) && "id" in s && typeof s.id == "number" && "error" in s;
40
+ return M(s) && "id" in s && typeof s.id == "number" && "error" in s;
41
41
  }
42
42
  function Ce(s) {
43
- return ve(s) || B(s);
43
+ return be(s) || B(s);
44
44
  }
45
45
  function Se(s) {
46
- return A(s) && "method" in s && typeof s.method == "string" && !("id" in s);
46
+ return M(s) && "method" in s && typeof s.method == "string" && !("id" in s);
47
47
  }
48
- function Zt(s) {
49
- return A(s) && "id" in s && typeof s.id == "number" && "method" in s && typeof s.method == "string";
48
+ function es(s) {
49
+ return M(s) && "id" in s && typeof s.id == "number" && "method" in s && typeof s.method == "string";
50
50
  }
51
51
  class Te {
52
52
  targetOrigin;
@@ -183,7 +183,7 @@ class _e {
183
183
  }
184
184
  function Ee() {
185
185
  }
186
- class es {
186
+ class ts {
187
187
  #e;
188
188
  #s = /* @__PURE__ */ new Set();
189
189
  #n = !1;
@@ -279,7 +279,7 @@ class es {
279
279
  }
280
280
  };
281
281
  }
282
- const Ae = 500, Me = "2026-01-26";
282
+ const Me = 500, Ae = "2026-01-26";
283
283
  class y extends _e {
284
284
  static initPromise = null;
285
285
  hostCtx = {};
@@ -311,11 +311,11 @@ class y extends _e {
311
311
  * still render (graceful degradation for non-SEP-1865 hosts).
312
312
  */
313
313
  async handshake(e) {
314
- const t = e?.handshakeTimeoutMs ?? Ae, r = e?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
314
+ const t = e?.handshakeTimeoutMs ?? Me, r = e?.appInfo ?? { name: "mcp-app", version: "1.0.0" };
315
315
  try {
316
316
  const n = /* @__PURE__ */ Symbol("timeout"), i = await Promise.race([
317
317
  this.request("ui/initialize", {
318
- protocolVersion: Me,
318
+ protocolVersion: Ae,
319
319
  appInfo: r,
320
320
  appCapabilities: {}
321
321
  }),
@@ -361,6 +361,7 @@ const Ie = {
361
361
  accessToolMetadata: !0,
362
362
  getWidgetState: !0,
363
363
  setWidgetState: !0,
364
+ setWidgetStateModelContext: !0,
364
365
  onToolCanceled: !0,
365
366
  setDisplayMode: !0,
366
367
  getHostContext: !0,
@@ -381,6 +382,7 @@ const Ie = {
381
382
  accessToolMetadata: !0,
382
383
  getWidgetState: !0,
383
384
  setWidgetState: !0,
385
+ setWidgetStateModelContext: !1,
384
386
  onToolCanceled: !1,
385
387
  setDisplayMode: !0,
386
388
  getHostContext: !1,
@@ -400,6 +402,7 @@ const Ie = {
400
402
  accessToolMetadata: !1,
401
403
  getWidgetState: !1,
402
404
  setWidgetState: !1,
405
+ setWidgetStateModelContext: !1,
403
406
  onToolCanceled: !1,
404
407
  setDisplayMode: !1,
405
408
  getHostContext: !1,
@@ -419,6 +422,7 @@ const Ie = {
419
422
  accessToolMetadata: !1,
420
423
  getWidgetState: !1,
421
424
  setWidgetState: !1,
425
+ setWidgetStateModelContext: !1,
422
426
  onToolCanceled: !1,
423
427
  setDisplayMode: !1,
424
428
  getHostContext: !1,
@@ -429,7 +433,7 @@ const Ie = {
429
433
  getTheme: !1,
430
434
  resize: !1
431
435
  };
432
- function ts(s) {
436
+ function ss(s) {
433
437
  switch (s) {
434
438
  case c.MCPApps:
435
439
  return { ...Ie };
@@ -445,7 +449,7 @@ function ts(s) {
445
449
  }
446
450
  }
447
451
  const Le = /* @__PURE__ */ new Set(["then", "catch", "finally"]);
448
- function M(s, e) {
452
+ function A(s, e) {
449
453
  return new Proxy(s, {
450
454
  get(t, r, n) {
451
455
  if (typeof r == "symbol" || Le.has(r)) {
@@ -459,7 +463,7 @@ Use \`const sdk = await ${e}();\` before accessing SDK methods.`
459
463
  }
460
464
  });
461
465
  }
462
- class Re {
466
+ class xe {
463
467
  constructor(e) {
464
468
  this.session = e;
465
469
  const t = e.getHostContext();
@@ -561,8 +565,10 @@ class Re {
561
565
  const e = this.globals.widgetState;
562
566
  return e || null;
563
567
  }
564
- setWidgetState(e) {
565
- this.globals.widgetState = e, this.session.request("ui/update-model-context", { state: e }).catch(() => {
568
+ setWidgetState(e, t) {
569
+ this.globals.widgetState = e;
570
+ const r = { state: e };
571
+ t?.content !== void 0 && (r.content = t.content), t?.structuredContent !== void 0 && (r.structuredContent = t.structuredContent), this.session.request("ui/update-model-context", r).catch(() => {
566
572
  }), this.notifySubscribers();
567
573
  }
568
574
  /**
@@ -594,7 +600,7 @@ class Re {
594
600
  }
595
601
  }
596
602
  const N = "openai:set_globals";
597
- class Oe {
603
+ class Re {
598
604
  sendMessageToHost(e) {
599
605
  return window.openai.sendFollowUpMessage({ prompt: e.content });
600
606
  }
@@ -617,7 +623,7 @@ class Oe {
617
623
  const e = window.openai.widgetState;
618
624
  return e || null;
619
625
  }
620
- setWidgetState(e) {
626
+ setWidgetState(e, t) {
621
627
  window.openai.setWidgetState(e);
622
628
  }
623
629
  async openLink(e) {
@@ -634,7 +640,7 @@ class Oe {
634
640
  };
635
641
  }
636
642
  }
637
- class xe {
643
+ class Oe {
638
644
  async sendMessageToHost(e) {
639
645
  throw console.warn("SalesforceACCChatSDK.sendMessageToHost: stub implementation", e), new Error("SalesforceACCChatSDK.sendMessageToHost not yet implemented");
640
646
  }
@@ -642,31 +648,31 @@ class xe {
642
648
  return console.warn("SalesforceACCChatSDK.followUpActions: stub implementation"), [];
643
649
  }
644
650
  }
645
- let S = null, O = null;
651
+ let S = null, R = null;
646
652
  function He(s) {
647
- return S || (S = qe(s).then((e) => (O = e, e))), S;
648
- }
649
- function ss() {
650
- return O;
653
+ return S || (S = qe(s).then((e) => (R = e, e))), S;
651
654
  }
652
655
  function rs() {
653
- S = null, O = null;
656
+ return R;
657
+ }
658
+ function ns() {
659
+ S = null, R = null;
654
660
  }
655
661
  function qe(s) {
656
- return M(
662
+ return A(
657
663
  (async () => {
658
664
  switch (C(s?.surface)) {
659
665
  case c.OpenAI:
660
- return new Oe();
666
+ return new Re();
661
667
  case c.WebApp:
662
668
  case c.Mosaic:
663
669
  return {};
664
670
  case c.SalesforceACC:
665
- return new xe();
671
+ return new Oe();
666
672
  case c.MicroFrontend:
667
673
  case c.MCPApps: {
668
674
  const t = await y.getInstance(s?.mcpApps);
669
- return t.handshakeSucceeded ? new Re(t) : {};
675
+ return t.handshakeSucceeded ? new xe(t) : {};
670
676
  }
671
677
  default:
672
678
  return {};
@@ -773,18 +779,18 @@ class Ue {
773
779
  return e ? { mode: e } : null;
774
780
  }
775
781
  }
776
- let T = null, x = null;
777
- function ns(s) {
778
- return T || (T = Ve(s).then((e) => (x = e, e))), T;
779
- }
780
- function is() {
781
- return x;
782
+ let T = null, O = null;
783
+ function is(s) {
784
+ return T || (T = Ve(s).then((e) => (O = e, e))), T;
782
785
  }
783
786
  function os() {
784
- T = null, x = null;
787
+ return O;
788
+ }
789
+ function as() {
790
+ T = null, O = null;
785
791
  }
786
792
  function Ve(s) {
787
- return M(
793
+ return A(
788
794
  (async () => {
789
795
  switch (C(s?.surface)) {
790
796
  case c.OpenAI:
@@ -806,7 +812,7 @@ function Ve(s) {
806
812
  "createViewSDK"
807
813
  );
808
814
  }
809
- function $e(s) {
815
+ function We(s) {
810
816
  return (e) => {
811
817
  const [t, r] = e;
812
818
  if (typeof t == "string" && !t.startsWith("http")) {
@@ -816,12 +822,12 @@ function $e(s) {
816
822
  return w(e);
817
823
  };
818
824
  }
819
- function We(s) {
825
+ function $e(s) {
820
826
  return (e) => w(_("Authorization", `Bearer ${s}`, e));
821
827
  }
822
828
  function Ke(s, e) {
823
829
  const t = [];
824
- return s && t.push($e(s)), e && t.push(We(e)), K({
830
+ return s && t.push(We(s)), e && t.push($e(e)), K({
825
831
  request: t
826
832
  }).service;
827
833
  }
@@ -832,7 +838,7 @@ function H(s) {
832
838
  try {
833
839
  return k(te(s));
834
840
  } catch (e) {
835
- return D(b(e));
841
+ return D(v(e));
836
842
  }
837
843
  }
838
844
  function q(s, e) {
@@ -841,7 +847,7 @@ function q(s, e) {
841
847
  );
842
848
  return t.length === 0 ? "unknown" : t.length === 1 ? e === void 0 || t[0].name?.value === e ? t[0].operation : "unknown" : e === void 0 ? "unknown" : t.find((r) => r.name?.value === e)?.operation ?? "unknown";
843
849
  }
844
- function b(s) {
850
+ function v(s) {
845
851
  if (s && typeof s == "object" && "data" in s) {
846
852
  const e = s.data;
847
853
  if (e && typeof e == "object" && "errors" in e && Array.isArray(e.errors))
@@ -864,7 +870,7 @@ async function j(s, { mutation: e, variables: t, operationName: r }) {
864
870
  };
865
871
  try {
866
872
  const a = await s({
867
- query: R(i),
873
+ query: x(i),
868
874
  variables: t,
869
875
  operationName: r
870
876
  });
@@ -873,13 +879,13 @@ async function j(s, { mutation: e, variables: t, operationName: r }) {
873
879
  errors: a.errors
874
880
  };
875
881
  } catch (a) {
876
- return { data: void 0, errors: b(a) };
882
+ return { data: void 0, errors: v(a) };
877
883
  }
878
884
  }
879
885
  function Q(s) {
880
886
  function e(r, n, i) {
881
887
  return s({
882
- query: R(r),
888
+ query: x(r),
883
889
  variables: n,
884
890
  operationName: i
885
891
  }).then(
@@ -887,7 +893,7 @@ function Q(s) {
887
893
  data: o.data ?? void 0,
888
894
  errors: o.errors
889
895
  }),
890
- (o) => ({ data: void 0, errors: b(o) })
896
+ (o) => ({ data: void 0, errors: v(o) })
891
897
  );
892
898
  }
893
899
  async function t({
@@ -903,30 +909,30 @@ function Q(s) {
903
909
  subscribe: () => E,
904
910
  refresh: L
905
911
  };
906
- const a = o.value, u = q(a, i);
907
- if (u !== "query")
912
+ const a = o.value, h = q(a, i);
913
+ if (h !== "query")
908
914
  return {
909
915
  data: void 0,
910
916
  errors: [
911
917
  {
912
- message: `DataSDK.graphql.query() requires a GraphQL query, received ${u}.`
918
+ message: `DataSDK.graphql.query() requires a GraphQL query, received ${h}.`
913
919
  }
914
920
  ],
915
921
  subscribe: () => E,
916
922
  refresh: L
917
923
  };
918
- const h = /* @__PURE__ */ new Set(), p = n, f = await e(a, p, i);
924
+ const d = /* @__PURE__ */ new Set(), p = n, f = await e(a, p, i);
919
925
  return {
920
926
  data: f.data,
921
927
  errors: f.errors,
922
928
  subscribe(l) {
923
- return h.add(l), () => {
924
- h.delete(l);
929
+ return d.add(l), () => {
930
+ d.delete(l);
925
931
  };
926
932
  },
927
933
  async refresh() {
928
934
  const l = await e(a, p, i);
929
- for (const d of h) d(l);
935
+ for (const u of d) u(l);
930
936
  }
931
937
  };
932
938
  }
@@ -993,7 +999,7 @@ class Je {
993
999
  })).structuredContent;
994
1000
  }
995
1001
  }
996
- const Xe = "X-SFDC-Client-Name", Ye = "X-SFDC-Client-Version", Ze = "@salesforce/platform-sdk", et = "9.1.0", tt = (s) => {
1002
+ const Xe = "X-SFDC-Client-Name", Ye = "X-SFDC-Client-Version", Ze = "@salesforce/platform-sdk", et = "9.4.0", tt = (s) => {
997
1003
  let e = _(Xe, Ze, s);
998
1004
  return e = _(Ye, et, e), w(e);
999
1005
  }, st = "X-CSRF-Token";
@@ -1002,8 +1008,8 @@ function rt(s, e = {}) {
1002
1008
  return async (n) => {
1003
1009
  const [i, o] = n, a = new Request(i, o);
1004
1010
  if (U(r, a.url) || nt(a.method) && U(t, a.url)) {
1005
- const h = await s.getToken();
1006
- n = _(st, h, n);
1011
+ const d = await s.getToken();
1012
+ n = _(st, d, n);
1007
1013
  }
1008
1014
  return w(n);
1009
1015
  };
@@ -1125,7 +1131,7 @@ function J() {
1125
1131
  "X-Chatter-Entity-Encoding": "false"
1126
1132
  };
1127
1133
  }
1128
- const $ = 300;
1134
+ const W = 300;
1129
1135
  function dt(s, e) {
1130
1136
  try {
1131
1137
  return JSON.parse(JSON.stringify(s));
@@ -1136,16 +1142,25 @@ function dt(s, e) {
1136
1142
  throw n.cause = t, n;
1137
1143
  }
1138
1144
  }
1139
- class ht extends ce {
1145
+ function ht(s) {
1146
+ if (typeof s == "object" && s.type === "max-age") {
1147
+ const e = s.maxAge;
1148
+ return Number.isFinite(e) && e >= 0 ? e : W;
1149
+ }
1150
+ return W;
1151
+ }
1152
+ class ft extends ce {
1140
1153
  constructor(e, t, r) {
1141
1154
  super(t), this.url = r, this.query = e.query, this.normalizedOperationName = e.operationName ?? "", this.normalizedVariables = dt(
1142
1155
  e.variables ?? {},
1143
1156
  this.normalizedOperationName
1144
- );
1157
+ ), this.cacheControl = e.cacheControl, this.resolvedMaxAge = ht(e.cacheControl);
1145
1158
  }
1146
1159
  query;
1147
1160
  normalizedVariables;
1148
1161
  normalizedOperationName;
1162
+ cacheControl;
1163
+ resolvedMaxAge;
1149
1164
  get fetchParams() {
1150
1165
  return [
1151
1166
  this.url,
@@ -1192,7 +1207,7 @@ class ht extends ce {
1192
1207
  metadata: {
1193
1208
  cacheControl: {
1194
1209
  type: "max-age",
1195
- maxAge: $,
1210
+ maxAge: this.resolvedMaxAge,
1196
1211
  generatedTime: r
1197
1212
  }
1198
1213
  }
@@ -1201,10 +1216,11 @@ class ht extends ce {
1201
1216
  return w(void 0);
1202
1217
  }
1203
1218
  get cacheControlStrategyConfig() {
1204
- return {
1219
+ const e = Math.floor(Date.now() / 1e3);
1220
+ return this.cacheControl === "no-cache" ? { type: "no-cache", now: e } : this.cacheControl === "only-if-cached" ? { type: "only-if-cached", now: e } : {
1205
1221
  type: "max-age",
1206
- requestMaxAge: $,
1207
- now: Math.floor(Date.now() / 1e3)
1222
+ requestMaxAge: this.resolvedMaxAge,
1223
+ now: e
1208
1224
  };
1209
1225
  }
1210
1226
  responseHasErrors(e) {
@@ -1214,28 +1230,28 @@ class ht extends ce {
1214
1230
  return this.responseHasErrors(e) ? D(new ee(e)) : k(e);
1215
1231
  }
1216
1232
  }
1217
- function ft(s) {
1233
+ function pt(s) {
1218
1234
  return (e) => {
1219
1235
  if (e.isOk()) {
1220
1236
  const t = e.value;
1221
1237
  z(t), s({ data: t, errors: void 0 });
1222
1238
  } else
1223
- s({ data: void 0, errors: b(e.error) });
1239
+ s({ data: void 0, errors: v(e.error) });
1224
1240
  };
1225
1241
  }
1226
- async function pt(s) {
1242
+ async function gt(s) {
1227
1243
  let e, t, r;
1228
1244
  try {
1229
1245
  const n = await s.execute();
1230
- n.isOk() ? (e = n.value.data, z(e), r = (i) => n.value.subscribe(i)) : (t = b(n.error.failure), r = (i) => n.error.subscribe(i));
1246
+ n.isOk() ? (e = n.value.data, z(e), r = (i) => n.value.subscribe(i)) : (t = v(n.error.failure), r = (i) => n.error.subscribe(i));
1231
1247
  } catch (n) {
1232
- t = b(n);
1248
+ t = v(n);
1233
1249
  }
1234
1250
  return {
1235
1251
  data: e,
1236
1252
  errors: t,
1237
1253
  subscribe(n) {
1238
- return r ? r(ft(n)) : E;
1254
+ return r ? r(pt(n)) : E;
1239
1255
  },
1240
1256
  async refresh() {
1241
1257
  await s.refresh();
@@ -1259,50 +1275,52 @@ function mt({
1259
1275
  async function n({
1260
1276
  query: i,
1261
1277
  variables: o,
1262
- operationName: a
1278
+ operationName: a,
1279
+ cacheControl: h
1263
1280
  }) {
1264
- const u = H(i);
1265
- if (u.isErr()) return I(u.error);
1266
- const h = u.value, p = q(h, a);
1267
- if (p !== "query")
1281
+ const d = H(i);
1282
+ if (d.isErr()) return I(d.error);
1283
+ const p = d.value, f = q(p, a);
1284
+ if (f !== "query")
1268
1285
  return I([
1269
1286
  {
1270
- message: `DataSDK.graphql.query() requires a GraphQL query, received ${p}.`
1287
+ message: `DataSDK.graphql.query() requires a GraphQL query, received ${f}.`
1271
1288
  }
1272
1289
  ]);
1273
- let f;
1290
+ let l;
1274
1291
  try {
1275
- f = new ht(
1292
+ l = new ft(
1276
1293
  {
1277
- query: R(h),
1294
+ query: x(p),
1278
1295
  variables: o,
1279
- operationName: a
1296
+ operationName: a,
1297
+ cacheControl: h
1280
1298
  },
1281
1299
  r,
1282
1300
  e
1283
1301
  );
1284
- } catch (l) {
1285
- return I(b(l));
1302
+ } catch (u) {
1303
+ return I(v(u));
1286
1304
  }
1287
- return pt(f);
1305
+ return gt(l);
1288
1306
  }
1289
1307
  return {
1290
1308
  query: n,
1291
1309
  mutate: (i) => j(t, i)
1292
1310
  };
1293
1311
  }
1294
- const gt = 1, yt = `@salesforce/platform-sdk-data_v${gt}`, X = G(), wt = `${X}/ui-api`, W = `${X}/graphql`;
1312
+ const yt = 1, wt = `@salesforce/platform-sdk-data_v${yt}`, X = G(), vt = `${X}/ui-api`, $ = `${X}/graphql`;
1295
1313
  class bt {
1296
1314
  baseUrl;
1297
1315
  clientFetch;
1298
1316
  onStatus;
1299
1317
  graphql;
1300
1318
  constructor(e) {
1301
- const t = vt();
1302
- this.baseUrl = Ct(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = lt({
1319
+ const t = Ct();
1320
+ this.baseUrl = St(e?.basePath ?? t.apiPath), this.onStatus = e?.onStatus ?? {}, this.clientFetch = lt({
1303
1321
  csrf: {
1304
- endpoint: `${this.baseUrl}${wt}/session/csrf`,
1305
- cacheName: yt,
1322
+ endpoint: `${this.baseUrl}${vt}/session/csrf`,
1323
+ cacheName: wt,
1306
1324
  protectedUrls: ["services/data/v", "services/apexrest"],
1307
1325
  alwaysProtectedUrls: ["services/apexrest"]
1308
1326
  }
@@ -1310,7 +1328,7 @@ class bt {
1310
1328
  const n = ut((i, o) => this.fetch(i, o));
1311
1329
  this.graphql = mt({
1312
1330
  bundle: n,
1313
- url: W,
1331
+ url: $,
1314
1332
  executeRaw: this.executeRawGraphQL.bind(this)
1315
1333
  });
1316
1334
  }
@@ -1329,7 +1347,7 @@ class bt {
1329
1347
  variables: t,
1330
1348
  operationName: r
1331
1349
  }) {
1332
- return (await this.fetch(W, {
1350
+ return (await this.fetch($, {
1333
1351
  method: "POST",
1334
1352
  body: JSON.stringify({ query: e, variables: t, operationName: r }),
1335
1353
  headers: J()
@@ -1349,24 +1367,24 @@ class bt {
1349
1367
  return e;
1350
1368
  }
1351
1369
  }
1352
- function vt() {
1370
+ function Ct() {
1353
1371
  return {
1354
1372
  apiPath: globalThis.SFDC_ENV?.apiPath
1355
1373
  };
1356
1374
  }
1357
- function Ct(s) {
1375
+ function St(s) {
1358
1376
  if (!s || s === "/") return "";
1359
1377
  let e = s;
1360
1378
  return e.startsWith("/") || (e = `/${e}`), e.endsWith("/") && (e = e.slice(0, -1)), e;
1361
1379
  }
1362
- function as(s, ...e) {
1380
+ function cs(s, ...e) {
1363
1381
  let t = s[0] ?? "";
1364
1382
  for (let r = 0; r < e.length; r += 1)
1365
1383
  t += String(e[r]) + (s[r + 1] ?? "");
1366
1384
  return t;
1367
1385
  }
1368
- function cs(s) {
1369
- return M(
1386
+ function ls(s) {
1387
+ return A(
1370
1388
  (async () => {
1371
1389
  switch (C(s?.surface)) {
1372
1390
  case c.OpenAI:
@@ -1386,8 +1404,8 @@ function cs(s) {
1386
1404
  "createDataSDK"
1387
1405
  );
1388
1406
  }
1389
- function ls(s) {
1390
- return M(
1407
+ function us(s) {
1408
+ return A(
1391
1409
  (async () => {
1392
1410
  switch (C(s?.surface)) {
1393
1411
  case c.OpenAI:
@@ -1409,13 +1427,13 @@ function ls(s) {
1409
1427
  "createLightningSDK"
1410
1428
  );
1411
1429
  }
1412
- function St(s) {
1430
+ function Tt(s) {
1413
1431
  let e = "";
1414
1432
  for (let r = 0; r < s.length; r += 8192)
1415
1433
  e += String.fromCharCode.apply(null, Array.from(s.subarray(r, r + 8192)));
1416
1434
  return btoa(e);
1417
1435
  }
1418
- class Tt {
1436
+ class _t {
1419
1437
  entries = [];
1420
1438
  totalBytes = 0;
1421
1439
  maxBufferSize;
@@ -1430,7 +1448,7 @@ class Tt {
1430
1448
  return this.entries.length === 0;
1431
1449
  }
1432
1450
  enqueue(e, t) {
1433
- const r = St(e), n = {
1451
+ const r = Tt(e), n = {
1434
1452
  data: r,
1435
1453
  traceId: t?.traceId,
1436
1454
  instanceId: t?.instanceId,
@@ -1452,8 +1470,8 @@ class Tt {
1452
1470
  e > 0 && this.onError?.({ reason: "buffer_overflow", droppedCount: e });
1453
1471
  }
1454
1472
  }
1455
- const _t = "telemetry/upload";
1456
- class Et {
1473
+ const Et = "telemetry/upload";
1474
+ class Mt {
1457
1475
  buffer;
1458
1476
  sdk;
1459
1477
  onError;
@@ -1472,7 +1490,7 @@ class Et {
1472
1490
  if (this.buffer.isEmpty || !this.sdk.callTool)
1473
1491
  return;
1474
1492
  const t = this.buffer.drain().map(At);
1475
- this.sdk.callTool({ toolName: _t, params: { envelopes: t } }).catch((r) => {
1493
+ this.sdk.callTool({ toolName: Et, params: { inputs: [{ envelopes: t }] } }).catch((r) => {
1476
1494
  this.onError?.({ reason: "tool_call_failed", error: r });
1477
1495
  });
1478
1496
  }
@@ -1484,25 +1502,25 @@ function At(s) {
1484
1502
  const e = { base64Env: s.data };
1485
1503
  return s.traceId !== void 0 && (e.traceId = s.traceId), e;
1486
1504
  }
1487
- const Mt = 65536, It = 3e4;
1488
- function us(s) {
1505
+ const It = 65536, kt = 3e4;
1506
+ function ds(s) {
1489
1507
  const {
1490
1508
  sdk: e,
1491
- maxBufferSize: t = Mt,
1492
- flushInterval: r = It,
1509
+ maxBufferSize: t = It,
1510
+ flushInterval: r = kt,
1493
1511
  onError: n
1494
- } = s, i = new Tt({ maxBufferSize: t, onError: n }), o = new Et(i, e, { flushInterval: r, onError: n });
1512
+ } = s, i = new _t({ maxBufferSize: t, onError: n }), o = new Mt(i, e, { flushInterval: r, onError: n });
1495
1513
  return {
1496
- enqueue(a, u) {
1497
- i.enqueue(a, u);
1514
+ enqueue(a, h) {
1515
+ i.enqueue(a, h);
1498
1516
  },
1499
1517
  dispose() {
1500
1518
  o.dispose();
1501
1519
  }
1502
1520
  };
1503
1521
  }
1504
- const kt = 1e4, Dt = 10, Pt = 10, Lt = 250, Rt = 1e3;
1505
- function v(s, e) {
1522
+ const Dt = 1e4, Pt = 10, Lt = 10, xt = 250, Rt = 1e3;
1523
+ function b(s, e) {
1506
1524
  if (s !== void 0 && (typeof s != "number" || !Number.isFinite(s) || s <= 0))
1507
1525
  throw new Error(`${e}, if defined, must be a finite number greater than 0`);
1508
1526
  }
@@ -1510,7 +1528,7 @@ function Ot(s, e) {
1510
1528
  if (typeof s != "function")
1511
1529
  throw new Error(`${e} must be a function`);
1512
1530
  }
1513
- class xt {
1531
+ class Ht {
1514
1532
  _collector;
1515
1533
  _onEnvelope;
1516
1534
  _onError;
@@ -1531,7 +1549,7 @@ class xt {
1531
1549
  _lastClickTriggeredAt = 0;
1532
1550
  _isDisposed = !1;
1533
1551
  constructor(e) {
1534
- Ot(e?.onEnvelope, "options.onEnvelope"), v(e.uploadInterval, "options.uploadInterval"), v(e.messagesLimit, "options.messagesLimit"), v(e.metricsLimit, "options.metricsLimit"), v(e.maxUniqueSchemas, "options.maxUniqueSchemas"), v(e.clickUploadDelay, "options.clickUploadDelay"), v(e.clickTriggerCooldown, "options.clickTriggerCooldown"), this._onEnvelope = e.onEnvelope, this._onError = e.onError, this._messagesLimit = e.messagesLimit ?? Dt, this._metricsLimit = e.metricsLimit ?? Pt, this._uploadInterval = e.uploadInterval ?? kt, this._clickUploadDelay = e.clickUploadDelay ?? Lt, this._clickTriggerCooldown = e.clickTriggerCooldown ?? Rt, this._enableClickTrigger = e.enableClickTrigger !== !1, this._enableVisibilityTrigger = e.enableVisibilityTrigger !== !1, this._collector = new ue({
1552
+ Ot(e?.onEnvelope, "options.onEnvelope"), b(e.uploadInterval, "options.uploadInterval"), b(e.messagesLimit, "options.messagesLimit"), b(e.metricsLimit, "options.metricsLimit"), b(e.maxUniqueSchemas, "options.maxUniqueSchemas"), b(e.clickUploadDelay, "options.clickUploadDelay"), b(e.clickTriggerCooldown, "options.clickTriggerCooldown"), this._onEnvelope = e.onEnvelope, this._onError = e.onError, this._messagesLimit = e.messagesLimit ?? Pt, this._metricsLimit = e.metricsLimit ?? Lt, this._uploadInterval = e.uploadInterval ?? Dt, this._clickUploadDelay = e.clickUploadDelay ?? xt, this._clickTriggerCooldown = e.clickTriggerCooldown ?? Rt, this._enableClickTrigger = e.enableClickTrigger !== !1, this._enableVisibilityTrigger = e.enableVisibilityTrigger !== !1, this._collector = new ue({
1535
1553
  environment: e.environment,
1536
1554
  maxUniqueSchemas: e.maxUniqueSchemas
1537
1555
  }), this._restartInterval(), this._attachWindowListeners();
@@ -1624,13 +1642,13 @@ class xt {
1624
1642
  }
1625
1643
  }
1626
1644
  }
1627
- function Ht(s, e) {
1645
+ function qt(s, e) {
1628
1646
  if (!s)
1629
1647
  throw new Error("instrumentedApp is required");
1630
- const t = new xt(e);
1648
+ const t = new Ht(e);
1631
1649
  return s.registerLogCollector(t), s.registerMetricsCollector(t), e.enableClickTrigger !== !1 && s.activateClickTracker?.(), t;
1632
1650
  }
1633
- function qt(s) {
1651
+ function Nt(s) {
1634
1652
  const e = (r, n, i, o, a) => {
1635
1653
  s.error(a ?? r);
1636
1654
  }, t = (r) => {
@@ -1640,33 +1658,33 @@ function qt(s) {
1640
1658
  window.removeEventListener("error", e), window.removeEventListener("unhandledrejection", t);
1641
1659
  };
1642
1660
  }
1643
- function g(s, e) {
1661
+ function m(s, e) {
1644
1662
  return { surface: e };
1645
1663
  }
1646
- const Nt = {
1664
+ const Ft = {
1647
1665
  callTool: {
1648
1666
  isAsync: !0,
1649
1667
  extractTags: (s, e) => ({ toolName: s[0]?.toolName ?? "unknown", surface: e })
1650
1668
  },
1651
1669
  setWidgetState: {
1652
1670
  isAsync: !1,
1653
- extractTags: g
1671
+ extractTags: m
1654
1672
  },
1655
1673
  getWidgetState: {
1656
1674
  isAsync: !1,
1657
- extractTags: g
1675
+ extractTags: m
1658
1676
  },
1659
1677
  sendMessageToHost: {
1660
1678
  isAsync: !0,
1661
- extractTags: g
1679
+ extractTags: m
1662
1680
  },
1663
1681
  openLink: {
1664
1682
  isAsync: !0,
1665
- extractTags: g
1683
+ extractTags: m
1666
1684
  },
1667
1685
  subscribe: {
1668
1686
  isAsync: !1,
1669
- extractTags: g,
1687
+ extractTags: m,
1670
1688
  wrapArgs: (s, e) => {
1671
1689
  const t = s[0];
1672
1690
  return [
@@ -1686,39 +1704,39 @@ const Nt = {
1686
1704
  },
1687
1705
  accessToolOutput: {
1688
1706
  isAsync: !1,
1689
- extractTags: g
1707
+ extractTags: m
1690
1708
  },
1691
1709
  accessToolInput: {
1692
1710
  isAsync: !1,
1693
- extractTags: g
1711
+ extractTags: m
1694
1712
  },
1695
1713
  accessToolMetadata: {
1696
1714
  isAsync: !1,
1697
- extractTags: g
1715
+ extractTags: m
1698
1716
  }
1699
1717
  };
1700
- function Ft(s, e, t) {
1718
+ function Ut(s, e, t) {
1701
1719
  return new Proxy(s, {
1702
1720
  get(r, n, i) {
1703
- const o = Reflect.get(r, n, i), a = Nt[n];
1704
- return !a || typeof o != "function" ? o : (...u) => {
1705
- const h = a.extractTags(u, t), p = a.wrapArgs ? a.wrapArgs(u, e) : u, f = `sdk.${String(n)}`;
1721
+ const o = Reflect.get(r, n, i), a = Ft[n];
1722
+ return !a || typeof o != "function" ? o : (...h) => {
1723
+ const d = a.extractTags(h, t), p = a.wrapArgs ? a.wrapArgs(h, e) : h, f = `sdk.${String(n)}`;
1706
1724
  return a.isAsync ? e.activityAsync(f, async () => {
1707
1725
  try {
1708
1726
  const l = await o.apply(
1709
1727
  r,
1710
1728
  p
1711
1729
  );
1712
- return e.incrementCounter(f, 1, !1, h), l;
1730
+ return e.incrementCounter(f, 1, !1, d), l;
1713
1731
  } catch (l) {
1714
- throw e.incrementCounter(f, 1, !0, h), l;
1732
+ throw e.incrementCounter(f, 1, !0, d), l;
1715
1733
  }
1716
- }) : (e.incrementCounter(f, 1, !1, h), o.apply(r, p));
1734
+ }) : (e.incrementCounter(f, 1, !1, d), o.apply(r, p));
1717
1735
  };
1718
1736
  }
1719
1737
  });
1720
1738
  }
1721
- async function ds(s) {
1739
+ async function hs(s) {
1722
1740
  const { appId: e, clientSessionId: t } = s, r = C(), n = Date.now(), i = s.sdk ?? await He(), o = de("mcp-widget", {
1723
1741
  appPayloadProvider: {
1724
1742
  getPayload: () => ({
@@ -1727,75 +1745,75 @@ async function ds(s) {
1727
1745
  })
1728
1746
  },
1729
1747
  clientSessionId: t
1730
- }), a = o, u = Ft(i, a, r), h = qt(a);
1748
+ }), a = o, h = Ut(i, a, r), d = Nt(a);
1731
1749
  let p;
1732
- s.transport && (p = Ht(o, {
1733
- onEnvelope: (d) => {
1734
- s.transport.enqueue(d);
1750
+ s.transport && (p = qt(o, {
1751
+ onEnvelope: (u) => {
1752
+ s.transport.enqueue(u);
1735
1753
  }
1736
1754
  }));
1737
1755
  let f, l = !1;
1738
1756
  return {
1739
- instrumentedSDK: u,
1757
+ instrumentedSDK: h,
1740
1758
  app: o,
1741
- trackEvent(d, m) {
1759
+ trackEvent(u, g) {
1742
1760
  l || a.log(ye, {
1743
- eventName: d,
1744
- properties: m ? JSON.stringify(m) : ""
1761
+ eventName: u,
1762
+ properties: g ? JSON.stringify(g) : ""
1745
1763
  });
1746
1764
  },
1747
- trackInteraction(d, m) {
1748
- l || a.log(ge, {
1749
- elementId: d,
1750
- properties: m ? JSON.stringify(m) : ""
1765
+ trackInteraction(u, g) {
1766
+ l || a.log(me, {
1767
+ elementId: u,
1768
+ properties: g ? JSON.stringify(g) : ""
1751
1769
  });
1752
1770
  },
1753
- trackError(d, m) {
1754
- l || a.error(d, me, {
1755
- properties: m ? JSON.stringify(m) : ""
1771
+ trackError(u, g) {
1772
+ l || a.error(u, ge, {
1773
+ properties: g ? JSON.stringify(g) : ""
1756
1774
  });
1757
1775
  },
1758
- trackPageView(d) {
1759
- l || d !== f && (f = d, a.log(pe, { componentRef: d }));
1776
+ trackPageView(u) {
1777
+ l || u !== f && (f = u, a.log(pe, { componentRef: u }));
1760
1778
  },
1761
1779
  dispose() {
1762
1780
  if (l) return;
1763
- l = !0, h();
1764
- const d = Date.now() - n;
1765
- a.log(fe, { durationMs: d }), p?.dispose();
1781
+ l = !0, d();
1782
+ const u = Date.now() - n;
1783
+ a.log(fe, { durationMs: u }), p?.dispose();
1766
1784
  }
1767
1785
  };
1768
1786
  }
1769
1787
  export {
1770
1788
  _e as JsonRpcClient,
1771
- Re as MCPAppsChatSDK,
1789
+ xe as MCPAppsChatSDK,
1772
1790
  Fe as MCPAppsViewSDK,
1773
1791
  y as McpAppsSession,
1774
- es as MessageChannelTransport,
1792
+ ts as MessageChannelTransport,
1775
1793
  c as Surface,
1776
- xt as TelemetryUploader,
1794
+ Ht as TelemetryUploader,
1777
1795
  Te as WindowPostMessageTransport,
1778
- ds as createAnalytics,
1796
+ hs as createAnalytics,
1779
1797
  qe as createChatSDK,
1780
- cs as createDataSDK,
1781
- ls as createLightningSDK,
1782
- us as createTelemetryTransport,
1798
+ ls as createDataSDK,
1799
+ us as createLightningSDK,
1800
+ ds as createTelemetryTransport,
1783
1801
  Ve as createViewSDK,
1784
1802
  He as getChatSDK,
1785
- ss as getChatSDKSync,
1803
+ rs as getChatSDKSync,
1786
1804
  C as getSurface,
1787
- ts as getSurfaceCapabilities,
1788
- ns as getViewSDK,
1789
- is as getViewSDKSync,
1790
- as as gql,
1791
- A as isJsonRpcBase,
1805
+ ss as getSurfaceCapabilities,
1806
+ is as getViewSDK,
1807
+ os as getViewSDKSync,
1808
+ cs as gql,
1809
+ M as isJsonRpcBase,
1792
1810
  B as isJsonRpcErrorResponse,
1793
1811
  Se as isJsonRpcNotification,
1794
- Zt as isJsonRpcRequest,
1812
+ es as isJsonRpcRequest,
1795
1813
  Ce as isJsonRpcResponse,
1796
- ve as isJsonRpcSuccessResponse,
1797
- Ht as registerTelemetryUploader,
1798
- rs as resetChatSDK,
1799
- os as resetViewSDK,
1800
- M as wrapSDKPromise
1814
+ be as isJsonRpcSuccessResponse,
1815
+ qt as registerTelemetryUploader,
1816
+ ns as resetChatSDK,
1817
+ as as resetViewSDK,
1818
+ A as wrapSDKPromise
1801
1819
  };