@pluno/product-agent-web 0.1.76 → 0.1.78

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 Kt = "pluno-product-agent-attachments";
2
- const Z = "files";
3
- async function _t(e) {
4
- const t = await x();
5
- await bt(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function Jt(e) {
8
- const t = await x(), s = await bt(
1
+ const te = "pluno-product-agent-attachments";
2
+ const tt = "files";
3
+ async function Ut(e) {
4
+ const t = await F();
5
+ await Nt(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function ee(e) {
8
+ const t = await F(), s = await Nt(
9
9
  t,
10
10
  "readonly",
11
11
  (r) => r.get(e)
@@ -13,12 +13,12 @@ async function Jt(e) {
13
13
  if (!s)
14
14
  return null;
15
15
  const n = Date.now();
16
- return await Ct(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
16
+ return await Dt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
17
17
  }
18
- async function Ct(e, t) {
19
- const s = await x();
20
- await rt(s, "readwrite", async (n) => {
21
- const r = await it(
18
+ async function Dt(e, t) {
19
+ const s = await F();
20
+ await at(s, "readwrite", async (n) => {
21
+ const r = await ct(
22
22
  n.get(e)
23
23
  );
24
24
  r && n.put({
@@ -27,40 +27,40 @@ async function Ct(e, t) {
27
27
  });
28
28
  });
29
29
  }
30
- async function Vt(e = 864e5) {
31
- const t = await x(), s = Date.now() - e;
32
- await rt(t, "readwrite", async (n) => {
30
+ async function se(e = 864e5) {
31
+ const t = await F(), s = Date.now() - e;
32
+ await at(t, "readwrite", async (n) => {
33
33
  const r = n.index("lastUsedAt");
34
- (await it(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
34
+ (await ct(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
35
35
  });
36
36
  }
37
- function x() {
37
+ function F() {
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(Kt, 1);
39
+ const s = indexedDB.open(te, 1);
40
40
  s.onupgradeneeded = () => {
41
- const r = s.result.createObjectStore(Z, { keyPath: "attachmentId" });
41
+ const r = s.result.createObjectStore(tt, { 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 bt(e, t, s) {
47
- return await rt(e, t, async (n) => await it(s(n)));
46
+ async function Nt(e, t, s) {
47
+ return await at(e, t, async (n) => await ct(s(n)));
48
48
  }
49
- function rt(e, t, s) {
49
+ function at(e, t, s) {
50
50
  return new Promise((n, r) => {
51
- const i = e.transaction(Z, t), o = i.objectStore(Z);
52
- let l, u = !1;
53
- s(o).then((a) => {
54
- l = a;
55
- }).catch((a) => {
51
+ const i = e.transaction(tt, t), o = i.objectStore(tt);
52
+ let c, u = !1;
53
+ s(o).then((l) => {
54
+ c = l;
55
+ }).catch((l) => {
56
56
  u = !0;
57
57
  try {
58
58
  i.abort();
59
59
  } catch {
60
60
  }
61
- r(a);
61
+ r(l);
62
62
  }), i.oncomplete = () => {
63
- u || n(l);
63
+ u || n(c);
64
64
  }, i.onerror = () => {
65
65
  u || (u = !0, r(i.error ?? new Error("Product Agent attachment storage transaction failed")));
66
66
  }, i.onabort = () => {
@@ -68,16 +68,16 @@ function rt(e, t, s) {
68
68
  };
69
69
  });
70
70
  }
71
- function it(e) {
71
+ function ct(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 Yt(e) {
76
+ function ne(e) {
77
77
  return e !== null && (typeof e == "object" || typeof e == "function");
78
78
  }
79
- function Zt(e, t, s) {
80
- const n = Reflect.get(e, "pluno"), r = Yt(n) ? n : {};
79
+ function re(e, t, s) {
80
+ const n = Reflect.get(e, "pluno"), r = ne(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,11 +91,213 @@ function Zt(e, t, s) {
91
91
  }
92
92
  };
93
93
  }
94
- const z = "pluno.productAgent.transportId", Qt = "pluno.productAgent.transportIdentity", G = "pluno.productAgent.transportIdentity.event", te = 50, ee = globalThis.setTimeout.bind(globalThis);
95
- let b = null;
96
- const v = /* @__PURE__ */ new Set();
97
- async function se(e = Mt()) {
98
- const t = e.randomUUID(), s = e.storage.getItem(z);
94
+ const et = "pluno.productAgent.scheduledChatContinuation.", vt = "plunoScheduledContinuation", lt = 10080 * 6e4, ie = 5e3, oe = 15e3;
95
+ function ae(e, { callId: t }) {
96
+ return `const plunoScheduledContinuation = Object.freeze(${JSON.stringify({
97
+ defaultTaskId: `scheduled-${t}`,
98
+ resultKey: vt,
99
+ expiresAfterDueMs: lt
100
+ })});
101
+ ${e}`;
102
+ }
103
+ async function ce(e, {
104
+ clientId: t,
105
+ sessionId: s,
106
+ callId: n
107
+ }, r) {
108
+ try {
109
+ const i = le(e, {
110
+ clientId: t,
111
+ sessionId: s,
112
+ callId: n
113
+ });
114
+ if (!i)
115
+ return e;
116
+ if (!await r(i))
117
+ throw new Error("Scheduled continuations are unavailable in this runtime.");
118
+ return mt(e, {
119
+ ok: !0,
120
+ id: i.id,
121
+ dueAt: i.dueAt
122
+ });
123
+ } catch (i) {
124
+ return mt(e, {
125
+ ok: !1,
126
+ error: i instanceof Error ? i.message : String(i)
127
+ });
128
+ }
129
+ }
130
+ function le(e, {
131
+ clientId: t,
132
+ sessionId: s,
133
+ callId: n
134
+ }) {
135
+ if (!e || typeof e != "object")
136
+ return null;
137
+ const r = e;
138
+ if (r.ok !== !0 || !r.result || typeof r.result != "object")
139
+ return null;
140
+ const i = r.result[vt];
141
+ if (i === void 0)
142
+ return null;
143
+ if (!i || typeof i != "object")
144
+ throw new Error("Scheduled continuation instruction must be an object.");
145
+ const o = i, c = `scheduled-${n}`;
146
+ if ((o.id ?? c) !== c)
147
+ throw new Error("Scheduled continuation id must use plunoScheduledContinuation.defaultTaskId.");
148
+ if (typeof o.prompt != "string" || o.prompt.trim().length === 0)
149
+ throw new Error("Scheduled continuation prompt must be a non-empty string.");
150
+ if (typeof o.dueAt != "number" || !Number.isFinite(o.dueAt))
151
+ throw new Error("Scheduled continuation dueAt must be a finite Unix time in milliseconds.");
152
+ return {
153
+ id: c,
154
+ clientId: t,
155
+ sessionId: s,
156
+ prompt: o.prompt.trim(),
157
+ dueAt: o.dueAt,
158
+ expiresAt: o.dueAt + lt
159
+ };
160
+ }
161
+ function ue(e) {
162
+ const t = e.storage === void 0 ? de() : e.storage;
163
+ let s = null, n = !1, r = !1, i = !1, o = t !== null;
164
+ const c = /* @__PURE__ */ new Map(), u = () => {
165
+ s !== null && (clearTimeout(s), s = null);
166
+ }, l = () => {
167
+ u(), !(i || !o) && (s = setTimeout(() => {
168
+ s = null, h();
169
+ }, ie));
170
+ }, a = () => {
171
+ o = !1, u();
172
+ }, h = async () => {
173
+ if (!(i || !o || !t)) {
174
+ if (n) {
175
+ r = !0;
176
+ return;
177
+ }
178
+ n = !0;
179
+ try {
180
+ const f = Date.now();
181
+ for (const [g, I] of c)
182
+ I <= f && c.delete(g);
183
+ const w = await t.list(), m = [];
184
+ for (const g of w) {
185
+ if (!U(g)) {
186
+ const I = g && typeof g == "object" ? g.id : null;
187
+ typeof I == "string" && await t.remove(I);
188
+ continue;
189
+ }
190
+ if (g.expiresAt <= f) {
191
+ await t.remove(g.id), c.delete(g.id);
192
+ continue;
193
+ }
194
+ m.push(g);
195
+ }
196
+ e.onTasksChanged?.(m);
197
+ for (const g of m)
198
+ if (!(g.clientId !== e.clientId || g.dueAt > f || c.has(g.id) || !await e.canDeliver(g))) {
199
+ c.set(g.id, f + oe);
200
+ try {
201
+ await e.deliver(g);
202
+ } catch {
203
+ c.delete(g.id);
204
+ }
205
+ }
206
+ } catch {
207
+ a();
208
+ } finally {
209
+ n = !1, r ? (r = !1, h()) : l();
210
+ }
211
+ }
212
+ }, T = async (f) => {
213
+ if (i || !o || !t || !U(f))
214
+ return !1;
215
+ try {
216
+ return await t.set(f), e.onTasksChanged?.((await t.list()).filter(U)), await h(), !0;
217
+ } catch {
218
+ return a(), !1;
219
+ }
220
+ }, p = async (f) => {
221
+ if (c.delete(f), i || !o || !t)
222
+ return !1;
223
+ try {
224
+ return await t.remove(f), e.onTasksChanged?.((await t.list()).filter(U)), !0;
225
+ } catch {
226
+ return a(), !1;
227
+ }
228
+ }, d = t?.subscribe?.(() => {
229
+ h();
230
+ }) ?? null;
231
+ return o && h(), {
232
+ processDueTasks: h,
233
+ scheduleTask: T,
234
+ acknowledgeTask: p,
235
+ isAvailable: () => o,
236
+ destroy() {
237
+ i = !0, u(), d?.(), c.clear();
238
+ }
239
+ };
240
+ }
241
+ function U(e) {
242
+ if (!e || typeof e != "object")
243
+ return !1;
244
+ const t = e;
245
+ 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 + lt;
246
+ }
247
+ function de() {
248
+ let e;
249
+ try {
250
+ e = window.localStorage, e.length;
251
+ } catch {
252
+ return null;
253
+ }
254
+ return {
255
+ async list() {
256
+ const t = [];
257
+ for (let s = 0; s < e.length; s += 1) {
258
+ const n = e.key(s);
259
+ if (!n?.startsWith(et))
260
+ continue;
261
+ const r = e.getItem(n);
262
+ if (r)
263
+ try {
264
+ const i = JSON.parse(r);
265
+ U(i) && n === G(i.id) ? t.push(i) : (e.removeItem(n), s -= 1);
266
+ } catch {
267
+ e.removeItem(n), s -= 1;
268
+ }
269
+ }
270
+ return t;
271
+ },
272
+ async set(t) {
273
+ e.setItem(G(t.id), JSON.stringify(t));
274
+ },
275
+ async remove(t) {
276
+ e.removeItem(G(t));
277
+ },
278
+ subscribe(t) {
279
+ const s = (n) => {
280
+ n.key?.startsWith(et) && t();
281
+ };
282
+ return window.addEventListener("storage", s), () => window.removeEventListener("storage", s);
283
+ }
284
+ };
285
+ }
286
+ function mt(e, t) {
287
+ return {
288
+ ...e && typeof e == "object" ? e : { result: e },
289
+ ...t.ok === !1 ? { ok: !1 } : {},
290
+ scheduledContinuation: t
291
+ };
292
+ }
293
+ function G(e) {
294
+ return `${et}${e}`;
295
+ }
296
+ const X = "pluno.productAgent.transportId", he = "pluno.productAgent.transportIdentity", K = "pluno.productAgent.transportIdentity.event", pe = 50, fe = globalThis.setTimeout.bind(globalThis);
297
+ let M = null;
298
+ const L = /* @__PURE__ */ new Set();
299
+ async function ge(e = Ot()) {
300
+ const t = e.randomUUID(), s = e.storage.getItem(X);
99
301
  let n = s ?? e.randomUUID(), r = !1, i = !1;
100
302
  const o = e.channel.subscribe((u) => {
101
303
  if (!(u.senderId === t || u.transportId !== n)) {
@@ -113,58 +315,58 @@ async function se(e = Mt()) {
113
315
  }
114
316
  });
115
317
  if (!s)
116
- e.storage.setItem(z, n), r = !0;
318
+ e.storage.setItem(X, n), r = !0;
117
319
  else
118
320
  for (; ; ) {
119
321
  if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
120
322
  r = !0;
121
323
  break;
122
324
  }
123
- n = e.randomUUID(), e.storage.setItem(z, n);
325
+ n = e.randomUUID(), e.storage.setItem(X, n);
124
326
  }
125
- let l = !1;
327
+ let c = !1;
126
328
  return {
127
329
  transportId: n,
128
330
  release: () => {
129
- l || (l = !0, o(), e.channel.close());
331
+ c || (c = !0, o(), e.channel.close());
130
332
  }
131
333
  };
132
334
  }
133
- async function ne() {
134
- b || (b = se(Mt()), b.then((n) => {
335
+ async function me() {
336
+ M || (M = ge(Ot()), M.then((n) => {
135
337
  const r = (i) => {
136
- i.persisted || (n.release(), b = null, v.clear(), window.removeEventListener("pagehide", r));
338
+ i.persisted || (n.release(), M = null, L.clear(), window.removeEventListener("pagehide", r));
137
339
  };
138
340
  window.addEventListener("pagehide", r);
139
341
  }));
140
- const e = await b, t = re();
141
- v.add(t);
342
+ const e = await M, t = ye();
343
+ L.add(t);
142
344
  let s = !1;
143
345
  return {
144
346
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
145
347
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
146
348
  release: () => {
147
- s || (s = !0, v.delete(t));
349
+ s || (s = !0, L.delete(t));
148
350
  }
149
351
  };
150
352
  }
151
- function re() {
353
+ function ye() {
152
354
  let e = 0;
153
- for (; v.has(e); )
355
+ for (; L.has(e); )
154
356
  e += 1;
155
357
  return e;
156
358
  }
157
- function Mt() {
359
+ function Ot() {
158
360
  return {
159
361
  storage: window.sessionStorage,
160
- channel: ie(),
362
+ channel: Te(),
161
363
  randomUUID: () => crypto.randomUUID(),
162
- settle: () => new Promise((e) => ee(e, te))
364
+ settle: () => new Promise((e) => fe(e, pe))
163
365
  };
164
366
  }
165
- function ie() {
367
+ function Te() {
166
368
  if (typeof BroadcastChannel < "u") {
167
- const e = new BroadcastChannel(Qt);
369
+ const e = new BroadcastChannel(he);
168
370
  return {
169
371
  postMessage: (t) => e.postMessage(t),
170
372
  subscribe: (t) => {
@@ -174,11 +376,11 @@ function ie() {
174
376
  close: () => e.close()
175
377
  };
176
378
  }
177
- return oe();
379
+ return we();
178
380
  }
179
- function oe() {
381
+ function we() {
180
382
  const e = /* @__PURE__ */ new Set(), t = (s) => {
181
- if (s.key !== G || !s.newValue)
383
+ if (s.key !== K || !s.newValue)
182
384
  return;
183
385
  const n = JSON.parse(s.newValue);
184
386
  for (const r of e)
@@ -187,9 +389,9 @@ function oe() {
187
389
  return window.addEventListener("storage", t), {
188
390
  postMessage: (s) => {
189
391
  window.localStorage.setItem(
190
- G,
392
+ K,
191
393
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
192
- ), window.localStorage.removeItem(G);
394
+ ), window.localStorage.removeItem(K);
193
395
  },
194
396
  subscribe: (s) => (e.add(s), () => e.delete(s)),
195
397
  close: () => {
@@ -197,17 +399,17 @@ function oe() {
197
399
  }
198
400
  };
199
401
  }
200
- const Q = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ae = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ce = ".pluno-pa-widget__panel", le = ".pluno-pa-widget__timeline", ht = `${Q}[data-pluno-sdk-preview-channel]`, ue = "https://app.pluno.ai", de = "gpt-5.6-terra", he = 2e4, pe = 1e4, fe = 1e4, ge = 1e4, me = 1e4, ye = 1e3, pt = 3e4, ft = 0.2, gt = 6e4, Te = 15e3, U = 3, we = 2e3, Ie = 15e3, Ae = 1e3, Se = 100, ke = 8e3, Ee = 15e3, mt = 3, Re = [300, 1e3], ot = 64e3, X = 4e3, at = 30, _e = 2e3, Ce = 1e3, be = 200 * 1024 * 1024, Me = "Image is too large for model vision input.", Pe = 100, Pt = "pluno.productAgent.state.", tt = "pluno.productAgent.pendingEvents.", F = "pluno.productAgent.activeToolCalls.", Ue = 100;
201
- function D(e, t = 0) {
202
- return Math.max(t, we * 4 ** e);
402
+ const st = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ie = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ae = ".pluno-pa-widget__panel", Se = ".pluno-pa-widget__timeline", yt = `${st}[data-pluno-sdk-preview-channel]`, ke = "https://app.pluno.ai", Ee = "gpt-5.6-terra", Re = 2e4, Ce = 1e4, _e = 1e4, be = 1e4, Me = 1e4, Pe = 1e3, Tt = 3e4, wt = 0.2, It = 6e4, Ue = 15e3, D = 3, De = 2e3, Ne = 15e3, ve = 1e3, Oe = 100, Le = 8e3, Be = 15e3, At = 3, xe = [300, 1e3], ut = 64e3, J = 4e3, dt = 30, qe = 2e3, He = 1e3, Fe = 200 * 1024 * 1024, We = "Image is too large for model vision input.", je = 100, Lt = "pluno.productAgent.state.", nt = "pluno.productAgent.pendingEvents.", W = "pluno.productAgent.activeToolCalls.", $e = 100;
403
+ function N(e, t = 0) {
404
+ return Math.max(t, De * 4 ** e);
203
405
  }
204
- const L = /* @__PURE__ */ new Set();
205
- let N = null;
206
- function De(e, t = Math.random) {
207
- const s = Math.min(pt, ye * 2 ** e), n = 1 - ft + t() * ft * 2;
208
- return Math.min(pt, Math.round(s * n));
406
+ const B = /* @__PURE__ */ new Set();
407
+ let v = null;
408
+ function ze(e, t = Math.random) {
409
+ const s = Math.min(Tt, Pe * 2 ** e), n = 1 - wt + t() * wt * 2;
410
+ return Math.min(Tt, Math.round(s * n));
209
411
  }
210
- function Ne(e, t, s) {
412
+ function Ge(e, t, s) {
211
413
  return new Promise((n, r) => {
212
414
  const i = setTimeout(() => r(new Error(s)), t);
213
415
  e.then(
@@ -220,13 +422,13 @@ function Ne(e, t, s) {
220
422
  );
221
423
  });
222
424
  }
223
- class Ut {
425
+ class Bt {
224
426
  constructor(t, s) {
225
427
  this.options = t, this.transportIdentity = s, this.state = {
226
428
  ...this.state,
227
- starterPrompts: Ze(t.initialStarterPrompts)
429
+ starterPrompts: hs(t.initialStarterPrompts)
228
430
  };
229
- const n = t.restorePersistedState === !1 ? null : bs(t.clientId, t.expectedPersistedSessionId);
431
+ const n = t.restorePersistedState === !1 ? null : Ws(t.clientId, t.expectedPersistedSessionId);
230
432
  n && (this.state = {
231
433
  ...this.state,
232
434
  ...n,
@@ -237,10 +439,17 @@ class Ut {
237
439
  assistantDraftRunId: null,
238
440
  isThinking: !1,
239
441
  lastError: null
240
- }), this.queuedClientEvents = Os(
241
- Ps(t.clientId),
242
- Ds(t.clientId)
243
- ), M(t.clientId, this.queuedClientEvents);
442
+ }), this.queuedClientEvents = Js(
443
+ $s(t.clientId),
444
+ Gs(t.clientId)
445
+ ), P(t.clientId, this.queuedClientEvents), this.scheduledChatContinuationScheduler = ue({
446
+ clientId: t.clientId,
447
+ canDeliver: (r) => r.sessionId === this.state.sessionId,
448
+ deliver: async (r) => {
449
+ if (!this.sendMessage(r.prompt, { clientMessageId: r.id }))
450
+ throw new Error("Scheduled continuation could not be sent.");
451
+ }
452
+ });
244
453
  }
245
454
  options;
246
455
  listeners = {};
@@ -275,6 +484,7 @@ class Ut {
275
484
  attachmentBlobCache = /* @__PURE__ */ new Map();
276
485
  sessionUserFilesApiCleanup = null;
277
486
  activeBrowserToolCalls = /* @__PURE__ */ new Map();
487
+ scheduledChatContinuationScheduler;
278
488
  pageLifecycleCleanup = null;
279
489
  transientStarterPromptsRequestInFlight = !1;
280
490
  transientStarterPromptsRequestAttempted = !1;
@@ -297,15 +507,15 @@ class Ut {
297
507
  lastErrorCode: null
298
508
  };
299
509
  static async init(t) {
300
- const s = await ne(), n = new Ut({
510
+ const s = await me(), n = new Bt({
301
511
  ...t,
302
- backendUrl: je(t.backendUrl ?? ue),
303
- clientId: t.clientId ?? ns(),
304
- model: t.model ?? de
512
+ backendUrl: ns(t.backendUrl ?? ke),
513
+ clientId: t.clientId ?? ys(),
514
+ model: t.model ?? Ee
305
515
  }, s);
306
516
  try {
307
- Vt().catch((r) => {
308
- p("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
517
+ se().catch((r) => {
518
+ y("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
309
519
  message: r instanceof Error ? r.message : String(r)
310
520
  });
311
521
  }), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
@@ -336,15 +546,15 @@ class Ut {
336
546
  lastError: null
337
547
  });
338
548
  try {
339
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ne(this.options.tokenProvider(), fe, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
549
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ge(this.options.tokenProvider(), _e, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
340
550
  return;
341
551
  if (!this.token && !this.options.webSocketFactory)
342
552
  throw new Error("Pluno requires a token or tokenProvider");
343
- const s = ze(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
553
+ const s = is(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
344
554
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
345
- this.socket === n && n.readyState === WebSocket.CONNECTING && (p("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
346
- }, ge), n.addEventListener("open", () => {
347
- this.socket !== n || (this.clearSocketConnectTimer(), p("web-sdk.agent", "Pluno socket opened", {
555
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (y("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
556
+ }, be), n.addEventListener("open", () => {
557
+ this.socket !== n || (this.clearSocketConnectTimer(), y("web-sdk.agent", "Pluno socket opened", {
348
558
  queuedClientEventCount: this.queuedClientEvents.length,
349
559
  isThinking: this.state.isThinking
350
560
  }), !(this.token ? this.sendNow({
@@ -354,12 +564,12 @@ class Ut {
354
564
  transportId: this.transportIdentity.transportId,
355
565
  pageUrl: location.href
356
566
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
357
- this.socket === n && (p("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
358
- }, me));
567
+ this.socket === n && (y("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
568
+ }, Me));
359
569
  }), n.addEventListener("message", (r) => {
360
- this.socket === n && this.handleServerEvent(Ye(r.data));
570
+ this.socket === n && this.handleServerEvent(ds(r.data));
361
571
  }), n.addEventListener("close", (r) => {
362
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (p("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
572
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (y("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
363
573
  code: typeof r?.code == "number" ? r.code : null,
364
574
  reason: typeof r?.reason == "string" ? r.reason : "",
365
575
  wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
@@ -367,7 +577,7 @@ class Ut {
367
577
  isThinking: this.state.isThinking
368
578
  }), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
369
579
  }), n.addEventListener("error", () => {
370
- this.socket !== n || this.state.status === "closed" || (p("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
580
+ this.socket !== n || this.state.status === "closed" || (y("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
371
581
  queuedClientEventCount: this.queuedClientEvents.length,
372
582
  isThinking: this.state.isThinking
373
583
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
@@ -390,25 +600,25 @@ class Ut {
390
600
  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;
391
601
  }
392
602
  destroy() {
393
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), vs(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
603
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), this.scheduledChatContinuationScheduler.destroy(), Vs(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
394
604
  for (const t of Object.values(this.listeners))
395
605
  t?.clear();
396
606
  }
397
607
  sendMessage(t, s = {}) {
398
- const n = t.trim(), r = s.attachments ?? [], i = r.map(ut);
608
+ const n = t.trim(), r = s.attachments ?? [], i = r.map(ft);
399
609
  if (!n && i.length === 0)
400
610
  return null;
401
- const o = I(), l = O();
611
+ const o = A(), c = s.clientMessageId ?? O();
402
612
  this.retryableClientMessageId = null;
403
613
  const u = {
404
- id: `local-${l}`,
614
+ id: `local-${c}`,
405
615
  role: "user",
406
616
  content: n,
407
617
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
408
618
  ...r.length > 0 ? { attachments: r } : {}
409
- };
619
+ }, l = this.state.messages.some((h) => h.id === u.id || h.clientMessageId === c);
410
620
  this.setState({
411
- messages: [...this.state.messages, u],
621
+ messages: l ? this.state.messages : [...this.state.messages, u],
412
622
  ...this.state.isThinking ? {} : {
413
623
  assistantDraft: "",
414
624
  assistantDraftRespondsToUserMessageId: null,
@@ -416,18 +626,18 @@ class Ut {
416
626
  },
417
627
  isThinking: !0,
418
628
  lastError: null
419
- }), this.emit("message", u);
629
+ }), l || this.emit("message", u);
420
630
  const a = {
421
631
  type: "chat.user_message",
422
632
  sessionId: this.state.sessionId ?? void 0,
423
- clientMessageId: l,
633
+ clientMessageId: c,
424
634
  content: n,
425
635
  attachments: i.length > 0 ? i : void 0,
426
636
  page: o,
427
637
  model: this.options.model,
428
- metadata: yt(this.options.metadata)
638
+ metadata: St(this.options.metadata)
429
639
  };
430
- return this.activeClientMessageId = l, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(l, i), l;
640
+ return this.activeClientMessageId = c, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(c, i), c;
431
641
  }
432
642
  retryLastMessage() {
433
643
  const t = this.state.sessionId, s = this.retryableClientMessageId;
@@ -437,23 +647,23 @@ class Ut {
437
647
  const s = O(), n = {
438
648
  id: s,
439
649
  name: t.name || "attachment",
440
- mimeType: kt(t),
650
+ mimeType: bt(t),
441
651
  sizeBytes: t.size
442
652
  };
443
653
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
444
654
  const r = Date.now();
445
- return _t({
655
+ return Ut({
446
656
  attachmentId: s,
447
657
  name: n.name,
448
658
  mimeType: n.mimeType,
449
659
  sizeBytes: n.sizeBytes,
450
660
  blob: t,
451
- origin: I().origin,
661
+ origin: A().origin,
452
662
  sessionId: this.state.sessionId ?? void 0,
453
663
  createdAt: r,
454
664
  lastUsedAt: r
455
665
  }).catch((i) => {
456
- p("web-sdk.attachments", "Failed to store Product Agent attachment", {
666
+ y("web-sdk.attachments", "Failed to store Product Agent attachment", {
457
667
  attachmentId: s,
458
668
  name: n.name,
459
669
  message: i instanceof Error ? i.message : String(i)
@@ -482,7 +692,7 @@ class Ut {
482
692
  waitForSession: !0,
483
693
  notifyCompletion: !0
484
694
  }).catch((i) => {
485
- p("web-sdk.agent", "Attachment background upload failed", {
695
+ y("web-sdk.agent", "Attachment background upload failed", {
486
696
  attachmentId: n.id,
487
697
  name: n.name,
488
698
  message: i instanceof Error ? i.message : String(i)
@@ -497,55 +707,55 @@ class Ut {
497
707
  waitForSession: r,
498
708
  notifyCompletion: i
499
709
  }) {
500
- const o = r ? await this.waitForSessionId() : this.state.sessionId, l = kt(t), u = {
710
+ const o = r ? await this.waitForSessionId() : this.state.sessionId, c = bt(t), u = {
501
711
  sessionId: o ?? void 0,
502
712
  attachmentId: s.id,
503
713
  clientId: this.options.clientId,
504
714
  transportId: this.transportIdentity.transportId,
505
715
  name: t.name || "attachment",
506
- mimeType: l,
716
+ mimeType: c,
507
717
  sizeBytes: t.size,
508
- page: I(),
718
+ page: A(),
509
719
  model: this.options.model,
510
- metadata: yt(this.options.metadata)
511
- }, a = this.options.prepareAttachmentUpload ? await Y(
720
+ metadata: St(this.options.metadata)
721
+ }, l = this.options.prepareAttachmentUpload ? await Q(
512
722
  () => this.options.prepareAttachmentUpload(u),
513
723
  "Failed to prepare attachment upload"
514
724
  ) : await this.prepareEmbedAttachmentUpload(u);
515
- await Y(async () => {
516
- const f = await fetch(a.uploadUrl, {
517
- method: a.uploadMethod,
518
- headers: a.uploadHeaders,
725
+ await Q(async () => {
726
+ const h = await fetch(l.uploadUrl, {
727
+ method: l.uploadMethod,
728
+ headers: l.uploadHeaders,
519
729
  body: t
520
730
  });
521
- if (!f.ok)
522
- throw new B("Failed to upload attachment", f.status);
523
- return f;
524
- }, "Failed to upload attachment"), this.setState({ sessionId: a.sessionId });
525
- const c = Ht(a.attachment, this.options.backendUrl);
526
- return this.updateAttachmentInState(s.id, c), s.id && Ct(s.id, {
527
- sessionId: a.sessionId,
528
- fileUrl: c.fileUrl,
529
- gcsPath: c.gcsPath,
731
+ if (!h.ok)
732
+ throw new x("Failed to upload attachment", h.status);
733
+ return h;
734
+ }, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
735
+ const a = zt(l.attachment, this.options.backendUrl);
736
+ return this.updateAttachmentInState(s.id, a), s.id && Dt(s.id, {
737
+ sessionId: l.sessionId,
738
+ fileUrl: a.fileUrl,
739
+ gcsPath: a.gcsPath,
530
740
  lastUsedAt: Date.now()
531
- }).catch((f) => {
532
- p("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
741
+ }).catch((h) => {
742
+ y("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
533
743
  attachmentId: s.id,
534
- name: c.name,
535
- message: f instanceof Error ? f.message : String(f)
744
+ name: a.name,
745
+ message: h instanceof Error ? h.message : String(h)
536
746
  });
537
- }), i && c.gcsPath && this.send({
747
+ }), i && a.gcsPath && this.send({
538
748
  type: "attachment.upload_completed",
539
- sessionId: a.sessionId,
749
+ sessionId: l.sessionId,
540
750
  clientMessageId: n,
541
- attachment: c
542
- }), c;
751
+ attachment: a
752
+ }), a;
543
753
  }
544
754
  waitForSessionId() {
545
755
  return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
546
756
  const n = window.setTimeout(() => {
547
757
  r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
548
- }, Ee), r = this.on("state", (i) => {
758
+ }, Be), r = this.on("state", (i) => {
549
759
  i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
550
760
  });
551
761
  });
@@ -563,18 +773,18 @@ class Ut {
563
773
  }
564
774
  async prepareEmbedAttachmentUpload(t) {
565
775
  let s = !1;
566
- return await Y(async () => {
776
+ return await Q(async () => {
567
777
  const n = await this.fetchEmbedAttachmentUpload(t);
568
778
  if (n.ok)
569
779
  return await n.json();
570
- if (Qs(n.status) && this.options.tokenProvider && !s) {
780
+ if (gn(n.status) && this.options.tokenProvider && !s) {
571
781
  s = !0;
572
782
  const r = await this.fetchEmbedAttachmentUpload(t);
573
783
  if (r.ok)
574
784
  return await r.json();
575
- throw new B("Failed to prepare attachment upload", r.status);
785
+ throw new x("Failed to prepare attachment upload", r.status);
576
786
  }
577
- throw new B("Failed to prepare attachment upload", n.status);
787
+ throw new x("Failed to prepare attachment upload", n.status);
578
788
  }, "Failed to prepare attachment upload");
579
789
  }
580
790
  async fetchEmbedAttachmentUpload(t) {
@@ -596,7 +806,7 @@ class Ut {
596
806
  s && this.state.sessionId && this.state.isThinking && this.sendNow({ type: "run.stop", sessionId: this.state.sessionId }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, s && this.send({
597
807
  type: "session.reset",
598
808
  sessionId: this.state.sessionId ?? void 0,
599
- page: I()
809
+ page: A()
600
810
  }), this.setState({
601
811
  sessionId: null,
602
812
  starterPrompts: [...this.state.starterPrompts],
@@ -610,14 +820,14 @@ class Ut {
610
820
  }
611
821
  listSessions(t = {}) {
612
822
  const s = O(), n = new Promise((i, o) => {
613
- const l = window.setTimeout(() => {
823
+ const c = window.setTimeout(() => {
614
824
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
615
- }, ke);
616
- this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: l });
825
+ }, Le);
826
+ this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: c });
617
827
  }), r = {
618
828
  type: "sessions.list",
619
829
  requestId: s,
620
- page: I(),
830
+ page: A(),
621
831
  ...t.cursor ? { cursor: t.cursor } : {},
622
832
  ...t.limit ? { limit: t.limit } : {}
623
833
  };
@@ -639,11 +849,11 @@ class Ut {
639
849
  }), this.send({
640
850
  type: "session.load",
641
851
  sessionId: t,
642
- page: I()
852
+ page: A()
643
853
  });
644
854
  }
645
855
  send(t) {
646
- this.sendNow(w(t)) || (this.queuedClientEvents.push(t), M(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
856
+ this.sendNow(S(t)) || (this.queuedClientEvents.push(t), P(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
647
857
  }
648
858
  async getUploadToken() {
649
859
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -658,7 +868,7 @@ class Ut {
658
868
  try {
659
869
  return s.send(JSON.stringify(t)), !0;
660
870
  } catch (n) {
661
- return p("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
871
+ return y("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
662
872
  message: n instanceof Error ? n.message : String(n),
663
873
  queuedClientEventCount: this.queuedClientEvents.length,
664
874
  isThinking: this.state.isThinking
@@ -669,9 +879,9 @@ class Ut {
669
879
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
670
880
  return;
671
881
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
672
- const t = Ge();
882
+ const t = os();
673
883
  this.sendNow(
674
- w({
884
+ S({
675
885
  type: "starter_prompts.page_context",
676
886
  pageUrl: t.pageUrl,
677
887
  pageTitle: t.pageTitle,
@@ -680,13 +890,13 @@ class Ut {
680
890
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
681
891
  }
682
892
  startStarterPromptUrlWatcher() {
683
- this.locationChangeCleanup || (this.locationChangeCleanup = Xe(() => this.handleStarterPromptUrlChange()));
893
+ this.locationChangeCleanup || (this.locationChangeCleanup = as(() => this.handleStarterPromptUrlChange()));
684
894
  }
685
895
  handleStarterPromptUrlChange() {
686
896
  const t = location.href;
687
897
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
688
898
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
689
- }, Ue));
899
+ }, $e));
690
900
  }
691
901
  refreshStarterPromptsForCurrentUrl() {
692
902
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -701,14 +911,14 @@ class Ut {
701
911
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
702
912
  return;
703
913
  const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
704
- M(this.options.clientId, this.queuedClientEvents);
914
+ P(this.options.clientId, this.queuedClientEvents);
705
915
  for (let s = 0; s < t.length; s += 1) {
706
916
  const n = t[s];
707
- if (!this.sendNow(w(n))) {
708
- this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), M(this.options.clientId, this.queuedClientEvents);
917
+ if (!this.sendNow(S(n))) {
918
+ this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), P(this.options.clientId, this.queuedClientEvents);
709
919
  return;
710
920
  }
711
- M(this.options.clientId, this.queuedClientEvents);
921
+ P(this.options.clientId, this.queuedClientEvents);
712
922
  }
713
923
  }
714
924
  handleServerEvent(t) {
@@ -720,51 +930,51 @@ class Ut {
720
930
  this.clearHeartbeatAckTimer();
721
931
  return;
722
932
  }
723
- if (Le(t) && this.markThinkingProgress(), t.type === "auth.ok") {
933
+ if (Je(t) && this.markThinkingProgress(), t.type === "auth.ok") {
724
934
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
725
- const s = Qe(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
726
- p("web-sdk.agent", "Received auth.ok appearance", {
935
+ const s = ps(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
936
+ y("web-sdk.agent", "Received auth.ok appearance", {
727
937
  hasAppearance: n,
728
938
  rawAppearance: t.appearance,
729
939
  normalizedAppearance: s
730
- }), this.runtimeHelperJavascript = ts(t.runtimeHelpers)?.javascript ?? null;
731
- const r = It(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, l = {
732
- user: rs(t.user),
940
+ }), this.runtimeHelperJavascript = fs(t.runtimeHelpers)?.javascript ?? null;
941
+ const r = Rt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
942
+ user: Ts(t.user),
733
943
  status: "connected"
734
944
  };
735
- (i || this.state.starterPrompts.length === 0) && (l.starterPrompts = r, l.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (l.appearance = s), this.setState(l), i && r.length === 0 && !o && !Je() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
945
+ (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 && !ls() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
736
946
  type: "page.upsert",
737
947
  sessionId: this.state.sessionId,
738
- page: I(),
948
+ page: A(),
739
949
  model: this.options.model
740
950
  });
741
951
  return;
742
952
  }
743
953
  if (t.type === "starterPrompts.updated") {
744
954
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
745
- starterPrompts: It(t, "starterPrompts"),
955
+ starterPrompts: Rt(t, "starterPrompts"),
746
956
  starterPromptsLoading: !1
747
957
  });
748
958
  return;
749
959
  }
750
960
  if (t.type === "conversation.state") {
751
- const s = Array.isArray(t.items) ? t.items : [], n = Is(s);
961
+ const s = Array.isArray(t.items) ? t.items : [], n = vs(s);
752
962
  if (n) {
753
- const l = As(s, n);
963
+ const c = Os(s, n);
754
964
  this.retryAttemptsByClientMessageId[n] = Math.max(
755
965
  this.retryAttemptsByClientMessageId[n] ?? 0,
756
- l
966
+ c
757
967
  );
758
968
  }
759
- const r = ps(
969
+ const r = _s(
760
970
  this.state.messages,
761
- is(s, this.options.backendUrl)
762
- ), i = At(r);
763
- if (!i && ws(this.state.messages, s))
971
+ ws(s, this.options.backendUrl)
972
+ ), i = Ct(r);
973
+ if (!i && Ns(this.state.messages, s))
764
974
  return;
765
- const o = i ? null : et(s);
766
- if (this.latestRecoverableClientMessageId = o, ys(r) && this.clearRetryTimers(), this.setState({
767
- sessionId: A(t.session, "id") ?? this.state.sessionId,
975
+ const o = i ? null : rt(s);
976
+ if (this.latestRecoverableClientMessageId = o, Us(r) && this.clearRetryTimers(), this.setState({
977
+ sessionId: k(t.session, "id") ?? this.state.sessionId,
768
978
  messages: r,
769
979
  ...i ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : o ? {
770
980
  assistantDraft: "",
@@ -774,30 +984,30 @@ class Ut {
774
984
  lastError: null
775
985
  } : {}
776
986
  }), i ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : o && (this.activeClientMessageId = o, this.markThinkingProgress()), n) {
777
- const l = A(t.session, "id") ?? this.state.sessionId;
778
- l && this.retryAfterInterruptedRun(l, n);
987
+ const c = k(t.session, "id") ?? this.state.sessionId;
988
+ c && this.retryAfterInterruptedRun(c, n);
779
989
  }
780
990
  return;
781
991
  }
782
992
  if (t.type === "sessions.page") {
783
993
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
784
994
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
785
- sessions: os(t.sessions),
995
+ sessions: Is(t.sessions),
786
996
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
787
997
  }));
788
998
  return;
789
999
  }
790
1000
  if (t.type === "session.updated") {
791
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: A(t.session, "id") ?? this.state.sessionId });
1001
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: k(t.session, "id") ?? this.state.sessionId });
792
1002
  return;
793
1003
  }
794
1004
  if (t.type === "session.item") {
795
- const s = Nt(t.item, this.options.backendUrl);
1005
+ const s = qt(t.item, this.options.backendUrl);
796
1006
  if (s) {
797
1007
  s.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
798
1008
  const n = t.item.data;
799
- Ss(n) && this.clearRunAckResyncRetryTimer();
800
- const r = hs(this.state.messages, s), i = At(r);
1009
+ Ls(n) && this.clearRunAckResyncRetryTimer();
1010
+ const r = Cs(this.state.messages, s), i = Ct(r);
801
1011
  this.setState({
802
1012
  messages: r,
803
1013
  assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
@@ -845,13 +1055,13 @@ class Ut {
845
1055
  if (this.retryAfterRetryableError(t))
846
1056
  return;
847
1057
  o && r && i && (this.retryableClientMessageId = i);
848
- const l = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = $e(l.message);
1058
+ const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = rs(c.message);
849
1059
  u && console.error(u), this.setState({
850
1060
  status: "error",
851
1061
  isThinking: !1,
852
- lastError: l.message,
1062
+ lastError: c.message,
853
1063
  lastErrorCode: typeof t.code == "string" ? t.code : null
854
- }), this.clearThinkingWatchdog(), this.emit("error", l);
1064
+ }), this.clearThinkingWatchdog(), this.emit("error", c);
855
1065
  }
856
1066
  }
857
1067
  retryAfterRetryableError(t) {
@@ -860,18 +1070,18 @@ class Ut {
860
1070
  return !1;
861
1071
  if (t.code === "run_still_active") {
862
1072
  if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
863
- const l = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
1073
+ const c = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
864
1074
  this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
865
1075
  delete this.retryTimersByClientMessageId[n], this.resyncThinkingSession(), this.markThinkingProgress();
866
- }, l);
1076
+ }, c);
867
1077
  }
868
1078
  return !0;
869
1079
  }
870
1080
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
871
- if (i >= U)
1081
+ if (i >= D)
872
1082
  return !1;
873
1083
  this.retryAttemptsByClientMessageId[n] = i + 1;
874
- const o = D(
1084
+ const o = N(
875
1085
  i,
876
1086
  typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
877
1087
  );
@@ -888,7 +1098,7 @@ class Ut {
888
1098
  if (this.retryTimersByClientMessageId[s] !== void 0)
889
1099
  return;
890
1100
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
891
- if (n >= U) {
1101
+ if (n >= D) {
892
1102
  this.retryableClientMessageId = s, this.setState({
893
1103
  isThinking: !1,
894
1104
  lastError: "Pluno could not finish this message. Try it again.",
@@ -898,7 +1108,7 @@ class Ut {
898
1108
  }
899
1109
  this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "reconnecting", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
900
1110
  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 });
901
- }, D(n));
1111
+ }, N(n));
902
1112
  }
903
1113
  clearRetryTimers() {
904
1114
  for (const t of Object.values(this.retryTimersByClientMessageId))
@@ -911,7 +1121,7 @@ class Ut {
911
1121
  this.pendingSessionHistoryRequests.clear();
912
1122
  }
913
1123
  markThinkingProgress() {
914
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(gt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1124
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(It), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
915
1125
  }
916
1126
  scheduleThinkingWatchdog(t) {
917
1127
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -923,15 +1133,15 @@ class Ut {
923
1133
  }
924
1134
  handleRunAck(t) {
925
1135
  const s = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
926
- !this.state.isThinking || !s || s !== this.activeClientMessageId || (this.clearRunAckResyncRetryTimer(), this.scheduleRunAckWatchdog(s));
1136
+ s && this.scheduledChatContinuationScheduler.acknowledgeTask(s), !(!this.state.isThinking || !s || s !== this.activeClientMessageId) && (this.clearRunAckResyncRetryTimer(), this.scheduleRunAckWatchdog(s));
927
1137
  }
928
1138
  scheduleRunAckWatchdog(t) {
929
1139
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
930
1140
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
931
- }, Ie);
1141
+ }, Ne);
932
1142
  }
933
1143
  recoverMissedRunAck(t) {
934
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (p("web-sdk.agent", "Pluno run ack missed; resyncing session", {
1144
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (y("web-sdk.agent", "Pluno run ack missed; resyncing session", {
935
1145
  sessionId: this.state.sessionId,
936
1146
  clientMessageId: t
937
1147
  }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
@@ -939,12 +1149,12 @@ class Ut {
939
1149
  scheduleRunAckResyncRetry(t) {
940
1150
  this.clearRunAckResyncRetryTimer();
941
1151
  const s = this.retryAttemptsByClientMessageId[t] ?? 0;
942
- s >= U || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1152
+ s >= D || (this.runAckResyncRetryTimer = window.setTimeout(() => {
943
1153
  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({
944
1154
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
945
1155
  isThinking: !0,
946
1156
  lastError: null
947
- }), p("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
1157
+ }), y("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
948
1158
  sessionId: this.state.sessionId,
949
1159
  clientMessageId: t
950
1160
  }), this.state.sessionId ? this.send({
@@ -952,8 +1162,8 @@ class Ut {
952
1162
  sessionId: this.state.sessionId,
953
1163
  clientMessageId: t,
954
1164
  automatic: !0
955
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(gt)));
956
- }, D(s)));
1165
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(It)));
1166
+ }, N(s)));
957
1167
  }
958
1168
  clearRunAckResyncRetryTimer() {
959
1169
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -966,7 +1176,7 @@ class Ut {
966
1176
  return;
967
1177
  const t = this.activeClientMessageId;
968
1178
  if (!t) {
969
- p("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
1179
+ y("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
970
1180
  sessionId: this.state.sessionId
971
1181
  }), this.setState({
972
1182
  isThinking: !1,
@@ -976,8 +1186,8 @@ class Ut {
976
1186
  return;
977
1187
  }
978
1188
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
979
- if (n >= U) {
980
- p("web-sdk.agent", "Pluno run recovery retry exhausted", {
1189
+ if (n >= D) {
1190
+ y("web-sdk.agent", "Pluno run recovery retry exhausted", {
981
1191
  sessionId: this.state.sessionId,
982
1192
  clientMessageId: t
983
1193
  }), this.retryableClientMessageId = t, this.setState({
@@ -988,18 +1198,18 @@ class Ut {
988
1198
  return;
989
1199
  }
990
1200
  if (s < 1) {
991
- this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, p("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
1201
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, y("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
992
1202
  sessionId: this.state.sessionId,
993
1203
  clientMessageId: t,
994
1204
  resyncAttempts: s + 1
995
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Te);
1205
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ue);
996
1206
  return;
997
1207
  }
998
1208
  this.setState({
999
1209
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1000
1210
  isThinking: !0,
1001
1211
  lastError: null
1002
- }), p("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
1212
+ }), y("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
1003
1213
  sessionId: this.state.sessionId,
1004
1214
  clientMessageId: t,
1005
1215
  retryAttempts: n + 1
@@ -1010,13 +1220,13 @@ class Ut {
1010
1220
  clientMessageId: t,
1011
1221
  automatic: !0
1012
1222
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1013
- }, D(n)));
1223
+ }, N(n)));
1014
1224
  }
1015
1225
  resyncThinkingSession() {
1016
1226
  this.state.sessionId ? this.send({
1017
1227
  type: "page.upsert",
1018
1228
  sessionId: this.state.sessionId,
1019
- page: I(),
1229
+ page: A(),
1020
1230
  model: this.options.model
1021
1231
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
1022
1232
  }
@@ -1024,15 +1234,15 @@ class Ut {
1024
1234
  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;
1025
1235
  if (!s || !n || !r)
1026
1236
  return;
1027
- if (r !== "execute_code" || !Fs(o)) {
1237
+ if (r !== "execute_code" || !sn(o)) {
1028
1238
  this.send({
1029
1239
  type: "tool.result",
1030
1240
  sessionId: s,
1031
1241
  callId: n,
1032
1242
  toolName: r,
1033
1243
  summary: i,
1034
- rawInput: w(o),
1035
- rawOutput: w({
1244
+ rawInput: S(o),
1245
+ rawOutput: S({
1036
1246
  ok: !1,
1037
1247
  toolName: r,
1038
1248
  error: `Unsupported browser tool: ${r}`
@@ -1040,7 +1250,7 @@ class Ut {
1040
1250
  });
1041
1251
  return;
1042
1252
  }
1043
- const l = qe(this.state.messages);
1253
+ const c = Ze(this.state.messages);
1044
1254
  this.activeBrowserToolCalls.set(n, {
1045
1255
  event: {
1046
1256
  type: "tool.result",
@@ -1048,77 +1258,90 @@ class Ut {
1048
1258
  callId: n,
1049
1259
  toolName: r,
1050
1260
  summary: o.summary,
1051
- rawInput: w(o),
1261
+ rawInput: S(o),
1052
1262
  rawOutput: null
1053
1263
  },
1054
1264
  startedAtMs: Date.now(),
1055
1265
  startedAtUrl: location.href,
1056
1266
  startedAtOrigin: location.origin
1057
- }), this.installSessionUserFilesApi(l);
1058
- let u = null, a;
1059
- u = await this.executeRuntimeHelper(), a = await wt(o).catch((c) => ({
1267
+ }), this.installSessionUserFilesApi(c);
1268
+ let u = null, l;
1269
+ u = await this.executeRuntimeHelper(), l = await Et({
1270
+ ...o,
1271
+ javascript: ae(o.javascript, {
1272
+ callId: n
1273
+ })
1274
+ }).catch((a) => ({
1060
1275
  ok: !1,
1061
1276
  exception: {
1062
- message: c instanceof Error ? c.message : String(c)
1277
+ message: a instanceof Error ? a.message : String(a)
1063
1278
  }
1064
- })), this.activeBrowserToolCalls.delete(n), this.send({
1279
+ })), l = await ce(
1280
+ l,
1281
+ {
1282
+ clientId: this.options.clientId,
1283
+ sessionId: s,
1284
+ callId: n
1285
+ },
1286
+ (a) => this.scheduledChatContinuationScheduler.scheduleTask(a)
1287
+ ), this.activeBrowserToolCalls.delete(n), this.send({
1065
1288
  type: "tool.result",
1066
1289
  sessionId: s,
1067
1290
  callId: n,
1068
1291
  toolName: r,
1069
1292
  summary: o.summary,
1070
- rawInput: w(o),
1071
- rawOutput: w(es(a, u))
1072
- }), Us(this.options.clientId, this.activeBrowserToolCalls.values());
1293
+ rawInput: S(o),
1294
+ rawOutput: S(gs(l, u))
1295
+ }), zs(this.options.clientId, this.activeBrowserToolCalls.values());
1073
1296
  }
1074
1297
  startPageLifecycleRecovery() {
1075
1298
  if (this.pageLifecycleCleanup)
1076
1299
  return;
1077
1300
  const t = () => {
1078
- Bt(this.options.clientId, this.activeBrowserToolCalls.values());
1301
+ jt(this.options.clientId, this.activeBrowserToolCalls.values());
1079
1302
  };
1080
1303
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1081
1304
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1082
1305
  };
1083
1306
  }
1084
1307
  installSessionUserFilesApi(t) {
1085
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = He(t, this.attachmentFiles, this.attachmentBlobCache);
1308
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Qe(t, this.attachmentFiles, this.attachmentBlobCache);
1086
1309
  }
1087
1310
  cleanupSessionUserFilesApi() {
1088
- this.sessionUserFilesApiCleanup && (xe(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1311
+ this.sessionUserFilesApiCleanup && (ts(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1089
1312
  }
1090
1313
  async executeRuntimeHelper() {
1091
1314
  if (!this.runtimeHelperJavascript?.trim())
1092
1315
  return null;
1093
- const t = await wt({
1316
+ const t = await Et({
1094
1317
  javascript: this.runtimeHelperJavascript
1095
1318
  });
1096
- return t.ok === !1 ? ss(t) : null;
1319
+ return t.ok === !1 ? ms(t) : null;
1097
1320
  }
1098
1321
  enableNetworkCapture() {
1099
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Oe((t) => {
1100
- Xs(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1322
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Xe((t) => {
1323
+ ln(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1101
1324
  }));
1102
1325
  }
1103
1326
  enqueueNetworkEvent(t) {
1104
- this.queuedNetworkEvents.length >= Se || (this.queuedNetworkEvents.push(Gs(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1327
+ this.queuedNetworkEvents.length >= Oe || (this.queuedNetworkEvents.push(cn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1105
1328
  this.networkBatchTimer = null;
1106
1329
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1107
1330
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
1108
1331
  type: "network.batch",
1109
1332
  sessionId: this.state.sessionId ?? void 0,
1110
- page: I(),
1333
+ page: A(),
1111
1334
  events: s
1112
1335
  });
1113
- }, Ae)));
1336
+ }, ve)));
1114
1337
  }
1115
1338
  scheduleReconnect() {
1116
1339
  if (this.reconnectTimer !== null || this.state.status === "closed")
1117
1340
  return;
1118
- const t = De(this.reconnectAttempts);
1341
+ const t = ze(this.reconnectAttempts);
1119
1342
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1120
1343
  this.reconnectTimer = null, this.connect().catch((s) => {
1121
- p("web-sdk.agent", "Pluno reconnect failed; retrying", {
1344
+ y("web-sdk.agent", "Pluno reconnect failed; retrying", {
1122
1345
  message: s instanceof Error ? s.message : String(s),
1123
1346
  queuedClientEventCount: this.queuedClientEvents.length,
1124
1347
  isThinking: this.state.isThinking
@@ -1130,9 +1353,9 @@ class Ut {
1130
1353
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
1131
1354
  const t = this.socket;
1132
1355
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1133
- this.socket === t && (p("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1134
- }, pe));
1135
- }, he);
1356
+ this.socket === t && (y("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1357
+ }, Ce));
1358
+ }, Re);
1136
1359
  }
1137
1360
  stopHeartbeat() {
1138
1361
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1157,92 +1380,92 @@ class Ut {
1157
1380
  ...this.state,
1158
1381
  ...t,
1159
1382
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
1160
- }, Ms(this.options.clientId, this.state), this.emit("state", this.getState());
1383
+ }, js(this.options.clientId, this.state), this.emit("state", this.getState());
1161
1384
  }
1162
1385
  emit(t, s) {
1163
1386
  this.listeners[t]?.forEach((r) => r(s));
1164
1387
  }
1165
1388
  }
1166
- const K = /* @__PURE__ */ new WeakMap();
1167
- function Oe(e) {
1168
- const t = window.__plunoProductAgentNetworkCapture ?? ve();
1389
+ const V = /* @__PURE__ */ new WeakMap();
1390
+ function Xe(e) {
1391
+ const t = window.__plunoProductAgentNetworkCapture ?? Ke();
1169
1392
  return t.subscribers.add(e), () => {
1170
1393
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1171
1394
  };
1172
1395
  }
1173
- function ve() {
1174
- const e = /* @__PURE__ */ new Set(), t = (g) => {
1175
- e.forEach((h) => {
1396
+ function Ke() {
1397
+ const e = /* @__PURE__ */ new Set(), t = (T) => {
1398
+ e.forEach((p) => {
1176
1399
  try {
1177
- h(g);
1400
+ p(T);
1178
1401
  } catch {
1179
1402
  }
1180
1403
  });
1181
- }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(h, d) {
1182
- const m = Date.now();
1183
- let T;
1404
+ }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, d) {
1405
+ const f = Date.now();
1406
+ let w;
1184
1407
  try {
1185
- T = s.call(this, h, d);
1186
- } catch (y) {
1187
- throw y;
1408
+ w = s.call(this, p, d);
1409
+ } catch (m) {
1410
+ throw m;
1188
1411
  }
1189
1412
  try {
1190
- const y = h instanceof Request ? h : null, P = Ws(h, y), C = xt(d?.headers ?? y?.headers);
1191
- if (!_(P, C, d?.body)) {
1192
- const $ = {
1193
- requestId: V("fetch"),
1194
- url: S(P, X),
1195
- method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
1196
- requestHeaders: C,
1197
- requestBody: Et(d?.body),
1413
+ const m = p instanceof Request ? p : null, g = nn(p, m), I = Gt(d?.headers ?? m?.headers);
1414
+ if (!b(g, I, d?.body)) {
1415
+ const z = {
1416
+ requestId: Z("fetch"),
1417
+ url: E(g, J),
1418
+ method: (d?.method ?? m?.method ?? "GET").toUpperCase(),
1419
+ requestHeaders: I,
1420
+ requestBody: Mt(d?.body),
1198
1421
  resourceType: "fetch",
1199
- startedAt: new Date(m).toISOString()
1422
+ startedAt: new Date(f).toISOString()
1200
1423
  };
1201
- T.then(
1202
- (E) => {
1203
- js(E, $, m, t).catch(() => {
1424
+ w.then(
1425
+ (C) => {
1426
+ rn(C, z, f, t).catch(() => {
1204
1427
  t({
1205
- ...$,
1206
- responseStatus: E.status,
1207
- durationMs: Date.now() - m
1428
+ ...z,
1429
+ responseStatus: C.status,
1430
+ durationMs: Date.now() - f
1208
1431
  });
1209
1432
  });
1210
1433
  },
1211
- (E) => {
1434
+ (C) => {
1212
1435
  t({
1213
- ...$,
1214
- errorText: S(E instanceof Error ? E.message : String(E)),
1215
- durationMs: Date.now() - m
1436
+ ...z,
1437
+ errorText: E(C instanceof Error ? C.message : String(C)),
1438
+ durationMs: Date.now() - f
1216
1439
  });
1217
1440
  }
1218
1441
  );
1219
1442
  }
1220
1443
  } catch {
1221
1444
  }
1222
- return T;
1223
- }, l = function(h, d, m, T, y) {
1224
- const P = n.call(this, h, d, m ?? !0, T ?? void 0, y ?? void 0), C = typeof d == "string" ? d : d.toString();
1225
- return K.set(this, {
1226
- requestId: V("xhr"),
1227
- method: String(h ?? "GET").toUpperCase(),
1228
- url: S(C, X),
1445
+ return w;
1446
+ }, c = function(p, d, f, w, m) {
1447
+ const g = n.call(this, p, d, f ?? !0, w ?? void 0, m ?? void 0), I = typeof d == "string" ? d : d.toString();
1448
+ return V.set(this, {
1449
+ requestId: Z("xhr"),
1450
+ method: String(p ?? "GET").toUpperCase(),
1451
+ url: E(I, J),
1229
1452
  requestHeaders: {},
1230
1453
  startedAtMs: Date.now(),
1231
1454
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1232
- excluded: _(C)
1233
- }), P;
1234
- }, u = function(h, d) {
1235
- const m = r.call(this, h, d), T = K.get(this);
1236
- return T && Object.keys(T.requestHeaders).length < at && (T.requestHeaders[h] = dt(h, d), T.excluded = T.excluded || _(T.url, T.requestHeaders)), m;
1237
- }, a = function(h) {
1455
+ excluded: b(I)
1456
+ }), g;
1457
+ }, u = function(p, d) {
1458
+ const f = r.call(this, p, d), w = V.get(this);
1459
+ return w && Object.keys(w.requestHeaders).length < dt && (w.requestHeaders[p] = gt(p, d), w.excluded = w.excluded || b(w.url, w.requestHeaders)), f;
1460
+ }, l = function(p) {
1238
1461
  try {
1239
- const d = K.get(this);
1240
- d && (d.excluded = d.excluded || _(d.url, d.requestHeaders, h), d.requestBody = Et(h), d.excluded || this.addEventListener(
1462
+ const d = V.get(this);
1463
+ d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Mt(p), d.excluded || this.addEventListener(
1241
1464
  "loadend",
1242
1465
  () => {
1243
1466
  queueMicrotask(() => {
1244
1467
  try {
1245
- const m = Js(this.getAllResponseHeaders());
1468
+ const f = dn(this.getAllResponseHeaders());
1246
1469
  t({
1247
1470
  requestId: d.requestId,
1248
1471
  url: d.url,
@@ -1251,8 +1474,8 @@ function ve() {
1251
1474
  requestBody: d.requestBody,
1252
1475
  resourceType: "xhr",
1253
1476
  responseStatus: this.status,
1254
- responseHeaders: m,
1255
- responseBody: zs(this, m),
1477
+ responseHeaders: f,
1478
+ responseBody: an(this, f),
1256
1479
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1257
1480
  startedAt: d.startedAt,
1258
1481
  durationMs: Date.now() - d.startedAtMs
@@ -1266,14 +1489,14 @@ function ve() {
1266
1489
  ));
1267
1490
  } catch {
1268
1491
  }
1269
- return i.call(this, h ?? null);
1492
+ return i.call(this, p ?? null);
1270
1493
  };
1271
1494
  try {
1272
1495
  window.fetch = o;
1273
1496
  } catch {
1274
1497
  }
1275
1498
  try {
1276
- XMLHttpRequest.prototype.open = l;
1499
+ XMLHttpRequest.prototype.open = c;
1277
1500
  } catch {
1278
1501
  }
1279
1502
  try {
@@ -1281,44 +1504,44 @@ function ve() {
1281
1504
  } catch {
1282
1505
  }
1283
1506
  try {
1284
- XMLHttpRequest.prototype.send = a;
1507
+ XMLHttpRequest.prototype.send = l;
1285
1508
  } catch {
1286
1509
  }
1287
- let c = null;
1510
+ let a = null;
1288
1511
  if (typeof PerformanceObserver < "u") {
1289
- c = new PerformanceObserver((g) => {
1290
- for (const h of g.getEntries()) {
1291
- const d = h;
1292
- if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || _(d.name))
1512
+ a = new PerformanceObserver((T) => {
1513
+ for (const p of T.getEntries()) {
1514
+ const d = p;
1515
+ if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || b(d.name))
1293
1516
  continue;
1294
- const m = performance.timeOrigin + d.startTime;
1517
+ const f = performance.timeOrigin + d.startTime;
1295
1518
  t({
1296
- requestId: V("resource"),
1297
- url: S(d.name, X),
1519
+ requestId: Z("resource"),
1520
+ url: E(d.name, J),
1298
1521
  method: "GET",
1299
1522
  resourceType: "resource",
1300
1523
  responseStatus: d.responseStatus,
1301
- startedAt: new Date(m).toISOString(),
1524
+ startedAt: new Date(f).toISOString(),
1302
1525
  durationMs: d.duration
1303
1526
  });
1304
1527
  }
1305
1528
  });
1306
1529
  try {
1307
- c.observe({ type: "resource", buffered: !0 });
1530
+ a.observe({ type: "resource", buffered: !0 });
1308
1531
  } catch {
1309
- c.disconnect(), c = null;
1532
+ a.disconnect(), a = null;
1310
1533
  }
1311
1534
  }
1312
- const f = {
1535
+ const h = {
1313
1536
  subscribers: e,
1314
1537
  destroy: () => {
1315
- c?.disconnect();
1538
+ a?.disconnect();
1316
1539
  try {
1317
1540
  window.fetch === o && (window.fetch = s);
1318
1541
  } catch {
1319
1542
  }
1320
1543
  try {
1321
- XMLHttpRequest.prototype.open === l && (XMLHttpRequest.prototype.open = n);
1544
+ XMLHttpRequest.prototype.open === c && (XMLHttpRequest.prototype.open = n);
1322
1545
  } catch {
1323
1546
  }
1324
1547
  try {
@@ -1326,14 +1549,14 @@ function ve() {
1326
1549
  } catch {
1327
1550
  }
1328
1551
  try {
1329
- XMLHttpRequest.prototype.send === a && (XMLHttpRequest.prototype.send = i);
1552
+ XMLHttpRequest.prototype.send === l && (XMLHttpRequest.prototype.send = i);
1330
1553
  } catch {
1331
1554
  }
1332
1555
  }
1333
1556
  };
1334
- return window.__plunoProductAgentNetworkCapture = f, f;
1557
+ return window.__plunoProductAgentNetworkCapture = h, h;
1335
1558
  }
1336
- function p(e, t, s) {
1559
+ function y(e, t, s) {
1337
1560
  if (typeof window > "u")
1338
1561
  return;
1339
1562
  const n = window, r = {
@@ -1344,15 +1567,15 @@ function p(e, t, s) {
1344
1567
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1345
1568
  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 }));
1346
1569
  }
1347
- function yt(e) {
1570
+ function St(e) {
1348
1571
  const t = typeof e == "function" ? e() : e;
1349
1572
  return t && Object.keys(t).length > 0 ? t : void 0;
1350
1573
  }
1351
- function Le(e) {
1574
+ function Je(e) {
1352
1575
  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";
1353
1576
  }
1354
- const Be = 5e3;
1355
- function qe(e) {
1577
+ const Ve = 5e3, Ye = 12e4;
1578
+ function Ze(e) {
1356
1579
  const t = [];
1357
1580
  for (const s of e)
1358
1581
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1363,105 +1586,105 @@ function qe(e) {
1363
1586
  });
1364
1587
  return t;
1365
1588
  }
1366
- function He(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1367
- const n = new Map(e.map((a) => [a.id, a])), r = (a) => ({
1368
- id: a.id,
1369
- name: a.name,
1370
- mimeType: a.mimeType,
1371
- sizeBytes: a.sizeBytes,
1372
- type: a.mimeType,
1373
- size: a.sizeBytes
1374
- }), i = (a) => {
1375
- const c = n.get(a);
1376
- if (!c)
1377
- throw new Error(`Unknown Pluno user file: ${a}`);
1378
- return c;
1379
- }, o = async (a) => {
1380
- const c = i(a), f = t.get(c.id);
1381
- if (f)
1382
- return f;
1383
- const g = s.get(c.id);
1384
- if (g)
1385
- return g;
1386
- const h = await Jt(c.id).then((y) => y?.blob ?? null).catch((y) => (p("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1387
- attachmentId: c.id,
1388
- name: c.name,
1389
- message: y instanceof Error ? y.message : String(y)
1390
- }), null));
1589
+ function Qe(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1590
+ const n = new Map(e.map((l) => [l.id, l])), r = (l) => ({
1591
+ id: l.id,
1592
+ name: l.name,
1593
+ mimeType: l.mimeType,
1594
+ sizeBytes: l.sizeBytes,
1595
+ type: l.mimeType,
1596
+ size: l.sizeBytes
1597
+ }), i = (l) => {
1598
+ const a = n.get(l);
1599
+ if (!a)
1600
+ throw new Error(`Unknown Pluno user file: ${l}`);
1601
+ return a;
1602
+ }, o = async (l) => {
1603
+ const a = i(l), h = t.get(a.id);
1391
1604
  if (h)
1392
- return s.set(c.id, h), h;
1393
- if (!c.fileUrl)
1394
- throw new Error(`Pluno user file is missing content: ${a}`);
1395
- const d = await fetch(c.fileUrl, Ls(c.fileUrl));
1605
+ return h;
1606
+ const T = s.get(a.id);
1607
+ if (T)
1608
+ return T;
1609
+ const p = await ee(a.id).then((m) => m?.blob ?? null).catch((m) => (y("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1610
+ attachmentId: a.id,
1611
+ name: a.name,
1612
+ message: m instanceof Error ? m.message : String(m)
1613
+ }), null));
1614
+ if (p)
1615
+ return s.set(a.id, p), p;
1616
+ if (!a.fileUrl)
1617
+ throw new Error(`Pluno user file is missing content: ${l}`);
1618
+ const d = await fetch(a.fileUrl, Ys(a.fileUrl));
1396
1619
  if (!d.ok)
1397
- throw new Error(`Failed to load Pluno user file: ${a}`);
1398
- const m = await d.blob();
1399
- s.set(c.id, m);
1400
- const T = Date.now();
1401
- return _t({
1402
- attachmentId: c.id,
1403
- name: c.name,
1404
- mimeType: c.mimeType,
1405
- sizeBytes: c.sizeBytes,
1406
- blob: m,
1407
- fileUrl: c.fileUrl,
1408
- gcsPath: c.gcsPath,
1409
- createdAt: T,
1410
- lastUsedAt: T
1411
- }).catch((y) => {
1412
- p("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
1413
- attachmentId: c.id,
1414
- name: c.name,
1415
- message: y instanceof Error ? y.message : String(y)
1620
+ throw new Error(`Failed to load Pluno user file: ${l}`);
1621
+ const f = await d.blob();
1622
+ s.set(a.id, f);
1623
+ const w = Date.now();
1624
+ return Ut({
1625
+ attachmentId: a.id,
1626
+ name: a.name,
1627
+ mimeType: a.mimeType,
1628
+ sizeBytes: a.sizeBytes,
1629
+ blob: f,
1630
+ fileUrl: a.fileUrl,
1631
+ gcsPath: a.gcsPath,
1632
+ createdAt: w,
1633
+ lastUsedAt: w
1634
+ }).catch((m) => {
1635
+ y("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
1636
+ attachmentId: a.id,
1637
+ name: a.name,
1638
+ message: m instanceof Error ? m.message : String(m)
1416
1639
  });
1417
- }), m;
1640
+ }), f;
1418
1641
  };
1419
- return Zt(globalThis, "userFiles", {
1642
+ return re(globalThis, "userFiles", {
1420
1643
  list: () => e.map(r),
1421
- get: (a) => {
1422
- const c = n.get(a);
1423
- return c ? r(c) : null;
1644
+ get: (l) => {
1645
+ const a = n.get(l);
1646
+ return a ? r(a) : null;
1424
1647
  },
1425
- inspectImage: async (a) => {
1426
- const c = i(a), f = await o(a), g = c.mimeType.startsWith("image/") ? c.mimeType : f.type || c.mimeType;
1427
- if (!g.startsWith("image/"))
1428
- throw new Error(`Pluno user file is not an image: ${a}`);
1429
- const h = f.type === g ? f : new Blob([f], { type: g });
1430
- return Fe(g, h.size) > be ? {
1648
+ inspectImage: async (l) => {
1649
+ const a = i(l), h = await o(l), T = a.mimeType.startsWith("image/") ? a.mimeType : h.type || a.mimeType;
1650
+ if (!T.startsWith("image/"))
1651
+ throw new Error(`Pluno user file is not an image: ${l}`);
1652
+ const p = h.type === T ? h : new Blob([h], { type: T });
1653
+ return es(T, p.size) > Fe ? {
1431
1654
  type: "pluno.userFiles.inspectImage",
1432
- id: c.id,
1433
- name: c.name,
1434
- mimeType: g,
1435
- sizeBytes: c.sizeBytes,
1655
+ id: a.id,
1656
+ name: a.name,
1657
+ mimeType: T,
1658
+ sizeBytes: a.sizeBytes,
1436
1659
  imageAttached: !1,
1437
- imageAttachmentError: Me
1660
+ imageAttachmentError: We
1438
1661
  } : {
1439
1662
  type: "pluno.userFiles.inspectImage",
1440
- id: c.id,
1441
- name: c.name,
1442
- mimeType: g,
1443
- sizeBytes: c.sizeBytes,
1663
+ id: a.id,
1664
+ name: a.name,
1665
+ mimeType: T,
1666
+ sizeBytes: a.sizeBytes,
1444
1667
  imageAttached: !0,
1445
- dataUrl: await Tt(h)
1668
+ dataUrl: await kt(p)
1446
1669
  };
1447
1670
  },
1448
- getDataUrl: async (a) => (i(a), await Tt(await o(a))),
1671
+ getDataUrl: async (l) => (i(l), await kt(await o(l))),
1449
1672
  getBlob: o,
1450
- getArrayBuffer: async (a) => await (await o(a)).arrayBuffer(),
1451
- getFile: async (a) => {
1452
- const c = i(a);
1453
- return new File([await o(a)], c.name, { type: c.mimeType });
1673
+ getArrayBuffer: async (l) => await (await o(l)).arrayBuffer(),
1674
+ getFile: async (l) => {
1675
+ const a = i(l);
1676
+ return new File([await o(l)], a.name, { type: a.mimeType });
1454
1677
  }
1455
1678
  }) ?? (() => {
1456
1679
  });
1457
1680
  }
1458
- function xe(e) {
1681
+ function ts(e) {
1459
1682
  try {
1460
1683
  e();
1461
1684
  } catch {
1462
1685
  }
1463
1686
  }
1464
- function Tt(e) {
1687
+ function kt(e) {
1465
1688
  return new Promise((t, s) => {
1466
1689
  const n = new FileReader();
1467
1690
  n.onload = () => {
@@ -1473,32 +1696,32 @@ function Tt(e) {
1473
1696
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1474
1697
  });
1475
1698
  }
1476
- function Fe(e, t) {
1699
+ function es(e, t) {
1477
1700
  return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
1478
1701
  }
1479
- async function wt(e) {
1702
+ async function Et(e) {
1480
1703
  const t = Object.getPrototypeOf(async function() {
1481
- }).constructor, s = e.timeoutMs ?? Be, n = Date.now(), r = [];
1704
+ }).constructor, s = e.timeoutMs ?? Ve, n = Date.now(), r = [];
1482
1705
  let i;
1483
1706
  const o = {
1484
1707
  log: console.log,
1485
1708
  info: console.info,
1486
1709
  warn: console.warn,
1487
1710
  error: console.error
1488
- }, l = (u) => (...a) => {
1489
- r.push({ level: u, args: a }), o[u](...a);
1711
+ }, c = (u) => (...l) => {
1712
+ r.push({ level: u, args: l }), o[u](...l);
1490
1713
  };
1491
- console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
1714
+ console.log = c("log"), console.info = c("info"), console.warn = c("warn"), console.error = c("error");
1492
1715
  try {
1493
- const u = /* @__PURE__ */ Symbol("execute_code_timeout"), a = await Promise.race([
1716
+ const u = /* @__PURE__ */ Symbol("execute_code_timeout"), l = await Promise.race([
1494
1717
  new t(e.javascript)(),
1495
- new Promise((c) => {
1496
- i = window.setTimeout(() => c(u), s);
1718
+ new Promise((a) => {
1719
+ i = window.setTimeout(() => a(u), s);
1497
1720
  })
1498
1721
  ]);
1499
- return a === u ? We(s) : {
1722
+ return l === u ? ss(s) : {
1500
1723
  ok: !0,
1501
- result: a,
1724
+ result: l,
1502
1725
  console: r,
1503
1726
  metadata: {
1504
1727
  durationMs: Date.now() - n,
@@ -1525,7 +1748,7 @@ async function wt(e) {
1525
1748
  i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
1526
1749
  }
1527
1750
  }
1528
- function We(e) {
1751
+ function ss(e) {
1529
1752
  return {
1530
1753
  ok: !1,
1531
1754
  exception: {
@@ -1539,18 +1762,18 @@ function We(e) {
1539
1762
  }
1540
1763
  };
1541
1764
  }
1542
- function je(e) {
1765
+ function ns(e) {
1543
1766
  return e.replace(/\/+$/, "");
1544
1767
  }
1545
- function $e(e, t = location.origin) {
1768
+ function rs(e, t = location.origin) {
1546
1769
  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;
1547
1770
  }
1548
- function ze(e) {
1771
+ function is(e) {
1549
1772
  const t = new URL("/api/product-agent/embed/ws", e);
1550
1773
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1551
1774
  }
1552
- function I() {
1553
- const e = Dt();
1775
+ function A() {
1776
+ const e = xt();
1554
1777
  return {
1555
1778
  url: location.href,
1556
1779
  title: document.title,
@@ -1558,21 +1781,21 @@ function I() {
1558
1781
  ...e ? { plunoProductAgentUi: e } : {}
1559
1782
  };
1560
1783
  }
1561
- function Ge() {
1784
+ function os() {
1562
1785
  return {
1563
1786
  pageUrl: location.href,
1564
1787
  pageTitle: document.title,
1565
- htmlContent: Ve()
1788
+ htmlContent: us()
1566
1789
  };
1567
1790
  }
1568
- function Xe(e) {
1569
- return L.add(e), N || (N = Ke()), () => {
1570
- L.delete(e), L.size === 0 && (N?.(), N = null);
1791
+ function as(e) {
1792
+ return B.add(e), v || (v = cs()), () => {
1793
+ B.delete(e), B.size === 0 && (v?.(), v = null);
1571
1794
  };
1572
1795
  }
1573
- function Ke() {
1796
+ function cs() {
1574
1797
  const e = () => {
1575
- for (const i of Array.from(L))
1798
+ for (const i of Array.from(B))
1576
1799
  i();
1577
1800
  }, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
1578
1801
  const o = t(...i);
@@ -1585,10 +1808,10 @@ function Ke() {
1585
1808
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1586
1809
  };
1587
1810
  }
1588
- function Je() {
1589
- return Dt()?.surface === "browser_extension_sdk_preview";
1811
+ function ls() {
1812
+ return xt()?.surface === "browser_extension_sdk_preview";
1590
1813
  }
1591
- function Ve() {
1814
+ function us() {
1592
1815
  const e = document.body?.cloneNode(!0);
1593
1816
  return e instanceof HTMLElement ? (e.querySelectorAll(
1594
1817
  [
@@ -1612,9 +1835,9 @@ function Ve() {
1612
1835
  s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
1613
1836
  }), 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) ?? "") : "";
1614
1837
  }
1615
- function Dt() {
1616
- const e = document.querySelector(ht);
1617
- if (!(e ?? document.querySelector(Q)))
1838
+ function xt() {
1839
+ const e = document.querySelector(yt);
1840
+ if (!(e ?? document.querySelector(st)))
1618
1841
  return;
1619
1842
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
1620
1843
  return {
@@ -1623,28 +1846,28 @@ function Dt() {
1623
1846
  selectors: [
1624
1847
  {
1625
1848
  name: "widget_host",
1626
- selector: s === "browser_extension_sdk_preview" ? ht : Q,
1849
+ selector: s === "browser_extension_sdk_preview" ? yt : st,
1627
1850
  description: "Finds Pluno's shadow-host element in the host page DOM."
1628
1851
  },
1629
1852
  {
1630
1853
  name: "widget_root",
1631
- selector: ae,
1854
+ selector: Ie,
1632
1855
  description: "Finds Pluno's widget root inside the widget host shadow root."
1633
1856
  },
1634
1857
  {
1635
1858
  name: "widget_panel",
1636
- selector: ce,
1859
+ selector: Ae,
1637
1860
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
1638
1861
  },
1639
1862
  {
1640
1863
  name: "widget_timeline",
1641
- selector: le,
1864
+ selector: Se,
1642
1865
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
1643
1866
  }
1644
1867
  ]
1645
1868
  };
1646
1869
  }
1647
- function Ye(e) {
1870
+ function ds(e) {
1648
1871
  try {
1649
1872
  const t = JSON.parse(e);
1650
1873
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -1652,33 +1875,33 @@ function Ye(e) {
1652
1875
  return { type: "error", message: "Invalid server event" };
1653
1876
  }
1654
1877
  }
1655
- function It(e, t) {
1878
+ function Rt(e, t) {
1656
1879
  if (!e || typeof e != "object")
1657
1880
  return [];
1658
1881
  const s = e[t];
1659
1882
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
1660
1883
  }
1661
- function Ze(e) {
1884
+ function hs(e) {
1662
1885
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
1663
1886
  }
1664
- function Qe(e) {
1887
+ function ps(e) {
1665
1888
  if (!e || typeof e != "object")
1666
1889
  return null;
1667
- 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, l = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
1668
- return !r && !i && !o && l === null ? null : {
1890
+ 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;
1891
+ return !r && !i && !o && c === null ? null : {
1669
1892
  ...r ? { accentColor: r } : {},
1670
1893
  ...i ? { colorScheme: i } : {},
1671
1894
  ...o ? { fontFamily: o } : {},
1672
- ...l !== null ? { scribbleStyle: l } : {}
1895
+ ...c !== null ? { scribbleStyle: c } : {}
1673
1896
  };
1674
1897
  }
1675
- function ts(e) {
1898
+ function fs(e) {
1676
1899
  if (!e || typeof e != "object")
1677
1900
  return null;
1678
1901
  const t = e.javascript;
1679
1902
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
1680
1903
  }
1681
- function es(e, t) {
1904
+ function gs(e, t) {
1682
1905
  return t ? e && typeof e == "object" ? {
1683
1906
  ...e,
1684
1907
  helperError: t
@@ -1688,13 +1911,13 @@ function es(e, t) {
1688
1911
  helperError: t
1689
1912
  } : e;
1690
1913
  }
1691
- function ss(e) {
1914
+ function ms(e) {
1692
1915
  if (!e || typeof e != "object")
1693
1916
  return e;
1694
1917
  const t = e;
1695
1918
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
1696
1919
  }
1697
- function ns() {
1920
+ function ys() {
1698
1921
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
1699
1922
  if (t)
1700
1923
  return t;
@@ -1704,7 +1927,7 @@ function ns() {
1704
1927
  function O() {
1705
1928
  return crypto.randomUUID();
1706
1929
  }
1707
- function rs(e) {
1930
+ function Ts(e) {
1708
1931
  if (!e || typeof e != "object")
1709
1932
  return null;
1710
1933
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -1715,23 +1938,23 @@ function rs(e) {
1715
1938
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
1716
1939
  } : null;
1717
1940
  }
1718
- function is(e, t) {
1719
- return Array.isArray(e) ? st(
1720
- nt(
1721
- e.map((s) => Nt(s, t)).filter((s) => s !== null)
1941
+ function ws(e, t) {
1942
+ return Array.isArray(e) ? it(
1943
+ ot(
1944
+ e.map((s) => qt(s, t)).filter((s) => s !== null)
1722
1945
  )
1723
1946
  ) : [];
1724
1947
  }
1725
- function os(e) {
1948
+ function Is(e) {
1726
1949
  return Array.isArray(e) ? e.flatMap((t) => {
1727
1950
  if (!t || typeof t != "object")
1728
1951
  return [];
1729
- const s = t, n = A(s, "id"), r = A(s, "createdAt"), i = A(s, "updatedAt"), o = A(s, "lastActiveAt");
1952
+ const s = t, n = k(s, "id"), r = k(s, "createdAt"), i = k(s, "updatedAt"), o = k(s, "lastActiveAt");
1730
1953
  return !n || !r || !i || !o ? [] : [
1731
1954
  {
1732
1955
  id: n,
1733
- title: A(s, "title"),
1734
- firstUserMessage: A(s, "firstUserMessage"),
1956
+ title: k(s, "title"),
1957
+ firstUserMessage: k(s, "firstUserMessage"),
1735
1958
  currentPage: s.currentPage ?? null,
1736
1959
  createdAt: r,
1737
1960
  updatedAt: i,
@@ -1740,7 +1963,7 @@ function os(e) {
1740
1963
  ];
1741
1964
  }) : [];
1742
1965
  }
1743
- function Nt(e, t) {
1966
+ function qt(e, t) {
1744
1967
  if (!e || typeof e != "object")
1745
1968
  return null;
1746
1969
  const s = e, n = s.data;
@@ -1752,39 +1975,39 @@ function Nt(e, t) {
1752
1975
  return {
1753
1976
  id: String(s.id ?? crypto.randomUUID()),
1754
1977
  role: i,
1755
- content: ds(r.content),
1978
+ content: Rs(r.content),
1756
1979
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1757
- respondsToUserMessageId: J(r) ?? void 0,
1758
- ...R(r) ? { runId: R(r) } : {},
1759
- attachments: qt(r.attachments, t)
1980
+ respondsToUserMessageId: Y(r) ?? void 0,
1981
+ ..._(r) ? { runId: _(r) } : {},
1982
+ attachments: $t(r.attachments, t)
1760
1983
  };
1761
1984
  }
1762
1985
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" ? {
1763
1986
  id: String(s.id ?? crypto.randomUUID()),
1764
1987
  role: "tool",
1765
- content: cs(r),
1988
+ content: Ss(r),
1766
1989
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1767
- respondsToUserMessageId: J(r) ?? void 0,
1768
- ...R(r) ? { runId: R(r) } : {},
1990
+ respondsToUserMessageId: Y(r) ?? void 0,
1991
+ ..._(r) ? { runId: _(r) } : {},
1769
1992
  dataType: String(r.type),
1770
1993
  toolName: typeof r.name == "string" ? r.name : void 0,
1771
- callId: us(r) ?? void 0,
1994
+ callId: Es(r) ?? void 0,
1772
1995
  loading: r.localExecutionStatus === "running"
1773
1996
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
1774
1997
  id: String(s.id ?? crypto.randomUUID()),
1775
1998
  role: "system",
1776
- content: as(r),
1999
+ content: As(r),
1777
2000
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1778
- respondsToUserMessageId: J(r) ?? void 0,
1779
- ...R(r) ? { runId: R(r) } : {},
2001
+ respondsToUserMessageId: Y(r) ?? void 0,
2002
+ ..._(r) ? { runId: _(r) } : {},
1780
2003
  dataType: String(r.type),
1781
2004
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying")
1782
2005
  } : null;
1783
2006
  }
1784
- function as(e) {
2007
+ function As(e) {
1785
2008
  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.";
1786
2009
  }
1787
- function cs(e) {
2010
+ function Ss(e) {
1788
2011
  if (e.type === "web_search_call") {
1789
2012
  const t = e.action;
1790
2013
  if (t && typeof t == "object") {
@@ -1796,9 +2019,9 @@ function cs(e) {
1796
2019
  }
1797
2020
  return "Searching the web";
1798
2021
  }
1799
- return ls(e);
2022
+ return ks(e);
1800
2023
  }
1801
- function ls(e) {
2024
+ function ks(e) {
1802
2025
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
1803
2026
  return e.summary;
1804
2027
  if (typeof e.arguments == "string")
@@ -1811,11 +2034,11 @@ function ls(e) {
1811
2034
  }
1812
2035
  return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
1813
2036
  }
1814
- function us(e) {
2037
+ function Es(e) {
1815
2038
  const t = e.callId ?? e.call_id;
1816
2039
  return typeof t == "string" && t ? t : null;
1817
2040
  }
1818
- function ds(e) {
2041
+ function Rs(e) {
1819
2042
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
1820
2043
  if (!t || typeof t != "object")
1821
2044
  return "";
@@ -1823,24 +2046,24 @@ function ds(e) {
1823
2046
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
1824
2047
  }).filter(Boolean).join("") : "";
1825
2048
  }
1826
- function hs(e, t) {
1827
- const s = Ot(e, t), n = ms(e, t), r = n.findIndex((o) => o.id === s.id);
2049
+ function Cs(e, t) {
2050
+ const s = Ht(e, t), n = Ps(e, t), r = n.findIndex((o) => o.id === s.id);
1828
2051
  if (r === -1)
1829
- return st(
1830
- nt([...n, s])
2052
+ return it(
2053
+ ot([...n, s])
1831
2054
  );
1832
2055
  const i = [...n];
1833
- return i[r] = s, st(nt(i));
2056
+ return i[r] = s, it(ot(i));
1834
2057
  }
1835
- function ps(e, t) {
2058
+ function _s(e, t) {
1836
2059
  const s = t.map(
1837
- (n) => Ot(e, n)
2060
+ (n) => Ht(e, n)
1838
2061
  );
1839
2062
  return t.length > 0 ? s : e.filter(
1840
2063
  (n) => n.role === "user" && n.id.startsWith("local-")
1841
2064
  );
1842
2065
  }
1843
- function Ot(e, t) {
2066
+ function Ht(e, t) {
1844
2067
  if (t.role !== "user" || !t.attachments?.length)
1845
2068
  return t;
1846
2069
  const s = e.find(
@@ -1849,19 +2072,19 @@ function Ot(e, t) {
1849
2072
  if (!s?.attachments?.length)
1850
2073
  return t;
1851
2074
  const n = t.attachments.map((r) => {
1852
- const i = fs(s.attachments ?? [], r);
1853
- return i ? gs(r, i) : r;
2075
+ const i = bs(s.attachments ?? [], r);
2076
+ return i ? Ms(r, i) : r;
1854
2077
  });
1855
2078
  return { ...t, attachments: n };
1856
2079
  }
1857
- function fs(e, t) {
2080
+ function bs(e, t) {
1858
2081
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
1859
2082
  }
1860
- function gs(e, t) {
2083
+ function Ms(e, t) {
1861
2084
  const { previewUrl: s } = t;
1862
2085
  return s ? { ...e, previewUrl: s } : e;
1863
2086
  }
1864
- function ms(e, t) {
2087
+ function Ps(e, t) {
1865
2088
  if (t.role !== "user")
1866
2089
  return e;
1867
2090
  const s = e.findIndex(
@@ -1872,8 +2095,8 @@ function ms(e, t) {
1872
2095
  const n = [...e];
1873
2096
  return n.splice(s, 1), n;
1874
2097
  }
1875
- function At(e) {
1876
- const t = vt(e);
2098
+ function Ct(e) {
2099
+ const t = Ft(e);
1877
2100
  if (t === null)
1878
2101
  return !1;
1879
2102
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -1889,20 +2112,20 @@ function At(e) {
1889
2112
  }
1890
2113
  return !1;
1891
2114
  }
1892
- function ys(e) {
1893
- const t = vt(e);
2115
+ function Us(e) {
2116
+ const t = Ft(e);
1894
2117
  return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
1895
2118
  }
1896
- function vt(e) {
2119
+ function Ft(e) {
1897
2120
  for (let t = e.length - 1; t >= 0; t -= 1)
1898
2121
  if (e[t].role === "user")
1899
2122
  return t;
1900
2123
  return null;
1901
2124
  }
1902
- function Ts(e) {
2125
+ function Ds(e) {
1903
2126
  return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
1904
2127
  }
1905
- function ct(e) {
2128
+ function ht(e) {
1906
2129
  for (let t = e.length - 1; t >= 0; t -= 1) {
1907
2130
  const s = e[t];
1908
2131
  if (!s || typeof s != "object")
@@ -1916,18 +2139,18 @@ function ct(e) {
1916
2139
  }
1917
2140
  return null;
1918
2141
  }
1919
- function ws(e, t) {
1920
- const s = ct(t);
2142
+ function Ns(e, t) {
2143
+ const s = ht(t);
1921
2144
  if (s === null)
1922
2145
  return !1;
1923
2146
  const n = t[s], r = n && typeof n == "object" ? n.id : null;
1924
2147
  if (typeof r != "string" || !r)
1925
2148
  return !1;
1926
2149
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
1927
- return i === -1 ? !1 : e.slice(i + 1).some(Ts);
2150
+ return i === -1 ? !1 : e.slice(i + 1).some(Ds);
1928
2151
  }
1929
- function et(e) {
1930
- const t = ct(e);
2152
+ function rt(e) {
2153
+ const t = ht(e);
1931
2154
  if (t === null)
1932
2155
  return null;
1933
2156
  const s = e[t];
@@ -1939,8 +2162,8 @@ function et(e) {
1939
2162
  const r = n.clientMessageId;
1940
2163
  return typeof r == "string" ? r : null;
1941
2164
  }
1942
- function Is(e) {
1943
- const t = ct(e);
2165
+ function vs(e) {
2166
+ const t = ht(e);
1944
2167
  if (t === null)
1945
2168
  return null;
1946
2169
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -1954,13 +2177,13 @@ function Is(e) {
1954
2177
  if (i.type === "message" && i.role === "assistant")
1955
2178
  return null;
1956
2179
  if (i.type === "run_error")
1957
- return i.retryable !== !0 ? null : typeof i.clientMessageId == "string" ? i.clientMessageId : et(e);
2180
+ return i.retryable !== !0 ? null : typeof i.clientMessageId == "string" ? i.clientMessageId : rt(e);
1958
2181
  if (i.type === "run_status")
1959
- return i.status === "interrupted" && i.retryable === !0 ? et(e) : null;
2182
+ return i.status === "interrupted" && i.retryable === !0 ? rt(e) : null;
1960
2183
  }
1961
2184
  return null;
1962
2185
  }
1963
- function As(e, t) {
2186
+ function Os(e, t) {
1964
2187
  let s = 0;
1965
2188
  for (const n of e) {
1966
2189
  if (!n || typeof n != "object")
@@ -1973,22 +2196,22 @@ function As(e, t) {
1973
2196
  }
1974
2197
  return s;
1975
2198
  }
1976
- function Ss(e) {
2199
+ function Ls(e) {
1977
2200
  if (!e || typeof e != "object")
1978
2201
  return !1;
1979
2202
  const t = e;
1980
2203
  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";
1981
2204
  }
1982
- function st(e) {
1983
- return e.filter((t, s) => Lt(t) ? !Cs(e, s) && !Rs(e, s) && !_s(e, s) : ks(t) ? !Es(e, s) : !0);
2205
+ function it(e) {
2206
+ return e.filter((t, s) => Wt(t) ? !Fs(e, s) && !qs(e, s) && !Hs(e, s) : Bs(t) ? !xs(e, s) : !0);
1984
2207
  }
1985
- function ks(e) {
2208
+ function Bs(e) {
1986
2209
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
1987
2210
  }
1988
- function Lt(e) {
2211
+ function Wt(e) {
1989
2212
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
1990
2213
  }
1991
- function nt(e) {
2214
+ function ot(e) {
1992
2215
  const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
1993
2216
  for (const i of e) {
1994
2217
  if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
@@ -2004,53 +2227,53 @@ function nt(e) {
2004
2227
  n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
2005
2228
  return r;
2006
2229
  }
2007
- function Es(e, t) {
2230
+ function xs(e, t) {
2008
2231
  const s = e[t];
2009
2232
  for (let n = t + 1; n < e.length; n += 1) {
2010
2233
  const r = e[n];
2011
2234
  if (r.role === "user")
2012
2235
  return !1;
2013
- if (r.role === "assistant" && W(s, r))
2236
+ if (r.role === "assistant" && j(s, r))
2014
2237
  return !0;
2015
2238
  }
2016
2239
  return !1;
2017
2240
  }
2018
- function Rs(e, t) {
2241
+ function qs(e, t) {
2019
2242
  const s = e[t];
2020
2243
  for (let n = t + 1; n < e.length; n += 1)
2021
- if (e[n].role === "assistant" && W(s, e[n]))
2244
+ if (e[n].role === "assistant" && j(s, e[n]))
2022
2245
  return !0;
2023
2246
  return !1;
2024
2247
  }
2025
- function _s(e, t) {
2248
+ function Hs(e, t) {
2026
2249
  const s = e[t];
2027
2250
  for (let n = t + 1; n < e.length; n += 1)
2028
- if (e[n].role === "tool" && W(s, e[n]))
2251
+ if (e[n].role === "tool" && j(s, e[n]))
2029
2252
  return !0;
2030
2253
  return !1;
2031
2254
  }
2032
- function Cs(e, t) {
2255
+ function Fs(e, t) {
2033
2256
  const s = e[t];
2034
2257
  for (let n = t + 1; n < e.length; n += 1)
2035
- if (Lt(e[n]) && W(s, e[n]))
2258
+ if (Wt(e[n]) && j(s, e[n]))
2036
2259
  return !0;
2037
2260
  return !1;
2038
2261
  }
2039
- function W(e, t) {
2262
+ function j(e, t) {
2040
2263
  return !e.runId || !t.runId ? !0 : e.runId === t.runId;
2041
2264
  }
2042
- function A(e, t) {
2265
+ function k(e, t) {
2043
2266
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2044
2267
  }
2045
- function bs(e, t) {
2268
+ function Ws(e, t) {
2046
2269
  try {
2047
- const s = window.localStorage.getItem(`${Pt}${e}`);
2270
+ const s = window.localStorage.getItem(`${Lt}${e}`);
2048
2271
  if (!s)
2049
2272
  return null;
2050
2273
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2051
2274
  if (t !== void 0 && r !== t)
2052
2275
  return null;
2053
- const i = Array.isArray(n.messages) ? n.messages.map(Hs).filter((o) => !!o) : [];
2276
+ const i = Array.isArray(n.messages) ? n.messages.map(tn).filter((o) => !!o) : [];
2054
2277
  return {
2055
2278
  sessionId: r,
2056
2279
  messages: i
@@ -2059,48 +2282,48 @@ function bs(e, t) {
2059
2282
  return null;
2060
2283
  }
2061
2284
  }
2062
- function Ms(e, t) {
2285
+ function js(e, t) {
2063
2286
  try {
2064
2287
  window.localStorage.setItem(
2065
- `${Pt}${e}`,
2288
+ `${Lt}${e}`,
2066
2289
  JSON.stringify({
2067
2290
  sessionId: t.sessionId,
2068
- messages: t.messages.slice(-Pe).map(xs)
2291
+ messages: t.messages.slice(-je).map(en)
2069
2292
  })
2070
2293
  );
2071
2294
  } catch {
2072
2295
  return;
2073
2296
  }
2074
2297
  }
2075
- function Ps(e) {
2298
+ function $s(e) {
2076
2299
  try {
2077
- const t = window.localStorage.getItem(`${tt}${e}`);
2300
+ const t = window.localStorage.getItem(`${nt}${e}`);
2078
2301
  if (!t)
2079
2302
  return [];
2080
2303
  const s = JSON.parse(t);
2081
- return Array.isArray(s) ? s.filter(lt) : [];
2304
+ return Array.isArray(s) ? s.filter(pt) : [];
2082
2305
  } catch {
2083
2306
  return [];
2084
2307
  }
2085
2308
  }
2086
- function M(e, t) {
2309
+ function P(e, t) {
2087
2310
  try {
2088
- const s = t.filter(lt);
2311
+ const s = t.filter(pt);
2089
2312
  if (s.length === 0) {
2090
- window.localStorage.removeItem(`${tt}${e}`);
2313
+ window.localStorage.removeItem(`${nt}${e}`);
2091
2314
  return;
2092
2315
  }
2093
2316
  window.localStorage.setItem(
2094
- `${tt}${e}`,
2317
+ `${nt}${e}`,
2095
2318
  JSON.stringify(s.slice(-25))
2096
2319
  );
2097
2320
  } catch {
2098
2321
  return;
2099
2322
  }
2100
2323
  }
2101
- function Bt(e, t) {
2324
+ function jt(e, t) {
2102
2325
  try {
2103
- const s = `${F}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2326
+ const s = `${W}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2104
2327
  ...o,
2105
2328
  storedAt: Date.now(),
2106
2329
  unloadUrl: n,
@@ -2114,30 +2337,29 @@ function Bt(e, t) {
2114
2337
  } catch {
2115
2338
  }
2116
2339
  }
2117
- function Us(e, t) {
2340
+ function zs(e, t) {
2118
2341
  try {
2119
- if (window.sessionStorage.getItem(`${F}${e}`) === null)
2342
+ if (window.sessionStorage.getItem(`${W}${e}`) === null)
2120
2343
  return;
2121
2344
  } catch {
2122
2345
  return;
2123
2346
  }
2124
- Bt(e, t);
2347
+ jt(e, t);
2125
2348
  }
2126
- function Ds(e) {
2349
+ function Gs(e) {
2127
2350
  try {
2128
- const t = `${F}${e}`, s = window.sessionStorage.getItem(t);
2351
+ const t = `${W}${e}`, s = window.sessionStorage.getItem(t);
2129
2352
  if (window.sessionStorage.removeItem(t), !s)
2130
2353
  return [];
2131
2354
  const n = JSON.parse(s);
2132
- return Array.isArray(n) ? n.flatMap((r) => Ns(r) ? [{
2355
+ return Array.isArray(n) ? n.flatMap((r) => Ks(r) ? [{
2133
2356
  ...r.event,
2357
+ page: A(),
2134
2358
  rawOutput: {
2135
- ok: !0,
2136
- result: {
2137
- navigated: !0,
2138
- url: location.href,
2139
- title: document.title
2140
- },
2359
+ pageContextRestarted: !0,
2360
+ outcome: "unknown",
2361
+ message: Xs(location.href),
2362
+ currentUrl: location.href,
2141
2363
  console: [],
2142
2364
  metadata: {
2143
2365
  durationMs: Math.max(0, Date.now() - r.startedAtMs),
@@ -2153,13 +2375,17 @@ function Ds(e) {
2153
2375
  return [];
2154
2376
  }
2155
2377
  }
2156
- function Ns(e) {
2378
+ function Xs(e) {
2379
+ return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2380
+ Current URL: ${e}`;
2381
+ }
2382
+ function Ks(e) {
2157
2383
  if (!e || typeof e != "object")
2158
2384
  return !1;
2159
2385
  const t = e, s = t.event;
2160
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && lt(s) && s.type === "tool.result";
2386
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && pt(s) && s.type === "tool.result";
2161
2387
  }
2162
- function Os(e, t) {
2388
+ function Js(e, t) {
2163
2389
  const s = new Set(
2164
2390
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2165
2391
  );
@@ -2168,26 +2394,26 @@ function Os(e, t) {
2168
2394
  ...t.filter((n) => !s.has(n.callId))
2169
2395
  ];
2170
2396
  }
2171
- function vs(e) {
2397
+ function Vs(e) {
2172
2398
  try {
2173
- window.sessionStorage.removeItem(`${F}${e}`);
2399
+ window.sessionStorage.removeItem(`${W}${e}`);
2174
2400
  } catch {
2175
2401
  return;
2176
2402
  }
2177
2403
  }
2178
- function lt(e) {
2404
+ function pt(e) {
2179
2405
  if (!e || typeof e != "object")
2180
2406
  return !1;
2181
2407
  const t = e;
2182
- return t.type === "chat.user_message" ? typeof t.content == "string" && St(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? St(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" : !1;
2408
+ return t.type === "chat.user_message" ? typeof t.content == "string" && _t(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? _t(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" : !1;
2183
2409
  }
2184
- function St(e) {
2410
+ function _t(e) {
2185
2411
  if (!e || typeof e != "object")
2186
2412
  return !1;
2187
2413
  const t = e;
2188
2414
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
2189
2415
  }
2190
- function qt(e, t) {
2416
+ function $t(e, t) {
2191
2417
  if (!Array.isArray(e))
2192
2418
  return;
2193
2419
  const s = e.filter((r) => {
@@ -2195,24 +2421,24 @@ function qt(e, t) {
2195
2421
  return !1;
2196
2422
  const i = r;
2197
2423
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
2198
- }), n = t ? s.map((r) => Ht(r, t)) : s;
2424
+ }), n = t ? s.map((r) => zt(r, t)) : s;
2199
2425
  return n.length > 0 ? n : void 0;
2200
2426
  }
2201
- function Ht(e, t) {
2427
+ function zt(e, t) {
2202
2428
  return e.fileUrl?.startsWith("/") ? {
2203
2429
  ...e,
2204
2430
  fileUrl: new URL(e.fileUrl, t).toString()
2205
2431
  } : e;
2206
2432
  }
2207
- function Ls(e) {
2208
- if (Bs(e))
2433
+ function Ys(e) {
2434
+ if (Zs(e))
2209
2435
  return {
2210
2436
  headers: {
2211
2437
  "ngrok-skip-browser-warning": "true"
2212
2438
  }
2213
2439
  };
2214
2440
  }
2215
- function Bs(e) {
2441
+ function Zs(e) {
2216
2442
  try {
2217
2443
  const t = new URL(e).hostname;
2218
2444
  return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
@@ -2220,14 +2446,14 @@ function Bs(e) {
2220
2446
  return !1;
2221
2447
  }
2222
2448
  }
2223
- function kt(e) {
2224
- return e.type || qs(e.name) || "application/octet-stream";
2449
+ function bt(e) {
2450
+ return e.type || Qs(e.name) || "application/octet-stream";
2225
2451
  }
2226
- function qs(e) {
2452
+ function Qs(e) {
2227
2453
  const t = e.toLowerCase();
2228
2454
  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;
2229
2455
  }
2230
- function Hs(e) {
2456
+ function tn(e) {
2231
2457
  if (!e || typeof e != "object")
2232
2458
  return null;
2233
2459
  const t = e;
@@ -2239,17 +2465,17 @@ function Hs(e) {
2239
2465
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
2240
2466
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
2241
2467
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
2242
- attachments: qt(t.attachments)?.map(ut),
2468
+ attachments: $t(t.attachments)?.map(ft),
2243
2469
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2244
2470
  };
2245
2471
  }
2246
- function xs(e) {
2472
+ function en(e) {
2247
2473
  return e.attachments?.length ? {
2248
2474
  ...e,
2249
- attachments: e.attachments.map(ut)
2475
+ attachments: e.attachments.map(ft)
2250
2476
  } : e;
2251
2477
  }
2252
- function ut(e) {
2478
+ function ft(e) {
2253
2479
  const {
2254
2480
  dataUrl: t,
2255
2481
  objectUrl: s,
@@ -2258,68 +2484,69 @@ function ut(e) {
2258
2484
  } = e;
2259
2485
  return r;
2260
2486
  }
2261
- function J(e) {
2487
+ function Y(e) {
2262
2488
  const t = e.respondsToUserMessageId;
2263
2489
  return typeof t == "string" && t ? t : null;
2264
2490
  }
2265
- function R(e) {
2491
+ function _(e) {
2266
2492
  const t = e.runId;
2267
2493
  return typeof t == "string" && t ? t : null;
2268
2494
  }
2269
- function Fs(e) {
2270
- return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
2495
+ function sn(e) {
2496
+ const t = e?.timeoutMs;
2497
+ return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Ye);
2271
2498
  }
2272
- function xt(e) {
2499
+ function Gt(e) {
2273
2500
  const t = {};
2274
2501
  try {
2275
2502
  new Headers(e).forEach((s, n) => {
2276
- Object.keys(t).length < at && (t[n] = dt(n, s));
2503
+ Object.keys(t).length < dt && (t[n] = gt(n, s));
2277
2504
  });
2278
2505
  } catch {
2279
2506
  return {};
2280
2507
  }
2281
2508
  return t;
2282
2509
  }
2283
- function dt(e, t) {
2284
- return Gt(e) ? j : S(H(t), _e);
2510
+ function gt(e, t) {
2511
+ return Zt(e) ? $ : E(H(t), qe);
2285
2512
  }
2286
- function Ws(e, t) {
2513
+ function nn(e, t) {
2287
2514
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2288
2515
  }
2289
- async function js(e, t, s, n) {
2290
- const r = xt(e.headers);
2516
+ async function rn(e, t, s, n) {
2517
+ const r = Gt(e.headers);
2291
2518
  n({
2292
2519
  ...t,
2293
2520
  responseStatus: e.status,
2294
2521
  responseHeaders: r,
2295
- responseBody: await $s(e),
2522
+ responseBody: await on(e),
2296
2523
  durationMs: Date.now() - s
2297
2524
  });
2298
2525
  }
2299
- async function $s(e) {
2300
- if (!Ft(e.headers))
2526
+ async function on(e) {
2527
+ if (!Xt(e.headers))
2301
2528
  return;
2302
2529
  let t = null, s = null;
2303
2530
  try {
2304
2531
  if (t = e.clone().body?.getReader() ?? null, !t)
2305
2532
  return;
2306
- const n = new Promise((l) => {
2533
+ const n = new Promise((c) => {
2307
2534
  s = window.setTimeout(() => {
2308
- t?.cancel(), l("timeout");
2309
- }, Ce);
2535
+ t?.cancel(), c("timeout");
2536
+ }, He);
2310
2537
  }), r = new TextDecoder();
2311
2538
  let i = "", o = 0;
2312
2539
  for (; ; ) {
2313
- const l = await Promise.race([t.read(), n]);
2314
- if (l === "timeout")
2540
+ const c = await Promise.race([t.read(), n]);
2541
+ if (c === "timeout")
2315
2542
  return;
2316
- const { done: u, value: a } = l;
2543
+ const { done: u, value: l } = c;
2317
2544
  if (u)
2318
- return S(i + r.decode());
2319
- const c = ot - o;
2320
- if (a.byteLength > c)
2321
- return i += r.decode(a.subarray(0, Math.max(c, 0)), { stream: !0 }), t.cancel(), `${S(i)}... [truncated]`;
2322
- o += a.byteLength, i += r.decode(a, { stream: !0 });
2545
+ return E(i + r.decode());
2546
+ const a = ut - o;
2547
+ if (l.byteLength > a)
2548
+ return i += r.decode(l.subarray(0, Math.max(a, 0)), { stream: !0 }), t.cancel(), `${E(i)}... [truncated]`;
2549
+ o += l.byteLength, i += r.decode(l, { stream: !0 });
2323
2550
  }
2324
2551
  } catch {
2325
2552
  t?.cancel();
@@ -2328,45 +2555,45 @@ async function $s(e) {
2328
2555
  s !== null && window.clearTimeout(s);
2329
2556
  }
2330
2557
  }
2331
- function zs(e, t) {
2332
- if (Ft(new Headers(t)))
2558
+ function an(e, t) {
2559
+ if (Xt(new Headers(t)))
2333
2560
  try {
2334
- return e.responseType === "" || e.responseType === "text" ? S(e.responseText ?? "") : void 0;
2561
+ return e.responseType === "" || e.responseType === "text" ? E(e.responseText ?? "") : void 0;
2335
2562
  } catch {
2336
2563
  return;
2337
2564
  }
2338
2565
  }
2339
- function Et(e) {
2566
+ function Mt(e) {
2340
2567
  if (typeof e == "string")
2341
- return S(e);
2568
+ return E(e);
2342
2569
  }
2343
- function Gs(e) {
2344
- return w({
2570
+ function cn(e) {
2571
+ return S({
2345
2572
  ...e,
2346
- requestBody: Rt(e.requestBody),
2347
- responseBody: Rt(e.responseBody)
2573
+ requestBody: Pt(e.requestBody),
2574
+ responseBody: Pt(e.responseBody)
2348
2575
  });
2349
2576
  }
2350
- function Rt(e) {
2577
+ function Pt(e) {
2351
2578
  if (typeof e != "string")
2352
2579
  return e;
2353
2580
  const t = e.trim();
2354
2581
  if (!t.startsWith("{") && !t.startsWith("["))
2355
2582
  return H(e);
2356
2583
  try {
2357
- return JSON.stringify(w(JSON.parse(e)));
2584
+ return JSON.stringify(S(JSON.parse(e)));
2358
2585
  } catch {
2359
2586
  return H(e);
2360
2587
  }
2361
2588
  }
2362
- function Ft(e) {
2589
+ function Xt(e) {
2363
2590
  if (!e)
2364
2591
  return !1;
2365
2592
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
2366
- return s !== null && Number.isInteger(n) && n >= 0 && n <= ot && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2593
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= ut && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2367
2594
  }
2368
- function _(e, t = {}, s) {
2369
- if (Ks(s))
2595
+ function b(e, t = {}, s) {
2596
+ if (un(s))
2370
2597
  return !0;
2371
2598
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
2372
2599
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -2376,13 +2603,13 @@ function _(e, t = {}, s) {
2376
2603
  if (r.protocol !== "http:" && r.protocol !== "https:")
2377
2604
  return !0;
2378
2605
  const i = r.hostname.toLowerCase(), o = r.pathname.toLowerCase();
2379
- return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((l) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(l));
2606
+ return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((c) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(c));
2380
2607
  } catch {
2381
2608
  return !0;
2382
2609
  }
2383
2610
  }
2384
- function Xs(e, t) {
2385
- if (_(e))
2611
+ function ln(e, t) {
2612
+ if (b(e))
2386
2613
  return !0;
2387
2614
  try {
2388
2615
  const s = new URL(e, location.href), n = new URL(t);
@@ -2391,62 +2618,62 @@ function Xs(e, t) {
2391
2618
  return !0;
2392
2619
  }
2393
2620
  }
2394
- function Ks(e) {
2621
+ function un(e) {
2395
2622
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
2396
2623
  }
2397
- function Js(e) {
2624
+ function dn(e) {
2398
2625
  const t = {};
2399
2626
  for (const s of e.trim().split(/[\r\n]+/)) {
2400
2627
  const n = s.indexOf(":");
2401
2628
  if (n <= 0)
2402
2629
  continue;
2403
- if (Object.keys(t).length >= at)
2630
+ if (Object.keys(t).length >= dt)
2404
2631
  break;
2405
2632
  const r = s.slice(0, n).trim();
2406
- t[r] = dt(r, s.slice(n + 1).trim());
2633
+ t[r] = gt(r, s.slice(n + 1).trim());
2407
2634
  }
2408
2635
  return t;
2409
2636
  }
2410
- function S(e, t = ot) {
2637
+ function E(e, t = ut) {
2411
2638
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
2412
2639
  }
2413
- function V(e) {
2640
+ function Z(e) {
2414
2641
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
2415
2642
  }
2416
- class B extends Error {
2643
+ class x extends Error {
2417
2644
  constructor(t, s) {
2418
2645
  super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
2419
2646
  }
2420
2647
  status;
2421
2648
  }
2422
- async function Y(e, t) {
2649
+ async function Q(e, t) {
2423
2650
  let s = null;
2424
- for (let n = 0; n < mt; n += 1)
2651
+ for (let n = 0; n < At; n += 1)
2425
2652
  try {
2426
2653
  return await e();
2427
2654
  } catch (r) {
2428
- if (s = r, n >= mt - 1 || !Ys(r))
2655
+ if (s = r, n >= At - 1 || !pn(r))
2429
2656
  throw r;
2430
- await Vs(n);
2657
+ await hn(n);
2431
2658
  }
2432
2659
  throw s instanceof Error ? s : new Error(t);
2433
2660
  }
2434
- function Vs(e) {
2661
+ function hn(e) {
2435
2662
  return new Promise((t) => {
2436
- window.setTimeout(t, Re[e] ?? 0);
2663
+ window.setTimeout(t, xe[e] ?? 0);
2437
2664
  });
2438
2665
  }
2439
- function Ys(e) {
2440
- return e instanceof B ? Zs(e.status) : e instanceof TypeError;
2666
+ function pn(e) {
2667
+ return e instanceof x ? fn(e.status) : e instanceof TypeError;
2441
2668
  }
2442
- function Zs(e) {
2669
+ function fn(e) {
2443
2670
  return e === 408 || e === 409 || e === 429 || e >= 500;
2444
2671
  }
2445
- function Qs(e) {
2672
+ function gn(e) {
2446
2673
  return e === 401 || e === 403;
2447
2674
  }
2448
- const j = "[REDACTED_SECRET]", k = "[REDACTED_TOKEN]", tn = "[REDACTED_SIGNED_URL]", en = 20, sn = /^(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, Wt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, jt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, $t = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, zt = /\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, nn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, rn = /\bhttps?:\/\/[^\s"'<>]+/gi, on = /[),.;\]]+$/;
2449
- function w(e) {
2675
+ const $ = "[REDACTED_SECRET]", R = "[REDACTED_TOKEN]", mn = "[REDACTED_SIGNED_URL]", yn = 20, Tn = /^(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, Kt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Jt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Vt = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Yt = /\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, wn = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, In = /\bhttps?:\/\/[^\s"'<>]+/gi, An = /[),.;\]]+$/;
2676
+ function S(e) {
2450
2677
  return q(e, 0, /* @__PURE__ */ new WeakSet());
2451
2678
  }
2452
2679
  function q(e, t, s) {
@@ -2454,7 +2681,7 @@ function q(e, t, s) {
2454
2681
  return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : H(e);
2455
2682
  if (e === null || typeof e != "object")
2456
2683
  return e;
2457
- if (t >= en)
2684
+ if (t >= yn)
2458
2685
  return "[REDACTED_MAX_DEPTH]";
2459
2686
  if (s.has(e))
2460
2687
  return "[REDACTED_CIRCULAR]";
@@ -2462,44 +2689,44 @@ function q(e, t, s) {
2462
2689
  return e.map((r) => q(r, t + 1, s));
2463
2690
  const n = {};
2464
2691
  for (const [r, i] of Object.entries(e))
2465
- Gt(r) ? n[r] = j : n[r] = r.toLowerCase() === "url" ? an(i) : q(i, t + 1, s);
2692
+ Zt(r) ? n[r] = $ : n[r] = r.toLowerCase() === "url" ? Sn(i) : q(i, t + 1, s);
2466
2693
  return n;
2467
2694
  }
2468
- function Gt(e) {
2695
+ function Zt(e) {
2469
2696
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
2470
2697
  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");
2471
2698
  }
2472
- function an(e) {
2473
- return typeof e == "string" ? Xt(e) : q(e, 0, /* @__PURE__ */ new WeakSet());
2699
+ function Sn(e) {
2700
+ return typeof e == "string" ? Qt(e) : q(e, 0, /* @__PURE__ */ new WeakSet());
2474
2701
  }
2475
- function Xt(e) {
2702
+ function Qt(e) {
2476
2703
  try {
2477
2704
  const t = new URL(e, location.href);
2478
2705
  for (const s of Array.from(t.searchParams.keys()))
2479
- sn.test(s) && t.searchParams.set(s, k);
2480
- return t.username && (t.username = k), t.password && (t.password = k), t.toString();
2706
+ Tn.test(s) && t.searchParams.set(s, R);
2707
+ return t.username && (t.username = R), t.password && (t.password = R), t.toString();
2481
2708
  } catch {
2482
- return cn(e);
2709
+ return kn(e);
2483
2710
  }
2484
2711
  }
2485
2712
  function H(e) {
2486
- return e.replace(nn, tn).replace(rn, ln).replace(Wt, `Bearer ${k}`).replace(jt, `Basic ${k}`).replace($t, k).replace(zt, (t, s) => `${s}: ${j}`);
2713
+ return e.replace(wn, mn).replace(In, En).replace(Kt, `Bearer ${R}`).replace(Jt, `Basic ${R}`).replace(Vt, R).replace(Yt, (t, s) => `${s}: ${$}`);
2487
2714
  }
2488
- function cn(e) {
2489
- return e.replace(Wt, `Bearer ${k}`).replace(jt, `Basic ${k}`).replace($t, k).replace(zt, (t, s) => `${s}: ${j}`);
2715
+ function kn(e) {
2716
+ return e.replace(Kt, `Bearer ${R}`).replace(Jt, `Basic ${R}`).replace(Vt, R).replace(Yt, (t, s) => `${s}: ${$}`);
2490
2717
  }
2491
- function ln(e) {
2492
- const t = e.match(on)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2493
- return `${Xt(s)}${t}`;
2718
+ function En(e) {
2719
+ const t = e.match(An)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2720
+ return `${Qt(s)}${t}`;
2494
2721
  }
2495
2722
  export {
2496
- ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2497
- Q as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2498
- ce as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2499
- ae as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2500
- le as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2501
- Ut as PlunoProductAgent,
2502
- De as calculateReconnectDelay,
2503
- Ut as default,
2504
- $e as getProductAgentOriginAccessErrorMessage
2723
+ yt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2724
+ st as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2725
+ Ae as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2726
+ Ie as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2727
+ Se as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2728
+ Bt as PlunoProductAgent,
2729
+ ze as calculateReconnectDelay,
2730
+ Bt as default,
2731
+ rs as getProductAgentOriginAccessErrorMessage
2505
2732
  };