@pluno/product-agent-web 0.1.205 → 0.1.207

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.
@@ -62,11 +62,11 @@ function It(s) {
62
62
  s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Product Agent attachment storage request failed"));
63
63
  });
64
64
  }
65
- function Xs(s) {
65
+ function Js(s) {
66
66
  return s !== null && (typeof s == "object" || typeof s == "function");
67
67
  }
68
68
  function hs(s, e, t) {
69
- const n = Reflect.get(s, "pluno"), i = Xs(n) ? n : {};
69
+ const n = Reflect.get(s, "pluno"), i = Js(n) ? n : {};
70
70
  if (i !== n && !Reflect.set(s, "pluno", i))
71
71
  return null;
72
72
  const r = Object.getOwnPropertyDescriptor(i, e);
@@ -80,10 +80,10 @@ function hs(s, e, t) {
80
80
  }
81
81
  };
82
82
  }
83
- const Js = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
83
+ const Xs = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
84
84
  function vt(s, e) {
85
85
  return e ? s.replace(
86
- Js,
86
+ Xs,
87
87
  (t, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
88
88
  ) : s;
89
89
  }
@@ -187,11 +187,11 @@ function Dt(s, e, t, n) {
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 ze = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", Ke = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
190
+ const Ke = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", Ge = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
191
191
  let le = null;
192
- const be = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Map();
192
+ const Re = /* @__PURE__ */ new Set(), Qe = /* @__PURE__ */ new Map();
193
193
  async function cn(s = ps()) {
194
- const e = s.randomUUID(), t = s.storage.getItem(ze);
194
+ const e = s.randomUUID(), t = s.storage.getItem(Ke);
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(ze, n), i = !0;
212
+ s.storage.setItem(Ke, 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(ze, n);
221
+ n = s.randomUUID(), s.storage.setItem(Ke, n);
222
222
  }
223
223
  let a = !1;
224
224
  return {
@@ -234,24 +234,24 @@ async function un(s = !1) {
234
234
  skipStoredIdentityCollisionCheck: s
235
235
  }), le.then((i) => {
236
236
  const r = (o) => {
237
- o.persisted || (i.release(), le = null, be.clear(), window.removeEventListener("pagehide", r));
237
+ o.persisted || (i.release(), le = null, Re.clear(), window.removeEventListener("pagehide", r));
238
238
  };
239
239
  window.addEventListener("pagehide", r);
240
240
  }));
241
241
  const e = await le, t = dn();
242
- be.add(t);
242
+ Re.add(t);
243
243
  let n = !1;
244
244
  return {
245
245
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
246
246
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
247
247
  release: () => {
248
- n || (n = !0, be.delete(t));
248
+ n || (n = !0, Re.delete(t));
249
249
  }
250
250
  };
251
251
  }
252
252
  function dn() {
253
253
  let s = 0;
254
- for (; be.has(s); )
254
+ for (; Re.has(s); )
255
255
  s += 1;
256
256
  return s;
257
257
  }
@@ -267,13 +267,13 @@ function hn() {
267
267
  return {
268
268
  getItem: (s) => {
269
269
  try {
270
- return window.sessionStorage?.getItem(s) ?? Ge.get(s) ?? null;
270
+ return window.sessionStorage?.getItem(s) ?? Qe.get(s) ?? null;
271
271
  } catch {
272
- return Ge.get(s) ?? null;
272
+ return Qe.get(s) ?? null;
273
273
  }
274
274
  },
275
275
  setItem: (s, e) => {
276
- Ge.set(s, e);
276
+ Qe.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 !== Ke || !t.newValue)
300
+ if (t.key !== Ge || !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
- Ke,
309
+ Ge,
310
310
  JSON.stringify({ ...t, eventId: crypto.randomUUID() })
311
- ), window.localStorage.removeItem(Ke);
311
+ ), window.localStorage.removeItem(Ge);
312
312
  },
313
313
  subscribe: (t) => (s.add(t), () => s.delete(t)),
314
314
  close: () => {
@@ -343,7 +343,7 @@ const mn = [
343
343
  ], In = [
344
344
  ...mn,
345
345
  ...yn
346
- ], Qe = (s) => In.some((e) => e.value === s);
346
+ ], Ve = (s) => In.some((e) => e.value === s);
347
347
  function qt(s, e) {
348
348
  return s.filter((t, n) => {
349
349
  const i = Ot(t);
@@ -369,7 +369,7 @@ function ms(s, e) {
369
369
  function ys(s, e) {
370
370
  return typeof s.respondsToUserMessageId == "string" && typeof e.respondsToUserMessageId == "string" ? s.respondsToUserMessageId === e.respondsToUserMessageId : typeof s.clientMessageId == "string" && typeof e.clientMessageId == "string" ? s.clientMessageId === e.clientMessageId : typeof s.runId == "string" && typeof e.runId == "string" && s.runId === e.runId;
371
371
  }
372
- function Re(s) {
372
+ function ke(s) {
373
373
  return {
374
374
  key: s,
375
375
  status: "not_requested",
@@ -381,7 +381,7 @@ function Re(s) {
381
381
  }
382
382
  class xt {
383
383
  constructor(e, t, n = (i, r) => r) {
384
- this.loader = t, this.merge = n, this.state = Re(e);
384
+ this.loader = t, this.merge = n, this.state = ke(e);
385
385
  }
386
386
  loader;
387
387
  merge;
@@ -396,10 +396,10 @@ class xt {
396
396
  return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
397
397
  }
398
398
  setKey(e) {
399
- e !== this.state.key && (this.state = Re(e), this.trailingLoad = null, this.publish());
399
+ e !== this.state.key && (this.state = ke(e), this.trailingLoad = null, this.publish());
400
400
  }
401
401
  reset() {
402
- this.state = Re(this.state.key), this.trailingLoad = null, this.publish();
402
+ this.state = ke(this.state.key), this.trailingLoad = null, this.publish();
403
403
  }
404
404
  invalidate() {
405
405
  this.state = {
@@ -454,7 +454,7 @@ class xt {
454
454
  for (const e of this.listeners) e(this.state);
455
455
  }
456
456
  }
457
- function ke(s) {
457
+ function Ee(s) {
458
458
  const e = {}, t = [];
459
459
  for (const n of s.entities)
460
460
  e[n.id] || t.push(n.id), e[n.id] = n;
@@ -474,7 +474,7 @@ function Tn(s, e, t) {
474
474
  function Is(s) {
475
475
  return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
476
476
  }
477
- function So(s) {
477
+ function Ao(s) {
478
478
  return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
479
479
  }
480
480
  function wn(s, e) {
@@ -485,7 +485,7 @@ function An(s) {
485
485
  const e = s.paidCreditFallbackModel;
486
486
  return typeof e == "string" && e.length > 0;
487
487
  }
488
- function To(s) {
488
+ function Mo(s) {
489
489
  const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
490
490
  return s.hasRunningAssistantTurn && !e ? {
491
491
  action: "stop",
@@ -499,7 +499,7 @@ class Mn {
499
499
  constructor(e, t, n = 20) {
500
500
  this.loadPage = t, this.limit = n, this.recentQuery = new xt(
501
501
  `${e}:recent`,
502
- async ({ cursor: i }) => ke(
502
+ async ({ cursor: i }) => Ee(
503
503
  await this.loadPage({ cursor: i, limit: this.limit, pinned: !1 }).then((r) => ({
504
504
  entities: r.sessions,
505
505
  nextCursor: r.nextCursor
@@ -508,7 +508,7 @@ class Mn {
508
508
  Tn
509
509
  ), this.pinnedQuery = new xt(
510
510
  `${e}:pinned`,
511
- async () => ke({
511
+ async () => Ee({
512
512
  entities: await this.loadAllPinned(),
513
513
  nextCursor: null
514
514
  })
@@ -532,7 +532,7 @@ class Mn {
532
532
  ...Ie(e.data)
533
533
  ], i = new Map(n.map((l) => [l.id, l])), r = Array.from(i.values()).map(
534
534
  (l) => this.applyOverrides(l, this.completedRefreshSequence)
535
- ), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ? ke({
535
+ ), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ? Ee({
536
536
  entities: [...o, ...r],
537
537
  nextCursor: e.data?.nextCursor ?? null
538
538
  }) : null;
@@ -825,17 +825,17 @@ class kn {
825
825
  return null;
826
826
  }
827
827
  getDecisionKey(e) {
828
- const t = Ve(e.scope);
828
+ const t = Je(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 `${Ve(e.scope)}:interaction:${e.key}`;
832
+ return `${Je(e.scope)}:interaction:${e.key}`;
833
833
  }
834
834
  getCategoryKey(e) {
835
- return `${Ve(e.scope)}:category:${e.category}`;
835
+ return `${Je(e.scope)}:category:${e.category}`;
836
836
  }
837
837
  }
838
- function wo(s, e) {
838
+ function bo(s, e) {
839
839
  return {
840
840
  load: async () => En(s, e),
841
841
  save: async (t) => s.setItem(e, JSON.stringify(t))
@@ -847,7 +847,7 @@ function En(s, e) {
847
847
  const n = JSON.parse(t);
848
848
  return Array.isArray(n) ? n.filter(rt) : [];
849
849
  }
850
- function Ve(s) {
850
+ function Je(s) {
851
851
  return `${s.level}:${s.key}`;
852
852
  }
853
853
  function Ss(s) {
@@ -863,13 +863,13 @@ const Cn = {
863
863
  completed: "✅",
864
864
  failed: "❗",
865
865
  stopped: "⏹️"
866
- }, Pn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
- function _n(s, e) {
868
- if (!e) return _e(s);
869
- const t = _e(s), n = `${Cn[e]} Pluno`;
866
+ }, _n = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
867
+ function Pn(s, e) {
868
+ if (!e) return ve(s);
869
+ const t = ve(s), n = `${Cn[e]} Pluno`;
870
870
  return t ? `${n}: ${t}` : n;
871
871
  }
872
- class Ao {
872
+ class Ro {
873
873
  constructor(e) {
874
874
  this.titleDocument = e;
875
875
  }
@@ -891,10 +891,10 @@ class Ao {
891
891
  }
892
892
  applyStatus(e) {
893
893
  const t = this.titleDocument.getTitle();
894
- t !== this.lastAppliedTitle && (this.baseTitle = _e(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
894
+ t !== this.lastAppliedTitle && (this.baseTitle = ve(t)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
895
895
  }
896
896
  applyClear() {
897
- const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? _e(e) : e;
897
+ const e = this.titleDocument.getTitle(), t = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? ve(e) : e;
898
898
  this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, t ? this.titleDocument.setTitle(this.baseTitle) : n !== e && this.titleDocument.setTitle(n);
899
899
  }
900
900
  handleTitleChanged() {
@@ -903,11 +903,11 @@ class Ao {
903
903
  applyTitle() {
904
904
  if (!this.status)
905
905
  return;
906
- const e = _n(this.baseTitle, this.status);
906
+ const e = Pn(this.baseTitle, this.status);
907
907
  this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
908
908
  }
909
909
  }
910
- function Mo(s) {
910
+ function ko(s) {
911
911
  return {
912
912
  getTitle: () => s.title,
913
913
  setTitle: (e) => {
@@ -923,10 +923,10 @@ function Mo(s) {
923
923
  }
924
924
  };
925
925
  }
926
- function _e(s) {
927
- return s.replace(Pn, "");
926
+ function ve(s) {
927
+ return s.replace(_n, "");
928
928
  }
929
- function bo(s) {
929
+ function Eo(s) {
930
930
  if (!s || typeof s != "object" || !("type" in s)) return !1;
931
931
  const e = s;
932
932
  switch (e.type) {
@@ -937,6 +937,10 @@ function bo(s) {
937
937
  return !0;
938
938
  case "runtime.warmup":
939
939
  return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
940
+ case "runtime.report_displayed_error":
941
+ return (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint);
942
+ case "runtime.report_invalid_state_transition":
943
+ return (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll") && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
940
944
  case "runtime.widget_lifecycle":
941
945
  return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
942
946
  case "session.load":
@@ -954,7 +958,7 @@ function bo(s) {
954
958
  case "conversation.stage_proactive_suggestion":
955
959
  return typeof e.question == "string" && typeof e.clientMessageId == "string";
956
960
  case "conversation.stage":
957
- return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.attachments === void 0 || Array.isArray(e.attachments));
961
+ return typeof e.content == "string" && typeof e.clientMessageId == "string" && (e.submittedAt === void 0 || typeof e.submittedAt == "number") && (e.attachments === void 0 || Array.isArray(e.attachments));
958
962
  case "conversation.fail_staged":
959
963
  return typeof e.clientMessageId == "string" && typeof e.message == "string";
960
964
  case "conversation.send":
@@ -963,7 +967,7 @@ function bo(s) {
963
967
  return !1;
964
968
  }
965
969
  }
966
- class Ro {
970
+ class Co {
967
971
  constructor(e, t, n) {
968
972
  this.adapter = t, this.state = Xe(e), this.model = n;
969
973
  }
@@ -974,7 +978,7 @@ class Ro {
974
978
  interactionListeners = /* @__PURE__ */ new Set();
975
979
  accountListeners = /* @__PURE__ */ new Set();
976
980
  state;
977
- sessionHistoryState = Re("unavailable");
981
+ sessionHistoryState = ke("unavailable");
978
982
  model;
979
983
  interactions = [];
980
984
  account = null;
@@ -1023,10 +1027,26 @@ class Ro {
1023
1027
  recordWidgetLifecycle(e, t) {
1024
1028
  this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: t });
1025
1029
  }
1030
+ reportInvalidStateTransition(e, t) {
1031
+ this.adapter.dispatch({
1032
+ type: "runtime.report_invalid_state_transition",
1033
+ reason: e,
1034
+ clientMessageId: t
1035
+ }).catch(() => {
1036
+ });
1037
+ }
1038
+ reportDisplayedError(e, t) {
1039
+ this.adapter.dispatch({
1040
+ type: "runtime.report_displayed_error",
1041
+ reason: e,
1042
+ errorFingerprint: t
1043
+ }).catch(() => {
1044
+ });
1045
+ }
1026
1046
  sendMessage(e, t = {}) {
1027
1047
  const n = e.trim(), i = t.attachments ?? [];
1028
1048
  if (!n && i.length === 0) return Promise.resolve(null);
1029
- const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = this.state, a = {
1049
+ const r = t.clientMessageId ?? (t.proactiveSuggestionQuestion && this.stagedProactiveSuggestionClientMessageId ? this.stagedProactiveSuggestionClientMessageId : crypto.randomUUID()), o = t.submittedAt ?? Date.now(), a = this.state, l = {
1030
1050
  id: `local-${r}`,
1031
1051
  role: "user",
1032
1052
  content: n,
@@ -1036,7 +1056,7 @@ class Ro {
1036
1056
  };
1037
1057
  return this.state = {
1038
1058
  ...this.state,
1039
- messages: [...this.state.messages, a],
1059
+ messages: [...this.state.messages, l],
1040
1060
  pendingMessageStatus: "sending",
1041
1061
  turnPhase: this.state.isThinking ? this.state.turnPhase : "sending",
1042
1062
  taskStatus: "working",
@@ -1044,8 +1064,8 @@ class Ro {
1044
1064
  lastError: null
1045
1065
  }, this.emit("state", this.getState()), this.enqueueOperation(() => this.sendMessageNow(
1046
1066
  n,
1047
- { ...t, clientMessageId: r },
1048
- o
1067
+ { ...t, clientMessageId: r, submittedAt: o },
1068
+ a
1049
1069
  ));
1050
1070
  }
1051
1071
  async sendMessageNow(e, t, n) {
@@ -1057,7 +1077,8 @@ class Ro {
1057
1077
  content: i,
1058
1078
  clientMessageId: r,
1059
1079
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1060
- attachments: o.length > 0 ? o : void 0
1080
+ attachments: o.length > 0 ? o : void 0,
1081
+ submittedAt: t.submittedAt
1061
1082
  }), a = !0, o.length > 0) {
1062
1083
  if (!this.adapter.uploadAttachment)
1063
1084
  throw new Error("The runtime does not support attachments.");
@@ -1225,9 +1246,12 @@ function Xe(s) {
1225
1246
  messages: s.messages.map((e) => {
1226
1247
  const t = {
1227
1248
  ...e,
1228
- attachments: e.attachments?.map((r) => ({ ...r }))
1229
- }, n = e.assistantDraftItemId, i = e.clientMessageId;
1230
- return n && Object.defineProperty(t, "assistantDraftItemId", {
1249
+ attachments: e.attachments?.map((o) => ({ ...o }))
1250
+ }, n = e.assistantDraftItemId, i = e.clientMessageId, r = e.proactiveSuggestionClientMessageId;
1251
+ return r && Object.defineProperty(t, "proactiveSuggestionClientMessageId", {
1252
+ value: r,
1253
+ enumerable: !1
1254
+ }), n && Object.defineProperty(t, "assistantDraftItemId", {
1231
1255
  value: n,
1232
1256
  enumerable: !1
1233
1257
  }), i && Object.defineProperty(t, "clientMessageId", {
@@ -1241,14 +1265,14 @@ function Xe(s) {
1241
1265
  function Nt(s) {
1242
1266
  return {
1243
1267
  ...s,
1244
- data: s.data ? ke({
1268
+ data: s.data ? Ee({
1245
1269
  entities: Is(s.data).map((e) => ({ ...e })),
1246
1270
  nextCursor: s.data.nextCursor
1247
1271
  }) : null
1248
1272
  };
1249
1273
  }
1250
1274
  const vn = globalThis.fetch.bind(globalThis), Ht = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Un = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Dn = ".pluno-pa-widget__panel", qn = ".pluno-pa-widget__timeline", On = "__plunoExtensionWidgetOwner";
1251
- class X extends Error {
1275
+ class J extends Error {
1252
1276
  constructor(e, t, n, i) {
1253
1277
  super(e), this.retryable = t, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
1254
1278
  }
@@ -1290,9 +1314,10 @@ function Bt(s) {
1290
1314
  const r = (l) => {
1291
1315
  if (!l || typeof l != "object")
1292
1316
  return null;
1293
- const c = l, u = c.data, d = u && typeof u == "object" ? u : {}, g = ve(l);
1317
+ const c = l, u = c.data, d = u && typeof u == "object" ? u : {}, g = Ue(l);
1294
1318
  return {
1295
1319
  id: typeof c.id == "string" ? c.id : null,
1320
+ streamId: d.type === "message" && d.role === "assistant" && typeof d.id == "string" ? d.id : null,
1296
1321
  type: typeof d.type == "string" ? d.type : null,
1297
1322
  role: typeof d.role == "string" ? d.role : null,
1298
1323
  sessionId: typeof c.sessionId == "string" ? c.sessionId : null,
@@ -1304,9 +1329,9 @@ function Bt(s) {
1304
1329
  visible: !!(g && !g.scheduledCheckInAt && g.toolName !== St && (d.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(d.status))))
1305
1330
  };
1306
1331
  }, 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);
1332
+ 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, o.streamId && (e.visibleItemAliases = JSON.stringify([[o.streamId, o.id]])))), Array.isArray(s.items)) {
1333
+ const l = s.items.map(r).filter((c) => c !== null && c.visible && !!c.id);
1334
+ e.visibleItemIds = JSON.stringify(l.map((c) => c.id)), e.visibleItemAliases = JSON.stringify(l.flatMap((c) => c.streamId ? [[c.streamId, c.id]] : []));
1310
1335
  }
1311
1336
  s.type === "chat.assistant_delta" && typeof s.itemId == "string" && (e.visibleItemId = s.itemId);
1312
1337
  const a = s.session;
@@ -1324,7 +1349,7 @@ function Bt(s) {
1324
1349
  }
1325
1350
  return e;
1326
1351
  }
1327
- function Je(s, e, t) {
1352
+ function Se(s, e, t) {
1328
1353
  if (typeof window > "u")
1329
1354
  return;
1330
1355
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -1343,29 +1368,29 @@ function Je(s, e, t) {
1343
1368
  };
1344
1369
  window.dispatchEvent(new CustomEvent("product-agent:trace", { detail: i }));
1345
1370
  }
1346
- class Se extends Error {
1371
+ class Te extends Error {
1347
1372
  }
1348
1373
  function Nn(s) {
1349
1374
  return s === 408 || s === 425 || s === 429 || s >= 500;
1350
1375
  }
1351
- const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
1376
+ const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Jn = 6e4, Xn = 8, Yn = "Browser connection was interrupted.", $t = 15e3, Zn = "Pluno could not send this message. Try it again.", ei = "Still connecting to Pluno. Retrying automatically.", ti = 2e3, si = 1e3, ni = 100, jt = 8e3, zt = 3, ii = [300, 1e3], Ts = 50 * 1024 * 1024, ri = /* @__PURE__ */ new Set([
1352
1377
  ".jpeg:image/jpeg",
1353
1378
  ".jpg:image/jpeg",
1354
1379
  ".pdf:application/pdf",
1355
1380
  ".png:image/png",
1356
1381
  ".webp:image/webp"
1357
- ]), ko = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", xe = "pluno.productAgent.activeToolCalls.", ci = 100;
1358
- function ui(s, e = 0) {
1382
+ ]), _o = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, oi = 2e3, ai = 1e3, ws = "Image is too large for model vision input.", li = 100, ci = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", Le = "pluno.productAgent.activeToolCalls.", ui = 100;
1383
+ function di(s, e = 0) {
1359
1384
  const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
1360
1385
  return Math.max(e, t);
1361
1386
  }
1362
- const Ee = /* @__PURE__ */ new Set();
1363
- let Te = null;
1364
- function di(s, e = Math.random) {
1387
+ const Ce = /* @__PURE__ */ new Set();
1388
+ let we = null;
1389
+ function hi(s, e = Math.random) {
1365
1390
  const t = Math.min(ot, Qn * 2 ** s), n = 1 - Wt + e() * Wt * 2;
1366
1391
  return Math.min(ot, Math.round(t * n));
1367
1392
  }
1368
- function hi(s) {
1393
+ function pi(s) {
1369
1394
  const e = s.split(".")[1];
1370
1395
  if (!e)
1371
1396
  return null;
@@ -1376,8 +1401,8 @@ function hi(s) {
1376
1401
  return null;
1377
1402
  }
1378
1403
  }
1379
- function pi(s) {
1380
- if (s instanceof X)
1404
+ function gi(s) {
1405
+ if (s instanceof J)
1381
1406
  return s.retryable;
1382
1407
  if (s && typeof s == "object") {
1383
1408
  const e = s.status;
@@ -1386,7 +1411,7 @@ function pi(s) {
1386
1411
  }
1387
1412
  return !0;
1388
1413
  }
1389
- function gi(s) {
1414
+ function fi(s) {
1390
1415
  if (s instanceof Error)
1391
1416
  return s;
1392
1417
  if (s && typeof s == "object") {
@@ -1398,7 +1423,7 @@ function gi(s) {
1398
1423
  }
1399
1424
  return new Error(String(s));
1400
1425
  }
1401
- class Le {
1426
+ class Ne {
1402
1427
  constructor(e, t) {
1403
1428
  this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new Mn(
1404
1429
  e.clientId,
@@ -1441,11 +1466,11 @@ class Le {
1441
1466
  activeIntervalMs: 3e3,
1442
1467
  idleIntervalMs: 15e3,
1443
1468
  maxFailureIntervalMs: 3e4
1444
- }), this.personalModelSelectionOverride = e.productVariant === "personal" && Qe(e.model) ? e.model : null, this.state = {
1469
+ }), this.personalModelSelectionOverride = e.productVariant === "personal" && Ve(e.model) ? e.model : null, this.state = {
1445
1470
  ...this.state,
1446
- starterPrompts: Gi(e.initialStarterPrompts)
1471
+ starterPrompts: Ji(e.initialStarterPrompts)
1447
1472
  }, this.account = e.initialAccount ? { ...e.initialAccount } : null;
1448
- const n = e.restorePersistedState === !1 ? null : Lr(e.clientId, e.expectedPersistedSessionId);
1473
+ const n = e.restorePersistedState === !1 ? null : Br(e.clientId, e.expectedPersistedSessionId);
1449
1474
  n && (this.state = {
1450
1475
  ...this.state,
1451
1476
  ...n,
@@ -1466,9 +1491,9 @@ class Le {
1466
1491
  taskStatus: null,
1467
1492
  isRetrying: !1,
1468
1493
  lastError: null
1469
- }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = $r(
1470
- Hr(e.clientId),
1471
- Br(e.clientId)
1494
+ }, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = Kr(
1495
+ Fr(e.clientId),
1496
+ $r(e.clientId)
1472
1497
  );
1473
1498
  const i = [...this.queuedClientEvents].reverse().find(
1474
1499
  (r) => r.type === "chat.user_message" && typeof r.clientMessageId == "string"
@@ -1533,6 +1558,9 @@ class Le {
1533
1558
  retryAttemptsByClientMessageId = {};
1534
1559
  retryTimersByClientMessageId = {};
1535
1560
  reportedHealthSignalKeys = /* @__PURE__ */ new Set();
1561
+ firstResponseTimersByClientMessageId = /* @__PURE__ */ new Map();
1562
+ lastProjectedTurnPhase = null;
1563
+ lastProjectedTurnClientMessageId = null;
1536
1564
  /** @internal */
1537
1565
  transportDiagnosticEpisodes = /* @__PURE__ */ new Map();
1538
1566
  /** @internal */
@@ -1613,12 +1641,12 @@ class Le {
1613
1641
  static async init(e) {
1614
1642
  const t = e, n = await un(
1615
1643
  t.skipStoredTransportIdentityCollisionCheck === !0
1616
- ), i = new Le({
1644
+ ), i = new Ne({
1617
1645
  ...e,
1618
- backendUrl: Ui(e.backendUrl ?? Hn),
1619
- clientId: e.clientId ?? Yi(),
1646
+ backendUrl: Oi(e.backendUrl ?? Hn),
1647
+ clientId: e.clientId ?? tr(),
1620
1648
  productVariant: e.productVariant ?? "customer_embedded",
1621
- entrySurface: Di(e.entrySurface)
1649
+ entrySurface: xi(e.entrySurface)
1622
1650
  }, n);
1623
1651
  try {
1624
1652
  Qs().catch((r) => {
@@ -1679,7 +1707,7 @@ class Le {
1679
1707
  let a = null;
1680
1708
  const l = new Promise((c, u) => {
1681
1709
  a = window.setTimeout(() => {
1682
- r.abort(), u(new X("Pluno token provider timed out", !0));
1710
+ r.abort(), u(new J("Pluno token provider timed out", !0));
1683
1711
  }, Fn);
1684
1712
  });
1685
1713
  try {
@@ -1688,10 +1716,10 @@ class Le {
1688
1716
  l
1689
1717
  ]);
1690
1718
  if (r.signal.aborted || this.tokenAbortController !== r)
1691
- throw new X("Pluno token request was cancelled", !0);
1719
+ throw new J("Pluno token request was cancelled", !0);
1692
1720
  if (!c)
1693
- throw new X("Pluno token provider did not return a token", !1);
1694
- return this.token = c, this.tokenExpiresAtMs = hi(c), c;
1721
+ throw new J("Pluno token provider did not return a token", !1);
1722
+ return this.token = c, this.tokenExpiresAtMs = pi(c), c;
1695
1723
  } finally {
1696
1724
  a !== null && window.clearTimeout(a);
1697
1725
  }
@@ -1715,8 +1743,8 @@ class Le {
1715
1743
  if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
1716
1744
  return;
1717
1745
  if (!this.token && !this.options.webSocketFactory)
1718
- throw new X("Pluno requires a token or tokenProvider", !1);
1719
- const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1746
+ throw new J("Pluno requires a token or tokenProvider", !1);
1747
+ const t = Hi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
1720
1748
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
1721
1749
  this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
1722
1750
  }, jn), n.addEventListener("open", () => {
@@ -1733,11 +1761,11 @@ class Le {
1733
1761
  this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
1734
1762
  }, zn));
1735
1763
  }), n.addEventListener("message", (i) => {
1736
- this.socket === n && this.handleServerEvent(zi(i.data));
1764
+ this.socket === n && this.handleServerEvent(Qi(i.data));
1737
1765
  }), n.addEventListener("sendfailure", (i) => {
1738
1766
  if (this.socket !== n)
1739
1767
  return;
1740
- const r = Ki(i?.detail?.data);
1768
+ const r = Vi(i?.detail?.data);
1741
1769
  r?.type === "chat.user_message" && r.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
1742
1770
  (o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
1743
1771
  ) && (this.queuedClientEvents.push(r), V(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
@@ -1761,17 +1789,17 @@ class Le {
1761
1789
  } catch (t) {
1762
1790
  if (e !== this.connectionAttemptId || this.state.status === "closed")
1763
1791
  return;
1764
- const n = gi(t);
1765
- if (pi(t)) {
1792
+ const n = fi(t);
1793
+ if (gi(t)) {
1766
1794
  b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
1767
1795
  message: n.message,
1768
1796
  reconnectAttempt: this.reconnectAttempts
1769
- }), t instanceof X && this.reportTransportDiagnostic("auth_timeout"), this.setState({
1797
+ }), t instanceof J && this.reportTransportDiagnostic("auth_timeout"), this.setState({
1770
1798
  status: "reconnecting",
1771
- lastError: Zn,
1799
+ lastError: ei,
1772
1800
  lastErrorCode: "connection_failed"
1773
1801
  }), this.emit("error", n), this.scheduleReconnect(
1774
- t instanceof X ? t.retryAfterMs : void 0
1802
+ t instanceof J ? t.retryAfterMs : void 0
1775
1803
  );
1776
1804
  return;
1777
1805
  }
@@ -1785,16 +1813,16 @@ class Le {
1785
1813
  }
1786
1814
  }
1787
1815
  disconnect() {
1788
- this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
1816
+ this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
1789
1817
  }
1790
1818
  destroy() {
1791
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
1819
+ this.disconnect(), this.clearAllFirstResponseTimers(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Gr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
1792
1820
  for (const e of Object.values(this.listeners))
1793
1821
  e?.clear();
1794
1822
  this.accountListeners.clear(), this.interactionListeners.clear();
1795
1823
  }
1796
1824
  warmup(e = "panel_open") {
1797
- const t = P(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
1825
+ const t = _(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
1798
1826
  type: "runtime.warmup",
1799
1827
  reason: e,
1800
1828
  ...e === "composer_input" ? { warmupId: i?.event.warmupId ?? x() } : {},
@@ -1821,7 +1849,7 @@ class Le {
1821
1849
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1822
1850
  entrySurface: this.options.entrySurface,
1823
1851
  ...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
1824
- pageOrigin: P().origin
1852
+ pageOrigin: _().origin
1825
1853
  }
1826
1854
  };
1827
1855
  this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
@@ -1833,12 +1861,12 @@ class Le {
1833
1861
  0
1834
1862
  ) > Ts))
1835
1863
  throw new Error("Embedded attachments must total at most 50 MB per message");
1836
- let r = i.map(De);
1864
+ let r = i.map(qe);
1837
1865
  if (!n && r.length === 0)
1838
1866
  return null;
1839
1867
  if (this.pendingClientMessageId)
1840
1868
  throw new Error("Wait for the current message to finish sending before sending another.");
1841
- const o = P(), a = t.clientMessageId ?? x(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
1869
+ const o = _(), a = t.clientMessageId ?? x(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
1842
1870
  (S) => S.id === this.stagedProactiveSuggestionQuestionMessageId
1843
1871
  ) ?? null : null, u = l ? {
1844
1872
  id: `local-proactive-suggestion-question-${a}`,
@@ -1884,7 +1912,7 @@ class Le {
1884
1912
  taskStatus: "working",
1885
1913
  isRetrying: !1,
1886
1914
  lastError: null
1887
- }), g || (this.sessionHistoryManager.addOptimistic({
1915
+ }), this.startFirstResponseTimer(a, t.submittedAt), g || (this.sessionHistoryManager.addOptimistic({
1888
1916
  id: d.id,
1889
1917
  title: null,
1890
1918
  customTitle: null,
@@ -1910,7 +1938,7 @@ class Le {
1910
1938
  }
1911
1939
  r = S;
1912
1940
  } catch (S) {
1913
- throw g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1941
+ throw this.clearFirstResponseTimer(a), g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
1914
1942
  ...g ? {} : { messages: m },
1915
1943
  ...f ? {} : { ...w, isThinking: !1 },
1916
1944
  pendingMessageStatus: p,
@@ -1924,23 +1952,32 @@ class Le {
1924
1952
  sessionId: this.state.sessionId ?? void 0,
1925
1953
  clientMessageId: a,
1926
1954
  initiatedBy: t.initiatedBy,
1927
- invocation: qi(t.invocation ?? t.initiatedBy),
1955
+ invocation: Li(t.invocation ?? t.initiatedBy),
1928
1956
  entrySurface: this.options.entrySurface,
1929
1957
  content: n,
1930
1958
  proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
1931
1959
  pageContent: D && At() || void 0,
1932
- attachments: r.length > 0 ? r.map(De) : void 0,
1960
+ attachments: r.length > 0 ? r.map(qe) : void 0,
1933
1961
  page: o,
1934
1962
  model: this.options.model,
1935
1963
  metadata: Kt(this.options.metadata)
1936
1964
  };
1937
1965
  return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
1938
1966
  }
1967
+ reportInvalidStateTransition(e, t) {
1968
+ this.reportHealthSignal("invalid_state_transition", {
1969
+ reason: e,
1970
+ clientMessageId: t
1971
+ });
1972
+ }
1973
+ reportDisplayedError(e, t) {
1974
+ this.reportHealthSignal("user_visible_error", { reason: e, errorFingerprint: t });
1975
+ }
1939
1976
  getModel() {
1940
1977
  return this.options.model;
1941
1978
  }
1942
1979
  setModel(e) {
1943
- this.options.model = e, this.options.productVariant === "personal" && Qe(e) && (this.personalModelSelectionOverride = e);
1980
+ this.options.model = e, this.options.productVariant === "personal" && Ve(e) && (this.personalModelSelectionOverride = e);
1944
1981
  }
1945
1982
  retryLastMessage() {
1946
1983
  const e = this.state.sessionId, t = this.retryableClientMessageId;
@@ -1958,7 +1995,7 @@ class Le {
1958
1995
  return e ? (this.retryAttemptsByClientMessageId[t] = 0, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.activeClientMessageId = t, this.latestRecoverableClientMessageId = t, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: t, automatic: !1 }), !0) : !1;
1959
1996
  }
1960
1997
  createLocalAttachment(e) {
1961
- this.options.productVariant === "customer_embedded" && zr(e);
1998
+ this.options.productVariant === "customer_embedded" && Qr(e);
1962
1999
  const t = x(), n = {
1963
2000
  id: t,
1964
2001
  name: e.name || "attachment",
@@ -1973,7 +2010,7 @@ class Le {
1973
2010
  mimeType: n.mimeType,
1974
2011
  sizeBytes: n.sizeBytes,
1975
2012
  blob: e,
1976
- origin: P().origin,
2013
+ origin: _().origin,
1977
2014
  sessionId: this.state.sessionId ?? void 0,
1978
2015
  createdAt: i,
1979
2016
  lastUsedAt: i
@@ -2004,23 +2041,23 @@ class Le {
2004
2041
  name: e.name || "attachment",
2005
2042
  mimeType: i,
2006
2043
  sizeBytes: e.size,
2007
- page: P(),
2044
+ page: _(),
2008
2045
  model: this.options.model,
2009
2046
  metadata: Kt(this.options.metadata),
2010
2047
  entrySurface: this.options.entrySurface
2011
2048
  };
2012
2049
  let o;
2013
2050
  if (this.options.persistAttachmentUpload)
2014
- o = await Me(
2051
+ o = await be(
2015
2052
  () => this.options.persistAttachmentUpload(r, e),
2016
2053
  "Failed to upload attachment"
2017
2054
  );
2018
2055
  else {
2019
- const l = this.options.prepareAttachmentUpload ? await Me(
2056
+ const l = this.options.prepareAttachmentUpload ? await be(
2020
2057
  () => this.options.prepareAttachmentUpload(r),
2021
2058
  "Failed to prepare attachment upload"
2022
2059
  ) : await this.prepareEmbedAttachmentUpload(r);
2023
- await Me(async () => {
2060
+ await be(async () => {
2024
2061
  const c = await fetch(new URL(l.uploadUrl, this.options.backendUrl), {
2025
2062
  method: l.uploadMethod,
2026
2063
  headers: l.uploadHeaders,
@@ -2060,11 +2097,11 @@ class Le {
2060
2097
  }
2061
2098
  async prepareEmbedAttachmentUpload(e) {
2062
2099
  let t = !1;
2063
- return await Me(async () => {
2100
+ return await be(async () => {
2064
2101
  const n = await this.fetchEmbedAttachmentUpload(e, !1);
2065
2102
  if (n.ok)
2066
2103
  return await n.json();
2067
- if (lo(n.status) && this.options.tokenProvider && !t) {
2104
+ if (ho(n.status) && this.options.tokenProvider && !t) {
2068
2105
  t = !0;
2069
2106
  const i = await this.fetchEmbedAttachmentUpload(e, !0);
2070
2107
  if (i.ok)
@@ -2089,7 +2126,7 @@ class Le {
2089
2126
  if (!this.state.sessionId)
2090
2127
  return;
2091
2128
  this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
2092
- const e = Er(
2129
+ const e = Pr(
2093
2130
  this.state.messages,
2094
2131
  this.state.assistantDraftRespondsToUserMessageId,
2095
2132
  this.state.assistantDraftRunId,
@@ -2104,7 +2141,7 @@ class Le {
2104
2141
  stoppedCausalSequence: null,
2105
2142
  toolCallIds: new Set(
2106
2143
  this.state.messages.filter(
2107
- (t) => Ae(
2144
+ (t) => Me(
2108
2145
  t,
2109
2146
  e.respondsToUserMessageId,
2110
2147
  e.runId
@@ -2132,11 +2169,11 @@ class Le {
2132
2169
  startNewSession(e = {}) {
2133
2170
  this.stopSessionRecoveryPolling();
2134
2171
  const t = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
2135
- !this.options.keepRunsActiveOnSessionNavigation && t && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((i) => i.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), t && this.send({
2172
+ !this.options.keepRunsActiveOnSessionNavigation && t && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((i) => i.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), t && this.send({
2136
2173
  type: "session.reset",
2137
2174
  sessionId: this.state.sessionId ?? void 0,
2138
2175
  warmupId: n ?? void 0,
2139
- page: P()
2176
+ page: _()
2140
2177
  }), this.setState({
2141
2178
  sessionId: null,
2142
2179
  starterPrompts: [...this.state.starterPrompts],
@@ -2164,7 +2201,7 @@ class Le {
2164
2201
  }), i = {
2165
2202
  type: "sessions.list",
2166
2203
  requestId: t,
2167
- page: P(),
2204
+ page: _(),
2168
2205
  ...e.cursor ? { cursor: e.cursor } : {},
2169
2206
  ...e.limit ? { limit: e.limit } : {},
2170
2207
  ...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
@@ -2399,12 +2436,12 @@ class Le {
2399
2436
  loadSession(e) {
2400
2437
  const t = x(), n = this.activeComposerWarmupId;
2401
2438
  this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages);
2402
- const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Rr(i ?? []);
2439
+ const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Cr(i ?? []);
2403
2440
  !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
2404
2441
  type: "session.reset",
2405
2442
  warmupId: n,
2406
- page: P()
2407
- }), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.options.productVariant === "personal" && this.state.sessionId !== e && (this.personalModelSelectionOverride = null, this.options.model = void 0), this.clearSessionLoadRequest(), this.sessionLoadRequestId = t, this.sessionActivityRequestId = null, this.setState({
2443
+ page: _()
2444
+ }), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.options.productVariant === "personal" && this.state.sessionId !== e && (this.personalModelSelectionOverride = null, this.options.model = void 0), this.clearSessionLoadRequest(), this.sessionLoadRequestId = t, this.sessionActivityRequestId = null, this.setState({
2408
2445
  sessionId: e,
2409
2446
  // A session-keyed timeline can render immediately while the subscription handshake and authoritative
2410
2447
  // history reload preserve the live-event race guarantees for this selected chat.
@@ -2426,7 +2463,7 @@ class Le {
2426
2463
  type: "session.load",
2427
2464
  requestId: t,
2428
2465
  sessionId: e,
2429
- page: P()
2466
+ page: _()
2430
2467
  });
2431
2468
  }
2432
2469
  canLoadSessionHistoryOverHttp() {
@@ -2472,7 +2509,7 @@ class Le {
2472
2509
  type: "session.load",
2473
2510
  requestId: t,
2474
2511
  sessionId: e,
2475
- page: P(),
2512
+ page: _(),
2476
2513
  subscribeOnly: !0
2477
2514
  }), n;
2478
2515
  }
@@ -2505,7 +2542,7 @@ class Le {
2505
2542
  try {
2506
2543
  return await this.fetchSessionHistoryPageOnce(e, t, n);
2507
2544
  } catch (o) {
2508
- if (o instanceof Se)
2545
+ if (o instanceof Te)
2509
2546
  throw o;
2510
2547
  b("web-sdk.history", "HTTP session history page failed; retrying", {
2511
2548
  sessionId: e,
@@ -2519,7 +2556,7 @@ class Le {
2519
2556
  async fetchSessionHistoryPageOnce(e, t, n, i = !1) {
2520
2557
  const r = await this.acquireToken("history", { preferCached: i });
2521
2558
  if (!r)
2522
- throw new Se("Product Agent history requires authentication");
2559
+ throw new Te("Product Agent history requires authentication");
2523
2560
  this.token = r;
2524
2561
  const o = new URLSearchParams({ limit: "200" });
2525
2562
  n && o.set("cursor", n);
@@ -2533,11 +2570,11 @@ class Le {
2533
2570
  });
2534
2571
  if (!c.ok) {
2535
2572
  const d = await c.text() || `History request failed (${c.status})`;
2536
- throw Nn(c.status) ? new Error(d) : new Se(d);
2573
+ throw Nn(c.status) ? new Error(d) : new Te(d);
2537
2574
  }
2538
2575
  const u = await c.json();
2539
2576
  if (!u?.session || !Array.isArray(u.items))
2540
- throw new Se("Invalid Product Agent session history response");
2577
+ throw new Te("Invalid Product Agent session history response");
2541
2578
  return {
2542
2579
  session: u.session,
2543
2580
  items: u.items,
@@ -2588,7 +2625,7 @@ class Le {
2588
2625
  return !1;
2589
2626
  const t = this.socket;
2590
2627
  try {
2591
- return t.send(JSON.stringify(e)), Je("client_event", e.type, Bt(e)), !0;
2628
+ return t.send(JSON.stringify(e)), Se("client_event", e.type, Bt(e)), !0;
2592
2629
  } catch (n) {
2593
2630
  return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
2594
2631
  message: n instanceof Error ? n.message : String(n),
@@ -2598,9 +2635,9 @@ class Le {
2598
2635
  }
2599
2636
  }
2600
2637
  reportHealthSignal(e, t = {}) {
2601
- const n = t.clientMessageId ?? this.activeResponseRunId;
2638
+ const n = t.errorFingerprint ?? t.clientMessageId ?? this.activeResponseRunId ?? (t.previousPhase && t.nextPhase ? `${t.previousPhase}:${t.nextPhase}:${t.reason ?? "unknown"}` : null);
2602
2639
  if (n) {
2603
- const r = `${e}:${n}`;
2640
+ const r = `${e}:${n}:${e === "invalid_state_transition" ? t.reason ?? "unknown" : ""}`;
2604
2641
  if (this.reportedHealthSignalKeys.has(r))
2605
2642
  return;
2606
2643
  this.reportedHealthSignalKeys.add(r);
@@ -2615,7 +2652,7 @@ class Le {
2615
2652
  ...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
2616
2653
  ...t
2617
2654
  };
2618
- if (this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN) {
2655
+ if (Se("client_event", "runtime.health", { ...i, signalName: e }), this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN || this.authenticatedSocket !== this.socket) {
2619
2656
  this.queueHealthDiagnostic(i);
2620
2657
  return;
2621
2658
  }
@@ -2631,6 +2668,27 @@ class Le {
2631
2668
  }), this.queueHealthDiagnostic(i);
2632
2669
  }
2633
2670
  }
2671
+ startFirstResponseTimer(e, t) {
2672
+ this.clearFirstResponseTimer(e);
2673
+ const n = t ?? Date.now(), i = window.setTimeout(() => {
2674
+ this.firstResponseTimersByClientMessageId.delete(e), this.reportHealthSignal("first_response_slow", {
2675
+ clientMessageId: e,
2676
+ durationMs: Date.now() - n
2677
+ });
2678
+ }, Math.max(0, Jn - (Date.now() - n)));
2679
+ this.firstResponseTimersByClientMessageId.set(e, { submittedAt: n, timer: i });
2680
+ }
2681
+ clearFirstResponseTimer(e) {
2682
+ if (!e)
2683
+ return;
2684
+ const t = this.firstResponseTimersByClientMessageId.get(e);
2685
+ t && (window.clearTimeout(t.timer), this.firstResponseTimersByClientMessageId.delete(e));
2686
+ }
2687
+ clearAllFirstResponseTimers() {
2688
+ for (const { timer: e } of this.firstResponseTimersByClientMessageId.values())
2689
+ window.clearTimeout(e);
2690
+ this.firstResponseTimersByClientMessageId.clear();
2691
+ }
2634
2692
  /** @internal */
2635
2693
  reportTransportDiagnostic(e, t = {}) {
2636
2694
  const n = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", i = `${e}:${t.closeCode ?? "none"}:${n}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(i), a = {
@@ -2727,7 +2785,7 @@ class Le {
2727
2785
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
2728
2786
  return;
2729
2787
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
2730
- const e = Li();
2788
+ const e = Bi();
2731
2789
  this.sendNow(
2732
2790
  L({
2733
2791
  type: "starter_prompts.page_context",
@@ -2738,13 +2796,13 @@ class Le {
2738
2796
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
2739
2797
  }
2740
2798
  startStarterPromptUrlWatcher() {
2741
- this.locationChangeCleanup || (this.locationChangeCleanup = Ni(() => this.handleStarterPromptUrlChange()));
2799
+ this.locationChangeCleanup || (this.locationChangeCleanup = Wi(() => this.handleStarterPromptUrlChange()));
2742
2800
  }
2743
2801
  handleStarterPromptUrlChange() {
2744
2802
  const e = location.href;
2745
2803
  e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
2746
2804
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
2747
- }, ci));
2805
+ }, ui));
2748
2806
  }
2749
2807
  refreshStarterPromptsForCurrentUrl() {
2750
2808
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -2774,7 +2832,7 @@ class Le {
2774
2832
  }
2775
2833
  rememberSessionTimeline(e, t) {
2776
2834
  const n = [...t];
2777
- for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > li; ) {
2835
+ for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > ci; ) {
2778
2836
  const i = this.sessionTimelineCache.keys().next().value;
2779
2837
  if (!i)
2780
2838
  break;
@@ -2826,7 +2884,7 @@ class Le {
2826
2884
  }
2827
2885
  rememberDurablyStoppedTurn(e, t) {
2828
2886
  const n = C(t);
2829
- if (!e || !n || !Ce(n) || this.findStoppedTurn(e, n))
2887
+ if (!e || !n || !_e(n) || this.findStoppedTurn(e, n))
2830
2888
  return;
2831
2889
  const i = O(n), r = k(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
2832
2890
  this.stoppedTurns.push({
@@ -2837,10 +2895,10 @@ class Le {
2837
2895
  reason: A(n, "reason"),
2838
2896
  stoppedItemId: A(t, "id"),
2839
2897
  stoppedAt: A(t, "createdAt"),
2840
- stoppedCausalSequence: _(n),
2898
+ stoppedCausalSequence: P(n),
2841
2899
  toolCallIds: new Set(
2842
2900
  this.state.messages.filter(
2843
- (a) => Ae(a, i, r)
2901
+ (a) => Me(a, i, r)
2844
2902
  ).map((a) => a.callId).filter((a) => typeof a == "string")
2845
2903
  )
2846
2904
  }), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
@@ -2858,15 +2916,15 @@ class Le {
2858
2916
  const n = typeof e.callId == "string" ? e.callId : null;
2859
2917
  return !!(n && this.stoppedTurns.some((i) => i.toolCallIds.has(n)));
2860
2918
  }
2861
- return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !Ce(C(e.item)) : e.type !== "conversation.state" : !1;
2919
+ return this.findStoppedTurnForEvent(e) ? e.type === "session.item" ? !_e(C(e.item)) : e.type !== "conversation.state" : !1;
2862
2920
  }
2863
2921
  filterStoppedSnapshotItems(e, t) {
2864
2922
  return e.filter((n) => {
2865
2923
  const i = C(n), r = i ? this.findStoppedTurn(t, i) : null;
2866
- if (!r || i?.type === "message" && i.role === "user" || Ce(i))
2924
+ if (!r || i?.type === "message" && i.role === "user" || _e(i))
2867
2925
  return !0;
2868
2926
  if (r.stoppedCausalSequence !== null) {
2869
- const o = i ? _(i) : null;
2927
+ const o = i ? P(i) : null;
2870
2928
  return o === null || o <= r.stoppedCausalSequence;
2871
2929
  }
2872
2930
  if (r.stoppedAt) {
@@ -2877,7 +2935,7 @@ class Le {
2877
2935
  });
2878
2936
  }
2879
2937
  handleServerEvent(e) {
2880
- if (Je("server_event", e.type, Bt(e)), e.type === "session.subscribed") {
2938
+ if (Se("server_event", e.type, Bt(e)), e.type === "session.subscribed") {
2881
2939
  const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
2882
2940
  if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
2883
2941
  const i = this.pendingSessionSubscription;
@@ -2928,7 +2986,7 @@ class Le {
2928
2986
  }
2929
2987
  }
2930
2988
  if (!this.shouldIgnoreStoppedTurnEvent(e) && (this.updateInactiveSessionTimelineCache(e), !this.shouldIgnoreBackgroundSessionEvent(e))) {
2931
- if (e.type === "run.steered") {
2989
+ if (Si(e) && this.clearFirstResponseTimer(this.activeClientMessageId), e.type === "run.steered") {
2932
2990
  this.handleRunSteered(e);
2933
2991
  return;
2934
2992
  }
@@ -2943,16 +3001,16 @@ class Le {
2943
3001
  this.activeResponseRunId = t, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
2944
3002
  return;
2945
3003
  }
2946
- if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
3004
+ if (Ii(e) && this.markThinkingProgress(), e.type === "auth.ok") {
2947
3005
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear();
2948
- const t = Zi(e.user);
3006
+ const t = sr(e.user);
2949
3007
  this.authenticatedSocket !== this.socket && this.authenticatedUserId && t && t.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = t?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
2950
- const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
3008
+ const n = Xi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
2951
3009
  b("web-sdk.agent", "Received auth.ok appearance", {
2952
3010
  hasAppearance: i,
2953
3011
  rawAppearance: e.appearance,
2954
3012
  normalizedAppearance: n
2955
- }), this.runtimeHelperJavascript = Vi(e.runtimeHelpers)?.javascript ?? null;
3013
+ }), this.runtimeHelperJavascript = Yi(e.runtimeHelpers)?.javascript ?? null;
2956
3014
  const r = Vt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
2957
3015
  user: t,
2958
3016
  status: "connected",
@@ -2965,7 +3023,7 @@ class Le {
2965
3023
  }), o && r.length === 0 && !a && !et() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
2966
3024
  type: "page.upsert",
2967
3025
  sessionId: this.state.sessionId,
2968
- page: P(),
3026
+ page: _(),
2969
3027
  model: this.options.model
2970
3028
  });
2971
3029
  return;
@@ -2979,7 +3037,7 @@ class Le {
2979
3037
  }
2980
3038
  if (e.type === "scheduled_follow_ups.updated") {
2981
3039
  typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
2982
- activeScheduledFollowUps: Xt(
3040
+ activeScheduledFollowUps: Jt(
2983
3041
  e.activeScheduledFollowUps
2984
3042
  )
2985
3043
  });
@@ -3003,7 +3061,7 @@ class Le {
3003
3061
  runId: u?.runId
3004
3062
  }), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
3005
3063
  f && h && (this.pendingClientMessageId = h);
3006
- let m = ar(
3064
+ let m = ur(
3007
3065
  e.assistantDraft
3008
3066
  );
3009
3067
  m && this.findStoppedTurn(r, {
@@ -3012,9 +3070,9 @@ class Le {
3012
3070
  }) && (m = void 0);
3013
3071
  const M = m !== void 0;
3014
3072
  this.rememberUserMessageClientMessageIds(g);
3015
- const w = Tr(g), D = g.filter((U) => {
3073
+ const w = Mr(g), D = g.filter((U) => {
3016
3074
  const q = C(U);
3017
- return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
3075
+ return wr(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
3018
3076
  }), S = lt(
3019
3077
  this.state.messages,
3020
3078
  st(D, this.options.backendUrl)
@@ -3025,18 +3083,18 @@ class Le {
3025
3083
  v,
3026
3084
  re,
3027
3085
  Y,
3028
- wr(g, q)
3086
+ br(g, q)
3029
3087
  )
3030
- ), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
3031
- if (!T && Sr(this.state.messages, g))
3088
+ ), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = Sr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
3089
+ if (!T && Ar(this.state.messages, g))
3032
3090
  return;
3033
- this.lastUserMessagePageUrl = yr(g);
3091
+ this.lastUserMessagePageUrl = Tr(g);
3034
3092
  const j = B || d ? null : ut(g);
3035
3093
  if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
3036
3094
  sessionId: A(e.session, "id") ?? this.state.sessionId,
3037
3095
  messages: S,
3038
3096
  ...i ? {
3039
- activeScheduledFollowUps: Xt(
3097
+ activeScheduledFollowUps: Jt(
3040
3098
  e.activeScheduledFollowUps
3041
3099
  )
3042
3100
  } : {},
@@ -3103,14 +3161,14 @@ class Le {
3103
3161
  this.options.backendUrl
3104
3162
  );
3105
3163
  t === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
3106
- messages: dr(this.state.messages, i)
3164
+ messages: gr(this.state.messages, i)
3107
3165
  });
3108
3166
  return;
3109
3167
  }
3110
3168
  if (e.type === "sessions.page") {
3111
3169
  const t = typeof e.requestId == "string" ? e.requestId : null, n = t ? this.pendingSessionHistoryRequests.get(t) : null;
3112
3170
  t && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(t), n.resolve({
3113
- sessions: er(e.sessions),
3171
+ sessions: nr(e.sessions),
3114
3172
  nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
3115
3173
  }));
3116
3174
  return;
@@ -3143,21 +3201,21 @@ class Le {
3143
3201
  o && (this.retryableClientMessageId = o);
3144
3202
  return;
3145
3203
  }
3146
- const n = ve(e.item, this.options.backendUrl);
3204
+ const n = Ue(e.item, this.options.backendUrl);
3147
3205
  if (n) {
3148
- const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3149
- n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
3206
+ const i = vr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
3207
+ n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), kr(t) && this.clearRunAckResyncRetryTimer();
3150
3208
  const o = de(this.state.messages, n), a = ss(o), l = ns(
3151
3209
  t,
3152
3210
  this.state.assistantDraft,
3153
3211
  this.state.assistantDraftItemId,
3154
3212
  this.state.assistantDraftRespondsToUserMessageId,
3155
3213
  this.state.assistantDraftRunId,
3156
- _s(
3214
+ Ps(
3157
3215
  o,
3158
3216
  o.findIndex((d) => d.id === n.id)
3159
3217
  )
3160
- ), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c || F(n) && !this.state.isThinking && this.activeClientMessageId === null);
3218
+ ), c = a && (!this.state.assistantDraft || l), u = De(n) && (c || F(n) && !this.state.isThinking && this.activeClientMessageId === null);
3161
3219
  this.setState({
3162
3220
  messages: o,
3163
3221
  ...l ? {
@@ -3217,7 +3275,7 @@ class Le {
3217
3275
  return;
3218
3276
  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(
3219
3277
  this.state.messages.filter(
3220
- (c) => c.dataType !== "assistant_draft" || !Ae(
3278
+ (c) => c.dataType !== "assistant_draft" || !Me(
3221
3279
  c,
3222
3280
  n,
3223
3281
  i
@@ -3322,13 +3380,13 @@ class Le {
3322
3380
  return;
3323
3381
  }
3324
3382
  o && i && r && (this.retryableClientMessageId = r);
3325
- const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
3383
+ const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Ni(a.message);
3326
3384
  l && console.error(l);
3327
3385
  const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = rs(
3328
3386
  this.state.messages,
3329
3387
  c,
3330
3388
  u
3331
- ), g = fr(
3389
+ ), g = Ir(
3332
3390
  d,
3333
3391
  c,
3334
3392
  u
@@ -3372,7 +3430,7 @@ class Le {
3372
3430
  if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
3373
3431
  return;
3374
3432
  const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
3375
- this.options.model = Qe(n) ? n : "gpt-5.6-sol";
3433
+ this.options.model = Ve(n) ? n : "gpt-5.6-sol";
3376
3434
  }
3377
3435
  updateAccountFallbackFromSession(e) {
3378
3436
  const t = e && typeof e == "object" ? e.metadata : null, n = An(t);
@@ -3412,7 +3470,7 @@ class Le {
3412
3470
  const i = C(e.item);
3413
3471
  if (pe(i))
3414
3472
  return;
3415
- const r = ve(e.item, this.options.backendUrl);
3473
+ const r = Ue(e.item, this.options.backendUrl);
3416
3474
  r && this.rememberSessionTimeline(t, de(n, r));
3417
3475
  return;
3418
3476
  }
@@ -3461,7 +3519,7 @@ class Le {
3461
3519
  if (e.type === "chat.assistant_done") {
3462
3520
  const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Dt(
3463
3521
  n.filter(
3464
- (a) => a.dataType !== "assistant_draft" || !Ae(a, i, r)
3522
+ (a) => a.dataType !== "assistant_draft" || !Me(a, i, r)
3465
3523
  ),
3466
3524
  i,
3467
3525
  r,
@@ -3495,7 +3553,7 @@ class Le {
3495
3553
  }
3496
3554
  e.type === "error" && typeof e.requestId != "string" && !is(e, t) && this.rememberSessionTimeline(
3497
3555
  t,
3498
- kr(n, e)
3556
+ _r(n, e)
3499
3557
  );
3500
3558
  }
3501
3559
  }
@@ -3601,7 +3659,7 @@ class Le {
3601
3659
  }, e);
3602
3660
  }
3603
3661
  clearThinkingWatchdog() {
3604
- this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId = null, this.activeResponseUserMessageId = null, this.activeResponseRunId = null, this.activeUserMessageEvent = null;
3662
+ this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.clearFirstResponseTimer(this.activeClientMessageId), this.activeClientMessageId = null, this.activeResponseUserMessageId = null, this.activeResponseRunId = null, this.activeUserMessageEvent = null;
3605
3663
  }
3606
3664
  handleRunAck(e) {
3607
3665
  const t = typeof e.clientMessageId == "string" ? e.clientMessageId : null, n = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId;
@@ -3663,11 +3721,12 @@ class Le {
3663
3721
  }
3664
3722
  t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
3665
3723
  this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
3666
- }, ui(t, ei));
3724
+ }, di(t, ti));
3667
3725
  }
3668
3726
  failPendingDelivery(e) {
3669
3727
  if (this.pendingClientMessageId !== e)
3670
3728
  return;
3729
+ this.clearFirstResponseTimer(e);
3671
3730
  const t = this.pendingUserMessageEvent;
3672
3731
  this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = t, this.retryableClientMessageId = e, this.setState({
3673
3732
  pendingMessageStatus: null,
@@ -3675,7 +3734,7 @@ class Le {
3675
3734
  ...this.state.isThinking ? {} : { turnPhase: null },
3676
3735
  isRetrying: !1,
3677
3736
  ...this.state.isThinking ? {} : { taskStatus: "failed" },
3678
- lastError: Yn,
3737
+ lastError: Zn,
3679
3738
  lastErrorCode: "message_delivery_failed"
3680
3739
  });
3681
3740
  }
@@ -3742,7 +3801,7 @@ class Le {
3742
3801
  ),
3743
3802
  isThinking: !1,
3744
3803
  taskStatus: "failed",
3745
- lastError: Jn,
3804
+ lastError: Yn,
3746
3805
  lastErrorCode: "run_recovery_exhausted"
3747
3806
  }), this.clearThinkingWatchdog();
3748
3807
  return;
@@ -3758,7 +3817,7 @@ class Le {
3758
3817
  this.state.sessionId ? this.send({
3759
3818
  type: "page.upsert",
3760
3819
  sessionId: this.state.sessionId,
3761
- page: P(),
3820
+ page: _(),
3762
3821
  model: this.options.model
3763
3822
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
3764
3823
  }
@@ -3769,7 +3828,7 @@ class Le {
3769
3828
  if (!t || !n || !i)
3770
3829
  return;
3771
3830
  const a = i === "execute_code", l = i === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
3772
- if (!a && !l || !Xr(o)) {
3831
+ if (!a && !l || !Zr(o)) {
3773
3832
  this.setToolMessageLoading(n, !1), this.send({
3774
3833
  type: "tool.result",
3775
3834
  sessionId: t,
@@ -3818,7 +3877,7 @@ class Le {
3818
3877
  let c = null, u;
3819
3878
  c = await this.executeRuntimeHelper(), u = await Gt(
3820
3879
  o,
3821
- _i(e.runtimeContext, this.options.backendUrl)
3880
+ Di(e.runtimeContext, this.options.backendUrl)
3822
3881
  ).catch((d) => ({
3823
3882
  ok: !1,
3824
3883
  exception: {
@@ -3831,7 +3890,7 @@ class Le {
3831
3890
  toolName: i,
3832
3891
  summary: o.summary,
3833
3892
  rawInput: L(o),
3834
- rawOutput: L(Xi(u, c))
3893
+ rawOutput: L(Zi(u, c))
3835
3894
  }), ls(this.options.clientId, this.activeBrowserToolCalls.values()));
3836
3895
  }
3837
3896
  setToolMessageLoading(e, t) {
@@ -3853,10 +3912,10 @@ class Le {
3853
3912
  };
3854
3913
  }
3855
3914
  installSessionBrowserApis() {
3856
- this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Ti();
3915
+ this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Mi();
3857
3916
  }
3858
3917
  cleanupSessionBrowserApis() {
3859
- this.sessionBrowserApisCleanup && (Ci(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3918
+ this.sessionBrowserApisCleanup && (vi(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
3860
3919
  }
3861
3920
  async executeRuntimeHelper() {
3862
3921
  if (!this.runtimeHelperJavascript?.trim())
@@ -3864,31 +3923,31 @@ class Le {
3864
3923
  const e = await Gt({
3865
3924
  javascript: this.runtimeHelperJavascript
3866
3925
  });
3867
- return e.ok === !1 ? Ji(e) : null;
3926
+ return e.ok === !1 ? er(e) : null;
3868
3927
  }
3869
3928
  enableNetworkCapture() {
3870
- this.networkCaptureCleanup || (this.networkCaptureCleanup = fi((e) => {
3871
- so(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3929
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = mi((e) => {
3930
+ ro(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
3872
3931
  }));
3873
3932
  }
3874
3933
  enqueueNetworkEvent(e) {
3875
- this.queuedNetworkEvents.length >= si || (this.queuedNetworkEvents.push(to(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3934
+ this.queuedNetworkEvents.length >= ni || (this.queuedNetworkEvents.push(io(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
3876
3935
  this.networkBatchTimer = null;
3877
3936
  const t = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
3878
3937
  t.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
3879
3938
  type: "network.batch",
3880
3939
  sessionId: this.state.sessionId ?? void 0,
3881
- page: P(),
3940
+ page: _(),
3882
3941
  events: t
3883
3942
  });
3884
- }, ti)));
3943
+ }, si)));
3885
3944
  }
3886
3945
  scheduleReconnect(e = 0) {
3887
3946
  if (this.reconnectTimer !== null || this.state.status === "closed")
3888
3947
  return;
3889
3948
  const t = Math.min(
3890
3949
  ot,
3891
- Math.max(di(this.reconnectAttempts), e)
3950
+ Math.max(hi(this.reconnectAttempts), e)
3892
3951
  );
3893
3952
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
3894
3953
  this.reconnectTimer = null, this.connect().catch((n) => {
@@ -3943,8 +4002,13 @@ class Le {
3943
4002
  taskStatus: r,
3944
4003
  ...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
3945
4004
  ...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
3946
- }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null;
3947
- this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
4005
+ }, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null, u = this.activeClientMessageId ?? this.pendingClientMessageId;
4006
+ u && u === this.lastProjectedTurnClientMessageId && c && Ti(this.lastProjectedTurnPhase, o.turnPhase) && this.reportHealthSignal("invalid_state_transition", {
4007
+ clientMessageId: u,
4008
+ reason: "active_turn_phase_moved_backward",
4009
+ previousPhase: this.lastProjectedTurnPhase,
4010
+ nextPhase: o.turnPhase
4011
+ }), this.state = o, this.lastProjectedTurnClientMessageId = u, this.lastProjectedTurnPhase = o.turnPhase, 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), Wr(this.options.clientId, this.state), this.emit("state", this.getState()), Se("state", this.state.status, {
3948
4012
  status: this.state.status,
3949
4013
  sessionId: this.state.sessionId,
3950
4014
  messageCount: this.state.messages.length,
@@ -4003,13 +4067,13 @@ class Le {
4003
4067
  }
4004
4068
  }
4005
4069
  const Ze = /* @__PURE__ */ new WeakMap();
4006
- function fi(s) {
4007
- const e = window.__plunoProductAgentNetworkCapture ?? mi();
4070
+ function mi(s) {
4071
+ const e = window.__plunoProductAgentNetworkCapture ?? yi();
4008
4072
  return e.subscribers.add(s), () => {
4009
4073
  e.subscribers.delete(s), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
4010
4074
  };
4011
4075
  }
4012
- function mi() {
4076
+ function yi() {
4013
4077
  const s = /* @__PURE__ */ new Set(), e = (g) => {
4014
4078
  s.forEach((f) => {
4015
4079
  try {
@@ -4026,7 +4090,7 @@ function mi() {
4026
4090
  throw m;
4027
4091
  }
4028
4092
  try {
4029
- const m = f instanceof Request ? f : null, M = Jr(f, m), w = xs(h?.headers ?? m?.headers);
4093
+ const m = f instanceof Request ? f : null, M = eo(f, m), w = xs(h?.headers ?? m?.headers);
4030
4094
  if (!te(M, w, h?.body)) {
4031
4095
  const H = {
4032
4096
  requestId: nt("fetch"),
@@ -4039,7 +4103,7 @@ function mi() {
4039
4103
  };
4040
4104
  y.then(
4041
4105
  (S) => {
4042
- Yr(S, H, p, e).catch(() => {
4106
+ to(S, H, p, e).catch(() => {
4043
4107
  e({
4044
4108
  ...H,
4045
4109
  responseStatus: S.status,
@@ -4081,7 +4145,7 @@ function mi() {
4081
4145
  () => {
4082
4146
  queueMicrotask(() => {
4083
4147
  try {
4084
- const p = io(this.getAllResponseHeaders());
4148
+ const p = ao(this.getAllResponseHeaders());
4085
4149
  e({
4086
4150
  requestId: h.requestId,
4087
4151
  url: h.url,
@@ -4091,7 +4155,7 @@ function mi() {
4091
4155
  resourceType: "xhr",
4092
4156
  responseStatus: this.status,
4093
4157
  responseHeaders: p,
4094
- responseBody: eo(this, p),
4158
+ responseBody: no(this, p),
4095
4159
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
4096
4160
  startedAt: h.startedAt,
4097
4161
  durationMs: Date.now() - h.startedAtMs
@@ -4187,9 +4251,29 @@ function Kt(s) {
4187
4251
  const e = typeof s == "function" ? s() : s;
4188
4252
  return e && Object.keys(e).length > 0 ? e : void 0;
4189
4253
  }
4190
- function yi(s) {
4254
+ function Ii(s) {
4191
4255
  return s.type === "run.model_started" || s.type === "conversation.state" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call";
4192
4256
  }
4257
+ function Si(s) {
4258
+ if (s.type === "chat.assistant_delta")
4259
+ return typeof s.delta == "string" && s.delta.trim().length > 0;
4260
+ if (s.type === "tool.call")
4261
+ return s.hiddenFromTranscript !== !0 && s.replayOnly !== !0;
4262
+ if (s.type !== "session.item")
4263
+ return !1;
4264
+ const e = C(s.item);
4265
+ return e ? e.type === "message" && e.role === "assistant" ? typeof e.content == "string" && e.content.trim().length > 0 : e.type === "tool_call" || e.type === "function_call" : !1;
4266
+ }
4267
+ function Ti(s, e) {
4268
+ if (!s || !e)
4269
+ return !1;
4270
+ const t = {
4271
+ sending: 0,
4272
+ starting: 1,
4273
+ thinking: 2
4274
+ };
4275
+ return t[e] < t[s];
4276
+ }
4193
4277
  function ce(s) {
4194
4278
  return s.type === "run.steered" || s.type === "run.ack" || s.type === "run.model_started" || s.type === "conversation.state" || s.type === "scheduled_follow_ups.updated" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call" || s.type === "tool.status" || s.type === "error" && typeof s.requestId != "string";
4195
4279
  }
@@ -4208,27 +4292,27 @@ function K(s) {
4208
4292
  }
4209
4293
  return null;
4210
4294
  }
4211
- const Ii = 5e3, Si = 12e4;
4212
- function Ti() {
4295
+ const wi = 5e3, Ai = 12e4;
4296
+ function Mi() {
4213
4297
  const s = [
4214
- Ai(),
4215
- wi()
4298
+ Ri(),
4299
+ bi()
4216
4300
  ].filter((e) => typeof e == "function");
4217
4301
  return () => {
4218
4302
  for (const e of s.reverse())
4219
4303
  e();
4220
4304
  };
4221
4305
  }
4222
- function wi() {
4306
+ function bi() {
4223
4307
  return hs(globalThis, "getPageSnapshot", async () => At());
4224
4308
  }
4225
- function Ai() {
4309
+ function Ri() {
4226
4310
  return hs(globalThis, "pageImages", {
4227
- inspectImage: async (e, t) => await Mi(e, t)
4311
+ inspectImage: async (e, t) => await ki(e, t)
4228
4312
  });
4229
4313
  }
4230
- async function Mi(s, e = {}) {
4231
- const t = Ei(e.name), n = await bi(s);
4314
+ async function ki(s, e = {}) {
4315
+ const t = Pi(e.name), n = await Ei(s);
4232
4316
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
4233
4317
  type: "pluno.pageImages.inspectImage",
4234
4318
  imageAttached: !1,
@@ -4246,15 +4330,15 @@ async function Mi(s, e = {}) {
4246
4330
  imageAttachmentError: n.error
4247
4331
  };
4248
4332
  }
4249
- async function bi(s) {
4333
+ async function Ei(s) {
4250
4334
  return s instanceof Blob ? s.type.startsWith("image/") ? s.size === 0 ? { ok: !1, error: "Page image is empty." } : s.size > 8 * 1024 * 1024 ? { ok: !1, error: ws } : {
4251
4335
  ok: !0,
4252
4336
  mimeType: s.type,
4253
4337
  sizeBytes: s.size,
4254
- dataUrl: await Pi(s)
4255
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ri(s);
4338
+ dataUrl: await Ui(s)
4339
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ci(s);
4256
4340
  }
4257
- function Ri(s) {
4341
+ function Ci(s) {
4258
4342
  if (!s.startsWith("data:") || !s.includes(","))
4259
4343
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
4260
4344
  const [e, t] = s.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), i = n[0] ?? "";
@@ -4265,7 +4349,7 @@ function Ri(s) {
4265
4349
  const r = t.replace(/[ \t\r\n\f]+/g, "");
4266
4350
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(r))
4267
4351
  return { ok: !1, error: "Page image data URL has invalid base64." };
4268
- const o = ki(r);
4352
+ const o = _i(r);
4269
4353
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
4270
4354
  ok: !0,
4271
4355
  mimeType: i,
@@ -4273,22 +4357,22 @@ function Ri(s) {
4273
4357
  dataUrl: `data:${i};base64,${r}`
4274
4358
  };
4275
4359
  }
4276
- function ki(s) {
4360
+ function _i(s) {
4277
4361
  if (s.length === 0 || s.length % 4 !== 0)
4278
4362
  return null;
4279
4363
  const e = s.length - s.replace(/=+$/, "").length;
4280
4364
  return e > 2 ? null : s.length / 4 * 3 - e;
4281
4365
  }
4282
- function Ei(s) {
4366
+ function Pi(s) {
4283
4367
  return (typeof s == "string" ? s.trim() : "") || "Page image";
4284
4368
  }
4285
- function Ci(s) {
4369
+ function vi(s) {
4286
4370
  try {
4287
4371
  s();
4288
4372
  } catch {
4289
4373
  }
4290
4374
  }
4291
- function Pi(s) {
4375
+ function Ui(s) {
4292
4376
  return new Promise((e, t) => {
4293
4377
  const n = new FileReader();
4294
4378
  n.onload = () => {
@@ -4302,7 +4386,7 @@ function Pi(s) {
4302
4386
  }
4303
4387
  async function Gt(s, e) {
4304
4388
  const t = Object.getPrototypeOf(async function() {
4305
- }).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
4389
+ }).constructor, n = s.timeoutMs ?? wi, i = Date.now(), r = [];
4306
4390
  let o;
4307
4391
  const a = {
4308
4392
  log: console.log,
@@ -4320,7 +4404,7 @@ async function Gt(s, e) {
4320
4404
  o = window.setTimeout(() => d(c), n);
4321
4405
  })
4322
4406
  ]);
4323
- return u === c ? vi(n) : {
4407
+ return u === c ? qi(n) : {
4324
4408
  ok: !0,
4325
4409
  result: u,
4326
4410
  console: r,
@@ -4349,7 +4433,7 @@ async function Gt(s, e) {
4349
4433
  e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
4350
4434
  }
4351
4435
  }
4352
- function _i(s, e) {
4436
+ function Di(s, e) {
4353
4437
  if (!s || typeof s != "object")
4354
4438
  return;
4355
4439
  const t = s.sandboxFilesToken;
@@ -4393,7 +4477,7 @@ function _i(s, e) {
4393
4477
  }
4394
4478
  };
4395
4479
  }
4396
- function vi(s) {
4480
+ function qi(s) {
4397
4481
  return {
4398
4482
  ok: !1,
4399
4483
  exception: {
@@ -4407,10 +4491,10 @@ function vi(s) {
4407
4491
  }
4408
4492
  };
4409
4493
  }
4410
- function Ui(s) {
4494
+ function Oi(s) {
4411
4495
  return s.replace(/\/+$/, "");
4412
4496
  }
4413
- function Di(s) {
4497
+ function xi(s) {
4414
4498
  const e = {
4415
4499
  sidepanel: "extension_sidepanel",
4416
4500
  browser_extension_page_ui: "extension_widget",
@@ -4422,17 +4506,17 @@ function Di(s) {
4422
4506
  };
4423
4507
  return s && s in e ? e[s] : s ?? "embedded_custom_ui";
4424
4508
  }
4425
- function qi(s) {
4509
+ function Li(s) {
4426
4510
  return s === "pluno" ? "scheduled_continuation" : s ?? "user";
4427
4511
  }
4428
- function Oi(s, e = location.origin) {
4512
+ function Ni(s, e = location.origin) {
4429
4513
  return /origin (?:is not allowed|does not match browser origin)/i.test(s) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
4430
4514
  }
4431
- function xi(s) {
4515
+ function Hi(s) {
4432
4516
  const e = new URL("/api/product-agent/embed/ws", s);
4433
4517
  return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
4434
4518
  }
4435
- function P() {
4519
+ function _() {
4436
4520
  const s = ks();
4437
4521
  return {
4438
4522
  url: location.href,
@@ -4441,21 +4525,21 @@ function P() {
4441
4525
  ...s ? { plunoProductAgentUi: s } : {}
4442
4526
  };
4443
4527
  }
4444
- function Li() {
4528
+ function Bi() {
4445
4529
  return {
4446
4530
  pageUrl: location.href,
4447
4531
  pageTitle: document.title,
4448
4532
  htmlContent: At()
4449
4533
  };
4450
4534
  }
4451
- function Ni(s) {
4452
- return Ee.add(s), Te || (Te = Hi()), () => {
4453
- Ee.delete(s), Ee.size === 0 && (Te?.(), Te = null);
4535
+ function Wi(s) {
4536
+ return Ce.add(s), we || (we = Fi()), () => {
4537
+ Ce.delete(s), Ce.size === 0 && (we?.(), we = null);
4454
4538
  };
4455
4539
  }
4456
- function Hi() {
4540
+ function Fi() {
4457
4541
  const s = () => {
4458
- for (const r of Array.from(Ee))
4542
+ for (const r of Array.from(Ce))
4459
4543
  r();
4460
4544
  }, e = window.history.pushState.bind(window.history), t = window.history.replaceState.bind(window.history), n = ((...r) => {
4461
4545
  const o = e(...r);
@@ -4484,12 +4568,12 @@ function At() {
4484
4568
  );
4485
4569
  for (const p of i.slice(0, 3))
4486
4570
  t("Active overlay", tt(he(p), e));
4487
- const r = Bi(), o = r ? tt(he(r), e) : "";
4571
+ const r = $i(), o = r ? tt(he(r), e) : "";
4488
4572
  t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
4489
4573
  const a = s.map(([p, y]) => `${p}:
4490
4574
  ${y}`).join(`
4491
4575
 
4492
- `).trim().slice(0, 12e3), l = Wi(i, r).trim(), c = `Simplified DOM outline:
4576
+ `).trim().slice(0, 12e3), l = ji(i, r).trim(), c = `Simplified DOM outline:
4493
4577
  `, u = `
4494
4578
 
4495
4579
  Visible page text:
@@ -4517,10 +4601,10 @@ function Ms(s) {
4517
4601
  const e = window.getComputedStyle(s);
4518
4602
  return e.display !== "none" && e.visibility !== "hidden" && s.getClientRects().length > 0;
4519
4603
  }
4520
- function Bi() {
4604
+ function $i() {
4521
4605
  return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ms).sort((s, e) => he(e).length - he(s).length)[0] ?? null;
4522
4606
  }
4523
- function Wi(s, e) {
4607
+ function ji(s, e) {
4524
4608
  const t = /* @__PURE__ */ new Set([
4525
4609
  "main",
4526
4610
  "nav",
@@ -4600,7 +4684,7 @@ function Wi(s, e) {
4600
4684
  "data-test",
4601
4685
  "data-qa",
4602
4686
  "data-cy"
4603
- ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = Fi(), g = new Set(s);
4687
+ ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = zi(), g = new Set(s);
4604
4688
  e && g.add(e);
4605
4689
  let f = 0;
4606
4690
  const h = (w) => {
@@ -4627,41 +4711,41 @@ function Wi(s, e) {
4627
4711
  }
4628
4712
  const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], kt = [];
4629
4713
  for (const I of B) {
4630
- const R = p(I), z = Q.get(R) ?? 0, Pt = j.get(R) ?? 0;
4631
- if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
4714
+ const R = p(I), z = Q.get(R) ?? 0, _t = j.get(R) ?? 0;
4715
+ if (j.set(R, _t + 1), z > 8 && _t >= 6 && !u.has(I)) {
4632
4716
  U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
4633
4717
  continue;
4634
4718
  }
4635
- const _t = S(I, N);
4636
- kt.push(_t), q.push(_t.lines);
4719
+ const Pt = S(I, N);
4720
+ kt.push(Pt), q.push(Pt.lines);
4637
4721
  }
4638
- const Be = [];
4722
+ const We = [];
4639
4723
  if (T.shadowRoot)
4640
4724
  for (const I of Array.from(T.shadowRoot.children))
4641
- I instanceof HTMLElement && Be.push(S(I, N + 1));
4642
- const ye = [...kt, ...Be], We = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
4725
+ I instanceof HTMLElement && We.push(S(I, N + 1));
4726
+ const ye = [...kt, ...We], Fe = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
4643
4727
  [ee, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
4644
- ).slice(0, 180), js = T.hasAttribute("contenteditable") && (ee.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Z || js, Fe = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || Y) && (We || Y) && (!i.has(v) || We || Ct || Y), $e = Fe ? 1 : 0, ae = [];
4645
- if (Fe) {
4728
+ ).slice(0, 180), js = T.hasAttribute("contenteditable") && (ee.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Z || js, $e = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || Y) && (Fe || Y) && (!i.has(v) || Fe || Ct || Y), je = $e ? 1 : 0, ae = [];
4729
+ if ($e) {
4646
4730
  const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et : ee;
4647
4731
  ae.push(bs(T, l, o, R.slice(0, 180)));
4648
4732
  }
4649
4733
  for (const I of q)
4650
- ae.push(...we(I, $e));
4651
- const je = Be.flatMap((I) => I.lines);
4652
- if (je.length > 0) {
4653
- const I = je.slice(0, 20);
4654
- je.length > I.length && I.push("… shadow DOM omitted");
4734
+ ae.push(...Ae(I, je));
4735
+ const ze = We.flatMap((I) => I.lines);
4736
+ if (ze.length > 0) {
4737
+ const I = ze.slice(0, 20);
4738
+ ze.length > I.length && I.push("… shadow DOM omitted");
4655
4739
  const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
4656
4740
  if (N < 2 && !R) {
4657
- const z = Fe ? "#shadow-root" : `${v} #shadow-root`;
4658
- ae.push(...we([z, ...we(I, 1)], $e));
4741
+ const z = $e ? "#shadow-root" : `${v} #shadow-root`;
4742
+ ae.push(...Ae([z, ...Ae(I, 1)], je));
4659
4743
  } else
4660
- ae.push(...we(I, $e));
4744
+ ae.push(...Ae(I, je));
4661
4745
  }
4662
4746
  return {
4663
4747
  lines: ae,
4664
- hasUsefulContent: We,
4748
+ hasUsefulContent: Fe,
4665
4749
  textPreview: Et,
4666
4750
  containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
4667
4751
  };
@@ -4670,7 +4754,7 @@ function Wi(s, e) {
4670
4754
  `);
4671
4755
  }, m = [], M = ne(window.getSelection()?.toString() ?? "");
4672
4756
  M && m.push(`--- selected text ---
4673
- ${JSON.stringify(M)}`), d.length > 0 && m.push($i(d, t, l, o));
4757
+ ${JSON.stringify(M)}`), d.length > 0 && m.push(Ki(d, t, l, o));
4674
4758
  for (const w of s.slice(0, 3))
4675
4759
  m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
4676
4760
  if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
@@ -4685,7 +4769,7 @@ function bs(s, e, t, n) {
4685
4769
  const i = s.tagName.toLowerCase();
4686
4770
  let r = i;
4687
4771
  const o = s.getAttribute("id");
4688
- o && ji(o) && (r += `#${o}`);
4772
+ o && Gi(o) && (r += `#${o}`);
4689
4773
  for (const a of e) {
4690
4774
  const l = s.getAttribute(a);
4691
4775
  l && l.length <= 160 && (a !== "role" || !t.has(l)) && (r += `[${a}=${JSON.stringify(l)}]`);
@@ -4698,7 +4782,7 @@ function bs(s, e, t, n) {
4698
4782
  s.hasAttribute(a) && (r += `[${a}]`);
4699
4783
  return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
4700
4784
  }
4701
- function Fi() {
4785
+ function zi() {
4702
4786
  const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
4703
4787
  if (!a)
4704
4788
  return;
@@ -4741,7 +4825,7 @@ function Fi() {
4741
4825
  priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
4742
4826
  };
4743
4827
  }
4744
- function $i(s, e, t, n) {
4828
+ function Ki(s, e, t, n) {
4745
4829
  const i = ["--- active/current elements ---"];
4746
4830
  for (const r of s) {
4747
4831
  const o = [];
@@ -4766,7 +4850,7 @@ function $i(s, e, t, n) {
4766
4850
  function Qt(s) {
4767
4851
  return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
4768
4852
  }
4769
- function we(s, e) {
4853
+ function Ae(s, e) {
4770
4854
  if (e === 0)
4771
4855
  return s;
4772
4856
  const t = " ".repeat(e);
@@ -4777,7 +4861,7 @@ function Rs(s) {
4777
4861
  Array.from(s.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
4778
4862
  );
4779
4863
  }
4780
- function ji(s) {
4864
+ function Gi(s) {
4781
4865
  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);
4782
4866
  }
4783
4867
  function ks() {
@@ -4814,7 +4898,7 @@ function ks() {
4814
4898
  ]
4815
4899
  };
4816
4900
  }
4817
- function zi(s) {
4901
+ function Qi(s) {
4818
4902
  try {
4819
4903
  const e = JSON.parse(s);
4820
4904
  return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
@@ -4822,7 +4906,7 @@ function zi(s) {
4822
4906
  return { type: "error", message: "Invalid server event" };
4823
4907
  }
4824
4908
  }
4825
- function Ki(s) {
4909
+ function Vi(s) {
4826
4910
  if (typeof s != "string")
4827
4911
  return null;
4828
4912
  try {
@@ -4838,7 +4922,7 @@ function Vt(s, e) {
4838
4922
  const t = s[e];
4839
4923
  return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
4840
4924
  }
4841
- function Xt(s) {
4925
+ function Jt(s) {
4842
4926
  return Array.isArray(s) ? s.flatMap((e) => {
4843
4927
  if (!e || typeof e != "object")
4844
4928
  return [];
@@ -4846,10 +4930,10 @@ function Xt(s) {
4846
4930
  return typeof t.taskId != "string" || !t.taskId || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? [] : [{ taskId: t.taskId, dueAt: t.dueAt }];
4847
4931
  }) : [];
4848
4932
  }
4849
- function Gi(s) {
4933
+ function Ji(s) {
4850
4934
  return Array.isArray(s) ? s.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
4851
4935
  }
4852
- function Qi(s) {
4936
+ function Xi(s) {
4853
4937
  if (!s || typeof s != "object")
4854
4938
  return null;
4855
4939
  const e = s, t = e.appearance, n = t && typeof t == "object" ? t : e, i = typeof n.accentColor == "string" ? n.accentColor : null, r = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -4860,13 +4944,13 @@ function Qi(s) {
4860
4944
  ...a !== null ? { scribbleStyle: a } : {}
4861
4945
  };
4862
4946
  }
4863
- function Vi(s) {
4947
+ function Yi(s) {
4864
4948
  if (!s || typeof s != "object")
4865
4949
  return null;
4866
4950
  const e = s.javascript;
4867
4951
  return typeof e != "string" || !e.trim() ? null : { javascript: e };
4868
4952
  }
4869
- function Xi(s, e) {
4953
+ function Zi(s, e) {
4870
4954
  return e ? s && typeof s == "object" ? {
4871
4955
  ...s,
4872
4956
  helperError: e
@@ -4876,13 +4960,13 @@ function Xi(s, e) {
4876
4960
  helperError: e
4877
4961
  } : s;
4878
4962
  }
4879
- function Ji(s) {
4963
+ function er(s) {
4880
4964
  if (!s || typeof s != "object")
4881
4965
  return s;
4882
4966
  const e = s;
4883
4967
  return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : s;
4884
4968
  }
4885
- function Yi() {
4969
+ function tr() {
4886
4970
  const s = "pluno.productAgent.clientId", e = window.localStorage.getItem(s);
4887
4971
  if (e)
4888
4972
  return e;
@@ -4892,7 +4976,7 @@ function Yi() {
4892
4976
  function x() {
4893
4977
  return crypto.randomUUID();
4894
4978
  }
4895
- function Zi(s) {
4979
+ function sr(s) {
4896
4980
  if (!s || typeof s != "object")
4897
4981
  return null;
4898
4982
  const e = s, t = typeof e.id == "string" ? e.id : null;
@@ -4905,10 +4989,10 @@ function Zi(s) {
4905
4989
  }
4906
4990
  function st(s, e) {
4907
4991
  return Array.isArray(s) ? ht(
4908
- s.map((t) => ve(t, e)).filter((t) => t !== null)
4992
+ s.map((t) => Ue(t, e)).filter((t) => t !== null)
4909
4993
  ) : [];
4910
4994
  }
4911
- function er(s) {
4995
+ function nr(s) {
4912
4996
  return Array.isArray(s) ? s.flatMap((e) => {
4913
4997
  if (!e || typeof e != "object")
4914
4998
  return [];
@@ -4929,7 +5013,7 @@ function er(s) {
4929
5013
  ];
4930
5014
  }) : [];
4931
5015
  }
4932
- function ve(s, e) {
5016
+ function Ue(s, e) {
4933
5017
  if (!s || typeof s != "object")
4934
5018
  return null;
4935
5019
  const t = s, n = t.data;
@@ -4944,12 +5028,12 @@ function ve(s, e) {
4944
5028
  role: "assistant",
4945
5029
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4946
5030
  content: vt(
4947
- Jt(i.content),
5031
+ Xt(i.content),
4948
5032
  e
4949
5033
  ),
4950
5034
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4951
5035
  ...E(i) !== null ? { displaySequence: E(i) } : {},
4952
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5036
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
4953
5037
  respondsToUserMessageId: O(i) ?? void 0,
4954
5038
  ...k(i) ? { runId: k(i) } : {},
4955
5039
  dataType: "assistant_draft",
@@ -4961,12 +5045,12 @@ function ve(s, e) {
4961
5045
  role: r,
4962
5046
  ...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
4963
5047
  content: vt(
4964
- Jt(i.content),
5048
+ Xt(i.content),
4965
5049
  e
4966
5050
  ),
4967
5051
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
4968
5052
  ...E(i) !== null ? { displaySequence: E(i) } : {},
4969
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5053
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
4970
5054
  respondsToUserMessageId: O(i) ?? void 0,
4971
5055
  ...k(i) ? { runId: k(i) } : {},
4972
5056
  attachments: Ds(i.attachments, e),
@@ -5015,14 +5099,14 @@ function ve(s, e) {
5015
5099
  scheduledCheckInId: o.id ?? void 0,
5016
5100
  scheduledCheckInAt: o.dueAt
5017
5101
  };
5018
- const a = sr(i.output), l = nr(i.output);
5102
+ const a = rr(i.output), l = or(i.output);
5019
5103
  return a ? {
5020
5104
  id: String(t.id ?? crypto.randomUUID()),
5021
5105
  role: "tool",
5022
5106
  content: `Connect ${a.appName} to continue`,
5023
5107
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5024
5108
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5025
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5109
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5026
5110
  respondsToUserMessageId: O(i) ?? void 0,
5027
5111
  ...k(i) ? { runId: k(i) } : {},
5028
5112
  dataType: "function_call_output",
@@ -5035,7 +5119,7 @@ function ve(s, e) {
5035
5119
  content: "Connect WhatsApp to continue",
5036
5120
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5037
5121
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5038
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5122
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5039
5123
  respondsToUserMessageId: O(i) ?? void 0,
5040
5124
  ...k(i) ? { runId: k(i) } : {},
5041
5125
  dataType: "function_call_output",
@@ -5047,10 +5131,10 @@ function ve(s, e) {
5047
5131
  return i.type === "function_call" || i.type === "tool_call" || i.type === "web_search_call" || i.type === "mcp_call" || i.type === "tab_lifecycle_decision" ? {
5048
5132
  id: String(t.id ?? crypto.randomUUID()),
5049
5133
  role: "tool",
5050
- content: i.type === "mcp_call" ? tr(i) : rr(i),
5134
+ content: i.type === "mcp_call" ? ir(i) : lr(i),
5051
5135
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5052
5136
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5053
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5137
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5054
5138
  respondsToUserMessageId: O(i) ?? void 0,
5055
5139
  ...k(i) ? { runId: k(i) } : {},
5056
5140
  dataType: String(i.type),
@@ -5061,10 +5145,10 @@ function ve(s, e) {
5061
5145
  } : i.type === "run_status" || i.type === "run_error" ? i.type === "run_error" && i.stage === "tool_execution" ? null : {
5062
5146
  id: String(t.id ?? crypto.randomUUID()),
5063
5147
  role: "system",
5064
- content: ir(i),
5148
+ content: ar(i),
5065
5149
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
5066
5150
  ...E(i) !== null ? { displaySequence: E(i) } : {},
5067
- ..._(i) !== null ? { causalSequence: _(i) } : {},
5151
+ ...P(i) !== null ? { causalSequence: P(i) } : {},
5068
5152
  respondsToUserMessageId: O(i) ?? void 0,
5069
5153
  ...k(i) ? { runId: k(i) } : {},
5070
5154
  dataType: String(i.type),
@@ -5074,11 +5158,11 @@ function ve(s, e) {
5074
5158
  ...typeof i.securitySettingsUrl == "string" ? { securitySettingsUrl: i.securitySettingsUrl } : {}
5075
5159
  } : null;
5076
5160
  }
5077
- function tr(s) {
5161
+ function ir(s) {
5078
5162
  const t = (typeof s.server_label == "string" ? s.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
5079
5163
  return t ? `🔌 Using ${t}` : "🔌 Using connected integration";
5080
5164
  }
5081
- function sr(s) {
5165
+ function rr(s) {
5082
5166
  if (typeof s != "string")
5083
5167
  return null;
5084
5168
  try {
@@ -5095,7 +5179,7 @@ function sr(s) {
5095
5179
  return null;
5096
5180
  }
5097
5181
  }
5098
- function nr(s) {
5182
+ function or(s) {
5099
5183
  if (typeof s != "string")
5100
5184
  return null;
5101
5185
  try {
@@ -5110,10 +5194,10 @@ function nr(s) {
5110
5194
  return null;
5111
5195
  }
5112
5196
  }
5113
- function ir(s) {
5197
+ function ar(s) {
5114
5198
  return s.type === "run_status" && s.status === "steered" ? "Steered" : typeof s.message == "string" && s.message.trim().length > 0 ? s.message : "";
5115
5199
  }
5116
- function rr(s) {
5200
+ function lr(s) {
5117
5201
  if (s.type === "web_search_call") {
5118
5202
  const e = s.action;
5119
5203
  if (e && typeof e == "object") {
@@ -5125,9 +5209,9 @@ function rr(s) {
5125
5209
  }
5126
5210
  return "🔎 Searching the web";
5127
5211
  }
5128
- return or(s);
5212
+ return cr(s);
5129
5213
  }
5130
- function or(s) {
5214
+ function cr(s) {
5131
5215
  if (typeof s.summary == "string" && s.summary.trim().length > 0)
5132
5216
  return se(s.summary);
5133
5217
  if (typeof s.arguments == "string")
@@ -5144,7 +5228,7 @@ function se(s) {
5144
5228
  const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
5145
5229
  return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
5146
5230
  }
5147
- function ar(s) {
5231
+ function ur(s) {
5148
5232
  if (s == null)
5149
5233
  return s;
5150
5234
  if (typeof s != "object")
@@ -5163,13 +5247,13 @@ function ue(s) {
5163
5247
  const e = s.callId ?? s.call_id;
5164
5248
  return typeof e == "string" && e ? e : null;
5165
5249
  }
5166
- function _(s) {
5250
+ function P(s) {
5167
5251
  return typeof s.causalSequence == "number" && Number.isSafeInteger(s.causalSequence) ? s.causalSequence : null;
5168
5252
  }
5169
5253
  function E(s) {
5170
5254
  return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
5171
5255
  }
5172
- function Jt(s) {
5256
+ function Xt(s) {
5173
5257
  return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
5174
5258
  if (!e || typeof e != "object")
5175
5259
  return "";
@@ -5181,10 +5265,10 @@ function de(s, e) {
5181
5265
  const t = Es(
5182
5266
  s,
5183
5267
  Mt(s, e)
5184
- ), n = ur(
5185
- cr(
5186
- gr(
5187
- lr(s, e),
5268
+ ), n = pr(
5269
+ hr(
5270
+ yr(
5271
+ dr(s, e),
5188
5272
  e
5189
5273
  ),
5190
5274
  t
@@ -5209,7 +5293,7 @@ function Mt(s, e, t = !0) {
5209
5293
  const i = s.flatMap((r) => (e.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId === e.respondsToUserMessageId : e.runId !== void 0 && r.respondsToUserMessageId === void 0 && r.runId === e.runId) && r.displaySequence !== void 0 ? [r.displaySequence] : []);
5210
5294
  return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
5211
5295
  }
5212
- function lr(s, e) {
5296
+ function dr(s, e) {
5213
5297
  const t = e.proactiveSuggestionClientMessageId;
5214
5298
  if (!t)
5215
5299
  return s;
@@ -5219,13 +5303,13 @@ function lr(s, e) {
5219
5303
  const r = [...s];
5220
5304
  return r[i] = e, r;
5221
5305
  }
5222
- function cr(s, e) {
5306
+ function hr(s, e) {
5223
5307
  const t = e.assistantDraftItemId;
5224
5308
  return t ? s.map(
5225
5309
  (n) => n.dataType === "assistant_draft" && n.id === t ? e : n
5226
5310
  ) : s;
5227
5311
  }
5228
- function Ae(s, e, t) {
5312
+ function Me(s, e, t) {
5229
5313
  return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
5230
5314
  }
5231
5315
  function Yt(s, e, t, n) {
@@ -5287,7 +5371,7 @@ function ts(s) {
5287
5371
  loading: !0
5288
5372
  };
5289
5373
  }
5290
- function ur(s, e) {
5374
+ function pr(s, e) {
5291
5375
  if (e.id.startsWith("transient-activity:"))
5292
5376
  return s;
5293
5377
  const t = e.toolName === "tab_lifecycle";
@@ -5313,7 +5397,7 @@ function lt(s, e) {
5313
5397
  ct
5314
5398
  );
5315
5399
  }
5316
- function dr(s, e) {
5400
+ function gr(s, e) {
5317
5401
  const t = new Map(s.map((r) => [r.id, r])), n = e.map(
5318
5402
  (r) => Mt(s, r, !1)
5319
5403
  );
@@ -5335,7 +5419,7 @@ function dr(s, e) {
5335
5419
  return i;
5336
5420
  }
5337
5421
  function ct(s) {
5338
- const e = J(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5422
+ const e = X(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
5339
5423
  // Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
5340
5424
  // from substituting the call for its output and then appending a duplicate output at the end of the timeline.
5341
5425
  ...s.callId ? [`${n ? "call-output" : "call"}:${s.callId}`] : [],
@@ -5348,7 +5432,7 @@ function ct(s) {
5348
5432
  ...i.length > 0 ? { activityKeys: i } : {},
5349
5433
  ...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
5350
5434
  ...s.runId ? { runId: s.runId } : {},
5351
- isOptimistic: Ne(s),
5435
+ isOptimistic: He(s),
5352
5436
  isAssistantDraft: s.dataType === "assistant_draft",
5353
5437
  isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
5354
5438
  isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
@@ -5358,31 +5442,31 @@ function Es(s, e) {
5358
5442
  if (e.role !== "user" || !e.attachments?.length)
5359
5443
  return e;
5360
5444
  const t = s.find(
5361
- (o) => o.role === "user" && (o.id === e.id || Ne(o) && Cs(o, e))
5445
+ (o) => o.role === "user" && (o.id === e.id || He(o) && Cs(o, e))
5362
5446
  );
5363
5447
  if (!t?.attachments?.length)
5364
5448
  return e;
5365
5449
  const n = e.attachments.map((o) => {
5366
- const a = hr(t.attachments ?? [], o);
5367
- return a ? pr(o, a) : o;
5368
- }), i = { ...e, attachments: n }, r = J(e);
5450
+ const a = fr(t.attachments ?? [], o);
5451
+ return a ? mr(o, a) : o;
5452
+ }), i = { ...e, attachments: n }, r = X(e);
5369
5453
  return r && Object.defineProperty(i, "clientMessageId", {
5370
5454
  value: r,
5371
5455
  enumerable: !1
5372
5456
  }), i;
5373
5457
  }
5374
- function hr(s, e) {
5458
+ function fr(s, e) {
5375
5459
  return e.id ? s.find((t) => t.id === e.id) ?? null : null;
5376
5460
  }
5377
- function pr(s, e) {
5461
+ function mr(s, e) {
5378
5462
  const { previewUrl: t } = e;
5379
5463
  return t ? { ...s, previewUrl: t } : s;
5380
5464
  }
5381
- function gr(s, e) {
5465
+ function yr(s, e) {
5382
5466
  if (e.role !== "user")
5383
5467
  return s;
5384
5468
  const t = s.findIndex(
5385
- (i) => Ne(i) && Cs(i, e)
5469
+ (i) => He(i) && Cs(i, e)
5386
5470
  );
5387
5471
  if (t === -1)
5388
5472
  return s;
@@ -5390,13 +5474,13 @@ function gr(s, e) {
5390
5474
  return n.splice(t, 1), n;
5391
5475
  }
5392
5476
  function Cs(s, e) {
5393
- const t = J(s), n = J(e);
5477
+ const t = X(s), n = X(e);
5394
5478
  return t && n ? t === n : s.content === e.content;
5395
5479
  }
5396
- function Ne(s) {
5480
+ function He(s) {
5397
5481
  return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
5398
5482
  }
5399
- function J(s) {
5483
+ function X(s) {
5400
5484
  const e = s.clientMessageId;
5401
5485
  if (e)
5402
5486
  return e;
@@ -5406,12 +5490,12 @@ function J(s) {
5406
5490
  return n ? s.id.slice(n.length) : null;
5407
5491
  }
5408
5492
  function ss(s) {
5409
- const e = Ps(s);
5493
+ const e = _s(s);
5410
5494
  if (e === null)
5411
5495
  return !1;
5412
5496
  const t = s[e].id;
5413
5497
  if (s.some(
5414
- (i) => i.respondsToUserMessageId === t && Ue(i)
5498
+ (i) => i.respondsToUserMessageId === t && De(i)
5415
5499
  ))
5416
5500
  return !0;
5417
5501
  for (let i = s.length - 1; i > e; i -= 1) {
@@ -5429,10 +5513,10 @@ function ss(s) {
5429
5513
  }
5430
5514
  return !1;
5431
5515
  }
5432
- function fr(s, e, t) {
5516
+ function Ir(s, e, t) {
5433
5517
  const n = new Set(
5434
5518
  s.filter(
5435
- (i) => i.role === "user" && e !== null && J(i) === e
5519
+ (i) => i.role === "user" && e !== null && X(i) === e
5436
5520
  ).map((i) => i.id)
5437
5521
  );
5438
5522
  return s.some((i, r) => {
@@ -5443,14 +5527,14 @@ function fr(s, e, t) {
5443
5527
  if (t && i.runId === t) {
5444
5528
  if (n.size === 0)
5445
5529
  return !0;
5446
- const o = _s(s, r);
5530
+ const o = Ps(s, r);
5447
5531
  return !i.respondsToUserMessageId && o !== null && n.has(o);
5448
5532
  }
5449
5533
  return !1;
5450
5534
  });
5451
5535
  }
5452
- function mr(s) {
5453
- const e = Ps(s);
5536
+ function Sr(s) {
5537
+ const e = _s(s);
5454
5538
  if (e === null)
5455
5539
  return s.some(F);
5456
5540
  const t = s[e].id;
@@ -5458,13 +5542,13 @@ function mr(s) {
5458
5542
  (n) => n.respondsToUserMessageId === t && F(n)
5459
5543
  ) : s.slice(e + 1).some(F);
5460
5544
  }
5461
- function Ps(s) {
5545
+ function _s(s) {
5462
5546
  for (let e = s.length - 1; e >= 0; e -= 1)
5463
- if (s[e].role === "user" && !Ne(s[e]))
5547
+ if (s[e].role === "user" && !He(s[e]))
5464
5548
  return e;
5465
5549
  return null;
5466
5550
  }
5467
- function Ue(s) {
5551
+ function De(s) {
5468
5552
  return F(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
5469
5553
  }
5470
5554
  function ie(s) {
@@ -5481,7 +5565,7 @@ function ie(s) {
5481
5565
  }
5482
5566
  return null;
5483
5567
  }
5484
- function yr(s) {
5568
+ function Tr(s) {
5485
5569
  const e = ie(s);
5486
5570
  if (e === null)
5487
5571
  return null;
@@ -5500,10 +5584,10 @@ function C(s) {
5500
5584
  function pe(s) {
5501
5585
  return s?.retryable !== !0 ? !1 : s.type === "run_error" ? !0 : s.type === "run_status" && s.status === "interrupted";
5502
5586
  }
5503
- function Ir(s) {
5587
+ function wr(s) {
5504
5588
  return s?.type === "run_status" && s.status === "interrupted" && s.reason === "backend_restart";
5505
5589
  }
5506
- function Sr(s, e) {
5590
+ function Ar(s, e) {
5507
5591
  const t = ie(e);
5508
5592
  if (t === null)
5509
5593
  return !1;
@@ -5512,8 +5596,8 @@ function Sr(s, e) {
5512
5596
  return !1;
5513
5597
  const r = s.findIndex((o) => o.role === "user" && o.id === i);
5514
5598
  return r === -1 ? !1 : s.some((o) => o.respondsToUserMessageId === i) ? s.some(
5515
- (o) => o.respondsToUserMessageId === i && Ue(o)
5516
- ) : s.slice(r + 1).some(Ue);
5599
+ (o) => o.respondsToUserMessageId === i && De(o)
5600
+ ) : s.slice(r + 1).some(De);
5517
5601
  }
5518
5602
  function ut(s) {
5519
5603
  const e = ie(s);
@@ -5528,7 +5612,7 @@ function ut(s) {
5528
5612
  const i = n.clientMessageId;
5529
5613
  return typeof i == "string" ? i : null;
5530
5614
  }
5531
- function Tr(s) {
5615
+ function Mr(s) {
5532
5616
  const e = ie(s);
5533
5617
  if (e === null)
5534
5618
  return null;
@@ -5559,7 +5643,7 @@ function dt(s, e) {
5559
5643
  return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
5560
5644
  }
5561
5645
  function ns(s, e, t, n, i, r) {
5562
- if (!e || !Ar(s))
5646
+ if (!e || !Rr(s))
5563
5647
  return !1;
5564
5648
  const o = s;
5565
5649
  if (pe(o) || t !== null && typeof o.id == "string" && o.id !== t)
@@ -5567,7 +5651,7 @@ function ns(s, e, t, n, i, r) {
5567
5651
  const a = O(o);
5568
5652
  return n !== null ? a !== null ? a === n : i !== null && k(o) === i && r === n : i === null || k(o) === i;
5569
5653
  }
5570
- function wr(s, e) {
5654
+ function br(s, e) {
5571
5655
  for (let t = e - 1; t >= 0; t -= 1) {
5572
5656
  const n = C(s[t]);
5573
5657
  if (n?.type === "message" && n.role === "user")
@@ -5575,13 +5659,13 @@ function wr(s, e) {
5575
5659
  }
5576
5660
  return null;
5577
5661
  }
5578
- function _s(s, e) {
5662
+ function Ps(s, e) {
5579
5663
  for (let t = e - 1; t >= 0; t -= 1)
5580
5664
  if (s[t].role === "user")
5581
5665
  return s[t].id;
5582
5666
  return null;
5583
5667
  }
5584
- function Ar(s) {
5668
+ function Rr(s) {
5585
5669
  if (!s || typeof s != "object")
5586
5670
  return !1;
5587
5671
  const e = s;
@@ -5590,16 +5674,16 @@ function Ar(s) {
5590
5674
  function F(s) {
5591
5675
  return s.role === "assistant" && s.phase !== "commentary";
5592
5676
  }
5593
- function Mr(s) {
5677
+ function kr(s) {
5594
5678
  if (!s || typeof s != "object")
5595
5679
  return !1;
5596
5680
  const e = s;
5597
5681
  return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
5598
5682
  }
5599
5683
  function ht(s) {
5600
- return s.filter((e, t) => G(e) ? !xr(s, t) && !vs(s, t) && !qr(s, t) && !Or(s, t) : br(e) ? e.retryable === !0 && Dr(s, t) ? !1 : !Ur(s, t) : !0);
5684
+ return s.filter((e, t) => G(e) ? !Hr(s, t) && !vs(s, t) && !Lr(s, t) && !Nr(s, t) : Er(e) ? e.retryable === !0 && xr(s, t) ? !1 : !Or(s, t) : !0);
5601
5685
  }
5602
- function br(s) {
5686
+ function Er(s) {
5603
5687
  return s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.steered !== !0);
5604
5688
  }
5605
5689
  function G(s) {
@@ -5608,38 +5692,38 @@ function G(s) {
5608
5692
  function pt(s) {
5609
5693
  return s.steered !== !0 && (s.dataType === "assistant_draft" || s.loading === !0);
5610
5694
  }
5611
- function Rr(s) {
5695
+ function Cr(s) {
5612
5696
  return s.some(pt);
5613
5697
  }
5614
5698
  function is(s, e) {
5615
5699
  return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
5616
5700
  }
5617
- function kr(s, e) {
5701
+ function _r(s, e) {
5618
5702
  const t = [...s].reverse().find(pt), n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : t?.respondsToUserMessageId ?? null, i = typeof e.runId == "string" ? e.runId : t?.runId ?? null;
5619
5703
  return s.flatMap((r) => (n ? r.respondsToUserMessageId === n || !r.respondsToUserMessageId && i !== null && r.runId === i : i ? r.runId === i : pt(r)) ? r.dataType === "assistant_draft" || G(r) ? [] : r.loading === !0 ? [{ ...r, loading: !1 }] : [r] : [r]);
5620
5704
  }
5621
- function Er(s, e, t, n) {
5705
+ function Pr(s, e, t, n) {
5622
5706
  const i = s.findIndex(
5623
5707
  (l, c) => G(l) && !vs(s, c)
5624
5708
  ), r = i === -1 ? null : s[i], o = e ?? r?.respondsToUserMessageId ?? null, a = o ? s.find(
5625
5709
  (l) => l.role === "user" && l.id === o
5626
5710
  ) : null;
5627
5711
  return {
5628
- clientMessageId: a ? J(a) : o ? null : n,
5712
+ clientMessageId: a ? X(a) : o ? null : n,
5629
5713
  respondsToUserMessageId: o,
5630
5714
  runId: t ?? r?.runId ?? null
5631
5715
  };
5632
5716
  }
5633
- function Ce(s) {
5717
+ function _e(s) {
5634
5718
  return s?.type === "run_status" && s.status === "stopped";
5635
5719
  }
5636
- function Cr(s, e) {
5637
- return F(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5720
+ function vr(s, e) {
5721
+ return F(e) ? "completed" : _e(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
5638
5722
  }
5639
5723
  function rs(s, e, t) {
5640
5724
  const n = new Set(
5641
5725
  s.filter(
5642
- (i) => i.role === "user" && e !== null && J(i) === e
5726
+ (i) => i.role === "user" && e !== null && X(i) === e
5643
5727
  ).map((i) => i.id)
5644
5728
  );
5645
5729
  return s.filter(
@@ -5648,14 +5732,14 @@ function rs(s, e, t) {
5648
5732
  }
5649
5733
  function vs(s, e) {
5650
5734
  return s.some(
5651
- (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Pr(
5735
+ (t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && Ur(
5652
5736
  s,
5653
5737
  e,
5654
5738
  n
5655
5739
  )
5656
5740
  );
5657
5741
  }
5658
- function Pr(s, e, t) {
5742
+ function Ur(s, e, t) {
5659
5743
  const n = s[e], i = s[t];
5660
5744
  if (ge(n, i))
5661
5745
  return !0;
@@ -5668,11 +5752,11 @@ function Pr(s, e, t) {
5668
5752
  }
5669
5753
  function os(s, e, t, n) {
5670
5754
  const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
5671
- (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !vr(
5755
+ (l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !qr(
5672
5756
  s,
5673
5757
  l.respondsToUserMessageId
5674
5758
  )
5675
- )?.respondsToUserMessageId ?? _r(
5759
+ )?.respondsToUserMessageId ?? Dr(
5676
5760
  s,
5677
5761
  e
5678
5762
  );
@@ -5701,7 +5785,7 @@ function os(s, e, t, n) {
5701
5785
  }
5702
5786
  ];
5703
5787
  }
5704
- function _r(s, e) {
5788
+ function Dr(s, e) {
5705
5789
  const t = s.findIndex(
5706
5790
  (n) => n.role === "user" && n.id === e
5707
5791
  );
@@ -5715,12 +5799,12 @@ function _r(s, e) {
5715
5799
  function as(s) {
5716
5800
  return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
5717
5801
  }
5718
- function vr(s, e) {
5802
+ function qr(s, e) {
5719
5803
  return s.some(
5720
5804
  (t) => t.respondsToUserMessageId === e && (F(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
5721
5805
  );
5722
5806
  }
5723
- function Ur(s, e) {
5807
+ function Or(s, e) {
5724
5808
  const t = s[e];
5725
5809
  for (let n = e + 1; n < s.length; n += 1) {
5726
5810
  const i = s[n];
@@ -5729,7 +5813,7 @@ function Ur(s, e) {
5729
5813
  }
5730
5814
  return !1;
5731
5815
  }
5732
- function Dr(s, e) {
5816
+ function xr(s, e) {
5733
5817
  const t = s[e];
5734
5818
  if (!t.respondsToUserMessageId)
5735
5819
  return !1;
@@ -5742,19 +5826,19 @@ function Dr(s, e) {
5742
5826
  }
5743
5827
  return !1;
5744
5828
  }
5745
- function qr(s, e) {
5829
+ function Lr(s, e) {
5746
5830
  const t = s[e];
5747
5831
  return s.some(
5748
5832
  (n, i) => i !== e && n.role === "assistant" && ge(t, n)
5749
5833
  );
5750
5834
  }
5751
- function Or(s, e) {
5835
+ function Nr(s, e) {
5752
5836
  const t = s[e];
5753
5837
  return s.some(
5754
5838
  (n, i) => i !== e && n.role === "tool" && ge(t, n)
5755
5839
  );
5756
5840
  }
5757
- function xr(s, e) {
5841
+ function Hr(s, e) {
5758
5842
  const t = s[e];
5759
5843
  for (let n = e + 1; n < s.length; n += 1)
5760
5844
  if (G(s[n]) && ge(t, s[n]))
@@ -5767,7 +5851,7 @@ function ge(s, e) {
5767
5851
  function A(s, e) {
5768
5852
  return s && typeof s == "object" && typeof s[e] == "string" ? s[e] : null;
5769
5853
  }
5770
- function Lr(s, e) {
5854
+ function Br(s, e) {
5771
5855
  try {
5772
5856
  const t = window.localStorage.getItem(`${As}${s}`);
5773
5857
  if (!t)
@@ -5775,7 +5859,7 @@ function Lr(s, e) {
5775
5859
  const n = JSON.parse(t), i = typeof n.sessionId == "string" ? n.sessionId : null;
5776
5860
  if (e !== void 0 && i !== e)
5777
5861
  return null;
5778
- const r = Array.isArray(n.messages) ? n.messages.map(Qr).filter((o) => !!o) : [];
5862
+ const r = Array.isArray(n.messages) ? n.messages.map(Xr).filter((o) => !!o) : [];
5779
5863
  return {
5780
5864
  sessionId: i,
5781
5865
  messages: r
@@ -5789,20 +5873,20 @@ function gt(s) {
5789
5873
  // running tool or commentary history from disappearing while authoritative hydration is still in flight.
5790
5874
  s.role === "tool" || s.dataType === "run_status" || s.dataType === "run_error";
5791
5875
  }
5792
- function Nr(s, e) {
5876
+ function Wr(s, e) {
5793
5877
  try {
5794
5878
  window.localStorage.setItem(
5795
5879
  `${As}${s}`,
5796
5880
  JSON.stringify({
5797
5881
  sessionId: e.sessionId,
5798
- messages: e.messages.filter(gt).slice(-ai).map(Vr)
5882
+ messages: e.messages.filter(gt).slice(-li).map(Yr)
5799
5883
  })
5800
5884
  );
5801
5885
  } catch {
5802
5886
  return;
5803
5887
  }
5804
5888
  }
5805
- function Hr(s) {
5889
+ function Fr(s) {
5806
5890
  try {
5807
5891
  const e = window.localStorage.getItem(`${at}${s}`);
5808
5892
  if (!e)
@@ -5830,7 +5914,7 @@ function V(s, e) {
5830
5914
  }
5831
5915
  function Us(s, e) {
5832
5916
  try {
5833
- const t = `${xe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5917
+ const t = `${Le}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
5834
5918
  ...o,
5835
5919
  storedAt: Date.now(),
5836
5920
  unloadUrl: n,
@@ -5846,26 +5930,26 @@ function Us(s, e) {
5846
5930
  }
5847
5931
  function ls(s, e) {
5848
5932
  try {
5849
- if (window.sessionStorage.getItem(`${xe}${s}`) === null)
5933
+ if (window.sessionStorage.getItem(`${Le}${s}`) === null)
5850
5934
  return;
5851
5935
  } catch {
5852
5936
  return;
5853
5937
  }
5854
5938
  Us(s, e);
5855
5939
  }
5856
- function Br(s) {
5940
+ function $r(s) {
5857
5941
  try {
5858
- const e = `${xe}${s}`, t = window.sessionStorage.getItem(e);
5942
+ const e = `${Le}${s}`, t = window.sessionStorage.getItem(e);
5859
5943
  if (window.sessionStorage.removeItem(e), !t)
5860
5944
  return [];
5861
5945
  const n = JSON.parse(t);
5862
- return Array.isArray(n) ? n.flatMap((i) => Fr(i) ? [{
5946
+ return Array.isArray(n) ? n.flatMap((i) => zr(i) ? [{
5863
5947
  ...i.event,
5864
- page: P(),
5948
+ page: _(),
5865
5949
  rawOutput: {
5866
5950
  pageContextRestarted: !0,
5867
5951
  outcome: "unknown",
5868
- message: Wr(location.href),
5952
+ message: jr(location.href),
5869
5953
  currentUrl: location.href,
5870
5954
  console: [],
5871
5955
  metadata: {
@@ -5882,17 +5966,17 @@ function Br(s) {
5882
5966
  return [];
5883
5967
  }
5884
5968
  }
5885
- function Wr(s) {
5969
+ function jr(s) {
5886
5970
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
5887
5971
  Current URL: ${s}`;
5888
5972
  }
5889
- function Fr(s) {
5973
+ function zr(s) {
5890
5974
  if (!s || typeof s != "object")
5891
5975
  return !1;
5892
5976
  const e = s, t = e.event;
5893
5977
  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";
5894
5978
  }
5895
- function $r(s, e) {
5979
+ function Kr(s, e) {
5896
5980
  const t = new Set(
5897
5981
  s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
5898
5982
  );
@@ -5901,9 +5985,9 @@ function $r(s, e) {
5901
5985
  ...e.filter((n) => !t.has(n.callId))
5902
5986
  ];
5903
5987
  }
5904
- function jr(s) {
5988
+ function Gr(s) {
5905
5989
  try {
5906
- window.sessionStorage.removeItem(`${xe}${s}`);
5990
+ window.sessionStorage.removeItem(`${Le}${s}`);
5907
5991
  } catch {
5908
5992
  return;
5909
5993
  }
@@ -5938,9 +6022,9 @@ function qs(s, e) {
5938
6022
  } : s;
5939
6023
  }
5940
6024
  function ft(s) {
5941
- return s.type || Gr(s.name) || "application/octet-stream";
6025
+ return s.type || Jr(s.name) || "application/octet-stream";
5942
6026
  }
5943
- function zr(s) {
6027
+ function Qr(s) {
5944
6028
  Os({
5945
6029
  name: s.name,
5946
6030
  mimeType: ft(s),
@@ -5948,21 +6032,21 @@ function zr(s) {
5948
6032
  });
5949
6033
  }
5950
6034
  function Os(s) {
5951
- const e = Kr(s.name), t = s.mimeType.trim().toLowerCase();
5952
- if (!ii.has(`${e}:${t}`))
6035
+ const e = Vr(s.name), t = s.mimeType.trim().toLowerCase();
6036
+ if (!ri.has(`${e}:${t}`))
5953
6037
  throw new Error("This attachment type is not supported by the embedded model provider");
5954
6038
  if (s.sizeBytes <= 0 || s.sizeBytes >= Ts)
5955
6039
  throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
5956
6040
  }
5957
- function Kr(s) {
6041
+ function Vr(s) {
5958
6042
  const e = s.trim().toLowerCase(), t = e.lastIndexOf(".");
5959
6043
  return t >= 0 ? e.slice(t) : "";
5960
6044
  }
5961
- function Gr(s) {
6045
+ function Jr(s) {
5962
6046
  const e = s.toLowerCase();
5963
6047
  return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
5964
6048
  }
5965
- function Qr(s) {
6049
+ function Xr(s) {
5966
6050
  if (!s || typeof s != "object")
5967
6051
  return null;
5968
6052
  const e = s;
@@ -5980,17 +6064,17 @@ function Qr(s) {
5980
6064
  scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
5981
6065
  scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
5982
6066
  securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
5983
- attachments: Ds(e.attachments)?.map(De),
6067
+ attachments: Ds(e.attachments)?.map(qe),
5984
6068
  loading: typeof e.loading == "boolean" ? e.loading : void 0
5985
6069
  };
5986
6070
  }
5987
- function Vr(s) {
6071
+ function Yr(s) {
5988
6072
  return s.attachments?.length ? {
5989
6073
  ...s,
5990
- attachments: s.attachments.map(De)
6074
+ attachments: s.attachments.map(qe)
5991
6075
  } : s;
5992
6076
  }
5993
- function De(s) {
6077
+ function qe(s) {
5994
6078
  const {
5995
6079
  dataUrl: e,
5996
6080
  objectUrl: t,
@@ -6008,9 +6092,9 @@ function k(s) {
6008
6092
  const e = s.runId;
6009
6093
  return typeof e == "string" && e ? e : null;
6010
6094
  }
6011
- function Xr(s) {
6095
+ function Zr(s) {
6012
6096
  const e = s?.timeoutMs;
6013
- return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Si);
6097
+ return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Ai);
6014
6098
  }
6015
6099
  function xs(s) {
6016
6100
  const e = {};
@@ -6024,22 +6108,22 @@ function xs(s) {
6024
6108
  return e;
6025
6109
  }
6026
6110
  function Rt(s, e) {
6027
- return Fs(s) ? He : W(Oe(e), ri);
6111
+ return Fs(s) ? Be : W(xe(e), oi);
6028
6112
  }
6029
- function Jr(s, e) {
6113
+ function eo(s, e) {
6030
6114
  return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
6031
6115
  }
6032
- async function Yr(s, e, t, n) {
6116
+ async function to(s, e, t, n) {
6033
6117
  const i = xs(s.headers);
6034
6118
  n({
6035
6119
  ...e,
6036
6120
  responseStatus: s.status,
6037
6121
  responseHeaders: i,
6038
- responseBody: await Zr(s),
6122
+ responseBody: await so(s),
6039
6123
  durationMs: Date.now() - t
6040
6124
  });
6041
6125
  }
6042
- async function Zr(s) {
6126
+ async function so(s) {
6043
6127
  if (!Ls(s.headers))
6044
6128
  return;
6045
6129
  let e = null, t = null;
@@ -6049,7 +6133,7 @@ async function Zr(s) {
6049
6133
  const n = new Promise((a) => {
6050
6134
  t = window.setTimeout(() => {
6051
6135
  e?.cancel(), a("timeout");
6052
- }, oi);
6136
+ }, ai);
6053
6137
  }), i = new TextDecoder();
6054
6138
  let r = "", o = 0;
6055
6139
  for (; ; ) {
@@ -6071,7 +6155,7 @@ async function Zr(s) {
6071
6155
  t !== null && window.clearTimeout(t);
6072
6156
  }
6073
6157
  }
6074
- function eo(s, e) {
6158
+ function no(s, e) {
6075
6159
  if (Ls(new Headers(e)))
6076
6160
  try {
6077
6161
  return s.responseType === "" || s.responseType === "text" ? W(s.responseText ?? "") : void 0;
@@ -6083,7 +6167,7 @@ function us(s) {
6083
6167
  if (typeof s == "string")
6084
6168
  return W(s);
6085
6169
  }
6086
- function to(s) {
6170
+ function io(s) {
6087
6171
  return L({
6088
6172
  ...s,
6089
6173
  requestBody: ds(s.requestBody),
@@ -6095,11 +6179,11 @@ function ds(s) {
6095
6179
  return s;
6096
6180
  const e = s.trim();
6097
6181
  if (!e.startsWith("{") && !e.startsWith("["))
6098
- return Oe(s);
6182
+ return xe(s);
6099
6183
  try {
6100
6184
  return JSON.stringify(L(JSON.parse(s)));
6101
6185
  } catch {
6102
- return Oe(s);
6186
+ return xe(s);
6103
6187
  }
6104
6188
  }
6105
6189
  function Ls(s) {
@@ -6109,7 +6193,7 @@ function Ls(s) {
6109
6193
  return t !== null && Number.isInteger(n) && n >= 0 && n <= Tt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
6110
6194
  }
6111
6195
  function te(s, e = {}, t) {
6112
- if (no(t))
6196
+ if (oo(t))
6113
6197
  return !0;
6114
6198
  const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
6115
6199
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -6124,7 +6208,7 @@ function te(s, e = {}, t) {
6124
6208
  return !0;
6125
6209
  }
6126
6210
  }
6127
- function so(s, e) {
6211
+ function ro(s, e) {
6128
6212
  if (te(s))
6129
6213
  return !0;
6130
6214
  try {
@@ -6134,10 +6218,10 @@ function so(s, e) {
6134
6218
  return !0;
6135
6219
  }
6136
6220
  }
6137
- function no(s) {
6221
+ function oo(s) {
6138
6222
  return s instanceof FormData || s instanceof Blob || s instanceof ArrayBuffer || ArrayBuffer.isView(s) || typeof ReadableStream < "u" && s instanceof ReadableStream;
6139
6223
  }
6140
- function io(s) {
6224
+ function ao(s) {
6141
6225
  const e = {};
6142
6226
  for (const t of s.trim().split(/[\r\n]+/)) {
6143
6227
  const n = t.indexOf(":");
@@ -6162,114 +6246,114 @@ class Pe extends Error {
6162
6246
  }
6163
6247
  status;
6164
6248
  }
6165
- async function Me(s, e) {
6249
+ async function be(s, e) {
6166
6250
  let t = null;
6167
6251
  for (let n = 0; n < zt; n += 1)
6168
6252
  try {
6169
6253
  return await s();
6170
6254
  } catch (i) {
6171
- if (t = i, n >= zt - 1 || !oo(i))
6255
+ if (t = i, n >= zt - 1 || !co(i))
6172
6256
  throw i;
6173
- await ro(n);
6257
+ await lo(n);
6174
6258
  }
6175
6259
  throw t instanceof Error ? t : new Error(e);
6176
6260
  }
6177
- function ro(s) {
6261
+ function lo(s) {
6178
6262
  return new Promise((e) => {
6179
- window.setTimeout(e, ni[s] ?? 0);
6263
+ window.setTimeout(e, ii[s] ?? 0);
6180
6264
  });
6181
6265
  }
6182
- function oo(s) {
6183
- return s instanceof Pe ? ao(s.status) : s instanceof TypeError;
6266
+ function co(s) {
6267
+ return s instanceof Pe ? uo(s.status) : s instanceof TypeError;
6184
6268
  }
6185
- function ao(s) {
6269
+ function uo(s) {
6186
6270
  return s === 408 || s === 409 || s === 429 || s >= 500;
6187
6271
  }
6188
- function lo(s) {
6272
+ function ho(s) {
6189
6273
  return s === 401 || s === 403;
6190
6274
  }
6191
- const He = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
6275
+ const Be = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", po = "[REDACTED_SIGNED_URL]", go = 20, fo = /^(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, mo = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, yo = /\bhttps?:\/\/[^\s"'<>]+/gi, Io = /[),.;\]]+$/;
6192
6276
  function L(s) {
6193
- return qe(s, 0, /* @__PURE__ */ new WeakSet());
6277
+ return Oe(s, 0, /* @__PURE__ */ new WeakSet());
6194
6278
  }
6195
- function qe(s, e, t) {
6279
+ function Oe(s, e, t) {
6196
6280
  if (typeof s == "string")
6197
- return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : Oe(s);
6281
+ return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : xe(s);
6198
6282
  if (s === null || typeof s != "object")
6199
6283
  return s;
6200
- if (e >= uo)
6284
+ if (e >= go)
6201
6285
  return "[REDACTED_MAX_DEPTH]";
6202
6286
  if (t.has(s))
6203
6287
  return "[REDACTED_CIRCULAR]";
6204
6288
  if (t.add(s), Array.isArray(s))
6205
- return s.map((i) => qe(i, e + 1, t));
6289
+ return s.map((i) => Oe(i, e + 1, t));
6206
6290
  const n = {};
6207
6291
  for (const [i, r] of Object.entries(s))
6208
- i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
6292
+ i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = Be : n[i] = i.toLowerCase() === "url" ? So(r) : Oe(r, e + 1, t);
6209
6293
  return n;
6210
6294
  }
6211
6295
  function Fs(s) {
6212
6296
  const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
6213
6297
  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");
6214
6298
  }
6215
- function mo(s) {
6216
- return typeof s == "string" ? $s(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
6299
+ function So(s) {
6300
+ return typeof s == "string" ? $s(s) : Oe(s, 0, /* @__PURE__ */ new WeakSet());
6217
6301
  }
6218
6302
  function $s(s) {
6219
6303
  try {
6220
6304
  const e = new URL(s, location.href);
6221
6305
  for (const t of Array.from(e.searchParams.keys()))
6222
- ho.test(t) && e.searchParams.set(t, $);
6306
+ fo.test(t) && e.searchParams.set(t, $);
6223
6307
  return e.username && (e.username = $), e.password && (e.password = $), e.toString();
6224
6308
  } catch {
6225
- return yo(s);
6309
+ return To(s);
6226
6310
  }
6227
6311
  }
6228
- function Oe(s) {
6229
- return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6312
+ function xe(s) {
6313
+ return s.replace(mo, po).replace(yo, wo).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${Be}`);
6230
6314
  }
6231
- function yo(s) {
6232
- return s.replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
6315
+ function To(s) {
6316
+ return s.replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${Be}`);
6233
6317
  }
6234
- function Io(s) {
6235
- const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6318
+ function wo(s) {
6319
+ const e = s.match(Io)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
6236
6320
  return `${$s(t)}${e}`;
6237
6321
  }
6238
- const Eo = Object.freeze({
6239
- init: (s) => Le.init(s)
6322
+ const Po = Object.freeze({
6323
+ init: (s) => Ne.init(s)
6240
6324
  });
6241
- function Co(s) {
6242
- return Le.init(s);
6325
+ function vo(s) {
6326
+ return Ne.init(s);
6243
6327
  }
6244
6328
  export {
6245
6329
  Ht as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
6246
6330
  Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
6247
6331
  Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
6248
6332
  qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
6249
- ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6250
- Eo as PlunoProductAgent,
6333
+ _o as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
6334
+ Po as PlunoProductAgent,
6251
6335
  kn as ProductAgentInteractionManager,
6252
6336
  xt as ProductAgentQueryController,
6253
- Ro as ProductAgentRemoteRuntimeClient,
6254
- Le as ProductAgentSessionEngine,
6337
+ Co as ProductAgentRemoteRuntimeClient,
6338
+ Ne as ProductAgentSessionEngine,
6255
6339
  Mn as ProductAgentSessionHistoryManager,
6256
- Ao as ProductAgentTaskPageTitleController,
6257
- X as ProductAgentTokenProviderError,
6258
- di as calculateReconnectDelay,
6259
- wo as createLocalStorageInteractionDecisionStorage,
6260
- Re as createProductAgentQueryState,
6261
- Co as createProductAgentRuntime,
6262
- Mo as createProductAgentTaskPageTitleDocument,
6263
- Eo as default,
6264
- _n as formatProductAgentTaskPageTitle,
6265
- Oi as getProductAgentOriginAccessErrorMessage,
6266
- bo as isProductAgentRuntimeCommand,
6340
+ Ro as ProductAgentTaskPageTitleController,
6341
+ J as ProductAgentTokenProviderError,
6342
+ hi as calculateReconnectDelay,
6343
+ bo as createLocalStorageInteractionDecisionStorage,
6344
+ ke as createProductAgentQueryState,
6345
+ vo as createProductAgentRuntime,
6346
+ ko as createProductAgentTaskPageTitleDocument,
6347
+ Po as default,
6348
+ Pn as formatProductAgentTaskPageTitle,
6349
+ Ni as getProductAgentOriginAccessErrorMessage,
6350
+ Eo as isProductAgentRuntimeCommand,
6267
6351
  Tn as mergeProductAgentEntityPages,
6268
- ke as normalizeProductAgentEntityPage,
6352
+ Ee as normalizeProductAgentEntityPage,
6269
6353
  st as normalizeProductAgentSessionItems,
6270
6354
  En as readLocalStorageInteractionDecisions,
6271
- To as resolveProductAgentComposerAction,
6272
- So as resolveProductAgentWidgetPresentation,
6355
+ Mo as resolveProductAgentComposerAction,
6356
+ Ao as resolveProductAgentWidgetPresentation,
6273
6357
  Is as selectProductAgentQueryEntities,
6274
- zr as validateProductAgentProviderInputFile
6358
+ Qr as validateProductAgentProviderInputFile
6275
6359
  };