@pluno/product-agent-web 0.1.162 → 0.1.163

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
@@ -228,6 +228,7 @@ export declare class PlunoProductAgent {
228
228
  private readonly transportIdentity;
229
229
  private retryAttemptsByClientMessageId;
230
230
  private retryTimersByClientMessageId;
231
+ private readonly reportedHealthSignalKeys;
231
232
  private readonly clientMessageIdsByUserMessageItemId;
232
233
  private readonly backgroundSessionIds;
233
234
  private readonly backgroundClientMessageIds;
@@ -415,6 +415,7 @@ class xt {
415
415
  transportIdentity;
416
416
  retryAttemptsByClientMessageId = {};
417
417
  retryTimersByClientMessageId = {};
418
+ reportedHealthSignalKeys = /* @__PURE__ */ new Set();
418
419
  clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
419
420
  backgroundSessionIds = /* @__PURE__ */ new Set();
420
421
  backgroundClientMessageIds = /* @__PURE__ */ new Set();
@@ -944,27 +945,35 @@ class xt {
944
945
  }
945
946
  }
946
947
  reportHealthSignal(e, s = {}) {
947
- if (!(!this.socket || this.socket.readyState !== WebSocket.OPEN))
948
- try {
949
- this.socket.send(JSON.stringify({
950
- type: "runtime.health",
951
- signal: {
952
- id: crypto.randomUUID(),
953
- name: e,
954
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
955
- source: "web_sdk",
956
- entrySurface: this.options.entrySurface,
957
- ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
958
- ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
959
- ...s
960
- }
961
- }));
962
- } catch (n) {
963
- M("web-sdk.agent", "Pluno health signal send failed", {
948
+ if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
949
+ return;
950
+ const n = s.clientMessageId ?? this.activeResponseRunId;
951
+ if (n) {
952
+ const r = `${e}:${n}`;
953
+ if (this.reportedHealthSignalKeys.has(r))
954
+ return;
955
+ this.reportedHealthSignalKeys.add(r);
956
+ }
957
+ try {
958
+ this.socket.send(JSON.stringify({
959
+ type: "runtime.health",
960
+ signal: {
961
+ id: crypto.randomUUID(),
964
962
  name: e,
965
- message: n instanceof Error ? n.message : String(n)
966
- });
967
- }
963
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
964
+ source: "web_sdk",
965
+ entrySurface: this.options.entrySurface,
966
+ ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
967
+ ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
968
+ ...s
969
+ }
970
+ }));
971
+ } catch (r) {
972
+ M("web-sdk.agent", "Pluno health signal send failed", {
973
+ name: e,
974
+ message: r instanceof Error ? r.message : String(r)
975
+ });
976
+ }
968
977
  }
969
978
  requestTransientStarterPrompts() {
970
979
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
@@ -533,6 +533,7 @@ class ko {
533
533
  transportIdentity;
534
534
  retryAttemptsByClientMessageId = {};
535
535
  retryTimersByClientMessageId = {};
536
+ reportedHealthSignalKeys = /* @__PURE__ */ new Set();
536
537
  clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
537
538
  backgroundSessionIds = /* @__PURE__ */ new Set();
538
539
  backgroundClientMessageIds = /* @__PURE__ */ new Set();
@@ -1062,27 +1063,35 @@ class ko {
1062
1063
  }
1063
1064
  }
1064
1065
  reportHealthSignal(e, n = {}) {
1065
- if (!(!this.socket || this.socket.readyState !== WebSocket.OPEN))
1066
- try {
1067
- this.socket.send(JSON.stringify({
1068
- type: "runtime.health",
1069
- signal: {
1070
- id: crypto.randomUUID(),
1071
- name: e,
1072
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1073
- source: "web_sdk",
1074
- entrySurface: this.options.entrySurface,
1075
- ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
1076
- ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
1077
- ...n
1078
- }
1079
- }));
1080
- } catch (i) {
1081
- X("web-sdk.agent", "Pluno health signal send failed", {
1066
+ if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
1067
+ return;
1068
+ const i = n.clientMessageId ?? this.activeResponseRunId;
1069
+ if (i) {
1070
+ const o = `${e}:${i}`;
1071
+ if (this.reportedHealthSignalKeys.has(o))
1072
+ return;
1073
+ this.reportedHealthSignalKeys.add(o);
1074
+ }
1075
+ try {
1076
+ this.socket.send(JSON.stringify({
1077
+ type: "runtime.health",
1078
+ signal: {
1079
+ id: crypto.randomUUID(),
1082
1080
  name: e,
1083
- message: i instanceof Error ? i.message : String(i)
1084
- });
1085
- }
1081
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1082
+ source: "web_sdk",
1083
+ entrySurface: this.options.entrySurface,
1084
+ ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
1085
+ ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
1086
+ ...n
1087
+ }
1088
+ }));
1089
+ } catch (o) {
1090
+ X("web-sdk.agent", "Pluno health signal send failed", {
1091
+ name: e,
1092
+ message: o instanceof Error ? o.message : String(o)
1093
+ });
1094
+ }
1086
1095
  }
1087
1096
  requestTransientStarterPrompts() {
1088
1097
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.162",
3
+ "version": "0.1.163",
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",