@pluno/product-agent-web 0.1.168 → 0.1.170

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