@pluno/product-agent-web 0.1.165 → 0.1.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- const us = "pluno-product-agent-attachments";
1
+ const ds = "pluno-product-agent-attachments";
2
2
  const Be = "files";
3
- async function ds(t) {
4
- const e = await Xe();
5
- await gs(e, "readwrite", (s) => s.put(t));
3
+ async function hs(t) {
4
+ const e = await Ve();
5
+ await fs(e, "readwrite", (s) => s.put(t));
6
6
  }
7
7
  async function ps(t, e) {
8
- const s = await Xe();
9
- await Ve(s, "readwrite", async (n) => {
10
- const r = await Je(
8
+ const s = await Ve();
9
+ await Je(s, "readwrite", async (n) => {
10
+ const r = await Ye(
11
11
  n.get(t)
12
12
  );
13
13
  r && n.put({
@@ -16,26 +16,26 @@ async function ps(t, e) {
16
16
  });
17
17
  });
18
18
  }
19
- async function hs(t = 864e5) {
20
- const e = await Xe(), s = Date.now() - t;
21
- await Ve(e, "readwrite", async (n) => {
19
+ async function gs(t = 864e5) {
20
+ const e = await Ve(), s = Date.now() - t;
21
+ await Je(e, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Je(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Ye(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function Xe() {
26
+ function Ve() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
28
- const s = indexedDB.open(us, 1);
28
+ const s = indexedDB.open(ds, 1);
29
29
  s.onupgradeneeded = () => {
30
30
  const r = s.result.createObjectStore(Be, { keyPath: "attachmentId" });
31
31
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
32
32
  }, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
33
33
  });
34
34
  }
35
- async function gs(t, e, s) {
36
- return await Ve(t, e, async (n) => await Je(s(n)));
35
+ async function fs(t, e, s) {
36
+ return await Je(t, e, async (n) => await Ye(s(n)));
37
37
  }
38
- function Ve(t, e, s) {
38
+ function Je(t, e, s) {
39
39
  return new Promise((n, r) => {
40
40
  const i = t.transaction(Be, e), o = i.objectStore(Be);
41
41
  let a, l = !1;
@@ -57,16 +57,16 @@ function Ve(t, e, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Je(t) {
60
+ function Ye(t) {
61
61
  return new Promise((e, s) => {
62
62
  t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
63
63
  });
64
64
  }
65
- function fs(t) {
65
+ function ms(t) {
66
66
  return t !== null && (typeof t == "object" || typeof t == "function");
67
67
  }
68
- function vt(t, e, s) {
69
- const n = Reflect.get(t, "pluno"), r = fs(n) ? n : {};
68
+ function Ot(t, e, s) {
69
+ const n = Reflect.get(t, "pluno"), r = ms(n) ? n : {};
70
70
  if (r !== n && !Reflect.set(t, "pluno", r))
71
71
  return null;
72
72
  const i = Object.getOwnPropertyDescriptor(r, e);
@@ -80,16 +80,16 @@ function vt(t, e, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const ms = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function ys(t, e) {
83
+ const ys = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function Is(t, e) {
85
85
  return e ? t.replace(
86
- ms,
86
+ ys,
87
87
  (s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
88
88
  ) : t;
89
89
  }
90
- const Is = "save_runtime_captured_skill";
91
- function Ts(t) {
92
- return (t.type === "function_call" || t.type === "tool_call") && t.name === Is;
90
+ const Ts = "save_runtime_captured_skill";
91
+ function Ss(t) {
92
+ return (t.type === "function_call" || t.type === "tool_call") && t.name === Ts;
93
93
  }
94
94
  function ws(t, e, s) {
95
95
  const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
@@ -108,38 +108,38 @@ function ws(t, e, s) {
108
108
  )
109
109
  ), c = /* @__PURE__ */ new Map();
110
110
  for (const { item: u, identity: d } of i)
111
- for (const f of d.activityKeys ?? []) {
112
- const I = c.get(f);
113
- (!I || s(I).isTransient) && c.set(f, u);
111
+ for (const p of d.activityKeys ?? []) {
112
+ const I = c.get(p);
113
+ (!I || s(I).isTransient) && c.set(p, u);
114
114
  }
115
- const p = new Set(i.map(({ identity: u }) => u.id)), g = new Set(
115
+ const h = new Set(i.map(({ identity: u }) => u.id)), g = new Set(
116
116
  i.flatMap(({ identity: u }) => u.runId ? [u.runId] : [])
117
- ), T = /* @__PURE__ */ new Set(), h = [];
117
+ ), T = /* @__PURE__ */ new Set(), f = [];
118
118
  for (const u of t) {
119
119
  const d = s(u);
120
- let f = o.get(d.id);
121
- if (d.isOptimistic && d.optimisticKey ? f = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? f = l.get(d.assistantDraftKey) : d.isActivity && (f = d.activityKeys?.map((w) => c.get(w)).find((w) => w !== void 0) ?? f), f && !T.has(f)) {
122
- h.push(f), T.add(f);
120
+ let p = o.get(d.id);
121
+ if (d.isOptimistic && d.optimisticKey ? p = a.get(d.optimisticKey) : d.isAssistantDraft && d.assistantDraftKey ? p = l.get(d.assistantDraftKey) : d.isActivity && (p = d.activityKeys?.map((S) => c.get(S)).find((S) => S !== void 0) ?? p), p && !T.has(p)) {
122
+ f.push(p), T.add(p);
123
123
  continue;
124
124
  }
125
- const I = d.respondsToUserMessageId !== void 0 && p.has(d.respondsToUserMessageId) || d.runId !== void 0 && g.has(d.runId);
126
- (d.isOptimistic || (d.isAssistantDraft || d.isActivity) && I) && h.push(u);
125
+ const I = d.respondsToUserMessageId !== void 0 && h.has(d.respondsToUserMessageId) || d.runId !== void 0 && g.has(d.runId);
126
+ (d.isOptimistic || (d.isAssistantDraft || d.isActivity) && I) && f.push(u);
127
127
  }
128
128
  for (const { item: u } of i)
129
- T.has(u) || h.push(u);
130
- return h;
129
+ T.has(u) || f.push(u);
130
+ return f;
131
131
  }
132
- function Ss(t, e, s, n) {
132
+ function Ms(t, e, s, n) {
133
133
  return t.filter((r) => {
134
134
  const i = n(r);
135
135
  return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
136
136
  });
137
137
  }
138
- const be = "pluno.productAgent.transportId", Ms = "pluno.productAgent.transportIdentity", _e = "pluno.productAgent.transportIdentity.event", As = 50, Rs = globalThis.setTimeout.bind(globalThis);
139
- let J = null;
140
- const de = /* @__PURE__ */ new Set(), ke = /* @__PURE__ */ new Map();
141
- async function Es(t = Nt()) {
142
- const e = t.randomUUID(), s = t.storage.getItem(be);
138
+ const ke = "pluno.productAgent.transportId", As = "pluno.productAgent.transportIdentity", _e = "pluno.productAgent.transportIdentity.event", Rs = 50, Es = globalThis.setTimeout.bind(globalThis);
139
+ let Q = null;
140
+ const he = /* @__PURE__ */ new Set(), Pe = /* @__PURE__ */ new Map();
141
+ async function Cs(t = Lt()) {
142
+ const e = t.randomUUID(), s = t.storage.getItem(ke);
143
143
  let n = s ?? t.randomUUID(), r = !1, i = !1;
144
144
  const o = t.channel.subscribe((l) => {
145
145
  if (!(l.senderId === e || l.transportId !== n)) {
@@ -157,14 +157,14 @@ async function Es(t = Nt()) {
157
157
  }
158
158
  });
159
159
  if (!s)
160
- t.storage.setItem(be, n), r = !0;
160
+ t.storage.setItem(ke, n), r = !0;
161
161
  else
162
162
  for (; ; ) {
163
163
  if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
164
164
  r = !0;
165
165
  break;
166
166
  }
167
- n = t.randomUUID(), t.storage.setItem(be, n);
167
+ n = t.randomUUID(), t.storage.setItem(ke, n);
168
168
  }
169
169
  let a = !1;
170
170
  return {
@@ -174,49 +174,49 @@ async function Es(t = Nt()) {
174
174
  }
175
175
  };
176
176
  }
177
- async function Cs() {
178
- J || (J = Es(Nt()), J.then((n) => {
177
+ async function bs() {
178
+ Q || (Q = Cs(Lt()), Q.then((n) => {
179
179
  const r = (i) => {
180
- i.persisted || (n.release(), J = null, de.clear(), window.removeEventListener("pagehide", r));
180
+ i.persisted || (n.release(), Q = null, he.clear(), window.removeEventListener("pagehide", r));
181
181
  };
182
182
  window.addEventListener("pagehide", r);
183
183
  }));
184
- const t = await J, e = bs();
185
- de.add(e);
184
+ const t = await Q, e = ks();
185
+ he.add(e);
186
186
  let s = !1;
187
187
  return {
188
188
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
189
189
  transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
190
190
  release: () => {
191
- s || (s = !0, de.delete(e));
191
+ s || (s = !0, he.delete(e));
192
192
  }
193
193
  };
194
194
  }
195
- function bs() {
195
+ function ks() {
196
196
  let t = 0;
197
- for (; de.has(t); )
197
+ for (; he.has(t); )
198
198
  t += 1;
199
199
  return t;
200
200
  }
201
- function Nt() {
201
+ function Lt() {
202
202
  return {
203
203
  storage: _s(),
204
- channel: ks(),
204
+ channel: Ps(),
205
205
  randomUUID: () => crypto.randomUUID(),
206
- settle: () => new Promise((t) => Rs(t, As))
206
+ settle: () => new Promise((t) => Es(t, Rs))
207
207
  };
208
208
  }
209
209
  function _s() {
210
210
  return {
211
211
  getItem: (t) => {
212
212
  try {
213
- return window.sessionStorage?.getItem(t) ?? ke.get(t) ?? null;
213
+ return window.sessionStorage?.getItem(t) ?? Pe.get(t) ?? null;
214
214
  } catch {
215
- return ke.get(t) ?? null;
215
+ return Pe.get(t) ?? null;
216
216
  }
217
217
  },
218
218
  setItem: (t, e) => {
219
- ke.set(t, e);
219
+ Pe.set(t, e);
220
220
  try {
221
221
  window.sessionStorage?.setItem(t, e);
222
222
  } catch {
@@ -224,9 +224,9 @@ function _s() {
224
224
  }
225
225
  };
226
226
  }
227
- function ks() {
227
+ function Ps() {
228
228
  if (typeof BroadcastChannel < "u") {
229
- const t = new BroadcastChannel(Ms);
229
+ const t = new BroadcastChannel(As);
230
230
  return {
231
231
  postMessage: (e) => t.postMessage(e),
232
232
  subscribe: (e) => {
@@ -236,9 +236,9 @@ function ks() {
236
236
  close: () => t.close()
237
237
  };
238
238
  }
239
- return Ps();
239
+ return Us();
240
240
  }
241
- function Ps() {
241
+ function Us() {
242
242
  const t = /* @__PURE__ */ new Set(), e = (s) => {
243
243
  if (s.key !== _e || !s.newValue)
244
244
  return;
@@ -259,8 +259,8 @@ function Ps() {
259
259
  }
260
260
  };
261
261
  }
262
- const Ot = "schedule_follow_up";
263
- function Us(t) {
262
+ const Nt = "schedule_follow_up";
263
+ function Ds(t) {
264
264
  let e = t;
265
265
  if (typeof e == "string")
266
266
  try {
@@ -271,11 +271,11 @@ function Us(t) {
271
271
  if (!e || typeof e != "object")
272
272
  return null;
273
273
  const s = e;
274
- return s.ok !== !0 || s.toolName !== Ot || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
274
+ return s.ok !== !0 || s.toolName !== Nt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
275
275
  }
276
- const Ds = globalThis.fetch.bind(globalThis), qe = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', vs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ns = ".pluno-pa-widget__panel", Os = ".pluno-pa-widget__timeline", pt = `${qe}[data-pluno-sdk-preview-channel]`;
277
- let xs = 0;
278
- function ht(t) {
276
+ const vs = globalThis.fetch.bind(globalThis), We = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Os = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ls = ".pluno-pa-widget__panel", Ns = ".pluno-pa-widget__timeline", ht = `${We}[data-pluno-sdk-preview-channel]`;
277
+ let qs = 0;
278
+ function pt(t) {
279
279
  const e = {};
280
280
  for (const o of [
281
281
  "type",
@@ -313,7 +313,7 @@ function ht(t) {
313
313
  }
314
314
  return e;
315
315
  }
316
- function Pe(t, e, s) {
316
+ function Ue(t, e, s) {
317
317
  if (typeof window > "u")
318
318
  return;
319
319
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -325,31 +325,31 @@ function Pe(t, e, s) {
325
325
  source: "web_sdk",
326
326
  category: t,
327
327
  name: e,
328
- sequence: ++xs,
328
+ sequence: ++qs,
329
329
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
330
330
  monotonicMs: performance.now(),
331
331
  data: s
332
332
  };
333
333
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
334
334
  }
335
- const Ls = "https://app.pluno.ai", Bs = "gpt-5.6-terra", qs = 2e4, Ws = 1e4, Hs = 1e4, $s = 1e4, js = 1e4, Fs = 3e3, zs = 3e4, Ks = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, Gs = 15e3, Y = 8, Xs = "Pluno could not finish this message. Try it again.", Vs = "Browser connection was interrupted.", yt = 15e3, Js = "Pluno could not send this message. Try it again.", It = 2e3, Ys = 1e3, Qs = 100, Tt = 8e3, wt = 3, Zs = [300, 1e3], xt = 50 * 1024 * 1024, en = /* @__PURE__ */ new Set([
335
+ const xs = "https://app.pluno.ai", Bs = "gpt-5.6-terra", Ws = 2e4, Hs = 1e4, $s = 1e4, Fs = 1e4, js = 1e4, zs = 3e3, Ks = 3e4, Gs = 1e3, gt = 3e4, ft = 0.2, mt = 6e4, Xs = 15e3, Z = 8, Vs = "Pluno could not finish this message. Try it again.", Js = "Browser connection was interrupted.", yt = 15e3, Ys = "Pluno could not send this message. Try it again.", It = 2e3, Qs = 1e3, Zs = 100, Tt = 8e3, en = 8e3, St = 3, tn = [300, 1e3], qt = 50 * 1024 * 1024, sn = /* @__PURE__ */ new Set([
336
336
  ".jpeg:image/jpeg",
337
337
  ".jpg:image/jpeg",
338
338
  ".pdf:application/pdf",
339
339
  ".png:image/png",
340
340
  ".webp:image/webp"
341
- ]), di = ".pdf,.png,.jpg,.jpeg,.webp", Ye = 64e3, Ue = 4e3, Qe = 30, tn = 2e3, sn = 1e3, Lt = "Image is too large for model vision input.", nn = 100, Bt = "pluno.productAgent.state.", We = "pluno.productAgent.pendingEvents.", me = "pluno.productAgent.activeToolCalls.", rn = 100;
342
- function Q(t, e = 0) {
341
+ ]), pi = ".pdf,.png,.jpg,.jpeg,.webp", Qe = 64e3, De = 4e3, Ze = 30, nn = 2e3, rn = 1e3, xt = "Image is too large for model vision input.", on = 100, Bt = "pluno.productAgent.state.", He = "pluno.productAgent.pendingEvents.", ye = "pluno.productAgent.activeToolCalls.", an = 100;
342
+ function ee(t, e = 0) {
343
343
  const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
344
344
  return Math.max(e, s);
345
345
  }
346
346
  const pe = /* @__PURE__ */ new Set();
347
- let ie = null;
348
- function on(t, e = Math.random) {
349
- const s = Math.min(gt, Ks * 2 ** t), n = 1 - ft + e() * ft * 2;
347
+ let oe = null;
348
+ function ln(t, e = Math.random) {
349
+ const s = Math.min(gt, Gs * 2 ** t), n = 1 - ft + e() * ft * 2;
350
350
  return Math.min(gt, Math.round(s * n));
351
351
  }
352
- function an(t, e, s) {
352
+ function cn(t, e, s) {
353
353
  return new Promise((n, r) => {
354
354
  const i = setTimeout(() => r(new Error(s)), e);
355
355
  t.then(
@@ -362,13 +362,13 @@ function an(t, e, s) {
362
362
  );
363
363
  });
364
364
  }
365
- class qt {
365
+ class Wt {
366
366
  constructor(e, s) {
367
367
  this.options = e, this.transportIdentity = s, this.state = {
368
368
  ...this.state,
369
- starterPrompts: Hn(e.initialStarterPrompts)
369
+ starterPrompts: Fn(e.initialStarterPrompts)
370
370
  };
371
- const n = e.restorePersistedState === !1 ? null : Pr(e.clientId, e.expectedPersistedSessionId);
371
+ const n = e.restorePersistedState === !1 ? null : Dr(e.clientId, e.expectedPersistedSessionId);
372
372
  n && (this.state = {
373
373
  ...this.state,
374
374
  ...n,
@@ -385,13 +385,13 @@ class qt {
385
385
  isRetrying: !1,
386
386
  lastError: null
387
387
  }), this.queuedClientEvents = xr(
388
- Dr(e.clientId),
389
- vr(e.clientId)
388
+ Or(e.clientId),
389
+ Lr(e.clientId)
390
390
  );
391
391
  const r = [...this.queuedClientEvents].reverse().find(
392
392
  (i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
393
393
  );
394
- r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), $(e.clientId, this.queuedClientEvents);
394
+ r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), j(e.clientId, this.queuedClientEvents);
395
395
  }
396
396
  options;
397
397
  listeners = {};
@@ -405,6 +405,8 @@ class qt {
405
405
  connectionAttemptId = 0;
406
406
  connectionInProgress = !1;
407
407
  token = null;
408
+ authenticatedUserId = null;
409
+ authenticatedSocket = null;
408
410
  networkCaptureCleanup = null;
409
411
  networkBatchTimer = null;
410
412
  queuedNetworkEvents = [];
@@ -417,6 +419,12 @@ class qt {
417
419
  pendingSessionHistoryRequests = /* @__PURE__ */ new Map();
418
420
  pendingSessionPinRequests = /* @__PURE__ */ new Map();
419
421
  pendingSessionRenameRequests = /* @__PURE__ */ new Map();
422
+ sessionLoadRequestId = null;
423
+ sessionLoadRequestTimer = null;
424
+ sessionItemsRequestId = null;
425
+ sessionItemsCursor = null;
426
+ hasLoadedOlderSessionItems = !1;
427
+ loadedOlderSessionItemIds = /* @__PURE__ */ new Set();
420
428
  transportIdentity;
421
429
  retryAttemptsByClientMessageId = {};
422
430
  retryTimersByClientMessageId = {};
@@ -467,6 +475,9 @@ class qt {
467
475
  starterPromptsLoading: !1,
468
476
  appearance: null,
469
477
  messages: [],
478
+ isLoadingSession: !1,
479
+ isLoadingOlderMessages: !1,
480
+ hasOlderMessages: !1,
470
481
  assistantDraft: "",
471
482
  assistantDraftItemId: null,
472
483
  assistantDraftPhase: null,
@@ -481,16 +492,16 @@ class qt {
481
492
  lastErrorSecuritySettingsUrl: null
482
493
  };
483
494
  static async init(e) {
484
- const s = await Cs(), n = new qt({
495
+ const s = await bs(), n = new Wt({
485
496
  ...e,
486
- backendUrl: Cn(e.backendUrl ?? Ls),
487
- clientId: e.clientId ?? Kn(),
497
+ backendUrl: kn(e.backendUrl ?? xs),
498
+ clientId: e.clientId ?? Xn(),
488
499
  model: e.model ?? Bs,
489
500
  productVariant: e.productVariant ?? "customer_embedded",
490
- entrySurface: bn(e.entrySurface)
501
+ entrySurface: _n(e.entrySurface)
491
502
  }, s);
492
503
  try {
493
- hs().catch((r) => {
504
+ gs().catch((r) => {
494
505
  R("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
495
506
  message: r instanceof Error ? r.message : String(r)
496
507
  });
@@ -521,14 +532,14 @@ class qt {
521
532
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
522
533
  );
523
534
  try {
524
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await an(this.options.tokenProvider(), Hs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
535
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await cn(this.options.tokenProvider(), $s, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
525
536
  return;
526
537
  if (!this.token && !this.options.webSocketFactory)
527
538
  throw new Error("Pluno requires a token or tokenProvider");
528
- const s = Pn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
539
+ const s = Dn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
529
540
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
530
541
  this.socket === n && n.readyState === WebSocket.CONNECTING && (R("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
531
- }, $s), n.addEventListener("open", () => {
542
+ }, Fs), n.addEventListener("open", () => {
532
543
  this.socket !== n || (this.clearSocketConnectTimer(), R("web-sdk.agent", "Pluno socket opened", {
533
544
  queuedClientEventCount: this.queuedClientEvents.length,
534
545
  isThinking: this.state.isThinking
@@ -542,14 +553,14 @@ class qt {
542
553
  this.socket === n && (R("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
543
554
  }, js));
544
555
  }), n.addEventListener("message", (r) => {
545
- this.socket === n && this.handleServerEvent(qn(r.data));
556
+ this.socket === n && this.handleServerEvent(Hn(r.data));
546
557
  }), n.addEventListener("sendfailure", (r) => {
547
558
  if (this.socket !== n)
548
559
  return;
549
- const i = Wn(r?.detail?.data);
560
+ const i = $n(r?.detail?.data);
550
561
  i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
551
562
  (o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
552
- ) && (this.queuedClientEvents.push(i), $(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
563
+ ) && (this.queuedClientEvents.push(i), j(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
553
564
  }), n.addEventListener("close", (r) => {
554
565
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), R("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
555
566
  code: typeof r?.code == "number" ? r.code : null,
@@ -579,10 +590,10 @@ class qt {
579
590
  }
580
591
  }
581
592
  disconnect() {
582
- this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
593
+ this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
583
594
  }
584
595
  destroy() {
585
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Lr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
596
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Br(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
586
597
  for (const e of Object.values(this.listeners))
587
598
  e?.clear();
588
599
  }
@@ -590,7 +601,7 @@ class qt {
590
601
  const s = k(), n = `${this.state.sessionId ?? "draft"}:${s.url}`, r = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, i = {
591
602
  type: "runtime.warmup",
592
603
  reason: e,
593
- ...e === "composer_input" ? { warmupId: r?.event.warmupId ?? H() } : {},
604
+ ...e === "composer_input" ? { warmupId: r?.event.warmupId ?? $() } : {},
594
605
  entrySurface: this.options.entrySurface,
595
606
  sessionId: this.state.sessionId ?? void 0,
596
607
  page: s
@@ -605,23 +616,23 @@ class qt {
605
616
  }
606
617
  async sendMessage(e, s = {}) {
607
618
  const n = e.trim(), r = s.attachments ?? [];
608
- if (this.options.productVariant === "customer_embedded" && (r.forEach(Zt), r.reduce(
609
- (m, b) => m + b.sizeBytes,
619
+ if (this.options.productVariant === "customer_embedded" && (r.forEach(es), r.reduce(
620
+ (m, C) => m + C.sizeBytes,
610
621
  0
611
- ) > xt))
622
+ ) > qt))
612
623
  throw new Error("Embedded attachments must total at most 50 MB per message");
613
- let i = r.map(tt);
624
+ let i = r.map(st);
614
625
  if (!n && i.length === 0)
615
626
  return null;
616
627
  if (this.pendingClientMessageId)
617
628
  throw new Error("Wait for the current message to finish sending before sending another.");
618
- const o = k(), a = s.clientMessageId ?? H(), l = {
629
+ const o = k(), a = s.clientMessageId ?? $(), l = {
619
630
  id: `local-${a}`,
620
631
  role: "user",
621
632
  content: n,
622
633
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
623
634
  ...r.length > 0 ? { attachments: r } : {}
624
- }, c = this.state.messages.some((w) => w.id === l.id || w.clientMessageId === a), p = this.state.isThinking, g = this.state.pendingMessageStatus, T = this.state.turnPhase, h = this.state.messages, u = c ? this.state.messages : [...this.state.messages, l], d = {
635
+ }, c = this.state.messages.some((S) => S.id === l.id || S.clientMessageId === a), h = this.state.isThinking, g = this.state.pendingMessageStatus, T = this.state.turnPhase, f = this.state.messages, u = c ? this.state.messages : [...this.state.messages, l], d = {
625
636
  assistantDraft: this.state.assistantDraft,
626
637
  assistantDraftItemId: this.state.assistantDraftItemId,
627
638
  assistantDraftPhase: this.state.assistantDraftPhase,
@@ -631,7 +642,7 @@ class qt {
631
642
  };
632
643
  this.setState({
633
644
  messages: u,
634
- ...p ? {} : {
645
+ ...h ? {} : {
635
646
  assistantDraft: "",
636
647
  assistantDraftItemId: null,
637
648
  assistantDraftPhase: null,
@@ -639,46 +650,46 @@ class qt {
639
650
  assistantDraftRunId: null
640
651
  },
641
652
  pendingMessageStatus: "sending",
642
- turnPhase: p ? T : "sending",
643
- isThinking: p,
653
+ turnPhase: h ? T : "sending",
654
+ isThinking: h,
644
655
  isRetrying: !1,
645
656
  lastError: null
646
657
  }), c || this.emit("message", l);
647
658
  try {
648
- const w = [];
659
+ const S = [];
649
660
  for (const m of i) {
650
- const b = m.id ? this.attachmentFiles.get(m.id) : void 0;
661
+ const C = m.id ? this.attachmentFiles.get(m.id) : void 0;
651
662
  if (m.sandboxPath || m.storageKey) {
652
- w.push(m);
663
+ S.push(m);
653
664
  continue;
654
665
  }
655
- if (!b)
666
+ if (!C)
656
667
  throw new Error(`Attachment bytes are unavailable for ${m.name}`);
657
- w.push(await this.uploadAttachmentForMessage({ file: b, attachment: m }));
668
+ S.push(await this.uploadAttachmentForMessage({ file: C, attachment: m }));
658
669
  }
659
- i = w;
660
- } catch (w) {
670
+ i = S;
671
+ } catch (S) {
661
672
  throw this.setState({
662
- ...c ? {} : { messages: h },
663
- ...p ? {} : { ...d, isThinking: !1 },
673
+ ...c ? {} : { messages: f },
674
+ ...h ? {} : { ...d, isThinking: !1 },
664
675
  pendingMessageStatus: g,
665
676
  turnPhase: T
666
- }), w;
677
+ }), S;
667
678
  }
668
679
  this.retryableClientMessageId = null;
669
- const f = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, I = {
680
+ const p = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, I = {
670
681
  type: "chat.user_message",
671
682
  sessionId: this.state.sessionId ?? void 0,
672
683
  clientMessageId: a,
673
684
  initiatedBy: s.initiatedBy,
674
- invocation: _n(s.invocation ?? s.initiatedBy),
685
+ invocation: Pn(s.invocation ?? s.initiatedBy),
675
686
  entrySurface: this.options.entrySurface,
676
687
  content: n,
677
- pageContent: f && Ze() || void 0,
688
+ pageContent: p && et() || void 0,
678
689
  attachments: i.length > 0 ? i : void 0,
679
690
  page: o,
680
691
  model: this.options.model,
681
- metadata: St(this.options.metadata)
692
+ metadata: wt(this.options.metadata)
682
693
  };
683
694
  return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = I, this.browserConnectionInterruptedClientMessageIds.delete(a), this.send(I), this.schedulePendingDeliveryAck(a), a;
684
695
  }
@@ -698,16 +709,16 @@ class qt {
698
709
  return e ? (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.browserConnectionInterruptedClientMessageIds.delete(s), this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !1 }), !0) : !1;
699
710
  }
700
711
  createLocalAttachment(e) {
701
- this.options.productVariant === "customer_embedded" && Br(e);
702
- const s = H(), n = {
712
+ this.options.productVariant === "customer_embedded" && Wr(e);
713
+ const s = $(), n = {
703
714
  id: s,
704
715
  name: e.name || "attachment",
705
- mimeType: Ge(e),
716
+ mimeType: Xe(e),
706
717
  sizeBytes: e.size
707
718
  };
708
719
  this.attachmentFiles.set(s, e);
709
720
  const r = Date.now();
710
- return ds({
721
+ return hs({
711
722
  attachmentId: s,
712
723
  name: n.name,
713
724
  mimeType: n.mimeType,
@@ -736,7 +747,7 @@ class qt {
736
747
  file: e,
737
748
  attachment: s
738
749
  }) {
739
- const n = this.state.sessionId, r = Ge(e), i = {
750
+ const n = this.state.sessionId, r = Xe(e), i = {
740
751
  sessionId: n ?? void 0,
741
752
  attachmentId: s.id,
742
753
  clientId: this.options.clientId,
@@ -746,33 +757,33 @@ class qt {
746
757
  sizeBytes: e.size,
747
758
  page: k(),
748
759
  model: this.options.model,
749
- metadata: St(this.options.metadata),
760
+ metadata: wt(this.options.metadata),
750
761
  entrySurface: this.options.entrySurface
751
762
  };
752
763
  let o;
753
764
  if (this.options.persistAttachmentUpload)
754
- o = await ue(
765
+ o = await de(
755
766
  () => this.options.persistAttachmentUpload(i, e),
756
767
  "Failed to upload attachment"
757
768
  );
758
769
  else {
759
- const l = this.options.prepareAttachmentUpload ? await ue(
770
+ const l = this.options.prepareAttachmentUpload ? await de(
760
771
  () => this.options.prepareAttachmentUpload(i),
761
772
  "Failed to prepare attachment upload"
762
773
  ) : await this.prepareEmbedAttachmentUpload(i);
763
- await ue(async () => {
774
+ await de(async () => {
764
775
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
765
776
  method: l.uploadMethod,
766
777
  headers: l.uploadHeaders,
767
778
  body: e
768
779
  });
769
780
  if (!c.ok)
770
- throw new he("Failed to upload attachment", c.status);
781
+ throw new ge("Failed to upload attachment", c.status);
771
782
  return c;
772
783
  }, "Failed to upload attachment"), o = l;
773
784
  }
774
785
  this.setState({ sessionId: o.sessionId });
775
- const a = Qt(o.attachment, this.options.backendUrl);
786
+ const a = Zt(o.attachment, this.options.backendUrl);
776
787
  return this.updateAttachmentInState(s.id, a), s.id && ps(s.id, {
777
788
  sessionId: o.sessionId,
778
789
  fileUrl: a.fileUrl,
@@ -800,18 +811,18 @@ class qt {
800
811
  }
801
812
  async prepareEmbedAttachmentUpload(e) {
802
813
  let s = !1;
803
- return await ue(async () => {
814
+ return await de(async () => {
804
815
  const n = await this.fetchEmbedAttachmentUpload(e);
805
816
  if (n.ok)
806
817
  return await n.json();
807
- if (ti(n.status) && this.options.tokenProvider && !s) {
818
+ if (ni(n.status) && this.options.tokenProvider && !s) {
808
819
  s = !0;
809
820
  const r = await this.fetchEmbedAttachmentUpload(e);
810
821
  if (r.ok)
811
822
  return await r.json();
812
- throw new he("Failed to prepare attachment upload", r.status);
823
+ throw new ge("Failed to prepare attachment upload", r.status);
813
824
  }
814
- throw new he("Failed to prepare attachment upload", n.status);
825
+ throw new ge("Failed to prepare attachment upload", n.status);
815
826
  }, "Failed to prepare attachment upload");
816
827
  }
817
828
  async fetchEmbedAttachmentUpload(e) {
@@ -829,7 +840,7 @@ class qt {
829
840
  if (!this.state.sessionId)
830
841
  return;
831
842
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
832
- const e = Sr(
843
+ const e = Ar(
833
844
  this.state.messages,
834
845
  this.state.assistantDraftRespondsToUserMessageId,
835
846
  this.state.assistantDraftRunId,
@@ -842,7 +853,7 @@ class qt {
842
853
  stoppedCausalSequence: null,
843
854
  toolCallIds: new Set(
844
855
  this.state.messages.filter(
845
- (s) => Oe(
856
+ (s) => Ne(
846
857
  s,
847
858
  e.respondsToUserMessageId,
848
859
  e.runId
@@ -852,8 +863,8 @@ class qt {
852
863
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
853
864
  for (const [s, n] of this.activeBrowserToolCalls)
854
865
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(s);
855
- kt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
856
- messages: ce(
866
+ Pt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
867
+ messages: ue(
857
868
  this.state.messages,
858
869
  e.clientMessageId,
859
870
  e.runId
@@ -868,7 +879,7 @@ class qt {
868
879
  }
869
880
  startNewSession(e = {}) {
870
881
  const s = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
871
- !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
882
+ !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((r) => r.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionItemsRequestId = null, this.sessionItemsCursor = null, this.hasLoadedOlderSessionItems = !1, this.loadedOlderSessionItemIds.clear(), this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), s && this.send({
872
883
  type: "session.reset",
873
884
  sessionId: this.state.sessionId ?? void 0,
874
885
  warmupId: n ?? void 0,
@@ -877,6 +888,9 @@ class qt {
877
888
  sessionId: null,
878
889
  starterPrompts: [...this.state.starterPrompts],
879
890
  messages: [],
891
+ isLoadingSession: !1,
892
+ isLoadingOlderMessages: !1,
893
+ hasOlderMessages: !1,
880
894
  assistantDraft: "",
881
895
  assistantDraftItemId: null,
882
896
  assistantDraftPhase: null,
@@ -889,7 +903,7 @@ class qt {
889
903
  });
890
904
  }
891
905
  listSessions(e = {}) {
892
- const s = H(), n = new Promise((i, o) => {
906
+ const s = $(), n = new Promise((i, o) => {
893
907
  const a = window.setTimeout(() => {
894
908
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
895
909
  }, Tt);
@@ -911,25 +925,34 @@ class qt {
911
925
  setSessionPinned(e, s) {
912
926
  return this.sendSessionMutation(
913
927
  this.pendingSessionPinRequests,
914
- { type: "session.pin", requestId: H(), sessionId: e, pinned: s },
928
+ { type: "session.pin", requestId: $(), sessionId: e, pinned: s },
915
929
  "Session pin did not respond in time"
916
930
  );
917
931
  }
918
932
  renameSession(e, s) {
919
933
  return this.sendSessionMutation(
920
934
  this.pendingSessionRenameRequests,
921
- { type: "session.rename", requestId: H(), sessionId: e, title: s },
935
+ { type: "session.rename", requestId: $(), sessionId: e, title: s },
922
936
  "Session rename did not respond in time"
923
937
  );
924
938
  }
925
939
  loadSession(e) {
926
- const s = this.activeComposerWarmupId;
927
- !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), s && this.send({
940
+ const s = $(), n = this.activeComposerWarmupId;
941
+ !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
928
942
  type: "session.reset",
929
- warmupId: s,
943
+ warmupId: n,
930
944
  page: k()
931
- }), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.setState({
945
+ }), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionLoadRequestId = s, this.sessionLoadRequestTimer = window.setTimeout(() => {
946
+ this.sessionLoadRequestId === s && (this.clearSessionLoadRequest(), this.setState({
947
+ isLoadingSession: !1,
948
+ lastError: "This chat took too long to load. Please try again."
949
+ }));
950
+ }, en), this.sessionItemsRequestId = null, this.sessionItemsCursor = null, this.hasLoadedOlderSessionItems = !1, this.loadedOlderSessionItemIds.clear(), this.setState({
932
951
  sessionId: e,
952
+ messages: [],
953
+ isLoadingSession: !0,
954
+ isLoadingOlderMessages: !1,
955
+ hasOlderMessages: !1,
933
956
  assistantDraft: "",
934
957
  assistantDraftItemId: null,
935
958
  assistantDraftPhase: null,
@@ -942,14 +965,28 @@ class qt {
942
965
  lastErrorCode: null
943
966
  }), this.send({
944
967
  type: "session.load",
968
+ requestId: s,
945
969
  sessionId: e,
946
970
  page: k()
947
971
  });
948
972
  }
973
+ loadOlderMessages() {
974
+ if (!this.state.sessionId || !this.sessionItemsCursor || this.state.isLoadingSession || this.state.isLoadingOlderMessages)
975
+ return;
976
+ const e = $();
977
+ this.sessionItemsRequestId = e, this.setState({ isLoadingOlderMessages: !0, lastError: null, lastErrorCode: null }), this.send({
978
+ type: "session.items.list",
979
+ requestId: e,
980
+ sessionId: this.state.sessionId,
981
+ cursor: this.sessionItemsCursor,
982
+ limit: 50,
983
+ page: k()
984
+ });
985
+ }
949
986
  send(e) {
950
987
  this.sendNow(v(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
951
988
  (r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
952
- ) || this.queuedClientEvents.push(e), $(this.options.clientId, this.queuedClientEvents), this.setState({
989
+ ) || this.queuedClientEvents.push(e), j(this.options.clientId, this.queuedClientEvents), this.setState({
953
990
  status: "reconnecting",
954
991
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
955
992
  }), this.scheduleReconnect());
@@ -965,7 +1002,7 @@ class qt {
965
1002
  return !1;
966
1003
  const s = this.socket;
967
1004
  try {
968
- return s.send(JSON.stringify(e)), Pe("client_event", e.type, ht(e)), !0;
1005
+ return s.send(JSON.stringify(e)), Ue("client_event", e.type, pt(e)), !0;
969
1006
  } catch (n) {
970
1007
  return R("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
971
1008
  message: n instanceof Error ? n.message : String(n),
@@ -1009,7 +1046,7 @@ class qt {
1009
1046
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
1010
1047
  return;
1011
1048
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
1012
- const e = Un();
1049
+ const e = vn();
1013
1050
  this.sendNow(
1014
1051
  v({
1015
1052
  type: "starter_prompts.page_context",
@@ -1020,13 +1057,13 @@ class qt {
1020
1057
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
1021
1058
  }
1022
1059
  startStarterPromptUrlWatcher() {
1023
- this.locationChangeCleanup || (this.locationChangeCleanup = Dn(() => this.handleStarterPromptUrlChange()));
1060
+ this.locationChangeCleanup || (this.locationChangeCleanup = On(() => this.handleStarterPromptUrlChange()));
1024
1061
  }
1025
1062
  handleStarterPromptUrlChange() {
1026
1063
  const e = location.href;
1027
1064
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
1028
1065
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
1029
- }, rn));
1066
+ }, an));
1030
1067
  }
1031
1068
  refreshStarterPromptsForCurrentUrl() {
1032
1069
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -1041,16 +1078,19 @@ class qt {
1041
1078
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
1042
1079
  return;
1043
1080
  const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
1044
- $(this.options.clientId, this.queuedClientEvents);
1081
+ j(this.options.clientId, this.queuedClientEvents);
1045
1082
  for (let s = 0; s < e.length; s += 1) {
1046
1083
  const n = e[s];
1047
1084
  if (!this.sendNow(v(n))) {
1048
- this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), $(this.options.clientId, this.queuedClientEvents);
1085
+ this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), j(this.options.clientId, this.queuedClientEvents);
1049
1086
  return;
1050
1087
  }
1051
- $(this.options.clientId, this.queuedClientEvents);
1088
+ j(this.options.clientId, this.queuedClientEvents);
1052
1089
  }
1053
1090
  }
1091
+ resetForAuthenticationScopeChange() {
1092
+ this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], j(this.options.clientId, this.queuedClientEvents), this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear();
1093
+ }
1054
1094
  flushPendingPassiveWarmup() {
1055
1095
  !this.pendingPassiveWarmupEvent || !this.sendNow(this.pendingPassiveWarmupEvent) || (this.pendingPassiveWarmupEvent = null);
1056
1096
  }
@@ -1060,8 +1100,8 @@ class qt {
1060
1100
  return;
1061
1101
  this.clearPendingWarmupAckTimer();
1062
1102
  const s = Math.min(
1063
- Fs * 2 ** e.retryAttempt,
1064
- zs
1103
+ zs * 2 ** e.retryAttempt,
1104
+ Ks
1065
1105
  );
1066
1106
  e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
1067
1107
  this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
@@ -1076,24 +1116,24 @@ class qt {
1076
1116
  findStoppedTurnForEvent(e) {
1077
1117
  const s = e.type === "session.item" ? P(e.item) : null;
1078
1118
  return this.findStoppedTurn(
1079
- oe(e) ?? this.state.sessionId,
1119
+ ae(e) ?? this.state.sessionId,
1080
1120
  s ?? e
1081
1121
  );
1082
1122
  }
1083
1123
  rememberDurablyStoppedTurn(e, s, n) {
1084
- if (!e || !s || !xe(s) || this.findStoppedTurn(e, s))
1124
+ if (!e || !s || !qe(s) || this.findStoppedTurn(e, s))
1085
1125
  return;
1086
- const r = O(s), i = U(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
1126
+ const r = N(s), i = U(s), o = typeof s.clientMessageId == "string" ? s.clientMessageId : r ? this.clientMessageIdsByUserMessageItemId.get(r) ?? null : null;
1087
1127
  this.stoppedTurns.push({
1088
1128
  sessionId: e,
1089
1129
  clientMessageId: o,
1090
1130
  respondsToUserMessageId: r,
1091
1131
  runId: i,
1092
1132
  stoppedAt: n,
1093
- stoppedCausalSequence: N(s),
1133
+ stoppedCausalSequence: L(s),
1094
1134
  toolCallIds: new Set(
1095
1135
  this.state.messages.filter(
1096
- (a) => Oe(a, r, i)
1136
+ (a) => Ne(a, r, i)
1097
1137
  ).map((a) => a.callId).filter((a) => typeof a == "string")
1098
1138
  )
1099
1139
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -1103,29 +1143,29 @@ class qt {
1103
1143
  const n = typeof e.callId == "string" ? e.callId : null;
1104
1144
  return !!(n && this.stoppedTurns.some((r) => r.toolCallIds.has(n)));
1105
1145
  }
1106
- return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !xe(P(e.item)) : e.type !== "conversation.state" : !1;
1146
+ return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !qe(P(e.item)) : e.type !== "conversation.state" : !1;
1107
1147
  }
1108
1148
  filterStoppedSnapshotItems(e, s) {
1109
1149
  return e.filter((n) => {
1110
1150
  const r = P(n), i = r ? this.findStoppedTurn(s, r) : null;
1111
- if (!i || r?.type === "message" && r.role === "user" || xe(r))
1151
+ if (!i || r?.type === "message" && r.role === "user" || qe(r))
1112
1152
  return !0;
1113
1153
  if (i.stoppedCausalSequence !== null) {
1114
- const o = r ? N(r) : null;
1154
+ const o = r ? L(r) : null;
1115
1155
  return o === null || o <= i.stoppedCausalSequence;
1116
1156
  }
1117
1157
  if (i.stoppedAt) {
1118
- const o = S(n, "createdAt");
1158
+ const o = w(n, "createdAt");
1119
1159
  return !!(o && Date.parse(o) <= Date.parse(i.stoppedAt));
1120
1160
  }
1121
1161
  return !1;
1122
1162
  });
1123
1163
  }
1124
1164
  handleServerEvent(e) {
1125
- if (Pe("server_event", e.type, ht(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
1126
- S(e.item, "sessionId") ?? this.state.sessionId,
1165
+ if (Ue("server_event", e.type, pt(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
1166
+ w(e.item, "sessionId") ?? this.state.sessionId,
1127
1167
  P(e.item),
1128
- S(e.item, "createdAt")
1168
+ w(e.item, "createdAt")
1129
1169
  ), !(e.type === "session.updated" && typeof e.warmupId == "string" && e.warmupId !== this.activeComposerWarmupId)) {
1130
1170
  if (e.type === "runtime.warmup_ack" && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId) {
1131
1171
  this.clearPendingWarmupAckTimer(), this.pendingComposerWarmup.acknowledged = !0;
@@ -1134,12 +1174,12 @@ class qt {
1134
1174
  if (e.type === "run.ack") {
1135
1175
  if (this.shouldIgnoreStoppedTurnEvent(e))
1136
1176
  return;
1137
- const s = oe(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
1177
+ const s = ae(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
1138
1178
  s && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(s), this.deferredSessionUpdatedSessionIds.delete(s)) : s && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(s) && this.state.sessionId === null && this.setState({ sessionId: s }), this.handleRunAck(e);
1139
1179
  return;
1140
1180
  }
1141
1181
  if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
1142
- const s = oe(e);
1182
+ const s = ae(e);
1143
1183
  if (s) {
1144
1184
  this.deferredSessionUpdatedSessionIds.add(s);
1145
1185
  return;
@@ -1161,20 +1201,22 @@ class qt {
1161
1201
  this.activeResponseRunId = s, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
1162
1202
  return;
1163
1203
  }
1164
- if (un(e) && this.markThinkingProgress(), e.type === "auth.ok") {
1165
- this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
1166
- const s = $n(e), n = Object.prototype.hasOwnProperty.call(e, "appearance");
1204
+ if (hn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
1205
+ this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
1206
+ const s = Vn(e.user);
1207
+ this.authenticatedSocket !== this.socket && this.authenticatedUserId && s && s.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = s?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
1208
+ const n = jn(e), r = Object.prototype.hasOwnProperty.call(e, "appearance");
1167
1209
  R("web-sdk.agent", "Received auth.ok appearance", {
1168
- hasAppearance: n,
1210
+ hasAppearance: r,
1169
1211
  rawAppearance: e.appearance,
1170
- normalizedAppearance: s
1171
- }), this.runtimeHelperJavascript = jn(e.runtimeHelpers)?.javascript ?? null;
1172
- const r = Rt(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
1173
- user: Gn(e.user),
1212
+ normalizedAppearance: n
1213
+ }), this.runtimeHelperJavascript = zn(e.runtimeHelpers)?.javascript ?? null;
1214
+ const i = Rt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
1215
+ user: s,
1174
1216
  status: "connected",
1175
1217
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
1176
1218
  };
1177
- (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !ae() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1219
+ (o || this.state.starterPrompts.length === 0) && (l.starterPrompts = i, l.starterPromptsLoading = i.length > 0 ? !1 : a), o && i.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (r || n) && (l.appearance = n), this.setState(l), o && i.length === 0 && !a && !le() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1178
1220
  type: "page.upsert",
1179
1221
  sessionId: this.state.sessionId,
1180
1222
  page: k(),
@@ -1190,111 +1232,138 @@ class qt {
1190
1232
  return;
1191
1233
  }
1192
1234
  if (e.type === "conversation.state") {
1193
- const s = Array.isArray(e.items) ? e.items : [], n = S(e.session, "id") ?? this.state.sessionId;
1235
+ const s = Array.isArray(e.items) ? e.items : [], n = w(e.session, "id") ?? this.state.sessionId, r = typeof e.requestId == "string" ? e.requestId : null;
1236
+ if (r && r !== this.sessionLoadRequestId || this.state.isLoadingSession && n !== this.state.sessionId)
1237
+ return;
1238
+ n === this.state.sessionId && (this.clearSessionLoadRequest(), !this.hasLoadedOlderSessionItems && this.sessionItemsRequestId === null && (this.sessionItemsCursor = typeof e.itemsNextCursor == "string" ? e.itemsNextCursor : null));
1194
1239
  for (const E of s)
1195
1240
  this.rememberDurablyStoppedTurn(
1196
1241
  n,
1197
1242
  P(E),
1198
- S(E, "createdAt")
1243
+ w(E, "createdAt")
1199
1244
  );
1200
- const r = K(s), i = r === null ? null : s[r], o = P(i), a = this.findStoppedTurn(n, {
1201
- clientMessageId: o?.clientMessageId,
1202
- respondsToUserMessageId: S(i, "id"),
1203
- runId: o?.runId
1204
- }), l = this.filterStoppedSnapshotItems(s, n), c = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, p = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, g = e.isRetrying === !0, T = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
1205
- c && p && (this.pendingClientMessageId = p);
1206
- let h = tr(
1245
+ const i = X(s), o = i === null ? null : s[i], a = P(o), l = this.findStoppedTurn(n, {
1246
+ clientMessageId: a?.clientMessageId,
1247
+ respondsToUserMessageId: w(o, "id"),
1248
+ runId: a?.runId
1249
+ }), c = this.filterStoppedSnapshotItems(s, n), h = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, g = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, T = e.isRetrying === !0, f = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
1250
+ h && g && (this.pendingClientMessageId = g);
1251
+ let u = sr(
1207
1252
  e.assistantDraft
1208
1253
  );
1209
- h && this.findStoppedTurn(n, {
1210
- respondsToUserMessageId: h.respondsToUserMessageId,
1211
- runId: h.runId
1212
- }) && (h = void 0);
1213
- const u = h !== void 0;
1214
- this.rememberUserMessageClientMessageIds(l);
1215
- const d = mr(l);
1216
- if (d) {
1217
- const E = yr(l, d);
1218
- this.retryAttemptsByClientMessageId[d] = Math.max(
1219
- this.retryAttemptsByClientMessageId[d] ?? 0,
1254
+ u && this.findStoppedTurn(n, {
1255
+ respondsToUserMessageId: u.respondsToUserMessageId,
1256
+ runId: u.runId
1257
+ }) && (u = void 0);
1258
+ const d = u !== void 0;
1259
+ this.rememberUserMessageClientMessageIds(c);
1260
+ const p = Ir(c);
1261
+ if (p) {
1262
+ const E = Tr(c, p);
1263
+ this.retryAttemptsByClientMessageId[p] = Math.max(
1264
+ this.retryAttemptsByClientMessageId[p] ?? 0,
1220
1265
  E
1221
1266
  );
1222
1267
  }
1223
- const f = l.filter((E) => {
1268
+ const I = c.filter((E) => {
1224
1269
  const D = P(E);
1225
- return Ct(D) ? !1 : !D || !d || !je(D) ? !0 : ze(l, D) !== d;
1226
- }), I = cr(
1270
+ return bt(D) ? !1 : !D || !p || !je(D) ? !0 : Ke(c, D) !== p;
1271
+ }), S = ur(
1272
+ this.state.messages,
1273
+ Et(I, this.options.backendUrl)
1274
+ ), m = this.hasLoadedOlderSessionItems ? dr(
1227
1275
  this.state.messages,
1228
- Xn(f, this.options.backendUrl)
1229
- ), w = Et(I), m = !u && l.some(
1230
- (E) => bt(
1276
+ S,
1277
+ this.loadedOlderSessionItemIds
1278
+ ) : S, C = Ct(m), B = !d && c.some(
1279
+ (E) => kt(
1231
1280
  P(E),
1232
1281
  this.state.assistantDraft,
1233
1282
  this.state.assistantDraftItemId,
1234
1283
  this.state.assistantDraftRespondsToUserMessageId,
1235
1284
  this.state.assistantDraftRunId
1236
1285
  )
1237
- ), b = u ? h?.content ?? "" : this.state.assistantDraft, B = !!h?.content, _ = w && (!b || m), M = hr(I), X = _ && M;
1238
- if (!w && fr(this.state.messages, l))
1286
+ ), _ = d ? u?.content ?? "" : this.state.assistantDraft, M = !!u?.content, W = C && (!_ || B), b = fr(m), J = W && b;
1287
+ if (!C && yr(this.state.messages, c))
1239
1288
  return;
1240
- this.lastUserMessagePageUrl = gr(l);
1241
- const C = _ || a ? null : Fe(l);
1242
- if (this.latestRecoverableClientMessageId = C, M && this.clearRetryTimers(), this.setState({
1243
- sessionId: S(e.session, "id") ?? this.state.sessionId,
1244
- messages: I,
1245
- ...c ? { pendingMessageStatus: c } : {},
1246
- ...T ? { turnPhase: T } : {},
1247
- isRetrying: g,
1248
- ...u ? {
1249
- assistantDraft: h?.content ?? "",
1250
- assistantDraftItemId: h?.itemId ?? null,
1251
- assistantDraftPhase: h?.phase ?? null,
1252
- assistantDraftRespondsToUserMessageId: h?.respondsToUserMessageId ?? null,
1253
- assistantDraftRunId: h?.runId ?? null
1254
- } : m ? {
1289
+ this.lastUserMessagePageUrl = mr(c);
1290
+ const O = W || l ? null : ze(c);
1291
+ if (this.latestRecoverableClientMessageId = O, b && this.clearRetryTimers(), this.setState({
1292
+ sessionId: w(e.session, "id") ?? this.state.sessionId,
1293
+ messages: m,
1294
+ isLoadingSession: !1,
1295
+ isLoadingOlderMessages: this.sessionItemsRequestId !== null,
1296
+ hasOlderMessages: this.sessionItemsCursor !== null,
1297
+ ...h ? { pendingMessageStatus: h } : {},
1298
+ ...f ? { turnPhase: f } : {},
1299
+ isRetrying: T,
1300
+ ...d ? {
1301
+ assistantDraft: u?.content ?? "",
1302
+ assistantDraftItemId: u?.itemId ?? null,
1303
+ assistantDraftPhase: u?.phase ?? null,
1304
+ assistantDraftRespondsToUserMessageId: u?.respondsToUserMessageId ?? null,
1305
+ assistantDraftRunId: u?.runId ?? null
1306
+ } : B ? {
1255
1307
  assistantDraft: "",
1256
1308
  assistantDraftItemId: null,
1257
1309
  assistantDraftPhase: null,
1258
1310
  assistantDraftRespondsToUserMessageId: null,
1259
1311
  assistantDraftRunId: null
1260
1312
  } : {},
1261
- ...B ? {
1313
+ ...M ? {
1262
1314
  isThinking: !0,
1263
1315
  turnPhase: "thinking",
1264
1316
  lastError: null
1265
- } : _ ? {
1317
+ } : W ? {
1266
1318
  isThinking: !1,
1267
- ...X ? {
1319
+ ...J ? {
1268
1320
  status: "connected",
1269
1321
  lastError: null,
1270
1322
  lastErrorCode: null,
1271
1323
  lastErrorSecuritySettingsUrl: null
1272
1324
  } : {}
1273
- } : C ? {
1325
+ } : O ? {
1274
1326
  isThinking: !0,
1275
- turnPhase: T ?? this.state.turnPhase ?? "starting",
1327
+ turnPhase: f ?? this.state.turnPhase ?? "starting",
1276
1328
  lastError: null
1277
1329
  } : {}
1278
- }), _)
1330
+ }), W)
1279
1331
  this.retryableClientMessageId = null, this.clearThinkingWatchdog();
1280
- else if (!a && (B || C)) {
1281
- if (C) {
1282
- this.activeClientMessageId = C;
1283
- const E = K(l), D = E === null ? null : l[E];
1284
- this.activeResponseUserMessageId = S(D, "id");
1332
+ else if (!l && (M || O)) {
1333
+ if (O) {
1334
+ this.activeClientMessageId = O;
1335
+ const E = X(c), D = E === null ? null : c[E];
1336
+ this.activeResponseUserMessageId = w(D, "id");
1285
1337
  }
1286
1338
  this.markThinkingProgress();
1287
1339
  }
1288
- if (d) {
1289
- const E = S(e.session, "id") ?? this.state.sessionId;
1290
- E && this.retryAfterInterruptedRun(E, d);
1340
+ if (p) {
1341
+ const E = w(e.session, "id") ?? this.state.sessionId;
1342
+ E && this.retryAfterInterruptedRun(E, p);
1291
1343
  }
1292
1344
  return;
1293
1345
  }
1346
+ if (e.type === "session.items.page") {
1347
+ const s = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
1348
+ if (!s || s !== this.sessionItemsRequestId || n !== this.state.sessionId)
1349
+ return;
1350
+ const r = Et(
1351
+ Array.isArray(e.items) ? e.items : [],
1352
+ this.options.backendUrl
1353
+ ), i = new Set(r.map((o) => o.id));
1354
+ for (const o of i)
1355
+ this.loadedOlderSessionItemIds.add(o);
1356
+ this.sessionItemsRequestId = null, this.sessionItemsCursor = typeof e.nextCursor == "string" ? e.nextCursor : null, this.hasLoadedOlderSessionItems = !0, this.setState({
1357
+ messages: [...r, ...this.state.messages.filter((o) => !i.has(o.id))],
1358
+ isLoadingOlderMessages: !1,
1359
+ hasOlderMessages: this.sessionItemsCursor !== null
1360
+ });
1361
+ return;
1362
+ }
1294
1363
  if (e.type === "sessions.page") {
1295
1364
  const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1296
1365
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
1297
- sessions: Vn(e.sessions),
1366
+ sessions: Jn(e.sessions),
1298
1367
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
1299
1368
  }));
1300
1369
  return;
@@ -1309,7 +1378,7 @@ class qt {
1309
1378
  }
1310
1379
  if (e.type === "session.updated") {
1311
1380
  this.clearRunAckResyncRetryTimer();
1312
- const s = S(e.session, "id");
1381
+ const s = w(e.session, "id");
1313
1382
  s && typeof e.warmupId == "string" && e.warmupId === this.pendingComposerWarmup?.event.warmupId && (this.pendingComposerWarmup.event = {
1314
1383
  ...this.pendingComposerWarmup.event,
1315
1384
  sessionId: s
@@ -1323,7 +1392,7 @@ class qt {
1323
1392
  const s = P(e.item);
1324
1393
  if (je(s)) {
1325
1394
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1326
- const r = S(e.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1395
+ const r = w(e.item, "sessionId") ?? this.state.sessionId, i = s ? N(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
1327
1396
  if (r && a) {
1328
1397
  this.retryAfterInterruptedRun(r, a);
1329
1398
  return;
@@ -1333,21 +1402,21 @@ class qt {
1333
1402
  return;
1334
1403
  }
1335
1404
  }
1336
- if (Ct(s))
1405
+ if (bt(s))
1337
1406
  return;
1338
- const n = Ft(e.item, this.options.backendUrl);
1407
+ const n = zt(e.item, this.options.backendUrl);
1339
1408
  if (n) {
1340
1409
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1341
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1410
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1342
1411
  const i = e.item.data;
1343
- Tr(i) && this.clearRunAckResyncRetryTimer();
1344
- const o = He(this.state.messages, n), a = Et(o), l = bt(
1412
+ wr(i) && this.clearRunAckResyncRetryTimer();
1413
+ const o = $e(this.state.messages, n), a = Ct(o), l = kt(
1345
1414
  i,
1346
1415
  this.state.assistantDraft,
1347
1416
  this.state.assistantDraftItemId,
1348
1417
  this.state.assistantDraftRespondsToUserMessageId,
1349
1418
  this.state.assistantDraftRunId
1350
- ), c = a && (!this.state.assistantDraft || l), p = W(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
1419
+ ), c = a && (!this.state.assistantDraft || l), h = F(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
1351
1420
  this.setState({
1352
1421
  messages: o,
1353
1422
  ...l ? {
@@ -1361,7 +1430,7 @@ class qt {
1361
1430
  isThinking: !1,
1362
1431
  isRetrying: !1
1363
1432
  } : {},
1364
- ...p ? {
1433
+ ...h ? {
1365
1434
  status: "connected",
1366
1435
  lastError: null,
1367
1436
  lastErrorCode: null,
@@ -1373,9 +1442,9 @@ class qt {
1373
1442
  }
1374
1443
  if (e.type === "chat.assistant_delta") {
1375
1444
  this.clearRunAckResyncRetryTimer();
1376
- const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((g) => g.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, p = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
1377
- this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = p), this.setState({
1378
- messages: He(this.state.messages, {
1445
+ const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((g) => g.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
1446
+ this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = h), this.setState({
1447
+ messages: $e(this.state.messages, {
1379
1448
  id: o,
1380
1449
  role: "assistant",
1381
1450
  content: i,
@@ -1384,13 +1453,13 @@ class qt {
1384
1453
  dataType: "assistant_draft",
1385
1454
  ...l ? { phase: l } : {},
1386
1455
  ...c ? { respondsToUserMessageId: c } : {},
1387
- ...p ? { runId: p } : {}
1456
+ ...h ? { runId: h } : {}
1388
1457
  }),
1389
1458
  assistantDraft: i,
1390
1459
  assistantDraftItemId: n ?? this.state.assistantDraftItemId,
1391
1460
  assistantDraftPhase: l,
1392
1461
  assistantDraftRespondsToUserMessageId: c,
1393
- assistantDraftRunId: p,
1462
+ assistantDraftRunId: h,
1394
1463
  isThinking: !0,
1395
1464
  isRetrying: !1
1396
1465
  }), this.markThinkingProgress(), this.emit("delta", s);
@@ -1403,9 +1472,9 @@ class qt {
1403
1472
  const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null;
1404
1473
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1405
1474
  return;
1406
- const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = Ss(
1475
+ const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = Ms(
1407
1476
  this.state.messages.filter(
1408
- (c) => c.dataType !== "assistant_draft" || !Oe(
1477
+ (c) => c.dataType !== "assistant_draft" || !Ne(
1409
1478
  c,
1410
1479
  n,
1411
1480
  r
@@ -1413,11 +1482,11 @@ class qt {
1413
1482
  ),
1414
1483
  n,
1415
1484
  r,
1416
- zt
1485
+ Kt
1417
1486
  );
1418
1487
  this.setState({
1419
1488
  sessionId: s,
1420
- messages: rr(
1489
+ messages: ir(
1421
1490
  l,
1422
1491
  typeof e.responseId == "string" ? e.responseId : null,
1423
1492
  n,
@@ -1439,9 +1508,9 @@ class qt {
1439
1508
  if (s)
1440
1509
  this.nonTranscriptToolCallIds.add(s);
1441
1510
  else {
1442
- const n = ar(e);
1511
+ const n = lr(e);
1443
1512
  if (n) {
1444
- const r = ir(
1513
+ const r = or(
1445
1514
  this.state.messages,
1446
1515
  n
1447
1516
  );
@@ -1472,7 +1541,22 @@ class qt {
1472
1541
  return;
1473
1542
  }
1474
1543
  if (e.type === "error") {
1475
- const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1544
+ const s = typeof e.requestId == "string" ? e.requestId : null;
1545
+ if (s && s === this.sessionLoadRequestId) {
1546
+ this.clearSessionLoadRequest(), this.setState({
1547
+ isLoadingSession: !1,
1548
+ lastError: typeof e.message == "string" ? e.message : "Could not load this chat."
1549
+ });
1550
+ return;
1551
+ }
1552
+ if (s && s === this.sessionItemsRequestId) {
1553
+ this.sessionItemsRequestId = null, this.setState({
1554
+ isLoadingOlderMessages: !1,
1555
+ lastError: typeof e.message == "string" ? e.message : "Could not load older messages."
1556
+ });
1557
+ return;
1558
+ }
1559
+ const n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1476
1560
  if (s && n) {
1477
1561
  window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof e.message == "string" ? e.message : "Pluno error"));
1478
1562
  return;
@@ -1494,9 +1578,9 @@ class qt {
1494
1578
  return;
1495
1579
  }
1496
1580
  o && r && i && (this.retryableClientMessageId = i);
1497
- const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = kn(a.message);
1581
+ const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = Un(a.message);
1498
1582
  l && console.error(l), this.setState({
1499
- messages: ce(
1583
+ messages: ue(
1500
1584
  this.state.messages,
1501
1585
  i ?? this.activeClientMessageId,
1502
1586
  typeof e.runId == "string" ? e.runId : null
@@ -1513,9 +1597,9 @@ class qt {
1513
1597
  }
1514
1598
  }
1515
1599
  shouldIgnoreBackgroundSessionEvent(e) {
1516
- if (!this.options.keepRunsActiveOnSessionNavigation || !dn(e))
1600
+ if (!this.options.keepRunsActiveOnSessionNavigation || !pn(e))
1517
1601
  return !1;
1518
- const s = oe(e);
1602
+ const s = ae(e);
1519
1603
  return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
1520
1604
  }
1521
1605
  rememberCurrentRunAsBackground() {
@@ -1525,7 +1609,7 @@ class qt {
1525
1609
  const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
1526
1610
  if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
1527
1611
  return !1;
1528
- if (ae())
1612
+ if (le())
1529
1613
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
1530
1614
  if (e.code === "run_still_active") {
1531
1615
  if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
@@ -1539,10 +1623,10 @@ class qt {
1539
1623
  if (this.retryTimersByClientMessageId[n] !== void 0)
1540
1624
  return !0;
1541
1625
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
1542
- if (i >= Y)
1626
+ if (i >= Z)
1543
1627
  return !1;
1544
1628
  this.retryAttemptsByClientMessageId[n] = i + 1;
1545
- const o = Q(
1629
+ const o = ee(
1546
1630
  i,
1547
1631
  typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
1548
1632
  );
@@ -1556,20 +1640,20 @@ class qt {
1556
1640
  }, o), !0;
1557
1641
  }
1558
1642
  retryAfterInterruptedRun(e, s) {
1559
- if (ae()) {
1643
+ if (le()) {
1560
1644
  this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
1561
1645
  return;
1562
1646
  }
1563
1647
  if (this.retryTimersByClientMessageId[s] !== void 0)
1564
1648
  return;
1565
1649
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
1566
- if (n >= Y) {
1650
+ if (n >= Z) {
1567
1651
  this.reportHealthSignal("run_recovery_exhausted", {
1568
1652
  clientMessageId: s,
1569
1653
  retryAttempts: n,
1570
1654
  reason: "retry_budget_exhausted"
1571
1655
  }), this.retryableClientMessageId = s, this.setState({
1572
- messages: ce(
1656
+ messages: ue(
1573
1657
  this.state.messages,
1574
1658
  s,
1575
1659
  null
@@ -1583,7 +1667,7 @@ class qt {
1583
1667
  }
1584
1668
  this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
1585
1669
  delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: s, automatic: !0 });
1586
- }, Q(n));
1670
+ }, ee(n));
1587
1671
  }
1588
1672
  clearRetryTimers() {
1589
1673
  for (const e of Object.values(this.retryTimersByClientMessageId))
@@ -1592,10 +1676,10 @@ class qt {
1592
1676
  }
1593
1677
  rememberUserMessageClientMessageIds(e) {
1594
1678
  for (const s of e) {
1595
- const n = S(s, "id"), r = P(s);
1679
+ const n = w(s, "id"), r = P(s);
1596
1680
  n && r?.type === "message" && r.role === "user" && r.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof r.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId), r.clientMessageId === this.pendingClientMessageId && this.promotePendingDelivery(
1597
1681
  r.clientMessageId,
1598
- S(s, "sessionId") ?? this.state.sessionId,
1682
+ w(s, "sessionId") ?? this.state.sessionId,
1599
1683
  n,
1600
1684
  null
1601
1685
  ), r.clientMessageId === this.activeClientMessageId && (this.activeResponseUserMessageId = n));
@@ -1606,6 +1690,9 @@ class qt {
1606
1690
  window.clearTimeout(s.timeout), s.reject(new Error(e));
1607
1691
  this.pendingSessionHistoryRequests.clear();
1608
1692
  }
1693
+ clearSessionLoadRequest() {
1694
+ this.sessionLoadRequestTimer !== null && (window.clearTimeout(this.sessionLoadRequestTimer), this.sessionLoadRequestTimer = null), this.sessionLoadRequestId = null;
1695
+ }
1609
1696
  sendSessionMutation(e, s, n) {
1610
1697
  const r = new Promise((i, o) => {
1611
1698
  const a = window.setTimeout(() => {
@@ -1677,7 +1764,7 @@ class qt {
1677
1764
  }), this.markThinkingProgress();
1678
1765
  }
1679
1766
  schedulePendingDeliveryAck(e) {
1680
- this.clearPendingDeliveryTimers(), !ae() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
1767
+ this.clearPendingDeliveryTimers(), !le() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
1681
1768
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
1682
1769
  }, yt));
1683
1770
  }
@@ -1685,13 +1772,13 @@ class qt {
1685
1772
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
1686
1773
  return;
1687
1774
  const s = this.retryAttemptsByClientMessageId[e] ?? 0;
1688
- if (s >= Y) {
1775
+ if (s >= Z) {
1689
1776
  this.failPendingDelivery(e);
1690
1777
  return;
1691
1778
  }
1692
1779
  s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
1693
1780
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
1694
- }, Q(s, It));
1781
+ }, ee(s, It));
1695
1782
  }
1696
1783
  failPendingDelivery(e) {
1697
1784
  if (this.pendingClientMessageId !== e)
@@ -1702,7 +1789,7 @@ class qt {
1702
1789
  // A failed follow-up delivery must not hide an older acknowledged response that is still active.
1703
1790
  ...this.state.isThinking ? {} : { turnPhase: null },
1704
1791
  isRetrying: !1,
1705
- lastError: Js,
1792
+ lastError: Ys,
1706
1793
  lastErrorCode: "message_delivery_failed"
1707
1794
  });
1708
1795
  }
@@ -1717,7 +1804,7 @@ class qt {
1717
1804
  s,
1718
1805
  typeof e.runId == "string" ? e.runId : null
1719
1806
  ), !(!this.state.isThinking || !s) && this.setState({
1720
- messages: Ar(
1807
+ messages: Er(
1721
1808
  this.state.messages,
1722
1809
  s
1723
1810
  )
@@ -1737,7 +1824,7 @@ class qt {
1737
1824
  scheduleRunAckResyncRetry(e) {
1738
1825
  this.clearRunAckResyncRetryTimer();
1739
1826
  const s = this.retryAttemptsByClientMessageId[e] ?? 0;
1740
- s >= Y || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1827
+ s >= Z || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1741
1828
  this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[e] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || this.latestRecoverableClientMessageId !== e || (this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({
1742
1829
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1743
1830
  isThinking: !0,
@@ -1751,7 +1838,7 @@ class qt {
1751
1838
  clientMessageId: e,
1752
1839
  automatic: !0
1753
1840
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(mt)));
1754
- }, Q(s, It)));
1841
+ }, ee(s, It)));
1755
1842
  }
1756
1843
  clearRunAckResyncRetryTimer() {
1757
1844
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1776,7 +1863,7 @@ class qt {
1776
1863
  return;
1777
1864
  }
1778
1865
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
1779
- if (n >= Y) {
1866
+ if (n >= Z) {
1780
1867
  R("web-sdk.agent", "Pluno run recovery retry exhausted", {
1781
1868
  sessionId: this.state.sessionId,
1782
1869
  clientMessageId: e
@@ -1785,7 +1872,7 @@ class qt {
1785
1872
  retryAttempts: n,
1786
1873
  reason: "retry_budget_exhausted"
1787
1874
  }), this.retryableClientMessageId = e, this.setState({
1788
- messages: ce(
1875
+ messages: ue(
1789
1876
  this.state.messages,
1790
1877
  e,
1791
1878
  null
@@ -1801,7 +1888,7 @@ class qt {
1801
1888
  sessionId: this.state.sessionId,
1802
1889
  clientMessageId: e,
1803
1890
  resyncAttempts: s + 1
1804
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Gs);
1891
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Xs);
1805
1892
  return;
1806
1893
  }
1807
1894
  this.setState({
@@ -1819,7 +1906,7 @@ class qt {
1819
1906
  clientMessageId: e,
1820
1907
  automatic: !0
1821
1908
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1822
- }, Q(n)));
1909
+ }, ee(n)));
1823
1910
  }
1824
1911
  resyncThinkingSession() {
1825
1912
  this.state.sessionId ? this.send({
@@ -1830,13 +1917,13 @@ class qt {
1830
1917
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
1831
1918
  }
1832
1919
  async executeToolCall(e) {
1833
- const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = F(
1920
+ const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = K(
1834
1921
  typeof e.summary == "string" ? e.summary : "Running browser tool"
1835
1922
  ), o = e.rawInput;
1836
1923
  if (!s || !n || !r)
1837
1924
  return;
1838
1925
  const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1839
- if (!a && !l || !jr(o)) {
1926
+ if (!a && !l || !zr(o)) {
1840
1927
  this.setToolMessageLoading(n, !1), this.send({
1841
1928
  type: "tool.result",
1842
1929
  sessionId: s,
@@ -1882,10 +1969,10 @@ class qt {
1882
1969
  startedAtUrl: location.href,
1883
1970
  startedAtOrigin: location.origin
1884
1971
  }), this.installSessionBrowserApis();
1885
- let c = null, p;
1886
- c = await this.executeRuntimeHelper(), p = await Mt(
1972
+ let c = null, h;
1973
+ c = await this.executeRuntimeHelper(), h = await Mt(
1887
1974
  o,
1888
- Rn(e.runtimeContext, this.options.backendUrl)
1975
+ Cn(e.runtimeContext, this.options.backendUrl)
1889
1976
  ).catch((g) => ({
1890
1977
  ok: !1,
1891
1978
  exception: {
@@ -1898,11 +1985,11 @@ class qt {
1898
1985
  toolName: r,
1899
1986
  summary: o.summary,
1900
1987
  rawInput: v(o),
1901
- rawOutput: v(Fn(p, c))
1902
- }), kt(this.options.clientId, this.activeBrowserToolCalls.values()));
1988
+ rawOutput: v(Kn(h, c))
1989
+ }), Pt(this.options.clientId, this.activeBrowserToolCalls.values()));
1903
1990
  }
1904
1991
  setToolMessageLoading(e, s) {
1905
- const n = or(
1992
+ const n = ar(
1906
1993
  this.state.messages,
1907
1994
  e,
1908
1995
  s
@@ -1913,17 +2000,17 @@ class qt {
1913
2000
  if (this.pageLifecycleCleanup)
1914
2001
  return;
1915
2002
  const e = () => {
1916
- Jt(this.options.clientId, this.activeBrowserToolCalls.values());
2003
+ Yt(this.options.clientId, this.activeBrowserToolCalls.values());
1917
2004
  };
1918
2005
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
1919
2006
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
1920
2007
  };
1921
2008
  }
1922
2009
  installSessionBrowserApis() {
1923
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = gn();
2010
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = mn();
1924
2011
  }
1925
2012
  cleanupSessionBrowserApis() {
1926
- this.sessionBrowserApisCleanup && (Mn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
2013
+ this.sessionBrowserApisCleanup && (Rn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
1927
2014
  }
1928
2015
  async executeRuntimeHelper() {
1929
2016
  if (!this.runtimeHelperJavascript?.trim())
@@ -1931,15 +2018,15 @@ class qt {
1931
2018
  const e = await Mt({
1932
2019
  javascript: this.runtimeHelperJavascript
1933
2020
  });
1934
- return e.ok === !1 ? zn(e) : null;
2021
+ return e.ok === !1 ? Gn(e) : null;
1935
2022
  }
1936
2023
  enableNetworkCapture() {
1937
- this.networkCaptureCleanup || (this.networkCaptureCleanup = ln((e) => {
1938
- Vr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
2024
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = un((e) => {
2025
+ Yr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
1939
2026
  }));
1940
2027
  }
1941
2028
  enqueueNetworkEvent(e) {
1942
- this.queuedNetworkEvents.length >= Qs || (this.queuedNetworkEvents.push(Xr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
2029
+ this.queuedNetworkEvents.length >= Zs || (this.queuedNetworkEvents.push(Jr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1943
2030
  this.networkBatchTimer = null;
1944
2031
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1945
2032
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1948,12 +2035,12 @@ class qt {
1948
2035
  page: k(),
1949
2036
  events: s
1950
2037
  });
1951
- }, Ys)));
2038
+ }, Qs)));
1952
2039
  }
1953
2040
  scheduleReconnect() {
1954
2041
  if (this.reconnectTimer !== null || this.state.status === "closed")
1955
2042
  return;
1956
- const e = on(this.reconnectAttempts);
2043
+ const e = ln(this.reconnectAttempts);
1957
2044
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1958
2045
  this.reconnectTimer = null, this.connect().catch((s) => {
1959
2046
  R("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1969,8 +2056,8 @@ class qt {
1969
2056
  const e = this.socket;
1970
2057
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1971
2058
  this.socket === e && (R("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
1972
- }, Ws));
1973
- }, qs);
2059
+ }, Hs));
2060
+ }, Ws);
1974
2061
  }
1975
2062
  stopHeartbeat() {
1976
2063
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -2005,7 +2092,7 @@ class qt {
2005
2092
  turnPhase: r,
2006
2093
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
2007
2094
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
2008
- }, Ur(this.options.clientId, this.state), this.emit("state", this.getState()), Pe("state", this.state.status, {
2095
+ }, vr(this.options.clientId, this.state), this.emit("state", this.getState()), Ue("state", this.state.status, {
2009
2096
  status: this.state.status,
2010
2097
  sessionId: this.state.sessionId,
2011
2098
  messageCount: this.state.messages.length,
@@ -2026,50 +2113,50 @@ class qt {
2026
2113
  this.state.isThinking && this.activeClientMessageId ? this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.pendingClientMessageId);
2027
2114
  }
2028
2115
  getRunRecoveryExhaustedErrorMessage(e) {
2029
- return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? Vs : Xs;
2116
+ return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? Js : Vs;
2030
2117
  }
2031
2118
  emit(e, s) {
2032
2119
  this.listeners[e]?.forEach((r) => r(s));
2033
2120
  }
2034
2121
  }
2035
- const De = /* @__PURE__ */ new WeakMap();
2036
- function ln(t) {
2037
- const e = window.__plunoProductAgentNetworkCapture ?? cn();
2122
+ const ve = /* @__PURE__ */ new WeakMap();
2123
+ function un(t) {
2124
+ const e = window.__plunoProductAgentNetworkCapture ?? dn();
2038
2125
  return e.subscribers.add(t), () => {
2039
2126
  e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
2040
2127
  };
2041
2128
  }
2042
- function cn() {
2129
+ function dn() {
2043
2130
  const t = /* @__PURE__ */ new Set(), e = (T) => {
2044
- t.forEach((h) => {
2131
+ t.forEach((f) => {
2045
2132
  try {
2046
- h(T);
2133
+ f(T);
2047
2134
  } catch {
2048
2135
  }
2049
2136
  });
2050
- }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(h, u) {
2137
+ }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(f, u) {
2051
2138
  const d = Date.now();
2052
- let f;
2139
+ let p;
2053
2140
  try {
2054
- f = s.call(this, h, u);
2141
+ p = s.call(this, f, u);
2055
2142
  } catch (I) {
2056
2143
  throw I;
2057
2144
  }
2058
2145
  try {
2059
- const I = h instanceof Request ? h : null, w = Fr(h, I), m = es(u?.headers ?? I?.headers);
2060
- if (!j(w, m, u?.body)) {
2146
+ const I = f instanceof Request ? f : null, S = Kr(f, I), m = ts(u?.headers ?? I?.headers);
2147
+ if (!z(S, m, u?.body)) {
2061
2148
  const B = {
2062
- requestId: Le("fetch"),
2063
- url: x(w, Ue),
2149
+ requestId: xe("fetch"),
2150
+ url: q(S, De),
2064
2151
  method: (u?.method ?? I?.method ?? "GET").toUpperCase(),
2065
2152
  requestHeaders: m,
2066
- requestBody: Ut(u?.body),
2153
+ requestBody: Dt(u?.body),
2067
2154
  resourceType: "fetch",
2068
2155
  startedAt: new Date(d).toISOString()
2069
2156
  };
2070
- f.then(
2157
+ p.then(
2071
2158
  (_) => {
2072
- zr(_, B, d, e).catch(() => {
2159
+ Gr(_, B, d, e).catch(() => {
2073
2160
  e({
2074
2161
  ...B,
2075
2162
  responseStatus: _.status,
@@ -2080,7 +2167,7 @@ function cn() {
2080
2167
  (_) => {
2081
2168
  e({
2082
2169
  ...B,
2083
- errorText: x(_ instanceof Error ? _.message : String(_)),
2170
+ errorText: q(_ instanceof Error ? _.message : String(_)),
2084
2171
  durationMs: Date.now() - d
2085
2172
  });
2086
2173
  }
@@ -2088,30 +2175,30 @@ function cn() {
2088
2175
  }
2089
2176
  } catch {
2090
2177
  }
2091
- return f;
2092
- }, a = function(h, u, d, f, I) {
2093
- const w = n.call(this, h, u, d ?? !0, f ?? void 0, I ?? void 0), m = typeof u == "string" ? u : u.toString();
2094
- return De.set(this, {
2095
- requestId: Le("xhr"),
2096
- method: String(h ?? "GET").toUpperCase(),
2097
- url: x(m, Ue),
2178
+ return p;
2179
+ }, a = function(f, u, d, p, I) {
2180
+ const S = n.call(this, f, u, d ?? !0, p ?? void 0, I ?? void 0), m = typeof u == "string" ? u : u.toString();
2181
+ return ve.set(this, {
2182
+ requestId: xe("xhr"),
2183
+ method: String(f ?? "GET").toUpperCase(),
2184
+ url: q(m, De),
2098
2185
  requestHeaders: {},
2099
2186
  startedAtMs: Date.now(),
2100
2187
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
2101
- excluded: j(m)
2102
- }), w;
2103
- }, l = function(h, u) {
2104
- const d = r.call(this, h, u), f = De.get(this);
2105
- return f && Object.keys(f.requestHeaders).length < Qe && (f.requestHeaders[h] = st(h, u), f.excluded = f.excluded || j(f.url, f.requestHeaders)), d;
2106
- }, c = function(h) {
2188
+ excluded: z(m)
2189
+ }), S;
2190
+ }, l = function(f, u) {
2191
+ const d = r.call(this, f, u), p = ve.get(this);
2192
+ return p && Object.keys(p.requestHeaders).length < Ze && (p.requestHeaders[f] = nt(f, u), p.excluded = p.excluded || z(p.url, p.requestHeaders)), d;
2193
+ }, c = function(f) {
2107
2194
  try {
2108
- const u = De.get(this);
2109
- u && (u.excluded = u.excluded || j(u.url, u.requestHeaders, h), u.requestBody = Ut(h), u.excluded || this.addEventListener(
2195
+ const u = ve.get(this);
2196
+ u && (u.excluded = u.excluded || z(u.url, u.requestHeaders, f), u.requestBody = Dt(f), u.excluded || this.addEventListener(
2110
2197
  "loadend",
2111
2198
  () => {
2112
2199
  queueMicrotask(() => {
2113
2200
  try {
2114
- const d = Yr(this.getAllResponseHeaders());
2201
+ const d = Zr(this.getAllResponseHeaders());
2115
2202
  e({
2116
2203
  requestId: u.requestId,
2117
2204
  url: u.url,
@@ -2121,7 +2208,7 @@ function cn() {
2121
2208
  resourceType: "xhr",
2122
2209
  responseStatus: this.status,
2123
2210
  responseHeaders: d,
2124
- responseBody: Gr(this, d),
2211
+ responseBody: Vr(this, d),
2125
2212
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
2126
2213
  startedAt: u.startedAt,
2127
2214
  durationMs: Date.now() - u.startedAtMs
@@ -2135,7 +2222,7 @@ function cn() {
2135
2222
  ));
2136
2223
  } catch {
2137
2224
  }
2138
- return i.call(this, h ?? null);
2225
+ return i.call(this, f ?? null);
2139
2226
  };
2140
2227
  try {
2141
2228
  window.fetch = o;
@@ -2153,17 +2240,17 @@ function cn() {
2153
2240
  XMLHttpRequest.prototype.send = c;
2154
2241
  } catch {
2155
2242
  }
2156
- let p = null;
2243
+ let h = null;
2157
2244
  if (typeof PerformanceObserver < "u") {
2158
- p = new PerformanceObserver((T) => {
2159
- for (const h of T.getEntries()) {
2160
- const u = h;
2161
- if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || j(u.name))
2245
+ h = new PerformanceObserver((T) => {
2246
+ for (const f of T.getEntries()) {
2247
+ const u = f;
2248
+ if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || z(u.name))
2162
2249
  continue;
2163
2250
  const d = performance.timeOrigin + u.startTime;
2164
2251
  e({
2165
- requestId: Le("resource"),
2166
- url: x(u.name, Ue),
2252
+ requestId: xe("resource"),
2253
+ url: q(u.name, De),
2167
2254
  method: "GET",
2168
2255
  resourceType: "resource",
2169
2256
  responseStatus: u.responseStatus,
@@ -2173,15 +2260,15 @@ function cn() {
2173
2260
  }
2174
2261
  });
2175
2262
  try {
2176
- p.observe({ type: "resource", buffered: !0 });
2263
+ h.observe({ type: "resource", buffered: !0 });
2177
2264
  } catch {
2178
- p.disconnect(), p = null;
2265
+ h.disconnect(), h = null;
2179
2266
  }
2180
2267
  }
2181
2268
  const g = {
2182
2269
  subscribers: t,
2183
2270
  destroy: () => {
2184
- p?.disconnect();
2271
+ h?.disconnect();
2185
2272
  try {
2186
2273
  window.fetch === o && (window.fetch = s);
2187
2274
  } catch {
@@ -2213,17 +2300,17 @@ function R(t, e, s) {
2213
2300
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
2214
2301
  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 }));
2215
2302
  }
2216
- function St(t) {
2303
+ function wt(t) {
2217
2304
  const e = typeof t == "function" ? t() : t;
2218
2305
  return e && Object.keys(e).length > 0 ? e : void 0;
2219
2306
  }
2220
- function un(t) {
2307
+ function hn(t) {
2221
2308
  return t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call";
2222
2309
  }
2223
- function dn(t) {
2310
+ function pn(t) {
2224
2311
  return t.type === "run.steered" || t.type === "run.ack" || t.type === "run.model_started" || t.type === "conversation.state" || t.type === "session.updated" || t.type === "session.item" || t.type === "chat.assistant_delta" || t.type === "chat.assistant_done" || t.type === "tool.call" || t.type === "tool.status" || t.type === "error" && typeof t.requestId != "string";
2225
2312
  }
2226
- function oe(t) {
2313
+ function ae(t) {
2227
2314
  if (typeof t.sessionId == "string")
2228
2315
  return t.sessionId;
2229
2316
  if (t.session && typeof t.session == "object") {
@@ -2238,31 +2325,31 @@ function oe(t) {
2238
2325
  }
2239
2326
  return null;
2240
2327
  }
2241
- const pn = 5e3, hn = 12e4;
2242
- function gn() {
2328
+ const gn = 5e3, fn = 12e4;
2329
+ function mn() {
2243
2330
  const t = [
2244
- mn(),
2245
- fn()
2331
+ In(),
2332
+ yn()
2246
2333
  ].filter((e) => typeof e == "function");
2247
2334
  return () => {
2248
2335
  for (const e of t.reverse())
2249
2336
  e();
2250
2337
  };
2251
2338
  }
2252
- function fn() {
2253
- return vt(globalThis, "getPageSnapshot", async () => Ze());
2339
+ function yn() {
2340
+ return Ot(globalThis, "getPageSnapshot", async () => et());
2254
2341
  }
2255
- function mn() {
2256
- return vt(globalThis, "pageImages", {
2257
- inspectImage: async (e, s) => await yn(e, s)
2342
+ function In() {
2343
+ return Ot(globalThis, "pageImages", {
2344
+ inspectImage: async (e, s) => await Tn(e, s)
2258
2345
  });
2259
2346
  }
2260
- async function yn(t, e = {}) {
2261
- const s = Sn(e.name), n = await In(t);
2347
+ async function Tn(t, e = {}) {
2348
+ const s = An(e.name), n = await Sn(t);
2262
2349
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
2263
2350
  type: "pluno.pageImages.inspectImage",
2264
2351
  imageAttached: !1,
2265
- imageAttachmentError: Lt
2352
+ imageAttachmentError: xt
2266
2353
  } : {
2267
2354
  type: "pluno.pageImages.inspectImage",
2268
2355
  imageAttached: !0,
@@ -2276,15 +2363,15 @@ async function yn(t, e = {}) {
2276
2363
  imageAttachmentError: n.error
2277
2364
  };
2278
2365
  }
2279
- async function In(t) {
2280
- return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: Lt } : {
2366
+ async function Sn(t) {
2367
+ return t instanceof Blob ? t.type.startsWith("image/") ? t.size === 0 ? { ok: !1, error: "Page image is empty." } : t.size > 8 * 1024 * 1024 ? { ok: !1, error: xt } : {
2281
2368
  ok: !0,
2282
2369
  mimeType: t.type,
2283
2370
  sizeBytes: t.size,
2284
- dataUrl: await An(t)
2285
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Tn(t);
2371
+ dataUrl: await En(t)
2372
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : wn(t);
2286
2373
  }
2287
- function Tn(t) {
2374
+ function wn(t) {
2288
2375
  if (!t.startsWith("data:") || !t.includes(","))
2289
2376
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
2290
2377
  const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -2295,7 +2382,7 @@ function Tn(t) {
2295
2382
  const i = s.replace(/[ \t\r\n\f]+/g, "");
2296
2383
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
2297
2384
  return { ok: !1, error: "Page image data URL has invalid base64." };
2298
- const o = wn(i);
2385
+ const o = Mn(i);
2299
2386
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
2300
2387
  ok: !0,
2301
2388
  mimeType: r,
@@ -2303,22 +2390,22 @@ function Tn(t) {
2303
2390
  dataUrl: `data:${r};base64,${i}`
2304
2391
  };
2305
2392
  }
2306
- function wn(t) {
2393
+ function Mn(t) {
2307
2394
  if (t.length === 0 || t.length % 4 !== 0)
2308
2395
  return null;
2309
2396
  const e = t.length - t.replace(/=+$/, "").length;
2310
2397
  return e > 2 ? null : t.length / 4 * 3 - e;
2311
2398
  }
2312
- function Sn(t) {
2399
+ function An(t) {
2313
2400
  return (typeof t == "string" ? t.trim() : "") || "Page image";
2314
2401
  }
2315
- function Mn(t) {
2402
+ function Rn(t) {
2316
2403
  try {
2317
2404
  t();
2318
2405
  } catch {
2319
2406
  }
2320
2407
  }
2321
- function An(t) {
2408
+ function En(t) {
2322
2409
  return new Promise((e, s) => {
2323
2410
  const n = new FileReader();
2324
2411
  n.onload = () => {
@@ -2332,27 +2419,27 @@ function An(t) {
2332
2419
  }
2333
2420
  async function Mt(t, e) {
2334
2421
  const s = Object.getPrototypeOf(async function() {
2335
- }).constructor, n = t.timeoutMs ?? pn, r = Date.now(), i = [];
2422
+ }).constructor, n = t.timeoutMs ?? gn, r = Date.now(), i = [];
2336
2423
  let o;
2337
2424
  const a = {
2338
2425
  log: console.log,
2339
2426
  info: console.info,
2340
2427
  warn: console.warn,
2341
2428
  error: console.error
2342
- }, l = (c) => (...p) => {
2343
- i.push({ level: c, args: p }), a[c](...p);
2429
+ }, l = (c) => (...h) => {
2430
+ i.push({ level: c, args: h }), a[c](...h);
2344
2431
  };
2345
2432
  console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
2346
2433
  try {
2347
- const c = /* @__PURE__ */ Symbol("execute_code_timeout"), p = await Promise.race([
2434
+ const c = /* @__PURE__ */ Symbol("execute_code_timeout"), h = await Promise.race([
2348
2435
  new s("sandboxFiles", t.javascript)(e?.value),
2349
2436
  new Promise((g) => {
2350
2437
  o = window.setTimeout(() => g(c), n);
2351
2438
  })
2352
2439
  ]);
2353
- return p === c ? En(n) : {
2440
+ return h === c ? bn(n) : {
2354
2441
  ok: !0,
2355
- result: p,
2442
+ result: h,
2356
2443
  console: i,
2357
2444
  metadata: {
2358
2445
  durationMs: Date.now() - r,
@@ -2379,7 +2466,7 @@ async function Mt(t, e) {
2379
2466
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
2380
2467
  }
2381
2468
  }
2382
- function Rn(t, e) {
2469
+ function Cn(t, e) {
2383
2470
  if (!t || typeof t != "object")
2384
2471
  return;
2385
2472
  const s = t.sandboxFilesToken;
@@ -2389,20 +2476,20 @@ function Rn(t, e) {
2389
2476
  const r = () => {
2390
2477
  if (!n)
2391
2478
  throw new Error("sandboxFiles is only available during browser-code execution");
2392
- }, i = async (a, l) => await Ds(`${e.replace(/\/$/, "")}${a}`, l);
2479
+ }, i = async (a, l) => await vs(`${e.replace(/\/$/, "")}${a}`, l);
2393
2480
  return {
2394
2481
  value: Object.freeze({
2395
2482
  upload: async (a) => {
2396
2483
  if (r(), !(a instanceof Blob))
2397
2484
  throw new TypeError("sandboxFiles.upload expects a File or Blob");
2398
- const l = a instanceof File && a.name ? a.name : "file", c = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, p = await i(`/api/product-agent/attachments/sandbox-files${c}`, {
2485
+ const l = a instanceof File && a.name ? a.name : "file", c = `?name=${encodeURIComponent(l)}&size_bytes=${a.size}`, h = await i(`/api/product-agent/attachments/sandbox-files${c}`, {
2399
2486
  method: "PUT",
2400
2487
  headers: { Authorization: `Bearer ${s}` },
2401
2488
  body: a
2402
2489
  });
2403
- if (!p.ok)
2404
- throw new Error(`sandboxFiles.upload failed (${p.status})`);
2405
- return String((await p.json()).path);
2490
+ if (!h.ok)
2491
+ throw new Error(`sandboxFiles.upload failed (${h.status})`);
2492
+ return String((await h.json()).path);
2406
2493
  },
2407
2494
  download: async (a) => {
2408
2495
  r();
@@ -2423,7 +2510,7 @@ function Rn(t, e) {
2423
2510
  }
2424
2511
  };
2425
2512
  }
2426
- function En(t) {
2513
+ function bn(t) {
2427
2514
  return {
2428
2515
  ok: !1,
2429
2516
  exception: {
@@ -2437,10 +2524,10 @@ function En(t) {
2437
2524
  }
2438
2525
  };
2439
2526
  }
2440
- function Cn(t) {
2527
+ function kn(t) {
2441
2528
  return t.replace(/\/+$/, "");
2442
2529
  }
2443
- function bn(t) {
2530
+ function _n(t) {
2444
2531
  const e = {
2445
2532
  sidepanel: "extension_sidepanel",
2446
2533
  browser_extension_page_ui: "extension_widget",
@@ -2452,13 +2539,13 @@ function bn(t) {
2452
2539
  };
2453
2540
  return t && t in e ? e[t] : t ?? "embedded_custom_ui";
2454
2541
  }
2455
- function _n(t) {
2542
+ function Pn(t) {
2456
2543
  return t === "pluno" ? "scheduled_continuation" : t ?? "user";
2457
2544
  }
2458
- function kn(t, e = location.origin) {
2545
+ function Un(t, e = location.origin) {
2459
2546
  return /origin (?:is not allowed|does not match browser origin)/i.test(t) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
2460
2547
  }
2461
- function Pn(t) {
2548
+ function Dn(t) {
2462
2549
  const e = new URL("/api/product-agent/embed/ws", t);
2463
2550
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
2464
2551
  }
@@ -2471,19 +2558,19 @@ function k() {
2471
2558
  ...t ? { plunoProductAgentUi: t } : {}
2472
2559
  };
2473
2560
  }
2474
- function Un() {
2561
+ function vn() {
2475
2562
  return {
2476
2563
  pageUrl: location.href,
2477
2564
  pageTitle: document.title,
2478
- htmlContent: Ze()
2565
+ htmlContent: et()
2479
2566
  };
2480
2567
  }
2481
- function Dn(t) {
2482
- return pe.add(t), ie || (ie = vn()), () => {
2483
- pe.delete(t), pe.size === 0 && (ie?.(), ie = null);
2568
+ function On(t) {
2569
+ return pe.add(t), oe || (oe = Ln()), () => {
2570
+ pe.delete(t), pe.size === 0 && (oe?.(), oe = null);
2484
2571
  };
2485
2572
  }
2486
- function vn() {
2573
+ function Ln() {
2487
2574
  const t = () => {
2488
2575
  for (const i of Array.from(pe))
2489
2576
  i();
@@ -2498,38 +2585,38 @@ function vn() {
2498
2585
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
2499
2586
  };
2500
2587
  }
2501
- function ae() {
2588
+ function le() {
2502
2589
  return jt()?.surface === "browser_extension_sdk_preview";
2503
2590
  }
2504
- function Ze() {
2591
+ function et() {
2505
2592
  if (!document.body)
2506
2593
  return "";
2507
- const t = [], e = [], s = (d, f) => {
2508
- const I = z(f);
2594
+ const t = [], e = [], s = (d, p) => {
2595
+ const I = G(p);
2509
2596
  !I || e.includes(I) || (t.push([d, I]), e.push(I));
2510
2597
  };
2511
2598
  s("Selected text", window.getSelection()?.toString() ?? "");
2512
2599
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
2513
- (d) => Wt(d) && !d.parentElement?.closest(n)
2600
+ (d) => Ht(d) && !d.parentElement?.closest(n)
2514
2601
  );
2515
2602
  for (const d of r.slice(0, 3))
2516
- s("Active overlay", ve(Z(d), e));
2517
- const i = Nn(), o = i ? ve(Z(i), e) : "";
2518
- s("Main page content", o), s("Additional visible page text", ve(Z(document.body), e));
2519
- const a = t.map(([d, f]) => `${d}:
2520
- ${f}`).join(`
2603
+ s("Active overlay", Oe(te(d), e));
2604
+ const i = Nn(), o = i ? Oe(te(i), e) : "";
2605
+ s("Main page content", o), s("Additional visible page text", Oe(te(document.body), e));
2606
+ const a = t.map(([d, p]) => `${d}:
2607
+ ${p}`).join(`
2521
2608
 
2522
- `).trim().slice(0, 12e3), l = On(r, i).trim(), c = `Simplified DOM outline:
2523
- `, p = `
2609
+ `).trim().slice(0, 12e3), l = qn(r, i).trim(), c = `Simplified DOM outline:
2610
+ `, h = `
2524
2611
 
2525
2612
  Visible page text:
2526
- `, g = 12e3 - c.length - p.length, T = Math.min(a.length, 7900), h = l.slice(0, g - T), u = a.slice(0, g - h.length);
2527
- return `${c}${h}${p}${u}`;
2613
+ `, g = 12e3 - c.length - h.length, T = Math.min(a.length, 7900), f = l.slice(0, g - T), u = a.slice(0, g - f.length);
2614
+ return `${c}${f}${h}${u}`;
2528
2615
  }
2529
- function Z(t) {
2616
+ function te(t) {
2530
2617
  return t.innerText ?? t.textContent ?? "";
2531
2618
  }
2532
- function z(t) {
2619
+ function G(t) {
2533
2620
  return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
2534
2621
  `).split(`
2535
2622
  `).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
@@ -2537,20 +2624,20 @@ function z(t) {
2537
2624
 
2538
2625
  `).trim();
2539
2626
  }
2540
- function ve(t, e) {
2541
- let s = z(t);
2627
+ function Oe(t, e) {
2628
+ let s = G(t);
2542
2629
  for (const n of e)
2543
2630
  s = s.replace(n, "");
2544
- return z(s);
2631
+ return G(s);
2545
2632
  }
2546
- function Wt(t) {
2633
+ function Ht(t) {
2547
2634
  const e = window.getComputedStyle(t);
2548
2635
  return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
2549
2636
  }
2550
2637
  function Nn() {
2551
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Wt).sort((t, e) => Z(e).length - Z(t).length)[0] ?? null;
2638
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ht).sort((t, e) => te(e).length - te(t).length)[0] ?? null;
2552
2639
  }
2553
- function On(t, e) {
2640
+ function qn(t, e) {
2554
2641
  const s = /* @__PURE__ */ new Set([
2555
2642
  "main",
2556
2643
  "nav",
@@ -2630,92 +2717,92 @@ function On(t, e) {
2630
2717
  "data-test",
2631
2718
  "data-qa",
2632
2719
  "data-cy"
2633
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: p, priorityTargets: g } = xn(), T = new Set(t);
2720
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: h, priorityTargets: g } = xn(), T = new Set(t);
2634
2721
  e && T.add(e);
2635
- let h = 0;
2722
+ let f = 0;
2636
2723
  const u = (m) => {
2637
- const b = m.getAttribute("role");
2638
- return b && !o.has(b) ? b : "";
2724
+ const C = m.getAttribute("role");
2725
+ return C && !o.has(C) ? C : "";
2639
2726
  }, d = (m) => {
2640
- const b = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
2641
- return `${m.tagName.toLowerCase()}|${u(m)}|${b}`;
2642
- }, f = (m, b, B) => {
2643
- const _ = (M, X) => {
2644
- const C = M.tagName.toLowerCase(), E = window.getComputedStyle(M), D = p.has(M);
2645
- if (h >= 1e3 && !D || B.has(M) || i.has(C) || M.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || E.display === "none" || E.visibility === "hidden")
2727
+ const C = m.getAttribute("data-testid") || m.getAttribute("data-test") || m.getAttribute("data-qa") || m.getAttribute("data-cy") || "";
2728
+ return `${m.tagName.toLowerCase()}|${u(m)}|${C}`;
2729
+ }, p = (m, C, B) => {
2730
+ const _ = (M, W) => {
2731
+ const b = M.tagName.toLowerCase(), J = window.getComputedStyle(M), O = h.has(M);
2732
+ if (f >= 1e3 && !O || B.has(M) || i.has(b) || M.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || J.display === "none" || J.visibility === "hidden")
2646
2733
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2647
- h += 1;
2648
- const nt = u(M), se = $t(M), ls = a.has(nt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && M.hasAttribute("href"), Te = Array.from(M.children).filter((y) => y instanceof HTMLElement), ne = /* @__PURE__ */ new Map();
2649
- for (const y of Te) {
2734
+ f += 1;
2735
+ const E = u(M), D = Ft(M), cs = a.has(E) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && M.hasAttribute("href"), Se = Array.from(M.children).filter((y) => y instanceof HTMLElement), re = /* @__PURE__ */ new Map();
2736
+ for (const y of Se) {
2650
2737
  const A = d(y);
2651
- ne.set(A, (ne.get(A) ?? 0) + 1);
2738
+ re.set(A, (re.get(A) ?? 0) + 1);
2652
2739
  }
2653
2740
  const we = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Map();
2654
- for (const y of Te) {
2655
- const A = d(y), q = rt.get(A) ?? 0;
2656
- rt.set(A, q + 1), (ne.get(A) ?? 0) > 8 && q >= 6 && !p.has(y) && we.set(A, (we.get(A) ?? 0) + 1);
2741
+ for (const y of Se) {
2742
+ const A = d(y), H = rt.get(A) ?? 0;
2743
+ rt.set(A, H + 1), (re.get(A) ?? 0) > 8 && H >= 6 && !h.has(y) && we.set(A, (we.get(A) ?? 0) + 1);
2657
2744
  }
2658
- const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), Se = [], at = [];
2659
- for (const y of Te) {
2660
- const A = d(y), q = ne.get(A) ?? 0, ut = it.get(A) ?? 0;
2661
- if (it.set(A, ut + 1), q > 8 && ut >= 6 && !p.has(y)) {
2662
- ot.has(A) || (Se.push([`… ${we.get(A) ?? 0} similar siblings omitted`]), ot.add(A));
2745
+ const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), Me = [], at = [];
2746
+ for (const y of Se) {
2747
+ const A = d(y), H = re.get(A) ?? 0, ut = it.get(A) ?? 0;
2748
+ if (it.set(A, ut + 1), H > 8 && ut >= 6 && !h.has(y)) {
2749
+ ot.has(A) || (Me.push([`… ${we.get(A) ?? 0} similar siblings omitted`]), ot.add(A));
2663
2750
  continue;
2664
2751
  }
2665
- const dt = _(y, X);
2666
- at.push(dt), Se.push(dt.lines);
2752
+ const dt = _(y, W);
2753
+ at.push(dt), Me.push(dt.lines);
2667
2754
  }
2668
- const Me = [];
2755
+ const Ae = [];
2669
2756
  if (M.shadowRoot)
2670
2757
  for (const y of Array.from(M.shadowRoot.children))
2671
- y instanceof HTMLElement && Me.push(_(y, X + 1));
2672
- const re = [...at, ...Me], Ae = se.length > 0 || ls || re.some((y) => y.hasUsefulContent), lt = z(
2673
- [se, ...re.map((y) => y.textPreview)].filter(Boolean).join(" ")
2674
- ).slice(0, 180), cs = M.hasAttribute("contenteditable") && (se.length > 0 || !M.querySelector("[contenteditable]")), ct = c.some((y) => M.hasAttribute(y)) || !!nt || cs, Re = (M.getClientRects().length > 0 || E.display === "contents") && (s.has(C) || ct || D) && (Ae || D) && (!r.has(C) || Ae || ct || D), Ee = Re ? 1 : 0, V = [];
2675
- if (Re) {
2676
- const y = re.some((q) => q.containsTextElement), A = n.has(C) && !y ? lt : se;
2677
- V.push(Ht(M, l, o, A.slice(0, 180)));
2758
+ y instanceof HTMLElement && Ae.push(_(y, W + 1));
2759
+ const ie = [...at, ...Ae], Re = D.length > 0 || cs || ie.some((y) => y.hasUsefulContent), lt = G(
2760
+ [D, ...ie.map((y) => y.textPreview)].filter(Boolean).join(" ")
2761
+ ).slice(0, 180), us = M.hasAttribute("contenteditable") && (D.length > 0 || !M.querySelector("[contenteditable]")), ct = c.some((y) => M.hasAttribute(y)) || !!E || us, Ee = (M.getClientRects().length > 0 || J.display === "contents") && (s.has(b) || ct || O) && (Re || O) && (!r.has(b) || Re || ct || O), Ce = Ee ? 1 : 0, Y = [];
2762
+ if (Ee) {
2763
+ const y = ie.some((H) => H.containsTextElement), A = n.has(b) && !y ? lt : D;
2764
+ Y.push($t(M, l, o, A.slice(0, 180)));
2678
2765
  }
2679
- for (const y of Se)
2680
- V.push(...le(y, Ee));
2681
- const Ce = Me.flatMap((y) => y.lines);
2682
- if (Ce.length > 0) {
2683
- const y = Ce.slice(0, 20);
2684
- Ce.length > y.length && y.push("… shadow DOM omitted");
2685
- const A = C.includes("tooltip") || C.includes("popper") || C.includes("loader");
2686
- if (X < 2 && !A) {
2687
- const q = Re ? "#shadow-root" : `${C} #shadow-root`;
2688
- V.push(...le([q, ...le(y, 1)], Ee));
2766
+ for (const y of Me)
2767
+ Y.push(...ce(y, Ce));
2768
+ const be = Ae.flatMap((y) => y.lines);
2769
+ if (be.length > 0) {
2770
+ const y = be.slice(0, 20);
2771
+ be.length > y.length && y.push("… shadow DOM omitted");
2772
+ const A = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
2773
+ if (W < 2 && !A) {
2774
+ const H = Ee ? "#shadow-root" : `${b} #shadow-root`;
2775
+ Y.push(...ce([H, ...ce(y, 1)], Ce));
2689
2776
  } else
2690
- V.push(...le(y, Ee));
2777
+ Y.push(...ce(y, Ce));
2691
2778
  }
2692
2779
  return {
2693
- lines: V,
2694
- hasUsefulContent: Ae,
2780
+ lines: Y,
2781
+ hasUsefulContent: Re,
2695
2782
  textPreview: lt,
2696
- containsTextElement: n.has(C) || re.some((y) => y.containsTextElement)
2783
+ containsTextElement: n.has(b) || ie.some((y) => y.containsTextElement)
2697
2784
  };
2698
2785
  };
2699
- return [`--- ${b} ---`, ..._(m, 0).lines].join(`
2786
+ return [`--- ${C} ---`, ..._(m, 0).lines].join(`
2700
2787
  `);
2701
- }, I = [], w = z(window.getSelection()?.toString() ?? "");
2702
- w && I.push(`--- selected text ---
2703
- ${JSON.stringify(w)}`), g.length > 0 && I.push(Ln(g, s, l, o));
2788
+ }, I = [], S = G(window.getSelection()?.toString() ?? "");
2789
+ S && I.push(`--- selected text ---
2790
+ ${JSON.stringify(S)}`), g.length > 0 && I.push(Bn(g, s, l, o));
2704
2791
  for (const m of t.slice(0, 3))
2705
- I.push(f(m, "active overlay DOM", /* @__PURE__ */ new Set()));
2706
- if (e && I.push(f(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2792
+ I.push(p(m, "active overlay DOM", /* @__PURE__ */ new Set()));
2793
+ if (e && I.push(p(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
2707
2794
  const m = e || t.length ? "other visible DOM" : "visible DOM";
2708
- I.push(f(document.body, m, T));
2795
+ I.push(p(document.body, m, T));
2709
2796
  }
2710
2797
  return I.join(`
2711
2798
 
2712
2799
  `);
2713
2800
  }
2714
- function Ht(t, e, s, n) {
2801
+ function $t(t, e, s, n) {
2715
2802
  const r = t.tagName.toLowerCase();
2716
2803
  let i = r;
2717
2804
  const o = t.getAttribute("id");
2718
- o && Bn(o) && (i += `#${o}`);
2805
+ o && Wn(o) && (i += `#${o}`);
2719
2806
  for (const a of e) {
2720
2807
  const l = t.getAttribute(a);
2721
2808
  l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
@@ -2735,8 +2822,8 @@ function xn() {
2735
2822
  const c = window.getComputedStyle(a);
2736
2823
  if (c.display === "none" || c.visibility === "hidden")
2737
2824
  return;
2738
- const p = e.get(a) ?? /* @__PURE__ */ new Set();
2739
- p.add(l), e.set(a, p);
2825
+ const h = e.get(a) ?? /* @__PURE__ */ new Set();
2826
+ h.add(l), e.set(a, h);
2740
2827
  let g = a;
2741
2828
  for (; g; ) {
2742
2829
  t.add(g);
@@ -2760,9 +2847,9 @@ function xn() {
2760
2847
  ], o = [document];
2761
2848
  for (let a = 0; a < o.length; a += 1) {
2762
2849
  const l = o[a];
2763
- for (const [c, p] of i)
2850
+ for (const [c, h] of i)
2764
2851
  for (const g of Array.from(l.querySelectorAll(c)))
2765
- s(g, p);
2852
+ s(g, h);
2766
2853
  for (const c of Array.from(l.querySelectorAll("*")))
2767
2854
  c.shadowRoot && o.push(c.shadowRoot);
2768
2855
  }
@@ -2771,22 +2858,22 @@ function xn() {
2771
2858
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
2772
2859
  };
2773
2860
  }
2774
- function Ln(t, e, s, n) {
2861
+ function Bn(t, e, s, n) {
2775
2862
  const r = ["--- active/current elements ---"];
2776
2863
  for (const i of t) {
2777
2864
  const o = [];
2778
2865
  let a = i.element;
2779
2866
  for (; a; ) {
2780
- const p = a.tagName.toLowerCase();
2781
- (a === i.element || e.has(p) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
2867
+ const h = a.tagName.toLowerCase();
2868
+ (a === i.element || e.has(h) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
2782
2869
  const g = a.getRootNode();
2783
2870
  a = a.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
2784
2871
  }
2785
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((p, g) => Ht(
2786
- p,
2872
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h, g) => $t(
2873
+ h,
2787
2874
  s,
2788
2875
  n,
2789
- g === l.length - 1 ? $t(p).slice(0, 180) : ""
2876
+ g === l.length - 1 ? Ft(h).slice(0, 180) : ""
2790
2877
  ));
2791
2878
  o.length > l.length && c.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${c.join(" > ")}`);
2792
2879
  }
@@ -2796,23 +2883,23 @@ function Ln(t, e, s, n) {
2796
2883
  function At(t) {
2797
2884
  return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
2798
2885
  }
2799
- function le(t, e) {
2886
+ function ce(t, e) {
2800
2887
  if (e === 0)
2801
2888
  return t;
2802
2889
  const s = " ".repeat(e);
2803
2890
  return t.map((n) => `${s}${n}`);
2804
2891
  }
2805
- function $t(t) {
2806
- return z(
2892
+ function Ft(t) {
2893
+ return G(
2807
2894
  Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
2808
2895
  );
2809
2896
  }
2810
- function Bn(t) {
2897
+ function Wn(t) {
2811
2898
  return t.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(t) && !/[a-f0-9]{12,}/i.test(t) && !/:r[0-9a-z]+:/i.test(t);
2812
2899
  }
2813
2900
  function jt() {
2814
- const t = document.querySelector(pt);
2815
- if (!(t ?? document.querySelector(qe)))
2901
+ const t = document.querySelector(ht);
2902
+ if (!(t ?? document.querySelector(We)))
2816
2903
  return;
2817
2904
  const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
2818
2905
  return {
@@ -2821,28 +2908,28 @@ function jt() {
2821
2908
  selectors: [
2822
2909
  {
2823
2910
  name: "widget_host",
2824
- selector: s === "browser_extension_sdk_preview" ? pt : qe,
2911
+ selector: s === "browser_extension_sdk_preview" ? ht : We,
2825
2912
  description: "Finds Pluno's shadow-host element in the host page DOM."
2826
2913
  },
2827
2914
  {
2828
2915
  name: "widget_root",
2829
- selector: vs,
2916
+ selector: Os,
2830
2917
  description: "Finds Pluno's widget root inside the widget host shadow root."
2831
2918
  },
2832
2919
  {
2833
2920
  name: "widget_panel",
2834
- selector: Ns,
2921
+ selector: Ls,
2835
2922
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
2836
2923
  },
2837
2924
  {
2838
2925
  name: "widget_timeline",
2839
- selector: Os,
2926
+ selector: Ns,
2840
2927
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2841
2928
  }
2842
2929
  ]
2843
2930
  };
2844
2931
  }
2845
- function qn(t) {
2932
+ function Hn(t) {
2846
2933
  try {
2847
2934
  const e = JSON.parse(t);
2848
2935
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -2850,7 +2937,7 @@ function qn(t) {
2850
2937
  return { type: "error", message: "Invalid server event" };
2851
2938
  }
2852
2939
  }
2853
- function Wn(t) {
2940
+ function $n(t) {
2854
2941
  if (typeof t != "string")
2855
2942
  return null;
2856
2943
  try {
@@ -2866,10 +2953,10 @@ function Rt(t, e) {
2866
2953
  const s = t[e];
2867
2954
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2868
2955
  }
2869
- function Hn(t) {
2956
+ function Fn(t) {
2870
2957
  return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
2871
2958
  }
2872
- function $n(t) {
2959
+ function jn(t) {
2873
2960
  if (!t || typeof t != "object")
2874
2961
  return null;
2875
2962
  const e = t, s = e.appearance, n = s && typeof s == "object" ? s : e, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -2880,13 +2967,13 @@ function $n(t) {
2880
2967
  ...a !== null ? { scribbleStyle: a } : {}
2881
2968
  };
2882
2969
  }
2883
- function jn(t) {
2970
+ function zn(t) {
2884
2971
  if (!t || typeof t != "object")
2885
2972
  return null;
2886
2973
  const e = t.javascript;
2887
2974
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
2888
2975
  }
2889
- function Fn(t, e) {
2976
+ function Kn(t, e) {
2890
2977
  return e ? t && typeof t == "object" ? {
2891
2978
  ...t,
2892
2979
  helperError: e
@@ -2896,23 +2983,23 @@ function Fn(t, e) {
2896
2983
  helperError: e
2897
2984
  } : t;
2898
2985
  }
2899
- function zn(t) {
2986
+ function Gn(t) {
2900
2987
  if (!t || typeof t != "object")
2901
2988
  return t;
2902
2989
  const e = t;
2903
2990
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : t;
2904
2991
  }
2905
- function Kn() {
2992
+ function Xn() {
2906
2993
  const t = "pluno.productAgent.clientId", e = window.localStorage.getItem(t);
2907
2994
  if (e)
2908
2995
  return e;
2909
2996
  const s = crypto.randomUUID();
2910
2997
  return window.localStorage.setItem(t, s), s;
2911
2998
  }
2912
- function H() {
2999
+ function $() {
2913
3000
  return crypto.randomUUID();
2914
3001
  }
2915
- function Gn(t) {
3002
+ function Vn(t) {
2916
3003
  if (!t || typeof t != "object")
2917
3004
  return null;
2918
3005
  const e = t, s = typeof e.id == "string" ? e.id : null;
@@ -2923,22 +3010,22 @@ function Gn(t) {
2923
3010
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
2924
3011
  } : null;
2925
3012
  }
2926
- function Xn(t, e) {
2927
- return Array.isArray(t) ? Ke(
2928
- t.map((s) => Ft(s, e)).filter((s) => s !== null)
3013
+ function Et(t, e) {
3014
+ return Array.isArray(t) ? Ge(
3015
+ t.map((s) => zt(s, e)).filter((s) => s !== null)
2929
3016
  ) : [];
2930
3017
  }
2931
- function Vn(t) {
3018
+ function Jn(t) {
2932
3019
  return Array.isArray(t) ? t.flatMap((e) => {
2933
3020
  if (!e || typeof e != "object")
2934
3021
  return [];
2935
- const s = e, n = S(s, "id"), r = S(s, "createdAt"), i = S(s, "updatedAt"), o = S(s, "lastActiveAt");
3022
+ const s = e, n = w(s, "id"), r = w(s, "createdAt"), i = w(s, "updatedAt"), o = w(s, "lastActiveAt");
2936
3023
  return !n || !r || !i || !o ? [] : [
2937
3024
  {
2938
3025
  id: n,
2939
- title: S(s, "title"),
2940
- customTitle: S(s, "customTitle"),
2941
- firstUserMessage: S(s, "firstUserMessage"),
3026
+ title: w(s, "title"),
3027
+ customTitle: w(s, "customTitle"),
3028
+ firstUserMessage: w(s, "firstUserMessage"),
2942
3029
  currentPage: s.currentPage ?? null,
2943
3030
  createdAt: r,
2944
3031
  updatedAt: i,
@@ -2949,29 +3036,29 @@ function Vn(t) {
2949
3036
  ];
2950
3037
  }) : [];
2951
3038
  }
2952
- function Ft(t, e) {
3039
+ function zt(t, e) {
2953
3040
  if (!t || typeof t != "object")
2954
3041
  return null;
2955
3042
  const s = t, n = s.data;
2956
3043
  if (!n || typeof n != "object")
2957
3044
  return null;
2958
3045
  const r = n;
2959
- if (r.hiddenFromTranscript === !0 || Ts(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
3046
+ if (r.hiddenFromTranscript === !0 || Ss(r) || r.type === "tab_lifecycle_decision" && r.decision === "keep")
2960
3047
  return null;
2961
3048
  if (r.type === "message") {
2962
3049
  const i = r.role === "assistant" ? "assistant" : r.role === "user" ? "user" : "system", o = {
2963
3050
  id: String(s.id ?? crypto.randomUUID()),
2964
3051
  role: i,
2965
3052
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2966
- content: ys(
2967
- sr(r.content),
3053
+ content: Is(
3054
+ nr(r.content),
2968
3055
  e
2969
3056
  ),
2970
3057
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2971
- ...N(r) !== null ? { causalSequence: N(r) } : {},
2972
- respondsToUserMessageId: O(r) ?? void 0,
3058
+ ...L(r) !== null ? { causalSequence: L(r) } : {},
3059
+ respondsToUserMessageId: N(r) ?? void 0,
2973
3060
  ...U(r) ? { runId: U(r) } : {},
2974
- attachments: Yt(r.attachments, e)
3061
+ attachments: Qt(r.attachments, e)
2975
3062
  };
2976
3063
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2977
3064
  value: r.id,
@@ -2982,54 +3069,54 @@ function Ft(t, e) {
2982
3069
  }), o;
2983
3070
  }
2984
3071
  if (r.type === "function_call_output") {
2985
- const i = Us(r.output);
3072
+ const i = Ds(r.output);
2986
3073
  if (i)
2987
3074
  return {
2988
3075
  id: String(s.id ?? crypto.randomUUID()),
2989
3076
  role: "tool",
2990
3077
  content: "",
2991
3078
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2992
- respondsToUserMessageId: O(r) ?? void 0,
3079
+ respondsToUserMessageId: N(r) ?? void 0,
2993
3080
  ...U(r) ? { runId: U(r) } : {},
2994
3081
  dataType: "scheduled_check_in",
2995
- toolName: Ot,
2996
- callId: Ne(r) ?? void 0,
3082
+ toolName: Nt,
3083
+ callId: Le(r) ?? void 0,
2997
3084
  scheduledCheckInAt: i
2998
3085
  };
2999
- const o = Yn(r.output);
3086
+ const o = Qn(r.output);
3000
3087
  return o ? {
3001
3088
  id: String(s.id ?? crypto.randomUUID()),
3002
3089
  role: "tool",
3003
3090
  content: `Connect ${o.appName} to continue`,
3004
3091
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3005
- ...N(r) !== null ? { causalSequence: N(r) } : {},
3006
- respondsToUserMessageId: O(r) ?? void 0,
3092
+ ...L(r) !== null ? { causalSequence: L(r) } : {},
3093
+ respondsToUserMessageId: N(r) ?? void 0,
3007
3094
  ...U(r) ? { runId: U(r) } : {},
3008
3095
  dataType: "function_call_output",
3009
3096
  toolName: "authenticate_pipedream_app",
3010
- callId: Ne(r) ?? void 0,
3097
+ callId: Le(r) ?? void 0,
3011
3098
  integrationAuthRequest: o
3012
3099
  } : null;
3013
3100
  }
3014
3101
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
3015
3102
  id: String(s.id ?? crypto.randomUUID()),
3016
3103
  role: "tool",
3017
- content: r.type === "mcp_call" ? Jn(r) : Zn(r),
3104
+ content: r.type === "mcp_call" ? Yn(r) : er(r),
3018
3105
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3019
- ...N(r) !== null ? { causalSequence: N(r) } : {},
3020
- respondsToUserMessageId: O(r) ?? void 0,
3106
+ ...L(r) !== null ? { causalSequence: L(r) } : {},
3107
+ respondsToUserMessageId: N(r) ?? void 0,
3021
3108
  ...U(r) ? { runId: U(r) } : {},
3022
3109
  dataType: String(r.type),
3023
3110
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
3024
- callId: Ne(r) ?? void 0,
3111
+ callId: Le(r) ?? void 0,
3025
3112
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
3026
3113
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
3027
3114
  id: String(s.id ?? crypto.randomUUID()),
3028
3115
  role: "system",
3029
- content: Qn(r),
3116
+ content: Zn(r),
3030
3117
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
3031
- ...N(r) !== null ? { causalSequence: N(r) } : {},
3032
- respondsToUserMessageId: O(r) ?? void 0,
3118
+ ...L(r) !== null ? { causalSequence: L(r) } : {},
3119
+ respondsToUserMessageId: N(r) ?? void 0,
3033
3120
  ...U(r) ? { runId: U(r) } : {},
3034
3121
  dataType: String(r.type),
3035
3122
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
@@ -3038,11 +3125,11 @@ function Ft(t, e) {
3038
3125
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
3039
3126
  } : null;
3040
3127
  }
3041
- function Jn(t) {
3128
+ function Yn(t) {
3042
3129
  const s = (typeof t.server_label == "string" ? t.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
3043
3130
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
3044
3131
  }
3045
- function Yn(t) {
3132
+ function Qn(t) {
3046
3133
  if (typeof t != "string")
3047
3134
  return null;
3048
3135
  try {
@@ -3059,10 +3146,10 @@ function Yn(t) {
3059
3146
  return null;
3060
3147
  }
3061
3148
  }
3062
- function Qn(t) {
3149
+ function Zn(t) {
3063
3150
  return t.type === "run_status" && t.status === "stopped" ? "Run stopped by user" : t.type === "run_status" && t.status === "steered" ? "Steered" : typeof t.message == "string" && t.message.trim().length > 0 ? t.message.replace(/Product Agent/g, "Pluno") : t.type === "run_status" && t.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
3064
3151
  }
3065
- function Zn(t) {
3152
+ function er(t) {
3066
3153
  if (t.type === "web_search_call") {
3067
3154
  const e = t.action;
3068
3155
  if (e && typeof e == "object") {
@@ -3074,26 +3161,26 @@ function Zn(t) {
3074
3161
  }
3075
3162
  return "🔎 Searching the web";
3076
3163
  }
3077
- return er(t);
3164
+ return tr(t);
3078
3165
  }
3079
- function er(t) {
3166
+ function tr(t) {
3080
3167
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
3081
- return F(t.summary);
3168
+ return K(t.summary);
3082
3169
  if (typeof t.arguments == "string")
3083
3170
  try {
3084
3171
  const e = JSON.parse(t.arguments);
3085
3172
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
3086
- return F(e.summary);
3173
+ return K(e.summary);
3087
3174
  } catch {
3088
- return typeof t.name == "string" && t.name.trim().length > 0 ? F(t.name) : "🛠️ Run tool";
3175
+ return typeof t.name == "string" && t.name.trim().length > 0 ? K(t.name) : "🛠️ Run tool";
3089
3176
  }
3090
- return typeof t.name == "string" && t.name.trim().length > 0 ? F(t.name) : "🛠️ Run tool";
3177
+ return typeof t.name == "string" && t.name.trim().length > 0 ? K(t.name) : "🛠️ Run tool";
3091
3178
  }
3092
- function F(t) {
3179
+ function K(t) {
3093
3180
  const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
3094
3181
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
3095
3182
  }
3096
- function tr(t) {
3183
+ function sr(t) {
3097
3184
  if (t == null)
3098
3185
  return t;
3099
3186
  if (typeof t != "object")
@@ -3108,14 +3195,14 @@ function tr(t) {
3108
3195
  runId: typeof e.runId == "string" ? e.runId : null
3109
3196
  };
3110
3197
  }
3111
- function Ne(t) {
3198
+ function Le(t) {
3112
3199
  const e = t.callId ?? t.call_id;
3113
3200
  return typeof e == "string" && e ? e : null;
3114
3201
  }
3115
- function N(t) {
3202
+ function L(t) {
3116
3203
  return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
3117
3204
  }
3118
- function sr(t) {
3205
+ function nr(t) {
3119
3206
  return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
3120
3207
  if (!e || typeof e != "object")
3121
3208
  return "";
@@ -3123,31 +3210,31 @@ function sr(t) {
3123
3210
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
3124
3211
  }).filter(Boolean).join("") : "";
3125
3212
  }
3126
- function He(t, e) {
3127
- const s = Kt(t, e), n = lr(
3128
- nr(
3129
- pr(t, e),
3213
+ function $e(t, e) {
3214
+ const s = Gt(t, e), n = cr(
3215
+ rr(
3216
+ gr(t, e),
3130
3217
  s
3131
3218
  ),
3132
3219
  s
3133
3220
  ), r = n.findIndex((o) => o.id === s.id);
3134
3221
  if (r === -1)
3135
- return Ke(
3222
+ return Ge(
3136
3223
  [...n, s]
3137
3224
  );
3138
3225
  const i = [...n];
3139
- return i[r] = s, Ke(i);
3226
+ return i[r] = s, Ge(i);
3140
3227
  }
3141
- function nr(t, e) {
3228
+ function rr(t, e) {
3142
3229
  const s = e.assistantDraftItemId;
3143
3230
  return s ? t.map(
3144
3231
  (n) => n.dataType === "assistant_draft" && n.id === s ? e : n
3145
3232
  ) : t;
3146
3233
  }
3147
- function Oe(t, e, s) {
3234
+ function Ne(t, e, s) {
3148
3235
  return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
3149
3236
  }
3150
- function rr(t, e, s, n) {
3237
+ function ir(t, e, s, n) {
3151
3238
  if (s === null) return t;
3152
3239
  let r = -1;
3153
3240
  for (let o = t.length - 1; o >= 0; o -= 1) {
@@ -3164,12 +3251,12 @@ function rr(t, e, s, n) {
3164
3251
  respondsToUserMessageId: s
3165
3252
  }, i;
3166
3253
  }
3167
- function ir(t, e) {
3254
+ function or(t, e) {
3168
3255
  const s = t.findIndex(
3169
3256
  (r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
3170
3257
  );
3171
3258
  if (s === -1)
3172
- return He(t, e);
3259
+ return $e(t, e);
3173
3260
  const n = [...t];
3174
3261
  return n[s] = {
3175
3262
  ...n[s],
@@ -3181,19 +3268,19 @@ function ir(t, e) {
3181
3268
  ...n[s].runId ? {} : { runId: e.runId }
3182
3269
  }, n;
3183
3270
  }
3184
- function or(t, e, s) {
3271
+ function ar(t, e, s) {
3185
3272
  let n = !1;
3186
3273
  const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
3187
3274
  return n ? r : t;
3188
3275
  }
3189
- function ar(t) {
3276
+ function lr(t) {
3190
3277
  if (t.hiddenFromTranscript === !0)
3191
3278
  return null;
3192
3279
  const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
3193
3280
  return !e || !s ? null : {
3194
3281
  id: `transient-activity:${e}`,
3195
3282
  role: "tool",
3196
- content: F(
3283
+ content: K(
3197
3284
  typeof t.summary == "string" ? t.summary : "Running browser tool"
3198
3285
  ),
3199
3286
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3206,7 +3293,7 @@ function ar(t) {
3206
3293
  loading: !0
3207
3294
  };
3208
3295
  }
3209
- function lr(t, e) {
3296
+ function cr(t, e) {
3210
3297
  if (e.id.startsWith("transient-activity:"))
3211
3298
  return t;
3212
3299
  const s = e.toolName === "tab_lifecycle";
@@ -3215,17 +3302,24 @@ function lr(t, e) {
3215
3302
  const n = (i) => i.id === `transient-activity:${e.callId}` && i.callId === e.callId || s && i.id.startsWith("transient-activity:") && i.toolName === "browser_tabs" && !!i.runId && i.runId === e.runId, r = t.findIndex(n);
3216
3303
  return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
3217
3304
  }
3218
- function cr(t, e) {
3305
+ function ur(t, e) {
3219
3306
  return ws(
3220
3307
  t,
3221
3308
  e.map(
3222
- (s) => Kt(t, s)
3309
+ (s) => Gt(t, s)
3223
3310
  ),
3224
- zt
3311
+ Kt
3225
3312
  );
3226
3313
  }
3227
- function zt(t) {
3228
- const e = ee(t) ?? void 0, s = t.assistantDraftItemId, n = [
3314
+ function dr(t, e, s) {
3315
+ const n = new Map(e.map((i) => [i.id, i]));
3316
+ return [
3317
+ ...t.filter((i) => s.has(i.id)).map((i) => n.get(i.id) ?? i),
3318
+ ...e.filter((i) => !s.has(i.id))
3319
+ ];
3320
+ }
3321
+ function Kt(t) {
3322
+ const e = se(t) ?? void 0, s = t.assistantDraftItemId, n = [
3229
3323
  ...t.callId ? [`call:${t.callId}`] : [],
3230
3324
  ...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
3231
3325
  ];
@@ -3236,52 +3330,52 @@ function zt(t) {
3236
3330
  ...n.length > 0 ? { activityKeys: n } : {},
3237
3331
  ...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
3238
3332
  ...t.runId ? { runId: t.runId } : {},
3239
- isOptimistic: ye(t),
3333
+ isOptimistic: Ie(t),
3240
3334
  isAssistantDraft: t.dataType === "assistant_draft",
3241
3335
  isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
3242
3336
  isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
3243
3337
  };
3244
3338
  }
3245
- function Kt(t, e) {
3339
+ function Gt(t, e) {
3246
3340
  if (e.role !== "user" || !e.attachments?.length)
3247
3341
  return e;
3248
3342
  const s = t.find(
3249
- (r) => r.role === "user" && (r.id === e.id || ye(r) && Gt(r, e))
3343
+ (r) => r.role === "user" && (r.id === e.id || Ie(r) && Xt(r, e))
3250
3344
  );
3251
3345
  if (!s?.attachments?.length)
3252
3346
  return e;
3253
3347
  const n = e.attachments.map((r) => {
3254
- const i = ur(s.attachments ?? [], r);
3255
- return i ? dr(r, i) : r;
3348
+ const i = hr(s.attachments ?? [], r);
3349
+ return i ? pr(r, i) : r;
3256
3350
  });
3257
3351
  return { ...e, attachments: n };
3258
3352
  }
3259
- function ur(t, e) {
3353
+ function hr(t, e) {
3260
3354
  return e.id ? t.find((s) => s.id === e.id) ?? null : null;
3261
3355
  }
3262
- function dr(t, e) {
3356
+ function pr(t, e) {
3263
3357
  const { previewUrl: s } = e;
3264
3358
  return s ? { ...t, previewUrl: s } : t;
3265
3359
  }
3266
- function pr(t, e) {
3360
+ function gr(t, e) {
3267
3361
  if (e.role !== "user")
3268
3362
  return t;
3269
3363
  const s = t.findIndex(
3270
- (r) => ye(r) && Gt(r, e)
3364
+ (r) => Ie(r) && Xt(r, e)
3271
3365
  );
3272
3366
  if (s === -1)
3273
3367
  return t;
3274
3368
  const n = [...t];
3275
3369
  return n.splice(s, 1), n;
3276
3370
  }
3277
- function Gt(t, e) {
3278
- const s = ee(t), n = ee(e);
3371
+ function Xt(t, e) {
3372
+ const s = se(t), n = se(e);
3279
3373
  return s && n ? s === n : t.content === e.content;
3280
3374
  }
3281
- function ye(t) {
3375
+ function Ie(t) {
3282
3376
  return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
3283
3377
  }
3284
- function ee(t) {
3378
+ function se(t) {
3285
3379
  const e = t.clientMessageId;
3286
3380
  if (e)
3287
3381
  return e;
@@ -3290,18 +3384,18 @@ function ee(t) {
3290
3384
  );
3291
3385
  return n ? t.id.slice(n.length) : null;
3292
3386
  }
3293
- function Et(t) {
3294
- const e = Xt(t);
3387
+ function Ct(t) {
3388
+ const e = Vt(t);
3295
3389
  if (e === null)
3296
3390
  return !1;
3297
3391
  const s = t[e].id, n = t.some(
3298
- (r) => r.respondsToUserMessageId === s && $e(r)
3392
+ (r) => r.respondsToUserMessageId === s && Fe(r)
3299
3393
  );
3300
3394
  if (t.some((r) => r.respondsToUserMessageId === s))
3301
3395
  return n;
3302
3396
  for (let r = t.length - 1; r > e; r -= 1) {
3303
3397
  const i = t[r];
3304
- if (W(i))
3398
+ if (F(i))
3305
3399
  return !0;
3306
3400
  if (i.role === "system") {
3307
3401
  if (i.dataType === "run_error")
@@ -3312,25 +3406,25 @@ function Et(t) {
3312
3406
  }
3313
3407
  return !1;
3314
3408
  }
3315
- function hr(t) {
3316
- const e = Xt(t);
3409
+ function fr(t) {
3410
+ const e = Vt(t);
3317
3411
  if (e === null)
3318
- return t.some(W);
3412
+ return t.some(F);
3319
3413
  const s = t[e].id;
3320
3414
  return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
3321
- (n) => n.respondsToUserMessageId === s && W(n)
3322
- ) : t.slice(e + 1).some(W);
3415
+ (n) => n.respondsToUserMessageId === s && F(n)
3416
+ ) : t.slice(e + 1).some(F);
3323
3417
  }
3324
- function Xt(t) {
3418
+ function Vt(t) {
3325
3419
  for (let e = t.length - 1; e >= 0; e -= 1)
3326
- if (t[e].role === "user" && !ye(t[e]))
3420
+ if (t[e].role === "user" && !Ie(t[e]))
3327
3421
  return e;
3328
3422
  return null;
3329
3423
  }
3330
- function $e(t) {
3331
- return W(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3424
+ function Fe(t) {
3425
+ return F(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3332
3426
  }
3333
- function K(t) {
3427
+ function X(t) {
3334
3428
  for (let e = t.length - 1; e >= 0; e -= 1) {
3335
3429
  const s = t[e];
3336
3430
  if (!s || typeof s != "object")
@@ -3344,8 +3438,8 @@ function K(t) {
3344
3438
  }
3345
3439
  return null;
3346
3440
  }
3347
- function gr(t) {
3348
- const e = K(t);
3441
+ function mr(t) {
3442
+ const e = X(t);
3349
3443
  if (e === null)
3350
3444
  return null;
3351
3445
  const n = P(t[e])?.page;
@@ -3363,11 +3457,11 @@ function P(t) {
3363
3457
  function je(t) {
3364
3458
  return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
3365
3459
  }
3366
- function Ct(t) {
3460
+ function bt(t) {
3367
3461
  return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
3368
3462
  }
3369
- function fr(t, e) {
3370
- const s = K(e);
3463
+ function yr(t, e) {
3464
+ const s = X(e);
3371
3465
  if (s === null)
3372
3466
  return !1;
3373
3467
  const n = e[s], r = n && typeof n == "object" ? n.id : null;
@@ -3375,11 +3469,11 @@ function fr(t, e) {
3375
3469
  return !1;
3376
3470
  const i = t.findIndex((o) => o.role === "user" && o.id === r);
3377
3471
  return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
3378
- (o) => o.respondsToUserMessageId === r && $e(o)
3379
- ) : t.slice(i + 1).some($e);
3472
+ (o) => o.respondsToUserMessageId === r && Fe(o)
3473
+ ) : t.slice(i + 1).some(Fe);
3380
3474
  }
3381
- function Fe(t) {
3382
- const e = K(t);
3475
+ function ze(t) {
3476
+ const e = X(t);
3383
3477
  if (e === null)
3384
3478
  return null;
3385
3479
  const s = t[e];
@@ -3391,8 +3485,8 @@ function Fe(t) {
3391
3485
  const r = n.clientMessageId;
3392
3486
  return typeof r == "string" ? r : null;
3393
3487
  }
3394
- function mr(t) {
3395
- const e = K(t);
3488
+ function Ir(t) {
3489
+ const e = X(t);
3396
3490
  if (e === null)
3397
3491
  return null;
3398
3492
  for (let s = t.length - 1; s > e; s -= 1) {
@@ -3406,22 +3500,22 @@ function mr(t) {
3406
3500
  if (i.type === "message" && i.role === "assistant")
3407
3501
  return null;
3408
3502
  if (i.type === "run_error")
3409
- return i.retryable !== !0 ? null : ze(t, i) ?? Fe(t);
3503
+ return i.retryable !== !0 ? null : Ke(t, i) ?? ze(t);
3410
3504
  if (i.type === "run_status")
3411
- return i.status === "interrupted" && i.retryable === !0 ? ze(t, i) ?? Fe(t) : null;
3505
+ return i.status === "interrupted" && i.retryable === !0 ? Ke(t, i) ?? ze(t) : null;
3412
3506
  }
3413
3507
  return null;
3414
3508
  }
3415
- function ze(t, e) {
3509
+ function Ke(t, e) {
3416
3510
  if (typeof e.clientMessageId == "string")
3417
3511
  return e.clientMessageId;
3418
- const s = O(e);
3512
+ const s = N(e);
3419
3513
  if (!s)
3420
3514
  return null;
3421
- const n = t.find((i) => S(i, "id") === s), r = P(n);
3515
+ const n = t.find((i) => w(i, "id") === s), r = P(n);
3422
3516
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
3423
3517
  }
3424
- function yr(t, e) {
3518
+ function Tr(t, e) {
3425
3519
  let s = 0;
3426
3520
  for (const n of t) {
3427
3521
  if (!n || typeof n != "object")
@@ -3434,73 +3528,73 @@ function yr(t, e) {
3434
3528
  }
3435
3529
  return s;
3436
3530
  }
3437
- function bt(t, e, s, n, r) {
3438
- if (!e || !Ir(t))
3531
+ function kt(t, e, s, n, r) {
3532
+ if (!e || !Sr(t))
3439
3533
  return !1;
3440
3534
  const i = t;
3441
- return !(je(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && U(i) !== r));
3535
+ return !(je(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && U(i) !== r));
3442
3536
  }
3443
- function Ir(t) {
3537
+ function Sr(t) {
3444
3538
  if (!t || typeof t != "object")
3445
3539
  return !1;
3446
3540
  const e = t;
3447
3541
  return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
3448
3542
  }
3449
- function W(t) {
3543
+ function F(t) {
3450
3544
  return t.role === "assistant" && t.phase !== "commentary";
3451
3545
  }
3452
- function Tr(t) {
3546
+ function wr(t) {
3453
3547
  if (!t || typeof t != "object")
3454
3548
  return !1;
3455
3549
  const e = t;
3456
3550
  return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
3457
3551
  }
3458
- function Ke(t) {
3459
- return t.filter((e, s) => G(e) ? !kr(t, s) && !Vt(t, s) && !br(t, s) && !_r(t, s) : wr(e) ? e.retryable === !0 && Cr(t, s) ? !1 : !Er(t, s) : !0);
3552
+ function Ge(t) {
3553
+ return t.filter((e, s) => V(e) ? !Ur(t, s) && !Jt(t, s) && !_r(t, s) && !Pr(t, s) : Mr(e) ? e.retryable === !0 && kr(t, s) ? !1 : !br(t, s) : !0);
3460
3554
  }
3461
- function wr(t) {
3555
+ function Mr(t) {
3462
3556
  return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
3463
3557
  }
3464
- function G(t) {
3558
+ function V(t) {
3465
3559
  return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
3466
3560
  }
3467
- function Sr(t, e, s, n) {
3561
+ function Ar(t, e, s, n) {
3468
3562
  const r = t.findIndex(
3469
- (l, c) => G(l) && !Vt(t, c)
3563
+ (l, c) => V(l) && !Jt(t, c)
3470
3564
  ), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
3471
3565
  (l) => l.role === "user" && l.id === o
3472
3566
  ) : null;
3473
3567
  return {
3474
- clientMessageId: a ? ee(a) : o ? null : n,
3568
+ clientMessageId: a ? se(a) : o ? null : n,
3475
3569
  respondsToUserMessageId: o,
3476
3570
  runId: s ?? i?.runId ?? null
3477
3571
  };
3478
3572
  }
3479
- function xe(t) {
3573
+ function qe(t) {
3480
3574
  return t?.type === "run_status" && t.status === "stopped";
3481
3575
  }
3482
- function ce(t, e, s) {
3576
+ function ue(t, e, s) {
3483
3577
  const n = new Set(
3484
3578
  t.filter(
3485
- (r) => r.role === "user" && e !== null && ee(r) === e
3579
+ (r) => r.role === "user" && e !== null && se(r) === e
3486
3580
  ).map((r) => r.id)
3487
3581
  );
3488
3582
  return t.filter(
3489
- (r) => !G(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3583
+ (r) => !V(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3490
3584
  );
3491
3585
  }
3492
- function Vt(t, e) {
3586
+ function Jt(t, e) {
3493
3587
  return t.some(
3494
- (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Mr(
3588
+ (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && Rr(
3495
3589
  t,
3496
3590
  e,
3497
3591
  n
3498
3592
  )
3499
3593
  );
3500
3594
  }
3501
- function Mr(t, e, s) {
3595
+ function Rr(t, e, s) {
3502
3596
  const n = t[e], r = t[s];
3503
- if (te(n, r))
3597
+ if (ne(n, r))
3504
3598
  return !0;
3505
3599
  if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
3506
3600
  return !1;
@@ -3509,9 +3603,9 @@ function Mr(t, e, s) {
3509
3603
  return t[i].id === n.respondsToUserMessageId;
3510
3604
  return !1;
3511
3605
  }
3512
- function Ar(t, e) {
3606
+ function Er(t, e) {
3513
3607
  const s = [...t].reverse().find(
3514
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && _t(n) && !Rr(
3608
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && _t(n) && !Cr(
3515
3609
  t,
3516
3610
  n.respondsToUserMessageId
3517
3611
  )
@@ -3521,23 +3615,23 @@ function Ar(t, e) {
3521
3615
  ) : t;
3522
3616
  }
3523
3617
  function _t(t) {
3524
- return t.role === "tool" || G(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3618
+ return t.role === "tool" || V(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3525
3619
  }
3526
- function Rr(t, e) {
3620
+ function Cr(t, e) {
3527
3621
  return t.some(
3528
- (s) => s.respondsToUserMessageId === e && (W(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3622
+ (s) => s.respondsToUserMessageId === e && (F(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3529
3623
  );
3530
3624
  }
3531
- function Er(t, e) {
3625
+ function br(t, e) {
3532
3626
  const s = t[e];
3533
3627
  for (let n = e + 1; n < t.length; n += 1) {
3534
3628
  const r = t[n];
3535
- if (r.role === "assistant" && te(s, r))
3629
+ if (r.role === "assistant" && ne(s, r))
3536
3630
  return !0;
3537
3631
  }
3538
3632
  return !1;
3539
3633
  }
3540
- function Cr(t, e) {
3634
+ function kr(t, e) {
3541
3635
  const s = t[e];
3542
3636
  if (!s.respondsToUserMessageId)
3543
3637
  return !1;
@@ -3545,37 +3639,37 @@ function Cr(t, e) {
3545
3639
  const r = t[n];
3546
3640
  if (r.role === "user")
3547
3641
  return !1;
3548
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || G(r)))
3642
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || V(r)))
3549
3643
  return !0;
3550
3644
  }
3551
3645
  return !1;
3552
3646
  }
3553
- function br(t, e) {
3647
+ function _r(t, e) {
3554
3648
  const s = t[e];
3555
3649
  return t.some(
3556
- (n, r) => r !== e && n.role === "assistant" && te(s, n)
3650
+ (n, r) => r !== e && n.role === "assistant" && ne(s, n)
3557
3651
  );
3558
3652
  }
3559
- function _r(t, e) {
3653
+ function Pr(t, e) {
3560
3654
  const s = t[e];
3561
3655
  return t.some(
3562
- (n, r) => r !== e && n.role === "tool" && te(s, n)
3656
+ (n, r) => r !== e && n.role === "tool" && ne(s, n)
3563
3657
  );
3564
3658
  }
3565
- function kr(t, e) {
3659
+ function Ur(t, e) {
3566
3660
  const s = t[e];
3567
3661
  for (let n = e + 1; n < t.length; n += 1)
3568
- if (G(t[n]) && te(s, t[n]))
3662
+ if (V(t[n]) && ne(s, t[n]))
3569
3663
  return !0;
3570
3664
  return !1;
3571
3665
  }
3572
- function te(t, e) {
3666
+ function ne(t, e) {
3573
3667
  return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
3574
3668
  }
3575
- function S(t, e) {
3669
+ function w(t, e) {
3576
3670
  return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
3577
3671
  }
3578
- function Pr(t, e) {
3672
+ function Dr(t, e) {
3579
3673
  try {
3580
3674
  const s = window.localStorage.getItem(`${Bt}${t}`);
3581
3675
  if (!s)
@@ -3583,7 +3677,7 @@ function Pr(t, e) {
3583
3677
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3584
3678
  if (e !== void 0 && r !== e)
3585
3679
  return null;
3586
- const i = Array.isArray(n.messages) ? n.messages.map(Hr).filter((o) => !!o) : [];
3680
+ const i = Array.isArray(n.messages) ? n.messages.map(Fr).filter((o) => !!o) : [];
3587
3681
  return {
3588
3682
  sessionId: r,
3589
3683
  messages: i
@@ -3592,48 +3686,48 @@ function Pr(t, e) {
3592
3686
  return null;
3593
3687
  }
3594
3688
  }
3595
- function Ur(t, e) {
3689
+ function vr(t, e) {
3596
3690
  try {
3597
3691
  window.localStorage.setItem(
3598
3692
  `${Bt}${t}`,
3599
3693
  JSON.stringify({
3600
3694
  sessionId: e.sessionId,
3601
- messages: e.messages.slice(-nn).map($r)
3695
+ messages: e.messages.slice(-on).map(jr)
3602
3696
  })
3603
3697
  );
3604
3698
  } catch {
3605
3699
  return;
3606
3700
  }
3607
3701
  }
3608
- function Dr(t) {
3702
+ function Or(t) {
3609
3703
  try {
3610
- const e = window.localStorage.getItem(`${We}${t}`);
3704
+ const e = window.localStorage.getItem(`${He}${t}`);
3611
3705
  if (!e)
3612
3706
  return [];
3613
3707
  const s = JSON.parse(e);
3614
- return Array.isArray(s) ? s.filter(et) : [];
3708
+ return Array.isArray(s) ? s.filter(tt) : [];
3615
3709
  } catch {
3616
3710
  return [];
3617
3711
  }
3618
3712
  }
3619
- function $(t, e) {
3713
+ function j(t, e) {
3620
3714
  try {
3621
- const s = e.filter(et);
3715
+ const s = e.filter(tt);
3622
3716
  if (s.length === 0) {
3623
- window.localStorage.removeItem(`${We}${t}`);
3717
+ window.localStorage.removeItem(`${He}${t}`);
3624
3718
  return;
3625
3719
  }
3626
3720
  window.localStorage.setItem(
3627
- `${We}${t}`,
3721
+ `${He}${t}`,
3628
3722
  JSON.stringify(s.slice(-25))
3629
3723
  );
3630
3724
  } catch {
3631
3725
  return;
3632
3726
  }
3633
3727
  }
3634
- function Jt(t, e) {
3728
+ function Yt(t, e) {
3635
3729
  try {
3636
- const s = `${me}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
3730
+ const s = `${ye}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
3637
3731
  ...o,
3638
3732
  storedAt: Date.now(),
3639
3733
  unloadUrl: n,
@@ -3647,22 +3741,22 @@ function Jt(t, e) {
3647
3741
  } catch {
3648
3742
  }
3649
3743
  }
3650
- function kt(t, e) {
3744
+ function Pt(t, e) {
3651
3745
  try {
3652
- if (window.sessionStorage.getItem(`${me}${t}`) === null)
3746
+ if (window.sessionStorage.getItem(`${ye}${t}`) === null)
3653
3747
  return;
3654
3748
  } catch {
3655
3749
  return;
3656
3750
  }
3657
- Jt(t, e);
3751
+ Yt(t, e);
3658
3752
  }
3659
- function vr(t) {
3753
+ function Lr(t) {
3660
3754
  try {
3661
- const e = `${me}${t}`, s = window.sessionStorage.getItem(e);
3755
+ const e = `${ye}${t}`, s = window.sessionStorage.getItem(e);
3662
3756
  if (window.sessionStorage.removeItem(e), !s)
3663
3757
  return [];
3664
3758
  const n = JSON.parse(s);
3665
- return Array.isArray(n) ? n.flatMap((r) => Or(r) ? [{
3759
+ return Array.isArray(n) ? n.flatMap((r) => qr(r) ? [{
3666
3760
  ...r.event,
3667
3761
  page: k(),
3668
3762
  rawOutput: {
@@ -3689,11 +3783,11 @@ function Nr(t) {
3689
3783
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3690
3784
  Current URL: ${t}`;
3691
3785
  }
3692
- function Or(t) {
3786
+ function qr(t) {
3693
3787
  if (!t || typeof t != "object")
3694
3788
  return !1;
3695
3789
  const e = t, s = e.event;
3696
- return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && et(s) && s.type === "tool.result";
3790
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && tt(s) && s.type === "tool.result";
3697
3791
  }
3698
3792
  function xr(t, e) {
3699
3793
  const s = new Set(
@@ -3704,26 +3798,26 @@ function xr(t, e) {
3704
3798
  ...e.filter((n) => !s.has(n.callId))
3705
3799
  ];
3706
3800
  }
3707
- function Lr(t) {
3801
+ function Br(t) {
3708
3802
  try {
3709
- window.sessionStorage.removeItem(`${me}${t}`);
3803
+ window.sessionStorage.removeItem(`${ye}${t}`);
3710
3804
  } catch {
3711
3805
  return;
3712
3806
  }
3713
3807
  }
3714
- function et(t) {
3808
+ function tt(t) {
3715
3809
  if (!t || typeof t != "object")
3716
3810
  return !1;
3717
3811
  const e = t;
3718
- return e.type === "chat.user_message" ? typeof e.content == "string" && Pt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Pt(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
3812
+ return e.type === "chat.user_message" ? typeof e.content == "string" && Ut(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ut(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
3719
3813
  }
3720
- function Pt(t) {
3814
+ function Ut(t) {
3721
3815
  if (!t || typeof t != "object")
3722
3816
  return !1;
3723
3817
  const e = t;
3724
3818
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
3725
3819
  }
3726
- function Yt(t, e) {
3820
+ function Qt(t, e) {
3727
3821
  if (!Array.isArray(t))
3728
3822
  return;
3729
3823
  const s = t.filter((r) => {
@@ -3731,41 +3825,41 @@ function Yt(t, e) {
3731
3825
  return !1;
3732
3826
  const i = r;
3733
3827
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3734
- }), n = e ? s.map((r) => Qt(r, e)) : s;
3828
+ }), n = e ? s.map((r) => Zt(r, e)) : s;
3735
3829
  return n.length > 0 ? n : void 0;
3736
3830
  }
3737
- function Qt(t, e) {
3831
+ function Zt(t, e) {
3738
3832
  return t.fileUrl?.startsWith("/") ? {
3739
3833
  ...t,
3740
3834
  fileUrl: new URL(t.fileUrl, e).toString()
3741
3835
  } : t;
3742
3836
  }
3743
- function Ge(t) {
3744
- return t.type || Wr(t.name) || "application/octet-stream";
3837
+ function Xe(t) {
3838
+ return t.type || $r(t.name) || "application/octet-stream";
3745
3839
  }
3746
- function Br(t) {
3747
- Zt({
3840
+ function Wr(t) {
3841
+ es({
3748
3842
  name: t.name,
3749
- mimeType: Ge(t),
3843
+ mimeType: Xe(t),
3750
3844
  sizeBytes: t.size
3751
3845
  });
3752
3846
  }
3753
- function Zt(t) {
3754
- const e = qr(t.name), s = t.mimeType.trim().toLowerCase();
3755
- if (!en.has(`${e}:${s}`))
3847
+ function es(t) {
3848
+ const e = Hr(t.name), s = t.mimeType.trim().toLowerCase();
3849
+ if (!sn.has(`${e}:${s}`))
3756
3850
  throw new Error("This attachment type is not supported by the embedded model provider");
3757
- if (t.sizeBytes <= 0 || t.sizeBytes >= xt)
3851
+ if (t.sizeBytes <= 0 || t.sizeBytes >= qt)
3758
3852
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
3759
3853
  }
3760
- function qr(t) {
3854
+ function Hr(t) {
3761
3855
  const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
3762
3856
  return s >= 0 ? e.slice(s) : "";
3763
3857
  }
3764
- function Wr(t) {
3858
+ function $r(t) {
3765
3859
  const e = t.toLowerCase();
3766
3860
  return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
3767
3861
  }
3768
- function Hr(t) {
3862
+ function Fr(t) {
3769
3863
  if (!t || typeof t != "object")
3770
3864
  return null;
3771
3865
  const e = t;
@@ -3782,17 +3876,17 @@ function Hr(t) {
3782
3876
  dataType: typeof e.dataType == "string" ? e.dataType : void 0,
3783
3877
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
3784
3878
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
3785
- attachments: Yt(e.attachments)?.map(tt),
3879
+ attachments: Qt(e.attachments)?.map(st),
3786
3880
  loading: typeof e.loading == "boolean" ? e.loading : void 0
3787
3881
  };
3788
3882
  }
3789
- function $r(t) {
3883
+ function jr(t) {
3790
3884
  return t.attachments?.length ? {
3791
3885
  ...t,
3792
- attachments: t.attachments.map(tt)
3886
+ attachments: t.attachments.map(st)
3793
3887
  } : t;
3794
3888
  }
3795
- function tt(t) {
3889
+ function st(t) {
3796
3890
  const {
3797
3891
  dataUrl: e,
3798
3892
  objectUrl: s,
@@ -3801,7 +3895,7 @@ function tt(t) {
3801
3895
  } = t;
3802
3896
  return r;
3803
3897
  }
3804
- function O(t) {
3898
+ function N(t) {
3805
3899
  const e = t.respondsToUserMessageId;
3806
3900
  return typeof e == "string" && e ? e : null;
3807
3901
  }
@@ -3809,39 +3903,39 @@ function U(t) {
3809
3903
  const e = t.runId;
3810
3904
  return typeof e == "string" && e ? e : null;
3811
3905
  }
3812
- function jr(t) {
3906
+ function zr(t) {
3813
3907
  const e = t?.timeoutMs;
3814
- return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= hn);
3908
+ return !!t && typeof t == "object" && typeof t.summary == "string" && typeof t.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= fn);
3815
3909
  }
3816
- function es(t) {
3910
+ function ts(t) {
3817
3911
  const e = {};
3818
3912
  try {
3819
3913
  new Headers(t).forEach((s, n) => {
3820
- Object.keys(e).length < Qe && (e[n] = st(n, s));
3914
+ Object.keys(e).length < Ze && (e[n] = nt(n, s));
3821
3915
  });
3822
3916
  } catch {
3823
3917
  return {};
3824
3918
  }
3825
3919
  return e;
3826
3920
  }
3827
- function st(t, e) {
3828
- return os(t) ? Ie : x(fe(e), tn);
3921
+ function nt(t, e) {
3922
+ return as(t) ? Te : q(me(e), nn);
3829
3923
  }
3830
- function Fr(t, e) {
3924
+ function Kr(t, e) {
3831
3925
  return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
3832
3926
  }
3833
- async function zr(t, e, s, n) {
3834
- const r = es(t.headers);
3927
+ async function Gr(t, e, s, n) {
3928
+ const r = ts(t.headers);
3835
3929
  n({
3836
3930
  ...e,
3837
3931
  responseStatus: t.status,
3838
3932
  responseHeaders: r,
3839
- responseBody: await Kr(t),
3933
+ responseBody: await Xr(t),
3840
3934
  durationMs: Date.now() - s
3841
3935
  });
3842
3936
  }
3843
- async function Kr(t) {
3844
- if (!ts(t.headers))
3937
+ async function Xr(t) {
3938
+ if (!ss(t.headers))
3845
3939
  return;
3846
3940
  let e = null, s = null;
3847
3941
  try {
@@ -3850,7 +3944,7 @@ async function Kr(t) {
3850
3944
  const n = new Promise((a) => {
3851
3945
  s = window.setTimeout(() => {
3852
3946
  e?.cancel(), a("timeout");
3853
- }, sn);
3947
+ }, rn);
3854
3948
  }), r = new TextDecoder();
3855
3949
  let i = "", o = 0;
3856
3950
  for (; ; ) {
@@ -3859,10 +3953,10 @@ async function Kr(t) {
3859
3953
  return;
3860
3954
  const { done: l, value: c } = a;
3861
3955
  if (l)
3862
- return x(i + r.decode());
3863
- const p = Ye - o;
3864
- if (c.byteLength > p)
3865
- return i += r.decode(c.subarray(0, Math.max(p, 0)), { stream: !0 }), e.cancel(), `${x(i)}... [truncated]`;
3956
+ return q(i + r.decode());
3957
+ const h = Qe - o;
3958
+ if (c.byteLength > h)
3959
+ return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${q(i)}... [truncated]`;
3866
3960
  o += c.byteLength, i += r.decode(c, { stream: !0 });
3867
3961
  }
3868
3962
  } catch {
@@ -3872,45 +3966,45 @@ async function Kr(t) {
3872
3966
  s !== null && window.clearTimeout(s);
3873
3967
  }
3874
3968
  }
3875
- function Gr(t, e) {
3876
- if (ts(new Headers(e)))
3969
+ function Vr(t, e) {
3970
+ if (ss(new Headers(e)))
3877
3971
  try {
3878
- return t.responseType === "" || t.responseType === "text" ? x(t.responseText ?? "") : void 0;
3972
+ return t.responseType === "" || t.responseType === "text" ? q(t.responseText ?? "") : void 0;
3879
3973
  } catch {
3880
3974
  return;
3881
3975
  }
3882
3976
  }
3883
- function Ut(t) {
3977
+ function Dt(t) {
3884
3978
  if (typeof t == "string")
3885
- return x(t);
3979
+ return q(t);
3886
3980
  }
3887
- function Xr(t) {
3981
+ function Jr(t) {
3888
3982
  return v({
3889
3983
  ...t,
3890
- requestBody: Dt(t.requestBody),
3891
- responseBody: Dt(t.responseBody)
3984
+ requestBody: vt(t.requestBody),
3985
+ responseBody: vt(t.responseBody)
3892
3986
  });
3893
3987
  }
3894
- function Dt(t) {
3988
+ function vt(t) {
3895
3989
  if (typeof t != "string")
3896
3990
  return t;
3897
3991
  const e = t.trim();
3898
3992
  if (!e.startsWith("{") && !e.startsWith("["))
3899
- return fe(t);
3993
+ return me(t);
3900
3994
  try {
3901
3995
  return JSON.stringify(v(JSON.parse(t)));
3902
3996
  } catch {
3903
- return fe(t);
3997
+ return me(t);
3904
3998
  }
3905
3999
  }
3906
- function ts(t) {
4000
+ function ss(t) {
3907
4001
  if (!t)
3908
4002
  return !1;
3909
4003
  const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
3910
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Ye && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
4004
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Qe && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
3911
4005
  }
3912
- function j(t, e = {}, s) {
3913
- if (Jr(s))
4006
+ function z(t, e = {}, s) {
4007
+ if (Qr(s))
3914
4008
  return !0;
3915
4009
  const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3916
4010
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3925,8 +4019,8 @@ function j(t, e = {}, s) {
3925
4019
  return !0;
3926
4020
  }
3927
4021
  }
3928
- function Vr(t, e) {
3929
- if (j(t))
4022
+ function Yr(t, e) {
4023
+ if (z(t))
3930
4024
  return !0;
3931
4025
  try {
3932
4026
  const s = new URL(t, location.href), n = new URL(e);
@@ -3935,117 +4029,117 @@ function Vr(t, e) {
3935
4029
  return !0;
3936
4030
  }
3937
4031
  }
3938
- function Jr(t) {
4032
+ function Qr(t) {
3939
4033
  return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
3940
4034
  }
3941
- function Yr(t) {
4035
+ function Zr(t) {
3942
4036
  const e = {};
3943
4037
  for (const s of t.trim().split(/[\r\n]+/)) {
3944
4038
  const n = s.indexOf(":");
3945
4039
  if (n <= 0)
3946
4040
  continue;
3947
- if (Object.keys(e).length >= Qe)
4041
+ if (Object.keys(e).length >= Ze)
3948
4042
  break;
3949
4043
  const r = s.slice(0, n).trim();
3950
- e[r] = st(r, s.slice(n + 1).trim());
4044
+ e[r] = nt(r, s.slice(n + 1).trim());
3951
4045
  }
3952
4046
  return e;
3953
4047
  }
3954
- function x(t, e = Ye) {
4048
+ function q(t, e = Qe) {
3955
4049
  return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
3956
4050
  }
3957
- function Le(t) {
4051
+ function xe(t) {
3958
4052
  return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3959
4053
  }
3960
- class he extends Error {
4054
+ class ge extends Error {
3961
4055
  constructor(e, s) {
3962
4056
  super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
3963
4057
  }
3964
4058
  status;
3965
4059
  }
3966
- async function ue(t, e) {
4060
+ async function de(t, e) {
3967
4061
  let s = null;
3968
- for (let n = 0; n < wt; n += 1)
4062
+ for (let n = 0; n < St; n += 1)
3969
4063
  try {
3970
4064
  return await t();
3971
4065
  } catch (r) {
3972
- if (s = r, n >= wt - 1 || !Zr(r))
4066
+ if (s = r, n >= St - 1 || !ti(r))
3973
4067
  throw r;
3974
- await Qr(n);
4068
+ await ei(n);
3975
4069
  }
3976
4070
  throw s instanceof Error ? s : new Error(e);
3977
4071
  }
3978
- function Qr(t) {
4072
+ function ei(t) {
3979
4073
  return new Promise((e) => {
3980
- window.setTimeout(e, Zs[t] ?? 0);
4074
+ window.setTimeout(e, tn[t] ?? 0);
3981
4075
  });
3982
4076
  }
3983
- function Zr(t) {
3984
- return t instanceof he ? ei(t.status) : t instanceof TypeError;
4077
+ function ti(t) {
4078
+ return t instanceof ge ? si(t.status) : t instanceof TypeError;
3985
4079
  }
3986
- function ei(t) {
4080
+ function si(t) {
3987
4081
  return t === 408 || t === 409 || t === 429 || t >= 500;
3988
4082
  }
3989
- function ti(t) {
4083
+ function ni(t) {
3990
4084
  return t === 401 || t === 403;
3991
4085
  }
3992
- const Ie = "[REDACTED_SECRET]", L = "[REDACTED_TOKEN]", si = "[REDACTED_SIGNED_URL]", ni = 20, ri = /^(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, ss = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ns = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, rs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, is = /\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, ii = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, oi = /\bhttps?:\/\/[^\s"'<>]+/gi, ai = /[),.;\]]+$/;
4086
+ const Te = "[REDACTED_SECRET]", x = "[REDACTED_TOKEN]", ri = "[REDACTED_SIGNED_URL]", ii = 20, oi = /^(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, ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, rs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, is = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, os = /\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, ai = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, li = /\bhttps?:\/\/[^\s"'<>]+/gi, ci = /[),.;\]]+$/;
3993
4087
  function v(t) {
3994
- return ge(t, 0, /* @__PURE__ */ new WeakSet());
4088
+ return fe(t, 0, /* @__PURE__ */ new WeakSet());
3995
4089
  }
3996
- function ge(t, e, s) {
4090
+ function fe(t, e, s) {
3997
4091
  if (typeof t == "string")
3998
- return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : fe(t);
4092
+ return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : me(t);
3999
4093
  if (t === null || typeof t != "object")
4000
4094
  return t;
4001
- if (e >= ni)
4095
+ if (e >= ii)
4002
4096
  return "[REDACTED_MAX_DEPTH]";
4003
4097
  if (s.has(t))
4004
4098
  return "[REDACTED_CIRCULAR]";
4005
4099
  if (s.add(t), Array.isArray(t))
4006
- return t.map((r) => ge(r, e + 1, s));
4100
+ return t.map((r) => fe(r, e + 1, s));
4007
4101
  const n = {};
4008
4102
  for (const [r, i] of Object.entries(t))
4009
- r === "pageContent" ? n[r] = i : os(r) ? n[r] = Ie : n[r] = r.toLowerCase() === "url" ? li(i) : ge(i, e + 1, s);
4103
+ r === "pageContent" ? n[r] = i : as(r) ? n[r] = Te : n[r] = r.toLowerCase() === "url" ? ui(i) : fe(i, e + 1, s);
4010
4104
  return n;
4011
4105
  }
4012
- function os(t) {
4106
+ function as(t) {
4013
4107
  const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
4014
4108
  return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
4015
4109
  }
4016
- function li(t) {
4017
- return typeof t == "string" ? as(t) : ge(t, 0, /* @__PURE__ */ new WeakSet());
4110
+ function ui(t) {
4111
+ return typeof t == "string" ? ls(t) : fe(t, 0, /* @__PURE__ */ new WeakSet());
4018
4112
  }
4019
- function as(t) {
4113
+ function ls(t) {
4020
4114
  try {
4021
4115
  const e = new URL(t, location.href);
4022
4116
  for (const s of Array.from(e.searchParams.keys()))
4023
- ri.test(s) && e.searchParams.set(s, L);
4024
- return e.username && (e.username = L), e.password && (e.password = L), e.toString();
4117
+ oi.test(s) && e.searchParams.set(s, x);
4118
+ return e.username && (e.username = x), e.password && (e.password = x), e.toString();
4025
4119
  } catch {
4026
- return ci(t);
4120
+ return di(t);
4027
4121
  }
4028
4122
  }
4029
- function fe(t) {
4030
- return t.replace(ii, si).replace(oi, ui).replace(ss, `Bearer ${L}`).replace(ns, `Basic ${L}`).replace(rs, L).replace(is, (e, s) => `${s}: ${Ie}`);
4123
+ function me(t) {
4124
+ return t.replace(ai, ri).replace(li, hi).replace(ns, `Bearer ${x}`).replace(rs, `Basic ${x}`).replace(is, x).replace(os, (e, s) => `${s}: ${Te}`);
4031
4125
  }
4032
- function ci(t) {
4033
- return t.replace(ss, `Bearer ${L}`).replace(ns, `Basic ${L}`).replace(rs, L).replace(is, (e, s) => `${s}: ${Ie}`);
4126
+ function di(t) {
4127
+ return t.replace(ns, `Bearer ${x}`).replace(rs, `Basic ${x}`).replace(is, x).replace(os, (e, s) => `${s}: ${Te}`);
4034
4128
  }
4035
- function ui(t) {
4036
- const e = t.match(ai)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
4037
- return `${as(s)}${e}`;
4129
+ function hi(t) {
4130
+ const e = t.match(ci)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
4131
+ return `${ls(s)}${e}`;
4038
4132
  }
4039
4133
  export {
4040
- pt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
4041
- qe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
4042
- Ns as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
4043
- vs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
4044
- Os as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
4045
- di as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
4046
- qt as PlunoProductAgent,
4047
- on as calculateReconnectDelay,
4048
- qt as default,
4049
- kn as getProductAgentOriginAccessErrorMessage,
4050
- Br as validateProductAgentProviderInputFile
4134
+ ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
4135
+ We as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
4136
+ Ls as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
4137
+ Os as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
4138
+ Ns as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
4139
+ pi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
4140
+ Wt as PlunoProductAgent,
4141
+ ln as calculateReconnectDelay,
4142
+ Wt as default,
4143
+ Un as getProductAgentOriginAccessErrorMessage,
4144
+ Wr as validateProductAgentProviderInputFile
4051
4145
  };