@pluno/product-agent-web 0.1.114 → 0.1.115

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,11 +1,11 @@
1
1
  const ce = "pluno-product-agent-attachments";
2
2
  const et = "files";
3
- async function xt(e) {
3
+ async function qt(e) {
4
4
  const t = await $();
5
- await Ht(t, "readwrite", (s) => s.put(e));
5
+ await Ft(t, "readwrite", (s) => s.put(e));
6
6
  }
7
7
  async function le(e) {
8
- const t = await $(), s = await Ht(
8
+ const t = await $(), s = await Ft(
9
9
  t,
10
10
  "readonly",
11
11
  (r) => r.get(e)
@@ -13,9 +13,9 @@ async function le(e) {
13
13
  if (!s)
14
14
  return null;
15
15
  const n = Date.now();
16
- return await Ft(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
16
+ return await xt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
17
17
  }
18
- async function Ft(e, t) {
18
+ async function xt(e, t) {
19
19
  const s = await $();
20
20
  await lt(s, "readwrite", async (n) => {
21
21
  const r = await ut(
@@ -43,7 +43,7 @@ function $() {
43
43
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
44
44
  });
45
45
  }
46
- async function Ht(e, t, s) {
46
+ async function Ft(e, t, s) {
47
47
  return await lt(e, t, async (n) => await ut(s(n)));
48
48
  }
49
49
  function lt(e, t, s) {
@@ -76,7 +76,7 @@ function ut(e) {
76
76
  function de(e) {
77
77
  return e !== null && (typeof e == "object" || typeof e == "function");
78
78
  }
79
- function Wt(e, t, s) {
79
+ function Ht(e, t, s) {
80
80
  const n = Reflect.get(e, "pluno"), r = de(n) ? n : {};
81
81
  if (r !== n && !Reflect.set(e, "pluno", r))
82
82
  return null;
@@ -94,7 +94,7 @@ function Wt(e, t, s) {
94
94
  const J = "pluno.productAgent.transportId", he = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", pe = 50, fe = globalThis.setTimeout.bind(globalThis);
95
95
  let P = null;
96
96
  const x = /* @__PURE__ */ new Set();
97
- async function ge(e = jt()) {
97
+ async function ge(e = Wt()) {
98
98
  const t = e.randomUUID(), s = e.storage.getItem(J);
99
99
  let n = s ?? e.randomUUID(), r = !1, i = !1;
100
100
  const o = e.channel.subscribe((u) => {
@@ -131,7 +131,7 @@ async function ge(e = jt()) {
131
131
  };
132
132
  }
133
133
  async function me() {
134
- P || (P = ge(jt()), P.then((n) => {
134
+ P || (P = ge(Wt()), P.then((n) => {
135
135
  const r = (i) => {
136
136
  i.persisted || (n.release(), P = null, x.clear(), window.removeEventListener("pagehide", r));
137
137
  };
@@ -154,7 +154,7 @@ function ye() {
154
154
  e += 1;
155
155
  return e;
156
156
  }
157
- function jt() {
157
+ function Wt() {
158
158
  return {
159
159
  storage: window.sessionStorage,
160
160
  channel: Ie(),
@@ -197,8 +197,8 @@ function Te() {
197
197
  }
198
198
  };
199
199
  }
200
- const st = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', we = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ae = ".pluno-pa-widget__panel", Se = ".pluno-pa-widget__timeline", wt = `${st}[data-pluno-sdk-preview-channel]`, ke = "https://app.pluno.ai", Ee = "gpt-5.6-terra", Re = 2e4, _e = 1e4, be = 1e4, Me = 1e4, Ce = 1e4, Pe = 1e3, At = 3e4, St = 0.2, kt = 6e4, Ue = 15e3, B = 8, De = 15e3, Ne = 2e3, Oe = 1e3, Be = 100, Le = 8e3, ve = 15e3, Et = 3, qe = [300, 1e3], dt = 64e3, Y = 4e3, ht = 30, xe = 2e3, Fe = 1e3, He = 200 * 1024 * 1024, pt = "Image is too large for model vision input.", We = 100, $t = "pluno.productAgent.state.", nt = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", je = 100;
201
- function L(e, t = 0) {
200
+ const st = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', we = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ae = ".pluno-pa-widget__panel", Se = ".pluno-pa-widget__timeline", wt = `${st}[data-pluno-sdk-preview-channel]`, ke = "https://app.pluno.ai", Ee = "gpt-5.6-terra", Re = 2e4, _e = 1e4, be = 1e4, Me = 1e4, Ce = 1e4, Pe = 1e3, At = 3e4, St = 0.2, kt = 6e4, Ue = 15e3, L = 8, De = 15e3, Ne = 2e3, Oe = 1e3, Le = 100, Be = 8e3, ve = 15e3, Et = 3, qe = [300, 1e3], dt = 64e3, Y = 4e3, ht = 30, xe = 2e3, Fe = 1e3, He = 200 * 1024 * 1024, pt = "Image is too large for model vision input.", We = 100, jt = "pluno.productAgent.state.", nt = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", je = 100;
201
+ function B(e, t = 0) {
202
202
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
203
203
  return Math.max(t, s);
204
204
  }
@@ -221,13 +221,13 @@ function ze(e, t, s) {
221
221
  );
222
222
  });
223
223
  }
224
- class zt {
224
+ class $t {
225
225
  constructor(t, s) {
226
226
  this.options = t, this.transportIdentity = s, this.state = {
227
227
  ...this.state,
228
228
  starterPrompts: Is(t.initialStarterPrompts)
229
229
  };
230
- const n = t.restorePersistedState === !1 ? null : Zs(t.clientId, t.expectedPersistedSessionId);
230
+ const n = t.restorePersistedState === !1 ? null : tn(t.clientId, t.expectedPersistedSessionId);
231
231
  n && (this.state = {
232
232
  ...this.state,
233
233
  ...n,
@@ -240,9 +240,9 @@ class zt {
240
240
  assistantDraftRunId: null,
241
241
  isThinking: !1,
242
242
  lastError: null
243
- }), this.queuedClientEvents = on(
244
- tn(t.clientId),
245
- sn(t.clientId)
243
+ }), this.queuedClientEvents = cn(
244
+ sn(t.clientId),
245
+ rn(t.clientId)
246
246
  ), U(t.clientId, this.queuedClientEvents);
247
247
  }
248
248
  options;
@@ -307,7 +307,7 @@ class zt {
307
307
  lastErrorSecuritySettingsUrl: null
308
308
  };
309
309
  static async init(t) {
310
- const s = await me(), n = new zt({
310
+ const s = await me(), n = new $t({
311
311
  ...t,
312
312
  backendUrl: ls(t.backendUrl ?? ke),
313
313
  clientId: t.clientId ?? ks(),
@@ -400,7 +400,7 @@ class zt {
400
400
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
401
401
  }
402
402
  destroy() {
403
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), an(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
403
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), ln(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
404
404
  for (const t of Object.values(this.listeners))
405
405
  t?.clear();
406
406
  }
@@ -455,7 +455,7 @@ class zt {
455
455
  };
456
456
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
457
457
  const r = Date.now();
458
- return xt({
458
+ return qt({
459
459
  attachmentId: s,
460
460
  name: n.name,
461
461
  mimeType: n.mimeType,
@@ -536,7 +536,7 @@ class zt {
536
536
  return h;
537
537
  }, "Failed to upload attachment"), this.setState({ sessionId: c.sessionId });
538
538
  const a = Qt(c.attachment, this.options.backendUrl);
539
- return this.updateAttachmentInState(s.id, a), s.id && Ft(s.id, {
539
+ return this.updateAttachmentInState(s.id, a), s.id && xt(s.id, {
540
540
  sessionId: c.sessionId,
541
541
  fileUrl: a.fileUrl,
542
542
  gcsPath: a.gcsPath,
@@ -580,7 +580,7 @@ class zt {
580
580
  const n = await this.fetchEmbedAttachmentUpload(t);
581
581
  if (n.ok)
582
582
  return await n.json();
583
- if (Rn(n.status) && this.options.tokenProvider && !s) {
583
+ if (bn(n.status) && this.options.tokenProvider && !s) {
584
584
  s = !0;
585
585
  const r = await this.fetchEmbedAttachmentUpload(t);
586
586
  if (r.ok)
@@ -627,7 +627,7 @@ class zt {
627
627
  const s = q(), n = new Promise((i, o) => {
628
628
  const l = window.setTimeout(() => {
629
629
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
630
- }, Le);
630
+ }, Be);
631
631
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: l });
632
632
  }), r = {
633
633
  type: "sessions.list",
@@ -767,9 +767,9 @@ class zt {
767
767
  if (t.type === "conversation.state") {
768
768
  const s = Array.isArray(t.items) ? t.items : [];
769
769
  this.rememberUserMessageClientMessageIds(s);
770
- const n = Ws(s);
770
+ const n = $s(s);
771
771
  if (n) {
772
- const a = js(s, n);
772
+ const a = zs(s, n);
773
773
  this.retryAttemptsByClientMessageId[n] = Math.max(
774
774
  this.retryAttemptsByClientMessageId[n] ?? 0,
775
775
  a
@@ -777,12 +777,12 @@ class zt {
777
777
  }
778
778
  const r = s.filter((a) => {
779
779
  const h = D(a);
780
- return !Dt(h) && (!n || !it(h));
781
- }), i = Bs(
780
+ return !Ut(h) && (!n || !it(h));
781
+ }), i = vs(
782
782
  this.state.messages,
783
783
  Rs(r, this.options.backendUrl)
784
- ), o = Ut(i), l = s.some(
785
- (a) => Ot(
784
+ ), o = Pt(i), l = s.some(
785
+ (a) => Nt(
786
786
  D(a),
787
787
  this.state.assistantDraft,
788
788
  this.state.assistantDraftItemId,
@@ -790,10 +790,10 @@ class zt {
790
790
  this.state.assistantDraftRunId
791
791
  )
792
792
  ), u = o && (!this.state.assistantDraft || l);
793
- if (!o && Hs(this.state.messages, s))
793
+ if (!o && js(this.state.messages, s))
794
794
  return;
795
795
  const c = u ? null : ot(s);
796
- if (this.latestRecoverableClientMessageId = c, xs(i) && this.clearRetryTimers(), this.setState({
796
+ if (this.latestRecoverableClientMessageId = c, Hs(i) && this.clearRetryTimers(), this.setState({
797
797
  sessionId: T(t.session, "id") ?? this.state.sessionId,
798
798
  messages: i,
799
799
  ...l ? {
@@ -842,14 +842,14 @@ class zt {
842
842
  return;
843
843
  }
844
844
  }
845
- if (Dt(s))
845
+ if (Ut(s))
846
846
  return;
847
- const n = Xt(t.item, this.options.backendUrl);
847
+ const n = Gt(t.item, this.options.backendUrl);
848
848
  if (n) {
849
849
  N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
850
850
  const r = t.item.data;
851
- zs(r) && this.clearRunAckResyncRetryTimer();
852
- const i = Ct(this.state.messages, n), o = Ut(i), l = Ot(
851
+ Xs(r) && this.clearRunAckResyncRetryTimer();
852
+ const i = Xt(this.state.messages, n), o = Pt(i), l = Nt(
853
853
  r,
854
854
  this.state.assistantDraft,
855
855
  this.state.assistantDraftItemId,
@@ -901,11 +901,23 @@ class zt {
901
901
  }
902
902
  if (t.type === "tool.call") {
903
903
  this.clearRunAckResyncRetryTimer();
904
- const s = Ns(t);
905
- s && (this.setState({
906
- messages: Ct(this.state.messages, s),
907
- isThinking: !0
908
- }), this.emit("message", s)), this.executeToolCall(t);
904
+ const s = Ls(t);
905
+ if (s) {
906
+ const n = Ns(
907
+ this.state.messages,
908
+ s
909
+ );
910
+ this.setState({
911
+ messages: n,
912
+ isThinking: !0
913
+ }), this.emit(
914
+ "message",
915
+ n.find(
916
+ (r) => r.callId === s.callId
917
+ ) ?? s
918
+ );
919
+ }
920
+ this.executeToolCall(t);
909
921
  return;
910
922
  }
911
923
  if (t.type === "error") {
@@ -946,10 +958,10 @@ class zt {
946
958
  if (this.retryTimersByClientMessageId[n] !== void 0)
947
959
  return !0;
948
960
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
949
- if (i >= B)
961
+ if (i >= L)
950
962
  return !1;
951
963
  this.retryAttemptsByClientMessageId[n] = i + 1;
952
- const o = L(
964
+ const o = B(
953
965
  i,
954
966
  typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
955
967
  );
@@ -966,7 +978,7 @@ class zt {
966
978
  if (this.retryTimersByClientMessageId[s] !== void 0)
967
979
  return;
968
980
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
969
- if (n >= B) {
981
+ if (n >= L) {
970
982
  this.retryableClientMessageId = s, this.setState({
971
983
  isThinking: !1,
972
984
  lastError: "Pluno could not finish this message. Try it again.",
@@ -976,7 +988,7 @@ class zt {
976
988
  }
977
989
  this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
978
990
  delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !0 });
979
- }, L(n));
991
+ }, B(n));
980
992
  }
981
993
  clearRetryTimers() {
982
994
  for (const t of Object.values(this.retryTimersByClientMessageId))
@@ -1026,7 +1038,7 @@ class zt {
1026
1038
  scheduleRunAckResyncRetry(t) {
1027
1039
  this.clearRunAckResyncRetryTimer();
1028
1040
  const s = this.retryAttemptsByClientMessageId[t] ?? 0;
1029
- s >= B || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1041
+ s >= L || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1030
1042
  this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
1031
1043
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1032
1044
  isThinking: !0,
@@ -1040,7 +1052,7 @@ class zt {
1040
1052
  clientMessageId: t,
1041
1053
  automatic: !0
1042
1054
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(kt)));
1043
- }, L(s, Ne)));
1055
+ }, B(s, Ne)));
1044
1056
  }
1045
1057
  clearRunAckResyncRetryTimer() {
1046
1058
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1063,7 +1075,7 @@ class zt {
1063
1075
  return;
1064
1076
  }
1065
1077
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
1066
- if (n >= B) {
1078
+ if (n >= L) {
1067
1079
  f("web-sdk.agent", "Pluno run recovery retry exhausted", {
1068
1080
  sessionId: this.state.sessionId,
1069
1081
  clientMessageId: t
@@ -1097,7 +1109,7 @@ class zt {
1097
1109
  clientMessageId: t,
1098
1110
  automatic: !0
1099
1111
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1100
- }, L(n)));
1112
+ }, B(n)));
1101
1113
  }
1102
1114
  resyncThinkingSession() {
1103
1115
  this.state.sessionId ? this.send({
@@ -1114,8 +1126,8 @@ class zt {
1114
1126
  if (!s || !n || !r)
1115
1127
  return;
1116
1128
  const l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1117
- if (r !== "execute_code" && !l || !pn(o)) {
1118
- this.send({
1129
+ if (r !== "execute_code" && !l || !gn(o)) {
1130
+ this.setToolMessageLoading(n, !1), this.send({
1119
1131
  type: "tool.result",
1120
1132
  sessionId: s,
1121
1133
  callId: n,
@@ -1151,7 +1163,7 @@ class zt {
1151
1163
  exception: {
1152
1164
  message: h instanceof Error ? h.message : String(h)
1153
1165
  }
1154
- })), this.activeBrowserToolCalls.delete(n), this.send({
1166
+ })), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
1155
1167
  type: "tool.result",
1156
1168
  sessionId: s,
1157
1169
  callId: n,
@@ -1159,7 +1171,15 @@ class zt {
1159
1171
  summary: o.summary,
1160
1172
  rawInput: A(o),
1161
1173
  rawOutput: A(As(a, c))
1162
- }), en(this.options.clientId, this.activeBrowserToolCalls.values());
1174
+ }), nn(this.options.clientId, this.activeBrowserToolCalls.values());
1175
+ }
1176
+ setToolMessageLoading(t, s) {
1177
+ const n = Os(
1178
+ this.state.messages,
1179
+ t,
1180
+ s
1181
+ );
1182
+ n !== this.state.messages && this.setState({ messages: n });
1163
1183
  }
1164
1184
  startPageLifecycleRecovery() {
1165
1185
  if (this.pageLifecycleCleanup)
@@ -1187,11 +1207,11 @@ class zt {
1187
1207
  }
1188
1208
  enableNetworkCapture() {
1189
1209
  this.networkCaptureCleanup || (this.networkCaptureCleanup = Ge((t) => {
1190
- Tn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1210
+ An(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1191
1211
  }));
1192
1212
  }
1193
1213
  enqueueNetworkEvent(t) {
1194
- this.queuedNetworkEvents.length >= Be || (this.queuedNetworkEvents.push(In(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1214
+ this.queuedNetworkEvents.length >= Le || (this.queuedNetworkEvents.push(wn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1195
1215
  this.networkBatchTimer = null;
1196
1216
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1197
1217
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1248,7 +1268,7 @@ class zt {
1248
1268
  ...t,
1249
1269
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1250
1270
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1251
- }, Qs(this.options.clientId, this.state), this.emit("state", this.getState());
1271
+ }, en(this.options.clientId, this.state), this.emit("state", this.getState());
1252
1272
  }
1253
1273
  emit(t, s) {
1254
1274
  this.listeners[t]?.forEach((r) => r(s));
@@ -1278,20 +1298,20 @@ function Xe() {
1278
1298
  throw y;
1279
1299
  }
1280
1300
  try {
1281
- const y = p instanceof Request ? p : null, O = fn(p, y), C = te(d?.headers ?? y?.headers);
1301
+ const y = p instanceof Request ? p : null, O = mn(p, y), C = te(d?.headers ?? y?.headers);
1282
1302
  if (!b(O, C, d?.body)) {
1283
1303
  const K = {
1284
1304
  requestId: Q("fetch"),
1285
1305
  url: k(O, Y),
1286
1306
  method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
1287
1307
  requestHeaders: C,
1288
- requestBody: vt(d?.body),
1308
+ requestBody: Bt(d?.body),
1289
1309
  resourceType: "fetch",
1290
1310
  startedAt: new Date(m).toISOString()
1291
1311
  };
1292
1312
  I.then(
1293
1313
  (_) => {
1294
- gn(_, K, m, t).catch(() => {
1314
+ yn(_, K, m, t).catch(() => {
1295
1315
  t({
1296
1316
  ...K,
1297
1317
  responseStatus: _.status,
@@ -1328,12 +1348,12 @@ function Xe() {
1328
1348
  }, c = function(p) {
1329
1349
  try {
1330
1350
  const d = Z.get(this);
1331
- d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = vt(p), d.excluded || this.addEventListener(
1351
+ d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Bt(p), d.excluded || this.addEventListener(
1332
1352
  "loadend",
1333
1353
  () => {
1334
1354
  queueMicrotask(() => {
1335
1355
  try {
1336
- const m = An(this.getAllResponseHeaders());
1356
+ const m = kn(this.getAllResponseHeaders());
1337
1357
  t({
1338
1358
  requestId: d.requestId,
1339
1359
  url: d.url,
@@ -1343,7 +1363,7 @@ function Xe() {
1343
1363
  resourceType: "xhr",
1344
1364
  responseStatus: this.status,
1345
1365
  responseHeaders: m,
1346
- responseBody: yn(this, m),
1366
+ responseBody: Tn(this, m),
1347
1367
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1348
1368
  startedAt: d.startedAt,
1349
1369
  durationMs: Date.now() - d.startedAtMs
@@ -1493,13 +1513,13 @@ function Qe(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1493
1513
  return s.set(a.id, p), p;
1494
1514
  if (!a.fileUrl)
1495
1515
  throw new Error(`Pluno user file is missing content: ${c}`);
1496
- const d = await fetch(a.fileUrl, cn(a.fileUrl));
1516
+ const d = await fetch(a.fileUrl, un(a.fileUrl));
1497
1517
  if (!d.ok)
1498
1518
  throw new Error(`Failed to load Pluno user file: ${c}`);
1499
1519
  const m = await d.blob();
1500
1520
  s.set(a.id, m);
1501
1521
  const I = Date.now();
1502
- return xt({
1522
+ return qt({
1503
1523
  attachmentId: a.id,
1504
1524
  name: a.name,
1505
1525
  mimeType: a.mimeType,
@@ -1517,7 +1537,7 @@ function Qe(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1517
1537
  });
1518
1538
  }), m;
1519
1539
  };
1520
- return Wt(globalThis, "userFiles", {
1540
+ return Ht(globalThis, "userFiles", {
1521
1541
  list: () => e.map(r),
1522
1542
  get: (c) => {
1523
1543
  const a = n.get(c);
@@ -1556,7 +1576,7 @@ function Qe(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1556
1576
  });
1557
1577
  }
1558
1578
  function ts() {
1559
- return Wt(globalThis, "pageImages", {
1579
+ return Ht(globalThis, "pageImages", {
1560
1580
  inspectImage: async (t, s) => await es(t, s)
1561
1581
  });
1562
1582
  }
@@ -1710,7 +1730,7 @@ function ds(e) {
1710
1730
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1711
1731
  }
1712
1732
  function w() {
1713
- const e = Gt();
1733
+ const e = zt();
1714
1734
  return {
1715
1735
  url: location.href,
1716
1736
  title: document.title,
@@ -1746,7 +1766,7 @@ function fs() {
1746
1766
  };
1747
1767
  }
1748
1768
  function gs() {
1749
- return Gt()?.surface === "browser_extension_sdk_preview";
1769
+ return zt()?.surface === "browser_extension_sdk_preview";
1750
1770
  }
1751
1771
  function ms() {
1752
1772
  const e = document.body?.cloneNode(!0);
@@ -1772,7 +1792,7 @@ function ms() {
1772
1792
  s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
1773
1793
  }), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
1774
1794
  }
1775
- function Gt() {
1795
+ function zt() {
1776
1796
  const e = document.querySelector(wt);
1777
1797
  if (!(e ?? document.querySelector(st)))
1778
1798
  return;
@@ -1878,7 +1898,7 @@ function Es(e) {
1878
1898
  function Rs(e, t) {
1879
1899
  return Array.isArray(e) ? at(
1880
1900
  ct(
1881
- e.map((s) => Xt(s, t)).filter((s) => s !== null)
1901
+ e.map((s) => Gt(s, t)).filter((s) => s !== null)
1882
1902
  )
1883
1903
  ) : [];
1884
1904
  }
@@ -1901,7 +1921,7 @@ function _s(e) {
1901
1921
  ];
1902
1922
  }) : [];
1903
1923
  }
1904
- function Xt(e, t) {
1924
+ function Gt(e, t) {
1905
1925
  if (!e || typeof e != "object")
1906
1926
  return null;
1907
1927
  const s = e, n = s.data;
@@ -2034,9 +2054,9 @@ function Ds(e) {
2034
2054
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2035
2055
  }).filter(Boolean).join("") : "";
2036
2056
  }
2037
- function Ct(e, t) {
2038
- const s = Kt(e, t), n = Os(
2039
- qs(e, t),
2057
+ function Xt(e, t) {
2058
+ const s = Kt(e, t), n = Bs(
2059
+ Fs(e, t),
2040
2060
  s
2041
2061
  ), r = n.findIndex((o) => o.id === s.id);
2042
2062
  if (r === -1)
@@ -2046,7 +2066,25 @@ function Ct(e, t) {
2046
2066
  const i = [...n];
2047
2067
  return i[r] = s, at(ct(i));
2048
2068
  }
2049
- function Ns(e) {
2069
+ function Ns(e, t) {
2070
+ const s = e.findIndex(
2071
+ (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2072
+ );
2073
+ if (s === -1)
2074
+ return Xt(e, t);
2075
+ const n = [...e];
2076
+ return n[s] = {
2077
+ ...n[s],
2078
+ content: t.content,
2079
+ loading: !0
2080
+ }, n;
2081
+ }
2082
+ function Os(e, t, s) {
2083
+ let n = !1;
2084
+ const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2085
+ return n ? r : e;
2086
+ }
2087
+ function Ls(e) {
2050
2088
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
2051
2089
  return !t || !s ? null : {
2052
2090
  id: `transient-activity:${t}`,
@@ -2063,7 +2101,7 @@ function Ns(e) {
2063
2101
  loading: !0
2064
2102
  };
2065
2103
  }
2066
- function Os(e, t) {
2104
+ function Bs(e, t) {
2067
2105
  if (t.id.startsWith("transient-activity:"))
2068
2106
  return e;
2069
2107
  const s = t.toolName === "tab_lifecycle";
@@ -2071,7 +2109,7 @@ function Os(e, t) {
2071
2109
  (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
2072
2110
  );
2073
2111
  }
2074
- function Bs(e, t) {
2112
+ function vs(e, t) {
2075
2113
  const s = t.map(
2076
2114
  (n) => Kt(e, n)
2077
2115
  );
@@ -2086,19 +2124,19 @@ function Kt(e, t) {
2086
2124
  if (!s?.attachments?.length)
2087
2125
  return t;
2088
2126
  const n = t.attachments.map((r) => {
2089
- const i = Ls(s.attachments ?? [], r);
2090
- return i ? vs(r, i) : r;
2127
+ const i = qs(s.attachments ?? [], r);
2128
+ return i ? xs(r, i) : r;
2091
2129
  });
2092
2130
  return { ...t, attachments: n };
2093
2131
  }
2094
- function Ls(e, t) {
2132
+ function qs(e, t) {
2095
2133
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2096
2134
  }
2097
- function vs(e, t) {
2135
+ function xs(e, t) {
2098
2136
  const { previewUrl: s } = t;
2099
2137
  return s ? { ...e, previewUrl: s } : e;
2100
2138
  }
2101
- function qs(e, t) {
2139
+ function Fs(e, t) {
2102
2140
  if (t.role !== "user")
2103
2141
  return e;
2104
2142
  const s = e.findIndex(
@@ -2110,13 +2148,13 @@ function qs(e, t) {
2110
2148
  return n.splice(s, 1), n;
2111
2149
  }
2112
2150
  function Jt(e, t) {
2113
- const s = Pt(e), n = Pt(t);
2151
+ const s = Ct(e), n = Ct(t);
2114
2152
  return s && n ? s === n : e.content === t.content;
2115
2153
  }
2116
2154
  function ft(e) {
2117
2155
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2118
2156
  }
2119
- function Pt(e) {
2157
+ function Ct(e) {
2120
2158
  const t = e.clientMessageId;
2121
2159
  if (t)
2122
2160
  return t;
@@ -2125,7 +2163,7 @@ function Pt(e) {
2125
2163
  );
2126
2164
  return n ? e.id.slice(n.length) : null;
2127
2165
  }
2128
- function Ut(e) {
2166
+ function Pt(e) {
2129
2167
  const t = Vt(e);
2130
2168
  if (t === null)
2131
2169
  return !1;
@@ -2142,7 +2180,7 @@ function Ut(e) {
2142
2180
  }
2143
2181
  return !1;
2144
2182
  }
2145
- function xs(e) {
2183
+ function Hs(e) {
2146
2184
  const t = Vt(e);
2147
2185
  return t === null ? e.some(N) : e.slice(t + 1).some(N);
2148
2186
  }
@@ -2152,7 +2190,7 @@ function Vt(e) {
2152
2190
  return t;
2153
2191
  return null;
2154
2192
  }
2155
- function Fs(e) {
2193
+ function Ws(e) {
2156
2194
  return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2157
2195
  }
2158
2196
  function gt(e) {
@@ -2178,10 +2216,10 @@ function D(e) {
2178
2216
  function it(e) {
2179
2217
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2180
2218
  }
2181
- function Dt(e) {
2219
+ function Ut(e) {
2182
2220
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2183
2221
  }
2184
- function Hs(e, t) {
2222
+ function js(e, t) {
2185
2223
  const s = gt(t);
2186
2224
  if (s === null)
2187
2225
  return !1;
@@ -2189,7 +2227,7 @@ function Hs(e, t) {
2189
2227
  if (typeof r != "string" || !r)
2190
2228
  return !1;
2191
2229
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2192
- return i === -1 ? !1 : e.slice(i + 1).some(Fs);
2230
+ return i === -1 ? !1 : e.slice(i + 1).some(Ws);
2193
2231
  }
2194
2232
  function ot(e) {
2195
2233
  const t = gt(e);
@@ -2204,7 +2242,7 @@ function ot(e) {
2204
2242
  const r = n.clientMessageId;
2205
2243
  return typeof r == "string" ? r : null;
2206
2244
  }
2207
- function Ws(e) {
2245
+ function $s(e) {
2208
2246
  const t = gt(e);
2209
2247
  if (t === null)
2210
2248
  return null;
@@ -2219,13 +2257,13 @@ function Ws(e) {
2219
2257
  if (i.type === "message" && i.role === "assistant")
2220
2258
  return null;
2221
2259
  if (i.type === "run_error")
2222
- return i.retryable !== !0 ? null : Nt(e, i) ?? ot(e);
2260
+ return i.retryable !== !0 ? null : Dt(e, i) ?? ot(e);
2223
2261
  if (i.type === "run_status")
2224
- return i.status === "interrupted" && i.retryable === !0 ? Nt(e, i) ?? ot(e) : null;
2262
+ return i.status === "interrupted" && i.retryable === !0 ? Dt(e, i) ?? ot(e) : null;
2225
2263
  }
2226
2264
  return null;
2227
2265
  }
2228
- function Nt(e, t) {
2266
+ function Dt(e, t) {
2229
2267
  if (typeof t.clientMessageId == "string")
2230
2268
  return t.clientMessageId;
2231
2269
  const s = R(t);
@@ -2234,7 +2272,7 @@ function Nt(e, t) {
2234
2272
  const n = e.find((i) => T(i, "id") === s), r = D(n);
2235
2273
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2236
2274
  }
2237
- function js(e, t) {
2275
+ function zs(e, t) {
2238
2276
  let s = 0;
2239
2277
  for (const n of e) {
2240
2278
  if (!n || typeof n != "object")
@@ -2247,13 +2285,13 @@ function js(e, t) {
2247
2285
  }
2248
2286
  return s;
2249
2287
  }
2250
- function Ot(e, t, s, n, r) {
2251
- if (!t || !$s(e))
2288
+ function Nt(e, t, s, n, r) {
2289
+ if (!t || !Gs(e))
2252
2290
  return !1;
2253
2291
  const i = e;
2254
2292
  return !(it(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && R(i) !== n || r !== null && S(i) !== r);
2255
2293
  }
2256
- function $s(e) {
2294
+ function Gs(e) {
2257
2295
  if (!e || typeof e != "object")
2258
2296
  return !1;
2259
2297
  const t = e;
@@ -2262,16 +2300,16 @@ function $s(e) {
2262
2300
  function N(e) {
2263
2301
  return e.role === "assistant" && e.phase !== "commentary";
2264
2302
  }
2265
- function zs(e) {
2303
+ function Xs(e) {
2266
2304
  if (!e || typeof e != "object")
2267
2305
  return !1;
2268
2306
  const t = e;
2269
2307
  return t.type === "message" && t.role === "user" ? !1 : t.type === "message" || t.type === "function_call" || t.type === "function_call_output" || t.type === "run_error" || t.type === "run_status";
2270
2308
  }
2271
2309
  function at(e) {
2272
- return e.filter((t, s) => mt(t) ? !Ys(e, s) && !Js(e, s) && !Vs(e, s) : Gs(t) ? t.retryable === !0 && Ks(e, s) ? !1 : !Xs(e, s) : !0);
2310
+ return e.filter((t, s) => mt(t) ? !Qs(e, s) && !Ys(e, s) && !Zs(e, s) : Ks(t) ? t.retryable === !0 && Vs(e, s) ? !1 : !Js(e, s) : !0);
2273
2311
  }
2274
- function Gs(e) {
2312
+ function Ks(e) {
2275
2313
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
2276
2314
  }
2277
2315
  function mt(e) {
@@ -2293,7 +2331,7 @@ function ct(e) {
2293
2331
  n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
2294
2332
  return r;
2295
2333
  }
2296
- function Xs(e, t) {
2334
+ function Js(e, t) {
2297
2335
  const s = e[t];
2298
2336
  for (let n = t + 1; n < e.length; n += 1) {
2299
2337
  const r = e[n];
@@ -2304,7 +2342,7 @@ function Xs(e, t) {
2304
2342
  }
2305
2343
  return !1;
2306
2344
  }
2307
- function Ks(e, t) {
2345
+ function Vs(e, t) {
2308
2346
  const s = e[t];
2309
2347
  if (!s.respondsToUserMessageId)
2310
2348
  return !1;
@@ -2317,21 +2355,21 @@ function Ks(e, t) {
2317
2355
  }
2318
2356
  return !1;
2319
2357
  }
2320
- function Js(e, t) {
2358
+ function Ys(e, t) {
2321
2359
  const s = e[t];
2322
2360
  for (let n = t + 1; n < e.length; n += 1)
2323
2361
  if (e[n].role === "assistant" && G(s, e[n]))
2324
2362
  return !0;
2325
2363
  return !1;
2326
2364
  }
2327
- function Vs(e, t) {
2365
+ function Zs(e, t) {
2328
2366
  const s = e[t];
2329
2367
  for (let n = t + 1; n < e.length; n += 1)
2330
2368
  if (e[n].role === "tool" && G(s, e[n]))
2331
2369
  return !0;
2332
2370
  return !1;
2333
2371
  }
2334
- function Ys(e, t) {
2372
+ function Qs(e, t) {
2335
2373
  const s = e[t];
2336
2374
  for (let n = t + 1; n < e.length; n += 1)
2337
2375
  if (mt(e[n]) && G(s, e[n]))
@@ -2344,15 +2382,15 @@ function G(e, t) {
2344
2382
  function T(e, t) {
2345
2383
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2346
2384
  }
2347
- function Zs(e, t) {
2385
+ function tn(e, t) {
2348
2386
  try {
2349
- const s = window.localStorage.getItem(`${$t}${e}`);
2387
+ const s = window.localStorage.getItem(`${jt}${e}`);
2350
2388
  if (!s)
2351
2389
  return null;
2352
2390
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2353
2391
  if (t !== void 0 && r !== t)
2354
2392
  return null;
2355
- const i = Array.isArray(n.messages) ? n.messages.map(dn).filter((o) => !!o) : [];
2393
+ const i = Array.isArray(n.messages) ? n.messages.map(pn).filter((o) => !!o) : [];
2356
2394
  return {
2357
2395
  sessionId: r,
2358
2396
  messages: i
@@ -2361,20 +2399,20 @@ function Zs(e, t) {
2361
2399
  return null;
2362
2400
  }
2363
2401
  }
2364
- function Qs(e, t) {
2402
+ function en(e, t) {
2365
2403
  try {
2366
2404
  window.localStorage.setItem(
2367
- `${$t}${e}`,
2405
+ `${jt}${e}`,
2368
2406
  JSON.stringify({
2369
2407
  sessionId: t.sessionId,
2370
- messages: t.messages.slice(-We).map(hn)
2408
+ messages: t.messages.slice(-We).map(fn)
2371
2409
  })
2372
2410
  );
2373
2411
  } catch {
2374
2412
  return;
2375
2413
  }
2376
2414
  }
2377
- function tn(e) {
2415
+ function sn(e) {
2378
2416
  try {
2379
2417
  const t = window.localStorage.getItem(`${nt}${e}`);
2380
2418
  if (!t)
@@ -2416,7 +2454,7 @@ function Yt(e, t) {
2416
2454
  } catch {
2417
2455
  }
2418
2456
  }
2419
- function en(e, t) {
2457
+ function nn(e, t) {
2420
2458
  try {
2421
2459
  if (window.sessionStorage.getItem(`${z}${e}`) === null)
2422
2460
  return;
@@ -2425,19 +2463,19 @@ function en(e, t) {
2425
2463
  }
2426
2464
  Yt(e, t);
2427
2465
  }
2428
- function sn(e) {
2466
+ function rn(e) {
2429
2467
  try {
2430
2468
  const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
2431
2469
  if (window.sessionStorage.removeItem(t), !s)
2432
2470
  return [];
2433
2471
  const n = JSON.parse(s);
2434
- return Array.isArray(n) ? n.flatMap((r) => rn(r) ? [{
2472
+ return Array.isArray(n) ? n.flatMap((r) => an(r) ? [{
2435
2473
  ...r.event,
2436
2474
  page: w(),
2437
2475
  rawOutput: {
2438
2476
  pageContextRestarted: !0,
2439
2477
  outcome: "unknown",
2440
- message: nn(location.href),
2478
+ message: on(location.href),
2441
2479
  currentUrl: location.href,
2442
2480
  console: [],
2443
2481
  metadata: {
@@ -2454,17 +2492,17 @@ function sn(e) {
2454
2492
  return [];
2455
2493
  }
2456
2494
  }
2457
- function nn(e) {
2495
+ function on(e) {
2458
2496
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2459
2497
  Current URL: ${e}`;
2460
2498
  }
2461
- function rn(e) {
2499
+ function an(e) {
2462
2500
  if (!e || typeof e != "object")
2463
2501
  return !1;
2464
2502
  const t = e, s = t.event;
2465
2503
  return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && yt(s) && s.type === "tool.result";
2466
2504
  }
2467
- function on(e, t) {
2505
+ function cn(e, t) {
2468
2506
  const s = new Set(
2469
2507
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2470
2508
  );
@@ -2473,7 +2511,7 @@ function on(e, t) {
2473
2511
  ...t.filter((n) => !s.has(n.callId))
2474
2512
  ];
2475
2513
  }
2476
- function an(e) {
2514
+ function ln(e) {
2477
2515
  try {
2478
2516
  window.sessionStorage.removeItem(`${z}${e}`);
2479
2517
  } catch {
@@ -2484,9 +2522,9 @@ function yt(e) {
2484
2522
  if (!e || typeof e != "object")
2485
2523
  return !1;
2486
2524
  const t = e;
2487
- return t.type === "chat.user_message" ? typeof t.content == "string" && Bt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Bt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
2525
+ return t.type === "chat.user_message" ? typeof t.content == "string" && Ot(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ot(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
2488
2526
  }
2489
- function Bt(e) {
2527
+ function Ot(e) {
2490
2528
  if (!e || typeof e != "object")
2491
2529
  return !1;
2492
2530
  const t = e;
@@ -2509,15 +2547,15 @@ function Qt(e, t) {
2509
2547
  fileUrl: new URL(e.fileUrl, t).toString()
2510
2548
  } : e;
2511
2549
  }
2512
- function cn(e) {
2513
- if (ln(e))
2550
+ function un(e) {
2551
+ if (dn(e))
2514
2552
  return {
2515
2553
  headers: {
2516
2554
  "ngrok-skip-browser-warning": "true"
2517
2555
  }
2518
2556
  };
2519
2557
  }
2520
- function ln(e) {
2558
+ function dn(e) {
2521
2559
  try {
2522
2560
  const t = new URL(e).hostname;
2523
2561
  return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
@@ -2526,13 +2564,13 @@ function ln(e) {
2526
2564
  }
2527
2565
  }
2528
2566
  function Lt(e) {
2529
- return e.type || un(e.name) || "application/octet-stream";
2567
+ return e.type || hn(e.name) || "application/octet-stream";
2530
2568
  }
2531
- function un(e) {
2569
+ function hn(e) {
2532
2570
  const t = e.toLowerCase();
2533
2571
  return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
2534
2572
  }
2535
- function dn(e) {
2573
+ function pn(e) {
2536
2574
  if (!e || typeof e != "object")
2537
2575
  return null;
2538
2576
  const t = e;
@@ -2549,7 +2587,7 @@ function dn(e) {
2549
2587
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2550
2588
  };
2551
2589
  }
2552
- function hn(e) {
2590
+ function fn(e) {
2553
2591
  return e.attachments?.length ? {
2554
2592
  ...e,
2555
2593
  attachments: e.attachments.map(It)
@@ -2572,7 +2610,7 @@ function S(e) {
2572
2610
  const t = e.runId;
2573
2611
  return typeof t == "string" && t ? t : null;
2574
2612
  }
2575
- function pn(e) {
2613
+ function gn(e) {
2576
2614
  const t = e?.timeoutMs;
2577
2615
  return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Ve);
2578
2616
  }
@@ -2590,20 +2628,20 @@ function te(e) {
2590
2628
  function Tt(e, t) {
2591
2629
  return oe(e) ? X : k(j(t), xe);
2592
2630
  }
2593
- function fn(e, t) {
2631
+ function mn(e, t) {
2594
2632
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2595
2633
  }
2596
- async function gn(e, t, s, n) {
2634
+ async function yn(e, t, s, n) {
2597
2635
  const r = te(e.headers);
2598
2636
  n({
2599
2637
  ...t,
2600
2638
  responseStatus: e.status,
2601
2639
  responseHeaders: r,
2602
- responseBody: await mn(e),
2640
+ responseBody: await In(e),
2603
2641
  durationMs: Date.now() - s
2604
2642
  });
2605
2643
  }
2606
- async function mn(e) {
2644
+ async function In(e) {
2607
2645
  if (!ee(e.headers))
2608
2646
  return;
2609
2647
  let t = null, s = null;
@@ -2635,7 +2673,7 @@ async function mn(e) {
2635
2673
  s !== null && window.clearTimeout(s);
2636
2674
  }
2637
2675
  }
2638
- function yn(e, t) {
2676
+ function Tn(e, t) {
2639
2677
  if (ee(new Headers(t)))
2640
2678
  try {
2641
2679
  return e.responseType === "" || e.responseType === "text" ? k(e.responseText ?? "") : void 0;
@@ -2643,18 +2681,18 @@ function yn(e, t) {
2643
2681
  return;
2644
2682
  }
2645
2683
  }
2646
- function vt(e) {
2684
+ function Bt(e) {
2647
2685
  if (typeof e == "string")
2648
2686
  return k(e);
2649
2687
  }
2650
- function In(e) {
2688
+ function wn(e) {
2651
2689
  return A({
2652
2690
  ...e,
2653
- requestBody: qt(e.requestBody),
2654
- responseBody: qt(e.responseBody)
2691
+ requestBody: vt(e.requestBody),
2692
+ responseBody: vt(e.responseBody)
2655
2693
  });
2656
2694
  }
2657
- function qt(e) {
2695
+ function vt(e) {
2658
2696
  if (typeof e != "string")
2659
2697
  return e;
2660
2698
  const t = e.trim();
@@ -2673,7 +2711,7 @@ function ee(e) {
2673
2711
  return s !== null && Number.isInteger(n) && n >= 0 && n <= dt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2674
2712
  }
2675
2713
  function b(e, t = {}, s) {
2676
- if (wn(s))
2714
+ if (Sn(s))
2677
2715
  return !0;
2678
2716
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
2679
2717
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -2688,7 +2726,7 @@ function b(e, t = {}, s) {
2688
2726
  return !0;
2689
2727
  }
2690
2728
  }
2691
- function Tn(e, t) {
2729
+ function An(e, t) {
2692
2730
  if (b(e))
2693
2731
  return !0;
2694
2732
  try {
@@ -2698,10 +2736,10 @@ function Tn(e, t) {
2698
2736
  return !0;
2699
2737
  }
2700
2738
  }
2701
- function wn(e) {
2739
+ function Sn(e) {
2702
2740
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
2703
2741
  }
2704
- function An(e) {
2742
+ function kn(e) {
2705
2743
  const t = {};
2706
2744
  for (const s of e.trim().split(/[\r\n]+/)) {
2707
2745
  const n = s.indexOf(":");
@@ -2732,27 +2770,27 @@ async function tt(e, t) {
2732
2770
  try {
2733
2771
  return await e();
2734
2772
  } catch (r) {
2735
- if (s = r, n >= Et - 1 || !kn(r))
2773
+ if (s = r, n >= Et - 1 || !Rn(r))
2736
2774
  throw r;
2737
- await Sn(n);
2775
+ await En(n);
2738
2776
  }
2739
2777
  throw s instanceof Error ? s : new Error(t);
2740
2778
  }
2741
- function Sn(e) {
2779
+ function En(e) {
2742
2780
  return new Promise((t) => {
2743
2781
  window.setTimeout(t, qe[e] ?? 0);
2744
2782
  });
2745
2783
  }
2746
- function kn(e) {
2747
- return e instanceof H ? En(e.status) : e instanceof TypeError;
2784
+ function Rn(e) {
2785
+ return e instanceof H ? _n(e.status) : e instanceof TypeError;
2748
2786
  }
2749
- function En(e) {
2787
+ function _n(e) {
2750
2788
  return e === 408 || e === 409 || e === 429 || e >= 500;
2751
2789
  }
2752
- function Rn(e) {
2790
+ function bn(e) {
2753
2791
  return e === 401 || e === 403;
2754
2792
  }
2755
- const X = "[REDACTED_SECRET]", E = "[REDACTED_TOKEN]", _n = "[REDACTED_SIGNED_URL]", bn = 20, Mn = /^(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, se = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ne = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, re = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ie = /\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, Cn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Pn = /\bhttps?:\/\/[^\s"'<>]+/gi, Un = /[),.;\]]+$/;
2793
+ const X = "[REDACTED_SECRET]", E = "[REDACTED_TOKEN]", Mn = "[REDACTED_SIGNED_URL]", Cn = 20, Pn = /^(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, se = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ne = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, re = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ie = /\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, Un = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Dn = /\bhttps?:\/\/[^\s"'<>]+/gi, Nn = /[),.;\]]+$/;
2756
2794
  function A(e) {
2757
2795
  return W(e, 0, /* @__PURE__ */ new WeakSet());
2758
2796
  }
@@ -2761,7 +2799,7 @@ function W(e, t, s) {
2761
2799
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
2762
2800
  if (e === null || typeof e != "object")
2763
2801
  return e;
2764
- if (t >= bn)
2802
+ if (t >= Cn)
2765
2803
  return "[REDACTED_MAX_DEPTH]";
2766
2804
  if (s.has(e))
2767
2805
  return "[REDACTED_CIRCULAR]";
@@ -2769,34 +2807,34 @@ function W(e, t, s) {
2769
2807
  return e.map((r) => W(r, t + 1, s));
2770
2808
  const n = {};
2771
2809
  for (const [r, i] of Object.entries(e))
2772
- oe(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? Dn(i) : W(i, t + 1, s);
2810
+ oe(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? On(i) : W(i, t + 1, s);
2773
2811
  return n;
2774
2812
  }
2775
2813
  function oe(e) {
2776
2814
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
2777
2815
  return t.includes("authorization") || t.includes("cookie") || t.includes("password") || t.includes("passwd") || t === "pwd" || t.includes("secret") || t === "token" || t.endsWith("token") || t.includes("apikey") || t.includes("csrf") || t.includes("xsrf") || t === "jwt" || t === "session" || t === "signature" || t.includes("privatekey");
2778
2816
  }
2779
- function Dn(e) {
2817
+ function On(e) {
2780
2818
  return typeof e == "string" ? ae(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
2781
2819
  }
2782
2820
  function ae(e) {
2783
2821
  try {
2784
2822
  const t = new URL(e, location.href);
2785
2823
  for (const s of Array.from(t.searchParams.keys()))
2786
- Mn.test(s) && t.searchParams.set(s, E);
2824
+ Pn.test(s) && t.searchParams.set(s, E);
2787
2825
  return t.username && (t.username = E), t.password && (t.password = E), t.toString();
2788
2826
  } catch {
2789
- return Nn(e);
2827
+ return Ln(e);
2790
2828
  }
2791
2829
  }
2792
2830
  function j(e) {
2793
- return e.replace(Cn, _n).replace(Pn, On).replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
2831
+ return e.replace(Un, Mn).replace(Dn, Bn).replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
2794
2832
  }
2795
- function Nn(e) {
2833
+ function Ln(e) {
2796
2834
  return e.replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
2797
2835
  }
2798
- function On(e) {
2799
- const t = e.match(Un)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2836
+ function Bn(e) {
2837
+ const t = e.match(Nn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2800
2838
  return `${ae(s)}${t}`;
2801
2839
  }
2802
2840
  export {
@@ -2805,8 +2843,8 @@ export {
2805
2843
  Ae as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2806
2844
  we as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2807
2845
  Se as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2808
- zt as PlunoProductAgent,
2846
+ $t as PlunoProductAgent,
2809
2847
  $e as calculateReconnectDelay,
2810
- zt as default,
2848
+ $t as default,
2811
2849
  us as getProductAgentOriginAccessErrorMessage
2812
2850
  };