@pluno/product-agent-web 0.1.269 → 0.1.271

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.
@@ -37,7 +37,7 @@ function Hp(t, e, n, i) {
37
37
  function Kp(t) {
38
38
  return Ur(t) > 0.5 ? [24, 24, 27] : [250, 250, 249];
39
39
  }
40
- const Wp = "0.1.269", ri = {
40
+ const Wp = "0.1.271", ri = {
41
41
  version: Wp
42
42
  }, ye = (t) => typeof t == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(t) ? t : null;
43
43
  function Rd(t) {
@@ -6386,6 +6386,13 @@ class sf {
6386
6386
  forceNew: !0,
6387
6387
  auth: { ...e.auth },
6388
6388
  reconnection: e.reconnect ?? !0
6389
+ }), this.socket.io.on("open", () => {
6390
+ const n = this.socket.io.engine, i = this.attempt;
6391
+ n.on("packet", (s) => {
6392
+ this.socket.io.engine !== n || this.attempt !== i || (this.activity.lastPacketReceivedAt = Date.now(), s.type === "ping" && (this.activity.lastHeartbeatReceivedAt = this.activity.lastPacketReceivedAt));
6393
+ }), n.on("packetCreate", (s) => {
6394
+ this.socket.io.engine === n && this.attempt === i && s.type === "pong" && (this.activity.lastHeartbeatQueuedAt = Date.now());
6395
+ });
6389
6396
  }), this.socket.io.on("reconnect_attempt", () => this.beginAttempt()), this.socket.io.on("close", (n) => {
6390
6397
  const i = this.generation, s = this.attempt;
6391
6398
  n === "forced close" ? queueMicrotask(() => {
@@ -6468,6 +6475,15 @@ class sf {
6468
6475
  readinessTimer = null;
6469
6476
  attemptCount = 0;
6470
6477
  attempt = null;
6478
+ activity = {
6479
+ lastPacketReceivedAt: null,
6480
+ lastHeartbeatReceivedAt: null,
6481
+ lastHeartbeatQueuedAt: null,
6482
+ lastDisconnect: null
6483
+ };
6484
+ get connectionActivity() {
6485
+ return { ...this.activity, lastDisconnect: this.activity.lastDisconnect ? { ...this.activity.lastDisconnect } : null };
6486
+ }
6471
6487
  connect() {
6472
6488
  if (!this.retired && this.rejectedToken !== this.options.auth.token) {
6473
6489
  if (this.active) return;
@@ -6517,7 +6533,7 @@ class sf {
6517
6533
  !this.active || this.retired || (this.invalidate(!1, e), this.socket.io.engine.close());
6518
6534
  }
6519
6535
  beginAttempt() {
6520
- this.clearReadinessTimers(), this.active = !0, this.attempt = { connectionAttemptId: crypto.randomUUID(), reconnectAttempt: this.attemptCount++, startedAt: Date.now() }, this.socket.auth = { ...this.options.auth, connection_attempt_id: this.attempt.connectionAttemptId }, this.options.onAttempt?.(this.attempt);
6536
+ this.clearReadinessTimers(), this.activity = { ...this.activity, lastPacketReceivedAt: null, lastHeartbeatReceivedAt: null, lastHeartbeatQueuedAt: null }, this.active = !0, this.attempt = { connectionAttemptId: crypto.randomUUID(), reconnectAttempt: this.attemptCount++, startedAt: Date.now() }, this.socket.auth = { ...this.options.auth, connection_attempt_id: this.attempt.connectionAttemptId }, this.options.onAttempt?.(this.attempt);
6521
6537
  const e = this.generation, n = (i) => {
6522
6538
  e !== this.generation || !this.active || (this.options.onError(new L("Product Agent readiness timed out", i, !1, {
6523
6539
  retryable: !0,
@@ -6682,7 +6698,14 @@ class sf {
6682
6698
  }
6683
6699
  invalidate(e = !1, n = "local_invalidation") {
6684
6700
  if (this.clearReadinessTimers(), !!this.active) {
6685
- this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
6701
+ this.activity.lastDisconnect = {
6702
+ occurredAt: Date.now(),
6703
+ reason: n,
6704
+ connectionAttemptId: this.attempt?.connectionAttemptId ?? null,
6705
+ lastPacketReceivedAt: this.activity.lastPacketReceivedAt,
6706
+ lastHeartbeatReceivedAt: this.activity.lastHeartbeatReceivedAt,
6707
+ lastHeartbeatQueuedAt: this.activity.lastHeartbeatQueuedAt
6708
+ }, this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
6686
6709
  for (const i of [...this.pending]) i(new L("Connection lost before acknowledgement", "delivery_unknown", !0));
6687
6710
  this.options.onDisconnect(e, n);
6688
6711
  }
@@ -7344,6 +7367,9 @@ class Ae extends EventTarget {
7344
7367
  get connectionAttempt() {
7345
7368
  return this.transport.connectionAttempt;
7346
7369
  }
7370
+ get connectionActivity() {
7371
+ return this.transport.connectionActivity;
7372
+ }
7347
7373
  retryReadiness() {
7348
7374
  this.initialReadinessExpired = !1, this.startInitialReadinessBudget(), this.transport.replaceCredentials(this.options.auth, !1);
7349
7375
  }
@@ -14648,11 +14674,12 @@ async function uw(t = {}) {
14648
14674
  zo();
14649
14675
  let qn = null;
14650
14676
  const us = /* @__PURE__ */ new Map(), jo = /* @__PURE__ */ new Map(), Fo = /* @__PURE__ */ new Map(), qp = () => $.value.trim().length > 0 || lt.length > 0, Bc = (p) => {
14677
+ if (!l_(p, qp())) return !1;
14651
14678
  if (e.entrySurface === "extension_widget") {
14652
14679
  const S = e.billingStatus?.auth, C = S ? !!S.user : !!(p.user && !e.loginRequired), A = S ? !!S.workspace : !e.signupRequired;
14653
14680
  return C && A && qn !== null && qn > 0;
14654
14681
  }
14655
- return qn !== null && l_(p, qp());
14682
+ return qn !== null;
14656
14683
  }, jc = () => {
14657
14684
  const p = Bc(M.getState());
14658
14685
  W.hidden = !p, p && qn !== null && Xu(W, qn);
@@ -16813,9 +16840,13 @@ function ka(t, e) {
16813
16840
  }), n;
16814
16841
  }
16815
16842
  function l_(t, e) {
16816
- return t.messages.filter(
16843
+ const n = t.messages.filter(
16817
16844
  (i) => !lp(i)
16818
- ).length === 0 && !t.assistantDraft && !t.lastError && !t.isThinking && !e;
16845
+ );
16846
+ return (
16847
+ // Empty and loading existing chats are conversations, not welcome screens.
16848
+ (!t.sessionId || t.isDraftSession === !0) && !t.isLoadingSession && !t.historyPreparation && n.length === 0 && !t.assistantDraft && !t.lastError && !t.isThinking && !t.pendingMessageStatus && !t.turnPhase && !e
16849
+ );
16819
16850
  }
16820
16851
  function _d(t, e) {
16821
16852
  const n = t.querySelectorAll(".pluno-pa-widget__starter-placeholder");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.269",
3
+ "version": "0.1.271",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",