@pluno/product-agent-web 0.1.92 → 0.1.94

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,6 +1,6 @@
1
1
  const re = "pluno-product-agent-attachments";
2
2
  const st = "files";
3
- async function Nt(e) {
3
+ async function Ot(e) {
4
4
  const t = await $();
5
5
  await Bt(t, "readwrite", (s) => s.put(e));
6
6
  }
@@ -13,9 +13,9 @@ async function ie(e) {
13
13
  if (!s)
14
14
  return null;
15
15
  const n = Date.now();
16
- return await Ot(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
16
+ return await Lt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
17
17
  }
18
- async function Ot(e, t) {
18
+ async function Lt(e, t) {
19
19
  const s = await $();
20
20
  await ut(s, "readwrite", async (n) => {
21
21
  const r = await dt(
@@ -76,7 +76,7 @@ function dt(e) {
76
76
  function ae(e) {
77
77
  return e !== null && (typeof e == "object" || typeof e == "function");
78
78
  }
79
- function Lt(e, t, s) {
79
+ function qt(e, t, s) {
80
80
  const n = Reflect.get(e, "pluno"), r = ae(n) ? n : {};
81
81
  if (r !== n && !Reflect.set(e, "pluno", r))
82
82
  return null;
@@ -91,7 +91,7 @@ function Lt(e, t, s) {
91
91
  }
92
92
  };
93
93
  }
94
- const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed", qt = 10080 * 6e4, ce = 5e3, le = 15e3;
94
+ const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed", xt = 10080 * 6e4, ce = 5e3, le = 15e3;
95
95
  function ue(e, {
96
96
  clientId: t,
97
97
  sessionId: s,
@@ -103,7 +103,7 @@ function ue(e, {
103
103
  clientId: t,
104
104
  sessionId: s,
105
105
  defaultTaskId: `scheduled-${n}`,
106
- expiresAfterDueMs: qt
106
+ expiresAfterDueMs: xt
107
107
  })});
108
108
  const scheduleQuery = (query, delaySeconds) => {
109
109
  if (typeof query !== "string" || query.trim().length === 0) {
@@ -216,7 +216,7 @@ function U(e) {
216
216
  if (!e || typeof e != "object")
217
217
  return !1;
218
218
  const t = e;
219
- return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + qt;
219
+ return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + xt;
220
220
  }
221
221
  function he() {
222
222
  let e;
@@ -264,8 +264,8 @@ function J(e) {
264
264
  }
265
265
  const V = "pluno.productAgent.transportId", pe = "pluno.productAgent.transportIdentity", Y = "pluno.productAgent.transportIdentity.event", ge = 50, fe = globalThis.setTimeout.bind(globalThis);
266
266
  let M = null;
267
- const L = /* @__PURE__ */ new Set();
268
- async function me(e = xt()) {
267
+ const B = /* @__PURE__ */ new Set();
268
+ async function me(e = Ft()) {
269
269
  const t = e.randomUUID(), s = e.storage.getItem(V);
270
270
  let n = s ?? e.randomUUID(), r = !1, i = !1;
271
271
  const o = e.channel.subscribe((u) => {
@@ -302,30 +302,30 @@ async function me(e = xt()) {
302
302
  };
303
303
  }
304
304
  async function ye() {
305
- M || (M = me(xt()), M.then((n) => {
305
+ M || (M = me(Ft()), M.then((n) => {
306
306
  const r = (i) => {
307
- i.persisted || (n.release(), M = null, L.clear(), window.removeEventListener("pagehide", r));
307
+ i.persisted || (n.release(), M = null, B.clear(), window.removeEventListener("pagehide", r));
308
308
  };
309
309
  window.addEventListener("pagehide", r);
310
310
  }));
311
311
  const e = await M, t = Te();
312
- L.add(t);
312
+ B.add(t);
313
313
  let s = !1;
314
314
  return {
315
315
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
316
316
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
317
317
  release: () => {
318
- s || (s = !0, L.delete(t));
318
+ s || (s = !0, B.delete(t));
319
319
  }
320
320
  };
321
321
  }
322
322
  function Te() {
323
323
  let e = 0;
324
- for (; L.has(e); )
324
+ for (; B.has(e); )
325
325
  e += 1;
326
326
  return e;
327
327
  }
328
- function xt() {
328
+ function Ft() {
329
329
  return {
330
330
  storage: window.sessionStorage,
331
331
  channel: we(),
@@ -368,15 +368,15 @@ function Ie() {
368
368
  }
369
369
  };
370
370
  }
371
- const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ae = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Se = ".pluno-pa-widget__panel", ke = ".pluno-pa-widget__timeline", wt = `${rt}[data-pluno-sdk-preview-channel]`, Ee = "https://app.pluno.ai", Re = "gpt-5.6-terra", Ce = 2e4, _e = 1e4, be = 1e4, Me = 1e4, Pe = 1e4, Ue = 1e3, It = 3e4, At = 0.2, St = 6e4, De = 15e3, v = 3, ve = 2e3, Ne = 15e3, Oe = 1e3, Be = 100, Le = 8e3, qe = 15e3, kt = 3, xe = [300, 1e3], ht = 64e3, Z = 4e3, pt = 30, Fe = 2e3, He = 1e3, We = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", je = 100, Ft = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", $e = 100;
371
+ const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ae = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Se = ".pluno-pa-widget__panel", ke = ".pluno-pa-widget__timeline", It = `${rt}[data-pluno-sdk-preview-channel]`, Ee = "https://app.pluno.ai", Re = "gpt-5.6-terra", Ce = 2e4, _e = 1e4, be = 1e4, Me = 1e4, Pe = 1e4, Ue = 1e3, At = 3e4, St = 0.2, kt = 6e4, De = 15e3, v = 3, ve = 2e3, Ne = 15e3, Oe = 1e3, Le = 100, Be = 8e3, qe = 15e3, Et = 3, xe = [300, 1e3], ht = 64e3, Z = 4e3, pt = 30, Fe = 2e3, He = 1e3, We = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", je = 100, Ht = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", $e = 100;
372
372
  function N(e, t = 0) {
373
373
  return Math.max(t, ve * 4 ** e);
374
374
  }
375
375
  const q = /* @__PURE__ */ new Set();
376
376
  let O = null;
377
377
  function ze(e, t = Math.random) {
378
- const s = Math.min(It, Ue * 2 ** e), n = 1 - At + t() * At * 2;
379
- return Math.min(It, Math.round(s * n));
378
+ const s = Math.min(At, Ue * 2 ** e), n = 1 - St + t() * St * 2;
379
+ return Math.min(At, Math.round(s * n));
380
380
  }
381
381
  function Ge(e, t, s) {
382
382
  return new Promise((n, r) => {
@@ -391,13 +391,13 @@ function Ge(e, t, s) {
391
391
  );
392
392
  });
393
393
  }
394
- class Ht {
394
+ class Wt {
395
395
  constructor(t, s) {
396
396
  this.options = t, this.transportIdentity = s, this.state = {
397
397
  ...this.state,
398
398
  starterPrompts: ws(t.initialStarterPrompts)
399
399
  };
400
- const n = t.restorePersistedState === !1 ? null : Js(t.clientId, t.expectedPersistedSessionId);
400
+ const n = t.restorePersistedState === !1 ? null : Vs(t.clientId, t.expectedPersistedSessionId);
401
401
  n && (this.state = {
402
402
  ...this.state,
403
403
  ...n,
@@ -408,9 +408,9 @@ class Ht {
408
408
  assistantDraftRunId: null,
409
409
  isThinking: !1,
410
410
  lastError: null
411
- }), this.queuedClientEvents = sn(
412
- Ys(t.clientId),
413
- Qs(t.clientId)
411
+ }), this.queuedClientEvents = nn(
412
+ Zs(t.clientId),
413
+ tn(t.clientId)
414
414
  ), P(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = de({
415
415
  clientId: t.clientId,
416
416
  canDeliver: (r) => r.sessionId === this.state.sessionId,
@@ -483,7 +483,7 @@ class Ht {
483
483
  lastErrorCode: null
484
484
  };
485
485
  static async init(t) {
486
- const s = await ye(), n = new Ht({
486
+ const s = await ye(), n = new Wt({
487
487
  ...t,
488
488
  backendUrl: us(t.backendUrl ?? Ee),
489
489
  clientId: t.clientId ?? Es(),
@@ -576,15 +576,15 @@ class Ht {
576
576
  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;
577
577
  }
578
578
  destroy() {
579
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), nn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
579
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), rn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
580
580
  for (const t of Object.values(this.listeners))
581
581
  t?.clear();
582
582
  }
583
583
  sendMessage(t, s = {}) {
584
- const n = t.trim(), r = s.attachments ?? [], i = r.map(yt);
584
+ const n = t.trim(), r = s.attachments ?? [], i = r.map(Tt);
585
585
  if (!n && i.length === 0)
586
586
  return null;
587
- const o = S(), a = s.clientMessageId ?? B();
587
+ const o = S(), a = s.clientMessageId ?? L();
588
588
  this.retryableClientMessageId = null;
589
589
  const u = {
590
590
  id: `local-${a}`,
@@ -612,7 +612,7 @@ class Ht {
612
612
  attachments: i.length > 0 ? i : void 0,
613
613
  page: o,
614
614
  model: this.options.model,
615
- metadata: Et(this.options.metadata)
615
+ metadata: Rt(this.options.metadata)
616
616
  };
617
617
  return this.activeClientMessageId = a, this.activeUserMessageEvent = c, this.markThinkingProgress(), this.send(c), this.startBackgroundAttachmentUploads(a, i), a;
618
618
  }
@@ -621,15 +621,15 @@ class Ht {
621
621
  return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = 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: !1 }), !0);
622
622
  }
623
623
  createLocalAttachment(t) {
624
- const s = B(), n = {
624
+ const s = L(), n = {
625
625
  id: s,
626
626
  name: t.name || "attachment",
627
- mimeType: Ut(t),
627
+ mimeType: Dt(t),
628
628
  sizeBytes: t.size
629
629
  };
630
630
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
631
631
  const r = Date.now();
632
- return Nt({
632
+ return Ot({
633
633
  attachmentId: s,
634
634
  name: n.name,
635
635
  mimeType: n.mimeType,
@@ -652,7 +652,7 @@ class Ht {
652
652
  return await this.uploadAttachmentForMessage({
653
653
  file: t,
654
654
  attachment: s,
655
- clientMessageId: B(),
655
+ clientMessageId: L(),
656
656
  waitForSession: !1,
657
657
  notifyCompletion: !1
658
658
  });
@@ -684,7 +684,7 @@ class Ht {
684
684
  waitForSession: r,
685
685
  notifyCompletion: i
686
686
  }) {
687
- const o = r ? await this.waitForSessionId() : this.state.sessionId, a = Ut(t), u = {
687
+ const o = r ? await this.waitForSessionId() : this.state.sessionId, a = Dt(t), u = {
688
688
  sessionId: o ?? void 0,
689
689
  attachmentId: s.id,
690
690
  clientId: this.options.clientId,
@@ -694,7 +694,7 @@ class Ht {
694
694
  sizeBytes: t.size,
695
695
  page: S(),
696
696
  model: this.options.model,
697
- metadata: Et(this.options.metadata)
697
+ metadata: Rt(this.options.metadata)
698
698
  }, l = this.options.prepareAttachmentUpload ? await et(
699
699
  () => this.options.prepareAttachmentUpload(u),
700
700
  "Failed to prepare attachment upload"
@@ -710,7 +710,7 @@ class Ht {
710
710
  return h;
711
711
  }, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
712
712
  const c = Jt(l.attachment, this.options.backendUrl);
713
- return this.updateAttachmentInState(s.id, c), s.id && Ot(s.id, {
713
+ return this.updateAttachmentInState(s.id, c), s.id && Lt(s.id, {
714
714
  sessionId: l.sessionId,
715
715
  fileUrl: c.fileUrl,
716
716
  gcsPath: c.gcsPath,
@@ -754,7 +754,7 @@ class Ht {
754
754
  const n = await this.fetchEmbedAttachmentUpload(t);
755
755
  if (n.ok)
756
756
  return await n.json();
757
- if (Sn(n.status) && this.options.tokenProvider && !s) {
757
+ if (kn(n.status) && this.options.tokenProvider && !s) {
758
758
  s = !0;
759
759
  const r = await this.fetchEmbedAttachmentUpload(t);
760
760
  if (r.ok)
@@ -796,10 +796,10 @@ class Ht {
796
796
  });
797
797
  }
798
798
  listSessions(t = {}) {
799
- const s = B(), n = new Promise((i, o) => {
799
+ const s = L(), n = new Promise((i, o) => {
800
800
  const a = window.setTimeout(() => {
801
801
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
802
- }, Le);
802
+ }, Be);
803
803
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
804
804
  }), r = {
805
805
  type: "sessions.list",
@@ -915,7 +915,7 @@ class Ht {
915
915
  rawAppearance: t.appearance,
916
916
  normalizedAppearance: s
917
917
  }), this.runtimeHelperJavascript = As(t.runtimeHelpers)?.javascript ?? null;
918
- const r = Ct(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
918
+ const r = _t(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
919
919
  user: Rs(t.user),
920
920
  status: "connected"
921
921
  };
@@ -929,7 +929,7 @@ class Ht {
929
929
  }
930
930
  if (t.type === "starterPrompts.updated") {
931
931
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
932
- starterPrompts: Ct(t, "starterPrompts"),
932
+ starterPrompts: _t(t, "starterPrompts"),
933
933
  starterPromptsLoading: !1
934
934
  });
935
935
  return;
@@ -945,10 +945,10 @@ class Ht {
945
945
  u
946
946
  );
947
947
  }
948
- const r = n ? s.filter((u) => !bt(x(u))) : s, i = Ns(
948
+ const r = n ? s.filter((u) => !Mt(x(u))) : s, i = Ns(
949
949
  this.state.messages,
950
950
  Cs(r, this.options.backendUrl)
951
- ), o = _t(i);
951
+ ), o = bt(i);
952
952
  if (!o && Fs(this.state.messages, s))
953
953
  return;
954
954
  const a = o ? null : at(s);
@@ -983,7 +983,7 @@ class Ht {
983
983
  if (t.type === "session.item") {
984
984
  this.rememberUserMessageClientMessageIds([t.item]);
985
985
  const s = x(t.item);
986
- if (bt(s)) {
986
+ if (Mt(s)) {
987
987
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
988
988
  const r = I(t.item, "sessionId") ?? this.state.sessionId, i = s ? D(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
989
989
  if (r && a) {
@@ -995,12 +995,12 @@ class Ht {
995
995
  return;
996
996
  }
997
997
  }
998
- const n = jt(t.item, this.options.backendUrl);
998
+ const n = $t(t.item, this.options.backendUrl);
999
999
  if (n) {
1000
1000
  n.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1001
1001
  const r = t.item.data;
1002
1002
  js(r) && this.clearRunAckResyncRetryTimer();
1003
- const i = vs(this.state.messages, n), o = _t(i);
1003
+ const i = vs(this.state.messages, n), o = bt(i);
1004
1004
  this.setState({
1005
1005
  messages: i,
1006
1006
  assistantDraft: n.role === "assistant" ? "" : this.state.assistantDraft,
@@ -1126,7 +1126,7 @@ class Ht {
1126
1126
  this.pendingSessionHistoryRequests.clear();
1127
1127
  }
1128
1128
  markThinkingProgress() {
1129
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(St), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1129
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(kt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1130
1130
  }
1131
1131
  scheduleThinkingWatchdog(t) {
1132
1132
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1170,7 +1170,7 @@ class Ht {
1170
1170
  sessionId: this.state.sessionId,
1171
1171
  clientMessageId: t,
1172
1172
  automatic: !0
1173
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(St)));
1173
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(kt)));
1174
1174
  }, N(s)));
1175
1175
  }
1176
1176
  clearRunAckResyncRetryTimer() {
@@ -1242,7 +1242,7 @@ class Ht {
1242
1242
  const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = typeof t.summary == "string" ? t.summary : "Running browser tool", o = t.rawInput;
1243
1243
  if (!s || !n || !r)
1244
1244
  return;
1245
- if (r !== "execute_code" || !un(o)) {
1245
+ if (r !== "execute_code" || !dn(o)) {
1246
1246
  this.send({
1247
1247
  type: "tool.result",
1248
1248
  sessionId: s,
@@ -1274,7 +1274,7 @@ class Ht {
1274
1274
  startedAtOrigin: location.origin
1275
1275
  }), this.installSessionUserFilesApi(a);
1276
1276
  let u = null, l;
1277
- u = await this.executeRuntimeHelper(), l = await Rt({
1277
+ u = await this.executeRuntimeHelper(), l = await Ct({
1278
1278
  ...o,
1279
1279
  javascript: ue(o.javascript, {
1280
1280
  clientId: this.options.clientId,
@@ -1294,7 +1294,7 @@ class Ht {
1294
1294
  summary: o.summary,
1295
1295
  rawInput: k(o),
1296
1296
  rawOutput: k(Ss(l, u))
1297
- }), Zs(this.options.clientId, this.activeBrowserToolCalls.values());
1297
+ }), Qs(this.options.clientId, this.activeBrowserToolCalls.values());
1298
1298
  }
1299
1299
  startPageLifecycleRecovery() {
1300
1300
  if (this.pageLifecycleCleanup)
@@ -1315,18 +1315,18 @@ class Ht {
1315
1315
  async executeRuntimeHelper() {
1316
1316
  if (!this.runtimeHelperJavascript?.trim())
1317
1317
  return null;
1318
- const t = await Rt({
1318
+ const t = await Ct({
1319
1319
  javascript: this.runtimeHelperJavascript
1320
1320
  });
1321
1321
  return t.ok === !1 ? ks(t) : null;
1322
1322
  }
1323
1323
  enableNetworkCapture() {
1324
1324
  this.networkCaptureCleanup || (this.networkCaptureCleanup = Xe((t) => {
1325
- mn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1325
+ yn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1326
1326
  }));
1327
1327
  }
1328
1328
  enqueueNetworkEvent(t) {
1329
- this.queuedNetworkEvents.length >= Be || (this.queuedNetworkEvents.push(fn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1329
+ this.queuedNetworkEvents.length >= Le || (this.queuedNetworkEvents.push(mn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1330
1330
  this.networkBatchTimer = null;
1331
1331
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1332
1332
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1382,7 +1382,7 @@ class Ht {
1382
1382
  ...this.state,
1383
1383
  ...t,
1384
1384
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
1385
- }, Vs(this.options.clientId, this.state), this.emit("state", this.getState());
1385
+ }, Ys(this.options.clientId, this.state), this.emit("state", this.getState());
1386
1386
  }
1387
1387
  emit(t, s) {
1388
1388
  this.listeners[t]?.forEach((r) => r(s));
@@ -1412,20 +1412,20 @@ function Ke() {
1412
1412
  throw m;
1413
1413
  }
1414
1414
  try {
1415
- const m = p instanceof Request ? p : null, f = dn(p, m), A = Vt(d?.headers ?? m?.headers);
1415
+ const m = p instanceof Request ? p : null, f = hn(p, m), A = Vt(d?.headers ?? m?.headers);
1416
1416
  if (!b(f, A, d?.body)) {
1417
1417
  const K = {
1418
1418
  requestId: tt("fetch"),
1419
1419
  url: E(f, Z),
1420
1420
  method: (d?.method ?? m?.method ?? "GET").toUpperCase(),
1421
1421
  requestHeaders: A,
1422
- requestBody: Dt(d?.body),
1422
+ requestBody: vt(d?.body),
1423
1423
  resourceType: "fetch",
1424
1424
  startedAt: new Date(g).toISOString()
1425
1425
  };
1426
1426
  w.then(
1427
1427
  (C) => {
1428
- hn(C, K, g, t).catch(() => {
1428
+ pn(C, K, g, t).catch(() => {
1429
1429
  t({
1430
1430
  ...K,
1431
1431
  responseStatus: C.status,
@@ -1458,16 +1458,16 @@ function Ke() {
1458
1458
  }), f;
1459
1459
  }, u = function(p, d) {
1460
1460
  const g = r.call(this, p, d), w = Q.get(this);
1461
- return w && Object.keys(w.requestHeaders).length < pt && (w.requestHeaders[p] = Tt(p, d), w.excluded = w.excluded || b(w.url, w.requestHeaders)), g;
1461
+ return w && Object.keys(w.requestHeaders).length < pt && (w.requestHeaders[p] = wt(p, d), w.excluded = w.excluded || b(w.url, w.requestHeaders)), g;
1462
1462
  }, l = function(p) {
1463
1463
  try {
1464
1464
  const d = Q.get(this);
1465
- d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Dt(p), d.excluded || this.addEventListener(
1465
+ d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = vt(p), d.excluded || this.addEventListener(
1466
1466
  "loadend",
1467
1467
  () => {
1468
1468
  queueMicrotask(() => {
1469
1469
  try {
1470
- const g = Tn(this.getAllResponseHeaders());
1470
+ const g = wn(this.getAllResponseHeaders());
1471
1471
  t({
1472
1472
  requestId: d.requestId,
1473
1473
  url: d.url,
@@ -1477,7 +1477,7 @@ function Ke() {
1477
1477
  resourceType: "xhr",
1478
1478
  responseStatus: this.status,
1479
1479
  responseHeaders: g,
1480
- responseBody: gn(this, g),
1480
+ responseBody: fn(this, g),
1481
1481
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1482
1482
  startedAt: d.startedAt,
1483
1483
  durationMs: Date.now() - d.startedAtMs
@@ -1569,7 +1569,7 @@ function y(e, t, s) {
1569
1569
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1570
1570
  i.push(r), i.length > 120 && i.splice(0, i.length - 120), n.__plunoProductAgentDiagnostics__ = i, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: r }));
1571
1571
  }
1572
- function Et(e) {
1572
+ function Rt(e) {
1573
1573
  const t = typeof e == "function" ? e() : e;
1574
1574
  return t && Object.keys(t).length > 0 ? t : void 0;
1575
1575
  }
@@ -1627,13 +1627,13 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1627
1627
  return s.set(c.id, p), p;
1628
1628
  if (!c.fileUrl)
1629
1629
  throw new Error(`Pluno user file is missing content: ${l}`);
1630
- const d = await fetch(c.fileUrl, rn(c.fileUrl));
1630
+ const d = await fetch(c.fileUrl, on(c.fileUrl));
1631
1631
  if (!d.ok)
1632
1632
  throw new Error(`Failed to load Pluno user file: ${l}`);
1633
1633
  const g = await d.blob();
1634
1634
  s.set(c.id, g);
1635
1635
  const w = Date.now();
1636
- return Nt({
1636
+ return Ot({
1637
1637
  attachmentId: c.id,
1638
1638
  name: c.name,
1639
1639
  mimeType: c.mimeType,
@@ -1651,7 +1651,7 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1651
1651
  });
1652
1652
  }), g;
1653
1653
  };
1654
- return Lt(globalThis, "userFiles", {
1654
+ return qt(globalThis, "userFiles", {
1655
1655
  list: () => e.map(r),
1656
1656
  get: (l) => {
1657
1657
  const c = n.get(l);
@@ -1690,7 +1690,7 @@ function ts(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1690
1690
  });
1691
1691
  }
1692
1692
  function es() {
1693
- return Lt(globalThis, "pageImages", {
1693
+ return qt(globalThis, "pageImages", {
1694
1694
  inspectImage: async (t, s) => await ss(t, s)
1695
1695
  });
1696
1696
  }
@@ -1770,7 +1770,7 @@ function ot(e) {
1770
1770
  function cs(e, t) {
1771
1771
  return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
1772
1772
  }
1773
- async function Rt(e) {
1773
+ async function Ct(e) {
1774
1774
  const t = Object.getPrototypeOf(async function() {
1775
1775
  }).constructor, s = e.timeoutMs ?? Ve, n = Date.now(), r = [];
1776
1776
  let i;
@@ -1844,7 +1844,7 @@ function hs(e) {
1844
1844
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1845
1845
  }
1846
1846
  function S() {
1847
- const e = Wt();
1847
+ const e = jt();
1848
1848
  return {
1849
1849
  url: location.href,
1850
1850
  title: document.title,
@@ -1880,7 +1880,7 @@ function fs() {
1880
1880
  };
1881
1881
  }
1882
1882
  function ms() {
1883
- return Wt()?.surface === "browser_extension_sdk_preview";
1883
+ return jt()?.surface === "browser_extension_sdk_preview";
1884
1884
  }
1885
1885
  function ys() {
1886
1886
  const e = document.body?.cloneNode(!0);
@@ -1906,8 +1906,8 @@ function ys() {
1906
1906
  s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
1907
1907
  }), 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) ?? "") : "";
1908
1908
  }
1909
- function Wt() {
1910
- const e = document.querySelector(wt);
1909
+ function jt() {
1910
+ const e = document.querySelector(It);
1911
1911
  if (!(e ?? document.querySelector(rt)))
1912
1912
  return;
1913
1913
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
@@ -1917,7 +1917,7 @@ function Wt() {
1917
1917
  selectors: [
1918
1918
  {
1919
1919
  name: "widget_host",
1920
- selector: s === "browser_extension_sdk_preview" ? wt : rt,
1920
+ selector: s === "browser_extension_sdk_preview" ? It : rt,
1921
1921
  description: "Finds Pluno's shadow-host element in the host page DOM."
1922
1922
  },
1923
1923
  {
@@ -1946,7 +1946,7 @@ function Ts(e) {
1946
1946
  return { type: "error", message: "Invalid server event" };
1947
1947
  }
1948
1948
  }
1949
- function Ct(e, t) {
1949
+ function _t(e, t) {
1950
1950
  if (!e || typeof e != "object")
1951
1951
  return [];
1952
1952
  const s = e[t];
@@ -1995,7 +1995,7 @@ function Es() {
1995
1995
  const s = crypto.randomUUID();
1996
1996
  return window.localStorage.setItem(e, s), s;
1997
1997
  }
1998
- function B() {
1998
+ function L() {
1999
1999
  return crypto.randomUUID();
2000
2000
  }
2001
2001
  function Rs(e) {
@@ -2012,7 +2012,7 @@ function Rs(e) {
2012
2012
  function Cs(e, t) {
2013
2013
  return Array.isArray(e) ? ct(
2014
2014
  lt(
2015
- e.map((s) => jt(s, t)).filter((s) => s !== null)
2015
+ e.map((s) => $t(s, t)).filter((s) => s !== null)
2016
2016
  )
2017
2017
  ) : [];
2018
2018
  }
@@ -2035,7 +2035,7 @@ function _s(e) {
2035
2035
  ];
2036
2036
  }) : [];
2037
2037
  }
2038
- function jt(e, t) {
2038
+ function $t(e, t) {
2039
2039
  if (!e || typeof e != "object")
2040
2040
  return null;
2041
2041
  const s = e, n = s.data;
@@ -2073,7 +2073,8 @@ function jt(e, t) {
2073
2073
  respondsToUserMessageId: D(r) ?? void 0,
2074
2074
  ..._(r) ? { runId: _(r) } : {},
2075
2075
  dataType: String(r.type),
2076
- loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying")
2076
+ loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
2077
+ ...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {}
2077
2078
  } : null;
2078
2079
  }
2079
2080
  function bs(e) {
@@ -2119,7 +2120,7 @@ function Ds(e) {
2119
2120
  }).filter(Boolean).join("") : "";
2120
2121
  }
2121
2122
  function vs(e, t) {
2122
- const s = $t(e, t), n = Ls(e, t), r = n.findIndex((o) => o.id === s.id);
2123
+ const s = zt(e, t), n = Bs(e, t), r = n.findIndex((o) => o.id === s.id);
2123
2124
  if (r === -1)
2124
2125
  return ct(
2125
2126
  lt([...n, s])
@@ -2129,13 +2130,13 @@ function vs(e, t) {
2129
2130
  }
2130
2131
  function Ns(e, t) {
2131
2132
  const s = t.map(
2132
- (n) => $t(e, n)
2133
+ (n) => zt(e, n)
2133
2134
  );
2134
2135
  return t.length > 0 ? s : e.filter(
2135
2136
  (n) => n.role === "user" && n.id.startsWith("local-")
2136
2137
  );
2137
2138
  }
2138
- function $t(e, t) {
2139
+ function zt(e, t) {
2139
2140
  if (t.role !== "user" || !t.attachments?.length)
2140
2141
  return t;
2141
2142
  const s = e.find(
@@ -2145,18 +2146,18 @@ function $t(e, t) {
2145
2146
  return t;
2146
2147
  const n = t.attachments.map((r) => {
2147
2148
  const i = Os(s.attachments ?? [], r);
2148
- return i ? Bs(r, i) : r;
2149
+ return i ? Ls(r, i) : r;
2149
2150
  });
2150
2151
  return { ...t, attachments: n };
2151
2152
  }
2152
2153
  function Os(e, t) {
2153
2154
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2154
2155
  }
2155
- function Bs(e, t) {
2156
+ function Ls(e, t) {
2156
2157
  const { previewUrl: s } = t;
2157
2158
  return s ? { ...e, previewUrl: s } : e;
2158
2159
  }
2159
- function Ls(e, t) {
2160
+ function Bs(e, t) {
2160
2161
  if (t.role !== "user")
2161
2162
  return e;
2162
2163
  const s = e.findIndex(
@@ -2167,8 +2168,8 @@ function Ls(e, t) {
2167
2168
  const n = [...e];
2168
2169
  return n.splice(s, 1), n;
2169
2170
  }
2170
- function _t(e) {
2171
- const t = zt(e);
2171
+ function bt(e) {
2172
+ const t = Gt(e);
2172
2173
  if (t === null)
2173
2174
  return !1;
2174
2175
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -2185,10 +2186,10 @@ function _t(e) {
2185
2186
  return !1;
2186
2187
  }
2187
2188
  function qs(e) {
2188
- const t = zt(e);
2189
+ const t = Gt(e);
2189
2190
  return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
2190
2191
  }
2191
- function zt(e) {
2192
+ function Gt(e) {
2192
2193
  for (let t = e.length - 1; t >= 0; t -= 1)
2193
2194
  if (e[t].role === "user")
2194
2195
  return t;
@@ -2217,7 +2218,7 @@ function x(e) {
2217
2218
  const t = e.data;
2218
2219
  return t && typeof t == "object" ? t : null;
2219
2220
  }
2220
- function bt(e) {
2221
+ function Mt(e) {
2221
2222
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2222
2223
  }
2223
2224
  function Fs(e, t) {
@@ -2258,13 +2259,13 @@ function Hs(e) {
2258
2259
  if (i.type === "message" && i.role === "assistant")
2259
2260
  return null;
2260
2261
  if (i.type === "run_error")
2261
- return i.retryable !== !0 ? null : Mt(e, i) ?? at(e);
2262
+ return i.retryable !== !0 ? null : Pt(e, i) ?? at(e);
2262
2263
  if (i.type === "run_status")
2263
- return i.status === "interrupted" && i.retryable === !0 ? Mt(e, i) ?? at(e) : null;
2264
+ return i.status === "interrupted" && i.retryable === !0 ? Pt(e, i) ?? at(e) : null;
2264
2265
  }
2265
2266
  return null;
2266
2267
  }
2267
- function Mt(e, t) {
2268
+ function Pt(e, t) {
2268
2269
  if (typeof t.clientMessageId == "string")
2269
2270
  return t.clientMessageId;
2270
2271
  const s = D(t);
@@ -2293,12 +2294,12 @@ function js(e) {
2293
2294
  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";
2294
2295
  }
2295
2296
  function ct(e) {
2296
- return e.filter((t, s) => Gt(t) ? !Ks(e, s) && !Gs(e, s) && !Xs(e, s) : $s(t) ? !zs(e, s) : !0);
2297
+ return e.filter((t, s) => mt(t) ? !Js(e, s) && !Xs(e, s) && !Ks(e, s) : $s(t) ? t.retryable === !0 && Gs(e, s) ? !1 : !zs(e, s) : !0);
2297
2298
  }
2298
2299
  function $s(e) {
2299
2300
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
2300
2301
  }
2301
- function Gt(e) {
2302
+ function mt(e) {
2302
2303
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2303
2304
  }
2304
2305
  function lt(e) {
@@ -2329,23 +2330,36 @@ function zs(e, t) {
2329
2330
  return !1;
2330
2331
  }
2331
2332
  function Gs(e, t) {
2333
+ const s = e[t];
2334
+ if (!s.respondsToUserMessageId)
2335
+ return !1;
2336
+ for (let n = t + 1; n < e.length; n += 1) {
2337
+ const r = e[n];
2338
+ if (r.role === "user")
2339
+ return !1;
2340
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || mt(r)))
2341
+ return !0;
2342
+ }
2343
+ return !1;
2344
+ }
2345
+ function Xs(e, t) {
2332
2346
  const s = e[t];
2333
2347
  for (let n = t + 1; n < e.length; n += 1)
2334
2348
  if (e[n].role === "assistant" && G(s, e[n]))
2335
2349
  return !0;
2336
2350
  return !1;
2337
2351
  }
2338
- function Xs(e, t) {
2352
+ function Ks(e, t) {
2339
2353
  const s = e[t];
2340
2354
  for (let n = t + 1; n < e.length; n += 1)
2341
2355
  if (e[n].role === "tool" && G(s, e[n]))
2342
2356
  return !0;
2343
2357
  return !1;
2344
2358
  }
2345
- function Ks(e, t) {
2359
+ function Js(e, t) {
2346
2360
  const s = e[t];
2347
2361
  for (let n = t + 1; n < e.length; n += 1)
2348
- if (Gt(e[n]) && G(s, e[n]))
2362
+ if (mt(e[n]) && G(s, e[n]))
2349
2363
  return !0;
2350
2364
  return !1;
2351
2365
  }
@@ -2355,15 +2369,15 @@ function G(e, t) {
2355
2369
  function I(e, t) {
2356
2370
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2357
2371
  }
2358
- function Js(e, t) {
2372
+ function Vs(e, t) {
2359
2373
  try {
2360
- const s = window.localStorage.getItem(`${Ft}${e}`);
2374
+ const s = window.localStorage.getItem(`${Ht}${e}`);
2361
2375
  if (!s)
2362
2376
  return null;
2363
2377
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2364
2378
  if (t !== void 0 && r !== t)
2365
2379
  return null;
2366
- const i = Array.isArray(n.messages) ? n.messages.map(cn).filter((o) => !!o) : [];
2380
+ const i = Array.isArray(n.messages) ? n.messages.map(ln).filter((o) => !!o) : [];
2367
2381
  return {
2368
2382
  sessionId: r,
2369
2383
  messages: i
@@ -2372,33 +2386,33 @@ function Js(e, t) {
2372
2386
  return null;
2373
2387
  }
2374
2388
  }
2375
- function Vs(e, t) {
2389
+ function Ys(e, t) {
2376
2390
  try {
2377
2391
  window.localStorage.setItem(
2378
- `${Ft}${e}`,
2392
+ `${Ht}${e}`,
2379
2393
  JSON.stringify({
2380
2394
  sessionId: t.sessionId,
2381
- messages: t.messages.slice(-je).map(ln)
2395
+ messages: t.messages.slice(-je).map(un)
2382
2396
  })
2383
2397
  );
2384
2398
  } catch {
2385
2399
  return;
2386
2400
  }
2387
2401
  }
2388
- function Ys(e) {
2402
+ function Zs(e) {
2389
2403
  try {
2390
2404
  const t = window.localStorage.getItem(`${it}${e}`);
2391
2405
  if (!t)
2392
2406
  return [];
2393
2407
  const s = JSON.parse(t);
2394
- return Array.isArray(s) ? s.filter(mt) : [];
2408
+ return Array.isArray(s) ? s.filter(yt) : [];
2395
2409
  } catch {
2396
2410
  return [];
2397
2411
  }
2398
2412
  }
2399
2413
  function P(e, t) {
2400
2414
  try {
2401
- const s = t.filter(mt);
2415
+ const s = t.filter(yt);
2402
2416
  if (s.length === 0) {
2403
2417
  window.localStorage.removeItem(`${it}${e}`);
2404
2418
  return;
@@ -2427,7 +2441,7 @@ function Xt(e, t) {
2427
2441
  } catch {
2428
2442
  }
2429
2443
  }
2430
- function Zs(e, t) {
2444
+ function Qs(e, t) {
2431
2445
  try {
2432
2446
  if (window.sessionStorage.getItem(`${z}${e}`) === null)
2433
2447
  return;
@@ -2436,19 +2450,19 @@ function Zs(e, t) {
2436
2450
  }
2437
2451
  Xt(e, t);
2438
2452
  }
2439
- function Qs(e) {
2453
+ function tn(e) {
2440
2454
  try {
2441
2455
  const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
2442
2456
  if (window.sessionStorage.removeItem(t), !s)
2443
2457
  return [];
2444
2458
  const n = JSON.parse(s);
2445
- return Array.isArray(n) ? n.flatMap((r) => en(r) ? [{
2459
+ return Array.isArray(n) ? n.flatMap((r) => sn(r) ? [{
2446
2460
  ...r.event,
2447
2461
  page: S(),
2448
2462
  rawOutput: {
2449
2463
  pageContextRestarted: !0,
2450
2464
  outcome: "unknown",
2451
- message: tn(location.href),
2465
+ message: en(location.href),
2452
2466
  currentUrl: location.href,
2453
2467
  console: [],
2454
2468
  metadata: {
@@ -2465,17 +2479,17 @@ function Qs(e) {
2465
2479
  return [];
2466
2480
  }
2467
2481
  }
2468
- function tn(e) {
2482
+ function en(e) {
2469
2483
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2470
2484
  Current URL: ${e}`;
2471
2485
  }
2472
- function en(e) {
2486
+ function sn(e) {
2473
2487
  if (!e || typeof e != "object")
2474
2488
  return !1;
2475
2489
  const t = e, s = t.event;
2476
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && mt(s) && s.type === "tool.result";
2490
+ 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";
2477
2491
  }
2478
- function sn(e, t) {
2492
+ function nn(e, t) {
2479
2493
  const s = new Set(
2480
2494
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2481
2495
  );
@@ -2484,20 +2498,20 @@ function sn(e, t) {
2484
2498
  ...t.filter((n) => !s.has(n.callId))
2485
2499
  ];
2486
2500
  }
2487
- function nn(e) {
2501
+ function rn(e) {
2488
2502
  try {
2489
2503
  window.sessionStorage.removeItem(`${z}${e}`);
2490
2504
  } catch {
2491
2505
  return;
2492
2506
  }
2493
2507
  }
2494
- function mt(e) {
2508
+ function yt(e) {
2495
2509
  if (!e || typeof e != "object")
2496
2510
  return !1;
2497
2511
  const t = e;
2498
- return t.type === "chat.user_message" ? typeof t.content == "string" && Pt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Pt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : 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;
2512
+ return t.type === "chat.user_message" ? typeof t.content == "string" && Ut(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ut(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : 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;
2499
2513
  }
2500
- function Pt(e) {
2514
+ function Ut(e) {
2501
2515
  if (!e || typeof e != "object")
2502
2516
  return !1;
2503
2517
  const t = e;
@@ -2520,15 +2534,15 @@ function Jt(e, t) {
2520
2534
  fileUrl: new URL(e.fileUrl, t).toString()
2521
2535
  } : e;
2522
2536
  }
2523
- function rn(e) {
2524
- if (on(e))
2537
+ function on(e) {
2538
+ if (an(e))
2525
2539
  return {
2526
2540
  headers: {
2527
2541
  "ngrok-skip-browser-warning": "true"
2528
2542
  }
2529
2543
  };
2530
2544
  }
2531
- function on(e) {
2545
+ function an(e) {
2532
2546
  try {
2533
2547
  const t = new URL(e).hostname;
2534
2548
  return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
@@ -2536,14 +2550,14 @@ function on(e) {
2536
2550
  return !1;
2537
2551
  }
2538
2552
  }
2539
- function Ut(e) {
2540
- return e.type || an(e.name) || "application/octet-stream";
2553
+ function Dt(e) {
2554
+ return e.type || cn(e.name) || "application/octet-stream";
2541
2555
  }
2542
- function an(e) {
2556
+ function cn(e) {
2543
2557
  const t = e.toLowerCase();
2544
2558
  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;
2545
2559
  }
2546
- function cn(e) {
2560
+ function ln(e) {
2547
2561
  if (!e || typeof e != "object")
2548
2562
  return null;
2549
2563
  const t = e;
@@ -2555,17 +2569,17 @@ function cn(e) {
2555
2569
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
2556
2570
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
2557
2571
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
2558
- attachments: Kt(t.attachments)?.map(yt),
2572
+ attachments: Kt(t.attachments)?.map(Tt),
2559
2573
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2560
2574
  };
2561
2575
  }
2562
- function ln(e) {
2576
+ function un(e) {
2563
2577
  return e.attachments?.length ? {
2564
2578
  ...e,
2565
- attachments: e.attachments.map(yt)
2579
+ attachments: e.attachments.map(Tt)
2566
2580
  } : e;
2567
2581
  }
2568
- function yt(e) {
2582
+ function Tt(e) {
2569
2583
  const {
2570
2584
  dataUrl: t,
2571
2585
  objectUrl: s,
@@ -2582,7 +2596,7 @@ function _(e) {
2582
2596
  const t = e.runId;
2583
2597
  return typeof t == "string" && t ? t : null;
2584
2598
  }
2585
- function un(e) {
2599
+ function dn(e) {
2586
2600
  const t = e?.timeoutMs;
2587
2601
  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 <= Ye);
2588
2602
  }
@@ -2590,30 +2604,30 @@ function Vt(e) {
2590
2604
  const t = {};
2591
2605
  try {
2592
2606
  new Headers(e).forEach((s, n) => {
2593
- Object.keys(t).length < pt && (t[n] = Tt(n, s));
2607
+ Object.keys(t).length < pt && (t[n] = wt(n, s));
2594
2608
  });
2595
2609
  } catch {
2596
2610
  return {};
2597
2611
  }
2598
2612
  return t;
2599
2613
  }
2600
- function Tt(e, t) {
2614
+ function wt(e, t) {
2601
2615
  return se(e) ? X : E(j(t), Fe);
2602
2616
  }
2603
- function dn(e, t) {
2617
+ function hn(e, t) {
2604
2618
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2605
2619
  }
2606
- async function hn(e, t, s, n) {
2620
+ async function pn(e, t, s, n) {
2607
2621
  const r = Vt(e.headers);
2608
2622
  n({
2609
2623
  ...t,
2610
2624
  responseStatus: e.status,
2611
2625
  responseHeaders: r,
2612
- responseBody: await pn(e),
2626
+ responseBody: await gn(e),
2613
2627
  durationMs: Date.now() - s
2614
2628
  });
2615
2629
  }
2616
- async function pn(e) {
2630
+ async function gn(e) {
2617
2631
  if (!Yt(e.headers))
2618
2632
  return;
2619
2633
  let t = null, s = null;
@@ -2645,7 +2659,7 @@ async function pn(e) {
2645
2659
  s !== null && window.clearTimeout(s);
2646
2660
  }
2647
2661
  }
2648
- function gn(e, t) {
2662
+ function fn(e, t) {
2649
2663
  if (Yt(new Headers(t)))
2650
2664
  try {
2651
2665
  return e.responseType === "" || e.responseType === "text" ? E(e.responseText ?? "") : void 0;
@@ -2653,18 +2667,18 @@ function gn(e, t) {
2653
2667
  return;
2654
2668
  }
2655
2669
  }
2656
- function Dt(e) {
2670
+ function vt(e) {
2657
2671
  if (typeof e == "string")
2658
2672
  return E(e);
2659
2673
  }
2660
- function fn(e) {
2674
+ function mn(e) {
2661
2675
  return k({
2662
2676
  ...e,
2663
- requestBody: vt(e.requestBody),
2664
- responseBody: vt(e.responseBody)
2677
+ requestBody: Nt(e.requestBody),
2678
+ responseBody: Nt(e.responseBody)
2665
2679
  });
2666
2680
  }
2667
- function vt(e) {
2681
+ function Nt(e) {
2668
2682
  if (typeof e != "string")
2669
2683
  return e;
2670
2684
  const t = e.trim();
@@ -2683,7 +2697,7 @@ function Yt(e) {
2683
2697
  return s !== null && Number.isInteger(n) && n >= 0 && n <= ht && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2684
2698
  }
2685
2699
  function b(e, t = {}, s) {
2686
- if (yn(s))
2700
+ if (Tn(s))
2687
2701
  return !0;
2688
2702
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
2689
2703
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -2698,7 +2712,7 @@ function b(e, t = {}, s) {
2698
2712
  return !0;
2699
2713
  }
2700
2714
  }
2701
- function mn(e, t) {
2715
+ function yn(e, t) {
2702
2716
  if (b(e))
2703
2717
  return !0;
2704
2718
  try {
@@ -2708,10 +2722,10 @@ function mn(e, t) {
2708
2722
  return !0;
2709
2723
  }
2710
2724
  }
2711
- function yn(e) {
2725
+ function Tn(e) {
2712
2726
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
2713
2727
  }
2714
- function Tn(e) {
2728
+ function wn(e) {
2715
2729
  const t = {};
2716
2730
  for (const s of e.trim().split(/[\r\n]+/)) {
2717
2731
  const n = s.indexOf(":");
@@ -2720,7 +2734,7 @@ function Tn(e) {
2720
2734
  if (Object.keys(t).length >= pt)
2721
2735
  break;
2722
2736
  const r = s.slice(0, n).trim();
2723
- t[r] = Tt(r, s.slice(n + 1).trim());
2737
+ t[r] = wt(r, s.slice(n + 1).trim());
2724
2738
  }
2725
2739
  return t;
2726
2740
  }
@@ -2738,31 +2752,31 @@ class F extends Error {
2738
2752
  }
2739
2753
  async function et(e, t) {
2740
2754
  let s = null;
2741
- for (let n = 0; n < kt; n += 1)
2755
+ for (let n = 0; n < Et; n += 1)
2742
2756
  try {
2743
2757
  return await e();
2744
2758
  } catch (r) {
2745
- if (s = r, n >= kt - 1 || !In(r))
2759
+ if (s = r, n >= Et - 1 || !An(r))
2746
2760
  throw r;
2747
- await wn(n);
2761
+ await In(n);
2748
2762
  }
2749
2763
  throw s instanceof Error ? s : new Error(t);
2750
2764
  }
2751
- function wn(e) {
2765
+ function In(e) {
2752
2766
  return new Promise((t) => {
2753
2767
  window.setTimeout(t, xe[e] ?? 0);
2754
2768
  });
2755
2769
  }
2756
- function In(e) {
2757
- return e instanceof F ? An(e.status) : e instanceof TypeError;
2758
- }
2759
2770
  function An(e) {
2760
- return e === 408 || e === 409 || e === 429 || e >= 500;
2771
+ return e instanceof F ? Sn(e.status) : e instanceof TypeError;
2761
2772
  }
2762
2773
  function Sn(e) {
2774
+ return e === 408 || e === 409 || e === 429 || e >= 500;
2775
+ }
2776
+ function kn(e) {
2763
2777
  return e === 401 || e === 403;
2764
2778
  }
2765
- const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", kn = "[REDACTED_SIGNED_URL]", En = 20, Rn = /^(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, Zt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Qt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, te = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ee = /\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, _n = /\bhttps?:\/\/[^\s"'<>]+/gi, bn = /[),.;\]]+$/;
2779
+ const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", En = "[REDACTED_SIGNED_URL]", Rn = 20, Cn = /^(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, Zt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Qt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, te = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ee = /\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, _n = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, bn = /\bhttps?:\/\/[^\s"'<>]+/gi, Mn = /[),.;\]]+$/;
2766
2780
  function k(e) {
2767
2781
  return W(e, 0, /* @__PURE__ */ new WeakSet());
2768
2782
  }
@@ -2771,7 +2785,7 @@ function W(e, t, s) {
2771
2785
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
2772
2786
  if (e === null || typeof e != "object")
2773
2787
  return e;
2774
- if (t >= En)
2788
+ if (t >= Rn)
2775
2789
  return "[REDACTED_MAX_DEPTH]";
2776
2790
  if (s.has(e))
2777
2791
  return "[REDACTED_CIRCULAR]";
@@ -2779,44 +2793,44 @@ function W(e, t, s) {
2779
2793
  return e.map((r) => W(r, t + 1, s));
2780
2794
  const n = {};
2781
2795
  for (const [r, i] of Object.entries(e))
2782
- se(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? Mn(i) : W(i, t + 1, s);
2796
+ se(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? Pn(i) : W(i, t + 1, s);
2783
2797
  return n;
2784
2798
  }
2785
2799
  function se(e) {
2786
2800
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
2787
2801
  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");
2788
2802
  }
2789
- function Mn(e) {
2803
+ function Pn(e) {
2790
2804
  return typeof e == "string" ? ne(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
2791
2805
  }
2792
2806
  function ne(e) {
2793
2807
  try {
2794
2808
  const t = new URL(e, location.href);
2795
2809
  for (const s of Array.from(t.searchParams.keys()))
2796
- Rn.test(s) && t.searchParams.set(s, R);
2810
+ Cn.test(s) && t.searchParams.set(s, R);
2797
2811
  return t.username && (t.username = R), t.password && (t.password = R), t.toString();
2798
2812
  } catch {
2799
- return Pn(e);
2813
+ return Un(e);
2800
2814
  }
2801
2815
  }
2802
2816
  function j(e) {
2803
- return e.replace(Cn, kn).replace(_n, Un).replace(Zt, `Bearer ${R}`).replace(Qt, `Basic ${R}`).replace(te, R).replace(ee, (t, s) => `${s}: ${X}`);
2817
+ return e.replace(_n, En).replace(bn, Dn).replace(Zt, `Bearer ${R}`).replace(Qt, `Basic ${R}`).replace(te, R).replace(ee, (t, s) => `${s}: ${X}`);
2804
2818
  }
2805
- function Pn(e) {
2819
+ function Un(e) {
2806
2820
  return e.replace(Zt, `Bearer ${R}`).replace(Qt, `Basic ${R}`).replace(te, R).replace(ee, (t, s) => `${s}: ${X}`);
2807
2821
  }
2808
- function Un(e) {
2809
- const t = e.match(bn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2822
+ function Dn(e) {
2823
+ const t = e.match(Mn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2810
2824
  return `${ne(s)}${t}`;
2811
2825
  }
2812
2826
  export {
2813
- wt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2827
+ It as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2814
2828
  rt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2815
2829
  Se as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2816
2830
  Ae as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2817
2831
  ke as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2818
- Ht as PlunoProductAgent,
2832
+ Wt as PlunoProductAgent,
2819
2833
  ze as calculateReconnectDelay,
2820
- Ht as default,
2834
+ Wt as default,
2821
2835
  ds as getProductAgentOriginAccessErrorMessage
2822
2836
  };