@pluno/product-agent-web 0.1.107 → 0.1.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- const ue = "pluno-product-agent-attachments";
2
- const st = "files";
3
- async function Ft(e) {
4
- const t = await $();
5
- await Wt(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function de(e) {
8
- const t = await $(), s = await Wt(
1
+ const pe = "pluno-product-agent-attachments";
2
+ const rt = "files";
3
+ async function jt(e) {
4
+ const t = await G();
5
+ await zt(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function fe(e) {
8
+ const t = await G(), s = await zt(
9
9
  t,
10
10
  "readonly",
11
11
  (r) => r.get(e)
@@ -13,12 +13,12 @@ async function de(e) {
13
13
  if (!s)
14
14
  return null;
15
15
  const n = Date.now();
16
- return await Ht(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
16
+ return await $t(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
17
17
  }
18
- async function Ht(e, t) {
19
- const s = await $();
20
- await dt(s, "readwrite", async (n) => {
21
- const r = await ht(
18
+ async function $t(e, t) {
19
+ const s = await G();
20
+ await pt(s, "readwrite", async (n) => {
21
+ const r = await ft(
22
22
  n.get(e)
23
23
  );
24
24
  r && n.put({
@@ -27,28 +27,28 @@ async function Ht(e, t) {
27
27
  });
28
28
  });
29
29
  }
30
- async function he(e = 864e5) {
31
- const t = await $(), s = Date.now() - e;
32
- await dt(t, "readwrite", async (n) => {
30
+ async function ge(e = 864e5) {
31
+ const t = await G(), s = Date.now() - e;
32
+ await pt(t, "readwrite", async (n) => {
33
33
  const r = n.index("lastUsedAt");
34
- (await ht(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
34
+ (await ft(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
35
35
  });
36
36
  }
37
- function $() {
37
+ function G() {
38
38
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
39
- const s = indexedDB.open(ue, 1);
39
+ const s = indexedDB.open(pe, 1);
40
40
  s.onupgradeneeded = () => {
41
- const r = s.result.createObjectStore(st, { keyPath: "attachmentId" });
41
+ const r = s.result.createObjectStore(rt, { keyPath: "attachmentId" });
42
42
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
43
43
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
44
44
  });
45
45
  }
46
- async function Wt(e, t, s) {
47
- return await dt(e, t, async (n) => await ht(s(n)));
46
+ async function zt(e, t, s) {
47
+ return await pt(e, t, async (n) => await ft(s(n)));
48
48
  }
49
- function dt(e, t, s) {
49
+ function pt(e, t, s) {
50
50
  return new Promise((n, r) => {
51
- const i = e.transaction(st, t), o = i.objectStore(st);
51
+ const i = e.transaction(rt, t), o = i.objectStore(rt);
52
52
  let c, u = !1;
53
53
  s(o).then((l) => {
54
54
  c = l;
@@ -68,16 +68,16 @@ function dt(e, t, s) {
68
68
  };
69
69
  });
70
70
  }
71
- function ht(e) {
71
+ function ft(e) {
72
72
  return new Promise((t, s) => {
73
73
  e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
74
74
  });
75
75
  }
76
- function pe(e) {
76
+ function me(e) {
77
77
  return e !== null && (typeof e == "object" || typeof e == "function");
78
78
  }
79
- function jt(e, t, s) {
80
- const n = Reflect.get(e, "pluno"), r = pe(n) ? n : {};
79
+ function Gt(e, t, s) {
80
+ const n = Reflect.get(e, "pluno"), r = me(n) ? n : {};
81
81
  if (r !== n && !Reflect.set(e, "pluno", r))
82
82
  return null;
83
83
  const i = Object.getOwnPropertyDescriptor(r, t);
@@ -91,19 +91,19 @@ function jt(e, t, s) {
91
91
  }
92
92
  };
93
93
  }
94
- const H = "pluno.productAgent.scheduledChatContinuation.", nt = "pluno:scheduled-chat-continuation-changed", $t = 10080 * 6e4, fe = 5e3, ge = 15e3;
95
- function me(e, {
94
+ const j = "pluno.productAgent.scheduledChatContinuation.", it = "pluno:scheduled-chat-continuation-changed", Xt = 10080 * 6e4, ye = 5e3, Ie = 15e3;
95
+ function Te(e, {
96
96
  clientId: t,
97
97
  sessionId: s,
98
98
  callId: n
99
99
  }) {
100
100
  return `const plunoScheduledContinuation = Object.freeze(${JSON.stringify({
101
- storageKeyPrefix: H,
102
- changedEvent: nt,
101
+ storageKeyPrefix: j,
102
+ changedEvent: it,
103
103
  clientId: t,
104
104
  sessionId: s,
105
105
  defaultTaskId: `scheduled-${n}`,
106
- expiresAfterDueMs: $t
106
+ expiresAfterDueMs: Xt
107
107
  })});
108
108
  const scheduleQuery = (query, delaySeconds) => {
109
109
  if (typeof query !== "string" || query.trim().length === 0) {
@@ -132,15 +132,15 @@ const scheduleQuery = (query, delaySeconds) => {
132
132
  };
133
133
  ${e}`;
134
134
  }
135
- function ye(e) {
136
- const t = e.storage === void 0 ? Te() : e.storage;
135
+ function we(e) {
136
+ const t = e.storage === void 0 ? Ae() : e.storage;
137
137
  let s = null, n = !1, r = !1, i = !1, o = t !== null;
138
138
  const c = /* @__PURE__ */ new Map(), u = () => {
139
139
  s !== null && (clearTimeout(s), s = null);
140
140
  }, l = () => {
141
141
  u(), !(i || !o) && (s = setTimeout(() => {
142
142
  s = null, h();
143
- }, fe));
143
+ }, ye));
144
144
  }, a = () => {
145
145
  o = !1, u();
146
146
  }, h = async () => {
@@ -154,9 +154,9 @@ function ye(e) {
154
154
  const f = Date.now();
155
155
  for (const [g, A] of c)
156
156
  A <= f && c.delete(g);
157
- const w = await t.list(), m = [];
158
- for (const g of w) {
159
- if (!D(g)) {
157
+ const T = await t.list(), m = [];
158
+ for (const g of T) {
159
+ if (!N(g)) {
160
160
  const A = g && typeof g == "object" ? g.id : null;
161
161
  typeof A == "string" && await t.remove(A);
162
162
  continue;
@@ -170,7 +170,7 @@ function ye(e) {
170
170
  e.onTasksChanged?.(m);
171
171
  for (const g of m)
172
172
  if (!(g.clientId !== e.clientId || g.dueAt > f || c.has(g.id) || !await e.canDeliver(g))) {
173
- c.set(g.id, f + ge);
173
+ c.set(g.id, f + Ie);
174
174
  try {
175
175
  await e.deliver(g);
176
176
  } catch {
@@ -183,11 +183,11 @@ function ye(e) {
183
183
  n = !1, r ? (r = !1, h()) : l();
184
184
  }
185
185
  }
186
- }, T = async (f) => {
187
- if (i || !o || !t || !D(f))
186
+ }, I = async (f) => {
187
+ if (i || !o || !t || !N(f))
188
188
  return !1;
189
189
  try {
190
- return await t.set(f), e.onTasksChanged?.((await t.list()).filter(D)), await h(), !0;
190
+ return await t.set(f), e.onTasksChanged?.((await t.list()).filter(N)), await h(), !0;
191
191
  } catch {
192
192
  return a(), !1;
193
193
  }
@@ -195,7 +195,7 @@ function ye(e) {
195
195
  if (c.delete(f), i || !o || !t)
196
196
  return !1;
197
197
  try {
198
- return await t.remove(f), e.onTasksChanged?.((await t.list()).filter(D)), !0;
198
+ return await t.remove(f), e.onTasksChanged?.((await t.list()).filter(N)), !0;
199
199
  } catch {
200
200
  return a(), !1;
201
201
  }
@@ -204,7 +204,7 @@ function ye(e) {
204
204
  }) ?? null;
205
205
  return o && h(), {
206
206
  processDueTasks: h,
207
- scheduleTask: T,
207
+ scheduleTask: I,
208
208
  acknowledgeTask: p,
209
209
  isAvailable: () => o,
210
210
  destroy() {
@@ -212,13 +212,13 @@ function ye(e) {
212
212
  }
213
213
  };
214
214
  }
215
- function D(e) {
215
+ function N(e) {
216
216
  if (!e || typeof e != "object")
217
217
  return !1;
218
218
  const t = e;
219
- return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + $t;
219
+ return typeof t.id == "string" && t.id.length > 0 && typeof t.clientId == "string" && t.clientId.length > 0 && typeof t.sessionId == "string" && t.sessionId.length > 0 && typeof t.prompt == "string" && t.prompt.trim().length > 0 && typeof t.dueAt == "number" && Number.isFinite(t.dueAt) && typeof t.expiresAt == "number" && Number.isFinite(t.expiresAt) && t.expiresAt === t.dueAt + Xt;
220
220
  }
221
- function Te() {
221
+ function Ae() {
222
222
  let e;
223
223
  try {
224
224
  e = window.localStorage, e.length;
@@ -230,13 +230,13 @@ function Te() {
230
230
  const t = [];
231
231
  for (let s = 0; s < e.length; s += 1) {
232
232
  const n = e.key(s);
233
- if (!n?.startsWith(H))
233
+ if (!n?.startsWith(j))
234
234
  continue;
235
235
  const r = e.getItem(n);
236
236
  if (r)
237
237
  try {
238
238
  const i = JSON.parse(r);
239
- D(i) && n === J(i.id) ? t.push(i) : (e.removeItem(n), s -= 1);
239
+ N(i) && n === V(i.id) ? t.push(i) : (e.removeItem(n), s -= 1);
240
240
  } catch {
241
241
  e.removeItem(n), s -= 1;
242
242
  }
@@ -244,29 +244,29 @@ function Te() {
244
244
  return t;
245
245
  },
246
246
  async set(t) {
247
- e.setItem(J(t.id), JSON.stringify(t));
247
+ e.setItem(V(t.id), JSON.stringify(t));
248
248
  },
249
249
  async remove(t) {
250
- e.removeItem(J(t));
250
+ e.removeItem(V(t));
251
251
  },
252
252
  subscribe(t) {
253
253
  const s = (r) => {
254
- r.key?.startsWith(H) && t();
254
+ r.key?.startsWith(j) && t();
255
255
  }, n = () => t();
256
- return window.addEventListener("storage", s), window.addEventListener(nt, n), () => {
257
- window.removeEventListener("storage", s), window.removeEventListener(nt, n);
256
+ return window.addEventListener("storage", s), window.addEventListener(it, n), () => {
257
+ window.removeEventListener("storage", s), window.removeEventListener(it, n);
258
258
  };
259
259
  }
260
260
  };
261
261
  }
262
- function J(e) {
263
- return `${H}${e}`;
262
+ function V(e) {
263
+ return `${j}${e}`;
264
264
  }
265
- const Y = "pluno.productAgent.transportId", we = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", Ie = 50, Ae = globalThis.setTimeout.bind(globalThis);
266
- let U = null;
267
- const q = /* @__PURE__ */ new Set();
268
- async function Se(e = zt()) {
269
- const t = e.randomUUID(), s = e.storage.getItem(Y);
265
+ const Z = "pluno.productAgent.transportId", Se = "pluno.productAgent.transportIdentity", Q = "pluno.productAgent.transportIdentity.event", ke = 50, Ee = globalThis.setTimeout.bind(globalThis);
266
+ let P = null;
267
+ const F = /* @__PURE__ */ new Set();
268
+ async function _e(e = Kt()) {
269
+ const t = e.randomUUID(), s = e.storage.getItem(Z);
270
270
  let n = s ?? e.randomUUID(), r = !1, i = !1;
271
271
  const o = e.channel.subscribe((u) => {
272
272
  if (!(u.senderId === t || u.transportId !== n)) {
@@ -284,14 +284,14 @@ async function Se(e = zt()) {
284
284
  }
285
285
  });
286
286
  if (!s)
287
- e.storage.setItem(Y, n), r = !0;
287
+ e.storage.setItem(Z, n), r = !0;
288
288
  else
289
289
  for (; ; ) {
290
290
  if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
291
291
  r = !0;
292
292
  break;
293
293
  }
294
- n = e.randomUUID(), e.storage.setItem(Y, n);
294
+ n = e.randomUUID(), e.storage.setItem(Z, n);
295
295
  }
296
296
  let c = !1;
297
297
  return {
@@ -301,41 +301,41 @@ async function Se(e = zt()) {
301
301
  }
302
302
  };
303
303
  }
304
- async function ke() {
305
- U || (U = Se(zt()), U.then((n) => {
304
+ async function Re() {
305
+ P || (P = _e(Kt()), P.then((n) => {
306
306
  const r = (i) => {
307
- i.persisted || (n.release(), U = null, q.clear(), window.removeEventListener("pagehide", r));
307
+ i.persisted || (n.release(), P = null, F.clear(), window.removeEventListener("pagehide", r));
308
308
  };
309
309
  window.addEventListener("pagehide", r);
310
310
  }));
311
- const e = await U, t = Ee();
312
- q.add(t);
311
+ const e = await P, t = Ce();
312
+ F.add(t);
313
313
  let s = !1;
314
314
  return {
315
315
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
316
316
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
317
317
  release: () => {
318
- s || (s = !0, q.delete(t));
318
+ s || (s = !0, F.delete(t));
319
319
  }
320
320
  };
321
321
  }
322
- function Ee() {
322
+ function Ce() {
323
323
  let e = 0;
324
- for (; q.has(e); )
324
+ for (; F.has(e); )
325
325
  e += 1;
326
326
  return e;
327
327
  }
328
- function zt() {
328
+ function Kt() {
329
329
  return {
330
330
  storage: window.sessionStorage,
331
- channel: _e(),
331
+ channel: be(),
332
332
  randomUUID: () => crypto.randomUUID(),
333
- settle: () => new Promise((e) => Ae(e, Ie))
333
+ settle: () => new Promise((e) => Ee(e, ke))
334
334
  };
335
335
  }
336
- function _e() {
336
+ function be() {
337
337
  if (typeof BroadcastChannel < "u") {
338
- const e = new BroadcastChannel(we);
338
+ const e = new BroadcastChannel(Se);
339
339
  return {
340
340
  postMessage: (t) => e.postMessage(t),
341
341
  subscribe: (t) => {
@@ -345,11 +345,11 @@ function _e() {
345
345
  close: () => e.close()
346
346
  };
347
347
  }
348
- return Re();
348
+ return Me();
349
349
  }
350
- function Re() {
350
+ function Me() {
351
351
  const e = /* @__PURE__ */ new Set(), t = (s) => {
352
- if (s.key !== V || !s.newValue)
352
+ if (s.key !== Q || !s.newValue)
353
353
  return;
354
354
  const n = JSON.parse(s.newValue);
355
355
  for (const r of e)
@@ -358,9 +358,9 @@ function Re() {
358
358
  return window.addEventListener("storage", t), {
359
359
  postMessage: (s) => {
360
360
  window.localStorage.setItem(
361
- V,
361
+ Q,
362
362
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
363
- ), window.localStorage.removeItem(V);
363
+ ), window.localStorage.removeItem(Q);
364
364
  },
365
365
  subscribe: (s) => (e.add(s), () => e.delete(s)),
366
366
  close: () => {
@@ -368,18 +368,18 @@ function Re() {
368
368
  }
369
369
  };
370
370
  }
371
- const rt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ce = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', be = ".pluno-pa-widget__panel", Me = ".pluno-pa-widget__timeline", St = `${rt}[data-pluno-sdk-preview-channel]`, Ue = "https://app.pluno.ai", Pe = "gpt-5.6-terra", De = 2e4, ve = 1e4, Ne = 1e4, Oe = 1e4, Le = 1e4, Be = 1e3, kt = 3e4, Et = 0.2, _t = 6e4, qe = 15e3, N = 8, xe = 15e3, Fe = 2e3, He = 1e3, We = 100, je = 8e3, $e = 15e3, Rt = 3, ze = [300, 1e3], pt = 64e3, Z = 4e3, ft = 30, Ge = 2e3, Xe = 1e3, Ke = 200 * 1024 * 1024, gt = "Image is too large for model vision input.", Je = 100, Gt = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", Ye = 100;
372
- function O(e, t = 0) {
371
+ const ot = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ue = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Pe = ".pluno-pa-widget__panel", De = ".pluno-pa-widget__timeline", Et = `${ot}[data-pluno-sdk-preview-channel]`, Ne = "https://app.pluno.ai", Oe = "gpt-5.6-terra", ve = 2e4, Le = 1e4, Be = 1e4, qe = 1e4, xe = 1e4, Fe = 1e3, _t = 3e4, Rt = 0.2, Ct = 6e4, He = 15e3, L = 8, We = 15e3, je = 2e3, $e = 1e3, ze = 100, Ge = 8e3, Xe = 15e3, bt = 3, Ke = [300, 1e3], gt = 64e3, tt = 4e3, mt = 30, Je = 2e3, Ye = 1e3, Ve = 200 * 1024 * 1024, yt = "Image is too large for model vision input.", Ze = 100, Jt = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", X = "pluno.productAgent.activeToolCalls.", Qe = 100;
372
+ function B(e, t = 0) {
373
373
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
374
374
  return Math.max(t, s);
375
375
  }
376
- const x = /* @__PURE__ */ new Set();
377
- let L = null;
378
- function Ve(e, t = Math.random) {
379
- const s = Math.min(kt, Be * 2 ** e), n = 1 - Et + t() * Et * 2;
380
- return Math.min(kt, Math.round(s * n));
376
+ const H = /* @__PURE__ */ new Set();
377
+ let q = null;
378
+ function ts(e, t = Math.random) {
379
+ const s = Math.min(_t, Fe * 2 ** e), n = 1 - Rt + t() * Rt * 2;
380
+ return Math.min(_t, Math.round(s * n));
381
381
  }
382
- function Ze(e, t, s) {
382
+ function es(e, t, s) {
383
383
  return new Promise((n, r) => {
384
384
  const i = setTimeout(() => r(new Error(s)), t);
385
385
  e.then(
@@ -392,27 +392,29 @@ function Ze(e, t, s) {
392
392
  );
393
393
  });
394
394
  }
395
- class Xt {
395
+ class Yt {
396
396
  constructor(t, s) {
397
397
  this.options = t, this.transportIdentity = s, this.state = {
398
398
  ...this.state,
399
- starterPrompts: _s(t.initialStarterPrompts)
399
+ starterPrompts: bs(t.initialStarterPrompts)
400
400
  };
401
- const n = t.restorePersistedState === !1 ? null : rn(t.clientId, t.expectedPersistedSessionId);
401
+ const n = t.restorePersistedState === !1 ? null : ln(t.clientId, t.expectedPersistedSessionId);
402
402
  n && (this.state = {
403
403
  ...this.state,
404
404
  ...n,
405
405
  status: "idle",
406
406
  user: null,
407
407
  assistantDraft: "",
408
+ assistantDraftItemId: null,
409
+ assistantDraftPhase: null,
408
410
  assistantDraftRespondsToUserMessageId: null,
409
411
  assistantDraftRunId: null,
410
412
  isThinking: !1,
411
413
  lastError: null
412
- }), this.queuedClientEvents = hn(
413
- an(t.clientId),
414
- ln(t.clientId)
415
- ), P(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = ye({
414
+ }), this.queuedClientEvents = mn(
415
+ dn(t.clientId),
416
+ pn(t.clientId)
417
+ ), D(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = we({
416
418
  clientId: t.clientId,
417
419
  canDeliver: (r) => r.sessionId === this.state.sessionId,
418
420
  deliver: async (r) => {
@@ -477,6 +479,8 @@ class Xt {
477
479
  appearance: null,
478
480
  messages: [],
479
481
  assistantDraft: "",
482
+ assistantDraftItemId: null,
483
+ assistantDraftPhase: null,
480
484
  assistantDraftRespondsToUserMessageId: null,
481
485
  assistantDraftRunId: null,
482
486
  isThinking: !1,
@@ -485,14 +489,14 @@ class Xt {
485
489
  lastErrorSecuritySettingsUrl: null
486
490
  };
487
491
  static async init(t) {
488
- const s = await ke(), n = new Xt({
492
+ const s = await Re(), n = new Yt({
489
493
  ...t,
490
- backendUrl: ms(t.backendUrl ?? Ue),
491
- clientId: t.clientId ?? Us(),
492
- model: t.model ?? Pe
494
+ backendUrl: Ts(t.backendUrl ?? Ne),
495
+ clientId: t.clientId ?? Ns(),
496
+ model: t.model ?? Oe
493
497
  }, s);
494
498
  try {
495
- he().catch((r) => {
499
+ ge().catch((r) => {
496
500
  y("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
497
501
  message: r instanceof Error ? r.message : String(r)
498
502
  });
@@ -524,14 +528,14 @@ class Xt {
524
528
  lastError: null
525
529
  });
526
530
  try {
527
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ze(this.options.tokenProvider(), Ne, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
531
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await es(this.options.tokenProvider(), Be, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
528
532
  return;
529
533
  if (!this.token && !this.options.webSocketFactory)
530
534
  throw new Error("Pluno requires a token or tokenProvider");
531
- const s = Ts(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
535
+ const s = As(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
532
536
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
533
537
  this.socket === n && n.readyState === WebSocket.CONNECTING && (y("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
534
- }, Oe), n.addEventListener("open", () => {
538
+ }, qe), n.addEventListener("open", () => {
535
539
  this.socket !== n || (this.clearSocketConnectTimer(), y("web-sdk.agent", "Pluno socket opened", {
536
540
  queuedClientEventCount: this.queuedClientEvents.length,
537
541
  isThinking: this.state.isThinking
@@ -543,9 +547,9 @@ class Xt {
543
547
  pageUrl: location.href
544
548
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
545
549
  this.socket === n && (y("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
546
- }, Le));
550
+ }, xe));
547
551
  }), n.addEventListener("message", (r) => {
548
- this.socket === n && this.handleServerEvent(Es(r.data));
552
+ this.socket === n && this.handleServerEvent(Cs(r.data));
549
553
  }), n.addEventListener("close", (r) => {
550
554
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (y("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
551
555
  code: typeof r?.code == "number" ? r.code : null,
@@ -578,15 +582,15 @@ class Xt {
578
582
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
579
583
  }
580
584
  destroy() {
581
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), pn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
585
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), yn(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
582
586
  for (const t of Object.values(this.listeners))
583
587
  t?.clear();
584
588
  }
585
589
  sendMessage(t, s = {}) {
586
- const n = t.trim(), r = s.attachments ?? [], i = r.map(It);
590
+ const n = t.trim(), r = s.attachments ?? [], i = r.map(St);
587
591
  if (!n && i.length === 0)
588
592
  return null;
589
- const o = S(), c = s.clientMessageId ?? B();
593
+ const o = S(), c = s.clientMessageId ?? x();
590
594
  this.retryableClientMessageId = null;
591
595
  const u = {
592
596
  id: `local-${c}`,
@@ -599,6 +603,8 @@ class Xt {
599
603
  messages: l ? this.state.messages : [...this.state.messages, u],
600
604
  ...this.state.isThinking ? {} : {
601
605
  assistantDraft: "",
606
+ assistantDraftItemId: null,
607
+ assistantDraftPhase: null,
602
608
  assistantDraftRespondsToUserMessageId: null,
603
609
  assistantDraftRunId: null
604
610
  },
@@ -614,7 +620,7 @@ class Xt {
614
620
  attachments: i.length > 0 ? i : void 0,
615
621
  page: o,
616
622
  model: this.options.model,
617
- metadata: Ct(this.options.metadata)
623
+ metadata: Mt(this.options.metadata)
618
624
  };
619
625
  return this.activeClientMessageId = c, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(c, i), c;
620
626
  }
@@ -623,15 +629,15 @@ class Xt {
623
629
  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);
624
630
  }
625
631
  createLocalAttachment(t) {
626
- const s = B(), n = {
632
+ const s = x(), n = {
627
633
  id: s,
628
634
  name: t.name || "attachment",
629
- mimeType: Bt(t),
635
+ mimeType: Ft(t),
630
636
  sizeBytes: t.size
631
637
  };
632
638
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
633
639
  const r = Date.now();
634
- return Ft({
640
+ return jt({
635
641
  attachmentId: s,
636
642
  name: n.name,
637
643
  mimeType: n.mimeType,
@@ -654,7 +660,7 @@ class Xt {
654
660
  return await this.uploadAttachmentForMessage({
655
661
  file: t,
656
662
  attachment: s,
657
- clientMessageId: B(),
663
+ clientMessageId: x(),
658
664
  waitForSession: !1,
659
665
  notifyCompletion: !1
660
666
  });
@@ -686,7 +692,7 @@ class Xt {
686
692
  waitForSession: r,
687
693
  notifyCompletion: i
688
694
  }) {
689
- const o = r ? await this.waitForSessionId() : this.state.sessionId, c = Bt(t), u = {
695
+ const o = r ? await this.waitForSessionId() : this.state.sessionId, c = Ft(t), u = {
690
696
  sessionId: o ?? void 0,
691
697
  attachmentId: s.id,
692
698
  clientId: this.options.clientId,
@@ -696,23 +702,23 @@ class Xt {
696
702
  sizeBytes: t.size,
697
703
  page: S(),
698
704
  model: this.options.model,
699
- metadata: Ct(this.options.metadata)
700
- }, l = this.options.prepareAttachmentUpload ? await et(
705
+ metadata: Mt(this.options.metadata)
706
+ }, l = this.options.prepareAttachmentUpload ? await nt(
701
707
  () => this.options.prepareAttachmentUpload(u),
702
708
  "Failed to prepare attachment upload"
703
709
  ) : await this.prepareEmbedAttachmentUpload(u);
704
- await et(async () => {
710
+ await nt(async () => {
705
711
  const h = await fetch(l.uploadUrl, {
706
712
  method: l.uploadMethod,
707
713
  headers: l.uploadHeaders,
708
714
  body: t
709
715
  });
710
716
  if (!h.ok)
711
- throw new F("Failed to upload attachment", h.status);
717
+ throw new W("Failed to upload attachment", h.status);
712
718
  return h;
713
719
  }, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
714
- const a = ee(l.attachment, this.options.backendUrl);
715
- return this.updateAttachmentInState(s.id, a), s.id && Ht(s.id, {
720
+ const a = re(l.attachment, this.options.backendUrl);
721
+ return this.updateAttachmentInState(s.id, a), s.id && $t(s.id, {
716
722
  sessionId: l.sessionId,
717
723
  fileUrl: a.fileUrl,
718
724
  gcsPath: a.gcsPath,
@@ -734,7 +740,7 @@ class Xt {
734
740
  return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
735
741
  const n = window.setTimeout(() => {
736
742
  r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
737
- }, $e), r = this.on("state", (i) => {
743
+ }, Xe), r = this.on("state", (i) => {
738
744
  i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
739
745
  });
740
746
  });
@@ -752,18 +758,18 @@ class Xt {
752
758
  }
753
759
  async prepareEmbedAttachmentUpload(t) {
754
760
  let s = !1;
755
- return await et(async () => {
761
+ return await nt(async () => {
756
762
  const n = await this.fetchEmbedAttachmentUpload(t);
757
763
  if (n.ok)
758
764
  return await n.json();
759
- if (Pn(n.status) && this.options.tokenProvider && !s) {
765
+ if (vn(n.status) && this.options.tokenProvider && !s) {
760
766
  s = !0;
761
767
  const r = await this.fetchEmbedAttachmentUpload(t);
762
768
  if (r.ok)
763
769
  return await r.json();
764
- throw new F("Failed to prepare attachment upload", r.status);
770
+ throw new W("Failed to prepare attachment upload", r.status);
765
771
  }
766
- throw new F("Failed to prepare attachment upload", n.status);
772
+ throw new W("Failed to prepare attachment upload", n.status);
767
773
  }, "Failed to prepare attachment upload");
768
774
  }
769
775
  async fetchEmbedAttachmentUpload(t) {
@@ -791,6 +797,8 @@ class Xt {
791
797
  starterPrompts: [...this.state.starterPrompts],
792
798
  messages: [],
793
799
  assistantDraft: "",
800
+ assistantDraftItemId: null,
801
+ assistantDraftPhase: null,
794
802
  assistantDraftRespondsToUserMessageId: null,
795
803
  assistantDraftRunId: null,
796
804
  isThinking: !1,
@@ -798,10 +806,10 @@ class Xt {
798
806
  });
799
807
  }
800
808
  listSessions(t = {}) {
801
- const s = B(), n = new Promise((i, o) => {
809
+ const s = x(), n = new Promise((i, o) => {
802
810
  const c = window.setTimeout(() => {
803
811
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
804
- }, je);
812
+ }, Ge);
805
813
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: c });
806
814
  }), r = {
807
815
  type: "sessions.list",
@@ -820,6 +828,8 @@ class Xt {
820
828
  !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.clearThinkingWatchdog(), this.setState({
821
829
  sessionId: t,
822
830
  assistantDraft: "",
831
+ assistantDraftItemId: null,
832
+ assistantDraftPhase: null,
823
833
  assistantDraftRespondsToUserMessageId: null,
824
834
  assistantDraftRunId: null,
825
835
  isThinking: !1,
@@ -832,7 +842,7 @@ class Xt {
832
842
  });
833
843
  }
834
844
  send(t) {
835
- this.sendNow(k(t)) || (this.queuedClientEvents.push(t), P(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
845
+ this.sendNow(k(t)) || (this.queuedClientEvents.push(t), D(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
836
846
  }
837
847
  async getUploadToken() {
838
848
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -858,7 +868,7 @@ class Xt {
858
868
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
859
869
  return;
860
870
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
861
- const t = ws();
871
+ const t = Ss();
862
872
  this.sendNow(
863
873
  k({
864
874
  type: "starter_prompts.page_context",
@@ -869,13 +879,13 @@ class Xt {
869
879
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
870
880
  }
871
881
  startStarterPromptUrlWatcher() {
872
- this.locationChangeCleanup || (this.locationChangeCleanup = Is(() => this.handleStarterPromptUrlChange()));
882
+ this.locationChangeCleanup || (this.locationChangeCleanup = ks(() => this.handleStarterPromptUrlChange()));
873
883
  }
874
884
  handleStarterPromptUrlChange() {
875
885
  const t = location.href;
876
886
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
877
887
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
878
- }, Ye));
888
+ }, Qe));
879
889
  }
880
890
  refreshStarterPromptsForCurrentUrl() {
881
891
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -890,14 +900,14 @@ class Xt {
890
900
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
891
901
  return;
892
902
  const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
893
- P(this.options.clientId, this.queuedClientEvents);
903
+ D(this.options.clientId, this.queuedClientEvents);
894
904
  for (let s = 0; s < t.length; s += 1) {
895
905
  const n = t[s];
896
906
  if (!this.sendNow(k(n))) {
897
- this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), P(this.options.clientId, this.queuedClientEvents);
907
+ this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), D(this.options.clientId, this.queuedClientEvents);
898
908
  return;
899
909
  }
900
- P(this.options.clientId, this.queuedClientEvents);
910
+ D(this.options.clientId, this.queuedClientEvents);
901
911
  }
902
912
  }
903
913
  handleServerEvent(t) {
@@ -909,19 +919,19 @@ class Xt {
909
919
  this.clearHeartbeatAckTimer();
910
920
  return;
911
921
  }
912
- if (es(t) && this.markThinkingProgress(), t.type === "auth.ok") {
922
+ if (rs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
913
923
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
914
- const s = Rs(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
924
+ const s = Ms(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
915
925
  y("web-sdk.agent", "Received auth.ok appearance", {
916
926
  hasAppearance: n,
917
927
  rawAppearance: t.appearance,
918
928
  normalizedAppearance: s
919
- }), this.runtimeHelperJavascript = Cs(t.runtimeHelpers)?.javascript ?? null;
920
- const r = Mt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
921
- user: Ps(t.user),
929
+ }), this.runtimeHelperJavascript = Us(t.runtimeHelpers)?.javascript ?? null;
930
+ const r = Pt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
931
+ user: Os(t.user),
922
932
  status: "connected"
923
933
  };
924
- (i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !Ss() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
934
+ (i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !_s() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
925
935
  type: "page.upsert",
926
936
  sessionId: this.state.sessionId,
927
937
  page: S(),
@@ -931,7 +941,7 @@ class Xt {
931
941
  }
932
942
  if (t.type === "starterPrompts.updated") {
933
943
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
934
- starterPrompts: Mt(t, "starterPrompts"),
944
+ starterPrompts: Pt(t, "starterPrompts"),
935
945
  starterPromptsLoading: !1
936
946
  });
937
947
  return;
@@ -939,47 +949,50 @@ class Xt {
939
949
  if (t.type === "conversation.state") {
940
950
  const s = Array.isArray(t.items) ? t.items : [];
941
951
  this.rememberUserMessageClientMessageIds(s);
942
- const n = Ks(s);
952
+ const n = Zs(s);
943
953
  if (n) {
944
- const a = Js(s, n);
954
+ const a = Qs(s, n);
945
955
  this.retryAttemptsByClientMessageId[n] = Math.max(
946
956
  this.retryAttemptsByClientMessageId[n] ?? 0,
947
957
  a
948
958
  );
949
959
  }
950
960
  const r = s.filter((a) => {
951
- const h = v(a);
952
- return !vt(h) && (!n || !at(h));
953
- }), i = Hs(
961
+ const h = O(a);
962
+ return !Lt(h) && (!n || !lt(h));
963
+ }), i = zs(
954
964
  this.state.messages,
955
- Ds(r, this.options.backendUrl)
956
- ), o = Dt(i), c = s.some(
957
- (a) => Ot(
958
- v(a),
965
+ vs(r, this.options.backendUrl)
966
+ ), o = vt(i), c = s.some(
967
+ (a) => qt(
968
+ O(a),
959
969
  this.state.assistantDraft,
970
+ this.state.assistantDraftItemId,
960
971
  this.state.assistantDraftRespondsToUserMessageId,
961
972
  this.state.assistantDraftRunId
962
973
  )
963
974
  ), u = o && (!this.state.assistantDraft || c);
964
- if (!o && Xs(this.state.messages, s))
975
+ if (!o && Vs(this.state.messages, s))
965
976
  return;
966
- const l = u ? null : ct(s);
967
- if (this.latestRecoverableClientMessageId = l, zs(i) && this.clearRetryTimers(), this.setState({
968
- sessionId: I(t.session, "id") ?? this.state.sessionId,
977
+ const l = u ? null : ut(s);
978
+ if (this.latestRecoverableClientMessageId = l, Js(i) && this.clearRetryTimers(), this.setState({
979
+ sessionId: w(t.session, "id") ?? this.state.sessionId,
969
980
  messages: i,
981
+ ...c ? {
982
+ assistantDraft: "",
983
+ assistantDraftItemId: null,
984
+ assistantDraftPhase: null,
985
+ assistantDraftRespondsToUserMessageId: null,
986
+ assistantDraftRunId: null
987
+ } : {},
970
988
  ...u ? {
971
- ...c ? {
972
- assistantDraft: "",
973
- assistantDraftRespondsToUserMessageId: null,
974
- assistantDraftRunId: null
975
- } : {},
976
989
  isThinking: !1
977
990
  } : l ? {
978
991
  isThinking: !0,
979
992
  lastError: null
980
993
  } : {}
981
994
  }), u ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : l && (this.activeClientMessageId = l, this.markThinkingProgress()), n) {
982
- const a = I(t.session, "id") ?? this.state.sessionId;
995
+ const a = w(t.session, "id") ?? this.state.sessionId;
983
996
  a && this.retryAfterInterruptedRun(a, n);
984
997
  }
985
998
  return;
@@ -987,21 +1000,21 @@ class Xt {
987
1000
  if (t.type === "sessions.page") {
988
1001
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
989
1002
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
990
- sessions: vs(t.sessions),
1003
+ sessions: Ls(t.sessions),
991
1004
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
992
1005
  }));
993
1006
  return;
994
1007
  }
995
1008
  if (t.type === "session.updated") {
996
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: I(t.session, "id") ?? this.state.sessionId });
1009
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: w(t.session, "id") ?? this.state.sessionId });
997
1010
  return;
998
1011
  }
999
1012
  if (t.type === "session.item") {
1000
1013
  this.rememberUserMessageClientMessageIds([t.item]);
1001
- const s = v(t.item);
1002
- if (at(s)) {
1014
+ const s = O(t.item);
1015
+ if (lt(s)) {
1003
1016
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1004
- const r = I(t.item, "sessionId") ?? this.state.sessionId, i = s ? C(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, c = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1017
+ const r = w(t.item, "sessionId") ?? this.state.sessionId, i = s ? C(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, c = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1005
1018
  if (r && c) {
1006
1019
  this.retryAfterInterruptedRun(r, c);
1007
1020
  return;
@@ -1011,31 +1024,41 @@ class Xt {
1011
1024
  return;
1012
1025
  }
1013
1026
  }
1014
- if (vt(s))
1027
+ if (Lt(s))
1015
1028
  return;
1016
- const n = Jt(t.item, this.options.backendUrl);
1029
+ const n = Zt(t.item, this.options.backendUrl);
1017
1030
  if (n) {
1018
- n.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1031
+ v(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1019
1032
  const r = t.item.data;
1020
- Vs(r) && this.clearRunAckResyncRetryTimer();
1021
- const i = Fs(this.state.messages, n), o = Dt(i), c = Ot(
1033
+ en(r) && this.clearRunAckResyncRetryTimer();
1034
+ const i = Nt(this.state.messages, n), o = vt(i), c = qt(
1022
1035
  r,
1023
1036
  this.state.assistantDraft,
1037
+ this.state.assistantDraftItemId,
1024
1038
  this.state.assistantDraftRespondsToUserMessageId,
1025
1039
  this.state.assistantDraftRunId
1026
1040
  ), u = o && (!this.state.assistantDraft || c);
1027
1041
  this.setState({
1028
1042
  messages: i,
1029
- ...c ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : u ? { isThinking: !1 } : {}
1043
+ ...c ? {
1044
+ assistantDraft: "",
1045
+ assistantDraftItemId: null,
1046
+ assistantDraftPhase: null,
1047
+ assistantDraftRespondsToUserMessageId: null,
1048
+ assistantDraftRunId: null
1049
+ } : {},
1050
+ ...u ? { isThinking: !1 } : {}
1030
1051
  }), u && this.clearThinkingWatchdog(), this.emit("message", n);
1031
1052
  }
1032
1053
  return;
1033
1054
  }
1034
1055
  if (t.type === "chat.assistant_delta") {
1035
1056
  this.clearRunAckResyncRetryTimer();
1036
- const s = typeof t.delta == "string" ? t.delta : "";
1057
+ const s = typeof t.delta == "string" ? t.delta : "", n = typeof t.itemId == "string" ? t.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n;
1037
1058
  this.setState({
1038
- assistantDraft: `${this.state.assistantDraft}${s}`,
1059
+ assistantDraft: `${r ? "" : this.state.assistantDraft}${s}`,
1060
+ assistantDraftItemId: n ?? this.state.assistantDraftItemId,
1061
+ assistantDraftPhase: t.phase === "commentary" || t.phase === "final_answer" ? t.phase : r ? null : this.state.assistantDraftPhase,
1039
1062
  assistantDraftRespondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId,
1040
1063
  assistantDraftRunId: typeof t.runId == "string" ? t.runId : this.state.assistantDraftRunId,
1041
1064
  isThinking: !0
@@ -1050,6 +1073,8 @@ class Xt {
1050
1073
  this.setState({
1051
1074
  sessionId: s,
1052
1075
  assistantDraft: "",
1076
+ assistantDraftItemId: null,
1077
+ assistantDraftPhase: null,
1053
1078
  assistantDraftRespondsToUserMessageId: null,
1054
1079
  assistantDraftRunId: null,
1055
1080
  isThinking: !1
@@ -1057,7 +1082,12 @@ class Xt {
1057
1082
  return;
1058
1083
  }
1059
1084
  if (t.type === "tool.call") {
1060
- this.clearRunAckResyncRetryTimer(), this.executeToolCall(t);
1085
+ this.clearRunAckResyncRetryTimer();
1086
+ const s = js(t);
1087
+ s && (this.setState({
1088
+ messages: Nt(this.state.messages, s),
1089
+ isThinking: !0
1090
+ }), this.emit("message", s)), this.executeToolCall(t);
1061
1091
  return;
1062
1092
  }
1063
1093
  if (t.type === "error") {
@@ -1072,7 +1102,7 @@ class Xt {
1072
1102
  return;
1073
1103
  }
1074
1104
  o && r && i && (this.retryableClientMessageId = i);
1075
- const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = ys(c.message);
1105
+ const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = ws(c.message);
1076
1106
  u && console.error(u), this.setState({
1077
1107
  status: "error",
1078
1108
  isThinking: !1,
@@ -1098,10 +1128,10 @@ class Xt {
1098
1128
  if (this.retryTimersByClientMessageId[n] !== void 0)
1099
1129
  return !0;
1100
1130
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
1101
- if (i >= N)
1131
+ if (i >= L)
1102
1132
  return !1;
1103
1133
  this.retryAttemptsByClientMessageId[n] = i + 1;
1104
- const o = O(
1134
+ const o = B(
1105
1135
  i,
1106
1136
  typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
1107
1137
  );
@@ -1118,7 +1148,7 @@ class Xt {
1118
1148
  if (this.retryTimersByClientMessageId[s] !== void 0)
1119
1149
  return;
1120
1150
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
1121
- if (n >= N) {
1151
+ if (n >= L) {
1122
1152
  this.retryableClientMessageId = s, this.setState({
1123
1153
  isThinking: !1,
1124
1154
  lastError: "Pluno could not finish this message. Try it again.",
@@ -1128,7 +1158,7 @@ class Xt {
1128
1158
  }
1129
1159
  this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
1130
1160
  delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !0 });
1131
- }, O(n));
1161
+ }, B(n));
1132
1162
  }
1133
1163
  clearRetryTimers() {
1134
1164
  for (const t of Object.values(this.retryTimersByClientMessageId))
@@ -1137,7 +1167,7 @@ class Xt {
1137
1167
  }
1138
1168
  rememberUserMessageClientMessageIds(t) {
1139
1169
  for (const s of t) {
1140
- const n = I(s, "id"), r = v(s);
1170
+ const n = w(s, "id"), r = O(s);
1141
1171
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1142
1172
  }
1143
1173
  }
@@ -1147,7 +1177,7 @@ class Xt {
1147
1177
  this.pendingSessionHistoryRequests.clear();
1148
1178
  }
1149
1179
  markThinkingProgress() {
1150
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(_t), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1180
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Ct), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1151
1181
  }
1152
1182
  scheduleThinkingWatchdog(t) {
1153
1183
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1167,7 +1197,7 @@ class Xt {
1167
1197
  scheduleRunAckWatchdog(t) {
1168
1198
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1169
1199
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1170
- }, xe);
1200
+ }, We);
1171
1201
  }
1172
1202
  recoverMissedRunAck(t) {
1173
1203
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (y("web-sdk.agent", "Pluno run ack missed; resyncing session", {
@@ -1178,7 +1208,7 @@ class Xt {
1178
1208
  scheduleRunAckResyncRetry(t) {
1179
1209
  this.clearRunAckResyncRetryTimer();
1180
1210
  const s = this.retryAttemptsByClientMessageId[t] ?? 0;
1181
- s >= N || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1211
+ s >= L || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1182
1212
  this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
1183
1213
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1184
1214
  isThinking: !0,
@@ -1191,8 +1221,8 @@ class Xt {
1191
1221
  sessionId: this.state.sessionId,
1192
1222
  clientMessageId: t,
1193
1223
  automatic: !0
1194
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(_t)));
1195
- }, O(s, Fe)));
1224
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(Ct)));
1225
+ }, B(s, je)));
1196
1226
  }
1197
1227
  clearRunAckResyncRetryTimer() {
1198
1228
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1215,7 +1245,7 @@ class Xt {
1215
1245
  return;
1216
1246
  }
1217
1247
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
1218
- if (n >= N) {
1248
+ if (n >= L) {
1219
1249
  y("web-sdk.agent", "Pluno run recovery retry exhausted", {
1220
1250
  sessionId: this.state.sessionId,
1221
1251
  clientMessageId: t
@@ -1231,7 +1261,7 @@ class Xt {
1231
1261
  sessionId: this.state.sessionId,
1232
1262
  clientMessageId: t,
1233
1263
  resyncAttempts: s + 1
1234
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(qe);
1264
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(He);
1235
1265
  return;
1236
1266
  }
1237
1267
  this.setState({
@@ -1249,7 +1279,7 @@ class Xt {
1249
1279
  clientMessageId: t,
1250
1280
  automatic: !0
1251
1281
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1252
- }, O(n)));
1282
+ }, B(n)));
1253
1283
  }
1254
1284
  resyncThinkingSession() {
1255
1285
  this.state.sessionId ? this.send({
@@ -1260,10 +1290,12 @@ class Xt {
1260
1290
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
1261
1291
  }
1262
1292
  async executeToolCall(t) {
1263
- const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = typeof t.summary == "string" ? t.summary : "Running browser tool", o = t.rawInput;
1293
+ const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = U(
1294
+ typeof t.summary == "string" ? t.summary : "Running browser tool"
1295
+ ), o = t.rawInput;
1264
1296
  if (!s || !n || !r)
1265
1297
  return;
1266
- if (r !== "execute_code" || !wn(o)) {
1298
+ if (r !== "execute_code" || !kn(o)) {
1267
1299
  this.send({
1268
1300
  type: "tool.result",
1269
1301
  sessionId: s,
@@ -1279,14 +1311,14 @@ class Xt {
1279
1311
  });
1280
1312
  return;
1281
1313
  }
1282
- const c = rs(this.state.messages);
1314
+ const c = as(this.state.messages);
1283
1315
  this.activeBrowserToolCalls.set(n, {
1284
1316
  event: {
1285
1317
  type: "tool.result",
1286
1318
  sessionId: s,
1287
1319
  callId: n,
1288
1320
  toolName: r,
1289
- summary: o.summary,
1321
+ summary: i,
1290
1322
  rawInput: k(o),
1291
1323
  rawOutput: null
1292
1324
  },
@@ -1295,9 +1327,9 @@ class Xt {
1295
1327
  startedAtOrigin: location.origin
1296
1328
  }), this.installSessionUserFilesApi(c);
1297
1329
  let u = null, l;
1298
- u = await this.executeRuntimeHelper(), l = await bt({
1330
+ u = await this.executeRuntimeHelper(), l = await Ut({
1299
1331
  ...o,
1300
- javascript: me(o.javascript, {
1332
+ javascript: Te(o.javascript, {
1301
1333
  clientId: this.options.clientId,
1302
1334
  sessionId: s,
1303
1335
  callId: n
@@ -1314,40 +1346,40 @@ class Xt {
1314
1346
  toolName: r,
1315
1347
  summary: o.summary,
1316
1348
  rawInput: k(o),
1317
- rawOutput: k(bs(l, u))
1318
- }), cn(this.options.clientId, this.activeBrowserToolCalls.values());
1349
+ rawOutput: k(Ps(l, u))
1350
+ }), hn(this.options.clientId, this.activeBrowserToolCalls.values());
1319
1351
  }
1320
1352
  startPageLifecycleRecovery() {
1321
1353
  if (this.pageLifecycleCleanup)
1322
1354
  return;
1323
1355
  const t = () => {
1324
- Qt(this.options.clientId, this.activeBrowserToolCalls.values());
1356
+ se(this.options.clientId, this.activeBrowserToolCalls.values());
1325
1357
  };
1326
1358
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1327
1359
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1328
1360
  };
1329
1361
  }
1330
1362
  installSessionUserFilesApi(t) {
1331
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = is(t, this.attachmentFiles, this.attachmentBlobCache);
1363
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = cs(t, this.attachmentFiles, this.attachmentBlobCache);
1332
1364
  }
1333
1365
  cleanupSessionUserFilesApi() {
1334
- this.sessionUserFilesApiCleanup && (ps(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1366
+ this.sessionUserFilesApiCleanup && (ms(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1335
1367
  }
1336
1368
  async executeRuntimeHelper() {
1337
1369
  if (!this.runtimeHelperJavascript?.trim())
1338
1370
  return null;
1339
- const t = await bt({
1371
+ const t = await Ut({
1340
1372
  javascript: this.runtimeHelperJavascript
1341
1373
  });
1342
- return t.ok === !1 ? Ms(t) : null;
1374
+ return t.ok === !1 ? Ds(t) : null;
1343
1375
  }
1344
1376
  enableNetworkCapture() {
1345
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Qe((t) => {
1346
- _n(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1377
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = ss((t) => {
1378
+ Mn(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1347
1379
  }));
1348
1380
  }
1349
1381
  enqueueNetworkEvent(t) {
1350
- this.queuedNetworkEvents.length >= We || (this.queuedNetworkEvents.push(En(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1382
+ this.queuedNetworkEvents.length >= ze || (this.queuedNetworkEvents.push(bn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1351
1383
  this.networkBatchTimer = null;
1352
1384
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1353
1385
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1356,12 +1388,12 @@ class Xt {
1356
1388
  page: S(),
1357
1389
  events: s
1358
1390
  });
1359
- }, He)));
1391
+ }, $e)));
1360
1392
  }
1361
1393
  scheduleReconnect() {
1362
1394
  if (this.reconnectTimer !== null || this.state.status === "closed")
1363
1395
  return;
1364
- const t = Ve(this.reconnectAttempts);
1396
+ const t = ts(this.reconnectAttempts);
1365
1397
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1366
1398
  this.reconnectTimer = null, this.connect().catch((s) => {
1367
1399
  y("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1377,8 +1409,8 @@ class Xt {
1377
1409
  const t = this.socket;
1378
1410
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1379
1411
  this.socket === t && (y("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1380
- }, ve));
1381
- }, De);
1412
+ }, Le));
1413
+ }, ve);
1382
1414
  }
1383
1415
  stopHeartbeat() {
1384
1416
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1404,52 +1436,52 @@ class Xt {
1404
1436
  ...t,
1405
1437
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1406
1438
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1407
- }, on(this.options.clientId, this.state), this.emit("state", this.getState());
1439
+ }, un(this.options.clientId, this.state), this.emit("state", this.getState());
1408
1440
  }
1409
1441
  emit(t, s) {
1410
1442
  this.listeners[t]?.forEach((r) => r(s));
1411
1443
  }
1412
1444
  }
1413
- const Q = /* @__PURE__ */ new WeakMap();
1414
- function Qe(e) {
1415
- const t = window.__plunoProductAgentNetworkCapture ?? ts();
1445
+ const et = /* @__PURE__ */ new WeakMap();
1446
+ function ss(e) {
1447
+ const t = window.__plunoProductAgentNetworkCapture ?? ns();
1416
1448
  return t.subscribers.add(e), () => {
1417
1449
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1418
1450
  };
1419
1451
  }
1420
- function ts() {
1421
- const e = /* @__PURE__ */ new Set(), t = (T) => {
1452
+ function ns() {
1453
+ const e = /* @__PURE__ */ new Set(), t = (I) => {
1422
1454
  e.forEach((p) => {
1423
1455
  try {
1424
- p(T);
1456
+ p(I);
1425
1457
  } catch {
1426
1458
  }
1427
1459
  });
1428
1460
  }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, d) {
1429
1461
  const f = Date.now();
1430
- let w;
1462
+ let T;
1431
1463
  try {
1432
- w = s.call(this, p, d);
1464
+ T = s.call(this, p, d);
1433
1465
  } catch (m) {
1434
1466
  throw m;
1435
1467
  }
1436
1468
  try {
1437
- const m = p instanceof Request ? p : null, g = In(p, m), A = se(d?.headers ?? m?.headers);
1469
+ const m = p instanceof Request ? p : null, g = En(p, m), A = ie(d?.headers ?? m?.headers);
1438
1470
  if (!M(g, A, d?.body)) {
1439
- const K = {
1440
- requestId: tt("fetch"),
1441
- url: _(g, Z),
1471
+ const Y = {
1472
+ requestId: st("fetch"),
1473
+ url: _(g, tt),
1442
1474
  method: (d?.method ?? m?.method ?? "GET").toUpperCase(),
1443
1475
  requestHeaders: A,
1444
- requestBody: qt(d?.body),
1476
+ requestBody: Ht(d?.body),
1445
1477
  resourceType: "fetch",
1446
1478
  startedAt: new Date(f).toISOString()
1447
1479
  };
1448
- w.then(
1480
+ T.then(
1449
1481
  (b) => {
1450
- An(b, K, f, t).catch(() => {
1482
+ _n(b, Y, f, t).catch(() => {
1451
1483
  t({
1452
- ...K,
1484
+ ...Y,
1453
1485
  responseStatus: b.status,
1454
1486
  durationMs: Date.now() - f
1455
1487
  });
@@ -1457,7 +1489,7 @@ function ts() {
1457
1489
  },
1458
1490
  (b) => {
1459
1491
  t({
1460
- ...K,
1492
+ ...Y,
1461
1493
  errorText: _(b instanceof Error ? b.message : String(b)),
1462
1494
  durationMs: Date.now() - f
1463
1495
  });
@@ -1466,30 +1498,30 @@ function ts() {
1466
1498
  }
1467
1499
  } catch {
1468
1500
  }
1469
- return w;
1470
- }, c = function(p, d, f, w, m) {
1471
- const g = n.call(this, p, d, f ?? !0, w ?? void 0, m ?? void 0), A = typeof d == "string" ? d : d.toString();
1472
- return Q.set(this, {
1473
- requestId: tt("xhr"),
1501
+ return T;
1502
+ }, c = function(p, d, f, T, m) {
1503
+ const g = n.call(this, p, d, f ?? !0, T ?? void 0, m ?? void 0), A = typeof d == "string" ? d : d.toString();
1504
+ return et.set(this, {
1505
+ requestId: st("xhr"),
1474
1506
  method: String(p ?? "GET").toUpperCase(),
1475
- url: _(A, Z),
1507
+ url: _(A, tt),
1476
1508
  requestHeaders: {},
1477
1509
  startedAtMs: Date.now(),
1478
1510
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1479
1511
  excluded: M(A)
1480
1512
  }), g;
1481
1513
  }, u = function(p, d) {
1482
- const f = r.call(this, p, d), w = Q.get(this);
1483
- return w && Object.keys(w.requestHeaders).length < ft && (w.requestHeaders[p] = At(p, d), w.excluded = w.excluded || M(w.url, w.requestHeaders)), f;
1514
+ const f = r.call(this, p, d), T = et.get(this);
1515
+ return T && Object.keys(T.requestHeaders).length < mt && (T.requestHeaders[p] = kt(p, d), T.excluded = T.excluded || M(T.url, T.requestHeaders)), f;
1484
1516
  }, l = function(p) {
1485
1517
  try {
1486
- const d = Q.get(this);
1487
- d && (d.excluded = d.excluded || M(d.url, d.requestHeaders, p), d.requestBody = qt(p), d.excluded || this.addEventListener(
1518
+ const d = et.get(this);
1519
+ d && (d.excluded = d.excluded || M(d.url, d.requestHeaders, p), d.requestBody = Ht(p), d.excluded || this.addEventListener(
1488
1520
  "loadend",
1489
1521
  () => {
1490
1522
  queueMicrotask(() => {
1491
1523
  try {
1492
- const f = Cn(this.getAllResponseHeaders());
1524
+ const f = Pn(this.getAllResponseHeaders());
1493
1525
  t({
1494
1526
  requestId: d.requestId,
1495
1527
  url: d.url,
@@ -1499,7 +1531,7 @@ function ts() {
1499
1531
  resourceType: "xhr",
1500
1532
  responseStatus: this.status,
1501
1533
  responseHeaders: f,
1502
- responseBody: kn(this, f),
1534
+ responseBody: Cn(this, f),
1503
1535
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1504
1536
  startedAt: d.startedAt,
1505
1537
  durationMs: Date.now() - d.startedAtMs
@@ -1533,15 +1565,15 @@ function ts() {
1533
1565
  }
1534
1566
  let a = null;
1535
1567
  if (typeof PerformanceObserver < "u") {
1536
- a = new PerformanceObserver((T) => {
1537
- for (const p of T.getEntries()) {
1568
+ a = new PerformanceObserver((I) => {
1569
+ for (const p of I.getEntries()) {
1538
1570
  const d = p;
1539
1571
  if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || M(d.name))
1540
1572
  continue;
1541
1573
  const f = performance.timeOrigin + d.startTime;
1542
1574
  t({
1543
- requestId: tt("resource"),
1544
- url: _(d.name, Z),
1575
+ requestId: st("resource"),
1576
+ url: _(d.name, tt),
1545
1577
  method: "GET",
1546
1578
  resourceType: "resource",
1547
1579
  responseStatus: d.responseStatus,
@@ -1591,15 +1623,15 @@ function y(e, t, s) {
1591
1623
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1592
1624
  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 }));
1593
1625
  }
1594
- function Ct(e) {
1626
+ function Mt(e) {
1595
1627
  const t = typeof e == "function" ? e() : e;
1596
1628
  return t && Object.keys(t).length > 0 ? t : void 0;
1597
1629
  }
1598
- function es(e) {
1630
+ function rs(e) {
1599
1631
  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";
1600
1632
  }
1601
- const ss = 5e3, ns = 12e4;
1602
- function rs(e) {
1633
+ const is = 5e3, os = 12e4;
1634
+ function as(e) {
1603
1635
  const t = [];
1604
1636
  for (const s of e)
1605
1637
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1610,17 +1642,17 @@ function rs(e) {
1610
1642
  });
1611
1643
  return t;
1612
1644
  }
1613
- function is(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1645
+ function cs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1614
1646
  const n = [
1615
- os(e, t, s),
1616
- as()
1647
+ ls(e, t, s),
1648
+ us()
1617
1649
  ].filter((r) => typeof r == "function");
1618
1650
  return () => {
1619
1651
  for (const r of n.reverse())
1620
1652
  r();
1621
1653
  };
1622
1654
  }
1623
- function os(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1655
+ function ls(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1624
1656
  const n = new Map(e.map((l) => [l.id, l])), r = (l) => ({
1625
1657
  id: l.id,
1626
1658
  name: l.name,
@@ -1637,10 +1669,10 @@ function os(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1637
1669
  const a = i(l), h = t.get(a.id);
1638
1670
  if (h)
1639
1671
  return h;
1640
- const T = s.get(a.id);
1641
- if (T)
1642
- return T;
1643
- const p = await de(a.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1672
+ const I = s.get(a.id);
1673
+ if (I)
1674
+ return I;
1675
+ const p = await fe(a.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1644
1676
  attachmentId: a.id,
1645
1677
  name: a.name,
1646
1678
  message: m instanceof Error ? m.message : String(m)
@@ -1649,13 +1681,13 @@ function os(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1649
1681
  return s.set(a.id, p), p;
1650
1682
  if (!a.fileUrl)
1651
1683
  throw new Error(`Pluno user file is missing content: ${l}`);
1652
- const d = await fetch(a.fileUrl, fn(a.fileUrl));
1684
+ const d = await fetch(a.fileUrl, In(a.fileUrl));
1653
1685
  if (!d.ok)
1654
1686
  throw new Error(`Failed to load Pluno user file: ${l}`);
1655
1687
  const f = await d.blob();
1656
1688
  s.set(a.id, f);
1657
- const w = Date.now();
1658
- return Ft({
1689
+ const T = Date.now();
1690
+ return jt({
1659
1691
  attachmentId: a.id,
1660
1692
  name: a.name,
1661
1693
  mimeType: a.mimeType,
@@ -1663,8 +1695,8 @@ function os(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1663
1695
  blob: f,
1664
1696
  fileUrl: a.fileUrl,
1665
1697
  gcsPath: a.gcsPath,
1666
- createdAt: w,
1667
- lastUsedAt: w
1698
+ createdAt: T,
1699
+ lastUsedAt: T
1668
1700
  }).catch((m) => {
1669
1701
  y("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
1670
1702
  attachmentId: a.id,
@@ -1673,36 +1705,36 @@ function os(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1673
1705
  });
1674
1706
  }), f;
1675
1707
  };
1676
- return jt(globalThis, "userFiles", {
1708
+ return Gt(globalThis, "userFiles", {
1677
1709
  list: () => e.map(r),
1678
1710
  get: (l) => {
1679
1711
  const a = n.get(l);
1680
1712
  return a ? r(a) : null;
1681
1713
  },
1682
1714
  inspectImage: async (l) => {
1683
- const a = i(l), h = await o(l), T = a.mimeType.startsWith("image/") ? a.mimeType : h.type || a.mimeType;
1684
- if (!T.startsWith("image/"))
1715
+ const a = i(l), h = await o(l), I = a.mimeType.startsWith("image/") ? a.mimeType : h.type || a.mimeType;
1716
+ if (!I.startsWith("image/"))
1685
1717
  throw new Error(`Pluno user file is not an image: ${l}`);
1686
- const p = h.type === T ? h : new Blob([h], { type: T });
1687
- return fs(T, p.size) > Ke ? {
1718
+ const p = h.type === I ? h : new Blob([h], { type: I });
1719
+ return ys(I, p.size) > Ve ? {
1688
1720
  type: "pluno.userFiles.inspectImage",
1689
1721
  id: a.id,
1690
1722
  name: a.name,
1691
- mimeType: T,
1723
+ mimeType: I,
1692
1724
  sizeBytes: a.sizeBytes,
1693
1725
  imageAttached: !1,
1694
- imageAttachmentError: gt
1726
+ imageAttachmentError: yt
1695
1727
  } : {
1696
1728
  type: "pluno.userFiles.inspectImage",
1697
1729
  id: a.id,
1698
1730
  name: a.name,
1699
- mimeType: T,
1731
+ mimeType: I,
1700
1732
  sizeBytes: a.sizeBytes,
1701
1733
  imageAttached: !0,
1702
- dataUrl: await ot(p)
1734
+ dataUrl: await ct(p)
1703
1735
  };
1704
1736
  },
1705
- getDataUrl: async (l) => (i(l), await ot(await o(l))),
1737
+ getDataUrl: async (l) => (i(l), await ct(await o(l))),
1706
1738
  getBlob: o,
1707
1739
  getArrayBuffer: async (l) => await (await o(l)).arrayBuffer(),
1708
1740
  getFile: async (l) => {
@@ -1711,17 +1743,17 @@ function os(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1711
1743
  }
1712
1744
  });
1713
1745
  }
1714
- function as() {
1715
- return jt(globalThis, "pageImages", {
1716
- inspectImage: async (t, s) => await cs(t, s)
1746
+ function us() {
1747
+ return Gt(globalThis, "pageImages", {
1748
+ inspectImage: async (t, s) => await ds(t, s)
1717
1749
  });
1718
1750
  }
1719
- async function cs(e, t = {}) {
1720
- const s = hs(t.name), n = await ls(e);
1751
+ async function ds(e, t = {}) {
1752
+ const s = gs(t.name), n = await hs(e);
1721
1753
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1722
1754
  type: "pluno.pageImages.inspectImage",
1723
1755
  imageAttached: !1,
1724
- imageAttachmentError: gt
1756
+ imageAttachmentError: yt
1725
1757
  } : {
1726
1758
  type: "pluno.pageImages.inspectImage",
1727
1759
  imageAttached: !0,
@@ -1735,15 +1767,15 @@ async function cs(e, t = {}) {
1735
1767
  imageAttachmentError: n.error
1736
1768
  };
1737
1769
  }
1738
- async function ls(e) {
1739
- 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: gt } : {
1770
+ async function hs(e) {
1771
+ 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: yt } : {
1740
1772
  ok: !0,
1741
1773
  mimeType: e.type,
1742
1774
  sizeBytes: e.size,
1743
- dataUrl: await ot(e)
1744
- } : { 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." } : us(e);
1775
+ dataUrl: await ct(e)
1776
+ } : { 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." } : ps(e);
1745
1777
  }
1746
- function us(e) {
1778
+ function ps(e) {
1747
1779
  if (!e.startsWith("data:") || !e.includes(","))
1748
1780
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1749
1781
  const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((c) => c.trim()).filter(Boolean), r = n[0] ?? "";
@@ -1754,7 +1786,7 @@ function us(e) {
1754
1786
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1755
1787
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1756
1788
  return { ok: !1, error: "Page image data URL has invalid base64." };
1757
- const o = ds(i);
1789
+ const o = fs(i);
1758
1790
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1759
1791
  ok: !0,
1760
1792
  mimeType: r,
@@ -1762,22 +1794,22 @@ function us(e) {
1762
1794
  dataUrl: `data:${r};base64,${i}`
1763
1795
  };
1764
1796
  }
1765
- function ds(e) {
1797
+ function fs(e) {
1766
1798
  if (e.length === 0 || e.length % 4 !== 0)
1767
1799
  return null;
1768
1800
  const t = e.length - e.replace(/=+$/, "").length;
1769
1801
  return t > 2 ? null : e.length / 4 * 3 - t;
1770
1802
  }
1771
- function hs(e) {
1803
+ function gs(e) {
1772
1804
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1773
1805
  }
1774
- function ps(e) {
1806
+ function ms(e) {
1775
1807
  try {
1776
1808
  e();
1777
1809
  } catch {
1778
1810
  }
1779
1811
  }
1780
- function ot(e) {
1812
+ function ct(e) {
1781
1813
  return new Promise((t, s) => {
1782
1814
  const n = new FileReader();
1783
1815
  n.onload = () => {
@@ -1789,12 +1821,12 @@ function ot(e) {
1789
1821
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1790
1822
  });
1791
1823
  }
1792
- function fs(e, t) {
1824
+ function ys(e, t) {
1793
1825
  return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
1794
1826
  }
1795
- async function bt(e) {
1827
+ async function Ut(e) {
1796
1828
  const t = Object.getPrototypeOf(async function() {
1797
- }).constructor, s = e.timeoutMs ?? ss, n = Date.now(), r = [];
1829
+ }).constructor, s = e.timeoutMs ?? is, n = Date.now(), r = [];
1798
1830
  let i;
1799
1831
  const o = {
1800
1832
  log: console.log,
@@ -1812,7 +1844,7 @@ async function bt(e) {
1812
1844
  i = window.setTimeout(() => a(u), s);
1813
1845
  })
1814
1846
  ]);
1815
- return l === u ? gs(s) : {
1847
+ return l === u ? Is(s) : {
1816
1848
  ok: !0,
1817
1849
  result: l,
1818
1850
  console: r,
@@ -1841,7 +1873,7 @@ async function bt(e) {
1841
1873
  i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
1842
1874
  }
1843
1875
  }
1844
- function gs(e) {
1876
+ function Is(e) {
1845
1877
  return {
1846
1878
  ok: !1,
1847
1879
  exception: {
@@ -1855,18 +1887,18 @@ function gs(e) {
1855
1887
  }
1856
1888
  };
1857
1889
  }
1858
- function ms(e) {
1890
+ function Ts(e) {
1859
1891
  return e.replace(/\/+$/, "");
1860
1892
  }
1861
- function ys(e, t = location.origin) {
1893
+ function ws(e, t = location.origin) {
1862
1894
  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;
1863
1895
  }
1864
- function Ts(e) {
1896
+ function As(e) {
1865
1897
  const t = new URL("/api/product-agent/embed/ws", e);
1866
1898
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1867
1899
  }
1868
1900
  function S() {
1869
- const e = Kt();
1901
+ const e = Vt();
1870
1902
  return {
1871
1903
  url: location.href,
1872
1904
  title: document.title,
@@ -1874,21 +1906,21 @@ function S() {
1874
1906
  ...e ? { plunoProductAgentUi: e } : {}
1875
1907
  };
1876
1908
  }
1877
- function ws() {
1909
+ function Ss() {
1878
1910
  return {
1879
1911
  pageUrl: location.href,
1880
1912
  pageTitle: document.title,
1881
- htmlContent: ks()
1913
+ htmlContent: Rs()
1882
1914
  };
1883
1915
  }
1884
- function Is(e) {
1885
- return x.add(e), L || (L = As()), () => {
1886
- x.delete(e), x.size === 0 && (L?.(), L = null);
1916
+ function ks(e) {
1917
+ return H.add(e), q || (q = Es()), () => {
1918
+ H.delete(e), H.size === 0 && (q?.(), q = null);
1887
1919
  };
1888
1920
  }
1889
- function As() {
1921
+ function Es() {
1890
1922
  const e = () => {
1891
- for (const i of Array.from(x))
1923
+ for (const i of Array.from(H))
1892
1924
  i();
1893
1925
  }, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
1894
1926
  const o = t(...i);
@@ -1901,10 +1933,10 @@ function As() {
1901
1933
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1902
1934
  };
1903
1935
  }
1904
- function Ss() {
1905
- return Kt()?.surface === "browser_extension_sdk_preview";
1936
+ function _s() {
1937
+ return Vt()?.surface === "browser_extension_sdk_preview";
1906
1938
  }
1907
- function ks() {
1939
+ function Rs() {
1908
1940
  const e = document.body?.cloneNode(!0);
1909
1941
  return e instanceof HTMLElement ? (e.querySelectorAll(
1910
1942
  [
@@ -1928,9 +1960,9 @@ function ks() {
1928
1960
  s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
1929
1961
  }), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
1930
1962
  }
1931
- function Kt() {
1932
- const e = document.querySelector(St);
1933
- if (!(e ?? document.querySelector(rt)))
1963
+ function Vt() {
1964
+ const e = document.querySelector(Et);
1965
+ if (!(e ?? document.querySelector(ot)))
1934
1966
  return;
1935
1967
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
1936
1968
  return {
@@ -1939,28 +1971,28 @@ function Kt() {
1939
1971
  selectors: [
1940
1972
  {
1941
1973
  name: "widget_host",
1942
- selector: s === "browser_extension_sdk_preview" ? St : rt,
1974
+ selector: s === "browser_extension_sdk_preview" ? Et : ot,
1943
1975
  description: "Finds Pluno's shadow-host element in the host page DOM."
1944
1976
  },
1945
1977
  {
1946
1978
  name: "widget_root",
1947
- selector: Ce,
1979
+ selector: Ue,
1948
1980
  description: "Finds Pluno's widget root inside the widget host shadow root."
1949
1981
  },
1950
1982
  {
1951
1983
  name: "widget_panel",
1952
- selector: be,
1984
+ selector: Pe,
1953
1985
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
1954
1986
  },
1955
1987
  {
1956
1988
  name: "widget_timeline",
1957
- selector: Me,
1989
+ selector: De,
1958
1990
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
1959
1991
  }
1960
1992
  ]
1961
1993
  };
1962
1994
  }
1963
- function Es(e) {
1995
+ function Cs(e) {
1964
1996
  try {
1965
1997
  const t = JSON.parse(e);
1966
1998
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -1968,16 +2000,16 @@ function Es(e) {
1968
2000
  return { type: "error", message: "Invalid server event" };
1969
2001
  }
1970
2002
  }
1971
- function Mt(e, t) {
2003
+ function Pt(e, t) {
1972
2004
  if (!e || typeof e != "object")
1973
2005
  return [];
1974
2006
  const s = e[t];
1975
2007
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
1976
2008
  }
1977
- function _s(e) {
2009
+ function bs(e) {
1978
2010
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
1979
2011
  }
1980
- function Rs(e) {
2012
+ function Ms(e) {
1981
2013
  if (!e || typeof e != "object")
1982
2014
  return null;
1983
2015
  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, c = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -1988,13 +2020,13 @@ function Rs(e) {
1988
2020
  ...c !== null ? { scribbleStyle: c } : {}
1989
2021
  };
1990
2022
  }
1991
- function Cs(e) {
2023
+ function Us(e) {
1992
2024
  if (!e || typeof e != "object")
1993
2025
  return null;
1994
2026
  const t = e.javascript;
1995
2027
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
1996
2028
  }
1997
- function bs(e, t) {
2029
+ function Ps(e, t) {
1998
2030
  return t ? e && typeof e == "object" ? {
1999
2031
  ...e,
2000
2032
  helperError: t
@@ -2004,23 +2036,23 @@ function bs(e, t) {
2004
2036
  helperError: t
2005
2037
  } : e;
2006
2038
  }
2007
- function Ms(e) {
2039
+ function Ds(e) {
2008
2040
  if (!e || typeof e != "object")
2009
2041
  return e;
2010
2042
  const t = e;
2011
2043
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
2012
2044
  }
2013
- function Us() {
2045
+ function Ns() {
2014
2046
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
2015
2047
  if (t)
2016
2048
  return t;
2017
2049
  const s = crypto.randomUUID();
2018
2050
  return window.localStorage.setItem(e, s), s;
2019
2051
  }
2020
- function B() {
2052
+ function x() {
2021
2053
  return crypto.randomUUID();
2022
2054
  }
2023
- function Ps(e) {
2055
+ function Os(e) {
2024
2056
  if (!e || typeof e != "object")
2025
2057
  return null;
2026
2058
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -2031,23 +2063,23 @@ function Ps(e) {
2031
2063
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
2032
2064
  } : null;
2033
2065
  }
2034
- function Ds(e, t) {
2035
- return Array.isArray(e) ? lt(
2036
- ut(
2037
- e.map((s) => Jt(s, t)).filter((s) => s !== null)
2066
+ function vs(e, t) {
2067
+ return Array.isArray(e) ? dt(
2068
+ ht(
2069
+ e.map((s) => Zt(s, t)).filter((s) => s !== null)
2038
2070
  )
2039
2071
  ) : [];
2040
2072
  }
2041
- function vs(e) {
2073
+ function Ls(e) {
2042
2074
  return Array.isArray(e) ? e.flatMap((t) => {
2043
2075
  if (!t || typeof t != "object")
2044
2076
  return [];
2045
- const s = t, n = I(s, "id"), r = I(s, "createdAt"), i = I(s, "updatedAt"), o = I(s, "lastActiveAt");
2077
+ const s = t, n = w(s, "id"), r = w(s, "createdAt"), i = w(s, "updatedAt"), o = w(s, "lastActiveAt");
2046
2078
  return !n || !r || !i || !o ? [] : [
2047
2079
  {
2048
2080
  id: n,
2049
- title: I(s, "title"),
2050
- firstUserMessage: I(s, "firstUserMessage"),
2081
+ title: w(s, "title"),
2082
+ firstUserMessage: w(s, "firstUserMessage"),
2051
2083
  currentPage: s.currentPage ?? null,
2052
2084
  createdAt: r,
2053
2085
  updatedAt: i,
@@ -2057,7 +2089,7 @@ function vs(e) {
2057
2089
  ];
2058
2090
  }) : [];
2059
2091
  }
2060
- function Jt(e, t) {
2092
+ function Zt(e, t) {
2061
2093
  if (!e || typeof e != "object")
2062
2094
  return null;
2063
2095
  const s = e, n = s.data;
@@ -2072,11 +2104,12 @@ function Jt(e, t) {
2072
2104
  const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
2073
2105
  id: String(s.id ?? crypto.randomUUID()),
2074
2106
  role: i,
2075
- content: xs(r.content),
2107
+ ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2108
+ content: Ws(r.content),
2076
2109
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2077
2110
  respondsToUserMessageId: C(r) ?? void 0,
2078
2111
  ...E(r) ? { runId: E(r) } : {},
2079
- attachments: te(r.attachments, t)
2112
+ attachments: ne(r.attachments, t)
2080
2113
  };
2081
2114
  return typeof r.clientMessageId == "string" && Object.defineProperty(o, "clientMessageId", {
2082
2115
  value: r.clientMessageId,
@@ -2084,7 +2117,7 @@ function Jt(e, t) {
2084
2117
  }), o;
2085
2118
  }
2086
2119
  if (r.type === "function_call_output") {
2087
- const i = Os(r.output);
2120
+ const i = qs(r.output);
2088
2121
  return i ? {
2089
2122
  id: String(s.id ?? crypto.randomUUID()),
2090
2123
  role: "tool",
@@ -2094,25 +2127,25 @@ function Jt(e, t) {
2094
2127
  ...E(r) ? { runId: E(r) } : {},
2095
2128
  dataType: "function_call_output",
2096
2129
  toolName: "authenticate_pipedream_app",
2097
- callId: Ut(r) ?? void 0,
2130
+ callId: Dt(r) ?? void 0,
2098
2131
  integrationAuthRequest: i
2099
2132
  } : null;
2100
2133
  }
2101
2134
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2102
2135
  id: String(s.id ?? crypto.randomUUID()),
2103
2136
  role: "tool",
2104
- content: r.type === "mcp_call" ? Ns(r) : Bs(r),
2137
+ content: r.type === "mcp_call" ? Bs(r) : Fs(r),
2105
2138
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2106
2139
  respondsToUserMessageId: C(r) ?? void 0,
2107
2140
  ...E(r) ? { runId: E(r) } : {},
2108
2141
  dataType: String(r.type),
2109
2142
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2110
- callId: Ut(r) ?? void 0,
2143
+ callId: Dt(r) ?? void 0,
2111
2144
  loading: r.localExecutionStatus === "running"
2112
2145
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2113
2146
  id: String(s.id ?? crypto.randomUUID()),
2114
2147
  role: "system",
2115
- content: Ls(r),
2148
+ content: xs(r),
2116
2149
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2117
2150
  respondsToUserMessageId: C(r) ?? void 0,
2118
2151
  ...E(r) ? { runId: E(r) } : {},
@@ -2122,11 +2155,11 @@ function Jt(e, t) {
2122
2155
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2123
2156
  } : null;
2124
2157
  }
2125
- function Ns(e) {
2158
+ function Bs(e) {
2126
2159
  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(" ");
2127
- return s ? `Using ${s}` : "Using connected integration";
2160
+ return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2128
2161
  }
2129
- function Os(e) {
2162
+ function qs(e) {
2130
2163
  if (typeof e != "string")
2131
2164
  return null;
2132
2165
  try {
@@ -2143,41 +2176,45 @@ function Os(e) {
2143
2176
  return null;
2144
2177
  }
2145
2178
  }
2146
- function Ls(e) {
2147
- return 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." : e.type === "run_status" && e.status === "stopped" ? "Pluno stopped." : "Pluno run status changed.";
2179
+ function xs(e) {
2180
+ return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : 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.";
2148
2181
  }
2149
- function Bs(e) {
2182
+ function Fs(e) {
2150
2183
  if (e.type === "web_search_call") {
2151
2184
  const t = e.action;
2152
2185
  if (t && typeof t == "object") {
2153
2186
  const s = t;
2154
2187
  if (s.type === "open_page")
2155
- return "Opening a page";
2188
+ return "🌐 Opening a page";
2156
2189
  if (s.type === "find_in_page")
2157
- return "Finding relevant text";
2190
+ return "🔎 Finding relevant text";
2158
2191
  }
2159
- return "Searching the web";
2192
+ return "🔎 Searching the web";
2160
2193
  }
2161
- return qs(e);
2194
+ return Hs(e);
2162
2195
  }
2163
- function qs(e) {
2196
+ function Hs(e) {
2164
2197
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2165
- return e.summary;
2198
+ return U(e.summary);
2166
2199
  if (typeof e.arguments == "string")
2167
2200
  try {
2168
2201
  const t = JSON.parse(e.arguments);
2169
2202
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
2170
- return t.summary;
2203
+ return U(t.summary);
2171
2204
  } catch {
2172
- return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
2205
+ return typeof e.name == "string" && e.name.trim().length > 0 ? U(e.name) : "🛠️ Run tool";
2173
2206
  }
2174
- return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
2207
+ return typeof e.name == "string" && e.name.trim().length > 0 ? U(e.name) : "🛠️ Run tool";
2208
+ }
2209
+ function U(e) {
2210
+ const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2211
+ return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2175
2212
  }
2176
- function Ut(e) {
2213
+ function Dt(e) {
2177
2214
  const t = e.callId ?? e.call_id;
2178
2215
  return typeof t == "string" && t ? t : null;
2179
2216
  }
2180
- function xs(e) {
2217
+ function Ws(e) {
2181
2218
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2182
2219
  if (!t || typeof t != "object")
2183
2220
  return "";
@@ -2185,61 +2222,89 @@ function xs(e) {
2185
2222
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2186
2223
  }).filter(Boolean).join("") : "";
2187
2224
  }
2188
- function Fs(e, t) {
2189
- const s = Yt(e, t), n = $s(e, t), r = n.findIndex((o) => o.id === s.id);
2225
+ function Nt(e, t) {
2226
+ const s = Qt(e, t), n = $s(
2227
+ Ks(e, t),
2228
+ s
2229
+ ), r = n.findIndex((o) => o.id === s.id);
2190
2230
  if (r === -1)
2191
- return lt(
2192
- ut([...n, s])
2231
+ return dt(
2232
+ ht([...n, s])
2193
2233
  );
2194
2234
  const i = [...n];
2195
- return i[r] = s, lt(ut(i));
2235
+ return i[r] = s, dt(ht(i));
2236
+ }
2237
+ function js(e) {
2238
+ const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
2239
+ return !t || !s ? null : {
2240
+ id: `transient-activity:${t}`,
2241
+ role: "tool",
2242
+ content: U(
2243
+ typeof e.summary == "string" ? e.summary : "Running browser tool"
2244
+ ),
2245
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2246
+ respondsToUserMessageId: typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : void 0,
2247
+ runId: typeof e.runId == "string" ? e.runId : void 0,
2248
+ dataType: "function_call",
2249
+ toolName: s,
2250
+ callId: t,
2251
+ loading: !0
2252
+ };
2196
2253
  }
2197
- function Hs(e, t) {
2254
+ function $s(e, t) {
2255
+ if (t.id.startsWith("transient-activity:"))
2256
+ return e;
2257
+ const s = t.toolName === "tab_lifecycle";
2258
+ return !t.callId && !s ? e : e.filter(
2259
+ (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
2260
+ );
2261
+ }
2262
+ function zs(e, t) {
2198
2263
  const s = t.map(
2199
- (n) => Yt(e, n)
2264
+ (n) => Qt(e, n)
2200
2265
  );
2201
- return t.length > 0 ? s : e.filter(mt);
2266
+ return t.length > 0 ? s : e.filter(It);
2202
2267
  }
2203
- function Yt(e, t) {
2268
+ function Qt(e, t) {
2204
2269
  if (t.role !== "user" || !t.attachments?.length)
2205
2270
  return t;
2206
2271
  const s = e.find(
2207
- (r) => r.role === "user" && (r.id === t.id || mt(r) && Vt(r, t))
2272
+ (r) => r.role === "user" && (r.id === t.id || It(r) && te(r, t))
2208
2273
  );
2209
2274
  if (!s?.attachments?.length)
2210
2275
  return t;
2211
2276
  const n = t.attachments.map((r) => {
2212
- const i = Ws(s.attachments ?? [], r);
2213
- return i ? js(r, i) : r;
2277
+ const i = Gs(s.attachments ?? [], r);
2278
+ return i ? Xs(r, i) : r;
2214
2279
  });
2215
2280
  return { ...t, attachments: n };
2216
2281
  }
2217
- function Ws(e, t) {
2282
+ function Gs(e, t) {
2218
2283
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2219
2284
  }
2220
- function js(e, t) {
2285
+ function Xs(e, t) {
2221
2286
  const { previewUrl: s } = t;
2222
2287
  return s ? { ...e, previewUrl: s } : e;
2223
2288
  }
2224
- function $s(e, t) {
2289
+ function Ks(e, t) {
2225
2290
  if (t.role !== "user")
2226
2291
  return e;
2227
2292
  const s = e.findIndex(
2228
- (r) => mt(r) && Vt(r, t)
2293
+ (r) => It(r) && te(r, t)
2229
2294
  );
2230
2295
  if (s === -1)
2231
2296
  return e;
2232
2297
  const n = [...e];
2233
2298
  return n.splice(s, 1), n;
2234
2299
  }
2235
- function Vt(e, t) {
2236
- const s = Pt(e), n = Pt(t);
2300
+ function te(e, t) {
2301
+ const s = Ot(e), n = Ot(t);
2237
2302
  return s && n ? s === n : e.content === t.content;
2238
2303
  }
2239
- function mt(e) {
2304
+ function It(e) {
2240
2305
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2241
2306
  }
2242
- function Pt(e) {
2307
+ function Ot(e) {
2243
2308
  const t = e.clientMessageId;
2244
2309
  if (t)
2245
2310
  return t;
@@ -2248,13 +2313,13 @@ function Pt(e) {
2248
2313
  );
2249
2314
  return n ? e.id.slice(n.length) : null;
2250
2315
  }
2251
- function Dt(e) {
2252
- const t = Zt(e);
2316
+ function vt(e) {
2317
+ const t = ee(e);
2253
2318
  if (t === null)
2254
2319
  return !1;
2255
2320
  for (let s = e.length - 1; s > t; s -= 1) {
2256
2321
  const n = e[s];
2257
- if (n.role === "assistant")
2322
+ if (v(n))
2258
2323
  return !0;
2259
2324
  if (n.role === "system") {
2260
2325
  if (n.dataType === "run_error")
@@ -2265,20 +2330,20 @@ function Dt(e) {
2265
2330
  }
2266
2331
  return !1;
2267
2332
  }
2268
- function zs(e) {
2269
- const t = Zt(e);
2270
- return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
2333
+ function Js(e) {
2334
+ const t = ee(e);
2335
+ return t === null ? e.some(v) : e.slice(t + 1).some(v);
2271
2336
  }
2272
- function Zt(e) {
2337
+ function ee(e) {
2273
2338
  for (let t = e.length - 1; t >= 0; t -= 1)
2274
2339
  if (e[t].role === "user")
2275
2340
  return t;
2276
2341
  return null;
2277
2342
  }
2278
- function Gs(e) {
2279
- return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2343
+ function Ys(e) {
2344
+ return v(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2280
2345
  }
2281
- function yt(e) {
2346
+ function Tt(e) {
2282
2347
  for (let t = e.length - 1; t >= 0; t -= 1) {
2283
2348
  const s = e[t];
2284
2349
  if (!s || typeof s != "object")
@@ -2292,30 +2357,30 @@ function yt(e) {
2292
2357
  }
2293
2358
  return null;
2294
2359
  }
2295
- function v(e) {
2360
+ function O(e) {
2296
2361
  if (!e || typeof e != "object")
2297
2362
  return null;
2298
2363
  const t = e.data;
2299
2364
  return t && typeof t == "object" ? t : null;
2300
2365
  }
2301
- function at(e) {
2366
+ function lt(e) {
2302
2367
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2303
2368
  }
2304
- function vt(e) {
2369
+ function Lt(e) {
2305
2370
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2306
2371
  }
2307
- function Xs(e, t) {
2308
- const s = yt(t);
2372
+ function Vs(e, t) {
2373
+ const s = Tt(t);
2309
2374
  if (s === null)
2310
2375
  return !1;
2311
2376
  const n = t[s], r = n && typeof n == "object" ? n.id : null;
2312
2377
  if (typeof r != "string" || !r)
2313
2378
  return !1;
2314
2379
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2315
- return i === -1 ? !1 : e.slice(i + 1).some(Gs);
2380
+ return i === -1 ? !1 : e.slice(i + 1).some(Ys);
2316
2381
  }
2317
- function ct(e) {
2318
- const t = yt(e);
2382
+ function ut(e) {
2383
+ const t = Tt(e);
2319
2384
  if (t === null)
2320
2385
  return null;
2321
2386
  const s = e[t];
@@ -2327,8 +2392,8 @@ function ct(e) {
2327
2392
  const r = n.clientMessageId;
2328
2393
  return typeof r == "string" ? r : null;
2329
2394
  }
2330
- function Ks(e) {
2331
- const t = yt(e);
2395
+ function Zs(e) {
2396
+ const t = Tt(e);
2332
2397
  if (t === null)
2333
2398
  return null;
2334
2399
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -2342,22 +2407,22 @@ function Ks(e) {
2342
2407
  if (i.type === "message" && i.role === "assistant")
2343
2408
  return null;
2344
2409
  if (i.type === "run_error")
2345
- return i.retryable !== !0 ? null : Nt(e, i) ?? ct(e);
2410
+ return i.retryable !== !0 ? null : Bt(e, i) ?? ut(e);
2346
2411
  if (i.type === "run_status")
2347
- return i.status === "interrupted" && i.retryable === !0 ? Nt(e, i) ?? ct(e) : null;
2412
+ return i.status === "interrupted" && i.retryable === !0 ? Bt(e, i) ?? ut(e) : null;
2348
2413
  }
2349
2414
  return null;
2350
2415
  }
2351
- function Nt(e, t) {
2416
+ function Bt(e, t) {
2352
2417
  if (typeof t.clientMessageId == "string")
2353
2418
  return t.clientMessageId;
2354
2419
  const s = C(t);
2355
2420
  if (!s)
2356
2421
  return null;
2357
- const n = e.find((i) => I(i, "id") === s), r = v(n);
2422
+ const n = e.find((i) => w(i, "id") === s), r = O(n);
2358
2423
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2359
2424
  }
2360
- function Js(e, t) {
2425
+ function Qs(e, t) {
2361
2426
  let s = 0;
2362
2427
  for (const n of e) {
2363
2428
  if (!n || typeof n != "object")
@@ -2370,34 +2435,37 @@ function Js(e, t) {
2370
2435
  }
2371
2436
  return s;
2372
2437
  }
2373
- function Ot(e, t, s, n) {
2374
- if (!t || !Ys(e))
2438
+ function qt(e, t, s, n, r) {
2439
+ if (!t || !tn(e))
2375
2440
  return !1;
2376
- const r = e;
2377
- return !(at(r) || s !== null && C(r) !== s || n !== null && E(r) !== n);
2441
+ const i = e;
2442
+ return !(lt(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && C(i) !== n || r !== null && E(i) !== r);
2378
2443
  }
2379
- function Ys(e) {
2444
+ function tn(e) {
2380
2445
  if (!e || typeof e != "object")
2381
2446
  return !1;
2382
2447
  const t = e;
2383
2448
  return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted");
2384
2449
  }
2385
- function Vs(e) {
2450
+ function v(e) {
2451
+ return e.role === "assistant" && e.phase !== "commentary";
2452
+ }
2453
+ function en(e) {
2386
2454
  if (!e || typeof e != "object")
2387
2455
  return !1;
2388
2456
  const t = e;
2389
2457
  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";
2390
2458
  }
2391
- function lt(e) {
2392
- return e.filter((t, s) => Tt(t) ? !nn(e, s) && !en(e, s) && !sn(e, s) : Zs(t) ? t.retryable === !0 && tn(e, s) ? !1 : !Qs(e, s) : !0);
2459
+ function dt(e) {
2460
+ return e.filter((t, s) => wt(t) ? !cn(e, s) && !on(e, s) && !an(e, s) : sn(t) ? t.retryable === !0 && rn(e, s) ? !1 : !nn(e, s) : !0);
2393
2461
  }
2394
- function Zs(e) {
2462
+ function sn(e) {
2395
2463
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
2396
2464
  }
2397
- function Tt(e) {
2465
+ function wt(e) {
2398
2466
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2399
2467
  }
2400
- function ut(e) {
2468
+ function ht(e) {
2401
2469
  const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
2402
2470
  for (const i of e) {
2403
2471
  if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
@@ -2413,18 +2481,18 @@ function ut(e) {
2413
2481
  n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
2414
2482
  return r;
2415
2483
  }
2416
- function Qs(e, t) {
2484
+ function nn(e, t) {
2417
2485
  const s = e[t];
2418
2486
  for (let n = t + 1; n < e.length; n += 1) {
2419
2487
  const r = e[n];
2420
2488
  if (r.role === "user")
2421
2489
  return !1;
2422
- if (r.role === "assistant" && G(s, r))
2490
+ if (r.role === "assistant" && K(s, r))
2423
2491
  return !0;
2424
2492
  }
2425
2493
  return !1;
2426
2494
  }
2427
- function tn(e, t) {
2495
+ function rn(e, t) {
2428
2496
  const s = e[t];
2429
2497
  if (!s.respondsToUserMessageId)
2430
2498
  return !1;
@@ -2432,47 +2500,47 @@ function tn(e, t) {
2432
2500
  const r = e[n];
2433
2501
  if (r.role === "user")
2434
2502
  return !1;
2435
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || Tt(r)))
2503
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || wt(r)))
2436
2504
  return !0;
2437
2505
  }
2438
2506
  return !1;
2439
2507
  }
2440
- function en(e, t) {
2508
+ function on(e, t) {
2441
2509
  const s = e[t];
2442
2510
  for (let n = t + 1; n < e.length; n += 1)
2443
- if (e[n].role === "assistant" && G(s, e[n]))
2511
+ if (e[n].role === "assistant" && K(s, e[n]))
2444
2512
  return !0;
2445
2513
  return !1;
2446
2514
  }
2447
- function sn(e, t) {
2515
+ function an(e, t) {
2448
2516
  const s = e[t];
2449
2517
  for (let n = t + 1; n < e.length; n += 1)
2450
- if (e[n].role === "tool" && G(s, e[n]))
2518
+ if (e[n].role === "tool" && K(s, e[n]))
2451
2519
  return !0;
2452
2520
  return !1;
2453
2521
  }
2454
- function nn(e, t) {
2522
+ function cn(e, t) {
2455
2523
  const s = e[t];
2456
2524
  for (let n = t + 1; n < e.length; n += 1)
2457
- if (Tt(e[n]) && G(s, e[n]))
2525
+ if (wt(e[n]) && K(s, e[n]))
2458
2526
  return !0;
2459
2527
  return !1;
2460
2528
  }
2461
- function G(e, t) {
2529
+ function K(e, t) {
2462
2530
  return !e.runId || !t.runId ? !0 : e.runId === t.runId;
2463
2531
  }
2464
- function I(e, t) {
2532
+ function w(e, t) {
2465
2533
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2466
2534
  }
2467
- function rn(e, t) {
2535
+ function ln(e, t) {
2468
2536
  try {
2469
- const s = window.localStorage.getItem(`${Gt}${e}`);
2537
+ const s = window.localStorage.getItem(`${Jt}${e}`);
2470
2538
  if (!s)
2471
2539
  return null;
2472
2540
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2473
2541
  if (t !== void 0 && r !== t)
2474
2542
  return null;
2475
- const i = Array.isArray(n.messages) ? n.messages.map(yn).filter((o) => !!o) : [];
2543
+ const i = Array.isArray(n.messages) ? n.messages.map(An).filter((o) => !!o) : [];
2476
2544
  return {
2477
2545
  sessionId: r,
2478
2546
  messages: i
@@ -2481,48 +2549,48 @@ function rn(e, t) {
2481
2549
  return null;
2482
2550
  }
2483
2551
  }
2484
- function on(e, t) {
2552
+ function un(e, t) {
2485
2553
  try {
2486
2554
  window.localStorage.setItem(
2487
- `${Gt}${e}`,
2555
+ `${Jt}${e}`,
2488
2556
  JSON.stringify({
2489
2557
  sessionId: t.sessionId,
2490
- messages: t.messages.slice(-Je).map(Tn)
2558
+ messages: t.messages.slice(-Ze).map(Sn)
2491
2559
  })
2492
2560
  );
2493
2561
  } catch {
2494
2562
  return;
2495
2563
  }
2496
2564
  }
2497
- function an(e) {
2565
+ function dn(e) {
2498
2566
  try {
2499
- const t = window.localStorage.getItem(`${it}${e}`);
2567
+ const t = window.localStorage.getItem(`${at}${e}`);
2500
2568
  if (!t)
2501
2569
  return [];
2502
2570
  const s = JSON.parse(t);
2503
- return Array.isArray(s) ? s.filter(wt) : [];
2571
+ return Array.isArray(s) ? s.filter(At) : [];
2504
2572
  } catch {
2505
2573
  return [];
2506
2574
  }
2507
2575
  }
2508
- function P(e, t) {
2576
+ function D(e, t) {
2509
2577
  try {
2510
- const s = t.filter(wt);
2578
+ const s = t.filter(At);
2511
2579
  if (s.length === 0) {
2512
- window.localStorage.removeItem(`${it}${e}`);
2580
+ window.localStorage.removeItem(`${at}${e}`);
2513
2581
  return;
2514
2582
  }
2515
2583
  window.localStorage.setItem(
2516
- `${it}${e}`,
2584
+ `${at}${e}`,
2517
2585
  JSON.stringify(s.slice(-25))
2518
2586
  );
2519
2587
  } catch {
2520
2588
  return;
2521
2589
  }
2522
2590
  }
2523
- function Qt(e, t) {
2591
+ function se(e, t) {
2524
2592
  try {
2525
- const s = `${z}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2593
+ const s = `${X}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2526
2594
  ...o,
2527
2595
  storedAt: Date.now(),
2528
2596
  unloadUrl: n,
@@ -2536,28 +2604,28 @@ function Qt(e, t) {
2536
2604
  } catch {
2537
2605
  }
2538
2606
  }
2539
- function cn(e, t) {
2607
+ function hn(e, t) {
2540
2608
  try {
2541
- if (window.sessionStorage.getItem(`${z}${e}`) === null)
2609
+ if (window.sessionStorage.getItem(`${X}${e}`) === null)
2542
2610
  return;
2543
2611
  } catch {
2544
2612
  return;
2545
2613
  }
2546
- Qt(e, t);
2614
+ se(e, t);
2547
2615
  }
2548
- function ln(e) {
2616
+ function pn(e) {
2549
2617
  try {
2550
- const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
2618
+ const t = `${X}${e}`, s = window.sessionStorage.getItem(t);
2551
2619
  if (window.sessionStorage.removeItem(t), !s)
2552
2620
  return [];
2553
2621
  const n = JSON.parse(s);
2554
- return Array.isArray(n) ? n.flatMap((r) => dn(r) ? [{
2622
+ return Array.isArray(n) ? n.flatMap((r) => gn(r) ? [{
2555
2623
  ...r.event,
2556
2624
  page: S(),
2557
2625
  rawOutput: {
2558
2626
  pageContextRestarted: !0,
2559
2627
  outcome: "unknown",
2560
- message: un(location.href),
2628
+ message: fn(location.href),
2561
2629
  currentUrl: location.href,
2562
2630
  console: [],
2563
2631
  metadata: {
@@ -2574,17 +2642,17 @@ function ln(e) {
2574
2642
  return [];
2575
2643
  }
2576
2644
  }
2577
- function un(e) {
2645
+ function fn(e) {
2578
2646
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2579
2647
  Current URL: ${e}`;
2580
2648
  }
2581
- function dn(e) {
2649
+ function gn(e) {
2582
2650
  if (!e || typeof e != "object")
2583
2651
  return !1;
2584
2652
  const t = e, s = t.event;
2585
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && wt(s) && s.type === "tool.result";
2653
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && At(s) && s.type === "tool.result";
2586
2654
  }
2587
- function hn(e, t) {
2655
+ function mn(e, t) {
2588
2656
  const s = new Set(
2589
2657
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2590
2658
  );
@@ -2593,26 +2661,26 @@ function hn(e, t) {
2593
2661
  ...t.filter((n) => !s.has(n.callId))
2594
2662
  ];
2595
2663
  }
2596
- function pn(e) {
2664
+ function yn(e) {
2597
2665
  try {
2598
- window.sessionStorage.removeItem(`${z}${e}`);
2666
+ window.sessionStorage.removeItem(`${X}${e}`);
2599
2667
  } catch {
2600
2668
  return;
2601
2669
  }
2602
2670
  }
2603
- function wt(e) {
2671
+ function At(e) {
2604
2672
  if (!e || typeof e != "object")
2605
2673
  return !1;
2606
2674
  const t = e;
2607
- return t.type === "chat.user_message" ? typeof t.content == "string" && Lt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Lt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
2675
+ return t.type === "chat.user_message" ? typeof t.content == "string" && xt(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? xt(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
2608
2676
  }
2609
- function Lt(e) {
2677
+ function xt(e) {
2610
2678
  if (!e || typeof e != "object")
2611
2679
  return !1;
2612
2680
  const t = e;
2613
2681
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
2614
2682
  }
2615
- function te(e, t) {
2683
+ function ne(e, t) {
2616
2684
  if (!Array.isArray(e))
2617
2685
  return;
2618
2686
  const s = e.filter((r) => {
@@ -2620,24 +2688,24 @@ function te(e, t) {
2620
2688
  return !1;
2621
2689
  const i = r;
2622
2690
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
2623
- }), n = t ? s.map((r) => ee(r, t)) : s;
2691
+ }), n = t ? s.map((r) => re(r, t)) : s;
2624
2692
  return n.length > 0 ? n : void 0;
2625
2693
  }
2626
- function ee(e, t) {
2694
+ function re(e, t) {
2627
2695
  return e.fileUrl?.startsWith("/") ? {
2628
2696
  ...e,
2629
2697
  fileUrl: new URL(e.fileUrl, t).toString()
2630
2698
  } : e;
2631
2699
  }
2632
- function fn(e) {
2633
- if (gn(e))
2700
+ function In(e) {
2701
+ if (Tn(e))
2634
2702
  return {
2635
2703
  headers: {
2636
2704
  "ngrok-skip-browser-warning": "true"
2637
2705
  }
2638
2706
  };
2639
2707
  }
2640
- function gn(e) {
2708
+ function Tn(e) {
2641
2709
  try {
2642
2710
  const t = new URL(e).hostname;
2643
2711
  return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
@@ -2645,14 +2713,14 @@ function gn(e) {
2645
2713
  return !1;
2646
2714
  }
2647
2715
  }
2648
- function Bt(e) {
2649
- return e.type || mn(e.name) || "application/octet-stream";
2716
+ function Ft(e) {
2717
+ return e.type || wn(e.name) || "application/octet-stream";
2650
2718
  }
2651
- function mn(e) {
2719
+ function wn(e) {
2652
2720
  const t = e.toLowerCase();
2653
2721
  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;
2654
2722
  }
2655
- function yn(e) {
2723
+ function An(e) {
2656
2724
  if (!e || typeof e != "object")
2657
2725
  return null;
2658
2726
  const t = e;
@@ -2665,17 +2733,17 @@ function yn(e) {
2665
2733
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
2666
2734
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
2667
2735
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
2668
- attachments: te(t.attachments)?.map(It),
2736
+ attachments: ne(t.attachments)?.map(St),
2669
2737
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2670
2738
  };
2671
2739
  }
2672
- function Tn(e) {
2740
+ function Sn(e) {
2673
2741
  return e.attachments?.length ? {
2674
2742
  ...e,
2675
- attachments: e.attachments.map(It)
2743
+ attachments: e.attachments.map(St)
2676
2744
  } : e;
2677
2745
  }
2678
- function It(e) {
2746
+ function St(e) {
2679
2747
  const {
2680
2748
  dataUrl: t,
2681
2749
  objectUrl: s,
@@ -2692,39 +2760,39 @@ function E(e) {
2692
2760
  const t = e.runId;
2693
2761
  return typeof t == "string" && t ? t : null;
2694
2762
  }
2695
- function wn(e) {
2763
+ function kn(e) {
2696
2764
  const t = e?.timeoutMs;
2697
- 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 <= ns);
2765
+ 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 <= os);
2698
2766
  }
2699
- function se(e) {
2767
+ function ie(e) {
2700
2768
  const t = {};
2701
2769
  try {
2702
2770
  new Headers(e).forEach((s, n) => {
2703
- Object.keys(t).length < ft && (t[n] = At(n, s));
2771
+ Object.keys(t).length < mt && (t[n] = kt(n, s));
2704
2772
  });
2705
2773
  } catch {
2706
2774
  return {};
2707
2775
  }
2708
2776
  return t;
2709
2777
  }
2710
- function At(e, t) {
2711
- return ce(e) ? X : _(j(t), Ge);
2778
+ function kt(e, t) {
2779
+ return de(e) ? J : _(z(t), Je);
2712
2780
  }
2713
- function In(e, t) {
2781
+ function En(e, t) {
2714
2782
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2715
2783
  }
2716
- async function An(e, t, s, n) {
2717
- const r = se(e.headers);
2784
+ async function _n(e, t, s, n) {
2785
+ const r = ie(e.headers);
2718
2786
  n({
2719
2787
  ...t,
2720
2788
  responseStatus: e.status,
2721
2789
  responseHeaders: r,
2722
- responseBody: await Sn(e),
2790
+ responseBody: await Rn(e),
2723
2791
  durationMs: Date.now() - s
2724
2792
  });
2725
2793
  }
2726
- async function Sn(e) {
2727
- if (!ne(e.headers))
2794
+ async function Rn(e) {
2795
+ if (!oe(e.headers))
2728
2796
  return;
2729
2797
  let t = null, s = null;
2730
2798
  try {
@@ -2733,7 +2801,7 @@ async function Sn(e) {
2733
2801
  const n = new Promise((c) => {
2734
2802
  s = window.setTimeout(() => {
2735
2803
  t?.cancel(), c("timeout");
2736
- }, Xe);
2804
+ }, Ye);
2737
2805
  }), r = new TextDecoder();
2738
2806
  let i = "", o = 0;
2739
2807
  for (; ; ) {
@@ -2743,7 +2811,7 @@ async function Sn(e) {
2743
2811
  const { done: u, value: l } = c;
2744
2812
  if (u)
2745
2813
  return _(i + r.decode());
2746
- const a = pt - o;
2814
+ const a = gt - o;
2747
2815
  if (l.byteLength > a)
2748
2816
  return i += r.decode(l.subarray(0, Math.max(a, 0)), { stream: !0 }), t.cancel(), `${_(i)}... [truncated]`;
2749
2817
  o += l.byteLength, i += r.decode(l, { stream: !0 });
@@ -2755,45 +2823,45 @@ async function Sn(e) {
2755
2823
  s !== null && window.clearTimeout(s);
2756
2824
  }
2757
2825
  }
2758
- function kn(e, t) {
2759
- if (ne(new Headers(t)))
2826
+ function Cn(e, t) {
2827
+ if (oe(new Headers(t)))
2760
2828
  try {
2761
2829
  return e.responseType === "" || e.responseType === "text" ? _(e.responseText ?? "") : void 0;
2762
2830
  } catch {
2763
2831
  return;
2764
2832
  }
2765
2833
  }
2766
- function qt(e) {
2834
+ function Ht(e) {
2767
2835
  if (typeof e == "string")
2768
2836
  return _(e);
2769
2837
  }
2770
- function En(e) {
2838
+ function bn(e) {
2771
2839
  return k({
2772
2840
  ...e,
2773
- requestBody: xt(e.requestBody),
2774
- responseBody: xt(e.responseBody)
2841
+ requestBody: Wt(e.requestBody),
2842
+ responseBody: Wt(e.responseBody)
2775
2843
  });
2776
2844
  }
2777
- function xt(e) {
2845
+ function Wt(e) {
2778
2846
  if (typeof e != "string")
2779
2847
  return e;
2780
2848
  const t = e.trim();
2781
2849
  if (!t.startsWith("{") && !t.startsWith("["))
2782
- return j(e);
2850
+ return z(e);
2783
2851
  try {
2784
2852
  return JSON.stringify(k(JSON.parse(e)));
2785
2853
  } catch {
2786
- return j(e);
2854
+ return z(e);
2787
2855
  }
2788
2856
  }
2789
- function ne(e) {
2857
+ function oe(e) {
2790
2858
  if (!e)
2791
2859
  return !1;
2792
2860
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
2793
- return s !== null && Number.isInteger(n) && n >= 0 && n <= pt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2861
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= gt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2794
2862
  }
2795
2863
  function M(e, t = {}, s) {
2796
- if (Rn(s))
2864
+ if (Un(s))
2797
2865
  return !0;
2798
2866
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
2799
2867
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -2808,7 +2876,7 @@ function M(e, t = {}, s) {
2808
2876
  return !0;
2809
2877
  }
2810
2878
  }
2811
- function _n(e, t) {
2879
+ function Mn(e, t) {
2812
2880
  if (M(e))
2813
2881
  return !0;
2814
2882
  try {
@@ -2818,115 +2886,115 @@ function _n(e, t) {
2818
2886
  return !0;
2819
2887
  }
2820
2888
  }
2821
- function Rn(e) {
2889
+ function Un(e) {
2822
2890
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
2823
2891
  }
2824
- function Cn(e) {
2892
+ function Pn(e) {
2825
2893
  const t = {};
2826
2894
  for (const s of e.trim().split(/[\r\n]+/)) {
2827
2895
  const n = s.indexOf(":");
2828
2896
  if (n <= 0)
2829
2897
  continue;
2830
- if (Object.keys(t).length >= ft)
2898
+ if (Object.keys(t).length >= mt)
2831
2899
  break;
2832
2900
  const r = s.slice(0, n).trim();
2833
- t[r] = At(r, s.slice(n + 1).trim());
2901
+ t[r] = kt(r, s.slice(n + 1).trim());
2834
2902
  }
2835
2903
  return t;
2836
2904
  }
2837
- function _(e, t = pt) {
2905
+ function _(e, t = gt) {
2838
2906
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
2839
2907
  }
2840
- function tt(e) {
2908
+ function st(e) {
2841
2909
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
2842
2910
  }
2843
- class F extends Error {
2911
+ class W extends Error {
2844
2912
  constructor(t, s) {
2845
2913
  super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
2846
2914
  }
2847
2915
  status;
2848
2916
  }
2849
- async function et(e, t) {
2917
+ async function nt(e, t) {
2850
2918
  let s = null;
2851
- for (let n = 0; n < Rt; n += 1)
2919
+ for (let n = 0; n < bt; n += 1)
2852
2920
  try {
2853
2921
  return await e();
2854
2922
  } catch (r) {
2855
- if (s = r, n >= Rt - 1 || !Mn(r))
2923
+ if (s = r, n >= bt - 1 || !Nn(r))
2856
2924
  throw r;
2857
- await bn(n);
2925
+ await Dn(n);
2858
2926
  }
2859
2927
  throw s instanceof Error ? s : new Error(t);
2860
2928
  }
2861
- function bn(e) {
2929
+ function Dn(e) {
2862
2930
  return new Promise((t) => {
2863
- window.setTimeout(t, ze[e] ?? 0);
2931
+ window.setTimeout(t, Ke[e] ?? 0);
2864
2932
  });
2865
2933
  }
2866
- function Mn(e) {
2867
- return e instanceof F ? Un(e.status) : e instanceof TypeError;
2934
+ function Nn(e) {
2935
+ return e instanceof W ? On(e.status) : e instanceof TypeError;
2868
2936
  }
2869
- function Un(e) {
2937
+ function On(e) {
2870
2938
  return e === 408 || e === 409 || e === 429 || e >= 500;
2871
2939
  }
2872
- function Pn(e) {
2940
+ function vn(e) {
2873
2941
  return e === 401 || e === 403;
2874
2942
  }
2875
- const X = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Dn = "[REDACTED_SIGNED_URL]", vn = 20, Nn = /^(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, re = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ie = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, oe = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ae = /\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, On = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Ln = /\bhttps?:\/\/[^\s"'<>]+/gi, Bn = /[),.;\]]+$/;
2943
+ const J = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", Ln = "[REDACTED_SIGNED_URL]", Bn = 20, qn = /^(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, ae = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ce = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, le = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ue = /\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, xn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Fn = /\bhttps?:\/\/[^\s"'<>]+/gi, Hn = /[),.;\]]+$/;
2876
2944
  function k(e) {
2877
- return W(e, 0, /* @__PURE__ */ new WeakSet());
2945
+ return $(e, 0, /* @__PURE__ */ new WeakSet());
2878
2946
  }
2879
- function W(e, t, s) {
2947
+ function $(e, t, s) {
2880
2948
  if (typeof e == "string")
2881
- return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
2949
+ return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : z(e);
2882
2950
  if (e === null || typeof e != "object")
2883
2951
  return e;
2884
- if (t >= vn)
2952
+ if (t >= Bn)
2885
2953
  return "[REDACTED_MAX_DEPTH]";
2886
2954
  if (s.has(e))
2887
2955
  return "[REDACTED_CIRCULAR]";
2888
2956
  if (s.add(e), Array.isArray(e))
2889
- return e.map((r) => W(r, t + 1, s));
2957
+ return e.map((r) => $(r, t + 1, s));
2890
2958
  const n = {};
2891
2959
  for (const [r, i] of Object.entries(e))
2892
- ce(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? qn(i) : W(i, t + 1, s);
2960
+ de(r) ? n[r] = J : n[r] = r.toLowerCase() === "url" ? Wn(i) : $(i, t + 1, s);
2893
2961
  return n;
2894
2962
  }
2895
- function ce(e) {
2963
+ function de(e) {
2896
2964
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
2897
2965
  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");
2898
2966
  }
2899
- function qn(e) {
2900
- return typeof e == "string" ? le(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
2967
+ function Wn(e) {
2968
+ return typeof e == "string" ? he(e) : $(e, 0, /* @__PURE__ */ new WeakSet());
2901
2969
  }
2902
- function le(e) {
2970
+ function he(e) {
2903
2971
  try {
2904
2972
  const t = new URL(e, location.href);
2905
2973
  for (const s of Array.from(t.searchParams.keys()))
2906
- Nn.test(s) && t.searchParams.set(s, R);
2974
+ qn.test(s) && t.searchParams.set(s, R);
2907
2975
  return t.username && (t.username = R), t.password && (t.password = R), t.toString();
2908
2976
  } catch {
2909
- return xn(e);
2977
+ return jn(e);
2910
2978
  }
2911
2979
  }
2912
- function j(e) {
2913
- return e.replace(On, Dn).replace(Ln, Fn).replace(re, `Bearer ${R}`).replace(ie, `Basic ${R}`).replace(oe, R).replace(ae, (t, s) => `${s}: ${X}`);
2980
+ function z(e) {
2981
+ return e.replace(xn, Ln).replace(Fn, $n).replace(ae, `Bearer ${R}`).replace(ce, `Basic ${R}`).replace(le, R).replace(ue, (t, s) => `${s}: ${J}`);
2914
2982
  }
2915
- function xn(e) {
2916
- return e.replace(re, `Bearer ${R}`).replace(ie, `Basic ${R}`).replace(oe, R).replace(ae, (t, s) => `${s}: ${X}`);
2983
+ function jn(e) {
2984
+ return e.replace(ae, `Bearer ${R}`).replace(ce, `Basic ${R}`).replace(le, R).replace(ue, (t, s) => `${s}: ${J}`);
2917
2985
  }
2918
- function Fn(e) {
2919
- const t = e.match(Bn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2920
- return `${le(s)}${t}`;
2986
+ function $n(e) {
2987
+ const t = e.match(Hn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2988
+ return `${he(s)}${t}`;
2921
2989
  }
2922
2990
  export {
2923
- St as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2924
- rt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2925
- be as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2926
- Ce as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2927
- Me as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2928
- Xt as PlunoProductAgent,
2929
- Ve as calculateReconnectDelay,
2930
- Xt as default,
2931
- ys as getProductAgentOriginAccessErrorMessage
2991
+ Et as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2992
+ ot as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2993
+ Pe as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2994
+ Ue as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2995
+ De as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2996
+ Yt as PlunoProductAgent,
2997
+ ts as calculateReconnectDelay,
2998
+ Yt as default,
2999
+ ws as getProductAgentOriginAccessErrorMessage
2932
3000
  };