@pluno/product-agent-web 0.1.101 → 0.1.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -39,6 +39,7 @@ export type ProductAgentMessage = {
39
39
  attachments?: ProductAgentAttachment[];
40
40
  loading?: boolean;
41
41
  retryable?: boolean;
42
+ securitySettingsUrl?: string;
42
43
  };
43
44
  export type ProductAgentAttachment = {
44
45
  id?: string;
@@ -102,6 +103,7 @@ export type ProductAgentState = {
102
103
  isThinking: boolean;
103
104
  lastError: string | null;
104
105
  lastErrorCode: string | null;
106
+ lastErrorSecuritySettingsUrl: string | null;
105
107
  };
106
108
  export type ProductAgentInitOptions = {
107
109
  token?: string;
@@ -263,7 +263,7 @@ function J(e) {
263
263
  return `${H}${e}`;
264
264
  }
265
265
  const Y = "pluno.productAgent.transportId", Te = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", we = 50, Ie = globalThis.setTimeout.bind(globalThis);
266
- let P = null;
266
+ let U = null;
267
267
  const q = /* @__PURE__ */ new Set();
268
268
  async function Ae(e = $t()) {
269
269
  const t = e.randomUUID(), s = e.storage.getItem(Y);
@@ -302,13 +302,13 @@ async function Ae(e = $t()) {
302
302
  };
303
303
  }
304
304
  async function Se() {
305
- P || (P = Ae($t()), P.then((n) => {
305
+ U || (U = Ae($t()), U.then((n) => {
306
306
  const r = (i) => {
307
- i.persisted || (n.release(), P = null, q.clear(), window.removeEventListener("pagehide", r));
307
+ i.persisted || (n.release(), U = null, q.clear(), window.removeEventListener("pagehide", r));
308
308
  };
309
309
  window.addEventListener("pagehide", r);
310
310
  }));
311
- const e = await P, t = ke();
311
+ const e = await U, t = ke();
312
312
  q.add(t);
313
313
  let s = !1;
314
314
  return {
@@ -368,7 +368,7 @@ function Re() {
368
368
  }
369
369
  };
370
370
  }
371
- const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ce = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', _e = ".pluno-pa-widget__panel", be = ".pluno-pa-widget__timeline", St = `${rt}[data-pluno-sdk-preview-channel]`, Me = "https://app.pluno.ai", Pe = "gpt-5.6-terra", Ue = 2e4, De = 1e4, ve = 1e4, Ne = 1e4, Oe = 1e4, Le = 1e3, kt = 3e4, Et = 0.2, Rt = 6e4, Be = 15e3, N = 8, qe = 15e3, xe = 2e3, Fe = 1e3, He = 100, We = 8e3, je = 15e3, Ct = 3, $e = [300, 1e3], pt = 64e3, Z = 4e3, ft = 30, ze = 2e3, Ge = 1e3, Xe = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", Ke = 100, zt = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", Je = 100;
371
+ const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ce = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', _e = ".pluno-pa-widget__panel", be = ".pluno-pa-widget__timeline", St = `${rt}[data-pluno-sdk-preview-channel]`, Me = "https://app.pluno.ai", Ue = "gpt-5.6-terra", Pe = 2e4, De = 1e4, ve = 1e4, Ne = 1e4, Oe = 1e4, Le = 1e3, kt = 3e4, Et = 0.2, Rt = 6e4, Be = 15e3, N = 8, qe = 15e3, xe = 2e3, Fe = 1e3, He = 100, We = 8e3, je = 15e3, Ct = 3, $e = [300, 1e3], pt = 64e3, Z = 4e3, ft = 30, ze = 2e3, Ge = 1e3, Xe = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", Ke = 100, zt = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", Je = 100;
372
372
  function O(e, t = 0) {
373
373
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
374
374
  return Math.max(t, s);
@@ -412,7 +412,7 @@ class Gt {
412
412
  }), this.queuedClientEvents = un(
413
413
  rn(t.clientId),
414
414
  an(t.clientId)
415
- ), U(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = me({
415
+ ), P(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = me({
416
416
  clientId: t.clientId,
417
417
  canDeliver: (r) => r.sessionId === this.state.sessionId,
418
418
  deliver: async (r) => {
@@ -481,14 +481,15 @@ class Gt {
481
481
  assistantDraftRunId: null,
482
482
  isThinking: !1,
483
483
  lastError: null,
484
- lastErrorCode: null
484
+ lastErrorCode: null,
485
+ lastErrorSecuritySettingsUrl: null
485
486
  };
486
487
  static async init(t) {
487
488
  const s = await Se(), n = new Gt({
488
489
  ...t,
489
490
  backendUrl: gs(t.backendUrl ?? Me),
490
491
  clientId: t.clientId ?? Ms(),
491
- model: t.model ?? Pe
492
+ model: t.model ?? Ue
492
493
  }, s);
493
494
  try {
494
495
  de().catch((r) => {
@@ -831,7 +832,7 @@ class Gt {
831
832
  });
832
833
  }
833
834
  send(t) {
834
- this.sendNow(k(t)) || (this.queuedClientEvents.push(t), U(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
835
+ this.sendNow(k(t)) || (this.queuedClientEvents.push(t), P(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
835
836
  }
836
837
  async getUploadToken() {
837
838
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -889,14 +890,14 @@ class Gt {
889
890
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
890
891
  return;
891
892
  const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
892
- U(this.options.clientId, this.queuedClientEvents);
893
+ P(this.options.clientId, this.queuedClientEvents);
893
894
  for (let s = 0; s < t.length; s += 1) {
894
895
  const n = t[s];
895
896
  if (!this.sendNow(k(n))) {
896
- this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), U(this.options.clientId, this.queuedClientEvents);
897
+ this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), P(this.options.clientId, this.queuedClientEvents);
897
898
  return;
898
899
  }
899
- U(this.options.clientId, this.queuedClientEvents);
900
+ P(this.options.clientId, this.queuedClientEvents);
900
901
  }
901
902
  }
902
903
  handleServerEvent(t) {
@@ -917,7 +918,7 @@ class Gt {
917
918
  normalizedAppearance: s
918
919
  }), this.runtimeHelperJavascript = Cs(t.runtimeHelpers)?.javascript ?? null;
919
920
  const r = Mt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
920
- user: Ps(t.user),
921
+ user: Us(t.user),
921
922
  status: "connected"
922
923
  };
923
924
  (i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !As() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
@@ -951,8 +952,8 @@ class Gt {
951
952
  return !Dt(h) && (!n || !at(h));
952
953
  }), i = xs(
953
954
  this.state.messages,
954
- Us(r, this.options.backendUrl)
955
- ), o = Ut(i), c = s.some(
955
+ Ps(r, this.options.backendUrl)
956
+ ), o = Pt(i), c = s.some(
956
957
  (a) => Nt(
957
958
  v(a),
958
959
  this.state.assistantDraft,
@@ -1017,7 +1018,7 @@ class Gt {
1017
1018
  n.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1018
1019
  const r = t.item.data;
1019
1020
  Js(r) && this.clearRunAckResyncRetryTimer();
1020
- const i = qs(this.state.messages, n), o = Ut(i), c = Nt(
1021
+ const i = qs(this.state.messages, n), o = Pt(i), c = Nt(
1021
1022
  r,
1022
1023
  this.state.assistantDraft,
1023
1024
  this.state.assistantDraftRespondsToUserMessageId,
@@ -1076,7 +1077,8 @@ class Gt {
1076
1077
  status: "error",
1077
1078
  isThinking: !1,
1078
1079
  lastError: c.message,
1079
- lastErrorCode: typeof t.code == "string" ? t.code : null
1080
+ lastErrorCode: typeof t.code == "string" ? t.code : null,
1081
+ lastErrorSecuritySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : null
1080
1082
  }), this.clearThinkingWatchdog(), this.emit("error", c);
1081
1083
  }
1082
1084
  }
@@ -1376,7 +1378,7 @@ class Gt {
1376
1378
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1377
1379
  this.socket === t && (y("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1378
1380
  }, De));
1379
- }, Ue);
1381
+ }, Pe);
1380
1382
  }
1381
1383
  stopHeartbeat() {
1382
1384
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1400,7 +1402,8 @@ class Gt {
1400
1402
  this.state = {
1401
1403
  ...this.state,
1402
1404
  ...t,
1403
- ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
1405
+ ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1406
+ ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1404
1407
  }, nn(this.options.clientId, this.state), this.emit("state", this.getState());
1405
1408
  }
1406
1409
  emit(t, s) {
@@ -2017,7 +2020,7 @@ function Ms() {
2017
2020
  function B() {
2018
2021
  return crypto.randomUUID();
2019
2022
  }
2020
- function Ps(e) {
2023
+ function Us(e) {
2021
2024
  if (!e || typeof e != "object")
2022
2025
  return null;
2023
2026
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2028,7 +2031,7 @@ function Ps(e) {
2028
2031
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2029
2032
  } : null;
2030
2033
  }
2031
- function Us(e, t) {
2034
+ function Ps(e, t) {
2032
2035
  return Array.isArray(e) ? lt(
2033
2036
  ut(
2034
2037
  e.map((s) => Kt(s, t)).filter((s) => s !== null)
@@ -2098,7 +2101,8 @@ function Kt(e, t) {
2098
2101
  ...C(r) ? { runId: C(r) } : {},
2099
2102
  dataType: String(r.type),
2100
2103
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
2101
- ...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {}
2104
+ ...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {},
2105
+ ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2102
2106
  } : null;
2103
2107
  }
2104
2108
  function vs(e) {
@@ -2191,13 +2195,13 @@ function Ws(e, t) {
2191
2195
  return n.splice(s, 1), n;
2192
2196
  }
2193
2197
  function Yt(e, t) {
2194
- const s = Pt(e), n = Pt(t);
2198
+ const s = Ut(e), n = Ut(t);
2195
2199
  return s && n ? s === n : e.content === t.content;
2196
2200
  }
2197
2201
  function mt(e) {
2198
2202
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2199
2203
  }
2200
- function Pt(e) {
2204
+ function Ut(e) {
2201
2205
  const t = e.clientMessageId;
2202
2206
  if (t)
2203
2207
  return t;
@@ -2206,7 +2210,7 @@ function Pt(e) {
2206
2210
  );
2207
2211
  return n ? e.id.slice(n.length) : null;
2208
2212
  }
2209
- function Ut(e) {
2213
+ function Pt(e) {
2210
2214
  const t = Vt(e);
2211
2215
  if (t === null)
2212
2216
  return !1;
@@ -2463,7 +2467,7 @@ function rn(e) {
2463
2467
  return [];
2464
2468
  }
2465
2469
  }
2466
- function U(e, t) {
2470
+ function P(e, t) {
2467
2471
  try {
2468
2472
  const s = t.filter(wt);
2469
2473
  if (s.length === 0) {
@@ -2622,6 +2626,7 @@ function gn(e) {
2622
2626
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
2623
2627
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
2624
2628
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
2629
+ securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
2625
2630
  attachments: Qt(t.attachments)?.map(It),
2626
2631
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2627
2632
  };
@@ -2829,7 +2834,7 @@ function bn(e) {
2829
2834
  function Mn(e) {
2830
2835
  return e === 401 || e === 403;
2831
2836
  }
2832
- const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Pn = "[REDACTED_SIGNED_URL]", Un = 20, Dn = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, ne = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, re = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ie = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, oe = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, vn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Nn = /\bhttps?:\/\/[^\s"'<>]+/gi, On = /[),.;\]]+$/;
2837
+ const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Un = "[REDACTED_SIGNED_URL]", Pn = 20, Dn = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, ne = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, re = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ie = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, oe = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, vn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Nn = /\bhttps?:\/\/[^\s"'<>]+/gi, On = /[),.;\]]+$/;
2833
2838
  function k(e) {
2834
2839
  return W(e, 0, /* @__PURE__ */ new WeakSet());
2835
2840
  }
@@ -2838,7 +2843,7 @@ function W(e, t, s) {
2838
2843
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
2839
2844
  if (e === null || typeof e != "object")
2840
2845
  return e;
2841
- if (t >= Un)
2846
+ if (t >= Pn)
2842
2847
  return "[REDACTED_MAX_DEPTH]";
2843
2848
  if (s.has(e))
2844
2849
  return "[REDACTED_CIRCULAR]";
@@ -2867,7 +2872,7 @@ function ce(e) {
2867
2872
  }
2868
2873
  }
2869
2874
  function j(e) {
2870
- return e.replace(vn, Pn).replace(Nn, qn).replace(ne, `Bearer ${R}`).replace(re, `Basic ${R}`).replace(ie, R).replace(oe, (t, s) => `${s}: ${X}`);
2875
+ return e.replace(vn, Un).replace(Nn, qn).replace(ne, `Bearer ${R}`).replace(re, `Basic ${R}`).replace(ie, R).replace(oe, (t, s) => `${s}: ${X}`);
2871
2876
  }
2872
2877
  function Bn(e) {
2873
2878
  return e.replace(ne, `Bearer ${R}`).replace(re, `Basic ${R}`).replace(ie, R).replace(oe, (t, s) => `${s}: ${X}`);