@pluno/product-agent-web 0.1.201 → 0.1.203

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- const js = "pluno-product-agent-attachments";
2
- const st = "files";
3
- async function zs(s) {
4
- const e = await gt();
5
- await Qs(e, "readwrite", (t) => t.put(s));
6
- }
7
- async function Ks(s, e) {
8
- const t = await gt();
9
- await ft(t, "readwrite", async (n) => {
10
- const i = await mt(
1
+ const zs = "pluno-product-agent-attachments";
2
+ const it = "files";
3
+ async function Ks(s) {
4
+ const e = await mt();
5
+ await Vs(e, "readwrite", (t) => t.put(s));
6
+ }
7
+ async function Gs(s, e) {
8
+ const t = await mt();
9
+ await yt(t, "readwrite", async (n) => {
10
+ const i = await It(
11
11
  n.get(s)
12
12
  );
13
13
  i && n.put({
@@ -16,28 +16,28 @@ async function Ks(s, e) {
16
16
  });
17
17
  });
18
18
  }
19
- async function Gs(s = 864e5) {
20
- const e = await gt(), t = Date.now() - s;
21
- await ft(e, "readwrite", async (n) => {
19
+ async function Qs(s = 864e5) {
20
+ const e = await mt(), t = Date.now() - s;
21
+ await yt(e, "readwrite", async (n) => {
22
22
  const i = n.index("lastUsedAt");
23
- (await mt(i.getAllKeys(IDBKeyRange.upperBound(t)))).forEach((o) => n.delete(o));
23
+ (await It(i.getAllKeys(IDBKeyRange.upperBound(t)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function gt() {
26
+ function mt() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((s, e) => {
28
- const t = indexedDB.open(js, 1);
28
+ const t = indexedDB.open(zs, 1);
29
29
  t.onupgradeneeded = () => {
30
- const i = t.result.createObjectStore(st, { keyPath: "attachmentId" });
30
+ const i = t.result.createObjectStore(it, { keyPath: "attachmentId" });
31
31
  i.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), i.createIndex("sessionId", "sessionId", { unique: !1 }), i.createIndex("origin", "origin", { unique: !1 });
32
32
  }, t.onsuccess = () => s(t.result), t.onerror = () => e(t.error ?? new Error("Failed to open Product Agent attachment storage"));
33
33
  });
34
34
  }
35
- async function Qs(s, e, t) {
36
- return await ft(s, e, async (n) => await mt(t(n)));
35
+ async function Vs(s, e, t) {
36
+ return await yt(s, e, async (n) => await It(t(n)));
37
37
  }
38
- function ft(s, e, t) {
38
+ function yt(s, e, t) {
39
39
  return new Promise((n, i) => {
40
- const r = s.transaction(st, e), o = r.objectStore(st);
40
+ const r = s.transaction(it, e), o = r.objectStore(it);
41
41
  let a, l = !1;
42
42
  t(o).then((c) => {
43
43
  a = c;
@@ -57,16 +57,16 @@ function ft(s, e, t) {
57
57
  };
58
58
  });
59
59
  }
60
- function mt(s) {
60
+ function It(s) {
61
61
  return new Promise((e, t) => {
62
62
  s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Product Agent attachment storage request failed"));
63
63
  });
64
64
  }
65
- function Vs(s) {
65
+ function Xs(s) {
66
66
  return s !== null && (typeof s == "object" || typeof s == "function");
67
67
  }
68
- function us(s, e, t) {
69
- const n = Reflect.get(s, "pluno"), i = Vs(n) ? n : {};
68
+ function hs(s, e, t) {
69
+ const n = Reflect.get(s, "pluno"), i = Xs(n) ? n : {};
70
70
  if (i !== n && !Reflect.set(s, "pluno", i))
71
71
  return null;
72
72
  const r = Object.getOwnPropertyDescriptor(i, e);
@@ -80,25 +80,25 @@ function us(s, e, t) {
80
80
  }
81
81
  };
82
82
  }
83
- const Xs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function Ct(s, e) {
83
+ const Js = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function vt(s, e) {
85
85
  return e ? s.replace(
86
- Xs,
86
+ Js,
87
87
  (t, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
88
88
  ) : s;
89
89
  }
90
- const ds = "suggest_share_on_socials";
91
- function Js(s) {
90
+ const St = "suggest_share_on_socials";
91
+ function Ys(s) {
92
92
  for (let e = s.length - 1; e >= 0; e -= 1) {
93
93
  const t = s[e];
94
- if (t.role !== "tool" || t.toolName !== ds || t.sharePromptAllowed !== void 0)
94
+ if (t.role !== "tool" || t.toolName !== St || t.sharePromptAllowed !== void 0)
95
95
  continue;
96
- if (Zs(s, e, t.callId) !== !0)
96
+ if (en(s, e, t.callId) !== !0)
97
97
  return null;
98
- const n = Pt(s, e, "assistant");
98
+ const n = Ut(s, e, "assistant");
99
99
  if (!n)
100
100
  return null;
101
- const i = Pt(s, n.index, "user");
101
+ const i = Ut(s, n.index, "user");
102
102
  return i ? {
103
103
  id: `share:${t.callId ?? t.id}`,
104
104
  userPrompt: i.content,
@@ -107,7 +107,7 @@ function Js(s) {
107
107
  }
108
108
  return null;
109
109
  }
110
- function Ys(s) {
110
+ function Zs(s) {
111
111
  let e = s;
112
112
  if (typeof s == "string")
113
113
  try {
@@ -115,10 +115,10 @@ function Ys(s) {
115
115
  } catch {
116
116
  return null;
117
117
  }
118
- const t = en(e);
118
+ const t = tn(e);
119
119
  return t ? typeof t.showSharePrompt == "boolean" ? t.showSharePrompt : t.ok === !0 && typeof t.message == "string" && t.message.includes("social-sharing prompt") ? !0 : null : null;
120
120
  }
121
- function Zs(s, e, t) {
121
+ function en(s, e, t) {
122
122
  if (!t)
123
123
  return null;
124
124
  for (let n = e + 1; n < s.length; n += 1) {
@@ -128,7 +128,7 @@ function Zs(s, e, t) {
128
128
  }
129
129
  return null;
130
130
  }
131
- function Pt(s, e, t) {
131
+ function Ut(s, e, t) {
132
132
  for (let n = e - 1; n >= 0; n -= 1) {
133
133
  const i = s[n];
134
134
  if (i.role === t && i.content.trim())
@@ -136,62 +136,62 @@ function Pt(s, e, t) {
136
136
  }
137
137
  return null;
138
138
  }
139
- function en(s) {
139
+ function tn(s) {
140
140
  return s && typeof s == "object" && !Array.isArray(s) ? s : null;
141
141
  }
142
- const tn = "save_runtime_captured_skill";
143
- function sn(s) {
144
- return (s.type === "function_call" || s.type === "tool_call") && s.name === tn;
142
+ const sn = "save_runtime_captured_skill";
143
+ function nn(s) {
144
+ return (s.type === "function_call" || s.type === "tool_call") && s.name === sn;
145
145
  }
146
- function nn(s, e, t) {
147
- const n = e.map((d) => ({ item: d, identity: t(d) })), i = new Set(
146
+ function rn(s, e, t) {
147
+ const n = e.map((h) => ({ item: h, identity: t(h) })), i = new Set(
148
148
  n.flatMap(
149
- ({ identity: d }) => d.isActivity && !d.isTransient ? d.activityKeys ?? [] : []
149
+ ({ identity: h }) => h.isActivity && !h.isTransient ? h.activityKeys ?? [] : []
150
150
  )
151
151
  ), r = n.filter(
152
- ({ identity: d }) => !(d.isTransient && d.activityKeys?.some((p) => i.has(p)))
153
- ), o = new Map(r.map(({ item: d, identity: p }) => [p.id, d])), a = new Map(
152
+ ({ identity: h }) => !(h.isTransient && h.activityKeys?.some((p) => i.has(p)))
153
+ ), o = new Map(r.map(({ item: h, identity: p }) => [p.id, h])), a = new Map(
154
154
  r.flatMap(
155
- ({ item: d, identity: p }) => p.optimisticKey ? [[p.optimisticKey, d]] : []
155
+ ({ item: h, identity: p }) => p.optimisticKey ? [[p.optimisticKey, h]] : []
156
156
  )
157
157
  ), l = new Map(
158
158
  r.flatMap(
159
- ({ item: d, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, d]] : []
159
+ ({ item: h, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, h]] : []
160
160
  )
161
161
  ), c = /* @__PURE__ */ new Map();
162
- for (const { item: d, identity: p } of r)
163
- for (const m of p.activityKeys ?? []) {
164
- const g = c.get(m);
165
- (!g || t(g).isTransient) && c.set(m, d);
162
+ for (const { item: h, identity: p } of r)
163
+ for (const y of p.activityKeys ?? []) {
164
+ const m = c.get(y);
165
+ (!m || t(m).isTransient) && c.set(y, h);
166
166
  }
167
- const u = new Set(r.map(({ identity: d }) => d.id)), h = new Set(
168
- r.flatMap(({ identity: d }) => d.runId ? [d.runId] : [])
169
- ), f = /* @__PURE__ */ new Set(), y = [];
170
- for (const d of s) {
171
- const p = t(d);
172
- let m = o.get(p.id);
173
- if (p.isOptimistic && p.optimisticKey ? m = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? m = l.get(p.assistantDraftKey) : p.isActivity && (m = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? m), m && !f.has(m)) {
174
- y.push(m), f.add(m);
167
+ const u = new Set(r.map(({ identity: h }) => h.id)), d = new Set(
168
+ r.flatMap(({ identity: h }) => h.runId ? [h.runId] : [])
169
+ ), g = /* @__PURE__ */ new Set(), f = [];
170
+ for (const h of s) {
171
+ const p = t(h);
172
+ let y = o.get(p.id);
173
+ if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? y), y && !g.has(y)) {
174
+ f.push(y), g.add(y);
175
175
  continue;
176
176
  }
177
- const g = p.respondsToUserMessageId !== void 0 && u.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
178
- (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && g) && y.push(d);
177
+ const m = p.respondsToUserMessageId !== void 0 && u.has(p.respondsToUserMessageId) || p.runId !== void 0 && d.has(p.runId);
178
+ (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && m) && f.push(h);
179
179
  }
180
- for (const { item: d } of r)
181
- f.has(d) || y.push(d);
182
- return y;
180
+ for (const { item: h } of r)
181
+ g.has(h) || f.push(h);
182
+ return f;
183
183
  }
184
- function _t(s, e, t, n) {
184
+ function Dt(s, e, t, n) {
185
185
  return s.filter((i) => {
186
186
  const r = n(i);
187
187
  return !r.isActivity || !r.isTransient ? !0 : e !== null && r.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId !== e : t === null || r.runId !== t;
188
188
  });
189
189
  }
190
- const Fe = "pluno.productAgent.transportId", rn = "pluno.productAgent.transportIdentity", je = "pluno.productAgent.transportIdentity.event", on = 50, an = globalThis.setTimeout.bind(globalThis);
191
- let ae = null;
192
- const Me = /* @__PURE__ */ new Set(), ze = /* @__PURE__ */ new Map();
193
- async function ln(s = hs()) {
194
- const e = s.randomUUID(), t = s.storage.getItem(Fe);
190
+ const ze = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", Ke = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
191
+ let le = null;
192
+ const be = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Map();
193
+ async function cn(s = ps()) {
194
+ const e = s.randomUUID(), t = s.storage.getItem(ze);
195
195
  let n = t ?? s.randomUUID(), i = !1, r = !1;
196
196
  const o = s.channel.subscribe((l) => {
197
197
  if (!(l.senderId === e || l.transportId !== n)) {
@@ -209,7 +209,7 @@ async function ln(s = hs()) {
209
209
  }
210
210
  });
211
211
  if (!t)
212
- s.storage.setItem(Fe, n), i = !0;
212
+ s.storage.setItem(ze, n), i = !0;
213
213
  else if (s.skipStoredIdentityCollisionCheck)
214
214
  i = !0;
215
215
  else
@@ -218,7 +218,7 @@ async function ln(s = hs()) {
218
218
  i = !0;
219
219
  break;
220
220
  }
221
- n = s.randomUUID(), s.storage.setItem(Fe, n);
221
+ n = s.randomUUID(), s.storage.setItem(ze, n);
222
222
  }
223
223
  let a = !1;
224
224
  return {
@@ -228,52 +228,52 @@ async function ln(s = hs()) {
228
228
  }
229
229
  };
230
230
  }
231
- async function cn(s = !1) {
232
- ae || (ae = ln({
233
- ...hs(),
231
+ async function un(s = !1) {
232
+ le || (le = cn({
233
+ ...ps(),
234
234
  skipStoredIdentityCollisionCheck: s
235
- }), ae.then((i) => {
235
+ }), le.then((i) => {
236
236
  const r = (o) => {
237
- o.persisted || (i.release(), ae = null, Me.clear(), window.removeEventListener("pagehide", r));
237
+ o.persisted || (i.release(), le = null, be.clear(), window.removeEventListener("pagehide", r));
238
238
  };
239
239
  window.addEventListener("pagehide", r);
240
240
  }));
241
- const e = await ae, t = un();
242
- Me.add(t);
241
+ const e = await le, t = dn();
242
+ be.add(t);
243
243
  let n = !1;
244
244
  return {
245
245
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
246
246
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
247
247
  release: () => {
248
- n || (n = !0, Me.delete(t));
248
+ n || (n = !0, be.delete(t));
249
249
  }
250
250
  };
251
251
  }
252
- function un() {
252
+ function dn() {
253
253
  let s = 0;
254
- for (; Me.has(s); )
254
+ for (; be.has(s); )
255
255
  s += 1;
256
256
  return s;
257
257
  }
258
- function hs() {
258
+ function ps() {
259
259
  return {
260
- storage: dn(),
261
- channel: hn(),
260
+ storage: hn(),
261
+ channel: pn(),
262
262
  randomUUID: () => crypto.randomUUID(),
263
- settle: () => new Promise((s) => an(s, on))
263
+ settle: () => new Promise((s) => ln(s, an))
264
264
  };
265
265
  }
266
- function dn() {
266
+ function hn() {
267
267
  return {
268
268
  getItem: (s) => {
269
269
  try {
270
- return window.sessionStorage?.getItem(s) ?? ze.get(s) ?? null;
270
+ return window.sessionStorage?.getItem(s) ?? Ge.get(s) ?? null;
271
271
  } catch {
272
- return ze.get(s) ?? null;
272
+ return Ge.get(s) ?? null;
273
273
  }
274
274
  },
275
275
  setItem: (s, e) => {
276
- ze.set(s, e);
276
+ Ge.set(s, e);
277
277
  try {
278
278
  window.sessionStorage?.setItem(s, e);
279
279
  } catch {
@@ -281,9 +281,9 @@ function dn() {
281
281
  }
282
282
  };
283
283
  }
284
- function hn() {
284
+ function pn() {
285
285
  if (typeof BroadcastChannel < "u") {
286
- const s = new BroadcastChannel(rn);
286
+ const s = new BroadcastChannel(on);
287
287
  return {
288
288
  postMessage: (e) => s.postMessage(e),
289
289
  subscribe: (e) => {
@@ -293,11 +293,11 @@ function hn() {
293
293
  close: () => s.close()
294
294
  };
295
295
  }
296
- return pn();
296
+ return gn();
297
297
  }
298
- function pn() {
298
+ function gn() {
299
299
  const s = /* @__PURE__ */ new Set(), e = (t) => {
300
- if (t.key !== je || !t.newValue)
300
+ if (t.key !== Ke || !t.newValue)
301
301
  return;
302
302
  const n = JSON.parse(t.newValue);
303
303
  for (const i of s)
@@ -306,9 +306,9 @@ function pn() {
306
306
  return window.addEventListener("storage", e), {
307
307
  postMessage: (t) => {
308
308
  window.localStorage.setItem(
309
- je,
309
+ Ke,
310
310
  JSON.stringify({ ...t, eventId: crypto.randomUUID() })
311
- ), window.localStorage.removeItem(je);
311
+ ), window.localStorage.removeItem(Ke);
312
312
  },
313
313
  subscribe: (t) => (s.add(t), () => s.delete(t)),
314
314
  close: () => {
@@ -316,8 +316,8 @@ function pn() {
316
316
  }
317
317
  };
318
318
  }
319
- const ps = "schedule_follow_up";
320
- function gn(s) {
319
+ const gs = "schedule_follow_up";
320
+ function fn(s) {
321
321
  let e = s;
322
322
  if (typeof e == "string")
323
323
  try {
@@ -328,48 +328,48 @@ function gn(s) {
328
328
  if (!e || typeof e != "object")
329
329
  return null;
330
330
  const t = e;
331
- return t.ok !== !0 || t.toolName !== ps || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? null : {
331
+ return t.ok !== !0 || t.toolName !== gs || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? null : {
332
332
  id: typeof t.taskId == "string" && t.taskId ? t.taskId : null,
333
333
  dueAt: t.dueAt
334
334
  };
335
335
  }
336
- const fn = [
336
+ const mn = [
337
337
  { value: "gpt-5.6-sol", label: "gpt-5.6-sol", price: "$$" },
338
338
  { value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5", price: "$$" },
339
339
  { value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash", price: "$" }
340
- ], mn = [
340
+ ], yn = [
341
341
  { value: "anthropic/claude-opus-5", label: "Claude Opus 5", price: "$$$" },
342
342
  { value: "gpt-5.6-terra", label: "gpt-5.6-terra", price: "$$" }
343
- ], yn = [
344
- ...fn,
345
- ...mn
346
- ], Ke = (s) => yn.some((e) => e.value === s);
347
- function vt(s, e) {
343
+ ], In = [
344
+ ...mn,
345
+ ...yn
346
+ ], Qe = (s) => In.some((e) => e.value === s);
347
+ function qt(s, e) {
348
348
  return s.filter((t, n) => {
349
- const i = Ut(t);
350
- return gs(i) ? !s.slice(n + 1).some((r) => {
351
- const o = Ut(r);
352
- return fs(i, o) && ms(i, o);
349
+ const i = Ot(t);
350
+ return fs(i) ? !s.slice(n + 1).some((r) => {
351
+ const o = Ot(r);
352
+ return ms(i, o) && ys(i, o);
353
353
  }) : !0;
354
354
  });
355
355
  }
356
- function gs(s) {
356
+ function fs(s) {
357
357
  return s.type === "run_status" && s.status === "stopped" && s.reason === "task_tab_closed";
358
358
  }
359
- function In(s, e) {
360
- return s.reason === "task_tab_closed" && ms(s, e) && fs(s, e);
359
+ function Sn(s, e) {
360
+ return s.reason === "task_tab_closed" && ys(s, e) && ms(s, e);
361
361
  }
362
- function Ut(s) {
362
+ function Ot(s) {
363
363
  return s.data && typeof s.data == "object" ? s.data : {};
364
364
  }
365
- function fs(s, e) {
365
+ function ms(s, e) {
366
366
  const t = typeof s.runId == "string" ? s.runId : null, n = typeof e.runId == "string" ? e.runId : null;
367
- return t && n && t === n ? !1 : e.type === "message" ? e.role === "assistant" : e.type === "run_status" ? !gs(e) : e.type === "run_error";
367
+ return t && n && t === n ? !1 : e.type === "message" ? e.role === "assistant" : e.type === "run_status" ? !fs(e) : e.type === "run_error";
368
368
  }
369
- function ms(s, e) {
369
+ function ys(s, e) {
370
370
  return typeof s.respondsToUserMessageId == "string" && typeof e.respondsToUserMessageId == "string" ? s.respondsToUserMessageId === e.respondsToUserMessageId : typeof s.clientMessageId == "string" && typeof e.clientMessageId == "string" ? s.clientMessageId === e.clientMessageId : typeof s.runId == "string" && typeof e.runId == "string" && s.runId === e.runId;
371
371
  }
372
- function be(s) {
372
+ function Re(s) {
373
373
  return {
374
374
  key: s,
375
375
  status: "not_requested",
@@ -379,9 +379,9 @@ function be(s) {
379
379
  updatedAt: null
380
380
  };
381
381
  }
382
- class Dt {
382
+ class xt {
383
383
  constructor(e, t, n = (i, r) => r) {
384
- this.loader = t, this.merge = n, this.state = be(e);
384
+ this.loader = t, this.merge = n, this.state = Re(e);
385
385
  }
386
386
  loader;
387
387
  merge;
@@ -396,10 +396,10 @@ class Dt {
396
396
  return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
397
397
  }
398
398
  setKey(e) {
399
- e !== this.state.key && (this.state = be(e), this.trailingLoad = null, this.publish());
399
+ e !== this.state.key && (this.state = Re(e), this.trailingLoad = null, this.publish());
400
400
  }
401
401
  reset() {
402
- this.state = be(this.state.key), this.trailingLoad = null, this.publish();
402
+ this.state = Re(this.state.key), this.trailingLoad = null, this.publish();
403
403
  }
404
404
  invalidate() {
405
405
  this.state = {
@@ -454,7 +454,7 @@ class Dt {
454
454
  for (const e of this.listeners) e(this.state);
455
455
  }
456
456
  }
457
- function Re(s) {
457
+ function ke(s) {
458
458
  const e = {}, t = [];
459
459
  for (const n of s.entities)
460
460
  e[n.id] || t.push(n.id), e[n.id] = n;
@@ -464,28 +464,28 @@ function Re(s) {
464
464
  nextCursor: s.nextCursor
465
465
  };
466
466
  }
467
- function Sn(s, e, t) {
467
+ function Tn(s, e, t) {
468
468
  if (t === "replace" || s === null) return e;
469
469
  const n = { ...s.entitiesById, ...e.entitiesById }, i = [...s.ids];
470
470
  for (const r of e.ids)
471
471
  s.entitiesById[r] || i.push(r);
472
472
  return { entitiesById: n, ids: i, nextCursor: e.nextCursor };
473
473
  }
474
- function ys(s) {
474
+ function Is(s) {
475
475
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
476
476
  }
477
- function go(s) {
477
+ function So(s) {
478
478
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
479
479
  }
480
- function Tn(s, e) {
480
+ function wn(s, e) {
481
481
  return e === "limit_exceeded" ? { allowed: !1, reason: "credits_exhausted", actions: ["upgrade", "earn_credits"] } : e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required" ? { allowed: !1, reason: "payment_issue", actions: ["upgrade"] } : s ?? { allowed: !0, reason: "allowed", actions: [] };
482
482
  }
483
- function wn(s) {
483
+ function An(s) {
484
484
  if (!s || typeof s != "object") return !1;
485
485
  const e = s.paidCreditFallbackModel;
486
486
  return typeof e == "string" && e.length > 0;
487
487
  }
488
- function fo(s) {
488
+ function To(s) {
489
489
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
490
490
  return s.hasRunningAssistantTurn && !e ? {
491
491
  action: "stop",
@@ -495,20 +495,20 @@ function fo(s) {
495
495
  disabled: !e || !s.canSubmitMessage
496
496
  };
497
497
  }
498
- class An {
498
+ class Mn {
499
499
  constructor(e, t, n = 20) {
500
- this.loadPage = t, this.limit = n, this.recentQuery = new Dt(
500
+ this.loadPage = t, this.limit = n, this.recentQuery = new xt(
501
501
  `${e}:recent`,
502
- async ({ cursor: i }) => Re(
502
+ async ({ cursor: i }) => ke(
503
503
  await this.loadPage({ cursor: i, limit: this.limit, pinned: !1 }).then((r) => ({
504
504
  entities: r.sessions,
505
505
  nextCursor: r.nextCursor
506
506
  }))
507
507
  ),
508
- Sn
509
- ), this.pinnedQuery = new Dt(
508
+ Tn
509
+ ), this.pinnedQuery = new xt(
510
510
  `${e}:pinned`,
511
- async () => Re({
511
+ async () => ke({
512
512
  entities: await this.loadAllPinned(),
513
513
  nextCursor: null
514
514
  })
@@ -528,17 +528,17 @@ class An {
528
528
  activityReconciliationScheduled = !1;
529
529
  getState() {
530
530
  const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), n = [
531
- ...ye(t.data),
532
- ...ye(e.data)
531
+ ...Ie(t.data),
532
+ ...Ie(e.data)
533
533
  ], i = new Map(n.map((l) => [l.id, l])), r = Array.from(i.values()).map(
534
534
  (l) => this.applyOverrides(l, this.completedRefreshSequence)
535
- ), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ? Re({
535
+ ), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ? ke({
536
536
  entities: [...o, ...r],
537
537
  nextCursor: e.data?.nextCursor ?? null
538
538
  }) : null;
539
539
  return {
540
540
  key: e.key.slice(0, -7),
541
- status: Mn(e, t),
541
+ status: bn(e, t),
542
542
  data: a,
543
543
  error: e.error ?? t.error,
544
544
  requestId: Math.max(e.requestId, t.requestId),
@@ -604,8 +604,8 @@ class An {
604
604
  }
605
605
  reconcileDurableEntities() {
606
606
  const e = [
607
- ...ye(this.pinnedQuery.getState().data),
608
- ...ye(this.recentQuery.getState().data)
607
+ ...Ie(this.pinnedQuery.getState().data),
608
+ ...Ie(this.recentQuery.getState().data)
609
609
  ], t = new Set(e.map((n) => n.id));
610
610
  for (const n of this.optimisticEntities.keys())
611
611
  t.has(n) && this.optimisticEntities.delete(n);
@@ -644,13 +644,13 @@ class An {
644
644
  for (const e of this.listeners) e(this.getState());
645
645
  }
646
646
  }
647
- function ye(s) {
647
+ function Ie(s) {
648
648
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
649
649
  }
650
- function Mn(s, e) {
650
+ function bn(s, e) {
651
651
  return s.status === "error" || e.status === "error" ? "error" : s.status === "loading" || e.status === "loading" ? "loading" : s.status === "refreshing" || e.status === "refreshing" ? "refreshing" : s.status === "loading_more" ? "loading_more" : s.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
652
652
  }
653
- class qt {
653
+ class Lt {
654
654
  constructor(e) {
655
655
  this.options = e;
656
656
  }
@@ -694,7 +694,7 @@ class qt {
694
694
  this.schedule(r, e);
695
695
  }
696
696
  }
697
- class bn {
697
+ class Rn {
698
698
  constructor(e) {
699
699
  this.options = e;
700
700
  }
@@ -746,10 +746,10 @@ class bn {
746
746
  );
747
747
  }
748
748
  }
749
- class Rn {
749
+ class kn {
750
750
  constructor(e, t = null) {
751
751
  this.storage = e, t && (this.decisions = new Map(
752
- t.filter(nt).map((n) => [this.getDecisionKey(n), n])
752
+ t.filter(rt).map((n) => [this.getDecisionKey(n), n])
753
753
  ), this.initialized = !0);
754
754
  }
755
755
  storage;
@@ -761,7 +761,7 @@ class Rn {
761
761
  if (this.initialized) return;
762
762
  const e = await this.storage.load();
763
763
  this.decisions = new Map(
764
- e.filter(nt).map((t) => [this.getDecisionKey(t), t])
764
+ e.filter(rt).map((t) => [this.getDecisionKey(t), t])
765
765
  ), this.initialized = !0;
766
766
  }
767
767
  isEligible(e, t = Date.now()) {
@@ -799,7 +799,7 @@ class Rn {
799
799
  async applyAction(e, t, n) {
800
800
  if (!e.allowedActions.includes(t))
801
801
  throw new Error(`Interaction ${e.key} does not allow ${t}.`);
802
- if (!Is(t))
802
+ if (!Ss(t))
803
803
  throw new Error(`Interaction action ${t} is not a persistence decision.`);
804
804
  const i = n.now ?? /* @__PURE__ */ new Date(), r = {
805
805
  promptKey: e.key,
@@ -825,17 +825,17 @@ class Rn {
825
825
  return null;
826
826
  }
827
827
  getDecisionKey(e) {
828
- const t = Ge(e.scope);
828
+ const t = Ve(e.scope);
829
829
  return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
830
830
  }
831
831
  getExactKey(e) {
832
- return `${Ge(e.scope)}:interaction:${e.key}`;
832
+ return `${Ve(e.scope)}:interaction:${e.key}`;
833
833
  }
834
834
  getCategoryKey(e) {
835
- return `${Ge(e.scope)}:category:${e.category}`;
835
+ return `${Ve(e.scope)}:category:${e.category}`;
836
836
  }
837
837
  }
838
- function mo(s, e) {
838
+ function wo(s, e) {
839
839
  return {
840
840
  load: async () => En(s, e),
841
841
  save: async (t) => s.setItem(e, JSON.stringify(t))
@@ -845,31 +845,31 @@ function En(s, e) {
845
845
  const t = s.getItem(e);
846
846
  if (!t) return [];
847
847
  const n = JSON.parse(t);
848
- return Array.isArray(n) ? n.filter(nt) : [];
848
+ return Array.isArray(n) ? n.filter(rt) : [];
849
849
  }
850
- function Ge(s) {
850
+ function Ve(s) {
851
851
  return `${s.level}:${s.key}`;
852
852
  }
853
- function Is(s) {
853
+ function Ss(s) {
854
854
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
855
855
  }
856
- function nt(s) {
856
+ function rt(s) {
857
857
  if (!s || typeof s != "object") return !1;
858
858
  const e = s;
859
- return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Is(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
859
+ return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Ss(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
860
860
  }
861
- const kn = {
861
+ const Cn = {
862
862
  working: "⏳",
863
863
  completed: "✅",
864
864
  failed: "❗",
865
865
  stopped: "⏹️"
866
- }, Cn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
- function Pn(s, e) {
868
- if (!e) return Pe(s);
869
- const t = Pe(s), n = `${kn[e]} Pluno`;
866
+ }, Pn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
+ function _n(s, e) {
868
+ if (!e) return _e(s);
869
+ const t = _e(s), n = `${Cn[e]} Pluno`;
870
870
  return t ? `${n}: ${t}` : n;
871
871
  }
872
- class yo {
872
+ class Ao {
873
873
  constructor(e) {
874
874
  this.titleDocument = e;
875
875
  }
@@ -891,10 +891,10 @@ class yo {
891
891
  }
892
892
  applyStatus(e) {
893
893
  const t = this.titleDocument.getTitle();
894
- t !== this.lastAppliedTitle && (this.baseTitle = Pe(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
894
+ t !== this.lastAppliedTitle && (this.baseTitle = _e(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
895
895
  }
896
896
  applyClear() {
897
- const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? Pe(e) : e;
897
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? _e(e) : e;
898
898
  this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : n !== e && this.titleDocument.setTitle(n);
899
899
  }
900
900
  handleTitleChanged() {
@@ -903,11 +903,11 @@ class yo {
903
903
  applyTitle() {
904
904
  if (!this.status)
905
905
  return;
906
- const e = Pn(this.baseTitle, this.status);
906
+ const e = _n(this.baseTitle, this.status);
907
907
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
908
908
  }
909
909
  }
910
- function Io(s) {
910
+ function Mo(s) {
911
911
  return {
912
912
  getTitle: () => s.title,
913
913
  setTitle: (e) => {
@@ -923,10 +923,10 @@ function Io(s) {
923
923
  }
924
924
  };
925
925
  }
926
- function Pe(s) {
927
- return s.replace(Cn, "");
926
+ function _e(s) {
927
+ return s.replace(Pn, "");
928
928
  }
929
- function So(s) {
929
+ function bo(s) {
930
930
  if (!s || typeof s != "object" || !("type" in s)) return !1;
931
931
  const e = s;
932
932
  switch (e.type) {
@@ -963,9 +963,9 @@ function So(s) {
963
963
  return !1;
964
964
  }
965
965
  }
966
- class To {
966
+ class Ro {
967
967
  constructor(e, t, n) {
968
- this.adapter = t, this.state = Qe(e), this.model = n;
968
+ this.adapter = t, this.state = Xe(e), this.model = n;
969
969
  }
970
970
  adapter;
971
971
  listeners = {};
@@ -974,7 +974,7 @@ class To {
974
974
  interactionListeners = /* @__PURE__ */ new Set();
975
975
  accountListeners = /* @__PURE__ */ new Set();
976
976
  state;
977
- sessionHistoryState = be("unavailable");
977
+ sessionHistoryState = Re("unavailable");
978
978
  model;
979
979
  interactions = [];
980
980
  account = null;
@@ -986,12 +986,12 @@ class To {
986
986
  return n.add(t), this.listeners[e] = n, () => n.delete(t);
987
987
  }
988
988
  getState() {
989
- return Qe(this.state);
989
+ return Xe(this.state);
990
990
  }
991
991
  updateProjection(e, t, n, i, r) {
992
992
  if (!this.destroyed) {
993
- if (this.state = Qe(e), t !== void 0 && (this.model = t), n) {
994
- this.sessionHistoryState = Ot(n);
993
+ if (this.state = Xe(e), t !== void 0 && (this.model = t), n) {
994
+ this.sessionHistoryState = Nt(n);
995
995
  for (const o of this.sessionHistoryListeners)
996
996
  o(this.getSessionHistoryState());
997
997
  }
@@ -1067,9 +1067,9 @@ class To {
1067
1067
  c.push(u);
1068
1068
  continue;
1069
1069
  }
1070
- const h = u.id ? this.attachmentFiles.get(u.id) : void 0;
1071
- if (!h) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1072
- c.push(await this.adapter.uploadAttachment(h, u, { clientMessageId: r }));
1070
+ const d = u.id ? this.attachmentFiles.get(u.id) : void 0;
1071
+ if (!d) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1072
+ c.push(await this.adapter.uploadAttachment(d, u, { clientMessageId: r }));
1073
1073
  }
1074
1074
  o = c;
1075
1075
  }
@@ -1133,12 +1133,12 @@ class To {
1133
1133
  await this.dispatch({ type: "session.list", ...e });
1134
1134
  const t = this.sessionHistoryState.data;
1135
1135
  return {
1136
- sessions: ys(t),
1136
+ sessions: Is(t),
1137
1137
  nextCursor: t?.nextCursor ?? null
1138
1138
  };
1139
1139
  }
1140
1140
  getSessionHistoryState() {
1141
- return Ot(this.sessionHistoryState);
1141
+ return Nt(this.sessionHistoryState);
1142
1142
  }
1143
1143
  subscribeSessionHistory(e) {
1144
1144
  return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
@@ -1217,7 +1217,7 @@ class To {
1217
1217
  for (const i of n ?? []) i(t);
1218
1218
  }
1219
1219
  }
1220
- function Qe(s) {
1220
+ function Xe(s) {
1221
1221
  return {
1222
1222
  ...s,
1223
1223
  starterPrompts: [...s.starterPrompts],
@@ -1238,23 +1238,31 @@ function Qe(s) {
1238
1238
  activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1239
1239
  };
1240
1240
  }
1241
- function Ot(s) {
1241
+ function Nt(s) {
1242
1242
  return {
1243
1243
  ...s,
1244
- data: s.data ? Re({
1245
- entities: ys(s.data).map((e) => ({ ...e })),
1244
+ data: s.data ? ke({
1245
+ entities: Is(s.data).map((e) => ({ ...e })),
1246
1246
  nextCursor: s.data.nextCursor
1247
1247
  }) : null
1248
1248
  };
1249
1249
  }
1250
- const _n = globalThis.fetch.bind(globalThis), xt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', vn = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Un = ".pluno-pa-widget__panel", Dn = ".pluno-pa-widget__timeline", qn = "__plunoExtensionWidgetOwner";
1251
- function On(s) {
1250
+ const vn = globalThis.fetch.bind(globalThis), Ht = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Un = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Dn = ".pluno-pa-widget__panel", qn = ".pluno-pa-widget__timeline", On = "__plunoExtensionWidgetOwner";
1251
+ class ee extends Error {
1252
+ constructor(e, t, n, i) {
1253
+ super(e), this.retryable = t, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
1254
+ }
1255
+ retryable;
1256
+ status;
1257
+ retryAfterMs;
1258
+ }
1259
+ function xn(s) {
1252
1260
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
1253
1261
  }
1254
- let xn = 0;
1255
- function Lt(s) {
1262
+ let Ln = 0;
1263
+ function Bt(s) {
1256
1264
  const e = {};
1257
- for (const o of [
1265
+ for (const l of [
1258
1266
  "type",
1259
1267
  "requestId",
1260
1268
  "clientMessageId",
@@ -1262,12 +1270,16 @@ function Lt(s) {
1262
1270
  "warmupId",
1263
1271
  "runId",
1264
1272
  "itemId",
1273
+ "callId",
1274
+ "responseId",
1275
+ "respondsToUserMessageId",
1276
+ "status",
1265
1277
  "reason",
1266
1278
  "phase",
1267
1279
  "elapsedMs"
1268
1280
  ]) {
1269
- const a = s[o];
1270
- (typeof a == "string" || typeof a == "number" || typeof a == "boolean" || a === null) && (e[o] = a);
1281
+ const c = s[l];
1282
+ (typeof c == "string" || typeof c == "number" || typeof c == "boolean" || c === null) && (e[l] = c);
1271
1283
  }
1272
1284
  const t = s.content;
1273
1285
  typeof t == "string" && (e.contentLength = t.length);
@@ -1275,22 +1287,44 @@ function Lt(s) {
1275
1287
  typeof n == "string" && (e.deltaLength = n.length);
1276
1288
  const i = s.attachments;
1277
1289
  Array.isArray(i) && (e.attachmentCount = i.length);
1278
- const r = s.session;
1279
- if (r && typeof r == "object") {
1280
- const o = r;
1281
- typeof o.id == "string" && (e.sessionId = o.id);
1282
- const a = o.metadata;
1283
- if (a && typeof a == "object") {
1284
- const l = a.composerPreload;
1285
- if (l && typeof l == "object") {
1286
- const c = l.runId;
1287
- e.composerPreloaded = !0, typeof c == "string" && (e.preloadRunId = c);
1290
+ const r = (l) => {
1291
+ if (!l || typeof l != "object")
1292
+ return null;
1293
+ const c = l, u = c.data, d = u && typeof u == "object" ? u : {}, g = ve(l);
1294
+ return {
1295
+ id: typeof c.id == "string" ? c.id : null,
1296
+ type: typeof d.type == "string" ? d.type : null,
1297
+ role: typeof d.role == "string" ? d.role : null,
1298
+ sessionId: typeof c.sessionId == "string" ? c.sessionId : null,
1299
+ runId: typeof d.runId == "string" ? d.runId : null,
1300
+ respondsToUserMessageId: typeof d.respondsToUserMessageId == "string" ? d.respondsToUserMessageId : null,
1301
+ status: typeof d.status == "string" ? d.status : null,
1302
+ stage: typeof d.stage == "string" ? d.stage : null,
1303
+ retryable: d.retryable === !0,
1304
+ visible: !!(g && !g.scheduledCheckInAt && g.toolName !== St && (d.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(d.status))))
1305
+ };
1306
+ }, o = r(s.item);
1307
+ if (o?.id && (e.itemId = o.id, o.type && (e.itemType = o.type), o.role && (e.itemRole = o.role), o.sessionId && typeof e.sessionId != "string" && (e.sessionId = o.sessionId), o.runId && typeof e.runId != "string" && (e.runId = o.runId), o.respondsToUserMessageId && typeof e.respondsToUserMessageId != "string" && (e.respondsToUserMessageId = o.respondsToUserMessageId), o.status && (e.itemStatus = o.status), o.stage && (e.itemStage = o.stage), o.retryable && (e.itemRetryable = !0), o.visible && (e.visibleItemId = o.id)), Array.isArray(s.items)) {
1308
+ const l = s.items.map(r).filter((c) => c !== null && c.visible && !!c.id).map((c) => c.id);
1309
+ e.visibleItemIds = JSON.stringify(l);
1310
+ }
1311
+ s.type === "chat.assistant_delta" && typeof s.itemId == "string" && (e.visibleItemId = s.itemId);
1312
+ const a = s.session;
1313
+ if (a && typeof a == "object") {
1314
+ const l = a;
1315
+ typeof l.id == "string" && (e.sessionId = l.id);
1316
+ const c = l.metadata;
1317
+ if (c && typeof c == "object") {
1318
+ const u = c.composerPreload;
1319
+ if (u && typeof u == "object") {
1320
+ const d = u.runId;
1321
+ e.composerPreloaded = !0, typeof d == "string" && (e.preloadRunId = d);
1288
1322
  }
1289
1323
  }
1290
1324
  }
1291
1325
  return e;
1292
1326
  }
1293
- function Ve(s, e, t) {
1327
+ function Je(s, e, t) {
1294
1328
  if (typeof window > "u")
1295
1329
  return;
1296
1330
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -1302,54 +1336,74 @@ function Ve(s, e, t) {
1302
1336
  source: "web_sdk",
1303
1337
  category: s,
1304
1338
  name: e,
1305
- sequence: ++xn,
1339
+ sequence: ++Ln,
1306
1340
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
1307
1341
  monotonicMs: performance.now(),
1308
1342
  data: t
1309
1343
  };
1310
1344
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: i }));
1311
1345
  }
1312
- class Ie extends Error {
1346
+ class Se extends Error {
1313
1347
  }
1314
- function Ln(s) {
1348
+ function Nn(s) {
1315
1349
  return s === 408 || s === 425 || s === 429 || s >= 500;
1316
1350
  }
1317
- const Nn = "https://app.pluno.ai", Hn = 2e4, Bn = 1e4, Wn = 1e4, $n = 1e4, Fn = 1e4, jn = 3e3, zn = 3e4, Kn = 1e3, Nt = 3e4, Ht = 0.2, Gn = 6e4, Bt = 15e3, Qn = 8, Vn = "Browser connection was interrupted.", Wt = 15e3, Xn = "Pluno could not send this message. Try it again.", Jn = 2e3, Yn = 1e3, Zn = 100, $t = 8e3, Ft = 3, ei = [300, 1e3], Ss = 50 * 1024 * 1024, ti = /* @__PURE__ */ new Set([
1351
+ const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, $n = 6e4, Fn = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, $t = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", Ft = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
1318
1352
  ".jpeg:image/jpeg",
1319
1353
  ".jpg:image/jpeg",
1320
1354
  ".pdf:application/pdf",
1321
1355
  ".png:image/png",
1322
1356
  ".webp:image/webp"
1323
- ]), wo = ".pdf,.png,.jpg,.jpeg,.webp", yt = 64e3, Xe = 4e3, It = 30, si = 2e3, ni = 1e3, Ts = "Image is too large for model vision input.", ii = 100, ri = 20, ws = "pluno.productAgent.state.", it = "pluno.productAgent.pendingEvents.", qe = "pluno.productAgent.activeToolCalls.", oi = 100;
1324
- function ai(s, e = 0) {
1357
+ ]), ko = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", xe = "pluno.productAgent.activeToolCalls.", ci = 100;
1358
+ function ui(s, e = 0) {
1325
1359
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1326
1360
  return Math.max(e, t);
1327
1361
  }
1328
1362
  const Ee = /* @__PURE__ */ new Set();
1329
- let Se = null;
1330
- function li(s, e = Math.random) {
1331
- const t = Math.min(Nt, Kn * 2 ** s), n = 1 - Ht + e() * Ht * 2;
1332
- return Math.min(Nt, Math.round(t * n));
1363
+ let Te = null;
1364
+ function di(s, e = Math.random) {
1365
+ const t = Math.min(ot, Qn * 2 ** s), n = 1 - Wt + e() * Wt * 2;
1366
+ return Math.min(ot, Math.round(t * n));
1333
1367
  }
1334
- function ci(s, e, t) {
1335
- return new Promise((n, i) => {
1336
- const r = setTimeout(() => i(new Error(t)), e);
1337
- s.then(
1338
- (o) => {
1339
- clearTimeout(r), n(o);
1340
- },
1341
- (o) => {
1342
- clearTimeout(r), i(o);
1343
- }
1344
- );
1345
- });
1368
+ function hi(s) {
1369
+ const e = s.split(".")[1];
1370
+ if (!e)
1371
+ return null;
1372
+ try {
1373
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "="), i = JSON.parse(atob(n));
1374
+ return typeof i.exp == "number" && Number.isFinite(i.exp) ? i.exp * 1e3 : null;
1375
+ } catch {
1376
+ return null;
1377
+ }
1346
1378
  }
1347
- class Oe {
1379
+ function pi(s) {
1380
+ if (s instanceof ee)
1381
+ return s.retryable;
1382
+ if (s && typeof s == "object") {
1383
+ const e = s.status;
1384
+ if (typeof e == "number")
1385
+ return e === 408 || e === 425 || e === 429 || e >= 500;
1386
+ }
1387
+ return !0;
1388
+ }
1389
+ function gi(s) {
1390
+ if (s instanceof Error)
1391
+ return s;
1392
+ if (s && typeof s == "object") {
1393
+ const e = s, t = e.data && typeof e.data == "object" ? e.data.detail : null;
1394
+ if (typeof t == "string")
1395
+ return new Error(t);
1396
+ if (typeof e.error == "string")
1397
+ return new Error(e.error);
1398
+ }
1399
+ return new Error(String(s));
1400
+ }
1401
+ class Le {
1348
1402
  constructor(e, t) {
1349
- this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new An(
1403
+ this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new Mn(
1350
1404
  e.clientId,
1351
1405
  async ({ cursor: r, limit: o, pinned: a }) => await this.listSessions({ cursor: r, limit: o, pinned: a })
1352
- ), this.sessionRecoveryPoller = new qt({
1406
+ ), this.sessionRecoveryPoller = new Lt({
1353
1407
  poll: async ({ sessionId: r }) => await this.fetchSessionHistoryPageOnce(
1354
1408
  r,
1355
1409
  "transcript",
@@ -1361,7 +1415,7 @@ class Oe {
1361
1415
  activeIntervalMs: 3e3,
1362
1416
  idleIntervalMs: 15e3,
1363
1417
  maxFailureIntervalMs: 3e4
1364
- }), this.sessionActivityRecovery = new bn({
1418
+ }), this.sessionActivityRecovery = new Rn({
1365
1419
  fetchPage: async (r, o) => await this.fetchSessionHistoryPageOnce(
1366
1420
  r,
1367
1421
  "activity",
@@ -1380,24 +1434,24 @@ class Oe {
1380
1434
  },
1381
1435
  getItemId: (r) => A(r, "id"),
1382
1436
  maxPagesPerPoll: 3
1383
- }), this.sessionActivityRecoveryPoller = new qt({
1437
+ }), this.sessionActivityRecoveryPoller = new Lt({
1384
1438
  poll: async ({ sessionId: r }) => await this.sessionActivityRecovery.poll(r),
1385
1439
  apply: async (r) => await this.sessionActivityRecovery.apply(r),
1386
1440
  isActiveTurn: () => this.state.isThinking || this.state.pendingMessageStatus !== null,
1387
1441
  activeIntervalMs: 3e3,
1388
1442
  idleIntervalMs: 15e3,
1389
1443
  maxFailureIntervalMs: 3e4
1390
- }), this.personalModelSelectionOverride = e.productVariant === "personal" && Ke(e.model) ? e.model : null, this.state = {
1444
+ }), this.personalModelSelectionOverride = e.productVariant === "personal" && Qe(e.model) ? e.model : null, this.state = {
1391
1445
  ...this.state,
1392
- starterPrompts: $i(e.initialStarterPrompts)
1446
+ starterPrompts: Gi(e.initialStarterPrompts)
1393
1447
  }, this.account = e.initialAccount ? { ...e.initialAccount } : null;
1394
- const n = e.restorePersistedState === !1 ? null : Ur(e.clientId, e.expectedPersistedSessionId);
1448
+ const n = e.restorePersistedState === !1 ? null : Lr(e.clientId, e.expectedPersistedSessionId);
1395
1449
  n && (this.state = {
1396
1450
  ...this.state,
1397
1451
  ...n,
1398
1452
  // Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
1399
1453
  // activity is deliberately not restored here because it hydrates after the transcript is visible.
1400
- messages: n.messages.filter(ht),
1454
+ messages: n.messages.filter(gt),
1401
1455
  isLoadingSession: n.sessionId !== null,
1402
1456
  status: "idle",
1403
1457
  user: null,
@@ -1412,9 +1466,9 @@ class Oe {
1412
1466
  taskStatus: null,
1413
1467
  isRetrying: !1,
1414
1468
  lastError: null
1415
- }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Nr(
1416
- qr(e.clientId),
1417
- Or(e.clientId)
1469
+ }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Fr(
1470
+ Hr(e.clientId),
1471
+ Br(e.clientId)
1418
1472
  );
1419
1473
  const i = [...this.queuedClientEvents].reverse().find(
1420
1474
  (r) => r.type === "chat.user_message" && typeof r.clientMessageId == "string"
@@ -1433,6 +1487,9 @@ class Oe {
1433
1487
  connectionAttemptId = 0;
1434
1488
  connectionInProgress = !1;
1435
1489
  token = null;
1490
+ tokenExpiresAtMs = null;
1491
+ tokenRequest = null;
1492
+ tokenAbortController = null;
1436
1493
  authenticatedUserId = null;
1437
1494
  authenticatedSocket = null;
1438
1495
  networkCaptureCleanup = null;
@@ -1457,7 +1514,7 @@ class Oe {
1457
1514
  accountRefresh = null;
1458
1515
  runtimeInteractions = [];
1459
1516
  interactionListeners = /* @__PURE__ */ new Set();
1460
- interactionManager = new Rn(
1517
+ interactionManager = new kn(
1461
1518
  { load: async () => [], save: async () => {
1462
1519
  } },
1463
1520
  []
@@ -1544,18 +1601,18 @@ class Oe {
1544
1601
  lastErrorSecuritySettingsUrl: null
1545
1602
  };
1546
1603
  static async init(e) {
1547
- const t = e, n = await cn(
1604
+ const t = e, n = await un(
1548
1605
  t.skipStoredTransportIdentityCollisionCheck === !0
1549
- ), i = new Oe({
1606
+ ), i = new Le({
1550
1607
  ...e,
1551
- backendUrl: ki(e.backendUrl ?? Nn),
1552
- clientId: e.clientId ?? Gi(),
1608
+ backendUrl: Ui(e.backendUrl ?? Hn),
1609
+ clientId: e.clientId ?? Yi(),
1553
1610
  productVariant: e.productVariant ?? "customer_embedded",
1554
- entrySurface: Ci(e.entrySurface)
1611
+ entrySurface: Di(e.entrySurface)
1555
1612
  }, n);
1556
1613
  try {
1557
- Gs().catch((r) => {
1558
- R("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1614
+ Qs().catch((r) => {
1615
+ b("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1559
1616
  message: r instanceof Error ? r.message : String(r)
1560
1617
  });
1561
1618
  }), t.disableNetworkCapture || i.enableNetworkCapture(), i.startPageLifecycleRecovery(), i.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await i.connect();
@@ -1592,24 +1649,68 @@ class Oe {
1592
1649
  }, r = this.state.messages.findIndex((a) => a.id === n), o = [...this.state.messages];
1593
1650
  r >= 0 ? o[r] = i : o.push(i), this.setState({ messages: o }), this.emit("message", i);
1594
1651
  }
1652
+ invalidateProviderToken() {
1653
+ this.options.token || (this.token = null, this.tokenExpiresAtMs = null);
1654
+ }
1655
+ async acquireToken(e, t = {}) {
1656
+ if (this.options.token)
1657
+ return this.options.token;
1658
+ if (!this.options.tokenProvider)
1659
+ return this.token;
1660
+ const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - Fn > n;
1661
+ if (!t.forceRefresh && (i || t.preferCached && this.token !== null))
1662
+ return this.token;
1663
+ if (this.tokenRequest && !t.forceRefresh)
1664
+ return await this.tokenRequest;
1665
+ t.forceRefresh && (this.tokenAbortController?.abort(), this.tokenRequest = null, this.invalidateProviderToken());
1666
+ const r = new AbortController();
1667
+ this.tokenAbortController = r;
1668
+ const o = (async () => {
1669
+ let a = null;
1670
+ const l = new Promise((c, u) => {
1671
+ a = window.setTimeout(() => {
1672
+ r.abort(), u(new ee("Pluno token provider timed out", !0));
1673
+ }, $n);
1674
+ });
1675
+ try {
1676
+ const c = await Promise.race([
1677
+ this.options.tokenProvider?.({ signal: r.signal, reason: e }) ?? Promise.resolve(""),
1678
+ l
1679
+ ]);
1680
+ if (r.signal.aborted || this.tokenAbortController !== r)
1681
+ throw new ee("Pluno token request was cancelled", !0);
1682
+ if (!c)
1683
+ throw new ee("Pluno token provider did not return a token", !1);
1684
+ return this.token = c, this.tokenExpiresAtMs = hi(c), c;
1685
+ } finally {
1686
+ a !== null && window.clearTimeout(a);
1687
+ }
1688
+ })();
1689
+ this.tokenRequest = o;
1690
+ try {
1691
+ return await o;
1692
+ } finally {
1693
+ this.tokenRequest === o && (this.tokenRequest = null, this.tokenAbortController = null);
1694
+ }
1695
+ }
1595
1696
  async connect() {
1596
1697
  if (this.connectionInProgress || this.socket?.readyState === WebSocket.OPEN || this.socket?.readyState === WebSocket.CONNECTING)
1597
1698
  return;
1598
- this.connectionInProgress = !0;
1699
+ this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null, this.reconnectAttempts = 0), this.connectionInProgress = !0;
1599
1700
  const e = ++this.connectionAttemptId;
1600
1701
  this.setState(
1601
1702
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
1602
1703
  );
1603
1704
  try {
1604
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await ci(this.options.tokenProvider(), Wn, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
1705
+ if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
1605
1706
  return;
1606
1707
  if (!this.token && !this.options.webSocketFactory)
1607
- throw new Error("Pluno requires a token or tokenProvider");
1608
- const t = vi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1708
+ throw new ee("Pluno requires a token or tokenProvider", !1);
1709
+ const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1609
1710
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
1610
- this.socket === n && n.readyState === WebSocket.CONNECTING && (R("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
1611
- }, $n), n.addEventListener("open", () => {
1612
- this.socket !== n || (this.clearSocketConnectTimer(), R("web-sdk.agent", "Pluno socket opened", {
1711
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
1712
+ }, jn), n.addEventListener("open", () => {
1713
+ this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
1613
1714
  queuedClientEventCount: this.queuedClientEvents.length,
1614
1715
  isThinking: this.state.isThinking
1615
1716
  }), !(this.token ? this.sendNow({
@@ -1619,19 +1720,19 @@ class Oe {
1619
1720
  transportId: this.transportIdentity.transportId,
1620
1721
  pageUrl: location.href
1621
1722
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
1622
- this.socket === n && (R("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
1623
- }, Fn));
1723
+ this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
1724
+ }, zn));
1624
1725
  }), n.addEventListener("message", (i) => {
1625
- this.socket === n && this.handleServerEvent(Bi(i.data));
1726
+ this.socket === n && this.handleServerEvent(zi(i.data));
1626
1727
  }), n.addEventListener("sendfailure", (i) => {
1627
1728
  if (this.socket !== n)
1628
1729
  return;
1629
- const r = Wi(i?.detail?.data);
1730
+ const r = Ki(i?.detail?.data);
1630
1731
  r?.type === "chat.user_message" && r.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
1631
1732
  (o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
1632
1733
  ) && (this.queuedClientEvents.push(r), V(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();
1633
1734
  }), n.addEventListener("close", (i) => {
1634
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (R("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
1735
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (b("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
1635
1736
  code: typeof i?.code == "number" ? i.code : null,
1636
1737
  reason: typeof i?.reason == "string" ? i.reason : "",
1637
1738
  wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
@@ -1639,30 +1740,42 @@ class Oe {
1639
1740
  isThinking: this.state.isThinking
1640
1741
  }), this.setReconnectingState(), this.scheduleReconnect()));
1641
1742
  }), n.addEventListener("error", () => {
1642
- this.socket !== n || this.state.status === "closed" || (R("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1743
+ this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1643
1744
  queuedClientEventCount: this.queuedClientEvents.length,
1644
1745
  isThinking: this.state.isThinking
1645
1746
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
1646
1747
  });
1647
1748
  } catch (t) {
1648
- if (e === this.connectionAttemptId && this.state.status !== "closed") {
1649
- const n = t instanceof Error ? t : new Error(String(t));
1650
- this.setState({
1651
- status: "error",
1652
- lastError: n.message,
1749
+ if (e !== this.connectionAttemptId || this.state.status === "closed")
1750
+ return;
1751
+ const n = gi(t);
1752
+ if (pi(t)) {
1753
+ b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
1754
+ message: n.message,
1755
+ reconnectAttempt: this.reconnectAttempts
1756
+ }), this.setState({
1757
+ status: "reconnecting",
1758
+ lastError: Zn,
1653
1759
  lastErrorCode: "connection_failed"
1654
- }), this.emit("error", n);
1760
+ }), this.emit("error", n), this.scheduleReconnect(
1761
+ t instanceof ee ? t.retryAfterMs : void 0
1762
+ );
1763
+ return;
1655
1764
  }
1656
- throw t;
1765
+ throw this.setState({
1766
+ status: "error",
1767
+ lastError: n.message,
1768
+ lastErrorCode: "connection_failed"
1769
+ }), this.emit("error", n), n;
1657
1770
  } finally {
1658
1771
  this.connectionInProgress = !1;
1659
1772
  }
1660
1773
  }
1661
1774
  disconnect() {
1662
- this.stopSessionRecoveryPolling(), 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.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
1775
+ this.stopSessionRecoveryPolling(), 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.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
1663
1776
  }
1664
1777
  destroy() {
1665
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Hr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
1778
+ 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 = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
1666
1779
  for (const e of Object.values(this.listeners))
1667
1780
  e?.clear();
1668
1781
  this.accountListeners.clear(), this.interactionListeners.clear();
@@ -1702,12 +1815,12 @@ class Oe {
1702
1815
  }
1703
1816
  async sendMessage(e, t = {}) {
1704
1817
  const n = e.trim(), i = t.attachments ?? [];
1705
- if (this.options.productVariant === "customer_embedded" && (i.forEach(qs), i.reduce(
1818
+ if (this.options.productVariant === "customer_embedded" && (i.forEach(Os), i.reduce(
1706
1819
  (T, N) => T + N.sizeBytes,
1707
1820
  0
1708
- ) > Ss))
1821
+ ) > Ts))
1709
1822
  throw new Error("Embedded attachments must total at most 50 MB per message");
1710
- let r = i.map(ve);
1823
+ let r = i.map(De);
1711
1824
  if (!n && r.length === 0)
1712
1825
  return null;
1713
1826
  if (this.pendingClientMessageId)
@@ -1720,13 +1833,13 @@ class Oe {
1720
1833
  phase: "final_answer",
1721
1834
  content: l,
1722
1835
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
1723
- } : null, h = {
1836
+ } : null, d = {
1724
1837
  id: `local-${a}`,
1725
1838
  role: "user",
1726
1839
  content: n,
1727
1840
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1728
1841
  ...i.length > 0 ? { attachments: i } : {}
1729
- }, f = this.state.messages.some((S) => S.id === h.id || S.clientMessageId === a), y = this.state.isThinking, d = this.state.taskStatus, p = this.state.pendingMessageStatus, m = this.state.turnPhase, g = this.state.messages, M = f ? this.state.messages : [
1842
+ }, g = this.state.messages.some((S) => S.id === d.id || S.clientMessageId === a), f = this.state.isThinking, h = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, m = this.state.messages, M = g ? this.state.messages : [
1730
1843
  ...this.state.messages.map(
1731
1844
  (S) => c && S.id === c.id ? {
1732
1845
  ...S,
@@ -1734,7 +1847,7 @@ class Oe {
1734
1847
  } : S
1735
1848
  ),
1736
1849
  ...!c && u ? [u] : [],
1737
- h
1850
+ d
1738
1851
  ], w = {
1739
1852
  assistantDraft: this.state.assistantDraft,
1740
1853
  assistantDraftItemId: this.state.assistantDraftItemId,
@@ -1745,7 +1858,7 @@ class Oe {
1745
1858
  };
1746
1859
  this.setState({
1747
1860
  messages: M,
1748
- ...y ? {} : {
1861
+ ...f ? {} : {
1749
1862
  assistantDraft: "",
1750
1863
  assistantDraftItemId: null,
1751
1864
  assistantDraftPhase: null,
@@ -1753,23 +1866,23 @@ class Oe {
1753
1866
  assistantDraftRunId: null
1754
1867
  },
1755
1868
  pendingMessageStatus: "sending",
1756
- turnPhase: y ? m : "sending",
1757
- isThinking: y,
1869
+ turnPhase: f ? y : "sending",
1870
+ isThinking: f,
1758
1871
  taskStatus: "working",
1759
1872
  isRetrying: !1,
1760
1873
  lastError: null
1761
- }), f || (this.sessionHistoryManager.addOptimistic({
1762
- id: h.id,
1874
+ }), g || (this.sessionHistoryManager.addOptimistic({
1875
+ id: d.id,
1763
1876
  title: null,
1764
1877
  customTitle: null,
1765
- firstUserMessage: h.content,
1878
+ firstUserMessage: d.content,
1766
1879
  currentPage: o,
1767
- createdAt: h.createdAt,
1768
- updatedAt: h.createdAt,
1769
- lastActiveAt: h.createdAt,
1880
+ createdAt: d.createdAt,
1881
+ updatedAt: d.createdAt,
1882
+ lastActiveAt: d.createdAt,
1770
1883
  isActive: !0,
1771
1884
  isPinned: !1
1772
- }), u && !c && this.emit("message", u), this.emit("message", h));
1885
+ }), u && !c && this.emit("message", u), this.emit("message", d));
1773
1886
  try {
1774
1887
  const S = [];
1775
1888
  for (const T of r) {
@@ -1784,12 +1897,12 @@ class Oe {
1784
1897
  }
1785
1898
  r = S;
1786
1899
  } catch (S) {
1787
- throw f || this.sessionHistoryManager.removeOptimistic(h.id), this.setState({
1788
- ...f ? {} : { messages: g },
1789
- ...y ? {} : { ...w, isThinking: !1 },
1900
+ throw g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1901
+ ...g ? {} : { messages: m },
1902
+ ...f ? {} : { ...w, isThinking: !1 },
1790
1903
  pendingMessageStatus: p,
1791
- turnPhase: m,
1792
- taskStatus: d
1904
+ turnPhase: y,
1905
+ taskStatus: h
1793
1906
  }), S;
1794
1907
  }
1795
1908
  this.retryableClientMessageId = null;
@@ -1798,15 +1911,15 @@ class Oe {
1798
1911
  sessionId: this.state.sessionId ?? void 0,
1799
1912
  clientMessageId: a,
1800
1913
  initiatedBy: t.initiatedBy,
1801
- invocation: Pi(t.invocation ?? t.initiatedBy),
1914
+ invocation: qi(t.invocation ?? t.initiatedBy),
1802
1915
  entrySurface: this.options.entrySurface,
1803
1916
  content: n,
1804
1917
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1805
- pageContent: D && St() || void 0,
1806
- attachments: r.length > 0 ? r.map(ve) : void 0,
1918
+ pageContent: D && At() || void 0,
1919
+ attachments: r.length > 0 ? r.map(De) : void 0,
1807
1920
  page: o,
1808
1921
  model: this.options.model,
1809
- metadata: jt(this.options.metadata)
1922
+ metadata: Kt(this.options.metadata)
1810
1923
  };
1811
1924
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1812
1925
  }
@@ -1814,7 +1927,7 @@ class Oe {
1814
1927
  return this.options.model;
1815
1928
  }
1816
1929
  setModel(e) {
1817
- this.options.model = e, this.options.productVariant === "personal" && Ke(e) && (this.personalModelSelectionOverride = e);
1930
+ this.options.model = e, this.options.productVariant === "personal" && Qe(e) && (this.personalModelSelectionOverride = e);
1818
1931
  }
1819
1932
  retryLastMessage() {
1820
1933
  const e = this.state.sessionId, t = this.retryableClientMessageId;
@@ -1832,16 +1945,16 @@ class Oe {
1832
1945
  return e ? (this.retryAttemptsByClientMessageId[t] = 0, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.activeClientMessageId = t, this.latestRecoverableClientMessageId = t, 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: t, automatic: !1 }), !0) : !1;
1833
1946
  }
1834
1947
  createLocalAttachment(e) {
1835
- this.options.productVariant === "customer_embedded" && Br(e);
1948
+ this.options.productVariant === "customer_embedded" && zr(e);
1836
1949
  const t = x(), n = {
1837
1950
  id: t,
1838
1951
  name: e.name || "attachment",
1839
- mimeType: pt(e),
1952
+ mimeType: ft(e),
1840
1953
  sizeBytes: e.size
1841
1954
  };
1842
1955
  this.attachmentFiles.set(t, e);
1843
1956
  const i = Date.now();
1844
- return zs({
1957
+ return Ks({
1845
1958
  attachmentId: t,
1846
1959
  name: n.name,
1847
1960
  mimeType: n.mimeType,
@@ -1852,7 +1965,7 @@ class Oe {
1852
1965
  createdAt: i,
1853
1966
  lastUsedAt: i
1854
1967
  }).catch((r) => {
1855
- R("web-sdk.attachments", "Failed to store Product Agent attachment", {
1968
+ b("web-sdk.attachments", "Failed to store Product Agent attachment", {
1856
1969
  attachmentId: t,
1857
1970
  name: n.name,
1858
1971
  message: r instanceof Error ? r.message : String(r)
@@ -1870,7 +1983,7 @@ class Oe {
1870
1983
  file: e,
1871
1984
  attachment: t
1872
1985
  }) {
1873
- const n = this.state.sessionId, i = pt(e), r = {
1986
+ const n = this.state.sessionId, i = ft(e), r = {
1874
1987
  sessionId: n ?? void 0,
1875
1988
  attachmentId: t.id,
1876
1989
  clientId: this.options.clientId,
@@ -1880,41 +1993,41 @@ class Oe {
1880
1993
  sizeBytes: e.size,
1881
1994
  page: P(),
1882
1995
  model: this.options.model,
1883
- metadata: jt(this.options.metadata),
1996
+ metadata: Kt(this.options.metadata),
1884
1997
  entrySurface: this.options.entrySurface
1885
1998
  };
1886
1999
  let o;
1887
2000
  if (this.options.persistAttachmentUpload)
1888
- o = await Ae(
2001
+ o = await Me(
1889
2002
  () => this.options.persistAttachmentUpload(r, e),
1890
2003
  "Failed to upload attachment"
1891
2004
  );
1892
2005
  else {
1893
- const l = this.options.prepareAttachmentUpload ? await Ae(
2006
+ const l = this.options.prepareAttachmentUpload ? await Me(
1894
2007
  () => this.options.prepareAttachmentUpload(r),
1895
2008
  "Failed to prepare attachment upload"
1896
2009
  ) : await this.prepareEmbedAttachmentUpload(r);
1897
- await Ae(async () => {
2010
+ await Me(async () => {
1898
2011
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
1899
2012
  method: l.uploadMethod,
1900
2013
  headers: l.uploadHeaders,
1901
2014
  body: e
1902
2015
  });
1903
2016
  if (!c.ok)
1904
- throw new Ce("Failed to upload attachment", c.status);
2017
+ throw new Pe("Failed to upload attachment", c.status);
1905
2018
  return c;
1906
2019
  }, "Failed to upload attachment"), o = l;
1907
2020
  }
1908
2021
  this.setState({ sessionId: o.sessionId });
1909
- const a = Ds(o.attachment, this.options.backendUrl);
1910
- return this.updateAttachmentInState(t.id, a), t.id && Ks(t.id, {
2022
+ const a = qs(o.attachment, this.options.backendUrl);
2023
+ return this.updateAttachmentInState(t.id, a), t.id && Gs(t.id, {
1911
2024
  sessionId: o.sessionId,
1912
2025
  fileUrl: a.fileUrl,
1913
2026
  sandboxPath: a.sandboxPath,
1914
2027
  storageKey: a.storageKey,
1915
2028
  lastUsedAt: Date.now()
1916
2029
  }).catch((l) => {
1917
- R("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
2030
+ b("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
1918
2031
  attachmentId: t.id,
1919
2032
  name: a.name,
1920
2033
  message: l instanceof Error ? l.message : String(l)
@@ -1934,26 +2047,26 @@ class Oe {
1934
2047
  }
1935
2048
  async prepareEmbedAttachmentUpload(e) {
1936
2049
  let t = !1;
1937
- return await Ae(async () => {
1938
- const n = await this.fetchEmbedAttachmentUpload(e);
2050
+ return await Me(async () => {
2051
+ const n = await this.fetchEmbedAttachmentUpload(e, !1);
1939
2052
  if (n.ok)
1940
2053
  return await n.json();
1941
- if (no(n.status) && this.options.tokenProvider && !t) {
2054
+ if (lo(n.status) && this.options.tokenProvider && !t) {
1942
2055
  t = !0;
1943
- const i = await this.fetchEmbedAttachmentUpload(e);
2056
+ const i = await this.fetchEmbedAttachmentUpload(e, !0);
1944
2057
  if (i.ok)
1945
2058
  return await i.json();
1946
- throw new Ce("Failed to prepare attachment upload", i.status);
2059
+ throw new Pe("Failed to prepare attachment upload", i.status);
1947
2060
  }
1948
- throw new Ce("Failed to prepare attachment upload", n.status);
2061
+ throw new Pe("Failed to prepare attachment upload", n.status);
1949
2062
  }, "Failed to prepare attachment upload");
1950
2063
  }
1951
- async fetchEmbedAttachmentUpload(e) {
1952
- const t = await this.getUploadToken();
2064
+ async fetchEmbedAttachmentUpload(e, t) {
2065
+ const n = await this.getUploadToken(t);
1953
2066
  return await fetch(new URL("/api/product-agent/embed/attachments/upload", this.options.backendUrl), {
1954
2067
  method: "POST",
1955
2068
  headers: {
1956
- authorization: `Bearer ${t}`,
2069
+ authorization: `Bearer ${n}`,
1957
2070
  "content-type": "application/json"
1958
2071
  },
1959
2072
  body: JSON.stringify(e)
@@ -1963,7 +2076,7 @@ class Oe {
1963
2076
  if (!this.state.sessionId)
1964
2077
  return;
1965
2078
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
1966
- const e = Ar(
2079
+ const e = Er(
1967
2080
  this.state.messages,
1968
2081
  this.state.assistantDraftRespondsToUserMessageId,
1969
2082
  this.state.assistantDraftRunId,
@@ -1978,7 +2091,7 @@ class Oe {
1978
2091
  stoppedCausalSequence: null,
1979
2092
  toolCallIds: new Set(
1980
2093
  this.state.messages.filter(
1981
- (t) => we(
2094
+ (t) => Ae(
1982
2095
  t,
1983
2096
  e.respondsToUserMessageId,
1984
2097
  e.runId
@@ -1988,8 +2101,8 @@ class Oe {
1988
2101
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
1989
2102
  for (const [t, n] of this.activeBrowserToolCalls)
1990
2103
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
1991
- os(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
1992
- messages: ns(
2104
+ ls(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
2105
+ messages: rs(
1993
2106
  this.state.messages,
1994
2107
  e.clientMessageId,
1995
2108
  e.runId
@@ -2033,7 +2146,7 @@ class Oe {
2033
2146
  const t = x(), n = new Promise((r, o) => {
2034
2147
  const a = window.setTimeout(() => {
2035
2148
  this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
2036
- }, $t);
2149
+ }, jt);
2037
2150
  this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
2038
2151
  }), i = {
2039
2152
  type: "sessions.list",
@@ -2098,7 +2211,7 @@ class Oe {
2098
2211
  throw new Error("This interaction is no longer available.");
2099
2212
  if (!r.allowedActions.includes(t))
2100
2213
  throw new Error("This action is not available for the interaction.");
2101
- if (On(t) && await this.interactionManager.act(
2214
+ if (xn(t) && await this.interactionManager.act(
2102
2215
  {
2103
2216
  key: r.id,
2104
2217
  category: r.category,
@@ -2147,7 +2260,7 @@ class Oe {
2147
2260
  this.rebuildRuntimeInteractions();
2148
2261
  }
2149
2262
  rebuildRuntimeInteractions() {
2150
- const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? Js(this.state.messages) : null;
2263
+ const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? Ys(this.state.messages) : null;
2151
2264
  if (t) {
2152
2265
  const r = {
2153
2266
  key: t.id,
@@ -2273,7 +2386,7 @@ class Oe {
2273
2386
  loadSession(e) {
2274
2387
  const t = x(), n = this.activeComposerWarmupId;
2275
2388
  this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages);
2276
- const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Tr(i ?? []);
2389
+ const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Rr(i ?? []);
2277
2390
  !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !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({
2278
2391
  type: "session.reset",
2279
2392
  warmupId: n,
@@ -2379,9 +2492,9 @@ class Oe {
2379
2492
  try {
2380
2493
  return await this.fetchSessionHistoryPageOnce(e, t, n);
2381
2494
  } catch (o) {
2382
- if (o instanceof Ie)
2495
+ if (o instanceof Se)
2383
2496
  throw o;
2384
- R("web-sdk.history", "HTTP session history page failed; retrying", {
2497
+ b("web-sdk.history", "HTTP session history page failed; retrying", {
2385
2498
  sessionId: e,
2386
2499
  hasCursor: !!n,
2387
2500
  retryDelayMs: r,
@@ -2391,9 +2504,9 @@ class Oe {
2391
2504
  return null;
2392
2505
  }
2393
2506
  async fetchSessionHistoryPageOnce(e, t, n, i = !1) {
2394
- const r = this.options.token ?? (i ? this.token : null) ?? await this.options.tokenProvider?.() ?? this.token;
2507
+ const r = await this.acquireToken("history", { preferCached: i });
2395
2508
  if (!r)
2396
- throw new Ie("Product Agent history requires authentication");
2509
+ throw new Se("Product Agent history requires authentication");
2397
2510
  this.token = r;
2398
2511
  const o = new URLSearchParams({ limit: "200" });
2399
2512
  n && o.set("cursor", n);
@@ -2406,12 +2519,12 @@ class Oe {
2406
2519
  signal: AbortSignal.timeout(15e3)
2407
2520
  });
2408
2521
  if (!c.ok) {
2409
- const h = await c.text() || `History request failed (${c.status})`;
2410
- throw Ln(c.status) ? new Error(h) : new Ie(h);
2522
+ const d = await c.text() || `History request failed (${c.status})`;
2523
+ throw Nn(c.status) ? new Error(d) : new Se(d);
2411
2524
  }
2412
2525
  const u = await c.json();
2413
2526
  if (!u?.session || !Array.isArray(u.items))
2414
- throw new Ie("Invalid Product Agent session history response");
2527
+ throw new Se("Invalid Product Agent session history response");
2415
2528
  return {
2416
2529
  session: u.session,
2417
2530
  items: u.items,
@@ -2424,7 +2537,7 @@ class Oe {
2424
2537
  return;
2425
2538
  const r = n instanceof Error ? n.message : String(n);
2426
2539
  if (i) {
2427
- this.sessionActivityRequestId = null, R("web-sdk.history", "Background session activity hydration stopped", {
2540
+ this.sessionActivityRequestId = null, b("web-sdk.history", "Background session activity hydration stopped", {
2428
2541
  sessionId: t,
2429
2542
  message: r
2430
2543
  });
@@ -2436,7 +2549,7 @@ class Oe {
2436
2549
  message: r,
2437
2550
  requestId: e,
2438
2551
  sessionId: t
2439
- }), R("web-sdk.history", "HTTP session history page failed permanently", {
2552
+ }), b("web-sdk.history", "HTTP session history page failed permanently", {
2440
2553
  sessionId: t,
2441
2554
  message: r
2442
2555
  });
@@ -2449,20 +2562,22 @@ class Oe {
2449
2562
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
2450
2563
  }), this.scheduleReconnect());
2451
2564
  }
2452
- async getUploadToken() {
2453
- const e = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
2454
- if (!e)
2565
+ async getUploadToken(e = !1) {
2566
+ const t = await this.acquireToken("upload", {
2567
+ forceRefresh: e
2568
+ });
2569
+ if (!t)
2455
2570
  throw new Error("Pluno attachment upload requires a token or tokenProvider");
2456
- return this.token = e, e;
2571
+ return this.token = t, t;
2457
2572
  }
2458
2573
  sendNow(e) {
2459
2574
  if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
2460
2575
  return !1;
2461
2576
  const t = this.socket;
2462
2577
  try {
2463
- return t.send(JSON.stringify(e)), Ve("client_event", e.type, Lt(e)), !0;
2578
+ return t.send(JSON.stringify(e)), Je("client_event", e.type, Bt(e)), !0;
2464
2579
  } catch (n) {
2465
- return R("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2580
+ return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2466
2581
  message: n instanceof Error ? n.message : String(n),
2467
2582
  queuedClientEventCount: this.queuedClientEvents.length,
2468
2583
  isThinking: this.state.isThinking
@@ -2494,7 +2609,7 @@ class Oe {
2494
2609
  }
2495
2610
  }));
2496
2611
  } catch (i) {
2497
- R("web-sdk.agent", "Pluno health signal send failed", {
2612
+ b("web-sdk.agent", "Pluno health signal send failed", {
2498
2613
  name: e,
2499
2614
  message: i instanceof Error ? i.message : String(i)
2500
2615
  });
@@ -2504,7 +2619,7 @@ class Oe {
2504
2619
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
2505
2620
  return;
2506
2621
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
2507
- const e = Ui();
2622
+ const e = Li();
2508
2623
  this.sendNow(
2509
2624
  L({
2510
2625
  type: "starter_prompts.page_context",
@@ -2515,13 +2630,13 @@ class Oe {
2515
2630
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
2516
2631
  }
2517
2632
  startStarterPromptUrlWatcher() {
2518
- this.locationChangeCleanup || (this.locationChangeCleanup = Di(() => this.handleStarterPromptUrlChange()));
2633
+ this.locationChangeCleanup || (this.locationChangeCleanup = Ni(() => this.handleStarterPromptUrlChange()));
2519
2634
  }
2520
2635
  handleStarterPromptUrlChange() {
2521
2636
  const e = location.href;
2522
2637
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
2523
2638
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
2524
- }, oi));
2639
+ }, ci));
2525
2640
  }
2526
2641
  refreshStarterPromptsForCurrentUrl() {
2527
2642
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -2551,7 +2666,7 @@ class Oe {
2551
2666
  }
2552
2667
  rememberSessionTimeline(e, t) {
2553
2668
  const n = [...t];
2554
- for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > ri; ) {
2669
+ for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > li; ) {
2555
2670
  const i = this.sessionTimelineCache.keys().next().value;
2556
2671
  if (!i)
2557
2672
  break;
@@ -2581,8 +2696,8 @@ class Oe {
2581
2696
  return;
2582
2697
  this.clearPendingWarmupAckTimer();
2583
2698
  const t = Math.min(
2584
- jn * 2 ** e.retryAttempt,
2585
- zn
2699
+ Kn * 2 ** e.retryAttempt,
2700
+ Gn
2586
2701
  );
2587
2702
  e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
2588
2703
  this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
@@ -2603,9 +2718,9 @@ class Oe {
2603
2718
  }
2604
2719
  rememberDurablyStoppedTurn(e, t) {
2605
2720
  const n = C(t);
2606
- if (!e || !n || !ke(n) || this.findStoppedTurn(e, n))
2721
+ if (!e || !n || !Ce(n) || this.findStoppedTurn(e, n))
2607
2722
  return;
2608
- const i = O(n), r = E(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
2723
+ const i = O(n), r = k(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
2609
2724
  this.stoppedTurns.push({
2610
2725
  sessionId: e,
2611
2726
  clientMessageId: o,
@@ -2617,7 +2732,7 @@ class Oe {
2617
2732
  stoppedCausalSequence: _(n),
2618
2733
  toolCallIds: new Set(
2619
2734
  this.state.messages.filter(
2620
- (a) => we(a, i, r)
2735
+ (a) => Ae(a, i, r)
2621
2736
  ).map((a) => a.callId).filter((a) => typeof a == "string")
2622
2737
  )
2623
2738
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -2626,7 +2741,7 @@ class Oe {
2626
2741
  if (!e || !t)
2627
2742
  return;
2628
2743
  const n = this.findStoppedTurn(e, t);
2629
- !n || n.reason !== "task_tab_closed" || In(n, t) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
2744
+ !n || n.reason !== "task_tab_closed" || Sn(n, t) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
2630
2745
  messages: this.state.messages.filter((i) => i.id !== n.stoppedItemId)
2631
2746
  }));
2632
2747
  }
@@ -2635,12 +2750,12 @@ class Oe {
2635
2750
  const n = typeof e.callId == "string" ? e.callId : null;
2636
2751
  return !!(n && this.stoppedTurns.some((i) => i.toolCallIds.has(n)));
2637
2752
  }
2638
- return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !ke(C(e.item)) : e.type !== "conversation.state" : !1;
2753
+ return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Ce(C(e.item)) : e.type !== "conversation.state" : !1;
2639
2754
  }
2640
2755
  filterStoppedSnapshotItems(e, t) {
2641
2756
  return e.filter((n) => {
2642
2757
  const i = C(n), r = i ? this.findStoppedTurn(t, i) : null;
2643
- if (!r || i?.type === "message" && i.role === "user" || ke(i))
2758
+ if (!r || i?.type === "message" && i.role === "user" || Ce(i))
2644
2759
  return !0;
2645
2760
  if (r.stoppedCausalSequence !== null) {
2646
2761
  const o = i ? _(i) : null;
@@ -2654,7 +2769,7 @@ class Oe {
2654
2769
  });
2655
2770
  }
2656
2771
  handleServerEvent(e) {
2657
- if (Ve("server_event", e.type, Lt(e)), e.type === "session.subscribed") {
2772
+ if (Je("server_event", e.type, Bt(e)), e.type === "session.subscribed") {
2658
2773
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2659
2774
  if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
2660
2775
  const i = this.pendingSessionSubscription;
@@ -2667,7 +2782,7 @@ class Oe {
2667
2782
  this.pendingSessionSubscription = null, t.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
2668
2783
  return;
2669
2784
  }
2670
- if (this.sessionHistoryHydration && le(e) && K(e) === this.sessionHistoryHydration.sessionId) {
2785
+ if (this.sessionHistoryHydration && ce(e) && K(e) === this.sessionHistoryHydration.sessionId) {
2671
2786
  this.sessionHistoryHydration.bufferedEvents.push(e);
2672
2787
  return;
2673
2788
  }
@@ -2720,17 +2835,17 @@ class Oe {
2720
2835
  this.activeResponseRunId = t, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
2721
2836
  return;
2722
2837
  }
2723
- if (hi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2838
+ if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2724
2839
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
2725
- const t = Qi(e.user);
2840
+ const t = Zi(e.user);
2726
2841
  this.authenticatedSocket !== this.socket && this.authenticatedUserId && t && t.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = t?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
2727
- const n = Fi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2728
- R("web-sdk.agent", "Received auth.ok appearance", {
2842
+ const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2843
+ b("web-sdk.agent", "Received auth.ok appearance", {
2729
2844
  hasAppearance: i,
2730
2845
  rawAppearance: e.appearance,
2731
2846
  normalizedAppearance: n
2732
- }), this.runtimeHelperJavascript = ji(e.runtimeHelpers)?.javascript ?? null;
2733
- const r = Gt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2847
+ }), this.runtimeHelperJavascript = Vi(e.runtimeHelpers)?.javascript ?? null;
2848
+ const r = Vt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2734
2849
  user: t,
2735
2850
  status: "connected",
2736
2851
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
@@ -2739,7 +2854,7 @@ class Oe {
2739
2854
  type: "runtime.auth_ack",
2740
2855
  connectionAttempt: this.connectionAttemptId,
2741
2856
  entrySurface: this.options.entrySurface
2742
- }), o && r.length === 0 && !a && !Ye() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2857
+ }), o && r.length === 0 && !a && !et() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2743
2858
  type: "page.upsert",
2744
2859
  sessionId: this.state.sessionId,
2745
2860
  page: P(),
@@ -2749,21 +2864,21 @@ class Oe {
2749
2864
  }
2750
2865
  if (e.type === "starterPrompts.updated") {
2751
2866
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
2752
- starterPrompts: Gt(e, "starterPrompts"),
2867
+ starterPrompts: Vt(e, "starterPrompts"),
2753
2868
  starterPromptsLoading: !1
2754
2869
  });
2755
2870
  return;
2756
2871
  }
2757
2872
  if (e.type === "scheduled_follow_ups.updated") {
2758
2873
  typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
2759
- activeScheduledFollowUps: Qt(
2874
+ activeScheduledFollowUps: Xt(
2760
2875
  e.activeScheduledFollowUps
2761
2876
  )
2762
2877
  });
2763
2878
  return;
2764
2879
  }
2765
2880
  if (e.type === "conversation.state") {
2766
- const t = Array.isArray(e.items) ? e.items : [], n = vt(t), i = Object.prototype.hasOwnProperty.call(
2881
+ const t = Array.isArray(e.items) ? e.items : [], n = qt(t), i = Object.prototype.hasOwnProperty.call(
2767
2882
  e,
2768
2883
  "activeScheduledFollowUps"
2769
2884
  ), r = A(e.session, "id") ?? this.state.sessionId, o = typeof e.requestId == "string" ? e.requestId : null, a = this.state.isLoadingSession && this.sessionLoadRequestId === null && o === null && r === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
@@ -2774,55 +2889,55 @@ class Oe {
2774
2889
  this.forgetSupersededTaskTabClosedTurn(r, C(U));
2775
2890
  for (const U of n)
2776
2891
  this.rememberDurablyStoppedTurn(r, U);
2777
- const l = ne(n), c = l === null ? null : n[l], u = C(c), h = this.findStoppedTurn(r, {
2892
+ const l = ie(n), c = l === null ? null : n[l], u = C(c), d = this.findStoppedTurn(r, {
2778
2893
  clientMessageId: u?.clientMessageId,
2779
2894
  respondsToUserMessageId: A(c, "id"),
2780
2895
  runId: u?.runId
2781
- }), f = this.filterStoppedSnapshotItems(n, r), y = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, d = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, m = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
2782
- y && d && (this.pendingClientMessageId = d);
2783
- let g = sr(
2896
+ }), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
2897
+ f && h && (this.pendingClientMessageId = h);
2898
+ let m = ar(
2784
2899
  e.assistantDraft
2785
2900
  );
2786
- g && this.findStoppedTurn(r, {
2787
- respondsToUserMessageId: g.respondsToUserMessageId,
2788
- runId: g.runId
2789
- }) && (g = void 0);
2790
- const M = g !== void 0;
2791
- this.rememberUserMessageClientMessageIds(f);
2792
- const w = fr(f), D = f.filter((U) => {
2901
+ m && this.findStoppedTurn(r, {
2902
+ respondsToUserMessageId: m.respondsToUserMessageId,
2903
+ runId: m.runId
2904
+ }) && (m = void 0);
2905
+ const M = m !== void 0;
2906
+ this.rememberUserMessageClientMessageIds(g);
2907
+ const w = Tr(g), D = g.filter((U) => {
2793
2908
  const q = C(U);
2794
- return pr(q) ? !1 : !q || !w || !he(q) ? !0 : ct(f, q) !== w;
2795
- }), S = ot(
2909
+ return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
2910
+ }), S = lt(
2796
2911
  this.state.messages,
2797
- et(D, this.options.backendUrl)
2798
- ), T = es(S), N = M ? g?.content ?? "" : this.state.assistantDraft, v = M ? g?.itemId ?? null : this.state.assistantDraftItemId, ie = M ? g?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, J = M ? g?.runId ?? null : this.state.assistantDraftRunId, Y = f.some(
2799
- (U, q) => ts(
2912
+ st(D, this.options.backendUrl)
2913
+ ), T = ss(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, J = M ? m?.runId ?? null : this.state.assistantDraftRunId, Y = g.some(
2914
+ (U, q) => ns(
2800
2915
  C(U),
2801
2916
  N,
2802
2917
  v,
2803
- ie,
2918
+ re,
2804
2919
  J,
2805
- mr(f, q)
2920
+ wr(g, q)
2806
2921
  )
2807
- ), Z = M ? g?.content ?? "" : this.state.assistantDraft, ge = !!g?.content && !Y, B = T && (!Z || Y), Q = dr(S), re = B && Q ? "completed" : h ? "stopped" : B ? "failed" : null;
2808
- if (!T && gr(this.state.messages, f))
2922
+ ), Z = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Y, B = T && (!Z || Y), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
2923
+ if (!T && Sr(this.state.messages, g))
2809
2924
  return;
2810
- this.lastUserMessagePageUrl = hr(f);
2811
- const j = B || h ? null : lt(f);
2925
+ this.lastUserMessagePageUrl = yr(g);
2926
+ const j = B || d ? null : ut(g);
2812
2927
  if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
2813
2928
  sessionId: A(e.session, "id") ?? this.state.sessionId,
2814
2929
  messages: S,
2815
2930
  ...i ? {
2816
- activeScheduledFollowUps: Qt(
2931
+ activeScheduledFollowUps: Xt(
2817
2932
  e.activeScheduledFollowUps
2818
2933
  )
2819
2934
  } : {},
2820
2935
  isLoadingSession: !1,
2821
- ...y ? { pendingMessageStatus: y } : {},
2822
- ...m ? { turnPhase: m } : {},
2936
+ ...f ? { pendingMessageStatus: f } : {},
2937
+ ...y ? { turnPhase: y } : {},
2823
2938
  isRetrying: p,
2824
- ...m ? { taskStatus: "working" } : {},
2825
- ...re && this.state.taskStatus === "working" ? { taskStatus: re } : {},
2939
+ ...y ? { taskStatus: "working" } : {},
2940
+ ...oe && this.state.taskStatus === "working" ? { taskStatus: oe } : {},
2826
2941
  ...Y ? {
2827
2942
  assistantDraft: "",
2828
2943
  assistantDraftItemId: null,
@@ -2830,17 +2945,17 @@ class Oe {
2830
2945
  assistantDraftRespondsToUserMessageId: null,
2831
2946
  assistantDraftRunId: null
2832
2947
  } : M ? {
2833
- assistantDraft: g?.content ?? "",
2834
- assistantDraftItemId: g?.itemId ?? null,
2835
- assistantDraftPhase: g?.phase ?? null,
2836
- assistantDraftRespondsToUserMessageId: g?.respondsToUserMessageId ?? null,
2837
- assistantDraftRunId: g?.runId ?? null
2948
+ assistantDraft: m?.content ?? "",
2949
+ assistantDraftItemId: m?.itemId ?? null,
2950
+ assistantDraftPhase: m?.phase ?? null,
2951
+ assistantDraftRespondsToUserMessageId: m?.respondsToUserMessageId ?? null,
2952
+ assistantDraftRunId: m?.runId ?? null
2838
2953
  } : {},
2839
- ...ge ? {
2954
+ ...fe ? {
2840
2955
  isThinking: !0,
2841
2956
  turnPhase: "thinking",
2842
2957
  lastError: null
2843
- } : m ? {
2958
+ } : y ? {
2844
2959
  isThinking: !0,
2845
2960
  lastError: null,
2846
2961
  lastErrorCode: null,
@@ -2853,15 +2968,15 @@ class Oe {
2853
2968
  lastErrorSecuritySettingsUrl: null
2854
2969
  } : j ? {
2855
2970
  isThinking: !0,
2856
- turnPhase: m ?? this.state.turnPhase ?? "starting",
2971
+ turnPhase: y ?? this.state.turnPhase ?? "starting",
2857
2972
  lastError: null
2858
2973
  } : {}
2859
2974
  }), B)
2860
2975
  this.retryableClientMessageId = w, this.clearThinkingWatchdog();
2861
- else if (!h && (ge || j)) {
2976
+ else if (!d && (fe || j)) {
2862
2977
  if (j) {
2863
2978
  this.activeClientMessageId = j;
2864
- const U = ne(f), q = U === null ? null : f[U];
2979
+ const U = ie(g), q = U === null ? null : g[U];
2865
2980
  this.activeResponseUserMessageId = A(q, "id");
2866
2981
  }
2867
2982
  this.markThinkingProgress();
@@ -2875,19 +2990,19 @@ class Oe {
2875
2990
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2876
2991
  if (!t || n !== this.state.sessionId)
2877
2992
  return;
2878
- const i = et(
2993
+ const i = st(
2879
2994
  Array.isArray(e.items) ? e.items : [],
2880
2995
  this.options.backendUrl
2881
2996
  );
2882
2997
  t === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
2883
- messages: or(this.state.messages, i)
2998
+ messages: dr(this.state.messages, i)
2884
2999
  });
2885
3000
  return;
2886
3001
  }
2887
3002
  if (e.type === "sessions.page") {
2888
3003
  const t = typeof e.requestId == "string" ? e.requestId : null, n = t ? this.pendingSessionHistoryRequests.get(t) : null;
2889
3004
  t && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(t), n.resolve({
2890
- sessions: Vi(e.sessions),
3005
+ sessions: er(e.sessions),
2891
3006
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
2892
3007
  }));
2893
3008
  return;
@@ -2914,27 +3029,27 @@ class Oe {
2914
3029
  if (e.type === "session.item") {
2915
3030
  this.rememberUserMessageClientMessageIds([e.item]);
2916
3031
  const t = C(e.item);
2917
- if (he(t)) {
3032
+ if (pe(t)) {
2918
3033
  typeof t?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(t.runId);
2919
3034
  const i = t ? O(t) : null, r = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, o = typeof t?.clientMessageId == "string" ? t.clientMessageId : r ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
2920
3035
  o && (this.retryableClientMessageId = o);
2921
3036
  return;
2922
3037
  }
2923
- const n = rt(e.item, this.options.backendUrl);
3038
+ const n = ve(e.item, this.options.backendUrl);
2924
3039
  if (n) {
2925
- const i = Mr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
2926
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), $(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Ir(t) && this.clearRunAckResyncRetryTimer();
2927
- const o = ue(this.state.messages, n), a = es(o), l = ts(
3040
+ const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3041
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), $(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
3042
+ const o = de(this.state.messages, n), a = ss(o), l = ns(
2928
3043
  t,
2929
3044
  this.state.assistantDraft,
2930
3045
  this.state.assistantDraftItemId,
2931
3046
  this.state.assistantDraftRespondsToUserMessageId,
2932
3047
  this.state.assistantDraftRunId,
2933
- Ps(
3048
+ _s(
2934
3049
  o,
2935
- o.findIndex((h) => h.id === n.id)
3050
+ o.findIndex((d) => d.id === n.id)
2936
3051
  )
2937
- ), c = a && (!this.state.assistantDraft || l), u = _e(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
3052
+ ), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
2938
3053
  this.setState({
2939
3054
  messages: o,
2940
3055
  ...l ? {
@@ -2961,9 +3076,9 @@ class Oe {
2961
3076
  }
2962
3077
  if (e.type === "chat.assistant_delta") {
2963
3078
  this.clearRunAckResyncRetryTimer();
2964
- const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
3079
+ const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((d) => d.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
2965
3080
  this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = u), this.setState({
2966
- messages: ue(this.state.messages, {
3081
+ messages: de(this.state.messages, {
2967
3082
  id: o,
2968
3083
  role: "assistant",
2969
3084
  content: r,
@@ -2992,9 +3107,9 @@ class Oe {
2992
3107
  const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, i = typeof e.runId == "string" ? e.runId : null;
2993
3108
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
2994
3109
  return;
2995
- const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = _t(
3110
+ const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = Dt(
2996
3111
  this.state.messages.filter(
2997
- (c) => c.dataType !== "assistant_draft" || !we(
3112
+ (c) => c.dataType !== "assistant_draft" || !Ae(
2998
3113
  c,
2999
3114
  n,
3000
3115
  i
@@ -3002,11 +3117,11 @@ class Oe {
3002
3117
  ),
3003
3118
  n,
3004
3119
  i,
3005
- at
3120
+ ct
3006
3121
  );
3007
3122
  this.setState({
3008
3123
  sessionId: t,
3009
- messages: Xt(
3124
+ messages: Yt(
3010
3125
  l,
3011
3126
  typeof e.responseId == "string" ? e.responseId : null,
3012
3127
  n,
@@ -3029,9 +3144,9 @@ class Oe {
3029
3144
  if (t)
3030
3145
  this.nonTranscriptToolCallIds.add(t);
3031
3146
  else {
3032
- const n = Zt(e);
3147
+ const n = ts(e);
3033
3148
  if (n) {
3034
- const i = Jt(
3149
+ const i = Zt(
3035
3150
  this.state.messages,
3036
3151
  n
3037
3152
  );
@@ -3062,6 +3177,12 @@ class Oe {
3062
3177
  return;
3063
3178
  }
3064
3179
  if (e.type === "error") {
3180
+ if (e.code === "unauthorized" && e.reason === "token_expired" && e.retryable === !0 && this.options.tokenProvider) {
3181
+ this.invalidateProviderToken(), this.clearSocketPhaseTimers(), this.stopHeartbeat();
3182
+ const f = this.socket;
3183
+ this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), f?.close();
3184
+ return;
3185
+ }
3065
3186
  const t = typeof e.requestId == "string" ? e.requestId : null;
3066
3187
  if (t && t === this.sessionLoadRequestId) {
3067
3188
  this.clearSessionLoadRequest(), this.setState({
@@ -3093,20 +3214,20 @@ class Oe {
3093
3214
  return;
3094
3215
  }
3095
3216
  o && i && r && (this.retryableClientMessageId = r);
3096
- const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = _i(a.message);
3217
+ const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
3097
3218
  l && console.error(l);
3098
- const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = ns(
3219
+ const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = rs(
3099
3220
  this.state.messages,
3100
3221
  c,
3101
3222
  u
3102
- ), f = ur(
3103
- h,
3223
+ ), g = fr(
3224
+ d,
3104
3225
  c,
3105
3226
  u
3106
3227
  );
3107
- this.setState({
3108
- status: f ? "connected" : "error",
3109
- messages: h,
3228
+ if (this.setState({
3229
+ status: g ? "connected" : "error",
3230
+ messages: d,
3110
3231
  assistantDraft: "",
3111
3232
  assistantDraftItemId: null,
3112
3233
  assistantDraftPhase: null,
@@ -3115,10 +3236,14 @@ class Oe {
3115
3236
  isThinking: !1,
3116
3237
  ...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
3117
3238
  isRetrying: !1,
3118
- lastError: f ? null : a.message,
3119
- lastErrorCode: f ? null : typeof e.code == "string" ? e.code : null,
3120
- lastErrorSecuritySettingsUrl: f ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
3121
- }), this.clearThinkingWatchdog(), this.emit("error", a);
3239
+ lastError: g ? null : a.message,
3240
+ lastErrorCode: g ? null : typeof e.code == "string" ? e.code : null,
3241
+ lastErrorSecuritySettingsUrl: g ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
3242
+ }), this.clearThinkingWatchdog(), this.emit("error", a), e.code === "unauthorized") {
3243
+ this.clearSocketPhaseTimers(), this.stopHeartbeat();
3244
+ const f = this.socket;
3245
+ this.socket = null, f?.close();
3246
+ }
3122
3247
  }
3123
3248
  }
3124
3249
  }
@@ -3126,7 +3251,7 @@ class Oe {
3126
3251
  }
3127
3252
  applyAccountSubmissionError(e) {
3128
3253
  if (!this.account || !e) return;
3129
- const t = Tn(this.account.submissionGate, e);
3254
+ const t = wn(this.account.submissionGate, e);
3130
3255
  if (!(t === this.account.submissionGate || t.allowed)) {
3131
3256
  this.account = {
3132
3257
  ...this.account,
@@ -3139,55 +3264,55 @@ class Oe {
3139
3264
  if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
3140
3265
  return;
3141
3266
  const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
3142
- this.options.model = Ke(n) ? n : "gpt-5.6-sol";
3267
+ this.options.model = Qe(n) ? n : "gpt-5.6-sol";
3143
3268
  }
3144
3269
  updateAccountFallbackFromSession(e) {
3145
- const t = e && typeof e == "object" ? e.metadata : null, n = wn(t);
3270
+ const t = e && typeof e == "object" ? e.metadata : null, n = An(t);
3146
3271
  if (this.usingPaidCreditFallback !== n && (this.usingPaidCreditFallback = n, !!this.account)) {
3147
3272
  this.account = { ...this.account, usingPaidCreditFallback: n };
3148
3273
  for (const i of this.accountListeners) i(this.getAccount());
3149
3274
  }
3150
3275
  }
3151
3276
  shouldIgnoreBackgroundSessionEvent(e) {
3152
- if (!this.options.keepRunsActiveOnSessionNavigation || !le(e))
3277
+ if (!this.options.keepRunsActiveOnSessionNavigation || !ce(e))
3153
3278
  return !1;
3154
3279
  const t = K(e);
3155
3280
  return t ? this.deferredSessionUpdatedSessionIds.has(t) ? !0 : this.state.sessionId ? t !== this.state.sessionId : this.backgroundSessionIds.has(t) : !1;
3156
3281
  }
3157
3282
  updateInactiveSessionTimelineCache(e) {
3158
- if (!le(e))
3283
+ if (!ce(e))
3159
3284
  return;
3160
3285
  const t = K(e);
3161
3286
  if (!t || t === this.state.sessionId)
3162
3287
  return;
3163
3288
  const n = this.sessionTimelineCache.get(t);
3164
3289
  if (e.type === "conversation.state") {
3165
- const i = vt(
3290
+ const i = qt(
3166
3291
  Array.isArray(e.items) ? e.items : []
3167
- ), r = et(
3292
+ ), r = st(
3168
3293
  this.filterStoppedSnapshotItems(i, t),
3169
3294
  this.options.backendUrl
3170
3295
  );
3171
3296
  (n || r.length > 0) && this.rememberSessionTimeline(
3172
3297
  t,
3173
- n ? ot(n, r) : r
3298
+ n ? lt(n, r) : r
3174
3299
  );
3175
3300
  return;
3176
3301
  }
3177
3302
  if (n) {
3178
3303
  if (e.type === "session.item") {
3179
3304
  const i = C(e.item);
3180
- if (he(i))
3305
+ if (pe(i))
3181
3306
  return;
3182
- const r = rt(e.item, this.options.backendUrl);
3183
- r && this.rememberSessionTimeline(t, ue(n, r));
3307
+ const r = ve(e.item, this.options.backendUrl);
3308
+ r && this.rememberSessionTimeline(t, de(n, r));
3184
3309
  return;
3185
3310
  }
3186
3311
  if (e.type === "tool.call") {
3187
- const i = e.hiddenFromTranscript === !0 ? null : Zt(e);
3312
+ const i = e.hiddenFromTranscript === !0 ? null : ts(e);
3188
3313
  i && this.rememberSessionTimeline(
3189
3314
  t,
3190
- Jt(n, i)
3315
+ Zt(n, i)
3191
3316
  );
3192
3317
  return;
3193
3318
  }
@@ -3199,7 +3324,7 @@ class Oe {
3199
3324
  return;
3200
3325
  this.rememberSessionTimeline(
3201
3326
  t,
3202
- Yt(
3327
+ es(
3203
3328
  n,
3204
3329
  e.callId,
3205
3330
  i
@@ -3211,7 +3336,7 @@ class Oe {
3211
3336
  const r = (typeof e.itemId == "string" ? e.itemId : null) ?? "assistant-draft", o = n.find((c) => c.id === r), l = `${!o || o.dataType !== "assistant_draft" ? "" : o.content}${e.delta}`;
3212
3337
  this.rememberSessionTimeline(
3213
3338
  t,
3214
- ue(n, {
3339
+ de(n, {
3215
3340
  id: r,
3216
3341
  role: "assistant",
3217
3342
  content: l,
@@ -3226,17 +3351,17 @@ class Oe {
3226
3351
  return;
3227
3352
  }
3228
3353
  if (e.type === "chat.assistant_done") {
3229
- const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = _t(
3354
+ const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Dt(
3230
3355
  n.filter(
3231
- (a) => a.dataType !== "assistant_draft" || !we(a, i, r)
3356
+ (a) => a.dataType !== "assistant_draft" || !Ae(a, i, r)
3232
3357
  ),
3233
3358
  i,
3234
3359
  r,
3235
- at
3360
+ ct
3236
3361
  );
3237
3362
  this.rememberSessionTimeline(
3238
3363
  t,
3239
- Xt(
3364
+ Yt(
3240
3365
  o,
3241
3366
  typeof e.responseId == "string" ? e.responseId : null,
3242
3367
  i,
@@ -3251,7 +3376,7 @@ class Oe {
3251
3376
  return;
3252
3377
  this.rememberSessionTimeline(
3253
3378
  t,
3254
- is(
3379
+ os(
3255
3380
  n,
3256
3381
  i,
3257
3382
  null,
@@ -3260,20 +3385,20 @@ class Oe {
3260
3385
  );
3261
3386
  return;
3262
3387
  }
3263
- e.type === "error" && typeof e.requestId != "string" && !ss(e, t) && this.rememberSessionTimeline(
3388
+ e.type === "error" && typeof e.requestId != "string" && !is(e, t) && this.rememberSessionTimeline(
3264
3389
  t,
3265
- wr(n, e)
3390
+ kr(n, e)
3266
3391
  );
3267
3392
  }
3268
3393
  }
3269
3394
  shouldIgnoreDetachedSessionEvent(e) {
3270
- if (this.options.keepRunsActiveOnSessionNavigation || !le(e))
3395
+ if (this.options.keepRunsActiveOnSessionNavigation || !ce(e))
3271
3396
  return !1;
3272
3397
  const t = K(e);
3273
3398
  return !!(t && this.detachedSessionIds.has(t));
3274
3399
  }
3275
3400
  shouldDeferDetachedSessionEvent(e) {
3276
- if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !le(e))
3401
+ if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !ce(e))
3277
3402
  return !1;
3278
3403
  const t = K(e);
3279
3404
  if (!t || t === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(t))
@@ -3296,9 +3421,9 @@ class Oe {
3296
3421
  }
3297
3422
  handleRetryableRecoveryError(e) {
3298
3423
  const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
3299
- if (!ss(e, t) || !n)
3424
+ if (!is(e, t) || !n)
3300
3425
  return !1;
3301
- if (Ye())
3426
+ if (et())
3302
3427
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
3303
3428
  if (this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
3304
3429
  const i = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
@@ -3337,7 +3462,7 @@ class Oe {
3337
3462
  const i = new Promise((r, o) => {
3338
3463
  const a = window.setTimeout(() => {
3339
3464
  e.delete(t.requestId), o(new Error(n));
3340
- }, $t);
3465
+ }, jt);
3341
3466
  e.set(t.requestId, { resolve: r, reject: o, timeout: a });
3342
3467
  });
3343
3468
  if (!this.sendNow(t)) {
@@ -3360,7 +3485,7 @@ class Oe {
3360
3485
  e.clear();
3361
3486
  }
3362
3487
  markThinkingProgress() {
3363
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Gn), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
3488
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Vn), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
3364
3489
  }
3365
3490
  scheduleThinkingWatchdog(e) {
3366
3491
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -3416,21 +3541,21 @@ class Oe {
3416
3541
  return this.pendingClientMessageId === e && this.state.isThinking && this.activeClientMessageId !== null && this.activeClientMessageId !== e;
3417
3542
  }
3418
3543
  schedulePendingDeliveryAck(e) {
3419
- this.clearPendingDeliveryTimers(), !Ye() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3544
+ this.clearPendingDeliveryTimers(), !et() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3420
3545
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
3421
- }, Wt));
3546
+ }, Ft));
3422
3547
  }
3423
3548
  retryPendingDelivery(e) {
3424
3549
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
3425
3550
  return;
3426
3551
  const t = this.retryAttemptsByClientMessageId[e] ?? 0;
3427
- if (t >= Qn) {
3552
+ if (t >= Xn) {
3428
3553
  this.failPendingDelivery(e);
3429
3554
  return;
3430
3555
  }
3431
3556
  t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
3432
3557
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
3433
- }, ai(t, Jn));
3558
+ }, ui(t, ei));
3434
3559
  }
3435
3560
  failPendingDelivery(e) {
3436
3561
  if (this.pendingClientMessageId !== e)
@@ -3442,7 +3567,7 @@ class Oe {
3442
3567
  ...this.state.isThinking ? {} : { turnPhase: null },
3443
3568
  isRetrying: !1,
3444
3569
  ...this.state.isThinking ? {} : { taskStatus: "failed" },
3445
- lastError: Xn,
3570
+ lastError: Yn,
3446
3571
  lastErrorCode: "message_delivery_failed"
3447
3572
  });
3448
3573
  }
@@ -3454,7 +3579,7 @@ class Oe {
3454
3579
  if (this.state.isThinking && t) {
3455
3580
  const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
3456
3581
  this.setState({
3457
- messages: is(
3582
+ messages: os(
3458
3583
  this.state.messages,
3459
3584
  t,
3460
3585
  n,
@@ -3480,13 +3605,13 @@ class Oe {
3480
3605
  scheduleRunAckWatchdog(e) {
3481
3606
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
3482
3607
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
3483
- }, Wt);
3608
+ }, Ft);
3484
3609
  }
3485
3610
  recoverMissedRunAck(e) {
3486
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (R("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3611
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3487
3612
  sessionId: this.state.sessionId,
3488
3613
  clientMessageId: e
3489
- }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Bt));
3614
+ }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog($t));
3490
3615
  }
3491
3616
  clearRunAckResyncRetryTimer() {
3492
3617
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -3499,7 +3624,7 @@ class Oe {
3499
3624
  return;
3500
3625
  const e = this.activeClientMessageId;
3501
3626
  if (!e) {
3502
- R("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
3627
+ b("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
3503
3628
  sessionId: this.state.sessionId
3504
3629
  }), this.reportHealthSignal("run_recovery_exhausted", {
3505
3630
  reason: "missing_client_message_id"
@@ -3509,17 +3634,17 @@ class Oe {
3509
3634
  ),
3510
3635
  isThinking: !1,
3511
3636
  taskStatus: "failed",
3512
- lastError: Vn,
3637
+ lastError: Jn,
3513
3638
  lastErrorCode: "run_recovery_exhausted"
3514
3639
  }), this.clearThinkingWatchdog();
3515
3640
  return;
3516
3641
  }
3517
3642
  const t = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0;
3518
- this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = t + 1, R("web-sdk.agent", "Pluno thinking watchdog resyncing authoritative session state", {
3643
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = t + 1, b("web-sdk.agent", "Pluno thinking watchdog resyncing authoritative session state", {
3519
3644
  sessionId: this.state.sessionId,
3520
3645
  clientMessageId: e,
3521
3646
  resyncAttempts: t + 1
3522
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Bt);
3647
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog($t);
3523
3648
  }
3524
3649
  resyncThinkingSession() {
3525
3650
  this.state.sessionId ? this.send({
@@ -3530,13 +3655,13 @@ class Oe {
3530
3655
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
3531
3656
  }
3532
3657
  async executeToolCall(e) {
3533
- const t = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, i = typeof e.toolName == "string" ? e.toolName : null, r = te(
3658
+ const t = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, i = typeof e.toolName == "string" ? e.toolName : null, r = se(
3534
3659
  typeof e.summary == "string" ? e.summary : "Running browser tool"
3535
3660
  ), o = e.rawInput;
3536
3661
  if (!t || !n || !i)
3537
3662
  return;
3538
3663
  const a = i === "execute_code", l = i === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
3539
- if (!a && !l || !zr(o)) {
3664
+ if (!a && !l || !Xr(o)) {
3540
3665
  this.setToolMessageLoading(n, !1), this.send({
3541
3666
  type: "tool.result",
3542
3667
  sessionId: t,
@@ -3583,13 +3708,13 @@ class Oe {
3583
3708
  startedAtOrigin: location.origin
3584
3709
  }), this.installSessionBrowserApis();
3585
3710
  let c = null, u;
3586
- c = await this.executeRuntimeHelper(), u = await zt(
3711
+ c = await this.executeRuntimeHelper(), u = await Gt(
3587
3712
  o,
3588
- Ri(e.runtimeContext, this.options.backendUrl)
3589
- ).catch((h) => ({
3713
+ _i(e.runtimeContext, this.options.backendUrl)
3714
+ ).catch((d) => ({
3590
3715
  ok: !1,
3591
3716
  exception: {
3592
- message: h instanceof Error ? h.message : String(h)
3717
+ message: d instanceof Error ? d.message : String(d)
3593
3718
  }
3594
3719
  })), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
3595
3720
  type: "tool.result",
@@ -3598,11 +3723,11 @@ class Oe {
3598
3723
  toolName: i,
3599
3724
  summary: o.summary,
3600
3725
  rawInput: L(o),
3601
- rawOutput: L(zi(u, c))
3602
- }), os(this.options.clientId, this.activeBrowserToolCalls.values()));
3726
+ rawOutput: L(Xi(u, c))
3727
+ }), ls(this.options.clientId, this.activeBrowserToolCalls.values()));
3603
3728
  }
3604
3729
  setToolMessageLoading(e, t) {
3605
- const n = Yt(
3730
+ const n = es(
3606
3731
  this.state.messages,
3607
3732
  e,
3608
3733
  t
@@ -3613,33 +3738,33 @@ class Oe {
3613
3738
  if (this.pageLifecycleCleanup)
3614
3739
  return;
3615
3740
  const e = () => {
3616
- vs(this.options.clientId, this.activeBrowserToolCalls.values());
3741
+ Us(this.options.clientId, this.activeBrowserToolCalls.values());
3617
3742
  };
3618
3743
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
3619
3744
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
3620
3745
  };
3621
3746
  }
3622
3747
  installSessionBrowserApis() {
3623
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = fi();
3748
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Ti();
3624
3749
  }
3625
3750
  cleanupSessionBrowserApis() {
3626
- this.sessionBrowserApisCleanup && (Mi(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3751
+ this.sessionBrowserApisCleanup && (Ci(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3627
3752
  }
3628
3753
  async executeRuntimeHelper() {
3629
3754
  if (!this.runtimeHelperJavascript?.trim())
3630
3755
  return null;
3631
- const e = await zt({
3756
+ const e = await Gt({
3632
3757
  javascript: this.runtimeHelperJavascript
3633
3758
  });
3634
- return e.ok === !1 ? Ki(e) : null;
3759
+ return e.ok === !1 ? Ji(e) : null;
3635
3760
  }
3636
3761
  enableNetworkCapture() {
3637
- this.networkCaptureCleanup || (this.networkCaptureCleanup = ui((e) => {
3638
- Jr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3762
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = fi((e) => {
3763
+ so(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3639
3764
  }));
3640
3765
  }
3641
3766
  enqueueNetworkEvent(e) {
3642
- this.queuedNetworkEvents.length >= Zn || (this.queuedNetworkEvents.push(Xr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3767
+ this.queuedNetworkEvents.length >= si || (this.queuedNetworkEvents.push(to(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3643
3768
  this.networkBatchTimer = null;
3644
3769
  const t = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
3645
3770
  t.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -3648,29 +3773,32 @@ class Oe {
3648
3773
  page: P(),
3649
3774
  events: t
3650
3775
  });
3651
- }, Yn)));
3776
+ }, ti)));
3652
3777
  }
3653
- scheduleReconnect() {
3778
+ scheduleReconnect(e = 0) {
3654
3779
  if (this.reconnectTimer !== null || this.state.status === "closed")
3655
3780
  return;
3656
- const e = li(this.reconnectAttempts);
3781
+ const t = Math.min(
3782
+ ot,
3783
+ Math.max(di(this.reconnectAttempts), e)
3784
+ );
3657
3785
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
3658
- this.reconnectTimer = null, this.connect().catch((t) => {
3659
- R("web-sdk.agent", "Pluno reconnect failed; retrying", {
3660
- message: t instanceof Error ? t.message : String(t),
3786
+ this.reconnectTimer = null, this.connect().catch((n) => {
3787
+ b("web-sdk.agent", "Pluno reconnect failed; retrying", {
3788
+ message: n instanceof Error ? n.message : String(n),
3661
3789
  queuedClientEventCount: this.queuedClientEvents.length,
3662
3790
  isThinking: this.state.isThinking
3663
3791
  }), this.setReconnectingState(), this.scheduleReconnect();
3664
3792
  });
3665
- }, e);
3793
+ }, t);
3666
3794
  }
3667
3795
  startHeartbeat() {
3668
3796
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
3669
3797
  const e = this.socket;
3670
3798
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
3671
- this.socket === e && (R("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
3672
- }, Bn));
3673
- }, Hn);
3799
+ this.socket === e && (b("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
3800
+ }, Wn));
3801
+ }, Bn);
3674
3802
  }
3675
3803
  stopHeartbeat() {
3676
3804
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -3708,7 +3836,7 @@ class Oe {
3708
3836
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3709
3837
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3710
3838
  }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null;
3711
- this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Dr(this.options.clientId, this.state), this.emit("state", this.getState()), Ve("state", this.state.status, {
3839
+ this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
3712
3840
  status: this.state.status,
3713
3841
  sessionId: this.state.sessionId,
3714
3842
  messageCount: this.state.messages.length,
@@ -3736,7 +3864,7 @@ class Oe {
3736
3864
  this.transportIdentity.transportId
3737
3865
  ].join(":"), n = `${e}:${t}`;
3738
3866
  if (this.sessionRecoveryScope !== n) {
3739
- const i = [...this.state.messages].reverse().find((r) => !ht(r) && !r.id.startsWith("transient-activity:"));
3867
+ const i = [...this.state.messages].reverse().find((r) => !gt(r) && !r.id.startsWith("transient-activity:"));
3740
3868
  this.sessionActivityRecovery.reset(i?.id ?? null), this.sessionRecoveryScope = n;
3741
3869
  }
3742
3870
  this.sessionRecoveryPoller.start(e, t), this.sessionActivityRecoveryPoller.start(e, t);
@@ -3766,44 +3894,44 @@ class Oe {
3766
3894
  this.listeners[e]?.forEach((i) => i(t));
3767
3895
  }
3768
3896
  }
3769
- const Je = /* @__PURE__ */ new WeakMap();
3770
- function ui(s) {
3771
- const e = window.__plunoProductAgentNetworkCapture ?? di();
3897
+ const Ze = /* @__PURE__ */ new WeakMap();
3898
+ function fi(s) {
3899
+ const e = window.__plunoProductAgentNetworkCapture ?? mi();
3772
3900
  return e.subscribers.add(s), () => {
3773
3901
  e.subscribers.delete(s), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
3774
3902
  };
3775
3903
  }
3776
- function di() {
3777
- const s = /* @__PURE__ */ new Set(), e = (f) => {
3778
- s.forEach((y) => {
3904
+ function mi() {
3905
+ const s = /* @__PURE__ */ new Set(), e = (g) => {
3906
+ s.forEach((f) => {
3779
3907
  try {
3780
- y(f);
3908
+ f(g);
3781
3909
  } catch {
3782
3910
  }
3783
3911
  });
3784
- }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(y, d) {
3912
+ }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(f, h) {
3785
3913
  const p = Date.now();
3786
- let m;
3914
+ let y;
3787
3915
  try {
3788
- m = t.call(this, y, d);
3789
- } catch (g) {
3790
- throw g;
3916
+ y = t.call(this, f, h);
3917
+ } catch (m) {
3918
+ throw m;
3791
3919
  }
3792
3920
  try {
3793
- const g = y instanceof Request ? y : null, M = Kr(y, g), w = Os(d?.headers ?? g?.headers);
3794
- if (!ee(M, w, d?.body)) {
3921
+ const m = f instanceof Request ? f : null, M = Jr(f, m), w = xs(h?.headers ?? m?.headers);
3922
+ if (!te(M, w, h?.body)) {
3795
3923
  const H = {
3796
- requestId: tt("fetch"),
3797
- url: W(M, Xe),
3798
- method: (d?.method ?? g?.method ?? "GET").toUpperCase(),
3924
+ requestId: nt("fetch"),
3925
+ url: W(M, Ye),
3926
+ method: (h?.method ?? m?.method ?? "GET").toUpperCase(),
3799
3927
  requestHeaders: w,
3800
- requestBody: ls(d?.body),
3928
+ requestBody: us(h?.body),
3801
3929
  resourceType: "fetch",
3802
3930
  startedAt: new Date(p).toISOString()
3803
3931
  };
3804
- m.then(
3932
+ y.then(
3805
3933
  (S) => {
3806
- Gr(S, H, p, e).catch(() => {
3934
+ Yr(S, H, p, e).catch(() => {
3807
3935
  e({
3808
3936
  ...H,
3809
3937
  responseStatus: S.status,
@@ -3822,43 +3950,43 @@ function di() {
3822
3950
  }
3823
3951
  } catch {
3824
3952
  }
3825
- return m;
3826
- }, a = function(y, d, p, m, g) {
3827
- const M = n.call(this, y, d, p ?? !0, m ?? void 0, g ?? void 0), w = typeof d == "string" ? d : d.toString();
3828
- return Je.set(this, {
3829
- requestId: tt("xhr"),
3830
- method: String(y ?? "GET").toUpperCase(),
3831
- url: W(w, Xe),
3953
+ return y;
3954
+ }, a = function(f, h, p, y, m) {
3955
+ const M = n.call(this, f, h, p ?? !0, y ?? void 0, m ?? void 0), w = typeof h == "string" ? h : h.toString();
3956
+ return Ze.set(this, {
3957
+ requestId: nt("xhr"),
3958
+ method: String(f ?? "GET").toUpperCase(),
3959
+ url: W(w, Ye),
3832
3960
  requestHeaders: {},
3833
3961
  startedAtMs: Date.now(),
3834
3962
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3835
- excluded: ee(w)
3963
+ excluded: te(w)
3836
3964
  }), M;
3837
- }, l = function(y, d) {
3838
- const p = i.call(this, y, d), m = Je.get(this);
3839
- return m && Object.keys(m.requestHeaders).length < It && (m.requestHeaders[y] = At(y, d), m.excluded = m.excluded || ee(m.url, m.requestHeaders)), p;
3840
- }, c = function(y) {
3965
+ }, l = function(f, h) {
3966
+ const p = i.call(this, f, h), y = Ze.get(this);
3967
+ return y && Object.keys(y.requestHeaders).length < wt && (y.requestHeaders[f] = Rt(f, h), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
3968
+ }, c = function(f) {
3841
3969
  try {
3842
- const d = Je.get(this);
3843
- d && (d.excluded = d.excluded || ee(d.url, d.requestHeaders, y), d.requestBody = ls(y), d.excluded || this.addEventListener(
3970
+ const h = Ze.get(this);
3971
+ h && (h.excluded = h.excluded || te(h.url, h.requestHeaders, f), h.requestBody = us(f), h.excluded || this.addEventListener(
3844
3972
  "loadend",
3845
3973
  () => {
3846
3974
  queueMicrotask(() => {
3847
3975
  try {
3848
- const p = Zr(this.getAllResponseHeaders());
3976
+ const p = io(this.getAllResponseHeaders());
3849
3977
  e({
3850
- requestId: d.requestId,
3851
- url: d.url,
3852
- method: d.method,
3853
- requestHeaders: d.requestHeaders,
3854
- requestBody: d.requestBody,
3978
+ requestId: h.requestId,
3979
+ url: h.url,
3980
+ method: h.method,
3981
+ requestHeaders: h.requestHeaders,
3982
+ requestBody: h.requestBody,
3855
3983
  resourceType: "xhr",
3856
3984
  responseStatus: this.status,
3857
3985
  responseHeaders: p,
3858
- responseBody: Vr(this, p),
3986
+ responseBody: eo(this, p),
3859
3987
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
3860
- startedAt: d.startedAt,
3861
- durationMs: Date.now() - d.startedAtMs
3988
+ startedAt: h.startedAt,
3989
+ durationMs: Date.now() - h.startedAtMs
3862
3990
  });
3863
3991
  } catch {
3864
3992
  return;
@@ -3869,7 +3997,7 @@ function di() {
3869
3997
  ));
3870
3998
  } catch {
3871
3999
  }
3872
- return r.call(this, y ?? null);
4000
+ return r.call(this, f ?? null);
3873
4001
  };
3874
4002
  try {
3875
4003
  window.fetch = o;
@@ -3889,20 +4017,20 @@ function di() {
3889
4017
  }
3890
4018
  let u = null;
3891
4019
  if (typeof PerformanceObserver < "u") {
3892
- u = new PerformanceObserver((f) => {
3893
- for (const y of f.getEntries()) {
3894
- const d = y;
3895
- if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || ee(d.name))
4020
+ u = new PerformanceObserver((g) => {
4021
+ for (const f of g.getEntries()) {
4022
+ const h = f;
4023
+ if (h.initiatorType === "fetch" || h.initiatorType === "xmlhttprequest" || te(h.name))
3896
4024
  continue;
3897
- const p = performance.timeOrigin + d.startTime;
4025
+ const p = performance.timeOrigin + h.startTime;
3898
4026
  e({
3899
- requestId: tt("resource"),
3900
- url: W(d.name, Xe),
4027
+ requestId: nt("resource"),
4028
+ url: W(h.name, Ye),
3901
4029
  method: "GET",
3902
4030
  resourceType: "resource",
3903
- responseStatus: d.responseStatus,
4031
+ responseStatus: h.responseStatus,
3904
4032
  startedAt: new Date(p).toISOString(),
3905
- durationMs: d.duration
4033
+ durationMs: h.duration
3906
4034
  });
3907
4035
  }
3908
4036
  });
@@ -3912,7 +4040,7 @@ function di() {
3912
4040
  u.disconnect(), u = null;
3913
4041
  }
3914
4042
  }
3915
- const h = {
4043
+ const d = {
3916
4044
  subscribers: s,
3917
4045
  destroy: () => {
3918
4046
  u?.disconnect();
@@ -3934,9 +4062,9 @@ function di() {
3934
4062
  }
3935
4063
  }
3936
4064
  };
3937
- return window.__plunoProductAgentNetworkCapture = h, h;
4065
+ return window.__plunoProductAgentNetworkCapture = d, d;
3938
4066
  }
3939
- function R(s, e, t) {
4067
+ function b(s, e, t) {
3940
4068
  if (typeof window > "u")
3941
4069
  return;
3942
4070
  const n = window, i = {
@@ -3947,14 +4075,14 @@ function R(s, e, t) {
3947
4075
  }, r = n.__plunoProductAgentDiagnostics__ ?? [];
3948
4076
  r.push(i), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: i }));
3949
4077
  }
3950
- function jt(s) {
4078
+ function Kt(s) {
3951
4079
  const e = typeof s == "function" ? s() : s;
3952
4080
  return e && Object.keys(e).length > 0 ? e : void 0;
3953
4081
  }
3954
- function hi(s) {
4082
+ function yi(s) {
3955
4083
  return s.type === "run.model_started" || s.type === "conversation.state" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call";
3956
4084
  }
3957
- function le(s) {
4085
+ function ce(s) {
3958
4086
  return s.type === "run.steered" || s.type === "run.ack" || s.type === "run.model_started" || s.type === "conversation.state" || s.type === "scheduled_follow_ups.updated" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call" || s.type === "tool.status" || s.type === "error" && typeof s.requestId != "string";
3959
4087
  }
3960
4088
  function K(s) {
@@ -3972,31 +4100,31 @@ function K(s) {
3972
4100
  }
3973
4101
  return null;
3974
4102
  }
3975
- const pi = 5e3, gi = 12e4;
3976
- function fi() {
4103
+ const Ii = 5e3, Si = 12e4;
4104
+ function Ti() {
3977
4105
  const s = [
3978
- yi(),
3979
- mi()
4106
+ Ai(),
4107
+ wi()
3980
4108
  ].filter((e) => typeof e == "function");
3981
4109
  return () => {
3982
4110
  for (const e of s.reverse())
3983
4111
  e();
3984
4112
  };
3985
4113
  }
3986
- function mi() {
3987
- return us(globalThis, "getPageSnapshot", async () => St());
4114
+ function wi() {
4115
+ return hs(globalThis, "getPageSnapshot", async () => At());
3988
4116
  }
3989
- function yi() {
3990
- return us(globalThis, "pageImages", {
3991
- inspectImage: async (e, t) => await Ii(e, t)
4117
+ function Ai() {
4118
+ return hs(globalThis, "pageImages", {
4119
+ inspectImage: async (e, t) => await Mi(e, t)
3992
4120
  });
3993
4121
  }
3994
- async function Ii(s, e = {}) {
3995
- const t = Ai(e.name), n = await Si(s);
4122
+ async function Mi(s, e = {}) {
4123
+ const t = Ei(e.name), n = await bi(s);
3996
4124
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
3997
4125
  type: "pluno.pageImages.inspectImage",
3998
4126
  imageAttached: !1,
3999
- imageAttachmentError: Ts
4127
+ imageAttachmentError: ws
4000
4128
  } : {
4001
4129
  type: "pluno.pageImages.inspectImage",
4002
4130
  imageAttached: !0,
@@ -4010,15 +4138,15 @@ async function Ii(s, e = {}) {
4010
4138
  imageAttachmentError: n.error
4011
4139
  };
4012
4140
  }
4013
- async function Si(s) {
4014
- return s instanceof Blob ? s.type.startsWith("image/") ? s.size === 0 ? { ok: !1, error: "Page image is empty." } : s.size > 8 * 1024 * 1024 ? { ok: !1, error: Ts } : {
4141
+ async function bi(s) {
4142
+ return s instanceof Blob ? s.type.startsWith("image/") ? s.size === 0 ? { ok: !1, error: "Page image is empty." } : s.size > 8 * 1024 * 1024 ? { ok: !1, error: ws } : {
4015
4143
  ok: !0,
4016
4144
  mimeType: s.type,
4017
4145
  sizeBytes: s.size,
4018
- dataUrl: await bi(s)
4019
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ti(s);
4146
+ dataUrl: await Pi(s)
4147
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ri(s);
4020
4148
  }
4021
- function Ti(s) {
4149
+ function Ri(s) {
4022
4150
  if (!s.startsWith("data:") || !s.includes(","))
4023
4151
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
4024
4152
  const [e, t] = s.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), i = n[0] ?? "";
@@ -4029,7 +4157,7 @@ function Ti(s) {
4029
4157
  const r = t.replace(/[ \t\r\n\f]+/g, "");
4030
4158
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(r))
4031
4159
  return { ok: !1, error: "Page image data URL has invalid base64." };
4032
- const o = wi(r);
4160
+ const o = ki(r);
4033
4161
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
4034
4162
  ok: !0,
4035
4163
  mimeType: i,
@@ -4037,22 +4165,22 @@ function Ti(s) {
4037
4165
  dataUrl: `data:${i};base64,${r}`
4038
4166
  };
4039
4167
  }
4040
- function wi(s) {
4168
+ function ki(s) {
4041
4169
  if (s.length === 0 || s.length % 4 !== 0)
4042
4170
  return null;
4043
4171
  const e = s.length - s.replace(/=+$/, "").length;
4044
4172
  return e > 2 ? null : s.length / 4 * 3 - e;
4045
4173
  }
4046
- function Ai(s) {
4174
+ function Ei(s) {
4047
4175
  return (typeof s == "string" ? s.trim() : "") || "Page image";
4048
4176
  }
4049
- function Mi(s) {
4177
+ function Ci(s) {
4050
4178
  try {
4051
4179
  s();
4052
4180
  } catch {
4053
4181
  }
4054
4182
  }
4055
- function bi(s) {
4183
+ function Pi(s) {
4056
4184
  return new Promise((e, t) => {
4057
4185
  const n = new FileReader();
4058
4186
  n.onload = () => {
@@ -4064,9 +4192,9 @@ function bi(s) {
4064
4192
  }, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
4065
4193
  });
4066
4194
  }
4067
- async function zt(s, e) {
4195
+ async function Gt(s, e) {
4068
4196
  const t = Object.getPrototypeOf(async function() {
4069
- }).constructor, n = s.timeoutMs ?? pi, i = Date.now(), r = [];
4197
+ }).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
4070
4198
  let o;
4071
4199
  const a = {
4072
4200
  log: console.log,
@@ -4080,11 +4208,11 @@ async function zt(s, e) {
4080
4208
  try {
4081
4209
  const c = /* @__PURE__ */ Symbol("execute_code_timeout"), u = await Promise.race([
4082
4210
  new t("sandboxFiles", s.javascript)(e?.value),
4083
- new Promise((h) => {
4084
- o = window.setTimeout(() => h(c), n);
4211
+ new Promise((d) => {
4212
+ o = window.setTimeout(() => d(c), n);
4085
4213
  })
4086
4214
  ]);
4087
- return u === c ? Ei(n) : {
4215
+ return u === c ? vi(n) : {
4088
4216
  ok: !0,
4089
4217
  result: u,
4090
4218
  console: r,
@@ -4113,7 +4241,7 @@ async function zt(s, e) {
4113
4241
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
4114
4242
  }
4115
4243
  }
4116
- function Ri(s, e) {
4244
+ function _i(s, e) {
4117
4245
  if (!s || typeof s != "object")
4118
4246
  return;
4119
4247
  const t = s.sandboxFilesToken;
@@ -4123,7 +4251,7 @@ function Ri(s, e) {
4123
4251
  const i = () => {
4124
4252
  if (!n)
4125
4253
  throw new Error("sandboxFiles is only available during browser-code execution");
4126
- }, r = async (a, l) => await _n(`${e.replace(/\/$/, "")}${a}`, l);
4254
+ }, r = async (a, l) => await vn(`${e.replace(/\/$/, "")}${a}`, l);
4127
4255
  return {
4128
4256
  value: Object.freeze({
4129
4257
  upload: async (a) => {
@@ -4146,8 +4274,8 @@ function Ri(s, e) {
4146
4274
  );
4147
4275
  if (!l.ok)
4148
4276
  throw new Error(`sandboxFiles.download failed (${l.status})`);
4149
- const c = await l.blob(), h = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
4150
- return new File([c], h || a.split("/").pop() || "file", {
4277
+ const c = await l.blob(), d = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
4278
+ return new File([c], d || a.split("/").pop() || "file", {
4151
4279
  type: c.type
4152
4280
  });
4153
4281
  }
@@ -4157,7 +4285,7 @@ function Ri(s, e) {
4157
4285
  }
4158
4286
  };
4159
4287
  }
4160
- function Ei(s) {
4288
+ function vi(s) {
4161
4289
  return {
4162
4290
  ok: !1,
4163
4291
  exception: {
@@ -4171,10 +4299,10 @@ function Ei(s) {
4171
4299
  }
4172
4300
  };
4173
4301
  }
4174
- function ki(s) {
4302
+ function Ui(s) {
4175
4303
  return s.replace(/\/+$/, "");
4176
4304
  }
4177
- function Ci(s) {
4305
+ function Di(s) {
4178
4306
  const e = {
4179
4307
  sidepanel: "extension_sidepanel",
4180
4308
  browser_extension_page_ui: "extension_widget",
@@ -4186,18 +4314,18 @@ function Ci(s) {
4186
4314
  };
4187
4315
  return s && s in e ? e[s] : s ?? "embedded_custom_ui";
4188
4316
  }
4189
- function Pi(s) {
4317
+ function qi(s) {
4190
4318
  return s === "pluno" ? "scheduled_continuation" : s ?? "user";
4191
4319
  }
4192
- function _i(s, e = location.origin) {
4320
+ function Oi(s, e = location.origin) {
4193
4321
  return /origin (?:is not allowed|does not match browser origin)/i.test(s) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
4194
4322
  }
4195
- function vi(s) {
4323
+ function xi(s) {
4196
4324
  const e = new URL("/api/product-agent/embed/ws", s);
4197
4325
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
4198
4326
  }
4199
4327
  function P() {
4200
- const s = Rs();
4328
+ const s = ks();
4201
4329
  return {
4202
4330
  url: location.href,
4203
4331
  title: document.title,
@@ -4205,19 +4333,19 @@ function P() {
4205
4333
  ...s ? { plunoProductAgentUi: s } : {}
4206
4334
  };
4207
4335
  }
4208
- function Ui() {
4336
+ function Li() {
4209
4337
  return {
4210
4338
  pageUrl: location.href,
4211
4339
  pageTitle: document.title,
4212
- htmlContent: St()
4340
+ htmlContent: At()
4213
4341
  };
4214
4342
  }
4215
- function Di(s) {
4216
- return Ee.add(s), Se || (Se = qi()), () => {
4217
- Ee.delete(s), Ee.size === 0 && (Se?.(), Se = null);
4343
+ function Ni(s) {
4344
+ return Ee.add(s), Te || (Te = Hi()), () => {
4345
+ Ee.delete(s), Ee.size === 0 && (Te?.(), Te = null);
4218
4346
  };
4219
4347
  }
4220
- function qi() {
4348
+ function Hi() {
4221
4349
  const s = () => {
4222
4350
  for (const r of Array.from(Ee))
4223
4351
  r();
@@ -4232,38 +4360,38 @@ function qi() {
4232
4360
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === i && (window.history.replaceState = t), window.removeEventListener("popstate", s), window.removeEventListener("hashchange", s);
4233
4361
  };
4234
4362
  }
4235
- function Ye() {
4236
- return Rs()?.surface === "browser_extension_sdk_preview";
4363
+ function et() {
4364
+ return ks()?.surface === "browser_extension_sdk_preview";
4237
4365
  }
4238
- function St() {
4366
+ function At() {
4239
4367
  if (!document.body)
4240
4368
  return "";
4241
- const s = [], e = [], t = (p, m) => {
4242
- const g = se(m);
4243
- !g || e.includes(g) || (s.push([p, g]), e.push(g));
4369
+ const s = [], e = [], t = (p, y) => {
4370
+ const m = ne(y);
4371
+ !m || e.includes(m) || (s.push([p, m]), e.push(m));
4244
4372
  };
4245
4373
  t("Selected text", window.getSelection()?.toString() ?? "");
4246
4374
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
4247
- (p) => As(p) && !p.parentElement?.closest(n)
4375
+ (p) => Ms(p) && !p.parentElement?.closest(n)
4248
4376
  );
4249
4377
  for (const p of i.slice(0, 3))
4250
- t("Active overlay", Ze(de(p), e));
4251
- const r = Oi(), o = r ? Ze(de(r), e) : "";
4252
- t("Main page content", o), t("Additional visible page text", Ze(de(document.body), e));
4253
- const a = s.map(([p, m]) => `${p}:
4254
- ${m}`).join(`
4378
+ t("Active overlay", tt(he(p), e));
4379
+ const r = Bi(), o = r ? tt(he(r), e) : "";
4380
+ t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
4381
+ const a = s.map(([p, y]) => `${p}:
4382
+ ${y}`).join(`
4255
4383
 
4256
- `).trim().slice(0, 12e3), l = xi(i, r).trim(), c = `Simplified DOM outline:
4384
+ `).trim().slice(0, 12e3), l = Wi(i, r).trim(), c = `Simplified DOM outline:
4257
4385
  `, u = `
4258
4386
 
4259
4387
  Visible page text:
4260
- `, h = 12e3 - c.length - u.length, f = Math.min(a.length, 7900), y = l.slice(0, h - f), d = a.slice(0, h - y.length);
4261
- return `${c}${y}${u}${d}`;
4388
+ `, d = 12e3 - c.length - u.length, g = Math.min(a.length, 7900), f = l.slice(0, d - g), h = a.slice(0, d - f.length);
4389
+ return `${c}${f}${u}${h}`;
4262
4390
  }
4263
- function de(s) {
4391
+ function he(s) {
4264
4392
  return s.innerText ?? s.textContent ?? "";
4265
4393
  }
4266
- function se(s) {
4394
+ function ne(s) {
4267
4395
  return (s ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
4268
4396
  `).split(`
4269
4397
  `).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
@@ -4271,20 +4399,20 @@ function se(s) {
4271
4399
 
4272
4400
  `).trim();
4273
4401
  }
4274
- function Ze(s, e) {
4275
- let t = se(s);
4402
+ function tt(s, e) {
4403
+ let t = ne(s);
4276
4404
  for (const n of e)
4277
4405
  t = t.replace(n, "");
4278
- return se(t);
4406
+ return ne(t);
4279
4407
  }
4280
- function As(s) {
4408
+ function Ms(s) {
4281
4409
  const e = window.getComputedStyle(s);
4282
4410
  return e.display !== "none" && e.visibility !== "hidden" && s.getClientRects().length > 0;
4283
4411
  }
4284
- function Oi() {
4285
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(As).sort((s, e) => de(e).length - de(s).length)[0] ?? null;
4412
+ function Bi() {
4413
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ms).sort((s, e) => he(e).length - he(s).length)[0] ?? null;
4286
4414
  }
4287
- function xi(s, e) {
4415
+ function Wi(s, e) {
4288
4416
  const t = /* @__PURE__ */ new Set([
4289
4417
  "main",
4290
4418
  "nav",
@@ -4364,92 +4492,92 @@ function xi(s, e) {
4364
4492
  "data-test",
4365
4493
  "data-qa",
4366
4494
  "data-cy"
4367
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: h } = Li(), f = new Set(s);
4368
- e && f.add(e);
4369
- let y = 0;
4370
- const d = (w) => {
4495
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = $i(), g = new Set(s);
4496
+ e && g.add(e);
4497
+ let f = 0;
4498
+ const h = (w) => {
4371
4499
  const D = w.getAttribute("role");
4372
4500
  return D && !o.has(D) ? D : "";
4373
4501
  }, p = (w) => {
4374
4502
  const D = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
4375
- return `${w.tagName.toLowerCase()}|${d(w)}|${D}`;
4376
- }, m = (w, D, H) => {
4503
+ return `${w.tagName.toLowerCase()}|${h(w)}|${D}`;
4504
+ }, y = (w, D, H) => {
4377
4505
  const S = (T, N) => {
4378
- const v = T.tagName.toLowerCase(), ie = window.getComputedStyle(T), J = u.has(T);
4379
- if (y >= 1e3 && !J || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ie.display === "none" || ie.visibility === "hidden")
4506
+ const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T), J = u.has(T);
4507
+ if (f >= 1e3 && !J || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || re.display === "none" || re.visibility === "hidden")
4380
4508
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
4381
- y += 1;
4382
- const Y = d(T), Z = bs(T), ge = a.has(Y) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(v) || v === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), Q = /* @__PURE__ */ new Map();
4509
+ f += 1;
4510
+ const Y = h(T), Z = Rs(T), fe = a.has(Y) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(v) || v === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), Q = /* @__PURE__ */ new Map();
4383
4511
  for (const I of B) {
4384
- const b = p(I);
4385
- Q.set(b, (Q.get(b) ?? 0) + 1);
4512
+ const R = p(I);
4513
+ Q.set(R, (Q.get(R) ?? 0) + 1);
4386
4514
  }
4387
- const fe = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
4515
+ const me = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map();
4388
4516
  for (const I of B) {
4389
- const b = p(I), z = re.get(b) ?? 0;
4390
- re.set(b, z + 1), (Q.get(b) ?? 0) > 8 && z >= 6 && !u.has(I) && fe.set(b, (fe.get(b) ?? 0) + 1);
4517
+ const R = p(I), z = oe.get(R) ?? 0;
4518
+ oe.set(R, z + 1), (Q.get(R) ?? 0) > 8 && z >= 6 && !u.has(I) && me.set(R, (me.get(R) ?? 0) + 1);
4391
4519
  }
4392
- const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Mt = [];
4520
+ const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], kt = [];
4393
4521
  for (const I of B) {
4394
- const b = p(I), z = Q.get(b) ?? 0, Et = j.get(b) ?? 0;
4395
- if (j.set(b, Et + 1), z > 8 && Et >= 6 && !u.has(I)) {
4396
- U.has(b) || (q.push([`… ${fe.get(b) ?? 0} similar siblings omitted`]), U.add(b));
4522
+ const R = p(I), z = Q.get(R) ?? 0, Pt = j.get(R) ?? 0;
4523
+ if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
4524
+ U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
4397
4525
  continue;
4398
4526
  }
4399
- const kt = S(I, N);
4400
- Mt.push(kt), q.push(kt.lines);
4527
+ const _t = S(I, N);
4528
+ kt.push(_t), q.push(_t.lines);
4401
4529
  }
4402
- const Ne = [];
4530
+ const Be = [];
4403
4531
  if (T.shadowRoot)
4404
4532
  for (const I of Array.from(T.shadowRoot.children))
4405
- I instanceof HTMLElement && Ne.push(S(I, N + 1));
4406
- const me = [...Mt, ...Ne], He = Z.length > 0 || ge || me.some((I) => I.hasUsefulContent), bt = se(
4407
- [Z, ...me.map((I) => I.textPreview)].filter(Boolean).join(" ")
4408
- ).slice(0, 180), Fs = T.hasAttribute("contenteditable") && (Z.length > 0 || !T.querySelector("[contenteditable]")), Rt = c.some((I) => T.hasAttribute(I)) || !!Y || Fs, Be = (T.getClientRects().length > 0 || ie.display === "contents") && (t.has(v) || Rt || J) && (He || J) && (!i.has(v) || He || Rt || J), We = Be ? 1 : 0, oe = [];
4409
- if (Be) {
4410
- const I = me.some((z) => z.containsTextElement), b = n.has(v) && !I ? bt : Z;
4411
- oe.push(Ms(T, l, o, b.slice(0, 180)));
4533
+ I instanceof HTMLElement && Be.push(S(I, N + 1));
4534
+ const ye = [...kt, ...Be], We = Z.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
4535
+ [Z, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
4536
+ ).slice(0, 180), js = T.hasAttribute("contenteditable") && (Z.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Y || js, $e = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || J) && (We || J) && (!i.has(v) || We || Ct || J), Fe = $e ? 1 : 0, ae = [];
4537
+ if ($e) {
4538
+ const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et : Z;
4539
+ ae.push(bs(T, l, o, R.slice(0, 180)));
4412
4540
  }
4413
4541
  for (const I of q)
4414
- oe.push(...Te(I, We));
4415
- const $e = Ne.flatMap((I) => I.lines);
4416
- if ($e.length > 0) {
4417
- const I = $e.slice(0, 20);
4418
- $e.length > I.length && I.push("… shadow DOM omitted");
4419
- const b = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
4420
- if (N < 2 && !b) {
4421
- const z = Be ? "#shadow-root" : `${v} #shadow-root`;
4422
- oe.push(...Te([z, ...Te(I, 1)], We));
4542
+ ae.push(...we(I, Fe));
4543
+ const je = Be.flatMap((I) => I.lines);
4544
+ if (je.length > 0) {
4545
+ const I = je.slice(0, 20);
4546
+ je.length > I.length && I.push("… shadow DOM omitted");
4547
+ const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
4548
+ if (N < 2 && !R) {
4549
+ const z = $e ? "#shadow-root" : `${v} #shadow-root`;
4550
+ ae.push(...we([z, ...we(I, 1)], Fe));
4423
4551
  } else
4424
- oe.push(...Te(I, We));
4552
+ ae.push(...we(I, Fe));
4425
4553
  }
4426
4554
  return {
4427
- lines: oe,
4428
- hasUsefulContent: He,
4429
- textPreview: bt,
4430
- containsTextElement: n.has(v) || me.some((I) => I.containsTextElement)
4555
+ lines: ae,
4556
+ hasUsefulContent: We,
4557
+ textPreview: Et,
4558
+ containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
4431
4559
  };
4432
4560
  };
4433
4561
  return [`--- ${D} ---`, ...S(w, 0).lines].join(`
4434
4562
  `);
4435
- }, g = [], M = se(window.getSelection()?.toString() ?? "");
4436
- M && g.push(`--- selected text ---
4437
- ${JSON.stringify(M)}`), h.length > 0 && g.push(Ni(h, t, l, o));
4563
+ }, m = [], M = ne(window.getSelection()?.toString() ?? "");
4564
+ M && m.push(`--- selected text ---
4565
+ ${JSON.stringify(M)}`), d.length > 0 && m.push(Fi(d, t, l, o));
4438
4566
  for (const w of s.slice(0, 3))
4439
- g.push(m(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4440
- if (e && g.push(m(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
4567
+ m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4568
+ if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
4441
4569
  const w = e || s.length ? "other visible DOM" : "visible DOM";
4442
- g.push(m(document.body, w, f));
4570
+ m.push(y(document.body, w, g));
4443
4571
  }
4444
- return g.join(`
4572
+ return m.join(`
4445
4573
 
4446
4574
  `);
4447
4575
  }
4448
- function Ms(s, e, t, n) {
4576
+ function bs(s, e, t, n) {
4449
4577
  const i = s.tagName.toLowerCase();
4450
4578
  let r = i;
4451
4579
  const o = s.getAttribute("id");
4452
- o && Hi(o) && (r += `#${o}`);
4580
+ o && ji(o) && (r += `#${o}`);
4453
4581
  for (const a of e) {
4454
4582
  const l = s.getAttribute(a);
4455
4583
  l && l.length <= 160 && (a !== "role" || !t.has(l)) && (r += `[${a}=${JSON.stringify(l)}]`);
@@ -4462,7 +4590,7 @@ function Ms(s, e, t, n) {
4462
4590
  s.hasAttribute(a) && (r += `[${a}]`);
4463
4591
  return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
4464
4592
  }
4465
- function Li() {
4593
+ function $i() {
4466
4594
  const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
4467
4595
  if (!a)
4468
4596
  return;
@@ -4471,11 +4599,11 @@ function Li() {
4471
4599
  return;
4472
4600
  const u = e.get(a) ?? /* @__PURE__ */ new Set();
4473
4601
  u.add(l), e.set(a, u);
4474
- let h = a;
4475
- for (; h; ) {
4476
- s.add(h);
4477
- const f = h.getRootNode();
4478
- h = h.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
4602
+ let d = a;
4603
+ for (; d; ) {
4604
+ s.add(d);
4605
+ const g = d.getRootNode();
4606
+ d = d.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
4479
4607
  }
4480
4608
  };
4481
4609
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -4483,7 +4611,7 @@ function Li() {
4483
4611
  n = n.shadowRoot.activeElement;
4484
4612
  n !== document.body && n !== document.documentElement && t(n, "focused");
4485
4613
  const i = window.getSelection();
4486
- i && !i.isCollapsed && (t(Kt(i.anchorNode), "selected text"), t(Kt(i.focusNode), "selected text"));
4614
+ i && !i.isCollapsed && (t(Qt(i.anchorNode), "selected text"), t(Qt(i.focusNode), "selected text"));
4487
4615
  const r = [
4488
4616
  ["[aria-selected='true']", "selected"],
4489
4617
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -4495,8 +4623,8 @@ function Li() {
4495
4623
  for (let a = 0; a < o.length; a += 1) {
4496
4624
  const l = o[a];
4497
4625
  for (const [c, u] of r)
4498
- for (const h of Array.from(l.querySelectorAll(c)))
4499
- t(h, u);
4626
+ for (const d of Array.from(l.querySelectorAll(c)))
4627
+ t(d, u);
4500
4628
  for (const c of Array.from(l.querySelectorAll("*")))
4501
4629
  c.shadowRoot && o.push(c.shadowRoot);
4502
4630
  }
@@ -4505,7 +4633,7 @@ function Li() {
4505
4633
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
4506
4634
  };
4507
4635
  }
4508
- function Ni(s, e, t, n) {
4636
+ function Fi(s, e, t, n) {
4509
4637
  const i = ["--- active/current elements ---"];
4510
4638
  for (const r of s) {
4511
4639
  const o = [];
@@ -4513,40 +4641,40 @@ function Ni(s, e, t, n) {
4513
4641
  for (; a; ) {
4514
4642
  const u = a.tagName.toLowerCase();
4515
4643
  (a === r.element || e.has(u) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
4516
- const h = a.getRootNode();
4517
- a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
4644
+ const d = a.getRootNode();
4645
+ a = a.parentElement ?? (d instanceof ShadowRoot && d.host instanceof HTMLElement ? d.host : null);
4518
4646
  }
4519
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => Ms(
4647
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, d) => bs(
4520
4648
  u,
4521
4649
  t,
4522
4650
  n,
4523
- h === l.length - 1 ? bs(u).slice(0, 180) : ""
4651
+ d === l.length - 1 ? Rs(u).slice(0, 180) : ""
4524
4652
  ));
4525
4653
  o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
4526
4654
  }
4527
4655
  return i.join(`
4528
4656
  `);
4529
4657
  }
4530
- function Kt(s) {
4658
+ function Qt(s) {
4531
4659
  return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
4532
4660
  }
4533
- function Te(s, e) {
4661
+ function we(s, e) {
4534
4662
  if (e === 0)
4535
4663
  return s;
4536
4664
  const t = " ".repeat(e);
4537
4665
  return s.map((n) => `${t}${n}`);
4538
4666
  }
4539
- function bs(s) {
4540
- return se(
4667
+ function Rs(s) {
4668
+ return ne(
4541
4669
  Array.from(s.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
4542
4670
  );
4543
4671
  }
4544
- function Hi(s) {
4672
+ function ji(s) {
4545
4673
  return s.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(s) && !/[a-f0-9]{12,}/i.test(s) && !/:r[0-9a-z]+:/i.test(s);
4546
4674
  }
4547
- function Rs() {
4548
- const s = Array.from(document.querySelectorAll(xt)), e = s.find(
4549
- (r) => typeof r[qn] == "string"
4675
+ function ks() {
4676
+ const s = Array.from(document.querySelectorAll(Ht)), e = s.find(
4677
+ (r) => typeof r[On] == "string"
4550
4678
  );
4551
4679
  if (!(e ?? s[0]))
4552
4680
  return;
@@ -4557,28 +4685,28 @@ function Rs() {
4557
4685
  selectors: [
4558
4686
  {
4559
4687
  name: "widget_host",
4560
- selector: xt,
4688
+ selector: Ht,
4561
4689
  description: "Finds Pluno's shadow-host element in the host page DOM."
4562
4690
  },
4563
4691
  {
4564
4692
  name: "widget_root",
4565
- selector: vn,
4693
+ selector: Un,
4566
4694
  description: "Finds Pluno's widget root inside the widget host shadow root."
4567
4695
  },
4568
4696
  {
4569
4697
  name: "widget_panel",
4570
- selector: Un,
4698
+ selector: Dn,
4571
4699
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
4572
4700
  },
4573
4701
  {
4574
4702
  name: "widget_timeline",
4575
- selector: Dn,
4703
+ selector: qn,
4576
4704
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
4577
4705
  }
4578
4706
  ]
4579
4707
  };
4580
4708
  }
4581
- function Bi(s) {
4709
+ function zi(s) {
4582
4710
  try {
4583
4711
  const e = JSON.parse(s);
4584
4712
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -4586,7 +4714,7 @@ function Bi(s) {
4586
4714
  return { type: "error", message: "Invalid server event" };
4587
4715
  }
4588
4716
  }
4589
- function Wi(s) {
4717
+ function Ki(s) {
4590
4718
  if (typeof s != "string")
4591
4719
  return null;
4592
4720
  try {
@@ -4596,13 +4724,13 @@ function Wi(s) {
4596
4724
  return null;
4597
4725
  }
4598
4726
  }
4599
- function Gt(s, e) {
4727
+ function Vt(s, e) {
4600
4728
  if (!s || typeof s != "object")
4601
4729
  return [];
4602
4730
  const t = s[e];
4603
4731
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
4604
4732
  }
4605
- function Qt(s) {
4733
+ function Xt(s) {
4606
4734
  return Array.isArray(s) ? s.flatMap((e) => {
4607
4735
  if (!e || typeof e != "object")
4608
4736
  return [];
@@ -4610,10 +4738,10 @@ function Qt(s) {
4610
4738
  return typeof t.taskId != "string" || !t.taskId || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? [] : [{ taskId: t.taskId, dueAt: t.dueAt }];
4611
4739
  }) : [];
4612
4740
  }
4613
- function $i(s) {
4741
+ function Gi(s) {
4614
4742
  return Array.isArray(s) ? s.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
4615
4743
  }
4616
- function Fi(s) {
4744
+ function Qi(s) {
4617
4745
  if (!s || typeof s != "object")
4618
4746
  return null;
4619
4747
  const e = s, t = e.appearance, n = t && typeof t == "object" ? t : e, i = typeof n.accentColor == "string" ? n.accentColor : null, r = 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;
@@ -4624,13 +4752,13 @@ function Fi(s) {
4624
4752
  ...a !== null ? { scribbleStyle: a } : {}
4625
4753
  };
4626
4754
  }
4627
- function ji(s) {
4755
+ function Vi(s) {
4628
4756
  if (!s || typeof s != "object")
4629
4757
  return null;
4630
4758
  const e = s.javascript;
4631
4759
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
4632
4760
  }
4633
- function zi(s, e) {
4761
+ function Xi(s, e) {
4634
4762
  return e ? s && typeof s == "object" ? {
4635
4763
  ...s,
4636
4764
  helperError: e
@@ -4640,13 +4768,13 @@ function zi(s, e) {
4640
4768
  helperError: e
4641
4769
  } : s;
4642
4770
  }
4643
- function Ki(s) {
4771
+ function Ji(s) {
4644
4772
  if (!s || typeof s != "object")
4645
4773
  return s;
4646
4774
  const e = s;
4647
4775
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : s;
4648
4776
  }
4649
- function Gi() {
4777
+ function Yi() {
4650
4778
  const s = "pluno.productAgent.clientId", e = window.localStorage.getItem(s);
4651
4779
  if (e)
4652
4780
  return e;
@@ -4656,7 +4784,7 @@ function Gi() {
4656
4784
  function x() {
4657
4785
  return crypto.randomUUID();
4658
4786
  }
4659
- function Qi(s) {
4787
+ function Zi(s) {
4660
4788
  if (!s || typeof s != "object")
4661
4789
  return null;
4662
4790
  const e = s, t = typeof e.id == "string" ? e.id : null;
@@ -4667,12 +4795,12 @@ function Qi(s) {
4667
4795
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
4668
4796
  } : null;
4669
4797
  }
4670
- function et(s, e) {
4671
- return Array.isArray(s) ? ut(
4672
- s.map((t) => rt(t, e)).filter((t) => t !== null)
4798
+ function st(s, e) {
4799
+ return Array.isArray(s) ? ht(
4800
+ s.map((t) => ve(t, e)).filter((t) => t !== null)
4673
4801
  ) : [];
4674
4802
  }
4675
- function Vi(s) {
4803
+ function er(s) {
4676
4804
  return Array.isArray(s) ? s.flatMap((e) => {
4677
4805
  if (!e || typeof e != "object")
4678
4806
  return [];
@@ -4693,29 +4821,29 @@ function Vi(s) {
4693
4821
  ];
4694
4822
  }) : [];
4695
4823
  }
4696
- function rt(s, e) {
4824
+ function ve(s, e) {
4697
4825
  if (!s || typeof s != "object")
4698
4826
  return null;
4699
4827
  const t = s, n = t.data;
4700
4828
  if (!n || typeof n != "object")
4701
4829
  return null;
4702
4830
  const i = n;
4703
- if (i.hiddenFromTranscript === !0 || sn(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
4831
+ if (i.hiddenFromTranscript === !0 || nn(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
4704
4832
  return null;
4705
4833
  if (i.type === "assistant_draft")
4706
4834
  return {
4707
4835
  id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
4708
4836
  role: "assistant",
4709
4837
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4710
- content: Ct(
4711
- Vt(i.content),
4838
+ content: vt(
4839
+ Jt(i.content),
4712
4840
  e
4713
4841
  ),
4714
4842
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4715
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4843
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4716
4844
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4717
4845
  respondsToUserMessageId: O(i) ?? void 0,
4718
- ...E(i) ? { runId: E(i) } : {},
4846
+ ...k(i) ? { runId: k(i) } : {},
4719
4847
  dataType: "assistant_draft",
4720
4848
  ...i.steered === !0 ? { steered: !0 } : {}
4721
4849
  };
@@ -4724,16 +4852,16 @@ function rt(s, e) {
4724
4852
  id: String(t.id ?? crypto.randomUUID()),
4725
4853
  role: r,
4726
4854
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4727
- content: Ct(
4728
- Vt(i.content),
4855
+ content: vt(
4856
+ Jt(i.content),
4729
4857
  e
4730
4858
  ),
4731
4859
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4732
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4860
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4733
4861
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4734
4862
  respondsToUserMessageId: O(i) ?? void 0,
4735
- ...E(i) ? { runId: E(i) } : {},
4736
- attachments: Us(i.attachments, e),
4863
+ ...k(i) ? { runId: k(i) } : {},
4864
+ attachments: Ds(i.attachments, e),
4737
4865
  ...i.steered === !0 ? { steered: !0 } : {}
4738
4866
  };
4739
4867
  return r === "assistant" && typeof i.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
@@ -4748,89 +4876,89 @@ function rt(s, e) {
4748
4876
  }), o;
4749
4877
  }
4750
4878
  if (i.type === "function_call_output") {
4751
- const r = Ys(i.output);
4879
+ const r = Zs(i.output);
4752
4880
  if (r !== null)
4753
4881
  return {
4754
4882
  id: String(t.id ?? crypto.randomUUID()),
4755
4883
  role: "tool",
4756
4884
  content: "",
4757
4885
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4758
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4886
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4759
4887
  respondsToUserMessageId: O(i) ?? void 0,
4760
- ...E(i) ? { runId: E(i) } : {},
4888
+ ...k(i) ? { runId: k(i) } : {},
4761
4889
  dataType: "function_call_output",
4762
- toolName: ds,
4763
- callId: ce(i) ?? void 0,
4890
+ toolName: St,
4891
+ callId: ue(i) ?? void 0,
4764
4892
  sharePromptAllowed: r
4765
4893
  };
4766
- const o = gn(i.output);
4894
+ const o = fn(i.output);
4767
4895
  if (o)
4768
4896
  return {
4769
4897
  id: String(t.id ?? crypto.randomUUID()),
4770
4898
  role: "tool",
4771
4899
  content: "",
4772
4900
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4773
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4901
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4774
4902
  respondsToUserMessageId: O(i) ?? void 0,
4775
- ...E(i) ? { runId: E(i) } : {},
4903
+ ...k(i) ? { runId: k(i) } : {},
4776
4904
  dataType: "scheduled_check_in",
4777
- toolName: ps,
4778
- callId: ce(i) ?? void 0,
4905
+ toolName: gs,
4906
+ callId: ue(i) ?? void 0,
4779
4907
  scheduledCheckInId: o.id ?? void 0,
4780
4908
  scheduledCheckInAt: o.dueAt
4781
4909
  };
4782
- const a = Ji(i.output), l = Yi(i.output);
4910
+ const a = sr(i.output), l = nr(i.output);
4783
4911
  return a ? {
4784
4912
  id: String(t.id ?? crypto.randomUUID()),
4785
4913
  role: "tool",
4786
4914
  content: `Connect ${a.appName} to continue`,
4787
4915
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4788
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4916
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4789
4917
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4790
4918
  respondsToUserMessageId: O(i) ?? void 0,
4791
- ...E(i) ? { runId: E(i) } : {},
4919
+ ...k(i) ? { runId: k(i) } : {},
4792
4920
  dataType: "function_call_output",
4793
4921
  toolName: "authenticate_pipedream_app",
4794
- callId: ce(i) ?? void 0,
4922
+ callId: ue(i) ?? void 0,
4795
4923
  integrationAuthRequest: a
4796
4924
  } : l ? {
4797
4925
  id: String(t.id ?? crypto.randomUUID()),
4798
4926
  role: "tool",
4799
4927
  content: "Connect WhatsApp to continue",
4800
4928
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4801
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4929
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4802
4930
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4803
4931
  respondsToUserMessageId: O(i) ?? void 0,
4804
- ...E(i) ? { runId: E(i) } : {},
4932
+ ...k(i) ? { runId: k(i) } : {},
4805
4933
  dataType: "function_call_output",
4806
4934
  toolName: "request_personal_channel_connection",
4807
- callId: ce(i) ?? void 0,
4935
+ callId: ue(i) ?? void 0,
4808
4936
  personalChannelConnectionRequest: l
4809
4937
  } : null;
4810
4938
  }
4811
4939
  return i.type === "function_call" || i.type === "tool_call" || i.type === "web_search_call" || i.type === "mcp_call" || i.type === "tab_lifecycle_decision" ? {
4812
4940
  id: String(t.id ?? crypto.randomUUID()),
4813
4941
  role: "tool",
4814
- content: i.type === "mcp_call" ? Xi(i) : er(i),
4942
+ content: i.type === "mcp_call" ? tr(i) : rr(i),
4815
4943
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4816
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4944
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4817
4945
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4818
4946
  respondsToUserMessageId: O(i) ?? void 0,
4819
- ...E(i) ? { runId: E(i) } : {},
4947
+ ...k(i) ? { runId: k(i) } : {},
4820
4948
  dataType: String(i.type),
4821
4949
  toolName: i.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof i.name == "string" ? i.name : void 0,
4822
- callId: ce(i) ?? void 0,
4950
+ callId: ue(i) ?? void 0,
4823
4951
  loading: i.steered === !0 ? !1 : i.localExecutionStatus === "queued" || i.localExecutionStatus === "running" ? !0 : typeof i.localExecutionStatus == "string" ? !1 : void 0,
4824
4952
  ...i.steered === !0 ? { steered: !0 } : {}
4825
4953
  } : i.type === "run_status" || i.type === "run_error" ? i.type === "run_error" && i.stage === "tool_execution" ? null : {
4826
4954
  id: String(t.id ?? crypto.randomUUID()),
4827
4955
  role: "system",
4828
- content: Zi(i),
4956
+ content: ir(i),
4829
4957
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4830
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4958
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4831
4959
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4832
4960
  respondsToUserMessageId: O(i) ?? void 0,
4833
- ...E(i) ? { runId: E(i) } : {},
4961
+ ...k(i) ? { runId: k(i) } : {},
4834
4962
  dataType: String(i.type),
4835
4963
  loading: i.steered !== !0 && i.type === "run_status" && (i.status === "running" || i.status === "retrying"),
4836
4964
  ...i.steered === !0 || i.type === "run_status" && i.status === "steered" ? { steered: !0 } : {},
@@ -4838,11 +4966,11 @@ function rt(s, e) {
4838
4966
  ...typeof i.securitySettingsUrl == "string" ? { securitySettingsUrl: i.securitySettingsUrl } : {}
4839
4967
  } : null;
4840
4968
  }
4841
- function Xi(s) {
4969
+ function tr(s) {
4842
4970
  const t = (typeof s.server_label == "string" ? s.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
4843
4971
  return t ? `🔌 Using ${t}` : "🔌 Using connected integration";
4844
4972
  }
4845
- function Ji(s) {
4973
+ function sr(s) {
4846
4974
  if (typeof s != "string")
4847
4975
  return null;
4848
4976
  try {
@@ -4859,7 +4987,7 @@ function Ji(s) {
4859
4987
  return null;
4860
4988
  }
4861
4989
  }
4862
- function Yi(s) {
4990
+ function nr(s) {
4863
4991
  if (typeof s != "string")
4864
4992
  return null;
4865
4993
  try {
@@ -4874,10 +5002,10 @@ function Yi(s) {
4874
5002
  return null;
4875
5003
  }
4876
5004
  }
4877
- function Zi(s) {
5005
+ function ir(s) {
4878
5006
  return s.type === "run_status" && s.status === "steered" ? "Steered" : typeof s.message == "string" && s.message.trim().length > 0 ? s.message : "";
4879
5007
  }
4880
- function er(s) {
5008
+ function rr(s) {
4881
5009
  if (s.type === "web_search_call") {
4882
5010
  const e = s.action;
4883
5011
  if (e && typeof e == "object") {
@@ -4889,26 +5017,26 @@ function er(s) {
4889
5017
  }
4890
5018
  return "🔎 Searching the web";
4891
5019
  }
4892
- return tr(s);
5020
+ return or(s);
4893
5021
  }
4894
- function tr(s) {
5022
+ function or(s) {
4895
5023
  if (typeof s.summary == "string" && s.summary.trim().length > 0)
4896
- return te(s.summary);
5024
+ return se(s.summary);
4897
5025
  if (typeof s.arguments == "string")
4898
5026
  try {
4899
5027
  const e = JSON.parse(s.arguments);
4900
5028
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
4901
- return te(e.summary);
5029
+ return se(e.summary);
4902
5030
  } catch {
4903
- return typeof s.name == "string" && s.name.trim().length > 0 ? te(s.name) : "🛠️ Run tool";
5031
+ return typeof s.name == "string" && s.name.trim().length > 0 ? se(s.name) : "🛠️ Run tool";
4904
5032
  }
4905
- return typeof s.name == "string" && s.name.trim().length > 0 ? te(s.name) : "🛠️ Run tool";
5033
+ return typeof s.name == "string" && s.name.trim().length > 0 ? se(s.name) : "🛠️ Run tool";
4906
5034
  }
4907
- function te(s) {
5035
+ function se(s) {
4908
5036
  const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
4909
5037
  return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
4910
5038
  }
4911
- function sr(s) {
5039
+ function ar(s) {
4912
5040
  if (s == null)
4913
5041
  return s;
4914
5042
  if (typeof s != "object")
@@ -4923,17 +5051,17 @@ function sr(s) {
4923
5051
  runId: typeof e.runId == "string" ? e.runId : null
4924
5052
  };
4925
5053
  }
4926
- function ce(s) {
5054
+ function ue(s) {
4927
5055
  const e = s.callId ?? s.call_id;
4928
5056
  return typeof e == "string" && e ? e : null;
4929
5057
  }
4930
5058
  function _(s) {
4931
5059
  return typeof s.causalSequence == "number" && Number.isSafeInteger(s.causalSequence) ? s.causalSequence : null;
4932
5060
  }
4933
- function k(s) {
5061
+ function E(s) {
4934
5062
  return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
4935
5063
  }
4936
- function Vt(s) {
5064
+ function Jt(s) {
4937
5065
  return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
4938
5066
  if (!e || typeof e != "object")
4939
5067
  return "";
@@ -4941,14 +5069,14 @@ function Vt(s) {
4941
5069
  return typeof t.text == "string" ? t.text : typeof t.content == "string" ? t.content : "";
4942
5070
  }).filter(Boolean).join("") : "";
4943
5071
  }
4944
- function ue(s, e) {
5072
+ function de(s, e) {
4945
5073
  const t = Es(
4946
5074
  s,
4947
- Tt(s, e)
4948
- ), n = rr(
4949
- ir(
4950
- cr(
4951
- nr(s, e),
5075
+ Mt(s, e)
5076
+ ), n = ur(
5077
+ cr(
5078
+ gr(
5079
+ lr(s, e),
4952
5080
  e
4953
5081
  ),
4954
5082
  t
@@ -4956,13 +5084,13 @@ function ue(s, e) {
4956
5084
  t
4957
5085
  ), i = n.findIndex((o) => o.id === t.id);
4958
5086
  if (i === -1)
4959
- return ut(
5087
+ return ht(
4960
5088
  [...n, t]
4961
5089
  );
4962
5090
  const r = [...n];
4963
- return r[i] = t, ut(r);
5091
+ return r[i] = t, ht(r);
4964
5092
  }
4965
- function Tt(s, e, t = !0) {
5093
+ function Mt(s, e, t = !0) {
4966
5094
  const n = s.find(
4967
5095
  (r) => r.id === e.id || e.callId !== void 0 && r.callId === e.callId || e.assistantDraftItemId !== void 0 && (r.id === e.assistantDraftItemId || r.assistantDraftItemId === e.assistantDraftItemId)
4968
5096
  );
@@ -4973,7 +5101,7 @@ function Tt(s, e, t = !0) {
4973
5101
  const i = s.flatMap((r) => (e.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId === e.respondsToUserMessageId : e.runId !== void 0 && r.respondsToUserMessageId === void 0 && r.runId === e.runId) && r.displaySequence !== void 0 ? [r.displaySequence] : []);
4974
5102
  return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
4975
5103
  }
4976
- function nr(s, e) {
5104
+ function lr(s, e) {
4977
5105
  const t = e.proactiveSuggestionClientMessageId;
4978
5106
  if (!t)
4979
5107
  return s;
@@ -4983,16 +5111,16 @@ function nr(s, e) {
4983
5111
  const r = [...s];
4984
5112
  return r[i] = e, r;
4985
5113
  }
4986
- function ir(s, e) {
5114
+ function cr(s, e) {
4987
5115
  const t = e.assistantDraftItemId;
4988
5116
  return t ? s.map(
4989
5117
  (n) => n.dataType === "assistant_draft" && n.id === t ? e : n
4990
5118
  ) : s;
4991
5119
  }
4992
- function we(s, e, t) {
5120
+ function Ae(s, e, t) {
4993
5121
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
4994
5122
  }
4995
- function Xt(s, e, t, n) {
5123
+ function Yt(s, e, t, n) {
4996
5124
  if (t === null) return s;
4997
5125
  let i = -1;
4998
5126
  for (let o = s.length - 1; o >= 0; o -= 1) {
@@ -5009,12 +5137,12 @@ function Xt(s, e, t, n) {
5009
5137
  respondsToUserMessageId: t
5010
5138
  }, r;
5011
5139
  }
5012
- function Jt(s, e) {
5140
+ function Zt(s, e) {
5013
5141
  const t = s.findIndex(
5014
5142
  (i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
5015
5143
  );
5016
5144
  if (t === -1)
5017
- return ue(s, e);
5145
+ return de(s, e);
5018
5146
  const n = [...s];
5019
5147
  return n[t] = {
5020
5148
  ...n[t],
@@ -5026,19 +5154,19 @@ function Jt(s, e) {
5026
5154
  ...n[t].runId ? {} : { runId: e.runId }
5027
5155
  }, n;
5028
5156
  }
5029
- function Yt(s, e, t) {
5157
+ function es(s, e, t) {
5030
5158
  let n = !1;
5031
5159
  const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
5032
5160
  return n ? i : s;
5033
5161
  }
5034
- function Zt(s) {
5162
+ function ts(s) {
5035
5163
  if (s.hiddenFromTranscript === !0)
5036
5164
  return null;
5037
5165
  const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
5038
5166
  return !e || !t ? null : {
5039
5167
  id: `transient-activity:${e}`,
5040
5168
  role: "tool",
5041
- content: te(
5169
+ content: se(
5042
5170
  typeof s.summary == "string" ? s.summary : "Running browser tool"
5043
5171
  ),
5044
5172
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -5051,7 +5179,7 @@ function Zt(s) {
5051
5179
  loading: !0
5052
5180
  };
5053
5181
  }
5054
- function rr(s, e) {
5182
+ function ur(s, e) {
5055
5183
  if (e.id.startsWith("transient-activity:"))
5056
5184
  return s;
5057
5185
  const t = e.toolName === "tab_lifecycle";
@@ -5060,30 +5188,30 @@ function rr(s, e) {
5060
5188
  const n = (r) => r.id === `transient-activity:${e.callId}` && r.callId === e.callId || t && r.id.startsWith("transient-activity:") && r.toolName === "browser_tabs" && !!r.runId && r.runId === e.runId, i = s.findIndex(n);
5061
5189
  return i === -1 ? s : s.flatMap((r, o) => n(r) ? o === i ? [e] : [] : r.id === e.id ? [] : [r]);
5062
5190
  }
5063
- function ot(s, e) {
5191
+ function lt(s, e) {
5064
5192
  const t = [];
5065
5193
  for (const n of e) {
5066
5194
  const i = [...s, ...t];
5067
5195
  t.push(
5068
5196
  Es(
5069
5197
  i,
5070
- Tt(i, n, !1)
5198
+ Mt(i, n, !1)
5071
5199
  )
5072
5200
  );
5073
5201
  }
5074
- return nn(
5202
+ return rn(
5075
5203
  s,
5076
5204
  t,
5077
- at
5205
+ ct
5078
5206
  );
5079
5207
  }
5080
- function or(s, e) {
5208
+ function dr(s, e) {
5081
5209
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5082
- (r) => Tt(s, r, !1)
5210
+ (r) => Mt(s, r, !1)
5083
5211
  );
5084
5212
  for (const r of n)
5085
5213
  t.set(r.id, r);
5086
- const i = ot(
5214
+ const i = lt(
5087
5215
  s,
5088
5216
  [...t.values()]
5089
5217
  );
@@ -5098,7 +5226,7 @@ function or(s, e) {
5098
5226
  }
5099
5227
  return i;
5100
5228
  }
5101
- function at(s) {
5229
+ function ct(s) {
5102
5230
  const e = X(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5103
5231
  // Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
5104
5232
  // from substituting the call for its output and then appending a duplicate output at the end of the timeline.
@@ -5112,7 +5240,7 @@ function at(s) {
5112
5240
  ...i.length > 0 ? { activityKeys: i } : {},
5113
5241
  ...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
5114
5242
  ...s.runId ? { runId: s.runId } : {},
5115
- isOptimistic: xe(s),
5243
+ isOptimistic: Ne(s),
5116
5244
  isAssistantDraft: s.dataType === "assistant_draft",
5117
5245
  isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
5118
5246
  isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
@@ -5122,42 +5250,42 @@ function Es(s, e) {
5122
5250
  if (e.role !== "user" || !e.attachments?.length)
5123
5251
  return e;
5124
5252
  const t = s.find(
5125
- (o) => o.role === "user" && (o.id === e.id || xe(o) && ks(o, e))
5253
+ (o) => o.role === "user" && (o.id === e.id || Ne(o) && Cs(o, e))
5126
5254
  );
5127
5255
  if (!t?.attachments?.length)
5128
5256
  return e;
5129
5257
  const n = e.attachments.map((o) => {
5130
- const a = ar(t.attachments ?? [], o);
5131
- return a ? lr(o, a) : o;
5258
+ const a = hr(t.attachments ?? [], o);
5259
+ return a ? pr(o, a) : o;
5132
5260
  }), i = { ...e, attachments: n }, r = X(e);
5133
5261
  return r && Object.defineProperty(i, "clientMessageId", {
5134
5262
  value: r,
5135
5263
  enumerable: !1
5136
5264
  }), i;
5137
5265
  }
5138
- function ar(s, e) {
5266
+ function hr(s, e) {
5139
5267
  return e.id ? s.find((t) => t.id === e.id) ?? null : null;
5140
5268
  }
5141
- function lr(s, e) {
5269
+ function pr(s, e) {
5142
5270
  const { previewUrl: t } = e;
5143
5271
  return t ? { ...s, previewUrl: t } : s;
5144
5272
  }
5145
- function cr(s, e) {
5273
+ function gr(s, e) {
5146
5274
  if (e.role !== "user")
5147
5275
  return s;
5148
5276
  const t = s.findIndex(
5149
- (i) => xe(i) && ks(i, e)
5277
+ (i) => Ne(i) && Cs(i, e)
5150
5278
  );
5151
5279
  if (t === -1)
5152
5280
  return s;
5153
5281
  const n = [...s];
5154
5282
  return n.splice(t, 1), n;
5155
5283
  }
5156
- function ks(s, e) {
5284
+ function Cs(s, e) {
5157
5285
  const t = X(s), n = X(e);
5158
5286
  return t && n ? t === n : s.content === e.content;
5159
5287
  }
5160
- function xe(s) {
5288
+ function Ne(s) {
5161
5289
  return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
5162
5290
  }
5163
5291
  function X(s) {
@@ -5169,13 +5297,13 @@ function X(s) {
5169
5297
  );
5170
5298
  return n ? s.id.slice(n.length) : null;
5171
5299
  }
5172
- function es(s) {
5173
- const e = Cs(s);
5300
+ function ss(s) {
5301
+ const e = Ps(s);
5174
5302
  if (e === null)
5175
5303
  return !1;
5176
5304
  const t = s[e].id;
5177
5305
  if (s.some(
5178
- (i) => i.respondsToUserMessageId === t && _e(i)
5306
+ (i) => i.respondsToUserMessageId === t && Ue(i)
5179
5307
  ))
5180
5308
  return !0;
5181
5309
  for (let i = s.length - 1; i > e; i -= 1) {
@@ -5193,7 +5321,7 @@ function es(s) {
5193
5321
  }
5194
5322
  return !1;
5195
5323
  }
5196
- function ur(s, e, t) {
5324
+ function fr(s, e, t) {
5197
5325
  const n = new Set(
5198
5326
  s.filter(
5199
5327
  (i) => i.role === "user" && e !== null && X(i) === e
@@ -5207,14 +5335,14 @@ function ur(s, e, t) {
5207
5335
  if (t && i.runId === t) {
5208
5336
  if (n.size === 0)
5209
5337
  return !0;
5210
- const o = Ps(s, r);
5338
+ const o = _s(s, r);
5211
5339
  return !i.respondsToUserMessageId && o !== null && n.has(o);
5212
5340
  }
5213
5341
  return !1;
5214
5342
  });
5215
5343
  }
5216
- function dr(s) {
5217
- const e = Cs(s);
5344
+ function mr(s) {
5345
+ const e = Ps(s);
5218
5346
  if (e === null)
5219
5347
  return s.some($);
5220
5348
  const t = s[e].id;
@@ -5222,16 +5350,16 @@ function dr(s) {
5222
5350
  (n) => n.respondsToUserMessageId === t && $(n)
5223
5351
  ) : s.slice(e + 1).some($);
5224
5352
  }
5225
- function Cs(s) {
5353
+ function Ps(s) {
5226
5354
  for (let e = s.length - 1; e >= 0; e -= 1)
5227
- if (s[e].role === "user" && !xe(s[e]))
5355
+ if (s[e].role === "user" && !Ne(s[e]))
5228
5356
  return e;
5229
5357
  return null;
5230
5358
  }
5231
- function _e(s) {
5359
+ function Ue(s) {
5232
5360
  return $(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5233
5361
  }
5234
- function ne(s) {
5362
+ function ie(s) {
5235
5363
  for (let e = s.length - 1; e >= 0; e -= 1) {
5236
5364
  const t = s[e];
5237
5365
  if (!t || typeof t != "object")
@@ -5245,8 +5373,8 @@ function ne(s) {
5245
5373
  }
5246
5374
  return null;
5247
5375
  }
5248
- function hr(s) {
5249
- const e = ne(s);
5376
+ function yr(s) {
5377
+ const e = ie(s);
5250
5378
  if (e === null)
5251
5379
  return null;
5252
5380
  const n = C(s[e])?.page;
@@ -5261,14 +5389,14 @@ function C(s) {
5261
5389
  const e = s.data;
5262
5390
  return e && typeof e == "object" ? e : null;
5263
5391
  }
5264
- function he(s) {
5392
+ function pe(s) {
5265
5393
  return s?.retryable !== !0 ? !1 : s.type === "run_error" ? !0 : s.type === "run_status" && s.status === "interrupted";
5266
5394
  }
5267
- function pr(s) {
5395
+ function Ir(s) {
5268
5396
  return s?.type === "run_status" && s.status === "interrupted" && s.reason === "backend_restart";
5269
5397
  }
5270
- function gr(s, e) {
5271
- const t = ne(e);
5398
+ function Sr(s, e) {
5399
+ const t = ie(e);
5272
5400
  if (t === null)
5273
5401
  return !1;
5274
5402
  const n = e[t], i = n && typeof n == "object" ? n.id : null;
@@ -5276,11 +5404,11 @@ function gr(s, e) {
5276
5404
  return !1;
5277
5405
  const r = s.findIndex((o) => o.role === "user" && o.id === i);
5278
5406
  return r === -1 ? !1 : s.some((o) => o.respondsToUserMessageId === i) ? s.some(
5279
- (o) => o.respondsToUserMessageId === i && _e(o)
5280
- ) : s.slice(r + 1).some(_e);
5407
+ (o) => o.respondsToUserMessageId === i && Ue(o)
5408
+ ) : s.slice(r + 1).some(Ue);
5281
5409
  }
5282
- function lt(s) {
5283
- const e = ne(s);
5410
+ function ut(s) {
5411
+ const e = ie(s);
5284
5412
  if (e === null)
5285
5413
  return null;
5286
5414
  const t = s[e];
@@ -5292,8 +5420,8 @@ function lt(s) {
5292
5420
  const i = n.clientMessageId;
5293
5421
  return typeof i == "string" ? i : null;
5294
5422
  }
5295
- function fr(s) {
5296
- const e = ne(s);
5423
+ function Tr(s) {
5424
+ const e = ie(s);
5297
5425
  if (e === null)
5298
5426
  return null;
5299
5427
  for (let t = s.length - 1; t > e; t -= 1) {
@@ -5307,13 +5435,13 @@ function fr(s) {
5307
5435
  if (r.type === "message" && r.role === "assistant")
5308
5436
  return null;
5309
5437
  if (r.type === "run_error")
5310
- return r.retryable !== !0 ? null : ct(s, r) ?? lt(s);
5438
+ return r.retryable !== !0 ? null : dt(s, r) ?? ut(s);
5311
5439
  if (r.type === "run_status")
5312
- return r.status === "interrupted" && r.retryable === !0 ? ct(s, r) ?? lt(s) : null;
5440
+ return r.status === "interrupted" && r.retryable === !0 ? dt(s, r) ?? ut(s) : null;
5313
5441
  }
5314
5442
  return null;
5315
5443
  }
5316
- function ct(s, e) {
5444
+ function dt(s, e) {
5317
5445
  if (typeof e.clientMessageId == "string")
5318
5446
  return e.clientMessageId;
5319
5447
  const t = O(e);
@@ -5322,16 +5450,16 @@ function ct(s, e) {
5322
5450
  const n = s.find((r) => A(r, "id") === t), i = C(n);
5323
5451
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5324
5452
  }
5325
- function ts(s, e, t, n, i, r) {
5326
- if (!e || !yr(s))
5453
+ function ns(s, e, t, n, i, r) {
5454
+ if (!e || !Ar(s))
5327
5455
  return !1;
5328
5456
  const o = s;
5329
- if (he(o) || t !== null && typeof o.id == "string" && o.id !== t)
5457
+ if (pe(o) || t !== null && typeof o.id == "string" && o.id !== t)
5330
5458
  return !1;
5331
5459
  const a = O(o);
5332
- return n !== null ? a !== null ? a === n : i !== null && E(o) === i && r === n : i === null || E(o) === i;
5460
+ return n !== null ? a !== null ? a === n : i !== null && k(o) === i && r === n : i === null || k(o) === i;
5333
5461
  }
5334
- function mr(s, e) {
5462
+ function wr(s, e) {
5335
5463
  for (let t = e - 1; t >= 0; t -= 1) {
5336
5464
  const n = C(s[t]);
5337
5465
  if (n?.type === "message" && n.role === "user")
@@ -5339,13 +5467,13 @@ function mr(s, e) {
5339
5467
  }
5340
5468
  return null;
5341
5469
  }
5342
- function Ps(s, e) {
5470
+ function _s(s, e) {
5343
5471
  for (let t = e - 1; t >= 0; t -= 1)
5344
5472
  if (s[t].role === "user")
5345
5473
  return s[t].id;
5346
5474
  return null;
5347
5475
  }
5348
- function yr(s) {
5476
+ function Ar(s) {
5349
5477
  if (!s || typeof s != "object")
5350
5478
  return !1;
5351
5479
  const e = s;
@@ -5354,37 +5482,37 @@ function yr(s) {
5354
5482
  function $(s) {
5355
5483
  return s.role === "assistant" && s.phase !== "commentary";
5356
5484
  }
5357
- function Ir(s) {
5485
+ function Mr(s) {
5358
5486
  if (!s || typeof s != "object")
5359
5487
  return !1;
5360
5488
  const e = s;
5361
5489
  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";
5362
5490
  }
5363
- function ut(s) {
5364
- return s.filter((e, t) => G(e) ? !vr(s, t) && !_s(s, t) && !Pr(s, t) && !_r(s, t) : Sr(e) ? e.retryable === !0 && Cr(s, t) ? !1 : !kr(s, t) : !0);
5491
+ function ht(s) {
5492
+ return s.filter((e, t) => G(e) ? !xr(s, t) && !vs(s, t) && !qr(s, t) && !Or(s, t) : br(e) ? e.retryable === !0 && Dr(s, t) ? !1 : !Ur(s, t) : !0);
5365
5493
  }
5366
- function Sr(s) {
5494
+ function br(s) {
5367
5495
  return s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.steered !== !0);
5368
5496
  }
5369
5497
  function G(s) {
5370
5498
  return s.role === "system" && s.dataType === "run_status" && s.loading === !0;
5371
5499
  }
5372
- function dt(s) {
5500
+ function pt(s) {
5373
5501
  return s.steered !== !0 && (s.dataType === "assistant_draft" || s.loading === !0);
5374
5502
  }
5375
- function Tr(s) {
5376
- return s.some(dt);
5503
+ function Rr(s) {
5504
+ return s.some(pt);
5377
5505
  }
5378
- function ss(s, e) {
5506
+ function is(s, e) {
5379
5507
  return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5380
5508
  }
5381
- function wr(s, e) {
5382
- const t = [...s].reverse().find(dt), n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : t?.respondsToUserMessageId ?? null, i = typeof e.runId == "string" ? e.runId : t?.runId ?? null;
5383
- return s.flatMap((r) => (n ? r.respondsToUserMessageId === n || !r.respondsToUserMessageId && i !== null && r.runId === i : i ? r.runId === i : dt(r)) ? r.dataType === "assistant_draft" || G(r) ? [] : r.loading === !0 ? [{ ...r, loading: !1 }] : [r] : [r]);
5509
+ function kr(s, e) {
5510
+ const t = [...s].reverse().find(pt), n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : t?.respondsToUserMessageId ?? null, i = typeof e.runId == "string" ? e.runId : t?.runId ?? null;
5511
+ return s.flatMap((r) => (n ? r.respondsToUserMessageId === n || !r.respondsToUserMessageId && i !== null && r.runId === i : i ? r.runId === i : pt(r)) ? r.dataType === "assistant_draft" || G(r) ? [] : r.loading === !0 ? [{ ...r, loading: !1 }] : [r] : [r]);
5384
5512
  }
5385
- function Ar(s, e, t, n) {
5513
+ function Er(s, e, t, n) {
5386
5514
  const i = s.findIndex(
5387
- (l, c) => G(l) && !_s(s, c)
5515
+ (l, c) => G(l) && !vs(s, c)
5388
5516
  ), r = i === -1 ? null : s[i], o = e ?? r?.respondsToUserMessageId ?? null, a = o ? s.find(
5389
5517
  (l) => l.role === "user" && l.id === o
5390
5518
  ) : null;
@@ -5394,13 +5522,13 @@ function Ar(s, e, t, n) {
5394
5522
  runId: t ?? r?.runId ?? null
5395
5523
  };
5396
5524
  }
5397
- function ke(s) {
5525
+ function Ce(s) {
5398
5526
  return s?.type === "run_status" && s.status === "stopped";
5399
5527
  }
5400
- function Mr(s, e) {
5401
- return $(e) ? "completed" : ke(s) ? "stopped" : !he(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5528
+ function Cr(s, e) {
5529
+ return $(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5402
5530
  }
5403
- function ns(s, e, t) {
5531
+ function rs(s, e, t) {
5404
5532
  const n = new Set(
5405
5533
  s.filter(
5406
5534
  (i) => i.role === "user" && e !== null && X(i) === e
@@ -5410,18 +5538,18 @@ function ns(s, e, t) {
5410
5538
  (i) => !G(i) || (n.size > 0 ? !i.respondsToUserMessageId || !n.has(i.respondsToUserMessageId) : !t || i.runId !== t)
5411
5539
  );
5412
5540
  }
5413
- function _s(s, e) {
5541
+ function vs(s, e) {
5414
5542
  return s.some(
5415
- (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && br(
5543
+ (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Pr(
5416
5544
  s,
5417
5545
  e,
5418
5546
  n
5419
5547
  )
5420
5548
  );
5421
5549
  }
5422
- function br(s, e, t) {
5550
+ function Pr(s, e, t) {
5423
5551
  const n = s[e], i = s[t];
5424
- if (pe(n, i))
5552
+ if (ge(n, i))
5425
5553
  return !0;
5426
5554
  if (!n.respondsToUserMessageId || i.respondsToUserMessageId || !n.runId || n.runId !== i.runId)
5427
5555
  return !1;
@@ -5430,20 +5558,20 @@ function br(s, e, t) {
5430
5558
  return s[r].id === n.respondsToUserMessageId;
5431
5559
  return !1;
5432
5560
  }
5433
- function is(s, e, t, n) {
5561
+ function os(s, e, t, n) {
5434
5562
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5435
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && rs(l) && !Er(
5563
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !vr(
5436
5564
  s,
5437
5565
  l.respondsToUserMessageId
5438
5566
  )
5439
- )?.respondsToUserMessageId ?? Rr(
5567
+ )?.respondsToUserMessageId ?? _r(
5440
5568
  s,
5441
5569
  e
5442
5570
  );
5443
5571
  if (!i)
5444
5572
  return s;
5445
5573
  let r = !1;
5446
- const o = s.map((l) => l.respondsToUserMessageId !== i || !rs(l) ? l : (r = !0, { ...l, steered: !0 }));
5574
+ const o = s.map((l) => l.respondsToUserMessageId !== i || !as(l) ? l : (r = !0, { ...l, steered: !0 }));
5447
5575
  if (r)
5448
5576
  return o;
5449
5577
  const a = s.find(
@@ -5465,7 +5593,7 @@ function is(s, e, t, n) {
5465
5593
  }
5466
5594
  ];
5467
5595
  }
5468
- function Rr(s, e) {
5596
+ function _r(s, e) {
5469
5597
  const t = s.findIndex(
5470
5598
  (n) => n.role === "user" && n.id === e
5471
5599
  );
@@ -5476,24 +5604,24 @@ function Rr(s, e) {
5476
5604
  return s[n].id;
5477
5605
  return null;
5478
5606
  }
5479
- function rs(s) {
5607
+ function as(s) {
5480
5608
  return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5481
5609
  }
5482
- function Er(s, e) {
5610
+ function vr(s, e) {
5483
5611
  return s.some(
5484
5612
  (t) => t.respondsToUserMessageId === e && ($(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5485
5613
  );
5486
5614
  }
5487
- function kr(s, e) {
5615
+ function Ur(s, e) {
5488
5616
  const t = s[e];
5489
5617
  for (let n = e + 1; n < s.length; n += 1) {
5490
5618
  const i = s[n];
5491
- if (i.role === "assistant" && pe(t, i))
5619
+ if (i.role === "assistant" && ge(t, i))
5492
5620
  return !0;
5493
5621
  }
5494
5622
  return !1;
5495
5623
  }
5496
- function Cr(s, e) {
5624
+ function Dr(s, e) {
5497
5625
  const t = s[e];
5498
5626
  if (!t.respondsToUserMessageId)
5499
5627
  return !1;
@@ -5506,40 +5634,40 @@ function Cr(s, e) {
5506
5634
  }
5507
5635
  return !1;
5508
5636
  }
5509
- function Pr(s, e) {
5637
+ function qr(s, e) {
5510
5638
  const t = s[e];
5511
5639
  return s.some(
5512
- (n, i) => i !== e && n.role === "assistant" && pe(t, n)
5640
+ (n, i) => i !== e && n.role === "assistant" && ge(t, n)
5513
5641
  );
5514
5642
  }
5515
- function _r(s, e) {
5643
+ function Or(s, e) {
5516
5644
  const t = s[e];
5517
5645
  return s.some(
5518
- (n, i) => i !== e && n.role === "tool" && pe(t, n)
5646
+ (n, i) => i !== e && n.role === "tool" && ge(t, n)
5519
5647
  );
5520
5648
  }
5521
- function vr(s, e) {
5649
+ function xr(s, e) {
5522
5650
  const t = s[e];
5523
5651
  for (let n = e + 1; n < s.length; n += 1)
5524
- if (G(s[n]) && pe(t, s[n]))
5652
+ if (G(s[n]) && ge(t, s[n]))
5525
5653
  return !0;
5526
5654
  return !1;
5527
5655
  }
5528
- function pe(s, e) {
5656
+ function ge(s, e) {
5529
5657
  return !!(s.respondsToUserMessageId && s.respondsToUserMessageId === e.respondsToUserMessageId);
5530
5658
  }
5531
5659
  function A(s, e) {
5532
5660
  return s && typeof s == "object" && typeof s[e] == "string" ? s[e] : null;
5533
5661
  }
5534
- function Ur(s, e) {
5662
+ function Lr(s, e) {
5535
5663
  try {
5536
- const t = window.localStorage.getItem(`${ws}${s}`);
5664
+ const t = window.localStorage.getItem(`${As}${s}`);
5537
5665
  if (!t)
5538
5666
  return null;
5539
5667
  const n = JSON.parse(t), i = typeof n.sessionId == "string" ? n.sessionId : null;
5540
5668
  if (e !== void 0 && i !== e)
5541
5669
  return null;
5542
- const r = Array.isArray(n.messages) ? n.messages.map(Fr).filter((o) => !!o) : [];
5670
+ const r = Array.isArray(n.messages) ? n.messages.map(Qr).filter((o) => !!o) : [];
5543
5671
  return {
5544
5672
  sessionId: i,
5545
5673
  messages: r
@@ -5548,53 +5676,53 @@ function Ur(s, e) {
5548
5676
  return null;
5549
5677
  }
5550
5678
  }
5551
- function ht(s) {
5679
+ function gt(s) {
5552
5680
  return s.role === "user" || s.role === "assistant" || // Live activity is part of the readable conversation cache. Keeping it across host navigation prevents a
5553
5681
  // running tool or commentary history from disappearing while authoritative hydration is still in flight.
5554
5682
  s.role === "tool" || s.dataType === "run_status" || s.dataType === "run_error";
5555
5683
  }
5556
- function Dr(s, e) {
5684
+ function Nr(s, e) {
5557
5685
  try {
5558
5686
  window.localStorage.setItem(
5559
- `${ws}${s}`,
5687
+ `${As}${s}`,
5560
5688
  JSON.stringify({
5561
5689
  sessionId: e.sessionId,
5562
- messages: e.messages.filter(ht).slice(-ii).map(jr)
5690
+ messages: e.messages.filter(gt).slice(-ai).map(Vr)
5563
5691
  })
5564
5692
  );
5565
5693
  } catch {
5566
5694
  return;
5567
5695
  }
5568
5696
  }
5569
- function qr(s) {
5697
+ function Hr(s) {
5570
5698
  try {
5571
- const e = window.localStorage.getItem(`${it}${s}`);
5699
+ const e = window.localStorage.getItem(`${at}${s}`);
5572
5700
  if (!e)
5573
5701
  return [];
5574
5702
  const t = JSON.parse(e);
5575
- return Array.isArray(t) ? t.filter(wt) : [];
5703
+ return Array.isArray(t) ? t.filter(bt) : [];
5576
5704
  } catch {
5577
5705
  return [];
5578
5706
  }
5579
5707
  }
5580
5708
  function V(s, e) {
5581
5709
  try {
5582
- const t = e.filter(wt);
5710
+ const t = e.filter(bt);
5583
5711
  if (t.length === 0) {
5584
- window.localStorage.removeItem(`${it}${s}`);
5712
+ window.localStorage.removeItem(`${at}${s}`);
5585
5713
  return;
5586
5714
  }
5587
5715
  window.localStorage.setItem(
5588
- `${it}${s}`,
5716
+ `${at}${s}`,
5589
5717
  JSON.stringify(t.slice(-25))
5590
5718
  );
5591
5719
  } catch {
5592
5720
  return;
5593
5721
  }
5594
5722
  }
5595
- function vs(s, e) {
5723
+ function Us(s, e) {
5596
5724
  try {
5597
- const t = `${qe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5725
+ const t = `${xe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5598
5726
  ...o,
5599
5727
  storedAt: Date.now(),
5600
5728
  unloadUrl: n,
@@ -5608,28 +5736,28 @@ function vs(s, e) {
5608
5736
  } catch {
5609
5737
  }
5610
5738
  }
5611
- function os(s, e) {
5739
+ function ls(s, e) {
5612
5740
  try {
5613
- if (window.sessionStorage.getItem(`${qe}${s}`) === null)
5741
+ if (window.sessionStorage.getItem(`${xe}${s}`) === null)
5614
5742
  return;
5615
5743
  } catch {
5616
5744
  return;
5617
5745
  }
5618
- vs(s, e);
5746
+ Us(s, e);
5619
5747
  }
5620
- function Or(s) {
5748
+ function Br(s) {
5621
5749
  try {
5622
- const e = `${qe}${s}`, t = window.sessionStorage.getItem(e);
5750
+ const e = `${xe}${s}`, t = window.sessionStorage.getItem(e);
5623
5751
  if (window.sessionStorage.removeItem(e), !t)
5624
5752
  return [];
5625
5753
  const n = JSON.parse(t);
5626
- return Array.isArray(n) ? n.flatMap((i) => Lr(i) ? [{
5754
+ return Array.isArray(n) ? n.flatMap((i) => $r(i) ? [{
5627
5755
  ...i.event,
5628
5756
  page: P(),
5629
5757
  rawOutput: {
5630
5758
  pageContextRestarted: !0,
5631
5759
  outcome: "unknown",
5632
- message: xr(location.href),
5760
+ message: Wr(location.href),
5633
5761
  currentUrl: location.href,
5634
5762
  console: [],
5635
5763
  metadata: {
@@ -5646,17 +5774,17 @@ function Or(s) {
5646
5774
  return [];
5647
5775
  }
5648
5776
  }
5649
- function xr(s) {
5777
+ function Wr(s) {
5650
5778
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
5651
5779
  Current URL: ${s}`;
5652
5780
  }
5653
- function Lr(s) {
5781
+ function $r(s) {
5654
5782
  if (!s || typeof s != "object")
5655
5783
  return !1;
5656
5784
  const e = s, t = e.event;
5657
- return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && wt(t) && t.type === "tool.result";
5785
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && bt(t) && t.type === "tool.result";
5658
5786
  }
5659
- function Nr(s, e) {
5787
+ function Fr(s, e) {
5660
5788
  const t = new Set(
5661
5789
  s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
5662
5790
  );
@@ -5665,26 +5793,26 @@ function Nr(s, e) {
5665
5793
  ...e.filter((n) => !t.has(n.callId))
5666
5794
  ];
5667
5795
  }
5668
- function Hr(s) {
5796
+ function jr(s) {
5669
5797
  try {
5670
- window.sessionStorage.removeItem(`${qe}${s}`);
5798
+ window.sessionStorage.removeItem(`${xe}${s}`);
5671
5799
  } catch {
5672
5800
  return;
5673
5801
  }
5674
5802
  }
5675
- function wt(s) {
5803
+ function bt(s) {
5676
5804
  if (!s || typeof s != "object")
5677
5805
  return !1;
5678
5806
  const e = s;
5679
- return e.type === "chat.user_message" ? typeof e.content == "string" && as(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? as(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;
5807
+ return e.type === "chat.user_message" ? typeof e.content == "string" && cs(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? cs(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;
5680
5808
  }
5681
- function as(s) {
5809
+ function cs(s) {
5682
5810
  if (!s || typeof s != "object")
5683
5811
  return !1;
5684
5812
  const e = s;
5685
5813
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
5686
5814
  }
5687
- function Us(s, e) {
5815
+ function Ds(s, e) {
5688
5816
  if (!Array.isArray(s))
5689
5817
  return;
5690
5818
  const t = s.filter((i) => {
@@ -5692,41 +5820,41 @@ function Us(s, e) {
5692
5820
  return !1;
5693
5821
  const r = i;
5694
5822
  return typeof r.name == "string" && typeof r.mimeType == "string" && typeof r.sizeBytes == "number";
5695
- }), n = e ? t.map((i) => Ds(i, e)) : t;
5823
+ }), n = e ? t.map((i) => qs(i, e)) : t;
5696
5824
  return n.length > 0 ? n : void 0;
5697
5825
  }
5698
- function Ds(s, e) {
5826
+ function qs(s, e) {
5699
5827
  return s.fileUrl?.startsWith("/") ? {
5700
5828
  ...s,
5701
5829
  fileUrl: new URL(s.fileUrl, e).toString()
5702
5830
  } : s;
5703
5831
  }
5704
- function pt(s) {
5705
- return s.type || $r(s.name) || "application/octet-stream";
5832
+ function ft(s) {
5833
+ return s.type || Gr(s.name) || "application/octet-stream";
5706
5834
  }
5707
- function Br(s) {
5708
- qs({
5835
+ function zr(s) {
5836
+ Os({
5709
5837
  name: s.name,
5710
- mimeType: pt(s),
5838
+ mimeType: ft(s),
5711
5839
  sizeBytes: s.size
5712
5840
  });
5713
5841
  }
5714
- function qs(s) {
5715
- const e = Wr(s.name), t = s.mimeType.trim().toLowerCase();
5716
- if (!ti.has(`${e}:${t}`))
5842
+ function Os(s) {
5843
+ const e = Kr(s.name), t = s.mimeType.trim().toLowerCase();
5844
+ if (!ii.has(`${e}:${t}`))
5717
5845
  throw new Error("This attachment type is not supported by the embedded model provider");
5718
- if (s.sizeBytes <= 0 || s.sizeBytes >= Ss)
5846
+ if (s.sizeBytes <= 0 || s.sizeBytes >= Ts)
5719
5847
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
5720
5848
  }
5721
- function Wr(s) {
5849
+ function Kr(s) {
5722
5850
  const e = s.trim().toLowerCase(), t = e.lastIndexOf(".");
5723
5851
  return t >= 0 ? e.slice(t) : "";
5724
5852
  }
5725
- function $r(s) {
5853
+ function Gr(s) {
5726
5854
  const e = s.toLowerCase();
5727
5855
  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;
5728
5856
  }
5729
- function Fr(s) {
5857
+ function Qr(s) {
5730
5858
  if (!s || typeof s != "object")
5731
5859
  return null;
5732
5860
  const e = s;
@@ -5744,17 +5872,17 @@ function Fr(s) {
5744
5872
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
5745
5873
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
5746
5874
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
5747
- attachments: Us(e.attachments)?.map(ve),
5875
+ attachments: Ds(e.attachments)?.map(De),
5748
5876
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5749
5877
  };
5750
5878
  }
5751
- function jr(s) {
5879
+ function Vr(s) {
5752
5880
  return s.attachments?.length ? {
5753
5881
  ...s,
5754
- attachments: s.attachments.map(ve)
5882
+ attachments: s.attachments.map(De)
5755
5883
  } : s;
5756
5884
  }
5757
- function ve(s) {
5885
+ function De(s) {
5758
5886
  const {
5759
5887
  dataUrl: e,
5760
5888
  objectUrl: t,
@@ -5768,43 +5896,43 @@ function O(s) {
5768
5896
  const e = s.respondsToUserMessageId;
5769
5897
  return typeof e == "string" && e ? e : null;
5770
5898
  }
5771
- function E(s) {
5899
+ function k(s) {
5772
5900
  const e = s.runId;
5773
5901
  return typeof e == "string" && e ? e : null;
5774
5902
  }
5775
- function zr(s) {
5903
+ function Xr(s) {
5776
5904
  const e = s?.timeoutMs;
5777
- return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= gi);
5905
+ return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Si);
5778
5906
  }
5779
- function Os(s) {
5907
+ function xs(s) {
5780
5908
  const e = {};
5781
5909
  try {
5782
5910
  new Headers(s).forEach((t, n) => {
5783
- Object.keys(e).length < It && (e[n] = At(n, t));
5911
+ Object.keys(e).length < wt && (e[n] = Rt(n, t));
5784
5912
  });
5785
5913
  } catch {
5786
5914
  return {};
5787
5915
  }
5788
5916
  return e;
5789
5917
  }
5790
- function At(s, e) {
5791
- return Ws(s) ? Le : W(De(e), si);
5918
+ function Rt(s, e) {
5919
+ return $s(s) ? He : W(Oe(e), ri);
5792
5920
  }
5793
- function Kr(s, e) {
5921
+ function Jr(s, e) {
5794
5922
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
5795
5923
  }
5796
- async function Gr(s, e, t, n) {
5797
- const i = Os(s.headers);
5924
+ async function Yr(s, e, t, n) {
5925
+ const i = xs(s.headers);
5798
5926
  n({
5799
5927
  ...e,
5800
5928
  responseStatus: s.status,
5801
5929
  responseHeaders: i,
5802
- responseBody: await Qr(s),
5930
+ responseBody: await Zr(s),
5803
5931
  durationMs: Date.now() - t
5804
5932
  });
5805
5933
  }
5806
- async function Qr(s) {
5807
- if (!xs(s.headers))
5934
+ async function Zr(s) {
5935
+ if (!Ls(s.headers))
5808
5936
  return;
5809
5937
  let e = null, t = null;
5810
5938
  try {
@@ -5813,7 +5941,7 @@ async function Qr(s) {
5813
5941
  const n = new Promise((a) => {
5814
5942
  t = window.setTimeout(() => {
5815
5943
  e?.cancel(), a("timeout");
5816
- }, ni);
5944
+ }, oi);
5817
5945
  }), i = new TextDecoder();
5818
5946
  let r = "", o = 0;
5819
5947
  for (; ; ) {
@@ -5823,7 +5951,7 @@ async function Qr(s) {
5823
5951
  const { done: l, value: c } = a;
5824
5952
  if (l)
5825
5953
  return W(r + i.decode());
5826
- const u = yt - o;
5954
+ const u = Tt - o;
5827
5955
  if (c.byteLength > u)
5828
5956
  return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${W(r)}... [truncated]`;
5829
5957
  o += c.byteLength, r += i.decode(c, { stream: !0 });
@@ -5835,45 +5963,45 @@ async function Qr(s) {
5835
5963
  t !== null && window.clearTimeout(t);
5836
5964
  }
5837
5965
  }
5838
- function Vr(s, e) {
5839
- if (xs(new Headers(e)))
5966
+ function eo(s, e) {
5967
+ if (Ls(new Headers(e)))
5840
5968
  try {
5841
5969
  return s.responseType === "" || s.responseType === "text" ? W(s.responseText ?? "") : void 0;
5842
5970
  } catch {
5843
5971
  return;
5844
5972
  }
5845
5973
  }
5846
- function ls(s) {
5974
+ function us(s) {
5847
5975
  if (typeof s == "string")
5848
5976
  return W(s);
5849
5977
  }
5850
- function Xr(s) {
5978
+ function to(s) {
5851
5979
  return L({
5852
5980
  ...s,
5853
- requestBody: cs(s.requestBody),
5854
- responseBody: cs(s.responseBody)
5981
+ requestBody: ds(s.requestBody),
5982
+ responseBody: ds(s.responseBody)
5855
5983
  });
5856
5984
  }
5857
- function cs(s) {
5985
+ function ds(s) {
5858
5986
  if (typeof s != "string")
5859
5987
  return s;
5860
5988
  const e = s.trim();
5861
5989
  if (!e.startsWith("{") && !e.startsWith("["))
5862
- return De(s);
5990
+ return Oe(s);
5863
5991
  try {
5864
5992
  return JSON.stringify(L(JSON.parse(s)));
5865
5993
  } catch {
5866
- return De(s);
5994
+ return Oe(s);
5867
5995
  }
5868
5996
  }
5869
- function xs(s) {
5997
+ function Ls(s) {
5870
5998
  if (!s)
5871
5999
  return !1;
5872
6000
  const e = s.get("content-type")?.toLowerCase() ?? "", t = s.get("content-length"), n = Number(t);
5873
- return t !== null && Number.isInteger(n) && n >= 0 && n <= yt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
6001
+ return t !== null && Number.isInteger(n) && n >= 0 && n <= Tt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
5874
6002
  }
5875
- function ee(s, e = {}, t) {
5876
- if (Yr(t))
6003
+ function te(s, e = {}, t) {
6004
+ if (no(t))
5877
6005
  return !0;
5878
6006
  const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
5879
6007
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -5888,8 +6016,8 @@ function ee(s, e = {}, t) {
5888
6016
  return !0;
5889
6017
  }
5890
6018
  }
5891
- function Jr(s, e) {
5892
- if (ee(s))
6019
+ function so(s, e) {
6020
+ if (te(s))
5893
6021
  return !0;
5894
6022
  try {
5895
6023
  const t = new URL(s, location.href), n = new URL(e);
@@ -5898,141 +6026,142 @@ function Jr(s, e) {
5898
6026
  return !0;
5899
6027
  }
5900
6028
  }
5901
- function Yr(s) {
6029
+ function no(s) {
5902
6030
  return s instanceof FormData || s instanceof Blob || s instanceof ArrayBuffer || ArrayBuffer.isView(s) || typeof ReadableStream < "u" && s instanceof ReadableStream;
5903
6031
  }
5904
- function Zr(s) {
6032
+ function io(s) {
5905
6033
  const e = {};
5906
6034
  for (const t of s.trim().split(/[\r\n]+/)) {
5907
6035
  const n = t.indexOf(":");
5908
6036
  if (n <= 0)
5909
6037
  continue;
5910
- if (Object.keys(e).length >= It)
6038
+ if (Object.keys(e).length >= wt)
5911
6039
  break;
5912
6040
  const i = t.slice(0, n).trim();
5913
- e[i] = At(i, t.slice(n + 1).trim());
6041
+ e[i] = Rt(i, t.slice(n + 1).trim());
5914
6042
  }
5915
6043
  return e;
5916
6044
  }
5917
- function W(s, e = yt) {
6045
+ function W(s, e = Tt) {
5918
6046
  return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
5919
6047
  }
5920
- function tt(s) {
6048
+ function nt(s) {
5921
6049
  return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
5922
6050
  }
5923
- class Ce extends Error {
6051
+ class Pe extends Error {
5924
6052
  constructor(e, t) {
5925
6053
  super(`${e} (${t})`), this.status = t, this.name = "AttachmentUploadHttpError";
5926
6054
  }
5927
6055
  status;
5928
6056
  }
5929
- async function Ae(s, e) {
6057
+ async function Me(s, e) {
5930
6058
  let t = null;
5931
- for (let n = 0; n < Ft; n += 1)
6059
+ for (let n = 0; n < zt; n += 1)
5932
6060
  try {
5933
6061
  return await s();
5934
6062
  } catch (i) {
5935
- if (t = i, n >= Ft - 1 || !to(i))
6063
+ if (t = i, n >= zt - 1 || !oo(i))
5936
6064
  throw i;
5937
- await eo(n);
6065
+ await ro(n);
5938
6066
  }
5939
6067
  throw t instanceof Error ? t : new Error(e);
5940
6068
  }
5941
- function eo(s) {
6069
+ function ro(s) {
5942
6070
  return new Promise((e) => {
5943
- window.setTimeout(e, ei[s] ?? 0);
6071
+ window.setTimeout(e, ni[s] ?? 0);
5944
6072
  });
5945
6073
  }
5946
- function to(s) {
5947
- return s instanceof Ce ? so(s.status) : s instanceof TypeError;
6074
+ function oo(s) {
6075
+ return s instanceof Pe ? ao(s.status) : s instanceof TypeError;
5948
6076
  }
5949
- function so(s) {
6077
+ function ao(s) {
5950
6078
  return s === 408 || s === 409 || s === 429 || s >= 500;
5951
6079
  }
5952
- function no(s) {
6080
+ function lo(s) {
5953
6081
  return s === 401 || s === 403;
5954
6082
  }
5955
- const Le = "[REDACTED_SECRET]", F = "[REDACTED_TOKEN]", io = "[REDACTED_SIGNED_URL]", ro = 20, oo = /^(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, Ls = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Ns = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Hs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Bs = /\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, ao = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, lo = /\bhttps?:\/\/[^\s"'<>]+/gi, co = /[),.;\]]+$/;
6083
+ const He = "[REDACTED_SECRET]", F = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(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, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\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, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
5956
6084
  function L(s) {
5957
- return Ue(s, 0, /* @__PURE__ */ new WeakSet());
6085
+ return qe(s, 0, /* @__PURE__ */ new WeakSet());
5958
6086
  }
5959
- function Ue(s, e, t) {
6087
+ function qe(s, e, t) {
5960
6088
  if (typeof s == "string")
5961
- return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : De(s);
6089
+ return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : Oe(s);
5962
6090
  if (s === null || typeof s != "object")
5963
6091
  return s;
5964
- if (e >= ro)
6092
+ if (e >= uo)
5965
6093
  return "[REDACTED_MAX_DEPTH]";
5966
6094
  if (t.has(s))
5967
6095
  return "[REDACTED_CIRCULAR]";
5968
6096
  if (t.add(s), Array.isArray(s))
5969
- return s.map((i) => Ue(i, e + 1, t));
6097
+ return s.map((i) => qe(i, e + 1, t));
5970
6098
  const n = {};
5971
6099
  for (const [i, r] of Object.entries(s))
5972
- i === "pageContent" ? n[i] = r : Ws(i) ? n[i] = Le : n[i] = i.toLowerCase() === "url" ? uo(r) : Ue(r, e + 1, t);
6100
+ i === "pageContent" ? n[i] = r : $s(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
5973
6101
  return n;
5974
6102
  }
5975
- function Ws(s) {
6103
+ function $s(s) {
5976
6104
  const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
5977
6105
  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");
5978
6106
  }
5979
- function uo(s) {
5980
- return typeof s == "string" ? $s(s) : Ue(s, 0, /* @__PURE__ */ new WeakSet());
6107
+ function mo(s) {
6108
+ return typeof s == "string" ? Fs(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
5981
6109
  }
5982
- function $s(s) {
6110
+ function Fs(s) {
5983
6111
  try {
5984
6112
  const e = new URL(s, location.href);
5985
6113
  for (const t of Array.from(e.searchParams.keys()))
5986
- oo.test(t) && e.searchParams.set(t, F);
6114
+ ho.test(t) && e.searchParams.set(t, F);
5987
6115
  return e.username && (e.username = F), e.password && (e.password = F), e.toString();
5988
6116
  } catch {
5989
- return ho(s);
6117
+ return yo(s);
5990
6118
  }
5991
6119
  }
5992
- function De(s) {
5993
- return s.replace(ao, io).replace(lo, po).replace(Ls, `Bearer ${F}`).replace(Ns, `Basic ${F}`).replace(Hs, F).replace(Bs, (e, t) => `${t}: ${Le}`);
6120
+ function Oe(s) {
6121
+ return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${He}`);
5994
6122
  }
5995
- function ho(s) {
5996
- return s.replace(Ls, `Bearer ${F}`).replace(Ns, `Basic ${F}`).replace(Hs, F).replace(Bs, (e, t) => `${t}: ${Le}`);
6123
+ function yo(s) {
6124
+ return s.replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${He}`);
5997
6125
  }
5998
- function po(s) {
5999
- const e = s.match(co)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6000
- return `${$s(t)}${e}`;
6126
+ function Io(s) {
6127
+ const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6128
+ return `${Fs(t)}${e}`;
6001
6129
  }
6002
- const Ao = Object.freeze({
6003
- init: (s) => Oe.init(s)
6130
+ const Eo = Object.freeze({
6131
+ init: (s) => Le.init(s)
6004
6132
  });
6005
- function Mo(s) {
6006
- return Oe.init(s);
6133
+ function Co(s) {
6134
+ return Le.init(s);
6007
6135
  }
6008
6136
  export {
6009
- xt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6010
- Un as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6011
- vn as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6012
- Dn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6013
- wo as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6014
- Ao as PlunoProductAgent,
6015
- Rn as ProductAgentInteractionManager,
6016
- Dt as ProductAgentQueryController,
6017
- To as ProductAgentRemoteRuntimeClient,
6018
- Oe as ProductAgentSessionEngine,
6019
- An as ProductAgentSessionHistoryManager,
6020
- yo as ProductAgentTaskPageTitleController,
6021
- li as calculateReconnectDelay,
6022
- mo as createLocalStorageInteractionDecisionStorage,
6023
- be as createProductAgentQueryState,
6024
- Mo as createProductAgentRuntime,
6025
- Io as createProductAgentTaskPageTitleDocument,
6026
- Ao as default,
6027
- Pn as formatProductAgentTaskPageTitle,
6028
- _i as getProductAgentOriginAccessErrorMessage,
6029
- So as isProductAgentRuntimeCommand,
6030
- Sn as mergeProductAgentEntityPages,
6031
- Re as normalizeProductAgentEntityPage,
6032
- et as normalizeProductAgentSessionItems,
6137
+ Ht as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6138
+ Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6139
+ Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6140
+ qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6141
+ ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6142
+ Eo as PlunoProductAgent,
6143
+ kn as ProductAgentInteractionManager,
6144
+ xt as ProductAgentQueryController,
6145
+ Ro as ProductAgentRemoteRuntimeClient,
6146
+ Le as ProductAgentSessionEngine,
6147
+ Mn as ProductAgentSessionHistoryManager,
6148
+ Ao as ProductAgentTaskPageTitleController,
6149
+ ee as ProductAgentTokenProviderError,
6150
+ di as calculateReconnectDelay,
6151
+ wo as createLocalStorageInteractionDecisionStorage,
6152
+ Re as createProductAgentQueryState,
6153
+ Co as createProductAgentRuntime,
6154
+ Mo as createProductAgentTaskPageTitleDocument,
6155
+ Eo as default,
6156
+ _n as formatProductAgentTaskPageTitle,
6157
+ Oi as getProductAgentOriginAccessErrorMessage,
6158
+ bo as isProductAgentRuntimeCommand,
6159
+ Tn as mergeProductAgentEntityPages,
6160
+ ke as normalizeProductAgentEntityPage,
6161
+ st as normalizeProductAgentSessionItems,
6033
6162
  En as readLocalStorageInteractionDecisions,
6034
- fo as resolveProductAgentComposerAction,
6035
- go as resolveProductAgentWidgetPresentation,
6036
- ys as selectProductAgentQueryEntities,
6037
- Br as validateProductAgentProviderInputFile
6163
+ To as resolveProductAgentComposerAction,
6164
+ So as resolveProductAgentWidgetPresentation,
6165
+ Is as selectProductAgentQueryEntities,
6166
+ zr as validateProductAgentProviderInputFile
6038
6167
  };