@pluno/product-agent-web 0.1.201 → 0.1.202

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 nt = "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(nt, { 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(nt, e), o = r.objectStore(nt);
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 ds(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 _t(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 hs = "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 !== hs || 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 = vt(s, e, "assistant");
99
99
  if (!n)
100
100
  return null;
101
- const i = Pt(s, n.index, "user");
101
+ const i = vt(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 vt(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,14 +136,14 @@ 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) {
146
+ function rn(s, e, t) {
147
147
  const n = e.map((d) => ({ item: d, identity: t(d) })), i = new Set(
148
148
  n.flatMap(
149
149
  ({ identity: d }) => d.isActivity && !d.isTransient ? d.activityKeys ?? [] : []
@@ -160,38 +160,38 @@ function nn(s, e, t) {
160
160
  )
161
161
  ), c = /* @__PURE__ */ new Map();
162
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);
163
+ for (const y of p.activityKeys ?? []) {
164
+ const f = c.get(y);
165
+ (!f || t(f).isTransient) && c.set(y, d);
166
166
  }
167
167
  const u = new Set(r.map(({ identity: d }) => d.id)), h = new Set(
168
168
  r.flatMap(({ identity: d }) => d.runId ? [d.runId] : [])
169
- ), f = /* @__PURE__ */ new Set(), y = [];
169
+ ), m = /* @__PURE__ */ new Set(), g = [];
170
170
  for (const d of s) {
171
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);
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 && !m.has(y)) {
174
+ g.push(y), m.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 f = p.respondsToUserMessageId !== void 0 && u.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
178
+ (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && f) && g.push(d);
179
179
  }
180
180
  for (const { item: d } of r)
181
- f.has(d) || y.push(d);
182
- return y;
181
+ m.has(d) || g.push(d);
182
+ return g;
183
183
  }
184
- function _t(s, e, t, n) {
184
+ function Ut(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 je = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", ze = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
191
+ let le = null;
192
+ const be = /* @__PURE__ */ new Set(), Ke = /* @__PURE__ */ new Map();
193
+ async function cn(s = ps()) {
194
+ const e = s.randomUUID(), t = s.storage.getItem(je);
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(je, 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(je, 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) ?? Ke.get(s) ?? null;
271
271
  } catch {
272
- return ze.get(s) ?? null;
272
+ return Ke.get(s) ?? null;
273
273
  }
274
274
  },
275
275
  setItem: (s, e) => {
276
- ze.set(s, e);
276
+ Ke.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 !== ze || !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
+ ze,
310
310
  JSON.stringify({ ...t, eventId: crypto.randomUUID() })
311
- ), window.localStorage.removeItem(je);
311
+ ), window.localStorage.removeItem(ze);
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
+ ], Ge = (s) => In.some((e) => e.value === s);
347
+ function Dt(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 = qt(t);
350
+ return fs(i) ? !s.slice(n + 1).some((r) => {
351
+ const o = qt(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 qt(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 Ot {
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 Ot(
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 Ot(
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 xt {
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(it).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(it).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 = Qe(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 `${Qe(e.scope)}:interaction:${e.key}`;
833
833
  }
834
834
  getCategoryKey(e) {
835
- return `${Ge(e.scope)}:category:${e.category}`;
835
+ return `${Qe(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(it) : [];
849
849
  }
850
- function Ge(s) {
850
+ function Qe(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 it(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 = Ve(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 Ve(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 = Ve(e), t !== void 0 && (this.model = t), n) {
994
+ this.sessionHistoryState = Lt(n);
995
995
  for (const o of this.sessionHistoryListeners)
996
996
  o(this.getSessionHistoryState());
997
997
  }
@@ -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 Lt(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 Ve(s) {
1221
1221
  return {
1222
1222
  ...s,
1223
1223
  starterPrompts: [...s.starterPrompts],
@@ -1238,21 +1238,29 @@ function Qe(s) {
1238
1238
  activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1239
1239
  };
1240
1240
  }
1241
- function Ot(s) {
1241
+ function Lt(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), Nt = '.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 Ht(s) {
1256
1264
  const e = {};
1257
1265
  for (const o of [
1258
1266
  "type",
@@ -1290,7 +1298,7 @@ function Lt(s) {
1290
1298
  }
1291
1299
  return e;
1292
1300
  }
1293
- function Ve(s, e, t) {
1301
+ function Xe(s, e, t) {
1294
1302
  if (typeof window > "u")
1295
1303
  return;
1296
1304
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -1302,54 +1310,74 @@ function Ve(s, e, t) {
1302
1310
  source: "web_sdk",
1303
1311
  category: s,
1304
1312
  name: e,
1305
- sequence: ++xn,
1313
+ sequence: ++Ln,
1306
1314
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
1307
1315
  monotonicMs: performance.now(),
1308
1316
  data: t
1309
1317
  };
1310
1318
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: i }));
1311
1319
  }
1312
- class Ie extends Error {
1320
+ class Se extends Error {
1313
1321
  }
1314
- function Ln(s) {
1322
+ function Nn(s) {
1315
1323
  return s === 408 || s === 425 || s === 429 || s >= 500;
1316
1324
  }
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([
1325
+ const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, $n = 6e4, Fn = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, rt = 3e4, Bt = 0.2, Vn = 6e4, Wt = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, Ft = 8e3, jt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
1318
1326
  ".jpeg:image/jpeg",
1319
1327
  ".jpg:image/jpeg",
1320
1328
  ".pdf:application/pdf",
1321
1329
  ".png:image/png",
1322
1330
  ".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) {
1331
+ ]), ko = ".pdf,.png,.jpg,.jpeg,.webp", St = 64e3, Je = 4e3, Tt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", ot = "pluno.productAgent.pendingEvents.", Oe = "pluno.productAgent.activeToolCalls.", ci = 100;
1332
+ function ui(s, e = 0) {
1325
1333
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1326
1334
  return Math.max(e, t);
1327
1335
  }
1328
1336
  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));
1337
+ let Te = null;
1338
+ function di(s, e = Math.random) {
1339
+ const t = Math.min(rt, Qn * 2 ** s), n = 1 - Bt + e() * Bt * 2;
1340
+ return Math.min(rt, Math.round(t * n));
1333
1341
  }
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
- });
1342
+ function hi(s) {
1343
+ const e = s.split(".")[1];
1344
+ if (!e)
1345
+ return null;
1346
+ try {
1347
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "="), i = JSON.parse(atob(n));
1348
+ return typeof i.exp == "number" && Number.isFinite(i.exp) ? i.exp * 1e3 : null;
1349
+ } catch {
1350
+ return null;
1351
+ }
1352
+ }
1353
+ function pi(s) {
1354
+ if (s instanceof ee)
1355
+ return s.retryable;
1356
+ if (s && typeof s == "object") {
1357
+ const e = s.status;
1358
+ if (typeof e == "number")
1359
+ return e === 408 || e === 425 || e === 429 || e >= 500;
1360
+ }
1361
+ return !0;
1362
+ }
1363
+ function gi(s) {
1364
+ if (s instanceof Error)
1365
+ return s;
1366
+ if (s && typeof s == "object") {
1367
+ const e = s, t = e.data && typeof e.data == "object" ? e.data.detail : null;
1368
+ if (typeof t == "string")
1369
+ return new Error(t);
1370
+ if (typeof e.error == "string")
1371
+ return new Error(e.error);
1372
+ }
1373
+ return new Error(String(s));
1346
1374
  }
1347
- class Oe {
1375
+ class xe {
1348
1376
  constructor(e, t) {
1349
- this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new An(
1377
+ this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new Mn(
1350
1378
  e.clientId,
1351
1379
  async ({ cursor: r, limit: o, pinned: a }) => await this.listSessions({ cursor: r, limit: o, pinned: a })
1352
- ), this.sessionRecoveryPoller = new qt({
1380
+ ), this.sessionRecoveryPoller = new xt({
1353
1381
  poll: async ({ sessionId: r }) => await this.fetchSessionHistoryPageOnce(
1354
1382
  r,
1355
1383
  "transcript",
@@ -1361,7 +1389,7 @@ class Oe {
1361
1389
  activeIntervalMs: 3e3,
1362
1390
  idleIntervalMs: 15e3,
1363
1391
  maxFailureIntervalMs: 3e4
1364
- }), this.sessionActivityRecovery = new bn({
1392
+ }), this.sessionActivityRecovery = new Rn({
1365
1393
  fetchPage: async (r, o) => await this.fetchSessionHistoryPageOnce(
1366
1394
  r,
1367
1395
  "activity",
@@ -1380,24 +1408,24 @@ class Oe {
1380
1408
  },
1381
1409
  getItemId: (r) => A(r, "id"),
1382
1410
  maxPagesPerPoll: 3
1383
- }), this.sessionActivityRecoveryPoller = new qt({
1411
+ }), this.sessionActivityRecoveryPoller = new xt({
1384
1412
  poll: async ({ sessionId: r }) => await this.sessionActivityRecovery.poll(r),
1385
1413
  apply: async (r) => await this.sessionActivityRecovery.apply(r),
1386
1414
  isActiveTurn: () => this.state.isThinking || this.state.pendingMessageStatus !== null,
1387
1415
  activeIntervalMs: 3e3,
1388
1416
  idleIntervalMs: 15e3,
1389
1417
  maxFailureIntervalMs: 3e4
1390
- }), this.personalModelSelectionOverride = e.productVariant === "personal" && Ke(e.model) ? e.model : null, this.state = {
1418
+ }), this.personalModelSelectionOverride = e.productVariant === "personal" && Ge(e.model) ? e.model : null, this.state = {
1391
1419
  ...this.state,
1392
- starterPrompts: $i(e.initialStarterPrompts)
1420
+ starterPrompts: Gi(e.initialStarterPrompts)
1393
1421
  }, this.account = e.initialAccount ? { ...e.initialAccount } : null;
1394
- const n = e.restorePersistedState === !1 ? null : Ur(e.clientId, e.expectedPersistedSessionId);
1422
+ const n = e.restorePersistedState === !1 ? null : Lr(e.clientId, e.expectedPersistedSessionId);
1395
1423
  n && (this.state = {
1396
1424
  ...this.state,
1397
1425
  ...n,
1398
1426
  // Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
1399
1427
  // activity is deliberately not restored here because it hydrates after the transcript is visible.
1400
- messages: n.messages.filter(ht),
1428
+ messages: n.messages.filter(gt),
1401
1429
  isLoadingSession: n.sessionId !== null,
1402
1430
  status: "idle",
1403
1431
  user: null,
@@ -1412,9 +1440,9 @@ class Oe {
1412
1440
  taskStatus: null,
1413
1441
  isRetrying: !1,
1414
1442
  lastError: null
1415
- }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Nr(
1416
- qr(e.clientId),
1417
- Or(e.clientId)
1443
+ }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Fr(
1444
+ Hr(e.clientId),
1445
+ Br(e.clientId)
1418
1446
  );
1419
1447
  const i = [...this.queuedClientEvents].reverse().find(
1420
1448
  (r) => r.type === "chat.user_message" && typeof r.clientMessageId == "string"
@@ -1433,6 +1461,9 @@ class Oe {
1433
1461
  connectionAttemptId = 0;
1434
1462
  connectionInProgress = !1;
1435
1463
  token = null;
1464
+ tokenExpiresAtMs = null;
1465
+ tokenRequest = null;
1466
+ tokenAbortController = null;
1436
1467
  authenticatedUserId = null;
1437
1468
  authenticatedSocket = null;
1438
1469
  networkCaptureCleanup = null;
@@ -1457,7 +1488,7 @@ class Oe {
1457
1488
  accountRefresh = null;
1458
1489
  runtimeInteractions = [];
1459
1490
  interactionListeners = /* @__PURE__ */ new Set();
1460
- interactionManager = new Rn(
1491
+ interactionManager = new kn(
1461
1492
  { load: async () => [], save: async () => {
1462
1493
  } },
1463
1494
  []
@@ -1544,18 +1575,18 @@ class Oe {
1544
1575
  lastErrorSecuritySettingsUrl: null
1545
1576
  };
1546
1577
  static async init(e) {
1547
- const t = e, n = await cn(
1578
+ const t = e, n = await un(
1548
1579
  t.skipStoredTransportIdentityCollisionCheck === !0
1549
- ), i = new Oe({
1580
+ ), i = new xe({
1550
1581
  ...e,
1551
- backendUrl: ki(e.backendUrl ?? Nn),
1552
- clientId: e.clientId ?? Gi(),
1582
+ backendUrl: Ui(e.backendUrl ?? Hn),
1583
+ clientId: e.clientId ?? Yi(),
1553
1584
  productVariant: e.productVariant ?? "customer_embedded",
1554
- entrySurface: Ci(e.entrySurface)
1585
+ entrySurface: Di(e.entrySurface)
1555
1586
  }, n);
1556
1587
  try {
1557
- Gs().catch((r) => {
1558
- R("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1588
+ Qs().catch((r) => {
1589
+ b("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1559
1590
  message: r instanceof Error ? r.message : String(r)
1560
1591
  });
1561
1592
  }), t.disableNetworkCapture || i.enableNetworkCapture(), i.startPageLifecycleRecovery(), i.startStarterPromptUrlWatcher(), e.autoConnect !== !1 && await i.connect();
@@ -1592,24 +1623,68 @@ class Oe {
1592
1623
  }, r = this.state.messages.findIndex((a) => a.id === n), o = [...this.state.messages];
1593
1624
  r >= 0 ? o[r] = i : o.push(i), this.setState({ messages: o }), this.emit("message", i);
1594
1625
  }
1626
+ invalidateProviderToken() {
1627
+ this.options.token || (this.token = null, this.tokenExpiresAtMs = null);
1628
+ }
1629
+ async acquireToken(e, t = {}) {
1630
+ if (this.options.token)
1631
+ return this.options.token;
1632
+ if (!this.options.tokenProvider)
1633
+ return this.token;
1634
+ const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - Fn > n;
1635
+ if (!t.forceRefresh && (i || t.preferCached && this.token !== null))
1636
+ return this.token;
1637
+ if (this.tokenRequest && !t.forceRefresh)
1638
+ return await this.tokenRequest;
1639
+ t.forceRefresh && (this.tokenAbortController?.abort(), this.tokenRequest = null, this.invalidateProviderToken());
1640
+ const r = new AbortController();
1641
+ this.tokenAbortController = r;
1642
+ const o = (async () => {
1643
+ let a = null;
1644
+ const l = new Promise((c, u) => {
1645
+ a = window.setTimeout(() => {
1646
+ r.abort(), u(new ee("Pluno token provider timed out", !0));
1647
+ }, $n);
1648
+ });
1649
+ try {
1650
+ const c = await Promise.race([
1651
+ this.options.tokenProvider?.({ signal: r.signal, reason: e }) ?? Promise.resolve(""),
1652
+ l
1653
+ ]);
1654
+ if (r.signal.aborted || this.tokenAbortController !== r)
1655
+ throw new ee("Pluno token request was cancelled", !0);
1656
+ if (!c)
1657
+ throw new ee("Pluno token provider did not return a token", !1);
1658
+ return this.token = c, this.tokenExpiresAtMs = hi(c), c;
1659
+ } finally {
1660
+ a !== null && window.clearTimeout(a);
1661
+ }
1662
+ })();
1663
+ this.tokenRequest = o;
1664
+ try {
1665
+ return await o;
1666
+ } finally {
1667
+ this.tokenRequest === o && (this.tokenRequest = null, this.tokenAbortController = null);
1668
+ }
1669
+ }
1595
1670
  async connect() {
1596
1671
  if (this.connectionInProgress || this.socket?.readyState === WebSocket.OPEN || this.socket?.readyState === WebSocket.CONNECTING)
1597
1672
  return;
1598
- this.connectionInProgress = !0;
1673
+ this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null, this.reconnectAttempts = 0), this.connectionInProgress = !0;
1599
1674
  const e = ++this.connectionAttemptId;
1600
1675
  this.setState(
1601
1676
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
1602
1677
  );
1603
1678
  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")
1679
+ if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
1605
1680
  return;
1606
1681
  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);
1682
+ throw new ee("Pluno requires a token or tokenProvider", !1);
1683
+ const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1609
1684
  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", {
1685
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
1686
+ }, jn), n.addEventListener("open", () => {
1687
+ this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
1613
1688
  queuedClientEventCount: this.queuedClientEvents.length,
1614
1689
  isThinking: this.state.isThinking
1615
1690
  }), !(this.token ? this.sendNow({
@@ -1619,19 +1694,19 @@ class Oe {
1619
1694
  transportId: this.transportIdentity.transportId,
1620
1695
  pageUrl: location.href
1621
1696
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
1622
- this.socket === n && (R("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
1623
- }, Fn));
1697
+ this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
1698
+ }, zn));
1624
1699
  }), n.addEventListener("message", (i) => {
1625
- this.socket === n && this.handleServerEvent(Bi(i.data));
1700
+ this.socket === n && this.handleServerEvent(zi(i.data));
1626
1701
  }), n.addEventListener("sendfailure", (i) => {
1627
1702
  if (this.socket !== n)
1628
1703
  return;
1629
- const r = Wi(i?.detail?.data);
1704
+ const r = Ki(i?.detail?.data);
1630
1705
  r?.type === "chat.user_message" && r.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
1631
1706
  (o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
1632
1707
  ) && (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
1708
  }), 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", {
1709
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (b("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
1635
1710
  code: typeof i?.code == "number" ? i.code : null,
1636
1711
  reason: typeof i?.reason == "string" ? i.reason : "",
1637
1712
  wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
@@ -1639,30 +1714,42 @@ class Oe {
1639
1714
  isThinking: this.state.isThinking
1640
1715
  }), this.setReconnectingState(), this.scheduleReconnect()));
1641
1716
  }), n.addEventListener("error", () => {
1642
- this.socket !== n || this.state.status === "closed" || (R("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1717
+ this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1643
1718
  queuedClientEventCount: this.queuedClientEvents.length,
1644
1719
  isThinking: this.state.isThinking
1645
1720
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
1646
1721
  });
1647
1722
  } 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,
1723
+ if (e !== this.connectionAttemptId || this.state.status === "closed")
1724
+ return;
1725
+ const n = gi(t);
1726
+ if (pi(t)) {
1727
+ b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
1728
+ message: n.message,
1729
+ reconnectAttempt: this.reconnectAttempts
1730
+ }), this.setState({
1731
+ status: "reconnecting",
1732
+ lastError: Zn,
1653
1733
  lastErrorCode: "connection_failed"
1654
- }), this.emit("error", n);
1734
+ }), this.emit("error", n), this.scheduleReconnect(
1735
+ t instanceof ee ? t.retryAfterMs : void 0
1736
+ );
1737
+ return;
1655
1738
  }
1656
- throw t;
1739
+ throw this.setState({
1740
+ status: "error",
1741
+ lastError: n.message,
1742
+ lastErrorCode: "connection_failed"
1743
+ }), this.emit("error", n), n;
1657
1744
  } finally {
1658
1745
  this.connectionInProgress = !1;
1659
1746
  }
1660
1747
  }
1661
1748
  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;
1749
+ 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
1750
  }
1664
1751
  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();
1752
+ 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
1753
  for (const e of Object.values(this.listeners))
1667
1754
  e?.clear();
1668
1755
  this.accountListeners.clear(), this.interactionListeners.clear();
@@ -1702,12 +1789,12 @@ class Oe {
1702
1789
  }
1703
1790
  async sendMessage(e, t = {}) {
1704
1791
  const n = e.trim(), i = t.attachments ?? [];
1705
- if (this.options.productVariant === "customer_embedded" && (i.forEach(qs), i.reduce(
1792
+ if (this.options.productVariant === "customer_embedded" && (i.forEach(Os), i.reduce(
1706
1793
  (T, N) => T + N.sizeBytes,
1707
1794
  0
1708
- ) > Ss))
1795
+ ) > Ts))
1709
1796
  throw new Error("Embedded attachments must total at most 50 MB per message");
1710
- let r = i.map(ve);
1797
+ let r = i.map(Ue);
1711
1798
  if (!n && r.length === 0)
1712
1799
  return null;
1713
1800
  if (this.pendingClientMessageId)
@@ -1726,7 +1813,7 @@ class Oe {
1726
1813
  content: n,
1727
1814
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1728
1815
  ...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 : [
1816
+ }, m = this.state.messages.some((S) => S.id === h.id || S.clientMessageId === a), g = this.state.isThinking, d = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, f = this.state.messages, M = m ? this.state.messages : [
1730
1817
  ...this.state.messages.map(
1731
1818
  (S) => c && S.id === c.id ? {
1732
1819
  ...S,
@@ -1745,7 +1832,7 @@ class Oe {
1745
1832
  };
1746
1833
  this.setState({
1747
1834
  messages: M,
1748
- ...y ? {} : {
1835
+ ...g ? {} : {
1749
1836
  assistantDraft: "",
1750
1837
  assistantDraftItemId: null,
1751
1838
  assistantDraftPhase: null,
@@ -1753,12 +1840,12 @@ class Oe {
1753
1840
  assistantDraftRunId: null
1754
1841
  },
1755
1842
  pendingMessageStatus: "sending",
1756
- turnPhase: y ? m : "sending",
1757
- isThinking: y,
1843
+ turnPhase: g ? y : "sending",
1844
+ isThinking: g,
1758
1845
  taskStatus: "working",
1759
1846
  isRetrying: !1,
1760
1847
  lastError: null
1761
- }), f || (this.sessionHistoryManager.addOptimistic({
1848
+ }), m || (this.sessionHistoryManager.addOptimistic({
1762
1849
  id: h.id,
1763
1850
  title: null,
1764
1851
  customTitle: null,
@@ -1784,11 +1871,11 @@ class Oe {
1784
1871
  }
1785
1872
  r = S;
1786
1873
  } catch (S) {
1787
- throw f || this.sessionHistoryManager.removeOptimistic(h.id), this.setState({
1788
- ...f ? {} : { messages: g },
1789
- ...y ? {} : { ...w, isThinking: !1 },
1874
+ throw m || this.sessionHistoryManager.removeOptimistic(h.id), this.setState({
1875
+ ...m ? {} : { messages: f },
1876
+ ...g ? {} : { ...w, isThinking: !1 },
1790
1877
  pendingMessageStatus: p,
1791
- turnPhase: m,
1878
+ turnPhase: y,
1792
1879
  taskStatus: d
1793
1880
  }), S;
1794
1881
  }
@@ -1798,15 +1885,15 @@ class Oe {
1798
1885
  sessionId: this.state.sessionId ?? void 0,
1799
1886
  clientMessageId: a,
1800
1887
  initiatedBy: t.initiatedBy,
1801
- invocation: Pi(t.invocation ?? t.initiatedBy),
1888
+ invocation: qi(t.invocation ?? t.initiatedBy),
1802
1889
  entrySurface: this.options.entrySurface,
1803
1890
  content: n,
1804
1891
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1805
- pageContent: D && St() || void 0,
1806
- attachments: r.length > 0 ? r.map(ve) : void 0,
1892
+ pageContent: D && wt() || void 0,
1893
+ attachments: r.length > 0 ? r.map(Ue) : void 0,
1807
1894
  page: o,
1808
1895
  model: this.options.model,
1809
- metadata: jt(this.options.metadata)
1896
+ metadata: zt(this.options.metadata)
1810
1897
  };
1811
1898
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1812
1899
  }
@@ -1814,7 +1901,7 @@ class Oe {
1814
1901
  return this.options.model;
1815
1902
  }
1816
1903
  setModel(e) {
1817
- this.options.model = e, this.options.productVariant === "personal" && Ke(e) && (this.personalModelSelectionOverride = e);
1904
+ this.options.model = e, this.options.productVariant === "personal" && Ge(e) && (this.personalModelSelectionOverride = e);
1818
1905
  }
1819
1906
  retryLastMessage() {
1820
1907
  const e = this.state.sessionId, t = this.retryableClientMessageId;
@@ -1832,16 +1919,16 @@ class Oe {
1832
1919
  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
1920
  }
1834
1921
  createLocalAttachment(e) {
1835
- this.options.productVariant === "customer_embedded" && Br(e);
1922
+ this.options.productVariant === "customer_embedded" && zr(e);
1836
1923
  const t = x(), n = {
1837
1924
  id: t,
1838
1925
  name: e.name || "attachment",
1839
- mimeType: pt(e),
1926
+ mimeType: ft(e),
1840
1927
  sizeBytes: e.size
1841
1928
  };
1842
1929
  this.attachmentFiles.set(t, e);
1843
1930
  const i = Date.now();
1844
- return zs({
1931
+ return Ks({
1845
1932
  attachmentId: t,
1846
1933
  name: n.name,
1847
1934
  mimeType: n.mimeType,
@@ -1852,7 +1939,7 @@ class Oe {
1852
1939
  createdAt: i,
1853
1940
  lastUsedAt: i
1854
1941
  }).catch((r) => {
1855
- R("web-sdk.attachments", "Failed to store Product Agent attachment", {
1942
+ b("web-sdk.attachments", "Failed to store Product Agent attachment", {
1856
1943
  attachmentId: t,
1857
1944
  name: n.name,
1858
1945
  message: r instanceof Error ? r.message : String(r)
@@ -1870,7 +1957,7 @@ class Oe {
1870
1957
  file: e,
1871
1958
  attachment: t
1872
1959
  }) {
1873
- const n = this.state.sessionId, i = pt(e), r = {
1960
+ const n = this.state.sessionId, i = ft(e), r = {
1874
1961
  sessionId: n ?? void 0,
1875
1962
  attachmentId: t.id,
1876
1963
  clientId: this.options.clientId,
@@ -1880,41 +1967,41 @@ class Oe {
1880
1967
  sizeBytes: e.size,
1881
1968
  page: P(),
1882
1969
  model: this.options.model,
1883
- metadata: jt(this.options.metadata),
1970
+ metadata: zt(this.options.metadata),
1884
1971
  entrySurface: this.options.entrySurface
1885
1972
  };
1886
1973
  let o;
1887
1974
  if (this.options.persistAttachmentUpload)
1888
- o = await Ae(
1975
+ o = await Me(
1889
1976
  () => this.options.persistAttachmentUpload(r, e),
1890
1977
  "Failed to upload attachment"
1891
1978
  );
1892
1979
  else {
1893
- const l = this.options.prepareAttachmentUpload ? await Ae(
1980
+ const l = this.options.prepareAttachmentUpload ? await Me(
1894
1981
  () => this.options.prepareAttachmentUpload(r),
1895
1982
  "Failed to prepare attachment upload"
1896
1983
  ) : await this.prepareEmbedAttachmentUpload(r);
1897
- await Ae(async () => {
1984
+ await Me(async () => {
1898
1985
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
1899
1986
  method: l.uploadMethod,
1900
1987
  headers: l.uploadHeaders,
1901
1988
  body: e
1902
1989
  });
1903
1990
  if (!c.ok)
1904
- throw new Ce("Failed to upload attachment", c.status);
1991
+ throw new Pe("Failed to upload attachment", c.status);
1905
1992
  return c;
1906
1993
  }, "Failed to upload attachment"), o = l;
1907
1994
  }
1908
1995
  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, {
1996
+ const a = qs(o.attachment, this.options.backendUrl);
1997
+ return this.updateAttachmentInState(t.id, a), t.id && Gs(t.id, {
1911
1998
  sessionId: o.sessionId,
1912
1999
  fileUrl: a.fileUrl,
1913
2000
  sandboxPath: a.sandboxPath,
1914
2001
  storageKey: a.storageKey,
1915
2002
  lastUsedAt: Date.now()
1916
2003
  }).catch((l) => {
1917
- R("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
2004
+ b("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
1918
2005
  attachmentId: t.id,
1919
2006
  name: a.name,
1920
2007
  message: l instanceof Error ? l.message : String(l)
@@ -1934,26 +2021,26 @@ class Oe {
1934
2021
  }
1935
2022
  async prepareEmbedAttachmentUpload(e) {
1936
2023
  let t = !1;
1937
- return await Ae(async () => {
1938
- const n = await this.fetchEmbedAttachmentUpload(e);
2024
+ return await Me(async () => {
2025
+ const n = await this.fetchEmbedAttachmentUpload(e, !1);
1939
2026
  if (n.ok)
1940
2027
  return await n.json();
1941
- if (no(n.status) && this.options.tokenProvider && !t) {
2028
+ if (lo(n.status) && this.options.tokenProvider && !t) {
1942
2029
  t = !0;
1943
- const i = await this.fetchEmbedAttachmentUpload(e);
2030
+ const i = await this.fetchEmbedAttachmentUpload(e, !0);
1944
2031
  if (i.ok)
1945
2032
  return await i.json();
1946
- throw new Ce("Failed to prepare attachment upload", i.status);
2033
+ throw new Pe("Failed to prepare attachment upload", i.status);
1947
2034
  }
1948
- throw new Ce("Failed to prepare attachment upload", n.status);
2035
+ throw new Pe("Failed to prepare attachment upload", n.status);
1949
2036
  }, "Failed to prepare attachment upload");
1950
2037
  }
1951
- async fetchEmbedAttachmentUpload(e) {
1952
- const t = await this.getUploadToken();
2038
+ async fetchEmbedAttachmentUpload(e, t) {
2039
+ const n = await this.getUploadToken(t);
1953
2040
  return await fetch(new URL("/api/product-agent/embed/attachments/upload", this.options.backendUrl), {
1954
2041
  method: "POST",
1955
2042
  headers: {
1956
- authorization: `Bearer ${t}`,
2043
+ authorization: `Bearer ${n}`,
1957
2044
  "content-type": "application/json"
1958
2045
  },
1959
2046
  body: JSON.stringify(e)
@@ -1963,7 +2050,7 @@ class Oe {
1963
2050
  if (!this.state.sessionId)
1964
2051
  return;
1965
2052
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
1966
- const e = Ar(
2053
+ const e = Er(
1967
2054
  this.state.messages,
1968
2055
  this.state.assistantDraftRespondsToUserMessageId,
1969
2056
  this.state.assistantDraftRunId,
@@ -1978,7 +2065,7 @@ class Oe {
1978
2065
  stoppedCausalSequence: null,
1979
2066
  toolCallIds: new Set(
1980
2067
  this.state.messages.filter(
1981
- (t) => we(
2068
+ (t) => Ae(
1982
2069
  t,
1983
2070
  e.respondsToUserMessageId,
1984
2071
  e.runId
@@ -1988,8 +2075,8 @@ class Oe {
1988
2075
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
1989
2076
  for (const [t, n] of this.activeBrowserToolCalls)
1990
2077
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
1991
- os(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
1992
- messages: ns(
2078
+ as(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
2079
+ messages: is(
1993
2080
  this.state.messages,
1994
2081
  e.clientMessageId,
1995
2082
  e.runId
@@ -2033,7 +2120,7 @@ class Oe {
2033
2120
  const t = x(), n = new Promise((r, o) => {
2034
2121
  const a = window.setTimeout(() => {
2035
2122
  this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
2036
- }, $t);
2123
+ }, Ft);
2037
2124
  this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
2038
2125
  }), i = {
2039
2126
  type: "sessions.list",
@@ -2098,7 +2185,7 @@ class Oe {
2098
2185
  throw new Error("This interaction is no longer available.");
2099
2186
  if (!r.allowedActions.includes(t))
2100
2187
  throw new Error("This action is not available for the interaction.");
2101
- if (On(t) && await this.interactionManager.act(
2188
+ if (xn(t) && await this.interactionManager.act(
2102
2189
  {
2103
2190
  key: r.id,
2104
2191
  category: r.category,
@@ -2147,7 +2234,7 @@ class Oe {
2147
2234
  this.rebuildRuntimeInteractions();
2148
2235
  }
2149
2236
  rebuildRuntimeInteractions() {
2150
- const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? Js(this.state.messages) : null;
2237
+ const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? Ys(this.state.messages) : null;
2151
2238
  if (t) {
2152
2239
  const r = {
2153
2240
  key: t.id,
@@ -2273,7 +2360,7 @@ class Oe {
2273
2360
  loadSession(e) {
2274
2361
  const t = x(), n = this.activeComposerWarmupId;
2275
2362
  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 ?? []);
2363
+ const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Rr(i ?? []);
2277
2364
  !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
2365
  type: "session.reset",
2279
2366
  warmupId: n,
@@ -2379,9 +2466,9 @@ class Oe {
2379
2466
  try {
2380
2467
  return await this.fetchSessionHistoryPageOnce(e, t, n);
2381
2468
  } catch (o) {
2382
- if (o instanceof Ie)
2469
+ if (o instanceof Se)
2383
2470
  throw o;
2384
- R("web-sdk.history", "HTTP session history page failed; retrying", {
2471
+ b("web-sdk.history", "HTTP session history page failed; retrying", {
2385
2472
  sessionId: e,
2386
2473
  hasCursor: !!n,
2387
2474
  retryDelayMs: r,
@@ -2391,9 +2478,9 @@ class Oe {
2391
2478
  return null;
2392
2479
  }
2393
2480
  async fetchSessionHistoryPageOnce(e, t, n, i = !1) {
2394
- const r = this.options.token ?? (i ? this.token : null) ?? await this.options.tokenProvider?.() ?? this.token;
2481
+ const r = await this.acquireToken("history", { preferCached: i });
2395
2482
  if (!r)
2396
- throw new Ie("Product Agent history requires authentication");
2483
+ throw new Se("Product Agent history requires authentication");
2397
2484
  this.token = r;
2398
2485
  const o = new URLSearchParams({ limit: "200" });
2399
2486
  n && o.set("cursor", n);
@@ -2407,11 +2494,11 @@ class Oe {
2407
2494
  });
2408
2495
  if (!c.ok) {
2409
2496
  const h = await c.text() || `History request failed (${c.status})`;
2410
- throw Ln(c.status) ? new Error(h) : new Ie(h);
2497
+ throw Nn(c.status) ? new Error(h) : new Se(h);
2411
2498
  }
2412
2499
  const u = await c.json();
2413
2500
  if (!u?.session || !Array.isArray(u.items))
2414
- throw new Ie("Invalid Product Agent session history response");
2501
+ throw new Se("Invalid Product Agent session history response");
2415
2502
  return {
2416
2503
  session: u.session,
2417
2504
  items: u.items,
@@ -2424,7 +2511,7 @@ class Oe {
2424
2511
  return;
2425
2512
  const r = n instanceof Error ? n.message : String(n);
2426
2513
  if (i) {
2427
- this.sessionActivityRequestId = null, R("web-sdk.history", "Background session activity hydration stopped", {
2514
+ this.sessionActivityRequestId = null, b("web-sdk.history", "Background session activity hydration stopped", {
2428
2515
  sessionId: t,
2429
2516
  message: r
2430
2517
  });
@@ -2436,7 +2523,7 @@ class Oe {
2436
2523
  message: r,
2437
2524
  requestId: e,
2438
2525
  sessionId: t
2439
- }), R("web-sdk.history", "HTTP session history page failed permanently", {
2526
+ }), b("web-sdk.history", "HTTP session history page failed permanently", {
2440
2527
  sessionId: t,
2441
2528
  message: r
2442
2529
  });
@@ -2449,20 +2536,22 @@ class Oe {
2449
2536
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
2450
2537
  }), this.scheduleReconnect());
2451
2538
  }
2452
- async getUploadToken() {
2453
- const e = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
2454
- if (!e)
2539
+ async getUploadToken(e = !1) {
2540
+ const t = await this.acquireToken("upload", {
2541
+ forceRefresh: e
2542
+ });
2543
+ if (!t)
2455
2544
  throw new Error("Pluno attachment upload requires a token or tokenProvider");
2456
- return this.token = e, e;
2545
+ return this.token = t, t;
2457
2546
  }
2458
2547
  sendNow(e) {
2459
2548
  if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
2460
2549
  return !1;
2461
2550
  const t = this.socket;
2462
2551
  try {
2463
- return t.send(JSON.stringify(e)), Ve("client_event", e.type, Lt(e)), !0;
2552
+ return t.send(JSON.stringify(e)), Xe("client_event", e.type, Ht(e)), !0;
2464
2553
  } catch (n) {
2465
- return R("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2554
+ return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2466
2555
  message: n instanceof Error ? n.message : String(n),
2467
2556
  queuedClientEventCount: this.queuedClientEvents.length,
2468
2557
  isThinking: this.state.isThinking
@@ -2494,7 +2583,7 @@ class Oe {
2494
2583
  }
2495
2584
  }));
2496
2585
  } catch (i) {
2497
- R("web-sdk.agent", "Pluno health signal send failed", {
2586
+ b("web-sdk.agent", "Pluno health signal send failed", {
2498
2587
  name: e,
2499
2588
  message: i instanceof Error ? i.message : String(i)
2500
2589
  });
@@ -2504,7 +2593,7 @@ class Oe {
2504
2593
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
2505
2594
  return;
2506
2595
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
2507
- const e = Ui();
2596
+ const e = Li();
2508
2597
  this.sendNow(
2509
2598
  L({
2510
2599
  type: "starter_prompts.page_context",
@@ -2515,13 +2604,13 @@ class Oe {
2515
2604
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
2516
2605
  }
2517
2606
  startStarterPromptUrlWatcher() {
2518
- this.locationChangeCleanup || (this.locationChangeCleanup = Di(() => this.handleStarterPromptUrlChange()));
2607
+ this.locationChangeCleanup || (this.locationChangeCleanup = Ni(() => this.handleStarterPromptUrlChange()));
2519
2608
  }
2520
2609
  handleStarterPromptUrlChange() {
2521
2610
  const e = location.href;
2522
2611
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
2523
2612
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
2524
- }, oi));
2613
+ }, ci));
2525
2614
  }
2526
2615
  refreshStarterPromptsForCurrentUrl() {
2527
2616
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -2551,7 +2640,7 @@ class Oe {
2551
2640
  }
2552
2641
  rememberSessionTimeline(e, t) {
2553
2642
  const n = [...t];
2554
- for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > ri; ) {
2643
+ for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > li; ) {
2555
2644
  const i = this.sessionTimelineCache.keys().next().value;
2556
2645
  if (!i)
2557
2646
  break;
@@ -2581,8 +2670,8 @@ class Oe {
2581
2670
  return;
2582
2671
  this.clearPendingWarmupAckTimer();
2583
2672
  const t = Math.min(
2584
- jn * 2 ** e.retryAttempt,
2585
- zn
2673
+ Kn * 2 ** e.retryAttempt,
2674
+ Gn
2586
2675
  );
2587
2676
  e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
2588
2677
  this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
@@ -2603,9 +2692,9 @@ class Oe {
2603
2692
  }
2604
2693
  rememberDurablyStoppedTurn(e, t) {
2605
2694
  const n = C(t);
2606
- if (!e || !n || !ke(n) || this.findStoppedTurn(e, n))
2695
+ if (!e || !n || !Ce(n) || this.findStoppedTurn(e, n))
2607
2696
  return;
2608
- const i = O(n), r = E(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
2697
+ const i = O(n), r = k(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
2609
2698
  this.stoppedTurns.push({
2610
2699
  sessionId: e,
2611
2700
  clientMessageId: o,
@@ -2617,7 +2706,7 @@ class Oe {
2617
2706
  stoppedCausalSequence: _(n),
2618
2707
  toolCallIds: new Set(
2619
2708
  this.state.messages.filter(
2620
- (a) => we(a, i, r)
2709
+ (a) => Ae(a, i, r)
2621
2710
  ).map((a) => a.callId).filter((a) => typeof a == "string")
2622
2711
  )
2623
2712
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -2626,7 +2715,7 @@ class Oe {
2626
2715
  if (!e || !t)
2627
2716
  return;
2628
2717
  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({
2718
+ !n || n.reason !== "task_tab_closed" || Sn(n, t) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
2630
2719
  messages: this.state.messages.filter((i) => i.id !== n.stoppedItemId)
2631
2720
  }));
2632
2721
  }
@@ -2635,12 +2724,12 @@ class Oe {
2635
2724
  const n = typeof e.callId == "string" ? e.callId : null;
2636
2725
  return !!(n && this.stoppedTurns.some((i) => i.toolCallIds.has(n)));
2637
2726
  }
2638
- return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !ke(C(e.item)) : e.type !== "conversation.state" : !1;
2727
+ return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Ce(C(e.item)) : e.type !== "conversation.state" : !1;
2639
2728
  }
2640
2729
  filterStoppedSnapshotItems(e, t) {
2641
2730
  return e.filter((n) => {
2642
2731
  const i = C(n), r = i ? this.findStoppedTurn(t, i) : null;
2643
- if (!r || i?.type === "message" && i.role === "user" || ke(i))
2732
+ if (!r || i?.type === "message" && i.role === "user" || Ce(i))
2644
2733
  return !0;
2645
2734
  if (r.stoppedCausalSequence !== null) {
2646
2735
  const o = i ? _(i) : null;
@@ -2654,7 +2743,7 @@ class Oe {
2654
2743
  });
2655
2744
  }
2656
2745
  handleServerEvent(e) {
2657
- if (Ve("server_event", e.type, Lt(e)), e.type === "session.subscribed") {
2746
+ if (Xe("server_event", e.type, Ht(e)), e.type === "session.subscribed") {
2658
2747
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2659
2748
  if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
2660
2749
  const i = this.pendingSessionSubscription;
@@ -2667,7 +2756,7 @@ class Oe {
2667
2756
  this.pendingSessionSubscription = null, t.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
2668
2757
  return;
2669
2758
  }
2670
- if (this.sessionHistoryHydration && le(e) && K(e) === this.sessionHistoryHydration.sessionId) {
2759
+ if (this.sessionHistoryHydration && ce(e) && K(e) === this.sessionHistoryHydration.sessionId) {
2671
2760
  this.sessionHistoryHydration.bufferedEvents.push(e);
2672
2761
  return;
2673
2762
  }
@@ -2720,17 +2809,17 @@ class Oe {
2720
2809
  this.activeResponseRunId = t, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
2721
2810
  return;
2722
2811
  }
2723
- if (hi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2812
+ if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2724
2813
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
2725
- const t = Qi(e.user);
2814
+ const t = Zi(e.user);
2726
2815
  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", {
2816
+ const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2817
+ b("web-sdk.agent", "Received auth.ok appearance", {
2729
2818
  hasAppearance: i,
2730
2819
  rawAppearance: e.appearance,
2731
2820
  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 = {
2821
+ }), this.runtimeHelperJavascript = Vi(e.runtimeHelpers)?.javascript ?? null;
2822
+ const r = Qt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2734
2823
  user: t,
2735
2824
  status: "connected",
2736
2825
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
@@ -2739,7 +2828,7 @@ class Oe {
2739
2828
  type: "runtime.auth_ack",
2740
2829
  connectionAttempt: this.connectionAttemptId,
2741
2830
  entrySurface: this.options.entrySurface
2742
- }), o && r.length === 0 && !a && !Ye() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2831
+ }), o && r.length === 0 && !a && !Ze() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2743
2832
  type: "page.upsert",
2744
2833
  sessionId: this.state.sessionId,
2745
2834
  page: P(),
@@ -2749,21 +2838,21 @@ class Oe {
2749
2838
  }
2750
2839
  if (e.type === "starterPrompts.updated") {
2751
2840
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
2752
- starterPrompts: Gt(e, "starterPrompts"),
2841
+ starterPrompts: Qt(e, "starterPrompts"),
2753
2842
  starterPromptsLoading: !1
2754
2843
  });
2755
2844
  return;
2756
2845
  }
2757
2846
  if (e.type === "scheduled_follow_ups.updated") {
2758
2847
  typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
2759
- activeScheduledFollowUps: Qt(
2848
+ activeScheduledFollowUps: Vt(
2760
2849
  e.activeScheduledFollowUps
2761
2850
  )
2762
2851
  });
2763
2852
  return;
2764
2853
  }
2765
2854
  if (e.type === "conversation.state") {
2766
- const t = Array.isArray(e.items) ? e.items : [], n = vt(t), i = Object.prototype.hasOwnProperty.call(
2855
+ const t = Array.isArray(e.items) ? e.items : [], n = Dt(t), i = Object.prototype.hasOwnProperty.call(
2767
2856
  e,
2768
2857
  "activeScheduledFollowUps"
2769
2858
  ), 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 +2863,55 @@ class Oe {
2774
2863
  this.forgetSupersededTaskTabClosedTurn(r, C(U));
2775
2864
  for (const U of n)
2776
2865
  this.rememberDurablyStoppedTurn(r, U);
2777
- const l = ne(n), c = l === null ? null : n[l], u = C(c), h = this.findStoppedTurn(r, {
2866
+ const l = ie(n), c = l === null ? null : n[l], u = C(c), h = this.findStoppedTurn(r, {
2778
2867
  clientMessageId: u?.clientMessageId,
2779
2868
  respondsToUserMessageId: A(c, "id"),
2780
2869
  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(
2870
+ }), m = this.filterStoppedSnapshotItems(n, r), g = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, d = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
2871
+ g && d && (this.pendingClientMessageId = d);
2872
+ let f = ar(
2784
2873
  e.assistantDraft
2785
2874
  );
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) => {
2875
+ f && this.findStoppedTurn(r, {
2876
+ respondsToUserMessageId: f.respondsToUserMessageId,
2877
+ runId: f.runId
2878
+ }) && (f = void 0);
2879
+ const M = f !== void 0;
2880
+ this.rememberUserMessageClientMessageIds(m);
2881
+ const w = Tr(m), D = m.filter((U) => {
2793
2882
  const q = C(U);
2794
- return pr(q) ? !1 : !q || !w || !he(q) ? !0 : ct(f, q) !== w;
2795
- }), S = ot(
2883
+ return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(m, q) !== w;
2884
+ }), S = lt(
2796
2885
  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(
2886
+ tt(D, this.options.backendUrl)
2887
+ ), T = ts(S), N = M ? f?.content ?? "" : this.state.assistantDraft, v = M ? f?.itemId ?? null : this.state.assistantDraftItemId, re = M ? f?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, J = M ? f?.runId ?? null : this.state.assistantDraftRunId, Y = m.some(
2888
+ (U, q) => ss(
2800
2889
  C(U),
2801
2890
  N,
2802
2891
  v,
2803
- ie,
2892
+ re,
2804
2893
  J,
2805
- mr(f, q)
2894
+ wr(m, q)
2806
2895
  )
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))
2896
+ ), Z = M ? f?.content ?? "" : this.state.assistantDraft, fe = !!f?.content && !Y, B = T && (!Z || Y), Q = mr(S), oe = B && Q ? "completed" : h ? "stopped" : B ? "failed" : null;
2897
+ if (!T && Sr(this.state.messages, m))
2809
2898
  return;
2810
- this.lastUserMessagePageUrl = hr(f);
2811
- const j = B || h ? null : lt(f);
2899
+ this.lastUserMessagePageUrl = yr(m);
2900
+ const j = B || h ? null : ut(m);
2812
2901
  if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
2813
2902
  sessionId: A(e.session, "id") ?? this.state.sessionId,
2814
2903
  messages: S,
2815
2904
  ...i ? {
2816
- activeScheduledFollowUps: Qt(
2905
+ activeScheduledFollowUps: Vt(
2817
2906
  e.activeScheduledFollowUps
2818
2907
  )
2819
2908
  } : {},
2820
2909
  isLoadingSession: !1,
2821
- ...y ? { pendingMessageStatus: y } : {},
2822
- ...m ? { turnPhase: m } : {},
2910
+ ...g ? { pendingMessageStatus: g } : {},
2911
+ ...y ? { turnPhase: y } : {},
2823
2912
  isRetrying: p,
2824
- ...m ? { taskStatus: "working" } : {},
2825
- ...re && this.state.taskStatus === "working" ? { taskStatus: re } : {},
2913
+ ...y ? { taskStatus: "working" } : {},
2914
+ ...oe && this.state.taskStatus === "working" ? { taskStatus: oe } : {},
2826
2915
  ...Y ? {
2827
2916
  assistantDraft: "",
2828
2917
  assistantDraftItemId: null,
@@ -2830,17 +2919,17 @@ class Oe {
2830
2919
  assistantDraftRespondsToUserMessageId: null,
2831
2920
  assistantDraftRunId: null
2832
2921
  } : 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
2922
+ assistantDraft: f?.content ?? "",
2923
+ assistantDraftItemId: f?.itemId ?? null,
2924
+ assistantDraftPhase: f?.phase ?? null,
2925
+ assistantDraftRespondsToUserMessageId: f?.respondsToUserMessageId ?? null,
2926
+ assistantDraftRunId: f?.runId ?? null
2838
2927
  } : {},
2839
- ...ge ? {
2928
+ ...fe ? {
2840
2929
  isThinking: !0,
2841
2930
  turnPhase: "thinking",
2842
2931
  lastError: null
2843
- } : m ? {
2932
+ } : y ? {
2844
2933
  isThinking: !0,
2845
2934
  lastError: null,
2846
2935
  lastErrorCode: null,
@@ -2853,15 +2942,15 @@ class Oe {
2853
2942
  lastErrorSecuritySettingsUrl: null
2854
2943
  } : j ? {
2855
2944
  isThinking: !0,
2856
- turnPhase: m ?? this.state.turnPhase ?? "starting",
2945
+ turnPhase: y ?? this.state.turnPhase ?? "starting",
2857
2946
  lastError: null
2858
2947
  } : {}
2859
2948
  }), B)
2860
2949
  this.retryableClientMessageId = w, this.clearThinkingWatchdog();
2861
- else if (!h && (ge || j)) {
2950
+ else if (!h && (fe || j)) {
2862
2951
  if (j) {
2863
2952
  this.activeClientMessageId = j;
2864
- const U = ne(f), q = U === null ? null : f[U];
2953
+ const U = ie(m), q = U === null ? null : m[U];
2865
2954
  this.activeResponseUserMessageId = A(q, "id");
2866
2955
  }
2867
2956
  this.markThinkingProgress();
@@ -2875,19 +2964,19 @@ class Oe {
2875
2964
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2876
2965
  if (!t || n !== this.state.sessionId)
2877
2966
  return;
2878
- const i = et(
2967
+ const i = tt(
2879
2968
  Array.isArray(e.items) ? e.items : [],
2880
2969
  this.options.backendUrl
2881
2970
  );
2882
2971
  t === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
2883
- messages: or(this.state.messages, i)
2972
+ messages: dr(this.state.messages, i)
2884
2973
  });
2885
2974
  return;
2886
2975
  }
2887
2976
  if (e.type === "sessions.page") {
2888
2977
  const t = typeof e.requestId == "string" ? e.requestId : null, n = t ? this.pendingSessionHistoryRequests.get(t) : null;
2889
2978
  t && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(t), n.resolve({
2890
- sessions: Vi(e.sessions),
2979
+ sessions: er(e.sessions),
2891
2980
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
2892
2981
  }));
2893
2982
  return;
@@ -2914,27 +3003,27 @@ class Oe {
2914
3003
  if (e.type === "session.item") {
2915
3004
  this.rememberUserMessageClientMessageIds([e.item]);
2916
3005
  const t = C(e.item);
2917
- if (he(t)) {
3006
+ if (pe(t)) {
2918
3007
  typeof t?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(t.runId);
2919
3008
  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
3009
  o && (this.retryableClientMessageId = o);
2921
3010
  return;
2922
3011
  }
2923
- const n = rt(e.item, this.options.backendUrl);
3012
+ const n = at(e.item, this.options.backendUrl);
2924
3013
  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(
3014
+ const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3015
+ 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();
3016
+ const o = de(this.state.messages, n), a = ts(o), l = ss(
2928
3017
  t,
2929
3018
  this.state.assistantDraft,
2930
3019
  this.state.assistantDraftItemId,
2931
3020
  this.state.assistantDraftRespondsToUserMessageId,
2932
3021
  this.state.assistantDraftRunId,
2933
- Ps(
3022
+ _s(
2934
3023
  o,
2935
3024
  o.findIndex((h) => h.id === n.id)
2936
3025
  )
2937
- ), c = a && (!this.state.assistantDraft || l), u = _e(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
3026
+ ), c = a && (!this.state.assistantDraft || l), u = ve(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
2938
3027
  this.setState({
2939
3028
  messages: o,
2940
3029
  ...l ? {
@@ -2963,7 +3052,7 @@ class Oe {
2963
3052
  this.clearRunAckResyncRetryTimer();
2964
3053
  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;
2965
3054
  this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = u), this.setState({
2966
- messages: ue(this.state.messages, {
3055
+ messages: de(this.state.messages, {
2967
3056
  id: o,
2968
3057
  role: "assistant",
2969
3058
  content: r,
@@ -2992,9 +3081,9 @@ class Oe {
2992
3081
  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
3082
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
2994
3083
  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(
3084
+ 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 = Ut(
2996
3085
  this.state.messages.filter(
2997
- (c) => c.dataType !== "assistant_draft" || !we(
3086
+ (c) => c.dataType !== "assistant_draft" || !Ae(
2998
3087
  c,
2999
3088
  n,
3000
3089
  i
@@ -3002,11 +3091,11 @@ class Oe {
3002
3091
  ),
3003
3092
  n,
3004
3093
  i,
3005
- at
3094
+ ct
3006
3095
  );
3007
3096
  this.setState({
3008
3097
  sessionId: t,
3009
- messages: Xt(
3098
+ messages: Jt(
3010
3099
  l,
3011
3100
  typeof e.responseId == "string" ? e.responseId : null,
3012
3101
  n,
@@ -3029,9 +3118,9 @@ class Oe {
3029
3118
  if (t)
3030
3119
  this.nonTranscriptToolCallIds.add(t);
3031
3120
  else {
3032
- const n = Zt(e);
3121
+ const n = es(e);
3033
3122
  if (n) {
3034
- const i = Jt(
3123
+ const i = Yt(
3035
3124
  this.state.messages,
3036
3125
  n
3037
3126
  );
@@ -3062,6 +3151,12 @@ class Oe {
3062
3151
  return;
3063
3152
  }
3064
3153
  if (e.type === "error") {
3154
+ if (e.code === "unauthorized" && e.reason === "token_expired" && e.retryable === !0 && this.options.tokenProvider) {
3155
+ this.invalidateProviderToken(), this.clearSocketPhaseTimers(), this.stopHeartbeat();
3156
+ const g = this.socket;
3157
+ this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), g?.close();
3158
+ return;
3159
+ }
3065
3160
  const t = typeof e.requestId == "string" ? e.requestId : null;
3066
3161
  if (t && t === this.sessionLoadRequestId) {
3067
3162
  this.clearSessionLoadRequest(), this.setState({
@@ -3093,19 +3188,19 @@ class Oe {
3093
3188
  return;
3094
3189
  }
3095
3190
  o && i && r && (this.retryableClientMessageId = r);
3096
- const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = _i(a.message);
3191
+ const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
3097
3192
  l && console.error(l);
3098
- const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = ns(
3193
+ const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = is(
3099
3194
  this.state.messages,
3100
3195
  c,
3101
3196
  u
3102
- ), f = ur(
3197
+ ), m = fr(
3103
3198
  h,
3104
3199
  c,
3105
3200
  u
3106
3201
  );
3107
- this.setState({
3108
- status: f ? "connected" : "error",
3202
+ if (this.setState({
3203
+ status: m ? "connected" : "error",
3109
3204
  messages: h,
3110
3205
  assistantDraft: "",
3111
3206
  assistantDraftItemId: null,
@@ -3115,10 +3210,14 @@ class Oe {
3115
3210
  isThinking: !1,
3116
3211
  ...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
3117
3212
  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);
3213
+ lastError: m ? null : a.message,
3214
+ lastErrorCode: m ? null : typeof e.code == "string" ? e.code : null,
3215
+ lastErrorSecuritySettingsUrl: m ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
3216
+ }), this.clearThinkingWatchdog(), this.emit("error", a), e.code === "unauthorized") {
3217
+ this.clearSocketPhaseTimers(), this.stopHeartbeat();
3218
+ const g = this.socket;
3219
+ this.socket = null, g?.close();
3220
+ }
3122
3221
  }
3123
3222
  }
3124
3223
  }
@@ -3126,7 +3225,7 @@ class Oe {
3126
3225
  }
3127
3226
  applyAccountSubmissionError(e) {
3128
3227
  if (!this.account || !e) return;
3129
- const t = Tn(this.account.submissionGate, e);
3228
+ const t = wn(this.account.submissionGate, e);
3130
3229
  if (!(t === this.account.submissionGate || t.allowed)) {
3131
3230
  this.account = {
3132
3231
  ...this.account,
@@ -3139,55 +3238,55 @@ class Oe {
3139
3238
  if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
3140
3239
  return;
3141
3240
  const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
3142
- this.options.model = Ke(n) ? n : "gpt-5.6-sol";
3241
+ this.options.model = Ge(n) ? n : "gpt-5.6-sol";
3143
3242
  }
3144
3243
  updateAccountFallbackFromSession(e) {
3145
- const t = e && typeof e == "object" ? e.metadata : null, n = wn(t);
3244
+ const t = e && typeof e == "object" ? e.metadata : null, n = An(t);
3146
3245
  if (this.usingPaidCreditFallback !== n && (this.usingPaidCreditFallback = n, !!this.account)) {
3147
3246
  this.account = { ...this.account, usingPaidCreditFallback: n };
3148
3247
  for (const i of this.accountListeners) i(this.getAccount());
3149
3248
  }
3150
3249
  }
3151
3250
  shouldIgnoreBackgroundSessionEvent(e) {
3152
- if (!this.options.keepRunsActiveOnSessionNavigation || !le(e))
3251
+ if (!this.options.keepRunsActiveOnSessionNavigation || !ce(e))
3153
3252
  return !1;
3154
3253
  const t = K(e);
3155
3254
  return t ? this.deferredSessionUpdatedSessionIds.has(t) ? !0 : this.state.sessionId ? t !== this.state.sessionId : this.backgroundSessionIds.has(t) : !1;
3156
3255
  }
3157
3256
  updateInactiveSessionTimelineCache(e) {
3158
- if (!le(e))
3257
+ if (!ce(e))
3159
3258
  return;
3160
3259
  const t = K(e);
3161
3260
  if (!t || t === this.state.sessionId)
3162
3261
  return;
3163
3262
  const n = this.sessionTimelineCache.get(t);
3164
3263
  if (e.type === "conversation.state") {
3165
- const i = vt(
3264
+ const i = Dt(
3166
3265
  Array.isArray(e.items) ? e.items : []
3167
- ), r = et(
3266
+ ), r = tt(
3168
3267
  this.filterStoppedSnapshotItems(i, t),
3169
3268
  this.options.backendUrl
3170
3269
  );
3171
3270
  (n || r.length > 0) && this.rememberSessionTimeline(
3172
3271
  t,
3173
- n ? ot(n, r) : r
3272
+ n ? lt(n, r) : r
3174
3273
  );
3175
3274
  return;
3176
3275
  }
3177
3276
  if (n) {
3178
3277
  if (e.type === "session.item") {
3179
3278
  const i = C(e.item);
3180
- if (he(i))
3279
+ if (pe(i))
3181
3280
  return;
3182
- const r = rt(e.item, this.options.backendUrl);
3183
- r && this.rememberSessionTimeline(t, ue(n, r));
3281
+ const r = at(e.item, this.options.backendUrl);
3282
+ r && this.rememberSessionTimeline(t, de(n, r));
3184
3283
  return;
3185
3284
  }
3186
3285
  if (e.type === "tool.call") {
3187
- const i = e.hiddenFromTranscript === !0 ? null : Zt(e);
3286
+ const i = e.hiddenFromTranscript === !0 ? null : es(e);
3188
3287
  i && this.rememberSessionTimeline(
3189
3288
  t,
3190
- Jt(n, i)
3289
+ Yt(n, i)
3191
3290
  );
3192
3291
  return;
3193
3292
  }
@@ -3199,7 +3298,7 @@ class Oe {
3199
3298
  return;
3200
3299
  this.rememberSessionTimeline(
3201
3300
  t,
3202
- Yt(
3301
+ Zt(
3203
3302
  n,
3204
3303
  e.callId,
3205
3304
  i
@@ -3211,7 +3310,7 @@ class Oe {
3211
3310
  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
3311
  this.rememberSessionTimeline(
3213
3312
  t,
3214
- ue(n, {
3313
+ de(n, {
3215
3314
  id: r,
3216
3315
  role: "assistant",
3217
3316
  content: l,
@@ -3226,17 +3325,17 @@ class Oe {
3226
3325
  return;
3227
3326
  }
3228
3327
  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(
3328
+ const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Ut(
3230
3329
  n.filter(
3231
- (a) => a.dataType !== "assistant_draft" || !we(a, i, r)
3330
+ (a) => a.dataType !== "assistant_draft" || !Ae(a, i, r)
3232
3331
  ),
3233
3332
  i,
3234
3333
  r,
3235
- at
3334
+ ct
3236
3335
  );
3237
3336
  this.rememberSessionTimeline(
3238
3337
  t,
3239
- Xt(
3338
+ Jt(
3240
3339
  o,
3241
3340
  typeof e.responseId == "string" ? e.responseId : null,
3242
3341
  i,
@@ -3251,7 +3350,7 @@ class Oe {
3251
3350
  return;
3252
3351
  this.rememberSessionTimeline(
3253
3352
  t,
3254
- is(
3353
+ rs(
3255
3354
  n,
3256
3355
  i,
3257
3356
  null,
@@ -3260,20 +3359,20 @@ class Oe {
3260
3359
  );
3261
3360
  return;
3262
3361
  }
3263
- e.type === "error" && typeof e.requestId != "string" && !ss(e, t) && this.rememberSessionTimeline(
3362
+ e.type === "error" && typeof e.requestId != "string" && !ns(e, t) && this.rememberSessionTimeline(
3264
3363
  t,
3265
- wr(n, e)
3364
+ kr(n, e)
3266
3365
  );
3267
3366
  }
3268
3367
  }
3269
3368
  shouldIgnoreDetachedSessionEvent(e) {
3270
- if (this.options.keepRunsActiveOnSessionNavigation || !le(e))
3369
+ if (this.options.keepRunsActiveOnSessionNavigation || !ce(e))
3271
3370
  return !1;
3272
3371
  const t = K(e);
3273
3372
  return !!(t && this.detachedSessionIds.has(t));
3274
3373
  }
3275
3374
  shouldDeferDetachedSessionEvent(e) {
3276
- if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !le(e))
3375
+ if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !ce(e))
3277
3376
  return !1;
3278
3377
  const t = K(e);
3279
3378
  if (!t || t === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(t))
@@ -3296,9 +3395,9 @@ class Oe {
3296
3395
  }
3297
3396
  handleRetryableRecoveryError(e) {
3298
3397
  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)
3398
+ if (!ns(e, t) || !n)
3300
3399
  return !1;
3301
- if (Ye())
3400
+ if (Ze())
3302
3401
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
3303
3402
  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
3403
  const i = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
@@ -3337,7 +3436,7 @@ class Oe {
3337
3436
  const i = new Promise((r, o) => {
3338
3437
  const a = window.setTimeout(() => {
3339
3438
  e.delete(t.requestId), o(new Error(n));
3340
- }, $t);
3439
+ }, Ft);
3341
3440
  e.set(t.requestId, { resolve: r, reject: o, timeout: a });
3342
3441
  });
3343
3442
  if (!this.sendNow(t)) {
@@ -3360,7 +3459,7 @@ class Oe {
3360
3459
  e.clear();
3361
3460
  }
3362
3461
  markThinkingProgress() {
3363
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Gn), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
3462
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Vn), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
3364
3463
  }
3365
3464
  scheduleThinkingWatchdog(e) {
3366
3465
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -3416,21 +3515,21 @@ class Oe {
3416
3515
  return this.pendingClientMessageId === e && this.state.isThinking && this.activeClientMessageId !== null && this.activeClientMessageId !== e;
3417
3516
  }
3418
3517
  schedulePendingDeliveryAck(e) {
3419
- this.clearPendingDeliveryTimers(), !Ye() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3518
+ this.clearPendingDeliveryTimers(), !Ze() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3420
3519
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
3421
- }, Wt));
3520
+ }, $t));
3422
3521
  }
3423
3522
  retryPendingDelivery(e) {
3424
3523
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
3425
3524
  return;
3426
3525
  const t = this.retryAttemptsByClientMessageId[e] ?? 0;
3427
- if (t >= Qn) {
3526
+ if (t >= Xn) {
3428
3527
  this.failPendingDelivery(e);
3429
3528
  return;
3430
3529
  }
3431
3530
  t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
3432
3531
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
3433
- }, ai(t, Jn));
3532
+ }, ui(t, ei));
3434
3533
  }
3435
3534
  failPendingDelivery(e) {
3436
3535
  if (this.pendingClientMessageId !== e)
@@ -3442,7 +3541,7 @@ class Oe {
3442
3541
  ...this.state.isThinking ? {} : { turnPhase: null },
3443
3542
  isRetrying: !1,
3444
3543
  ...this.state.isThinking ? {} : { taskStatus: "failed" },
3445
- lastError: Xn,
3544
+ lastError: Yn,
3446
3545
  lastErrorCode: "message_delivery_failed"
3447
3546
  });
3448
3547
  }
@@ -3454,7 +3553,7 @@ class Oe {
3454
3553
  if (this.state.isThinking && t) {
3455
3554
  const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
3456
3555
  this.setState({
3457
- messages: is(
3556
+ messages: rs(
3458
3557
  this.state.messages,
3459
3558
  t,
3460
3559
  n,
@@ -3480,13 +3579,13 @@ class Oe {
3480
3579
  scheduleRunAckWatchdog(e) {
3481
3580
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
3482
3581
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
3483
- }, Wt);
3582
+ }, $t);
3484
3583
  }
3485
3584
  recoverMissedRunAck(e) {
3486
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (R("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3585
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3487
3586
  sessionId: this.state.sessionId,
3488
3587
  clientMessageId: e
3489
- }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Bt));
3588
+ }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Wt));
3490
3589
  }
3491
3590
  clearRunAckResyncRetryTimer() {
3492
3591
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -3499,7 +3598,7 @@ class Oe {
3499
3598
  return;
3500
3599
  const e = this.activeClientMessageId;
3501
3600
  if (!e) {
3502
- R("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
3601
+ b("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
3503
3602
  sessionId: this.state.sessionId
3504
3603
  }), this.reportHealthSignal("run_recovery_exhausted", {
3505
3604
  reason: "missing_client_message_id"
@@ -3509,17 +3608,17 @@ class Oe {
3509
3608
  ),
3510
3609
  isThinking: !1,
3511
3610
  taskStatus: "failed",
3512
- lastError: Vn,
3611
+ lastError: Jn,
3513
3612
  lastErrorCode: "run_recovery_exhausted"
3514
3613
  }), this.clearThinkingWatchdog();
3515
3614
  return;
3516
3615
  }
3517
3616
  const t = this.thinkingWatchdogResyncAttemptsByClientMessageId[e] ?? 0;
3518
- this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = t + 1, R("web-sdk.agent", "Pluno thinking watchdog resyncing authoritative session state", {
3617
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[e] = t + 1, b("web-sdk.agent", "Pluno thinking watchdog resyncing authoritative session state", {
3519
3618
  sessionId: this.state.sessionId,
3520
3619
  clientMessageId: e,
3521
3620
  resyncAttempts: t + 1
3522
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Bt);
3621
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Wt);
3523
3622
  }
3524
3623
  resyncThinkingSession() {
3525
3624
  this.state.sessionId ? this.send({
@@ -3530,13 +3629,13 @@ class Oe {
3530
3629
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
3531
3630
  }
3532
3631
  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(
3632
+ 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
3633
  typeof e.summary == "string" ? e.summary : "Running browser tool"
3535
3634
  ), o = e.rawInput;
3536
3635
  if (!t || !n || !i)
3537
3636
  return;
3538
3637
  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)) {
3638
+ if (!a && !l || !Xr(o)) {
3540
3639
  this.setToolMessageLoading(n, !1), this.send({
3541
3640
  type: "tool.result",
3542
3641
  sessionId: t,
@@ -3583,9 +3682,9 @@ class Oe {
3583
3682
  startedAtOrigin: location.origin
3584
3683
  }), this.installSessionBrowserApis();
3585
3684
  let c = null, u;
3586
- c = await this.executeRuntimeHelper(), u = await zt(
3685
+ c = await this.executeRuntimeHelper(), u = await Kt(
3587
3686
  o,
3588
- Ri(e.runtimeContext, this.options.backendUrl)
3687
+ _i(e.runtimeContext, this.options.backendUrl)
3589
3688
  ).catch((h) => ({
3590
3689
  ok: !1,
3591
3690
  exception: {
@@ -3598,11 +3697,11 @@ class Oe {
3598
3697
  toolName: i,
3599
3698
  summary: o.summary,
3600
3699
  rawInput: L(o),
3601
- rawOutput: L(zi(u, c))
3602
- }), os(this.options.clientId, this.activeBrowserToolCalls.values()));
3700
+ rawOutput: L(Xi(u, c))
3701
+ }), as(this.options.clientId, this.activeBrowserToolCalls.values()));
3603
3702
  }
3604
3703
  setToolMessageLoading(e, t) {
3605
- const n = Yt(
3704
+ const n = Zt(
3606
3705
  this.state.messages,
3607
3706
  e,
3608
3707
  t
@@ -3613,33 +3712,33 @@ class Oe {
3613
3712
  if (this.pageLifecycleCleanup)
3614
3713
  return;
3615
3714
  const e = () => {
3616
- vs(this.options.clientId, this.activeBrowserToolCalls.values());
3715
+ Us(this.options.clientId, this.activeBrowserToolCalls.values());
3617
3716
  };
3618
3717
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
3619
3718
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
3620
3719
  };
3621
3720
  }
3622
3721
  installSessionBrowserApis() {
3623
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = fi();
3722
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Ti();
3624
3723
  }
3625
3724
  cleanupSessionBrowserApis() {
3626
- this.sessionBrowserApisCleanup && (Mi(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3725
+ this.sessionBrowserApisCleanup && (Ci(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3627
3726
  }
3628
3727
  async executeRuntimeHelper() {
3629
3728
  if (!this.runtimeHelperJavascript?.trim())
3630
3729
  return null;
3631
- const e = await zt({
3730
+ const e = await Kt({
3632
3731
  javascript: this.runtimeHelperJavascript
3633
3732
  });
3634
- return e.ok === !1 ? Ki(e) : null;
3733
+ return e.ok === !1 ? Ji(e) : null;
3635
3734
  }
3636
3735
  enableNetworkCapture() {
3637
- this.networkCaptureCleanup || (this.networkCaptureCleanup = ui((e) => {
3638
- Jr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3736
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = fi((e) => {
3737
+ so(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3639
3738
  }));
3640
3739
  }
3641
3740
  enqueueNetworkEvent(e) {
3642
- this.queuedNetworkEvents.length >= Zn || (this.queuedNetworkEvents.push(Xr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3741
+ this.queuedNetworkEvents.length >= si || (this.queuedNetworkEvents.push(to(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3643
3742
  this.networkBatchTimer = null;
3644
3743
  const t = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
3645
3744
  t.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -3648,29 +3747,32 @@ class Oe {
3648
3747
  page: P(),
3649
3748
  events: t
3650
3749
  });
3651
- }, Yn)));
3750
+ }, ti)));
3652
3751
  }
3653
- scheduleReconnect() {
3752
+ scheduleReconnect(e = 0) {
3654
3753
  if (this.reconnectTimer !== null || this.state.status === "closed")
3655
3754
  return;
3656
- const e = li(this.reconnectAttempts);
3755
+ const t = Math.min(
3756
+ rt,
3757
+ Math.max(di(this.reconnectAttempts), e)
3758
+ );
3657
3759
  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),
3760
+ this.reconnectTimer = null, this.connect().catch((n) => {
3761
+ b("web-sdk.agent", "Pluno reconnect failed; retrying", {
3762
+ message: n instanceof Error ? n.message : String(n),
3661
3763
  queuedClientEventCount: this.queuedClientEvents.length,
3662
3764
  isThinking: this.state.isThinking
3663
3765
  }), this.setReconnectingState(), this.scheduleReconnect();
3664
3766
  });
3665
- }, e);
3767
+ }, t);
3666
3768
  }
3667
3769
  startHeartbeat() {
3668
3770
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
3669
3771
  const e = this.socket;
3670
3772
  !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);
3773
+ this.socket === e && (b("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
3774
+ }, Wn));
3775
+ }, Bn);
3674
3776
  }
3675
3777
  stopHeartbeat() {
3676
3778
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -3708,7 +3810,7 @@ class Oe {
3708
3810
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3709
3811
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3710
3812
  }, 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, {
3813
+ 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()), Xe("state", this.state.status, {
3712
3814
  status: this.state.status,
3713
3815
  sessionId: this.state.sessionId,
3714
3816
  messageCount: this.state.messages.length,
@@ -3736,7 +3838,7 @@ class Oe {
3736
3838
  this.transportIdentity.transportId
3737
3839
  ].join(":"), n = `${e}:${t}`;
3738
3840
  if (this.sessionRecoveryScope !== n) {
3739
- const i = [...this.state.messages].reverse().find((r) => !ht(r) && !r.id.startsWith("transient-activity:"));
3841
+ const i = [...this.state.messages].reverse().find((r) => !gt(r) && !r.id.startsWith("transient-activity:"));
3740
3842
  this.sessionActivityRecovery.reset(i?.id ?? null), this.sessionRecoveryScope = n;
3741
3843
  }
3742
3844
  this.sessionRecoveryPoller.start(e, t), this.sessionActivityRecoveryPoller.start(e, t);
@@ -3766,44 +3868,44 @@ class Oe {
3766
3868
  this.listeners[e]?.forEach((i) => i(t));
3767
3869
  }
3768
3870
  }
3769
- const Je = /* @__PURE__ */ new WeakMap();
3770
- function ui(s) {
3771
- const e = window.__plunoProductAgentNetworkCapture ?? di();
3871
+ const Ye = /* @__PURE__ */ new WeakMap();
3872
+ function fi(s) {
3873
+ const e = window.__plunoProductAgentNetworkCapture ?? mi();
3772
3874
  return e.subscribers.add(s), () => {
3773
3875
  e.subscribers.delete(s), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
3774
3876
  };
3775
3877
  }
3776
- function di() {
3777
- const s = /* @__PURE__ */ new Set(), e = (f) => {
3778
- s.forEach((y) => {
3878
+ function mi() {
3879
+ const s = /* @__PURE__ */ new Set(), e = (m) => {
3880
+ s.forEach((g) => {
3779
3881
  try {
3780
- y(f);
3882
+ g(m);
3781
3883
  } catch {
3782
3884
  }
3783
3885
  });
3784
- }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(y, d) {
3886
+ }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(g, d) {
3785
3887
  const p = Date.now();
3786
- let m;
3888
+ let y;
3787
3889
  try {
3788
- m = t.call(this, y, d);
3789
- } catch (g) {
3790
- throw g;
3890
+ y = t.call(this, g, d);
3891
+ } catch (f) {
3892
+ throw f;
3791
3893
  }
3792
3894
  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)) {
3895
+ const f = g instanceof Request ? g : null, M = Jr(g, f), w = xs(d?.headers ?? f?.headers);
3896
+ if (!te(M, w, d?.body)) {
3795
3897
  const H = {
3796
- requestId: tt("fetch"),
3797
- url: W(M, Xe),
3798
- method: (d?.method ?? g?.method ?? "GET").toUpperCase(),
3898
+ requestId: st("fetch"),
3899
+ url: W(M, Je),
3900
+ method: (d?.method ?? f?.method ?? "GET").toUpperCase(),
3799
3901
  requestHeaders: w,
3800
- requestBody: ls(d?.body),
3902
+ requestBody: cs(d?.body),
3801
3903
  resourceType: "fetch",
3802
3904
  startedAt: new Date(p).toISOString()
3803
3905
  };
3804
- m.then(
3906
+ y.then(
3805
3907
  (S) => {
3806
- Gr(S, H, p, e).catch(() => {
3908
+ Yr(S, H, p, e).catch(() => {
3807
3909
  e({
3808
3910
  ...H,
3809
3911
  responseStatus: S.status,
@@ -3822,30 +3924,30 @@ function di() {
3822
3924
  }
3823
3925
  } catch {
3824
3926
  }
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),
3927
+ return y;
3928
+ }, a = function(g, d, p, y, f) {
3929
+ const M = n.call(this, g, d, p ?? !0, y ?? void 0, f ?? void 0), w = typeof d == "string" ? d : d.toString();
3930
+ return Ye.set(this, {
3931
+ requestId: st("xhr"),
3932
+ method: String(g ?? "GET").toUpperCase(),
3933
+ url: W(w, Je),
3832
3934
  requestHeaders: {},
3833
3935
  startedAtMs: Date.now(),
3834
3936
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3835
- excluded: ee(w)
3937
+ excluded: te(w)
3836
3938
  }), 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) {
3939
+ }, l = function(g, d) {
3940
+ const p = i.call(this, g, d), y = Ye.get(this);
3941
+ return y && Object.keys(y.requestHeaders).length < Tt && (y.requestHeaders[g] = bt(g, d), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
3942
+ }, c = function(g) {
3841
3943
  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(
3944
+ const d = Ye.get(this);
3945
+ d && (d.excluded = d.excluded || te(d.url, d.requestHeaders, g), d.requestBody = cs(g), d.excluded || this.addEventListener(
3844
3946
  "loadend",
3845
3947
  () => {
3846
3948
  queueMicrotask(() => {
3847
3949
  try {
3848
- const p = Zr(this.getAllResponseHeaders());
3950
+ const p = io(this.getAllResponseHeaders());
3849
3951
  e({
3850
3952
  requestId: d.requestId,
3851
3953
  url: d.url,
@@ -3855,7 +3957,7 @@ function di() {
3855
3957
  resourceType: "xhr",
3856
3958
  responseStatus: this.status,
3857
3959
  responseHeaders: p,
3858
- responseBody: Vr(this, p),
3960
+ responseBody: eo(this, p),
3859
3961
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
3860
3962
  startedAt: d.startedAt,
3861
3963
  durationMs: Date.now() - d.startedAtMs
@@ -3869,7 +3971,7 @@ function di() {
3869
3971
  ));
3870
3972
  } catch {
3871
3973
  }
3872
- return r.call(this, y ?? null);
3974
+ return r.call(this, g ?? null);
3873
3975
  };
3874
3976
  try {
3875
3977
  window.fetch = o;
@@ -3889,15 +3991,15 @@ function di() {
3889
3991
  }
3890
3992
  let u = null;
3891
3993
  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))
3994
+ u = new PerformanceObserver((m) => {
3995
+ for (const g of m.getEntries()) {
3996
+ const d = g;
3997
+ if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || te(d.name))
3896
3998
  continue;
3897
3999
  const p = performance.timeOrigin + d.startTime;
3898
4000
  e({
3899
- requestId: tt("resource"),
3900
- url: W(d.name, Xe),
4001
+ requestId: st("resource"),
4002
+ url: W(d.name, Je),
3901
4003
  method: "GET",
3902
4004
  resourceType: "resource",
3903
4005
  responseStatus: d.responseStatus,
@@ -3936,7 +4038,7 @@ function di() {
3936
4038
  };
3937
4039
  return window.__plunoProductAgentNetworkCapture = h, h;
3938
4040
  }
3939
- function R(s, e, t) {
4041
+ function b(s, e, t) {
3940
4042
  if (typeof window > "u")
3941
4043
  return;
3942
4044
  const n = window, i = {
@@ -3947,14 +4049,14 @@ function R(s, e, t) {
3947
4049
  }, r = n.__plunoProductAgentDiagnostics__ ?? [];
3948
4050
  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
4051
  }
3950
- function jt(s) {
4052
+ function zt(s) {
3951
4053
  const e = typeof s == "function" ? s() : s;
3952
4054
  return e && Object.keys(e).length > 0 ? e : void 0;
3953
4055
  }
3954
- function hi(s) {
4056
+ function yi(s) {
3955
4057
  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
4058
  }
3957
- function le(s) {
4059
+ function ce(s) {
3958
4060
  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
4061
  }
3960
4062
  function K(s) {
@@ -3972,31 +4074,31 @@ function K(s) {
3972
4074
  }
3973
4075
  return null;
3974
4076
  }
3975
- const pi = 5e3, gi = 12e4;
3976
- function fi() {
4077
+ const Ii = 5e3, Si = 12e4;
4078
+ function Ti() {
3977
4079
  const s = [
3978
- yi(),
3979
- mi()
4080
+ Ai(),
4081
+ wi()
3980
4082
  ].filter((e) => typeof e == "function");
3981
4083
  return () => {
3982
4084
  for (const e of s.reverse())
3983
4085
  e();
3984
4086
  };
3985
4087
  }
3986
- function mi() {
3987
- return us(globalThis, "getPageSnapshot", async () => St());
4088
+ function wi() {
4089
+ return ds(globalThis, "getPageSnapshot", async () => wt());
3988
4090
  }
3989
- function yi() {
3990
- return us(globalThis, "pageImages", {
3991
- inspectImage: async (e, t) => await Ii(e, t)
4091
+ function Ai() {
4092
+ return ds(globalThis, "pageImages", {
4093
+ inspectImage: async (e, t) => await Mi(e, t)
3992
4094
  });
3993
4095
  }
3994
- async function Ii(s, e = {}) {
3995
- const t = Ai(e.name), n = await Si(s);
4096
+ async function Mi(s, e = {}) {
4097
+ const t = Ei(e.name), n = await bi(s);
3996
4098
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
3997
4099
  type: "pluno.pageImages.inspectImage",
3998
4100
  imageAttached: !1,
3999
- imageAttachmentError: Ts
4101
+ imageAttachmentError: ws
4000
4102
  } : {
4001
4103
  type: "pluno.pageImages.inspectImage",
4002
4104
  imageAttached: !0,
@@ -4010,15 +4112,15 @@ async function Ii(s, e = {}) {
4010
4112
  imageAttachmentError: n.error
4011
4113
  };
4012
4114
  }
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 } : {
4115
+ async function bi(s) {
4116
+ 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
4117
  ok: !0,
4016
4118
  mimeType: s.type,
4017
4119
  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);
4120
+ dataUrl: await Pi(s)
4121
+ } : { 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
4122
  }
4021
- function Ti(s) {
4123
+ function Ri(s) {
4022
4124
  if (!s.startsWith("data:") || !s.includes(","))
4023
4125
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
4024
4126
  const [e, t] = s.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), i = n[0] ?? "";
@@ -4029,7 +4131,7 @@ function Ti(s) {
4029
4131
  const r = t.replace(/[ \t\r\n\f]+/g, "");
4030
4132
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(r))
4031
4133
  return { ok: !1, error: "Page image data URL has invalid base64." };
4032
- const o = wi(r);
4134
+ const o = ki(r);
4033
4135
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
4034
4136
  ok: !0,
4035
4137
  mimeType: i,
@@ -4037,22 +4139,22 @@ function Ti(s) {
4037
4139
  dataUrl: `data:${i};base64,${r}`
4038
4140
  };
4039
4141
  }
4040
- function wi(s) {
4142
+ function ki(s) {
4041
4143
  if (s.length === 0 || s.length % 4 !== 0)
4042
4144
  return null;
4043
4145
  const e = s.length - s.replace(/=+$/, "").length;
4044
4146
  return e > 2 ? null : s.length / 4 * 3 - e;
4045
4147
  }
4046
- function Ai(s) {
4148
+ function Ei(s) {
4047
4149
  return (typeof s == "string" ? s.trim() : "") || "Page image";
4048
4150
  }
4049
- function Mi(s) {
4151
+ function Ci(s) {
4050
4152
  try {
4051
4153
  s();
4052
4154
  } catch {
4053
4155
  }
4054
4156
  }
4055
- function bi(s) {
4157
+ function Pi(s) {
4056
4158
  return new Promise((e, t) => {
4057
4159
  const n = new FileReader();
4058
4160
  n.onload = () => {
@@ -4064,9 +4166,9 @@ function bi(s) {
4064
4166
  }, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
4065
4167
  });
4066
4168
  }
4067
- async function zt(s, e) {
4169
+ async function Kt(s, e) {
4068
4170
  const t = Object.getPrototypeOf(async function() {
4069
- }).constructor, n = s.timeoutMs ?? pi, i = Date.now(), r = [];
4171
+ }).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
4070
4172
  let o;
4071
4173
  const a = {
4072
4174
  log: console.log,
@@ -4084,7 +4186,7 @@ async function zt(s, e) {
4084
4186
  o = window.setTimeout(() => h(c), n);
4085
4187
  })
4086
4188
  ]);
4087
- return u === c ? Ei(n) : {
4189
+ return u === c ? vi(n) : {
4088
4190
  ok: !0,
4089
4191
  result: u,
4090
4192
  console: r,
@@ -4113,7 +4215,7 @@ async function zt(s, e) {
4113
4215
  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
4216
  }
4115
4217
  }
4116
- function Ri(s, e) {
4218
+ function _i(s, e) {
4117
4219
  if (!s || typeof s != "object")
4118
4220
  return;
4119
4221
  const t = s.sandboxFilesToken;
@@ -4123,7 +4225,7 @@ function Ri(s, e) {
4123
4225
  const i = () => {
4124
4226
  if (!n)
4125
4227
  throw new Error("sandboxFiles is only available during browser-code execution");
4126
- }, r = async (a, l) => await _n(`${e.replace(/\/$/, "")}${a}`, l);
4228
+ }, r = async (a, l) => await vn(`${e.replace(/\/$/, "")}${a}`, l);
4127
4229
  return {
4128
4230
  value: Object.freeze({
4129
4231
  upload: async (a) => {
@@ -4157,7 +4259,7 @@ function Ri(s, e) {
4157
4259
  }
4158
4260
  };
4159
4261
  }
4160
- function Ei(s) {
4262
+ function vi(s) {
4161
4263
  return {
4162
4264
  ok: !1,
4163
4265
  exception: {
@@ -4171,10 +4273,10 @@ function Ei(s) {
4171
4273
  }
4172
4274
  };
4173
4275
  }
4174
- function ki(s) {
4276
+ function Ui(s) {
4175
4277
  return s.replace(/\/+$/, "");
4176
4278
  }
4177
- function Ci(s) {
4279
+ function Di(s) {
4178
4280
  const e = {
4179
4281
  sidepanel: "extension_sidepanel",
4180
4282
  browser_extension_page_ui: "extension_widget",
@@ -4186,18 +4288,18 @@ function Ci(s) {
4186
4288
  };
4187
4289
  return s && s in e ? e[s] : s ?? "embedded_custom_ui";
4188
4290
  }
4189
- function Pi(s) {
4291
+ function qi(s) {
4190
4292
  return s === "pluno" ? "scheduled_continuation" : s ?? "user";
4191
4293
  }
4192
- function _i(s, e = location.origin) {
4294
+ function Oi(s, e = location.origin) {
4193
4295
  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
4296
  }
4195
- function vi(s) {
4297
+ function xi(s) {
4196
4298
  const e = new URL("/api/product-agent/embed/ws", s);
4197
4299
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
4198
4300
  }
4199
4301
  function P() {
4200
- const s = Rs();
4302
+ const s = ks();
4201
4303
  return {
4202
4304
  url: location.href,
4203
4305
  title: document.title,
@@ -4205,19 +4307,19 @@ function P() {
4205
4307
  ...s ? { plunoProductAgentUi: s } : {}
4206
4308
  };
4207
4309
  }
4208
- function Ui() {
4310
+ function Li() {
4209
4311
  return {
4210
4312
  pageUrl: location.href,
4211
4313
  pageTitle: document.title,
4212
- htmlContent: St()
4314
+ htmlContent: wt()
4213
4315
  };
4214
4316
  }
4215
- function Di(s) {
4216
- return Ee.add(s), Se || (Se = qi()), () => {
4217
- Ee.delete(s), Ee.size === 0 && (Se?.(), Se = null);
4317
+ function Ni(s) {
4318
+ return Ee.add(s), Te || (Te = Hi()), () => {
4319
+ Ee.delete(s), Ee.size === 0 && (Te?.(), Te = null);
4218
4320
  };
4219
4321
  }
4220
- function qi() {
4322
+ function Hi() {
4221
4323
  const s = () => {
4222
4324
  for (const r of Array.from(Ee))
4223
4325
  r();
@@ -4232,38 +4334,38 @@ function qi() {
4232
4334
  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
4335
  };
4234
4336
  }
4235
- function Ye() {
4236
- return Rs()?.surface === "browser_extension_sdk_preview";
4337
+ function Ze() {
4338
+ return ks()?.surface === "browser_extension_sdk_preview";
4237
4339
  }
4238
- function St() {
4340
+ function wt() {
4239
4341
  if (!document.body)
4240
4342
  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));
4343
+ const s = [], e = [], t = (p, y) => {
4344
+ const f = ne(y);
4345
+ !f || e.includes(f) || (s.push([p, f]), e.push(f));
4244
4346
  };
4245
4347
  t("Selected text", window.getSelection()?.toString() ?? "");
4246
4348
  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)
4349
+ (p) => Ms(p) && !p.parentElement?.closest(n)
4248
4350
  );
4249
4351
  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(`
4352
+ t("Active overlay", et(he(p), e));
4353
+ const r = Bi(), o = r ? et(he(r), e) : "";
4354
+ t("Main page content", o), t("Additional visible page text", et(he(document.body), e));
4355
+ const a = s.map(([p, y]) => `${p}:
4356
+ ${y}`).join(`
4255
4357
 
4256
- `).trim().slice(0, 12e3), l = xi(i, r).trim(), c = `Simplified DOM outline:
4358
+ `).trim().slice(0, 12e3), l = Wi(i, r).trim(), c = `Simplified DOM outline:
4257
4359
  `, u = `
4258
4360
 
4259
4361
  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}`;
4362
+ `, h = 12e3 - c.length - u.length, m = Math.min(a.length, 7900), g = l.slice(0, h - m), d = a.slice(0, h - g.length);
4363
+ return `${c}${g}${u}${d}`;
4262
4364
  }
4263
- function de(s) {
4365
+ function he(s) {
4264
4366
  return s.innerText ?? s.textContent ?? "";
4265
4367
  }
4266
- function se(s) {
4368
+ function ne(s) {
4267
4369
  return (s ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
4268
4370
  `).split(`
4269
4371
  `).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
@@ -4271,20 +4373,20 @@ function se(s) {
4271
4373
 
4272
4374
  `).trim();
4273
4375
  }
4274
- function Ze(s, e) {
4275
- let t = se(s);
4376
+ function et(s, e) {
4377
+ let t = ne(s);
4276
4378
  for (const n of e)
4277
4379
  t = t.replace(n, "");
4278
- return se(t);
4380
+ return ne(t);
4279
4381
  }
4280
- function As(s) {
4382
+ function Ms(s) {
4281
4383
  const e = window.getComputedStyle(s);
4282
4384
  return e.display !== "none" && e.visibility !== "hidden" && s.getClientRects().length > 0;
4283
4385
  }
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;
4386
+ function Bi() {
4387
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ms).sort((s, e) => he(e).length - he(s).length)[0] ?? null;
4286
4388
  }
4287
- function xi(s, e) {
4389
+ function Wi(s, e) {
4288
4390
  const t = /* @__PURE__ */ new Set([
4289
4391
  "main",
4290
4392
  "nav",
@@ -4364,92 +4466,92 @@ function xi(s, e) {
4364
4466
  "data-test",
4365
4467
  "data-qa",
4366
4468
  "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;
4469
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: h } = $i(), m = new Set(s);
4470
+ e && m.add(e);
4471
+ let g = 0;
4370
4472
  const d = (w) => {
4371
4473
  const D = w.getAttribute("role");
4372
4474
  return D && !o.has(D) ? D : "";
4373
4475
  }, p = (w) => {
4374
4476
  const D = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
4375
4477
  return `${w.tagName.toLowerCase()}|${d(w)}|${D}`;
4376
- }, m = (w, D, H) => {
4478
+ }, y = (w, D, H) => {
4377
4479
  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")
4480
+ const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T), J = u.has(T);
4481
+ if (g >= 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
4482
  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();
4483
+ g += 1;
4484
+ const Y = d(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
4485
  for (const I of B) {
4384
- const b = p(I);
4385
- Q.set(b, (Q.get(b) ?? 0) + 1);
4486
+ const R = p(I);
4487
+ Q.set(R, (Q.get(R) ?? 0) + 1);
4386
4488
  }
4387
- const fe = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
4489
+ const me = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map();
4388
4490
  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);
4491
+ const R = p(I), z = oe.get(R) ?? 0;
4492
+ oe.set(R, z + 1), (Q.get(R) ?? 0) > 8 && z >= 6 && !u.has(I) && me.set(R, (me.get(R) ?? 0) + 1);
4391
4493
  }
4392
- const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Mt = [];
4494
+ const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Rt = [];
4393
4495
  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));
4496
+ const R = p(I), z = Q.get(R) ?? 0, Ct = j.get(R) ?? 0;
4497
+ if (j.set(R, Ct + 1), z > 8 && Ct >= 6 && !u.has(I)) {
4498
+ U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
4397
4499
  continue;
4398
4500
  }
4399
- const kt = S(I, N);
4400
- Mt.push(kt), q.push(kt.lines);
4501
+ const Pt = S(I, N);
4502
+ Rt.push(Pt), q.push(Pt.lines);
4401
4503
  }
4402
- const Ne = [];
4504
+ const He = [];
4403
4505
  if (T.shadowRoot)
4404
4506
  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)));
4507
+ I instanceof HTMLElement && He.push(S(I, N + 1));
4508
+ const ye = [...Rt, ...He], Be = Z.length > 0 || fe || ye.some((I) => I.hasUsefulContent), kt = ne(
4509
+ [Z, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
4510
+ ).slice(0, 180), js = T.hasAttribute("contenteditable") && (Z.length > 0 || !T.querySelector("[contenteditable]")), Et = c.some((I) => T.hasAttribute(I)) || !!Y || js, We = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Et || J) && (Be || J) && (!i.has(v) || Be || Et || J), $e = We ? 1 : 0, ae = [];
4511
+ if (We) {
4512
+ const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? kt : Z;
4513
+ ae.push(bs(T, l, o, R.slice(0, 180)));
4412
4514
  }
4413
4515
  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));
4516
+ ae.push(...we(I, $e));
4517
+ const Fe = He.flatMap((I) => I.lines);
4518
+ if (Fe.length > 0) {
4519
+ const I = Fe.slice(0, 20);
4520
+ Fe.length > I.length && I.push("… shadow DOM omitted");
4521
+ const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
4522
+ if (N < 2 && !R) {
4523
+ const z = We ? "#shadow-root" : `${v} #shadow-root`;
4524
+ ae.push(...we([z, ...we(I, 1)], $e));
4423
4525
  } else
4424
- oe.push(...Te(I, We));
4526
+ ae.push(...we(I, $e));
4425
4527
  }
4426
4528
  return {
4427
- lines: oe,
4428
- hasUsefulContent: He,
4429
- textPreview: bt,
4430
- containsTextElement: n.has(v) || me.some((I) => I.containsTextElement)
4529
+ lines: ae,
4530
+ hasUsefulContent: Be,
4531
+ textPreview: kt,
4532
+ containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
4431
4533
  };
4432
4534
  };
4433
4535
  return [`--- ${D} ---`, ...S(w, 0).lines].join(`
4434
4536
  `);
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));
4537
+ }, f = [], M = ne(window.getSelection()?.toString() ?? "");
4538
+ M && f.push(`--- selected text ---
4539
+ ${JSON.stringify(M)}`), h.length > 0 && f.push(Fi(h, t, l, o));
4438
4540
  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) {
4541
+ f.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4542
+ if (e && f.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
4441
4543
  const w = e || s.length ? "other visible DOM" : "visible DOM";
4442
- g.push(m(document.body, w, f));
4544
+ f.push(y(document.body, w, m));
4443
4545
  }
4444
- return g.join(`
4546
+ return f.join(`
4445
4547
 
4446
4548
  `);
4447
4549
  }
4448
- function Ms(s, e, t, n) {
4550
+ function bs(s, e, t, n) {
4449
4551
  const i = s.tagName.toLowerCase();
4450
4552
  let r = i;
4451
4553
  const o = s.getAttribute("id");
4452
- o && Hi(o) && (r += `#${o}`);
4554
+ o && ji(o) && (r += `#${o}`);
4453
4555
  for (const a of e) {
4454
4556
  const l = s.getAttribute(a);
4455
4557
  l && l.length <= 160 && (a !== "role" || !t.has(l)) && (r += `[${a}=${JSON.stringify(l)}]`);
@@ -4462,7 +4564,7 @@ function Ms(s, e, t, n) {
4462
4564
  s.hasAttribute(a) && (r += `[${a}]`);
4463
4565
  return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
4464
4566
  }
4465
- function Li() {
4567
+ function $i() {
4466
4568
  const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
4467
4569
  if (!a)
4468
4570
  return;
@@ -4474,8 +4576,8 @@ function Li() {
4474
4576
  let h = a;
4475
4577
  for (; h; ) {
4476
4578
  s.add(h);
4477
- const f = h.getRootNode();
4478
- h = h.parentElement ?? (f instanceof ShadowRoot && f.host instanceof HTMLElement ? f.host : null);
4579
+ const m = h.getRootNode();
4580
+ h = h.parentElement ?? (m instanceof ShadowRoot && m.host instanceof HTMLElement ? m.host : null);
4479
4581
  }
4480
4582
  };
4481
4583
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -4483,7 +4585,7 @@ function Li() {
4483
4585
  n = n.shadowRoot.activeElement;
4484
4586
  n !== document.body && n !== document.documentElement && t(n, "focused");
4485
4587
  const i = window.getSelection();
4486
- i && !i.isCollapsed && (t(Kt(i.anchorNode), "selected text"), t(Kt(i.focusNode), "selected text"));
4588
+ i && !i.isCollapsed && (t(Gt(i.anchorNode), "selected text"), t(Gt(i.focusNode), "selected text"));
4487
4589
  const r = [
4488
4590
  ["[aria-selected='true']", "selected"],
4489
4591
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -4505,7 +4607,7 @@ function Li() {
4505
4607
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
4506
4608
  };
4507
4609
  }
4508
- function Ni(s, e, t, n) {
4610
+ function Fi(s, e, t, n) {
4509
4611
  const i = ["--- active/current elements ---"];
4510
4612
  for (const r of s) {
4511
4613
  const o = [];
@@ -4516,37 +4618,37 @@ function Ni(s, e, t, n) {
4516
4618
  const h = a.getRootNode();
4517
4619
  a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
4518
4620
  }
4519
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => Ms(
4621
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => bs(
4520
4622
  u,
4521
4623
  t,
4522
4624
  n,
4523
- h === l.length - 1 ? bs(u).slice(0, 180) : ""
4625
+ h === l.length - 1 ? Rs(u).slice(0, 180) : ""
4524
4626
  ));
4525
4627
  o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
4526
4628
  }
4527
4629
  return i.join(`
4528
4630
  `);
4529
4631
  }
4530
- function Kt(s) {
4632
+ function Gt(s) {
4531
4633
  return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
4532
4634
  }
4533
- function Te(s, e) {
4635
+ function we(s, e) {
4534
4636
  if (e === 0)
4535
4637
  return s;
4536
4638
  const t = " ".repeat(e);
4537
4639
  return s.map((n) => `${t}${n}`);
4538
4640
  }
4539
- function bs(s) {
4540
- return se(
4641
+ function Rs(s) {
4642
+ return ne(
4541
4643
  Array.from(s.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
4542
4644
  );
4543
4645
  }
4544
- function Hi(s) {
4646
+ function ji(s) {
4545
4647
  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
4648
  }
4547
- function Rs() {
4548
- const s = Array.from(document.querySelectorAll(xt)), e = s.find(
4549
- (r) => typeof r[qn] == "string"
4649
+ function ks() {
4650
+ const s = Array.from(document.querySelectorAll(Nt)), e = s.find(
4651
+ (r) => typeof r[On] == "string"
4550
4652
  );
4551
4653
  if (!(e ?? s[0]))
4552
4654
  return;
@@ -4557,28 +4659,28 @@ function Rs() {
4557
4659
  selectors: [
4558
4660
  {
4559
4661
  name: "widget_host",
4560
- selector: xt,
4662
+ selector: Nt,
4561
4663
  description: "Finds Pluno's shadow-host element in the host page DOM."
4562
4664
  },
4563
4665
  {
4564
4666
  name: "widget_root",
4565
- selector: vn,
4667
+ selector: Un,
4566
4668
  description: "Finds Pluno's widget root inside the widget host shadow root."
4567
4669
  },
4568
4670
  {
4569
4671
  name: "widget_panel",
4570
- selector: Un,
4672
+ selector: Dn,
4571
4673
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
4572
4674
  },
4573
4675
  {
4574
4676
  name: "widget_timeline",
4575
- selector: Dn,
4677
+ selector: qn,
4576
4678
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
4577
4679
  }
4578
4680
  ]
4579
4681
  };
4580
4682
  }
4581
- function Bi(s) {
4683
+ function zi(s) {
4582
4684
  try {
4583
4685
  const e = JSON.parse(s);
4584
4686
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -4586,7 +4688,7 @@ function Bi(s) {
4586
4688
  return { type: "error", message: "Invalid server event" };
4587
4689
  }
4588
4690
  }
4589
- function Wi(s) {
4691
+ function Ki(s) {
4590
4692
  if (typeof s != "string")
4591
4693
  return null;
4592
4694
  try {
@@ -4596,13 +4698,13 @@ function Wi(s) {
4596
4698
  return null;
4597
4699
  }
4598
4700
  }
4599
- function Gt(s, e) {
4701
+ function Qt(s, e) {
4600
4702
  if (!s || typeof s != "object")
4601
4703
  return [];
4602
4704
  const t = s[e];
4603
4705
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
4604
4706
  }
4605
- function Qt(s) {
4707
+ function Vt(s) {
4606
4708
  return Array.isArray(s) ? s.flatMap((e) => {
4607
4709
  if (!e || typeof e != "object")
4608
4710
  return [];
@@ -4610,10 +4712,10 @@ function Qt(s) {
4610
4712
  return typeof t.taskId != "string" || !t.taskId || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? [] : [{ taskId: t.taskId, dueAt: t.dueAt }];
4611
4713
  }) : [];
4612
4714
  }
4613
- function $i(s) {
4715
+ function Gi(s) {
4614
4716
  return Array.isArray(s) ? s.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
4615
4717
  }
4616
- function Fi(s) {
4718
+ function Qi(s) {
4617
4719
  if (!s || typeof s != "object")
4618
4720
  return null;
4619
4721
  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 +4726,13 @@ function Fi(s) {
4624
4726
  ...a !== null ? { scribbleStyle: a } : {}
4625
4727
  };
4626
4728
  }
4627
- function ji(s) {
4729
+ function Vi(s) {
4628
4730
  if (!s || typeof s != "object")
4629
4731
  return null;
4630
4732
  const e = s.javascript;
4631
4733
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
4632
4734
  }
4633
- function zi(s, e) {
4735
+ function Xi(s, e) {
4634
4736
  return e ? s && typeof s == "object" ? {
4635
4737
  ...s,
4636
4738
  helperError: e
@@ -4640,13 +4742,13 @@ function zi(s, e) {
4640
4742
  helperError: e
4641
4743
  } : s;
4642
4744
  }
4643
- function Ki(s) {
4745
+ function Ji(s) {
4644
4746
  if (!s || typeof s != "object")
4645
4747
  return s;
4646
4748
  const e = s;
4647
4749
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : s;
4648
4750
  }
4649
- function Gi() {
4751
+ function Yi() {
4650
4752
  const s = "pluno.productAgent.clientId", e = window.localStorage.getItem(s);
4651
4753
  if (e)
4652
4754
  return e;
@@ -4656,7 +4758,7 @@ function Gi() {
4656
4758
  function x() {
4657
4759
  return crypto.randomUUID();
4658
4760
  }
4659
- function Qi(s) {
4761
+ function Zi(s) {
4660
4762
  if (!s || typeof s != "object")
4661
4763
  return null;
4662
4764
  const e = s, t = typeof e.id == "string" ? e.id : null;
@@ -4667,12 +4769,12 @@ function Qi(s) {
4667
4769
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
4668
4770
  } : null;
4669
4771
  }
4670
- function et(s, e) {
4671
- return Array.isArray(s) ? ut(
4672
- s.map((t) => rt(t, e)).filter((t) => t !== null)
4772
+ function tt(s, e) {
4773
+ return Array.isArray(s) ? ht(
4774
+ s.map((t) => at(t, e)).filter((t) => t !== null)
4673
4775
  ) : [];
4674
4776
  }
4675
- function Vi(s) {
4777
+ function er(s) {
4676
4778
  return Array.isArray(s) ? s.flatMap((e) => {
4677
4779
  if (!e || typeof e != "object")
4678
4780
  return [];
@@ -4693,29 +4795,29 @@ function Vi(s) {
4693
4795
  ];
4694
4796
  }) : [];
4695
4797
  }
4696
- function rt(s, e) {
4798
+ function at(s, e) {
4697
4799
  if (!s || typeof s != "object")
4698
4800
  return null;
4699
4801
  const t = s, n = t.data;
4700
4802
  if (!n || typeof n != "object")
4701
4803
  return null;
4702
4804
  const i = n;
4703
- if (i.hiddenFromTranscript === !0 || sn(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
4805
+ if (i.hiddenFromTranscript === !0 || nn(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
4704
4806
  return null;
4705
4807
  if (i.type === "assistant_draft")
4706
4808
  return {
4707
4809
  id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
4708
4810
  role: "assistant",
4709
4811
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4710
- content: Ct(
4711
- Vt(i.content),
4812
+ content: _t(
4813
+ Xt(i.content),
4712
4814
  e
4713
4815
  ),
4714
4816
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4715
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4817
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4716
4818
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4717
4819
  respondsToUserMessageId: O(i) ?? void 0,
4718
- ...E(i) ? { runId: E(i) } : {},
4820
+ ...k(i) ? { runId: k(i) } : {},
4719
4821
  dataType: "assistant_draft",
4720
4822
  ...i.steered === !0 ? { steered: !0 } : {}
4721
4823
  };
@@ -4724,16 +4826,16 @@ function rt(s, e) {
4724
4826
  id: String(t.id ?? crypto.randomUUID()),
4725
4827
  role: r,
4726
4828
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4727
- content: Ct(
4728
- Vt(i.content),
4829
+ content: _t(
4830
+ Xt(i.content),
4729
4831
  e
4730
4832
  ),
4731
4833
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4732
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4834
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4733
4835
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4734
4836
  respondsToUserMessageId: O(i) ?? void 0,
4735
- ...E(i) ? { runId: E(i) } : {},
4736
- attachments: Us(i.attachments, e),
4837
+ ...k(i) ? { runId: k(i) } : {},
4838
+ attachments: Ds(i.attachments, e),
4737
4839
  ...i.steered === !0 ? { steered: !0 } : {}
4738
4840
  };
4739
4841
  return r === "assistant" && typeof i.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
@@ -4748,89 +4850,89 @@ function rt(s, e) {
4748
4850
  }), o;
4749
4851
  }
4750
4852
  if (i.type === "function_call_output") {
4751
- const r = Ys(i.output);
4853
+ const r = Zs(i.output);
4752
4854
  if (r !== null)
4753
4855
  return {
4754
4856
  id: String(t.id ?? crypto.randomUUID()),
4755
4857
  role: "tool",
4756
4858
  content: "",
4757
4859
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4758
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4860
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4759
4861
  respondsToUserMessageId: O(i) ?? void 0,
4760
- ...E(i) ? { runId: E(i) } : {},
4862
+ ...k(i) ? { runId: k(i) } : {},
4761
4863
  dataType: "function_call_output",
4762
- toolName: ds,
4763
- callId: ce(i) ?? void 0,
4864
+ toolName: hs,
4865
+ callId: ue(i) ?? void 0,
4764
4866
  sharePromptAllowed: r
4765
4867
  };
4766
- const o = gn(i.output);
4868
+ const o = fn(i.output);
4767
4869
  if (o)
4768
4870
  return {
4769
4871
  id: String(t.id ?? crypto.randomUUID()),
4770
4872
  role: "tool",
4771
4873
  content: "",
4772
4874
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4773
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4875
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4774
4876
  respondsToUserMessageId: O(i) ?? void 0,
4775
- ...E(i) ? { runId: E(i) } : {},
4877
+ ...k(i) ? { runId: k(i) } : {},
4776
4878
  dataType: "scheduled_check_in",
4777
- toolName: ps,
4778
- callId: ce(i) ?? void 0,
4879
+ toolName: gs,
4880
+ callId: ue(i) ?? void 0,
4779
4881
  scheduledCheckInId: o.id ?? void 0,
4780
4882
  scheduledCheckInAt: o.dueAt
4781
4883
  };
4782
- const a = Ji(i.output), l = Yi(i.output);
4884
+ const a = sr(i.output), l = nr(i.output);
4783
4885
  return a ? {
4784
4886
  id: String(t.id ?? crypto.randomUUID()),
4785
4887
  role: "tool",
4786
4888
  content: `Connect ${a.appName} to continue`,
4787
4889
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4788
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4890
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4789
4891
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4790
4892
  respondsToUserMessageId: O(i) ?? void 0,
4791
- ...E(i) ? { runId: E(i) } : {},
4893
+ ...k(i) ? { runId: k(i) } : {},
4792
4894
  dataType: "function_call_output",
4793
4895
  toolName: "authenticate_pipedream_app",
4794
- callId: ce(i) ?? void 0,
4896
+ callId: ue(i) ?? void 0,
4795
4897
  integrationAuthRequest: a
4796
4898
  } : l ? {
4797
4899
  id: String(t.id ?? crypto.randomUUID()),
4798
4900
  role: "tool",
4799
4901
  content: "Connect WhatsApp to continue",
4800
4902
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4801
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4903
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4802
4904
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4803
4905
  respondsToUserMessageId: O(i) ?? void 0,
4804
- ...E(i) ? { runId: E(i) } : {},
4906
+ ...k(i) ? { runId: k(i) } : {},
4805
4907
  dataType: "function_call_output",
4806
4908
  toolName: "request_personal_channel_connection",
4807
- callId: ce(i) ?? void 0,
4909
+ callId: ue(i) ?? void 0,
4808
4910
  personalChannelConnectionRequest: l
4809
4911
  } : null;
4810
4912
  }
4811
4913
  return i.type === "function_call" || i.type === "tool_call" || i.type === "web_search_call" || i.type === "mcp_call" || i.type === "tab_lifecycle_decision" ? {
4812
4914
  id: String(t.id ?? crypto.randomUUID()),
4813
4915
  role: "tool",
4814
- content: i.type === "mcp_call" ? Xi(i) : er(i),
4916
+ content: i.type === "mcp_call" ? tr(i) : rr(i),
4815
4917
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4816
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4918
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4817
4919
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4818
4920
  respondsToUserMessageId: O(i) ?? void 0,
4819
- ...E(i) ? { runId: E(i) } : {},
4921
+ ...k(i) ? { runId: k(i) } : {},
4820
4922
  dataType: String(i.type),
4821
4923
  toolName: i.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof i.name == "string" ? i.name : void 0,
4822
- callId: ce(i) ?? void 0,
4924
+ callId: ue(i) ?? void 0,
4823
4925
  loading: i.steered === !0 ? !1 : i.localExecutionStatus === "queued" || i.localExecutionStatus === "running" ? !0 : typeof i.localExecutionStatus == "string" ? !1 : void 0,
4824
4926
  ...i.steered === !0 ? { steered: !0 } : {}
4825
4927
  } : i.type === "run_status" || i.type === "run_error" ? i.type === "run_error" && i.stage === "tool_execution" ? null : {
4826
4928
  id: String(t.id ?? crypto.randomUUID()),
4827
4929
  role: "system",
4828
- content: Zi(i),
4930
+ content: ir(i),
4829
4931
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4830
- ...k(i) !== null ? { displaySequence: k(i) } : {},
4932
+ ...E(i) !== null ? { displaySequence: E(i) } : {},
4831
4933
  ..._(i) !== null ? { causalSequence: _(i) } : {},
4832
4934
  respondsToUserMessageId: O(i) ?? void 0,
4833
- ...E(i) ? { runId: E(i) } : {},
4935
+ ...k(i) ? { runId: k(i) } : {},
4834
4936
  dataType: String(i.type),
4835
4937
  loading: i.steered !== !0 && i.type === "run_status" && (i.status === "running" || i.status === "retrying"),
4836
4938
  ...i.steered === !0 || i.type === "run_status" && i.status === "steered" ? { steered: !0 } : {},
@@ -4838,11 +4940,11 @@ function rt(s, e) {
4838
4940
  ...typeof i.securitySettingsUrl == "string" ? { securitySettingsUrl: i.securitySettingsUrl } : {}
4839
4941
  } : null;
4840
4942
  }
4841
- function Xi(s) {
4943
+ function tr(s) {
4842
4944
  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
4945
  return t ? `🔌 Using ${t}` : "🔌 Using connected integration";
4844
4946
  }
4845
- function Ji(s) {
4947
+ function sr(s) {
4846
4948
  if (typeof s != "string")
4847
4949
  return null;
4848
4950
  try {
@@ -4859,7 +4961,7 @@ function Ji(s) {
4859
4961
  return null;
4860
4962
  }
4861
4963
  }
4862
- function Yi(s) {
4964
+ function nr(s) {
4863
4965
  if (typeof s != "string")
4864
4966
  return null;
4865
4967
  try {
@@ -4874,10 +4976,10 @@ function Yi(s) {
4874
4976
  return null;
4875
4977
  }
4876
4978
  }
4877
- function Zi(s) {
4979
+ function ir(s) {
4878
4980
  return s.type === "run_status" && s.status === "steered" ? "Steered" : typeof s.message == "string" && s.message.trim().length > 0 ? s.message : "";
4879
4981
  }
4880
- function er(s) {
4982
+ function rr(s) {
4881
4983
  if (s.type === "web_search_call") {
4882
4984
  const e = s.action;
4883
4985
  if (e && typeof e == "object") {
@@ -4889,26 +4991,26 @@ function er(s) {
4889
4991
  }
4890
4992
  return "🔎 Searching the web";
4891
4993
  }
4892
- return tr(s);
4994
+ return or(s);
4893
4995
  }
4894
- function tr(s) {
4996
+ function or(s) {
4895
4997
  if (typeof s.summary == "string" && s.summary.trim().length > 0)
4896
- return te(s.summary);
4998
+ return se(s.summary);
4897
4999
  if (typeof s.arguments == "string")
4898
5000
  try {
4899
5001
  const e = JSON.parse(s.arguments);
4900
5002
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
4901
- return te(e.summary);
5003
+ return se(e.summary);
4902
5004
  } catch {
4903
- return typeof s.name == "string" && s.name.trim().length > 0 ? te(s.name) : "🛠️ Run tool";
5005
+ return typeof s.name == "string" && s.name.trim().length > 0 ? se(s.name) : "🛠️ Run tool";
4904
5006
  }
4905
- return typeof s.name == "string" && s.name.trim().length > 0 ? te(s.name) : "🛠️ Run tool";
5007
+ return typeof s.name == "string" && s.name.trim().length > 0 ? se(s.name) : "🛠️ Run tool";
4906
5008
  }
4907
- function te(s) {
5009
+ function se(s) {
4908
5010
  const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
4909
5011
  return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
4910
5012
  }
4911
- function sr(s) {
5013
+ function ar(s) {
4912
5014
  if (s == null)
4913
5015
  return s;
4914
5016
  if (typeof s != "object")
@@ -4923,17 +5025,17 @@ function sr(s) {
4923
5025
  runId: typeof e.runId == "string" ? e.runId : null
4924
5026
  };
4925
5027
  }
4926
- function ce(s) {
5028
+ function ue(s) {
4927
5029
  const e = s.callId ?? s.call_id;
4928
5030
  return typeof e == "string" && e ? e : null;
4929
5031
  }
4930
5032
  function _(s) {
4931
5033
  return typeof s.causalSequence == "number" && Number.isSafeInteger(s.causalSequence) ? s.causalSequence : null;
4932
5034
  }
4933
- function k(s) {
5035
+ function E(s) {
4934
5036
  return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
4935
5037
  }
4936
- function Vt(s) {
5038
+ function Xt(s) {
4937
5039
  return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
4938
5040
  if (!e || typeof e != "object")
4939
5041
  return "";
@@ -4941,14 +5043,14 @@ function Vt(s) {
4941
5043
  return typeof t.text == "string" ? t.text : typeof t.content == "string" ? t.content : "";
4942
5044
  }).filter(Boolean).join("") : "";
4943
5045
  }
4944
- function ue(s, e) {
5046
+ function de(s, e) {
4945
5047
  const t = Es(
4946
5048
  s,
4947
- Tt(s, e)
4948
- ), n = rr(
4949
- ir(
4950
- cr(
4951
- nr(s, e),
5049
+ At(s, e)
5050
+ ), n = ur(
5051
+ cr(
5052
+ gr(
5053
+ lr(s, e),
4952
5054
  e
4953
5055
  ),
4954
5056
  t
@@ -4956,13 +5058,13 @@ function ue(s, e) {
4956
5058
  t
4957
5059
  ), i = n.findIndex((o) => o.id === t.id);
4958
5060
  if (i === -1)
4959
- return ut(
5061
+ return ht(
4960
5062
  [...n, t]
4961
5063
  );
4962
5064
  const r = [...n];
4963
- return r[i] = t, ut(r);
5065
+ return r[i] = t, ht(r);
4964
5066
  }
4965
- function Tt(s, e, t = !0) {
5067
+ function At(s, e, t = !0) {
4966
5068
  const n = s.find(
4967
5069
  (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
5070
  );
@@ -4973,7 +5075,7 @@ function Tt(s, e, t = !0) {
4973
5075
  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
5076
  return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
4975
5077
  }
4976
- function nr(s, e) {
5078
+ function lr(s, e) {
4977
5079
  const t = e.proactiveSuggestionClientMessageId;
4978
5080
  if (!t)
4979
5081
  return s;
@@ -4983,16 +5085,16 @@ function nr(s, e) {
4983
5085
  const r = [...s];
4984
5086
  return r[i] = e, r;
4985
5087
  }
4986
- function ir(s, e) {
5088
+ function cr(s, e) {
4987
5089
  const t = e.assistantDraftItemId;
4988
5090
  return t ? s.map(
4989
5091
  (n) => n.dataType === "assistant_draft" && n.id === t ? e : n
4990
5092
  ) : s;
4991
5093
  }
4992
- function we(s, e, t) {
5094
+ function Ae(s, e, t) {
4993
5095
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
4994
5096
  }
4995
- function Xt(s, e, t, n) {
5097
+ function Jt(s, e, t, n) {
4996
5098
  if (t === null) return s;
4997
5099
  let i = -1;
4998
5100
  for (let o = s.length - 1; o >= 0; o -= 1) {
@@ -5009,12 +5111,12 @@ function Xt(s, e, t, n) {
5009
5111
  respondsToUserMessageId: t
5010
5112
  }, r;
5011
5113
  }
5012
- function Jt(s, e) {
5114
+ function Yt(s, e) {
5013
5115
  const t = s.findIndex(
5014
5116
  (i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
5015
5117
  );
5016
5118
  if (t === -1)
5017
- return ue(s, e);
5119
+ return de(s, e);
5018
5120
  const n = [...s];
5019
5121
  return n[t] = {
5020
5122
  ...n[t],
@@ -5026,19 +5128,19 @@ function Jt(s, e) {
5026
5128
  ...n[t].runId ? {} : { runId: e.runId }
5027
5129
  }, n;
5028
5130
  }
5029
- function Yt(s, e, t) {
5131
+ function Zt(s, e, t) {
5030
5132
  let n = !1;
5031
5133
  const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
5032
5134
  return n ? i : s;
5033
5135
  }
5034
- function Zt(s) {
5136
+ function es(s) {
5035
5137
  if (s.hiddenFromTranscript === !0)
5036
5138
  return null;
5037
5139
  const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
5038
5140
  return !e || !t ? null : {
5039
5141
  id: `transient-activity:${e}`,
5040
5142
  role: "tool",
5041
- content: te(
5143
+ content: se(
5042
5144
  typeof s.summary == "string" ? s.summary : "Running browser tool"
5043
5145
  ),
5044
5146
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -5051,7 +5153,7 @@ function Zt(s) {
5051
5153
  loading: !0
5052
5154
  };
5053
5155
  }
5054
- function rr(s, e) {
5156
+ function ur(s, e) {
5055
5157
  if (e.id.startsWith("transient-activity:"))
5056
5158
  return s;
5057
5159
  const t = e.toolName === "tab_lifecycle";
@@ -5060,30 +5162,30 @@ function rr(s, e) {
5060
5162
  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
5163
  return i === -1 ? s : s.flatMap((r, o) => n(r) ? o === i ? [e] : [] : r.id === e.id ? [] : [r]);
5062
5164
  }
5063
- function ot(s, e) {
5165
+ function lt(s, e) {
5064
5166
  const t = [];
5065
5167
  for (const n of e) {
5066
5168
  const i = [...s, ...t];
5067
5169
  t.push(
5068
5170
  Es(
5069
5171
  i,
5070
- Tt(i, n, !1)
5172
+ At(i, n, !1)
5071
5173
  )
5072
5174
  );
5073
5175
  }
5074
- return nn(
5176
+ return rn(
5075
5177
  s,
5076
5178
  t,
5077
- at
5179
+ ct
5078
5180
  );
5079
5181
  }
5080
- function or(s, e) {
5182
+ function dr(s, e) {
5081
5183
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5082
- (r) => Tt(s, r, !1)
5184
+ (r) => At(s, r, !1)
5083
5185
  );
5084
5186
  for (const r of n)
5085
5187
  t.set(r.id, r);
5086
- const i = ot(
5188
+ const i = lt(
5087
5189
  s,
5088
5190
  [...t.values()]
5089
5191
  );
@@ -5098,7 +5200,7 @@ function or(s, e) {
5098
5200
  }
5099
5201
  return i;
5100
5202
  }
5101
- function at(s) {
5203
+ function ct(s) {
5102
5204
  const e = X(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5103
5205
  // Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
5104
5206
  // from substituting the call for its output and then appending a duplicate output at the end of the timeline.
@@ -5112,7 +5214,7 @@ function at(s) {
5112
5214
  ...i.length > 0 ? { activityKeys: i } : {},
5113
5215
  ...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
5114
5216
  ...s.runId ? { runId: s.runId } : {},
5115
- isOptimistic: xe(s),
5217
+ isOptimistic: Le(s),
5116
5218
  isAssistantDraft: s.dataType === "assistant_draft",
5117
5219
  isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
5118
5220
  isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
@@ -5122,42 +5224,42 @@ function Es(s, e) {
5122
5224
  if (e.role !== "user" || !e.attachments?.length)
5123
5225
  return e;
5124
5226
  const t = s.find(
5125
- (o) => o.role === "user" && (o.id === e.id || xe(o) && ks(o, e))
5227
+ (o) => o.role === "user" && (o.id === e.id || Le(o) && Cs(o, e))
5126
5228
  );
5127
5229
  if (!t?.attachments?.length)
5128
5230
  return e;
5129
5231
  const n = e.attachments.map((o) => {
5130
- const a = ar(t.attachments ?? [], o);
5131
- return a ? lr(o, a) : o;
5232
+ const a = hr(t.attachments ?? [], o);
5233
+ return a ? pr(o, a) : o;
5132
5234
  }), i = { ...e, attachments: n }, r = X(e);
5133
5235
  return r && Object.defineProperty(i, "clientMessageId", {
5134
5236
  value: r,
5135
5237
  enumerable: !1
5136
5238
  }), i;
5137
5239
  }
5138
- function ar(s, e) {
5240
+ function hr(s, e) {
5139
5241
  return e.id ? s.find((t) => t.id === e.id) ?? null : null;
5140
5242
  }
5141
- function lr(s, e) {
5243
+ function pr(s, e) {
5142
5244
  const { previewUrl: t } = e;
5143
5245
  return t ? { ...s, previewUrl: t } : s;
5144
5246
  }
5145
- function cr(s, e) {
5247
+ function gr(s, e) {
5146
5248
  if (e.role !== "user")
5147
5249
  return s;
5148
5250
  const t = s.findIndex(
5149
- (i) => xe(i) && ks(i, e)
5251
+ (i) => Le(i) && Cs(i, e)
5150
5252
  );
5151
5253
  if (t === -1)
5152
5254
  return s;
5153
5255
  const n = [...s];
5154
5256
  return n.splice(t, 1), n;
5155
5257
  }
5156
- function ks(s, e) {
5258
+ function Cs(s, e) {
5157
5259
  const t = X(s), n = X(e);
5158
5260
  return t && n ? t === n : s.content === e.content;
5159
5261
  }
5160
- function xe(s) {
5262
+ function Le(s) {
5161
5263
  return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
5162
5264
  }
5163
5265
  function X(s) {
@@ -5169,13 +5271,13 @@ function X(s) {
5169
5271
  );
5170
5272
  return n ? s.id.slice(n.length) : null;
5171
5273
  }
5172
- function es(s) {
5173
- const e = Cs(s);
5274
+ function ts(s) {
5275
+ const e = Ps(s);
5174
5276
  if (e === null)
5175
5277
  return !1;
5176
5278
  const t = s[e].id;
5177
5279
  if (s.some(
5178
- (i) => i.respondsToUserMessageId === t && _e(i)
5280
+ (i) => i.respondsToUserMessageId === t && ve(i)
5179
5281
  ))
5180
5282
  return !0;
5181
5283
  for (let i = s.length - 1; i > e; i -= 1) {
@@ -5193,7 +5295,7 @@ function es(s) {
5193
5295
  }
5194
5296
  return !1;
5195
5297
  }
5196
- function ur(s, e, t) {
5298
+ function fr(s, e, t) {
5197
5299
  const n = new Set(
5198
5300
  s.filter(
5199
5301
  (i) => i.role === "user" && e !== null && X(i) === e
@@ -5207,14 +5309,14 @@ function ur(s, e, t) {
5207
5309
  if (t && i.runId === t) {
5208
5310
  if (n.size === 0)
5209
5311
  return !0;
5210
- const o = Ps(s, r);
5312
+ const o = _s(s, r);
5211
5313
  return !i.respondsToUserMessageId && o !== null && n.has(o);
5212
5314
  }
5213
5315
  return !1;
5214
5316
  });
5215
5317
  }
5216
- function dr(s) {
5217
- const e = Cs(s);
5318
+ function mr(s) {
5319
+ const e = Ps(s);
5218
5320
  if (e === null)
5219
5321
  return s.some($);
5220
5322
  const t = s[e].id;
@@ -5222,16 +5324,16 @@ function dr(s) {
5222
5324
  (n) => n.respondsToUserMessageId === t && $(n)
5223
5325
  ) : s.slice(e + 1).some($);
5224
5326
  }
5225
- function Cs(s) {
5327
+ function Ps(s) {
5226
5328
  for (let e = s.length - 1; e >= 0; e -= 1)
5227
- if (s[e].role === "user" && !xe(s[e]))
5329
+ if (s[e].role === "user" && !Le(s[e]))
5228
5330
  return e;
5229
5331
  return null;
5230
5332
  }
5231
- function _e(s) {
5333
+ function ve(s) {
5232
5334
  return $(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5233
5335
  }
5234
- function ne(s) {
5336
+ function ie(s) {
5235
5337
  for (let e = s.length - 1; e >= 0; e -= 1) {
5236
5338
  const t = s[e];
5237
5339
  if (!t || typeof t != "object")
@@ -5245,8 +5347,8 @@ function ne(s) {
5245
5347
  }
5246
5348
  return null;
5247
5349
  }
5248
- function hr(s) {
5249
- const e = ne(s);
5350
+ function yr(s) {
5351
+ const e = ie(s);
5250
5352
  if (e === null)
5251
5353
  return null;
5252
5354
  const n = C(s[e])?.page;
@@ -5261,14 +5363,14 @@ function C(s) {
5261
5363
  const e = s.data;
5262
5364
  return e && typeof e == "object" ? e : null;
5263
5365
  }
5264
- function he(s) {
5366
+ function pe(s) {
5265
5367
  return s?.retryable !== !0 ? !1 : s.type === "run_error" ? !0 : s.type === "run_status" && s.status === "interrupted";
5266
5368
  }
5267
- function pr(s) {
5369
+ function Ir(s) {
5268
5370
  return s?.type === "run_status" && s.status === "interrupted" && s.reason === "backend_restart";
5269
5371
  }
5270
- function gr(s, e) {
5271
- const t = ne(e);
5372
+ function Sr(s, e) {
5373
+ const t = ie(e);
5272
5374
  if (t === null)
5273
5375
  return !1;
5274
5376
  const n = e[t], i = n && typeof n == "object" ? n.id : null;
@@ -5276,11 +5378,11 @@ function gr(s, e) {
5276
5378
  return !1;
5277
5379
  const r = s.findIndex((o) => o.role === "user" && o.id === i);
5278
5380
  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);
5381
+ (o) => o.respondsToUserMessageId === i && ve(o)
5382
+ ) : s.slice(r + 1).some(ve);
5281
5383
  }
5282
- function lt(s) {
5283
- const e = ne(s);
5384
+ function ut(s) {
5385
+ const e = ie(s);
5284
5386
  if (e === null)
5285
5387
  return null;
5286
5388
  const t = s[e];
@@ -5292,8 +5394,8 @@ function lt(s) {
5292
5394
  const i = n.clientMessageId;
5293
5395
  return typeof i == "string" ? i : null;
5294
5396
  }
5295
- function fr(s) {
5296
- const e = ne(s);
5397
+ function Tr(s) {
5398
+ const e = ie(s);
5297
5399
  if (e === null)
5298
5400
  return null;
5299
5401
  for (let t = s.length - 1; t > e; t -= 1) {
@@ -5307,13 +5409,13 @@ function fr(s) {
5307
5409
  if (r.type === "message" && r.role === "assistant")
5308
5410
  return null;
5309
5411
  if (r.type === "run_error")
5310
- return r.retryable !== !0 ? null : ct(s, r) ?? lt(s);
5412
+ return r.retryable !== !0 ? null : dt(s, r) ?? ut(s);
5311
5413
  if (r.type === "run_status")
5312
- return r.status === "interrupted" && r.retryable === !0 ? ct(s, r) ?? lt(s) : null;
5414
+ return r.status === "interrupted" && r.retryable === !0 ? dt(s, r) ?? ut(s) : null;
5313
5415
  }
5314
5416
  return null;
5315
5417
  }
5316
- function ct(s, e) {
5418
+ function dt(s, e) {
5317
5419
  if (typeof e.clientMessageId == "string")
5318
5420
  return e.clientMessageId;
5319
5421
  const t = O(e);
@@ -5322,16 +5424,16 @@ function ct(s, e) {
5322
5424
  const n = s.find((r) => A(r, "id") === t), i = C(n);
5323
5425
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5324
5426
  }
5325
- function ts(s, e, t, n, i, r) {
5326
- if (!e || !yr(s))
5427
+ function ss(s, e, t, n, i, r) {
5428
+ if (!e || !Ar(s))
5327
5429
  return !1;
5328
5430
  const o = s;
5329
- if (he(o) || t !== null && typeof o.id == "string" && o.id !== t)
5431
+ if (pe(o) || t !== null && typeof o.id == "string" && o.id !== t)
5330
5432
  return !1;
5331
5433
  const a = O(o);
5332
- return n !== null ? a !== null ? a === n : i !== null && E(o) === i && r === n : i === null || E(o) === i;
5434
+ return n !== null ? a !== null ? a === n : i !== null && k(o) === i && r === n : i === null || k(o) === i;
5333
5435
  }
5334
- function mr(s, e) {
5436
+ function wr(s, e) {
5335
5437
  for (let t = e - 1; t >= 0; t -= 1) {
5336
5438
  const n = C(s[t]);
5337
5439
  if (n?.type === "message" && n.role === "user")
@@ -5339,13 +5441,13 @@ function mr(s, e) {
5339
5441
  }
5340
5442
  return null;
5341
5443
  }
5342
- function Ps(s, e) {
5444
+ function _s(s, e) {
5343
5445
  for (let t = e - 1; t >= 0; t -= 1)
5344
5446
  if (s[t].role === "user")
5345
5447
  return s[t].id;
5346
5448
  return null;
5347
5449
  }
5348
- function yr(s) {
5450
+ function Ar(s) {
5349
5451
  if (!s || typeof s != "object")
5350
5452
  return !1;
5351
5453
  const e = s;
@@ -5354,37 +5456,37 @@ function yr(s) {
5354
5456
  function $(s) {
5355
5457
  return s.role === "assistant" && s.phase !== "commentary";
5356
5458
  }
5357
- function Ir(s) {
5459
+ function Mr(s) {
5358
5460
  if (!s || typeof s != "object")
5359
5461
  return !1;
5360
5462
  const e = s;
5361
5463
  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
5464
  }
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);
5465
+ function ht(s) {
5466
+ 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
5467
  }
5366
- function Sr(s) {
5468
+ function br(s) {
5367
5469
  return s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.steered !== !0);
5368
5470
  }
5369
5471
  function G(s) {
5370
5472
  return s.role === "system" && s.dataType === "run_status" && s.loading === !0;
5371
5473
  }
5372
- function dt(s) {
5474
+ function pt(s) {
5373
5475
  return s.steered !== !0 && (s.dataType === "assistant_draft" || s.loading === !0);
5374
5476
  }
5375
- function Tr(s) {
5376
- return s.some(dt);
5477
+ function Rr(s) {
5478
+ return s.some(pt);
5377
5479
  }
5378
- function ss(s, e) {
5480
+ function ns(s, e) {
5379
5481
  return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5380
5482
  }
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]);
5483
+ function kr(s, e) {
5484
+ 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;
5485
+ 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
5486
  }
5385
- function Ar(s, e, t, n) {
5487
+ function Er(s, e, t, n) {
5386
5488
  const i = s.findIndex(
5387
- (l, c) => G(l) && !_s(s, c)
5489
+ (l, c) => G(l) && !vs(s, c)
5388
5490
  ), r = i === -1 ? null : s[i], o = e ?? r?.respondsToUserMessageId ?? null, a = o ? s.find(
5389
5491
  (l) => l.role === "user" && l.id === o
5390
5492
  ) : null;
@@ -5394,13 +5496,13 @@ function Ar(s, e, t, n) {
5394
5496
  runId: t ?? r?.runId ?? null
5395
5497
  };
5396
5498
  }
5397
- function ke(s) {
5499
+ function Ce(s) {
5398
5500
  return s?.type === "run_status" && s.status === "stopped";
5399
5501
  }
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;
5502
+ function Cr(s, e) {
5503
+ 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
5504
  }
5403
- function ns(s, e, t) {
5505
+ function is(s, e, t) {
5404
5506
  const n = new Set(
5405
5507
  s.filter(
5406
5508
  (i) => i.role === "user" && e !== null && X(i) === e
@@ -5410,18 +5512,18 @@ function ns(s, e, t) {
5410
5512
  (i) => !G(i) || (n.size > 0 ? !i.respondsToUserMessageId || !n.has(i.respondsToUserMessageId) : !t || i.runId !== t)
5411
5513
  );
5412
5514
  }
5413
- function _s(s, e) {
5515
+ function vs(s, e) {
5414
5516
  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(
5517
+ (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Pr(
5416
5518
  s,
5417
5519
  e,
5418
5520
  n
5419
5521
  )
5420
5522
  );
5421
5523
  }
5422
- function br(s, e, t) {
5524
+ function Pr(s, e, t) {
5423
5525
  const n = s[e], i = s[t];
5424
- if (pe(n, i))
5526
+ if (ge(n, i))
5425
5527
  return !0;
5426
5528
  if (!n.respondsToUserMessageId || i.respondsToUserMessageId || !n.runId || n.runId !== i.runId)
5427
5529
  return !1;
@@ -5430,20 +5532,20 @@ function br(s, e, t) {
5430
5532
  return s[r].id === n.respondsToUserMessageId;
5431
5533
  return !1;
5432
5534
  }
5433
- function is(s, e, t, n) {
5535
+ function rs(s, e, t, n) {
5434
5536
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5435
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && rs(l) && !Er(
5537
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && os(l) && !vr(
5436
5538
  s,
5437
5539
  l.respondsToUserMessageId
5438
5540
  )
5439
- )?.respondsToUserMessageId ?? Rr(
5541
+ )?.respondsToUserMessageId ?? _r(
5440
5542
  s,
5441
5543
  e
5442
5544
  );
5443
5545
  if (!i)
5444
5546
  return s;
5445
5547
  let r = !1;
5446
- const o = s.map((l) => l.respondsToUserMessageId !== i || !rs(l) ? l : (r = !0, { ...l, steered: !0 }));
5548
+ const o = s.map((l) => l.respondsToUserMessageId !== i || !os(l) ? l : (r = !0, { ...l, steered: !0 }));
5447
5549
  if (r)
5448
5550
  return o;
5449
5551
  const a = s.find(
@@ -5465,7 +5567,7 @@ function is(s, e, t, n) {
5465
5567
  }
5466
5568
  ];
5467
5569
  }
5468
- function Rr(s, e) {
5570
+ function _r(s, e) {
5469
5571
  const t = s.findIndex(
5470
5572
  (n) => n.role === "user" && n.id === e
5471
5573
  );
@@ -5476,24 +5578,24 @@ function Rr(s, e) {
5476
5578
  return s[n].id;
5477
5579
  return null;
5478
5580
  }
5479
- function rs(s) {
5581
+ function os(s) {
5480
5582
  return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5481
5583
  }
5482
- function Er(s, e) {
5584
+ function vr(s, e) {
5483
5585
  return s.some(
5484
5586
  (t) => t.respondsToUserMessageId === e && ($(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5485
5587
  );
5486
5588
  }
5487
- function kr(s, e) {
5589
+ function Ur(s, e) {
5488
5590
  const t = s[e];
5489
5591
  for (let n = e + 1; n < s.length; n += 1) {
5490
5592
  const i = s[n];
5491
- if (i.role === "assistant" && pe(t, i))
5593
+ if (i.role === "assistant" && ge(t, i))
5492
5594
  return !0;
5493
5595
  }
5494
5596
  return !1;
5495
5597
  }
5496
- function Cr(s, e) {
5598
+ function Dr(s, e) {
5497
5599
  const t = s[e];
5498
5600
  if (!t.respondsToUserMessageId)
5499
5601
  return !1;
@@ -5506,40 +5608,40 @@ function Cr(s, e) {
5506
5608
  }
5507
5609
  return !1;
5508
5610
  }
5509
- function Pr(s, e) {
5611
+ function qr(s, e) {
5510
5612
  const t = s[e];
5511
5613
  return s.some(
5512
- (n, i) => i !== e && n.role === "assistant" && pe(t, n)
5614
+ (n, i) => i !== e && n.role === "assistant" && ge(t, n)
5513
5615
  );
5514
5616
  }
5515
- function _r(s, e) {
5617
+ function Or(s, e) {
5516
5618
  const t = s[e];
5517
5619
  return s.some(
5518
- (n, i) => i !== e && n.role === "tool" && pe(t, n)
5620
+ (n, i) => i !== e && n.role === "tool" && ge(t, n)
5519
5621
  );
5520
5622
  }
5521
- function vr(s, e) {
5623
+ function xr(s, e) {
5522
5624
  const t = s[e];
5523
5625
  for (let n = e + 1; n < s.length; n += 1)
5524
- if (G(s[n]) && pe(t, s[n]))
5626
+ if (G(s[n]) && ge(t, s[n]))
5525
5627
  return !0;
5526
5628
  return !1;
5527
5629
  }
5528
- function pe(s, e) {
5630
+ function ge(s, e) {
5529
5631
  return !!(s.respondsToUserMessageId && s.respondsToUserMessageId === e.respondsToUserMessageId);
5530
5632
  }
5531
5633
  function A(s, e) {
5532
5634
  return s && typeof s == "object" && typeof s[e] == "string" ? s[e] : null;
5533
5635
  }
5534
- function Ur(s, e) {
5636
+ function Lr(s, e) {
5535
5637
  try {
5536
- const t = window.localStorage.getItem(`${ws}${s}`);
5638
+ const t = window.localStorage.getItem(`${As}${s}`);
5537
5639
  if (!t)
5538
5640
  return null;
5539
5641
  const n = JSON.parse(t), i = typeof n.sessionId == "string" ? n.sessionId : null;
5540
5642
  if (e !== void 0 && i !== e)
5541
5643
  return null;
5542
- const r = Array.isArray(n.messages) ? n.messages.map(Fr).filter((o) => !!o) : [];
5644
+ const r = Array.isArray(n.messages) ? n.messages.map(Qr).filter((o) => !!o) : [];
5543
5645
  return {
5544
5646
  sessionId: i,
5545
5647
  messages: r
@@ -5548,53 +5650,53 @@ function Ur(s, e) {
5548
5650
  return null;
5549
5651
  }
5550
5652
  }
5551
- function ht(s) {
5653
+ function gt(s) {
5552
5654
  return s.role === "user" || s.role === "assistant" || // Live activity is part of the readable conversation cache. Keeping it across host navigation prevents a
5553
5655
  // running tool or commentary history from disappearing while authoritative hydration is still in flight.
5554
5656
  s.role === "tool" || s.dataType === "run_status" || s.dataType === "run_error";
5555
5657
  }
5556
- function Dr(s, e) {
5658
+ function Nr(s, e) {
5557
5659
  try {
5558
5660
  window.localStorage.setItem(
5559
- `${ws}${s}`,
5661
+ `${As}${s}`,
5560
5662
  JSON.stringify({
5561
5663
  sessionId: e.sessionId,
5562
- messages: e.messages.filter(ht).slice(-ii).map(jr)
5664
+ messages: e.messages.filter(gt).slice(-ai).map(Vr)
5563
5665
  })
5564
5666
  );
5565
5667
  } catch {
5566
5668
  return;
5567
5669
  }
5568
5670
  }
5569
- function qr(s) {
5671
+ function Hr(s) {
5570
5672
  try {
5571
- const e = window.localStorage.getItem(`${it}${s}`);
5673
+ const e = window.localStorage.getItem(`${ot}${s}`);
5572
5674
  if (!e)
5573
5675
  return [];
5574
5676
  const t = JSON.parse(e);
5575
- return Array.isArray(t) ? t.filter(wt) : [];
5677
+ return Array.isArray(t) ? t.filter(Mt) : [];
5576
5678
  } catch {
5577
5679
  return [];
5578
5680
  }
5579
5681
  }
5580
5682
  function V(s, e) {
5581
5683
  try {
5582
- const t = e.filter(wt);
5684
+ const t = e.filter(Mt);
5583
5685
  if (t.length === 0) {
5584
- window.localStorage.removeItem(`${it}${s}`);
5686
+ window.localStorage.removeItem(`${ot}${s}`);
5585
5687
  return;
5586
5688
  }
5587
5689
  window.localStorage.setItem(
5588
- `${it}${s}`,
5690
+ `${ot}${s}`,
5589
5691
  JSON.stringify(t.slice(-25))
5590
5692
  );
5591
5693
  } catch {
5592
5694
  return;
5593
5695
  }
5594
5696
  }
5595
- function vs(s, e) {
5697
+ function Us(s, e) {
5596
5698
  try {
5597
- const t = `${qe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5699
+ const t = `${Oe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5598
5700
  ...o,
5599
5701
  storedAt: Date.now(),
5600
5702
  unloadUrl: n,
@@ -5608,28 +5710,28 @@ function vs(s, e) {
5608
5710
  } catch {
5609
5711
  }
5610
5712
  }
5611
- function os(s, e) {
5713
+ function as(s, e) {
5612
5714
  try {
5613
- if (window.sessionStorage.getItem(`${qe}${s}`) === null)
5715
+ if (window.sessionStorage.getItem(`${Oe}${s}`) === null)
5614
5716
  return;
5615
5717
  } catch {
5616
5718
  return;
5617
5719
  }
5618
- vs(s, e);
5720
+ Us(s, e);
5619
5721
  }
5620
- function Or(s) {
5722
+ function Br(s) {
5621
5723
  try {
5622
- const e = `${qe}${s}`, t = window.sessionStorage.getItem(e);
5724
+ const e = `${Oe}${s}`, t = window.sessionStorage.getItem(e);
5623
5725
  if (window.sessionStorage.removeItem(e), !t)
5624
5726
  return [];
5625
5727
  const n = JSON.parse(t);
5626
- return Array.isArray(n) ? n.flatMap((i) => Lr(i) ? [{
5728
+ return Array.isArray(n) ? n.flatMap((i) => $r(i) ? [{
5627
5729
  ...i.event,
5628
5730
  page: P(),
5629
5731
  rawOutput: {
5630
5732
  pageContextRestarted: !0,
5631
5733
  outcome: "unknown",
5632
- message: xr(location.href),
5734
+ message: Wr(location.href),
5633
5735
  currentUrl: location.href,
5634
5736
  console: [],
5635
5737
  metadata: {
@@ -5646,17 +5748,17 @@ function Or(s) {
5646
5748
  return [];
5647
5749
  }
5648
5750
  }
5649
- function xr(s) {
5751
+ function Wr(s) {
5650
5752
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
5651
5753
  Current URL: ${s}`;
5652
5754
  }
5653
- function Lr(s) {
5755
+ function $r(s) {
5654
5756
  if (!s || typeof s != "object")
5655
5757
  return !1;
5656
5758
  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";
5759
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Mt(t) && t.type === "tool.result";
5658
5760
  }
5659
- function Nr(s, e) {
5761
+ function Fr(s, e) {
5660
5762
  const t = new Set(
5661
5763
  s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
5662
5764
  );
@@ -5665,26 +5767,26 @@ function Nr(s, e) {
5665
5767
  ...e.filter((n) => !t.has(n.callId))
5666
5768
  ];
5667
5769
  }
5668
- function Hr(s) {
5770
+ function jr(s) {
5669
5771
  try {
5670
- window.sessionStorage.removeItem(`${qe}${s}`);
5772
+ window.sessionStorage.removeItem(`${Oe}${s}`);
5671
5773
  } catch {
5672
5774
  return;
5673
5775
  }
5674
5776
  }
5675
- function wt(s) {
5777
+ function Mt(s) {
5676
5778
  if (!s || typeof s != "object")
5677
5779
  return !1;
5678
5780
  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;
5781
+ return e.type === "chat.user_message" ? typeof e.content == "string" && ls(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? ls(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
5782
  }
5681
- function as(s) {
5783
+ function ls(s) {
5682
5784
  if (!s || typeof s != "object")
5683
5785
  return !1;
5684
5786
  const e = s;
5685
5787
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
5686
5788
  }
5687
- function Us(s, e) {
5789
+ function Ds(s, e) {
5688
5790
  if (!Array.isArray(s))
5689
5791
  return;
5690
5792
  const t = s.filter((i) => {
@@ -5692,41 +5794,41 @@ function Us(s, e) {
5692
5794
  return !1;
5693
5795
  const r = i;
5694
5796
  return typeof r.name == "string" && typeof r.mimeType == "string" && typeof r.sizeBytes == "number";
5695
- }), n = e ? t.map((i) => Ds(i, e)) : t;
5797
+ }), n = e ? t.map((i) => qs(i, e)) : t;
5696
5798
  return n.length > 0 ? n : void 0;
5697
5799
  }
5698
- function Ds(s, e) {
5800
+ function qs(s, e) {
5699
5801
  return s.fileUrl?.startsWith("/") ? {
5700
5802
  ...s,
5701
5803
  fileUrl: new URL(s.fileUrl, e).toString()
5702
5804
  } : s;
5703
5805
  }
5704
- function pt(s) {
5705
- return s.type || $r(s.name) || "application/octet-stream";
5806
+ function ft(s) {
5807
+ return s.type || Gr(s.name) || "application/octet-stream";
5706
5808
  }
5707
- function Br(s) {
5708
- qs({
5809
+ function zr(s) {
5810
+ Os({
5709
5811
  name: s.name,
5710
- mimeType: pt(s),
5812
+ mimeType: ft(s),
5711
5813
  sizeBytes: s.size
5712
5814
  });
5713
5815
  }
5714
- function qs(s) {
5715
- const e = Wr(s.name), t = s.mimeType.trim().toLowerCase();
5716
- if (!ti.has(`${e}:${t}`))
5816
+ function Os(s) {
5817
+ const e = Kr(s.name), t = s.mimeType.trim().toLowerCase();
5818
+ if (!ii.has(`${e}:${t}`))
5717
5819
  throw new Error("This attachment type is not supported by the embedded model provider");
5718
- if (s.sizeBytes <= 0 || s.sizeBytes >= Ss)
5820
+ if (s.sizeBytes <= 0 || s.sizeBytes >= Ts)
5719
5821
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
5720
5822
  }
5721
- function Wr(s) {
5823
+ function Kr(s) {
5722
5824
  const e = s.trim().toLowerCase(), t = e.lastIndexOf(".");
5723
5825
  return t >= 0 ? e.slice(t) : "";
5724
5826
  }
5725
- function $r(s) {
5827
+ function Gr(s) {
5726
5828
  const e = s.toLowerCase();
5727
5829
  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
5830
  }
5729
- function Fr(s) {
5831
+ function Qr(s) {
5730
5832
  if (!s || typeof s != "object")
5731
5833
  return null;
5732
5834
  const e = s;
@@ -5744,17 +5846,17 @@ function Fr(s) {
5744
5846
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
5745
5847
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
5746
5848
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
5747
- attachments: Us(e.attachments)?.map(ve),
5849
+ attachments: Ds(e.attachments)?.map(Ue),
5748
5850
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5749
5851
  };
5750
5852
  }
5751
- function jr(s) {
5853
+ function Vr(s) {
5752
5854
  return s.attachments?.length ? {
5753
5855
  ...s,
5754
- attachments: s.attachments.map(ve)
5856
+ attachments: s.attachments.map(Ue)
5755
5857
  } : s;
5756
5858
  }
5757
- function ve(s) {
5859
+ function Ue(s) {
5758
5860
  const {
5759
5861
  dataUrl: e,
5760
5862
  objectUrl: t,
@@ -5768,43 +5870,43 @@ function O(s) {
5768
5870
  const e = s.respondsToUserMessageId;
5769
5871
  return typeof e == "string" && e ? e : null;
5770
5872
  }
5771
- function E(s) {
5873
+ function k(s) {
5772
5874
  const e = s.runId;
5773
5875
  return typeof e == "string" && e ? e : null;
5774
5876
  }
5775
- function zr(s) {
5877
+ function Xr(s) {
5776
5878
  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);
5879
+ 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
5880
  }
5779
- function Os(s) {
5881
+ function xs(s) {
5780
5882
  const e = {};
5781
5883
  try {
5782
5884
  new Headers(s).forEach((t, n) => {
5783
- Object.keys(e).length < It && (e[n] = At(n, t));
5885
+ Object.keys(e).length < Tt && (e[n] = bt(n, t));
5784
5886
  });
5785
5887
  } catch {
5786
5888
  return {};
5787
5889
  }
5788
5890
  return e;
5789
5891
  }
5790
- function At(s, e) {
5791
- return Ws(s) ? Le : W(De(e), si);
5892
+ function bt(s, e) {
5893
+ return $s(s) ? Ne : W(qe(e), ri);
5792
5894
  }
5793
- function Kr(s, e) {
5895
+ function Jr(s, e) {
5794
5896
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
5795
5897
  }
5796
- async function Gr(s, e, t, n) {
5797
- const i = Os(s.headers);
5898
+ async function Yr(s, e, t, n) {
5899
+ const i = xs(s.headers);
5798
5900
  n({
5799
5901
  ...e,
5800
5902
  responseStatus: s.status,
5801
5903
  responseHeaders: i,
5802
- responseBody: await Qr(s),
5904
+ responseBody: await Zr(s),
5803
5905
  durationMs: Date.now() - t
5804
5906
  });
5805
5907
  }
5806
- async function Qr(s) {
5807
- if (!xs(s.headers))
5908
+ async function Zr(s) {
5909
+ if (!Ls(s.headers))
5808
5910
  return;
5809
5911
  let e = null, t = null;
5810
5912
  try {
@@ -5813,7 +5915,7 @@ async function Qr(s) {
5813
5915
  const n = new Promise((a) => {
5814
5916
  t = window.setTimeout(() => {
5815
5917
  e?.cancel(), a("timeout");
5816
- }, ni);
5918
+ }, oi);
5817
5919
  }), i = new TextDecoder();
5818
5920
  let r = "", o = 0;
5819
5921
  for (; ; ) {
@@ -5823,7 +5925,7 @@ async function Qr(s) {
5823
5925
  const { done: l, value: c } = a;
5824
5926
  if (l)
5825
5927
  return W(r + i.decode());
5826
- const u = yt - o;
5928
+ const u = St - o;
5827
5929
  if (c.byteLength > u)
5828
5930
  return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${W(r)}... [truncated]`;
5829
5931
  o += c.byteLength, r += i.decode(c, { stream: !0 });
@@ -5835,45 +5937,45 @@ async function Qr(s) {
5835
5937
  t !== null && window.clearTimeout(t);
5836
5938
  }
5837
5939
  }
5838
- function Vr(s, e) {
5839
- if (xs(new Headers(e)))
5940
+ function eo(s, e) {
5941
+ if (Ls(new Headers(e)))
5840
5942
  try {
5841
5943
  return s.responseType === "" || s.responseType === "text" ? W(s.responseText ?? "") : void 0;
5842
5944
  } catch {
5843
5945
  return;
5844
5946
  }
5845
5947
  }
5846
- function ls(s) {
5948
+ function cs(s) {
5847
5949
  if (typeof s == "string")
5848
5950
  return W(s);
5849
5951
  }
5850
- function Xr(s) {
5952
+ function to(s) {
5851
5953
  return L({
5852
5954
  ...s,
5853
- requestBody: cs(s.requestBody),
5854
- responseBody: cs(s.responseBody)
5955
+ requestBody: us(s.requestBody),
5956
+ responseBody: us(s.responseBody)
5855
5957
  });
5856
5958
  }
5857
- function cs(s) {
5959
+ function us(s) {
5858
5960
  if (typeof s != "string")
5859
5961
  return s;
5860
5962
  const e = s.trim();
5861
5963
  if (!e.startsWith("{") && !e.startsWith("["))
5862
- return De(s);
5964
+ return qe(s);
5863
5965
  try {
5864
5966
  return JSON.stringify(L(JSON.parse(s)));
5865
5967
  } catch {
5866
- return De(s);
5968
+ return qe(s);
5867
5969
  }
5868
5970
  }
5869
- function xs(s) {
5971
+ function Ls(s) {
5870
5972
  if (!s)
5871
5973
  return !1;
5872
5974
  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"));
5975
+ return t !== null && Number.isInteger(n) && n >= 0 && n <= St && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
5874
5976
  }
5875
- function ee(s, e = {}, t) {
5876
- if (Yr(t))
5977
+ function te(s, e = {}, t) {
5978
+ if (no(t))
5877
5979
  return !0;
5878
5980
  const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
5879
5981
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -5888,8 +5990,8 @@ function ee(s, e = {}, t) {
5888
5990
  return !0;
5889
5991
  }
5890
5992
  }
5891
- function Jr(s, e) {
5892
- if (ee(s))
5993
+ function so(s, e) {
5994
+ if (te(s))
5893
5995
  return !0;
5894
5996
  try {
5895
5997
  const t = new URL(s, location.href), n = new URL(e);
@@ -5898,141 +6000,142 @@ function Jr(s, e) {
5898
6000
  return !0;
5899
6001
  }
5900
6002
  }
5901
- function Yr(s) {
6003
+ function no(s) {
5902
6004
  return s instanceof FormData || s instanceof Blob || s instanceof ArrayBuffer || ArrayBuffer.isView(s) || typeof ReadableStream < "u" && s instanceof ReadableStream;
5903
6005
  }
5904
- function Zr(s) {
6006
+ function io(s) {
5905
6007
  const e = {};
5906
6008
  for (const t of s.trim().split(/[\r\n]+/)) {
5907
6009
  const n = t.indexOf(":");
5908
6010
  if (n <= 0)
5909
6011
  continue;
5910
- if (Object.keys(e).length >= It)
6012
+ if (Object.keys(e).length >= Tt)
5911
6013
  break;
5912
6014
  const i = t.slice(0, n).trim();
5913
- e[i] = At(i, t.slice(n + 1).trim());
6015
+ e[i] = bt(i, t.slice(n + 1).trim());
5914
6016
  }
5915
6017
  return e;
5916
6018
  }
5917
- function W(s, e = yt) {
6019
+ function W(s, e = St) {
5918
6020
  return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
5919
6021
  }
5920
- function tt(s) {
6022
+ function st(s) {
5921
6023
  return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
5922
6024
  }
5923
- class Ce extends Error {
6025
+ class Pe extends Error {
5924
6026
  constructor(e, t) {
5925
6027
  super(`${e} (${t})`), this.status = t, this.name = "AttachmentUploadHttpError";
5926
6028
  }
5927
6029
  status;
5928
6030
  }
5929
- async function Ae(s, e) {
6031
+ async function Me(s, e) {
5930
6032
  let t = null;
5931
- for (let n = 0; n < Ft; n += 1)
6033
+ for (let n = 0; n < jt; n += 1)
5932
6034
  try {
5933
6035
  return await s();
5934
6036
  } catch (i) {
5935
- if (t = i, n >= Ft - 1 || !to(i))
6037
+ if (t = i, n >= jt - 1 || !oo(i))
5936
6038
  throw i;
5937
- await eo(n);
6039
+ await ro(n);
5938
6040
  }
5939
6041
  throw t instanceof Error ? t : new Error(e);
5940
6042
  }
5941
- function eo(s) {
6043
+ function ro(s) {
5942
6044
  return new Promise((e) => {
5943
- window.setTimeout(e, ei[s] ?? 0);
6045
+ window.setTimeout(e, ni[s] ?? 0);
5944
6046
  });
5945
6047
  }
5946
- function to(s) {
5947
- return s instanceof Ce ? so(s.status) : s instanceof TypeError;
6048
+ function oo(s) {
6049
+ return s instanceof Pe ? ao(s.status) : s instanceof TypeError;
5948
6050
  }
5949
- function so(s) {
6051
+ function ao(s) {
5950
6052
  return s === 408 || s === 409 || s === 429 || s >= 500;
5951
6053
  }
5952
- function no(s) {
6054
+ function lo(s) {
5953
6055
  return s === 401 || s === 403;
5954
6056
  }
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 = /[),.;\]]+$/;
6057
+ const Ne = "[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
6058
  function L(s) {
5957
- return Ue(s, 0, /* @__PURE__ */ new WeakSet());
6059
+ return De(s, 0, /* @__PURE__ */ new WeakSet());
5958
6060
  }
5959
- function Ue(s, e, t) {
6061
+ function De(s, e, t) {
5960
6062
  if (typeof s == "string")
5961
- return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : De(s);
6063
+ return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : qe(s);
5962
6064
  if (s === null || typeof s != "object")
5963
6065
  return s;
5964
- if (e >= ro)
6066
+ if (e >= uo)
5965
6067
  return "[REDACTED_MAX_DEPTH]";
5966
6068
  if (t.has(s))
5967
6069
  return "[REDACTED_CIRCULAR]";
5968
6070
  if (t.add(s), Array.isArray(s))
5969
- return s.map((i) => Ue(i, e + 1, t));
6071
+ return s.map((i) => De(i, e + 1, t));
5970
6072
  const n = {};
5971
6073
  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);
6074
+ i === "pageContent" ? n[i] = r : $s(i) ? n[i] = Ne : n[i] = i.toLowerCase() === "url" ? mo(r) : De(r, e + 1, t);
5973
6075
  return n;
5974
6076
  }
5975
- function Ws(s) {
6077
+ function $s(s) {
5976
6078
  const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
5977
6079
  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
6080
  }
5979
- function uo(s) {
5980
- return typeof s == "string" ? $s(s) : Ue(s, 0, /* @__PURE__ */ new WeakSet());
6081
+ function mo(s) {
6082
+ return typeof s == "string" ? Fs(s) : De(s, 0, /* @__PURE__ */ new WeakSet());
5981
6083
  }
5982
- function $s(s) {
6084
+ function Fs(s) {
5983
6085
  try {
5984
6086
  const e = new URL(s, location.href);
5985
6087
  for (const t of Array.from(e.searchParams.keys()))
5986
- oo.test(t) && e.searchParams.set(t, F);
6088
+ ho.test(t) && e.searchParams.set(t, F);
5987
6089
  return e.username && (e.username = F), e.password && (e.password = F), e.toString();
5988
6090
  } catch {
5989
- return ho(s);
6091
+ return yo(s);
5990
6092
  }
5991
6093
  }
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}`);
6094
+ function qe(s) {
6095
+ return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${Ne}`);
5994
6096
  }
5995
- function ho(s) {
5996
- return s.replace(Ls, `Bearer ${F}`).replace(Ns, `Basic ${F}`).replace(Hs, F).replace(Bs, (e, t) => `${t}: ${Le}`);
6097
+ function yo(s) {
6098
+ return s.replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${Ne}`);
5997
6099
  }
5998
- function po(s) {
5999
- const e = s.match(co)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6000
- return `${$s(t)}${e}`;
6100
+ function Io(s) {
6101
+ const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6102
+ return `${Fs(t)}${e}`;
6001
6103
  }
6002
- const Ao = Object.freeze({
6003
- init: (s) => Oe.init(s)
6104
+ const Eo = Object.freeze({
6105
+ init: (s) => xe.init(s)
6004
6106
  });
6005
- function Mo(s) {
6006
- return Oe.init(s);
6107
+ function Co(s) {
6108
+ return xe.init(s);
6007
6109
  }
6008
6110
  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,
6111
+ Nt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6112
+ Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6113
+ Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6114
+ qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6115
+ ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6116
+ Eo as PlunoProductAgent,
6117
+ kn as ProductAgentInteractionManager,
6118
+ Ot as ProductAgentQueryController,
6119
+ Ro as ProductAgentRemoteRuntimeClient,
6120
+ xe as ProductAgentSessionEngine,
6121
+ Mn as ProductAgentSessionHistoryManager,
6122
+ Ao as ProductAgentTaskPageTitleController,
6123
+ ee as ProductAgentTokenProviderError,
6124
+ di as calculateReconnectDelay,
6125
+ wo as createLocalStorageInteractionDecisionStorage,
6126
+ Re as createProductAgentQueryState,
6127
+ Co as createProductAgentRuntime,
6128
+ Mo as createProductAgentTaskPageTitleDocument,
6129
+ Eo as default,
6130
+ _n as formatProductAgentTaskPageTitle,
6131
+ Oi as getProductAgentOriginAccessErrorMessage,
6132
+ bo as isProductAgentRuntimeCommand,
6133
+ Tn as mergeProductAgentEntityPages,
6134
+ ke as normalizeProductAgentEntityPage,
6135
+ tt as normalizeProductAgentSessionItems,
6033
6136
  En as readLocalStorageInteractionDecisions,
6034
- fo as resolveProductAgentComposerAction,
6035
- go as resolveProductAgentWidgetPresentation,
6036
- ys as selectProductAgentQueryEntities,
6037
- Br as validateProductAgentProviderInputFile
6137
+ To as resolveProductAgentComposerAction,
6138
+ So as resolveProductAgentWidgetPresentation,
6139
+ Is as selectProductAgentQueryEntities,
6140
+ zr as validateProductAgentProviderInputFile
6038
6141
  };