@pluno/product-agent-web 0.1.113 → 0.1.115

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