@pluno/product-agent-web 0.1.149 → 0.1.151

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,13 +1,13 @@
1
- const Ze = "pluno-product-agent-attachments";
1
+ const Qe = "pluno-product-agent-attachments";
2
2
  const Pt = "files";
3
- async function Qe(e) {
4
- const t = await Bt();
5
- await ss(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function ts(e, t) {
8
- const s = await Bt();
9
- await Ft(s, "readwrite", async (n) => {
10
- const r = await Ht(
3
+ async function ts(e) {
4
+ const t = await Ft();
5
+ await ns(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function es(e, t) {
8
+ const s = await Ft();
9
+ await Ht(s, "readwrite", async (n) => {
10
+ const r = await Wt(
11
11
  n.get(e)
12
12
  );
13
13
  r && n.put({
@@ -16,26 +16,26 @@ async function ts(e, t) {
16
16
  });
17
17
  });
18
18
  }
19
- async function es(e = 864e5) {
20
- const t = await Bt(), s = Date.now() - e;
21
- await Ft(t, "readwrite", async (n) => {
19
+ async function ss(e = 864e5) {
20
+ const t = await Ft(), s = Date.now() - e;
21
+ await Ht(t, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Wt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function Bt() {
26
+ function Ft() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
28
- const s = indexedDB.open(Ze, 1);
28
+ const s = indexedDB.open(Qe, 1);
29
29
  s.onupgradeneeded = () => {
30
30
  const r = s.result.createObjectStore(Pt, { keyPath: "attachmentId" });
31
31
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
32
32
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
33
33
  });
34
34
  }
35
- async function ss(e, t, s) {
36
- return await Ft(e, t, async (n) => await Ht(s(n)));
35
+ async function ns(e, t, s) {
36
+ return await Ht(e, t, async (n) => await Wt(s(n)));
37
37
  }
38
- function Ft(e, t, s) {
38
+ function Ht(e, t, s) {
39
39
  return new Promise((n, r) => {
40
40
  const i = e.transaction(Pt, t), o = i.objectStore(Pt);
41
41
  let a, c = !1;
@@ -57,16 +57,16 @@ function Ft(e, t, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Ht(e) {
60
+ function Wt(e) {
61
61
  return new Promise((t, s) => {
62
62
  e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
63
63
  });
64
64
  }
65
- function ns(e) {
65
+ function rs(e) {
66
66
  return e !== null && (typeof e == "object" || typeof e == "function");
67
67
  }
68
- function Re(e, t, s) {
69
- const n = Reflect.get(e, "pluno"), r = ns(n) ? n : {};
68
+ function be(e, t, s) {
69
+ const n = Reflect.get(e, "pluno"), r = rs(n) ? n : {};
70
70
  if (r !== n && !Reflect.set(e, "pluno", r))
71
71
  return null;
72
72
  const i = Object.getOwnPropertyDescriptor(r, t);
@@ -80,14 +80,14 @@ function Re(e, t, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const rs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function is(e, t) {
83
+ const is = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function os(e, t) {
85
85
  return t ? e.replace(
86
- rs,
86
+ is,
87
87
  (s, n, r, i) => `${n}${new URL(r, t).toString()}${i}`
88
88
  ) : e;
89
89
  }
90
- function os(e, t, s) {
90
+ function as(e, t, s) {
91
91
  const n = t.map((u) => ({ item: u, identity: s(u) })), r = new Set(
92
92
  n.flatMap(
93
93
  ({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
@@ -114,7 +114,7 @@ function os(e, t, s) {
114
114
  for (const u of e) {
115
115
  const d = s(u);
116
116
  let p = o.get(d.id);
117
- if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((b) => l.get(b)).find((b) => b !== void 0) ?? p), p && !I.has(p)) {
117
+ if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = c.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((E) => l.get(E)).find((E) => E !== void 0) ?? p), p && !I.has(p)) {
118
118
  g.push(p), I.add(p);
119
119
  continue;
120
120
  }
@@ -125,16 +125,16 @@ function os(e, t, s) {
125
125
  I.has(u) || g.push(u);
126
126
  return g;
127
127
  }
128
- function as(e, t, s, n) {
128
+ function cs(e, t, s, n) {
129
129
  return e.filter((r) => {
130
130
  const i = n(r);
131
131
  return !i.isActivity || !i.isTransient ? !0 : t !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== t : s === null || i.runId !== s;
132
132
  });
133
133
  }
134
- const St = "pluno.productAgent.transportId", cs = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", ls = 50, us = globalThis.setTimeout.bind(globalThis);
134
+ const St = "pluno.productAgent.transportId", ls = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", us = 50, ds = globalThis.setTimeout.bind(globalThis);
135
135
  let W = null;
136
- const et = /* @__PURE__ */ new Set(), bt = /* @__PURE__ */ new Map();
137
- async function ds(e = ke()) {
136
+ const et = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Map();
137
+ async function hs(e = Me()) {
138
138
  const t = e.randomUUID(), s = e.storage.getItem(St);
139
139
  let n = s ?? e.randomUUID(), r = !1, i = !1;
140
140
  const o = e.channel.subscribe((c) => {
@@ -170,14 +170,14 @@ async function ds(e = ke()) {
170
170
  }
171
171
  };
172
172
  }
173
- async function hs() {
174
- W || (W = ds(ke()), W.then((n) => {
173
+ async function ps() {
174
+ W || (W = hs(Me()), W.then((n) => {
175
175
  const r = (i) => {
176
176
  i.persisted || (n.release(), W = null, et.clear(), window.removeEventListener("pagehide", r));
177
177
  };
178
178
  window.addEventListener("pagehide", r);
179
179
  }));
180
- const e = await W, t = ps();
180
+ const e = await W, t = fs();
181
181
  et.add(t);
182
182
  let s = !1;
183
183
  return {
@@ -188,31 +188,31 @@ async function hs() {
188
188
  }
189
189
  };
190
190
  }
191
- function ps() {
191
+ function fs() {
192
192
  let e = 0;
193
193
  for (; et.has(e); )
194
194
  e += 1;
195
195
  return e;
196
196
  }
197
- function ke() {
197
+ function Me() {
198
198
  return {
199
- storage: fs(),
200
- channel: gs(),
199
+ storage: gs(),
200
+ channel: ms(),
201
201
  randomUUID: () => crypto.randomUUID(),
202
- settle: () => new Promise((e) => us(e, ls))
202
+ settle: () => new Promise((e) => ds(e, us))
203
203
  };
204
204
  }
205
- function fs() {
205
+ function gs() {
206
206
  return {
207
207
  getItem: (e) => {
208
208
  try {
209
- return window.sessionStorage?.getItem(e) ?? bt.get(e) ?? null;
209
+ return window.sessionStorage?.getItem(e) ?? Et.get(e) ?? null;
210
210
  } catch {
211
- return bt.get(e) ?? null;
211
+ return Et.get(e) ?? null;
212
212
  }
213
213
  },
214
214
  setItem: (e, t) => {
215
- bt.set(e, t);
215
+ Et.set(e, t);
216
216
  try {
217
217
  window.sessionStorage?.setItem(e, t);
218
218
  } catch {
@@ -220,9 +220,9 @@ function fs() {
220
220
  }
221
221
  };
222
222
  }
223
- function gs() {
223
+ function ms() {
224
224
  if (typeof BroadcastChannel < "u") {
225
- const e = new BroadcastChannel(cs);
225
+ const e = new BroadcastChannel(ls);
226
226
  return {
227
227
  postMessage: (t) => e.postMessage(t),
228
228
  subscribe: (t) => {
@@ -232,9 +232,9 @@ function gs() {
232
232
  close: () => e.close()
233
233
  };
234
234
  }
235
- return ms();
235
+ return ys();
236
236
  }
237
- function ms() {
237
+ function ys() {
238
238
  const e = /* @__PURE__ */ new Set(), t = (s) => {
239
239
  if (s.key !== At || !s.newValue)
240
240
  return;
@@ -255,9 +255,23 @@ function ms() {
255
255
  }
256
256
  };
257
257
  }
258
- const ys = globalThis.fetch.bind(globalThis), Ut = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Is = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ts = ".pluno-pa-widget__panel", ws = ".pluno-pa-widget__timeline", re = `${Ut}[data-pluno-sdk-preview-channel]`;
259
- let Ss = 0;
260
- function ie(e) {
258
+ const ke = "schedule_follow_up";
259
+ function Is(e) {
260
+ let t = e;
261
+ if (typeof t == "string")
262
+ try {
263
+ t = JSON.parse(t);
264
+ } catch {
265
+ return null;
266
+ }
267
+ if (!t || typeof t != "object")
268
+ return null;
269
+ const s = t;
270
+ return s.ok !== !0 || s.toolName !== ke || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
271
+ }
272
+ const Ts = globalThis.fetch.bind(globalThis), Dt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ws = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ss = ".pluno-pa-widget__panel", As = ".pluno-pa-widget__timeline", ie = `${Dt}[data-pluno-sdk-preview-channel]`;
273
+ let Es = 0;
274
+ function oe(e) {
261
275
  const t = {};
262
276
  for (const i of ["type", "requestId", "clientMessageId", "sessionId", "runId", "itemId", "reason", "phase"]) {
263
277
  const o = e[i];
@@ -270,7 +284,7 @@ function ie(e) {
270
284
  const r = e.attachments;
271
285
  return Array.isArray(r) && (t.attachmentCount = r.length), t;
272
286
  }
273
- function Et(e, t, s) {
287
+ function Rt(e, t, s) {
274
288
  if (typeof window > "u")
275
289
  return;
276
290
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -282,25 +296,25 @@ function Et(e, t, s) {
282
296
  source: "web_sdk",
283
297
  category: e,
284
298
  name: t,
285
- sequence: ++Ss,
299
+ sequence: ++Es,
286
300
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
287
301
  monotonicMs: performance.now(),
288
302
  data: s
289
303
  };
290
304
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
291
305
  }
292
- const As = "https://app.pluno.ai", bs = "gpt-5.6-terra", Es = 2e4, Rs = 1e4, ks = 1e4, Ms = 1e4, _s = 1e4, Cs = 1e3, oe = 3e4, ae = 0.2, ce = 6e4, Ps = 15e3, V = 8, Us = 15e3, Ds = 2e3, Os = 1e3, Ns = 100, le = 8e3, ue = 3, vs = [300, 1e3], Wt = 64e3, Rt = 4e3, $t = 30, xs = 2e3, Ls = 1e3, Me = "Image is too large for model vision input.", qs = 100, _e = "pluno.productAgent.state.", Dt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Bs = 100;
306
+ const Rs = "https://app.pluno.ai", bs = "gpt-5.6-terra", Ms = 2e4, ks = 1e4, _s = 1e4, Cs = 1e4, Us = 1e4, Ps = 1e3, ae = 3e4, ce = 0.2, le = 6e4, Ds = 15e3, V = 8, vs = "Pluno could not finish this message. Try it again.", Os = "Browser connection was interrupted.", Ns = 15e3, xs = 2e3, Ls = 1e3, qs = 100, ue = 8e3, de = 3, Bs = [300, 1e3], $t = 64e3, bt = 4e3, jt = 30, Fs = 2e3, Hs = 1e3, _e = "Image is too large for model vision input.", Ws = 100, Ce = "pluno.productAgent.state.", vt = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", $s = 100;
293
307
  function Y(e, t = 0) {
294
308
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
295
309
  return Math.max(t, s);
296
310
  }
297
311
  const st = /* @__PURE__ */ new Set();
298
312
  let Z = null;
299
- function Fs(e, t = Math.random) {
300
- const s = Math.min(oe, Cs * 2 ** e), n = 1 - ae + t() * ae * 2;
301
- return Math.min(oe, Math.round(s * n));
313
+ function js(e, t = Math.random) {
314
+ const s = Math.min(ae, Ps * 2 ** e), n = 1 - ce + t() * ce * 2;
315
+ return Math.min(ae, Math.round(s * n));
302
316
  }
303
- function Hs(e, t, s) {
317
+ function zs(e, t, s) {
304
318
  return new Promise((n, r) => {
305
319
  const i = setTimeout(() => r(new Error(s)), t);
306
320
  e.then(
@@ -313,13 +327,13 @@ function Hs(e, t, s) {
313
327
  );
314
328
  });
315
329
  }
316
- class Ce {
330
+ class Ue {
317
331
  constructor(t, s) {
318
332
  this.options = t, this.transportIdentity = s, this.state = {
319
333
  ...this.state,
320
- starterPrompts: bn(t.initialStarterPrompts)
334
+ starterPrompts: kn(t.initialStarterPrompts)
321
335
  };
322
- const n = t.restorePersistedState === !1 ? null : dr(t.clientId, t.expectedPersistedSessionId);
336
+ const n = t.restorePersistedState === !1 ? null : gr(t.clientId, t.expectedPersistedSessionId);
323
337
  n && (this.state = {
324
338
  ...this.state,
325
339
  ...n,
@@ -332,9 +346,9 @@ class Ce {
332
346
  assistantDraftRunId: null,
333
347
  isThinking: !1,
334
348
  lastError: null
335
- }), this.queuedClientEvents = Ir(
336
- pr(t.clientId),
337
- gr(t.clientId)
349
+ }), this.queuedClientEvents = Ar(
350
+ yr(t.clientId),
351
+ Tr(t.clientId)
338
352
  ), j(t.clientId, this.queuedClientEvents);
339
353
  }
340
354
  options;
@@ -372,6 +386,7 @@ class Ce {
372
386
  runAckResyncRetryTimer = null;
373
387
  activeClientMessageId = null;
374
388
  activeUserMessageEvent = null;
389
+ browserConnectionInterruptedClientMessageIds = /* @__PURE__ */ new Set();
375
390
  latestRecoverableClientMessageId = null;
376
391
  lastUserMessagePageUrl = null;
377
392
  thinkingWatchdogResyncAttemptsByClientMessageId = {};
@@ -409,15 +424,15 @@ class Ce {
409
424
  lastErrorSecuritySettingsUrl: null
410
425
  };
411
426
  static async init(t) {
412
- const s = await hs(), n = new Ce({
427
+ const s = await ps(), n = new Ue({
413
428
  ...t,
414
- backendUrl: cn(t.backendUrl ?? As),
415
- clientId: t.clientId ?? _n(),
429
+ backendUrl: hn(t.backendUrl ?? Rs),
430
+ clientId: t.clientId ?? Dn(),
416
431
  model: t.model ?? bs,
417
- entrySurface: ln(t.entrySurface)
432
+ entrySurface: pn(t.entrySurface)
418
433
  }, s);
419
434
  try {
420
- es().catch((r) => {
435
+ ss().catch((r) => {
421
436
  S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
422
437
  message: r instanceof Error ? r.message : String(r)
423
438
  });
@@ -448,14 +463,14 @@ class Ce {
448
463
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
449
464
  );
450
465
  try {
451
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Hs(this.options.tokenProvider(), ks, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
466
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await zs(this.options.tokenProvider(), _s, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
452
467
  return;
453
468
  if (!this.token && !this.options.webSocketFactory)
454
469
  throw new Error("Pluno requires a token or tokenProvider");
455
- const s = hn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
470
+ const s = mn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
456
471
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
457
472
  this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
458
- }, Ms), n.addEventListener("open", () => {
473
+ }, Cs), n.addEventListener("open", () => {
459
474
  this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
460
475
  queuedClientEventCount: this.queuedClientEvents.length,
461
476
  isThinking: this.state.isThinking
@@ -467,11 +482,11 @@ class Ce {
467
482
  pageUrl: location.href
468
483
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
469
484
  this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
470
- }, _s));
485
+ }, Us));
471
486
  }), n.addEventListener("message", (r) => {
472
- this.socket === n && this.handleServerEvent(An(r.data));
487
+ this.socket === n && this.handleServerEvent(Mn(r.data));
473
488
  }), n.addEventListener("close", (r) => {
474
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
489
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
475
490
  code: typeof r?.code == "number" ? r.code : null,
476
491
  reason: typeof r?.reason == "string" ? r.reason : "",
477
492
  wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
@@ -482,7 +497,7 @@ class Ce {
482
497
  this.socket !== n || this.state.status === "closed" || (S("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
483
498
  queuedClientEventCount: this.queuedClientEvents.length,
484
499
  isThinking: this.state.isThinking
485
- }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
500
+ }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.rememberBrowserConnectionInterruptionForActiveRun(), this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
486
501
  });
487
502
  } catch (s) {
488
503
  if (t === this.connectionAttemptId && this.state.status !== "closed") {
@@ -502,7 +517,7 @@ class Ce {
502
517
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
503
518
  }
504
519
  destroy() {
505
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Tr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
520
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Er(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
506
521
  for (const t of Object.values(this.listeners))
507
522
  t?.clear();
508
523
  }
@@ -512,16 +527,16 @@ class Ce {
512
527
  reason: t,
513
528
  entrySurface: this.options.entrySurface,
514
529
  sessionId: this.state.sessionId ?? void 0,
515
- page: k()
530
+ page: M()
516
531
  };
517
532
  this.sendNow(s) || (this.pendingWarmupEvent = s);
518
533
  }
519
534
  async sendMessage(t, s = {}) {
520
535
  const n = t.trim(), r = s.attachments ?? [];
521
- let i = r.map(Gt);
536
+ let i = r.map(Xt);
522
537
  if (!n && i.length === 0)
523
538
  return null;
524
- const o = k(), a = s.clientMessageId ?? $(), c = {
539
+ const o = M(), a = s.clientMessageId ?? $(), c = {
525
540
  id: `local-${a}`,
526
541
  role: "user",
527
542
  content: n,
@@ -550,14 +565,14 @@ class Ce {
550
565
  try {
551
566
  const p = [];
552
567
  for (const m of i) {
553
- const b = m.id ? this.attachmentFiles.get(m.id) : void 0;
568
+ const E = m.id ? this.attachmentFiles.get(m.id) : void 0;
554
569
  if (m.sandboxPath) {
555
570
  p.push(m);
556
571
  continue;
557
572
  }
558
- if (!b)
573
+ if (!E)
559
574
  throw new Error(`Attachment bytes are unavailable for ${m.name}`);
560
- p.push(await this.uploadAttachmentForMessage({ file: b, attachment: m }));
575
+ p.push(await this.uploadAttachmentForMessage({ file: E, attachment: m }));
561
576
  }
562
577
  i = p;
563
578
  } catch (p) {
@@ -572,20 +587,20 @@ class Ce {
572
587
  sessionId: this.state.sessionId ?? void 0,
573
588
  clientMessageId: a,
574
589
  initiatedBy: s.initiatedBy,
575
- invocation: un(s.invocation ?? s.initiatedBy),
590
+ invocation: fn(s.invocation ?? s.initiatedBy),
576
591
  entrySurface: this.options.entrySurface,
577
592
  content: n,
578
- pageContent: u && jt() || void 0,
593
+ pageContent: u && zt() || void 0,
579
594
  attachments: i.length > 0 ? i : void 0,
580
595
  page: o,
581
596
  model: this.options.model,
582
- metadata: de(this.options.metadata)
597
+ metadata: he(this.options.metadata)
583
598
  };
584
- return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), a;
599
+ return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.browserConnectionInterruptedClientMessageIds.delete(a), this.markThinkingProgress(), this.send(d), a;
585
600
  }
586
601
  retryLastMessage() {
587
602
  const t = this.state.sessionId, s = this.retryableClientMessageId;
588
- 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);
603
+ return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(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);
589
604
  }
590
605
  createLocalAttachment(t) {
591
606
  const s = $(), n = {
@@ -596,13 +611,13 @@ class Ce {
596
611
  };
597
612
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
598
613
  const r = Date.now();
599
- return Qe({
614
+ return ts({
600
615
  attachmentId: s,
601
616
  name: n.name,
602
617
  mimeType: n.mimeType,
603
618
  sizeBytes: n.sizeBytes,
604
619
  blob: t,
605
- origin: k().origin,
620
+ origin: M().origin,
606
621
  sessionId: this.state.sessionId ?? void 0,
607
622
  createdAt: r,
608
623
  lastUsedAt: r
@@ -633,9 +648,9 @@ class Ce {
633
648
  name: t.name || "attachment",
634
649
  mimeType: r,
635
650
  sizeBytes: t.size,
636
- page: k(),
651
+ page: M(),
637
652
  model: this.options.model,
638
- metadata: de(this.options.metadata),
653
+ metadata: he(this.options.metadata),
639
654
  entrySurface: this.options.entrySurface
640
655
  };
641
656
  let o;
@@ -661,8 +676,8 @@ class Ce {
661
676
  }, "Failed to upload attachment"), o = c;
662
677
  }
663
678
  this.setState({ sessionId: o.sessionId });
664
- const a = He(o.attachment, this.options.backendUrl);
665
- return this.updateAttachmentInState(s.id, a), s.id && ts(s.id, {
679
+ const a = We(o.attachment, this.options.backendUrl);
680
+ return this.updateAttachmentInState(s.id, a), s.id && es(s.id, {
666
681
  sessionId: o.sessionId,
667
682
  fileUrl: a.fileUrl,
668
683
  sandboxPath: a.sandboxPath,
@@ -692,7 +707,7 @@ class Ce {
692
707
  const n = await this.fetchEmbedAttachmentUpload(t);
693
708
  if (n.ok)
694
709
  return await n.json();
695
- if (vr(n.status) && this.options.tokenProvider && !s) {
710
+ if (Br(n.status) && this.options.tokenProvider && !s) {
696
711
  s = !0;
697
712
  const r = await this.fetchEmbedAttachmentUpload(t);
698
713
  if (r.ok)
@@ -721,7 +736,7 @@ class Ce {
721
736
  !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
722
737
  type: "session.reset",
723
738
  sessionId: this.state.sessionId ?? void 0,
724
- page: k()
739
+ page: M()
725
740
  }), this.setState({
726
741
  sessionId: null,
727
742
  starterPrompts: [...this.state.starterPrompts],
@@ -739,12 +754,12 @@ class Ce {
739
754
  const s = $(), n = new Promise((i, o) => {
740
755
  const a = window.setTimeout(() => {
741
756
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
742
- }, le);
757
+ }, ue);
743
758
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
744
759
  }), r = {
745
760
  type: "sessions.list",
746
761
  requestId: s,
747
- page: k(),
762
+ page: M(),
748
763
  ...t.cursor ? { cursor: t.cursor } : {},
749
764
  ...t.limit ? { limit: t.limit } : {},
750
765
  ...typeof t.pinned == "boolean" ? { pinned: t.pinned } : {}
@@ -783,11 +798,11 @@ class Ce {
783
798
  }), this.send({
784
799
  type: "session.load",
785
800
  sessionId: t,
786
- page: k()
801
+ page: M()
787
802
  });
788
803
  }
789
804
  send(t) {
790
- this.sendNow(M(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
805
+ this.sendNow(_(t)) || (this.queuedClientEvents.push(t), j(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
791
806
  }
792
807
  async getUploadToken() {
793
808
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -800,7 +815,7 @@ class Ce {
800
815
  return !1;
801
816
  const s = this.socket;
802
817
  try {
803
- return s.send(JSON.stringify(t)), Et("client_event", t.type, ie(t)), !0;
818
+ return s.send(JSON.stringify(t)), Rt("client_event", t.type, oe(t)), !0;
804
819
  } catch (n) {
805
820
  return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
806
821
  message: n instanceof Error ? n.message : String(n),
@@ -813,9 +828,9 @@ class Ce {
813
828
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
814
829
  return;
815
830
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
816
- const t = pn();
831
+ const t = yn();
817
832
  this.sendNow(
818
- M({
833
+ _({
819
834
  type: "starter_prompts.page_context",
820
835
  pageUrl: t.pageUrl,
821
836
  pageTitle: t.pageTitle,
@@ -824,13 +839,13 @@ class Ce {
824
839
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
825
840
  }
826
841
  startStarterPromptUrlWatcher() {
827
- this.locationChangeCleanup || (this.locationChangeCleanup = fn(() => this.handleStarterPromptUrlChange()));
842
+ this.locationChangeCleanup || (this.locationChangeCleanup = In(() => this.handleStarterPromptUrlChange()));
828
843
  }
829
844
  handleStarterPromptUrlChange() {
830
845
  const t = location.href;
831
846
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
832
847
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
833
- }, Bs));
848
+ }, $s));
834
849
  }
835
850
  refreshStarterPromptsForCurrentUrl() {
836
851
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -848,7 +863,7 @@ class Ce {
848
863
  j(this.options.clientId, this.queuedClientEvents);
849
864
  for (let s = 0; s < t.length; s += 1) {
850
865
  const n = t[s];
851
- if (!this.sendNow(M(n))) {
866
+ if (!this.sendNow(_(n))) {
852
867
  this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
853
868
  return;
854
869
  }
@@ -859,13 +874,13 @@ class Ce {
859
874
  !this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
860
875
  }
861
876
  handleServerEvent(t) {
862
- if (Et("server_event", t.type, ie(t)), t.type === "run.ack") {
863
- const s = Mt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
877
+ if (Rt("server_event", t.type, oe(t)), t.type === "run.ack") {
878
+ const s = kt(t), n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
864
879
  s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && n === this.activeClientMessageId && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(t);
865
880
  return;
866
881
  }
867
882
  if (t.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
868
- const s = Mt(t);
883
+ const s = kt(t);
869
884
  if (s) {
870
885
  this.deferredSessionUpdatedSessionIds.add(s);
871
886
  return;
@@ -880,42 +895,42 @@ class Ce {
880
895
  this.clearHeartbeatAckTimer();
881
896
  return;
882
897
  }
883
- if (js(t) && this.markThinkingProgress(), t.type === "auth.ok") {
898
+ if (Xs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
884
899
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.flushPendingWarmupEvent(), this.startHeartbeat();
885
- const s = En(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
900
+ const s = _n(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
886
901
  S("web-sdk.agent", "Received auth.ok appearance", {
887
902
  hasAppearance: n,
888
903
  rawAppearance: t.appearance,
889
904
  normalizedAppearance: s
890
- }), this.runtimeHelperJavascript = Rn(t.runtimeHelpers)?.javascript ?? null;
891
- const r = fe(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
892
- user: Cn(t.user),
905
+ }), this.runtimeHelperJavascript = Cn(t.runtimeHelpers)?.javascript ?? null;
906
+ const r = ge(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
907
+ user: vn(t.user),
893
908
  status: "connected",
894
909
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
895
910
  };
896
- (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !mn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
911
+ (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !wn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
897
912
  type: "page.upsert",
898
913
  sessionId: this.state.sessionId,
899
- page: k(),
914
+ page: M(),
900
915
  model: this.options.model
901
916
  });
902
917
  return;
903
918
  }
904
919
  if (t.type === "starterPrompts.updated") {
905
920
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
906
- starterPrompts: fe(t, "starterPrompts"),
921
+ starterPrompts: ge(t, "starterPrompts"),
907
922
  starterPromptsLoading: !1
908
923
  });
909
924
  return;
910
925
  }
911
926
  if (t.type === "conversation.state") {
912
- const s = Array.isArray(t.items) ? t.items : [], n = Ln(
927
+ const s = Array.isArray(t.items) ? t.items : [], n = Hn(
913
928
  t.assistantDraft
914
929
  ), r = n !== void 0;
915
930
  this.rememberUserMessageClientMessageIds(s);
916
- const i = Qn(s);
931
+ const i = nr(s);
917
932
  if (i) {
918
- const p = tr(s, i);
933
+ const p = rr(s, i);
919
934
  this.retryAttemptsByClientMessageId[i] = Math.max(
920
935
  this.retryAttemptsByClientMessageId[i] ?? 0,
921
936
  p
@@ -923,10 +938,10 @@ class Ce {
923
938
  }
924
939
  const o = s.filter((p) => {
925
940
  const m = q(p);
926
- return !ye(m) && (!i || !xt(m));
927
- }), a = Kn(
941
+ return !ye(m) && (!i || !Lt(m));
942
+ }), a = Vn(
928
943
  this.state.messages,
929
- Pn(o, this.options.backendUrl)
944
+ On(o, this.options.backendUrl)
930
945
  ), c = me(a), l = !r && s.some(
931
946
  (p) => Te(
932
947
  q(p),
@@ -935,13 +950,13 @@ class Ce {
935
950
  this.state.assistantDraftRespondsToUserMessageId,
936
951
  this.state.assistantDraftRunId
937
952
  )
938
- ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = Vn(a), u = I && g;
939
- if (!c && Zn(this.state.messages, s))
953
+ ), h = r ? n?.content ?? "" : this.state.assistantDraft, f = !!n?.content, I = c && (!h || l), g = tr(a), u = I && g;
954
+ if (!c && sr(this.state.messages, s))
940
955
  return;
941
- this.lastUserMessagePageUrl = Yn(s);
942
- const d = I ? null : Lt(s);
956
+ this.lastUserMessagePageUrl = er(s);
957
+ const d = I ? null : qt(s);
943
958
  if (this.latestRecoverableClientMessageId = d, g && this.clearRetryTimers(), this.setState({
944
- sessionId: E(t.session, "id") ?? this.state.sessionId,
959
+ sessionId: R(t.session, "id") ?? this.state.sessionId,
945
960
  messages: a,
946
961
  ...r ? {
947
962
  assistantDraft: n?.content ?? "",
@@ -972,7 +987,7 @@ class Ce {
972
987
  lastError: null
973
988
  } : {}
974
989
  }), I ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (f || d) && (d && (this.activeClientMessageId = d), this.markThinkingProgress()), i) {
975
- const p = E(t.session, "id") ?? this.state.sessionId;
990
+ const p = R(t.session, "id") ?? this.state.sessionId;
976
991
  p && this.retryAfterInterruptedRun(p, i);
977
992
  }
978
993
  return;
@@ -980,7 +995,7 @@ class Ce {
980
995
  if (t.type === "sessions.page") {
981
996
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
982
997
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
983
- sessions: Un(t.sessions),
998
+ sessions: Nn(t.sessions),
984
999
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
985
1000
  }));
986
1001
  return;
@@ -994,15 +1009,15 @@ class Ce {
994
1009
  return;
995
1010
  }
996
1011
  if (t.type === "session.updated") {
997
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
1012
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: R(t.session, "id") ?? this.state.sessionId });
998
1013
  return;
999
1014
  }
1000
1015
  if (t.type === "session.item") {
1001
1016
  this.rememberUserMessageClientMessageIds([t.item]);
1002
1017
  const s = q(t.item);
1003
- if (xt(s)) {
1018
+ if (Lt(s)) {
1004
1019
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1005
- const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1020
+ const r = R(t.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1006
1021
  if (r && a) {
1007
1022
  this.retryAfterInterruptedRun(r, a);
1008
1023
  return;
@@ -1019,7 +1034,7 @@ class Ce {
1019
1034
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1020
1035
  n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1021
1036
  const i = t.item.data;
1022
- sr(i) && this.clearRunAckResyncRetryTimer();
1037
+ or(i) && this.clearRunAckResyncRetryTimer();
1023
1038
  const o = Ot(this.state.messages, n), a = me(o), c = Te(
1024
1039
  i,
1025
1040
  this.state.assistantDraft,
@@ -1079,9 +1094,9 @@ class Ce {
1079
1094
  const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null, r = typeof t.runId == "string" ? t.runId : null;
1080
1095
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1081
1096
  return;
1082
- const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = as(
1097
+ const o = [...this.state.messages].reverse().find((l) => l.role === "user")?.id, a = !n || !o || n === o, c = cs(
1083
1098
  this.state.messages.filter(
1084
- (l) => l.dataType !== "assistant_draft" || !Fn(
1099
+ (l) => l.dataType !== "assistant_draft" || !jn(
1085
1100
  l,
1086
1101
  n,
1087
1102
  r
@@ -1089,11 +1104,11 @@ class Ce {
1089
1104
  ),
1090
1105
  n,
1091
1106
  r,
1092
- ve
1107
+ xe
1093
1108
  );
1094
1109
  this.setState({
1095
1110
  sessionId: s,
1096
- messages: Hn(
1111
+ messages: zn(
1097
1112
  c,
1098
1113
  typeof t.responseId == "string" ? t.responseId : null,
1099
1114
  n,
@@ -1114,9 +1129,9 @@ class Ce {
1114
1129
  if (s)
1115
1130
  this.nonTranscriptToolCallIds.add(s);
1116
1131
  else {
1117
- const n = jn(t);
1132
+ const n = Xn(t);
1118
1133
  if (n) {
1119
- const r = Wn(
1134
+ const r = Kn(
1120
1135
  this.state.messages,
1121
1136
  n
1122
1137
  );
@@ -1160,7 +1175,7 @@ class Ce {
1160
1175
  return;
1161
1176
  }
1162
1177
  o && r && i && (this.retryableClientMessageId = i);
1163
- const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = dn(a.message);
1178
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = gn(a.message);
1164
1179
  c && console.error(c), this.setState({
1165
1180
  status: "error",
1166
1181
  isThinking: !1,
@@ -1172,9 +1187,9 @@ class Ce {
1172
1187
  }
1173
1188
  }
1174
1189
  shouldIgnoreBackgroundSessionEvent(t) {
1175
- if (!this.options.keepRunsActiveOnSessionNavigation || !zs(t))
1190
+ if (!this.options.keepRunsActiveOnSessionNavigation || !Js(t))
1176
1191
  return !1;
1177
- const s = Mt(t);
1192
+ const s = kt(t);
1178
1193
  return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
1179
1194
  }
1180
1195
  rememberCurrentRunAsBackground() {
@@ -1219,7 +1234,7 @@ class Ce {
1219
1234
  if (n >= V) {
1220
1235
  this.retryableClientMessageId = s, this.setState({
1221
1236
  isThinking: !1,
1222
- lastError: "Pluno could not finish this message. Try it again.",
1237
+ lastError: this.getRunRecoveryExhaustedErrorMessage(s),
1223
1238
  lastErrorCode: "run_recovery_exhausted"
1224
1239
  }), this.clearThinkingWatchdog();
1225
1240
  return;
@@ -1235,7 +1250,7 @@ class Ce {
1235
1250
  }
1236
1251
  rememberUserMessageClientMessageIds(t) {
1237
1252
  for (const s of t) {
1238
- const n = E(s, "id"), r = q(s);
1253
+ const n = R(s, "id"), r = q(s);
1239
1254
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1240
1255
  }
1241
1256
  }
@@ -1248,7 +1263,7 @@ class Ce {
1248
1263
  const r = new Promise((i, o) => {
1249
1264
  const a = window.setTimeout(() => {
1250
1265
  t.delete(s.requestId), o(new Error(n));
1251
- }, le);
1266
+ }, ue);
1252
1267
  t.set(s.requestId, { resolve: i, reject: o, timeout: a });
1253
1268
  });
1254
1269
  if (!this.sendNow(s)) {
@@ -1271,7 +1286,7 @@ class Ce {
1271
1286
  t.clear();
1272
1287
  }
1273
1288
  markThinkingProgress() {
1274
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ce), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1289
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(le), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1275
1290
  }
1276
1291
  scheduleThinkingWatchdog(t) {
1277
1292
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1279,7 +1294,7 @@ class Ce {
1279
1294
  }, t);
1280
1295
  }
1281
1296
  clearThinkingWatchdog() {
1282
- this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId = null, this.activeUserMessageEvent = null;
1297
+ this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.delete(this.activeClientMessageId), this.activeClientMessageId = null, this.activeUserMessageEvent = null;
1283
1298
  }
1284
1299
  handleRunAck(t) {
1285
1300
  const s = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
@@ -1291,7 +1306,7 @@ class Ce {
1291
1306
  handleRunSteered(t) {
1292
1307
  const s = typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : null;
1293
1308
  !this.state.isThinking || !s || this.setState({
1294
- messages: rr(
1309
+ messages: cr(
1295
1310
  this.state.messages,
1296
1311
  s
1297
1312
  )
@@ -1300,7 +1315,7 @@ class Ce {
1300
1315
  scheduleRunAckWatchdog(t) {
1301
1316
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1302
1317
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1303
- }, Us);
1318
+ }, Ns);
1304
1319
  }
1305
1320
  recoverMissedRunAck(t) {
1306
1321
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1324,8 +1339,8 @@ class Ce {
1324
1339
  sessionId: this.state.sessionId,
1325
1340
  clientMessageId: t,
1326
1341
  automatic: !0
1327
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ce)));
1328
- }, Y(s, Ds)));
1342
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(le)));
1343
+ }, Y(s, xs)));
1329
1344
  }
1330
1345
  clearRunAckResyncRetryTimer() {
1331
1346
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1342,7 +1357,7 @@ class Ce {
1342
1357
  sessionId: this.state.sessionId
1343
1358
  }), this.setState({
1344
1359
  isThinking: !1,
1345
- lastError: "Pluno could not finish this message. Please send it again.",
1360
+ lastError: this.getRunRecoveryExhaustedErrorMessage(null),
1346
1361
  lastErrorCode: "run_recovery_exhausted"
1347
1362
  }), this.clearThinkingWatchdog();
1348
1363
  return;
@@ -1354,7 +1369,7 @@ class Ce {
1354
1369
  clientMessageId: t
1355
1370
  }), this.retryableClientMessageId = t, this.setState({
1356
1371
  isThinking: !1,
1357
- lastError: "Pluno could not finish this message. Try it again.",
1372
+ lastError: this.getRunRecoveryExhaustedErrorMessage(t),
1358
1373
  lastErrorCode: "run_recovery_exhausted"
1359
1374
  }), this.clearThinkingWatchdog();
1360
1375
  return;
@@ -1364,7 +1379,7 @@ class Ce {
1364
1379
  sessionId: this.state.sessionId,
1365
1380
  clientMessageId: t,
1366
1381
  resyncAttempts: s + 1
1367
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ps);
1382
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ds);
1368
1383
  return;
1369
1384
  }
1370
1385
  this.setState({
@@ -1388,7 +1403,7 @@ class Ce {
1388
1403
  this.state.sessionId ? this.send({
1389
1404
  type: "page.upsert",
1390
1405
  sessionId: this.state.sessionId,
1391
- page: k(),
1406
+ page: M(),
1392
1407
  model: this.options.model
1393
1408
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
1394
1409
  }
@@ -1399,15 +1414,15 @@ class Ce {
1399
1414
  if (!s || !n || !r)
1400
1415
  return;
1401
1416
  const a = r === "execute_code", c = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1402
- if (!a && !c || !br(o)) {
1417
+ if (!a && !c || !kr(o)) {
1403
1418
  this.setToolMessageLoading(n, !1), this.send({
1404
1419
  type: "tool.result",
1405
1420
  sessionId: s,
1406
1421
  callId: n,
1407
1422
  toolName: r,
1408
1423
  summary: i,
1409
- rawInput: M(o),
1410
- rawOutput: M({
1424
+ rawInput: _(o),
1425
+ rawOutput: _({
1411
1426
  ok: !1,
1412
1427
  toolName: r,
1413
1428
  error: `Unsupported browser tool: ${r}`
@@ -1422,7 +1437,7 @@ class Ce {
1422
1437
  callId: n,
1423
1438
  toolName: r,
1424
1439
  summary: i,
1425
- rawInput: M(o),
1440
+ rawInput: _(o),
1426
1441
  rawOutput: {
1427
1442
  ok: !1,
1428
1443
  toolName: r,
@@ -1431,7 +1446,7 @@ class Ce {
1431
1446
  });
1432
1447
  return;
1433
1448
  }
1434
- const l = Xs(this.state.messages);
1449
+ const l = Zs(this.state.messages);
1435
1450
  this.activeBrowserToolCalls.set(n, {
1436
1451
  event: {
1437
1452
  type: "tool.result",
@@ -1439,7 +1454,7 @@ class Ce {
1439
1454
  callId: n,
1440
1455
  toolName: r,
1441
1456
  summary: i,
1442
- rawInput: M(o),
1457
+ rawInput: _(o),
1443
1458
  rawOutput: null
1444
1459
  },
1445
1460
  startedAtMs: Date.now(),
@@ -1447,9 +1462,9 @@ class Ce {
1447
1462
  startedAtOrigin: location.origin
1448
1463
  }), this.installSessionUserFilesApi(l);
1449
1464
  let h = null, f;
1450
- h = await this.executeRuntimeHelper(), f = await he(
1465
+ h = await this.executeRuntimeHelper(), f = await pe(
1451
1466
  o,
1452
- on(t.runtimeContext, this.options.backendUrl)
1467
+ un(t.runtimeContext, this.options.backendUrl)
1453
1468
  ).catch((I) => ({
1454
1469
  ok: !1,
1455
1470
  exception: {
@@ -1461,12 +1476,12 @@ class Ce {
1461
1476
  callId: n,
1462
1477
  toolName: r,
1463
1478
  summary: o.summary,
1464
- rawInput: M(o),
1465
- rawOutput: M(kn(f, h))
1466
- }), fr(this.options.clientId, this.activeBrowserToolCalls.values());
1479
+ rawInput: _(o),
1480
+ rawOutput: _(Un(f, h))
1481
+ }), Ir(this.options.clientId, this.activeBrowserToolCalls.values());
1467
1482
  }
1468
1483
  setToolMessageLoading(t, s) {
1469
- const n = $n(
1484
+ const n = Gn(
1470
1485
  this.state.messages,
1471
1486
  t,
1472
1487
  s
@@ -1477,47 +1492,47 @@ class Ce {
1477
1492
  if (this.pageLifecycleCleanup)
1478
1493
  return;
1479
1494
  const t = () => {
1480
- Be(this.options.clientId, this.activeBrowserToolCalls.values());
1495
+ Fe(this.options.clientId, this.activeBrowserToolCalls.values());
1481
1496
  };
1482
1497
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1483
1498
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1484
1499
  };
1485
1500
  }
1486
1501
  installSessionUserFilesApi(t) {
1487
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Js(t, this.attachmentFiles, this.attachmentBlobCache);
1502
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Qs(t, this.attachmentFiles, this.attachmentBlobCache);
1488
1503
  }
1489
1504
  cleanupSessionUserFilesApi() {
1490
- this.sessionUserFilesApiCleanup && (nn(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1505
+ this.sessionUserFilesApiCleanup && (cn(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1491
1506
  }
1492
1507
  async executeRuntimeHelper() {
1493
1508
  if (!this.runtimeHelperJavascript?.trim())
1494
1509
  return null;
1495
- const t = await he({
1510
+ const t = await pe({
1496
1511
  javascript: this.runtimeHelperJavascript
1497
1512
  });
1498
- return t.ok === !1 ? Mn(t) : null;
1513
+ return t.ok === !1 ? Pn(t) : null;
1499
1514
  }
1500
1515
  enableNetworkCapture() {
1501
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Ws((t) => {
1502
- Cr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1516
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Ks((t) => {
1517
+ vr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1503
1518
  }));
1504
1519
  }
1505
1520
  enqueueNetworkEvent(t) {
1506
- this.queuedNetworkEvents.length >= Ns || (this.queuedNetworkEvents.push(_r(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1521
+ this.queuedNetworkEvents.length >= qs || (this.queuedNetworkEvents.push(Dr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1507
1522
  this.networkBatchTimer = null;
1508
1523
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1509
1524
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
1510
1525
  type: "network.batch",
1511
1526
  sessionId: this.state.sessionId ?? void 0,
1512
- page: k(),
1527
+ page: M(),
1513
1528
  events: s
1514
1529
  });
1515
- }, Os)));
1530
+ }, Ls)));
1516
1531
  }
1517
1532
  scheduleReconnect() {
1518
1533
  if (this.reconnectTimer !== null || this.state.status === "closed")
1519
1534
  return;
1520
- const t = Fs(this.reconnectAttempts);
1535
+ const t = js(this.reconnectAttempts);
1521
1536
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1522
1537
  this.reconnectTimer = null, this.connect().catch((s) => {
1523
1538
  S("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1533,8 +1548,8 @@ class Ce {
1533
1548
  const t = this.socket;
1534
1549
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1535
1550
  this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1536
- }, Rs));
1537
- }, Es);
1551
+ }, ks));
1552
+ }, Ms);
1538
1553
  }
1539
1554
  stopHeartbeat() {
1540
1555
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1552,7 +1567,7 @@ class Ce {
1552
1567
  this.clearSocketConnectTimer(), this.clearSocketAuthTimer();
1553
1568
  }
1554
1569
  replaceTimedOutSocket(t) {
1555
- this.socket !== t || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), t.readyState !== WebSocket.CLOSED && t.readyState !== WebSocket.CLOSING && t.close());
1570
+ this.socket !== t || this.state.status === "closed" || (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.rememberBrowserConnectionInterruptionForActiveRun(), this.setReconnectingState(), this.scheduleReconnect(), t.readyState !== WebSocket.CLOSED && t.readyState !== WebSocket.CLOSING && t.close());
1556
1571
  }
1557
1572
  setState(t) {
1558
1573
  this.state = {
@@ -1560,7 +1575,7 @@ class Ce {
1560
1575
  ...t,
1561
1576
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1562
1577
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1563
- }, hr(this.options.clientId, this.state), this.emit("state", this.getState()), Et("state", this.state.status, {
1578
+ }, mr(this.options.clientId, this.state), this.emit("state", this.getState()), Rt("state", this.state.status, {
1564
1579
  status: this.state.status,
1565
1580
  sessionId: this.state.sessionId,
1566
1581
  messageCount: this.state.messages.length,
@@ -1573,18 +1588,24 @@ class Ce {
1573
1588
  const t = this.state.lastError !== null && !this.state.isThinking && this.state.lastErrorCode !== "connection_failed";
1574
1589
  this.setState(t ? { status: "reconnecting" } : { status: "reconnecting", lastError: null });
1575
1590
  }
1591
+ rememberBrowserConnectionInterruptionForActiveRun() {
1592
+ this.state.isThinking && this.activeClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId);
1593
+ }
1594
+ getRunRecoveryExhaustedErrorMessage(t) {
1595
+ return t && this.browserConnectionInterruptedClientMessageIds.has(t) ? Os : vs;
1596
+ }
1576
1597
  emit(t, s) {
1577
1598
  this.listeners[t]?.forEach((r) => r(s));
1578
1599
  }
1579
1600
  }
1580
- const kt = /* @__PURE__ */ new WeakMap();
1581
- function Ws(e) {
1582
- const t = window.__plunoProductAgentNetworkCapture ?? $s();
1601
+ const Mt = /* @__PURE__ */ new WeakMap();
1602
+ function Ks(e) {
1603
+ const t = window.__plunoProductAgentNetworkCapture ?? Gs();
1583
1604
  return t.subscribers.add(e), () => {
1584
1605
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1585
1606
  };
1586
1607
  }
1587
- function $s() {
1608
+ function Gs() {
1588
1609
  const e = /* @__PURE__ */ new Set(), t = (I) => {
1589
1610
  e.forEach((g) => {
1590
1611
  try {
@@ -1601,31 +1622,31 @@ function $s() {
1601
1622
  throw m;
1602
1623
  }
1603
1624
  try {
1604
- const m = g instanceof Request ? g : null, b = Er(g, m), T = We(u?.headers ?? m?.headers);
1605
- if (!x(b, T, u?.body)) {
1625
+ const m = g instanceof Request ? g : null, E = _r(g, m), T = $e(u?.headers ?? m?.headers);
1626
+ if (!x(E, T, u?.body)) {
1606
1627
  const F = {
1607
- requestId: Ct("fetch"),
1608
- url: P(b, Rt),
1628
+ requestId: Ut("fetch"),
1629
+ url: U(E, bt),
1609
1630
  method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
1610
1631
  requestHeaders: T,
1611
- requestBody: be(u?.body),
1632
+ requestBody: Ee(u?.body),
1612
1633
  resourceType: "fetch",
1613
1634
  startedAt: new Date(d).toISOString()
1614
1635
  };
1615
1636
  p.then(
1616
- (_) => {
1617
- Rr(_, F, d, t).catch(() => {
1637
+ (C) => {
1638
+ Cr(C, F, d, t).catch(() => {
1618
1639
  t({
1619
1640
  ...F,
1620
- responseStatus: _.status,
1641
+ responseStatus: C.status,
1621
1642
  durationMs: Date.now() - d
1622
1643
  });
1623
1644
  });
1624
1645
  },
1625
- (_) => {
1646
+ (C) => {
1626
1647
  t({
1627
1648
  ...F,
1628
- errorText: P(_ instanceof Error ? _.message : String(_)),
1649
+ errorText: U(C instanceof Error ? C.message : String(C)),
1629
1650
  durationMs: Date.now() - d
1630
1651
  });
1631
1652
  }
@@ -1635,28 +1656,28 @@ function $s() {
1635
1656
  }
1636
1657
  return p;
1637
1658
  }, a = function(g, u, d, p, m) {
1638
- const b = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1639
- return kt.set(this, {
1640
- requestId: Ct("xhr"),
1659
+ const E = n.call(this, g, u, d ?? !0, p ?? void 0, m ?? void 0), T = typeof u == "string" ? u : u.toString();
1660
+ return Mt.set(this, {
1661
+ requestId: Ut("xhr"),
1641
1662
  method: String(g ?? "GET").toUpperCase(),
1642
- url: P(T, Rt),
1663
+ url: U(T, bt),
1643
1664
  requestHeaders: {},
1644
1665
  startedAtMs: Date.now(),
1645
1666
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1646
1667
  excluded: x(T)
1647
- }), b;
1668
+ }), E;
1648
1669
  }, c = function(g, u) {
1649
- const d = r.call(this, g, u), p = kt.get(this);
1650
- return p && Object.keys(p.requestHeaders).length < $t && (p.requestHeaders[g] = Xt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1670
+ const d = r.call(this, g, u), p = Mt.get(this);
1671
+ return p && Object.keys(p.requestHeaders).length < jt && (p.requestHeaders[g] = Jt(g, u), p.excluded = p.excluded || x(p.url, p.requestHeaders)), d;
1651
1672
  }, l = function(g) {
1652
1673
  try {
1653
- const u = kt.get(this);
1654
- u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = be(g), u.excluded || this.addEventListener(
1674
+ const u = Mt.get(this);
1675
+ u && (u.excluded = u.excluded || x(u.url, u.requestHeaders, g), u.requestBody = Ee(g), u.excluded || this.addEventListener(
1655
1676
  "loadend",
1656
1677
  () => {
1657
1678
  queueMicrotask(() => {
1658
1679
  try {
1659
- const d = Ur(this.getAllResponseHeaders());
1680
+ const d = Nr(this.getAllResponseHeaders());
1660
1681
  t({
1661
1682
  requestId: u.requestId,
1662
1683
  url: u.url,
@@ -1666,7 +1687,7 @@ function $s() {
1666
1687
  resourceType: "xhr",
1667
1688
  responseStatus: this.status,
1668
1689
  responseHeaders: d,
1669
- responseBody: Mr(this, d),
1690
+ responseBody: Pr(this, d),
1670
1691
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1671
1692
  startedAt: u.startedAt,
1672
1693
  durationMs: Date.now() - u.startedAtMs
@@ -1707,8 +1728,8 @@ function $s() {
1707
1728
  continue;
1708
1729
  const d = performance.timeOrigin + u.startTime;
1709
1730
  t({
1710
- requestId: Ct("resource"),
1711
- url: P(u.name, Rt),
1731
+ requestId: Ut("resource"),
1732
+ url: U(u.name, bt),
1712
1733
  method: "GET",
1713
1734
  resourceType: "resource",
1714
1735
  responseStatus: u.responseStatus,
@@ -1758,17 +1779,17 @@ function S(e, t, s) {
1758
1779
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1759
1780
  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 }));
1760
1781
  }
1761
- function de(e) {
1782
+ function he(e) {
1762
1783
  const t = typeof e == "function" ? e() : e;
1763
1784
  return t && Object.keys(t).length > 0 ? t : void 0;
1764
1785
  }
1765
- function js(e) {
1786
+ function Xs(e) {
1766
1787
  return e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call";
1767
1788
  }
1768
- function zs(e) {
1789
+ function Js(e) {
1769
1790
  return e.type === "run.steered" || e.type === "run.ack" || e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call" || e.type === "tool.status" || e.type === "error" && typeof e.requestId != "string";
1770
1791
  }
1771
- function Mt(e) {
1792
+ function kt(e) {
1772
1793
  if (typeof e.sessionId == "string")
1773
1794
  return e.sessionId;
1774
1795
  if (e.session && typeof e.session == "object") {
@@ -1783,8 +1804,8 @@ function Mt(e) {
1783
1804
  }
1784
1805
  return null;
1785
1806
  }
1786
- const Ks = 5e3, Gs = 12e4;
1787
- function Xs(e) {
1807
+ const Vs = 5e3, Ys = 12e4;
1808
+ function Zs(e) {
1788
1809
  const t = [];
1789
1810
  for (const s of e)
1790
1811
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1795,30 +1816,30 @@ function Xs(e) {
1795
1816
  });
1796
1817
  return t;
1797
1818
  }
1798
- function Js(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1819
+ function Qs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1799
1820
  const n = [
1800
- Ys(),
1801
- Vs()
1821
+ en(),
1822
+ tn()
1802
1823
  ].filter((r) => typeof r == "function");
1803
1824
  return () => {
1804
1825
  for (const r of n.reverse())
1805
1826
  r();
1806
1827
  };
1807
1828
  }
1808
- function Vs() {
1809
- return Re(globalThis, "getPageSnapshot", async () => jt());
1829
+ function tn() {
1830
+ return be(globalThis, "getPageSnapshot", async () => zt());
1810
1831
  }
1811
- function Ys() {
1812
- return Re(globalThis, "pageImages", {
1813
- inspectImage: async (t, s) => await Zs(t, s)
1832
+ function en() {
1833
+ return be(globalThis, "pageImages", {
1834
+ inspectImage: async (t, s) => await sn(t, s)
1814
1835
  });
1815
1836
  }
1816
- async function Zs(e, t = {}) {
1817
- const s = sn(t.name), n = await Qs(e);
1837
+ async function sn(e, t = {}) {
1838
+ const s = an(t.name), n = await nn(e);
1818
1839
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1819
1840
  type: "pluno.pageImages.inspectImage",
1820
1841
  imageAttached: !1,
1821
- imageAttachmentError: Me
1842
+ imageAttachmentError: _e
1822
1843
  } : {
1823
1844
  type: "pluno.pageImages.inspectImage",
1824
1845
  imageAttached: !0,
@@ -1832,15 +1853,15 @@ async function Zs(e, t = {}) {
1832
1853
  imageAttachmentError: n.error
1833
1854
  };
1834
1855
  }
1835
- async function Qs(e) {
1836
- return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: Me } : {
1856
+ async function nn(e) {
1857
+ return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: _e } : {
1837
1858
  ok: !0,
1838
1859
  mimeType: e.type,
1839
1860
  sizeBytes: e.size,
1840
- dataUrl: await rn(e)
1841
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : tn(e);
1861
+ dataUrl: await ln(e)
1862
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : rn(e);
1842
1863
  }
1843
- function tn(e) {
1864
+ function rn(e) {
1844
1865
  if (!e.startsWith("data:") || !e.includes(","))
1845
1866
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1846
1867
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1851,7 +1872,7 @@ function tn(e) {
1851
1872
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1852
1873
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1853
1874
  return { ok: !1, error: "Page image data URL has invalid base64." };
1854
- const o = en(i);
1875
+ const o = on(i);
1855
1876
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1856
1877
  ok: !0,
1857
1878
  mimeType: r,
@@ -1859,22 +1880,22 @@ function tn(e) {
1859
1880
  dataUrl: `data:${r};base64,${i}`
1860
1881
  };
1861
1882
  }
1862
- function en(e) {
1883
+ function on(e) {
1863
1884
  if (e.length === 0 || e.length % 4 !== 0)
1864
1885
  return null;
1865
1886
  const t = e.length - e.replace(/=+$/, "").length;
1866
1887
  return t > 2 ? null : e.length / 4 * 3 - t;
1867
1888
  }
1868
- function sn(e) {
1889
+ function an(e) {
1869
1890
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1870
1891
  }
1871
- function nn(e) {
1892
+ function cn(e) {
1872
1893
  try {
1873
1894
  e();
1874
1895
  } catch {
1875
1896
  }
1876
1897
  }
1877
- function rn(e) {
1898
+ function ln(e) {
1878
1899
  return new Promise((t, s) => {
1879
1900
  const n = new FileReader();
1880
1901
  n.onload = () => {
@@ -1886,9 +1907,9 @@ function rn(e) {
1886
1907
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1887
1908
  });
1888
1909
  }
1889
- async function he(e, t) {
1910
+ async function pe(e, t) {
1890
1911
  const s = Object.getPrototypeOf(async function() {
1891
- }).constructor, n = e.timeoutMs ?? Ks, r = Date.now(), i = [];
1912
+ }).constructor, n = e.timeoutMs ?? Vs, r = Date.now(), i = [];
1892
1913
  let o;
1893
1914
  const a = {
1894
1915
  log: console.log,
@@ -1906,7 +1927,7 @@ async function he(e, t) {
1906
1927
  o = window.setTimeout(() => f(l), n);
1907
1928
  })
1908
1929
  ]);
1909
- return h === l ? an(n) : {
1930
+ return h === l ? dn(n) : {
1910
1931
  ok: !0,
1911
1932
  result: h,
1912
1933
  console: i,
@@ -1935,7 +1956,7 @@ async function he(e, t) {
1935
1956
  t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
1936
1957
  }
1937
1958
  }
1938
- function on(e, t) {
1959
+ function un(e, t) {
1939
1960
  if (!e || typeof e != "object")
1940
1961
  return;
1941
1962
  const s = e.sandboxFilesToken;
@@ -1945,7 +1966,7 @@ function on(e, t) {
1945
1966
  const r = () => {
1946
1967
  if (!n)
1947
1968
  throw new Error("sandboxFiles is only available during browser-code execution");
1948
- }, i = async (a, c) => await ys(`${t.replace(/\/$/, "")}${a}`, c);
1969
+ }, i = async (a, c) => await Ts(`${t.replace(/\/$/, "")}${a}`, c);
1949
1970
  return {
1950
1971
  value: Object.freeze({
1951
1972
  upload: async (a) => {
@@ -1979,7 +2000,7 @@ function on(e, t) {
1979
2000
  }
1980
2001
  };
1981
2002
  }
1982
- function an(e) {
2003
+ function dn(e) {
1983
2004
  return {
1984
2005
  ok: !1,
1985
2006
  exception: {
@@ -1993,10 +2014,10 @@ function an(e) {
1993
2014
  }
1994
2015
  };
1995
2016
  }
1996
- function cn(e) {
2017
+ function hn(e) {
1997
2018
  return e.replace(/\/+$/, "");
1998
2019
  }
1999
- function ln(e) {
2020
+ function pn(e) {
2000
2021
  const t = {
2001
2022
  sidepanel: "extension_sidepanel",
2002
2023
  browser_extension_page_ui: "extension_widget",
@@ -2008,17 +2029,17 @@ function ln(e) {
2008
2029
  };
2009
2030
  return e && e in t ? t[e] : e ?? "embedded_custom_ui";
2010
2031
  }
2011
- function un(e) {
2032
+ function fn(e) {
2012
2033
  return e === "pluno" ? "scheduled_continuation" : e ?? "user";
2013
2034
  }
2014
- function dn(e, t = location.origin) {
2035
+ function gn(e, t = location.origin) {
2015
2036
  return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
2016
2037
  }
2017
- function hn(e) {
2038
+ function mn(e) {
2018
2039
  const t = new URL("/api/product-agent/embed/ws", e);
2019
2040
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
2020
2041
  }
2021
- function k() {
2042
+ function M() {
2022
2043
  const e = Oe();
2023
2044
  return {
2024
2045
  url: location.href,
@@ -2027,19 +2048,19 @@ function k() {
2027
2048
  ...e ? { plunoProductAgentUi: e } : {}
2028
2049
  };
2029
2050
  }
2030
- function pn() {
2051
+ function yn() {
2031
2052
  return {
2032
2053
  pageUrl: location.href,
2033
2054
  pageTitle: document.title,
2034
- htmlContent: jt()
2055
+ htmlContent: zt()
2035
2056
  };
2036
2057
  }
2037
- function fn(e) {
2038
- return st.add(e), Z || (Z = gn()), () => {
2058
+ function In(e) {
2059
+ return st.add(e), Z || (Z = Tn()), () => {
2039
2060
  st.delete(e), st.size === 0 && (Z?.(), Z = null);
2040
2061
  };
2041
2062
  }
2042
- function gn() {
2063
+ function Tn() {
2043
2064
  const e = () => {
2044
2065
  for (const i of Array.from(st))
2045
2066
  i();
@@ -2054,10 +2075,10 @@ function gn() {
2054
2075
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
2055
2076
  };
2056
2077
  }
2057
- function mn() {
2078
+ function wn() {
2058
2079
  return Oe()?.surface === "browser_extension_sdk_preview";
2059
2080
  }
2060
- function jt() {
2081
+ function zt() {
2061
2082
  if (!document.body)
2062
2083
  return "";
2063
2084
  const e = [], t = [], s = (d, p) => {
@@ -2070,12 +2091,12 @@ function jt() {
2070
2091
  );
2071
2092
  for (const d of r.slice(0, 3))
2072
2093
  s("Active overlay", _t(z(d), t));
2073
- const i = yn(), o = i ? _t(z(i), t) : "";
2094
+ const i = Sn(), o = i ? _t(z(i), t) : "";
2074
2095
  s("Main page content", o), s("Additional visible page text", _t(z(document.body), t));
2075
2096
  const a = e.map(([d, p]) => `${d}:
2076
2097
  ${p}`).join(`
2077
2098
 
2078
- `).trim().slice(0, 12e3), c = In(r, i).trim(), l = `Simplified DOM outline:
2099
+ `).trim().slice(0, 12e3), c = An(r, i).trim(), l = `Simplified DOM outline:
2079
2100
  `, h = `
2080
2101
 
2081
2102
  Visible page text:
@@ -2103,10 +2124,10 @@ function Pe(e) {
2103
2124
  const t = window.getComputedStyle(e);
2104
2125
  return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
2105
2126
  }
2106
- function yn() {
2127
+ function Sn() {
2107
2128
  return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Pe).sort((e, t) => z(t).length - z(e).length)[0] ?? null;
2108
2129
  }
2109
- function In(e, t) {
2130
+ function An(e, t) {
2110
2131
  const s = /* @__PURE__ */ new Set([
2111
2132
  "main",
2112
2133
  "nav",
@@ -2186,7 +2207,7 @@ function In(e, t) {
2186
2207
  "data-test",
2187
2208
  "data-qa",
2188
2209
  "data-cy"
2189
- ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = Tn(), I = new Set(e);
2210
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: f } = En(), I = new Set(e);
2190
2211
  t && I.add(t);
2191
2212
  let g = 0;
2192
2213
  const u = (T) => {
@@ -2196,41 +2217,41 @@ function In(e, t) {
2196
2217
  const D = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
2197
2218
  return `${T.tagName.toLowerCase()}|${u(T)}|${D}`;
2198
2219
  }, p = (T, D, F) => {
2199
- const _ = (A, dt) => {
2200
- const R = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2201
- if (g >= 1e3 && !K || F.has(A) || i.has(R) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2220
+ const C = (A, dt) => {
2221
+ const b = A.tagName.toLowerCase(), ht = window.getComputedStyle(A), K = h.has(A);
2222
+ if (g >= 1e3 && !K || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ht.display === "none" || ht.visibility === "hidden")
2202
2223
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2203
2224
  g += 1;
2204
- const Jt = u(A), G = De(A), Ve = a.has(Jt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(R) || R === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2225
+ const Vt = u(A), G = ve(A), Ye = a.has(Vt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), pt = Array.from(A.children).filter((y) => y instanceof HTMLElement), X = /* @__PURE__ */ new Map();
2205
2226
  for (const y of pt) {
2206
2227
  const w = d(y);
2207
2228
  X.set(w, (X.get(w) ?? 0) + 1);
2208
2229
  }
2209
- const ft = /* @__PURE__ */ new Map(), Vt = /* @__PURE__ */ new Map();
2230
+ const ft = /* @__PURE__ */ new Map(), Yt = /* @__PURE__ */ new Map();
2210
2231
  for (const y of pt) {
2211
- const w = d(y), O = Vt.get(w) ?? 0;
2212
- Vt.set(w, O + 1), (X.get(w) ?? 0) > 8 && O >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2232
+ const w = d(y), v = Yt.get(w) ?? 0;
2233
+ Yt.set(w, v + 1), (X.get(w) ?? 0) > 8 && v >= 6 && !h.has(y) && ft.set(w, (ft.get(w) ?? 0) + 1);
2213
2234
  }
2214
- const Yt = /* @__PURE__ */ new Map(), Zt = /* @__PURE__ */ new Set(), gt = [], Qt = [];
2235
+ const Zt = /* @__PURE__ */ new Map(), Qt = /* @__PURE__ */ new Set(), gt = [], te = [];
2215
2236
  for (const y of pt) {
2216
- const w = d(y), O = X.get(w) ?? 0, se = Yt.get(w) ?? 0;
2217
- if (Yt.set(w, se + 1), O > 8 && se >= 6 && !h.has(y)) {
2218
- Zt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Zt.add(w));
2237
+ const w = d(y), v = X.get(w) ?? 0, ne = Zt.get(w) ?? 0;
2238
+ if (Zt.set(w, ne + 1), v > 8 && ne >= 6 && !h.has(y)) {
2239
+ Qt.has(w) || (gt.push([`… ${ft.get(w) ?? 0} similar siblings omitted`]), Qt.add(w));
2219
2240
  continue;
2220
2241
  }
2221
- const ne = _(y, dt);
2222
- Qt.push(ne), gt.push(ne.lines);
2242
+ const re = C(y, dt);
2243
+ te.push(re), gt.push(re.lines);
2223
2244
  }
2224
2245
  const mt = [];
2225
2246
  if (A.shadowRoot)
2226
2247
  for (const y of Array.from(A.shadowRoot.children))
2227
- y instanceof HTMLElement && mt.push(_(y, dt + 1));
2228
- const J = [...Qt, ...mt], yt = G.length > 0 || Ve || J.some((y) => y.hasUsefulContent), te = B(
2248
+ y instanceof HTMLElement && mt.push(C(y, dt + 1));
2249
+ const J = [...te, ...mt], yt = G.length > 0 || Ye || J.some((y) => y.hasUsefulContent), ee = B(
2229
2250
  [G, ...J.map((y) => y.textPreview)].filter(Boolean).join(" ")
2230
- ).slice(0, 180), Ye = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), ee = l.some((y) => A.hasAttribute(y)) || !!Jt || Ye, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(R) || ee || K) && (yt || K) && (!r.has(R) || yt || ee || K), Tt = It ? 1 : 0, H = [];
2251
+ ).slice(0, 180), Ze = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), se = l.some((y) => A.hasAttribute(y)) || !!Vt || Ze, It = (A.getClientRects().length > 0 || ht.display === "contents") && (s.has(b) || se || K) && (yt || K) && (!r.has(b) || yt || se || K), Tt = It ? 1 : 0, H = [];
2231
2252
  if (It) {
2232
- const y = J.some((O) => O.containsTextElement), w = n.has(R) && !y ? te : G;
2233
- H.push(Ue(A, c, o, w.slice(0, 180)));
2253
+ const y = J.some((v) => v.containsTextElement), w = n.has(b) && !y ? ee : G;
2254
+ H.push(De(A, c, o, w.slice(0, 180)));
2234
2255
  }
2235
2256
  for (const y of gt)
2236
2257
  H.push(...Q(y, Tt));
@@ -2238,25 +2259,25 @@ function In(e, t) {
2238
2259
  if (wt.length > 0) {
2239
2260
  const y = wt.slice(0, 20);
2240
2261
  wt.length > y.length && y.push("… shadow DOM omitted");
2241
- const w = R.includes("tooltip") || R.includes("popper") || R.includes("loader");
2262
+ const w = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
2242
2263
  if (dt < 2 && !w) {
2243
- const O = It ? "#shadow-root" : `${R} #shadow-root`;
2244
- H.push(...Q([O, ...Q(y, 1)], Tt));
2264
+ const v = It ? "#shadow-root" : `${b} #shadow-root`;
2265
+ H.push(...Q([v, ...Q(y, 1)], Tt));
2245
2266
  } else
2246
2267
  H.push(...Q(y, Tt));
2247
2268
  }
2248
2269
  return {
2249
2270
  lines: H,
2250
2271
  hasUsefulContent: yt,
2251
- textPreview: te,
2252
- containsTextElement: n.has(R) || J.some((y) => y.containsTextElement)
2272
+ textPreview: ee,
2273
+ containsTextElement: n.has(b) || J.some((y) => y.containsTextElement)
2253
2274
  };
2254
2275
  };
2255
- return [`--- ${D} ---`, ..._(T, 0).lines].join(`
2276
+ return [`--- ${D} ---`, ...C(T, 0).lines].join(`
2256
2277
  `);
2257
- }, m = [], b = B(window.getSelection()?.toString() ?? "");
2258
- b && m.push(`--- selected text ---
2259
- ${JSON.stringify(b)}`), f.length > 0 && m.push(wn(f, s, c, o));
2278
+ }, m = [], E = B(window.getSelection()?.toString() ?? "");
2279
+ E && m.push(`--- selected text ---
2280
+ ${JSON.stringify(E)}`), f.length > 0 && m.push(Rn(f, s, c, o));
2260
2281
  for (const T of e.slice(0, 3))
2261
2282
  m.push(p(T, "active overlay DOM", /* @__PURE__ */ new Set()));
2262
2283
  if (t && m.push(p(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -2267,11 +2288,11 @@ ${JSON.stringify(b)}`), f.length > 0 && m.push(wn(f, s, c, o));
2267
2288
 
2268
2289
  `);
2269
2290
  }
2270
- function Ue(e, t, s, n) {
2291
+ function De(e, t, s, n) {
2271
2292
  const r = e.tagName.toLowerCase();
2272
2293
  let i = r;
2273
2294
  const o = e.getAttribute("id");
2274
- o && Sn(o) && (i += `#${o}`);
2295
+ o && bn(o) && (i += `#${o}`);
2275
2296
  for (const a of t) {
2276
2297
  const c = e.getAttribute(a);
2277
2298
  c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
@@ -2284,7 +2305,7 @@ function Ue(e, t, s, n) {
2284
2305
  e.hasAttribute(a) && (i += `[${a}]`);
2285
2306
  return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2286
2307
  }
2287
- function Tn() {
2308
+ function En() {
2288
2309
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
2289
2310
  if (!a)
2290
2311
  return;
@@ -2305,7 +2326,7 @@ function Tn() {
2305
2326
  n = n.shadowRoot.activeElement;
2306
2327
  n !== document.body && n !== document.documentElement && s(n, "focused");
2307
2328
  const r = window.getSelection();
2308
- r && !r.isCollapsed && (s(pe(r.anchorNode), "selected text"), s(pe(r.focusNode), "selected text"));
2329
+ r && !r.isCollapsed && (s(fe(r.anchorNode), "selected text"), s(fe(r.focusNode), "selected text"));
2309
2330
  const i = [
2310
2331
  ["[aria-selected='true']", "selected"],
2311
2332
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -2327,7 +2348,7 @@ function Tn() {
2327
2348
  priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
2328
2349
  };
2329
2350
  }
2330
- function wn(e, t, s, n) {
2351
+ function Rn(e, t, s, n) {
2331
2352
  const r = ["--- active/current elements ---"];
2332
2353
  for (const i of e) {
2333
2354
  const o = [];
@@ -2338,18 +2359,18 @@ function wn(e, t, s, n) {
2338
2359
  const f = a.getRootNode();
2339
2360
  a = a.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
2340
2361
  }
2341
- const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => Ue(
2362
+ const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((h, f) => De(
2342
2363
  h,
2343
2364
  s,
2344
2365
  n,
2345
- f === c.length - 1 ? De(h).slice(0, 180) : ""
2366
+ f === c.length - 1 ? ve(h).slice(0, 180) : ""
2346
2367
  ));
2347
2368
  o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2348
2369
  }
2349
2370
  return r.join(`
2350
2371
  `);
2351
2372
  }
2352
- function pe(e) {
2373
+ function fe(e) {
2353
2374
  return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
2354
2375
  }
2355
2376
  function Q(e, t) {
@@ -2358,17 +2379,17 @@ function Q(e, t) {
2358
2379
  const s = " ".repeat(t);
2359
2380
  return e.map((n) => `${s}${n}`);
2360
2381
  }
2361
- function De(e) {
2382
+ function ve(e) {
2362
2383
  return B(
2363
2384
  Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2364
2385
  );
2365
2386
  }
2366
- function Sn(e) {
2387
+ function bn(e) {
2367
2388
  return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
2368
2389
  }
2369
2390
  function Oe() {
2370
- const e = document.querySelector(re);
2371
- if (!(e ?? document.querySelector(Ut)))
2391
+ const e = document.querySelector(ie);
2392
+ if (!(e ?? document.querySelector(Dt)))
2372
2393
  return;
2373
2394
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
2374
2395
  return {
@@ -2377,28 +2398,28 @@ function Oe() {
2377
2398
  selectors: [
2378
2399
  {
2379
2400
  name: "widget_host",
2380
- selector: s === "browser_extension_sdk_preview" ? re : Ut,
2401
+ selector: s === "browser_extension_sdk_preview" ? ie : Dt,
2381
2402
  description: "Finds Pluno's shadow-host element in the host page DOM."
2382
2403
  },
2383
2404
  {
2384
2405
  name: "widget_root",
2385
- selector: Is,
2406
+ selector: ws,
2386
2407
  description: "Finds Pluno's widget root inside the widget host shadow root."
2387
2408
  },
2388
2409
  {
2389
2410
  name: "widget_panel",
2390
- selector: Ts,
2411
+ selector: Ss,
2391
2412
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2392
2413
  },
2393
2414
  {
2394
2415
  name: "widget_timeline",
2395
- selector: ws,
2416
+ selector: As,
2396
2417
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2397
2418
  }
2398
2419
  ]
2399
2420
  };
2400
2421
  }
2401
- function An(e) {
2422
+ function Mn(e) {
2402
2423
  try {
2403
2424
  const t = JSON.parse(e);
2404
2425
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -2406,16 +2427,16 @@ function An(e) {
2406
2427
  return { type: "error", message: "Invalid server event" };
2407
2428
  }
2408
2429
  }
2409
- function fe(e, t) {
2430
+ function ge(e, t) {
2410
2431
  if (!e || typeof e != "object")
2411
2432
  return [];
2412
2433
  const s = e[t];
2413
2434
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2414
2435
  }
2415
- function bn(e) {
2436
+ function kn(e) {
2416
2437
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
2417
2438
  }
2418
- function En(e) {
2439
+ function _n(e) {
2419
2440
  if (!e || typeof e != "object")
2420
2441
  return null;
2421
2442
  const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -2426,13 +2447,13 @@ function En(e) {
2426
2447
  ...a !== null ? { scribbleStyle: a } : {}
2427
2448
  };
2428
2449
  }
2429
- function Rn(e) {
2450
+ function Cn(e) {
2430
2451
  if (!e || typeof e != "object")
2431
2452
  return null;
2432
2453
  const t = e.javascript;
2433
2454
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
2434
2455
  }
2435
- function kn(e, t) {
2456
+ function Un(e, t) {
2436
2457
  return t ? e && typeof e == "object" ? {
2437
2458
  ...e,
2438
2459
  helperError: t
@@ -2442,13 +2463,13 @@ function kn(e, t) {
2442
2463
  helperError: t
2443
2464
  } : e;
2444
2465
  }
2445
- function Mn(e) {
2466
+ function Pn(e) {
2446
2467
  if (!e || typeof e != "object")
2447
2468
  return e;
2448
2469
  const t = e;
2449
2470
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2450
2471
  }
2451
- function _n() {
2472
+ function Dn() {
2452
2473
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2453
2474
  if (t)
2454
2475
  return t;
@@ -2458,7 +2479,7 @@ function _n() {
2458
2479
  function $() {
2459
2480
  return crypto.randomUUID();
2460
2481
  }
2461
- function Cn(e) {
2482
+ function vn(e) {
2462
2483
  if (!e || typeof e != "object")
2463
2484
  return null;
2464
2485
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2469,22 +2490,22 @@ function Cn(e) {
2469
2490
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2470
2491
  } : null;
2471
2492
  }
2472
- function Pn(e, t) {
2473
- return Array.isArray(e) ? qt(
2493
+ function On(e, t) {
2494
+ return Array.isArray(e) ? Bt(
2474
2495
  e.map((s) => Ne(s, t)).filter((s) => s !== null)
2475
2496
  ) : [];
2476
2497
  }
2477
- function Un(e) {
2498
+ function Nn(e) {
2478
2499
  return Array.isArray(e) ? e.flatMap((t) => {
2479
2500
  if (!t || typeof t != "object")
2480
2501
  return [];
2481
- const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
2502
+ const s = t, n = R(s, "id"), r = R(s, "createdAt"), i = R(s, "updatedAt"), o = R(s, "lastActiveAt");
2482
2503
  return !n || !r || !i || !o ? [] : [
2483
2504
  {
2484
2505
  id: n,
2485
- title: E(s, "title"),
2486
- customTitle: E(s, "customTitle"),
2487
- firstUserMessage: E(s, "firstUserMessage"),
2506
+ title: R(s, "title"),
2507
+ customTitle: R(s, "customTitle"),
2508
+ firstUserMessage: R(s, "firstUserMessage"),
2488
2509
  currentPage: s.currentPage ?? null,
2489
2510
  createdAt: r,
2490
2511
  updatedAt: i,
@@ -2509,14 +2530,14 @@ function Ne(e, t) {
2509
2530
  id: String(s.id ?? crypto.randomUUID()),
2510
2531
  role: i,
2511
2532
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2512
- content: is(
2513
- qn(r.content),
2533
+ content: os(
2534
+ Wn(r.content),
2514
2535
  t
2515
2536
  ),
2516
2537
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2517
- respondsToUserMessageId: v(r) ?? void 0,
2518
- ...C(r) ? { runId: C(r) } : {},
2519
- attachments: Fe(r.attachments, t)
2538
+ respondsToUserMessageId: O(r) ?? void 0,
2539
+ ...k(r) ? { runId: k(r) } : {},
2540
+ attachments: He(r.attachments, t)
2520
2541
  };
2521
2542
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2522
2543
  value: r.id,
@@ -2527,38 +2548,52 @@ function Ne(e, t) {
2527
2548
  }), o;
2528
2549
  }
2529
2550
  if (r.type === "function_call_output") {
2530
- const i = On(r.output);
2531
- return i ? {
2551
+ const i = Is(r.output);
2552
+ if (i)
2553
+ return {
2554
+ id: String(s.id ?? crypto.randomUUID()),
2555
+ role: "tool",
2556
+ content: "",
2557
+ createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2558
+ respondsToUserMessageId: O(r) ?? void 0,
2559
+ ...k(r) ? { runId: k(r) } : {},
2560
+ dataType: "scheduled_check_in",
2561
+ toolName: ke,
2562
+ callId: Ct(r) ?? void 0,
2563
+ scheduledCheckInAt: i
2564
+ };
2565
+ const o = Ln(r.output);
2566
+ return o ? {
2532
2567
  id: String(s.id ?? crypto.randomUUID()),
2533
2568
  role: "tool",
2534
- content: `Connect ${i.appName} to continue`,
2569
+ content: `Connect ${o.appName} to continue`,
2535
2570
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2536
- respondsToUserMessageId: v(r) ?? void 0,
2537
- ...C(r) ? { runId: C(r) } : {},
2571
+ respondsToUserMessageId: O(r) ?? void 0,
2572
+ ...k(r) ? { runId: k(r) } : {},
2538
2573
  dataType: "function_call_output",
2539
2574
  toolName: "authenticate_pipedream_app",
2540
- callId: ge(r) ?? void 0,
2541
- integrationAuthRequest: i
2575
+ callId: Ct(r) ?? void 0,
2576
+ integrationAuthRequest: o
2542
2577
  } : null;
2543
2578
  }
2544
2579
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2545
2580
  id: String(s.id ?? crypto.randomUUID()),
2546
2581
  role: "tool",
2547
- content: r.type === "mcp_call" ? Dn(r) : vn(r),
2582
+ content: r.type === "mcp_call" ? xn(r) : Bn(r),
2548
2583
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2549
- respondsToUserMessageId: v(r) ?? void 0,
2550
- ...C(r) ? { runId: C(r) } : {},
2584
+ respondsToUserMessageId: O(r) ?? void 0,
2585
+ ...k(r) ? { runId: k(r) } : {},
2551
2586
  dataType: String(r.type),
2552
2587
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2553
- callId: ge(r) ?? void 0,
2588
+ callId: Ct(r) ?? void 0,
2554
2589
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
2555
2590
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2556
2591
  id: String(s.id ?? crypto.randomUUID()),
2557
2592
  role: "system",
2558
- content: Nn(r),
2593
+ content: qn(r),
2559
2594
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2560
- respondsToUserMessageId: v(r) ?? void 0,
2561
- ...C(r) ? { runId: C(r) } : {},
2595
+ respondsToUserMessageId: O(r) ?? void 0,
2596
+ ...k(r) ? { runId: k(r) } : {},
2562
2597
  dataType: String(r.type),
2563
2598
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
2564
2599
  ...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
@@ -2566,11 +2601,11 @@ function Ne(e, t) {
2566
2601
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2567
2602
  } : null;
2568
2603
  }
2569
- function Dn(e) {
2604
+ function xn(e) {
2570
2605
  const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
2571
2606
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2572
2607
  }
2573
- function On(e) {
2608
+ function Ln(e) {
2574
2609
  if (typeof e != "string")
2575
2610
  return null;
2576
2611
  try {
@@ -2587,10 +2622,10 @@ function On(e) {
2587
2622
  return null;
2588
2623
  }
2589
2624
  }
2590
- function Nn(e) {
2625
+ function qn(e) {
2591
2626
  return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : e.type === "run_status" && e.status === "steered" ? "Steered" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
2592
2627
  }
2593
- function vn(e) {
2628
+ function Bn(e) {
2594
2629
  if (e.type === "web_search_call") {
2595
2630
  const t = e.action;
2596
2631
  if (t && typeof t == "object") {
@@ -2602,9 +2637,9 @@ function vn(e) {
2602
2637
  }
2603
2638
  return "🔎 Searching the web";
2604
2639
  }
2605
- return xn(e);
2640
+ return Fn(e);
2606
2641
  }
2607
- function xn(e) {
2642
+ function Fn(e) {
2608
2643
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2609
2644
  return L(e.summary);
2610
2645
  if (typeof e.arguments == "string")
@@ -2621,7 +2656,7 @@ function L(e) {
2621
2656
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2622
2657
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2623
2658
  }
2624
- function Ln(e) {
2659
+ function Hn(e) {
2625
2660
  if (e == null)
2626
2661
  return e;
2627
2662
  if (typeof e != "object")
@@ -2636,11 +2671,11 @@ function Ln(e) {
2636
2671
  runId: typeof t.runId == "string" ? t.runId : null
2637
2672
  };
2638
2673
  }
2639
- function ge(e) {
2674
+ function Ct(e) {
2640
2675
  const t = e.callId ?? e.call_id;
2641
2676
  return typeof t == "string" && t ? t : null;
2642
2677
  }
2643
- function qn(e) {
2678
+ function Wn(e) {
2644
2679
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2645
2680
  if (!t || typeof t != "object")
2646
2681
  return "";
@@ -2649,30 +2684,30 @@ function qn(e) {
2649
2684
  }).filter(Boolean).join("") : "";
2650
2685
  }
2651
2686
  function Ot(e, t) {
2652
- const s = xe(e, t), n = zn(
2653
- Bn(
2654
- Jn(e, t),
2687
+ const s = Le(e, t), n = Jn(
2688
+ $n(
2689
+ Qn(e, t),
2655
2690
  s
2656
2691
  ),
2657
2692
  s
2658
2693
  ), r = n.findIndex((o) => o.id === s.id);
2659
2694
  if (r === -1)
2660
- return qt(
2695
+ return Bt(
2661
2696
  [...n, s]
2662
2697
  );
2663
2698
  const i = [...n];
2664
- return i[r] = s, qt(i);
2699
+ return i[r] = s, Bt(i);
2665
2700
  }
2666
- function Bn(e, t) {
2701
+ function $n(e, t) {
2667
2702
  const s = t.assistantDraftItemId;
2668
2703
  return s ? e.map(
2669
2704
  (n) => n.dataType === "assistant_draft" && n.id === s ? t : n
2670
2705
  ) : e;
2671
2706
  }
2672
- function Fn(e, t, s) {
2707
+ function jn(e, t, s) {
2673
2708
  return t !== null ? e.respondsToUserMessageId === t : s !== null && e.runId === s;
2674
2709
  }
2675
- function Hn(e, t, s, n) {
2710
+ function zn(e, t, s, n) {
2676
2711
  if (s === null) return e;
2677
2712
  let r = -1;
2678
2713
  for (let o = e.length - 1; o >= 0; o -= 1) {
@@ -2689,7 +2724,7 @@ function Hn(e, t, s, n) {
2689
2724
  respondsToUserMessageId: s
2690
2725
  }, i;
2691
2726
  }
2692
- function Wn(e, t) {
2727
+ function Kn(e, t) {
2693
2728
  const s = e.findIndex(
2694
2729
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2695
2730
  );
@@ -2706,12 +2741,12 @@ function Wn(e, t) {
2706
2741
  ...n[s].runId ? {} : { runId: t.runId }
2707
2742
  }, n;
2708
2743
  }
2709
- function $n(e, t, s) {
2744
+ function Gn(e, t, s) {
2710
2745
  let n = !1;
2711
2746
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2712
2747
  return n ? r : e;
2713
2748
  }
2714
- function jn(e) {
2749
+ function Xn(e) {
2715
2750
  if (e.hiddenFromTranscript === !0)
2716
2751
  return null;
2717
2752
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
@@ -2730,7 +2765,7 @@ function jn(e) {
2730
2765
  loading: !0
2731
2766
  };
2732
2767
  }
2733
- function zn(e, t) {
2768
+ function Jn(e, t) {
2734
2769
  if (t.id.startsWith("transient-activity:"))
2735
2770
  return e;
2736
2771
  const s = t.toolName === "tab_lifecycle";
@@ -2738,16 +2773,16 @@ function zn(e, t) {
2738
2773
  (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === t.runId)
2739
2774
  );
2740
2775
  }
2741
- function Kn(e, t) {
2742
- return os(
2776
+ function Vn(e, t) {
2777
+ return as(
2743
2778
  e,
2744
2779
  t.map(
2745
- (s) => xe(e, s)
2780
+ (s) => Le(e, s)
2746
2781
  ),
2747
- ve
2782
+ xe
2748
2783
  );
2749
2784
  }
2750
- function ve(e) {
2785
+ function xe(e) {
2751
2786
  const t = Nt(e) ?? void 0, s = e.assistantDraftItemId, n = [
2752
2787
  ...e.callId ? [`call:${e.callId}`] : [],
2753
2788
  ...e.runId && (e.toolName === "browser_tabs" || e.toolName === "tab_lifecycle") ? [`tab-lifecycle:${e.runId}`] : []
@@ -2759,49 +2794,49 @@ function ve(e) {
2759
2794
  ...n.length > 0 ? { activityKeys: n } : {},
2760
2795
  ...e.respondsToUserMessageId ? { respondsToUserMessageId: e.respondsToUserMessageId } : {},
2761
2796
  ...e.runId ? { runId: e.runId } : {},
2762
- isOptimistic: zt(e),
2797
+ isOptimistic: Kt(e),
2763
2798
  isAssistantDraft: e.dataType === "assistant_draft",
2764
2799
  isActivity: e.role === "tool" || e.phase === "commentary" || e.dataType === "assistant_draft",
2765
2800
  isTransient: e.id.startsWith("transient-activity:") || e.dataType === "assistant_draft"
2766
2801
  };
2767
2802
  }
2768
- function xe(e, t) {
2803
+ function Le(e, t) {
2769
2804
  if (t.role !== "user" || !t.attachments?.length)
2770
2805
  return t;
2771
2806
  const s = e.find(
2772
- (r) => r.role === "user" && (r.id === t.id || zt(r) && Le(r, t))
2807
+ (r) => r.role === "user" && (r.id === t.id || Kt(r) && qe(r, t))
2773
2808
  );
2774
2809
  if (!s?.attachments?.length)
2775
2810
  return t;
2776
2811
  const n = t.attachments.map((r) => {
2777
- const i = Gn(s.attachments ?? [], r);
2778
- return i ? Xn(r, i) : r;
2812
+ const i = Yn(s.attachments ?? [], r);
2813
+ return i ? Zn(r, i) : r;
2779
2814
  });
2780
2815
  return { ...t, attachments: n };
2781
2816
  }
2782
- function Gn(e, t) {
2817
+ function Yn(e, t) {
2783
2818
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2784
2819
  }
2785
- function Xn(e, t) {
2820
+ function Zn(e, t) {
2786
2821
  const { previewUrl: s } = t;
2787
2822
  return s ? { ...e, previewUrl: s } : e;
2788
2823
  }
2789
- function Jn(e, t) {
2824
+ function Qn(e, t) {
2790
2825
  if (t.role !== "user")
2791
2826
  return e;
2792
2827
  const s = e.findIndex(
2793
- (r) => zt(r) && Le(r, t)
2828
+ (r) => Kt(r) && qe(r, t)
2794
2829
  );
2795
2830
  if (s === -1)
2796
2831
  return e;
2797
2832
  const n = [...e];
2798
2833
  return n.splice(s, 1), n;
2799
2834
  }
2800
- function Le(e, t) {
2835
+ function qe(e, t) {
2801
2836
  const s = Nt(e), n = Nt(t);
2802
2837
  return s && n ? s === n : e.content === t.content;
2803
2838
  }
2804
- function zt(e) {
2839
+ function Kt(e) {
2805
2840
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2806
2841
  }
2807
2842
  function Nt(e) {
@@ -2814,11 +2849,11 @@ function Nt(e) {
2814
2849
  return n ? e.id.slice(n.length) : null;
2815
2850
  }
2816
2851
  function me(e) {
2817
- const t = qe(e);
2852
+ const t = Be(e);
2818
2853
  if (t === null)
2819
2854
  return !1;
2820
2855
  const s = e[t].id, n = e.some(
2821
- (r) => r.respondsToUserMessageId === s && vt(r)
2856
+ (r) => r.respondsToUserMessageId === s && xt(r)
2822
2857
  );
2823
2858
  if (e.some((r) => r.respondsToUserMessageId === s))
2824
2859
  return n;
@@ -2835,8 +2870,8 @@ function me(e) {
2835
2870
  }
2836
2871
  return !1;
2837
2872
  }
2838
- function Vn(e) {
2839
- const t = qe(e);
2873
+ function tr(e) {
2874
+ const t = Be(e);
2840
2875
  if (t === null)
2841
2876
  return e.some(N);
2842
2877
  const s = e[t].id;
@@ -2844,13 +2879,13 @@ function Vn(e) {
2844
2879
  (n) => n.respondsToUserMessageId === s && N(n)
2845
2880
  ) : e.slice(t + 1).some(N);
2846
2881
  }
2847
- function qe(e) {
2882
+ function Be(e) {
2848
2883
  for (let t = e.length - 1; t >= 0; t -= 1)
2849
2884
  if (e[t].role === "user")
2850
2885
  return t;
2851
2886
  return null;
2852
2887
  }
2853
- function vt(e) {
2888
+ function xt(e) {
2854
2889
  return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2855
2890
  }
2856
2891
  function at(e) {
@@ -2867,7 +2902,7 @@ function at(e) {
2867
2902
  }
2868
2903
  return null;
2869
2904
  }
2870
- function Yn(e) {
2905
+ function er(e) {
2871
2906
  const t = at(e);
2872
2907
  if (t === null)
2873
2908
  return null;
@@ -2883,13 +2918,13 @@ function q(e) {
2883
2918
  const t = e.data;
2884
2919
  return t && typeof t == "object" ? t : null;
2885
2920
  }
2886
- function xt(e) {
2921
+ function Lt(e) {
2887
2922
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2888
2923
  }
2889
2924
  function ye(e) {
2890
2925
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2891
2926
  }
2892
- function Zn(e, t) {
2927
+ function sr(e, t) {
2893
2928
  const s = at(t);
2894
2929
  if (s === null)
2895
2930
  return !1;
@@ -2898,10 +2933,10 @@ function Zn(e, t) {
2898
2933
  return !1;
2899
2934
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2900
2935
  return i === -1 ? !1 : e.some((o) => o.respondsToUserMessageId === r) ? e.some(
2901
- (o) => o.respondsToUserMessageId === r && vt(o)
2902
- ) : e.slice(i + 1).some(vt);
2936
+ (o) => o.respondsToUserMessageId === r && xt(o)
2937
+ ) : e.slice(i + 1).some(xt);
2903
2938
  }
2904
- function Lt(e) {
2939
+ function qt(e) {
2905
2940
  const t = at(e);
2906
2941
  if (t === null)
2907
2942
  return null;
@@ -2914,7 +2949,7 @@ function Lt(e) {
2914
2949
  const r = n.clientMessageId;
2915
2950
  return typeof r == "string" ? r : null;
2916
2951
  }
2917
- function Qn(e) {
2952
+ function nr(e) {
2918
2953
  const t = at(e);
2919
2954
  if (t === null)
2920
2955
  return null;
@@ -2929,22 +2964,22 @@ function Qn(e) {
2929
2964
  if (i.type === "message" && i.role === "assistant")
2930
2965
  return null;
2931
2966
  if (i.type === "run_error")
2932
- return i.retryable !== !0 ? null : Ie(e, i) ?? Lt(e);
2967
+ return i.retryable !== !0 ? null : Ie(e, i) ?? qt(e);
2933
2968
  if (i.type === "run_status")
2934
- return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? Lt(e) : null;
2969
+ return i.status === "interrupted" && i.retryable === !0 ? Ie(e, i) ?? qt(e) : null;
2935
2970
  }
2936
2971
  return null;
2937
2972
  }
2938
2973
  function Ie(e, t) {
2939
2974
  if (typeof t.clientMessageId == "string")
2940
2975
  return t.clientMessageId;
2941
- const s = v(t);
2976
+ const s = O(t);
2942
2977
  if (!s)
2943
2978
  return null;
2944
- const n = e.find((i) => E(i, "id") === s), r = q(n);
2979
+ const n = e.find((i) => R(i, "id") === s), r = q(n);
2945
2980
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2946
2981
  }
2947
- function tr(e, t) {
2982
+ function rr(e, t) {
2948
2983
  let s = 0;
2949
2984
  for (const n of e) {
2950
2985
  if (!n || typeof n != "object")
@@ -2958,12 +2993,12 @@ function tr(e, t) {
2958
2993
  return s;
2959
2994
  }
2960
2995
  function Te(e, t, s, n, r) {
2961
- if (!t || !er(e))
2996
+ if (!t || !ir(e))
2962
2997
  return !1;
2963
2998
  const i = e;
2964
- return !(xt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? v(i) !== n : r !== null && C(i) !== r));
2999
+ return !(Lt(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && k(i) !== r));
2965
3000
  }
2966
- function er(e) {
3001
+ function ir(e) {
2967
3002
  if (!e || typeof e != "object")
2968
3003
  return !1;
2969
3004
  const t = e;
@@ -2972,24 +3007,24 @@ function er(e) {
2972
3007
  function N(e) {
2973
3008
  return e.role === "assistant" && e.phase !== "commentary";
2974
3009
  }
2975
- function sr(e) {
3010
+ function or(e) {
2976
3011
  if (!e || typeof e != "object")
2977
3012
  return !1;
2978
3013
  const t = e;
2979
3014
  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";
2980
3015
  }
2981
- function qt(e) {
2982
- return e.filter((t, s) => ct(t) ? !ur(e, s) && !cr(e, s) && !lr(e, s) : nr(t) ? t.retryable === !0 && ar(e, s) ? !1 : !or(e, s) : !0);
3016
+ function Bt(e) {
3017
+ return e.filter((t, s) => ct(t) ? !fr(e, s) && !hr(e, s) && !pr(e, s) : ar(t) ? t.retryable === !0 && dr(e, s) ? !1 : !ur(e, s) : !0);
2983
3018
  }
2984
- function nr(e) {
3019
+ function ar(e) {
2985
3020
  return e.role === "system" && (e.dataType === "run_error" || e.dataType === "run_status" && e.steered !== !0);
2986
3021
  }
2987
3022
  function ct(e) {
2988
3023
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2989
3024
  }
2990
- function rr(e, t) {
3025
+ function cr(e, t) {
2991
3026
  const s = [...e].reverse().find(
2992
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !ir(
3027
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== t && we(n) && !lr(
2993
3028
  e,
2994
3029
  n.respondsToUserMessageId
2995
3030
  )
@@ -3001,12 +3036,12 @@ function rr(e, t) {
3001
3036
  function we(e) {
3002
3037
  return e.role === "tool" || ct(e) ? !0 : e.role === "assistant" && e.phase === "commentary";
3003
3038
  }
3004
- function ir(e, t) {
3039
+ function lr(e, t) {
3005
3040
  return e.some(
3006
3041
  (s) => s.respondsToUserMessageId === t && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3007
3042
  );
3008
3043
  }
3009
- function or(e, t) {
3044
+ function ur(e, t) {
3010
3045
  const s = e[t];
3011
3046
  for (let n = t + 1; n < e.length; n += 1) {
3012
3047
  const r = e[n];
@@ -3015,7 +3050,7 @@ function or(e, t) {
3015
3050
  }
3016
3051
  return !1;
3017
3052
  }
3018
- function ar(e, t) {
3053
+ function dr(e, t) {
3019
3054
  const s = e[t];
3020
3055
  if (!s.respondsToUserMessageId)
3021
3056
  return !1;
@@ -3028,19 +3063,19 @@ function ar(e, t) {
3028
3063
  }
3029
3064
  return !1;
3030
3065
  }
3031
- function cr(e, t) {
3066
+ function hr(e, t) {
3032
3067
  const s = e[t];
3033
3068
  return e.some(
3034
3069
  (n, r) => r !== t && n.role === "assistant" && lt(s, n)
3035
3070
  );
3036
3071
  }
3037
- function lr(e, t) {
3072
+ function pr(e, t) {
3038
3073
  const s = e[t];
3039
3074
  return e.some(
3040
3075
  (n, r) => r !== t && n.role === "tool" && lt(s, n)
3041
3076
  );
3042
3077
  }
3043
- function ur(e, t) {
3078
+ function fr(e, t) {
3044
3079
  const s = e[t];
3045
3080
  for (let n = t + 1; n < e.length; n += 1)
3046
3081
  if (ct(e[n]) && lt(s, e[n]))
@@ -3050,18 +3085,18 @@ function ur(e, t) {
3050
3085
  function lt(e, t) {
3051
3086
  return !!(e.respondsToUserMessageId && e.respondsToUserMessageId === t.respondsToUserMessageId);
3052
3087
  }
3053
- function E(e, t) {
3088
+ function R(e, t) {
3054
3089
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
3055
3090
  }
3056
- function dr(e, t) {
3091
+ function gr(e, t) {
3057
3092
  try {
3058
- const s = window.localStorage.getItem(`${_e}${e}`);
3093
+ const s = window.localStorage.getItem(`${Ce}${e}`);
3059
3094
  if (!s)
3060
3095
  return null;
3061
3096
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3062
3097
  if (t !== void 0 && r !== t)
3063
3098
  return null;
3064
- const i = Array.isArray(n.messages) ? n.messages.map(Sr).filter((o) => !!o) : [];
3099
+ const i = Array.isArray(n.messages) ? n.messages.map(br).filter((o) => !!o) : [];
3065
3100
  return {
3066
3101
  sessionId: r,
3067
3102
  messages: i
@@ -3070,46 +3105,46 @@ function dr(e, t) {
3070
3105
  return null;
3071
3106
  }
3072
3107
  }
3073
- function hr(e, t) {
3108
+ function mr(e, t) {
3074
3109
  try {
3075
3110
  window.localStorage.setItem(
3076
- `${_e}${e}`,
3111
+ `${Ce}${e}`,
3077
3112
  JSON.stringify({
3078
3113
  sessionId: t.sessionId,
3079
- messages: t.messages.slice(-qs).map(Ar)
3114
+ messages: t.messages.slice(-Ws).map(Mr)
3080
3115
  })
3081
3116
  );
3082
3117
  } catch {
3083
3118
  return;
3084
3119
  }
3085
3120
  }
3086
- function pr(e) {
3121
+ function yr(e) {
3087
3122
  try {
3088
- const t = window.localStorage.getItem(`${Dt}${e}`);
3123
+ const t = window.localStorage.getItem(`${vt}${e}`);
3089
3124
  if (!t)
3090
3125
  return [];
3091
3126
  const s = JSON.parse(t);
3092
- return Array.isArray(s) ? s.filter(Kt) : [];
3127
+ return Array.isArray(s) ? s.filter(Gt) : [];
3093
3128
  } catch {
3094
3129
  return [];
3095
3130
  }
3096
3131
  }
3097
3132
  function j(e, t) {
3098
3133
  try {
3099
- const s = t.filter(Kt);
3134
+ const s = t.filter(Gt);
3100
3135
  if (s.length === 0) {
3101
- window.localStorage.removeItem(`${Dt}${e}`);
3136
+ window.localStorage.removeItem(`${vt}${e}`);
3102
3137
  return;
3103
3138
  }
3104
3139
  window.localStorage.setItem(
3105
- `${Dt}${e}`,
3140
+ `${vt}${e}`,
3106
3141
  JSON.stringify(s.slice(-25))
3107
3142
  );
3108
3143
  } catch {
3109
3144
  return;
3110
3145
  }
3111
3146
  }
3112
- function Be(e, t) {
3147
+ function Fe(e, t) {
3113
3148
  try {
3114
3149
  const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
3115
3150
  ...o,
@@ -3125,28 +3160,28 @@ function Be(e, t) {
3125
3160
  } catch {
3126
3161
  }
3127
3162
  }
3128
- function fr(e, t) {
3163
+ function Ir(e, t) {
3129
3164
  try {
3130
3165
  if (window.sessionStorage.getItem(`${ot}${e}`) === null)
3131
3166
  return;
3132
3167
  } catch {
3133
3168
  return;
3134
3169
  }
3135
- Be(e, t);
3170
+ Fe(e, t);
3136
3171
  }
3137
- function gr(e) {
3172
+ function Tr(e) {
3138
3173
  try {
3139
3174
  const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
3140
3175
  if (window.sessionStorage.removeItem(t), !s)
3141
3176
  return [];
3142
3177
  const n = JSON.parse(s);
3143
- return Array.isArray(n) ? n.flatMap((r) => yr(r) ? [{
3178
+ return Array.isArray(n) ? n.flatMap((r) => Sr(r) ? [{
3144
3179
  ...r.event,
3145
- page: k(),
3180
+ page: M(),
3146
3181
  rawOutput: {
3147
3182
  pageContextRestarted: !0,
3148
3183
  outcome: "unknown",
3149
- message: mr(location.href),
3184
+ message: wr(location.href),
3150
3185
  currentUrl: location.href,
3151
3186
  console: [],
3152
3187
  metadata: {
@@ -3163,17 +3198,17 @@ function gr(e) {
3163
3198
  return [];
3164
3199
  }
3165
3200
  }
3166
- function mr(e) {
3201
+ function wr(e) {
3167
3202
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3168
3203
  Current URL: ${e}`;
3169
3204
  }
3170
- function yr(e) {
3205
+ function Sr(e) {
3171
3206
  if (!e || typeof e != "object")
3172
3207
  return !1;
3173
3208
  const t = e, s = t.event;
3174
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Kt(s) && s.type === "tool.result";
3209
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && Gt(s) && s.type === "tool.result";
3175
3210
  }
3176
- function Ir(e, t) {
3211
+ function Ar(e, t) {
3177
3212
  const s = new Set(
3178
3213
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3179
3214
  );
@@ -3182,14 +3217,14 @@ function Ir(e, t) {
3182
3217
  ...t.filter((n) => !s.has(n.callId))
3183
3218
  ];
3184
3219
  }
3185
- function Tr(e) {
3220
+ function Er(e) {
3186
3221
  try {
3187
3222
  window.sessionStorage.removeItem(`${ot}${e}`);
3188
3223
  } catch {
3189
3224
  return;
3190
3225
  }
3191
3226
  }
3192
- function Kt(e) {
3227
+ function Gt(e) {
3193
3228
  if (!e || typeof e != "object")
3194
3229
  return !1;
3195
3230
  const t = e;
@@ -3201,7 +3236,7 @@ function Se(e) {
3201
3236
  const t = e;
3202
3237
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
3203
3238
  }
3204
- function Fe(e, t) {
3239
+ function He(e, t) {
3205
3240
  if (!Array.isArray(e))
3206
3241
  return;
3207
3242
  const s = e.filter((r) => {
@@ -3209,23 +3244,23 @@ function Fe(e, t) {
3209
3244
  return !1;
3210
3245
  const i = r;
3211
3246
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3212
- }), n = t ? s.map((r) => He(r, t)) : s;
3247
+ }), n = t ? s.map((r) => We(r, t)) : s;
3213
3248
  return n.length > 0 ? n : void 0;
3214
3249
  }
3215
- function He(e, t) {
3250
+ function We(e, t) {
3216
3251
  return e.fileUrl?.startsWith("/") ? {
3217
3252
  ...e,
3218
3253
  fileUrl: new URL(e.fileUrl, t).toString()
3219
3254
  } : e;
3220
3255
  }
3221
3256
  function Ae(e) {
3222
- return e.type || wr(e.name) || "application/octet-stream";
3257
+ return e.type || Rr(e.name) || "application/octet-stream";
3223
3258
  }
3224
- function wr(e) {
3259
+ function Rr(e) {
3225
3260
  const t = e.toLowerCase();
3226
3261
  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;
3227
3262
  }
3228
- function Sr(e) {
3263
+ function br(e) {
3229
3264
  if (!e || typeof e != "object")
3230
3265
  return null;
3231
3266
  const t = e;
@@ -3237,18 +3272,19 @@ function Sr(e) {
3237
3272
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
3238
3273
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
3239
3274
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
3275
+ scheduledCheckInAt: typeof t.scheduledCheckInAt == "string" ? t.scheduledCheckInAt : void 0,
3240
3276
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
3241
- attachments: Fe(t.attachments)?.map(Gt),
3277
+ attachments: He(t.attachments)?.map(Xt),
3242
3278
  loading: typeof t.loading == "boolean" ? t.loading : void 0
3243
3279
  };
3244
3280
  }
3245
- function Ar(e) {
3281
+ function Mr(e) {
3246
3282
  return e.attachments?.length ? {
3247
3283
  ...e,
3248
- attachments: e.attachments.map(Gt)
3284
+ attachments: e.attachments.map(Xt)
3249
3285
  } : e;
3250
3286
  }
3251
- function Gt(e) {
3287
+ function Xt(e) {
3252
3288
  const {
3253
3289
  dataUrl: t,
3254
3290
  objectUrl: s,
@@ -3257,47 +3293,47 @@ function Gt(e) {
3257
3293
  } = e;
3258
3294
  return r;
3259
3295
  }
3260
- function v(e) {
3296
+ function O(e) {
3261
3297
  const t = e.respondsToUserMessageId;
3262
3298
  return typeof t == "string" && t ? t : null;
3263
3299
  }
3264
- function C(e) {
3300
+ function k(e) {
3265
3301
  const t = e.runId;
3266
3302
  return typeof t == "string" && t ? t : null;
3267
3303
  }
3268
- function br(e) {
3304
+ function kr(e) {
3269
3305
  const t = e?.timeoutMs;
3270
- 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 <= Gs);
3306
+ 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 <= Ys);
3271
3307
  }
3272
- function We(e) {
3308
+ function $e(e) {
3273
3309
  const t = {};
3274
3310
  try {
3275
3311
  new Headers(e).forEach((s, n) => {
3276
- Object.keys(t).length < $t && (t[n] = Xt(n, s));
3312
+ Object.keys(t).length < jt && (t[n] = Jt(n, s));
3277
3313
  });
3278
3314
  } catch {
3279
3315
  return {};
3280
3316
  }
3281
3317
  return t;
3282
3318
  }
3283
- function Xt(e, t) {
3284
- return Xe(e) ? ut : P(it(t), xs);
3319
+ function Jt(e, t) {
3320
+ return Je(e) ? ut : U(it(t), Fs);
3285
3321
  }
3286
- function Er(e, t) {
3322
+ function _r(e, t) {
3287
3323
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
3288
3324
  }
3289
- async function Rr(e, t, s, n) {
3290
- const r = We(e.headers);
3325
+ async function Cr(e, t, s, n) {
3326
+ const r = $e(e.headers);
3291
3327
  n({
3292
3328
  ...t,
3293
3329
  responseStatus: e.status,
3294
3330
  responseHeaders: r,
3295
- responseBody: await kr(e),
3331
+ responseBody: await Ur(e),
3296
3332
  durationMs: Date.now() - s
3297
3333
  });
3298
3334
  }
3299
- async function kr(e) {
3300
- if (!$e(e.headers))
3335
+ async function Ur(e) {
3336
+ if (!je(e.headers))
3301
3337
  return;
3302
3338
  let t = null, s = null;
3303
3339
  try {
@@ -3306,7 +3342,7 @@ async function kr(e) {
3306
3342
  const n = new Promise((a) => {
3307
3343
  s = window.setTimeout(() => {
3308
3344
  t?.cancel(), a("timeout");
3309
- }, Ls);
3345
+ }, Hs);
3310
3346
  }), r = new TextDecoder();
3311
3347
  let i = "", o = 0;
3312
3348
  for (; ; ) {
@@ -3315,10 +3351,10 @@ async function kr(e) {
3315
3351
  return;
3316
3352
  const { done: c, value: l } = a;
3317
3353
  if (c)
3318
- return P(i + r.decode());
3319
- const h = Wt - o;
3354
+ return U(i + r.decode());
3355
+ const h = $t - o;
3320
3356
  if (l.byteLength > h)
3321
- return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${P(i)}... [truncated]`;
3357
+ return i += r.decode(l.subarray(0, Math.max(h, 0)), { stream: !0 }), t.cancel(), `${U(i)}... [truncated]`;
3322
3358
  o += l.byteLength, i += r.decode(l, { stream: !0 });
3323
3359
  }
3324
3360
  } catch {
@@ -3328,45 +3364,45 @@ async function kr(e) {
3328
3364
  s !== null && window.clearTimeout(s);
3329
3365
  }
3330
3366
  }
3331
- function Mr(e, t) {
3332
- if ($e(new Headers(t)))
3367
+ function Pr(e, t) {
3368
+ if (je(new Headers(t)))
3333
3369
  try {
3334
- return e.responseType === "" || e.responseType === "text" ? P(e.responseText ?? "") : void 0;
3370
+ return e.responseType === "" || e.responseType === "text" ? U(e.responseText ?? "") : void 0;
3335
3371
  } catch {
3336
3372
  return;
3337
3373
  }
3338
3374
  }
3339
- function be(e) {
3375
+ function Ee(e) {
3340
3376
  if (typeof e == "string")
3341
- return P(e);
3377
+ return U(e);
3342
3378
  }
3343
- function _r(e) {
3344
- return M({
3379
+ function Dr(e) {
3380
+ return _({
3345
3381
  ...e,
3346
- requestBody: Ee(e.requestBody),
3347
- responseBody: Ee(e.responseBody)
3382
+ requestBody: Re(e.requestBody),
3383
+ responseBody: Re(e.responseBody)
3348
3384
  });
3349
3385
  }
3350
- function Ee(e) {
3386
+ function Re(e) {
3351
3387
  if (typeof e != "string")
3352
3388
  return e;
3353
3389
  const t = e.trim();
3354
3390
  if (!t.startsWith("{") && !t.startsWith("["))
3355
3391
  return it(e);
3356
3392
  try {
3357
- return JSON.stringify(M(JSON.parse(e)));
3393
+ return JSON.stringify(_(JSON.parse(e)));
3358
3394
  } catch {
3359
3395
  return it(e);
3360
3396
  }
3361
3397
  }
3362
- function $e(e) {
3398
+ function je(e) {
3363
3399
  if (!e)
3364
3400
  return !1;
3365
3401
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
3366
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Wt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3402
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= $t && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3367
3403
  }
3368
3404
  function x(e, t = {}, s) {
3369
- if (Pr(s))
3405
+ if (Or(s))
3370
3406
  return !0;
3371
3407
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3372
3408
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3381,7 +3417,7 @@ function x(e, t = {}, s) {
3381
3417
  return !0;
3382
3418
  }
3383
3419
  }
3384
- function Cr(e, t) {
3420
+ function vr(e, t) {
3385
3421
  if (x(e))
3386
3422
  return !0;
3387
3423
  try {
@@ -3391,26 +3427,26 @@ function Cr(e, t) {
3391
3427
  return !0;
3392
3428
  }
3393
3429
  }
3394
- function Pr(e) {
3430
+ function Or(e) {
3395
3431
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
3396
3432
  }
3397
- function Ur(e) {
3433
+ function Nr(e) {
3398
3434
  const t = {};
3399
3435
  for (const s of e.trim().split(/[\r\n]+/)) {
3400
3436
  const n = s.indexOf(":");
3401
3437
  if (n <= 0)
3402
3438
  continue;
3403
- if (Object.keys(t).length >= $t)
3439
+ if (Object.keys(t).length >= jt)
3404
3440
  break;
3405
3441
  const r = s.slice(0, n).trim();
3406
- t[r] = Xt(r, s.slice(n + 1).trim());
3442
+ t[r] = Jt(r, s.slice(n + 1).trim());
3407
3443
  }
3408
3444
  return t;
3409
3445
  }
3410
- function P(e, t = Wt) {
3446
+ function U(e, t = $t) {
3411
3447
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
3412
3448
  }
3413
- function Ct(e) {
3449
+ function Ut(e) {
3414
3450
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3415
3451
  }
3416
3452
  class nt extends Error {
@@ -3421,32 +3457,32 @@ class nt extends Error {
3421
3457
  }
3422
3458
  async function tt(e, t) {
3423
3459
  let s = null;
3424
- for (let n = 0; n < ue; n += 1)
3460
+ for (let n = 0; n < de; n += 1)
3425
3461
  try {
3426
3462
  return await e();
3427
3463
  } catch (r) {
3428
- if (s = r, n >= ue - 1 || !Or(r))
3464
+ if (s = r, n >= de - 1 || !Lr(r))
3429
3465
  throw r;
3430
- await Dr(n);
3466
+ await xr(n);
3431
3467
  }
3432
3468
  throw s instanceof Error ? s : new Error(t);
3433
3469
  }
3434
- function Dr(e) {
3470
+ function xr(e) {
3435
3471
  return new Promise((t) => {
3436
- window.setTimeout(t, vs[e] ?? 0);
3472
+ window.setTimeout(t, Bs[e] ?? 0);
3437
3473
  });
3438
3474
  }
3439
- function Or(e) {
3440
- return e instanceof nt ? Nr(e.status) : e instanceof TypeError;
3475
+ function Lr(e) {
3476
+ return e instanceof nt ? qr(e.status) : e instanceof TypeError;
3441
3477
  }
3442
- function Nr(e) {
3478
+ function qr(e) {
3443
3479
  return e === 408 || e === 409 || e === 429 || e >= 500;
3444
3480
  }
3445
- function vr(e) {
3481
+ function Br(e) {
3446
3482
  return e === 401 || e === 403;
3447
3483
  }
3448
- const ut = "[REDACTED_SECRET]", U = "[REDACTED_TOKEN]", xr = "[REDACTED_SIGNED_URL]", Lr = 20, qr = /^(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, je = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ze = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ke = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ge = /\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, Br = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Fr = /\bhttps?:\/\/[^\s"'<>]+/gi, Hr = /[),.;\]]+$/;
3449
- function M(e) {
3484
+ const ut = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Fr = "[REDACTED_SIGNED_URL]", Hr = 20, Wr = /^(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, ze = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ke = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ge = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Xe = /\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, $r = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, jr = /\bhttps?:\/\/[^\s"'<>]+/gi, zr = /[),.;\]]+$/;
3485
+ function _(e) {
3450
3486
  return rt(e, 0, /* @__PURE__ */ new WeakSet());
3451
3487
  }
3452
3488
  function rt(e, t, s) {
@@ -3454,7 +3490,7 @@ function rt(e, t, s) {
3454
3490
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : it(e);
3455
3491
  if (e === null || typeof e != "object")
3456
3492
  return e;
3457
- if (t >= Lr)
3493
+ if (t >= Hr)
3458
3494
  return "[REDACTED_MAX_DEPTH]";
3459
3495
  if (s.has(e))
3460
3496
  return "[REDACTED_CIRCULAR]";
@@ -3462,44 +3498,44 @@ function rt(e, t, s) {
3462
3498
  return e.map((r) => rt(r, t + 1, s));
3463
3499
  const n = {};
3464
3500
  for (const [r, i] of Object.entries(e))
3465
- r === "pageContent" ? n[r] = i : Xe(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Wr(i) : rt(i, t + 1, s);
3501
+ r === "pageContent" ? n[r] = i : Je(r) ? n[r] = ut : n[r] = r.toLowerCase() === "url" ? Kr(i) : rt(i, t + 1, s);
3466
3502
  return n;
3467
3503
  }
3468
- function Xe(e) {
3504
+ function Je(e) {
3469
3505
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
3470
3506
  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");
3471
3507
  }
3472
- function Wr(e) {
3473
- return typeof e == "string" ? Je(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3508
+ function Kr(e) {
3509
+ return typeof e == "string" ? Ve(e) : rt(e, 0, /* @__PURE__ */ new WeakSet());
3474
3510
  }
3475
- function Je(e) {
3511
+ function Ve(e) {
3476
3512
  try {
3477
3513
  const t = new URL(e, location.href);
3478
3514
  for (const s of Array.from(t.searchParams.keys()))
3479
- qr.test(s) && t.searchParams.set(s, U);
3480
- return t.username && (t.username = U), t.password && (t.password = U), t.toString();
3515
+ Wr.test(s) && t.searchParams.set(s, P);
3516
+ return t.username && (t.username = P), t.password && (t.password = P), t.toString();
3481
3517
  } catch {
3482
- return $r(e);
3518
+ return Gr(e);
3483
3519
  }
3484
3520
  }
3485
3521
  function it(e) {
3486
- return e.replace(Br, xr).replace(Fr, jr).replace(je, `Bearer ${U}`).replace(ze, `Basic ${U}`).replace(Ke, U).replace(Ge, (t, s) => `${s}: ${ut}`);
3522
+ return e.replace($r, Fr).replace(jr, Xr).replace(ze, `Bearer ${P}`).replace(Ke, `Basic ${P}`).replace(Ge, P).replace(Xe, (t, s) => `${s}: ${ut}`);
3487
3523
  }
3488
- function $r(e) {
3489
- return e.replace(je, `Bearer ${U}`).replace(ze, `Basic ${U}`).replace(Ke, U).replace(Ge, (t, s) => `${s}: ${ut}`);
3524
+ function Gr(e) {
3525
+ return e.replace(ze, `Bearer ${P}`).replace(Ke, `Basic ${P}`).replace(Ge, P).replace(Xe, (t, s) => `${s}: ${ut}`);
3490
3526
  }
3491
- function jr(e) {
3492
- const t = e.match(Hr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3493
- return `${Je(s)}${t}`;
3527
+ function Xr(e) {
3528
+ const t = e.match(zr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3529
+ return `${Ve(s)}${t}`;
3494
3530
  }
3495
3531
  export {
3496
- re as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3497
- Ut as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3498
- Ts as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3499
- Is as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3500
- ws as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3501
- Ce as PlunoProductAgent,
3502
- Fs as calculateReconnectDelay,
3503
- Ce as default,
3504
- dn as getProductAgentOriginAccessErrorMessage
3532
+ ie as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3533
+ Dt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3534
+ Ss as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3535
+ ws as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3536
+ As as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3537
+ Ue as PlunoProductAgent,
3538
+ js as calculateReconnectDelay,
3539
+ Ue as default,
3540
+ gn as getProductAgentOriginAccessErrorMessage
3505
3541
  };