@pluno/product-agent-web 0.1.202 → 0.1.204

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,5 +1,5 @@
1
1
  const zs = "pluno-product-agent-attachments";
2
- const nt = "files";
2
+ const it = "files";
3
3
  async function Ks(s) {
4
4
  const e = await mt();
5
5
  await Vs(e, "readwrite", (t) => t.put(s));
@@ -27,7 +27,7 @@ function mt() {
27
27
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((s, e) => {
28
28
  const t = indexedDB.open(zs, 1);
29
29
  t.onupgradeneeded = () => {
30
- const i = t.result.createObjectStore(nt, { keyPath: "attachmentId" });
30
+ const i = t.result.createObjectStore(it, { keyPath: "attachmentId" });
31
31
  i.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), i.createIndex("sessionId", "sessionId", { unique: !1 }), i.createIndex("origin", "origin", { unique: !1 });
32
32
  }, t.onsuccess = () => s(t.result), t.onerror = () => e(t.error ?? new Error("Failed to open Product Agent attachment storage"));
33
33
  });
@@ -37,7 +37,7 @@ async function Vs(s, e, t) {
37
37
  }
38
38
  function yt(s, e, t) {
39
39
  return new Promise((n, i) => {
40
- const r = s.transaction(nt, e), o = r.objectStore(nt);
40
+ const r = s.transaction(it, e), o = r.objectStore(it);
41
41
  let a, l = !1;
42
42
  t(o).then((c) => {
43
43
  a = c;
@@ -65,7 +65,7 @@ function It(s) {
65
65
  function Xs(s) {
66
66
  return s !== null && (typeof s == "object" || typeof s == "function");
67
67
  }
68
- function ds(s, e, t) {
68
+ function hs(s, e, t) {
69
69
  const n = Reflect.get(s, "pluno"), i = Xs(n) ? n : {};
70
70
  if (i !== n && !Reflect.set(s, "pluno", i))
71
71
  return null;
@@ -81,24 +81,24 @@ function ds(s, e, t) {
81
81
  };
82
82
  }
83
83
  const Js = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
- function _t(s, e) {
84
+ function vt(s, e) {
85
85
  return e ? s.replace(
86
86
  Js,
87
87
  (t, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
88
88
  ) : s;
89
89
  }
90
- const hs = "suggest_share_on_socials";
90
+ const St = "suggest_share_on_socials";
91
91
  function Ys(s) {
92
92
  for (let e = s.length - 1; e >= 0; e -= 1) {
93
93
  const t = s[e];
94
- if (t.role !== "tool" || t.toolName !== hs || t.sharePromptAllowed !== void 0)
94
+ if (t.role !== "tool" || t.toolName !== St || t.sharePromptAllowed !== void 0)
95
95
  continue;
96
96
  if (en(s, e, t.callId) !== !0)
97
97
  return null;
98
- const n = vt(s, e, "assistant");
98
+ const n = Ut(s, e, "assistant");
99
99
  if (!n)
100
100
  return null;
101
- const i = vt(s, n.index, "user");
101
+ const i = Ut(s, n.index, "user");
102
102
  return i ? {
103
103
  id: `share:${t.callId ?? t.id}`,
104
104
  userPrompt: i.content,
@@ -128,7 +128,7 @@ function en(s, e, t) {
128
128
  }
129
129
  return null;
130
130
  }
131
- function vt(s, e, t) {
131
+ function Ut(s, e, t) {
132
132
  for (let n = e - 1; n >= 0; n -= 1) {
133
133
  const i = s[n];
134
134
  if (i.role === t && i.content.trim())
@@ -144,54 +144,54 @@ function nn(s) {
144
144
  return (s.type === "function_call" || s.type === "tool_call") && s.name === sn;
145
145
  }
146
146
  function rn(s, e, t) {
147
- const n = e.map((d) => ({ item: d, identity: t(d) })), i = new Set(
147
+ const n = e.map((h) => ({ item: h, identity: t(h) })), i = new Set(
148
148
  n.flatMap(
149
- ({ identity: d }) => d.isActivity && !d.isTransient ? d.activityKeys ?? [] : []
149
+ ({ identity: h }) => h.isActivity && !h.isTransient ? h.activityKeys ?? [] : []
150
150
  )
151
151
  ), r = n.filter(
152
- ({ identity: d }) => !(d.isTransient && d.activityKeys?.some((p) => i.has(p)))
153
- ), o = new Map(r.map(({ item: d, identity: p }) => [p.id, d])), a = new Map(
152
+ ({ identity: h }) => !(h.isTransient && h.activityKeys?.some((p) => i.has(p)))
153
+ ), o = new Map(r.map(({ item: h, identity: p }) => [p.id, h])), a = new Map(
154
154
  r.flatMap(
155
- ({ item: d, identity: p }) => p.optimisticKey ? [[p.optimisticKey, d]] : []
155
+ ({ item: h, identity: p }) => p.optimisticKey ? [[p.optimisticKey, h]] : []
156
156
  )
157
157
  ), l = new Map(
158
158
  r.flatMap(
159
- ({ item: d, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, d]] : []
159
+ ({ item: h, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, h]] : []
160
160
  )
161
161
  ), c = /* @__PURE__ */ new Map();
162
- for (const { item: d, identity: p } of r)
162
+ for (const { item: h, identity: p } of r)
163
163
  for (const y of p.activityKeys ?? []) {
164
- const f = c.get(y);
165
- (!f || t(f).isTransient) && c.set(y, d);
164
+ const m = c.get(y);
165
+ (!m || t(m).isTransient) && c.set(y, h);
166
166
  }
167
- const u = new Set(r.map(({ identity: d }) => d.id)), h = new Set(
168
- r.flatMap(({ identity: d }) => d.runId ? [d.runId] : [])
169
- ), m = /* @__PURE__ */ new Set(), g = [];
170
- for (const d of s) {
171
- const p = t(d);
167
+ const u = new Set(r.map(({ identity: h }) => h.id)), d = new Set(
168
+ r.flatMap(({ identity: h }) => h.runId ? [h.runId] : [])
169
+ ), g = /* @__PURE__ */ new Set(), f = [];
170
+ for (const h of s) {
171
+ const p = t(h);
172
172
  let y = o.get(p.id);
173
- if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? y), y && !m.has(y)) {
174
- g.push(y), m.add(y);
173
+ if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? y), y && !g.has(y)) {
174
+ f.push(y), g.add(y);
175
175
  continue;
176
176
  }
177
- const f = p.respondsToUserMessageId !== void 0 && u.has(p.respondsToUserMessageId) || p.runId !== void 0 && h.has(p.runId);
178
- (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && f) && g.push(d);
177
+ const m = p.respondsToUserMessageId !== void 0 && u.has(p.respondsToUserMessageId) || p.runId !== void 0 && d.has(p.runId);
178
+ (p.isOptimistic || (p.isAssistantDraft || p.isActivity) && m) && f.push(h);
179
179
  }
180
- for (const { item: d } of r)
181
- m.has(d) || g.push(d);
182
- return g;
180
+ for (const { item: h } of r)
181
+ g.has(h) || f.push(h);
182
+ return f;
183
183
  }
184
- function Ut(s, e, t, n) {
184
+ function Dt(s, e, t, n) {
185
185
  return s.filter((i) => {
186
186
  const r = n(i);
187
187
  return !r.isActivity || !r.isTransient ? !0 : e !== null && r.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId !== e : t === null || r.runId !== t;
188
188
  });
189
189
  }
190
- const je = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", ze = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
190
+ const ze = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", Ke = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
191
191
  let le = null;
192
- const be = /* @__PURE__ */ new Set(), Ke = /* @__PURE__ */ new Map();
192
+ const be = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Map();
193
193
  async function cn(s = ps()) {
194
- const e = s.randomUUID(), t = s.storage.getItem(je);
194
+ const e = s.randomUUID(), t = s.storage.getItem(ze);
195
195
  let n = t ?? s.randomUUID(), i = !1, r = !1;
196
196
  const o = s.channel.subscribe((l) => {
197
197
  if (!(l.senderId === e || l.transportId !== n)) {
@@ -209,7 +209,7 @@ async function cn(s = ps()) {
209
209
  }
210
210
  });
211
211
  if (!t)
212
- s.storage.setItem(je, n), i = !0;
212
+ s.storage.setItem(ze, n), i = !0;
213
213
  else if (s.skipStoredIdentityCollisionCheck)
214
214
  i = !0;
215
215
  else
@@ -218,7 +218,7 @@ async function cn(s = ps()) {
218
218
  i = !0;
219
219
  break;
220
220
  }
221
- n = s.randomUUID(), s.storage.setItem(je, n);
221
+ n = s.randomUUID(), s.storage.setItem(ze, n);
222
222
  }
223
223
  let a = !1;
224
224
  return {
@@ -267,13 +267,13 @@ function hn() {
267
267
  return {
268
268
  getItem: (s) => {
269
269
  try {
270
- return window.sessionStorage?.getItem(s) ?? Ke.get(s) ?? null;
270
+ return window.sessionStorage?.getItem(s) ?? Ge.get(s) ?? null;
271
271
  } catch {
272
- return Ke.get(s) ?? null;
272
+ return Ge.get(s) ?? null;
273
273
  }
274
274
  },
275
275
  setItem: (s, e) => {
276
- Ke.set(s, e);
276
+ Ge.set(s, e);
277
277
  try {
278
278
  window.sessionStorage?.setItem(s, e);
279
279
  } catch {
@@ -297,7 +297,7 @@ function pn() {
297
297
  }
298
298
  function gn() {
299
299
  const s = /* @__PURE__ */ new Set(), e = (t) => {
300
- if (t.key !== ze || !t.newValue)
300
+ if (t.key !== Ke || !t.newValue)
301
301
  return;
302
302
  const n = JSON.parse(t.newValue);
303
303
  for (const i of s)
@@ -306,9 +306,9 @@ function gn() {
306
306
  return window.addEventListener("storage", e), {
307
307
  postMessage: (t) => {
308
308
  window.localStorage.setItem(
309
- ze,
309
+ Ke,
310
310
  JSON.stringify({ ...t, eventId: crypto.randomUUID() })
311
- ), window.localStorage.removeItem(ze);
311
+ ), window.localStorage.removeItem(Ke);
312
312
  },
313
313
  subscribe: (t) => (s.add(t), () => s.delete(t)),
314
314
  close: () => {
@@ -343,12 +343,12 @@ const mn = [
343
343
  ], In = [
344
344
  ...mn,
345
345
  ...yn
346
- ], Ge = (s) => In.some((e) => e.value === s);
347
- function Dt(s, e) {
346
+ ], Qe = (s) => In.some((e) => e.value === s);
347
+ function qt(s, e) {
348
348
  return s.filter((t, n) => {
349
- const i = qt(t);
349
+ const i = Ot(t);
350
350
  return fs(i) ? !s.slice(n + 1).some((r) => {
351
- const o = qt(r);
351
+ const o = Ot(r);
352
352
  return ms(i, o) && ys(i, o);
353
353
  }) : !0;
354
354
  });
@@ -359,7 +359,7 @@ function fs(s) {
359
359
  function Sn(s, e) {
360
360
  return s.reason === "task_tab_closed" && ys(s, e) && ms(s, e);
361
361
  }
362
- function qt(s) {
362
+ function Ot(s) {
363
363
  return s.data && typeof s.data == "object" ? s.data : {};
364
364
  }
365
365
  function ms(s, e) {
@@ -379,7 +379,7 @@ function Re(s) {
379
379
  updatedAt: null
380
380
  };
381
381
  }
382
- class Ot {
382
+ class xt {
383
383
  constructor(e, t, n = (i, r) => r) {
384
384
  this.loader = t, this.merge = n, this.state = Re(e);
385
385
  }
@@ -497,7 +497,7 @@ function To(s) {
497
497
  }
498
498
  class Mn {
499
499
  constructor(e, t, n = 20) {
500
- this.loadPage = t, this.limit = n, this.recentQuery = new Ot(
500
+ this.loadPage = t, this.limit = n, this.recentQuery = new xt(
501
501
  `${e}:recent`,
502
502
  async ({ cursor: i }) => ke(
503
503
  await this.loadPage({ cursor: i, limit: this.limit, pinned: !1 }).then((r) => ({
@@ -506,7 +506,7 @@ class Mn {
506
506
  }))
507
507
  ),
508
508
  Tn
509
- ), this.pinnedQuery = new Ot(
509
+ ), this.pinnedQuery = new xt(
510
510
  `${e}:pinned`,
511
511
  async () => ke({
512
512
  entities: await this.loadAllPinned(),
@@ -650,7 +650,7 @@ function Ie(s) {
650
650
  function bn(s, e) {
651
651
  return s.status === "error" || e.status === "error" ? "error" : s.status === "loading" || e.status === "loading" ? "loading" : s.status === "refreshing" || e.status === "refreshing" ? "refreshing" : s.status === "loading_more" ? "loading_more" : s.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
652
652
  }
653
- class xt {
653
+ class Lt {
654
654
  constructor(e) {
655
655
  this.options = e;
656
656
  }
@@ -749,7 +749,7 @@ class Rn {
749
749
  class kn {
750
750
  constructor(e, t = null) {
751
751
  this.storage = e, t && (this.decisions = new Map(
752
- t.filter(it).map((n) => [this.getDecisionKey(n), n])
752
+ t.filter(rt).map((n) => [this.getDecisionKey(n), n])
753
753
  ), this.initialized = !0);
754
754
  }
755
755
  storage;
@@ -761,7 +761,7 @@ class kn {
761
761
  if (this.initialized) return;
762
762
  const e = await this.storage.load();
763
763
  this.decisions = new Map(
764
- e.filter(it).map((t) => [this.getDecisionKey(t), t])
764
+ e.filter(rt).map((t) => [this.getDecisionKey(t), t])
765
765
  ), this.initialized = !0;
766
766
  }
767
767
  isEligible(e, t = Date.now()) {
@@ -825,14 +825,14 @@ class kn {
825
825
  return null;
826
826
  }
827
827
  getDecisionKey(e) {
828
- const t = Qe(e.scope);
828
+ const t = Ve(e.scope);
829
829
  return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
830
830
  }
831
831
  getExactKey(e) {
832
- return `${Qe(e.scope)}:interaction:${e.key}`;
832
+ return `${Ve(e.scope)}:interaction:${e.key}`;
833
833
  }
834
834
  getCategoryKey(e) {
835
- return `${Qe(e.scope)}:category:${e.category}`;
835
+ return `${Ve(e.scope)}:category:${e.category}`;
836
836
  }
837
837
  }
838
838
  function wo(s, e) {
@@ -845,15 +845,15 @@ 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(it) : [];
848
+ return Array.isArray(n) ? n.filter(rt) : [];
849
849
  }
850
- function Qe(s) {
850
+ function Ve(s) {
851
851
  return `${s.level}:${s.key}`;
852
852
  }
853
853
  function Ss(s) {
854
854
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
855
855
  }
856
- function it(s) {
856
+ function rt(s) {
857
857
  if (!s || typeof s != "object") return !1;
858
858
  const e = s;
859
859
  return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Ss(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
@@ -965,7 +965,7 @@ function bo(s) {
965
965
  }
966
966
  class Ro {
967
967
  constructor(e, t, n) {
968
- this.adapter = t, this.state = Ve(e), this.model = n;
968
+ this.adapter = t, this.state = Xe(e), this.model = n;
969
969
  }
970
970
  adapter;
971
971
  listeners = {};
@@ -986,12 +986,12 @@ class Ro {
986
986
  return n.add(t), this.listeners[e] = n, () => n.delete(t);
987
987
  }
988
988
  getState() {
989
- return Ve(this.state);
989
+ return Xe(this.state);
990
990
  }
991
991
  updateProjection(e, t, n, i, r) {
992
992
  if (!this.destroyed) {
993
- if (this.state = Ve(e), t !== void 0 && (this.model = t), n) {
994
- this.sessionHistoryState = Lt(n);
993
+ if (this.state = Xe(e), t !== void 0 && (this.model = t), n) {
994
+ this.sessionHistoryState = Nt(n);
995
995
  for (const o of this.sessionHistoryListeners)
996
996
  o(this.getSessionHistoryState());
997
997
  }
@@ -1067,9 +1067,9 @@ class Ro {
1067
1067
  c.push(u);
1068
1068
  continue;
1069
1069
  }
1070
- const h = u.id ? this.attachmentFiles.get(u.id) : void 0;
1071
- if (!h) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1072
- c.push(await this.adapter.uploadAttachment(h, u, { clientMessageId: r }));
1070
+ const d = u.id ? this.attachmentFiles.get(u.id) : void 0;
1071
+ if (!d) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
1072
+ c.push(await this.adapter.uploadAttachment(d, u, { clientMessageId: r }));
1073
1073
  }
1074
1074
  o = c;
1075
1075
  }
@@ -1138,7 +1138,7 @@ class Ro {
1138
1138
  };
1139
1139
  }
1140
1140
  getSessionHistoryState() {
1141
- return Lt(this.sessionHistoryState);
1141
+ return Nt(this.sessionHistoryState);
1142
1142
  }
1143
1143
  subscribeSessionHistory(e) {
1144
1144
  return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
@@ -1217,7 +1217,7 @@ class Ro {
1217
1217
  for (const i of n ?? []) i(t);
1218
1218
  }
1219
1219
  }
1220
- function Ve(s) {
1220
+ function Xe(s) {
1221
1221
  return {
1222
1222
  ...s,
1223
1223
  starterPrompts: [...s.starterPrompts],
@@ -1238,7 +1238,7 @@ function Ve(s) {
1238
1238
  activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
1239
1239
  };
1240
1240
  }
1241
- function Lt(s) {
1241
+ function Nt(s) {
1242
1242
  return {
1243
1243
  ...s,
1244
1244
  data: s.data ? ke({
@@ -1247,8 +1247,8 @@ function Lt(s) {
1247
1247
  }) : null
1248
1248
  };
1249
1249
  }
1250
- const vn = globalThis.fetch.bind(globalThis), Nt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Un = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Dn = ".pluno-pa-widget__panel", qn = ".pluno-pa-widget__timeline", On = "__plunoExtensionWidgetOwner";
1251
- class ee extends Error {
1250
+ const vn = globalThis.fetch.bind(globalThis), Ht = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Un = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Dn = ".pluno-pa-widget__panel", qn = ".pluno-pa-widget__timeline", On = "__plunoExtensionWidgetOwner";
1251
+ class X extends Error {
1252
1252
  constructor(e, t, n, i) {
1253
1253
  super(e), this.retryable = t, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
1254
1254
  }
@@ -1260,9 +1260,9 @@ function xn(s) {
1260
1260
  return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
1261
1261
  }
1262
1262
  let Ln = 0;
1263
- function Ht(s) {
1263
+ function Bt(s) {
1264
1264
  const e = {};
1265
- for (const o of [
1265
+ for (const l of [
1266
1266
  "type",
1267
1267
  "requestId",
1268
1268
  "clientMessageId",
@@ -1270,12 +1270,16 @@ function Ht(s) {
1270
1270
  "warmupId",
1271
1271
  "runId",
1272
1272
  "itemId",
1273
+ "callId",
1274
+ "responseId",
1275
+ "respondsToUserMessageId",
1276
+ "status",
1273
1277
  "reason",
1274
1278
  "phase",
1275
1279
  "elapsedMs"
1276
1280
  ]) {
1277
- const a = s[o];
1278
- (typeof a == "string" || typeof a == "number" || typeof a == "boolean" || a === null) && (e[o] = a);
1281
+ const c = s[l];
1282
+ (typeof c == "string" || typeof c == "number" || typeof c == "boolean" || c === null) && (e[l] = c);
1279
1283
  }
1280
1284
  const t = s.content;
1281
1285
  typeof t == "string" && (e.contentLength = t.length);
@@ -1283,22 +1287,44 @@ function Ht(s) {
1283
1287
  typeof n == "string" && (e.deltaLength = n.length);
1284
1288
  const i = s.attachments;
1285
1289
  Array.isArray(i) && (e.attachmentCount = i.length);
1286
- const r = s.session;
1287
- if (r && typeof r == "object") {
1288
- const o = r;
1289
- typeof o.id == "string" && (e.sessionId = o.id);
1290
- const a = o.metadata;
1291
- if (a && typeof a == "object") {
1292
- const l = a.composerPreload;
1293
- if (l && typeof l == "object") {
1294
- const c = l.runId;
1295
- e.composerPreloaded = !0, typeof c == "string" && (e.preloadRunId = c);
1290
+ const r = (l) => {
1291
+ if (!l || typeof l != "object")
1292
+ return null;
1293
+ const c = l, u = c.data, d = u && typeof u == "object" ? u : {}, g = ve(l);
1294
+ return {
1295
+ id: typeof c.id == "string" ? c.id : null,
1296
+ type: typeof d.type == "string" ? d.type : null,
1297
+ role: typeof d.role == "string" ? d.role : null,
1298
+ sessionId: typeof c.sessionId == "string" ? c.sessionId : null,
1299
+ runId: typeof d.runId == "string" ? d.runId : null,
1300
+ respondsToUserMessageId: typeof d.respondsToUserMessageId == "string" ? d.respondsToUserMessageId : null,
1301
+ status: typeof d.status == "string" ? d.status : null,
1302
+ stage: typeof d.stage == "string" ? d.stage : null,
1303
+ retryable: d.retryable === !0,
1304
+ visible: !!(g && !g.scheduledCheckInAt && g.toolName !== St && (d.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(d.status))))
1305
+ };
1306
+ }, o = r(s.item);
1307
+ if (o?.id && (e.itemId = o.id, o.type && (e.itemType = o.type), o.role && (e.itemRole = o.role), o.sessionId && typeof e.sessionId != "string" && (e.sessionId = o.sessionId), o.runId && typeof e.runId != "string" && (e.runId = o.runId), o.respondsToUserMessageId && typeof e.respondsToUserMessageId != "string" && (e.respondsToUserMessageId = o.respondsToUserMessageId), o.status && (e.itemStatus = o.status), o.stage && (e.itemStage = o.stage), o.retryable && (e.itemRetryable = !0), o.visible && (e.visibleItemId = o.id)), Array.isArray(s.items)) {
1308
+ const l = s.items.map(r).filter((c) => c !== null && c.visible && !!c.id).map((c) => c.id);
1309
+ e.visibleItemIds = JSON.stringify(l);
1310
+ }
1311
+ s.type === "chat.assistant_delta" && typeof s.itemId == "string" && (e.visibleItemId = s.itemId);
1312
+ const a = s.session;
1313
+ if (a && typeof a == "object") {
1314
+ const l = a;
1315
+ typeof l.id == "string" && (e.sessionId = l.id);
1316
+ const c = l.metadata;
1317
+ if (c && typeof c == "object") {
1318
+ const u = c.composerPreload;
1319
+ if (u && typeof u == "object") {
1320
+ const d = u.runId;
1321
+ e.composerPreloaded = !0, typeof d == "string" && (e.preloadRunId = d);
1296
1322
  }
1297
1323
  }
1298
1324
  }
1299
1325
  return e;
1300
1326
  }
1301
- function Xe(s, e, t) {
1327
+ function Je(s, e, t) {
1302
1328
  if (typeof window > "u")
1303
1329
  return;
1304
1330
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -1322,13 +1348,13 @@ class Se extends Error {
1322
1348
  function Nn(s) {
1323
1349
  return s === 408 || s === 425 || s === 429 || s >= 500;
1324
1350
  }
1325
- const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, $n = 6e4, Fn = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, rt = 3e4, Bt = 0.2, Vn = 6e4, Wt = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, Ft = 8e3, jt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
1351
+ const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
1326
1352
  ".jpeg:image/jpeg",
1327
1353
  ".jpg:image/jpeg",
1328
1354
  ".pdf:application/pdf",
1329
1355
  ".png:image/png",
1330
1356
  ".webp:image/webp"
1331
- ]), ko = ".pdf,.png,.jpg,.jpeg,.webp", St = 64e3, Je = 4e3, Tt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", ot = "pluno.productAgent.pendingEvents.", Oe = "pluno.productAgent.activeToolCalls.", ci = 100;
1357
+ ]), ko = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", xe = "pluno.productAgent.activeToolCalls.", ci = 100;
1332
1358
  function ui(s, e = 0) {
1333
1359
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1334
1360
  return Math.max(e, t);
@@ -1336,8 +1362,8 @@ function ui(s, e = 0) {
1336
1362
  const Ee = /* @__PURE__ */ new Set();
1337
1363
  let Te = null;
1338
1364
  function di(s, e = Math.random) {
1339
- const t = Math.min(rt, Qn * 2 ** s), n = 1 - Bt + e() * Bt * 2;
1340
- return Math.min(rt, Math.round(t * n));
1365
+ const t = Math.min(ot, Qn * 2 ** s), n = 1 - Wt + e() * Wt * 2;
1366
+ return Math.min(ot, Math.round(t * n));
1341
1367
  }
1342
1368
  function hi(s) {
1343
1369
  const e = s.split(".")[1];
@@ -1351,7 +1377,7 @@ function hi(s) {
1351
1377
  }
1352
1378
  }
1353
1379
  function pi(s) {
1354
- if (s instanceof ee)
1380
+ if (s instanceof X)
1355
1381
  return s.retryable;
1356
1382
  if (s && typeof s == "object") {
1357
1383
  const e = s.status;
@@ -1372,12 +1398,12 @@ function gi(s) {
1372
1398
  }
1373
1399
  return new Error(String(s));
1374
1400
  }
1375
- class xe {
1401
+ class Le {
1376
1402
  constructor(e, t) {
1377
1403
  this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new Mn(
1378
1404
  e.clientId,
1379
1405
  async ({ cursor: r, limit: o, pinned: a }) => await this.listSessions({ cursor: r, limit: o, pinned: a })
1380
- ), this.sessionRecoveryPoller = new xt({
1406
+ ), this.sessionRecoveryPoller = new Lt({
1381
1407
  poll: async ({ sessionId: r }) => await this.fetchSessionHistoryPageOnce(
1382
1408
  r,
1383
1409
  "transcript",
@@ -1408,14 +1434,14 @@ class xe {
1408
1434
  },
1409
1435
  getItemId: (r) => A(r, "id"),
1410
1436
  maxPagesPerPoll: 3
1411
- }), this.sessionActivityRecoveryPoller = new xt({
1437
+ }), this.sessionActivityRecoveryPoller = new Lt({
1412
1438
  poll: async ({ sessionId: r }) => await this.sessionActivityRecovery.poll(r),
1413
1439
  apply: async (r) => await this.sessionActivityRecovery.apply(r),
1414
1440
  isActiveTurn: () => this.state.isThinking || this.state.pendingMessageStatus !== null,
1415
1441
  activeIntervalMs: 3e3,
1416
1442
  idleIntervalMs: 15e3,
1417
1443
  maxFailureIntervalMs: 3e4
1418
- }), this.personalModelSelectionOverride = e.productVariant === "personal" && Ge(e.model) ? e.model : null, this.state = {
1444
+ }), this.personalModelSelectionOverride = e.productVariant === "personal" && Qe(e.model) ? e.model : null, this.state = {
1419
1445
  ...this.state,
1420
1446
  starterPrompts: Gi(e.initialStarterPrompts)
1421
1447
  }, this.account = e.initialAccount ? { ...e.initialAccount } : null;
@@ -1440,7 +1466,7 @@ class xe {
1440
1466
  taskStatus: null,
1441
1467
  isRetrying: !1,
1442
1468
  lastError: null
1443
- }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Fr(
1469
+ }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = $r(
1444
1470
  Hr(e.clientId),
1445
1471
  Br(e.clientId)
1446
1472
  );
@@ -1507,6 +1533,16 @@ class xe {
1507
1533
  retryAttemptsByClientMessageId = {};
1508
1534
  retryTimersByClientMessageId = {};
1509
1535
  reportedHealthSignalKeys = /* @__PURE__ */ new Set();
1536
+ /** @internal */
1537
+ transportDiagnosticEpisodes = /* @__PURE__ */ new Map();
1538
+ /** @internal */
1539
+ pendingTransportDiagnostics = [];
1540
+ /** @internal */
1541
+ pendingHealthDiagnostics = [];
1542
+ /** @internal */
1543
+ clientDiagnosticsFlush = null;
1544
+ /** @internal */
1545
+ clientDiagnosticsRetryTimer = null;
1510
1546
  clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
1511
1547
  backgroundSessionIds = /* @__PURE__ */ new Set();
1512
1548
  backgroundClientMessageIds = /* @__PURE__ */ new Set();
@@ -1577,7 +1613,7 @@ class xe {
1577
1613
  static async init(e) {
1578
1614
  const t = e, n = await un(
1579
1615
  t.skipStoredTransportIdentityCollisionCheck === !0
1580
- ), i = new xe({
1616
+ ), i = new Le({
1581
1617
  ...e,
1582
1618
  backendUrl: Ui(e.backendUrl ?? Hn),
1583
1619
  clientId: e.clientId ?? Yi(),
@@ -1631,7 +1667,7 @@ class xe {
1631
1667
  return this.options.token;
1632
1668
  if (!this.options.tokenProvider)
1633
1669
  return this.token;
1634
- const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - Fn > n;
1670
+ const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - $n > n;
1635
1671
  if (!t.forceRefresh && (i || t.preferCached && this.token !== null))
1636
1672
  return this.token;
1637
1673
  if (this.tokenRequest && !t.forceRefresh)
@@ -1643,8 +1679,8 @@ class xe {
1643
1679
  let a = null;
1644
1680
  const l = new Promise((c, u) => {
1645
1681
  a = window.setTimeout(() => {
1646
- r.abort(), u(new ee("Pluno token provider timed out", !0));
1647
- }, $n);
1682
+ r.abort(), u(new X("Pluno token provider timed out", !0));
1683
+ }, Fn);
1648
1684
  });
1649
1685
  try {
1650
1686
  const c = await Promise.race([
@@ -1652,9 +1688,9 @@ class xe {
1652
1688
  l
1653
1689
  ]);
1654
1690
  if (r.signal.aborted || this.tokenAbortController !== r)
1655
- throw new ee("Pluno token request was cancelled", !0);
1691
+ throw new X("Pluno token request was cancelled", !0);
1656
1692
  if (!c)
1657
- throw new ee("Pluno token provider did not return a token", !1);
1693
+ throw new X("Pluno token provider did not return a token", !1);
1658
1694
  return this.token = c, this.tokenExpiresAtMs = hi(c), c;
1659
1695
  } finally {
1660
1696
  a !== null && window.clearTimeout(a);
@@ -1679,10 +1715,10 @@ class xe {
1679
1715
  if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
1680
1716
  return;
1681
1717
  if (!this.token && !this.options.webSocketFactory)
1682
- throw new ee("Pluno requires a token or tokenProvider", !1);
1718
+ throw new X("Pluno requires a token or tokenProvider", !1);
1683
1719
  const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1684
1720
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
1685
- this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
1721
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
1686
1722
  }, jn), n.addEventListener("open", () => {
1687
1723
  this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
1688
1724
  queuedClientEventCount: this.queuedClientEvents.length,
@@ -1694,7 +1730,7 @@ class xe {
1694
1730
  transportId: this.transportIdentity.transportId,
1695
1731
  pageUrl: location.href
1696
1732
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
1697
- this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
1733
+ this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
1698
1734
  }, zn));
1699
1735
  }), n.addEventListener("message", (i) => {
1700
1736
  this.socket === n && this.handleServerEvent(zi(i.data));
@@ -1712,12 +1748,15 @@ class xe {
1712
1748
  wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
1713
1749
  queuedClientEventCount: this.queuedClientEvents.length,
1714
1750
  isThinking: this.state.isThinking
1751
+ }), (typeof i?.code != "number" || i.code !== 1e3) && this.reportTransportDiagnostic("socket_closed", {
1752
+ closeCode: typeof i?.code == "number" ? i.code : void 0,
1753
+ wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : void 0
1715
1754
  }), this.setReconnectingState(), this.scheduleReconnect()));
1716
1755
  }), n.addEventListener("error", () => {
1717
1756
  this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
1718
1757
  queuedClientEventCount: this.queuedClientEvents.length,
1719
1758
  isThinking: this.state.isThinking
1720
- }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
1759
+ }), this.reportTransportDiagnostic("socket_error"), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
1721
1760
  });
1722
1761
  } catch (t) {
1723
1762
  if (e !== this.connectionAttemptId || this.state.status === "closed")
@@ -1727,12 +1766,12 @@ class xe {
1727
1766
  b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
1728
1767
  message: n.message,
1729
1768
  reconnectAttempt: this.reconnectAttempts
1730
- }), this.setState({
1769
+ }), t instanceof X && this.reportTransportDiagnostic("auth_timeout"), this.setState({
1731
1770
  status: "reconnecting",
1732
1771
  lastError: Zn,
1733
1772
  lastErrorCode: "connection_failed"
1734
1773
  }), this.emit("error", n), this.scheduleReconnect(
1735
- t instanceof ee ? t.retryAfterMs : void 0
1774
+ t instanceof X ? t.retryAfterMs : void 0
1736
1775
  );
1737
1776
  return;
1738
1777
  }
@@ -1746,7 +1785,7 @@ class xe {
1746
1785
  }
1747
1786
  }
1748
1787
  disconnect() {
1749
- this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
1788
+ this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], 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;
1750
1789
  }
1751
1790
  destroy() {
1752
1791
  this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
@@ -1794,7 +1833,7 @@ class xe {
1794
1833
  0
1795
1834
  ) > Ts))
1796
1835
  throw new Error("Embedded attachments must total at most 50 MB per message");
1797
- let r = i.map(Ue);
1836
+ let r = i.map(De);
1798
1837
  if (!n && r.length === 0)
1799
1838
  return null;
1800
1839
  if (this.pendingClientMessageId)
@@ -1807,13 +1846,13 @@ class xe {
1807
1846
  phase: "final_answer",
1808
1847
  content: l,
1809
1848
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
1810
- } : null, h = {
1849
+ } : null, d = {
1811
1850
  id: `local-${a}`,
1812
1851
  role: "user",
1813
1852
  content: n,
1814
1853
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1815
1854
  ...i.length > 0 ? { attachments: i } : {}
1816
- }, m = this.state.messages.some((S) => S.id === h.id || S.clientMessageId === a), g = this.state.isThinking, d = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, f = this.state.messages, M = m ? this.state.messages : [
1855
+ }, g = this.state.messages.some((S) => S.id === d.id || S.clientMessageId === a), f = this.state.isThinking, h = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, m = this.state.messages, M = g ? this.state.messages : [
1817
1856
  ...this.state.messages.map(
1818
1857
  (S) => c && S.id === c.id ? {
1819
1858
  ...S,
@@ -1821,7 +1860,7 @@ class xe {
1821
1860
  } : S
1822
1861
  ),
1823
1862
  ...!c && u ? [u] : [],
1824
- h
1863
+ d
1825
1864
  ], w = {
1826
1865
  assistantDraft: this.state.assistantDraft,
1827
1866
  assistantDraftItemId: this.state.assistantDraftItemId,
@@ -1832,7 +1871,7 @@ class xe {
1832
1871
  };
1833
1872
  this.setState({
1834
1873
  messages: M,
1835
- ...g ? {} : {
1874
+ ...f ? {} : {
1836
1875
  assistantDraft: "",
1837
1876
  assistantDraftItemId: null,
1838
1877
  assistantDraftPhase: null,
@@ -1840,23 +1879,23 @@ class xe {
1840
1879
  assistantDraftRunId: null
1841
1880
  },
1842
1881
  pendingMessageStatus: "sending",
1843
- turnPhase: g ? y : "sending",
1844
- isThinking: g,
1882
+ turnPhase: f ? y : "sending",
1883
+ isThinking: f,
1845
1884
  taskStatus: "working",
1846
1885
  isRetrying: !1,
1847
1886
  lastError: null
1848
- }), m || (this.sessionHistoryManager.addOptimistic({
1849
- id: h.id,
1887
+ }), g || (this.sessionHistoryManager.addOptimistic({
1888
+ id: d.id,
1850
1889
  title: null,
1851
1890
  customTitle: null,
1852
- firstUserMessage: h.content,
1891
+ firstUserMessage: d.content,
1853
1892
  currentPage: o,
1854
- createdAt: h.createdAt,
1855
- updatedAt: h.createdAt,
1856
- lastActiveAt: h.createdAt,
1893
+ createdAt: d.createdAt,
1894
+ updatedAt: d.createdAt,
1895
+ lastActiveAt: d.createdAt,
1857
1896
  isActive: !0,
1858
1897
  isPinned: !1
1859
- }), u && !c && this.emit("message", u), this.emit("message", h));
1898
+ }), u && !c && this.emit("message", u), this.emit("message", d));
1860
1899
  try {
1861
1900
  const S = [];
1862
1901
  for (const T of r) {
@@ -1871,12 +1910,12 @@ class xe {
1871
1910
  }
1872
1911
  r = S;
1873
1912
  } catch (S) {
1874
- throw m || this.sessionHistoryManager.removeOptimistic(h.id), this.setState({
1875
- ...m ? {} : { messages: f },
1876
- ...g ? {} : { ...w, isThinking: !1 },
1913
+ throw g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1914
+ ...g ? {} : { messages: m },
1915
+ ...f ? {} : { ...w, isThinking: !1 },
1877
1916
  pendingMessageStatus: p,
1878
1917
  turnPhase: y,
1879
- taskStatus: d
1918
+ taskStatus: h
1880
1919
  }), S;
1881
1920
  }
1882
1921
  this.retryableClientMessageId = null;
@@ -1889,11 +1928,11 @@ class xe {
1889
1928
  entrySurface: this.options.entrySurface,
1890
1929
  content: n,
1891
1930
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1892
- pageContent: D && wt() || void 0,
1893
- attachments: r.length > 0 ? r.map(Ue) : void 0,
1931
+ pageContent: D && At() || void 0,
1932
+ attachments: r.length > 0 ? r.map(De) : void 0,
1894
1933
  page: o,
1895
1934
  model: this.options.model,
1896
- metadata: zt(this.options.metadata)
1935
+ metadata: Kt(this.options.metadata)
1897
1936
  };
1898
1937
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1899
1938
  }
@@ -1901,7 +1940,7 @@ class xe {
1901
1940
  return this.options.model;
1902
1941
  }
1903
1942
  setModel(e) {
1904
- this.options.model = e, this.options.productVariant === "personal" && Ge(e) && (this.personalModelSelectionOverride = e);
1943
+ this.options.model = e, this.options.productVariant === "personal" && Qe(e) && (this.personalModelSelectionOverride = e);
1905
1944
  }
1906
1945
  retryLastMessage() {
1907
1946
  const e = this.state.sessionId, t = this.retryableClientMessageId;
@@ -1967,7 +2006,7 @@ class xe {
1967
2006
  sizeBytes: e.size,
1968
2007
  page: P(),
1969
2008
  model: this.options.model,
1970
- metadata: zt(this.options.metadata),
2009
+ metadata: Kt(this.options.metadata),
1971
2010
  entrySurface: this.options.entrySurface
1972
2011
  };
1973
2012
  let o;
@@ -2075,8 +2114,8 @@ class xe {
2075
2114
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
2076
2115
  for (const [t, n] of this.activeBrowserToolCalls)
2077
2116
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
2078
- as(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
2079
- messages: is(
2117
+ ls(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
2118
+ messages: rs(
2080
2119
  this.state.messages,
2081
2120
  e.clientMessageId,
2082
2121
  e.runId
@@ -2120,7 +2159,7 @@ class xe {
2120
2159
  const t = x(), n = new Promise((r, o) => {
2121
2160
  const a = window.setTimeout(() => {
2122
2161
  this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
2123
- }, Ft);
2162
+ }, jt);
2124
2163
  this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
2125
2164
  }), i = {
2126
2165
  type: "sessions.list",
@@ -2493,8 +2532,8 @@ class xe {
2493
2532
  signal: AbortSignal.timeout(15e3)
2494
2533
  });
2495
2534
  if (!c.ok) {
2496
- const h = await c.text() || `History request failed (${c.status})`;
2497
- throw Nn(c.status) ? new Error(h) : new Se(h);
2535
+ const d = await c.text() || `History request failed (${c.status})`;
2536
+ throw Nn(c.status) ? new Error(d) : new Se(d);
2498
2537
  }
2499
2538
  const u = await c.json();
2500
2539
  if (!u?.session || !Array.isArray(u.items))
@@ -2549,7 +2588,7 @@ class xe {
2549
2588
  return !1;
2550
2589
  const t = this.socket;
2551
2590
  try {
2552
- return t.send(JSON.stringify(e)), Xe("client_event", e.type, Ht(e)), !0;
2591
+ return t.send(JSON.stringify(e)), Je("client_event", e.type, Bt(e)), !0;
2553
2592
  } catch (n) {
2554
2593
  return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2555
2594
  message: n instanceof Error ? n.message : String(n),
@@ -2559,36 +2598,131 @@ class xe {
2559
2598
  }
2560
2599
  }
2561
2600
  reportHealthSignal(e, t = {}) {
2562
- if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
2563
- return;
2564
2601
  const n = t.clientMessageId ?? this.activeResponseRunId;
2565
2602
  if (n) {
2566
- const i = `${e}:${n}`;
2567
- if (this.reportedHealthSignalKeys.has(i))
2603
+ const r = `${e}:${n}`;
2604
+ if (this.reportedHealthSignalKeys.has(r))
2568
2605
  return;
2569
- this.reportedHealthSignalKeys.add(i);
2606
+ this.reportedHealthSignalKeys.add(r);
2607
+ }
2608
+ const i = {
2609
+ id: crypto.randomUUID(),
2610
+ name: e,
2611
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
2612
+ source: "web_sdk",
2613
+ entrySurface: this.options.entrySurface,
2614
+ ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
2615
+ ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
2616
+ ...t
2617
+ };
2618
+ if (this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN) {
2619
+ this.queueHealthDiagnostic(i);
2620
+ return;
2570
2621
  }
2571
2622
  try {
2572
2623
  this.socket.send(JSON.stringify({
2573
2624
  type: "runtime.health",
2574
- signal: {
2575
- id: crypto.randomUUID(),
2576
- name: e,
2577
- occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
2578
- source: "web_sdk",
2579
- entrySurface: this.options.entrySurface,
2580
- ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
2581
- ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
2582
- ...t
2583
- }
2625
+ signal: i
2584
2626
  }));
2585
- } catch (i) {
2627
+ } catch (r) {
2586
2628
  b("web-sdk.agent", "Pluno health signal send failed", {
2587
2629
  name: e,
2588
- message: i instanceof Error ? i.message : String(i)
2630
+ message: r instanceof Error ? r.message : String(r)
2631
+ }), this.queueHealthDiagnostic(i);
2632
+ }
2633
+ }
2634
+ /** @internal */
2635
+ reportTransportDiagnostic(e, t = {}) {
2636
+ const n = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", i = `${e}:${t.closeCode ?? "none"}:${n}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(i), a = {
2637
+ id: o?.id ?? crypto.randomUUID(),
2638
+ phase: e,
2639
+ entrySurface: this.options.entrySurface,
2640
+ firstOccurredAt: o?.firstOccurredAt ?? r,
2641
+ lastOccurredAt: r,
2642
+ occurrenceCount: (o?.occurrenceCount ?? 0) + 1,
2643
+ maxReconnectAttempt: Math.max(o?.maxReconnectAttempt ?? 0, this.reconnectAttempts),
2644
+ connectivity: n,
2645
+ ...t
2646
+ };
2647
+ this.transportDiagnosticEpisodes.set(i, a), [1, 3, 10, 30, 100].includes(a.occurrenceCount) && (this.pendingTransportDiagnostics = [
2648
+ ...this.pendingTransportDiagnostics.filter((l) => l.id !== a.id),
2649
+ a
2650
+ ], this.pendingTransportDiagnostics.splice(0, Math.max(0, this.pendingTransportDiagnostics.length - 20)), this.flushClientDiagnostics());
2651
+ }
2652
+ /** @internal */
2653
+ queueHealthDiagnostic(e) {
2654
+ this.pendingHealthDiagnostics.push(e), this.pendingHealthDiagnostics.splice(0, Math.max(0, this.pendingHealthDiagnostics.length - 20)), this.flushClientDiagnostics();
2655
+ }
2656
+ /** @internal */
2657
+ async flushClientDiagnostics() {
2658
+ if (this.clientDiagnosticsFlush)
2659
+ return await this.clientDiagnosticsFlush;
2660
+ if (this.clientDiagnosticsRetryTimer !== null || this.pendingTransportDiagnostics.length === 0 && this.pendingHealthDiagnostics.length === 0)
2661
+ return;
2662
+ const e = this.performClientDiagnosticsFlush();
2663
+ this.clientDiagnosticsFlush = e;
2664
+ try {
2665
+ await e;
2666
+ } finally {
2667
+ this.clientDiagnosticsFlush === e && (this.clientDiagnosticsFlush = null), this.clientDiagnosticsRetryTimer === null && (this.pendingTransportDiagnostics.length > 0 || this.pendingHealthDiagnostics.length > 0) && this.flushClientDiagnostics();
2668
+ }
2669
+ }
2670
+ /** @internal */
2671
+ async performClientDiagnosticsFlush() {
2672
+ const e = this.token ?? this.options.token ?? null;
2673
+ if (!e) {
2674
+ if (!this.options.tokenProvider) {
2675
+ this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [];
2676
+ return;
2677
+ }
2678
+ this.scheduleClientDiagnosticsRetry();
2679
+ return;
2680
+ }
2681
+ const t = this.pendingTransportDiagnostics.slice(0, 20), n = this.pendingHealthDiagnostics.slice(0, 20), i = this.options.productVariant === "customer_embedded" ? "/api/product-agent/embed/diagnostics" : "/api/product-agent/runtime/diagnostics";
2682
+ try {
2683
+ const r = await fetch(new URL(i, this.options.backendUrl), {
2684
+ method: "POST",
2685
+ headers: {
2686
+ "content-type": "application/json",
2687
+ authorization: this.options.productVariant === "customer_embedded" ? `Bearer ${e}` : e
2688
+ },
2689
+ body: JSON.stringify({
2690
+ clientId: this.options.clientId,
2691
+ transportId: this.transportIdentity.transportId,
2692
+ transportEpisodes: t,
2693
+ healthSignals: n
2694
+ }),
2695
+ signal: AbortSignal.timeout(1e4)
2589
2696
  });
2697
+ if (r.status === 401 || r.status === 403) {
2698
+ const l = new Set(t.map((u) => u.id)), c = new Set(n.map((u) => u.id));
2699
+ this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
2700
+ (u) => !l.has(u.id)
2701
+ ), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
2702
+ (u) => !c.has(u.id)
2703
+ );
2704
+ return;
2705
+ }
2706
+ if (!r.ok)
2707
+ throw new Error(`Client diagnostic upload failed (${r.status})`);
2708
+ const o = new Map(
2709
+ t.map((l) => [l.id, l.occurrenceCount])
2710
+ ), a = new Set(n.map((l) => l.id));
2711
+ this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
2712
+ (l) => !o.has(l.id) || l.occurrenceCount > (o.get(l.id) ?? 0)
2713
+ ), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
2714
+ (l) => !a.has(l.id)
2715
+ );
2716
+ } catch {
2717
+ this.scheduleClientDiagnosticsRetry();
2590
2718
  }
2591
2719
  }
2720
+ /** @internal */
2721
+ scheduleClientDiagnosticsRetry() {
2722
+ this.clientDiagnosticsRetryTimer !== null || this.state.status === "closed" || (this.clientDiagnosticsRetryTimer = window.setTimeout(() => {
2723
+ this.clientDiagnosticsRetryTimer = null, this.flushClientDiagnostics();
2724
+ }, 3e4));
2725
+ }
2592
2726
  requestTransientStarterPrompts() {
2593
2727
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
2594
2728
  return;
@@ -2743,7 +2877,7 @@ class xe {
2743
2877
  });
2744
2878
  }
2745
2879
  handleServerEvent(e) {
2746
- if (Xe("server_event", e.type, Ht(e)), e.type === "session.subscribed") {
2880
+ if (Je("server_event", e.type, Bt(e)), e.type === "session.subscribed") {
2747
2881
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2748
2882
  if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
2749
2883
  const i = this.pendingSessionSubscription;
@@ -2810,7 +2944,7 @@ class xe {
2810
2944
  return;
2811
2945
  }
2812
2946
  if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2813
- this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
2947
+ this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear();
2814
2948
  const t = Zi(e.user);
2815
2949
  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();
2816
2950
  const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
@@ -2819,7 +2953,7 @@ class xe {
2819
2953
  rawAppearance: e.appearance,
2820
2954
  normalizedAppearance: n
2821
2955
  }), this.runtimeHelperJavascript = Vi(e.runtimeHelpers)?.javascript ?? null;
2822
- const r = Qt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2956
+ const r = Vt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2823
2957
  user: t,
2824
2958
  status: "connected",
2825
2959
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
@@ -2828,7 +2962,7 @@ class xe {
2828
2962
  type: "runtime.auth_ack",
2829
2963
  connectionAttempt: this.connectionAttemptId,
2830
2964
  entrySurface: this.options.entrySurface
2831
- }), o && r.length === 0 && !a && !Ze() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2965
+ }), o && r.length === 0 && !a && !et() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2832
2966
  type: "page.upsert",
2833
2967
  sessionId: this.state.sessionId,
2834
2968
  page: P(),
@@ -2838,21 +2972,21 @@ class xe {
2838
2972
  }
2839
2973
  if (e.type === "starterPrompts.updated") {
2840
2974
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
2841
- starterPrompts: Qt(e, "starterPrompts"),
2975
+ starterPrompts: Vt(e, "starterPrompts"),
2842
2976
  starterPromptsLoading: !1
2843
2977
  });
2844
2978
  return;
2845
2979
  }
2846
2980
  if (e.type === "scheduled_follow_ups.updated") {
2847
2981
  typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
2848
- activeScheduledFollowUps: Vt(
2982
+ activeScheduledFollowUps: Xt(
2849
2983
  e.activeScheduledFollowUps
2850
2984
  )
2851
2985
  });
2852
2986
  return;
2853
2987
  }
2854
2988
  if (e.type === "conversation.state") {
2855
- const t = Array.isArray(e.items) ? e.items : [], n = Dt(t), i = Object.prototype.hasOwnProperty.call(
2989
+ const t = Array.isArray(e.items) ? e.items : [], n = qt(t), i = Object.prototype.hasOwnProperty.call(
2856
2990
  e,
2857
2991
  "activeScheduledFollowUps"
2858
2992
  ), 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();
@@ -2863,67 +2997,67 @@ class xe {
2863
2997
  this.forgetSupersededTaskTabClosedTurn(r, C(U));
2864
2998
  for (const U of n)
2865
2999
  this.rememberDurablyStoppedTurn(r, U);
2866
- const l = ie(n), c = l === null ? null : n[l], u = C(c), h = this.findStoppedTurn(r, {
3000
+ const l = ie(n), c = l === null ? null : n[l], u = C(c), d = this.findStoppedTurn(r, {
2867
3001
  clientMessageId: u?.clientMessageId,
2868
3002
  respondsToUserMessageId: A(c, "id"),
2869
3003
  runId: u?.runId
2870
- }), m = this.filterStoppedSnapshotItems(n, r), g = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, d = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
2871
- g && d && (this.pendingClientMessageId = d);
2872
- let f = ar(
3004
+ }), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
3005
+ f && h && (this.pendingClientMessageId = h);
3006
+ let m = ar(
2873
3007
  e.assistantDraft
2874
3008
  );
2875
- f && this.findStoppedTurn(r, {
2876
- respondsToUserMessageId: f.respondsToUserMessageId,
2877
- runId: f.runId
2878
- }) && (f = void 0);
2879
- const M = f !== void 0;
2880
- this.rememberUserMessageClientMessageIds(m);
2881
- const w = Tr(m), D = m.filter((U) => {
3009
+ m && this.findStoppedTurn(r, {
3010
+ respondsToUserMessageId: m.respondsToUserMessageId,
3011
+ runId: m.runId
3012
+ }) && (m = void 0);
3013
+ const M = m !== void 0;
3014
+ this.rememberUserMessageClientMessageIds(g);
3015
+ const w = Tr(g), D = g.filter((U) => {
2882
3016
  const q = C(U);
2883
- return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(m, q) !== w;
3017
+ return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
2884
3018
  }), S = lt(
2885
3019
  this.state.messages,
2886
- tt(D, this.options.backendUrl)
2887
- ), T = ts(S), N = M ? f?.content ?? "" : this.state.assistantDraft, v = M ? f?.itemId ?? null : this.state.assistantDraftItemId, re = M ? f?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, J = M ? f?.runId ?? null : this.state.assistantDraftRunId, Y = m.some(
2888
- (U, q) => ss(
3020
+ st(D, this.options.backendUrl)
3021
+ ), T = ss(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, Y = M ? m?.runId ?? null : this.state.assistantDraftRunId, Z = g.some(
3022
+ (U, q) => ns(
2889
3023
  C(U),
2890
3024
  N,
2891
3025
  v,
2892
3026
  re,
2893
- J,
2894
- wr(m, q)
3027
+ Y,
3028
+ wr(g, q)
2895
3029
  )
2896
- ), Z = M ? f?.content ?? "" : this.state.assistantDraft, fe = !!f?.content && !Y, B = T && (!Z || Y), Q = mr(S), oe = B && Q ? "completed" : h ? "stopped" : B ? "failed" : null;
2897
- if (!T && Sr(this.state.messages, m))
3030
+ ), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
3031
+ if (!T && Sr(this.state.messages, g))
2898
3032
  return;
2899
- this.lastUserMessagePageUrl = yr(m);
2900
- const j = B || h ? null : ut(m);
3033
+ this.lastUserMessagePageUrl = yr(g);
3034
+ const j = B || d ? null : ut(g);
2901
3035
  if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
2902
3036
  sessionId: A(e.session, "id") ?? this.state.sessionId,
2903
3037
  messages: S,
2904
3038
  ...i ? {
2905
- activeScheduledFollowUps: Vt(
3039
+ activeScheduledFollowUps: Xt(
2906
3040
  e.activeScheduledFollowUps
2907
3041
  )
2908
3042
  } : {},
2909
3043
  isLoadingSession: !1,
2910
- ...g ? { pendingMessageStatus: g } : {},
3044
+ ...f ? { pendingMessageStatus: f } : {},
2911
3045
  ...y ? { turnPhase: y } : {},
2912
3046
  isRetrying: p,
2913
3047
  ...y ? { taskStatus: "working" } : {},
2914
3048
  ...oe && this.state.taskStatus === "working" ? { taskStatus: oe } : {},
2915
- ...Y ? {
3049
+ ...Z ? {
2916
3050
  assistantDraft: "",
2917
3051
  assistantDraftItemId: null,
2918
3052
  assistantDraftPhase: null,
2919
3053
  assistantDraftRespondsToUserMessageId: null,
2920
3054
  assistantDraftRunId: null
2921
3055
  } : M ? {
2922
- assistantDraft: f?.content ?? "",
2923
- assistantDraftItemId: f?.itemId ?? null,
2924
- assistantDraftPhase: f?.phase ?? null,
2925
- assistantDraftRespondsToUserMessageId: f?.respondsToUserMessageId ?? null,
2926
- assistantDraftRunId: f?.runId ?? null
3056
+ assistantDraft: m?.content ?? "",
3057
+ assistantDraftItemId: m?.itemId ?? null,
3058
+ assistantDraftPhase: m?.phase ?? null,
3059
+ assistantDraftRespondsToUserMessageId: m?.respondsToUserMessageId ?? null,
3060
+ assistantDraftRunId: m?.runId ?? null
2927
3061
  } : {},
2928
3062
  ...fe ? {
2929
3063
  isThinking: !0,
@@ -2947,10 +3081,10 @@ class xe {
2947
3081
  } : {}
2948
3082
  }), B)
2949
3083
  this.retryableClientMessageId = w, this.clearThinkingWatchdog();
2950
- else if (!h && (fe || j)) {
3084
+ else if (!d && (fe || j)) {
2951
3085
  if (j) {
2952
3086
  this.activeClientMessageId = j;
2953
- const U = ie(m), q = U === null ? null : m[U];
3087
+ const U = ie(g), q = U === null ? null : g[U];
2954
3088
  this.activeResponseUserMessageId = A(q, "id");
2955
3089
  }
2956
3090
  this.markThinkingProgress();
@@ -2964,7 +3098,7 @@ class xe {
2964
3098
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2965
3099
  if (!t || n !== this.state.sessionId)
2966
3100
  return;
2967
- const i = tt(
3101
+ const i = st(
2968
3102
  Array.isArray(e.items) ? e.items : [],
2969
3103
  this.options.backendUrl
2970
3104
  );
@@ -3009,11 +3143,11 @@ class xe {
3009
3143
  o && (this.retryableClientMessageId = o);
3010
3144
  return;
3011
3145
  }
3012
- const n = at(e.item, this.options.backendUrl);
3146
+ const n = ve(e.item, this.options.backendUrl);
3013
3147
  if (n) {
3014
3148
  const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3015
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), $(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
3016
- const o = de(this.state.messages, n), a = ts(o), l = ss(
3149
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
3150
+ const o = de(this.state.messages, n), a = ss(o), l = ns(
3017
3151
  t,
3018
3152
  this.state.assistantDraft,
3019
3153
  this.state.assistantDraftItemId,
@@ -3021,9 +3155,9 @@ class xe {
3021
3155
  this.state.assistantDraftRunId,
3022
3156
  _s(
3023
3157
  o,
3024
- o.findIndex((h) => h.id === n.id)
3158
+ o.findIndex((d) => d.id === n.id)
3025
3159
  )
3026
- ), c = a && (!this.state.assistantDraft || l), u = ve(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
3160
+ ), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c || F(n) && !this.state.isThinking && this.activeClientMessageId === null);
3027
3161
  this.setState({
3028
3162
  messages: o,
3029
3163
  ...l ? {
@@ -3050,7 +3184,7 @@ class xe {
3050
3184
  }
3051
3185
  if (e.type === "chat.assistant_delta") {
3052
3186
  this.clearRunAckResyncRetryTimer();
3053
- const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((h) => h.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
3187
+ const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((d) => d.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
3054
3188
  this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = u), this.setState({
3055
3189
  messages: de(this.state.messages, {
3056
3190
  id: o,
@@ -3081,7 +3215,7 @@ class xe {
3081
3215
  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;
3082
3216
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
3083
3217
  return;
3084
- const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = Ut(
3218
+ const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = Dt(
3085
3219
  this.state.messages.filter(
3086
3220
  (c) => c.dataType !== "assistant_draft" || !Ae(
3087
3221
  c,
@@ -3095,7 +3229,7 @@ class xe {
3095
3229
  );
3096
3230
  this.setState({
3097
3231
  sessionId: t,
3098
- messages: Jt(
3232
+ messages: Yt(
3099
3233
  l,
3100
3234
  typeof e.responseId == "string" ? e.responseId : null,
3101
3235
  n,
@@ -3118,9 +3252,9 @@ class xe {
3118
3252
  if (t)
3119
3253
  this.nonTranscriptToolCallIds.add(t);
3120
3254
  else {
3121
- const n = es(e);
3255
+ const n = ts(e);
3122
3256
  if (n) {
3123
- const i = Yt(
3257
+ const i = Zt(
3124
3258
  this.state.messages,
3125
3259
  n
3126
3260
  );
@@ -3153,8 +3287,8 @@ class xe {
3153
3287
  if (e.type === "error") {
3154
3288
  if (e.code === "unauthorized" && e.reason === "token_expired" && e.retryable === !0 && this.options.tokenProvider) {
3155
3289
  this.invalidateProviderToken(), this.clearSocketPhaseTimers(), this.stopHeartbeat();
3156
- const g = this.socket;
3157
- this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), g?.close();
3290
+ const f = this.socket;
3291
+ this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), f?.close();
3158
3292
  return;
3159
3293
  }
3160
3294
  const t = typeof e.requestId == "string" ? e.requestId : null;
@@ -3190,18 +3324,18 @@ class xe {
3190
3324
  o && i && r && (this.retryableClientMessageId = r);
3191
3325
  const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
3192
3326
  l && console.error(l);
3193
- const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = is(
3327
+ const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = rs(
3194
3328
  this.state.messages,
3195
3329
  c,
3196
3330
  u
3197
- ), m = fr(
3198
- h,
3331
+ ), g = fr(
3332
+ d,
3199
3333
  c,
3200
3334
  u
3201
3335
  );
3202
3336
  if (this.setState({
3203
- status: m ? "connected" : "error",
3204
- messages: h,
3337
+ status: g ? "connected" : "error",
3338
+ messages: d,
3205
3339
  assistantDraft: "",
3206
3340
  assistantDraftItemId: null,
3207
3341
  assistantDraftPhase: null,
@@ -3210,13 +3344,13 @@ class xe {
3210
3344
  isThinking: !1,
3211
3345
  ...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
3212
3346
  isRetrying: !1,
3213
- lastError: m ? null : a.message,
3214
- lastErrorCode: m ? null : typeof e.code == "string" ? e.code : null,
3215
- lastErrorSecuritySettingsUrl: m ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
3347
+ lastError: g ? null : a.message,
3348
+ lastErrorCode: g ? null : typeof e.code == "string" ? e.code : null,
3349
+ lastErrorSecuritySettingsUrl: g ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
3216
3350
  }), this.clearThinkingWatchdog(), this.emit("error", a), e.code === "unauthorized") {
3217
3351
  this.clearSocketPhaseTimers(), this.stopHeartbeat();
3218
- const g = this.socket;
3219
- this.socket = null, g?.close();
3352
+ const f = this.socket;
3353
+ this.socket = null, f?.close();
3220
3354
  }
3221
3355
  }
3222
3356
  }
@@ -3238,7 +3372,7 @@ class xe {
3238
3372
  if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
3239
3373
  return;
3240
3374
  const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
3241
- this.options.model = Ge(n) ? n : "gpt-5.6-sol";
3375
+ this.options.model = Qe(n) ? n : "gpt-5.6-sol";
3242
3376
  }
3243
3377
  updateAccountFallbackFromSession(e) {
3244
3378
  const t = e && typeof e == "object" ? e.metadata : null, n = An(t);
@@ -3261,9 +3395,9 @@ class xe {
3261
3395
  return;
3262
3396
  const n = this.sessionTimelineCache.get(t);
3263
3397
  if (e.type === "conversation.state") {
3264
- const i = Dt(
3398
+ const i = qt(
3265
3399
  Array.isArray(e.items) ? e.items : []
3266
- ), r = tt(
3400
+ ), r = st(
3267
3401
  this.filterStoppedSnapshotItems(i, t),
3268
3402
  this.options.backendUrl
3269
3403
  );
@@ -3278,15 +3412,15 @@ class xe {
3278
3412
  const i = C(e.item);
3279
3413
  if (pe(i))
3280
3414
  return;
3281
- const r = at(e.item, this.options.backendUrl);
3415
+ const r = ve(e.item, this.options.backendUrl);
3282
3416
  r && this.rememberSessionTimeline(t, de(n, r));
3283
3417
  return;
3284
3418
  }
3285
3419
  if (e.type === "tool.call") {
3286
- const i = e.hiddenFromTranscript === !0 ? null : es(e);
3420
+ const i = e.hiddenFromTranscript === !0 ? null : ts(e);
3287
3421
  i && this.rememberSessionTimeline(
3288
3422
  t,
3289
- Yt(n, i)
3423
+ Zt(n, i)
3290
3424
  );
3291
3425
  return;
3292
3426
  }
@@ -3298,7 +3432,7 @@ class xe {
3298
3432
  return;
3299
3433
  this.rememberSessionTimeline(
3300
3434
  t,
3301
- Zt(
3435
+ es(
3302
3436
  n,
3303
3437
  e.callId,
3304
3438
  i
@@ -3325,7 +3459,7 @@ class xe {
3325
3459
  return;
3326
3460
  }
3327
3461
  if (e.type === "chat.assistant_done") {
3328
- const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Ut(
3462
+ const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Dt(
3329
3463
  n.filter(
3330
3464
  (a) => a.dataType !== "assistant_draft" || !Ae(a, i, r)
3331
3465
  ),
@@ -3335,7 +3469,7 @@ class xe {
3335
3469
  );
3336
3470
  this.rememberSessionTimeline(
3337
3471
  t,
3338
- Jt(
3472
+ Yt(
3339
3473
  o,
3340
3474
  typeof e.responseId == "string" ? e.responseId : null,
3341
3475
  i,
@@ -3350,7 +3484,7 @@ class xe {
3350
3484
  return;
3351
3485
  this.rememberSessionTimeline(
3352
3486
  t,
3353
- rs(
3487
+ os(
3354
3488
  n,
3355
3489
  i,
3356
3490
  null,
@@ -3359,7 +3493,7 @@ class xe {
3359
3493
  );
3360
3494
  return;
3361
3495
  }
3362
- e.type === "error" && typeof e.requestId != "string" && !ns(e, t) && this.rememberSessionTimeline(
3496
+ e.type === "error" && typeof e.requestId != "string" && !is(e, t) && this.rememberSessionTimeline(
3363
3497
  t,
3364
3498
  kr(n, e)
3365
3499
  );
@@ -3395,9 +3529,9 @@ class xe {
3395
3529
  }
3396
3530
  handleRetryableRecoveryError(e) {
3397
3531
  const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
3398
- if (!ns(e, t) || !n)
3532
+ if (!is(e, t) || !n)
3399
3533
  return !1;
3400
- if (Ze())
3534
+ if (et())
3401
3535
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
3402
3536
  if (this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
3403
3537
  const i = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
@@ -3436,7 +3570,7 @@ class xe {
3436
3570
  const i = new Promise((r, o) => {
3437
3571
  const a = window.setTimeout(() => {
3438
3572
  e.delete(t.requestId), o(new Error(n));
3439
- }, Ft);
3573
+ }, jt);
3440
3574
  e.set(t.requestId, { resolve: r, reject: o, timeout: a });
3441
3575
  });
3442
3576
  if (!this.sendNow(t)) {
@@ -3515,7 +3649,7 @@ class xe {
3515
3649
  return this.pendingClientMessageId === e && this.state.isThinking && this.activeClientMessageId !== null && this.activeClientMessageId !== e;
3516
3650
  }
3517
3651
  schedulePendingDeliveryAck(e) {
3518
- this.clearPendingDeliveryTimers(), !Ze() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3652
+ this.clearPendingDeliveryTimers(), !et() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3519
3653
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
3520
3654
  }, $t));
3521
3655
  }
@@ -3553,7 +3687,7 @@ class xe {
3553
3687
  if (this.state.isThinking && t) {
3554
3688
  const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
3555
3689
  this.setState({
3556
- messages: rs(
3690
+ messages: os(
3557
3691
  this.state.messages,
3558
3692
  t,
3559
3693
  n,
@@ -3585,7 +3719,7 @@ class xe {
3585
3719
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3586
3720
  sessionId: this.state.sessionId,
3587
3721
  clientMessageId: e
3588
- }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Wt));
3722
+ }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft));
3589
3723
  }
3590
3724
  clearRunAckResyncRetryTimer() {
3591
3725
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -3618,7 +3752,7 @@ class xe {
3618
3752
  sessionId: this.state.sessionId,
3619
3753
  clientMessageId: e,
3620
3754
  resyncAttempts: t + 1
3621
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Wt);
3755
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft);
3622
3756
  }
3623
3757
  resyncThinkingSession() {
3624
3758
  this.state.sessionId ? this.send({
@@ -3682,13 +3816,13 @@ class xe {
3682
3816
  startedAtOrigin: location.origin
3683
3817
  }), this.installSessionBrowserApis();
3684
3818
  let c = null, u;
3685
- c = await this.executeRuntimeHelper(), u = await Kt(
3819
+ c = await this.executeRuntimeHelper(), u = await Gt(
3686
3820
  o,
3687
3821
  _i(e.runtimeContext, this.options.backendUrl)
3688
- ).catch((h) => ({
3822
+ ).catch((d) => ({
3689
3823
  ok: !1,
3690
3824
  exception: {
3691
- message: h instanceof Error ? h.message : String(h)
3825
+ message: d instanceof Error ? d.message : String(d)
3692
3826
  }
3693
3827
  })), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
3694
3828
  type: "tool.result",
@@ -3698,10 +3832,10 @@ class xe {
3698
3832
  summary: o.summary,
3699
3833
  rawInput: L(o),
3700
3834
  rawOutput: L(Xi(u, c))
3701
- }), as(this.options.clientId, this.activeBrowserToolCalls.values()));
3835
+ }), ls(this.options.clientId, this.activeBrowserToolCalls.values()));
3702
3836
  }
3703
3837
  setToolMessageLoading(e, t) {
3704
- const n = Zt(
3838
+ const n = es(
3705
3839
  this.state.messages,
3706
3840
  e,
3707
3841
  t
@@ -3727,7 +3861,7 @@ class xe {
3727
3861
  async executeRuntimeHelper() {
3728
3862
  if (!this.runtimeHelperJavascript?.trim())
3729
3863
  return null;
3730
- const e = await Kt({
3864
+ const e = await Gt({
3731
3865
  javascript: this.runtimeHelperJavascript
3732
3866
  });
3733
3867
  return e.ok === !1 ? Ji(e) : null;
@@ -3753,7 +3887,7 @@ class xe {
3753
3887
  if (this.reconnectTimer !== null || this.state.status === "closed")
3754
3888
  return;
3755
3889
  const t = Math.min(
3756
- rt,
3890
+ ot,
3757
3891
  Math.max(di(this.reconnectAttempts), e)
3758
3892
  );
3759
3893
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
@@ -3810,7 +3944,7 @@ class xe {
3810
3944
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3811
3945
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3812
3946
  }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null;
3813
- this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Xe("state", this.state.status, {
3947
+ this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
3814
3948
  status: this.state.status,
3815
3949
  sessionId: this.state.sessionId,
3816
3950
  messageCount: this.state.messages.length,
@@ -3868,7 +4002,7 @@ class xe {
3868
4002
  this.listeners[e]?.forEach((i) => i(t));
3869
4003
  }
3870
4004
  }
3871
- const Ye = /* @__PURE__ */ new WeakMap();
4005
+ const Ze = /* @__PURE__ */ new WeakMap();
3872
4006
  function fi(s) {
3873
4007
  const e = window.__plunoProductAgentNetworkCapture ?? mi();
3874
4008
  return e.subscribers.add(s), () => {
@@ -3876,30 +4010,30 @@ function fi(s) {
3876
4010
  };
3877
4011
  }
3878
4012
  function mi() {
3879
- const s = /* @__PURE__ */ new Set(), e = (m) => {
3880
- s.forEach((g) => {
4013
+ const s = /* @__PURE__ */ new Set(), e = (g) => {
4014
+ s.forEach((f) => {
3881
4015
  try {
3882
- g(m);
4016
+ f(g);
3883
4017
  } catch {
3884
4018
  }
3885
4019
  });
3886
- }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(g, d) {
4020
+ }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(f, h) {
3887
4021
  const p = Date.now();
3888
4022
  let y;
3889
4023
  try {
3890
- y = t.call(this, g, d);
3891
- } catch (f) {
3892
- throw f;
4024
+ y = t.call(this, f, h);
4025
+ } catch (m) {
4026
+ throw m;
3893
4027
  }
3894
4028
  try {
3895
- const f = g instanceof Request ? g : null, M = Jr(g, f), w = xs(d?.headers ?? f?.headers);
3896
- if (!te(M, w, d?.body)) {
4029
+ const m = f instanceof Request ? f : null, M = Jr(f, m), w = xs(h?.headers ?? m?.headers);
4030
+ if (!te(M, w, h?.body)) {
3897
4031
  const H = {
3898
- requestId: st("fetch"),
3899
- url: W(M, Je),
3900
- method: (d?.method ?? f?.method ?? "GET").toUpperCase(),
4032
+ requestId: nt("fetch"),
4033
+ url: W(M, Ye),
4034
+ method: (h?.method ?? m?.method ?? "GET").toUpperCase(),
3901
4035
  requestHeaders: w,
3902
- requestBody: cs(d?.body),
4036
+ requestBody: us(h?.body),
3903
4037
  resourceType: "fetch",
3904
4038
  startedAt: new Date(p).toISOString()
3905
4039
  };
@@ -3925,42 +4059,42 @@ function mi() {
3925
4059
  } catch {
3926
4060
  }
3927
4061
  return y;
3928
- }, a = function(g, d, p, y, f) {
3929
- const M = n.call(this, g, d, p ?? !0, y ?? void 0, f ?? void 0), w = typeof d == "string" ? d : d.toString();
3930
- return Ye.set(this, {
3931
- requestId: st("xhr"),
3932
- method: String(g ?? "GET").toUpperCase(),
3933
- url: W(w, Je),
4062
+ }, a = function(f, h, p, y, m) {
4063
+ const M = n.call(this, f, h, p ?? !0, y ?? void 0, m ?? void 0), w = typeof h == "string" ? h : h.toString();
4064
+ return Ze.set(this, {
4065
+ requestId: nt("xhr"),
4066
+ method: String(f ?? "GET").toUpperCase(),
4067
+ url: W(w, Ye),
3934
4068
  requestHeaders: {},
3935
4069
  startedAtMs: Date.now(),
3936
4070
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3937
4071
  excluded: te(w)
3938
4072
  }), M;
3939
- }, l = function(g, d) {
3940
- const p = i.call(this, g, d), y = Ye.get(this);
3941
- return y && Object.keys(y.requestHeaders).length < Tt && (y.requestHeaders[g] = bt(g, d), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
3942
- }, c = function(g) {
4073
+ }, l = function(f, h) {
4074
+ const p = i.call(this, f, h), y = Ze.get(this);
4075
+ return y && Object.keys(y.requestHeaders).length < wt && (y.requestHeaders[f] = Rt(f, h), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
4076
+ }, c = function(f) {
3943
4077
  try {
3944
- const d = Ye.get(this);
3945
- d && (d.excluded = d.excluded || te(d.url, d.requestHeaders, g), d.requestBody = cs(g), d.excluded || this.addEventListener(
4078
+ const h = Ze.get(this);
4079
+ h && (h.excluded = h.excluded || te(h.url, h.requestHeaders, f), h.requestBody = us(f), h.excluded || this.addEventListener(
3946
4080
  "loadend",
3947
4081
  () => {
3948
4082
  queueMicrotask(() => {
3949
4083
  try {
3950
4084
  const p = io(this.getAllResponseHeaders());
3951
4085
  e({
3952
- requestId: d.requestId,
3953
- url: d.url,
3954
- method: d.method,
3955
- requestHeaders: d.requestHeaders,
3956
- requestBody: d.requestBody,
4086
+ requestId: h.requestId,
4087
+ url: h.url,
4088
+ method: h.method,
4089
+ requestHeaders: h.requestHeaders,
4090
+ requestBody: h.requestBody,
3957
4091
  resourceType: "xhr",
3958
4092
  responseStatus: this.status,
3959
4093
  responseHeaders: p,
3960
4094
  responseBody: eo(this, p),
3961
4095
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
3962
- startedAt: d.startedAt,
3963
- durationMs: Date.now() - d.startedAtMs
4096
+ startedAt: h.startedAt,
4097
+ durationMs: Date.now() - h.startedAtMs
3964
4098
  });
3965
4099
  } catch {
3966
4100
  return;
@@ -3971,7 +4105,7 @@ function mi() {
3971
4105
  ));
3972
4106
  } catch {
3973
4107
  }
3974
- return r.call(this, g ?? null);
4108
+ return r.call(this, f ?? null);
3975
4109
  };
3976
4110
  try {
3977
4111
  window.fetch = o;
@@ -3991,20 +4125,20 @@ function mi() {
3991
4125
  }
3992
4126
  let u = null;
3993
4127
  if (typeof PerformanceObserver < "u") {
3994
- u = new PerformanceObserver((m) => {
3995
- for (const g of m.getEntries()) {
3996
- const d = g;
3997
- if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || te(d.name))
4128
+ u = new PerformanceObserver((g) => {
4129
+ for (const f of g.getEntries()) {
4130
+ const h = f;
4131
+ if (h.initiatorType === "fetch" || h.initiatorType === "xmlhttprequest" || te(h.name))
3998
4132
  continue;
3999
- const p = performance.timeOrigin + d.startTime;
4133
+ const p = performance.timeOrigin + h.startTime;
4000
4134
  e({
4001
- requestId: st("resource"),
4002
- url: W(d.name, Je),
4135
+ requestId: nt("resource"),
4136
+ url: W(h.name, Ye),
4003
4137
  method: "GET",
4004
4138
  resourceType: "resource",
4005
- responseStatus: d.responseStatus,
4139
+ responseStatus: h.responseStatus,
4006
4140
  startedAt: new Date(p).toISOString(),
4007
- durationMs: d.duration
4141
+ durationMs: h.duration
4008
4142
  });
4009
4143
  }
4010
4144
  });
@@ -4014,7 +4148,7 @@ function mi() {
4014
4148
  u.disconnect(), u = null;
4015
4149
  }
4016
4150
  }
4017
- const h = {
4151
+ const d = {
4018
4152
  subscribers: s,
4019
4153
  destroy: () => {
4020
4154
  u?.disconnect();
@@ -4036,7 +4170,7 @@ function mi() {
4036
4170
  }
4037
4171
  }
4038
4172
  };
4039
- return window.__plunoProductAgentNetworkCapture = h, h;
4173
+ return window.__plunoProductAgentNetworkCapture = d, d;
4040
4174
  }
4041
4175
  function b(s, e, t) {
4042
4176
  if (typeof window > "u")
@@ -4049,7 +4183,7 @@ function b(s, e, t) {
4049
4183
  }, r = n.__plunoProductAgentDiagnostics__ ?? [];
4050
4184
  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 }));
4051
4185
  }
4052
- function zt(s) {
4186
+ function Kt(s) {
4053
4187
  const e = typeof s == "function" ? s() : s;
4054
4188
  return e && Object.keys(e).length > 0 ? e : void 0;
4055
4189
  }
@@ -4086,10 +4220,10 @@ function Ti() {
4086
4220
  };
4087
4221
  }
4088
4222
  function wi() {
4089
- return ds(globalThis, "getPageSnapshot", async () => wt());
4223
+ return hs(globalThis, "getPageSnapshot", async () => At());
4090
4224
  }
4091
4225
  function Ai() {
4092
- return ds(globalThis, "pageImages", {
4226
+ return hs(globalThis, "pageImages", {
4093
4227
  inspectImage: async (e, t) => await Mi(e, t)
4094
4228
  });
4095
4229
  }
@@ -4166,7 +4300,7 @@ function Pi(s) {
4166
4300
  }, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
4167
4301
  });
4168
4302
  }
4169
- async function Kt(s, e) {
4303
+ async function Gt(s, e) {
4170
4304
  const t = Object.getPrototypeOf(async function() {
4171
4305
  }).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
4172
4306
  let o;
@@ -4182,8 +4316,8 @@ async function Kt(s, e) {
4182
4316
  try {
4183
4317
  const c = /* @__PURE__ */ Symbol("execute_code_timeout"), u = await Promise.race([
4184
4318
  new t("sandboxFiles", s.javascript)(e?.value),
4185
- new Promise((h) => {
4186
- o = window.setTimeout(() => h(c), n);
4319
+ new Promise((d) => {
4320
+ o = window.setTimeout(() => d(c), n);
4187
4321
  })
4188
4322
  ]);
4189
4323
  return u === c ? vi(n) : {
@@ -4248,8 +4382,8 @@ function _i(s, e) {
4248
4382
  );
4249
4383
  if (!l.ok)
4250
4384
  throw new Error(`sandboxFiles.download failed (${l.status})`);
4251
- const c = await l.blob(), h = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
4252
- return new File([c], h || a.split("/").pop() || "file", {
4385
+ const c = await l.blob(), d = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
4386
+ return new File([c], d || a.split("/").pop() || "file", {
4253
4387
  type: c.type
4254
4388
  });
4255
4389
  }
@@ -4311,7 +4445,7 @@ function Li() {
4311
4445
  return {
4312
4446
  pageUrl: location.href,
4313
4447
  pageTitle: document.title,
4314
- htmlContent: wt()
4448
+ htmlContent: At()
4315
4449
  };
4316
4450
  }
4317
4451
  function Ni(s) {
@@ -4334,24 +4468,24 @@ function Hi() {
4334
4468
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === i && (window.history.replaceState = t), window.removeEventListener("popstate", s), window.removeEventListener("hashchange", s);
4335
4469
  };
4336
4470
  }
4337
- function Ze() {
4471
+ function et() {
4338
4472
  return ks()?.surface === "browser_extension_sdk_preview";
4339
4473
  }
4340
- function wt() {
4474
+ function At() {
4341
4475
  if (!document.body)
4342
4476
  return "";
4343
4477
  const s = [], e = [], t = (p, y) => {
4344
- const f = ne(y);
4345
- !f || e.includes(f) || (s.push([p, f]), e.push(f));
4478
+ const m = ne(y);
4479
+ !m || e.includes(m) || (s.push([p, m]), e.push(m));
4346
4480
  };
4347
4481
  t("Selected text", window.getSelection()?.toString() ?? "");
4348
4482
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
4349
4483
  (p) => Ms(p) && !p.parentElement?.closest(n)
4350
4484
  );
4351
4485
  for (const p of i.slice(0, 3))
4352
- t("Active overlay", et(he(p), e));
4353
- const r = Bi(), o = r ? et(he(r), e) : "";
4354
- t("Main page content", o), t("Additional visible page text", et(he(document.body), e));
4486
+ t("Active overlay", tt(he(p), e));
4487
+ const r = Bi(), o = r ? tt(he(r), e) : "";
4488
+ t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
4355
4489
  const a = s.map(([p, y]) => `${p}:
4356
4490
  ${y}`).join(`
4357
4491
 
@@ -4359,8 +4493,8 @@ ${y}`).join(`
4359
4493
  `, u = `
4360
4494
 
4361
4495
  Visible page text:
4362
- `, h = 12e3 - c.length - u.length, m = Math.min(a.length, 7900), g = l.slice(0, h - m), d = a.slice(0, h - g.length);
4363
- return `${c}${g}${u}${d}`;
4496
+ `, d = 12e3 - c.length - u.length, g = Math.min(a.length, 7900), f = l.slice(0, d - g), h = a.slice(0, d - f.length);
4497
+ return `${c}${f}${u}${h}`;
4364
4498
  }
4365
4499
  function he(s) {
4366
4500
  return s.innerText ?? s.textContent ?? "";
@@ -4373,7 +4507,7 @@ function ne(s) {
4373
4507
 
4374
4508
  `).trim();
4375
4509
  }
4376
- function et(s, e) {
4510
+ function tt(s, e) {
4377
4511
  let t = ne(s);
4378
4512
  for (const n of e)
4379
4513
  t = t.replace(n, "");
@@ -4466,22 +4600,22 @@ function Wi(s, e) {
4466
4600
  "data-test",
4467
4601
  "data-qa",
4468
4602
  "data-cy"
4469
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: h } = $i(), m = new Set(s);
4470
- e && m.add(e);
4471
- let g = 0;
4472
- const d = (w) => {
4603
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = Fi(), g = new Set(s);
4604
+ e && g.add(e);
4605
+ let f = 0;
4606
+ const h = (w) => {
4473
4607
  const D = w.getAttribute("role");
4474
4608
  return D && !o.has(D) ? D : "";
4475
4609
  }, p = (w) => {
4476
4610
  const D = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
4477
- return `${w.tagName.toLowerCase()}|${d(w)}|${D}`;
4611
+ return `${w.tagName.toLowerCase()}|${h(w)}|${D}`;
4478
4612
  }, y = (w, D, H) => {
4479
4613
  const S = (T, N) => {
4480
- const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T), J = u.has(T);
4481
- if (g >= 1e3 && !J || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || re.display === "none" || re.visibility === "hidden")
4614
+ const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T), Y = u.has(T);
4615
+ if (f >= 1e3 && !Y || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || re.display === "none" || re.visibility === "hidden")
4482
4616
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
4483
- g += 1;
4484
- const Y = d(T), Z = Rs(T), fe = a.has(Y) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(v) || v === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), Q = /* @__PURE__ */ new Map();
4617
+ f += 1;
4618
+ const Z = h(T), ee = Rs(T), fe = a.has(Z) || ["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();
4485
4619
  for (const I of B) {
4486
4620
  const R = p(I);
4487
4621
  Q.set(R, (Q.get(R) ?? 0) + 1);
@@ -4491,59 +4625,59 @@ function Wi(s, e) {
4491
4625
  const R = p(I), z = oe.get(R) ?? 0;
4492
4626
  oe.set(R, z + 1), (Q.get(R) ?? 0) > 8 && z >= 6 && !u.has(I) && me.set(R, (me.get(R) ?? 0) + 1);
4493
4627
  }
4494
- const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Rt = [];
4628
+ const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], kt = [];
4495
4629
  for (const I of B) {
4496
- const R = p(I), z = Q.get(R) ?? 0, Ct = j.get(R) ?? 0;
4497
- if (j.set(R, Ct + 1), z > 8 && Ct >= 6 && !u.has(I)) {
4630
+ const R = p(I), z = Q.get(R) ?? 0, Pt = j.get(R) ?? 0;
4631
+ if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
4498
4632
  U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
4499
4633
  continue;
4500
4634
  }
4501
- const Pt = S(I, N);
4502
- Rt.push(Pt), q.push(Pt.lines);
4635
+ const _t = S(I, N);
4636
+ kt.push(_t), q.push(_t.lines);
4503
4637
  }
4504
- const He = [];
4638
+ const Be = [];
4505
4639
  if (T.shadowRoot)
4506
4640
  for (const I of Array.from(T.shadowRoot.children))
4507
- I instanceof HTMLElement && He.push(S(I, N + 1));
4508
- const ye = [...Rt, ...He], Be = Z.length > 0 || fe || ye.some((I) => I.hasUsefulContent), kt = ne(
4509
- [Z, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
4510
- ).slice(0, 180), js = T.hasAttribute("contenteditable") && (Z.length > 0 || !T.querySelector("[contenteditable]")), Et = c.some((I) => T.hasAttribute(I)) || !!Y || js, We = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Et || J) && (Be || J) && (!i.has(v) || Be || Et || J), $e = We ? 1 : 0, ae = [];
4511
- if (We) {
4512
- const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? kt : Z;
4641
+ I instanceof HTMLElement && Be.push(S(I, N + 1));
4642
+ const ye = [...kt, ...Be], We = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
4643
+ [ee, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
4644
+ ).slice(0, 180), js = T.hasAttribute("contenteditable") && (ee.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Z || js, Fe = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || Y) && (We || Y) && (!i.has(v) || We || Ct || Y), $e = Fe ? 1 : 0, ae = [];
4645
+ if (Fe) {
4646
+ const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et : ee;
4513
4647
  ae.push(bs(T, l, o, R.slice(0, 180)));
4514
4648
  }
4515
4649
  for (const I of q)
4516
4650
  ae.push(...we(I, $e));
4517
- const Fe = He.flatMap((I) => I.lines);
4518
- if (Fe.length > 0) {
4519
- const I = Fe.slice(0, 20);
4520
- Fe.length > I.length && I.push("… shadow DOM omitted");
4651
+ const je = Be.flatMap((I) => I.lines);
4652
+ if (je.length > 0) {
4653
+ const I = je.slice(0, 20);
4654
+ je.length > I.length && I.push("… shadow DOM omitted");
4521
4655
  const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
4522
4656
  if (N < 2 && !R) {
4523
- const z = We ? "#shadow-root" : `${v} #shadow-root`;
4657
+ const z = Fe ? "#shadow-root" : `${v} #shadow-root`;
4524
4658
  ae.push(...we([z, ...we(I, 1)], $e));
4525
4659
  } else
4526
4660
  ae.push(...we(I, $e));
4527
4661
  }
4528
4662
  return {
4529
4663
  lines: ae,
4530
- hasUsefulContent: Be,
4531
- textPreview: kt,
4664
+ hasUsefulContent: We,
4665
+ textPreview: Et,
4532
4666
  containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
4533
4667
  };
4534
4668
  };
4535
4669
  return [`--- ${D} ---`, ...S(w, 0).lines].join(`
4536
4670
  `);
4537
- }, f = [], M = ne(window.getSelection()?.toString() ?? "");
4538
- M && f.push(`--- selected text ---
4539
- ${JSON.stringify(M)}`), h.length > 0 && f.push(Fi(h, t, l, o));
4671
+ }, m = [], M = ne(window.getSelection()?.toString() ?? "");
4672
+ M && m.push(`--- selected text ---
4673
+ ${JSON.stringify(M)}`), d.length > 0 && m.push($i(d, t, l, o));
4540
4674
  for (const w of s.slice(0, 3))
4541
- f.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4542
- if (e && f.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
4675
+ m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4676
+ if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
4543
4677
  const w = e || s.length ? "other visible DOM" : "visible DOM";
4544
- f.push(y(document.body, w, m));
4678
+ m.push(y(document.body, w, g));
4545
4679
  }
4546
- return f.join(`
4680
+ return m.join(`
4547
4681
 
4548
4682
  `);
4549
4683
  }
@@ -4564,7 +4698,7 @@ function bs(s, e, t, n) {
4564
4698
  s.hasAttribute(a) && (r += `[${a}]`);
4565
4699
  return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
4566
4700
  }
4567
- function $i() {
4701
+ function Fi() {
4568
4702
  const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
4569
4703
  if (!a)
4570
4704
  return;
@@ -4573,11 +4707,11 @@ function $i() {
4573
4707
  return;
4574
4708
  const u = e.get(a) ?? /* @__PURE__ */ new Set();
4575
4709
  u.add(l), e.set(a, u);
4576
- let h = a;
4577
- for (; h; ) {
4578
- s.add(h);
4579
- const m = h.getRootNode();
4580
- h = h.parentElement ?? (m instanceof ShadowRoot && m.host instanceof HTMLElement ? m.host : null);
4710
+ let d = a;
4711
+ for (; d; ) {
4712
+ s.add(d);
4713
+ const g = d.getRootNode();
4714
+ d = d.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
4581
4715
  }
4582
4716
  };
4583
4717
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -4585,7 +4719,7 @@ function $i() {
4585
4719
  n = n.shadowRoot.activeElement;
4586
4720
  n !== document.body && n !== document.documentElement && t(n, "focused");
4587
4721
  const i = window.getSelection();
4588
- i && !i.isCollapsed && (t(Gt(i.anchorNode), "selected text"), t(Gt(i.focusNode), "selected text"));
4722
+ i && !i.isCollapsed && (t(Qt(i.anchorNode), "selected text"), t(Qt(i.focusNode), "selected text"));
4589
4723
  const r = [
4590
4724
  ["[aria-selected='true']", "selected"],
4591
4725
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -4597,8 +4731,8 @@ function $i() {
4597
4731
  for (let a = 0; a < o.length; a += 1) {
4598
4732
  const l = o[a];
4599
4733
  for (const [c, u] of r)
4600
- for (const h of Array.from(l.querySelectorAll(c)))
4601
- t(h, u);
4734
+ for (const d of Array.from(l.querySelectorAll(c)))
4735
+ t(d, u);
4602
4736
  for (const c of Array.from(l.querySelectorAll("*")))
4603
4737
  c.shadowRoot && o.push(c.shadowRoot);
4604
4738
  }
@@ -4607,7 +4741,7 @@ function $i() {
4607
4741
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
4608
4742
  };
4609
4743
  }
4610
- function Fi(s, e, t, n) {
4744
+ function $i(s, e, t, n) {
4611
4745
  const i = ["--- active/current elements ---"];
4612
4746
  for (const r of s) {
4613
4747
  const o = [];
@@ -4615,21 +4749,21 @@ function Fi(s, e, t, n) {
4615
4749
  for (; a; ) {
4616
4750
  const u = a.tagName.toLowerCase();
4617
4751
  (a === r.element || e.has(u) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
4618
- const h = a.getRootNode();
4619
- a = a.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
4752
+ const d = a.getRootNode();
4753
+ a = a.parentElement ?? (d instanceof ShadowRoot && d.host instanceof HTMLElement ? d.host : null);
4620
4754
  }
4621
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => bs(
4755
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, d) => bs(
4622
4756
  u,
4623
4757
  t,
4624
4758
  n,
4625
- h === l.length - 1 ? Rs(u).slice(0, 180) : ""
4759
+ d === l.length - 1 ? Rs(u).slice(0, 180) : ""
4626
4760
  ));
4627
4761
  o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
4628
4762
  }
4629
4763
  return i.join(`
4630
4764
  `);
4631
4765
  }
4632
- function Gt(s) {
4766
+ function Qt(s) {
4633
4767
  return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
4634
4768
  }
4635
4769
  function we(s, e) {
@@ -4647,7 +4781,7 @@ function ji(s) {
4647
4781
  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);
4648
4782
  }
4649
4783
  function ks() {
4650
- const s = Array.from(document.querySelectorAll(Nt)), e = s.find(
4784
+ const s = Array.from(document.querySelectorAll(Ht)), e = s.find(
4651
4785
  (r) => typeof r[On] == "string"
4652
4786
  );
4653
4787
  if (!(e ?? s[0]))
@@ -4659,7 +4793,7 @@ function ks() {
4659
4793
  selectors: [
4660
4794
  {
4661
4795
  name: "widget_host",
4662
- selector: Nt,
4796
+ selector: Ht,
4663
4797
  description: "Finds Pluno's shadow-host element in the host page DOM."
4664
4798
  },
4665
4799
  {
@@ -4698,13 +4832,13 @@ function Ki(s) {
4698
4832
  return null;
4699
4833
  }
4700
4834
  }
4701
- function Qt(s, e) {
4835
+ function Vt(s, e) {
4702
4836
  if (!s || typeof s != "object")
4703
4837
  return [];
4704
4838
  const t = s[e];
4705
4839
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
4706
4840
  }
4707
- function Vt(s) {
4841
+ function Xt(s) {
4708
4842
  return Array.isArray(s) ? s.flatMap((e) => {
4709
4843
  if (!e || typeof e != "object")
4710
4844
  return [];
@@ -4769,9 +4903,9 @@ function Zi(s) {
4769
4903
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
4770
4904
  } : null;
4771
4905
  }
4772
- function tt(s, e) {
4906
+ function st(s, e) {
4773
4907
  return Array.isArray(s) ? ht(
4774
- s.map((t) => at(t, e)).filter((t) => t !== null)
4908
+ s.map((t) => ve(t, e)).filter((t) => t !== null)
4775
4909
  ) : [];
4776
4910
  }
4777
4911
  function er(s) {
@@ -4795,7 +4929,7 @@ function er(s) {
4795
4929
  ];
4796
4930
  }) : [];
4797
4931
  }
4798
- function at(s, e) {
4932
+ function ve(s, e) {
4799
4933
  if (!s || typeof s != "object")
4800
4934
  return null;
4801
4935
  const t = s, n = t.data;
@@ -4809,8 +4943,8 @@ function at(s, e) {
4809
4943
  id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
4810
4944
  role: "assistant",
4811
4945
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4812
- content: _t(
4813
- Xt(i.content),
4946
+ content: vt(
4947
+ Jt(i.content),
4814
4948
  e
4815
4949
  ),
4816
4950
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -4826,8 +4960,8 @@ function at(s, e) {
4826
4960
  id: String(t.id ?? crypto.randomUUID()),
4827
4961
  role: r,
4828
4962
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4829
- content: _t(
4830
- Xt(i.content),
4963
+ content: vt(
4964
+ Jt(i.content),
4831
4965
  e
4832
4966
  ),
4833
4967
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -4861,7 +4995,7 @@ function at(s, e) {
4861
4995
  respondsToUserMessageId: O(i) ?? void 0,
4862
4996
  ...k(i) ? { runId: k(i) } : {},
4863
4997
  dataType: "function_call_output",
4864
- toolName: hs,
4998
+ toolName: St,
4865
4999
  callId: ue(i) ?? void 0,
4866
5000
  sharePromptAllowed: r
4867
5001
  };
@@ -5035,7 +5169,7 @@ function _(s) {
5035
5169
  function E(s) {
5036
5170
  return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
5037
5171
  }
5038
- function Xt(s) {
5172
+ function Jt(s) {
5039
5173
  return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
5040
5174
  if (!e || typeof e != "object")
5041
5175
  return "";
@@ -5046,7 +5180,7 @@ function Xt(s) {
5046
5180
  function de(s, e) {
5047
5181
  const t = Es(
5048
5182
  s,
5049
- At(s, e)
5183
+ Mt(s, e)
5050
5184
  ), n = ur(
5051
5185
  cr(
5052
5186
  gr(
@@ -5064,7 +5198,7 @@ function de(s, e) {
5064
5198
  const r = [...n];
5065
5199
  return r[i] = t, ht(r);
5066
5200
  }
5067
- function At(s, e, t = !0) {
5201
+ function Mt(s, e, t = !0) {
5068
5202
  const n = s.find(
5069
5203
  (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)
5070
5204
  );
@@ -5094,7 +5228,7 @@ function cr(s, e) {
5094
5228
  function Ae(s, e, t) {
5095
5229
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
5096
5230
  }
5097
- function Jt(s, e, t, n) {
5231
+ function Yt(s, e, t, n) {
5098
5232
  if (t === null) return s;
5099
5233
  let i = -1;
5100
5234
  for (let o = s.length - 1; o >= 0; o -= 1) {
@@ -5111,7 +5245,7 @@ function Jt(s, e, t, n) {
5111
5245
  respondsToUserMessageId: t
5112
5246
  }, r;
5113
5247
  }
5114
- function Yt(s, e) {
5248
+ function Zt(s, e) {
5115
5249
  const t = s.findIndex(
5116
5250
  (i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
5117
5251
  );
@@ -5128,12 +5262,12 @@ function Yt(s, e) {
5128
5262
  ...n[t].runId ? {} : { runId: e.runId }
5129
5263
  }, n;
5130
5264
  }
5131
- function Zt(s, e, t) {
5265
+ function es(s, e, t) {
5132
5266
  let n = !1;
5133
5267
  const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
5134
5268
  return n ? i : s;
5135
5269
  }
5136
- function es(s) {
5270
+ function ts(s) {
5137
5271
  if (s.hiddenFromTranscript === !0)
5138
5272
  return null;
5139
5273
  const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
@@ -5169,7 +5303,7 @@ function lt(s, e) {
5169
5303
  t.push(
5170
5304
  Es(
5171
5305
  i,
5172
- At(i, n, !1)
5306
+ Mt(i, n, !1)
5173
5307
  )
5174
5308
  );
5175
5309
  }
@@ -5181,7 +5315,7 @@ function lt(s, e) {
5181
5315
  }
5182
5316
  function dr(s, e) {
5183
5317
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5184
- (r) => At(s, r, !1)
5318
+ (r) => Mt(s, r, !1)
5185
5319
  );
5186
5320
  for (const r of n)
5187
5321
  t.set(r.id, r);
@@ -5201,7 +5335,7 @@ function dr(s, e) {
5201
5335
  return i;
5202
5336
  }
5203
5337
  function ct(s) {
5204
- const e = X(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5338
+ const e = J(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5205
5339
  // Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
5206
5340
  // from substituting the call for its output and then appending a duplicate output at the end of the timeline.
5207
5341
  ...s.callId ? [`${n ? "call-output" : "call"}:${s.callId}`] : [],
@@ -5214,7 +5348,7 @@ function ct(s) {
5214
5348
  ...i.length > 0 ? { activityKeys: i } : {},
5215
5349
  ...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
5216
5350
  ...s.runId ? { runId: s.runId } : {},
5217
- isOptimistic: Le(s),
5351
+ isOptimistic: Ne(s),
5218
5352
  isAssistantDraft: s.dataType === "assistant_draft",
5219
5353
  isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
5220
5354
  isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
@@ -5224,14 +5358,14 @@ function Es(s, e) {
5224
5358
  if (e.role !== "user" || !e.attachments?.length)
5225
5359
  return e;
5226
5360
  const t = s.find(
5227
- (o) => o.role === "user" && (o.id === e.id || Le(o) && Cs(o, e))
5361
+ (o) => o.role === "user" && (o.id === e.id || Ne(o) && Cs(o, e))
5228
5362
  );
5229
5363
  if (!t?.attachments?.length)
5230
5364
  return e;
5231
5365
  const n = e.attachments.map((o) => {
5232
5366
  const a = hr(t.attachments ?? [], o);
5233
5367
  return a ? pr(o, a) : o;
5234
- }), i = { ...e, attachments: n }, r = X(e);
5368
+ }), i = { ...e, attachments: n }, r = J(e);
5235
5369
  return r && Object.defineProperty(i, "clientMessageId", {
5236
5370
  value: r,
5237
5371
  enumerable: !1
@@ -5248,7 +5382,7 @@ function gr(s, e) {
5248
5382
  if (e.role !== "user")
5249
5383
  return s;
5250
5384
  const t = s.findIndex(
5251
- (i) => Le(i) && Cs(i, e)
5385
+ (i) => Ne(i) && Cs(i, e)
5252
5386
  );
5253
5387
  if (t === -1)
5254
5388
  return s;
@@ -5256,13 +5390,13 @@ function gr(s, e) {
5256
5390
  return n.splice(t, 1), n;
5257
5391
  }
5258
5392
  function Cs(s, e) {
5259
- const t = X(s), n = X(e);
5393
+ const t = J(s), n = J(e);
5260
5394
  return t && n ? t === n : s.content === e.content;
5261
5395
  }
5262
- function Le(s) {
5396
+ function Ne(s) {
5263
5397
  return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
5264
5398
  }
5265
- function X(s) {
5399
+ function J(s) {
5266
5400
  const e = s.clientMessageId;
5267
5401
  if (e)
5268
5402
  return e;
@@ -5271,19 +5405,19 @@ function X(s) {
5271
5405
  );
5272
5406
  return n ? s.id.slice(n.length) : null;
5273
5407
  }
5274
- function ts(s) {
5408
+ function ss(s) {
5275
5409
  const e = Ps(s);
5276
5410
  if (e === null)
5277
5411
  return !1;
5278
5412
  const t = s[e].id;
5279
5413
  if (s.some(
5280
- (i) => i.respondsToUserMessageId === t && ve(i)
5414
+ (i) => i.respondsToUserMessageId === t && Ue(i)
5281
5415
  ))
5282
5416
  return !0;
5283
5417
  for (let i = s.length - 1; i > e; i -= 1) {
5284
5418
  const r = s[i];
5285
5419
  if (!r.respondsToUserMessageId) {
5286
- if ($(r))
5420
+ if (F(r))
5287
5421
  return !0;
5288
5422
  if (r.role === "system") {
5289
5423
  if (r.dataType === "run_error")
@@ -5298,7 +5432,7 @@ function ts(s) {
5298
5432
  function fr(s, e, t) {
5299
5433
  const n = new Set(
5300
5434
  s.filter(
5301
- (i) => i.role === "user" && e !== null && X(i) === e
5435
+ (i) => i.role === "user" && e !== null && J(i) === e
5302
5436
  ).map((i) => i.id)
5303
5437
  );
5304
5438
  return s.some((i, r) => {
@@ -5318,20 +5452,20 @@ function fr(s, e, t) {
5318
5452
  function mr(s) {
5319
5453
  const e = Ps(s);
5320
5454
  if (e === null)
5321
- return s.some($);
5455
+ return s.some(F);
5322
5456
  const t = s[e].id;
5323
5457
  return s.some((n) => n.respondsToUserMessageId === t) ? s.some(
5324
- (n) => n.respondsToUserMessageId === t && $(n)
5325
- ) : s.slice(e + 1).some($);
5458
+ (n) => n.respondsToUserMessageId === t && F(n)
5459
+ ) : s.slice(e + 1).some(F);
5326
5460
  }
5327
5461
  function Ps(s) {
5328
5462
  for (let e = s.length - 1; e >= 0; e -= 1)
5329
- if (s[e].role === "user" && !Le(s[e]))
5463
+ if (s[e].role === "user" && !Ne(s[e]))
5330
5464
  return e;
5331
5465
  return null;
5332
5466
  }
5333
- function ve(s) {
5334
- return $(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5467
+ function Ue(s) {
5468
+ return F(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5335
5469
  }
5336
5470
  function ie(s) {
5337
5471
  for (let e = s.length - 1; e >= 0; e -= 1) {
@@ -5378,8 +5512,8 @@ function Sr(s, e) {
5378
5512
  return !1;
5379
5513
  const r = s.findIndex((o) => o.role === "user" && o.id === i);
5380
5514
  return r === -1 ? !1 : s.some((o) => o.respondsToUserMessageId === i) ? s.some(
5381
- (o) => o.respondsToUserMessageId === i && ve(o)
5382
- ) : s.slice(r + 1).some(ve);
5515
+ (o) => o.respondsToUserMessageId === i && Ue(o)
5516
+ ) : s.slice(r + 1).some(Ue);
5383
5517
  }
5384
5518
  function ut(s) {
5385
5519
  const e = ie(s);
@@ -5424,7 +5558,7 @@ function dt(s, e) {
5424
5558
  const n = s.find((r) => A(r, "id") === t), i = C(n);
5425
5559
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5426
5560
  }
5427
- function ss(s, e, t, n, i, r) {
5561
+ function ns(s, e, t, n, i, r) {
5428
5562
  if (!e || !Ar(s))
5429
5563
  return !1;
5430
5564
  const o = s;
@@ -5453,7 +5587,7 @@ function Ar(s) {
5453
5587
  const e = s;
5454
5588
  return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
5455
5589
  }
5456
- function $(s) {
5590
+ function F(s) {
5457
5591
  return s.role === "assistant" && s.phase !== "commentary";
5458
5592
  }
5459
5593
  function Mr(s) {
@@ -5477,7 +5611,7 @@ function pt(s) {
5477
5611
  function Rr(s) {
5478
5612
  return s.some(pt);
5479
5613
  }
5480
- function ns(s, e) {
5614
+ function is(s, e) {
5481
5615
  return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5482
5616
  }
5483
5617
  function kr(s, e) {
@@ -5491,7 +5625,7 @@ function Er(s, e, t, n) {
5491
5625
  (l) => l.role === "user" && l.id === o
5492
5626
  ) : null;
5493
5627
  return {
5494
- clientMessageId: a ? X(a) : o ? null : n,
5628
+ clientMessageId: a ? J(a) : o ? null : n,
5495
5629
  respondsToUserMessageId: o,
5496
5630
  runId: t ?? r?.runId ?? null
5497
5631
  };
@@ -5500,12 +5634,12 @@ function Ce(s) {
5500
5634
  return s?.type === "run_status" && s.status === "stopped";
5501
5635
  }
5502
5636
  function Cr(s, e) {
5503
- return $(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5637
+ return F(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5504
5638
  }
5505
- function is(s, e, t) {
5639
+ function rs(s, e, t) {
5506
5640
  const n = new Set(
5507
5641
  s.filter(
5508
- (i) => i.role === "user" && e !== null && X(i) === e
5642
+ (i) => i.role === "user" && e !== null && J(i) === e
5509
5643
  ).map((i) => i.id)
5510
5644
  );
5511
5645
  return s.filter(
@@ -5532,9 +5666,9 @@ function Pr(s, e, t) {
5532
5666
  return s[r].id === n.respondsToUserMessageId;
5533
5667
  return !1;
5534
5668
  }
5535
- function rs(s, e, t, n) {
5669
+ function os(s, e, t, n) {
5536
5670
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5537
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && os(l) && !vr(
5671
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !vr(
5538
5672
  s,
5539
5673
  l.respondsToUserMessageId
5540
5674
  )
@@ -5545,7 +5679,7 @@ function rs(s, e, t, n) {
5545
5679
  if (!i)
5546
5680
  return s;
5547
5681
  let r = !1;
5548
- const o = s.map((l) => l.respondsToUserMessageId !== i || !os(l) ? l : (r = !0, { ...l, steered: !0 }));
5682
+ const o = s.map((l) => l.respondsToUserMessageId !== i || !as(l) ? l : (r = !0, { ...l, steered: !0 }));
5549
5683
  if (r)
5550
5684
  return o;
5551
5685
  const a = s.find(
@@ -5578,12 +5712,12 @@ function _r(s, e) {
5578
5712
  return s[n].id;
5579
5713
  return null;
5580
5714
  }
5581
- function os(s) {
5715
+ function as(s) {
5582
5716
  return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5583
5717
  }
5584
5718
  function vr(s, e) {
5585
5719
  return s.some(
5586
- (t) => t.respondsToUserMessageId === e && ($(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5720
+ (t) => t.respondsToUserMessageId === e && (F(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5587
5721
  );
5588
5722
  }
5589
5723
  function Ur(s, e) {
@@ -5670,24 +5804,24 @@ function Nr(s, e) {
5670
5804
  }
5671
5805
  function Hr(s) {
5672
5806
  try {
5673
- const e = window.localStorage.getItem(`${ot}${s}`);
5807
+ const e = window.localStorage.getItem(`${at}${s}`);
5674
5808
  if (!e)
5675
5809
  return [];
5676
5810
  const t = JSON.parse(e);
5677
- return Array.isArray(t) ? t.filter(Mt) : [];
5811
+ return Array.isArray(t) ? t.filter(bt) : [];
5678
5812
  } catch {
5679
5813
  return [];
5680
5814
  }
5681
5815
  }
5682
5816
  function V(s, e) {
5683
5817
  try {
5684
- const t = e.filter(Mt);
5818
+ const t = e.filter(bt);
5685
5819
  if (t.length === 0) {
5686
- window.localStorage.removeItem(`${ot}${s}`);
5820
+ window.localStorage.removeItem(`${at}${s}`);
5687
5821
  return;
5688
5822
  }
5689
5823
  window.localStorage.setItem(
5690
- `${ot}${s}`,
5824
+ `${at}${s}`,
5691
5825
  JSON.stringify(t.slice(-25))
5692
5826
  );
5693
5827
  } catch {
@@ -5696,7 +5830,7 @@ function V(s, e) {
5696
5830
  }
5697
5831
  function Us(s, e) {
5698
5832
  try {
5699
- const t = `${Oe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5833
+ const t = `${xe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5700
5834
  ...o,
5701
5835
  storedAt: Date.now(),
5702
5836
  unloadUrl: n,
@@ -5710,9 +5844,9 @@ function Us(s, e) {
5710
5844
  } catch {
5711
5845
  }
5712
5846
  }
5713
- function as(s, e) {
5847
+ function ls(s, e) {
5714
5848
  try {
5715
- if (window.sessionStorage.getItem(`${Oe}${s}`) === null)
5849
+ if (window.sessionStorage.getItem(`${xe}${s}`) === null)
5716
5850
  return;
5717
5851
  } catch {
5718
5852
  return;
@@ -5721,11 +5855,11 @@ function as(s, e) {
5721
5855
  }
5722
5856
  function Br(s) {
5723
5857
  try {
5724
- const e = `${Oe}${s}`, t = window.sessionStorage.getItem(e);
5858
+ const e = `${xe}${s}`, t = window.sessionStorage.getItem(e);
5725
5859
  if (window.sessionStorage.removeItem(e), !t)
5726
5860
  return [];
5727
5861
  const n = JSON.parse(t);
5728
- return Array.isArray(n) ? n.flatMap((i) => $r(i) ? [{
5862
+ return Array.isArray(n) ? n.flatMap((i) => Fr(i) ? [{
5729
5863
  ...i.event,
5730
5864
  page: P(),
5731
5865
  rawOutput: {
@@ -5752,13 +5886,13 @@ function Wr(s) {
5752
5886
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
5753
5887
  Current URL: ${s}`;
5754
5888
  }
5755
- function $r(s) {
5889
+ function Fr(s) {
5756
5890
  if (!s || typeof s != "object")
5757
5891
  return !1;
5758
5892
  const e = s, t = e.event;
5759
- return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Mt(t) && t.type === "tool.result";
5893
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && bt(t) && t.type === "tool.result";
5760
5894
  }
5761
- function Fr(s, e) {
5895
+ function $r(s, e) {
5762
5896
  const t = new Set(
5763
5897
  s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
5764
5898
  );
@@ -5769,18 +5903,18 @@ function Fr(s, e) {
5769
5903
  }
5770
5904
  function jr(s) {
5771
5905
  try {
5772
- window.sessionStorage.removeItem(`${Oe}${s}`);
5906
+ window.sessionStorage.removeItem(`${xe}${s}`);
5773
5907
  } catch {
5774
5908
  return;
5775
5909
  }
5776
5910
  }
5777
- function Mt(s) {
5911
+ function bt(s) {
5778
5912
  if (!s || typeof s != "object")
5779
5913
  return !1;
5780
5914
  const e = s;
5781
- return e.type === "chat.user_message" ? typeof e.content == "string" && ls(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? ls(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
5915
+ return e.type === "chat.user_message" ? typeof e.content == "string" && cs(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? cs(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
5782
5916
  }
5783
- function ls(s) {
5917
+ function cs(s) {
5784
5918
  if (!s || typeof s != "object")
5785
5919
  return !1;
5786
5920
  const e = s;
@@ -5846,17 +5980,17 @@ function Qr(s) {
5846
5980
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
5847
5981
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
5848
5982
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
5849
- attachments: Ds(e.attachments)?.map(Ue),
5983
+ attachments: Ds(e.attachments)?.map(De),
5850
5984
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5851
5985
  };
5852
5986
  }
5853
5987
  function Vr(s) {
5854
5988
  return s.attachments?.length ? {
5855
5989
  ...s,
5856
- attachments: s.attachments.map(Ue)
5990
+ attachments: s.attachments.map(De)
5857
5991
  } : s;
5858
5992
  }
5859
- function Ue(s) {
5993
+ function De(s) {
5860
5994
  const {
5861
5995
  dataUrl: e,
5862
5996
  objectUrl: t,
@@ -5882,15 +6016,15 @@ function xs(s) {
5882
6016
  const e = {};
5883
6017
  try {
5884
6018
  new Headers(s).forEach((t, n) => {
5885
- Object.keys(e).length < Tt && (e[n] = bt(n, t));
6019
+ Object.keys(e).length < wt && (e[n] = Rt(n, t));
5886
6020
  });
5887
6021
  } catch {
5888
6022
  return {};
5889
6023
  }
5890
6024
  return e;
5891
6025
  }
5892
- function bt(s, e) {
5893
- return $s(s) ? Ne : W(qe(e), ri);
6026
+ function Rt(s, e) {
6027
+ return Fs(s) ? He : W(Oe(e), ri);
5894
6028
  }
5895
6029
  function Jr(s, e) {
5896
6030
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
@@ -5925,7 +6059,7 @@ async function Zr(s) {
5925
6059
  const { done: l, value: c } = a;
5926
6060
  if (l)
5927
6061
  return W(r + i.decode());
5928
- const u = St - o;
6062
+ const u = Tt - o;
5929
6063
  if (c.byteLength > u)
5930
6064
  return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${W(r)}... [truncated]`;
5931
6065
  o += c.byteLength, r += i.decode(c, { stream: !0 });
@@ -5945,34 +6079,34 @@ function eo(s, e) {
5945
6079
  return;
5946
6080
  }
5947
6081
  }
5948
- function cs(s) {
6082
+ function us(s) {
5949
6083
  if (typeof s == "string")
5950
6084
  return W(s);
5951
6085
  }
5952
6086
  function to(s) {
5953
6087
  return L({
5954
6088
  ...s,
5955
- requestBody: us(s.requestBody),
5956
- responseBody: us(s.responseBody)
6089
+ requestBody: ds(s.requestBody),
6090
+ responseBody: ds(s.responseBody)
5957
6091
  });
5958
6092
  }
5959
- function us(s) {
6093
+ function ds(s) {
5960
6094
  if (typeof s != "string")
5961
6095
  return s;
5962
6096
  const e = s.trim();
5963
6097
  if (!e.startsWith("{") && !e.startsWith("["))
5964
- return qe(s);
6098
+ return Oe(s);
5965
6099
  try {
5966
6100
  return JSON.stringify(L(JSON.parse(s)));
5967
6101
  } catch {
5968
- return qe(s);
6102
+ return Oe(s);
5969
6103
  }
5970
6104
  }
5971
6105
  function Ls(s) {
5972
6106
  if (!s)
5973
6107
  return !1;
5974
6108
  const e = s.get("content-type")?.toLowerCase() ?? "", t = s.get("content-length"), n = Number(t);
5975
- return t !== null && Number.isInteger(n) && n >= 0 && n <= St && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
6109
+ return t !== null && Number.isInteger(n) && n >= 0 && n <= Tt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
5976
6110
  }
5977
6111
  function te(s, e = {}, t) {
5978
6112
  if (no(t))
@@ -6009,17 +6143,17 @@ function io(s) {
6009
6143
  const n = t.indexOf(":");
6010
6144
  if (n <= 0)
6011
6145
  continue;
6012
- if (Object.keys(e).length >= Tt)
6146
+ if (Object.keys(e).length >= wt)
6013
6147
  break;
6014
6148
  const i = t.slice(0, n).trim();
6015
- e[i] = bt(i, t.slice(n + 1).trim());
6149
+ e[i] = Rt(i, t.slice(n + 1).trim());
6016
6150
  }
6017
6151
  return e;
6018
6152
  }
6019
- function W(s, e = St) {
6153
+ function W(s, e = Tt) {
6020
6154
  return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
6021
6155
  }
6022
- function st(s) {
6156
+ function nt(s) {
6023
6157
  return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
6024
6158
  }
6025
6159
  class Pe extends Error {
@@ -6030,11 +6164,11 @@ class Pe extends Error {
6030
6164
  }
6031
6165
  async function Me(s, e) {
6032
6166
  let t = null;
6033
- for (let n = 0; n < jt; n += 1)
6167
+ for (let n = 0; n < zt; n += 1)
6034
6168
  try {
6035
6169
  return await s();
6036
6170
  } catch (i) {
6037
- if (t = i, n >= jt - 1 || !oo(i))
6171
+ if (t = i, n >= zt - 1 || !oo(i))
6038
6172
  throw i;
6039
6173
  await ro(n);
6040
6174
  }
@@ -6054,13 +6188,13 @@ function ao(s) {
6054
6188
  function lo(s) {
6055
6189
  return s === 401 || s === 403;
6056
6190
  }
6057
- const Ne = "[REDACTED_SECRET]", F = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
6191
+ const He = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
6058
6192
  function L(s) {
6059
- return De(s, 0, /* @__PURE__ */ new WeakSet());
6193
+ return qe(s, 0, /* @__PURE__ */ new WeakSet());
6060
6194
  }
6061
- function De(s, e, t) {
6195
+ function qe(s, e, t) {
6062
6196
  if (typeof s == "string")
6063
- return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : qe(s);
6197
+ return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : Oe(s);
6064
6198
  if (s === null || typeof s != "object")
6065
6199
  return s;
6066
6200
  if (e >= uo)
@@ -6068,59 +6202,59 @@ function De(s, e, t) {
6068
6202
  if (t.has(s))
6069
6203
  return "[REDACTED_CIRCULAR]";
6070
6204
  if (t.add(s), Array.isArray(s))
6071
- return s.map((i) => De(i, e + 1, t));
6205
+ return s.map((i) => qe(i, e + 1, t));
6072
6206
  const n = {};
6073
6207
  for (const [i, r] of Object.entries(s))
6074
- i === "pageContent" ? n[i] = r : $s(i) ? n[i] = Ne : n[i] = i.toLowerCase() === "url" ? mo(r) : De(r, e + 1, t);
6208
+ i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
6075
6209
  return n;
6076
6210
  }
6077
- function $s(s) {
6211
+ function Fs(s) {
6078
6212
  const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
6079
6213
  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");
6080
6214
  }
6081
6215
  function mo(s) {
6082
- return typeof s == "string" ? Fs(s) : De(s, 0, /* @__PURE__ */ new WeakSet());
6216
+ return typeof s == "string" ? $s(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
6083
6217
  }
6084
- function Fs(s) {
6218
+ function $s(s) {
6085
6219
  try {
6086
6220
  const e = new URL(s, location.href);
6087
6221
  for (const t of Array.from(e.searchParams.keys()))
6088
- ho.test(t) && e.searchParams.set(t, F);
6089
- return e.username && (e.username = F), e.password && (e.password = F), e.toString();
6222
+ ho.test(t) && e.searchParams.set(t, $);
6223
+ return e.username && (e.username = $), e.password && (e.password = $), e.toString();
6090
6224
  } catch {
6091
6225
  return yo(s);
6092
6226
  }
6093
6227
  }
6094
- function qe(s) {
6095
- return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${Ne}`);
6228
+ function Oe(s) {
6229
+ return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6096
6230
  }
6097
6231
  function yo(s) {
6098
- return s.replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${Ne}`);
6232
+ return s.replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6099
6233
  }
6100
6234
  function Io(s) {
6101
6235
  const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6102
- return `${Fs(t)}${e}`;
6236
+ return `${$s(t)}${e}`;
6103
6237
  }
6104
6238
  const Eo = Object.freeze({
6105
- init: (s) => xe.init(s)
6239
+ init: (s) => Le.init(s)
6106
6240
  });
6107
6241
  function Co(s) {
6108
- return xe.init(s);
6242
+ return Le.init(s);
6109
6243
  }
6110
6244
  export {
6111
- Nt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6245
+ Ht as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6112
6246
  Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6113
6247
  Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6114
6248
  qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6115
6249
  ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6116
6250
  Eo as PlunoProductAgent,
6117
6251
  kn as ProductAgentInteractionManager,
6118
- Ot as ProductAgentQueryController,
6252
+ xt as ProductAgentQueryController,
6119
6253
  Ro as ProductAgentRemoteRuntimeClient,
6120
- xe as ProductAgentSessionEngine,
6254
+ Le as ProductAgentSessionEngine,
6121
6255
  Mn as ProductAgentSessionHistoryManager,
6122
6256
  Ao as ProductAgentTaskPageTitleController,
6123
- ee as ProductAgentTokenProviderError,
6257
+ X as ProductAgentTokenProviderError,
6124
6258
  di as calculateReconnectDelay,
6125
6259
  wo as createLocalStorageInteractionDecisionStorage,
6126
6260
  Re as createProductAgentQueryState,
@@ -6132,7 +6266,7 @@ export {
6132
6266
  bo as isProductAgentRuntimeCommand,
6133
6267
  Tn as mergeProductAgentEntityPages,
6134
6268
  ke as normalizeProductAgentEntityPage,
6135
- tt as normalizeProductAgentSessionItems,
6269
+ st as normalizeProductAgentSessionItems,
6136
6270
  En as readLocalStorageInteractionDecisions,
6137
6271
  To as resolveProductAgentComposerAction,
6138
6272
  So as resolveProductAgentWidgetPresentation,