@pluno/product-agent-web 0.1.197 → 0.1.200

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- const Os = "pluno-product-agent-attachments";
2
- const et = "files";
3
- async function Ls(s) {
4
- const e = await ct();
5
- await Hs(e, "readwrite", (t) => t.put(s));
6
- }
7
- async function xs(s, e) {
8
- const t = await ct();
9
- await ut(t, "readwrite", async (n) => {
10
- const i = await dt(
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(
11
11
  n.get(s)
12
12
  );
13
13
  i && n.put({
@@ -16,28 +16,28 @@ async function xs(s, e) {
16
16
  });
17
17
  });
18
18
  }
19
- async function Ns(s = 864e5) {
20
- const e = await ct(), t = Date.now() - s;
21
- await ut(e, "readwrite", async (n) => {
19
+ async function Gs(s = 864e5) {
20
+ const e = await gt(), t = Date.now() - s;
21
+ await ft(e, "readwrite", async (n) => {
22
22
  const i = n.index("lastUsedAt");
23
- (await dt(i.getAllKeys(IDBKeyRange.upperBound(t)))).forEach((o) => n.delete(o));
23
+ (await mt(i.getAllKeys(IDBKeyRange.upperBound(t)))).forEach((o) => n.delete(o));
24
24
  });
25
25
  }
26
- function ct() {
26
+ function gt() {
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(Os, 1);
28
+ const t = indexedDB.open(js, 1);
29
29
  t.onupgradeneeded = () => {
30
- const i = t.result.createObjectStore(et, { keyPath: "attachmentId" });
30
+ const i = t.result.createObjectStore(st, { 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 Hs(s, e, t) {
36
- return await ut(s, e, async (n) => await dt(t(n)));
35
+ async function Qs(s, e, t) {
36
+ return await ft(s, e, async (n) => await mt(t(n)));
37
37
  }
38
- function ut(s, e, t) {
38
+ function ft(s, e, t) {
39
39
  return new Promise((n, i) => {
40
- const r = s.transaction(et, e), o = r.objectStore(et);
40
+ const r = s.transaction(st, e), o = r.objectStore(st);
41
41
  let a, l = !1;
42
42
  t(o).then((c) => {
43
43
  a = c;
@@ -57,16 +57,16 @@ function ut(s, e, t) {
57
57
  };
58
58
  });
59
59
  }
60
- function dt(s) {
60
+ function mt(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 Bs(s) {
65
+ function Vs(s) {
66
66
  return s !== null && (typeof s == "object" || typeof s == "function");
67
67
  }
68
- function Yt(s, e, t) {
69
- const n = Reflect.get(s, "pluno"), i = Bs(n) ? n : {};
68
+ function us(s, e, t) {
69
+ const n = Reflect.get(s, "pluno"), i = Vs(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 Yt(s, e, t) {
80
80
  }
81
81
  };
82
82
  }
83
- const Ws = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function Mt(s, e) {
83
+ const Xs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
+ function Ct(s, e) {
85
85
  return e ? s.replace(
86
- Ws,
86
+ Xs,
87
87
  (t, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
88
88
  ) : s;
89
89
  }
90
- const Zt = "suggest_share_on_socials";
91
- function $s(s) {
90
+ const ds = "suggest_share_on_socials";
91
+ function Js(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 !== Zt || t.sharePromptAllowed !== void 0)
94
+ if (t.role !== "tool" || t.toolName !== ds || t.sharePromptAllowed !== void 0)
95
95
  continue;
96
- if (js(s, e, t.callId) !== !0)
96
+ if (Zs(s, e, t.callId) !== !0)
97
97
  return null;
98
- const n = bt(s, e, "assistant");
98
+ const n = Pt(s, e, "assistant");
99
99
  if (!n)
100
100
  return null;
101
- const i = bt(s, n.index, "user");
101
+ const i = Pt(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 $s(s) {
107
107
  }
108
108
  return null;
109
109
  }
110
- function Fs(s) {
110
+ function Ys(s) {
111
111
  let e = s;
112
112
  if (typeof s == "string")
113
113
  try {
@@ -115,10 +115,10 @@ function Fs(s) {
115
115
  } catch {
116
116
  return null;
117
117
  }
118
- const t = zs(e);
118
+ const t = en(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 js(s, e, t) {
121
+ function Zs(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 js(s, e, t) {
128
128
  }
129
129
  return null;
130
130
  }
131
- function bt(s, e, t) {
131
+ function Pt(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 bt(s, e, t) {
136
136
  }
137
137
  return null;
138
138
  }
139
- function zs(s) {
139
+ function en(s) {
140
140
  return s && typeof s == "object" && !Array.isArray(s) ? s : null;
141
141
  }
142
- const Ks = "save_runtime_captured_skill";
143
- function Gs(s) {
144
- return (s.type === "function_call" || s.type === "tool_call") && s.name === Ks;
142
+ const tn = "save_runtime_captured_skill";
143
+ function sn(s) {
144
+ return (s.type === "function_call" || s.type === "tool_call") && s.name === tn;
145
145
  }
146
- function Qs(s, e, t) {
146
+ function nn(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 Qs(s, e, t) {
160
160
  )
161
161
  ), c = /* @__PURE__ */ new Map();
162
162
  for (const { item: d, identity: p } of r)
163
- for (const y of p.activityKeys ?? []) {
164
- const g = c.get(y);
165
- (!g || t(g).isTransient) && c.set(y, d);
163
+ for (const m of p.activityKeys ?? []) {
164
+ const g = c.get(m);
165
+ (!g || t(g).isTransient) && c.set(m, 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(), m = [];
169
+ ), f = /* @__PURE__ */ new Set(), y = [];
170
170
  for (const d of s) {
171
171
  const p = t(d);
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 && !f.has(y)) {
174
- m.push(y), f.add(y);
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);
175
175
  continue;
176
176
  }
177
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) && m.push(d);
178
+ (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && g) && y.push(d);
179
179
  }
180
180
  for (const { item: d } of r)
181
- f.has(d) || m.push(d);
182
- return m;
181
+ f.has(d) || y.push(d);
182
+ return y;
183
183
  }
184
- function Vs(s, e, t, n) {
184
+ function _t(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 We = "pluno.productAgent.transportId", Xs = "pluno.productAgent.transportIdentity", $e = "pluno.productAgent.transportIdentity.event", Js = 50, Ys = globalThis.setTimeout.bind(globalThis);
190
+ const Fe = "pluno.productAgent.transportId", rn = "pluno.productAgent.transportIdentity", je = "pluno.productAgent.transportIdentity.event", on = 50, an = globalThis.setTimeout.bind(globalThis);
191
191
  let ae = null;
192
- const Te = /* @__PURE__ */ new Set(), Fe = /* @__PURE__ */ new Map();
193
- async function Zs(s = es()) {
194
- const e = s.randomUUID(), t = s.storage.getItem(We);
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);
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 Zs(s = es()) {
209
209
  }
210
210
  });
211
211
  if (!t)
212
- s.storage.setItem(We, n), i = !0;
212
+ s.storage.setItem(Fe, n), i = !0;
213
213
  else if (s.skipStoredIdentityCollisionCheck)
214
214
  i = !0;
215
215
  else
@@ -218,7 +218,7 @@ async function Zs(s = es()) {
218
218
  i = !0;
219
219
  break;
220
220
  }
221
- n = s.randomUUID(), s.storage.setItem(We, n);
221
+ n = s.randomUUID(), s.storage.setItem(Fe, n);
222
222
  }
223
223
  let a = !1;
224
224
  return {
@@ -228,52 +228,52 @@ async function Zs(s = es()) {
228
228
  }
229
229
  };
230
230
  }
231
- async function en(s = !1) {
232
- ae || (ae = Zs({
233
- ...es(),
231
+ async function cn(s = !1) {
232
+ ae || (ae = ln({
233
+ ...hs(),
234
234
  skipStoredIdentityCollisionCheck: s
235
235
  }), ae.then((i) => {
236
236
  const r = (o) => {
237
- o.persisted || (i.release(), ae = null, Te.clear(), window.removeEventListener("pagehide", r));
237
+ o.persisted || (i.release(), ae = null, Me.clear(), window.removeEventListener("pagehide", r));
238
238
  };
239
239
  window.addEventListener("pagehide", r);
240
240
  }));
241
- const e = await ae, t = tn();
242
- Te.add(t);
241
+ const e = await ae, t = un();
242
+ Me.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, Te.delete(t));
248
+ n || (n = !0, Me.delete(t));
249
249
  }
250
250
  };
251
251
  }
252
- function tn() {
252
+ function un() {
253
253
  let s = 0;
254
- for (; Te.has(s); )
254
+ for (; Me.has(s); )
255
255
  s += 1;
256
256
  return s;
257
257
  }
258
- function es() {
258
+ function hs() {
259
259
  return {
260
- storage: sn(),
261
- channel: nn(),
260
+ storage: dn(),
261
+ channel: hn(),
262
262
  randomUUID: () => crypto.randomUUID(),
263
- settle: () => new Promise((s) => Ys(s, Js))
263
+ settle: () => new Promise((s) => an(s, on))
264
264
  };
265
265
  }
266
- function sn() {
266
+ function dn() {
267
267
  return {
268
268
  getItem: (s) => {
269
269
  try {
270
- return window.sessionStorage?.getItem(s) ?? Fe.get(s) ?? null;
270
+ return window.sessionStorage?.getItem(s) ?? ze.get(s) ?? null;
271
271
  } catch {
272
- return Fe.get(s) ?? null;
272
+ return ze.get(s) ?? null;
273
273
  }
274
274
  },
275
275
  setItem: (s, e) => {
276
- Fe.set(s, e);
276
+ ze.set(s, e);
277
277
  try {
278
278
  window.sessionStorage?.setItem(s, e);
279
279
  } catch {
@@ -281,9 +281,9 @@ function sn() {
281
281
  }
282
282
  };
283
283
  }
284
- function nn() {
284
+ function hn() {
285
285
  if (typeof BroadcastChannel < "u") {
286
- const s = new BroadcastChannel(Xs);
286
+ const s = new BroadcastChannel(rn);
287
287
  return {
288
288
  postMessage: (e) => s.postMessage(e),
289
289
  subscribe: (e) => {
@@ -293,11 +293,11 @@ function nn() {
293
293
  close: () => s.close()
294
294
  };
295
295
  }
296
- return rn();
296
+ return pn();
297
297
  }
298
- function rn() {
298
+ function pn() {
299
299
  const s = /* @__PURE__ */ new Set(), e = (t) => {
300
- if (t.key !== $e || !t.newValue)
300
+ if (t.key !== je || !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 rn() {
306
306
  return window.addEventListener("storage", e), {
307
307
  postMessage: (t) => {
308
308
  window.localStorage.setItem(
309
- $e,
309
+ je,
310
310
  JSON.stringify({ ...t, eventId: crypto.randomUUID() })
311
- ), window.localStorage.removeItem($e);
311
+ ), window.localStorage.removeItem(je);
312
312
  },
313
313
  subscribe: (t) => (s.add(t), () => s.delete(t)),
314
314
  close: () => {
@@ -316,8 +316,8 @@ function rn() {
316
316
  }
317
317
  };
318
318
  }
319
- const ts = "schedule_follow_up";
320
- function on(s) {
319
+ const ps = "schedule_follow_up";
320
+ function gn(s) {
321
321
  let e = s;
322
322
  if (typeof e == "string")
323
323
  try {
@@ -328,48 +328,48 @@ function on(s) {
328
328
  if (!e || typeof e != "object")
329
329
  return null;
330
330
  const t = e;
331
- return t.ok !== !0 || t.toolName !== ts || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? null : {
331
+ return t.ok !== !0 || t.toolName !== ps || 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 an = [
336
+ const fn = [
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
- ], ln = [
340
+ ], mn = [
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
- ], cn = [
344
- ...an,
345
- ...ln
346
- ], je = (s) => cn.some((e) => e.value === s);
347
- function un(s, e) {
343
+ ], yn = [
344
+ ...fn,
345
+ ...mn
346
+ ], Ke = (s) => yn.some((e) => e.value === s);
347
+ function vt(s, e) {
348
348
  return s.filter((t, n) => {
349
- const i = Rt(t);
350
- return ss(i) ? !s.slice(n + 1).some((r) => {
351
- const o = Rt(r);
352
- return ns(i, o) && is(i, o);
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);
353
353
  }) : !0;
354
354
  });
355
355
  }
356
- function ss(s) {
356
+ function gs(s) {
357
357
  return s.type === "run_status" && s.status === "stopped" && s.reason === "task_tab_closed";
358
358
  }
359
- function dn(s, e) {
360
- return s.reason === "task_tab_closed" && is(s, e) && ns(s, e);
359
+ function In(s, e) {
360
+ return s.reason === "task_tab_closed" && ms(s, e) && fs(s, e);
361
361
  }
362
- function Rt(s) {
362
+ function Ut(s) {
363
363
  return s.data && typeof s.data == "object" ? s.data : {};
364
364
  }
365
- function ns(s, e) {
365
+ function fs(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" ? !ss(e) : e.type === "run_error";
367
+ return t && n && t === n ? !1 : e.type === "message" ? e.role === "assistant" : e.type === "run_status" ? !gs(e) : e.type === "run_error";
368
368
  }
369
- function is(s, e) {
369
+ function ms(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 we(s) {
372
+ function be(s) {
373
373
  return {
374
374
  key: s,
375
375
  status: "not_requested",
@@ -379,9 +379,9 @@ function we(s) {
379
379
  updatedAt: null
380
380
  };
381
381
  }
382
- class Et {
382
+ class Dt {
383
383
  constructor(e, t, n = (i, r) => r) {
384
- this.loader = t, this.merge = n, this.state = we(e);
384
+ this.loader = t, this.merge = n, this.state = be(e);
385
385
  }
386
386
  loader;
387
387
  merge;
@@ -396,10 +396,10 @@ class Et {
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 = we(e), this.trailingLoad = null, this.publish());
399
+ e !== this.state.key && (this.state = be(e), this.trailingLoad = null, this.publish());
400
400
  }
401
401
  reset() {
402
- this.state = we(this.state.key), this.trailingLoad = null, this.publish();
402
+ this.state = be(this.state.key), this.trailingLoad = null, this.publish();
403
403
  }
404
404
  invalidate() {
405
405
  this.state = {
@@ -454,7 +454,7 @@ class Et {
454
454
  for (const e of this.listeners) e(this.state);
455
455
  }
456
456
  }
457
- function Ae(s) {
457
+ function Re(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 Ae(s) {
464
464
  nextCursor: s.nextCursor
465
465
  };
466
466
  }
467
- function hn(s, e, t) {
467
+ function Sn(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 rs(s) {
474
+ function ys(s) {
475
475
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
476
476
  }
477
- function lo(s) {
477
+ function go(s) {
478
478
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
479
479
  }
480
- function pn(s, e) {
480
+ function Tn(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 gn(s) {
483
+ function wn(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 co(s) {
488
+ function fo(s) {
489
489
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
490
490
  return s.hasRunningAssistantTurn && !e ? {
491
491
  action: "stop",
@@ -495,20 +495,20 @@ function co(s) {
495
495
  disabled: !e || !s.canSubmitMessage
496
496
  };
497
497
  }
498
- class fn {
498
+ class An {
499
499
  constructor(e, t, n = 20) {
500
- this.loadPage = t, this.limit = n, this.recentQuery = new Et(
500
+ this.loadPage = t, this.limit = n, this.recentQuery = new Dt(
501
501
  `${e}:recent`,
502
- async ({ cursor: i }) => Ae(
502
+ async ({ cursor: i }) => Re(
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
- hn
509
- ), this.pinnedQuery = new Et(
508
+ Sn
509
+ ), this.pinnedQuery = new Dt(
510
510
  `${e}:pinned`,
511
- async () => Ae({
511
+ async () => Re({
512
512
  entities: await this.loadAllPinned(),
513
513
  nextCursor: null
514
514
  })
@@ -528,17 +528,17 @@ class fn {
528
528
  activityReconciliationScheduled = !1;
529
529
  getState() {
530
530
  const e = this.recentQuery.getState(), t = this.pinnedQuery.getState(), n = [
531
- ...ge(t.data),
532
- ...ge(e.data)
531
+ ...ye(t.data),
532
+ ...ye(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 ? Ae({
535
+ ), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ? Re({
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: yn(e, t),
541
+ status: Mn(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 fn {
604
604
  }
605
605
  reconcileDurableEntities() {
606
606
  const e = [
607
- ...ge(this.pinnedQuery.getState().data),
608
- ...ge(this.recentQuery.getState().data)
607
+ ...ye(this.pinnedQuery.getState().data),
608
+ ...ye(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 fn {
644
644
  for (const e of this.listeners) e(this.getState());
645
645
  }
646
646
  }
647
- function ge(s) {
647
+ function ye(s) {
648
648
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
649
649
  }
650
- function yn(s, e) {
650
+ function Mn(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 kt {
653
+ class qt {
654
654
  constructor(e) {
655
655
  this.options = e;
656
656
  }
@@ -694,7 +694,7 @@ class kt {
694
694
  this.schedule(r, e);
695
695
  }
696
696
  }
697
- class mn {
697
+ class bn {
698
698
  constructor(e) {
699
699
  this.options = e;
700
700
  }
@@ -746,10 +746,10 @@ class mn {
746
746
  );
747
747
  }
748
748
  }
749
- class In {
749
+ class Rn {
750
750
  constructor(e, t = null) {
751
751
  this.storage = e, t && (this.decisions = new Map(
752
- t.filter(tt).map((n) => [this.getDecisionKey(n), n])
752
+ t.filter(nt).map((n) => [this.getDecisionKey(n), n])
753
753
  ), this.initialized = !0);
754
754
  }
755
755
  storage;
@@ -761,7 +761,7 @@ class In {
761
761
  if (this.initialized) return;
762
762
  const e = await this.storage.load();
763
763
  this.decisions = new Map(
764
- e.filter(tt).map((t) => [this.getDecisionKey(t), t])
764
+ e.filter(nt).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 In {
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 (!os(t))
802
+ if (!Is(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,51 +825,51 @@ class In {
825
825
  return null;
826
826
  }
827
827
  getDecisionKey(e) {
828
- const t = ze(e.scope);
828
+ const t = Ge(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 `${ze(e.scope)}:interaction:${e.key}`;
832
+ return `${Ge(e.scope)}:interaction:${e.key}`;
833
833
  }
834
834
  getCategoryKey(e) {
835
- return `${ze(e.scope)}:category:${e.category}`;
835
+ return `${Ge(e.scope)}:category:${e.category}`;
836
836
  }
837
837
  }
838
- function uo(s, e) {
838
+ function mo(s, e) {
839
839
  return {
840
- load: async () => Sn(s, e),
840
+ load: async () => En(s, e),
841
841
  save: async (t) => s.setItem(e, JSON.stringify(t))
842
842
  };
843
843
  }
844
- function Sn(s, e) {
844
+ 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(tt) : [];
848
+ return Array.isArray(n) ? n.filter(nt) : [];
849
849
  }
850
- function ze(s) {
850
+ function Ge(s) {
851
851
  return `${s.level}:${s.key}`;
852
852
  }
853
- function os(s) {
853
+ function Is(s) {
854
854
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
855
855
  }
856
- function tt(s) {
856
+ function nt(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") && os(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") && Is(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
860
860
  }
861
- const Tn = {
861
+ const kn = {
862
862
  working: "⏳",
863
863
  completed: "✅",
864
864
  failed: "❗",
865
865
  stopped: "⏹️"
866
- }, wn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
- function An(s, e) {
868
- if (!e) return Ee(s);
869
- const t = Ee(s), n = `${Tn[e]} Pluno`;
866
+ }, Cn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
+ function Pn(s, e) {
868
+ if (!e) return Pe(s);
869
+ const t = Pe(s), n = `${kn[e]} Pluno`;
870
870
  return t ? `${n}: ${t}` : n;
871
871
  }
872
- class ho {
872
+ class yo {
873
873
  constructor(e) {
874
874
  this.titleDocument = e;
875
875
  }
@@ -891,10 +891,10 @@ class ho {
891
891
  }
892
892
  applyStatus(e) {
893
893
  const t = this.titleDocument.getTitle();
894
- t !== this.lastAppliedTitle && (this.baseTitle = Ee(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
894
+ t !== this.lastAppliedTitle && (this.baseTitle = Pe(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 ? Ee(e) : e;
897
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? Pe(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 ho {
903
903
  applyTitle() {
904
904
  if (!this.status)
905
905
  return;
906
- const e = An(this.baseTitle, this.status);
906
+ const e = Pn(this.baseTitle, this.status);
907
907
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
908
908
  }
909
909
  }
910
- function po(s) {
910
+ function Io(s) {
911
911
  return {
912
912
  getTitle: () => s.title,
913
913
  setTitle: (e) => {
@@ -923,10 +923,10 @@ function po(s) {
923
923
  }
924
924
  };
925
925
  }
926
- function Ee(s) {
927
- return s.replace(wn, "");
926
+ function Pe(s) {
927
+ return s.replace(Cn, "");
928
928
  }
929
- function go(s) {
929
+ function So(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 go(s) {
963
963
  return !1;
964
964
  }
965
965
  }
966
- class fo {
966
+ class To {
967
967
  constructor(e, t, n) {
968
- this.adapter = t, this.state = Ke(e), this.model = n;
968
+ this.adapter = t, this.state = Qe(e), this.model = n;
969
969
  }
970
970
  adapter;
971
971
  listeners = {};
@@ -974,7 +974,7 @@ class fo {
974
974
  interactionListeners = /* @__PURE__ */ new Set();
975
975
  accountListeners = /* @__PURE__ */ new Set();
976
976
  state;
977
- sessionHistoryState = we("unavailable");
977
+ sessionHistoryState = be("unavailable");
978
978
  model;
979
979
  interactions = [];
980
980
  account = null;
@@ -986,12 +986,12 @@ class fo {
986
986
  return n.add(t), this.listeners[e] = n, () => n.delete(t);
987
987
  }
988
988
  getState() {
989
- return Ke(this.state);
989
+ return Qe(this.state);
990
990
  }
991
991
  updateProjection(e, t, n, i, r) {
992
992
  if (!this.destroyed) {
993
- if (this.state = Ke(e), t !== void 0 && (this.model = t), n) {
994
- this.sessionHistoryState = vt(n);
993
+ if (this.state = Qe(e), t !== void 0 && (this.model = t), n) {
994
+ this.sessionHistoryState = Ot(n);
995
995
  for (const o of this.sessionHistoryListeners)
996
996
  o(this.getSessionHistoryState());
997
997
  }
@@ -1017,7 +1017,7 @@ class fo {
1017
1017
  }
1018
1018
  }
1019
1019
  warmup(e = "panel_open") {
1020
- return this.dispatch({ type: "runtime.warmup", reason: e }).then(() => {
1020
+ return this.adapter.dispatch({ type: "runtime.warmup", reason: e }).then(() => {
1021
1021
  });
1022
1022
  }
1023
1023
  recordWidgetLifecycle(e, t) {
@@ -1133,12 +1133,12 @@ class fo {
1133
1133
  await this.dispatch({ type: "session.list", ...e });
1134
1134
  const t = this.sessionHistoryState.data;
1135
1135
  return {
1136
- sessions: rs(t),
1136
+ sessions: ys(t),
1137
1137
  nextCursor: t?.nextCursor ?? null
1138
1138
  };
1139
1139
  }
1140
1140
  getSessionHistoryState() {
1141
- return vt(this.sessionHistoryState);
1141
+ return Ot(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 fo {
1217
1217
  for (const i of n ?? []) i(t);
1218
1218
  }
1219
1219
  }
1220
- function Ke(s) {
1220
+ function Qe(s) {
1221
1221
  return {
1222
1222
  ...s,
1223
1223
  starterPrompts: [...s.starterPrompts],
@@ -1238,21 +1238,21 @@ function Ke(s) {
1238
1238
  activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1239
1239
  };
1240
1240
  }
1241
- function vt(s) {
1241
+ function Ot(s) {
1242
1242
  return {
1243
1243
  ...s,
1244
- data: s.data ? Ae({
1245
- entities: rs(s.data).map((e) => ({ ...e })),
1244
+ data: s.data ? Re({
1245
+ entities: ys(s.data).map((e) => ({ ...e })),
1246
1246
  nextCursor: s.data.nextCursor
1247
1247
  }) : null
1248
1248
  };
1249
1249
  }
1250
- const Mn = globalThis.fetch.bind(globalThis), Ct = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', bn = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Rn = ".pluno-pa-widget__panel", En = ".pluno-pa-widget__timeline", kn = "__plunoExtensionWidgetOwner";
1251
- function vn(s) {
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) {
1252
1252
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
1253
1253
  }
1254
- let Cn = 0;
1255
- function Pt(s) {
1254
+ let xn = 0;
1255
+ function Lt(s) {
1256
1256
  const e = {};
1257
1257
  for (const o of [
1258
1258
  "type",
@@ -1290,7 +1290,7 @@ function Pt(s) {
1290
1290
  }
1291
1291
  return e;
1292
1292
  }
1293
- function Ge(s, e, t) {
1293
+ function Ve(s, e, t) {
1294
1294
  if (typeof window > "u")
1295
1295
  return;
1296
1296
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -1302,36 +1302,36 @@ function Ge(s, e, t) {
1302
1302
  source: "web_sdk",
1303
1303
  category: s,
1304
1304
  name: e,
1305
- sequence: ++Cn,
1305
+ sequence: ++xn,
1306
1306
  wallTime: (/* @__PURE__ */ new Date()).toISOString(),
1307
1307
  monotonicMs: performance.now(),
1308
1308
  data: t
1309
1309
  };
1310
1310
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: i }));
1311
1311
  }
1312
- class fe extends Error {
1312
+ class Ie extends Error {
1313
1313
  }
1314
- function Pn(s) {
1314
+ function Ln(s) {
1315
1315
  return s === 408 || s === 425 || s === 429 || s >= 500;
1316
1316
  }
1317
- const _n = "https://app.pluno.ai", Un = 2e4, Dn = 1e4, qn = 1e4, On = 1e4, Ln = 1e4, xn = 3e3, Nn = 3e4, Hn = 1e3, _t = 3e4, Ut = 0.2, Bn = 6e4, Dt = 15e3, Wn = 8, $n = "Browser connection was interrupted.", qt = 15e3, Fn = "Pluno could not send this message. Try it again.", jn = 2e3, zn = 1e3, Kn = 100, Ot = 8e3, Lt = 3, Gn = [300, 1e3], as = 50 * 1024 * 1024, Qn = /* @__PURE__ */ new Set([
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([
1318
1318
  ".jpeg:image/jpeg",
1319
1319
  ".jpg:image/jpeg",
1320
1320
  ".pdf:application/pdf",
1321
1321
  ".png:image/png",
1322
1322
  ".webp:image/webp"
1323
- ]), yo = ".pdf,.png,.jpg,.jpeg,.webp", ht = 64e3, Qe = 4e3, pt = 30, Vn = 2e3, Xn = 1e3, ls = "Image is too large for model vision input.", Jn = 100, cs = "pluno.productAgent.state.", st = "pluno.productAgent.pendingEvents.", Ue = "pluno.productAgent.activeToolCalls.", Yn = 100;
1324
- function Zn(s, e = 0) {
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) {
1325
1325
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1326
1326
  return Math.max(e, t);
1327
1327
  }
1328
- const Me = /* @__PURE__ */ new Set();
1329
- let ye = null;
1330
- function ei(s, e = Math.random) {
1331
- const t = Math.min(_t, Hn * 2 ** s), n = 1 - Ut + e() * Ut * 2;
1332
- return Math.min(_t, Math.round(t * n));
1328
+ 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));
1333
1333
  }
1334
- function ti(s, e, t) {
1334
+ function ci(s, e, t) {
1335
1335
  return new Promise((n, i) => {
1336
1336
  const r = setTimeout(() => i(new Error(t)), e);
1337
1337
  s.then(
@@ -1344,12 +1344,12 @@ function ti(s, e, t) {
1344
1344
  );
1345
1345
  });
1346
1346
  }
1347
- class De {
1347
+ class Oe {
1348
1348
  constructor(e, t) {
1349
- this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new fn(
1349
+ this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new An(
1350
1350
  e.clientId,
1351
1351
  async ({ cursor: r, limit: o, pinned: a }) => await this.listSessions({ cursor: r, limit: o, pinned: a })
1352
- ), this.sessionRecoveryPoller = new kt({
1352
+ ), this.sessionRecoveryPoller = new qt({
1353
1353
  poll: async ({ sessionId: r }) => await this.fetchSessionHistoryPageOnce(
1354
1354
  r,
1355
1355
  "transcript",
@@ -1361,7 +1361,7 @@ class De {
1361
1361
  activeIntervalMs: 3e3,
1362
1362
  idleIntervalMs: 15e3,
1363
1363
  maxFailureIntervalMs: 3e4
1364
- }), this.sessionActivityRecovery = new mn({
1364
+ }), this.sessionActivityRecovery = new bn({
1365
1365
  fetchPage: async (r, o) => await this.fetchSessionHistoryPageOnce(
1366
1366
  r,
1367
1367
  "activity",
@@ -1372,7 +1372,7 @@ class De {
1372
1372
  const o = A(r.session, "id");
1373
1373
  o && this.handleServerEvent({
1374
1374
  type: "session.activity.page",
1375
- requestId: L(),
1375
+ requestId: x(),
1376
1376
  sessionId: o,
1377
1377
  items: r.items,
1378
1378
  nextCursor: r.nextCursor
@@ -1380,24 +1380,24 @@ class De {
1380
1380
  },
1381
1381
  getItemId: (r) => A(r, "id"),
1382
1382
  maxPagesPerPoll: 3
1383
- }), this.sessionActivityRecoveryPoller = new kt({
1383
+ }), this.sessionActivityRecoveryPoller = new qt({
1384
1384
  poll: async ({ sessionId: r }) => await this.sessionActivityRecovery.poll(r),
1385
1385
  apply: async (r) => await this.sessionActivityRecovery.apply(r),
1386
1386
  isActiveTurn: () => this.state.isThinking || this.state.pendingMessageStatus !== null,
1387
1387
  activeIntervalMs: 3e3,
1388
1388
  idleIntervalMs: 15e3,
1389
1389
  maxFailureIntervalMs: 3e4
1390
- }), this.personalModelSelectionOverride = e.productVariant === "personal" && je(e.model) ? e.model : null, this.state = {
1390
+ }), this.personalModelSelectionOverride = e.productVariant === "personal" && Ke(e.model) ? e.model : null, this.state = {
1391
1391
  ...this.state,
1392
- starterPrompts: qi(e.initialStarterPrompts)
1392
+ starterPrompts: $i(e.initialStarterPrompts)
1393
1393
  }, this.account = e.initialAccount ? { ...e.initialAccount } : null;
1394
- const n = e.restorePersistedState === !1 ? null : kr(e.clientId, e.expectedPersistedSessionId);
1394
+ const n = e.restorePersistedState === !1 ? null : Ur(e.clientId, e.expectedPersistedSessionId);
1395
1395
  n && (this.state = {
1396
1396
  ...this.state,
1397
1397
  ...n,
1398
1398
  // Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
1399
1399
  // activity is deliberately not restored here because it hydrates after the transcript is visible.
1400
- messages: n.messages.filter(at),
1400
+ messages: n.messages.filter(ht),
1401
1401
  isLoadingSession: n.sessionId !== null,
1402
1402
  status: "idle",
1403
1403
  user: null,
@@ -1412,14 +1412,14 @@ class De {
1412
1412
  taskStatus: null,
1413
1413
  isRetrying: !1,
1414
1414
  lastError: null
1415
- }), this.queuedClientEvents = Dr(
1416
- Cr(e.clientId),
1417
- Pr(e.clientId)
1415
+ }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Nr(
1416
+ qr(e.clientId),
1417
+ Or(e.clientId)
1418
1418
  );
1419
1419
  const i = [...this.queuedClientEvents].reverse().find(
1420
1420
  (r) => r.type === "chat.user_message" && typeof r.clientMessageId == "string"
1421
1421
  );
1422
- i?.clientMessageId && (this.pendingClientMessageId = i.clientMessageId, this.pendingUserMessageEvent = i, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), Q(e.clientId, this.queuedClientEvents);
1422
+ i?.clientMessageId && (this.pendingClientMessageId = i.clientMessageId, this.pendingUserMessageEvent = i, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), V(e.clientId, this.queuedClientEvents);
1423
1423
  }
1424
1424
  options;
1425
1425
  listeners = {};
@@ -1457,7 +1457,7 @@ class De {
1457
1457
  accountRefresh = null;
1458
1458
  runtimeInteractions = [];
1459
1459
  interactionListeners = /* @__PURE__ */ new Set();
1460
- interactionManager = new In(
1460
+ interactionManager = new Rn(
1461
1461
  { load: async () => [], save: async () => {
1462
1462
  } },
1463
1463
  []
@@ -1480,6 +1480,7 @@ class De {
1480
1480
  backgroundSessionIds = /* @__PURE__ */ new Set();
1481
1481
  backgroundClientMessageIds = /* @__PURE__ */ new Set();
1482
1482
  deferredSessionUpdatedSessionIds = /* @__PURE__ */ new Set();
1483
+ sessionTimelineCache = /* @__PURE__ */ new Map();
1483
1484
  detachedSessionIds = /* @__PURE__ */ new Set();
1484
1485
  detachedClientMessageIds = /* @__PURE__ */ new Set();
1485
1486
  deferredDetachedSessionEvents = /* @__PURE__ */ new Map();
@@ -1543,17 +1544,17 @@ class De {
1543
1544
  lastErrorSecuritySettingsUrl: null
1544
1545
  };
1545
1546
  static async init(e) {
1546
- const t = e, n = await en(
1547
+ const t = e, n = await cn(
1547
1548
  t.skipStoredTransportIdentityCollisionCheck === !0
1548
- ), i = new De({
1549
+ ), i = new Oe({
1549
1550
  ...e,
1550
- backendUrl: Si(e.backendUrl ?? _n),
1551
- clientId: e.clientId ?? Hi(),
1551
+ backendUrl: ki(e.backendUrl ?? Nn),
1552
+ clientId: e.clientId ?? Gi(),
1552
1553
  productVariant: e.productVariant ?? "customer_embedded",
1553
- entrySurface: Ti(e.entrySurface)
1554
+ entrySurface: Ci(e.entrySurface)
1554
1555
  }, n);
1555
1556
  try {
1556
- Ns().catch((r) => {
1557
+ Gs().catch((r) => {
1557
1558
  R("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
1558
1559
  message: r instanceof Error ? r.message : String(r)
1559
1560
  });
@@ -1580,7 +1581,7 @@ class De {
1580
1581
  const t = e.trim();
1581
1582
  if (!t)
1582
1583
  return;
1583
- const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${L()}`;
1584
+ const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${x()}`;
1584
1585
  this.stagedProactiveSuggestionQuestionMessageId = n;
1585
1586
  const i = {
1586
1587
  id: n,
@@ -1600,14 +1601,14 @@ class De {
1600
1601
  this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
1601
1602
  );
1602
1603
  try {
1603
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await ti(this.options.tokenProvider(), qn, "Pluno token provider timed out") : null), e !== this.connectionAttemptId || this.state.status === "closed")
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")
1604
1605
  return;
1605
1606
  if (!this.token && !this.options.webSocketFactory)
1606
1607
  throw new Error("Pluno requires a token or tokenProvider");
1607
- const t = Mi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1608
+ const t = vi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1608
1609
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
1609
1610
  this.socket === n && n.readyState === WebSocket.CONNECTING && (R("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
1610
- }, On), n.addEventListener("open", () => {
1611
+ }, $n), n.addEventListener("open", () => {
1611
1612
  this.socket !== n || (this.clearSocketConnectTimer(), R("web-sdk.agent", "Pluno socket opened", {
1612
1613
  queuedClientEventCount: this.queuedClientEvents.length,
1613
1614
  isThinking: this.state.isThinking
@@ -1619,16 +1620,16 @@ class De {
1619
1620
  pageUrl: location.href
1620
1621
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
1621
1622
  this.socket === n && (R("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
1622
- }, Ln));
1623
+ }, Fn));
1623
1624
  }), n.addEventListener("message", (i) => {
1624
- this.socket === n && this.handleServerEvent(Ui(i.data));
1625
+ this.socket === n && this.handleServerEvent(Bi(i.data));
1625
1626
  }), n.addEventListener("sendfailure", (i) => {
1626
1627
  if (this.socket !== n)
1627
1628
  return;
1628
- const r = Di(i?.detail?.data);
1629
+ const r = Wi(i?.detail?.data);
1629
1630
  r?.type === "chat.user_message" && r.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
1630
1631
  (o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
1631
- ) && (this.queuedClientEvents.push(r), Q(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();
1632
+ ) && (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();
1632
1633
  }), n.addEventListener("close", (i) => {
1633
1634
  this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (R("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
1634
1635
  code: typeof i?.code == "number" ? i.code : null,
@@ -1661,16 +1662,16 @@ class De {
1661
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;
1662
1663
  }
1663
1664
  destroy() {
1664
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), qr(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();
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();
1665
1666
  for (const e of Object.values(this.listeners))
1666
1667
  e?.clear();
1667
1668
  this.accountListeners.clear(), this.interactionListeners.clear();
1668
1669
  }
1669
1670
  warmup(e = "panel_open") {
1670
- const t = v(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
1671
+ const t = P(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
1671
1672
  type: "runtime.warmup",
1672
1673
  reason: e,
1673
- ...e === "composer_input" ? { warmupId: i?.event.warmupId ?? L() } : {},
1674
+ ...e === "composer_input" ? { warmupId: i?.event.warmupId ?? x() } : {},
1674
1675
  entrySurface: this.options.entrySurface,
1675
1676
  sessionId: this.state.sessionId ?? void 0,
1676
1677
  page: t,
@@ -1694,24 +1695,24 @@ class De {
1694
1695
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1695
1696
  entrySurface: this.options.entrySurface,
1696
1697
  ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
1697
- pageOrigin: v().origin
1698
+ pageOrigin: P().origin
1698
1699
  }
1699
1700
  };
1700
1701
  this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
1701
1702
  }
1702
1703
  async sendMessage(e, t = {}) {
1703
1704
  const n = e.trim(), i = t.attachments ?? [];
1704
- if (this.options.productVariant === "customer_embedded" && (i.forEach(Rs), i.reduce(
1705
+ if (this.options.productVariant === "customer_embedded" && (i.forEach(qs), i.reduce(
1705
1706
  (T, N) => T + N.sizeBytes,
1706
1707
  0
1707
- ) > as))
1708
+ ) > Ss))
1708
1709
  throw new Error("Embedded attachments must total at most 50 MB per message");
1709
- let r = i.map(Ce);
1710
+ let r = i.map(ve);
1710
1711
  if (!n && r.length === 0)
1711
1712
  return null;
1712
1713
  if (this.pendingClientMessageId)
1713
1714
  throw new Error("Wait for the current message to finish sending before sending another.");
1714
- const o = v(), a = t.clientMessageId ?? L(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
1715
+ const o = P(), a = t.clientMessageId ?? x(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
1715
1716
  (S) => S.id === this.stagedProactiveSuggestionQuestionMessageId
1716
1717
  ) ?? null : null, u = l ? {
1717
1718
  id: `local-proactive-suggestion-question-${a}`,
@@ -1725,7 +1726,7 @@ class De {
1725
1726
  content: n,
1726
1727
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1727
1728
  ...i.length > 0 ? { attachments: i } : {}
1728
- }, f = this.state.messages.some((S) => S.id === h.id || S.clientMessageId === a), m = this.state.isThinking, d = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, g = this.state.messages, M = f ? this.state.messages : [
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 : [
1729
1730
  ...this.state.messages.map(
1730
1731
  (S) => c && S.id === c.id ? {
1731
1732
  ...S,
@@ -1744,7 +1745,7 @@ class De {
1744
1745
  };
1745
1746
  this.setState({
1746
1747
  messages: M,
1747
- ...m ? {} : {
1748
+ ...y ? {} : {
1748
1749
  assistantDraft: "",
1749
1750
  assistantDraftItemId: null,
1750
1751
  assistantDraftPhase: null,
@@ -1752,8 +1753,8 @@ class De {
1752
1753
  assistantDraftRunId: null
1753
1754
  },
1754
1755
  pendingMessageStatus: "sending",
1755
- turnPhase: m ? y : "sending",
1756
- isThinking: m,
1756
+ turnPhase: y ? m : "sending",
1757
+ isThinking: y,
1757
1758
  taskStatus: "working",
1758
1759
  isRetrying: !1,
1759
1760
  lastError: null
@@ -1785,9 +1786,9 @@ class De {
1785
1786
  } catch (S) {
1786
1787
  throw f || this.sessionHistoryManager.removeOptimistic(h.id), this.setState({
1787
1788
  ...f ? {} : { messages: g },
1788
- ...m ? {} : { ...w, isThinking: !1 },
1789
+ ...y ? {} : { ...w, isThinking: !1 },
1789
1790
  pendingMessageStatus: p,
1790
- turnPhase: y,
1791
+ turnPhase: m,
1791
1792
  taskStatus: d
1792
1793
  }), S;
1793
1794
  }
@@ -1797,15 +1798,15 @@ class De {
1797
1798
  sessionId: this.state.sessionId ?? void 0,
1798
1799
  clientMessageId: a,
1799
1800
  initiatedBy: t.initiatedBy,
1800
- invocation: wi(t.invocation ?? t.initiatedBy),
1801
+ invocation: Pi(t.invocation ?? t.initiatedBy),
1801
1802
  entrySurface: this.options.entrySurface,
1802
1803
  content: n,
1803
1804
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1804
- pageContent: D && gt() || void 0,
1805
- attachments: r.length > 0 ? r.map(Ce) : void 0,
1805
+ pageContent: D && St() || void 0,
1806
+ attachments: r.length > 0 ? r.map(ve) : void 0,
1806
1807
  page: o,
1807
1808
  model: this.options.model,
1808
- metadata: xt(this.options.metadata)
1809
+ metadata: jt(this.options.metadata)
1809
1810
  };
1810
1811
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1811
1812
  }
@@ -1813,7 +1814,7 @@ class De {
1813
1814
  return this.options.model;
1814
1815
  }
1815
1816
  setModel(e) {
1816
- this.options.model = e, this.options.productVariant === "personal" && je(e) && (this.personalModelSelectionOverride = e);
1817
+ this.options.model = e, this.options.productVariant === "personal" && Ke(e) && (this.personalModelSelectionOverride = e);
1817
1818
  }
1818
1819
  retryLastMessage() {
1819
1820
  const e = this.state.sessionId, t = this.retryableClientMessageId;
@@ -1831,22 +1832,22 @@ class De {
1831
1832
  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;
1832
1833
  }
1833
1834
  createLocalAttachment(e) {
1834
- this.options.productVariant === "customer_embedded" && Or(e);
1835
- const t = L(), n = {
1835
+ this.options.productVariant === "customer_embedded" && Br(e);
1836
+ const t = x(), n = {
1836
1837
  id: t,
1837
1838
  name: e.name || "attachment",
1838
- mimeType: lt(e),
1839
+ mimeType: pt(e),
1839
1840
  sizeBytes: e.size
1840
1841
  };
1841
1842
  this.attachmentFiles.set(t, e);
1842
1843
  const i = Date.now();
1843
- return Ls({
1844
+ return zs({
1844
1845
  attachmentId: t,
1845
1846
  name: n.name,
1846
1847
  mimeType: n.mimeType,
1847
1848
  sizeBytes: n.sizeBytes,
1848
1849
  blob: e,
1849
- origin: v().origin,
1850
+ origin: P().origin,
1850
1851
  sessionId: this.state.sessionId ?? void 0,
1851
1852
  createdAt: i,
1852
1853
  lastUsedAt: i
@@ -1869,7 +1870,7 @@ class De {
1869
1870
  file: e,
1870
1871
  attachment: t
1871
1872
  }) {
1872
- const n = this.state.sessionId, i = lt(e), r = {
1873
+ const n = this.state.sessionId, i = pt(e), r = {
1873
1874
  sessionId: n ?? void 0,
1874
1875
  attachmentId: t.id,
1875
1876
  clientId: this.options.clientId,
@@ -1877,36 +1878,36 @@ class De {
1877
1878
  name: e.name || "attachment",
1878
1879
  mimeType: i,
1879
1880
  sizeBytes: e.size,
1880
- page: v(),
1881
+ page: P(),
1881
1882
  model: this.options.model,
1882
- metadata: xt(this.options.metadata),
1883
+ metadata: jt(this.options.metadata),
1883
1884
  entrySurface: this.options.entrySurface
1884
1885
  };
1885
1886
  let o;
1886
1887
  if (this.options.persistAttachmentUpload)
1887
- o = await Se(
1888
+ o = await Ae(
1888
1889
  () => this.options.persistAttachmentUpload(r, e),
1889
1890
  "Failed to upload attachment"
1890
1891
  );
1891
1892
  else {
1892
- const l = this.options.prepareAttachmentUpload ? await Se(
1893
+ const l = this.options.prepareAttachmentUpload ? await Ae(
1893
1894
  () => this.options.prepareAttachmentUpload(r),
1894
1895
  "Failed to prepare attachment upload"
1895
1896
  ) : await this.prepareEmbedAttachmentUpload(r);
1896
- await Se(async () => {
1897
+ await Ae(async () => {
1897
1898
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
1898
1899
  method: l.uploadMethod,
1899
1900
  headers: l.uploadHeaders,
1900
1901
  body: e
1901
1902
  });
1902
1903
  if (!c.ok)
1903
- throw new Re("Failed to upload attachment", c.status);
1904
+ throw new Ce("Failed to upload attachment", c.status);
1904
1905
  return c;
1905
1906
  }, "Failed to upload attachment"), o = l;
1906
1907
  }
1907
1908
  this.setState({ sessionId: o.sessionId });
1908
- const a = bs(o.attachment, this.options.backendUrl);
1909
- return this.updateAttachmentInState(t.id, a), t.id && xs(t.id, {
1909
+ const a = Ds(o.attachment, this.options.backendUrl);
1910
+ return this.updateAttachmentInState(t.id, a), t.id && Ks(t.id, {
1910
1911
  sessionId: o.sessionId,
1911
1912
  fileUrl: a.fileUrl,
1912
1913
  sandboxPath: a.sandboxPath,
@@ -1933,18 +1934,18 @@ class De {
1933
1934
  }
1934
1935
  async prepareEmbedAttachmentUpload(e) {
1935
1936
  let t = !1;
1936
- return await Se(async () => {
1937
+ return await Ae(async () => {
1937
1938
  const n = await this.fetchEmbedAttachmentUpload(e);
1938
1939
  if (n.ok)
1939
1940
  return await n.json();
1940
- if (Yr(n.status) && this.options.tokenProvider && !t) {
1941
+ if (no(n.status) && this.options.tokenProvider && !t) {
1941
1942
  t = !0;
1942
1943
  const i = await this.fetchEmbedAttachmentUpload(e);
1943
1944
  if (i.ok)
1944
1945
  return await i.json();
1945
- throw new Re("Failed to prepare attachment upload", i.status);
1946
+ throw new Ce("Failed to prepare attachment upload", i.status);
1946
1947
  }
1947
- throw new Re("Failed to prepare attachment upload", n.status);
1948
+ throw new Ce("Failed to prepare attachment upload", n.status);
1948
1949
  }, "Failed to prepare attachment upload");
1949
1950
  }
1950
1951
  async fetchEmbedAttachmentUpload(e) {
@@ -1962,7 +1963,7 @@ class De {
1962
1963
  if (!this.state.sessionId)
1963
1964
  return;
1964
1965
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
1965
- const e = yr(
1966
+ const e = Ar(
1966
1967
  this.state.messages,
1967
1968
  this.state.assistantDraftRespondsToUserMessageId,
1968
1969
  this.state.assistantDraftRunId,
@@ -1977,7 +1978,7 @@ class De {
1977
1978
  stoppedCausalSequence: null,
1978
1979
  toolCallIds: new Set(
1979
1980
  this.state.messages.filter(
1980
- (t) => Ye(
1981
+ (t) => we(
1981
1982
  t,
1982
1983
  e.respondsToUserMessageId,
1983
1984
  e.runId
@@ -1987,8 +1988,8 @@ class De {
1987
1988
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
1988
1989
  for (const [t, n] of this.activeBrowserToolCalls)
1989
1990
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
1990
- Qt(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
1991
- messages: Kt(
1991
+ os(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
1992
+ messages: ns(
1992
1993
  this.state.messages,
1993
1994
  e.clientMessageId,
1994
1995
  e.runId
@@ -2009,7 +2010,7 @@ class De {
2009
2010
  type: "session.reset",
2010
2011
  sessionId: this.state.sessionId ?? void 0,
2011
2012
  warmupId: n ?? void 0,
2012
- page: v()
2013
+ page: P()
2013
2014
  }), this.setState({
2014
2015
  sessionId: null,
2015
2016
  starterPrompts: [...this.state.starterPrompts],
@@ -2029,15 +2030,15 @@ class De {
2029
2030
  });
2030
2031
  }
2031
2032
  listSessions(e = {}) {
2032
- const t = L(), n = new Promise((r, o) => {
2033
+ const t = x(), n = new Promise((r, o) => {
2033
2034
  const a = window.setTimeout(() => {
2034
2035
  this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
2035
- }, Ot);
2036
+ }, $t);
2036
2037
  this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
2037
2038
  }), i = {
2038
2039
  type: "sessions.list",
2039
2040
  requestId: t,
2040
- page: v(),
2041
+ page: P(),
2041
2042
  ...e.cursor ? { cursor: e.cursor } : {},
2042
2043
  ...e.limit ? { limit: e.limit } : {},
2043
2044
  ...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
@@ -2065,7 +2066,7 @@ class De {
2065
2066
  const n = this.sessionHistoryManager.getEntity(e)?.isPinned === !0, i = this.sessionHistoryManager.setPinned(e, t);
2066
2067
  return this.sendSessionMutation(
2067
2068
  this.pendingSessionPinRequests,
2068
- { type: "session.pin", requestId: L(), sessionId: e, pinned: t },
2069
+ { type: "session.pin", requestId: x(), sessionId: e, pinned: t },
2069
2070
  "Session pin did not respond in time"
2070
2071
  ).then(() => {
2071
2072
  this.sessionHistoryManager.confirmPinned(e, i), this.sessionHistoryManager.refresh();
@@ -2077,7 +2078,7 @@ class De {
2077
2078
  const n = this.sessionHistoryManager.getEntity(e)?.customTitle ?? null;
2078
2079
  return this.sessionHistoryManager.setTitle(e, t), this.sendSessionMutation(
2079
2080
  this.pendingSessionRenameRequests,
2080
- { type: "session.rename", requestId: L(), sessionId: e, title: t },
2081
+ { type: "session.rename", requestId: x(), sessionId: e, title: t },
2081
2082
  "Session rename did not respond in time"
2082
2083
  ).then(() => {
2083
2084
  this.sessionHistoryManager.confirmTitle(e), this.sessionHistoryManager.refresh();
@@ -2097,7 +2098,7 @@ class De {
2097
2098
  throw new Error("This interaction is no longer available.");
2098
2099
  if (!r.allowedActions.includes(t))
2099
2100
  throw new Error("This action is not available for the interaction.");
2100
- if (vn(t) && await this.interactionManager.act(
2101
+ if (On(t) && await this.interactionManager.act(
2101
2102
  {
2102
2103
  key: r.id,
2103
2104
  category: r.category,
@@ -2146,7 +2147,7 @@ class De {
2146
2147
  this.rebuildRuntimeInteractions();
2147
2148
  }
2148
2149
  rebuildRuntimeInteractions() {
2149
- const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? $s(this.state.messages) : null;
2150
+ const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? Js(this.state.messages) : null;
2150
2151
  if (t) {
2151
2152
  const r = {
2152
2153
  key: t.id,
@@ -2270,24 +2271,28 @@ class De {
2270
2271
  }), this.accountRefresh) : Promise.resolve();
2271
2272
  }
2272
2273
  loadSession(e) {
2273
- const t = L(), n = this.activeComposerWarmupId;
2274
+ const t = x(), n = this.activeComposerWarmupId;
2275
+ 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 ?? []);
2274
2277
  !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({
2275
2278
  type: "session.reset",
2276
2279
  warmupId: n,
2277
- page: v()
2280
+ page: P()
2278
2281
  }), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.options.productVariant === "personal" && this.state.sessionId !== e && (this.personalModelSelectionOverride = null, this.options.model = void 0), this.clearSessionLoadRequest(), this.sessionLoadRequestId = t, this.sessionActivityRequestId = null, this.setState({
2279
2282
  sessionId: e,
2280
- messages: [],
2283
+ // A session-keyed timeline can render immediately while the subscription handshake and authoritative
2284
+ // history reload preserve the live-event race guarantees for this selected chat.
2285
+ messages: i ?? [],
2281
2286
  activeScheduledFollowUps: null,
2282
2287
  isLoadingSession: !0,
2283
- assistantDraft: "",
2284
- assistantDraftItemId: null,
2285
- assistantDraftPhase: null,
2286
- assistantDraftRespondsToUserMessageId: null,
2287
- assistantDraftRunId: null,
2288
+ assistantDraft: r?.content ?? "",
2289
+ assistantDraftItemId: r?.id ?? null,
2290
+ assistantDraftPhase: r?.phase ?? null,
2291
+ assistantDraftRespondsToUserMessageId: r?.respondsToUserMessageId ?? null,
2292
+ assistantDraftRunId: r?.runId ?? null,
2288
2293
  pendingMessageStatus: null,
2289
- isThinking: !1,
2290
- taskStatus: null,
2294
+ isThinking: o,
2295
+ taskStatus: o ? "working" : null,
2291
2296
  isRetrying: !1,
2292
2297
  lastError: null,
2293
2298
  lastErrorCode: null
@@ -2295,7 +2300,7 @@ class De {
2295
2300
  type: "session.load",
2296
2301
  requestId: t,
2297
2302
  sessionId: e,
2298
- page: v()
2303
+ page: P()
2299
2304
  });
2300
2305
  }
2301
2306
  canLoadSessionHistoryOverHttp() {
@@ -2334,21 +2339,21 @@ class De {
2334
2339
  }
2335
2340
  subscribeToSessionBeforeHistory(e) {
2336
2341
  this.pendingSessionSubscription?.resolve(!1);
2337
- const t = L(), n = new Promise((i) => {
2342
+ const t = x(), n = new Promise((i) => {
2338
2343
  this.pendingSessionSubscription = { requestId: t, sessionId: e, resolve: i };
2339
2344
  });
2340
2345
  return this.send({
2341
2346
  type: "session.load",
2342
2347
  requestId: t,
2343
2348
  sessionId: e,
2344
- page: v(),
2349
+ page: P(),
2345
2350
  subscribeOnly: !0
2346
2351
  }), n;
2347
2352
  }
2348
2353
  async autoLoadSessionActivity(e) {
2349
2354
  let t = null;
2350
2355
  do {
2351
- const n = L();
2356
+ const n = x();
2352
2357
  this.sessionActivityRequestId = n;
2353
2358
  let i;
2354
2359
  try {
@@ -2374,7 +2379,7 @@ class De {
2374
2379
  try {
2375
2380
  return await this.fetchSessionHistoryPageOnce(e, t, n);
2376
2381
  } catch (o) {
2377
- if (o instanceof fe)
2382
+ if (o instanceof Ie)
2378
2383
  throw o;
2379
2384
  R("web-sdk.history", "HTTP session history page failed; retrying", {
2380
2385
  sessionId: e,
@@ -2388,7 +2393,7 @@ class De {
2388
2393
  async fetchSessionHistoryPageOnce(e, t, n, i = !1) {
2389
2394
  const r = this.options.token ?? (i ? this.token : null) ?? await this.options.tokenProvider?.() ?? this.token;
2390
2395
  if (!r)
2391
- throw new fe("Product Agent history requires authentication");
2396
+ throw new Ie("Product Agent history requires authentication");
2392
2397
  this.token = r;
2393
2398
  const o = new URLSearchParams({ limit: "200" });
2394
2399
  n && o.set("cursor", n);
@@ -2402,11 +2407,11 @@ class De {
2402
2407
  });
2403
2408
  if (!c.ok) {
2404
2409
  const h = await c.text() || `History request failed (${c.status})`;
2405
- throw Pn(c.status) ? new Error(h) : new fe(h);
2410
+ throw Ln(c.status) ? new Error(h) : new Ie(h);
2406
2411
  }
2407
2412
  const u = await c.json();
2408
2413
  if (!u?.session || !Array.isArray(u.items))
2409
- throw new fe("Invalid Product Agent session history response");
2414
+ throw new Ie("Invalid Product Agent session history response");
2410
2415
  return {
2411
2416
  session: u.session,
2412
2417
  items: u.items,
@@ -2437,9 +2442,9 @@ class De {
2437
2442
  });
2438
2443
  }
2439
2444
  send(e) {
2440
- this.sendNow(x(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
2445
+ this.sendNow(L(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
2441
2446
  (i) => i.type === "chat.user_message" && i.clientMessageId === e.clientMessageId
2442
- ) || this.queuedClientEvents.push(e), Q(this.options.clientId, this.queuedClientEvents), this.setState({
2447
+ ) || this.queuedClientEvents.push(e), V(this.options.clientId, this.queuedClientEvents), this.setState({
2443
2448
  status: "reconnecting",
2444
2449
  ...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
2445
2450
  }), this.scheduleReconnect());
@@ -2455,7 +2460,7 @@ class De {
2455
2460
  return !1;
2456
2461
  const t = this.socket;
2457
2462
  try {
2458
- return t.send(JSON.stringify(e)), Ge("client_event", e.type, Pt(e)), !0;
2463
+ return t.send(JSON.stringify(e)), Ve("client_event", e.type, Lt(e)), !0;
2459
2464
  } catch (n) {
2460
2465
  return R("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2461
2466
  message: n instanceof Error ? n.message : String(n),
@@ -2499,9 +2504,9 @@ class De {
2499
2504
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
2500
2505
  return;
2501
2506
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
2502
- const e = bi();
2507
+ const e = Ui();
2503
2508
  this.sendNow(
2504
- x({
2509
+ L({
2505
2510
  type: "starter_prompts.page_context",
2506
2511
  pageUrl: e.pageUrl,
2507
2512
  pageTitle: e.pageTitle,
@@ -2510,13 +2515,13 @@ class De {
2510
2515
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
2511
2516
  }
2512
2517
  startStarterPromptUrlWatcher() {
2513
- this.locationChangeCleanup || (this.locationChangeCleanup = Ri(() => this.handleStarterPromptUrlChange()));
2518
+ this.locationChangeCleanup || (this.locationChangeCleanup = Di(() => this.handleStarterPromptUrlChange()));
2514
2519
  }
2515
2520
  handleStarterPromptUrlChange() {
2516
2521
  const e = location.href;
2517
2522
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
2518
2523
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
2519
- }, Yn));
2524
+ }, oi));
2520
2525
  }
2521
2526
  refreshStarterPromptsForCurrentUrl() {
2522
2527
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -2531,18 +2536,31 @@ class De {
2531
2536
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
2532
2537
  return;
2533
2538
  const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
2534
- Q(this.options.clientId, this.queuedClientEvents);
2539
+ V(this.options.clientId, this.queuedClientEvents);
2535
2540
  for (let t = 0; t < e.length; t += 1) {
2536
2541
  const n = e[t];
2537
- if (!this.sendNow(x(n))) {
2538
- this.queuedClientEvents.unshift(n, ...e.slice(t + 1)), Q(this.options.clientId, this.queuedClientEvents);
2542
+ if (!this.sendNow(L(n))) {
2543
+ this.queuedClientEvents.unshift(n, ...e.slice(t + 1)), V(this.options.clientId, this.queuedClientEvents);
2539
2544
  return;
2540
2545
  }
2541
- Q(this.options.clientId, this.queuedClientEvents);
2546
+ V(this.options.clientId, this.queuedClientEvents);
2542
2547
  }
2543
2548
  }
2544
2549
  resetForAuthenticationScopeChange() {
2545
- this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], Q(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
2550
+ this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], V(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear(), this.sessionTimelineCache.clear();
2551
+ }
2552
+ rememberSessionTimeline(e, t) {
2553
+ const n = [...t];
2554
+ for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > ri; ) {
2555
+ const i = this.sessionTimelineCache.keys().next().value;
2556
+ if (!i)
2557
+ break;
2558
+ this.sessionTimelineCache.delete(i);
2559
+ }
2560
+ }
2561
+ getCachedSessionTimeline(e) {
2562
+ const t = this.sessionTimelineCache.get(e);
2563
+ return t ? (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, t), [...t]) : null;
2546
2564
  }
2547
2565
  flushPendingWidgetLifecycleEvents() {
2548
2566
  if (this.authenticatedSocket !== this.socket || this.socket?.readyState !== WebSocket.OPEN || this.pendingWidgetLifecycleEvents.length === 0)
@@ -2563,8 +2581,8 @@ class De {
2563
2581
  return;
2564
2582
  this.clearPendingWarmupAckTimer();
2565
2583
  const t = Math.min(
2566
- xn * 2 ** e.retryAttempt,
2567
- Nn
2584
+ jn * 2 ** e.retryAttempt,
2585
+ zn
2568
2586
  );
2569
2587
  e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
2570
2588
  this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
@@ -2577,15 +2595,15 @@ class De {
2577
2595
  return [...this.stoppedTurns].reverse().find((o) => o.sessionId !== e ? !1 : i && o.respondsToUserMessageId ? i === o.respondsToUserMessageId : n && o.clientMessageId ? n === o.clientMessageId : !!(r && o.runId && r === o.runId)) ?? null;
2578
2596
  }
2579
2597
  findStoppedTurnForEvent(e) {
2580
- const t = e.type === "session.item" ? P(e.item) : null;
2598
+ const t = e.type === "session.item" ? C(e.item) : null;
2581
2599
  return this.findStoppedTurn(
2582
- G(e) ?? this.state.sessionId,
2600
+ K(e) ?? this.state.sessionId,
2583
2601
  t ?? e
2584
2602
  );
2585
2603
  }
2586
2604
  rememberDurablyStoppedTurn(e, t) {
2587
- const n = P(t);
2588
- if (!e || !n || !be(n) || this.findStoppedTurn(e, n))
2605
+ const n = C(t);
2606
+ if (!e || !n || !ke(n) || this.findStoppedTurn(e, n))
2589
2607
  return;
2590
2608
  const i = O(n), r = E(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
2591
2609
  this.stoppedTurns.push({
@@ -2596,10 +2614,10 @@ class De {
2596
2614
  reason: A(n, "reason"),
2597
2615
  stoppedItemId: A(t, "id"),
2598
2616
  stoppedAt: A(t, "createdAt"),
2599
- stoppedCausalSequence: C(n),
2617
+ stoppedCausalSequence: _(n),
2600
2618
  toolCallIds: new Set(
2601
2619
  this.state.messages.filter(
2602
- (a) => Ye(a, i, r)
2620
+ (a) => we(a, i, r)
2603
2621
  ).map((a) => a.callId).filter((a) => typeof a == "string")
2604
2622
  )
2605
2623
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -2608,7 +2626,7 @@ class De {
2608
2626
  if (!e || !t)
2609
2627
  return;
2610
2628
  const n = this.findStoppedTurn(e, t);
2611
- !n || n.reason !== "task_tab_closed" || dn(n, t) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
2629
+ !n || n.reason !== "task_tab_closed" || In(n, t) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
2612
2630
  messages: this.state.messages.filter((i) => i.id !== n.stoppedItemId)
2613
2631
  }));
2614
2632
  }
@@ -2617,15 +2635,15 @@ class De {
2617
2635
  const n = typeof e.callId == "string" ? e.callId : null;
2618
2636
  return !!(n && this.stoppedTurns.some((i) => i.toolCallIds.has(n)));
2619
2637
  }
2620
- return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !be(P(e.item)) : e.type !== "conversation.state" : !1;
2638
+ return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !ke(C(e.item)) : e.type !== "conversation.state" : !1;
2621
2639
  }
2622
2640
  filterStoppedSnapshotItems(e, t) {
2623
2641
  return e.filter((n) => {
2624
- const i = P(n), r = i ? this.findStoppedTurn(t, i) : null;
2625
- if (!r || i?.type === "message" && i.role === "user" || be(i))
2642
+ const i = C(n), r = i ? this.findStoppedTurn(t, i) : null;
2643
+ if (!r || i?.type === "message" && i.role === "user" || ke(i))
2626
2644
  return !0;
2627
2645
  if (r.stoppedCausalSequence !== null) {
2628
- const o = i ? C(i) : null;
2646
+ const o = i ? _(i) : null;
2629
2647
  return o === null || o <= r.stoppedCausalSequence;
2630
2648
  }
2631
2649
  if (r.stoppedAt) {
@@ -2636,7 +2654,7 @@ class De {
2636
2654
  });
2637
2655
  }
2638
2656
  handleServerEvent(e) {
2639
- if (Ge("server_event", e.type, Pt(e)), e.type === "session.subscribed") {
2657
+ if (Ve("server_event", e.type, Lt(e)), e.type === "session.subscribed") {
2640
2658
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2641
2659
  if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
2642
2660
  const i = this.pendingSessionSubscription;
@@ -2649,13 +2667,13 @@ class De {
2649
2667
  this.pendingSessionSubscription = null, t.resolve(!1), n && (this.sessionHistoryHydration = null, this.handleServerEvent({ ...e, requestId: n.requestId }));
2650
2668
  return;
2651
2669
  }
2652
- if (this.sessionHistoryHydration && me(e) && G(e) === this.sessionHistoryHydration.sessionId) {
2670
+ if (this.sessionHistoryHydration && le(e) && K(e) === this.sessionHistoryHydration.sessionId) {
2653
2671
  this.sessionHistoryHydration.bufferedEvents.push(e);
2654
2672
  return;
2655
2673
  }
2656
2674
  if (e.type === "session.item") {
2657
2675
  const t = A(e.item, "sessionId") ?? this.state.sessionId;
2658
- this.forgetSupersededTaskTabClosedTurn(t, P(e.item)), this.rememberDurablyStoppedTurn(
2676
+ this.forgetSupersededTaskTabClosedTurn(t, C(e.item)), this.rememberDurablyStoppedTurn(
2659
2677
  t,
2660
2678
  e.item
2661
2679
  );
@@ -2673,20 +2691,20 @@ class De {
2673
2691
  if (e.type === "run.ack") {
2674
2692
  if (this.shouldIgnoreStoppedTurnEvent(e))
2675
2693
  return;
2676
- const t = G(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, i = t ? this.deferredDetachedSessionEvents.get(t) ?? [] : [];
2694
+ const t = K(e), n = typeof e.clientMessageId == "string" ? e.clientMessageId : null, i = t ? this.deferredDetachedSessionEvents.get(t) ?? [] : [];
2677
2695
  t && this.deferredDetachedSessionEvents.delete(t), t && n && this.backgroundClientMessageIds.delete(n) ? (this.backgroundSessionIds.add(t), this.deferredSessionUpdatedSessionIds.delete(t)) : t && (n === this.activeClientMessageId || n === this.pendingClientMessageId) && this.deferredSessionUpdatedSessionIds.delete(t) && this.state.sessionId === null && this.setState({ sessionId: t }), this.handleRunAck(e);
2678
2696
  for (const r of i)
2679
2697
  this.handleServerEvent(r);
2680
2698
  return;
2681
2699
  }
2682
2700
  if (e.type === "session.updated" && this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId === null && this.backgroundClientMessageIds.size > 0) {
2683
- const t = G(e);
2701
+ const t = K(e);
2684
2702
  if (t) {
2685
2703
  this.deferredSessionUpdatedSessionIds.add(t);
2686
2704
  return;
2687
2705
  }
2688
2706
  }
2689
- if (!this.shouldIgnoreBackgroundSessionEvent(e) && !this.shouldIgnoreStoppedTurnEvent(e)) {
2707
+ if (!this.shouldIgnoreStoppedTurnEvent(e) && (this.updateInactiveSessionTimelineCache(e), !this.shouldIgnoreBackgroundSessionEvent(e))) {
2690
2708
  if (e.type === "run.steered") {
2691
2709
  this.handleRunSteered(e);
2692
2710
  return;
@@ -2702,17 +2720,17 @@ class De {
2702
2720
  this.activeResponseRunId = t, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
2703
2721
  return;
2704
2722
  }
2705
- if (ii(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2723
+ if (hi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2706
2724
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
2707
- const t = Bi(e.user);
2725
+ const t = Qi(e.user);
2708
2726
  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();
2709
- const n = Oi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2727
+ const n = Fi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2710
2728
  R("web-sdk.agent", "Received auth.ok appearance", {
2711
2729
  hasAppearance: i,
2712
2730
  rawAppearance: e.appearance,
2713
2731
  normalizedAppearance: n
2714
- }), this.runtimeHelperJavascript = Li(e.runtimeHelpers)?.javascript ?? null;
2715
- const r = Bt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
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 = {
2716
2734
  user: t,
2717
2735
  status: "connected",
2718
2736
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
@@ -2721,31 +2739,31 @@ class De {
2721
2739
  type: "runtime.auth_ack",
2722
2740
  connectionAttempt: this.connectionAttemptId,
2723
2741
  entrySurface: this.options.entrySurface
2724
- }), o && r.length === 0 && !a && !Xe() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2742
+ }), o && r.length === 0 && !a && !Ye() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2725
2743
  type: "page.upsert",
2726
2744
  sessionId: this.state.sessionId,
2727
- page: v(),
2745
+ page: P(),
2728
2746
  model: this.options.model
2729
2747
  });
2730
2748
  return;
2731
2749
  }
2732
2750
  if (e.type === "starterPrompts.updated") {
2733
2751
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
2734
- starterPrompts: Bt(e, "starterPrompts"),
2752
+ starterPrompts: Gt(e, "starterPrompts"),
2735
2753
  starterPromptsLoading: !1
2736
2754
  });
2737
2755
  return;
2738
2756
  }
2739
2757
  if (e.type === "scheduled_follow_ups.updated") {
2740
2758
  typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
2741
- activeScheduledFollowUps: Wt(
2759
+ activeScheduledFollowUps: Qt(
2742
2760
  e.activeScheduledFollowUps
2743
2761
  )
2744
2762
  });
2745
2763
  return;
2746
2764
  }
2747
2765
  if (e.type === "conversation.state") {
2748
- const t = Array.isArray(e.items) ? e.items : [], n = un(t), i = Object.prototype.hasOwnProperty.call(
2766
+ const t = Array.isArray(e.items) ? e.items : [], n = vt(t), i = Object.prototype.hasOwnProperty.call(
2749
2767
  e,
2750
2768
  "activeScheduledFollowUps"
2751
2769
  ), 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();
@@ -2753,16 +2771,16 @@ class De {
2753
2771
  return;
2754
2772
  this.updateAccountFallbackFromSession(e.session), this.updatePersonalModelFromSession(e.session), r === this.state.sessionId && this.clearSessionLoadRequest();
2755
2773
  for (const U of n)
2756
- this.forgetSupersededTaskTabClosedTurn(r, P(U));
2774
+ this.forgetSupersededTaskTabClosedTurn(r, C(U));
2757
2775
  for (const U of n)
2758
2776
  this.rememberDurablyStoppedTurn(r, U);
2759
- const l = ne(n), c = l === null ? null : n[l], u = P(c), h = this.findStoppedTurn(r, {
2777
+ const l = ne(n), c = l === null ? null : n[l], u = C(c), h = this.findStoppedTurn(r, {
2760
2778
  clientMessageId: u?.clientMessageId,
2761
2779
  respondsToUserMessageId: A(c, "id"),
2762
2780
  runId: u?.runId
2763
- }), f = this.filterStoppedSnapshotItems(n, r), m = 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;
2764
- m && d && (this.pendingClientMessageId = d);
2765
- let g = Qi(
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(
2766
2784
  e.assistantDraft
2767
2785
  );
2768
2786
  g && this.findStoppedTurn(r, {
@@ -2771,39 +2789,39 @@ class De {
2771
2789
  }) && (g = void 0);
2772
2790
  const M = g !== void 0;
2773
2791
  this.rememberUserMessageClientMessageIds(f);
2774
- const w = dr(f), D = f.filter((U) => {
2775
- const q = P(U);
2776
- return cr(q) ? !1 : !q || !w || !ve(q) ? !0 : rt(f, q) !== w;
2777
- }), S = fs(
2792
+ const w = fr(f), D = f.filter((U) => {
2793
+ const q = C(U);
2794
+ return pr(q) ? !1 : !q || !w || !he(q) ? !0 : ct(f, q) !== w;
2795
+ }), S = ot(
2778
2796
  this.state.messages,
2779
- $t(D, this.options.backendUrl)
2780
- ), T = jt(S), N = M ? g?.content ?? "" : this.state.assistantDraft, _ = 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(
2781
- (U, q) => zt(
2782
- P(U),
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(
2800
+ C(U),
2783
2801
  N,
2784
- _,
2802
+ v,
2785
2803
  ie,
2786
2804
  J,
2787
- hr(f, q)
2805
+ mr(f, q)
2788
2806
  )
2789
- ), Z = M ? g?.content ?? "" : this.state.assistantDraft, de = !!g?.content && !Y, B = T && (!Z || Y), K = ar(S), re = B && K ? "completed" : h ? "stopped" : B ? "failed" : null;
2790
- if (!T && ur(this.state.messages, f))
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))
2791
2809
  return;
2792
- this.lastUserMessagePageUrl = lr(f);
2793
- const j = B || h ? null : it(f);
2794
- if (this.latestRecoverableClientMessageId = j, K && this.clearRetryTimers(), this.setState({
2810
+ this.lastUserMessagePageUrl = hr(f);
2811
+ const j = B || h ? null : lt(f);
2812
+ if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
2795
2813
  sessionId: A(e.session, "id") ?? this.state.sessionId,
2796
2814
  messages: S,
2797
2815
  ...i ? {
2798
- activeScheduledFollowUps: Wt(
2816
+ activeScheduledFollowUps: Qt(
2799
2817
  e.activeScheduledFollowUps
2800
2818
  )
2801
2819
  } : {},
2802
2820
  isLoadingSession: !1,
2803
- ...m ? { pendingMessageStatus: m } : {},
2804
- ...y ? { turnPhase: y } : {},
2821
+ ...y ? { pendingMessageStatus: y } : {},
2822
+ ...m ? { turnPhase: m } : {},
2805
2823
  isRetrying: p,
2806
- ...y ? { taskStatus: "working" } : {},
2824
+ ...m ? { taskStatus: "working" } : {},
2807
2825
  ...re && this.state.taskStatus === "working" ? { taskStatus: re } : {},
2808
2826
  ...Y ? {
2809
2827
  assistantDraft: "",
@@ -2818,11 +2836,11 @@ class De {
2818
2836
  assistantDraftRespondsToUserMessageId: g?.respondsToUserMessageId ?? null,
2819
2837
  assistantDraftRunId: g?.runId ?? null
2820
2838
  } : {},
2821
- ...de ? {
2839
+ ...ge ? {
2822
2840
  isThinking: !0,
2823
2841
  turnPhase: "thinking",
2824
2842
  lastError: null
2825
- } : y ? {
2843
+ } : m ? {
2826
2844
  isThinking: !0,
2827
2845
  lastError: null,
2828
2846
  lastErrorCode: null,
@@ -2835,12 +2853,12 @@ class De {
2835
2853
  lastErrorSecuritySettingsUrl: null
2836
2854
  } : j ? {
2837
2855
  isThinking: !0,
2838
- turnPhase: y ?? this.state.turnPhase ?? "starting",
2856
+ turnPhase: m ?? this.state.turnPhase ?? "starting",
2839
2857
  lastError: null
2840
2858
  } : {}
2841
2859
  }), B)
2842
2860
  this.retryableClientMessageId = w, this.clearThinkingWatchdog();
2843
- else if (!h && (de || j)) {
2861
+ else if (!h && (ge || j)) {
2844
2862
  if (j) {
2845
2863
  this.activeClientMessageId = j;
2846
2864
  const U = ne(f), q = U === null ? null : f[U];
@@ -2857,19 +2875,19 @@ class De {
2857
2875
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2858
2876
  if (!t || n !== this.state.sessionId)
2859
2877
  return;
2860
- const i = $t(
2878
+ const i = et(
2861
2879
  Array.isArray(e.items) ? e.items : [],
2862
2880
  this.options.backendUrl
2863
2881
  );
2864
2882
  t === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
2865
- messages: sr(this.state.messages, i)
2883
+ messages: or(this.state.messages, i)
2866
2884
  });
2867
2885
  return;
2868
2886
  }
2869
2887
  if (e.type === "sessions.page") {
2870
2888
  const t = typeof e.requestId == "string" ? e.requestId : null, n = t ? this.pendingSessionHistoryRequests.get(t) : null;
2871
2889
  t && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(t), n.resolve({
2872
- sessions: Wi(e.sessions),
2890
+ sessions: Vi(e.sessions),
2873
2891
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
2874
2892
  }));
2875
2893
  return;
@@ -2895,28 +2913,28 @@ class De {
2895
2913
  }
2896
2914
  if (e.type === "session.item") {
2897
2915
  this.rememberUserMessageClientMessageIds([e.item]);
2898
- const t = P(e.item);
2899
- if (ve(t)) {
2916
+ const t = C(e.item);
2917
+ if (he(t)) {
2900
2918
  typeof t?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(t.runId);
2901
2919
  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);
2902
2920
  o && (this.retryableClientMessageId = o);
2903
2921
  return;
2904
2922
  }
2905
- const n = gs(e.item, this.options.backendUrl);
2923
+ const n = rt(e.item, this.options.backendUrl);
2906
2924
  if (n) {
2907
- const i = mr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
2908
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), $(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), gr(t) && this.clearRunAckResyncRetryTimer();
2909
- const o = nt(this.state.messages, n), a = jt(o), l = zt(
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(
2910
2928
  t,
2911
2929
  this.state.assistantDraft,
2912
2930
  this.state.assistantDraftItemId,
2913
2931
  this.state.assistantDraftRespondsToUserMessageId,
2914
2932
  this.state.assistantDraftRunId,
2915
- Ts(
2933
+ Ps(
2916
2934
  o,
2917
2935
  o.findIndex((h) => h.id === n.id)
2918
2936
  )
2919
- ), c = a && (!this.state.assistantDraft || l), u = ke(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
2937
+ ), c = a && (!this.state.assistantDraft || l), u = _e(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
2920
2938
  this.setState({
2921
2939
  messages: o,
2922
2940
  ...l ? {
@@ -2945,7 +2963,7 @@ class De {
2945
2963
  this.clearRunAckResyncRetryTimer();
2946
2964
  const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
2947
2965
  this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = u), this.setState({
2948
- messages: nt(this.state.messages, {
2966
+ messages: ue(this.state.messages, {
2949
2967
  id: o,
2950
2968
  role: "assistant",
2951
2969
  content: r,
@@ -2974,9 +2992,9 @@ class De {
2974
2992
  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;
2975
2993
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
2976
2994
  return;
2977
- 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 = Vs(
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(
2978
2996
  this.state.messages.filter(
2979
- (c) => c.dataType !== "assistant_draft" || !Ye(
2997
+ (c) => c.dataType !== "assistant_draft" || !we(
2980
2998
  c,
2981
2999
  n,
2982
3000
  i
@@ -2984,11 +3002,11 @@ class De {
2984
3002
  ),
2985
3003
  n,
2986
3004
  i,
2987
- ys
3005
+ at
2988
3006
  );
2989
3007
  this.setState({
2990
3008
  sessionId: t,
2991
- messages: Ji(
3009
+ messages: Xt(
2992
3010
  l,
2993
3011
  typeof e.responseId == "string" ? e.responseId : null,
2994
3012
  n,
@@ -3011,9 +3029,9 @@ class De {
3011
3029
  if (t)
3012
3030
  this.nonTranscriptToolCallIds.add(t);
3013
3031
  else {
3014
- const n = er(e);
3032
+ const n = Zt(e);
3015
3033
  if (n) {
3016
- const i = Yi(
3034
+ const i = Jt(
3017
3035
  this.state.messages,
3018
3036
  n
3019
3037
  );
@@ -3075,13 +3093,13 @@ class De {
3075
3093
  return;
3076
3094
  }
3077
3095
  o && i && r && (this.retryableClientMessageId = r);
3078
- const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Ai(a.message);
3096
+ const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = _i(a.message);
3079
3097
  l && console.error(l);
3080
- const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = Kt(
3098
+ const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = ns(
3081
3099
  this.state.messages,
3082
3100
  c,
3083
3101
  u
3084
- ), f = or(
3102
+ ), f = ur(
3085
3103
  h,
3086
3104
  c,
3087
3105
  u
@@ -3108,7 +3126,7 @@ class De {
3108
3126
  }
3109
3127
  applyAccountSubmissionError(e) {
3110
3128
  if (!this.account || !e) return;
3111
- const t = pn(this.account.submissionGate, e);
3129
+ const t = Tn(this.account.submissionGate, e);
3112
3130
  if (!(t === this.account.submissionGate || t.allowed)) {
3113
3131
  this.account = {
3114
3132
  ...this.account,
@@ -3121,31 +3139,143 @@ class De {
3121
3139
  if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
3122
3140
  return;
3123
3141
  const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
3124
- this.options.model = je(n) ? n : "gpt-5.6-sol";
3142
+ this.options.model = Ke(n) ? n : "gpt-5.6-sol";
3125
3143
  }
3126
3144
  updateAccountFallbackFromSession(e) {
3127
- const t = e && typeof e == "object" ? e.metadata : null, n = gn(t);
3145
+ const t = e && typeof e == "object" ? e.metadata : null, n = wn(t);
3128
3146
  if (this.usingPaidCreditFallback !== n && (this.usingPaidCreditFallback = n, !!this.account)) {
3129
3147
  this.account = { ...this.account, usingPaidCreditFallback: n };
3130
3148
  for (const i of this.accountListeners) i(this.getAccount());
3131
3149
  }
3132
3150
  }
3133
3151
  shouldIgnoreBackgroundSessionEvent(e) {
3134
- if (!this.options.keepRunsActiveOnSessionNavigation || !me(e))
3152
+ if (!this.options.keepRunsActiveOnSessionNavigation || !le(e))
3135
3153
  return !1;
3136
- const t = G(e);
3154
+ const t = K(e);
3137
3155
  return t ? this.deferredSessionUpdatedSessionIds.has(t) ? !0 : this.state.sessionId ? t !== this.state.sessionId : this.backgroundSessionIds.has(t) : !1;
3138
3156
  }
3157
+ updateInactiveSessionTimelineCache(e) {
3158
+ if (!le(e))
3159
+ return;
3160
+ const t = K(e);
3161
+ if (!t || t === this.state.sessionId)
3162
+ return;
3163
+ const n = this.sessionTimelineCache.get(t);
3164
+ if (e.type === "conversation.state") {
3165
+ const i = vt(
3166
+ Array.isArray(e.items) ? e.items : []
3167
+ ), r = et(
3168
+ this.filterStoppedSnapshotItems(i, t),
3169
+ this.options.backendUrl
3170
+ );
3171
+ (n || r.length > 0) && this.rememberSessionTimeline(
3172
+ t,
3173
+ n ? ot(n, r) : r
3174
+ );
3175
+ return;
3176
+ }
3177
+ if (n) {
3178
+ if (e.type === "session.item") {
3179
+ const i = C(e.item);
3180
+ if (he(i))
3181
+ return;
3182
+ const r = rt(e.item, this.options.backendUrl);
3183
+ r && this.rememberSessionTimeline(t, ue(n, r));
3184
+ return;
3185
+ }
3186
+ if (e.type === "tool.call") {
3187
+ const i = e.hiddenFromTranscript === !0 ? null : Zt(e);
3188
+ i && this.rememberSessionTimeline(
3189
+ t,
3190
+ Jt(n, i)
3191
+ );
3192
+ return;
3193
+ }
3194
+ if (e.type === "tool.status") {
3195
+ if (typeof e.callId != "string")
3196
+ return;
3197
+ const i = e.status === "queued" || e.status === "running";
3198
+ if (i && this.terminalToolCallIds.has(e.callId))
3199
+ return;
3200
+ this.rememberSessionTimeline(
3201
+ t,
3202
+ Yt(
3203
+ n,
3204
+ e.callId,
3205
+ i
3206
+ )
3207
+ );
3208
+ return;
3209
+ }
3210
+ if (e.type === "chat.assistant_delta") {
3211
+ 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
+ this.rememberSessionTimeline(
3213
+ t,
3214
+ ue(n, {
3215
+ id: r,
3216
+ role: "assistant",
3217
+ content: l,
3218
+ createdAt: o?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
3219
+ ...typeof e.causalSequence == "number" ? { causalSequence: e.causalSequence } : {},
3220
+ dataType: "assistant_draft",
3221
+ ...e.phase === "commentary" || e.phase === "final_answer" ? { phase: e.phase } : o?.phase ? { phase: o.phase } : {},
3222
+ ...typeof e.respondsToUserMessageId == "string" ? { respondsToUserMessageId: e.respondsToUserMessageId } : o?.respondsToUserMessageId ? { respondsToUserMessageId: o.respondsToUserMessageId } : {},
3223
+ ...typeof e.runId == "string" ? { runId: e.runId } : o?.runId ? { runId: o.runId } : {}
3224
+ })
3225
+ );
3226
+ return;
3227
+ }
3228
+ 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(
3230
+ n.filter(
3231
+ (a) => a.dataType !== "assistant_draft" || !we(a, i, r)
3232
+ ),
3233
+ i,
3234
+ r,
3235
+ at
3236
+ );
3237
+ this.rememberSessionTimeline(
3238
+ t,
3239
+ Xt(
3240
+ o,
3241
+ typeof e.responseId == "string" ? e.responseId : null,
3242
+ i,
3243
+ r
3244
+ )
3245
+ );
3246
+ return;
3247
+ }
3248
+ if (e.type === "run.steered") {
3249
+ const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null;
3250
+ if (!i)
3251
+ return;
3252
+ this.rememberSessionTimeline(
3253
+ t,
3254
+ is(
3255
+ n,
3256
+ i,
3257
+ null,
3258
+ typeof e.runId == "string" ? e.runId : null
3259
+ )
3260
+ );
3261
+ return;
3262
+ }
3263
+ e.type === "error" && typeof e.requestId != "string" && !ss(e, t) && this.rememberSessionTimeline(
3264
+ t,
3265
+ wr(n, e)
3266
+ );
3267
+ }
3268
+ }
3139
3269
  shouldIgnoreDetachedSessionEvent(e) {
3140
- if (this.options.keepRunsActiveOnSessionNavigation || !me(e))
3270
+ if (this.options.keepRunsActiveOnSessionNavigation || !le(e))
3141
3271
  return !1;
3142
- const t = G(e);
3272
+ const t = K(e);
3143
3273
  return !!(t && this.detachedSessionIds.has(t));
3144
3274
  }
3145
3275
  shouldDeferDetachedSessionEvent(e) {
3146
- if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !me(e))
3276
+ if (this.options.keepRunsActiveOnSessionNavigation || e.type === "run.ack" || !le(e))
3147
3277
  return !1;
3148
- const t = G(e);
3278
+ const t = K(e);
3149
3279
  if (!t || t === this.state.sessionId || this.detachedClientMessageIds.size === 0 && !this.deferredDetachedSessionEvents.has(t))
3150
3280
  return !1;
3151
3281
  const n = this.deferredDetachedSessionEvents.get(t) ?? [];
@@ -3166,15 +3296,15 @@ class De {
3166
3296
  }
3167
3297
  handleRetryableRecoveryError(e) {
3168
3298
  const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
3169
- if (!(e.retryable === !0 || e.code === "transient_model_error") || e.code === "run_recovery_exhausted" || !t || !n)
3299
+ if (!ss(e, t) || !n)
3170
3300
  return !1;
3171
- if (Xe())
3301
+ if (Ye())
3172
3302
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
3173
3303
  if (this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
3174
- const r = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
3304
+ const i = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
3175
3305
  this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
3176
3306
  delete this.retryTimersByClientMessageId[n], this.resyncThinkingSession(), this.markThinkingProgress();
3177
- }, r);
3307
+ }, i);
3178
3308
  }
3179
3309
  return !0;
3180
3310
  }
@@ -3185,7 +3315,7 @@ class De {
3185
3315
  }
3186
3316
  rememberUserMessageClientMessageIds(e) {
3187
3317
  for (const t of e) {
3188
- const n = A(t, "id"), i = P(t);
3318
+ const n = A(t, "id"), i = C(t);
3189
3319
  n && i?.type === "message" && i.role === "user" && i.optimistic !== !0 && !n.startsWith("optimistic-user-message:") && typeof i.clientMessageId == "string" && (this.clientMessageIdsByUserMessageItemId.set(n, i.clientMessageId), i.clientMessageId === this.pendingClientMessageId && (this.shouldDeferPendingDeliveryPromotion(i.clientMessageId) || this.promotePendingDelivery(
3190
3320
  i.clientMessageId,
3191
3321
  A(t, "sessionId") ?? this.state.sessionId,
@@ -3207,7 +3337,7 @@ class De {
3207
3337
  const i = new Promise((r, o) => {
3208
3338
  const a = window.setTimeout(() => {
3209
3339
  e.delete(t.requestId), o(new Error(n));
3210
- }, Ot);
3340
+ }, $t);
3211
3341
  e.set(t.requestId, { resolve: r, reject: o, timeout: a });
3212
3342
  });
3213
3343
  if (!this.sendNow(t)) {
@@ -3230,7 +3360,7 @@ class De {
3230
3360
  e.clear();
3231
3361
  }
3232
3362
  markThinkingProgress() {
3233
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Bn), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
3363
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(Gn), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
3234
3364
  }
3235
3365
  scheduleThinkingWatchdog(e) {
3236
3366
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -3286,21 +3416,21 @@ class De {
3286
3416
  return this.pendingClientMessageId === e && this.state.isThinking && this.activeClientMessageId !== null && this.activeClientMessageId !== e;
3287
3417
  }
3288
3418
  schedulePendingDeliveryAck(e) {
3289
- this.clearPendingDeliveryTimers(), !Xe() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3419
+ this.clearPendingDeliveryTimers(), !Ye() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3290
3420
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
3291
- }, qt));
3421
+ }, Wt));
3292
3422
  }
3293
3423
  retryPendingDelivery(e) {
3294
3424
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
3295
3425
  return;
3296
3426
  const t = this.retryAttemptsByClientMessageId[e] ?? 0;
3297
- if (t >= Wn) {
3427
+ if (t >= Qn) {
3298
3428
  this.failPendingDelivery(e);
3299
3429
  return;
3300
3430
  }
3301
3431
  t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
3302
3432
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
3303
- }, Zn(t, jn));
3433
+ }, ai(t, Jn));
3304
3434
  }
3305
3435
  failPendingDelivery(e) {
3306
3436
  if (this.pendingClientMessageId !== e)
@@ -3312,7 +3442,7 @@ class De {
3312
3442
  ...this.state.isThinking ? {} : { turnPhase: null },
3313
3443
  isRetrying: !1,
3314
3444
  ...this.state.isThinking ? {} : { taskStatus: "failed" },
3315
- lastError: Fn,
3445
+ lastError: Xn,
3316
3446
  lastErrorCode: "message_delivery_failed"
3317
3447
  });
3318
3448
  }
@@ -3324,7 +3454,7 @@ class De {
3324
3454
  if (this.state.isThinking && t) {
3325
3455
  const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
3326
3456
  this.setState({
3327
- messages: Sr(
3457
+ messages: is(
3328
3458
  this.state.messages,
3329
3459
  t,
3330
3460
  n,
@@ -3350,13 +3480,13 @@ class De {
3350
3480
  scheduleRunAckWatchdog(e) {
3351
3481
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
3352
3482
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
3353
- }, qt);
3483
+ }, Wt);
3354
3484
  }
3355
3485
  recoverMissedRunAck(e) {
3356
3486
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (R("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3357
3487
  sessionId: this.state.sessionId,
3358
3488
  clientMessageId: e
3359
- }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Dt));
3489
+ }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Bt));
3360
3490
  }
3361
3491
  clearRunAckResyncRetryTimer() {
3362
3492
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -3375,11 +3505,11 @@ class De {
3375
3505
  reason: "missing_client_message_id"
3376
3506
  }), this.setState({
3377
3507
  messages: this.state.messages.filter(
3378
- (n) => !X(n)
3508
+ (n) => !G(n)
3379
3509
  ),
3380
3510
  isThinking: !1,
3381
3511
  taskStatus: "failed",
3382
- lastError: $n,
3512
+ lastError: Vn,
3383
3513
  lastErrorCode: "run_recovery_exhausted"
3384
3514
  }), this.clearThinkingWatchdog();
3385
3515
  return;
@@ -3389,13 +3519,13 @@ class De {
3389
3519
  sessionId: this.state.sessionId,
3390
3520
  clientMessageId: e,
3391
3521
  resyncAttempts: t + 1
3392
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Dt);
3522
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Bt);
3393
3523
  }
3394
3524
  resyncThinkingSession() {
3395
3525
  this.state.sessionId ? this.send({
3396
3526
  type: "page.upsert",
3397
3527
  sessionId: this.state.sessionId,
3398
- page: v(),
3528
+ page: P(),
3399
3529
  model: this.options.model
3400
3530
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
3401
3531
  }
@@ -3406,15 +3536,15 @@ class De {
3406
3536
  if (!t || !n || !i)
3407
3537
  return;
3408
3538
  const a = i === "execute_code", l = i === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
3409
- if (!a && !l || !Br(o)) {
3539
+ if (!a && !l || !zr(o)) {
3410
3540
  this.setToolMessageLoading(n, !1), this.send({
3411
3541
  type: "tool.result",
3412
3542
  sessionId: t,
3413
3543
  callId: n,
3414
3544
  toolName: i,
3415
3545
  summary: r,
3416
- rawInput: x(o),
3417
- rawOutput: x({
3546
+ rawInput: L(o),
3547
+ rawOutput: L({
3418
3548
  ok: !1,
3419
3549
  toolName: i,
3420
3550
  error: `Unsupported browser tool: ${i}`
@@ -3429,7 +3559,7 @@ class De {
3429
3559
  callId: n,
3430
3560
  toolName: i,
3431
3561
  summary: r,
3432
- rawInput: x(o),
3562
+ rawInput: L(o),
3433
3563
  rawOutput: {
3434
3564
  ok: !1,
3435
3565
  toolName: i,
@@ -3445,7 +3575,7 @@ class De {
3445
3575
  callId: n,
3446
3576
  toolName: i,
3447
3577
  summary: r,
3448
- rawInput: x(o),
3578
+ rawInput: L(o),
3449
3579
  rawOutput: null
3450
3580
  },
3451
3581
  startedAtMs: Date.now(),
@@ -3453,9 +3583,9 @@ class De {
3453
3583
  startedAtOrigin: location.origin
3454
3584
  }), this.installSessionBrowserApis();
3455
3585
  let c = null, u;
3456
- c = await this.executeRuntimeHelper(), u = await Nt(
3586
+ c = await this.executeRuntimeHelper(), u = await zt(
3457
3587
  o,
3458
- mi(e.runtimeContext, this.options.backendUrl)
3588
+ Ri(e.runtimeContext, this.options.backendUrl)
3459
3589
  ).catch((h) => ({
3460
3590
  ok: !1,
3461
3591
  exception: {
@@ -3467,12 +3597,12 @@ class De {
3467
3597
  callId: n,
3468
3598
  toolName: i,
3469
3599
  summary: o.summary,
3470
- rawInput: x(o),
3471
- rawOutput: x(xi(u, c))
3472
- }), Qt(this.options.clientId, this.activeBrowserToolCalls.values()));
3600
+ rawInput: L(o),
3601
+ rawOutput: L(zi(u, c))
3602
+ }), os(this.options.clientId, this.activeBrowserToolCalls.values()));
3473
3603
  }
3474
3604
  setToolMessageLoading(e, t) {
3475
- const n = Zi(
3605
+ const n = Yt(
3476
3606
  this.state.messages,
3477
3607
  e,
3478
3608
  t
@@ -3483,47 +3613,47 @@ class De {
3483
3613
  if (this.pageLifecycleCleanup)
3484
3614
  return;
3485
3615
  const e = () => {
3486
- As(this.options.clientId, this.activeBrowserToolCalls.values());
3616
+ vs(this.options.clientId, this.activeBrowserToolCalls.values());
3487
3617
  };
3488
3618
  window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
3489
3619
  window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
3490
3620
  };
3491
3621
  }
3492
3622
  installSessionBrowserApis() {
3493
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = ai();
3623
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = fi();
3494
3624
  }
3495
3625
  cleanupSessionBrowserApis() {
3496
- this.sessionBrowserApisCleanup && (fi(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3626
+ this.sessionBrowserApisCleanup && (Mi(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3497
3627
  }
3498
3628
  async executeRuntimeHelper() {
3499
3629
  if (!this.runtimeHelperJavascript?.trim())
3500
3630
  return null;
3501
- const e = await Nt({
3631
+ const e = await zt({
3502
3632
  javascript: this.runtimeHelperJavascript
3503
3633
  });
3504
- return e.ok === !1 ? Ni(e) : null;
3634
+ return e.ok === !1 ? Ki(e) : null;
3505
3635
  }
3506
3636
  enableNetworkCapture() {
3507
- this.networkCaptureCleanup || (this.networkCaptureCleanup = si((e) => {
3508
- Kr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3637
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = ui((e) => {
3638
+ Jr(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3509
3639
  }));
3510
3640
  }
3511
3641
  enqueueNetworkEvent(e) {
3512
- this.queuedNetworkEvents.length >= Kn || (this.queuedNetworkEvents.push(zr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3642
+ this.queuedNetworkEvents.length >= Zn || (this.queuedNetworkEvents.push(Xr(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3513
3643
  this.networkBatchTimer = null;
3514
3644
  const t = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
3515
3645
  t.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
3516
3646
  type: "network.batch",
3517
3647
  sessionId: this.state.sessionId ?? void 0,
3518
- page: v(),
3648
+ page: P(),
3519
3649
  events: t
3520
3650
  });
3521
- }, zn)));
3651
+ }, Yn)));
3522
3652
  }
3523
3653
  scheduleReconnect() {
3524
3654
  if (this.reconnectTimer !== null || this.state.status === "closed")
3525
3655
  return;
3526
- const e = ei(this.reconnectAttempts);
3656
+ const e = li(this.reconnectAttempts);
3527
3657
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
3528
3658
  this.reconnectTimer = null, this.connect().catch((t) => {
3529
3659
  R("web-sdk.agent", "Pluno reconnect failed; retrying", {
@@ -3539,8 +3669,8 @@ class De {
3539
3669
  const e = this.socket;
3540
3670
  !e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
3541
3671
  this.socket === e && (R("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
3542
- }, Dn));
3543
- }, Un);
3672
+ }, Bn));
3673
+ }, Hn);
3544
3674
  }
3545
3675
  stopHeartbeat() {
3546
3676
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -3578,7 +3708,7 @@ class De {
3578
3708
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3579
3709
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3580
3710
  }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null;
3581
- 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(), vr(this.options.clientId, this.state), this.emit("state", this.getState()), Ge("state", this.state.status, {
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, {
3582
3712
  status: this.state.status,
3583
3713
  sessionId: this.state.sessionId,
3584
3714
  messageCount: this.state.messages.length,
@@ -3606,7 +3736,7 @@ class De {
3606
3736
  this.transportIdentity.transportId
3607
3737
  ].join(":"), n = `${e}:${t}`;
3608
3738
  if (this.sessionRecoveryScope !== n) {
3609
- const i = [...this.state.messages].reverse().find((r) => !at(r) && !r.id.startsWith("transient-activity:"));
3739
+ const i = [...this.state.messages].reverse().find((r) => !ht(r) && !r.id.startsWith("transient-activity:"));
3610
3740
  this.sessionActivityRecovery.reset(i?.id ?? null), this.sessionRecoveryScope = n;
3611
3741
  }
3612
3742
  this.sessionRecoveryPoller.start(e, t), this.sessionActivityRecoveryPoller.start(e, t);
@@ -3636,44 +3766,44 @@ class De {
3636
3766
  this.listeners[e]?.forEach((i) => i(t));
3637
3767
  }
3638
3768
  }
3639
- const Ve = /* @__PURE__ */ new WeakMap();
3640
- function si(s) {
3641
- const e = window.__plunoProductAgentNetworkCapture ?? ni();
3769
+ const Je = /* @__PURE__ */ new WeakMap();
3770
+ function ui(s) {
3771
+ const e = window.__plunoProductAgentNetworkCapture ?? di();
3642
3772
  return e.subscribers.add(s), () => {
3643
3773
  e.subscribers.delete(s), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
3644
3774
  };
3645
3775
  }
3646
- function ni() {
3776
+ function di() {
3647
3777
  const s = /* @__PURE__ */ new Set(), e = (f) => {
3648
- s.forEach((m) => {
3778
+ s.forEach((y) => {
3649
3779
  try {
3650
- m(f);
3780
+ y(f);
3651
3781
  } catch {
3652
3782
  }
3653
3783
  });
3654
- }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(m, d) {
3784
+ }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(y, d) {
3655
3785
  const p = Date.now();
3656
- let y;
3786
+ let m;
3657
3787
  try {
3658
- y = t.call(this, m, d);
3788
+ m = t.call(this, y, d);
3659
3789
  } catch (g) {
3660
3790
  throw g;
3661
3791
  }
3662
3792
  try {
3663
- const g = m instanceof Request ? m : null, M = Wr(m, g), w = Es(d?.headers ?? g?.headers);
3793
+ const g = y instanceof Request ? y : null, M = Kr(y, g), w = Os(d?.headers ?? g?.headers);
3664
3794
  if (!ee(M, w, d?.body)) {
3665
3795
  const H = {
3666
- requestId: Ze("fetch"),
3667
- url: W(M, Qe),
3796
+ requestId: tt("fetch"),
3797
+ url: W(M, Xe),
3668
3798
  method: (d?.method ?? g?.method ?? "GET").toUpperCase(),
3669
3799
  requestHeaders: w,
3670
- requestBody: Xt(d?.body),
3800
+ requestBody: ls(d?.body),
3671
3801
  resourceType: "fetch",
3672
3802
  startedAt: new Date(p).toISOString()
3673
3803
  };
3674
- y.then(
3804
+ m.then(
3675
3805
  (S) => {
3676
- $r(S, H, p, e).catch(() => {
3806
+ Gr(S, H, p, e).catch(() => {
3677
3807
  e({
3678
3808
  ...H,
3679
3809
  responseStatus: S.status,
@@ -3692,30 +3822,30 @@ function ni() {
3692
3822
  }
3693
3823
  } catch {
3694
3824
  }
3695
- return y;
3696
- }, a = function(m, d, p, y, g) {
3697
- const M = n.call(this, m, d, p ?? !0, y ?? void 0, g ?? void 0), w = typeof d == "string" ? d : d.toString();
3698
- return Ve.set(this, {
3699
- requestId: Ze("xhr"),
3700
- method: String(m ?? "GET").toUpperCase(),
3701
- url: W(w, Qe),
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),
3702
3832
  requestHeaders: {},
3703
3833
  startedAtMs: Date.now(),
3704
3834
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3705
3835
  excluded: ee(w)
3706
3836
  }), M;
3707
- }, l = function(m, d) {
3708
- const p = i.call(this, m, d), y = Ve.get(this);
3709
- return y && Object.keys(y.requestHeaders).length < pt && (y.requestHeaders[m] = mt(m, d), y.excluded = y.excluded || ee(y.url, y.requestHeaders)), p;
3710
- }, c = function(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) {
3711
3841
  try {
3712
- const d = Ve.get(this);
3713
- d && (d.excluded = d.excluded || ee(d.url, d.requestHeaders, m), d.requestBody = Xt(m), d.excluded || this.addEventListener(
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(
3714
3844
  "loadend",
3715
3845
  () => {
3716
3846
  queueMicrotask(() => {
3717
3847
  try {
3718
- const p = Qr(this.getAllResponseHeaders());
3848
+ const p = Zr(this.getAllResponseHeaders());
3719
3849
  e({
3720
3850
  requestId: d.requestId,
3721
3851
  url: d.url,
@@ -3725,7 +3855,7 @@ function ni() {
3725
3855
  resourceType: "xhr",
3726
3856
  responseStatus: this.status,
3727
3857
  responseHeaders: p,
3728
- responseBody: jr(this, p),
3858
+ responseBody: Vr(this, p),
3729
3859
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
3730
3860
  startedAt: d.startedAt,
3731
3861
  durationMs: Date.now() - d.startedAtMs
@@ -3739,7 +3869,7 @@ function ni() {
3739
3869
  ));
3740
3870
  } catch {
3741
3871
  }
3742
- return r.call(this, m ?? null);
3872
+ return r.call(this, y ?? null);
3743
3873
  };
3744
3874
  try {
3745
3875
  window.fetch = o;
@@ -3760,14 +3890,14 @@ function ni() {
3760
3890
  let u = null;
3761
3891
  if (typeof PerformanceObserver < "u") {
3762
3892
  u = new PerformanceObserver((f) => {
3763
- for (const m of f.getEntries()) {
3764
- const d = m;
3893
+ for (const y of f.getEntries()) {
3894
+ const d = y;
3765
3895
  if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || ee(d.name))
3766
3896
  continue;
3767
3897
  const p = performance.timeOrigin + d.startTime;
3768
3898
  e({
3769
- requestId: Ze("resource"),
3770
- url: W(d.name, Qe),
3899
+ requestId: tt("resource"),
3900
+ url: W(d.name, Xe),
3771
3901
  method: "GET",
3772
3902
  resourceType: "resource",
3773
3903
  responseStatus: d.responseStatus,
@@ -3817,17 +3947,17 @@ function R(s, e, t) {
3817
3947
  }, r = n.__plunoProductAgentDiagnostics__ ?? [];
3818
3948
  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 }));
3819
3949
  }
3820
- function xt(s) {
3950
+ function jt(s) {
3821
3951
  const e = typeof s == "function" ? s() : s;
3822
3952
  return e && Object.keys(e).length > 0 ? e : void 0;
3823
3953
  }
3824
- function ii(s) {
3954
+ function hi(s) {
3825
3955
  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";
3826
3956
  }
3827
- function me(s) {
3957
+ function le(s) {
3828
3958
  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";
3829
3959
  }
3830
- function G(s) {
3960
+ function K(s) {
3831
3961
  if (typeof s.sessionId == "string")
3832
3962
  return s.sessionId;
3833
3963
  if (s.session && typeof s.session == "object") {
@@ -3842,31 +3972,31 @@ function G(s) {
3842
3972
  }
3843
3973
  return null;
3844
3974
  }
3845
- const ri = 5e3, oi = 12e4;
3846
- function ai() {
3975
+ const pi = 5e3, gi = 12e4;
3976
+ function fi() {
3847
3977
  const s = [
3848
- ci(),
3849
- li()
3978
+ yi(),
3979
+ mi()
3850
3980
  ].filter((e) => typeof e == "function");
3851
3981
  return () => {
3852
3982
  for (const e of s.reverse())
3853
3983
  e();
3854
3984
  };
3855
3985
  }
3856
- function li() {
3857
- return Yt(globalThis, "getPageSnapshot", async () => gt());
3986
+ function mi() {
3987
+ return us(globalThis, "getPageSnapshot", async () => St());
3858
3988
  }
3859
- function ci() {
3860
- return Yt(globalThis, "pageImages", {
3861
- inspectImage: async (e, t) => await ui(e, t)
3989
+ function yi() {
3990
+ return us(globalThis, "pageImages", {
3991
+ inspectImage: async (e, t) => await Ii(e, t)
3862
3992
  });
3863
3993
  }
3864
- async function ui(s, e = {}) {
3865
- const t = gi(e.name), n = await di(s);
3994
+ async function Ii(s, e = {}) {
3995
+ const t = Ai(e.name), n = await Si(s);
3866
3996
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
3867
3997
  type: "pluno.pageImages.inspectImage",
3868
3998
  imageAttached: !1,
3869
- imageAttachmentError: ls
3999
+ imageAttachmentError: Ts
3870
4000
  } : {
3871
4001
  type: "pluno.pageImages.inspectImage",
3872
4002
  imageAttached: !0,
@@ -3880,15 +4010,15 @@ async function ui(s, e = {}) {
3880
4010
  imageAttachmentError: n.error
3881
4011
  };
3882
4012
  }
3883
- async function di(s) {
3884
- 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: ls } : {
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 } : {
3885
4015
  ok: !0,
3886
4016
  mimeType: s.type,
3887
4017
  sizeBytes: s.size,
3888
- dataUrl: await yi(s)
3889
- } : { 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." } : hi(s);
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);
3890
4020
  }
3891
- function hi(s) {
4021
+ function Ti(s) {
3892
4022
  if (!s.startsWith("data:") || !s.includes(","))
3893
4023
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
3894
4024
  const [e, t] = s.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), i = n[0] ?? "";
@@ -3899,7 +4029,7 @@ function hi(s) {
3899
4029
  const r = t.replace(/[ \t\r\n\f]+/g, "");
3900
4030
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(r))
3901
4031
  return { ok: !1, error: "Page image data URL has invalid base64." };
3902
- const o = pi(r);
4032
+ const o = wi(r);
3903
4033
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
3904
4034
  ok: !0,
3905
4035
  mimeType: i,
@@ -3907,22 +4037,22 @@ function hi(s) {
3907
4037
  dataUrl: `data:${i};base64,${r}`
3908
4038
  };
3909
4039
  }
3910
- function pi(s) {
4040
+ function wi(s) {
3911
4041
  if (s.length === 0 || s.length % 4 !== 0)
3912
4042
  return null;
3913
4043
  const e = s.length - s.replace(/=+$/, "").length;
3914
4044
  return e > 2 ? null : s.length / 4 * 3 - e;
3915
4045
  }
3916
- function gi(s) {
4046
+ function Ai(s) {
3917
4047
  return (typeof s == "string" ? s.trim() : "") || "Page image";
3918
4048
  }
3919
- function fi(s) {
4049
+ function Mi(s) {
3920
4050
  try {
3921
4051
  s();
3922
4052
  } catch {
3923
4053
  }
3924
4054
  }
3925
- function yi(s) {
4055
+ function bi(s) {
3926
4056
  return new Promise((e, t) => {
3927
4057
  const n = new FileReader();
3928
4058
  n.onload = () => {
@@ -3934,9 +4064,9 @@ function yi(s) {
3934
4064
  }, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
3935
4065
  });
3936
4066
  }
3937
- async function Nt(s, e) {
4067
+ async function zt(s, e) {
3938
4068
  const t = Object.getPrototypeOf(async function() {
3939
- }).constructor, n = s.timeoutMs ?? ri, i = Date.now(), r = [];
4069
+ }).constructor, n = s.timeoutMs ?? pi, i = Date.now(), r = [];
3940
4070
  let o;
3941
4071
  const a = {
3942
4072
  log: console.log,
@@ -3954,7 +4084,7 @@ async function Nt(s, e) {
3954
4084
  o = window.setTimeout(() => h(c), n);
3955
4085
  })
3956
4086
  ]);
3957
- return u === c ? Ii(n) : {
4087
+ return u === c ? Ei(n) : {
3958
4088
  ok: !0,
3959
4089
  result: u,
3960
4090
  console: r,
@@ -3983,7 +4113,7 @@ async function Nt(s, e) {
3983
4113
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
3984
4114
  }
3985
4115
  }
3986
- function mi(s, e) {
4116
+ function Ri(s, e) {
3987
4117
  if (!s || typeof s != "object")
3988
4118
  return;
3989
4119
  const t = s.sandboxFilesToken;
@@ -3993,7 +4123,7 @@ function mi(s, e) {
3993
4123
  const i = () => {
3994
4124
  if (!n)
3995
4125
  throw new Error("sandboxFiles is only available during browser-code execution");
3996
- }, r = async (a, l) => await Mn(`${e.replace(/\/$/, "")}${a}`, l);
4126
+ }, r = async (a, l) => await _n(`${e.replace(/\/$/, "")}${a}`, l);
3997
4127
  return {
3998
4128
  value: Object.freeze({
3999
4129
  upload: async (a) => {
@@ -4027,7 +4157,7 @@ function mi(s, e) {
4027
4157
  }
4028
4158
  };
4029
4159
  }
4030
- function Ii(s) {
4160
+ function Ei(s) {
4031
4161
  return {
4032
4162
  ok: !1,
4033
4163
  exception: {
@@ -4041,10 +4171,10 @@ function Ii(s) {
4041
4171
  }
4042
4172
  };
4043
4173
  }
4044
- function Si(s) {
4174
+ function ki(s) {
4045
4175
  return s.replace(/\/+$/, "");
4046
4176
  }
4047
- function Ti(s) {
4177
+ function Ci(s) {
4048
4178
  const e = {
4049
4179
  sidepanel: "extension_sidepanel",
4050
4180
  browser_extension_page_ui: "extension_widget",
@@ -4056,18 +4186,18 @@ function Ti(s) {
4056
4186
  };
4057
4187
  return s && s in e ? e[s] : s ?? "embedded_custom_ui";
4058
4188
  }
4059
- function wi(s) {
4189
+ function Pi(s) {
4060
4190
  return s === "pluno" ? "scheduled_continuation" : s ?? "user";
4061
4191
  }
4062
- function Ai(s, e = location.origin) {
4192
+ function _i(s, e = location.origin) {
4063
4193
  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;
4064
4194
  }
4065
- function Mi(s) {
4195
+ function vi(s) {
4066
4196
  const e = new URL("/api/product-agent/embed/ws", s);
4067
4197
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
4068
4198
  }
4069
- function v() {
4070
- const s = ps();
4199
+ function P() {
4200
+ const s = Rs();
4071
4201
  return {
4072
4202
  url: location.href,
4073
4203
  title: document.title,
@@ -4075,21 +4205,21 @@ function v() {
4075
4205
  ...s ? { plunoProductAgentUi: s } : {}
4076
4206
  };
4077
4207
  }
4078
- function bi() {
4208
+ function Ui() {
4079
4209
  return {
4080
4210
  pageUrl: location.href,
4081
4211
  pageTitle: document.title,
4082
- htmlContent: gt()
4212
+ htmlContent: St()
4083
4213
  };
4084
4214
  }
4085
- function Ri(s) {
4086
- return Me.add(s), ye || (ye = Ei()), () => {
4087
- Me.delete(s), Me.size === 0 && (ye?.(), ye = null);
4215
+ function Di(s) {
4216
+ return Ee.add(s), Se || (Se = qi()), () => {
4217
+ Ee.delete(s), Ee.size === 0 && (Se?.(), Se = null);
4088
4218
  };
4089
4219
  }
4090
- function Ei() {
4220
+ function qi() {
4091
4221
  const s = () => {
4092
- for (const r of Array.from(Me))
4222
+ for (const r of Array.from(Ee))
4093
4223
  r();
4094
4224
  }, e = window.history.pushState.bind(window.history), t = window.history.replaceState.bind(window.history), n = ((...r) => {
4095
4225
  const o = e(...r);
@@ -4102,35 +4232,35 @@ function Ei() {
4102
4232
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === i && (window.history.replaceState = t), window.removeEventListener("popstate", s), window.removeEventListener("hashchange", s);
4103
4233
  };
4104
4234
  }
4105
- function Xe() {
4106
- return ps()?.surface === "browser_extension_sdk_preview";
4235
+ function Ye() {
4236
+ return Rs()?.surface === "browser_extension_sdk_preview";
4107
4237
  }
4108
- function gt() {
4238
+ function St() {
4109
4239
  if (!document.body)
4110
4240
  return "";
4111
- const s = [], e = [], t = (p, y) => {
4112
- const g = se(y);
4241
+ const s = [], e = [], t = (p, m) => {
4242
+ const g = se(m);
4113
4243
  !g || e.includes(g) || (s.push([p, g]), e.push(g));
4114
4244
  };
4115
4245
  t("Selected text", window.getSelection()?.toString() ?? "");
4116
4246
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
4117
- (p) => us(p) && !p.parentElement?.closest(n)
4247
+ (p) => As(p) && !p.parentElement?.closest(n)
4118
4248
  );
4119
4249
  for (const p of i.slice(0, 3))
4120
- t("Active overlay", Je(ce(p), e));
4121
- const r = ki(), o = r ? Je(ce(r), e) : "";
4122
- t("Main page content", o), t("Additional visible page text", Je(ce(document.body), e));
4123
- const a = s.map(([p, y]) => `${p}:
4124
- ${y}`).join(`
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(`
4125
4255
 
4126
- `).trim().slice(0, 12e3), l = vi(i, r).trim(), c = `Simplified DOM outline:
4256
+ `).trim().slice(0, 12e3), l = xi(i, r).trim(), c = `Simplified DOM outline:
4127
4257
  `, u = `
4128
4258
 
4129
4259
  Visible page text:
4130
- `, h = 12e3 - c.length - u.length, f = Math.min(a.length, 7900), m = l.slice(0, h - f), d = a.slice(0, h - m.length);
4131
- return `${c}${m}${u}${d}`;
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}`;
4132
4262
  }
4133
- function ce(s) {
4263
+ function de(s) {
4134
4264
  return s.innerText ?? s.textContent ?? "";
4135
4265
  }
4136
4266
  function se(s) {
@@ -4141,20 +4271,20 @@ function se(s) {
4141
4271
 
4142
4272
  `).trim();
4143
4273
  }
4144
- function Je(s, e) {
4274
+ function Ze(s, e) {
4145
4275
  let t = se(s);
4146
4276
  for (const n of e)
4147
4277
  t = t.replace(n, "");
4148
4278
  return se(t);
4149
4279
  }
4150
- function us(s) {
4280
+ function As(s) {
4151
4281
  const e = window.getComputedStyle(s);
4152
4282
  return e.display !== "none" && e.visibility !== "hidden" && s.getClientRects().length > 0;
4153
4283
  }
4154
- function ki() {
4155
- return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(us).sort((s, e) => ce(e).length - ce(s).length)[0] ?? null;
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;
4156
4286
  }
4157
- function vi(s, e) {
4287
+ function xi(s, e) {
4158
4288
  const t = /* @__PURE__ */ new Set([
4159
4289
  "main",
4160
4290
  "nav",
@@ -4234,92 +4364,92 @@ function vi(s, e) {
4234
4364
  "data-test",
4235
4365
  "data-qa",
4236
4366
  "data-cy"
4237
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: h } = Ci(), f = new Set(s);
4367
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: h } = Li(), f = new Set(s);
4238
4368
  e && f.add(e);
4239
- let m = 0;
4369
+ let y = 0;
4240
4370
  const d = (w) => {
4241
4371
  const D = w.getAttribute("role");
4242
4372
  return D && !o.has(D) ? D : "";
4243
4373
  }, p = (w) => {
4244
4374
  const D = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
4245
4375
  return `${w.tagName.toLowerCase()}|${d(w)}|${D}`;
4246
- }, y = (w, D, H) => {
4376
+ }, m = (w, D, H) => {
4247
4377
  const S = (T, N) => {
4248
- const _ = T.tagName.toLowerCase(), ie = window.getComputedStyle(T), J = u.has(T);
4249
- if (m >= 1e3 && !J || H.has(T) || r.has(_) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || ie.display === "none" || ie.visibility === "hidden")
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")
4250
4380
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
4251
- m += 1;
4252
- const Y = d(T), Z = hs(T), de = a.has(Y) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(_) || _ === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), K = /* @__PURE__ */ new Map();
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();
4253
4383
  for (const I of B) {
4254
4384
  const b = p(I);
4255
- K.set(b, (K.get(b) ?? 0) + 1);
4385
+ Q.set(b, (Q.get(b) ?? 0) + 1);
4256
4386
  }
4257
- const he = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
4387
+ const fe = /* @__PURE__ */ new Map(), re = /* @__PURE__ */ new Map();
4258
4388
  for (const I of B) {
4259
4389
  const b = p(I), z = re.get(b) ?? 0;
4260
- re.set(b, z + 1), (K.get(b) ?? 0) > 8 && z >= 6 && !u.has(I) && he.set(b, (he.get(b) ?? 0) + 1);
4390
+ re.set(b, z + 1), (Q.get(b) ?? 0) > 8 && z >= 6 && !u.has(I) && fe.set(b, (fe.get(b) ?? 0) + 1);
4261
4391
  }
4262
- const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], It = [];
4392
+ const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Mt = [];
4263
4393
  for (const I of B) {
4264
- const b = p(I), z = K.get(b) ?? 0, wt = j.get(b) ?? 0;
4265
- if (j.set(b, wt + 1), z > 8 && wt >= 6 && !u.has(I)) {
4266
- U.has(b) || (q.push([`… ${he.get(b) ?? 0} similar siblings omitted`]), U.add(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));
4267
4397
  continue;
4268
4398
  }
4269
- const At = S(I, N);
4270
- It.push(At), q.push(At.lines);
4399
+ const kt = S(I, N);
4400
+ Mt.push(kt), q.push(kt.lines);
4271
4401
  }
4272
- const Le = [];
4402
+ const Ne = [];
4273
4403
  if (T.shadowRoot)
4274
4404
  for (const I of Array.from(T.shadowRoot.children))
4275
- I instanceof HTMLElement && Le.push(S(I, N + 1));
4276
- const pe = [...It, ...Le], xe = Z.length > 0 || de || pe.some((I) => I.hasUsefulContent), St = se(
4277
- [Z, ...pe.map((I) => I.textPreview)].filter(Boolean).join(" ")
4278
- ).slice(0, 180), qs = T.hasAttribute("contenteditable") && (Z.length > 0 || !T.querySelector("[contenteditable]")), Tt = c.some((I) => T.hasAttribute(I)) || !!Y || qs, Ne = (T.getClientRects().length > 0 || ie.display === "contents") && (t.has(_) || Tt || J) && (xe || J) && (!i.has(_) || xe || Tt || J), He = Ne ? 1 : 0, oe = [];
4279
- if (Ne) {
4280
- const I = pe.some((z) => z.containsTextElement), b = n.has(_) && !I ? St : Z;
4281
- oe.push(ds(T, l, o, b.slice(0, 180)));
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)));
4282
4412
  }
4283
4413
  for (const I of q)
4284
- oe.push(...Ie(I, He));
4285
- const Be = Le.flatMap((I) => I.lines);
4286
- if (Be.length > 0) {
4287
- const I = Be.slice(0, 20);
4288
- Be.length > I.length && I.push("… shadow DOM omitted");
4289
- const b = _.includes("tooltip") || _.includes("popper") || _.includes("loader");
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");
4290
4420
  if (N < 2 && !b) {
4291
- const z = Ne ? "#shadow-root" : `${_} #shadow-root`;
4292
- oe.push(...Ie([z, ...Ie(I, 1)], He));
4421
+ const z = Be ? "#shadow-root" : `${v} #shadow-root`;
4422
+ oe.push(...Te([z, ...Te(I, 1)], We));
4293
4423
  } else
4294
- oe.push(...Ie(I, He));
4424
+ oe.push(...Te(I, We));
4295
4425
  }
4296
4426
  return {
4297
4427
  lines: oe,
4298
- hasUsefulContent: xe,
4299
- textPreview: St,
4300
- containsTextElement: n.has(_) || pe.some((I) => I.containsTextElement)
4428
+ hasUsefulContent: He,
4429
+ textPreview: bt,
4430
+ containsTextElement: n.has(v) || me.some((I) => I.containsTextElement)
4301
4431
  };
4302
4432
  };
4303
4433
  return [`--- ${D} ---`, ...S(w, 0).lines].join(`
4304
4434
  `);
4305
4435
  }, g = [], M = se(window.getSelection()?.toString() ?? "");
4306
4436
  M && g.push(`--- selected text ---
4307
- ${JSON.stringify(M)}`), h.length > 0 && g.push(Pi(h, t, l, o));
4437
+ ${JSON.stringify(M)}`), h.length > 0 && g.push(Ni(h, t, l, o));
4308
4438
  for (const w of s.slice(0, 3))
4309
- g.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4310
- if (e && g.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
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) {
4311
4441
  const w = e || s.length ? "other visible DOM" : "visible DOM";
4312
- g.push(y(document.body, w, f));
4442
+ g.push(m(document.body, w, f));
4313
4443
  }
4314
4444
  return g.join(`
4315
4445
 
4316
4446
  `);
4317
4447
  }
4318
- function ds(s, e, t, n) {
4448
+ function Ms(s, e, t, n) {
4319
4449
  const i = s.tagName.toLowerCase();
4320
4450
  let r = i;
4321
4451
  const o = s.getAttribute("id");
4322
- o && _i(o) && (r += `#${o}`);
4452
+ o && Hi(o) && (r += `#${o}`);
4323
4453
  for (const a of e) {
4324
4454
  const l = s.getAttribute(a);
4325
4455
  l && l.length <= 160 && (a !== "role" || !t.has(l)) && (r += `[${a}=${JSON.stringify(l)}]`);
@@ -4332,7 +4462,7 @@ function ds(s, e, t, n) {
4332
4462
  s.hasAttribute(a) && (r += `[${a}]`);
4333
4463
  return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
4334
4464
  }
4335
- function Ci() {
4465
+ function Li() {
4336
4466
  const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
4337
4467
  if (!a)
4338
4468
  return;
@@ -4353,7 +4483,7 @@ function Ci() {
4353
4483
  n = n.shadowRoot.activeElement;
4354
4484
  n !== document.body && n !== document.documentElement && t(n, "focused");
4355
4485
  const i = window.getSelection();
4356
- i && !i.isCollapsed && (t(Ht(i.anchorNode), "selected text"), t(Ht(i.focusNode), "selected text"));
4486
+ i && !i.isCollapsed && (t(Kt(i.anchorNode), "selected text"), t(Kt(i.focusNode), "selected text"));
4357
4487
  const r = [
4358
4488
  ["[aria-selected='true']", "selected"],
4359
4489
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -4375,7 +4505,7 @@ function Ci() {
4375
4505
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
4376
4506
  };
4377
4507
  }
4378
- function Pi(s, e, t, n) {
4508
+ function Ni(s, e, t, n) {
4379
4509
  const i = ["--- active/current elements ---"];
4380
4510
  for (const r of s) {
4381
4511
  const o = [];
@@ -4386,37 +4516,37 @@ function Pi(s, e, t, n) {
4386
4516
  const h = a.getRootNode();
4387
4517
  a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
4388
4518
  }
4389
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => ds(
4519
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => Ms(
4390
4520
  u,
4391
4521
  t,
4392
4522
  n,
4393
- h === l.length - 1 ? hs(u).slice(0, 180) : ""
4523
+ h === l.length - 1 ? bs(u).slice(0, 180) : ""
4394
4524
  ));
4395
4525
  o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
4396
4526
  }
4397
4527
  return i.join(`
4398
4528
  `);
4399
4529
  }
4400
- function Ht(s) {
4530
+ function Kt(s) {
4401
4531
  return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
4402
4532
  }
4403
- function Ie(s, e) {
4533
+ function Te(s, e) {
4404
4534
  if (e === 0)
4405
4535
  return s;
4406
4536
  const t = " ".repeat(e);
4407
4537
  return s.map((n) => `${t}${n}`);
4408
4538
  }
4409
- function hs(s) {
4539
+ function bs(s) {
4410
4540
  return se(
4411
4541
  Array.from(s.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
4412
4542
  );
4413
4543
  }
4414
- function _i(s) {
4544
+ function Hi(s) {
4415
4545
  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);
4416
4546
  }
4417
- function ps() {
4418
- const s = Array.from(document.querySelectorAll(Ct)), e = s.find(
4419
- (r) => typeof r[kn] == "string"
4547
+ function Rs() {
4548
+ const s = Array.from(document.querySelectorAll(xt)), e = s.find(
4549
+ (r) => typeof r[qn] == "string"
4420
4550
  );
4421
4551
  if (!(e ?? s[0]))
4422
4552
  return;
@@ -4427,28 +4557,28 @@ function ps() {
4427
4557
  selectors: [
4428
4558
  {
4429
4559
  name: "widget_host",
4430
- selector: Ct,
4560
+ selector: xt,
4431
4561
  description: "Finds Pluno's shadow-host element in the host page DOM."
4432
4562
  },
4433
4563
  {
4434
4564
  name: "widget_root",
4435
- selector: bn,
4565
+ selector: vn,
4436
4566
  description: "Finds Pluno's widget root inside the widget host shadow root."
4437
4567
  },
4438
4568
  {
4439
4569
  name: "widget_panel",
4440
- selector: Rn,
4570
+ selector: Un,
4441
4571
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
4442
4572
  },
4443
4573
  {
4444
4574
  name: "widget_timeline",
4445
- selector: En,
4575
+ selector: Dn,
4446
4576
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
4447
4577
  }
4448
4578
  ]
4449
4579
  };
4450
4580
  }
4451
- function Ui(s) {
4581
+ function Bi(s) {
4452
4582
  try {
4453
4583
  const e = JSON.parse(s);
4454
4584
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -4456,7 +4586,7 @@ function Ui(s) {
4456
4586
  return { type: "error", message: "Invalid server event" };
4457
4587
  }
4458
4588
  }
4459
- function Di(s) {
4589
+ function Wi(s) {
4460
4590
  if (typeof s != "string")
4461
4591
  return null;
4462
4592
  try {
@@ -4466,13 +4596,13 @@ function Di(s) {
4466
4596
  return null;
4467
4597
  }
4468
4598
  }
4469
- function Bt(s, e) {
4599
+ function Gt(s, e) {
4470
4600
  if (!s || typeof s != "object")
4471
4601
  return [];
4472
4602
  const t = s[e];
4473
4603
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
4474
4604
  }
4475
- function Wt(s) {
4605
+ function Qt(s) {
4476
4606
  return Array.isArray(s) ? s.flatMap((e) => {
4477
4607
  if (!e || typeof e != "object")
4478
4608
  return [];
@@ -4480,10 +4610,10 @@ function Wt(s) {
4480
4610
  return typeof t.taskId != "string" || !t.taskId || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? [] : [{ taskId: t.taskId, dueAt: t.dueAt }];
4481
4611
  }) : [];
4482
4612
  }
4483
- function qi(s) {
4613
+ function $i(s) {
4484
4614
  return Array.isArray(s) ? s.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
4485
4615
  }
4486
- function Oi(s) {
4616
+ function Fi(s) {
4487
4617
  if (!s || typeof s != "object")
4488
4618
  return null;
4489
4619
  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;
@@ -4494,13 +4624,13 @@ function Oi(s) {
4494
4624
  ...a !== null ? { scribbleStyle: a } : {}
4495
4625
  };
4496
4626
  }
4497
- function Li(s) {
4627
+ function ji(s) {
4498
4628
  if (!s || typeof s != "object")
4499
4629
  return null;
4500
4630
  const e = s.javascript;
4501
4631
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
4502
4632
  }
4503
- function xi(s, e) {
4633
+ function zi(s, e) {
4504
4634
  return e ? s && typeof s == "object" ? {
4505
4635
  ...s,
4506
4636
  helperError: e
@@ -4510,23 +4640,23 @@ function xi(s, e) {
4510
4640
  helperError: e
4511
4641
  } : s;
4512
4642
  }
4513
- function Ni(s) {
4643
+ function Ki(s) {
4514
4644
  if (!s || typeof s != "object")
4515
4645
  return s;
4516
4646
  const e = s;
4517
4647
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : s;
4518
4648
  }
4519
- function Hi() {
4649
+ function Gi() {
4520
4650
  const s = "pluno.productAgent.clientId", e = window.localStorage.getItem(s);
4521
4651
  if (e)
4522
4652
  return e;
4523
4653
  const t = crypto.randomUUID();
4524
4654
  return window.localStorage.setItem(s, t), t;
4525
4655
  }
4526
- function L() {
4656
+ function x() {
4527
4657
  return crypto.randomUUID();
4528
4658
  }
4529
- function Bi(s) {
4659
+ function Qi(s) {
4530
4660
  if (!s || typeof s != "object")
4531
4661
  return null;
4532
4662
  const e = s, t = typeof e.id == "string" ? e.id : null;
@@ -4537,12 +4667,12 @@ function Bi(s) {
4537
4667
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
4538
4668
  } : null;
4539
4669
  }
4540
- function $t(s, e) {
4541
- return Array.isArray(s) ? ot(
4542
- s.map((t) => gs(t, e)).filter((t) => t !== null)
4670
+ function et(s, e) {
4671
+ return Array.isArray(s) ? ut(
4672
+ s.map((t) => rt(t, e)).filter((t) => t !== null)
4543
4673
  ) : [];
4544
4674
  }
4545
- function Wi(s) {
4675
+ function Vi(s) {
4546
4676
  return Array.isArray(s) ? s.flatMap((e) => {
4547
4677
  if (!e || typeof e != "object")
4548
4678
  return [];
@@ -4563,27 +4693,27 @@ function Wi(s) {
4563
4693
  ];
4564
4694
  }) : [];
4565
4695
  }
4566
- function gs(s, e) {
4696
+ function rt(s, e) {
4567
4697
  if (!s || typeof s != "object")
4568
4698
  return null;
4569
4699
  const t = s, n = t.data;
4570
4700
  if (!n || typeof n != "object")
4571
4701
  return null;
4572
4702
  const i = n;
4573
- if (i.hiddenFromTranscript === !0 || Gs(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
4703
+ if (i.hiddenFromTranscript === !0 || sn(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
4574
4704
  return null;
4575
4705
  if (i.type === "assistant_draft")
4576
4706
  return {
4577
4707
  id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
4578
4708
  role: "assistant",
4579
4709
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4580
- content: Mt(
4581
- Ft(i.content),
4710
+ content: Ct(
4711
+ Vt(i.content),
4582
4712
  e
4583
4713
  ),
4584
4714
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4585
4715
  ...k(i) !== null ? { displaySequence: k(i) } : {},
4586
- ...C(i) !== null ? { causalSequence: C(i) } : {},
4716
+ ..._(i) !== null ? { causalSequence: _(i) } : {},
4587
4717
  respondsToUserMessageId: O(i) ?? void 0,
4588
4718
  ...E(i) ? { runId: E(i) } : {},
4589
4719
  dataType: "assistant_draft",
@@ -4594,16 +4724,16 @@ function gs(s, e) {
4594
4724
  id: String(t.id ?? crypto.randomUUID()),
4595
4725
  role: r,
4596
4726
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4597
- content: Mt(
4598
- Ft(i.content),
4727
+ content: Ct(
4728
+ Vt(i.content),
4599
4729
  e
4600
4730
  ),
4601
4731
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4602
4732
  ...k(i) !== null ? { displaySequence: k(i) } : {},
4603
- ...C(i) !== null ? { causalSequence: C(i) } : {},
4733
+ ..._(i) !== null ? { causalSequence: _(i) } : {},
4604
4734
  respondsToUserMessageId: O(i) ?? void 0,
4605
4735
  ...E(i) ? { runId: E(i) } : {},
4606
- attachments: Ms(i.attachments, e),
4736
+ attachments: Us(i.attachments, e),
4607
4737
  ...i.steered === !0 ? { steered: !0 } : {}
4608
4738
  };
4609
4739
  return r === "assistant" && typeof i.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
@@ -4618,7 +4748,7 @@ function gs(s, e) {
4618
4748
  }), o;
4619
4749
  }
4620
4750
  if (i.type === "function_call_output") {
4621
- const r = Fs(i.output);
4751
+ const r = Ys(i.output);
4622
4752
  if (r !== null)
4623
4753
  return {
4624
4754
  id: String(t.id ?? crypto.randomUUID()),
@@ -4629,11 +4759,11 @@ function gs(s, e) {
4629
4759
  respondsToUserMessageId: O(i) ?? void 0,
4630
4760
  ...E(i) ? { runId: E(i) } : {},
4631
4761
  dataType: "function_call_output",
4632
- toolName: Zt,
4633
- callId: le(i) ?? void 0,
4762
+ toolName: ds,
4763
+ callId: ce(i) ?? void 0,
4634
4764
  sharePromptAllowed: r
4635
4765
  };
4636
- const o = on(i.output);
4766
+ const o = gn(i.output);
4637
4767
  if (o)
4638
4768
  return {
4639
4769
  id: String(t.id ?? crypto.randomUUID()),
@@ -4644,24 +4774,24 @@ function gs(s, e) {
4644
4774
  respondsToUserMessageId: O(i) ?? void 0,
4645
4775
  ...E(i) ? { runId: E(i) } : {},
4646
4776
  dataType: "scheduled_check_in",
4647
- toolName: ts,
4648
- callId: le(i) ?? void 0,
4777
+ toolName: ps,
4778
+ callId: ce(i) ?? void 0,
4649
4779
  scheduledCheckInId: o.id ?? void 0,
4650
4780
  scheduledCheckInAt: o.dueAt
4651
4781
  };
4652
- const a = Fi(i.output), l = ji(i.output);
4782
+ const a = Ji(i.output), l = Yi(i.output);
4653
4783
  return a ? {
4654
4784
  id: String(t.id ?? crypto.randomUUID()),
4655
4785
  role: "tool",
4656
4786
  content: `Connect ${a.appName} to continue`,
4657
4787
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4658
4788
  ...k(i) !== null ? { displaySequence: k(i) } : {},
4659
- ...C(i) !== null ? { causalSequence: C(i) } : {},
4789
+ ..._(i) !== null ? { causalSequence: _(i) } : {},
4660
4790
  respondsToUserMessageId: O(i) ?? void 0,
4661
4791
  ...E(i) ? { runId: E(i) } : {},
4662
4792
  dataType: "function_call_output",
4663
4793
  toolName: "authenticate_pipedream_app",
4664
- callId: le(i) ?? void 0,
4794
+ callId: ce(i) ?? void 0,
4665
4795
  integrationAuthRequest: a
4666
4796
  } : l ? {
4667
4797
  id: String(t.id ?? crypto.randomUUID()),
@@ -4669,36 +4799,36 @@ function gs(s, e) {
4669
4799
  content: "Connect WhatsApp to continue",
4670
4800
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4671
4801
  ...k(i) !== null ? { displaySequence: k(i) } : {},
4672
- ...C(i) !== null ? { causalSequence: C(i) } : {},
4802
+ ..._(i) !== null ? { causalSequence: _(i) } : {},
4673
4803
  respondsToUserMessageId: O(i) ?? void 0,
4674
4804
  ...E(i) ? { runId: E(i) } : {},
4675
4805
  dataType: "function_call_output",
4676
4806
  toolName: "request_personal_channel_connection",
4677
- callId: le(i) ?? void 0,
4807
+ callId: ce(i) ?? void 0,
4678
4808
  personalChannelConnectionRequest: l
4679
4809
  } : null;
4680
4810
  }
4681
4811
  return i.type === "function_call" || i.type === "tool_call" || i.type === "web_search_call" || i.type === "mcp_call" || i.type === "tab_lifecycle_decision" ? {
4682
4812
  id: String(t.id ?? crypto.randomUUID()),
4683
4813
  role: "tool",
4684
- content: i.type === "mcp_call" ? $i(i) : Ki(i),
4814
+ content: i.type === "mcp_call" ? Xi(i) : er(i),
4685
4815
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4686
4816
  ...k(i) !== null ? { displaySequence: k(i) } : {},
4687
- ...C(i) !== null ? { causalSequence: C(i) } : {},
4817
+ ..._(i) !== null ? { causalSequence: _(i) } : {},
4688
4818
  respondsToUserMessageId: O(i) ?? void 0,
4689
4819
  ...E(i) ? { runId: E(i) } : {},
4690
4820
  dataType: String(i.type),
4691
4821
  toolName: i.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof i.name == "string" ? i.name : void 0,
4692
- callId: le(i) ?? void 0,
4822
+ callId: ce(i) ?? void 0,
4693
4823
  loading: i.steered === !0 ? !1 : i.localExecutionStatus === "queued" || i.localExecutionStatus === "running" ? !0 : typeof i.localExecutionStatus == "string" ? !1 : void 0,
4694
4824
  ...i.steered === !0 ? { steered: !0 } : {}
4695
4825
  } : i.type === "run_status" || i.type === "run_error" ? i.type === "run_error" && i.stage === "tool_execution" ? null : {
4696
4826
  id: String(t.id ?? crypto.randomUUID()),
4697
4827
  role: "system",
4698
- content: zi(i),
4828
+ content: Zi(i),
4699
4829
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4700
4830
  ...k(i) !== null ? { displaySequence: k(i) } : {},
4701
- ...C(i) !== null ? { causalSequence: C(i) } : {},
4831
+ ..._(i) !== null ? { causalSequence: _(i) } : {},
4702
4832
  respondsToUserMessageId: O(i) ?? void 0,
4703
4833
  ...E(i) ? { runId: E(i) } : {},
4704
4834
  dataType: String(i.type),
@@ -4708,11 +4838,11 @@ function gs(s, e) {
4708
4838
  ...typeof i.securitySettingsUrl == "string" ? { securitySettingsUrl: i.securitySettingsUrl } : {}
4709
4839
  } : null;
4710
4840
  }
4711
- function $i(s) {
4841
+ function Xi(s) {
4712
4842
  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(" ");
4713
4843
  return t ? `🔌 Using ${t}` : "🔌 Using connected integration";
4714
4844
  }
4715
- function Fi(s) {
4845
+ function Ji(s) {
4716
4846
  if (typeof s != "string")
4717
4847
  return null;
4718
4848
  try {
@@ -4729,7 +4859,7 @@ function Fi(s) {
4729
4859
  return null;
4730
4860
  }
4731
4861
  }
4732
- function ji(s) {
4862
+ function Yi(s) {
4733
4863
  if (typeof s != "string")
4734
4864
  return null;
4735
4865
  try {
@@ -4744,10 +4874,10 @@ function ji(s) {
4744
4874
  return null;
4745
4875
  }
4746
4876
  }
4747
- function zi(s) {
4877
+ function Zi(s) {
4748
4878
  return s.type === "run_status" && s.status === "steered" ? "Steered" : typeof s.message == "string" && s.message.trim().length > 0 ? s.message : "";
4749
4879
  }
4750
- function Ki(s) {
4880
+ function er(s) {
4751
4881
  if (s.type === "web_search_call") {
4752
4882
  const e = s.action;
4753
4883
  if (e && typeof e == "object") {
@@ -4759,9 +4889,9 @@ function Ki(s) {
4759
4889
  }
4760
4890
  return "🔎 Searching the web";
4761
4891
  }
4762
- return Gi(s);
4892
+ return tr(s);
4763
4893
  }
4764
- function Gi(s) {
4894
+ function tr(s) {
4765
4895
  if (typeof s.summary == "string" && s.summary.trim().length > 0)
4766
4896
  return te(s.summary);
4767
4897
  if (typeof s.arguments == "string")
@@ -4778,7 +4908,7 @@ function te(s) {
4778
4908
  const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
4779
4909
  return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
4780
4910
  }
4781
- function Qi(s) {
4911
+ function sr(s) {
4782
4912
  if (s == null)
4783
4913
  return s;
4784
4914
  if (typeof s != "object")
@@ -4793,17 +4923,17 @@ function Qi(s) {
4793
4923
  runId: typeof e.runId == "string" ? e.runId : null
4794
4924
  };
4795
4925
  }
4796
- function le(s) {
4926
+ function ce(s) {
4797
4927
  const e = s.callId ?? s.call_id;
4798
4928
  return typeof e == "string" && e ? e : null;
4799
4929
  }
4800
- function C(s) {
4930
+ function _(s) {
4801
4931
  return typeof s.causalSequence == "number" && Number.isSafeInteger(s.causalSequence) ? s.causalSequence : null;
4802
4932
  }
4803
4933
  function k(s) {
4804
4934
  return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
4805
4935
  }
4806
- function Ft(s) {
4936
+ function Vt(s) {
4807
4937
  return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
4808
4938
  if (!e || typeof e != "object")
4809
4939
  return "";
@@ -4811,14 +4941,14 @@ function Ft(s) {
4811
4941
  return typeof t.text == "string" ? t.text : typeof t.content == "string" ? t.content : "";
4812
4942
  }).filter(Boolean).join("") : "";
4813
4943
  }
4814
- function nt(s, e) {
4815
- const t = ms(
4944
+ function ue(s, e) {
4945
+ const t = Es(
4816
4946
  s,
4817
- ft(s, e)
4818
- ), n = tr(
4819
- Xi(
4820
- rr(
4821
- Vi(s, e),
4947
+ Tt(s, e)
4948
+ ), n = rr(
4949
+ ir(
4950
+ cr(
4951
+ nr(s, e),
4822
4952
  e
4823
4953
  ),
4824
4954
  t
@@ -4826,13 +4956,13 @@ function nt(s, e) {
4826
4956
  t
4827
4957
  ), i = n.findIndex((o) => o.id === t.id);
4828
4958
  if (i === -1)
4829
- return ot(
4959
+ return ut(
4830
4960
  [...n, t]
4831
4961
  );
4832
4962
  const r = [...n];
4833
- return r[i] = t, ot(r);
4963
+ return r[i] = t, ut(r);
4834
4964
  }
4835
- function ft(s, e, t = !0) {
4965
+ function Tt(s, e, t = !0) {
4836
4966
  const n = s.find(
4837
4967
  (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)
4838
4968
  );
@@ -4843,7 +4973,7 @@ function ft(s, e, t = !0) {
4843
4973
  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] : []);
4844
4974
  return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
4845
4975
  }
4846
- function Vi(s, e) {
4976
+ function nr(s, e) {
4847
4977
  const t = e.proactiveSuggestionClientMessageId;
4848
4978
  if (!t)
4849
4979
  return s;
@@ -4853,16 +4983,16 @@ function Vi(s, e) {
4853
4983
  const r = [...s];
4854
4984
  return r[i] = e, r;
4855
4985
  }
4856
- function Xi(s, e) {
4986
+ function ir(s, e) {
4857
4987
  const t = e.assistantDraftItemId;
4858
4988
  return t ? s.map(
4859
4989
  (n) => n.dataType === "assistant_draft" && n.id === t ? e : n
4860
4990
  ) : s;
4861
4991
  }
4862
- function Ye(s, e, t) {
4992
+ function we(s, e, t) {
4863
4993
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
4864
4994
  }
4865
- function Ji(s, e, t, n) {
4995
+ function Xt(s, e, t, n) {
4866
4996
  if (t === null) return s;
4867
4997
  let i = -1;
4868
4998
  for (let o = s.length - 1; o >= 0; o -= 1) {
@@ -4879,12 +5009,12 @@ function Ji(s, e, t, n) {
4879
5009
  respondsToUserMessageId: t
4880
5010
  }, r;
4881
5011
  }
4882
- function Yi(s, e) {
5012
+ function Jt(s, e) {
4883
5013
  const t = s.findIndex(
4884
5014
  (i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
4885
5015
  );
4886
5016
  if (t === -1)
4887
- return nt(s, e);
5017
+ return ue(s, e);
4888
5018
  const n = [...s];
4889
5019
  return n[t] = {
4890
5020
  ...n[t],
@@ -4896,12 +5026,12 @@ function Yi(s, e) {
4896
5026
  ...n[t].runId ? {} : { runId: e.runId }
4897
5027
  }, n;
4898
5028
  }
4899
- function Zi(s, e, t) {
5029
+ function Yt(s, e, t) {
4900
5030
  let n = !1;
4901
5031
  const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
4902
5032
  return n ? i : s;
4903
5033
  }
4904
- function er(s) {
5034
+ function Zt(s) {
4905
5035
  if (s.hiddenFromTranscript === !0)
4906
5036
  return null;
4907
5037
  const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
@@ -4921,7 +5051,7 @@ function er(s) {
4921
5051
  loading: !0
4922
5052
  };
4923
5053
  }
4924
- function tr(s, e) {
5054
+ function rr(s, e) {
4925
5055
  if (e.id.startsWith("transient-activity:"))
4926
5056
  return s;
4927
5057
  const t = e.toolName === "tab_lifecycle";
@@ -4930,30 +5060,30 @@ function tr(s, e) {
4930
5060
  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);
4931
5061
  return i === -1 ? s : s.flatMap((r, o) => n(r) ? o === i ? [e] : [] : r.id === e.id ? [] : [r]);
4932
5062
  }
4933
- function fs(s, e) {
5063
+ function ot(s, e) {
4934
5064
  const t = [];
4935
5065
  for (const n of e) {
4936
5066
  const i = [...s, ...t];
4937
5067
  t.push(
4938
- ms(
5068
+ Es(
4939
5069
  i,
4940
- ft(i, n, !1)
5070
+ Tt(i, n, !1)
4941
5071
  )
4942
5072
  );
4943
5073
  }
4944
- return Qs(
5074
+ return nn(
4945
5075
  s,
4946
5076
  t,
4947
- ys
5077
+ at
4948
5078
  );
4949
5079
  }
4950
- function sr(s, e) {
5080
+ function or(s, e) {
4951
5081
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
4952
- (r) => ft(s, r, !1)
5082
+ (r) => Tt(s, r, !1)
4953
5083
  );
4954
5084
  for (const r of n)
4955
5085
  t.set(r.id, r);
4956
- const i = fs(
5086
+ const i = ot(
4957
5087
  s,
4958
5088
  [...t.values()]
4959
5089
  );
@@ -4968,8 +5098,8 @@ function sr(s, e) {
4968
5098
  }
4969
5099
  return i;
4970
5100
  }
4971
- function ys(s) {
4972
- const e = V(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5101
+ function at(s) {
5102
+ const e = X(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
4973
5103
  // Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
4974
5104
  // from substituting the call for its output and then appending a duplicate output at the end of the timeline.
4975
5105
  ...s.callId ? [`${n ? "call-output" : "call"}:${s.callId}`] : [],
@@ -4982,55 +5112,55 @@ function ys(s) {
4982
5112
  ...i.length > 0 ? { activityKeys: i } : {},
4983
5113
  ...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
4984
5114
  ...s.runId ? { runId: s.runId } : {},
4985
- isOptimistic: qe(s),
5115
+ isOptimistic: xe(s),
4986
5116
  isAssistantDraft: s.dataType === "assistant_draft",
4987
5117
  isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
4988
5118
  isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
4989
5119
  };
4990
5120
  }
4991
- function ms(s, e) {
5121
+ function Es(s, e) {
4992
5122
  if (e.role !== "user" || !e.attachments?.length)
4993
5123
  return e;
4994
5124
  const t = s.find(
4995
- (o) => o.role === "user" && (o.id === e.id || qe(o) && Is(o, e))
5125
+ (o) => o.role === "user" && (o.id === e.id || xe(o) && ks(o, e))
4996
5126
  );
4997
5127
  if (!t?.attachments?.length)
4998
5128
  return e;
4999
5129
  const n = e.attachments.map((o) => {
5000
- const a = nr(t.attachments ?? [], o);
5001
- return a ? ir(o, a) : o;
5002
- }), i = { ...e, attachments: n }, r = V(e);
5130
+ const a = ar(t.attachments ?? [], o);
5131
+ return a ? lr(o, a) : o;
5132
+ }), i = { ...e, attachments: n }, r = X(e);
5003
5133
  return r && Object.defineProperty(i, "clientMessageId", {
5004
5134
  value: r,
5005
5135
  enumerable: !1
5006
5136
  }), i;
5007
5137
  }
5008
- function nr(s, e) {
5138
+ function ar(s, e) {
5009
5139
  return e.id ? s.find((t) => t.id === e.id) ?? null : null;
5010
5140
  }
5011
- function ir(s, e) {
5141
+ function lr(s, e) {
5012
5142
  const { previewUrl: t } = e;
5013
5143
  return t ? { ...s, previewUrl: t } : s;
5014
5144
  }
5015
- function rr(s, e) {
5145
+ function cr(s, e) {
5016
5146
  if (e.role !== "user")
5017
5147
  return s;
5018
5148
  const t = s.findIndex(
5019
- (i) => qe(i) && Is(i, e)
5149
+ (i) => xe(i) && ks(i, e)
5020
5150
  );
5021
5151
  if (t === -1)
5022
5152
  return s;
5023
5153
  const n = [...s];
5024
5154
  return n.splice(t, 1), n;
5025
5155
  }
5026
- function Is(s, e) {
5027
- const t = V(s), n = V(e);
5156
+ function ks(s, e) {
5157
+ const t = X(s), n = X(e);
5028
5158
  return t && n ? t === n : s.content === e.content;
5029
5159
  }
5030
- function qe(s) {
5160
+ function xe(s) {
5031
5161
  return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
5032
5162
  }
5033
- function V(s) {
5163
+ function X(s) {
5034
5164
  const e = s.clientMessageId;
5035
5165
  if (e)
5036
5166
  return e;
@@ -5039,13 +5169,13 @@ function V(s) {
5039
5169
  );
5040
5170
  return n ? s.id.slice(n.length) : null;
5041
5171
  }
5042
- function jt(s) {
5043
- const e = Ss(s);
5172
+ function es(s) {
5173
+ const e = Cs(s);
5044
5174
  if (e === null)
5045
5175
  return !1;
5046
5176
  const t = s[e].id;
5047
5177
  if (s.some(
5048
- (i) => i.respondsToUserMessageId === t && ke(i)
5178
+ (i) => i.respondsToUserMessageId === t && _e(i)
5049
5179
  ))
5050
5180
  return !0;
5051
5181
  for (let i = s.length - 1; i > e; i -= 1) {
@@ -5063,10 +5193,10 @@ function jt(s) {
5063
5193
  }
5064
5194
  return !1;
5065
5195
  }
5066
- function or(s, e, t) {
5196
+ function ur(s, e, t) {
5067
5197
  const n = new Set(
5068
5198
  s.filter(
5069
- (i) => i.role === "user" && e !== null && V(i) === e
5199
+ (i) => i.role === "user" && e !== null && X(i) === e
5070
5200
  ).map((i) => i.id)
5071
5201
  );
5072
5202
  return s.some((i, r) => {
@@ -5077,14 +5207,14 @@ function or(s, e, t) {
5077
5207
  if (t && i.runId === t) {
5078
5208
  if (n.size === 0)
5079
5209
  return !0;
5080
- const o = Ts(s, r);
5210
+ const o = Ps(s, r);
5081
5211
  return !i.respondsToUserMessageId && o !== null && n.has(o);
5082
5212
  }
5083
5213
  return !1;
5084
5214
  });
5085
5215
  }
5086
- function ar(s) {
5087
- const e = Ss(s);
5216
+ function dr(s) {
5217
+ const e = Cs(s);
5088
5218
  if (e === null)
5089
5219
  return s.some($);
5090
5220
  const t = s[e].id;
@@ -5092,13 +5222,13 @@ function ar(s) {
5092
5222
  (n) => n.respondsToUserMessageId === t && $(n)
5093
5223
  ) : s.slice(e + 1).some($);
5094
5224
  }
5095
- function Ss(s) {
5225
+ function Cs(s) {
5096
5226
  for (let e = s.length - 1; e >= 0; e -= 1)
5097
- if (s[e].role === "user" && !qe(s[e]))
5227
+ if (s[e].role === "user" && !xe(s[e]))
5098
5228
  return e;
5099
5229
  return null;
5100
5230
  }
5101
- function ke(s) {
5231
+ function _e(s) {
5102
5232
  return $(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5103
5233
  }
5104
5234
  function ne(s) {
@@ -5115,29 +5245,29 @@ function ne(s) {
5115
5245
  }
5116
5246
  return null;
5117
5247
  }
5118
- function lr(s) {
5248
+ function hr(s) {
5119
5249
  const e = ne(s);
5120
5250
  if (e === null)
5121
5251
  return null;
5122
- const n = P(s[e])?.page;
5252
+ const n = C(s[e])?.page;
5123
5253
  if (!n || typeof n != "object")
5124
5254
  return null;
5125
5255
  const i = n.url;
5126
5256
  return typeof i == "string" ? i : null;
5127
5257
  }
5128
- function P(s) {
5258
+ function C(s) {
5129
5259
  if (!s || typeof s != "object")
5130
5260
  return null;
5131
5261
  const e = s.data;
5132
5262
  return e && typeof e == "object" ? e : null;
5133
5263
  }
5134
- function ve(s) {
5264
+ function he(s) {
5135
5265
  return s?.retryable !== !0 ? !1 : s.type === "run_error" ? !0 : s.type === "run_status" && s.status === "interrupted";
5136
5266
  }
5137
- function cr(s) {
5267
+ function pr(s) {
5138
5268
  return s?.type === "run_status" && s.status === "interrupted" && s.reason === "backend_restart";
5139
5269
  }
5140
- function ur(s, e) {
5270
+ function gr(s, e) {
5141
5271
  const t = ne(e);
5142
5272
  if (t === null)
5143
5273
  return !1;
@@ -5146,10 +5276,10 @@ function ur(s, e) {
5146
5276
  return !1;
5147
5277
  const r = s.findIndex((o) => o.role === "user" && o.id === i);
5148
5278
  return r === -1 ? !1 : s.some((o) => o.respondsToUserMessageId === i) ? s.some(
5149
- (o) => o.respondsToUserMessageId === i && ke(o)
5150
- ) : s.slice(r + 1).some(ke);
5279
+ (o) => o.respondsToUserMessageId === i && _e(o)
5280
+ ) : s.slice(r + 1).some(_e);
5151
5281
  }
5152
- function it(s) {
5282
+ function lt(s) {
5153
5283
  const e = ne(s);
5154
5284
  if (e === null)
5155
5285
  return null;
@@ -5162,7 +5292,7 @@ function it(s) {
5162
5292
  const i = n.clientMessageId;
5163
5293
  return typeof i == "string" ? i : null;
5164
5294
  }
5165
- function dr(s) {
5295
+ function fr(s) {
5166
5296
  const e = ne(s);
5167
5297
  if (e === null)
5168
5298
  return null;
@@ -5177,45 +5307,45 @@ function dr(s) {
5177
5307
  if (r.type === "message" && r.role === "assistant")
5178
5308
  return null;
5179
5309
  if (r.type === "run_error")
5180
- return r.retryable !== !0 ? null : rt(s, r) ?? it(s);
5310
+ return r.retryable !== !0 ? null : ct(s, r) ?? lt(s);
5181
5311
  if (r.type === "run_status")
5182
- return r.status === "interrupted" && r.retryable === !0 ? rt(s, r) ?? it(s) : null;
5312
+ return r.status === "interrupted" && r.retryable === !0 ? ct(s, r) ?? lt(s) : null;
5183
5313
  }
5184
5314
  return null;
5185
5315
  }
5186
- function rt(s, e) {
5316
+ function ct(s, e) {
5187
5317
  if (typeof e.clientMessageId == "string")
5188
5318
  return e.clientMessageId;
5189
5319
  const t = O(e);
5190
5320
  if (!t)
5191
5321
  return null;
5192
- const n = s.find((r) => A(r, "id") === t), i = P(n);
5322
+ const n = s.find((r) => A(r, "id") === t), i = C(n);
5193
5323
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5194
5324
  }
5195
- function zt(s, e, t, n, i, r) {
5196
- if (!e || !pr(s))
5325
+ function ts(s, e, t, n, i, r) {
5326
+ if (!e || !yr(s))
5197
5327
  return !1;
5198
5328
  const o = s;
5199
- if (ve(o) || t !== null && typeof o.id == "string" && o.id !== t)
5329
+ if (he(o) || t !== null && typeof o.id == "string" && o.id !== t)
5200
5330
  return !1;
5201
5331
  const a = O(o);
5202
5332
  return n !== null ? a !== null ? a === n : i !== null && E(o) === i && r === n : i === null || E(o) === i;
5203
5333
  }
5204
- function hr(s, e) {
5334
+ function mr(s, e) {
5205
5335
  for (let t = e - 1; t >= 0; t -= 1) {
5206
- const n = P(s[t]);
5336
+ const n = C(s[t]);
5207
5337
  if (n?.type === "message" && n.role === "user")
5208
5338
  return A(s[t], "id");
5209
5339
  }
5210
5340
  return null;
5211
5341
  }
5212
- function Ts(s, e) {
5342
+ function Ps(s, e) {
5213
5343
  for (let t = e - 1; t >= 0; t -= 1)
5214
5344
  if (s[t].role === "user")
5215
5345
  return s[t].id;
5216
5346
  return null;
5217
5347
  }
5218
- function pr(s) {
5348
+ function yr(s) {
5219
5349
  if (!s || typeof s != "object")
5220
5350
  return !1;
5221
5351
  const e = s;
@@ -5224,61 +5354,74 @@ function pr(s) {
5224
5354
  function $(s) {
5225
5355
  return s.role === "assistant" && s.phase !== "commentary";
5226
5356
  }
5227
- function gr(s) {
5357
+ function Ir(s) {
5228
5358
  if (!s || typeof s != "object")
5229
5359
  return !1;
5230
5360
  const e = s;
5231
5361
  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";
5232
5362
  }
5233
- function ot(s) {
5234
- return s.filter((e, t) => X(e) ? !Er(s, t) && !ws(s, t) && !br(s, t) && !Rr(s, t) : fr(e) ? e.retryable === !0 && Mr(s, t) ? !1 : !Ar(s, t) : !0);
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);
5235
5365
  }
5236
- function fr(s) {
5366
+ function Sr(s) {
5237
5367
  return s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.steered !== !0);
5238
5368
  }
5239
- function X(s) {
5369
+ function G(s) {
5240
5370
  return s.role === "system" && s.dataType === "run_status" && s.loading === !0;
5241
5371
  }
5242
- function yr(s, e, t, n) {
5372
+ function dt(s) {
5373
+ return s.steered !== !0 && (s.dataType === "assistant_draft" || s.loading === !0);
5374
+ }
5375
+ function Tr(s) {
5376
+ return s.some(dt);
5377
+ }
5378
+ function ss(s, e) {
5379
+ return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5380
+ }
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]);
5384
+ }
5385
+ function Ar(s, e, t, n) {
5243
5386
  const i = s.findIndex(
5244
- (l, c) => X(l) && !ws(s, c)
5387
+ (l, c) => G(l) && !_s(s, c)
5245
5388
  ), r = i === -1 ? null : s[i], o = e ?? r?.respondsToUserMessageId ?? null, a = o ? s.find(
5246
5389
  (l) => l.role === "user" && l.id === o
5247
5390
  ) : null;
5248
5391
  return {
5249
- clientMessageId: a ? V(a) : o ? null : n,
5392
+ clientMessageId: a ? X(a) : o ? null : n,
5250
5393
  respondsToUserMessageId: o,
5251
5394
  runId: t ?? r?.runId ?? null
5252
5395
  };
5253
5396
  }
5254
- function be(s) {
5397
+ function ke(s) {
5255
5398
  return s?.type === "run_status" && s.status === "stopped";
5256
5399
  }
5257
- function mr(s, e) {
5258
- return $(e) ? "completed" : be(s) ? "stopped" : !ve(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
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;
5259
5402
  }
5260
- function Kt(s, e, t) {
5403
+ function ns(s, e, t) {
5261
5404
  const n = new Set(
5262
5405
  s.filter(
5263
- (i) => i.role === "user" && e !== null && V(i) === e
5406
+ (i) => i.role === "user" && e !== null && X(i) === e
5264
5407
  ).map((i) => i.id)
5265
5408
  );
5266
5409
  return s.filter(
5267
- (i) => !X(i) || (n.size > 0 ? !i.respondsToUserMessageId || !n.has(i.respondsToUserMessageId) : !t || i.runId !== t)
5410
+ (i) => !G(i) || (n.size > 0 ? !i.respondsToUserMessageId || !n.has(i.respondsToUserMessageId) : !t || i.runId !== t)
5268
5411
  );
5269
5412
  }
5270
- function ws(s, e) {
5413
+ function _s(s, e) {
5271
5414
  return s.some(
5272
- (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Ir(
5415
+ (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && br(
5273
5416
  s,
5274
5417
  e,
5275
5418
  n
5276
5419
  )
5277
5420
  );
5278
5421
  }
5279
- function Ir(s, e, t) {
5422
+ function br(s, e, t) {
5280
5423
  const n = s[e], i = s[t];
5281
- if (ue(n, i))
5424
+ if (pe(n, i))
5282
5425
  return !0;
5283
5426
  if (!n.respondsToUserMessageId || i.respondsToUserMessageId || !n.runId || n.runId !== i.runId)
5284
5427
  return !1;
@@ -5287,20 +5430,20 @@ function Ir(s, e, t) {
5287
5430
  return s[r].id === n.respondsToUserMessageId;
5288
5431
  return !1;
5289
5432
  }
5290
- function Sr(s, e, t, n) {
5433
+ function is(s, e, t, n) {
5291
5434
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5292
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && Gt(l) && !wr(
5435
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && rs(l) && !Er(
5293
5436
  s,
5294
5437
  l.respondsToUserMessageId
5295
5438
  )
5296
- )?.respondsToUserMessageId ?? Tr(
5439
+ )?.respondsToUserMessageId ?? Rr(
5297
5440
  s,
5298
5441
  e
5299
5442
  );
5300
5443
  if (!i)
5301
5444
  return s;
5302
5445
  let r = !1;
5303
- const o = s.map((l) => l.respondsToUserMessageId !== i || !Gt(l) ? l : (r = !0, { ...l, steered: !0 }));
5446
+ const o = s.map((l) => l.respondsToUserMessageId !== i || !rs(l) ? l : (r = !0, { ...l, steered: !0 }));
5304
5447
  if (r)
5305
5448
  return o;
5306
5449
  const a = s.find(
@@ -5322,7 +5465,7 @@ function Sr(s, e, t, n) {
5322
5465
  }
5323
5466
  ];
5324
5467
  }
5325
- function Tr(s, e) {
5468
+ function Rr(s, e) {
5326
5469
  const t = s.findIndex(
5327
5470
  (n) => n.role === "user" && n.id === e
5328
5471
  );
@@ -5333,24 +5476,24 @@ function Tr(s, e) {
5333
5476
  return s[n].id;
5334
5477
  return null;
5335
5478
  }
5336
- function Gt(s) {
5337
- return s.role === "tool" || X(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5479
+ function rs(s) {
5480
+ return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5338
5481
  }
5339
- function wr(s, e) {
5482
+ function Er(s, e) {
5340
5483
  return s.some(
5341
5484
  (t) => t.respondsToUserMessageId === e && ($(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5342
5485
  );
5343
5486
  }
5344
- function Ar(s, e) {
5487
+ function kr(s, e) {
5345
5488
  const t = s[e];
5346
5489
  for (let n = e + 1; n < s.length; n += 1) {
5347
5490
  const i = s[n];
5348
- if (i.role === "assistant" && ue(t, i))
5491
+ if (i.role === "assistant" && pe(t, i))
5349
5492
  return !0;
5350
5493
  }
5351
5494
  return !1;
5352
5495
  }
5353
- function Mr(s, e) {
5496
+ function Cr(s, e) {
5354
5497
  const t = s[e];
5355
5498
  if (!t.respondsToUserMessageId)
5356
5499
  return !1;
@@ -5358,45 +5501,45 @@ function Mr(s, e) {
5358
5501
  const i = s[n];
5359
5502
  if (i.role === "user")
5360
5503
  return !1;
5361
- if (i.respondsToUserMessageId === t.respondsToUserMessageId && (i.role === "assistant" || i.role === "tool" || X(i)))
5504
+ if (i.respondsToUserMessageId === t.respondsToUserMessageId && (i.role === "assistant" || i.role === "tool" || G(i)))
5362
5505
  return !0;
5363
5506
  }
5364
5507
  return !1;
5365
5508
  }
5366
- function br(s, e) {
5509
+ function Pr(s, e) {
5367
5510
  const t = s[e];
5368
5511
  return s.some(
5369
- (n, i) => i !== e && n.role === "assistant" && ue(t, n)
5512
+ (n, i) => i !== e && n.role === "assistant" && pe(t, n)
5370
5513
  );
5371
5514
  }
5372
- function Rr(s, e) {
5515
+ function _r(s, e) {
5373
5516
  const t = s[e];
5374
5517
  return s.some(
5375
- (n, i) => i !== e && n.role === "tool" && ue(t, n)
5518
+ (n, i) => i !== e && n.role === "tool" && pe(t, n)
5376
5519
  );
5377
5520
  }
5378
- function Er(s, e) {
5521
+ function vr(s, e) {
5379
5522
  const t = s[e];
5380
5523
  for (let n = e + 1; n < s.length; n += 1)
5381
- if (X(s[n]) && ue(t, s[n]))
5524
+ if (G(s[n]) && pe(t, s[n]))
5382
5525
  return !0;
5383
5526
  return !1;
5384
5527
  }
5385
- function ue(s, e) {
5528
+ function pe(s, e) {
5386
5529
  return !!(s.respondsToUserMessageId && s.respondsToUserMessageId === e.respondsToUserMessageId);
5387
5530
  }
5388
5531
  function A(s, e) {
5389
5532
  return s && typeof s == "object" && typeof s[e] == "string" ? s[e] : null;
5390
5533
  }
5391
- function kr(s, e) {
5534
+ function Ur(s, e) {
5392
5535
  try {
5393
- const t = window.localStorage.getItem(`${cs}${s}`);
5536
+ const t = window.localStorage.getItem(`${ws}${s}`);
5394
5537
  if (!t)
5395
5538
  return null;
5396
5539
  const n = JSON.parse(t), i = typeof n.sessionId == "string" ? n.sessionId : null;
5397
5540
  if (e !== void 0 && i !== e)
5398
5541
  return null;
5399
- const r = Array.isArray(n.messages) ? n.messages.map(Nr).filter((o) => !!o) : [];
5542
+ const r = Array.isArray(n.messages) ? n.messages.map(Fr).filter((o) => !!o) : [];
5400
5543
  return {
5401
5544
  sessionId: i,
5402
5545
  messages: r
@@ -5405,53 +5548,53 @@ function kr(s, e) {
5405
5548
  return null;
5406
5549
  }
5407
5550
  }
5408
- function at(s) {
5551
+ function ht(s) {
5409
5552
  return s.role === "user" || s.role === "assistant" || // Live activity is part of the readable conversation cache. Keeping it across host navigation prevents a
5410
5553
  // running tool or commentary history from disappearing while authoritative hydration is still in flight.
5411
5554
  s.role === "tool" || s.dataType === "run_status" || s.dataType === "run_error";
5412
5555
  }
5413
- function vr(s, e) {
5556
+ function Dr(s, e) {
5414
5557
  try {
5415
5558
  window.localStorage.setItem(
5416
- `${cs}${s}`,
5559
+ `${ws}${s}`,
5417
5560
  JSON.stringify({
5418
5561
  sessionId: e.sessionId,
5419
- messages: e.messages.filter(at).slice(-Jn).map(Hr)
5562
+ messages: e.messages.filter(ht).slice(-ii).map(jr)
5420
5563
  })
5421
5564
  );
5422
5565
  } catch {
5423
5566
  return;
5424
5567
  }
5425
5568
  }
5426
- function Cr(s) {
5569
+ function qr(s) {
5427
5570
  try {
5428
- const e = window.localStorage.getItem(`${st}${s}`);
5571
+ const e = window.localStorage.getItem(`${it}${s}`);
5429
5572
  if (!e)
5430
5573
  return [];
5431
5574
  const t = JSON.parse(e);
5432
- return Array.isArray(t) ? t.filter(yt) : [];
5575
+ return Array.isArray(t) ? t.filter(wt) : [];
5433
5576
  } catch {
5434
5577
  return [];
5435
5578
  }
5436
5579
  }
5437
- function Q(s, e) {
5580
+ function V(s, e) {
5438
5581
  try {
5439
- const t = e.filter(yt);
5582
+ const t = e.filter(wt);
5440
5583
  if (t.length === 0) {
5441
- window.localStorage.removeItem(`${st}${s}`);
5584
+ window.localStorage.removeItem(`${it}${s}`);
5442
5585
  return;
5443
5586
  }
5444
5587
  window.localStorage.setItem(
5445
- `${st}${s}`,
5588
+ `${it}${s}`,
5446
5589
  JSON.stringify(t.slice(-25))
5447
5590
  );
5448
5591
  } catch {
5449
5592
  return;
5450
5593
  }
5451
5594
  }
5452
- function As(s, e) {
5595
+ function vs(s, e) {
5453
5596
  try {
5454
- const t = `${Ue}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5597
+ const t = `${qe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5455
5598
  ...o,
5456
5599
  storedAt: Date.now(),
5457
5600
  unloadUrl: n,
@@ -5465,28 +5608,28 @@ function As(s, e) {
5465
5608
  } catch {
5466
5609
  }
5467
5610
  }
5468
- function Qt(s, e) {
5611
+ function os(s, e) {
5469
5612
  try {
5470
- if (window.sessionStorage.getItem(`${Ue}${s}`) === null)
5613
+ if (window.sessionStorage.getItem(`${qe}${s}`) === null)
5471
5614
  return;
5472
5615
  } catch {
5473
5616
  return;
5474
5617
  }
5475
- As(s, e);
5618
+ vs(s, e);
5476
5619
  }
5477
- function Pr(s) {
5620
+ function Or(s) {
5478
5621
  try {
5479
- const e = `${Ue}${s}`, t = window.sessionStorage.getItem(e);
5622
+ const e = `${qe}${s}`, t = window.sessionStorage.getItem(e);
5480
5623
  if (window.sessionStorage.removeItem(e), !t)
5481
5624
  return [];
5482
5625
  const n = JSON.parse(t);
5483
- return Array.isArray(n) ? n.flatMap((i) => Ur(i) ? [{
5626
+ return Array.isArray(n) ? n.flatMap((i) => Lr(i) ? [{
5484
5627
  ...i.event,
5485
- page: v(),
5628
+ page: P(),
5486
5629
  rawOutput: {
5487
5630
  pageContextRestarted: !0,
5488
5631
  outcome: "unknown",
5489
- message: _r(location.href),
5632
+ message: xr(location.href),
5490
5633
  currentUrl: location.href,
5491
5634
  console: [],
5492
5635
  metadata: {
@@ -5503,17 +5646,17 @@ function Pr(s) {
5503
5646
  return [];
5504
5647
  }
5505
5648
  }
5506
- function _r(s) {
5649
+ function xr(s) {
5507
5650
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
5508
5651
  Current URL: ${s}`;
5509
5652
  }
5510
- function Ur(s) {
5653
+ function Lr(s) {
5511
5654
  if (!s || typeof s != "object")
5512
5655
  return !1;
5513
5656
  const e = s, t = e.event;
5514
- return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && yt(t) && t.type === "tool.result";
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";
5515
5658
  }
5516
- function Dr(s, e) {
5659
+ function Nr(s, e) {
5517
5660
  const t = new Set(
5518
5661
  s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
5519
5662
  );
@@ -5522,26 +5665,26 @@ function Dr(s, e) {
5522
5665
  ...e.filter((n) => !t.has(n.callId))
5523
5666
  ];
5524
5667
  }
5525
- function qr(s) {
5668
+ function Hr(s) {
5526
5669
  try {
5527
- window.sessionStorage.removeItem(`${Ue}${s}`);
5670
+ window.sessionStorage.removeItem(`${qe}${s}`);
5528
5671
  } catch {
5529
5672
  return;
5530
5673
  }
5531
5674
  }
5532
- function yt(s) {
5675
+ function wt(s) {
5533
5676
  if (!s || typeof s != "object")
5534
5677
  return !1;
5535
5678
  const e = s;
5536
- return e.type === "chat.user_message" ? typeof e.content == "string" && Vt(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? Vt(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;
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;
5537
5680
  }
5538
- function Vt(s) {
5681
+ function as(s) {
5539
5682
  if (!s || typeof s != "object")
5540
5683
  return !1;
5541
5684
  const e = s;
5542
5685
  return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
5543
5686
  }
5544
- function Ms(s, e) {
5687
+ function Us(s, e) {
5545
5688
  if (!Array.isArray(s))
5546
5689
  return;
5547
5690
  const t = s.filter((i) => {
@@ -5549,41 +5692,41 @@ function Ms(s, e) {
5549
5692
  return !1;
5550
5693
  const r = i;
5551
5694
  return typeof r.name == "string" && typeof r.mimeType == "string" && typeof r.sizeBytes == "number";
5552
- }), n = e ? t.map((i) => bs(i, e)) : t;
5695
+ }), n = e ? t.map((i) => Ds(i, e)) : t;
5553
5696
  return n.length > 0 ? n : void 0;
5554
5697
  }
5555
- function bs(s, e) {
5698
+ function Ds(s, e) {
5556
5699
  return s.fileUrl?.startsWith("/") ? {
5557
5700
  ...s,
5558
5701
  fileUrl: new URL(s.fileUrl, e).toString()
5559
5702
  } : s;
5560
5703
  }
5561
- function lt(s) {
5562
- return s.type || xr(s.name) || "application/octet-stream";
5704
+ function pt(s) {
5705
+ return s.type || $r(s.name) || "application/octet-stream";
5563
5706
  }
5564
- function Or(s) {
5565
- Rs({
5707
+ function Br(s) {
5708
+ qs({
5566
5709
  name: s.name,
5567
- mimeType: lt(s),
5710
+ mimeType: pt(s),
5568
5711
  sizeBytes: s.size
5569
5712
  });
5570
5713
  }
5571
- function Rs(s) {
5572
- const e = Lr(s.name), t = s.mimeType.trim().toLowerCase();
5573
- if (!Qn.has(`${e}:${t}`))
5714
+ function qs(s) {
5715
+ const e = Wr(s.name), t = s.mimeType.trim().toLowerCase();
5716
+ if (!ti.has(`${e}:${t}`))
5574
5717
  throw new Error("This attachment type is not supported by the embedded model provider");
5575
- if (s.sizeBytes <= 0 || s.sizeBytes >= as)
5718
+ if (s.sizeBytes <= 0 || s.sizeBytes >= Ss)
5576
5719
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
5577
5720
  }
5578
- function Lr(s) {
5721
+ function Wr(s) {
5579
5722
  const e = s.trim().toLowerCase(), t = e.lastIndexOf(".");
5580
5723
  return t >= 0 ? e.slice(t) : "";
5581
5724
  }
5582
- function xr(s) {
5725
+ function $r(s) {
5583
5726
  const e = s.toLowerCase();
5584
5727
  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;
5585
5728
  }
5586
- function Nr(s) {
5729
+ function Fr(s) {
5587
5730
  if (!s || typeof s != "object")
5588
5731
  return null;
5589
5732
  const e = s;
@@ -5601,17 +5744,17 @@ function Nr(s) {
5601
5744
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
5602
5745
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
5603
5746
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
5604
- attachments: Ms(e.attachments)?.map(Ce),
5747
+ attachments: Us(e.attachments)?.map(ve),
5605
5748
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5606
5749
  };
5607
5750
  }
5608
- function Hr(s) {
5751
+ function jr(s) {
5609
5752
  return s.attachments?.length ? {
5610
5753
  ...s,
5611
- attachments: s.attachments.map(Ce)
5754
+ attachments: s.attachments.map(ve)
5612
5755
  } : s;
5613
5756
  }
5614
- function Ce(s) {
5757
+ function ve(s) {
5615
5758
  const {
5616
5759
  dataUrl: e,
5617
5760
  objectUrl: t,
@@ -5629,39 +5772,39 @@ function E(s) {
5629
5772
  const e = s.runId;
5630
5773
  return typeof e == "string" && e ? e : null;
5631
5774
  }
5632
- function Br(s) {
5775
+ function zr(s) {
5633
5776
  const e = s?.timeoutMs;
5634
- 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 <= oi);
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);
5635
5778
  }
5636
- function Es(s) {
5779
+ function Os(s) {
5637
5780
  const e = {};
5638
5781
  try {
5639
5782
  new Headers(s).forEach((t, n) => {
5640
- Object.keys(e).length < pt && (e[n] = mt(n, t));
5783
+ Object.keys(e).length < It && (e[n] = At(n, t));
5641
5784
  });
5642
5785
  } catch {
5643
5786
  return {};
5644
5787
  }
5645
5788
  return e;
5646
5789
  }
5647
- function mt(s, e) {
5648
- return Us(s) ? Oe : W(_e(e), Vn);
5790
+ function At(s, e) {
5791
+ return Ws(s) ? Le : W(De(e), si);
5649
5792
  }
5650
- function Wr(s, e) {
5793
+ function Kr(s, e) {
5651
5794
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
5652
5795
  }
5653
- async function $r(s, e, t, n) {
5654
- const i = Es(s.headers);
5796
+ async function Gr(s, e, t, n) {
5797
+ const i = Os(s.headers);
5655
5798
  n({
5656
5799
  ...e,
5657
5800
  responseStatus: s.status,
5658
5801
  responseHeaders: i,
5659
- responseBody: await Fr(s),
5802
+ responseBody: await Qr(s),
5660
5803
  durationMs: Date.now() - t
5661
5804
  });
5662
5805
  }
5663
- async function Fr(s) {
5664
- if (!ks(s.headers))
5806
+ async function Qr(s) {
5807
+ if (!xs(s.headers))
5665
5808
  return;
5666
5809
  let e = null, t = null;
5667
5810
  try {
@@ -5670,7 +5813,7 @@ async function Fr(s) {
5670
5813
  const n = new Promise((a) => {
5671
5814
  t = window.setTimeout(() => {
5672
5815
  e?.cancel(), a("timeout");
5673
- }, Xn);
5816
+ }, ni);
5674
5817
  }), i = new TextDecoder();
5675
5818
  let r = "", o = 0;
5676
5819
  for (; ; ) {
@@ -5680,7 +5823,7 @@ async function Fr(s) {
5680
5823
  const { done: l, value: c } = a;
5681
5824
  if (l)
5682
5825
  return W(r + i.decode());
5683
- const u = ht - o;
5826
+ const u = yt - o;
5684
5827
  if (c.byteLength > u)
5685
5828
  return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${W(r)}... [truncated]`;
5686
5829
  o += c.byteLength, r += i.decode(c, { stream: !0 });
@@ -5692,45 +5835,45 @@ async function Fr(s) {
5692
5835
  t !== null && window.clearTimeout(t);
5693
5836
  }
5694
5837
  }
5695
- function jr(s, e) {
5696
- if (ks(new Headers(e)))
5838
+ function Vr(s, e) {
5839
+ if (xs(new Headers(e)))
5697
5840
  try {
5698
5841
  return s.responseType === "" || s.responseType === "text" ? W(s.responseText ?? "") : void 0;
5699
5842
  } catch {
5700
5843
  return;
5701
5844
  }
5702
5845
  }
5703
- function Xt(s) {
5846
+ function ls(s) {
5704
5847
  if (typeof s == "string")
5705
5848
  return W(s);
5706
5849
  }
5707
- function zr(s) {
5708
- return x({
5850
+ function Xr(s) {
5851
+ return L({
5709
5852
  ...s,
5710
- requestBody: Jt(s.requestBody),
5711
- responseBody: Jt(s.responseBody)
5853
+ requestBody: cs(s.requestBody),
5854
+ responseBody: cs(s.responseBody)
5712
5855
  });
5713
5856
  }
5714
- function Jt(s) {
5857
+ function cs(s) {
5715
5858
  if (typeof s != "string")
5716
5859
  return s;
5717
5860
  const e = s.trim();
5718
5861
  if (!e.startsWith("{") && !e.startsWith("["))
5719
- return _e(s);
5862
+ return De(s);
5720
5863
  try {
5721
- return JSON.stringify(x(JSON.parse(s)));
5864
+ return JSON.stringify(L(JSON.parse(s)));
5722
5865
  } catch {
5723
- return _e(s);
5866
+ return De(s);
5724
5867
  }
5725
5868
  }
5726
- function ks(s) {
5869
+ function xs(s) {
5727
5870
  if (!s)
5728
5871
  return !1;
5729
5872
  const e = s.get("content-type")?.toLowerCase() ?? "", t = s.get("content-length"), n = Number(t);
5730
- return t !== null && Number.isInteger(n) && n >= 0 && n <= ht && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
5873
+ return t !== null && Number.isInteger(n) && n >= 0 && n <= yt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
5731
5874
  }
5732
5875
  function ee(s, e = {}, t) {
5733
- if (Gr(t))
5876
+ if (Yr(t))
5734
5877
  return !0;
5735
5878
  const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
5736
5879
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -5745,7 +5888,7 @@ function ee(s, e = {}, t) {
5745
5888
  return !0;
5746
5889
  }
5747
5890
  }
5748
- function Kr(s, e) {
5891
+ function Jr(s, e) {
5749
5892
  if (ee(s))
5750
5893
  return !0;
5751
5894
  try {
@@ -5755,141 +5898,141 @@ function Kr(s, e) {
5755
5898
  return !0;
5756
5899
  }
5757
5900
  }
5758
- function Gr(s) {
5901
+ function Yr(s) {
5759
5902
  return s instanceof FormData || s instanceof Blob || s instanceof ArrayBuffer || ArrayBuffer.isView(s) || typeof ReadableStream < "u" && s instanceof ReadableStream;
5760
5903
  }
5761
- function Qr(s) {
5904
+ function Zr(s) {
5762
5905
  const e = {};
5763
5906
  for (const t of s.trim().split(/[\r\n]+/)) {
5764
5907
  const n = t.indexOf(":");
5765
5908
  if (n <= 0)
5766
5909
  continue;
5767
- if (Object.keys(e).length >= pt)
5910
+ if (Object.keys(e).length >= It)
5768
5911
  break;
5769
5912
  const i = t.slice(0, n).trim();
5770
- e[i] = mt(i, t.slice(n + 1).trim());
5913
+ e[i] = At(i, t.slice(n + 1).trim());
5771
5914
  }
5772
5915
  return e;
5773
5916
  }
5774
- function W(s, e = ht) {
5917
+ function W(s, e = yt) {
5775
5918
  return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
5776
5919
  }
5777
- function Ze(s) {
5920
+ function tt(s) {
5778
5921
  return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
5779
5922
  }
5780
- class Re extends Error {
5923
+ class Ce extends Error {
5781
5924
  constructor(e, t) {
5782
5925
  super(`${e} (${t})`), this.status = t, this.name = "AttachmentUploadHttpError";
5783
5926
  }
5784
5927
  status;
5785
5928
  }
5786
- async function Se(s, e) {
5929
+ async function Ae(s, e) {
5787
5930
  let t = null;
5788
- for (let n = 0; n < Lt; n += 1)
5931
+ for (let n = 0; n < Ft; n += 1)
5789
5932
  try {
5790
5933
  return await s();
5791
5934
  } catch (i) {
5792
- if (t = i, n >= Lt - 1 || !Xr(i))
5935
+ if (t = i, n >= Ft - 1 || !to(i))
5793
5936
  throw i;
5794
- await Vr(n);
5937
+ await eo(n);
5795
5938
  }
5796
5939
  throw t instanceof Error ? t : new Error(e);
5797
5940
  }
5798
- function Vr(s) {
5941
+ function eo(s) {
5799
5942
  return new Promise((e) => {
5800
- window.setTimeout(e, Gn[s] ?? 0);
5943
+ window.setTimeout(e, ei[s] ?? 0);
5801
5944
  });
5802
5945
  }
5803
- function Xr(s) {
5804
- return s instanceof Re ? Jr(s.status) : s instanceof TypeError;
5946
+ function to(s) {
5947
+ return s instanceof Ce ? so(s.status) : s instanceof TypeError;
5805
5948
  }
5806
- function Jr(s) {
5949
+ function so(s) {
5807
5950
  return s === 408 || s === 409 || s === 429 || s >= 500;
5808
5951
  }
5809
- function Yr(s) {
5952
+ function no(s) {
5810
5953
  return s === 401 || s === 403;
5811
5954
  }
5812
- const Oe = "[REDACTED_SECRET]", F = "[REDACTED_TOKEN]", Zr = "[REDACTED_SIGNED_URL]", eo = 20, to = /^(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, vs = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Cs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ps = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, _s = /\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, so = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, no = /\bhttps?:\/\/[^\s"'<>]+/gi, io = /[),.;\]]+$/;
5813
- function x(s) {
5814
- return Pe(s, 0, /* @__PURE__ */ new WeakSet());
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 = /[),.;\]]+$/;
5956
+ function L(s) {
5957
+ return Ue(s, 0, /* @__PURE__ */ new WeakSet());
5815
5958
  }
5816
- function Pe(s, e, t) {
5959
+ function Ue(s, e, t) {
5817
5960
  if (typeof s == "string")
5818
- return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : _e(s);
5961
+ return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : De(s);
5819
5962
  if (s === null || typeof s != "object")
5820
5963
  return s;
5821
- if (e >= eo)
5964
+ if (e >= ro)
5822
5965
  return "[REDACTED_MAX_DEPTH]";
5823
5966
  if (t.has(s))
5824
5967
  return "[REDACTED_CIRCULAR]";
5825
5968
  if (t.add(s), Array.isArray(s))
5826
- return s.map((i) => Pe(i, e + 1, t));
5969
+ return s.map((i) => Ue(i, e + 1, t));
5827
5970
  const n = {};
5828
5971
  for (const [i, r] of Object.entries(s))
5829
- i === "pageContent" ? n[i] = r : Us(i) ? n[i] = Oe : n[i] = i.toLowerCase() === "url" ? ro(r) : Pe(r, e + 1, t);
5972
+ i === "pageContent" ? n[i] = r : Ws(i) ? n[i] = Le : n[i] = i.toLowerCase() === "url" ? uo(r) : Ue(r, e + 1, t);
5830
5973
  return n;
5831
5974
  }
5832
- function Us(s) {
5975
+ function Ws(s) {
5833
5976
  const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
5834
5977
  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");
5835
5978
  }
5836
- function ro(s) {
5837
- return typeof s == "string" ? Ds(s) : Pe(s, 0, /* @__PURE__ */ new WeakSet());
5979
+ function uo(s) {
5980
+ return typeof s == "string" ? $s(s) : Ue(s, 0, /* @__PURE__ */ new WeakSet());
5838
5981
  }
5839
- function Ds(s) {
5982
+ function $s(s) {
5840
5983
  try {
5841
5984
  const e = new URL(s, location.href);
5842
5985
  for (const t of Array.from(e.searchParams.keys()))
5843
- to.test(t) && e.searchParams.set(t, F);
5986
+ oo.test(t) && e.searchParams.set(t, F);
5844
5987
  return e.username && (e.username = F), e.password && (e.password = F), e.toString();
5845
5988
  } catch {
5846
- return oo(s);
5989
+ return ho(s);
5847
5990
  }
5848
5991
  }
5849
- function _e(s) {
5850
- return s.replace(so, Zr).replace(no, ao).replace(vs, `Bearer ${F}`).replace(Cs, `Basic ${F}`).replace(Ps, F).replace(_s, (e, t) => `${t}: ${Oe}`);
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}`);
5851
5994
  }
5852
- function oo(s) {
5853
- return s.replace(vs, `Bearer ${F}`).replace(Cs, `Basic ${F}`).replace(Ps, F).replace(_s, (e, t) => `${t}: ${Oe}`);
5995
+ function ho(s) {
5996
+ return s.replace(Ls, `Bearer ${F}`).replace(Ns, `Basic ${F}`).replace(Hs, F).replace(Bs, (e, t) => `${t}: ${Le}`);
5854
5997
  }
5855
- function ao(s) {
5856
- const e = s.match(io)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
5857
- return `${Ds(t)}${e}`;
5998
+ function po(s) {
5999
+ const e = s.match(co)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6000
+ return `${$s(t)}${e}`;
5858
6001
  }
5859
- const mo = Object.freeze({
5860
- init: (s) => De.init(s)
6002
+ const Ao = Object.freeze({
6003
+ init: (s) => Oe.init(s)
5861
6004
  });
5862
- function Io(s) {
5863
- return De.init(s);
6005
+ function Mo(s) {
6006
+ return Oe.init(s);
5864
6007
  }
5865
6008
  export {
5866
- Ct as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
5867
- Rn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
5868
- bn as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
5869
- En as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
5870
- yo as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
5871
- mo as PlunoProductAgent,
5872
- In as ProductAgentInteractionManager,
5873
- Et as ProductAgentQueryController,
5874
- fo as ProductAgentRemoteRuntimeClient,
5875
- De as ProductAgentSessionEngine,
5876
- fn as ProductAgentSessionHistoryManager,
5877
- ho as ProductAgentTaskPageTitleController,
5878
- ei as calculateReconnectDelay,
5879
- uo as createLocalStorageInteractionDecisionStorage,
5880
- we as createProductAgentQueryState,
5881
- Io as createProductAgentRuntime,
5882
- po as createProductAgentTaskPageTitleDocument,
5883
- mo as default,
5884
- An as formatProductAgentTaskPageTitle,
5885
- Ai as getProductAgentOriginAccessErrorMessage,
5886
- go as isProductAgentRuntimeCommand,
5887
- hn as mergeProductAgentEntityPages,
5888
- Ae as normalizeProductAgentEntityPage,
5889
- $t as normalizeProductAgentSessionItems,
5890
- Sn as readLocalStorageInteractionDecisions,
5891
- co as resolveProductAgentComposerAction,
5892
- lo as resolveProductAgentWidgetPresentation,
5893
- rs as selectProductAgentQueryEntities,
5894
- Or as validateProductAgentProviderInputFile
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,
6033
+ En as readLocalStorageInteractionDecisions,
6034
+ fo as resolveProductAgentComposerAction,
6035
+ go as resolveProductAgentWidgetPresentation,
6036
+ ys as selectProductAgentQueryEntities,
6037
+ Br as validateProductAgentProviderInputFile
5895
6038
  };