@pluno/product-agent-web 0.1.158 → 0.1.160

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 os = "pluno-product-agent-attachments";
2
- const Ne = "files";
3
- async function as(t) {
4
- const e = await ze();
5
- await us(e, "readwrite", (s) => s.put(t));
6
- }
7
- async function ls(t, e) {
8
- const s = await ze();
9
- await Ke(s, "readwrite", async (n) => {
10
- const r = await Ge(
1
+ const as = "pluno-product-agent-attachments";
2
+ const xe = "files";
3
+ async function ls(t) {
4
+ const e = await Ke();
5
+ await ds(e, "readwrite", (s) => s.put(t));
6
+ }
7
+ async function cs(t, e) {
8
+ const s = await Ke();
9
+ await Ge(s, "readwrite", async (n) => {
10
+ const r = await Xe(
11
11
  n.get(t)
12
12
  );
13
13
  r && n.put({
@@ -16,28 +16,28 @@ async function ls(t, e) {
16
16
  });
17
17
  });
18
18
  }
19
- async function cs(t = 864e5) {
20
- const e = await ze(), s = Date.now() - t;
21
- await Ke(e, "readwrite", async (n) => {
19
+ async function us(t = 864e5) {
20
+ const e = await Ke(), s = Date.now() - t;
21
+ await Ge(e, "readwrite", async (n) => {
22
22
  const r = n.index("lastUsedAt");
23
- (await Ge(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
23
+ (await Xe(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function ze() {
26
+ function Ke() {
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(os, 1);
28
+ const s = indexedDB.open(as, 1);
29
29
  s.onupgradeneeded = () => {
30
- const r = s.result.createObjectStore(Ne, { keyPath: "attachmentId" });
30
+ const r = s.result.createObjectStore(xe, { 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 us(t, e, s) {
36
- return await Ke(t, e, async (n) => await Ge(s(n)));
35
+ async function ds(t, e, s) {
36
+ return await Ge(t, e, async (n) => await Xe(s(n)));
37
37
  }
38
- function Ke(t, e, s) {
38
+ function Ge(t, e, s) {
39
39
  return new Promise((n, r) => {
40
- const i = t.transaction(Ne, e), o = i.objectStore(Ne);
40
+ const i = t.transaction(xe, e), o = i.objectStore(xe);
41
41
  let a, l = !1;
42
42
  s(o).then((c) => {
43
43
  a = c;
@@ -57,16 +57,16 @@ function Ke(t, e, s) {
57
57
  };
58
58
  });
59
59
  }
60
- function Ge(t) {
60
+ function Xe(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 ds(t) {
65
+ function hs(t) {
66
66
  return t !== null && (typeof t == "object" || typeof t == "function");
67
67
  }
68
- function _t(t, e, s) {
69
- const n = Reflect.get(t, "pluno"), r = ds(n) ? n : {};
68
+ function Ut(t, e, s) {
69
+ const n = Reflect.get(t, "pluno"), r = hs(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,14 +80,14 @@ function _t(t, e, s) {
80
80
  }
81
81
  };
82
82
  }
83
- const hs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function ps(t, e) {
83
+ const ps = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function gs(t, e) {
85
85
  return e ? t.replace(
86
- hs,
86
+ ps,
87
87
  (s, n, r, i) => `${n}${new URL(r, e).toString()}${i}`
88
88
  ) : t;
89
89
  }
90
- function gs(t, e, s) {
90
+ function fs(t, e, s) {
91
91
  const n = e.map((u) => ({ item: u, identity: s(u) })), r = new Set(
92
92
  n.flatMap(
93
93
  ({ identity: u }) => u.isActivity && !u.isTransient ? u.activityKeys ?? [] : []
@@ -125,17 +125,17 @@ function gs(t, e, s) {
125
125
  w.has(u) || y.push(u);
126
126
  return y;
127
127
  }
128
- function fs(t, e, s, n) {
128
+ function ms(t, e, s, n) {
129
129
  return t.filter((r) => {
130
130
  const i = n(r);
131
131
  return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
132
132
  });
133
133
  }
134
- const Ee = "pluno.productAgent.transportId", ms = "pluno.productAgent.transportIdentity", be = "pluno.productAgent.transportIdentity.event", ys = 50, Is = globalThis.setTimeout.bind(globalThis);
135
- let $ = null;
136
- const ae = /* @__PURE__ */ new Set(), Ce = /* @__PURE__ */ new Map();
137
- async function Ts(t = Ut()) {
138
- const e = t.randomUUID(), s = t.storage.getItem(Ee);
134
+ const be = "pluno.productAgent.transportId", ys = "pluno.productAgent.transportIdentity", Ce = "pluno.productAgent.transportIdentity.event", Is = 50, Ts = globalThis.setTimeout.bind(globalThis);
135
+ let z = null;
136
+ const le = /* @__PURE__ */ new Set(), _e = /* @__PURE__ */ new Map();
137
+ async function ws(t = Pt()) {
138
+ const e = t.randomUUID(), s = t.storage.getItem(be);
139
139
  let n = s ?? t.randomUUID(), r = !1, i = !1;
140
140
  const o = t.channel.subscribe((l) => {
141
141
  if (!(l.senderId === e || l.transportId !== n)) {
@@ -153,14 +153,14 @@ async function Ts(t = Ut()) {
153
153
  }
154
154
  });
155
155
  if (!s)
156
- t.storage.setItem(Ee, n), r = !0;
156
+ t.storage.setItem(be, n), r = !0;
157
157
  else
158
158
  for (; ; ) {
159
159
  if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
160
160
  r = !0;
161
161
  break;
162
162
  }
163
- n = t.randomUUID(), t.storage.setItem(Ee, n);
163
+ n = t.randomUUID(), t.storage.setItem(be, n);
164
164
  }
165
165
  let a = !1;
166
166
  return {
@@ -170,49 +170,49 @@ async function Ts(t = Ut()) {
170
170
  }
171
171
  };
172
172
  }
173
- async function ws() {
174
- $ || ($ = Ts(Ut()), $.then((n) => {
173
+ async function Ss() {
174
+ z || (z = ws(Pt()), z.then((n) => {
175
175
  const r = (i) => {
176
- i.persisted || (n.release(), $ = null, ae.clear(), window.removeEventListener("pagehide", r));
176
+ i.persisted || (n.release(), z = null, le.clear(), window.removeEventListener("pagehide", r));
177
177
  };
178
178
  window.addEventListener("pagehide", r);
179
179
  }));
180
- const t = await $, e = Ss();
181
- ae.add(e);
180
+ const t = await z, e = Ms();
181
+ le.add(e);
182
182
  let s = !1;
183
183
  return {
184
184
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
185
185
  transportId: e === 0 ? t.transportId : `${t.transportId}.${e}`,
186
186
  release: () => {
187
- s || (s = !0, ae.delete(e));
187
+ s || (s = !0, le.delete(e));
188
188
  }
189
189
  };
190
190
  }
191
- function Ss() {
191
+ function Ms() {
192
192
  let t = 0;
193
- for (; ae.has(t); )
193
+ for (; le.has(t); )
194
194
  t += 1;
195
195
  return t;
196
196
  }
197
- function Ut() {
197
+ function Pt() {
198
198
  return {
199
- storage: Ms(),
200
- channel: As(),
199
+ storage: As(),
200
+ channel: Rs(),
201
201
  randomUUID: () => crypto.randomUUID(),
202
- settle: () => new Promise((t) => Is(t, ys))
202
+ settle: () => new Promise((t) => Ts(t, Is))
203
203
  };
204
204
  }
205
- function Ms() {
205
+ function As() {
206
206
  return {
207
207
  getItem: (t) => {
208
208
  try {
209
- return window.sessionStorage?.getItem(t) ?? Ce.get(t) ?? null;
209
+ return window.sessionStorage?.getItem(t) ?? _e.get(t) ?? null;
210
210
  } catch {
211
- return Ce.get(t) ?? null;
211
+ return _e.get(t) ?? null;
212
212
  }
213
213
  },
214
214
  setItem: (t, e) => {
215
- Ce.set(t, e);
215
+ _e.set(t, e);
216
216
  try {
217
217
  window.sessionStorage?.setItem(t, e);
218
218
  } catch {
@@ -220,9 +220,9 @@ function Ms() {
220
220
  }
221
221
  };
222
222
  }
223
- function As() {
223
+ function Rs() {
224
224
  if (typeof BroadcastChannel < "u") {
225
- const t = new BroadcastChannel(ms);
225
+ const t = new BroadcastChannel(ys);
226
226
  return {
227
227
  postMessage: (e) => t.postMessage(e),
228
228
  subscribe: (e) => {
@@ -232,11 +232,11 @@ function As() {
232
232
  close: () => t.close()
233
233
  };
234
234
  }
235
- return Rs();
235
+ return Es();
236
236
  }
237
- function Rs() {
237
+ function Es() {
238
238
  const t = /* @__PURE__ */ new Set(), e = (s) => {
239
- if (s.key !== be || !s.newValue)
239
+ if (s.key !== Ce || !s.newValue)
240
240
  return;
241
241
  const n = JSON.parse(s.newValue);
242
242
  for (const r of t)
@@ -245,9 +245,9 @@ function Rs() {
245
245
  return window.addEventListener("storage", e), {
246
246
  postMessage: (s) => {
247
247
  window.localStorage.setItem(
248
- be,
248
+ Ce,
249
249
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
250
- ), window.localStorage.removeItem(be);
250
+ ), window.localStorage.removeItem(Ce);
251
251
  },
252
252
  subscribe: (s) => (t.add(s), () => t.delete(s)),
253
253
  close: () => {
@@ -255,8 +255,8 @@ function Rs() {
255
255
  }
256
256
  };
257
257
  }
258
- const Pt = "schedule_follow_up";
259
- function Es(t) {
258
+ const Dt = "schedule_follow_up";
259
+ function bs(t) {
260
260
  let e = t;
261
261
  if (typeof e == "string")
262
262
  try {
@@ -267,11 +267,11 @@ function Es(t) {
267
267
  if (!e || typeof e != "object")
268
268
  return null;
269
269
  const s = e;
270
- return s.ok !== !0 || s.toolName !== Pt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
270
+ return s.ok !== !0 || s.toolName !== Dt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
271
271
  }
272
- const bs = globalThis.fetch.bind(globalThis), xe = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Cs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ks = ".pluno-pa-widget__panel", _s = ".pluno-pa-widget__timeline", ct = `${xe}[data-pluno-sdk-preview-channel]`;
273
- let Us = 0;
274
- function ut(t) {
272
+ const Cs = globalThis.fetch.bind(globalThis), Le = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', _s = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ks = ".pluno-pa-widget__panel", Us = ".pluno-pa-widget__timeline", ut = `${Le}[data-pluno-sdk-preview-channel]`;
273
+ let Ps = 0;
274
+ function dt(t) {
275
275
  const e = {};
276
276
  for (const o of [
277
277
  "type",
@@ -320,31 +320,31 @@ function ke(t, e, s) {
320
320
  source: "web_sdk",
321
321
  category: t,
322
322
  name: e,
323
- sequence: ++Us,
323
+ sequence: ++Ps,
324
324
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
325
325
  monotonicMs: performance.now(),
326
326
  data: s
327
327
  };
328
328
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: r }));
329
329
  }
330
- const Ps = "https://app.pluno.ai", Ds = "gpt-5.6-terra", vs = 2e4, Os = 1e4, Ns = 1e4, xs = 1e4, Ls = 1e4, Bs = 1e3, dt = 3e4, ht = 0.2, pt = 6e4, qs = 15e3, z = 8, Hs = "Pluno could not finish this message. Try it again.", Ws = "Browser connection was interrupted.", gt = 15e3, js = "Pluno could not send this message. Try it again.", ft = 2e3, Fs = 1e3, $s = 100, mt = 8e3, yt = 3, zs = [300, 1e3], Dt = 50 * 1024 * 1024, Ks = /* @__PURE__ */ new Set([
330
+ const Ds = "https://app.pluno.ai", vs = "gpt-5.6-terra", Os = 2e4, Ns = 1e4, xs = 1e4, Ls = 1e4, qs = 1e4, Bs = 1e3, ht = 3e4, pt = 0.2, gt = 6e4, Hs = 15e3, K = 8, Ws = "Pluno could not finish this message. Try it again.", js = "Browser connection was interrupted.", ft = 15e3, Fs = "Pluno could not send this message. Try it again.", mt = 2e3, $s = 1e3, zs = 100, yt = 8e3, It = 3, Ks = [300, 1e3], vt = 50 * 1024 * 1024, Gs = /* @__PURE__ */ new Set([
331
331
  ".jpeg:image/jpeg",
332
332
  ".jpg:image/jpeg",
333
333
  ".pdf:application/pdf",
334
334
  ".png:image/png",
335
335
  ".webp:image/webp"
336
- ]), ii = ".pdf,.png,.jpg,.jpeg,.webp", Xe = 64e3, _e = 4e3, Je = 30, Gs = 2e3, Xs = 1e3, vt = "Image is too large for model vision input.", Js = 100, Ot = "pluno.productAgent.state.", Le = "pluno.productAgent.pendingEvents.", he = "pluno.productAgent.activeToolCalls.", Vs = 100;
337
- function K(t, e = 0) {
336
+ ]), oi = ".pdf,.png,.jpg,.jpeg,.webp", Je = 64e3, Ue = 4e3, Ve = 30, Xs = 2e3, Js = 1e3, Ot = "Image is too large for model vision input.", Vs = 100, Nt = "pluno.productAgent.state.", qe = "pluno.productAgent.pendingEvents.", pe = "pluno.productAgent.activeToolCalls.", Ys = 100;
337
+ function G(t, e = 0) {
338
338
  const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
339
339
  return Math.max(e, s);
340
340
  }
341
- const le = /* @__PURE__ */ new Set();
342
- let se = null;
343
- function Ys(t, e = Math.random) {
344
- const s = Math.min(dt, Bs * 2 ** t), n = 1 - ht + e() * ht * 2;
345
- return Math.min(dt, Math.round(s * n));
341
+ const ce = /* @__PURE__ */ new Set();
342
+ let ne = null;
343
+ function Qs(t, e = Math.random) {
344
+ const s = Math.min(ht, Bs * 2 ** t), n = 1 - pt + e() * pt * 2;
345
+ return Math.min(ht, Math.round(s * n));
346
346
  }
347
- function Qs(t, e, s) {
347
+ function Zs(t, e, s) {
348
348
  return new Promise((n, r) => {
349
349
  const i = setTimeout(() => r(new Error(s)), e);
350
350
  t.then(
@@ -357,13 +357,13 @@ function Qs(t, e, s) {
357
357
  );
358
358
  });
359
359
  }
360
- class Nt {
360
+ class xt {
361
361
  constructor(e, s) {
362
362
  this.options = e, this.transportIdentity = s, this.state = {
363
363
  ...this.state,
364
- starterPrompts: vn(e.initialStarterPrompts)
364
+ starterPrompts: On(e.initialStarterPrompts)
365
365
  };
366
- const n = e.restorePersistedState === !1 ? null : Ar(e.clientId, e.expectedPersistedSessionId);
366
+ const n = e.restorePersistedState === !1 ? null : Rr(e.clientId, e.expectedPersistedSessionId);
367
367
  n && (this.state = {
368
368
  ...this.state,
369
369
  ...n,
@@ -378,14 +378,14 @@ class Nt {
378
378
  isThinking: !1,
379
379
  isRetrying: !1,
380
380
  lastError: null
381
- }), this.queuedClientEvents = Ur(
382
- Er(e.clientId),
383
- Cr(e.clientId)
381
+ }), this.queuedClientEvents = Pr(
382
+ br(e.clientId),
383
+ _r(e.clientId)
384
384
  );
385
385
  const r = [...this.queuedClientEvents].reverse().find(
386
386
  (i) => i.type === "chat.user_message" && typeof i.clientMessageId == "string"
387
387
  );
388
- r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"), x(e.clientId, this.queuedClientEvents);
388
+ r?.clientMessageId && (this.pendingClientMessageId = r.clientMessageId, this.pendingUserMessageEvent = r, this.state.pendingMessageStatus = "reconnecting"), L(e.clientId, this.queuedClientEvents);
389
389
  }
390
390
  options;
391
391
  listeners = {};
@@ -468,15 +468,15 @@ class Nt {
468
468
  lastErrorSecuritySettingsUrl: null
469
469
  };
470
470
  static async init(e) {
471
- const s = await ws(), n = new Nt({
471
+ const s = await Ss(), n = new xt({
472
472
  ...e,
473
- backendUrl: In(e.backendUrl ?? Ps),
473
+ backendUrl: Tn(e.backendUrl ?? Ds),
474
474
  clientId: e.clientId ?? Bn(),
475
- model: e.model ?? Ds,
476
- entrySurface: Tn(e.entrySurface)
475
+ model: e.model ?? vs,
476
+ entrySurface: wn(e.entrySurface)
477
477
  }, s);
478
478
  try {
479
- cs().catch((r) => {
479
+ us().catch((r) => {
480
480
  M("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
481
481
  message: r instanceof Error ? r.message : String(r)
482
482
  });
@@ -507,14 +507,14 @@ class Nt {
507
507
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
508
508
  );
509
509
  try {
510
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await Qs(this.options.tokenProvider(), Ns, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
510
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Zs(this.options.tokenProvider(), xs, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
511
511
  return;
512
512
  if (!this.token && !this.options.webSocketFactory)
513
513
  throw new Error("Pluno requires a token or tokenProvider");
514
- const s = Mn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
514
+ const s = An(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
515
515
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
516
516
  this.socket === n && n.readyState === WebSocket.CONNECTING && (M("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
517
- }, xs), n.addEventListener("open", () => {
517
+ }, Ls), n.addEventListener("open", () => {
518
518
  this.socket !== n || (this.clearSocketConnectTimer(), M("web-sdk.agent", "Pluno socket opened", {
519
519
  queuedClientEventCount: this.queuedClientEvents.length,
520
520
  isThinking: this.state.isThinking
@@ -526,16 +526,16 @@ class Nt {
526
526
  pageUrl: location.href
527
527
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
528
528
  this.socket === n && (M("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
529
- }, Ls));
529
+ }, qs));
530
530
  }), n.addEventListener("message", (r) => {
531
- this.socket === n && this.handleServerEvent(Pn(r.data));
531
+ this.socket === n && this.handleServerEvent(Dn(r.data));
532
532
  }), n.addEventListener("sendfailure", (r) => {
533
533
  if (this.socket !== n)
534
534
  return;
535
- const i = Dn(r?.detail?.data);
535
+ const i = vn(r?.detail?.data);
536
536
  i?.type === "chat.user_message" && i.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
537
537
  (o) => o.type === "chat.user_message" && o.clientMessageId === i.clientMessageId
538
- ) && (this.queuedClientEvents.push(i), x(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();
538
+ ) && (this.queuedClientEvents.push(i), L(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();
539
539
  }), n.addEventListener("close", (r) => {
540
540
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (this.rememberBrowserConnectionInterruptionForActiveRun(), M("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
541
541
  code: typeof r?.code == "number" ? r.code : null,
@@ -568,7 +568,7 @@ class Nt {
568
568
  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.pendingWarmupEvent = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
569
569
  }
570
570
  destroy() {
571
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Pr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
571
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Dr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
572
572
  for (const e of Object.values(this.listeners))
573
573
  e?.clear();
574
574
  }
@@ -584,17 +584,17 @@ class Nt {
584
584
  }
585
585
  async sendMessage(e, s = {}) {
586
586
  const n = e.trim(), r = s.attachments ?? [];
587
- if (!this.options.persistAttachmentUpload && (r.forEach(Jt), r.reduce(
587
+ if (!this.options.persistAttachmentUpload && (r.forEach(Vt), r.reduce(
588
588
  (T, f) => T + f.sizeBytes,
589
589
  0
590
- ) > Dt))
590
+ ) > vt))
591
591
  throw new Error("Embedded attachments must total at most 50 MB per message");
592
- let i = r.map(Qe);
592
+ let i = r.map(Ze);
593
593
  if (!n && i.length === 0)
594
594
  return null;
595
595
  if (this.pendingClientMessageId)
596
596
  throw new Error("Wait for the current message to finish sending before sending another.");
597
- const o = C(), a = s.clientMessageId ?? G(), l = {
597
+ const o = C(), a = s.clientMessageId ?? X(), l = {
598
598
  id: `local-${a}`,
599
599
  role: "user",
600
600
  content: n,
@@ -648,14 +648,14 @@ class Nt {
648
648
  sessionId: this.state.sessionId ?? void 0,
649
649
  clientMessageId: a,
650
650
  initiatedBy: s.initiatedBy,
651
- invocation: wn(s.invocation ?? s.initiatedBy),
651
+ invocation: Sn(s.invocation ?? s.initiatedBy),
652
652
  entrySurface: this.options.entrySurface,
653
653
  content: n,
654
- pageContent: d && Ve() || void 0,
654
+ pageContent: d && Ye() || void 0,
655
655
  attachments: i.length > 0 ? i : void 0,
656
656
  page: o,
657
657
  model: this.options.model,
658
- metadata: It(this.options.metadata)
658
+ metadata: Tt(this.options.metadata)
659
659
  };
660
660
  return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = g, this.browserConnectionInterruptedClientMessageIds.delete(a), this.send(g), this.schedulePendingDeliveryAck(a), a;
661
661
  }
@@ -675,16 +675,16 @@ class Nt {
675
675
  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;
676
676
  }
677
677
  createLocalAttachment(e) {
678
- this.options.persistAttachmentUpload || Dr(e);
679
- const s = G(), n = {
678
+ this.options.persistAttachmentUpload || vr(e);
679
+ const s = X(), n = {
680
680
  id: s,
681
681
  name: e.name || "attachment",
682
- mimeType: $e(e),
682
+ mimeType: ze(e),
683
683
  sizeBytes: e.size
684
684
  };
685
685
  this.attachmentFiles.set(s, e);
686
686
  const r = Date.now();
687
- return as({
687
+ return ls({
688
688
  attachmentId: s,
689
689
  name: n.name,
690
690
  mimeType: n.mimeType,
@@ -713,7 +713,7 @@ class Nt {
713
713
  file: e,
714
714
  attachment: s
715
715
  }) {
716
- const n = this.state.sessionId, r = $e(e), i = {
716
+ const n = this.state.sessionId, r = ze(e), i = {
717
717
  sessionId: n ?? void 0,
718
718
  attachmentId: s.id,
719
719
  clientId: this.options.clientId,
@@ -723,34 +723,34 @@ class Nt {
723
723
  sizeBytes: e.size,
724
724
  page: C(),
725
725
  model: this.options.model,
726
- metadata: It(this.options.metadata),
726
+ metadata: Tt(this.options.metadata),
727
727
  entrySurface: this.options.entrySurface
728
728
  };
729
729
  let o;
730
730
  if (this.options.persistAttachmentUpload)
731
- o = await oe(
731
+ o = await ae(
732
732
  () => this.options.persistAttachmentUpload(i, e),
733
733
  "Failed to upload attachment"
734
734
  );
735
735
  else {
736
- const l = this.options.prepareAttachmentUpload ? await oe(
736
+ const l = this.options.prepareAttachmentUpload ? await ae(
737
737
  () => this.options.prepareAttachmentUpload(i),
738
738
  "Failed to prepare attachment upload"
739
739
  ) : await this.prepareEmbedAttachmentUpload(i);
740
- await oe(async () => {
740
+ await ae(async () => {
741
741
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
742
742
  method: l.uploadMethod,
743
743
  headers: l.uploadHeaders,
744
744
  body: e
745
745
  });
746
746
  if (!c.ok)
747
- throw new ce("Failed to upload attachment", c.status);
747
+ throw new ue("Failed to upload attachment", c.status);
748
748
  return c;
749
749
  }, "Failed to upload attachment"), o = l;
750
750
  }
751
751
  this.setState({ sessionId: o.sessionId });
752
- const a = Xt(o.attachment, this.options.backendUrl);
753
- return this.updateAttachmentInState(s.id, a), s.id && ls(s.id, {
752
+ const a = Jt(o.attachment, this.options.backendUrl);
753
+ return this.updateAttachmentInState(s.id, a), s.id && cs(s.id, {
754
754
  sessionId: o.sessionId,
755
755
  fileUrl: a.fileUrl,
756
756
  sandboxPath: a.sandboxPath,
@@ -777,18 +777,18 @@ class Nt {
777
777
  }
778
778
  async prepareEmbedAttachmentUpload(e) {
779
779
  let s = !1;
780
- return await oe(async () => {
780
+ return await ae(async () => {
781
781
  const n = await this.fetchEmbedAttachmentUpload(e);
782
782
  if (n.ok)
783
783
  return await n.json();
784
- if (Jr(n.status) && this.options.tokenProvider && !s) {
784
+ if (Vr(n.status) && this.options.tokenProvider && !s) {
785
785
  s = !0;
786
786
  const r = await this.fetchEmbedAttachmentUpload(e);
787
787
  if (r.ok)
788
788
  return await r.json();
789
- throw new ce("Failed to prepare attachment upload", r.status);
789
+ throw new ue("Failed to prepare attachment upload", r.status);
790
790
  }
791
- throw new ce("Failed to prepare attachment upload", n.status);
791
+ throw new ue("Failed to prepare attachment upload", n.status);
792
792
  }, "Failed to prepare attachment upload");
793
793
  }
794
794
  async fetchEmbedAttachmentUpload(e) {
@@ -806,14 +806,14 @@ class Nt {
806
806
  if (!this.state.sessionId)
807
807
  return;
808
808
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
809
- const e = gr(
809
+ const e = fr(
810
810
  this.state.messages,
811
811
  this.state.assistantDraftRespondsToUserMessageId,
812
812
  this.state.assistantDraftRunId,
813
813
  this.activeClientMessageId
814
814
  );
815
815
  this.setState({
816
- messages: ie(
816
+ messages: oe(
817
817
  this.state.messages,
818
818
  e.clientMessageId,
819
819
  e.runId
@@ -844,10 +844,10 @@ class Nt {
844
844
  });
845
845
  }
846
846
  listSessions(e = {}) {
847
- const s = G(), n = new Promise((i, o) => {
847
+ const s = X(), n = new Promise((i, o) => {
848
848
  const a = window.setTimeout(() => {
849
849
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
850
- }, mt);
850
+ }, yt);
851
851
  this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
852
852
  }), r = {
853
853
  type: "sessions.list",
@@ -866,14 +866,14 @@ class Nt {
866
866
  setSessionPinned(e, s) {
867
867
  return this.sendSessionMutation(
868
868
  this.pendingSessionPinRequests,
869
- { type: "session.pin", requestId: G(), sessionId: e, pinned: s },
869
+ { type: "session.pin", requestId: X(), sessionId: e, pinned: s },
870
870
  "Session pin did not respond in time"
871
871
  );
872
872
  }
873
873
  renameSession(e, s) {
874
874
  return this.sendSessionMutation(
875
875
  this.pendingSessionRenameRequests,
876
- { type: "session.rename", requestId: G(), sessionId: e, title: s },
876
+ { type: "session.rename", requestId: X(), sessionId: e, title: s },
877
877
  "Session rename did not respond in time"
878
878
  );
879
879
  }
@@ -897,9 +897,9 @@ class Nt {
897
897
  });
898
898
  }
899
899
  send(e) {
900
- this.sendNow(_(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
900
+ this.sendNow(k(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
901
901
  (r) => r.type === "chat.user_message" && r.clientMessageId === e.clientMessageId
902
- ) || this.queuedClientEvents.push(e), x(this.options.clientId, this.queuedClientEvents), this.setState({
902
+ ) || this.queuedClientEvents.push(e), L(this.options.clientId, this.queuedClientEvents), this.setState({
903
903
  status: "reconnecting",
904
904
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
905
905
  }), this.scheduleReconnect());
@@ -915,7 +915,7 @@ class Nt {
915
915
  return !1;
916
916
  const s = this.socket;
917
917
  try {
918
- return s.send(JSON.stringify(e)), ke("client_event", e.type, ut(e)), !0;
918
+ return s.send(JSON.stringify(e)), ke("client_event", e.type, dt(e)), !0;
919
919
  } catch (n) {
920
920
  return M("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
921
921
  message: n instanceof Error ? n.message : String(n),
@@ -924,13 +924,36 @@ class Nt {
924
924
  }), this.socket === s && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect()), s.readyState !== WebSocket.CLOSED && s.readyState !== WebSocket.CLOSING && s.close(), !1;
925
925
  }
926
926
  }
927
+ reportHealthSignal(e, s = {}) {
928
+ if (!(!this.socket || this.socket.readyState !== WebSocket.OPEN))
929
+ try {
930
+ this.socket.send(JSON.stringify({
931
+ type: "runtime.health",
932
+ signal: {
933
+ id: crypto.randomUUID(),
934
+ name: e,
935
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
936
+ source: "web_sdk",
937
+ entrySurface: this.options.entrySurface,
938
+ ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
939
+ ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
940
+ ...s
941
+ }
942
+ }));
943
+ } catch (n) {
944
+ M("web-sdk.agent", "Pluno health signal send failed", {
945
+ name: e,
946
+ message: n instanceof Error ? n.message : String(n)
947
+ });
948
+ }
949
+ }
927
950
  requestTransientStarterPrompts() {
928
951
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
929
952
  return;
930
953
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
931
- const e = An();
954
+ const e = Rn();
932
955
  this.sendNow(
933
- _({
956
+ k({
934
957
  type: "starter_prompts.page_context",
935
958
  pageUrl: e.pageUrl,
936
959
  pageTitle: e.pageTitle,
@@ -939,13 +962,13 @@ class Nt {
939
962
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
940
963
  }
941
964
  startStarterPromptUrlWatcher() {
942
- this.locationChangeCleanup || (this.locationChangeCleanup = Rn(() => this.handleStarterPromptUrlChange()));
965
+ this.locationChangeCleanup || (this.locationChangeCleanup = En(() => this.handleStarterPromptUrlChange()));
943
966
  }
944
967
  handleStarterPromptUrlChange() {
945
968
  const e = location.href;
946
969
  e !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
947
970
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
948
- }, Vs));
971
+ }, Ys));
949
972
  }
950
973
  refreshStarterPromptsForCurrentUrl() {
951
974
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -960,27 +983,27 @@ class Nt {
960
983
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
961
984
  return;
962
985
  const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
963
- x(this.options.clientId, this.queuedClientEvents);
986
+ L(this.options.clientId, this.queuedClientEvents);
964
987
  for (let s = 0; s < e.length; s += 1) {
965
988
  const n = e[s];
966
- if (!this.sendNow(_(n))) {
967
- this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), x(this.options.clientId, this.queuedClientEvents);
989
+ if (!this.sendNow(k(n))) {
990
+ this.queuedClientEvents.unshift(n, ...e.slice(s + 1)), L(this.options.clientId, this.queuedClientEvents);
968
991
  return;
969
992
  }
970
- x(this.options.clientId, this.queuedClientEvents);
993
+ L(this.options.clientId, this.queuedClientEvents);
971
994
  }
972
995
  }
973
996
  flushPendingWarmupEvent() {
974
997
  !this.pendingWarmupEvent || !this.sendNow(this.pendingWarmupEvent) || (this.pendingWarmupEvent = null);
975
998
  }
976
999
  handleServerEvent(e) {
977
- if (ke("server_event", e.type, ut(e)), e.type === "run.ack") {
978
- const s = Pe(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
1000
+ if (ke("server_event", e.type, dt(e)), e.type === "run.ack") {
1001
+ const s = De(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
979
1002
  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);
980
1003
  return;
981
1004
  }
982
1005
  if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
983
- const s = Pe(e);
1006
+ const s = De(e);
984
1007
  if (s) {
985
1008
  this.deferredSessionUpdatedSessionIds.add(s);
986
1009
  return;
@@ -995,20 +1018,20 @@ class Nt {
995
1018
  this.clearHeartbeatAckTimer();
996
1019
  return;
997
1020
  }
998
- if (tn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
1021
+ if (sn(e) && this.markThinkingProgress(), e.type === "auth.ok") {
999
1022
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingWarmupEvent(), this.startHeartbeat();
1000
- const s = On(e), n = Object.prototype.hasOwnProperty.call(e, "appearance");
1023
+ const s = Nn(e), n = Object.prototype.hasOwnProperty.call(e, "appearance");
1001
1024
  M("web-sdk.agent", "Received auth.ok appearance", {
1002
1025
  hasAppearance: n,
1003
1026
  rawAppearance: e.appearance,
1004
1027
  normalizedAppearance: s
1005
- }), this.runtimeHelperJavascript = Nn(e.runtimeHelpers)?.javascript ?? null;
1006
- const r = St(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
1007
- user: qn(e.user),
1028
+ }), this.runtimeHelperJavascript = xn(e.runtimeHelpers)?.javascript ?? null;
1029
+ const r = Mt(e, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), o = e.starterPromptsLoading === !0, a = {
1030
+ user: Hn(e.user),
1008
1031
  status: "connected",
1009
1032
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
1010
1033
  };
1011
- (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 && !ne() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1034
+ (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 && !re() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
1012
1035
  type: "page.upsert",
1013
1036
  sessionId: this.state.sessionId,
1014
1037
  page: C(),
@@ -1018,7 +1041,7 @@ class Nt {
1018
1041
  }
1019
1042
  if (e.type === "starterPrompts.updated") {
1020
1043
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
1021
- starterPrompts: St(e, "starterPrompts"),
1044
+ starterPrompts: Mt(e, "starterPrompts"),
1022
1045
  starterPromptsLoading: !1
1023
1046
  });
1024
1047
  return;
@@ -1026,37 +1049,37 @@ class Nt {
1026
1049
  if (e.type === "conversation.state") {
1027
1050
  const s = Array.isArray(e.items) ? e.items : [], n = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, r = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, i = e.isRetrying === !0;
1028
1051
  n && r && (this.pendingClientMessageId = r);
1029
- const o = Gn(
1052
+ const o = Xn(
1030
1053
  e.assistantDraft
1031
1054
  ), a = o !== void 0;
1032
1055
  this.rememberUserMessageClientMessageIds(s);
1033
- const l = cr(s);
1056
+ const l = ur(s);
1034
1057
  if (l) {
1035
- const f = ur(s, l);
1058
+ const f = dr(s, l);
1036
1059
  this.retryAttemptsByClientMessageId[l] = Math.max(
1037
1060
  this.retryAttemptsByClientMessageId[l] ?? 0,
1038
1061
  f
1039
1062
  );
1040
1063
  }
1041
1064
  const c = s.filter((f) => {
1042
- const R = q(f);
1043
- return At(R) ? !1 : !R || !l || !He(R) ? !0 : je(s, R) !== l;
1044
- }), h = sr(
1065
+ const R = H(f);
1066
+ return Rt(R) ? !1 : !R || !l || !We(R) ? !0 : Fe(s, R) !== l;
1067
+ }), h = nr(
1045
1068
  this.state.messages,
1046
- Hn(c, this.options.backendUrl)
1047
- ), p = Mt(h), w = !a && s.some(
1048
- (f) => Rt(
1049
- q(f),
1069
+ Wn(c, this.options.backendUrl)
1070
+ ), p = At(h), w = !a && s.some(
1071
+ (f) => Et(
1072
+ H(f),
1050
1073
  this.state.assistantDraft,
1051
1074
  this.state.assistantDraftItemId,
1052
1075
  this.state.assistantDraftRespondsToUserMessageId,
1053
1076
  this.state.assistantDraftRunId
1054
1077
  )
1055
- ), y = a ? o?.content ?? "" : this.state.assistantDraft, u = !!o?.content, d = p && (!y || w), g = or(h), m = d && g;
1056
- if (!p && lr(this.state.messages, s))
1078
+ ), y = a ? o?.content ?? "" : this.state.assistantDraft, u = !!o?.content, d = p && (!y || w), g = ar(h), m = d && g;
1079
+ if (!p && cr(this.state.messages, s))
1057
1080
  return;
1058
- this.lastUserMessagePageUrl = ar(s);
1059
- const T = d ? null : We(s);
1081
+ this.lastUserMessagePageUrl = lr(s);
1082
+ const T = d ? null : je(s);
1060
1083
  if (this.latestRecoverableClientMessageId = T, g && this.clearRetryTimers(), this.setState({
1061
1084
  sessionId: E(e.session, "id") ?? this.state.sessionId,
1062
1085
  messages: h,
@@ -1095,7 +1118,7 @@ class Nt {
1095
1118
  else if (u || T) {
1096
1119
  if (T) {
1097
1120
  this.activeClientMessageId = T;
1098
- const f = V(s), R = f === null ? null : s[f];
1121
+ const f = Y(s), R = f === null ? null : s[f];
1099
1122
  this.activeResponseUserMessageId = E(R, "id");
1100
1123
  }
1101
1124
  this.markThinkingProgress();
@@ -1109,7 +1132,7 @@ class Nt {
1109
1132
  if (e.type === "sessions.page") {
1110
1133
  const s = typeof e.requestId == "string" ? e.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
1111
1134
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
1112
- sessions: Wn(e.sessions),
1135
+ sessions: jn(e.sessions),
1113
1136
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
1114
1137
  }));
1115
1138
  return;
@@ -1128,10 +1151,10 @@ class Nt {
1128
1151
  }
1129
1152
  if (e.type === "session.item") {
1130
1153
  this.rememberUserMessageClientMessageIds([e.item]);
1131
- const s = q(e.item);
1132
- if (He(s)) {
1154
+ const s = H(e.item);
1155
+ if (We(s)) {
1133
1156
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
1134
- const r = E(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);
1157
+ const r = E(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);
1135
1158
  if (r && a) {
1136
1159
  this.retryAfterInterruptedRun(r, a);
1137
1160
  return;
@@ -1141,21 +1164,21 @@ class Nt {
1141
1164
  return;
1142
1165
  }
1143
1166
  }
1144
- if (At(s))
1167
+ if (Rt(s))
1145
1168
  return;
1146
- const n = Ht(e.item, this.options.backendUrl);
1169
+ const n = Wt(e.item, this.options.backendUrl);
1147
1170
  if (n) {
1148
1171
  const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
1149
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1172
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), x(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
1150
1173
  const i = e.item.data;
1151
- hr(i) && this.clearRunAckResyncRetryTimer();
1152
- const o = Be(this.state.messages, n), a = Mt(o), l = Rt(
1174
+ pr(i) && this.clearRunAckResyncRetryTimer();
1175
+ const o = Be(this.state.messages, n), a = At(o), l = Et(
1153
1176
  i,
1154
1177
  this.state.assistantDraft,
1155
1178
  this.state.assistantDraftItemId,
1156
1179
  this.state.assistantDraftRespondsToUserMessageId,
1157
1180
  this.state.assistantDraftRunId
1158
- ), c = a && (!this.state.assistantDraft || l), h = N(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
1181
+ ), c = a && (!this.state.assistantDraft || l), h = x(n) && (c || !this.state.isThinking && this.activeClientMessageId === null);
1159
1182
  this.setState({
1160
1183
  messages: o,
1161
1184
  ...l ? {
@@ -1188,6 +1211,7 @@ class Nt {
1188
1211
  role: "assistant",
1189
1212
  content: i,
1190
1213
  createdAt: a?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
1214
+ ...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
1191
1215
  dataType: "assistant_draft",
1192
1216
  ...l ? { phase: l } : {},
1193
1217
  ...c ? { respondsToUserMessageId: c } : {},
@@ -1210,9 +1234,9 @@ class Nt {
1210
1234
  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;
1211
1235
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !r || !this.state.assistantDraftRunId || r === this.state.assistantDraftRunId))
1212
1236
  return;
1213
- 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 = fs(
1237
+ 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(
1214
1238
  this.state.messages.filter(
1215
- (c) => c.dataType !== "assistant_draft" || !Vn(
1239
+ (c) => c.dataType !== "assistant_draft" || !Yn(
1216
1240
  c,
1217
1241
  n,
1218
1242
  r
@@ -1220,11 +1244,11 @@ class Nt {
1220
1244
  ),
1221
1245
  n,
1222
1246
  r,
1223
- Wt
1247
+ jt
1224
1248
  );
1225
1249
  this.setState({
1226
1250
  sessionId: s,
1227
- messages: Yn(
1251
+ messages: Qn(
1228
1252
  l,
1229
1253
  typeof e.responseId == "string" ? e.responseId : null,
1230
1254
  n,
@@ -1246,9 +1270,9 @@ class Nt {
1246
1270
  if (s)
1247
1271
  this.nonTranscriptToolCallIds.add(s);
1248
1272
  else {
1249
- const n = er(e);
1273
+ const n = tr(e);
1250
1274
  if (n) {
1251
- const r = Qn(
1275
+ const r = Zn(
1252
1276
  this.state.messages,
1253
1277
  n
1254
1278
  );
@@ -1301,9 +1325,9 @@ class Nt {
1301
1325
  return;
1302
1326
  }
1303
1327
  o && r && i && (this.retryableClientMessageId = i);
1304
- const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = Sn(a.message);
1328
+ const a = new Error(typeof e.message == "string" ? e.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), l = Mn(a.message);
1305
1329
  l && console.error(l), this.setState({
1306
- messages: ie(
1330
+ messages: oe(
1307
1331
  this.state.messages,
1308
1332
  i ?? this.activeClientMessageId,
1309
1333
  typeof e.runId == "string" ? e.runId : null
@@ -1319,9 +1343,9 @@ class Nt {
1319
1343
  }
1320
1344
  }
1321
1345
  shouldIgnoreBackgroundSessionEvent(e) {
1322
- if (!this.options.keepRunsActiveOnSessionNavigation || !sn(e))
1346
+ if (!this.options.keepRunsActiveOnSessionNavigation || !nn(e))
1323
1347
  return !1;
1324
- const s = Pe(e);
1348
+ const s = De(e);
1325
1349
  return s ? this.deferredSessionUpdatedSessionIds.has(s) ? !0 : this.state.sessionId ? s !== this.state.sessionId : this.backgroundSessionIds.has(s) : !1;
1326
1350
  }
1327
1351
  rememberCurrentRunAsBackground() {
@@ -1331,7 +1355,7 @@ class Nt {
1331
1355
  const s = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
1332
1356
  if (!(e.retryable === !0 || e.code === "transient_model_error") || !s || !n || e.code === "run_recovery_exhausted")
1333
1357
  return !1;
1334
- if (ne())
1358
+ if (re())
1335
1359
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
1336
1360
  if (e.code === "run_still_active") {
1337
1361
  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) {
@@ -1345,10 +1369,10 @@ class Nt {
1345
1369
  if (this.retryTimersByClientMessageId[n] !== void 0)
1346
1370
  return !0;
1347
1371
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
1348
- if (i >= z)
1372
+ if (i >= K)
1349
1373
  return !1;
1350
1374
  this.retryAttemptsByClientMessageId[n] = i + 1;
1351
- const o = K(
1375
+ const o = G(
1352
1376
  i,
1353
1377
  typeof e.retryAfterMs == "number" ? e.retryAfterMs : 0
1354
1378
  );
@@ -1362,16 +1386,20 @@ class Nt {
1362
1386
  }, o), !0;
1363
1387
  }
1364
1388
  retryAfterInterruptedRun(e, s) {
1365
- if (ne()) {
1389
+ if (re()) {
1366
1390
  this.retryableClientMessageId = s, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null });
1367
1391
  return;
1368
1392
  }
1369
1393
  if (this.retryTimersByClientMessageId[s] !== void 0)
1370
1394
  return;
1371
1395
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
1372
- if (n >= z) {
1373
- this.retryableClientMessageId = s, this.setState({
1374
- messages: ie(
1396
+ if (n >= K) {
1397
+ this.reportHealthSignal("run_recovery_exhausted", {
1398
+ clientMessageId: s,
1399
+ retryAttempts: n,
1400
+ reason: "retry_budget_exhausted"
1401
+ }), this.retryableClientMessageId = s, this.setState({
1402
+ messages: oe(
1375
1403
  this.state.messages,
1376
1404
  s,
1377
1405
  null
@@ -1385,7 +1413,7 @@ class Nt {
1385
1413
  }
1386
1414
  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(() => {
1387
1415
  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 });
1388
- }, K(n));
1416
+ }, G(n));
1389
1417
  }
1390
1418
  clearRetryTimers() {
1391
1419
  for (const e of Object.values(this.retryTimersByClientMessageId))
@@ -1394,7 +1422,7 @@ class Nt {
1394
1422
  }
1395
1423
  rememberUserMessageClientMessageIds(e) {
1396
1424
  for (const s of e) {
1397
- const n = E(s, "id"), r = q(s);
1425
+ const n = E(s, "id"), r = H(s);
1398
1426
  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(
1399
1427
  r.clientMessageId,
1400
1428
  E(s, "sessionId") ?? this.state.sessionId,
@@ -1412,7 +1440,7 @@ class Nt {
1412
1440
  const r = new Promise((i, o) => {
1413
1441
  const a = window.setTimeout(() => {
1414
1442
  e.delete(s.requestId), o(new Error(n));
1415
- }, mt);
1443
+ }, yt);
1416
1444
  e.set(s.requestId, { resolve: i, reject: o, timeout: a });
1417
1445
  });
1418
1446
  if (!this.sendNow(s)) {
@@ -1435,7 +1463,7 @@ class Nt {
1435
1463
  e.clear();
1436
1464
  }
1437
1465
  markThinkingProgress() {
1438
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(pt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1466
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(gt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1439
1467
  }
1440
1468
  scheduleThinkingWatchdog(e) {
1441
1469
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1478,21 +1506,21 @@ class Nt {
1478
1506
  }), this.markThinkingProgress();
1479
1507
  }
1480
1508
  schedulePendingDeliveryAck(e) {
1481
- this.clearPendingDeliveryTimers(), !ne() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
1509
+ this.clearPendingDeliveryTimers(), !re() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
1482
1510
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
1483
- }, gt));
1511
+ }, ft));
1484
1512
  }
1485
1513
  retryPendingDelivery(e) {
1486
1514
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
1487
1515
  return;
1488
1516
  const s = this.retryAttemptsByClientMessageId[e] ?? 0;
1489
- if (s >= z) {
1517
+ if (s >= K) {
1490
1518
  this.failPendingDelivery(e);
1491
1519
  return;
1492
1520
  }
1493
- this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
1521
+ s === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = s + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
1494
1522
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
1495
- }, K(s, ft));
1523
+ }, G(s, mt));
1496
1524
  }
1497
1525
  failPendingDelivery(e) {
1498
1526
  if (this.pendingClientMessageId !== e)
@@ -1501,7 +1529,7 @@ class Nt {
1501
1529
  this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = s, this.retryableClientMessageId = e, this.setState({
1502
1530
  pendingMessageStatus: null,
1503
1531
  isRetrying: !1,
1504
- lastError: js,
1532
+ lastError: Fs,
1505
1533
  lastErrorCode: "message_delivery_failed"
1506
1534
  });
1507
1535
  }
@@ -1516,7 +1544,7 @@ class Nt {
1516
1544
  s,
1517
1545
  typeof e.runId == "string" ? e.runId : null
1518
1546
  ), !(!this.state.isThinking || !s) && this.setState({
1519
- messages: mr(
1547
+ messages: yr(
1520
1548
  this.state.messages,
1521
1549
  s
1522
1550
  )
@@ -1525,18 +1553,18 @@ class Nt {
1525
1553
  scheduleRunAckWatchdog(e) {
1526
1554
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1527
1555
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
1528
- }, gt);
1556
+ }, ft);
1529
1557
  }
1530
1558
  recoverMissedRunAck(e) {
1531
1559
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (M("web-sdk.agent", "Pluno run ack missed; resyncing session", {
1532
1560
  sessionId: this.state.sessionId,
1533
1561
  clientMessageId: e
1534
- }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
1562
+ }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(e));
1535
1563
  }
1536
1564
  scheduleRunAckResyncRetry(e) {
1537
1565
  this.clearRunAckResyncRetryTimer();
1538
1566
  const s = this.retryAttemptsByClientMessageId[e] ?? 0;
1539
- s >= z || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1567
+ s >= K || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1540
1568
  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({
1541
1569
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1542
1570
  isThinking: !0,
@@ -1549,8 +1577,8 @@ class Nt {
1549
1577
  sessionId: this.state.sessionId,
1550
1578
  clientMessageId: e,
1551
1579
  automatic: !0
1552
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(pt)));
1553
- }, K(s, ft)));
1580
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(gt)));
1581
+ }, G(s, mt)));
1554
1582
  }
1555
1583
  clearRunAckResyncRetryTimer() {
1556
1584
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1565,6 +1593,8 @@ class Nt {
1565
1593
  if (!e) {
1566
1594
  M("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
1567
1595
  sessionId: this.state.sessionId
1596
+ }), this.reportHealthSignal("run_recovery_exhausted", {
1597
+ reason: "missing_client_message_id"
1568
1598
  }), this.setState({
1569
1599
  isThinking: !1,
1570
1600
  lastError: this.getRunRecoveryExhaustedErrorMessage(null),
@@ -1573,12 +1603,16 @@ class Nt {
1573
1603
  return;
1574
1604
  }
1575
1605
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0, n = this.retryAttemptsByClientMessageId[e] ?? 0;
1576
- if (n >= z) {
1606
+ if (n >= K) {
1577
1607
  M("web-sdk.agent", "Pluno run recovery retry exhausted", {
1578
1608
  sessionId: this.state.sessionId,
1579
1609
  clientMessageId: e
1610
+ }), this.reportHealthSignal("run_recovery_exhausted", {
1611
+ clientMessageId: e,
1612
+ retryAttempts: n,
1613
+ reason: "retry_budget_exhausted"
1580
1614
  }), this.retryableClientMessageId = e, this.setState({
1581
- messages: ie(
1615
+ messages: oe(
1582
1616
  this.state.messages,
1583
1617
  e,
1584
1618
  null
@@ -1594,7 +1628,7 @@ class Nt {
1594
1628
  sessionId: this.state.sessionId,
1595
1629
  clientMessageId: e,
1596
1630
  resyncAttempts: s + 1
1597
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(qs);
1631
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Hs);
1598
1632
  return;
1599
1633
  }
1600
1634
  this.setState({
@@ -1612,7 +1646,7 @@ class Nt {
1612
1646
  clientMessageId: e,
1613
1647
  automatic: !0
1614
1648
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1615
- }, K(n)));
1649
+ }, G(n)));
1616
1650
  }
1617
1651
  resyncThinkingSession() {
1618
1652
  this.state.sessionId ? this.send({
@@ -1629,15 +1663,15 @@ class Nt {
1629
1663
  if (!s || !n || !r)
1630
1664
  return;
1631
1665
  const a = r === "execute_code", l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1632
- if (!a && !l || !Lr(o)) {
1666
+ if (!a && !l || !qr(o)) {
1633
1667
  this.setToolMessageLoading(n, !1), this.send({
1634
1668
  type: "tool.result",
1635
1669
  sessionId: s,
1636
1670
  callId: n,
1637
1671
  toolName: r,
1638
1672
  summary: i,
1639
- rawInput: _(o),
1640
- rawOutput: _({
1673
+ rawInput: k(o),
1674
+ rawOutput: k({
1641
1675
  ok: !1,
1642
1676
  toolName: r,
1643
1677
  error: `Unsupported browser tool: ${r}`
@@ -1652,7 +1686,7 @@ class Nt {
1652
1686
  callId: n,
1653
1687
  toolName: r,
1654
1688
  summary: i,
1655
- rawInput: _(o),
1689
+ rawInput: k(o),
1656
1690
  rawOutput: {
1657
1691
  ok: !1,
1658
1692
  toolName: r,
@@ -1668,7 +1702,7 @@ class Nt {
1668
1702
  callId: n,
1669
1703
  toolName: r,
1670
1704
  summary: i,
1671
- rawInput: _(o),
1705
+ rawInput: k(o),
1672
1706
  rawOutput: null
1673
1707
  },
1674
1708
  startedAtMs: Date.now(),
@@ -1676,9 +1710,9 @@ class Nt {
1676
1710
  startedAtOrigin: location.origin
1677
1711
  }), this.installSessionBrowserApis();
1678
1712
  let c = null, h;
1679
- c = await this.executeRuntimeHelper(), h = await Tt(
1713
+ c = await this.executeRuntimeHelper(), h = await wt(
1680
1714
  o,
1681
- mn(e.runtimeContext, this.options.backendUrl)
1715
+ yn(e.runtimeContext, this.options.backendUrl)
1682
1716
  ).catch((p) => ({
1683
1717
  ok: !1,
1684
1718
  exception: {
@@ -1690,12 +1724,12 @@ class Nt {
1690
1724
  callId: n,
1691
1725
  toolName: r,
1692
1726
  summary: o.summary,
1693
- rawInput: _(o),
1694
- rawOutput: _(xn(h, c))
1695
- }), br(this.options.clientId, this.activeBrowserToolCalls.values());
1727
+ rawInput: k(o),
1728
+ rawOutput: k(Ln(h, c))
1729
+ }), Cr(this.options.clientId, this.activeBrowserToolCalls.values());
1696
1730
  }
1697
1731
  setToolMessageLoading(e, s) {
1698
- const n = Zn(
1732
+ const n = er(
1699
1733
  this.state.messages,
1700
1734
  e,
1701
1735
  s
@@ -1706,33 +1740,33 @@ class Nt {
1706
1740
  if (this.pageLifecycleCleanup)
1707
1741
  return;
1708
1742
  const e = () => {
1709
- Kt(this.options.clientId, this.activeBrowserToolCalls.values());
1743
+ Gt(this.options.clientId, this.activeBrowserToolCalls.values());
1710
1744
  };
1711
1745
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
1712
1746
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
1713
1747
  };
1714
1748
  }
1715
1749
  installSessionBrowserApis() {
1716
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = on();
1750
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = an();
1717
1751
  }
1718
1752
  cleanupSessionBrowserApis() {
1719
- this.sessionBrowserApisCleanup && (gn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
1753
+ this.sessionBrowserApisCleanup && (fn(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
1720
1754
  }
1721
1755
  async executeRuntimeHelper() {
1722
1756
  if (!this.runtimeHelperJavascript?.trim())
1723
1757
  return null;
1724
- const e = await Tt({
1758
+ const e = await wt({
1725
1759
  javascript: this.runtimeHelperJavascript
1726
1760
  });
1727
- return e.ok === !1 ? Ln(e) : null;
1761
+ return e.ok === !1 ? qn(e) : null;
1728
1762
  }
1729
1763
  enableNetworkCapture() {
1730
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Zs((e) => {
1731
- Fr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
1764
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = en((e) => {
1765
+ $r(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
1732
1766
  }));
1733
1767
  }
1734
1768
  enqueueNetworkEvent(e) {
1735
- this.queuedNetworkEvents.length >= $s || (this.queuedNetworkEvents.push(jr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1769
+ this.queuedNetworkEvents.length >= zs || (this.queuedNetworkEvents.push(Fr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1736
1770
  this.networkBatchTimer = null;
1737
1771
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1738
1772
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -1741,12 +1775,12 @@ class Nt {
1741
1775
  page: C(),
1742
1776
  events: s
1743
1777
  });
1744
- }, Fs)));
1778
+ }, $s)));
1745
1779
  }
1746
1780
  scheduleReconnect() {
1747
1781
  if (this.reconnectTimer !== null || this.state.status === "closed")
1748
1782
  return;
1749
- const e = Ys(this.reconnectAttempts);
1783
+ const e = Qs(this.reconnectAttempts);
1750
1784
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1751
1785
  this.reconnectTimer = null, this.connect().catch((s) => {
1752
1786
  M("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -1762,8 +1796,8 @@ class Nt {
1762
1796
  const e = this.socket;
1763
1797
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1764
1798
  this.socket === e && (M("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
1765
- }, Os));
1766
- }, vs);
1799
+ }, Ns));
1800
+ }, Os);
1767
1801
  }
1768
1802
  stopHeartbeat() {
1769
1803
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1789,7 +1823,7 @@ class Nt {
1789
1823
  ...e,
1790
1824
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1791
1825
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1792
- }, Rr(this.options.clientId, this.state), this.emit("state", this.getState()), ke("state", this.state.status, {
1826
+ }, Er(this.options.clientId, this.state), this.emit("state", this.getState()), ke("state", this.state.status, {
1793
1827
  status: this.state.status,
1794
1828
  sessionId: this.state.sessionId,
1795
1829
  messageCount: this.state.messages.length,
@@ -1809,20 +1843,20 @@ class Nt {
1809
1843
  this.state.isThinking && this.activeClientMessageId ? this.browserConnectionInterruptedClientMessageIds.add(this.activeClientMessageId) : this.pendingClientMessageId && this.browserConnectionInterruptedClientMessageIds.add(this.pendingClientMessageId);
1810
1844
  }
1811
1845
  getRunRecoveryExhaustedErrorMessage(e) {
1812
- return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? Ws : Hs;
1846
+ return e && this.browserConnectionInterruptedClientMessageIds.has(e) ? js : Ws;
1813
1847
  }
1814
1848
  emit(e, s) {
1815
1849
  this.listeners[e]?.forEach((r) => r(s));
1816
1850
  }
1817
1851
  }
1818
- const Ue = /* @__PURE__ */ new WeakMap();
1819
- function Zs(t) {
1820
- const e = window.__plunoProductAgentNetworkCapture ?? en();
1852
+ const Pe = /* @__PURE__ */ new WeakMap();
1853
+ function en(t) {
1854
+ const e = window.__plunoProductAgentNetworkCapture ?? tn();
1821
1855
  return e.subscribers.add(t), () => {
1822
1856
  e.subscribers.delete(t), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
1823
1857
  };
1824
1858
  }
1825
- function en() {
1859
+ function tn() {
1826
1860
  const t = /* @__PURE__ */ new Set(), e = (w) => {
1827
1861
  t.forEach((y) => {
1828
1862
  try {
@@ -1839,22 +1873,22 @@ function en() {
1839
1873
  throw m;
1840
1874
  }
1841
1875
  try {
1842
- const m = y instanceof Request ? y : null, T = Br(y, m), f = Vt(u?.headers ?? m?.headers);
1843
- if (!L(T, f, u?.body)) {
1844
- const j = {
1845
- requestId: Oe("fetch"),
1846
- url: P(T, _e),
1876
+ const m = y instanceof Request ? y : null, T = Br(y, m), f = Yt(u?.headers ?? m?.headers);
1877
+ if (!q(T, f, u?.body)) {
1878
+ const F = {
1879
+ requestId: Ne("fetch"),
1880
+ url: P(T, Ue),
1847
1881
  method: (u?.method ?? m?.method ?? "GET").toUpperCase(),
1848
1882
  requestHeaders: f,
1849
- requestBody: Ct(u?.body),
1883
+ requestBody: _t(u?.body),
1850
1884
  resourceType: "fetch",
1851
1885
  startedAt: new Date(d).toISOString()
1852
1886
  };
1853
1887
  g.then(
1854
1888
  (U) => {
1855
- qr(U, j, d, e).catch(() => {
1889
+ Hr(U, F, d, e).catch(() => {
1856
1890
  e({
1857
- ...j,
1891
+ ...F,
1858
1892
  responseStatus: U.status,
1859
1893
  durationMs: Date.now() - d
1860
1894
  });
@@ -1862,7 +1896,7 @@ function en() {
1862
1896
  },
1863
1897
  (U) => {
1864
1898
  e({
1865
- ...j,
1899
+ ...F,
1866
1900
  errorText: P(U instanceof Error ? U.message : String(U)),
1867
1901
  durationMs: Date.now() - d
1868
1902
  });
@@ -1874,27 +1908,27 @@ function en() {
1874
1908
  return g;
1875
1909
  }, a = function(y, u, d, g, m) {
1876
1910
  const T = n.call(this, y, u, d ?? !0, g ?? void 0, m ?? void 0), f = typeof u == "string" ? u : u.toString();
1877
- return Ue.set(this, {
1878
- requestId: Oe("xhr"),
1911
+ return Pe.set(this, {
1912
+ requestId: Ne("xhr"),
1879
1913
  method: String(y ?? "GET").toUpperCase(),
1880
- url: P(f, _e),
1914
+ url: P(f, Ue),
1881
1915
  requestHeaders: {},
1882
1916
  startedAtMs: Date.now(),
1883
1917
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1884
- excluded: L(f)
1918
+ excluded: q(f)
1885
1919
  }), T;
1886
1920
  }, l = function(y, u) {
1887
- const d = r.call(this, y, u), g = Ue.get(this);
1888
- return g && Object.keys(g.requestHeaders).length < Je && (g.requestHeaders[y] = Ze(y, u), g.excluded = g.excluded || L(g.url, g.requestHeaders)), d;
1921
+ const d = r.call(this, y, u), g = Pe.get(this);
1922
+ return g && Object.keys(g.requestHeaders).length < Ve && (g.requestHeaders[y] = et(y, u), g.excluded = g.excluded || q(g.url, g.requestHeaders)), d;
1889
1923
  }, c = function(y) {
1890
1924
  try {
1891
- const u = Ue.get(this);
1892
- u && (u.excluded = u.excluded || L(u.url, u.requestHeaders, y), u.requestBody = Ct(y), u.excluded || this.addEventListener(
1925
+ const u = Pe.get(this);
1926
+ u && (u.excluded = u.excluded || q(u.url, u.requestHeaders, y), u.requestBody = _t(y), u.excluded || this.addEventListener(
1893
1927
  "loadend",
1894
1928
  () => {
1895
1929
  queueMicrotask(() => {
1896
1930
  try {
1897
- const d = zr(this.getAllResponseHeaders());
1931
+ const d = Kr(this.getAllResponseHeaders());
1898
1932
  e({
1899
1933
  requestId: u.requestId,
1900
1934
  url: u.url,
@@ -1904,7 +1938,7 @@ function en() {
1904
1938
  resourceType: "xhr",
1905
1939
  responseStatus: this.status,
1906
1940
  responseHeaders: d,
1907
- responseBody: Wr(this, d),
1941
+ responseBody: jr(this, d),
1908
1942
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1909
1943
  startedAt: u.startedAt,
1910
1944
  durationMs: Date.now() - u.startedAtMs
@@ -1941,12 +1975,12 @@ function en() {
1941
1975
  h = new PerformanceObserver((w) => {
1942
1976
  for (const y of w.getEntries()) {
1943
1977
  const u = y;
1944
- if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || L(u.name))
1978
+ if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || q(u.name))
1945
1979
  continue;
1946
1980
  const d = performance.timeOrigin + u.startTime;
1947
1981
  e({
1948
- requestId: Oe("resource"),
1949
- url: P(u.name, _e),
1982
+ requestId: Ne("resource"),
1983
+ url: P(u.name, Ue),
1950
1984
  method: "GET",
1951
1985
  resourceType: "resource",
1952
1986
  responseStatus: u.responseStatus,
@@ -1996,17 +2030,17 @@ function M(t, e, s) {
1996
2030
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1997
2031
  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 }));
1998
2032
  }
1999
- function It(t) {
2033
+ function Tt(t) {
2000
2034
  const e = typeof t == "function" ? t() : t;
2001
2035
  return e && Object.keys(e).length > 0 ? e : void 0;
2002
2036
  }
2003
- function tn(t) {
2037
+ function sn(t) {
2004
2038
  return 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";
2005
2039
  }
2006
- function sn(t) {
2040
+ function nn(t) {
2007
2041
  return t.type === "run.steered" || t.type === "run.ack" || 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";
2008
2042
  }
2009
- function Pe(t) {
2043
+ function De(t) {
2010
2044
  if (typeof t.sessionId == "string")
2011
2045
  return t.sessionId;
2012
2046
  if (t.session && typeof t.session == "object") {
@@ -2021,31 +2055,31 @@ function Pe(t) {
2021
2055
  }
2022
2056
  return null;
2023
2057
  }
2024
- const nn = 5e3, rn = 12e4;
2025
- function on() {
2058
+ const rn = 5e3, on = 12e4;
2059
+ function an() {
2026
2060
  const t = [
2027
- ln(),
2028
- an()
2061
+ cn(),
2062
+ ln()
2029
2063
  ].filter((e) => typeof e == "function");
2030
2064
  return () => {
2031
2065
  for (const e of t.reverse())
2032
2066
  e();
2033
2067
  };
2034
2068
  }
2035
- function an() {
2036
- return _t(globalThis, "getPageSnapshot", async () => Ve());
2037
- }
2038
2069
  function ln() {
2039
- return _t(globalThis, "pageImages", {
2040
- inspectImage: async (e, s) => await cn(e, s)
2070
+ return Ut(globalThis, "getPageSnapshot", async () => Ye());
2071
+ }
2072
+ function cn() {
2073
+ return Ut(globalThis, "pageImages", {
2074
+ inspectImage: async (e, s) => await un(e, s)
2041
2075
  });
2042
2076
  }
2043
- async function cn(t, e = {}) {
2044
- const s = pn(e.name), n = await un(t);
2077
+ async function un(t, e = {}) {
2078
+ const s = gn(e.name), n = await dn(t);
2045
2079
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
2046
2080
  type: "pluno.pageImages.inspectImage",
2047
2081
  imageAttached: !1,
2048
- imageAttachmentError: vt
2082
+ imageAttachmentError: Ot
2049
2083
  } : {
2050
2084
  type: "pluno.pageImages.inspectImage",
2051
2085
  imageAttached: !0,
@@ -2059,15 +2093,15 @@ async function cn(t, e = {}) {
2059
2093
  imageAttachmentError: n.error
2060
2094
  };
2061
2095
  }
2062
- async function un(t) {
2063
- 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: vt } : {
2096
+ async function dn(t) {
2097
+ 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: Ot } : {
2064
2098
  ok: !0,
2065
2099
  mimeType: t.type,
2066
2100
  sizeBytes: t.size,
2067
- dataUrl: await fn(t)
2068
- } : { 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." } : dn(t);
2101
+ dataUrl: await mn(t)
2102
+ } : { 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." } : hn(t);
2069
2103
  }
2070
- function dn(t) {
2104
+ function hn(t) {
2071
2105
  if (!t.startsWith("data:") || !t.includes(","))
2072
2106
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
2073
2107
  const [e, s] = t.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
@@ -2078,7 +2112,7 @@ function dn(t) {
2078
2112
  const i = s.replace(/[ \t\r\n\f]+/g, "");
2079
2113
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
2080
2114
  return { ok: !1, error: "Page image data URL has invalid base64." };
2081
- const o = hn(i);
2115
+ const o = pn(i);
2082
2116
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
2083
2117
  ok: !0,
2084
2118
  mimeType: r,
@@ -2086,22 +2120,22 @@ function dn(t) {
2086
2120
  dataUrl: `data:${r};base64,${i}`
2087
2121
  };
2088
2122
  }
2089
- function hn(t) {
2123
+ function pn(t) {
2090
2124
  if (t.length === 0 || t.length % 4 !== 0)
2091
2125
  return null;
2092
2126
  const e = t.length - t.replace(/=+$/, "").length;
2093
2127
  return e > 2 ? null : t.length / 4 * 3 - e;
2094
2128
  }
2095
- function pn(t) {
2129
+ function gn(t) {
2096
2130
  return (typeof t == "string" ? t.trim() : "") || "Page image";
2097
2131
  }
2098
- function gn(t) {
2132
+ function fn(t) {
2099
2133
  try {
2100
2134
  t();
2101
2135
  } catch {
2102
2136
  }
2103
2137
  }
2104
- function fn(t) {
2138
+ function mn(t) {
2105
2139
  return new Promise((e, s) => {
2106
2140
  const n = new FileReader();
2107
2141
  n.onload = () => {
@@ -2113,9 +2147,9 @@ function fn(t) {
2113
2147
  }, n.onerror = () => s(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(t);
2114
2148
  });
2115
2149
  }
2116
- async function Tt(t, e) {
2150
+ async function wt(t, e) {
2117
2151
  const s = Object.getPrototypeOf(async function() {
2118
- }).constructor, n = t.timeoutMs ?? nn, r = Date.now(), i = [];
2152
+ }).constructor, n = t.timeoutMs ?? rn, r = Date.now(), i = [];
2119
2153
  let o;
2120
2154
  const a = {
2121
2155
  log: console.log,
@@ -2133,7 +2167,7 @@ async function Tt(t, e) {
2133
2167
  o = window.setTimeout(() => p(c), n);
2134
2168
  })
2135
2169
  ]);
2136
- return h === c ? yn(n) : {
2170
+ return h === c ? In(n) : {
2137
2171
  ok: !0,
2138
2172
  result: h,
2139
2173
  console: i,
@@ -2162,7 +2196,7 @@ async function Tt(t, e) {
2162
2196
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
2163
2197
  }
2164
2198
  }
2165
- function mn(t, e) {
2199
+ function yn(t, e) {
2166
2200
  if (!t || typeof t != "object")
2167
2201
  return;
2168
2202
  const s = t.sandboxFilesToken;
@@ -2172,7 +2206,7 @@ function mn(t, e) {
2172
2206
  const r = () => {
2173
2207
  if (!n)
2174
2208
  throw new Error("sandboxFiles is only available during browser-code execution");
2175
- }, i = async (a, l) => await bs(`${e.replace(/\/$/, "")}${a}`, l);
2209
+ }, i = async (a, l) => await Cs(`${e.replace(/\/$/, "")}${a}`, l);
2176
2210
  return {
2177
2211
  value: Object.freeze({
2178
2212
  upload: async (a) => {
@@ -2206,7 +2240,7 @@ function mn(t, e) {
2206
2240
  }
2207
2241
  };
2208
2242
  }
2209
- function yn(t) {
2243
+ function In(t) {
2210
2244
  return {
2211
2245
  ok: !1,
2212
2246
  exception: {
@@ -2220,10 +2254,10 @@ function yn(t) {
2220
2254
  }
2221
2255
  };
2222
2256
  }
2223
- function In(t) {
2257
+ function Tn(t) {
2224
2258
  return t.replace(/\/+$/, "");
2225
2259
  }
2226
- function Tn(t) {
2260
+ function wn(t) {
2227
2261
  const e = {
2228
2262
  sidepanel: "extension_sidepanel",
2229
2263
  browser_extension_page_ui: "extension_widget",
@@ -2235,18 +2269,18 @@ function Tn(t) {
2235
2269
  };
2236
2270
  return t && t in e ? e[t] : t ?? "embedded_custom_ui";
2237
2271
  }
2238
- function wn(t) {
2272
+ function Sn(t) {
2239
2273
  return t === "pluno" ? "scheduled_continuation" : t ?? "user";
2240
2274
  }
2241
- function Sn(t, e = location.origin) {
2275
+ function Mn(t, e = location.origin) {
2242
2276
  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;
2243
2277
  }
2244
- function Mn(t) {
2278
+ function An(t) {
2245
2279
  const e = new URL("/api/product-agent/embed/ws", t);
2246
2280
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
2247
2281
  }
2248
2282
  function C() {
2249
- const t = qt();
2283
+ const t = Ht();
2250
2284
  return {
2251
2285
  url: location.href,
2252
2286
  title: document.title,
@@ -2254,21 +2288,21 @@ function C() {
2254
2288
  ...t ? { plunoProductAgentUi: t } : {}
2255
2289
  };
2256
2290
  }
2257
- function An() {
2291
+ function Rn() {
2258
2292
  return {
2259
2293
  pageUrl: location.href,
2260
2294
  pageTitle: document.title,
2261
- htmlContent: Ve()
2295
+ htmlContent: Ye()
2262
2296
  };
2263
2297
  }
2264
- function Rn(t) {
2265
- return le.add(t), se || (se = En()), () => {
2266
- le.delete(t), le.size === 0 && (se?.(), se = null);
2298
+ function En(t) {
2299
+ return ce.add(t), ne || (ne = bn()), () => {
2300
+ ce.delete(t), ce.size === 0 && (ne?.(), ne = null);
2267
2301
  };
2268
2302
  }
2269
- function En() {
2303
+ function bn() {
2270
2304
  const t = () => {
2271
- for (const i of Array.from(le))
2305
+ for (const i of Array.from(ce))
2272
2306
  i();
2273
2307
  }, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
2274
2308
  const o = e(...i);
@@ -2281,38 +2315,38 @@ function En() {
2281
2315
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", t), window.removeEventListener("hashchange", t);
2282
2316
  };
2283
2317
  }
2284
- function ne() {
2285
- return qt()?.surface === "browser_extension_sdk_preview";
2318
+ function re() {
2319
+ return Ht()?.surface === "browser_extension_sdk_preview";
2286
2320
  }
2287
- function Ve() {
2321
+ function Ye() {
2288
2322
  if (!document.body)
2289
2323
  return "";
2290
2324
  const t = [], e = [], s = (d, g) => {
2291
- const m = H(g);
2325
+ const m = W(g);
2292
2326
  !m || e.includes(m) || (t.push([d, m]), e.push(m));
2293
2327
  };
2294
2328
  s("Selected text", window.getSelection()?.toString() ?? "");
2295
2329
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
2296
- (d) => xt(d) && !d.parentElement?.closest(n)
2330
+ (d) => Lt(d) && !d.parentElement?.closest(n)
2297
2331
  );
2298
2332
  for (const d of r.slice(0, 3))
2299
- s("Active overlay", De(X(d), e));
2300
- const i = bn(), o = i ? De(X(i), e) : "";
2301
- s("Main page content", o), s("Additional visible page text", De(X(document.body), e));
2333
+ s("Active overlay", ve(J(d), e));
2334
+ const i = Cn(), o = i ? ve(J(i), e) : "";
2335
+ s("Main page content", o), s("Additional visible page text", ve(J(document.body), e));
2302
2336
  const a = t.map(([d, g]) => `${d}:
2303
2337
  ${g}`).join(`
2304
2338
 
2305
- `).trim().slice(0, 12e3), l = Cn(r, i).trim(), c = `Simplified DOM outline:
2339
+ `).trim().slice(0, 12e3), l = _n(r, i).trim(), c = `Simplified DOM outline:
2306
2340
  `, h = `
2307
2341
 
2308
2342
  Visible page text:
2309
2343
  `, p = 12e3 - c.length - h.length, w = Math.min(a.length, 7900), y = l.slice(0, p - w), u = a.slice(0, p - y.length);
2310
2344
  return `${c}${y}${h}${u}`;
2311
2345
  }
2312
- function X(t) {
2346
+ function J(t) {
2313
2347
  return t.innerText ?? t.textContent ?? "";
2314
2348
  }
2315
- function H(t) {
2349
+ function W(t) {
2316
2350
  return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
2317
2351
  `).split(`
2318
2352
  `).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
@@ -2320,20 +2354,20 @@ function H(t) {
2320
2354
 
2321
2355
  `).trim();
2322
2356
  }
2323
- function De(t, e) {
2324
- let s = H(t);
2357
+ function ve(t, e) {
2358
+ let s = W(t);
2325
2359
  for (const n of e)
2326
2360
  s = s.replace(n, "");
2327
- return H(s);
2361
+ return W(s);
2328
2362
  }
2329
- function xt(t) {
2363
+ function Lt(t) {
2330
2364
  const e = window.getComputedStyle(t);
2331
2365
  return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
2332
2366
  }
2333
- function bn() {
2334
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(xt).sort((t, e) => X(e).length - X(t).length)[0] ?? null;
2367
+ function Cn() {
2368
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Lt).sort((t, e) => J(e).length - J(t).length)[0] ?? null;
2335
2369
  }
2336
- function Cn(t, e) {
2370
+ function _n(t, e) {
2337
2371
  const s = /* @__PURE__ */ new Set([
2338
2372
  "main",
2339
2373
  "nav",
@@ -2422,68 +2456,68 @@ function Cn(t, e) {
2422
2456
  }, d = (f) => {
2423
2457
  const R = f.getAttribute("data-testid") || f.getAttribute("data-test") || f.getAttribute("data-qa") || f.getAttribute("data-cy") || "";
2424
2458
  return `${f.tagName.toLowerCase()}|${u(f)}|${R}`;
2425
- }, g = (f, R, j) => {
2426
- const U = (A, fe) => {
2427
- const b = A.tagName.toLowerCase(), me = window.getComputedStyle(A), Q = h.has(A);
2428
- if (y >= 1e3 && !Q || j.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || me.display === "none" || me.visibility === "hidden")
2459
+ }, g = (f, R, F) => {
2460
+ const U = (A, me) => {
2461
+ const b = A.tagName.toLowerCase(), ye = window.getComputedStyle(A), Z = h.has(A);
2462
+ if (y >= 1e3 && !Z || F.has(A) || i.has(b) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ye.display === "none" || ye.visibility === "hidden")
2429
2463
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
2430
2464
  y += 1;
2431
- const et = u(A), Z = Bt(A), rs = a.has(et) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), ye = Array.from(A.children).filter((I) => I instanceof HTMLElement), ee = /* @__PURE__ */ new Map();
2432
- for (const I of ye) {
2465
+ const tt = u(A), ee = Bt(A), is = a.has(tt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(b) || b === "a" && A.hasAttribute("href"), Ie = Array.from(A.children).filter((I) => I instanceof HTMLElement), te = /* @__PURE__ */ new Map();
2466
+ for (const I of Ie) {
2433
2467
  const S = d(I);
2434
- ee.set(S, (ee.get(S) ?? 0) + 1);
2468
+ te.set(S, (te.get(S) ?? 0) + 1);
2435
2469
  }
2436
- const Ie = /* @__PURE__ */ new Map(), tt = /* @__PURE__ */ new Map();
2437
- for (const I of ye) {
2438
- const S = d(I), v = tt.get(S) ?? 0;
2439
- tt.set(S, v + 1), (ee.get(S) ?? 0) > 8 && v >= 6 && !h.has(I) && Ie.set(S, (Ie.get(S) ?? 0) + 1);
2470
+ const Te = /* @__PURE__ */ new Map(), st = /* @__PURE__ */ new Map();
2471
+ for (const I of Ie) {
2472
+ const S = d(I), v = st.get(S) ?? 0;
2473
+ st.set(S, v + 1), (te.get(S) ?? 0) > 8 && v >= 6 && !h.has(I) && Te.set(S, (Te.get(S) ?? 0) + 1);
2440
2474
  }
2441
- const st = /* @__PURE__ */ new Map(), nt = /* @__PURE__ */ new Set(), Te = [], rt = [];
2442
- for (const I of ye) {
2443
- const S = d(I), v = ee.get(S) ?? 0, at = st.get(S) ?? 0;
2444
- if (st.set(S, at + 1), v > 8 && at >= 6 && !h.has(I)) {
2445
- nt.has(S) || (Te.push([`… ${Ie.get(S) ?? 0} similar siblings omitted`]), nt.add(S));
2475
+ const nt = /* @__PURE__ */ new Map(), rt = /* @__PURE__ */ new Set(), we = [], it = [];
2476
+ for (const I of Ie) {
2477
+ const S = d(I), v = te.get(S) ?? 0, lt = nt.get(S) ?? 0;
2478
+ if (nt.set(S, lt + 1), v > 8 && lt >= 6 && !h.has(I)) {
2479
+ rt.has(S) || (we.push([`… ${Te.get(S) ?? 0} similar siblings omitted`]), rt.add(S));
2446
2480
  continue;
2447
2481
  }
2448
- const lt = U(I, fe);
2449
- rt.push(lt), Te.push(lt.lines);
2482
+ const ct = U(I, me);
2483
+ it.push(ct), we.push(ct.lines);
2450
2484
  }
2451
- const we = [];
2485
+ const Se = [];
2452
2486
  if (A.shadowRoot)
2453
2487
  for (const I of Array.from(A.shadowRoot.children))
2454
- I instanceof HTMLElement && we.push(U(I, fe + 1));
2455
- const te = [...rt, ...we], Se = Z.length > 0 || rs || te.some((I) => I.hasUsefulContent), it = H(
2456
- [Z, ...te.map((I) => I.textPreview)].filter(Boolean).join(" ")
2457
- ).slice(0, 180), is = A.hasAttribute("contenteditable") && (Z.length > 0 || !A.querySelector("[contenteditable]")), ot = c.some((I) => A.hasAttribute(I)) || !!et || is, Me = (A.getClientRects().length > 0 || me.display === "contents") && (s.has(b) || ot || Q) && (Se || Q) && (!r.has(b) || Se || ot || Q), Ae = Me ? 1 : 0, F = [];
2458
- if (Me) {
2459
- const I = te.some((v) => v.containsTextElement), S = n.has(b) && !I ? it : Z;
2460
- F.push(Lt(A, l, o, S.slice(0, 180)));
2488
+ I instanceof HTMLElement && Se.push(U(I, me + 1));
2489
+ const se = [...it, ...Se], Me = ee.length > 0 || is || se.some((I) => I.hasUsefulContent), ot = W(
2490
+ [ee, ...se.map((I) => I.textPreview)].filter(Boolean).join(" ")
2491
+ ).slice(0, 180), os = A.hasAttribute("contenteditable") && (ee.length > 0 || !A.querySelector("[contenteditable]")), at = c.some((I) => A.hasAttribute(I)) || !!tt || os, Ae = (A.getClientRects().length > 0 || ye.display === "contents") && (s.has(b) || at || Z) && (Me || Z) && (!r.has(b) || Me || at || Z), Re = Ae ? 1 : 0, $ = [];
2492
+ if (Ae) {
2493
+ const I = se.some((v) => v.containsTextElement), S = n.has(b) && !I ? ot : ee;
2494
+ $.push(qt(A, l, o, S.slice(0, 180)));
2461
2495
  }
2462
- for (const I of Te)
2463
- F.push(...re(I, Ae));
2464
- const Re = we.flatMap((I) => I.lines);
2465
- if (Re.length > 0) {
2466
- const I = Re.slice(0, 20);
2467
- Re.length > I.length && I.push("… shadow DOM omitted");
2496
+ for (const I of we)
2497
+ $.push(...ie(I, Re));
2498
+ const Ee = Se.flatMap((I) => I.lines);
2499
+ if (Ee.length > 0) {
2500
+ const I = Ee.slice(0, 20);
2501
+ Ee.length > I.length && I.push("… shadow DOM omitted");
2468
2502
  const S = b.includes("tooltip") || b.includes("popper") || b.includes("loader");
2469
- if (fe < 2 && !S) {
2470
- const v = Me ? "#shadow-root" : `${b} #shadow-root`;
2471
- F.push(...re([v, ...re(I, 1)], Ae));
2503
+ if (me < 2 && !S) {
2504
+ const v = Ae ? "#shadow-root" : `${b} #shadow-root`;
2505
+ $.push(...ie([v, ...ie(I, 1)], Re));
2472
2506
  } else
2473
- F.push(...re(I, Ae));
2507
+ $.push(...ie(I, Re));
2474
2508
  }
2475
2509
  return {
2476
- lines: F,
2477
- hasUsefulContent: Se,
2478
- textPreview: it,
2479
- containsTextElement: n.has(b) || te.some((I) => I.containsTextElement)
2510
+ lines: $,
2511
+ hasUsefulContent: Me,
2512
+ textPreview: ot,
2513
+ containsTextElement: n.has(b) || se.some((I) => I.containsTextElement)
2480
2514
  };
2481
2515
  };
2482
2516
  return [`--- ${R} ---`, ...U(f, 0).lines].join(`
2483
2517
  `);
2484
- }, m = [], T = H(window.getSelection()?.toString() ?? "");
2518
+ }, m = [], T = W(window.getSelection()?.toString() ?? "");
2485
2519
  T && m.push(`--- selected text ---
2486
- ${JSON.stringify(T)}`), p.length > 0 && m.push(_n(p, s, l, o));
2520
+ ${JSON.stringify(T)}`), p.length > 0 && m.push(Un(p, s, l, o));
2487
2521
  for (const f of t.slice(0, 3))
2488
2522
  m.push(g(f, "active overlay DOM", /* @__PURE__ */ new Set()));
2489
2523
  if (e && m.push(g(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -2494,11 +2528,11 @@ ${JSON.stringify(T)}`), p.length > 0 && m.push(_n(p, s, l, o));
2494
2528
 
2495
2529
  `);
2496
2530
  }
2497
- function Lt(t, e, s, n) {
2531
+ function qt(t, e, s, n) {
2498
2532
  const r = t.tagName.toLowerCase();
2499
2533
  let i = r;
2500
2534
  const o = t.getAttribute("id");
2501
- o && Un(o) && (i += `#${o}`);
2535
+ o && Pn(o) && (i += `#${o}`);
2502
2536
  for (const a of e) {
2503
2537
  const l = t.getAttribute(a);
2504
2538
  l && l.length <= 160 && (a !== "role" || !s.has(l)) && (i += `[${a}=${JSON.stringify(l)}]`);
@@ -2532,7 +2566,7 @@ function kn() {
2532
2566
  n = n.shadowRoot.activeElement;
2533
2567
  n !== document.body && n !== document.documentElement && s(n, "focused");
2534
2568
  const r = window.getSelection();
2535
- r && !r.isCollapsed && (s(wt(r.anchorNode), "selected text"), s(wt(r.focusNode), "selected text"));
2569
+ r && !r.isCollapsed && (s(St(r.anchorNode), "selected text"), s(St(r.focusNode), "selected text"));
2536
2570
  const i = [
2537
2571
  ["[aria-selected='true']", "selected"],
2538
2572
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -2554,7 +2588,7 @@ function kn() {
2554
2588
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
2555
2589
  };
2556
2590
  }
2557
- function _n(t, e, s, n) {
2591
+ function Un(t, e, s, n) {
2558
2592
  const r = ["--- active/current elements ---"];
2559
2593
  for (const i of t) {
2560
2594
  const o = [];
@@ -2565,7 +2599,7 @@ function _n(t, e, s, n) {
2565
2599
  const p = a.getRootNode();
2566
2600
  a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
2567
2601
  }
2568
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h, p) => Lt(
2602
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((h, p) => qt(
2569
2603
  h,
2570
2604
  s,
2571
2605
  n,
@@ -2576,26 +2610,26 @@ function _n(t, e, s, n) {
2576
2610
  return r.join(`
2577
2611
  `);
2578
2612
  }
2579
- function wt(t) {
2613
+ function St(t) {
2580
2614
  return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
2581
2615
  }
2582
- function re(t, e) {
2616
+ function ie(t, e) {
2583
2617
  if (e === 0)
2584
2618
  return t;
2585
2619
  const s = " ".repeat(e);
2586
2620
  return t.map((n) => `${s}${n}`);
2587
2621
  }
2588
2622
  function Bt(t) {
2589
- return H(
2623
+ return W(
2590
2624
  Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
2591
2625
  );
2592
2626
  }
2593
- function Un(t) {
2627
+ function Pn(t) {
2594
2628
  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);
2595
2629
  }
2596
- function qt() {
2597
- const t = document.querySelector(ct);
2598
- if (!(t ?? document.querySelector(xe)))
2630
+ function Ht() {
2631
+ const t = document.querySelector(ut);
2632
+ if (!(t ?? document.querySelector(Le)))
2599
2633
  return;
2600
2634
  const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
2601
2635
  return {
@@ -2604,12 +2638,12 @@ function qt() {
2604
2638
  selectors: [
2605
2639
  {
2606
2640
  name: "widget_host",
2607
- selector: s === "browser_extension_sdk_preview" ? ct : xe,
2641
+ selector: s === "browser_extension_sdk_preview" ? ut : Le,
2608
2642
  description: "Finds Pluno's shadow-host element in the host page DOM."
2609
2643
  },
2610
2644
  {
2611
2645
  name: "widget_root",
2612
- selector: Cs,
2646
+ selector: _s,
2613
2647
  description: "Finds Pluno's widget root inside the widget host shadow root."
2614
2648
  },
2615
2649
  {
@@ -2619,13 +2653,13 @@ function qt() {
2619
2653
  },
2620
2654
  {
2621
2655
  name: "widget_timeline",
2622
- selector: _s,
2656
+ selector: Us,
2623
2657
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
2624
2658
  }
2625
2659
  ]
2626
2660
  };
2627
2661
  }
2628
- function Pn(t) {
2662
+ function Dn(t) {
2629
2663
  try {
2630
2664
  const e = JSON.parse(t);
2631
2665
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -2633,7 +2667,7 @@ function Pn(t) {
2633
2667
  return { type: "error", message: "Invalid server event" };
2634
2668
  }
2635
2669
  }
2636
- function Dn(t) {
2670
+ function vn(t) {
2637
2671
  if (typeof t != "string")
2638
2672
  return null;
2639
2673
  try {
@@ -2643,16 +2677,16 @@ function Dn(t) {
2643
2677
  return null;
2644
2678
  }
2645
2679
  }
2646
- function St(t, e) {
2680
+ function Mt(t, e) {
2647
2681
  if (!t || typeof t != "object")
2648
2682
  return [];
2649
2683
  const s = t[e];
2650
2684
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
2651
2685
  }
2652
- function vn(t) {
2686
+ function On(t) {
2653
2687
  return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
2654
2688
  }
2655
- function On(t) {
2689
+ function Nn(t) {
2656
2690
  if (!t || typeof t != "object")
2657
2691
  return null;
2658
2692
  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;
@@ -2663,13 +2697,13 @@ function On(t) {
2663
2697
  ...a !== null ? { scribbleStyle: a } : {}
2664
2698
  };
2665
2699
  }
2666
- function Nn(t) {
2700
+ function xn(t) {
2667
2701
  if (!t || typeof t != "object")
2668
2702
  return null;
2669
2703
  const e = t.javascript;
2670
2704
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
2671
2705
  }
2672
- function xn(t, e) {
2706
+ function Ln(t, e) {
2673
2707
  return e ? t && typeof t == "object" ? {
2674
2708
  ...t,
2675
2709
  helperError: e
@@ -2679,7 +2713,7 @@ function xn(t, e) {
2679
2713
  helperError: e
2680
2714
  } : t;
2681
2715
  }
2682
- function Ln(t) {
2716
+ function qn(t) {
2683
2717
  if (!t || typeof t != "object")
2684
2718
  return t;
2685
2719
  const e = t;
@@ -2692,10 +2726,10 @@ function Bn() {
2692
2726
  const s = crypto.randomUUID();
2693
2727
  return window.localStorage.setItem(t, s), s;
2694
2728
  }
2695
- function G() {
2729
+ function X() {
2696
2730
  return crypto.randomUUID();
2697
2731
  }
2698
- function qn(t) {
2732
+ function Hn(t) {
2699
2733
  if (!t || typeof t != "object")
2700
2734
  return null;
2701
2735
  const e = t, s = typeof e.id == "string" ? e.id : null;
@@ -2706,12 +2740,12 @@ function qn(t) {
2706
2740
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
2707
2741
  } : null;
2708
2742
  }
2709
- function Hn(t, e) {
2710
- return Array.isArray(t) ? Fe(
2711
- t.map((s) => Ht(s, e)).filter((s) => s !== null)
2743
+ function Wn(t, e) {
2744
+ return Array.isArray(t) ? $e(
2745
+ t.map((s) => Wt(s, e)).filter((s) => s !== null)
2712
2746
  ) : [];
2713
2747
  }
2714
- function Wn(t) {
2748
+ function jn(t) {
2715
2749
  return Array.isArray(t) ? t.flatMap((e) => {
2716
2750
  if (!e || typeof e != "object")
2717
2751
  return [];
@@ -2732,7 +2766,7 @@ function Wn(t) {
2732
2766
  ];
2733
2767
  }) : [];
2734
2768
  }
2735
- function Ht(t, e) {
2769
+ function Wt(t, e) {
2736
2770
  if (!t || typeof t != "object")
2737
2771
  return null;
2738
2772
  const s = t, n = s.data;
@@ -2746,14 +2780,15 @@ function Ht(t, e) {
2746
2780
  id: String(s.id ?? crypto.randomUUID()),
2747
2781
  role: i,
2748
2782
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
2749
- content: ps(
2750
- Xn(r.content),
2783
+ content: gs(
2784
+ Jn(r.content),
2751
2785
  e
2752
2786
  ),
2753
2787
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2754
- respondsToUserMessageId: O(r) ?? void 0,
2755
- ...k(r) ? { runId: k(r) } : {},
2756
- attachments: Gt(r.attachments, e)
2788
+ ...O(r) !== null ? { causalSequence: O(r) } : {},
2789
+ respondsToUserMessageId: N(r) ?? void 0,
2790
+ ..._(r) ? { runId: _(r) } : {},
2791
+ attachments: Xt(r.attachments, e)
2757
2792
  };
2758
2793
  return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
2759
2794
  value: r.id,
@@ -2764,52 +2799,55 @@ function Ht(t, e) {
2764
2799
  }), o;
2765
2800
  }
2766
2801
  if (r.type === "function_call_output") {
2767
- const i = Es(r.output);
2802
+ const i = bs(r.output);
2768
2803
  if (i)
2769
2804
  return {
2770
2805
  id: String(s.id ?? crypto.randomUUID()),
2771
2806
  role: "tool",
2772
2807
  content: "",
2773
2808
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2774
- respondsToUserMessageId: O(r) ?? void 0,
2775
- ...k(r) ? { runId: k(r) } : {},
2809
+ respondsToUserMessageId: N(r) ?? void 0,
2810
+ ..._(r) ? { runId: _(r) } : {},
2776
2811
  dataType: "scheduled_check_in",
2777
- toolName: Pt,
2778
- callId: ve(r) ?? void 0,
2812
+ toolName: Dt,
2813
+ callId: Oe(r) ?? void 0,
2779
2814
  scheduledCheckInAt: i
2780
2815
  };
2781
- const o = Fn(r.output);
2816
+ const o = $n(r.output);
2782
2817
  return o ? {
2783
2818
  id: String(s.id ?? crypto.randomUUID()),
2784
2819
  role: "tool",
2785
2820
  content: `Connect ${o.appName} to continue`,
2786
2821
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2787
- respondsToUserMessageId: O(r) ?? void 0,
2788
- ...k(r) ? { runId: k(r) } : {},
2822
+ ...O(r) !== null ? { causalSequence: O(r) } : {},
2823
+ respondsToUserMessageId: N(r) ?? void 0,
2824
+ ..._(r) ? { runId: _(r) } : {},
2789
2825
  dataType: "function_call_output",
2790
2826
  toolName: "authenticate_pipedream_app",
2791
- callId: ve(r) ?? void 0,
2827
+ callId: Oe(r) ?? void 0,
2792
2828
  integrationAuthRequest: o
2793
2829
  } : null;
2794
2830
  }
2795
2831
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
2796
2832
  id: String(s.id ?? crypto.randomUUID()),
2797
2833
  role: "tool",
2798
- content: r.type === "mcp_call" ? jn(r) : zn(r),
2834
+ content: r.type === "mcp_call" ? Fn(r) : Kn(r),
2799
2835
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2800
- respondsToUserMessageId: O(r) ?? void 0,
2801
- ...k(r) ? { runId: k(r) } : {},
2836
+ ...O(r) !== null ? { causalSequence: O(r) } : {},
2837
+ respondsToUserMessageId: N(r) ?? void 0,
2838
+ ..._(r) ? { runId: _(r) } : {},
2802
2839
  dataType: String(r.type),
2803
2840
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
2804
- callId: ve(r) ?? void 0,
2841
+ callId: Oe(r) ?? void 0,
2805
2842
  loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
2806
2843
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
2807
2844
  id: String(s.id ?? crypto.randomUUID()),
2808
2845
  role: "system",
2809
- content: $n(r),
2846
+ content: zn(r),
2810
2847
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
2811
- respondsToUserMessageId: O(r) ?? void 0,
2812
- ...k(r) ? { runId: k(r) } : {},
2848
+ ...O(r) !== null ? { causalSequence: O(r) } : {},
2849
+ respondsToUserMessageId: N(r) ?? void 0,
2850
+ ..._(r) ? { runId: _(r) } : {},
2813
2851
  dataType: String(r.type),
2814
2852
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
2815
2853
  ...r.type === "run_status" && r.status === "steered" ? { steered: !0 } : {},
@@ -2817,11 +2855,11 @@ function Ht(t, e) {
2817
2855
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
2818
2856
  } : null;
2819
2857
  }
2820
- function jn(t) {
2858
+ function Fn(t) {
2821
2859
  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(" ");
2822
2860
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
2823
2861
  }
2824
- function Fn(t) {
2862
+ function $n(t) {
2825
2863
  if (typeof t != "string")
2826
2864
  return null;
2827
2865
  try {
@@ -2838,10 +2876,10 @@ function Fn(t) {
2838
2876
  return null;
2839
2877
  }
2840
2878
  }
2841
- function $n(t) {
2879
+ function zn(t) {
2842
2880
  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.";
2843
2881
  }
2844
- function zn(t) {
2882
+ function Kn(t) {
2845
2883
  if (t.type === "web_search_call") {
2846
2884
  const e = t.action;
2847
2885
  if (e && typeof e == "object") {
@@ -2853,9 +2891,9 @@ function zn(t) {
2853
2891
  }
2854
2892
  return "🔎 Searching the web";
2855
2893
  }
2856
- return Kn(t);
2894
+ return Gn(t);
2857
2895
  }
2858
- function Kn(t) {
2896
+ function Gn(t) {
2859
2897
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
2860
2898
  return B(t.summary);
2861
2899
  if (typeof t.arguments == "string")
@@ -2872,7 +2910,7 @@ function B(t) {
2872
2910
  const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
2873
2911
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
2874
2912
  }
2875
- function Gn(t) {
2913
+ function Xn(t) {
2876
2914
  if (t == null)
2877
2915
  return t;
2878
2916
  if (typeof t != "object")
@@ -2887,11 +2925,14 @@ function Gn(t) {
2887
2925
  runId: typeof e.runId == "string" ? e.runId : null
2888
2926
  };
2889
2927
  }
2890
- function ve(t) {
2928
+ function Oe(t) {
2891
2929
  const e = t.callId ?? t.call_id;
2892
2930
  return typeof e == "string" && e ? e : null;
2893
2931
  }
2894
- function Xn(t) {
2932
+ function O(t) {
2933
+ return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
2934
+ }
2935
+ function Jn(t) {
2895
2936
  return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => {
2896
2937
  if (!e || typeof e != "object")
2897
2938
  return "";
@@ -2900,30 +2941,30 @@ function Xn(t) {
2900
2941
  }).filter(Boolean).join("") : "";
2901
2942
  }
2902
2943
  function Be(t, e) {
2903
- const s = jt(t, e), n = tr(
2904
- Jn(
2905
- ir(t, e),
2944
+ const s = Ft(t, e), n = sr(
2945
+ Vn(
2946
+ or(t, e),
2906
2947
  s
2907
2948
  ),
2908
2949
  s
2909
2950
  ), r = n.findIndex((o) => o.id === s.id);
2910
2951
  if (r === -1)
2911
- return Fe(
2952
+ return $e(
2912
2953
  [...n, s]
2913
2954
  );
2914
2955
  const i = [...n];
2915
- return i[r] = s, Fe(i);
2956
+ return i[r] = s, $e(i);
2916
2957
  }
2917
- function Jn(t, e) {
2958
+ function Vn(t, e) {
2918
2959
  const s = e.assistantDraftItemId;
2919
2960
  return s ? t.map(
2920
2961
  (n) => n.dataType === "assistant_draft" && n.id === s ? e : n
2921
2962
  ) : t;
2922
2963
  }
2923
- function Vn(t, e, s) {
2964
+ function Yn(t, e, s) {
2924
2965
  return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
2925
2966
  }
2926
- function Yn(t, e, s, n) {
2967
+ function Qn(t, e, s, n) {
2927
2968
  if (s === null) return t;
2928
2969
  let r = -1;
2929
2970
  for (let o = t.length - 1; o >= 0; o -= 1) {
@@ -2940,7 +2981,7 @@ function Yn(t, e, s, n) {
2940
2981
  respondsToUserMessageId: s
2941
2982
  }, i;
2942
2983
  }
2943
- function Qn(t, e) {
2984
+ function Zn(t, e) {
2944
2985
  const s = t.findIndex(
2945
2986
  (r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
2946
2987
  );
@@ -2957,12 +2998,12 @@ function Qn(t, e) {
2957
2998
  ...n[s].runId ? {} : { runId: e.runId }
2958
2999
  }, n;
2959
3000
  }
2960
- function Zn(t, e, s) {
3001
+ function er(t, e, s) {
2961
3002
  let n = !1;
2962
3003
  const r = t.map((i) => i.callId !== e || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2963
3004
  return n ? r : t;
2964
3005
  }
2965
- function er(t) {
3006
+ function tr(t) {
2966
3007
  if (t.hiddenFromTranscript === !0)
2967
3008
  return null;
2968
3009
  const e = typeof t.callId == "string" ? t.callId : null, s = typeof t.toolName == "string" ? t.toolName : null;
@@ -2973,6 +3014,7 @@ function er(t) {
2973
3014
  typeof t.summary == "string" ? t.summary : "Running browser tool"
2974
3015
  ),
2975
3016
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3017
+ ...typeof t.causalSequence == "number" ? { causalSequence: t.causalSequence } : {},
2976
3018
  respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
2977
3019
  runId: typeof t.runId == "string" ? t.runId : void 0,
2978
3020
  dataType: "function_call",
@@ -2981,25 +3023,26 @@ function er(t) {
2981
3023
  loading: !0
2982
3024
  };
2983
3025
  }
2984
- function tr(t, e) {
3026
+ function sr(t, e) {
2985
3027
  if (e.id.startsWith("transient-activity:"))
2986
3028
  return t;
2987
3029
  const s = e.toolName === "tab_lifecycle";
2988
- return !e.callId && !s ? t : t.filter(
2989
- (n) => !(n.id === `transient-activity:${e.callId}` && n.callId === e.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId && n.runId === e.runId)
2990
- );
3030
+ if (!e.callId && !s)
3031
+ return t;
3032
+ 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);
3033
+ return r === -1 ? t : t.flatMap((i, o) => n(i) ? o === r ? [e] : [] : i.id === e.id ? [] : [i]);
2991
3034
  }
2992
- function sr(t, e) {
2993
- return gs(
3035
+ function nr(t, e) {
3036
+ return fs(
2994
3037
  t,
2995
3038
  e.map(
2996
- (s) => jt(t, s)
3039
+ (s) => Ft(t, s)
2997
3040
  ),
2998
- Wt
3041
+ jt
2999
3042
  );
3000
3043
  }
3001
- function Wt(t) {
3002
- const e = J(t) ?? void 0, s = t.assistantDraftItemId, n = [
3044
+ function jt(t) {
3045
+ const e = V(t) ?? void 0, s = t.assistantDraftItemId, n = [
3003
3046
  ...t.callId ? [`call:${t.callId}`] : [],
3004
3047
  ...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
3005
3048
  ];
@@ -3010,52 +3053,52 @@ function Wt(t) {
3010
3053
  ...n.length > 0 ? { activityKeys: n } : {},
3011
3054
  ...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
3012
3055
  ...t.runId ? { runId: t.runId } : {},
3013
- isOptimistic: pe(t),
3056
+ isOptimistic: ge(t),
3014
3057
  isAssistantDraft: t.dataType === "assistant_draft",
3015
3058
  isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
3016
3059
  isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
3017
3060
  };
3018
3061
  }
3019
- function jt(t, e) {
3062
+ function Ft(t, e) {
3020
3063
  if (e.role !== "user" || !e.attachments?.length)
3021
3064
  return e;
3022
3065
  const s = t.find(
3023
- (r) => r.role === "user" && (r.id === e.id || pe(r) && Ft(r, e))
3066
+ (r) => r.role === "user" && (r.id === e.id || ge(r) && $t(r, e))
3024
3067
  );
3025
3068
  if (!s?.attachments?.length)
3026
3069
  return e;
3027
3070
  const n = e.attachments.map((r) => {
3028
- const i = nr(s.attachments ?? [], r);
3029
- return i ? rr(r, i) : r;
3071
+ const i = rr(s.attachments ?? [], r);
3072
+ return i ? ir(r, i) : r;
3030
3073
  });
3031
3074
  return { ...e, attachments: n };
3032
3075
  }
3033
- function nr(t, e) {
3076
+ function rr(t, e) {
3034
3077
  return e.id ? t.find((s) => s.id === e.id) ?? null : null;
3035
3078
  }
3036
- function rr(t, e) {
3079
+ function ir(t, e) {
3037
3080
  const { previewUrl: s } = e;
3038
3081
  return s ? { ...t, previewUrl: s } : t;
3039
3082
  }
3040
- function ir(t, e) {
3083
+ function or(t, e) {
3041
3084
  if (e.role !== "user")
3042
3085
  return t;
3043
3086
  const s = t.findIndex(
3044
- (r) => pe(r) && Ft(r, e)
3087
+ (r) => ge(r) && $t(r, e)
3045
3088
  );
3046
3089
  if (s === -1)
3047
3090
  return t;
3048
3091
  const n = [...t];
3049
3092
  return n.splice(s, 1), n;
3050
3093
  }
3051
- function Ft(t, e) {
3052
- const s = J(t), n = J(e);
3094
+ function $t(t, e) {
3095
+ const s = V(t), n = V(e);
3053
3096
  return s && n ? s === n : t.content === e.content;
3054
3097
  }
3055
- function pe(t) {
3098
+ function ge(t) {
3056
3099
  return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
3057
3100
  }
3058
- function J(t) {
3101
+ function V(t) {
3059
3102
  const e = t.clientMessageId;
3060
3103
  if (e)
3061
3104
  return e;
@@ -3064,18 +3107,18 @@ function J(t) {
3064
3107
  );
3065
3108
  return n ? t.id.slice(n.length) : null;
3066
3109
  }
3067
- function Mt(t) {
3068
- const e = $t(t);
3110
+ function At(t) {
3111
+ const e = zt(t);
3069
3112
  if (e === null)
3070
3113
  return !1;
3071
3114
  const s = t[e].id, n = t.some(
3072
- (r) => r.respondsToUserMessageId === s && qe(r)
3115
+ (r) => r.respondsToUserMessageId === s && He(r)
3073
3116
  );
3074
3117
  if (t.some((r) => r.respondsToUserMessageId === s))
3075
3118
  return n;
3076
3119
  for (let r = t.length - 1; r > e; r -= 1) {
3077
3120
  const i = t[r];
3078
- if (N(i))
3121
+ if (x(i))
3079
3122
  return !0;
3080
3123
  if (i.role === "system") {
3081
3124
  if (i.dataType === "run_error")
@@ -3086,25 +3129,25 @@ function Mt(t) {
3086
3129
  }
3087
3130
  return !1;
3088
3131
  }
3089
- function or(t) {
3090
- const e = $t(t);
3132
+ function ar(t) {
3133
+ const e = zt(t);
3091
3134
  if (e === null)
3092
- return t.some(N);
3135
+ return t.some(x);
3093
3136
  const s = t[e].id;
3094
3137
  return t.some((n) => n.respondsToUserMessageId === s) ? t.some(
3095
- (n) => n.respondsToUserMessageId === s && N(n)
3096
- ) : t.slice(e + 1).some(N);
3138
+ (n) => n.respondsToUserMessageId === s && x(n)
3139
+ ) : t.slice(e + 1).some(x);
3097
3140
  }
3098
- function $t(t) {
3141
+ function zt(t) {
3099
3142
  for (let e = t.length - 1; e >= 0; e -= 1)
3100
- if (t[e].role === "user" && !pe(t[e]))
3143
+ if (t[e].role === "user" && !ge(t[e]))
3101
3144
  return e;
3102
3145
  return null;
3103
3146
  }
3104
- function qe(t) {
3105
- return N(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3147
+ function He(t) {
3148
+ return x(t) ? !0 : t.role !== "system" ? !1 : t.dataType === "run_error" ? !0 : t.dataType === "run_status" && t.loading !== !0;
3106
3149
  }
3107
- function V(t) {
3150
+ function Y(t) {
3108
3151
  for (let e = t.length - 1; e >= 0; e -= 1) {
3109
3152
  const s = t[e];
3110
3153
  if (!s || typeof s != "object")
@@ -3118,30 +3161,30 @@ function V(t) {
3118
3161
  }
3119
3162
  return null;
3120
3163
  }
3121
- function ar(t) {
3122
- const e = V(t);
3164
+ function lr(t) {
3165
+ const e = Y(t);
3123
3166
  if (e === null)
3124
3167
  return null;
3125
- const n = q(t[e])?.page;
3168
+ const n = H(t[e])?.page;
3126
3169
  if (!n || typeof n != "object")
3127
3170
  return null;
3128
3171
  const r = n.url;
3129
3172
  return typeof r == "string" ? r : null;
3130
3173
  }
3131
- function q(t) {
3174
+ function H(t) {
3132
3175
  if (!t || typeof t != "object")
3133
3176
  return null;
3134
3177
  const e = t.data;
3135
3178
  return e && typeof e == "object" ? e : null;
3136
3179
  }
3137
- function He(t) {
3180
+ function We(t) {
3138
3181
  return t?.retryable !== !0 ? !1 : t.type === "run_error" ? !0 : t.type === "run_status" && t.status === "interrupted";
3139
3182
  }
3140
- function At(t) {
3183
+ function Rt(t) {
3141
3184
  return t?.type === "run_status" && t.status === "interrupted" && t.reason === "backend_restart";
3142
3185
  }
3143
- function lr(t, e) {
3144
- const s = V(e);
3186
+ function cr(t, e) {
3187
+ const s = Y(e);
3145
3188
  if (s === null)
3146
3189
  return !1;
3147
3190
  const n = e[s], r = n && typeof n == "object" ? n.id : null;
@@ -3149,11 +3192,11 @@ function lr(t, e) {
3149
3192
  return !1;
3150
3193
  const i = t.findIndex((o) => o.role === "user" && o.id === r);
3151
3194
  return i === -1 ? !1 : t.some((o) => o.respondsToUserMessageId === r) ? t.some(
3152
- (o) => o.respondsToUserMessageId === r && qe(o)
3153
- ) : t.slice(i + 1).some(qe);
3195
+ (o) => o.respondsToUserMessageId === r && He(o)
3196
+ ) : t.slice(i + 1).some(He);
3154
3197
  }
3155
- function We(t) {
3156
- const e = V(t);
3198
+ function je(t) {
3199
+ const e = Y(t);
3157
3200
  if (e === null)
3158
3201
  return null;
3159
3202
  const s = t[e];
@@ -3165,8 +3208,8 @@ function We(t) {
3165
3208
  const r = n.clientMessageId;
3166
3209
  return typeof r == "string" ? r : null;
3167
3210
  }
3168
- function cr(t) {
3169
- const e = V(t);
3211
+ function ur(t) {
3212
+ const e = Y(t);
3170
3213
  if (e === null)
3171
3214
  return null;
3172
3215
  for (let s = t.length - 1; s > e; s -= 1) {
@@ -3180,22 +3223,22 @@ function cr(t) {
3180
3223
  if (i.type === "message" && i.role === "assistant")
3181
3224
  return null;
3182
3225
  if (i.type === "run_error")
3183
- return i.retryable !== !0 ? null : je(t, i) ?? We(t);
3226
+ return i.retryable !== !0 ? null : Fe(t, i) ?? je(t);
3184
3227
  if (i.type === "run_status")
3185
- return i.status === "interrupted" && i.retryable === !0 ? je(t, i) ?? We(t) : null;
3228
+ return i.status === "interrupted" && i.retryable === !0 ? Fe(t, i) ?? je(t) : null;
3186
3229
  }
3187
3230
  return null;
3188
3231
  }
3189
- function je(t, e) {
3232
+ function Fe(t, e) {
3190
3233
  if (typeof e.clientMessageId == "string")
3191
3234
  return e.clientMessageId;
3192
- const s = O(e);
3235
+ const s = N(e);
3193
3236
  if (!s)
3194
3237
  return null;
3195
- const n = t.find((i) => E(i, "id") === s), r = q(n);
3238
+ const n = t.find((i) => E(i, "id") === s), r = H(n);
3196
3239
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
3197
3240
  }
3198
- function ur(t, e) {
3241
+ function dr(t, e) {
3199
3242
  let s = 0;
3200
3243
  for (const n of t) {
3201
3244
  if (!n || typeof n != "object")
@@ -3208,69 +3251,69 @@ function ur(t, e) {
3208
3251
  }
3209
3252
  return s;
3210
3253
  }
3211
- function Rt(t, e, s, n, r) {
3212
- if (!e || !dr(t))
3254
+ function Et(t, e, s, n, r) {
3255
+ if (!e || !hr(t))
3213
3256
  return !1;
3214
3257
  const i = t;
3215
- return !(He(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? O(i) !== n : r !== null && k(i) !== r));
3258
+ return !(We(i) || s !== null && typeof i.id == "string" && i.id !== s || (n !== null ? N(i) !== n : r !== null && _(i) !== r));
3216
3259
  }
3217
- function dr(t) {
3260
+ function hr(t) {
3218
3261
  if (!t || typeof t != "object")
3219
3262
  return !1;
3220
3263
  const e = t;
3221
3264
  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");
3222
3265
  }
3223
- function N(t) {
3266
+ function x(t) {
3224
3267
  return t.role === "assistant" && t.phase !== "commentary";
3225
3268
  }
3226
- function hr(t) {
3269
+ function pr(t) {
3227
3270
  if (!t || typeof t != "object")
3228
3271
  return !1;
3229
3272
  const e = t;
3230
3273
  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";
3231
3274
  }
3232
- function Fe(t) {
3233
- return t.filter((e, s) => W(e) ? !Mr(t, s) && !zt(t, s) && !wr(t, s) && !Sr(t, s) : pr(e) ? e.retryable === !0 && Tr(t, s) ? !1 : !Ir(t, s) : !0);
3275
+ function $e(t) {
3276
+ return t.filter((e, s) => j(e) ? !Ar(t, s) && !Kt(t, s) && !Sr(t, s) && !Mr(t, s) : gr(e) ? e.retryable === !0 && wr(t, s) ? !1 : !Tr(t, s) : !0);
3234
3277
  }
3235
- function pr(t) {
3278
+ function gr(t) {
3236
3279
  return t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.steered !== !0);
3237
3280
  }
3238
- function W(t) {
3281
+ function j(t) {
3239
3282
  return t.role === "system" && t.dataType === "run_status" && t.loading === !0;
3240
3283
  }
3241
- function gr(t, e, s, n) {
3284
+ function fr(t, e, s, n) {
3242
3285
  const r = t.findIndex(
3243
- (l, c) => W(l) && !zt(t, c)
3286
+ (l, c) => j(l) && !Kt(t, c)
3244
3287
  ), i = r === -1 ? null : t[r], o = e ?? i?.respondsToUserMessageId ?? null, a = o ? t.find(
3245
3288
  (l) => l.role === "user" && l.id === o
3246
3289
  ) : null;
3247
3290
  return {
3248
- clientMessageId: a ? J(a) : o ? null : n,
3291
+ clientMessageId: a ? V(a) : o ? null : n,
3249
3292
  runId: s ?? i?.runId ?? null
3250
3293
  };
3251
3294
  }
3252
- function ie(t, e, s) {
3295
+ function oe(t, e, s) {
3253
3296
  const n = new Set(
3254
3297
  t.filter(
3255
- (r) => r.role === "user" && e !== null && J(r) === e
3298
+ (r) => r.role === "user" && e !== null && V(r) === e
3256
3299
  ).map((r) => r.id)
3257
3300
  );
3258
3301
  return t.filter(
3259
- (r) => !W(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3302
+ (r) => !j(r) || (n.size > 0 ? !r.respondsToUserMessageId || !n.has(r.respondsToUserMessageId) : !s || r.runId !== s)
3260
3303
  );
3261
3304
  }
3262
- function zt(t, e) {
3305
+ function Kt(t, e) {
3263
3306
  return t.some(
3264
- (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && fr(
3307
+ (s, n) => n !== e && s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0 && s.steered !== !0) && mr(
3265
3308
  t,
3266
3309
  e,
3267
3310
  n
3268
3311
  )
3269
3312
  );
3270
3313
  }
3271
- function fr(t, e, s) {
3314
+ function mr(t, e, s) {
3272
3315
  const n = t[e], r = t[s];
3273
- if (Y(n, r))
3316
+ if (Q(n, r))
3274
3317
  return !0;
3275
3318
  if (!n.respondsToUserMessageId || r.respondsToUserMessageId || !n.runId || n.runId !== r.runId)
3276
3319
  return !1;
@@ -3279,35 +3322,35 @@ function fr(t, e, s) {
3279
3322
  return t[i].id === n.respondsToUserMessageId;
3280
3323
  return !1;
3281
3324
  }
3282
- function mr(t, e) {
3325
+ function yr(t, e) {
3283
3326
  const s = [...t].reverse().find(
3284
- (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && Et(n) && !yr(
3327
+ (n) => n.respondsToUserMessageId !== void 0 && n.respondsToUserMessageId !== e && bt(n) && !Ir(
3285
3328
  t,
3286
3329
  n.respondsToUserMessageId
3287
3330
  )
3288
3331
  )?.respondsToUserMessageId;
3289
3332
  return s ? t.map(
3290
- (n) => n.respondsToUserMessageId === s && Et(n) ? { ...n, steered: !0 } : n
3333
+ (n) => n.respondsToUserMessageId === s && bt(n) ? { ...n, steered: !0 } : n
3291
3334
  ) : t;
3292
3335
  }
3293
- function Et(t) {
3294
- return t.role === "tool" || W(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3336
+ function bt(t) {
3337
+ return t.role === "tool" || j(t) ? !0 : t.role === "assistant" && t.phase === "commentary";
3295
3338
  }
3296
- function yr(t, e) {
3339
+ function Ir(t, e) {
3297
3340
  return t.some(
3298
- (s) => s.respondsToUserMessageId === e && (N(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3341
+ (s) => s.respondsToUserMessageId === e && (x(s) || s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.loading !== !0))
3299
3342
  );
3300
3343
  }
3301
- function Ir(t, e) {
3344
+ function Tr(t, e) {
3302
3345
  const s = t[e];
3303
3346
  for (let n = e + 1; n < t.length; n += 1) {
3304
3347
  const r = t[n];
3305
- if (r.role === "assistant" && Y(s, r))
3348
+ if (r.role === "assistant" && Q(s, r))
3306
3349
  return !0;
3307
3350
  }
3308
3351
  return !1;
3309
3352
  }
3310
- function Tr(t, e) {
3353
+ function wr(t, e) {
3311
3354
  const s = t[e];
3312
3355
  if (!s.respondsToUserMessageId)
3313
3356
  return !1;
@@ -3315,45 +3358,45 @@ function Tr(t, e) {
3315
3358
  const r = t[n];
3316
3359
  if (r.role === "user")
3317
3360
  return !1;
3318
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || W(r)))
3361
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || j(r)))
3319
3362
  return !0;
3320
3363
  }
3321
3364
  return !1;
3322
3365
  }
3323
- function wr(t, e) {
3366
+ function Sr(t, e) {
3324
3367
  const s = t[e];
3325
3368
  return t.some(
3326
- (n, r) => r !== e && n.role === "assistant" && Y(s, n)
3369
+ (n, r) => r !== e && n.role === "assistant" && Q(s, n)
3327
3370
  );
3328
3371
  }
3329
- function Sr(t, e) {
3372
+ function Mr(t, e) {
3330
3373
  const s = t[e];
3331
3374
  return t.some(
3332
- (n, r) => r !== e && n.role === "tool" && Y(s, n)
3375
+ (n, r) => r !== e && n.role === "tool" && Q(s, n)
3333
3376
  );
3334
3377
  }
3335
- function Mr(t, e) {
3378
+ function Ar(t, e) {
3336
3379
  const s = t[e];
3337
3380
  for (let n = e + 1; n < t.length; n += 1)
3338
- if (W(t[n]) && Y(s, t[n]))
3381
+ if (j(t[n]) && Q(s, t[n]))
3339
3382
  return !0;
3340
3383
  return !1;
3341
3384
  }
3342
- function Y(t, e) {
3385
+ function Q(t, e) {
3343
3386
  return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
3344
3387
  }
3345
3388
  function E(t, e) {
3346
3389
  return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
3347
3390
  }
3348
- function Ar(t, e) {
3391
+ function Rr(t, e) {
3349
3392
  try {
3350
- const s = window.localStorage.getItem(`${Ot}${t}`);
3393
+ const s = window.localStorage.getItem(`${Nt}${t}`);
3351
3394
  if (!s)
3352
3395
  return null;
3353
3396
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
3354
3397
  if (e !== void 0 && r !== e)
3355
3398
  return null;
3356
- const i = Array.isArray(n.messages) ? n.messages.map(Nr).filter((o) => !!o) : [];
3399
+ const i = Array.isArray(n.messages) ? n.messages.map(xr).filter((o) => !!o) : [];
3357
3400
  return {
3358
3401
  sessionId: r,
3359
3402
  messages: i
@@ -3362,48 +3405,48 @@ function Ar(t, e) {
3362
3405
  return null;
3363
3406
  }
3364
3407
  }
3365
- function Rr(t, e) {
3408
+ function Er(t, e) {
3366
3409
  try {
3367
3410
  window.localStorage.setItem(
3368
- `${Ot}${t}`,
3411
+ `${Nt}${t}`,
3369
3412
  JSON.stringify({
3370
3413
  sessionId: e.sessionId,
3371
- messages: e.messages.slice(-Js).map(xr)
3414
+ messages: e.messages.slice(-Vs).map(Lr)
3372
3415
  })
3373
3416
  );
3374
3417
  } catch {
3375
3418
  return;
3376
3419
  }
3377
3420
  }
3378
- function Er(t) {
3421
+ function br(t) {
3379
3422
  try {
3380
- const e = window.localStorage.getItem(`${Le}${t}`);
3423
+ const e = window.localStorage.getItem(`${qe}${t}`);
3381
3424
  if (!e)
3382
3425
  return [];
3383
3426
  const s = JSON.parse(e);
3384
- return Array.isArray(s) ? s.filter(Ye) : [];
3427
+ return Array.isArray(s) ? s.filter(Qe) : [];
3385
3428
  } catch {
3386
3429
  return [];
3387
3430
  }
3388
3431
  }
3389
- function x(t, e) {
3432
+ function L(t, e) {
3390
3433
  try {
3391
- const s = e.filter(Ye);
3434
+ const s = e.filter(Qe);
3392
3435
  if (s.length === 0) {
3393
- window.localStorage.removeItem(`${Le}${t}`);
3436
+ window.localStorage.removeItem(`${qe}${t}`);
3394
3437
  return;
3395
3438
  }
3396
3439
  window.localStorage.setItem(
3397
- `${Le}${t}`,
3440
+ `${qe}${t}`,
3398
3441
  JSON.stringify(s.slice(-25))
3399
3442
  );
3400
3443
  } catch {
3401
3444
  return;
3402
3445
  }
3403
3446
  }
3404
- function Kt(t, e) {
3447
+ function Gt(t, e) {
3405
3448
  try {
3406
- const s = `${he}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
3449
+ const s = `${pe}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
3407
3450
  ...o,
3408
3451
  storedAt: Date.now(),
3409
3452
  unloadUrl: n,
@@ -3417,22 +3460,22 @@ function Kt(t, e) {
3417
3460
  } catch {
3418
3461
  }
3419
3462
  }
3420
- function br(t, e) {
3463
+ function Cr(t, e) {
3421
3464
  try {
3422
- if (window.sessionStorage.getItem(`${he}${t}`) === null)
3465
+ if (window.sessionStorage.getItem(`${pe}${t}`) === null)
3423
3466
  return;
3424
3467
  } catch {
3425
3468
  return;
3426
3469
  }
3427
- Kt(t, e);
3470
+ Gt(t, e);
3428
3471
  }
3429
- function Cr(t) {
3472
+ function _r(t) {
3430
3473
  try {
3431
- const e = `${he}${t}`, s = window.sessionStorage.getItem(e);
3474
+ const e = `${pe}${t}`, s = window.sessionStorage.getItem(e);
3432
3475
  if (window.sessionStorage.removeItem(e), !s)
3433
3476
  return [];
3434
3477
  const n = JSON.parse(s);
3435
- return Array.isArray(n) ? n.flatMap((r) => _r(r) ? [{
3478
+ return Array.isArray(n) ? n.flatMap((r) => Ur(r) ? [{
3436
3479
  ...r.event,
3437
3480
  page: C(),
3438
3481
  rawOutput: {
@@ -3459,13 +3502,13 @@ function kr(t) {
3459
3502
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
3460
3503
  Current URL: ${t}`;
3461
3504
  }
3462
- function _r(t) {
3505
+ function Ur(t) {
3463
3506
  if (!t || typeof t != "object")
3464
3507
  return !1;
3465
3508
  const e = t, s = e.event;
3466
- return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Ye(s) && s.type === "tool.result";
3509
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Qe(s) && s.type === "tool.result";
3467
3510
  }
3468
- function Ur(t, e) {
3511
+ function Pr(t, e) {
3469
3512
  const s = new Set(
3470
3513
  t.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
3471
3514
  );
@@ -3474,26 +3517,26 @@ function Ur(t, e) {
3474
3517
  ...e.filter((n) => !s.has(n.callId))
3475
3518
  ];
3476
3519
  }
3477
- function Pr(t) {
3520
+ function Dr(t) {
3478
3521
  try {
3479
- window.sessionStorage.removeItem(`${he}${t}`);
3522
+ window.sessionStorage.removeItem(`${pe}${t}`);
3480
3523
  } catch {
3481
3524
  return;
3482
3525
  }
3483
3526
  }
3484
- function Ye(t) {
3527
+ function Qe(t) {
3485
3528
  if (!t || typeof t != "object")
3486
3529
  return !1;
3487
3530
  const e = t;
3488
- return e.type === "chat.user_message" ? typeof e.content == "string" && bt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? bt(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;
3531
+ return e.type === "chat.user_message" ? typeof e.content == "string" && Ct(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Ct(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;
3489
3532
  }
3490
- function bt(t) {
3533
+ function Ct(t) {
3491
3534
  if (!t || typeof t != "object")
3492
3535
  return !1;
3493
3536
  const e = t;
3494
3537
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
3495
3538
  }
3496
- function Gt(t, e) {
3539
+ function Xt(t, e) {
3497
3540
  if (!Array.isArray(t))
3498
3541
  return;
3499
3542
  const s = t.filter((r) => {
@@ -3501,41 +3544,41 @@ function Gt(t, e) {
3501
3544
  return !1;
3502
3545
  const i = r;
3503
3546
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
3504
- }), n = e ? s.map((r) => Xt(r, e)) : s;
3547
+ }), n = e ? s.map((r) => Jt(r, e)) : s;
3505
3548
  return n.length > 0 ? n : void 0;
3506
3549
  }
3507
- function Xt(t, e) {
3550
+ function Jt(t, e) {
3508
3551
  return t.fileUrl?.startsWith("/") ? {
3509
3552
  ...t,
3510
3553
  fileUrl: new URL(t.fileUrl, e).toString()
3511
3554
  } : t;
3512
3555
  }
3513
- function $e(t) {
3514
- return t.type || Or(t.name) || "application/octet-stream";
3556
+ function ze(t) {
3557
+ return t.type || Nr(t.name) || "application/octet-stream";
3515
3558
  }
3516
- function Dr(t) {
3517
- Jt({
3559
+ function vr(t) {
3560
+ Vt({
3518
3561
  name: t.name,
3519
- mimeType: $e(t),
3562
+ mimeType: ze(t),
3520
3563
  sizeBytes: t.size
3521
3564
  });
3522
3565
  }
3523
- function Jt(t) {
3524
- const e = vr(t.name), s = t.mimeType.trim().toLowerCase();
3525
- if (!Ks.has(`${e}:${s}`))
3566
+ function Vt(t) {
3567
+ const e = Or(t.name), s = t.mimeType.trim().toLowerCase();
3568
+ if (!Gs.has(`${e}:${s}`))
3526
3569
  throw new Error("This attachment type is not supported by the embedded model provider");
3527
- if (t.sizeBytes <= 0 || t.sizeBytes >= Dt)
3570
+ if (t.sizeBytes <= 0 || t.sizeBytes >= vt)
3528
3571
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
3529
3572
  }
3530
- function vr(t) {
3573
+ function Or(t) {
3531
3574
  const e = t.trim().toLowerCase(), s = e.lastIndexOf(".");
3532
3575
  return s >= 0 ? e.slice(s) : "";
3533
3576
  }
3534
- function Or(t) {
3577
+ function Nr(t) {
3535
3578
  const e = t.toLowerCase();
3536
3579
  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;
3537
3580
  }
3538
- function Nr(t) {
3581
+ function xr(t) {
3539
3582
  if (!t || typeof t != "object")
3540
3583
  return null;
3541
3584
  const e = t;
@@ -3552,17 +3595,17 @@ function Nr(t) {
3552
3595
  dataType: typeof e.dataType == "string" ? e.dataType : void 0,
3553
3596
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
3554
3597
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
3555
- attachments: Gt(e.attachments)?.map(Qe),
3598
+ attachments: Xt(e.attachments)?.map(Ze),
3556
3599
  loading: typeof e.loading == "boolean" ? e.loading : void 0
3557
3600
  };
3558
3601
  }
3559
- function xr(t) {
3602
+ function Lr(t) {
3560
3603
  return t.attachments?.length ? {
3561
3604
  ...t,
3562
- attachments: t.attachments.map(Qe)
3605
+ attachments: t.attachments.map(Ze)
3563
3606
  } : t;
3564
3607
  }
3565
- function Qe(t) {
3608
+ function Ze(t) {
3566
3609
  const {
3567
3610
  dataUrl: e,
3568
3611
  objectUrl: s,
@@ -3571,47 +3614,47 @@ function Qe(t) {
3571
3614
  } = t;
3572
3615
  return r;
3573
3616
  }
3574
- function O(t) {
3617
+ function N(t) {
3575
3618
  const e = t.respondsToUserMessageId;
3576
3619
  return typeof e == "string" && e ? e : null;
3577
3620
  }
3578
- function k(t) {
3621
+ function _(t) {
3579
3622
  const e = t.runId;
3580
3623
  return typeof e == "string" && e ? e : null;
3581
3624
  }
3582
- function Lr(t) {
3625
+ function qr(t) {
3583
3626
  const e = t?.timeoutMs;
3584
- 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 <= rn);
3627
+ 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 <= on);
3585
3628
  }
3586
- function Vt(t) {
3629
+ function Yt(t) {
3587
3630
  const e = {};
3588
3631
  try {
3589
3632
  new Headers(t).forEach((s, n) => {
3590
- Object.keys(e).length < Je && (e[n] = Ze(n, s));
3633
+ Object.keys(e).length < Ve && (e[n] = et(n, s));
3591
3634
  });
3592
3635
  } catch {
3593
3636
  return {};
3594
3637
  }
3595
3638
  return e;
3596
3639
  }
3597
- function Ze(t, e) {
3598
- return ss(t) ? ge : P(de(e), Gs);
3640
+ function et(t, e) {
3641
+ return ns(t) ? fe : P(he(e), Xs);
3599
3642
  }
3600
3643
  function Br(t, e) {
3601
3644
  return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
3602
3645
  }
3603
- async function qr(t, e, s, n) {
3604
- const r = Vt(t.headers);
3646
+ async function Hr(t, e, s, n) {
3647
+ const r = Yt(t.headers);
3605
3648
  n({
3606
3649
  ...e,
3607
3650
  responseStatus: t.status,
3608
3651
  responseHeaders: r,
3609
- responseBody: await Hr(t),
3652
+ responseBody: await Wr(t),
3610
3653
  durationMs: Date.now() - s
3611
3654
  });
3612
3655
  }
3613
- async function Hr(t) {
3614
- if (!Yt(t.headers))
3656
+ async function Wr(t) {
3657
+ if (!Qt(t.headers))
3615
3658
  return;
3616
3659
  let e = null, s = null;
3617
3660
  try {
@@ -3620,7 +3663,7 @@ async function Hr(t) {
3620
3663
  const n = new Promise((a) => {
3621
3664
  s = window.setTimeout(() => {
3622
3665
  e?.cancel(), a("timeout");
3623
- }, Xs);
3666
+ }, Js);
3624
3667
  }), r = new TextDecoder();
3625
3668
  let i = "", o = 0;
3626
3669
  for (; ; ) {
@@ -3630,7 +3673,7 @@ async function Hr(t) {
3630
3673
  const { done: l, value: c } = a;
3631
3674
  if (l)
3632
3675
  return P(i + r.decode());
3633
- const h = Xe - o;
3676
+ const h = Je - o;
3634
3677
  if (c.byteLength > h)
3635
3678
  return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${P(i)}... [truncated]`;
3636
3679
  o += c.byteLength, i += r.decode(c, { stream: !0 });
@@ -3642,20 +3685,20 @@ async function Hr(t) {
3642
3685
  s !== null && window.clearTimeout(s);
3643
3686
  }
3644
3687
  }
3645
- function Wr(t, e) {
3646
- if (Yt(new Headers(e)))
3688
+ function jr(t, e) {
3689
+ if (Qt(new Headers(e)))
3647
3690
  try {
3648
3691
  return t.responseType === "" || t.responseType === "text" ? P(t.responseText ?? "") : void 0;
3649
3692
  } catch {
3650
3693
  return;
3651
3694
  }
3652
3695
  }
3653
- function Ct(t) {
3696
+ function _t(t) {
3654
3697
  if (typeof t == "string")
3655
3698
  return P(t);
3656
3699
  }
3657
- function jr(t) {
3658
- return _({
3700
+ function Fr(t) {
3701
+ return k({
3659
3702
  ...t,
3660
3703
  requestBody: kt(t.requestBody),
3661
3704
  responseBody: kt(t.responseBody)
@@ -3666,21 +3709,21 @@ function kt(t) {
3666
3709
  return t;
3667
3710
  const e = t.trim();
3668
3711
  if (!e.startsWith("{") && !e.startsWith("["))
3669
- return de(t);
3712
+ return he(t);
3670
3713
  try {
3671
- return JSON.stringify(_(JSON.parse(t)));
3714
+ return JSON.stringify(k(JSON.parse(t)));
3672
3715
  } catch {
3673
- return de(t);
3716
+ return he(t);
3674
3717
  }
3675
3718
  }
3676
- function Yt(t) {
3719
+ function Qt(t) {
3677
3720
  if (!t)
3678
3721
  return !1;
3679
3722
  const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
3680
- return s !== null && Number.isInteger(n) && n >= 0 && n <= Xe && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
3723
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Je && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
3681
3724
  }
3682
- function L(t, e = {}, s) {
3683
- if ($r(s))
3725
+ function q(t, e = {}, s) {
3726
+ if (zr(s))
3684
3727
  return !0;
3685
3728
  const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
3686
3729
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -3695,8 +3738,8 @@ function L(t, e = {}, s) {
3695
3738
  return !0;
3696
3739
  }
3697
3740
  }
3698
- function Fr(t, e) {
3699
- if (L(t))
3741
+ function $r(t, e) {
3742
+ if (q(t))
3700
3743
  return !0;
3701
3744
  try {
3702
3745
  const s = new URL(t, location.href), n = new URL(e);
@@ -3705,117 +3748,117 @@ function Fr(t, e) {
3705
3748
  return !0;
3706
3749
  }
3707
3750
  }
3708
- function $r(t) {
3751
+ function zr(t) {
3709
3752
  return t instanceof FormData || t instanceof Blob || t instanceof ArrayBuffer || ArrayBuffer.isView(t) || typeof ReadableStream < "u" && t instanceof ReadableStream;
3710
3753
  }
3711
- function zr(t) {
3754
+ function Kr(t) {
3712
3755
  const e = {};
3713
3756
  for (const s of t.trim().split(/[\r\n]+/)) {
3714
3757
  const n = s.indexOf(":");
3715
3758
  if (n <= 0)
3716
3759
  continue;
3717
- if (Object.keys(e).length >= Je)
3760
+ if (Object.keys(e).length >= Ve)
3718
3761
  break;
3719
3762
  const r = s.slice(0, n).trim();
3720
- e[r] = Ze(r, s.slice(n + 1).trim());
3763
+ e[r] = et(r, s.slice(n + 1).trim());
3721
3764
  }
3722
3765
  return e;
3723
3766
  }
3724
- function P(t, e = Xe) {
3767
+ function P(t, e = Je) {
3725
3768
  return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
3726
3769
  }
3727
- function Oe(t) {
3770
+ function Ne(t) {
3728
3771
  return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
3729
3772
  }
3730
- class ce extends Error {
3773
+ class ue extends Error {
3731
3774
  constructor(e, s) {
3732
3775
  super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
3733
3776
  }
3734
3777
  status;
3735
3778
  }
3736
- async function oe(t, e) {
3779
+ async function ae(t, e) {
3737
3780
  let s = null;
3738
- for (let n = 0; n < yt; n += 1)
3781
+ for (let n = 0; n < It; n += 1)
3739
3782
  try {
3740
3783
  return await t();
3741
3784
  } catch (r) {
3742
- if (s = r, n >= yt - 1 || !Gr(r))
3785
+ if (s = r, n >= It - 1 || !Xr(r))
3743
3786
  throw r;
3744
- await Kr(n);
3787
+ await Gr(n);
3745
3788
  }
3746
3789
  throw s instanceof Error ? s : new Error(e);
3747
3790
  }
3748
- function Kr(t) {
3791
+ function Gr(t) {
3749
3792
  return new Promise((e) => {
3750
- window.setTimeout(e, zs[t] ?? 0);
3793
+ window.setTimeout(e, Ks[t] ?? 0);
3751
3794
  });
3752
3795
  }
3753
- function Gr(t) {
3754
- return t instanceof ce ? Xr(t.status) : t instanceof TypeError;
3755
- }
3756
3796
  function Xr(t) {
3757
- return t === 408 || t === 409 || t === 429 || t >= 500;
3797
+ return t instanceof ue ? Jr(t.status) : t instanceof TypeError;
3758
3798
  }
3759
3799
  function Jr(t) {
3800
+ return t === 408 || t === 409 || t === 429 || t >= 500;
3801
+ }
3802
+ function Vr(t) {
3760
3803
  return t === 401 || t === 403;
3761
3804
  }
3762
- const ge = "[REDACTED_SECRET]", D = "[REDACTED_TOKEN]", Vr = "[REDACTED_SIGNED_URL]", Yr = 20, Qr = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Qt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Zt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, es = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ts = /\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, Zr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ei = /\bhttps?:\/\/[^\s"'<>]+/gi, ti = /[),.;\]]+$/;
3763
- function _(t) {
3764
- return ue(t, 0, /* @__PURE__ */ new WeakSet());
3805
+ const fe = "[REDACTED_SECRET]", D = "[REDACTED_TOKEN]", Yr = "[REDACTED_SIGNED_URL]", Qr = 20, Zr = /^(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, Zt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, es = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, ts = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ss = /\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, ei = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ti = /\bhttps?:\/\/[^\s"'<>]+/gi, si = /[),.;\]]+$/;
3806
+ function k(t) {
3807
+ return de(t, 0, /* @__PURE__ */ new WeakSet());
3765
3808
  }
3766
- function ue(t, e, s) {
3809
+ function de(t, e, s) {
3767
3810
  if (typeof t == "string")
3768
- return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : de(t);
3811
+ return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : he(t);
3769
3812
  if (t === null || typeof t != "object")
3770
3813
  return t;
3771
- if (e >= Yr)
3814
+ if (e >= Qr)
3772
3815
  return "[REDACTED_MAX_DEPTH]";
3773
3816
  if (s.has(t))
3774
3817
  return "[REDACTED_CIRCULAR]";
3775
3818
  if (s.add(t), Array.isArray(t))
3776
- return t.map((r) => ue(r, e + 1, s));
3819
+ return t.map((r) => de(r, e + 1, s));
3777
3820
  const n = {};
3778
3821
  for (const [r, i] of Object.entries(t))
3779
- r === "pageContent" ? n[r] = i : ss(r) ? n[r] = ge : n[r] = r.toLowerCase() === "url" ? si(i) : ue(i, e + 1, s);
3822
+ r === "pageContent" ? n[r] = i : ns(r) ? n[r] = fe : n[r] = r.toLowerCase() === "url" ? ni(i) : de(i, e + 1, s);
3780
3823
  return n;
3781
3824
  }
3782
- function ss(t) {
3825
+ function ns(t) {
3783
3826
  const e = t.replace(/[^a-z0-9]/gi, "").toLowerCase();
3784
3827
  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");
3785
3828
  }
3786
- function si(t) {
3787
- return typeof t == "string" ? ns(t) : ue(t, 0, /* @__PURE__ */ new WeakSet());
3829
+ function ni(t) {
3830
+ return typeof t == "string" ? rs(t) : de(t, 0, /* @__PURE__ */ new WeakSet());
3788
3831
  }
3789
- function ns(t) {
3832
+ function rs(t) {
3790
3833
  try {
3791
3834
  const e = new URL(t, location.href);
3792
3835
  for (const s of Array.from(e.searchParams.keys()))
3793
- Qr.test(s) && e.searchParams.set(s, D);
3836
+ Zr.test(s) && e.searchParams.set(s, D);
3794
3837
  return e.username && (e.username = D), e.password && (e.password = D), e.toString();
3795
3838
  } catch {
3796
- return ni(t);
3839
+ return ri(t);
3797
3840
  }
3798
3841
  }
3799
- function de(t) {
3800
- return t.replace(Zr, Vr).replace(ei, ri).replace(Qt, `Bearer ${D}`).replace(Zt, `Basic ${D}`).replace(es, D).replace(ts, (e, s) => `${s}: ${ge}`);
3801
- }
3802
- function ni(t) {
3803
- return t.replace(Qt, `Bearer ${D}`).replace(Zt, `Basic ${D}`).replace(es, D).replace(ts, (e, s) => `${s}: ${ge}`);
3842
+ function he(t) {
3843
+ return t.replace(ei, Yr).replace(ti, ii).replace(Zt, `Bearer ${D}`).replace(es, `Basic ${D}`).replace(ts, D).replace(ss, (e, s) => `${s}: ${fe}`);
3804
3844
  }
3805
3845
  function ri(t) {
3806
- const e = t.match(ti)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
3807
- return `${ns(s)}${e}`;
3846
+ return t.replace(Zt, `Bearer ${D}`).replace(es, `Basic ${D}`).replace(ts, D).replace(ss, (e, s) => `${s}: ${fe}`);
3847
+ }
3848
+ function ii(t) {
3849
+ const e = t.match(si)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
3850
+ return `${rs(s)}${e}`;
3808
3851
  }
3809
3852
  export {
3810
- ct as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3811
- xe as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3853
+ ut as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3854
+ Le as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3812
3855
  ks as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3813
- Cs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3814
- _s as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3815
- ii as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
3816
- Nt as PlunoProductAgent,
3817
- Ys as calculateReconnectDelay,
3818
- Nt as default,
3819
- Sn as getProductAgentOriginAccessErrorMessage,
3820
- Dr as validateProductAgentProviderInputFile
3856
+ _s as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3857
+ Us as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3858
+ oi as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
3859
+ xt as PlunoProductAgent,
3860
+ Qs as calculateReconnectDelay,
3861
+ xt as default,
3862
+ Mn as getProductAgentOriginAccessErrorMessage,
3863
+ vr as validateProductAgentProviderInputFile
3821
3864
  };