@pluno/product-agent-web 0.1.202 → 0.1.203

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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,7 +1247,7 @@ 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";
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
1251
  class ee 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";
@@ -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, $n = 6e4, Fn = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, $t = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", Ft = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
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];
@@ -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;
@@ -1577,7 +1603,7 @@ class xe {
1577
1603
  static async init(e) {
1578
1604
  const t = e, n = await un(
1579
1605
  t.skipStoredTransportIdentityCollisionCheck === !0
1580
- ), i = new xe({
1606
+ ), i = new Le({
1581
1607
  ...e,
1582
1608
  backendUrl: Ui(e.backendUrl ?? Hn),
1583
1609
  clientId: e.clientId ?? Yi(),
@@ -1794,7 +1820,7 @@ class xe {
1794
1820
  0
1795
1821
  ) > Ts))
1796
1822
  throw new Error("Embedded attachments must total at most 50 MB per message");
1797
- let r = i.map(Ue);
1823
+ let r = i.map(De);
1798
1824
  if (!n && r.length === 0)
1799
1825
  return null;
1800
1826
  if (this.pendingClientMessageId)
@@ -1807,13 +1833,13 @@ class xe {
1807
1833
  phase: "final_answer",
1808
1834
  content: l,
1809
1835
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
1810
- } : null, h = {
1836
+ } : null, d = {
1811
1837
  id: `local-${a}`,
1812
1838
  role: "user",
1813
1839
  content: n,
1814
1840
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1815
1841
  ...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 : [
1842
+ }, g = this.state.messages.some((S) => S.id === d.id || S.clientMessageId === a), f = this.state.isThinking, h = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, m = this.state.messages, M = g ? this.state.messages : [
1817
1843
  ...this.state.messages.map(
1818
1844
  (S) => c && S.id === c.id ? {
1819
1845
  ...S,
@@ -1821,7 +1847,7 @@ class xe {
1821
1847
  } : S
1822
1848
  ),
1823
1849
  ...!c && u ? [u] : [],
1824
- h
1850
+ d
1825
1851
  ], w = {
1826
1852
  assistantDraft: this.state.assistantDraft,
1827
1853
  assistantDraftItemId: this.state.assistantDraftItemId,
@@ -1832,7 +1858,7 @@ class xe {
1832
1858
  };
1833
1859
  this.setState({
1834
1860
  messages: M,
1835
- ...g ? {} : {
1861
+ ...f ? {} : {
1836
1862
  assistantDraft: "",
1837
1863
  assistantDraftItemId: null,
1838
1864
  assistantDraftPhase: null,
@@ -1840,23 +1866,23 @@ class xe {
1840
1866
  assistantDraftRunId: null
1841
1867
  },
1842
1868
  pendingMessageStatus: "sending",
1843
- turnPhase: g ? y : "sending",
1844
- isThinking: g,
1869
+ turnPhase: f ? y : "sending",
1870
+ isThinking: f,
1845
1871
  taskStatus: "working",
1846
1872
  isRetrying: !1,
1847
1873
  lastError: null
1848
- }), m || (this.sessionHistoryManager.addOptimistic({
1849
- id: h.id,
1874
+ }), g || (this.sessionHistoryManager.addOptimistic({
1875
+ id: d.id,
1850
1876
  title: null,
1851
1877
  customTitle: null,
1852
- firstUserMessage: h.content,
1878
+ firstUserMessage: d.content,
1853
1879
  currentPage: o,
1854
- createdAt: h.createdAt,
1855
- updatedAt: h.createdAt,
1856
- lastActiveAt: h.createdAt,
1880
+ createdAt: d.createdAt,
1881
+ updatedAt: d.createdAt,
1882
+ lastActiveAt: d.createdAt,
1857
1883
  isActive: !0,
1858
1884
  isPinned: !1
1859
- }), u && !c && this.emit("message", u), this.emit("message", h));
1885
+ }), u && !c && this.emit("message", u), this.emit("message", d));
1860
1886
  try {
1861
1887
  const S = [];
1862
1888
  for (const T of r) {
@@ -1871,12 +1897,12 @@ class xe {
1871
1897
  }
1872
1898
  r = S;
1873
1899
  } catch (S) {
1874
- throw m || this.sessionHistoryManager.removeOptimistic(h.id), this.setState({
1875
- ...m ? {} : { messages: f },
1876
- ...g ? {} : { ...w, isThinking: !1 },
1900
+ throw g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1901
+ ...g ? {} : { messages: m },
1902
+ ...f ? {} : { ...w, isThinking: !1 },
1877
1903
  pendingMessageStatus: p,
1878
1904
  turnPhase: y,
1879
- taskStatus: d
1905
+ taskStatus: h
1880
1906
  }), S;
1881
1907
  }
1882
1908
  this.retryableClientMessageId = null;
@@ -1889,11 +1915,11 @@ class xe {
1889
1915
  entrySurface: this.options.entrySurface,
1890
1916
  content: n,
1891
1917
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1892
- pageContent: D && wt() || void 0,
1893
- attachments: r.length > 0 ? r.map(Ue) : void 0,
1918
+ pageContent: D && At() || void 0,
1919
+ attachments: r.length > 0 ? r.map(De) : void 0,
1894
1920
  page: o,
1895
1921
  model: this.options.model,
1896
- metadata: zt(this.options.metadata)
1922
+ metadata: Kt(this.options.metadata)
1897
1923
  };
1898
1924
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1899
1925
  }
@@ -1901,7 +1927,7 @@ class xe {
1901
1927
  return this.options.model;
1902
1928
  }
1903
1929
  setModel(e) {
1904
- this.options.model = e, this.options.productVariant === "personal" && Ge(e) && (this.personalModelSelectionOverride = e);
1930
+ this.options.model = e, this.options.productVariant === "personal" && Qe(e) && (this.personalModelSelectionOverride = e);
1905
1931
  }
1906
1932
  retryLastMessage() {
1907
1933
  const e = this.state.sessionId, t = this.retryableClientMessageId;
@@ -1967,7 +1993,7 @@ class xe {
1967
1993
  sizeBytes: e.size,
1968
1994
  page: P(),
1969
1995
  model: this.options.model,
1970
- metadata: zt(this.options.metadata),
1996
+ metadata: Kt(this.options.metadata),
1971
1997
  entrySurface: this.options.entrySurface
1972
1998
  };
1973
1999
  let o;
@@ -2075,8 +2101,8 @@ class xe {
2075
2101
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
2076
2102
  for (const [t, n] of this.activeBrowserToolCalls)
2077
2103
  n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
2078
- as(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
2079
- messages: is(
2104
+ ls(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
2105
+ messages: rs(
2080
2106
  this.state.messages,
2081
2107
  e.clientMessageId,
2082
2108
  e.runId
@@ -2120,7 +2146,7 @@ class xe {
2120
2146
  const t = x(), n = new Promise((r, o) => {
2121
2147
  const a = window.setTimeout(() => {
2122
2148
  this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
2123
- }, Ft);
2149
+ }, jt);
2124
2150
  this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
2125
2151
  }), i = {
2126
2152
  type: "sessions.list",
@@ -2493,8 +2519,8 @@ class xe {
2493
2519
  signal: AbortSignal.timeout(15e3)
2494
2520
  });
2495
2521
  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);
2522
+ const d = await c.text() || `History request failed (${c.status})`;
2523
+ throw Nn(c.status) ? new Error(d) : new Se(d);
2498
2524
  }
2499
2525
  const u = await c.json();
2500
2526
  if (!u?.session || !Array.isArray(u.items))
@@ -2549,7 +2575,7 @@ class xe {
2549
2575
  return !1;
2550
2576
  const t = this.socket;
2551
2577
  try {
2552
- return t.send(JSON.stringify(e)), Xe("client_event", e.type, Ht(e)), !0;
2578
+ return t.send(JSON.stringify(e)), Je("client_event", e.type, Bt(e)), !0;
2553
2579
  } catch (n) {
2554
2580
  return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2555
2581
  message: n instanceof Error ? n.message : String(n),
@@ -2743,7 +2769,7 @@ class xe {
2743
2769
  });
2744
2770
  }
2745
2771
  handleServerEvent(e) {
2746
- if (Xe("server_event", e.type, Ht(e)), e.type === "session.subscribed") {
2772
+ if (Je("server_event", e.type, Bt(e)), e.type === "session.subscribed") {
2747
2773
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2748
2774
  if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
2749
2775
  const i = this.pendingSessionSubscription;
@@ -2819,7 +2845,7 @@ class xe {
2819
2845
  rawAppearance: e.appearance,
2820
2846
  normalizedAppearance: n
2821
2847
  }), 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 = {
2848
+ const r = Vt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2823
2849
  user: t,
2824
2850
  status: "connected",
2825
2851
  ...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
@@ -2828,7 +2854,7 @@ class xe {
2828
2854
  type: "runtime.auth_ack",
2829
2855
  connectionAttempt: this.connectionAttemptId,
2830
2856
  entrySurface: this.options.entrySurface
2831
- }), o && r.length === 0 && !a && !Ze() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2857
+ }), o && r.length === 0 && !a && !et() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2832
2858
  type: "page.upsert",
2833
2859
  sessionId: this.state.sessionId,
2834
2860
  page: P(),
@@ -2838,21 +2864,21 @@ class xe {
2838
2864
  }
2839
2865
  if (e.type === "starterPrompts.updated") {
2840
2866
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
2841
- starterPrompts: Qt(e, "starterPrompts"),
2867
+ starterPrompts: Vt(e, "starterPrompts"),
2842
2868
  starterPromptsLoading: !1
2843
2869
  });
2844
2870
  return;
2845
2871
  }
2846
2872
  if (e.type === "scheduled_follow_ups.updated") {
2847
2873
  typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
2848
- activeScheduledFollowUps: Vt(
2874
+ activeScheduledFollowUps: Xt(
2849
2875
  e.activeScheduledFollowUps
2850
2876
  )
2851
2877
  });
2852
2878
  return;
2853
2879
  }
2854
2880
  if (e.type === "conversation.state") {
2855
- const t = Array.isArray(e.items) ? e.items : [], n = Dt(t), i = Object.prototype.hasOwnProperty.call(
2881
+ const t = Array.isArray(e.items) ? e.items : [], n = qt(t), i = Object.prototype.hasOwnProperty.call(
2856
2882
  e,
2857
2883
  "activeScheduledFollowUps"
2858
2884
  ), r = A(e.session, "id") ?? this.state.sessionId, o = typeof e.requestId == "string" ? e.requestId : null, a = this.state.isLoadingSession && this.sessionLoadRequestId === null && o === null && r === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
@@ -2863,51 +2889,51 @@ class xe {
2863
2889
  this.forgetSupersededTaskTabClosedTurn(r, C(U));
2864
2890
  for (const U of n)
2865
2891
  this.rememberDurablyStoppedTurn(r, U);
2866
- const l = ie(n), c = l === null ? null : n[l], u = C(c), h = this.findStoppedTurn(r, {
2892
+ const l = ie(n), c = l === null ? null : n[l], u = C(c), d = this.findStoppedTurn(r, {
2867
2893
  clientMessageId: u?.clientMessageId,
2868
2894
  respondsToUserMessageId: A(c, "id"),
2869
2895
  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(
2896
+ }), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
2897
+ f && h && (this.pendingClientMessageId = h);
2898
+ let m = ar(
2873
2899
  e.assistantDraft
2874
2900
  );
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) => {
2901
+ m && this.findStoppedTurn(r, {
2902
+ respondsToUserMessageId: m.respondsToUserMessageId,
2903
+ runId: m.runId
2904
+ }) && (m = void 0);
2905
+ const M = m !== void 0;
2906
+ this.rememberUserMessageClientMessageIds(g);
2907
+ const w = Tr(g), D = g.filter((U) => {
2882
2908
  const q = C(U);
2883
- return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(m, q) !== w;
2909
+ return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
2884
2910
  }), S = lt(
2885
2911
  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(
2912
+ st(D, this.options.backendUrl)
2913
+ ), T = ss(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, J = M ? m?.runId ?? null : this.state.assistantDraftRunId, Y = g.some(
2914
+ (U, q) => ns(
2889
2915
  C(U),
2890
2916
  N,
2891
2917
  v,
2892
2918
  re,
2893
2919
  J,
2894
- wr(m, q)
2920
+ wr(g, q)
2895
2921
  )
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))
2922
+ ), Z = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Y, B = T && (!Z || Y), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
2923
+ if (!T && Sr(this.state.messages, g))
2898
2924
  return;
2899
- this.lastUserMessagePageUrl = yr(m);
2900
- const j = B || h ? null : ut(m);
2925
+ this.lastUserMessagePageUrl = yr(g);
2926
+ const j = B || d ? null : ut(g);
2901
2927
  if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
2902
2928
  sessionId: A(e.session, "id") ?? this.state.sessionId,
2903
2929
  messages: S,
2904
2930
  ...i ? {
2905
- activeScheduledFollowUps: Vt(
2931
+ activeScheduledFollowUps: Xt(
2906
2932
  e.activeScheduledFollowUps
2907
2933
  )
2908
2934
  } : {},
2909
2935
  isLoadingSession: !1,
2910
- ...g ? { pendingMessageStatus: g } : {},
2936
+ ...f ? { pendingMessageStatus: f } : {},
2911
2937
  ...y ? { turnPhase: y } : {},
2912
2938
  isRetrying: p,
2913
2939
  ...y ? { taskStatus: "working" } : {},
@@ -2919,11 +2945,11 @@ class xe {
2919
2945
  assistantDraftRespondsToUserMessageId: null,
2920
2946
  assistantDraftRunId: null
2921
2947
  } : 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
2948
+ assistantDraft: m?.content ?? "",
2949
+ assistantDraftItemId: m?.itemId ?? null,
2950
+ assistantDraftPhase: m?.phase ?? null,
2951
+ assistantDraftRespondsToUserMessageId: m?.respondsToUserMessageId ?? null,
2952
+ assistantDraftRunId: m?.runId ?? null
2927
2953
  } : {},
2928
2954
  ...fe ? {
2929
2955
  isThinking: !0,
@@ -2947,10 +2973,10 @@ class xe {
2947
2973
  } : {}
2948
2974
  }), B)
2949
2975
  this.retryableClientMessageId = w, this.clearThinkingWatchdog();
2950
- else if (!h && (fe || j)) {
2976
+ else if (!d && (fe || j)) {
2951
2977
  if (j) {
2952
2978
  this.activeClientMessageId = j;
2953
- const U = ie(m), q = U === null ? null : m[U];
2979
+ const U = ie(g), q = U === null ? null : g[U];
2954
2980
  this.activeResponseUserMessageId = A(q, "id");
2955
2981
  }
2956
2982
  this.markThinkingProgress();
@@ -2964,7 +2990,7 @@ class xe {
2964
2990
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2965
2991
  if (!t || n !== this.state.sessionId)
2966
2992
  return;
2967
- const i = tt(
2993
+ const i = st(
2968
2994
  Array.isArray(e.items) ? e.items : [],
2969
2995
  this.options.backendUrl
2970
2996
  );
@@ -3009,11 +3035,11 @@ class xe {
3009
3035
  o && (this.retryableClientMessageId = o);
3010
3036
  return;
3011
3037
  }
3012
- const n = at(e.item, this.options.backendUrl);
3038
+ const n = ve(e.item, this.options.backendUrl);
3013
3039
  if (n) {
3014
3040
  const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3015
3041
  n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), $(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
3016
- const o = de(this.state.messages, n), a = ts(o), l = ss(
3042
+ const o = de(this.state.messages, n), a = ss(o), l = ns(
3017
3043
  t,
3018
3044
  this.state.assistantDraft,
3019
3045
  this.state.assistantDraftItemId,
@@ -3021,9 +3047,9 @@ class xe {
3021
3047
  this.state.assistantDraftRunId,
3022
3048
  _s(
3023
3049
  o,
3024
- o.findIndex((h) => h.id === n.id)
3050
+ o.findIndex((d) => d.id === n.id)
3025
3051
  )
3026
- ), c = a && (!this.state.assistantDraft || l), u = ve(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
3052
+ ), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c || $(n) && !this.state.isThinking && this.activeClientMessageId === null);
3027
3053
  this.setState({
3028
3054
  messages: o,
3029
3055
  ...l ? {
@@ -3050,7 +3076,7 @@ class xe {
3050
3076
  }
3051
3077
  if (e.type === "chat.assistant_delta") {
3052
3078
  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;
3079
+ const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((d) => d.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
3054
3080
  this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = u), this.setState({
3055
3081
  messages: de(this.state.messages, {
3056
3082
  id: o,
@@ -3081,7 +3107,7 @@ class xe {
3081
3107
  const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, i = typeof e.runId == "string" ? e.runId : null;
3082
3108
  if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
3083
3109
  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(
3110
+ const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = Dt(
3085
3111
  this.state.messages.filter(
3086
3112
  (c) => c.dataType !== "assistant_draft" || !Ae(
3087
3113
  c,
@@ -3095,7 +3121,7 @@ class xe {
3095
3121
  );
3096
3122
  this.setState({
3097
3123
  sessionId: t,
3098
- messages: Jt(
3124
+ messages: Yt(
3099
3125
  l,
3100
3126
  typeof e.responseId == "string" ? e.responseId : null,
3101
3127
  n,
@@ -3118,9 +3144,9 @@ class xe {
3118
3144
  if (t)
3119
3145
  this.nonTranscriptToolCallIds.add(t);
3120
3146
  else {
3121
- const n = es(e);
3147
+ const n = ts(e);
3122
3148
  if (n) {
3123
- const i = Yt(
3149
+ const i = Zt(
3124
3150
  this.state.messages,
3125
3151
  n
3126
3152
  );
@@ -3153,8 +3179,8 @@ class xe {
3153
3179
  if (e.type === "error") {
3154
3180
  if (e.code === "unauthorized" && e.reason === "token_expired" && e.retryable === !0 && this.options.tokenProvider) {
3155
3181
  this.invalidateProviderToken(), this.clearSocketPhaseTimers(), this.stopHeartbeat();
3156
- const g = this.socket;
3157
- this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), g?.close();
3182
+ const f = this.socket;
3183
+ this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), f?.close();
3158
3184
  return;
3159
3185
  }
3160
3186
  const t = typeof e.requestId == "string" ? e.requestId : null;
@@ -3190,18 +3216,18 @@ class xe {
3190
3216
  o && i && r && (this.retryableClientMessageId = r);
3191
3217
  const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
3192
3218
  l && console.error(l);
3193
- const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, h = is(
3219
+ const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = rs(
3194
3220
  this.state.messages,
3195
3221
  c,
3196
3222
  u
3197
- ), m = fr(
3198
- h,
3223
+ ), g = fr(
3224
+ d,
3199
3225
  c,
3200
3226
  u
3201
3227
  );
3202
3228
  if (this.setState({
3203
- status: m ? "connected" : "error",
3204
- messages: h,
3229
+ status: g ? "connected" : "error",
3230
+ messages: d,
3205
3231
  assistantDraft: "",
3206
3232
  assistantDraftItemId: null,
3207
3233
  assistantDraftPhase: null,
@@ -3210,13 +3236,13 @@ class xe {
3210
3236
  isThinking: !1,
3211
3237
  ...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
3212
3238
  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
3239
+ lastError: g ? null : a.message,
3240
+ lastErrorCode: g ? null : typeof e.code == "string" ? e.code : null,
3241
+ lastErrorSecuritySettingsUrl: g ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
3216
3242
  }), this.clearThinkingWatchdog(), this.emit("error", a), e.code === "unauthorized") {
3217
3243
  this.clearSocketPhaseTimers(), this.stopHeartbeat();
3218
- const g = this.socket;
3219
- this.socket = null, g?.close();
3244
+ const f = this.socket;
3245
+ this.socket = null, f?.close();
3220
3246
  }
3221
3247
  }
3222
3248
  }
@@ -3238,7 +3264,7 @@ class xe {
3238
3264
  if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
3239
3265
  return;
3240
3266
  const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
3241
- this.options.model = Ge(n) ? n : "gpt-5.6-sol";
3267
+ this.options.model = Qe(n) ? n : "gpt-5.6-sol";
3242
3268
  }
3243
3269
  updateAccountFallbackFromSession(e) {
3244
3270
  const t = e && typeof e == "object" ? e.metadata : null, n = An(t);
@@ -3261,9 +3287,9 @@ class xe {
3261
3287
  return;
3262
3288
  const n = this.sessionTimelineCache.get(t);
3263
3289
  if (e.type === "conversation.state") {
3264
- const i = Dt(
3290
+ const i = qt(
3265
3291
  Array.isArray(e.items) ? e.items : []
3266
- ), r = tt(
3292
+ ), r = st(
3267
3293
  this.filterStoppedSnapshotItems(i, t),
3268
3294
  this.options.backendUrl
3269
3295
  );
@@ -3278,15 +3304,15 @@ class xe {
3278
3304
  const i = C(e.item);
3279
3305
  if (pe(i))
3280
3306
  return;
3281
- const r = at(e.item, this.options.backendUrl);
3307
+ const r = ve(e.item, this.options.backendUrl);
3282
3308
  r && this.rememberSessionTimeline(t, de(n, r));
3283
3309
  return;
3284
3310
  }
3285
3311
  if (e.type === "tool.call") {
3286
- const i = e.hiddenFromTranscript === !0 ? null : es(e);
3312
+ const i = e.hiddenFromTranscript === !0 ? null : ts(e);
3287
3313
  i && this.rememberSessionTimeline(
3288
3314
  t,
3289
- Yt(n, i)
3315
+ Zt(n, i)
3290
3316
  );
3291
3317
  return;
3292
3318
  }
@@ -3298,7 +3324,7 @@ class xe {
3298
3324
  return;
3299
3325
  this.rememberSessionTimeline(
3300
3326
  t,
3301
- Zt(
3327
+ es(
3302
3328
  n,
3303
3329
  e.callId,
3304
3330
  i
@@ -3325,7 +3351,7 @@ class xe {
3325
3351
  return;
3326
3352
  }
3327
3353
  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(
3354
+ const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Dt(
3329
3355
  n.filter(
3330
3356
  (a) => a.dataType !== "assistant_draft" || !Ae(a, i, r)
3331
3357
  ),
@@ -3335,7 +3361,7 @@ class xe {
3335
3361
  );
3336
3362
  this.rememberSessionTimeline(
3337
3363
  t,
3338
- Jt(
3364
+ Yt(
3339
3365
  o,
3340
3366
  typeof e.responseId == "string" ? e.responseId : null,
3341
3367
  i,
@@ -3350,7 +3376,7 @@ class xe {
3350
3376
  return;
3351
3377
  this.rememberSessionTimeline(
3352
3378
  t,
3353
- rs(
3379
+ os(
3354
3380
  n,
3355
3381
  i,
3356
3382
  null,
@@ -3359,7 +3385,7 @@ class xe {
3359
3385
  );
3360
3386
  return;
3361
3387
  }
3362
- e.type === "error" && typeof e.requestId != "string" && !ns(e, t) && this.rememberSessionTimeline(
3388
+ e.type === "error" && typeof e.requestId != "string" && !is(e, t) && this.rememberSessionTimeline(
3363
3389
  t,
3364
3390
  kr(n, e)
3365
3391
  );
@@ -3395,9 +3421,9 @@ class xe {
3395
3421
  }
3396
3422
  handleRetryableRecoveryError(e) {
3397
3423
  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)
3424
+ if (!is(e, t) || !n)
3399
3425
  return !1;
3400
- if (Ze())
3426
+ if (et())
3401
3427
  return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
3402
3428
  if (this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
3403
3429
  const i = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
@@ -3436,7 +3462,7 @@ class xe {
3436
3462
  const i = new Promise((r, o) => {
3437
3463
  const a = window.setTimeout(() => {
3438
3464
  e.delete(t.requestId), o(new Error(n));
3439
- }, Ft);
3465
+ }, jt);
3440
3466
  e.set(t.requestId, { resolve: r, reject: o, timeout: a });
3441
3467
  });
3442
3468
  if (!this.sendNow(t)) {
@@ -3515,9 +3541,9 @@ class xe {
3515
3541
  return this.pendingClientMessageId === e && this.state.isThinking && this.activeClientMessageId !== null && this.activeClientMessageId !== e;
3516
3542
  }
3517
3543
  schedulePendingDeliveryAck(e) {
3518
- this.clearPendingDeliveryTimers(), !Ze() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3544
+ this.clearPendingDeliveryTimers(), !et() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
3519
3545
  this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
3520
- }, $t));
3546
+ }, Ft));
3521
3547
  }
3522
3548
  retryPendingDelivery(e) {
3523
3549
  if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
@@ -3553,7 +3579,7 @@ class xe {
3553
3579
  if (this.state.isThinking && t) {
3554
3580
  const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
3555
3581
  this.setState({
3556
- messages: rs(
3582
+ messages: os(
3557
3583
  this.state.messages,
3558
3584
  t,
3559
3585
  n,
@@ -3579,13 +3605,13 @@ class xe {
3579
3605
  scheduleRunAckWatchdog(e) {
3580
3606
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
3581
3607
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
3582
- }, $t);
3608
+ }, Ft);
3583
3609
  }
3584
3610
  recoverMissedRunAck(e) {
3585
3611
  !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
3586
3612
  sessionId: this.state.sessionId,
3587
3613
  clientMessageId: e
3588
- }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Wt));
3614
+ }), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog($t));
3589
3615
  }
3590
3616
  clearRunAckResyncRetryTimer() {
3591
3617
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -3618,7 +3644,7 @@ class xe {
3618
3644
  sessionId: this.state.sessionId,
3619
3645
  clientMessageId: e,
3620
3646
  resyncAttempts: t + 1
3621
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Wt);
3647
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog($t);
3622
3648
  }
3623
3649
  resyncThinkingSession() {
3624
3650
  this.state.sessionId ? this.send({
@@ -3682,13 +3708,13 @@ class xe {
3682
3708
  startedAtOrigin: location.origin
3683
3709
  }), this.installSessionBrowserApis();
3684
3710
  let c = null, u;
3685
- c = await this.executeRuntimeHelper(), u = await Kt(
3711
+ c = await this.executeRuntimeHelper(), u = await Gt(
3686
3712
  o,
3687
3713
  _i(e.runtimeContext, this.options.backendUrl)
3688
- ).catch((h) => ({
3714
+ ).catch((d) => ({
3689
3715
  ok: !1,
3690
3716
  exception: {
3691
- message: h instanceof Error ? h.message : String(h)
3717
+ message: d instanceof Error ? d.message : String(d)
3692
3718
  }
3693
3719
  })), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
3694
3720
  type: "tool.result",
@@ -3698,10 +3724,10 @@ class xe {
3698
3724
  summary: o.summary,
3699
3725
  rawInput: L(o),
3700
3726
  rawOutput: L(Xi(u, c))
3701
- }), as(this.options.clientId, this.activeBrowserToolCalls.values()));
3727
+ }), ls(this.options.clientId, this.activeBrowserToolCalls.values()));
3702
3728
  }
3703
3729
  setToolMessageLoading(e, t) {
3704
- const n = Zt(
3730
+ const n = es(
3705
3731
  this.state.messages,
3706
3732
  e,
3707
3733
  t
@@ -3727,7 +3753,7 @@ class xe {
3727
3753
  async executeRuntimeHelper() {
3728
3754
  if (!this.runtimeHelperJavascript?.trim())
3729
3755
  return null;
3730
- const e = await Kt({
3756
+ const e = await Gt({
3731
3757
  javascript: this.runtimeHelperJavascript
3732
3758
  });
3733
3759
  return e.ok === !1 ? Ji(e) : null;
@@ -3753,7 +3779,7 @@ class xe {
3753
3779
  if (this.reconnectTimer !== null || this.state.status === "closed")
3754
3780
  return;
3755
3781
  const t = Math.min(
3756
- rt,
3782
+ ot,
3757
3783
  Math.max(di(this.reconnectAttempts), e)
3758
3784
  );
3759
3785
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
@@ -3810,7 +3836,7 @@ class xe {
3810
3836
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3811
3837
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3812
3838
  }, 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, {
3839
+ this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
3814
3840
  status: this.state.status,
3815
3841
  sessionId: this.state.sessionId,
3816
3842
  messageCount: this.state.messages.length,
@@ -3868,7 +3894,7 @@ class xe {
3868
3894
  this.listeners[e]?.forEach((i) => i(t));
3869
3895
  }
3870
3896
  }
3871
- const Ye = /* @__PURE__ */ new WeakMap();
3897
+ const Ze = /* @__PURE__ */ new WeakMap();
3872
3898
  function fi(s) {
3873
3899
  const e = window.__plunoProductAgentNetworkCapture ?? mi();
3874
3900
  return e.subscribers.add(s), () => {
@@ -3876,30 +3902,30 @@ function fi(s) {
3876
3902
  };
3877
3903
  }
3878
3904
  function mi() {
3879
- const s = /* @__PURE__ */ new Set(), e = (m) => {
3880
- s.forEach((g) => {
3905
+ const s = /* @__PURE__ */ new Set(), e = (g) => {
3906
+ s.forEach((f) => {
3881
3907
  try {
3882
- g(m);
3908
+ f(g);
3883
3909
  } catch {
3884
3910
  }
3885
3911
  });
3886
- }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(g, d) {
3912
+ }, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(f, h) {
3887
3913
  const p = Date.now();
3888
3914
  let y;
3889
3915
  try {
3890
- y = t.call(this, g, d);
3891
- } catch (f) {
3892
- throw f;
3916
+ y = t.call(this, f, h);
3917
+ } catch (m) {
3918
+ throw m;
3893
3919
  }
3894
3920
  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)) {
3921
+ const m = f instanceof Request ? f : null, M = Jr(f, m), w = xs(h?.headers ?? m?.headers);
3922
+ if (!te(M, w, h?.body)) {
3897
3923
  const H = {
3898
- requestId: st("fetch"),
3899
- url: W(M, Je),
3900
- method: (d?.method ?? f?.method ?? "GET").toUpperCase(),
3924
+ requestId: nt("fetch"),
3925
+ url: W(M, Ye),
3926
+ method: (h?.method ?? m?.method ?? "GET").toUpperCase(),
3901
3927
  requestHeaders: w,
3902
- requestBody: cs(d?.body),
3928
+ requestBody: us(h?.body),
3903
3929
  resourceType: "fetch",
3904
3930
  startedAt: new Date(p).toISOString()
3905
3931
  };
@@ -3925,42 +3951,42 @@ function mi() {
3925
3951
  } catch {
3926
3952
  }
3927
3953
  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),
3954
+ }, a = function(f, h, p, y, m) {
3955
+ const M = n.call(this, f, h, p ?? !0, y ?? void 0, m ?? void 0), w = typeof h == "string" ? h : h.toString();
3956
+ return Ze.set(this, {
3957
+ requestId: nt("xhr"),
3958
+ method: String(f ?? "GET").toUpperCase(),
3959
+ url: W(w, Ye),
3934
3960
  requestHeaders: {},
3935
3961
  startedAtMs: Date.now(),
3936
3962
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
3937
3963
  excluded: te(w)
3938
3964
  }), 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) {
3965
+ }, l = function(f, h) {
3966
+ const p = i.call(this, f, h), y = Ze.get(this);
3967
+ return y && Object.keys(y.requestHeaders).length < wt && (y.requestHeaders[f] = Rt(f, h), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
3968
+ }, c = function(f) {
3943
3969
  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(
3970
+ const h = Ze.get(this);
3971
+ h && (h.excluded = h.excluded || te(h.url, h.requestHeaders, f), h.requestBody = us(f), h.excluded || this.addEventListener(
3946
3972
  "loadend",
3947
3973
  () => {
3948
3974
  queueMicrotask(() => {
3949
3975
  try {
3950
3976
  const p = io(this.getAllResponseHeaders());
3951
3977
  e({
3952
- requestId: d.requestId,
3953
- url: d.url,
3954
- method: d.method,
3955
- requestHeaders: d.requestHeaders,
3956
- requestBody: d.requestBody,
3978
+ requestId: h.requestId,
3979
+ url: h.url,
3980
+ method: h.method,
3981
+ requestHeaders: h.requestHeaders,
3982
+ requestBody: h.requestBody,
3957
3983
  resourceType: "xhr",
3958
3984
  responseStatus: this.status,
3959
3985
  responseHeaders: p,
3960
3986
  responseBody: eo(this, p),
3961
3987
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
3962
- startedAt: d.startedAt,
3963
- durationMs: Date.now() - d.startedAtMs
3988
+ startedAt: h.startedAt,
3989
+ durationMs: Date.now() - h.startedAtMs
3964
3990
  });
3965
3991
  } catch {
3966
3992
  return;
@@ -3971,7 +3997,7 @@ function mi() {
3971
3997
  ));
3972
3998
  } catch {
3973
3999
  }
3974
- return r.call(this, g ?? null);
4000
+ return r.call(this, f ?? null);
3975
4001
  };
3976
4002
  try {
3977
4003
  window.fetch = o;
@@ -3991,20 +4017,20 @@ function mi() {
3991
4017
  }
3992
4018
  let u = null;
3993
4019
  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))
4020
+ u = new PerformanceObserver((g) => {
4021
+ for (const f of g.getEntries()) {
4022
+ const h = f;
4023
+ if (h.initiatorType === "fetch" || h.initiatorType === "xmlhttprequest" || te(h.name))
3998
4024
  continue;
3999
- const p = performance.timeOrigin + d.startTime;
4025
+ const p = performance.timeOrigin + h.startTime;
4000
4026
  e({
4001
- requestId: st("resource"),
4002
- url: W(d.name, Je),
4027
+ requestId: nt("resource"),
4028
+ url: W(h.name, Ye),
4003
4029
  method: "GET",
4004
4030
  resourceType: "resource",
4005
- responseStatus: d.responseStatus,
4031
+ responseStatus: h.responseStatus,
4006
4032
  startedAt: new Date(p).toISOString(),
4007
- durationMs: d.duration
4033
+ durationMs: h.duration
4008
4034
  });
4009
4035
  }
4010
4036
  });
@@ -4014,7 +4040,7 @@ function mi() {
4014
4040
  u.disconnect(), u = null;
4015
4041
  }
4016
4042
  }
4017
- const h = {
4043
+ const d = {
4018
4044
  subscribers: s,
4019
4045
  destroy: () => {
4020
4046
  u?.disconnect();
@@ -4036,7 +4062,7 @@ function mi() {
4036
4062
  }
4037
4063
  }
4038
4064
  };
4039
- return window.__plunoProductAgentNetworkCapture = h, h;
4065
+ return window.__plunoProductAgentNetworkCapture = d, d;
4040
4066
  }
4041
4067
  function b(s, e, t) {
4042
4068
  if (typeof window > "u")
@@ -4049,7 +4075,7 @@ function b(s, e, t) {
4049
4075
  }, r = n.__plunoProductAgentDiagnostics__ ?? [];
4050
4076
  r.push(i), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: i }));
4051
4077
  }
4052
- function zt(s) {
4078
+ function Kt(s) {
4053
4079
  const e = typeof s == "function" ? s() : s;
4054
4080
  return e && Object.keys(e).length > 0 ? e : void 0;
4055
4081
  }
@@ -4086,10 +4112,10 @@ function Ti() {
4086
4112
  };
4087
4113
  }
4088
4114
  function wi() {
4089
- return ds(globalThis, "getPageSnapshot", async () => wt());
4115
+ return hs(globalThis, "getPageSnapshot", async () => At());
4090
4116
  }
4091
4117
  function Ai() {
4092
- return ds(globalThis, "pageImages", {
4118
+ return hs(globalThis, "pageImages", {
4093
4119
  inspectImage: async (e, t) => await Mi(e, t)
4094
4120
  });
4095
4121
  }
@@ -4166,7 +4192,7 @@ function Pi(s) {
4166
4192
  }, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
4167
4193
  });
4168
4194
  }
4169
- async function Kt(s, e) {
4195
+ async function Gt(s, e) {
4170
4196
  const t = Object.getPrototypeOf(async function() {
4171
4197
  }).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
4172
4198
  let o;
@@ -4182,8 +4208,8 @@ async function Kt(s, e) {
4182
4208
  try {
4183
4209
  const c = /* @__PURE__ */ Symbol("execute_code_timeout"), u = await Promise.race([
4184
4210
  new t("sandboxFiles", s.javascript)(e?.value),
4185
- new Promise((h) => {
4186
- o = window.setTimeout(() => h(c), n);
4211
+ new Promise((d) => {
4212
+ o = window.setTimeout(() => d(c), n);
4187
4213
  })
4188
4214
  ]);
4189
4215
  return u === c ? vi(n) : {
@@ -4248,8 +4274,8 @@ function _i(s, e) {
4248
4274
  );
4249
4275
  if (!l.ok)
4250
4276
  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", {
4277
+ const c = await l.blob(), d = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
4278
+ return new File([c], d || a.split("/").pop() || "file", {
4253
4279
  type: c.type
4254
4280
  });
4255
4281
  }
@@ -4311,7 +4337,7 @@ function Li() {
4311
4337
  return {
4312
4338
  pageUrl: location.href,
4313
4339
  pageTitle: document.title,
4314
- htmlContent: wt()
4340
+ htmlContent: At()
4315
4341
  };
4316
4342
  }
4317
4343
  function Ni(s) {
@@ -4334,24 +4360,24 @@ function Hi() {
4334
4360
  window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === i && (window.history.replaceState = t), window.removeEventListener("popstate", s), window.removeEventListener("hashchange", s);
4335
4361
  };
4336
4362
  }
4337
- function Ze() {
4363
+ function et() {
4338
4364
  return ks()?.surface === "browser_extension_sdk_preview";
4339
4365
  }
4340
- function wt() {
4366
+ function At() {
4341
4367
  if (!document.body)
4342
4368
  return "";
4343
4369
  const s = [], e = [], t = (p, y) => {
4344
- const f = ne(y);
4345
- !f || e.includes(f) || (s.push([p, f]), e.push(f));
4370
+ const m = ne(y);
4371
+ !m || e.includes(m) || (s.push([p, m]), e.push(m));
4346
4372
  };
4347
4373
  t("Selected text", window.getSelection()?.toString() ?? "");
4348
4374
  const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
4349
4375
  (p) => Ms(p) && !p.parentElement?.closest(n)
4350
4376
  );
4351
4377
  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));
4378
+ t("Active overlay", tt(he(p), e));
4379
+ const r = Bi(), o = r ? tt(he(r), e) : "";
4380
+ t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
4355
4381
  const a = s.map(([p, y]) => `${p}:
4356
4382
  ${y}`).join(`
4357
4383
 
@@ -4359,8 +4385,8 @@ ${y}`).join(`
4359
4385
  `, u = `
4360
4386
 
4361
4387
  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}`;
4388
+ `, d = 12e3 - c.length - u.length, g = Math.min(a.length, 7900), f = l.slice(0, d - g), h = a.slice(0, d - f.length);
4389
+ return `${c}${f}${u}${h}`;
4364
4390
  }
4365
4391
  function he(s) {
4366
4392
  return s.innerText ?? s.textContent ?? "";
@@ -4373,7 +4399,7 @@ function ne(s) {
4373
4399
 
4374
4400
  `).trim();
4375
4401
  }
4376
- function et(s, e) {
4402
+ function tt(s, e) {
4377
4403
  let t = ne(s);
4378
4404
  for (const n of e)
4379
4405
  t = t.replace(n, "");
@@ -4466,22 +4492,22 @@ function Wi(s, e) {
4466
4492
  "data-test",
4467
4493
  "data-qa",
4468
4494
  "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) => {
4495
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = $i(), g = new Set(s);
4496
+ e && g.add(e);
4497
+ let f = 0;
4498
+ const h = (w) => {
4473
4499
  const D = w.getAttribute("role");
4474
4500
  return D && !o.has(D) ? D : "";
4475
4501
  }, p = (w) => {
4476
4502
  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}`;
4503
+ return `${w.tagName.toLowerCase()}|${h(w)}|${D}`;
4478
4504
  }, y = (w, D, H) => {
4479
4505
  const S = (T, N) => {
4480
4506
  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")
4507
+ if (f >= 1e3 && !J || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || re.display === "none" || re.visibility === "hidden")
4482
4508
  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();
4509
+ f += 1;
4510
+ const Y = h(T), Z = Rs(T), fe = a.has(Y) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(v) || v === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), Q = /* @__PURE__ */ new Map();
4485
4511
  for (const I of B) {
4486
4512
  const R = p(I);
4487
4513
  Q.set(R, (Q.get(R) ?? 0) + 1);
@@ -4491,59 +4517,59 @@ function Wi(s, e) {
4491
4517
  const R = p(I), z = oe.get(R) ?? 0;
4492
4518
  oe.set(R, z + 1), (Q.get(R) ?? 0) > 8 && z >= 6 && !u.has(I) && me.set(R, (me.get(R) ?? 0) + 1);
4493
4519
  }
4494
- const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Rt = [];
4520
+ const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], kt = [];
4495
4521
  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)) {
4522
+ const R = p(I), z = Q.get(R) ?? 0, Pt = j.get(R) ?? 0;
4523
+ if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
4498
4524
  U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
4499
4525
  continue;
4500
4526
  }
4501
- const Pt = S(I, N);
4502
- Rt.push(Pt), q.push(Pt.lines);
4527
+ const _t = S(I, N);
4528
+ kt.push(_t), q.push(_t.lines);
4503
4529
  }
4504
- const He = [];
4530
+ const Be = [];
4505
4531
  if (T.shadowRoot)
4506
4532
  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(
4533
+ I instanceof HTMLElement && Be.push(S(I, N + 1));
4534
+ const ye = [...kt, ...Be], We = Z.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
4509
4535
  [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;
4536
+ ).slice(0, 180), js = T.hasAttribute("contenteditable") && (Z.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Y || js, $e = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || J) && (We || J) && (!i.has(v) || We || Ct || J), Fe = $e ? 1 : 0, ae = [];
4537
+ if ($e) {
4538
+ const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et : Z;
4513
4539
  ae.push(bs(T, l, o, R.slice(0, 180)));
4514
4540
  }
4515
4541
  for (const I of q)
4516
- ae.push(...we(I, $e));
4517
- const Fe = He.flatMap((I) => I.lines);
4518
- if (Fe.length > 0) {
4519
- const I = Fe.slice(0, 20);
4520
- Fe.length > I.length && I.push("… shadow DOM omitted");
4542
+ ae.push(...we(I, Fe));
4543
+ const je = Be.flatMap((I) => I.lines);
4544
+ if (je.length > 0) {
4545
+ const I = je.slice(0, 20);
4546
+ je.length > I.length && I.push("… shadow DOM omitted");
4521
4547
  const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
4522
4548
  if (N < 2 && !R) {
4523
- const z = We ? "#shadow-root" : `${v} #shadow-root`;
4524
- ae.push(...we([z, ...we(I, 1)], $e));
4549
+ const z = $e ? "#shadow-root" : `${v} #shadow-root`;
4550
+ ae.push(...we([z, ...we(I, 1)], Fe));
4525
4551
  } else
4526
- ae.push(...we(I, $e));
4552
+ ae.push(...we(I, Fe));
4527
4553
  }
4528
4554
  return {
4529
4555
  lines: ae,
4530
- hasUsefulContent: Be,
4531
- textPreview: kt,
4556
+ hasUsefulContent: We,
4557
+ textPreview: Et,
4532
4558
  containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
4533
4559
  };
4534
4560
  };
4535
4561
  return [`--- ${D} ---`, ...S(w, 0).lines].join(`
4536
4562
  `);
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));
4563
+ }, m = [], M = ne(window.getSelection()?.toString() ?? "");
4564
+ M && m.push(`--- selected text ---
4565
+ ${JSON.stringify(M)}`), d.length > 0 && m.push(Fi(d, t, l, o));
4540
4566
  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) {
4567
+ m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4568
+ if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
4543
4569
  const w = e || s.length ? "other visible DOM" : "visible DOM";
4544
- f.push(y(document.body, w, m));
4570
+ m.push(y(document.body, w, g));
4545
4571
  }
4546
- return f.join(`
4572
+ return m.join(`
4547
4573
 
4548
4574
  `);
4549
4575
  }
@@ -4573,11 +4599,11 @@ function $i() {
4573
4599
  return;
4574
4600
  const u = e.get(a) ?? /* @__PURE__ */ new Set();
4575
4601
  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);
4602
+ let d = a;
4603
+ for (; d; ) {
4604
+ s.add(d);
4605
+ const g = d.getRootNode();
4606
+ d = d.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
4581
4607
  }
4582
4608
  };
4583
4609
  let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
@@ -4585,7 +4611,7 @@ function $i() {
4585
4611
  n = n.shadowRoot.activeElement;
4586
4612
  n !== document.body && n !== document.documentElement && t(n, "focused");
4587
4613
  const i = window.getSelection();
4588
- i && !i.isCollapsed && (t(Gt(i.anchorNode), "selected text"), t(Gt(i.focusNode), "selected text"));
4614
+ i && !i.isCollapsed && (t(Qt(i.anchorNode), "selected text"), t(Qt(i.focusNode), "selected text"));
4589
4615
  const r = [
4590
4616
  ["[aria-selected='true']", "selected"],
4591
4617
  ["[aria-current]:not([aria-current='false'])", "current"],
@@ -4597,8 +4623,8 @@ function $i() {
4597
4623
  for (let a = 0; a < o.length; a += 1) {
4598
4624
  const l = o[a];
4599
4625
  for (const [c, u] of r)
4600
- for (const h of Array.from(l.querySelectorAll(c)))
4601
- t(h, u);
4626
+ for (const d of Array.from(l.querySelectorAll(c)))
4627
+ t(d, u);
4602
4628
  for (const c of Array.from(l.querySelectorAll("*")))
4603
4629
  c.shadowRoot && o.push(c.shadowRoot);
4604
4630
  }
@@ -4615,21 +4641,21 @@ function Fi(s, e, t, n) {
4615
4641
  for (; a; ) {
4616
4642
  const u = a.tagName.toLowerCase();
4617
4643
  (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);
4644
+ const d = a.getRootNode();
4645
+ a = a.parentElement ?? (d instanceof ShadowRoot && d.host instanceof HTMLElement ? d.host : null);
4620
4646
  }
4621
- const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, h) => bs(
4647
+ const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, d) => bs(
4622
4648
  u,
4623
4649
  t,
4624
4650
  n,
4625
- h === l.length - 1 ? Rs(u).slice(0, 180) : ""
4651
+ d === l.length - 1 ? Rs(u).slice(0, 180) : ""
4626
4652
  ));
4627
4653
  o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
4628
4654
  }
4629
4655
  return i.join(`
4630
4656
  `);
4631
4657
  }
4632
- function Gt(s) {
4658
+ function Qt(s) {
4633
4659
  return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
4634
4660
  }
4635
4661
  function we(s, e) {
@@ -4647,7 +4673,7 @@ function ji(s) {
4647
4673
  return s.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(s) && !/[a-f0-9]{12,}/i.test(s) && !/:r[0-9a-z]+:/i.test(s);
4648
4674
  }
4649
4675
  function ks() {
4650
- const s = Array.from(document.querySelectorAll(Nt)), e = s.find(
4676
+ const s = Array.from(document.querySelectorAll(Ht)), e = s.find(
4651
4677
  (r) => typeof r[On] == "string"
4652
4678
  );
4653
4679
  if (!(e ?? s[0]))
@@ -4659,7 +4685,7 @@ function ks() {
4659
4685
  selectors: [
4660
4686
  {
4661
4687
  name: "widget_host",
4662
- selector: Nt,
4688
+ selector: Ht,
4663
4689
  description: "Finds Pluno's shadow-host element in the host page DOM."
4664
4690
  },
4665
4691
  {
@@ -4698,13 +4724,13 @@ function Ki(s) {
4698
4724
  return null;
4699
4725
  }
4700
4726
  }
4701
- function Qt(s, e) {
4727
+ function Vt(s, e) {
4702
4728
  if (!s || typeof s != "object")
4703
4729
  return [];
4704
4730
  const t = s[e];
4705
4731
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
4706
4732
  }
4707
- function Vt(s) {
4733
+ function Xt(s) {
4708
4734
  return Array.isArray(s) ? s.flatMap((e) => {
4709
4735
  if (!e || typeof e != "object")
4710
4736
  return [];
@@ -4769,9 +4795,9 @@ function Zi(s) {
4769
4795
  avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
4770
4796
  } : null;
4771
4797
  }
4772
- function tt(s, e) {
4798
+ function st(s, e) {
4773
4799
  return Array.isArray(s) ? ht(
4774
- s.map((t) => at(t, e)).filter((t) => t !== null)
4800
+ s.map((t) => ve(t, e)).filter((t) => t !== null)
4775
4801
  ) : [];
4776
4802
  }
4777
4803
  function er(s) {
@@ -4795,7 +4821,7 @@ function er(s) {
4795
4821
  ];
4796
4822
  }) : [];
4797
4823
  }
4798
- function at(s, e) {
4824
+ function ve(s, e) {
4799
4825
  if (!s || typeof s != "object")
4800
4826
  return null;
4801
4827
  const t = s, n = t.data;
@@ -4809,8 +4835,8 @@ function at(s, e) {
4809
4835
  id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
4810
4836
  role: "assistant",
4811
4837
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4812
- content: _t(
4813
- Xt(i.content),
4838
+ content: vt(
4839
+ Jt(i.content),
4814
4840
  e
4815
4841
  ),
4816
4842
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -4826,8 +4852,8 @@ function at(s, e) {
4826
4852
  id: String(t.id ?? crypto.randomUUID()),
4827
4853
  role: r,
4828
4854
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4829
- content: _t(
4830
- Xt(i.content),
4855
+ content: vt(
4856
+ Jt(i.content),
4831
4857
  e
4832
4858
  ),
4833
4859
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
@@ -4861,7 +4887,7 @@ function at(s, e) {
4861
4887
  respondsToUserMessageId: O(i) ?? void 0,
4862
4888
  ...k(i) ? { runId: k(i) } : {},
4863
4889
  dataType: "function_call_output",
4864
- toolName: hs,
4890
+ toolName: St,
4865
4891
  callId: ue(i) ?? void 0,
4866
4892
  sharePromptAllowed: r
4867
4893
  };
@@ -5035,7 +5061,7 @@ function _(s) {
5035
5061
  function E(s) {
5036
5062
  return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
5037
5063
  }
5038
- function Xt(s) {
5064
+ function Jt(s) {
5039
5065
  return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
5040
5066
  if (!e || typeof e != "object")
5041
5067
  return "";
@@ -5046,7 +5072,7 @@ function Xt(s) {
5046
5072
  function de(s, e) {
5047
5073
  const t = Es(
5048
5074
  s,
5049
- At(s, e)
5075
+ Mt(s, e)
5050
5076
  ), n = ur(
5051
5077
  cr(
5052
5078
  gr(
@@ -5064,7 +5090,7 @@ function de(s, e) {
5064
5090
  const r = [...n];
5065
5091
  return r[i] = t, ht(r);
5066
5092
  }
5067
- function At(s, e, t = !0) {
5093
+ function Mt(s, e, t = !0) {
5068
5094
  const n = s.find(
5069
5095
  (r) => r.id === e.id || e.callId !== void 0 && r.callId === e.callId || e.assistantDraftItemId !== void 0 && (r.id === e.assistantDraftItemId || r.assistantDraftItemId === e.assistantDraftItemId)
5070
5096
  );
@@ -5094,7 +5120,7 @@ function cr(s, e) {
5094
5120
  function Ae(s, e, t) {
5095
5121
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
5096
5122
  }
5097
- function Jt(s, e, t, n) {
5123
+ function Yt(s, e, t, n) {
5098
5124
  if (t === null) return s;
5099
5125
  let i = -1;
5100
5126
  for (let o = s.length - 1; o >= 0; o -= 1) {
@@ -5111,7 +5137,7 @@ function Jt(s, e, t, n) {
5111
5137
  respondsToUserMessageId: t
5112
5138
  }, r;
5113
5139
  }
5114
- function Yt(s, e) {
5140
+ function Zt(s, e) {
5115
5141
  const t = s.findIndex(
5116
5142
  (i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
5117
5143
  );
@@ -5128,12 +5154,12 @@ function Yt(s, e) {
5128
5154
  ...n[t].runId ? {} : { runId: e.runId }
5129
5155
  }, n;
5130
5156
  }
5131
- function Zt(s, e, t) {
5157
+ function es(s, e, t) {
5132
5158
  let n = !1;
5133
5159
  const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
5134
5160
  return n ? i : s;
5135
5161
  }
5136
- function es(s) {
5162
+ function ts(s) {
5137
5163
  if (s.hiddenFromTranscript === !0)
5138
5164
  return null;
5139
5165
  const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
@@ -5169,7 +5195,7 @@ function lt(s, e) {
5169
5195
  t.push(
5170
5196
  Es(
5171
5197
  i,
5172
- At(i, n, !1)
5198
+ Mt(i, n, !1)
5173
5199
  )
5174
5200
  );
5175
5201
  }
@@ -5181,7 +5207,7 @@ function lt(s, e) {
5181
5207
  }
5182
5208
  function dr(s, e) {
5183
5209
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5184
- (r) => At(s, r, !1)
5210
+ (r) => Mt(s, r, !1)
5185
5211
  );
5186
5212
  for (const r of n)
5187
5213
  t.set(r.id, r);
@@ -5214,7 +5240,7 @@ function ct(s) {
5214
5240
  ...i.length > 0 ? { activityKeys: i } : {},
5215
5241
  ...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
5216
5242
  ...s.runId ? { runId: s.runId } : {},
5217
- isOptimistic: Le(s),
5243
+ isOptimistic: Ne(s),
5218
5244
  isAssistantDraft: s.dataType === "assistant_draft",
5219
5245
  isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
5220
5246
  isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
@@ -5224,7 +5250,7 @@ function Es(s, e) {
5224
5250
  if (e.role !== "user" || !e.attachments?.length)
5225
5251
  return e;
5226
5252
  const t = s.find(
5227
- (o) => o.role === "user" && (o.id === e.id || Le(o) && Cs(o, e))
5253
+ (o) => o.role === "user" && (o.id === e.id || Ne(o) && Cs(o, e))
5228
5254
  );
5229
5255
  if (!t?.attachments?.length)
5230
5256
  return e;
@@ -5248,7 +5274,7 @@ function gr(s, e) {
5248
5274
  if (e.role !== "user")
5249
5275
  return s;
5250
5276
  const t = s.findIndex(
5251
- (i) => Le(i) && Cs(i, e)
5277
+ (i) => Ne(i) && Cs(i, e)
5252
5278
  );
5253
5279
  if (t === -1)
5254
5280
  return s;
@@ -5259,7 +5285,7 @@ function Cs(s, e) {
5259
5285
  const t = X(s), n = X(e);
5260
5286
  return t && n ? t === n : s.content === e.content;
5261
5287
  }
5262
- function Le(s) {
5288
+ function Ne(s) {
5263
5289
  return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
5264
5290
  }
5265
5291
  function X(s) {
@@ -5271,13 +5297,13 @@ function X(s) {
5271
5297
  );
5272
5298
  return n ? s.id.slice(n.length) : null;
5273
5299
  }
5274
- function ts(s) {
5300
+ function ss(s) {
5275
5301
  const e = Ps(s);
5276
5302
  if (e === null)
5277
5303
  return !1;
5278
5304
  const t = s[e].id;
5279
5305
  if (s.some(
5280
- (i) => i.respondsToUserMessageId === t && ve(i)
5306
+ (i) => i.respondsToUserMessageId === t && Ue(i)
5281
5307
  ))
5282
5308
  return !0;
5283
5309
  for (let i = s.length - 1; i > e; i -= 1) {
@@ -5326,11 +5352,11 @@ function mr(s) {
5326
5352
  }
5327
5353
  function Ps(s) {
5328
5354
  for (let e = s.length - 1; e >= 0; e -= 1)
5329
- if (s[e].role === "user" && !Le(s[e]))
5355
+ if (s[e].role === "user" && !Ne(s[e]))
5330
5356
  return e;
5331
5357
  return null;
5332
5358
  }
5333
- function ve(s) {
5359
+ function Ue(s) {
5334
5360
  return $(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5335
5361
  }
5336
5362
  function ie(s) {
@@ -5378,8 +5404,8 @@ function Sr(s, e) {
5378
5404
  return !1;
5379
5405
  const r = s.findIndex((o) => o.role === "user" && o.id === i);
5380
5406
  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);
5407
+ (o) => o.respondsToUserMessageId === i && Ue(o)
5408
+ ) : s.slice(r + 1).some(Ue);
5383
5409
  }
5384
5410
  function ut(s) {
5385
5411
  const e = ie(s);
@@ -5424,7 +5450,7 @@ function dt(s, e) {
5424
5450
  const n = s.find((r) => A(r, "id") === t), i = C(n);
5425
5451
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5426
5452
  }
5427
- function ss(s, e, t, n, i, r) {
5453
+ function ns(s, e, t, n, i, r) {
5428
5454
  if (!e || !Ar(s))
5429
5455
  return !1;
5430
5456
  const o = s;
@@ -5477,7 +5503,7 @@ function pt(s) {
5477
5503
  function Rr(s) {
5478
5504
  return s.some(pt);
5479
5505
  }
5480
- function ns(s, e) {
5506
+ function is(s, e) {
5481
5507
  return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5482
5508
  }
5483
5509
  function kr(s, e) {
@@ -5502,7 +5528,7 @@ function Ce(s) {
5502
5528
  function Cr(s, e) {
5503
5529
  return $(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5504
5530
  }
5505
- function is(s, e, t) {
5531
+ function rs(s, e, t) {
5506
5532
  const n = new Set(
5507
5533
  s.filter(
5508
5534
  (i) => i.role === "user" && e !== null && X(i) === e
@@ -5532,9 +5558,9 @@ function Pr(s, e, t) {
5532
5558
  return s[r].id === n.respondsToUserMessageId;
5533
5559
  return !1;
5534
5560
  }
5535
- function rs(s, e, t, n) {
5561
+ function os(s, e, t, n) {
5536
5562
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5537
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && os(l) && !vr(
5563
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !vr(
5538
5564
  s,
5539
5565
  l.respondsToUserMessageId
5540
5566
  )
@@ -5545,7 +5571,7 @@ function rs(s, e, t, n) {
5545
5571
  if (!i)
5546
5572
  return s;
5547
5573
  let r = !1;
5548
- const o = s.map((l) => l.respondsToUserMessageId !== i || !os(l) ? l : (r = !0, { ...l, steered: !0 }));
5574
+ const o = s.map((l) => l.respondsToUserMessageId !== i || !as(l) ? l : (r = !0, { ...l, steered: !0 }));
5549
5575
  if (r)
5550
5576
  return o;
5551
5577
  const a = s.find(
@@ -5578,7 +5604,7 @@ function _r(s, e) {
5578
5604
  return s[n].id;
5579
5605
  return null;
5580
5606
  }
5581
- function os(s) {
5607
+ function as(s) {
5582
5608
  return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5583
5609
  }
5584
5610
  function vr(s, e) {
@@ -5670,24 +5696,24 @@ function Nr(s, e) {
5670
5696
  }
5671
5697
  function Hr(s) {
5672
5698
  try {
5673
- const e = window.localStorage.getItem(`${ot}${s}`);
5699
+ const e = window.localStorage.getItem(`${at}${s}`);
5674
5700
  if (!e)
5675
5701
  return [];
5676
5702
  const t = JSON.parse(e);
5677
- return Array.isArray(t) ? t.filter(Mt) : [];
5703
+ return Array.isArray(t) ? t.filter(bt) : [];
5678
5704
  } catch {
5679
5705
  return [];
5680
5706
  }
5681
5707
  }
5682
5708
  function V(s, e) {
5683
5709
  try {
5684
- const t = e.filter(Mt);
5710
+ const t = e.filter(bt);
5685
5711
  if (t.length === 0) {
5686
- window.localStorage.removeItem(`${ot}${s}`);
5712
+ window.localStorage.removeItem(`${at}${s}`);
5687
5713
  return;
5688
5714
  }
5689
5715
  window.localStorage.setItem(
5690
- `${ot}${s}`,
5716
+ `${at}${s}`,
5691
5717
  JSON.stringify(t.slice(-25))
5692
5718
  );
5693
5719
  } catch {
@@ -5696,7 +5722,7 @@ function V(s, e) {
5696
5722
  }
5697
5723
  function Us(s, e) {
5698
5724
  try {
5699
- const t = `${Oe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5725
+ const t = `${xe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5700
5726
  ...o,
5701
5727
  storedAt: Date.now(),
5702
5728
  unloadUrl: n,
@@ -5710,9 +5736,9 @@ function Us(s, e) {
5710
5736
  } catch {
5711
5737
  }
5712
5738
  }
5713
- function as(s, e) {
5739
+ function ls(s, e) {
5714
5740
  try {
5715
- if (window.sessionStorage.getItem(`${Oe}${s}`) === null)
5741
+ if (window.sessionStorage.getItem(`${xe}${s}`) === null)
5716
5742
  return;
5717
5743
  } catch {
5718
5744
  return;
@@ -5721,7 +5747,7 @@ function as(s, e) {
5721
5747
  }
5722
5748
  function Br(s) {
5723
5749
  try {
5724
- const e = `${Oe}${s}`, t = window.sessionStorage.getItem(e);
5750
+ const e = `${xe}${s}`, t = window.sessionStorage.getItem(e);
5725
5751
  if (window.sessionStorage.removeItem(e), !t)
5726
5752
  return [];
5727
5753
  const n = JSON.parse(t);
@@ -5756,7 +5782,7 @@ function $r(s) {
5756
5782
  if (!s || typeof s != "object")
5757
5783
  return !1;
5758
5784
  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";
5785
+ return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && bt(t) && t.type === "tool.result";
5760
5786
  }
5761
5787
  function Fr(s, e) {
5762
5788
  const t = new Set(
@@ -5769,18 +5795,18 @@ function Fr(s, e) {
5769
5795
  }
5770
5796
  function jr(s) {
5771
5797
  try {
5772
- window.sessionStorage.removeItem(`${Oe}${s}`);
5798
+ window.sessionStorage.removeItem(`${xe}${s}`);
5773
5799
  } catch {
5774
5800
  return;
5775
5801
  }
5776
5802
  }
5777
- function Mt(s) {
5803
+ function bt(s) {
5778
5804
  if (!s || typeof s != "object")
5779
5805
  return !1;
5780
5806
  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;
5807
+ return e.type === "chat.user_message" ? typeof e.content == "string" && cs(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? cs(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
5782
5808
  }
5783
- function ls(s) {
5809
+ function cs(s) {
5784
5810
  if (!s || typeof s != "object")
5785
5811
  return !1;
5786
5812
  const e = s;
@@ -5846,17 +5872,17 @@ function Qr(s) {
5846
5872
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
5847
5873
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
5848
5874
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
5849
- attachments: Ds(e.attachments)?.map(Ue),
5875
+ attachments: Ds(e.attachments)?.map(De),
5850
5876
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5851
5877
  };
5852
5878
  }
5853
5879
  function Vr(s) {
5854
5880
  return s.attachments?.length ? {
5855
5881
  ...s,
5856
- attachments: s.attachments.map(Ue)
5882
+ attachments: s.attachments.map(De)
5857
5883
  } : s;
5858
5884
  }
5859
- function Ue(s) {
5885
+ function De(s) {
5860
5886
  const {
5861
5887
  dataUrl: e,
5862
5888
  objectUrl: t,
@@ -5882,15 +5908,15 @@ function xs(s) {
5882
5908
  const e = {};
5883
5909
  try {
5884
5910
  new Headers(s).forEach((t, n) => {
5885
- Object.keys(e).length < Tt && (e[n] = bt(n, t));
5911
+ Object.keys(e).length < wt && (e[n] = Rt(n, t));
5886
5912
  });
5887
5913
  } catch {
5888
5914
  return {};
5889
5915
  }
5890
5916
  return e;
5891
5917
  }
5892
- function bt(s, e) {
5893
- return $s(s) ? Ne : W(qe(e), ri);
5918
+ function Rt(s, e) {
5919
+ return $s(s) ? He : W(Oe(e), ri);
5894
5920
  }
5895
5921
  function Jr(s, e) {
5896
5922
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
@@ -5925,7 +5951,7 @@ async function Zr(s) {
5925
5951
  const { done: l, value: c } = a;
5926
5952
  if (l)
5927
5953
  return W(r + i.decode());
5928
- const u = St - o;
5954
+ const u = Tt - o;
5929
5955
  if (c.byteLength > u)
5930
5956
  return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${W(r)}... [truncated]`;
5931
5957
  o += c.byteLength, r += i.decode(c, { stream: !0 });
@@ -5945,34 +5971,34 @@ function eo(s, e) {
5945
5971
  return;
5946
5972
  }
5947
5973
  }
5948
- function cs(s) {
5974
+ function us(s) {
5949
5975
  if (typeof s == "string")
5950
5976
  return W(s);
5951
5977
  }
5952
5978
  function to(s) {
5953
5979
  return L({
5954
5980
  ...s,
5955
- requestBody: us(s.requestBody),
5956
- responseBody: us(s.responseBody)
5981
+ requestBody: ds(s.requestBody),
5982
+ responseBody: ds(s.responseBody)
5957
5983
  });
5958
5984
  }
5959
- function us(s) {
5985
+ function ds(s) {
5960
5986
  if (typeof s != "string")
5961
5987
  return s;
5962
5988
  const e = s.trim();
5963
5989
  if (!e.startsWith("{") && !e.startsWith("["))
5964
- return qe(s);
5990
+ return Oe(s);
5965
5991
  try {
5966
5992
  return JSON.stringify(L(JSON.parse(s)));
5967
5993
  } catch {
5968
- return qe(s);
5994
+ return Oe(s);
5969
5995
  }
5970
5996
  }
5971
5997
  function Ls(s) {
5972
5998
  if (!s)
5973
5999
  return !1;
5974
6000
  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"));
6001
+ return t !== null && Number.isInteger(n) && n >= 0 && n <= Tt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
5976
6002
  }
5977
6003
  function te(s, e = {}, t) {
5978
6004
  if (no(t))
@@ -6009,17 +6035,17 @@ function io(s) {
6009
6035
  const n = t.indexOf(":");
6010
6036
  if (n <= 0)
6011
6037
  continue;
6012
- if (Object.keys(e).length >= Tt)
6038
+ if (Object.keys(e).length >= wt)
6013
6039
  break;
6014
6040
  const i = t.slice(0, n).trim();
6015
- e[i] = bt(i, t.slice(n + 1).trim());
6041
+ e[i] = Rt(i, t.slice(n + 1).trim());
6016
6042
  }
6017
6043
  return e;
6018
6044
  }
6019
- function W(s, e = St) {
6045
+ function W(s, e = Tt) {
6020
6046
  return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
6021
6047
  }
6022
- function st(s) {
6048
+ function nt(s) {
6023
6049
  return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
6024
6050
  }
6025
6051
  class Pe extends Error {
@@ -6030,11 +6056,11 @@ class Pe extends Error {
6030
6056
  }
6031
6057
  async function Me(s, e) {
6032
6058
  let t = null;
6033
- for (let n = 0; n < jt; n += 1)
6059
+ for (let n = 0; n < zt; n += 1)
6034
6060
  try {
6035
6061
  return await s();
6036
6062
  } catch (i) {
6037
- if (t = i, n >= jt - 1 || !oo(i))
6063
+ if (t = i, n >= zt - 1 || !oo(i))
6038
6064
  throw i;
6039
6065
  await ro(n);
6040
6066
  }
@@ -6054,13 +6080,13 @@ function ao(s) {
6054
6080
  function lo(s) {
6055
6081
  return s === 401 || s === 403;
6056
6082
  }
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 = /[),.;\]]+$/;
6083
+ const He = "[REDACTED_SECRET]", F = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
6058
6084
  function L(s) {
6059
- return De(s, 0, /* @__PURE__ */ new WeakSet());
6085
+ return qe(s, 0, /* @__PURE__ */ new WeakSet());
6060
6086
  }
6061
- function De(s, e, t) {
6087
+ function qe(s, e, t) {
6062
6088
  if (typeof s == "string")
6063
- return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : qe(s);
6089
+ return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : Oe(s);
6064
6090
  if (s === null || typeof s != "object")
6065
6091
  return s;
6066
6092
  if (e >= uo)
@@ -6068,10 +6094,10 @@ function De(s, e, t) {
6068
6094
  if (t.has(s))
6069
6095
  return "[REDACTED_CIRCULAR]";
6070
6096
  if (t.add(s), Array.isArray(s))
6071
- return s.map((i) => De(i, e + 1, t));
6097
+ return s.map((i) => qe(i, e + 1, t));
6072
6098
  const n = {};
6073
6099
  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);
6100
+ i === "pageContent" ? n[i] = r : $s(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
6075
6101
  return n;
6076
6102
  }
6077
6103
  function $s(s) {
@@ -6079,7 +6105,7 @@ function $s(s) {
6079
6105
  return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
6080
6106
  }
6081
6107
  function mo(s) {
6082
- return typeof s == "string" ? Fs(s) : De(s, 0, /* @__PURE__ */ new WeakSet());
6108
+ return typeof s == "string" ? Fs(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
6083
6109
  }
6084
6110
  function Fs(s) {
6085
6111
  try {
@@ -6091,33 +6117,33 @@ function Fs(s) {
6091
6117
  return yo(s);
6092
6118
  }
6093
6119
  }
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}`);
6120
+ function Oe(s) {
6121
+ return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${He}`);
6096
6122
  }
6097
6123
  function yo(s) {
6098
- return s.replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${Ne}`);
6124
+ return s.replace(Ns, `Bearer ${F}`).replace(Hs, `Basic ${F}`).replace(Bs, F).replace(Ws, (e, t) => `${t}: ${He}`);
6099
6125
  }
6100
6126
  function Io(s) {
6101
6127
  const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6102
6128
  return `${Fs(t)}${e}`;
6103
6129
  }
6104
6130
  const Eo = Object.freeze({
6105
- init: (s) => xe.init(s)
6131
+ init: (s) => Le.init(s)
6106
6132
  });
6107
6133
  function Co(s) {
6108
- return xe.init(s);
6134
+ return Le.init(s);
6109
6135
  }
6110
6136
  export {
6111
- Nt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6137
+ Ht as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6112
6138
  Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6113
6139
  Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6114
6140
  qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6115
6141
  ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6116
6142
  Eo as PlunoProductAgent,
6117
6143
  kn as ProductAgentInteractionManager,
6118
- Ot as ProductAgentQueryController,
6144
+ xt as ProductAgentQueryController,
6119
6145
  Ro as ProductAgentRemoteRuntimeClient,
6120
- xe as ProductAgentSessionEngine,
6146
+ Le as ProductAgentSessionEngine,
6121
6147
  Mn as ProductAgentSessionHistoryManager,
6122
6148
  Ao as ProductAgentTaskPageTitleController,
6123
6149
  ee as ProductAgentTokenProviderError,
@@ -6132,7 +6158,7 @@ export {
6132
6158
  bo as isProductAgentRuntimeCommand,
6133
6159
  Tn as mergeProductAgentEntityPages,
6134
6160
  ke as normalizeProductAgentEntityPage,
6135
- tt as normalizeProductAgentSessionItems,
6161
+ st as normalizeProductAgentSessionItems,
6136
6162
  En as readLocalStorageInteractionDecisions,
6137
6163
  To as resolveProductAgentComposerAction,
6138
6164
  So as resolveProductAgentWidgetPresentation,