@pluno/product-agent-web 0.1.120 → 0.1.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- const ce = "pluno-product-agent-attachments";
2
- const et = "files";
3
- async function qt(e) {
4
- const t = await $();
5
- await Ft(t, "readwrite", (s) => s.put(e));
6
- }
7
- async function le(e) {
8
- const t = await $(), s = await Ft(
1
+ const Ke = "pluno-product-agent-attachments";
2
+ const _t = "files";
3
+ async function Ae(e) {
4
+ const t = await it();
5
+ await Ee(t, "readwrite", (s) => s.put(e));
6
+ }
7
+ async function Ve(e) {
8
+ const t = await it(), s = await Ee(
9
9
  t,
10
10
  "readonly",
11
11
  (r) => r.get(e)
@@ -13,12 +13,12 @@ async function le(e) {
13
13
  if (!s)
14
14
  return null;
15
15
  const n = Date.now();
16
- return await xt(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
16
+ return await Se(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
17
17
  }
18
- async function xt(e, t) {
19
- const s = await $();
20
- await lt(s, "readwrite", async (n) => {
21
- const r = await ut(
18
+ async function Se(e, t) {
19
+ const s = await it();
20
+ await vt(s, "readwrite", async (n) => {
21
+ const r = await Lt(
22
22
  n.get(e)
23
23
  );
24
24
  r && n.put({
@@ -27,40 +27,40 @@ async function xt(e, t) {
27
27
  });
28
28
  });
29
29
  }
30
- async function ue(e = 864e5) {
31
- const t = await $(), s = Date.now() - e;
32
- await lt(t, "readwrite", async (n) => {
30
+ async function Ye(e = 864e5) {
31
+ const t = await it(), s = Date.now() - e;
32
+ await vt(t, "readwrite", async (n) => {
33
33
  const r = n.index("lastUsedAt");
34
- (await ut(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
34
+ (await Lt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
35
35
  });
36
36
  }
37
- function $() {
37
+ function it() {
38
38
  return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
39
- const s = indexedDB.open(ce, 1);
39
+ const s = indexedDB.open(Ke, 1);
40
40
  s.onupgradeneeded = () => {
41
- const r = s.result.createObjectStore(et, { keyPath: "attachmentId" });
41
+ const r = s.result.createObjectStore(_t, { keyPath: "attachmentId" });
42
42
  r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
43
43
  }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
44
44
  });
45
45
  }
46
- async function Ft(e, t, s) {
47
- return await lt(e, t, async (n) => await ut(s(n)));
46
+ async function Ee(e, t, s) {
47
+ return await vt(e, t, async (n) => await Lt(s(n)));
48
48
  }
49
- function lt(e, t, s) {
49
+ function vt(e, t, s) {
50
50
  return new Promise((n, r) => {
51
- const i = e.transaction(et, t), o = i.objectStore(et);
52
- let l, u = !1;
53
- s(o).then((c) => {
54
- l = c;
55
- }).catch((c) => {
51
+ const i = e.transaction(_t, t), o = i.objectStore(_t);
52
+ let a, u = !1;
53
+ s(o).then((l) => {
54
+ a = l;
55
+ }).catch((l) => {
56
56
  u = !0;
57
57
  try {
58
58
  i.abort();
59
59
  } catch {
60
60
  }
61
- r(c);
61
+ r(l);
62
62
  }), i.oncomplete = () => {
63
- u || n(l);
63
+ u || n(a);
64
64
  }, i.onerror = () => {
65
65
  u || (u = !0, r(i.error ?? new Error("Product Agent attachment storage transaction failed")));
66
66
  }, i.onabort = () => {
@@ -68,16 +68,16 @@ function lt(e, t, s) {
68
68
  };
69
69
  });
70
70
  }
71
- function ut(e) {
71
+ function Lt(e) {
72
72
  return new Promise((t, s) => {
73
73
  e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
74
74
  });
75
75
  }
76
- function de(e) {
76
+ function Ze(e) {
77
77
  return e !== null && (typeof e == "object" || typeof e == "function");
78
78
  }
79
- function Ht(e, t, s) {
80
- const n = Reflect.get(e, "pluno"), r = de(n) ? n : {};
79
+ function xt(e, t, s) {
80
+ const n = Reflect.get(e, "pluno"), r = Ze(n) ? n : {};
81
81
  if (r !== n && !Reflect.set(e, "pluno", r))
82
82
  return null;
83
83
  const i = Object.getOwnPropertyDescriptor(r, t);
@@ -91,11 +91,11 @@ function Ht(e, t, s) {
91
91
  }
92
92
  };
93
93
  }
94
- const J = "pluno.productAgent.transportId", he = "pluno.productAgent.transportIdentity", V = "pluno.productAgent.transportIdentity.event", pe = 50, fe = globalThis.setTimeout.bind(globalThis);
95
- let P = null;
96
- const x = /* @__PURE__ */ new Set();
97
- async function ge(e = Wt()) {
98
- const t = e.randomUUID(), s = e.storage.getItem(J);
94
+ const It = "pluno.productAgent.transportId", Qe = "pluno.productAgent.transportIdentity", At = "pluno.productAgent.transportIdentity.event", ts = 50, es = globalThis.setTimeout.bind(globalThis);
95
+ let F = null;
96
+ const tt = /* @__PURE__ */ new Set();
97
+ async function ss(e = ke()) {
98
+ const t = e.randomUUID(), s = e.storage.getItem(It);
99
99
  let n = s ?? e.randomUUID(), r = !1, i = !1;
100
100
  const o = e.channel.subscribe((u) => {
101
101
  if (!(u.senderId === t || u.transportId !== n)) {
@@ -113,58 +113,58 @@ async function ge(e = Wt()) {
113
113
  }
114
114
  });
115
115
  if (!s)
116
- e.storage.setItem(J, n), r = !0;
116
+ e.storage.setItem(It, n), r = !0;
117
117
  else
118
118
  for (; ; ) {
119
119
  if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
120
120
  r = !0;
121
121
  break;
122
122
  }
123
- n = e.randomUUID(), e.storage.setItem(J, n);
123
+ n = e.randomUUID(), e.storage.setItem(It, n);
124
124
  }
125
- let l = !1;
125
+ let a = !1;
126
126
  return {
127
127
  transportId: n,
128
128
  release: () => {
129
- l || (l = !0, o(), e.channel.close());
129
+ a || (a = !0, o(), e.channel.close());
130
130
  }
131
131
  };
132
132
  }
133
- async function me() {
134
- P || (P = ge(Wt()), P.then((n) => {
133
+ async function ns() {
134
+ F || (F = ss(ke()), F.then((n) => {
135
135
  const r = (i) => {
136
- i.persisted || (n.release(), P = null, x.clear(), window.removeEventListener("pagehide", r));
136
+ i.persisted || (n.release(), F = null, tt.clear(), window.removeEventListener("pagehide", r));
137
137
  };
138
138
  window.addEventListener("pagehide", r);
139
139
  }));
140
- const e = await P, t = ye();
141
- x.add(t);
140
+ const e = await F, t = rs();
141
+ tt.add(t);
142
142
  let s = !1;
143
143
  return {
144
144
  // A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
145
145
  transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
146
146
  release: () => {
147
- s || (s = !0, x.delete(t));
147
+ s || (s = !0, tt.delete(t));
148
148
  }
149
149
  };
150
150
  }
151
- function ye() {
151
+ function rs() {
152
152
  let e = 0;
153
- for (; x.has(e); )
153
+ for (; tt.has(e); )
154
154
  e += 1;
155
155
  return e;
156
156
  }
157
- function Wt() {
157
+ function ke() {
158
158
  return {
159
159
  storage: window.sessionStorage,
160
- channel: Ie(),
160
+ channel: is(),
161
161
  randomUUID: () => crypto.randomUUID(),
162
- settle: () => new Promise((e) => fe(e, pe))
162
+ settle: () => new Promise((e) => es(e, ts))
163
163
  };
164
164
  }
165
- function Ie() {
165
+ function is() {
166
166
  if (typeof BroadcastChannel < "u") {
167
- const e = new BroadcastChannel(he);
167
+ const e = new BroadcastChannel(Qe);
168
168
  return {
169
169
  postMessage: (t) => e.postMessage(t),
170
170
  subscribe: (t) => {
@@ -174,11 +174,11 @@ function Ie() {
174
174
  close: () => e.close()
175
175
  };
176
176
  }
177
- return Te();
177
+ return os();
178
178
  }
179
- function Te() {
179
+ function os() {
180
180
  const e = /* @__PURE__ */ new Set(), t = (s) => {
181
- if (s.key !== V || !s.newValue)
181
+ if (s.key !== At || !s.newValue)
182
182
  return;
183
183
  const n = JSON.parse(s.newValue);
184
184
  for (const r of e)
@@ -187,9 +187,9 @@ function Te() {
187
187
  return window.addEventListener("storage", t), {
188
188
  postMessage: (s) => {
189
189
  window.localStorage.setItem(
190
- V,
190
+ At,
191
191
  JSON.stringify({ ...s, eventId: crypto.randomUUID() })
192
- ), window.localStorage.removeItem(V);
192
+ ), window.localStorage.removeItem(At);
193
193
  },
194
194
  subscribe: (s) => (e.add(s), () => e.delete(s)),
195
195
  close: () => {
@@ -197,18 +197,18 @@ function Te() {
197
197
  }
198
198
  };
199
199
  }
200
- const st = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', we = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ae = ".pluno-pa-widget__panel", Se = ".pluno-pa-widget__timeline", wt = `${st}[data-pluno-sdk-preview-channel]`, ke = "https://app.pluno.ai", Ee = "gpt-5.6-terra", Re = 2e4, _e = 1e4, be = 1e4, Me = 1e4, Ce = 1e4, Pe = 1e3, At = 3e4, St = 0.2, kt = 6e4, Ue = 15e3, L = 8, De = 15e3, Ne = 2e3, Oe = 1e3, Le = 100, Be = 8e3, ve = 15e3, Et = 3, qe = [300, 1e3], dt = 64e3, Y = 4e3, ht = 30, xe = 2e3, Fe = 1e3, He = 200 * 1024 * 1024, pt = "Image is too large for model vision input.", We = 100, jt = "pluno.productAgent.state.", nt = "pluno.productAgent.pendingEvents.", z = "pluno.productAgent.activeToolCalls.", je = 100;
201
- function B(e, t = 0) {
200
+ const Mt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', as = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', cs = ".pluno-pa-widget__panel", ls = ".pluno-pa-widget__timeline", se = `${Mt}[data-pluno-sdk-preview-channel]`, us = "https://app.pluno.ai", ds = "gpt-5.6-terra", hs = 2e4, ps = 1e4, fs = 1e4, gs = 1e4, ms = 1e4, ys = 1e3, ne = 3e4, re = 0.2, ie = 6e4, Ts = 15e3, K = 8, ws = 15e3, Is = 2e3, As = 1e3, Ss = 100, Es = 8e3, ks = 15e3, oe = 3, bs = [300, 1e3], Bt = 64e3, St = 4e3, qt = 30, Rs = 2e3, _s = 1e3, Ms = 200 * 1024 * 1024, Ht = "Image is too large for model vision input.", Cs = 100, be = "pluno.productAgent.state.", Ct = "pluno.productAgent.pendingEvents.", ot = "pluno.productAgent.activeToolCalls.", Ps = 100;
201
+ function V(e, t = 0) {
202
202
  const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
203
203
  return Math.max(t, s);
204
204
  }
205
- const F = /* @__PURE__ */ new Set();
206
- let v = null;
207
- function $e(e, t = Math.random) {
208
- const s = Math.min(At, Pe * 2 ** e), n = 1 - St + t() * St * 2;
209
- return Math.min(At, Math.round(s * n));
205
+ const et = /* @__PURE__ */ new Set();
206
+ let Y = null;
207
+ function Us(e, t = Math.random) {
208
+ const s = Math.min(ne, ys * 2 ** e), n = 1 - re + t() * re * 2;
209
+ return Math.min(ne, Math.round(s * n));
210
210
  }
211
- function ze(e, t, s) {
211
+ function Ds(e, t, s) {
212
212
  return new Promise((n, r) => {
213
213
  const i = setTimeout(() => r(new Error(s)), t);
214
214
  e.then(
@@ -221,13 +221,13 @@ function ze(e, t, s) {
221
221
  );
222
222
  });
223
223
  }
224
- class $t {
224
+ class Re {
225
225
  constructor(t, s) {
226
226
  this.options = t, this.transportIdentity = s, this.state = {
227
227
  ...this.state,
228
- starterPrompts: Is(t.initialStarterPrompts)
228
+ starterPrompts: dn(t.initialStarterPrompts)
229
229
  };
230
- const n = t.restorePersistedState === !1 ? null : tn(t.clientId, t.expectedPersistedSessionId);
230
+ const n = t.restorePersistedState === !1 ? null : Jn(t.clientId, t.expectedPersistedSessionId);
231
231
  n && (this.state = {
232
232
  ...this.state,
233
233
  ...n,
@@ -240,10 +240,10 @@ class $t {
240
240
  assistantDraftRunId: null,
241
241
  isThinking: !1,
242
242
  lastError: null
243
- }), this.queuedClientEvents = cn(
244
- sn(t.clientId),
245
- rn(t.clientId)
246
- ), U(t.clientId, this.queuedClientEvents);
243
+ }), this.queuedClientEvents = er(
244
+ Vn(t.clientId),
245
+ Zn(t.clientId)
246
+ ), W(t.clientId, this.queuedClientEvents);
247
247
  }
248
248
  options;
249
249
  listeners = {};
@@ -275,6 +275,7 @@ class $t {
275
275
  activeClientMessageId = null;
276
276
  activeUserMessageEvent = null;
277
277
  latestRecoverableClientMessageId = null;
278
+ lastUserMessagePageUrl = null;
278
279
  thinkingWatchdogResyncAttemptsByClientMessageId = {};
279
280
  retryableClientMessageId = null;
280
281
  runtimeHelperJavascript = null;
@@ -307,15 +308,15 @@ class $t {
307
308
  lastErrorSecuritySettingsUrl: null
308
309
  };
309
310
  static async init(t) {
310
- const s = await me(), n = new $t({
311
+ const s = await ns(), n = new Re({
311
312
  ...t,
312
- backendUrl: ls(t.backendUrl ?? ke),
313
- clientId: t.clientId ?? ks(),
314
- model: t.model ?? Ee
313
+ backendUrl: Ys(t.backendUrl ?? us),
314
+ clientId: t.clientId ?? mn(),
315
+ model: t.model ?? ds
315
316
  }, s);
316
317
  try {
317
- ue().catch((r) => {
318
- f("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
318
+ Ye().catch((r) => {
319
+ w("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
319
320
  message: r instanceof Error ? r.message : String(r)
320
321
  });
321
322
  }), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
@@ -346,15 +347,15 @@ class $t {
346
347
  lastError: null
347
348
  });
348
349
  try {
349
- if (this.token = this.options.token ?? (this.options.tokenProvider ? await ze(this.options.tokenProvider(), be, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
350
+ if (this.token = this.options.token ?? (this.options.tokenProvider ? await Ds(this.options.tokenProvider(), fs, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
350
351
  return;
351
352
  if (!this.token && !this.options.webSocketFactory)
352
353
  throw new Error("Pluno requires a token or tokenProvider");
353
- const s = ds(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
354
+ const s = Qs(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
354
355
  this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
355
- this.socket === n && n.readyState === WebSocket.CONNECTING && (f("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
356
- }, Me), n.addEventListener("open", () => {
357
- this.socket !== n || (this.clearSocketConnectTimer(), f("web-sdk.agent", "Pluno socket opened", {
356
+ this.socket === n && n.readyState === WebSocket.CONNECTING && (w("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
357
+ }, gs), n.addEventListener("open", () => {
358
+ this.socket !== n || (this.clearSocketConnectTimer(), w("web-sdk.agent", "Pluno socket opened", {
358
359
  queuedClientEventCount: this.queuedClientEvents.length,
359
360
  isThinking: this.state.isThinking
360
361
  }), !(this.token ? this.sendNow({
@@ -364,12 +365,12 @@ class $t {
364
365
  transportId: this.transportIdentity.transportId,
365
366
  pageUrl: location.href
366
367
  }) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
367
- this.socket === n && (f("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
368
- }, Ce));
368
+ this.socket === n && (w("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
369
+ }, ms));
369
370
  }), n.addEventListener("message", (r) => {
370
- this.socket === n && this.handleServerEvent(ys(r.data));
371
+ this.socket === n && this.handleServerEvent(un(r.data));
371
372
  }), n.addEventListener("close", (r) => {
372
- this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (f("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
373
+ this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (w("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
373
374
  code: typeof r?.code == "number" ? r.code : null,
374
375
  reason: typeof r?.reason == "string" ? r.reason : "",
375
376
  wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
@@ -377,7 +378,7 @@ class $t {
377
378
  isThinking: this.state.isThinking
378
379
  }), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
379
380
  }), n.addEventListener("error", () => {
380
- this.socket !== n || this.state.status === "closed" || (f("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
381
+ this.socket !== n || this.state.status === "closed" || (w("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
381
382
  queuedClientEventCount: this.queuedClientEvents.length,
382
383
  isThinking: this.state.isThinking
383
384
  }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
@@ -400,25 +401,25 @@ class $t {
400
401
  this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
401
402
  }
402
403
  destroy() {
403
- this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), ln(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
404
+ this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), sr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
404
405
  for (const t of Object.values(this.listeners))
405
406
  t?.clear();
406
407
  }
407
408
  sendMessage(t, s = {}) {
408
- const n = t.trim(), r = s.attachments ?? [], i = r.map(It);
409
+ const n = t.trim(), r = s.attachments ?? [], i = r.map(zt);
409
410
  if (!n && i.length === 0)
410
411
  return null;
411
- const o = w(), l = s.clientMessageId ?? q();
412
+ const o = R(), a = s.clientMessageId ?? Q();
412
413
  this.retryableClientMessageId = null;
413
414
  const u = {
414
- id: `local-${l}`,
415
+ id: `local-${a}`,
415
416
  role: "user",
416
417
  content: n,
417
418
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
418
419
  ...r.length > 0 ? { attachments: r } : {}
419
- }, c = this.state.messages.some((h) => h.id === u.id || h.clientMessageId === l);
420
+ }, l = this.state.messages.some((m) => m.id === u.id || m.clientMessageId === a);
420
421
  this.setState({
421
- messages: c ? this.state.messages : [...this.state.messages, u],
422
+ messages: l ? this.state.messages : [...this.state.messages, u],
422
423
  ...this.state.isThinking ? {} : {
423
424
  assistantDraft: "",
424
425
  assistantDraftItemId: null,
@@ -428,45 +429,46 @@ class $t {
428
429
  },
429
430
  isThinking: !0,
430
431
  lastError: null
431
- }), c || this.emit("message", u);
432
- const a = {
432
+ }), l || this.emit("message", u);
433
+ const c = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, d = {
433
434
  type: "chat.user_message",
434
435
  sessionId: this.state.sessionId ?? void 0,
435
- clientMessageId: l,
436
+ clientMessageId: a,
436
437
  initiatedBy: s.initiatedBy,
437
438
  content: n,
439
+ pageContent: c && Ft() || void 0,
438
440
  attachments: i.length > 0 ? i : void 0,
439
441
  page: o,
440
442
  model: this.options.model,
441
- metadata: Rt(this.options.metadata)
443
+ metadata: ae(this.options.metadata)
442
444
  };
443
- return this.activeClientMessageId = l, this.activeUserMessageEvent = a, this.markThinkingProgress(), this.send(a), this.startBackgroundAttachmentUploads(l, i), l;
445
+ return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = d, this.markThinkingProgress(), this.send(d), this.startBackgroundAttachmentUploads(a, i), a;
444
446
  }
445
447
  retryLastMessage() {
446
448
  const t = this.state.sessionId, s = this.retryableClientMessageId;
447
449
  return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
448
450
  }
449
451
  createLocalAttachment(t) {
450
- const s = q(), n = {
452
+ const s = Q(), n = {
451
453
  id: s,
452
454
  name: t.name || "attachment",
453
- mimeType: Lt(t),
455
+ mimeType: Te(t),
454
456
  sizeBytes: t.size
455
457
  };
456
458
  this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
457
459
  const r = Date.now();
458
- return qt({
460
+ return Ae({
459
461
  attachmentId: s,
460
462
  name: n.name,
461
463
  mimeType: n.mimeType,
462
464
  sizeBytes: n.sizeBytes,
463
465
  blob: t,
464
- origin: w().origin,
466
+ origin: R().origin,
465
467
  sessionId: this.state.sessionId ?? void 0,
466
468
  createdAt: r,
467
469
  lastUsedAt: r
468
470
  }).catch((i) => {
469
- f("web-sdk.attachments", "Failed to store Product Agent attachment", {
471
+ w("web-sdk.attachments", "Failed to store Product Agent attachment", {
470
472
  attachmentId: s,
471
473
  name: n.name,
472
474
  message: i instanceof Error ? i.message : String(i)
@@ -478,7 +480,7 @@ class $t {
478
480
  return await this.uploadAttachmentForMessage({
479
481
  file: t,
480
482
  attachment: s,
481
- clientMessageId: q(),
483
+ clientMessageId: Q(),
482
484
  waitForSession: !1,
483
485
  notifyCompletion: !1
484
486
  });
@@ -495,7 +497,7 @@ class $t {
495
497
  waitForSession: !0,
496
498
  notifyCompletion: !0
497
499
  }).catch((i) => {
498
- f("web-sdk.agent", "Attachment background upload failed", {
500
+ w("web-sdk.agent", "Attachment background upload failed", {
499
501
  attachmentId: n.id,
500
502
  name: n.name,
501
503
  message: i instanceof Error ? i.message : String(i)
@@ -510,55 +512,55 @@ class $t {
510
512
  waitForSession: r,
511
513
  notifyCompletion: i
512
514
  }) {
513
- const o = r ? await this.waitForSessionId() : this.state.sessionId, l = Lt(t), u = {
515
+ const o = r ? await this.waitForSessionId() : this.state.sessionId, a = Te(t), u = {
514
516
  sessionId: o ?? void 0,
515
517
  attachmentId: s.id,
516
518
  clientId: this.options.clientId,
517
519
  transportId: this.transportIdentity.transportId,
518
520
  name: t.name || "attachment",
519
- mimeType: l,
521
+ mimeType: a,
520
522
  sizeBytes: t.size,
521
- page: w(),
523
+ page: R(),
522
524
  model: this.options.model,
523
- metadata: Rt(this.options.metadata)
524
- }, c = this.options.prepareAttachmentUpload ? await tt(
525
+ metadata: ae(this.options.metadata)
526
+ }, l = this.options.prepareAttachmentUpload ? await Rt(
525
527
  () => this.options.prepareAttachmentUpload(u),
526
528
  "Failed to prepare attachment upload"
527
529
  ) : await this.prepareEmbedAttachmentUpload(u);
528
- await tt(async () => {
529
- const h = await fetch(c.uploadUrl, {
530
- method: c.uploadMethod,
531
- headers: c.uploadHeaders,
530
+ await Rt(async () => {
531
+ const d = await fetch(l.uploadUrl, {
532
+ method: l.uploadMethod,
533
+ headers: l.uploadHeaders,
532
534
  body: t
533
535
  });
534
- if (!h.ok)
535
- throw new H("Failed to upload attachment", h.status);
536
- return h;
537
- }, "Failed to upload attachment"), this.setState({ sessionId: c.sessionId });
538
- const a = Qt(c.attachment, this.options.backendUrl);
539
- return this.updateAttachmentInState(s.id, a), s.id && xt(s.id, {
540
- sessionId: c.sessionId,
541
- fileUrl: a.fileUrl,
542
- gcsPath: a.gcsPath,
536
+ if (!d.ok)
537
+ throw new st("Failed to upload attachment", d.status);
538
+ return d;
539
+ }, "Failed to upload attachment"), this.setState({ sessionId: l.sessionId });
540
+ const c = Be(l.attachment, this.options.backendUrl);
541
+ return this.updateAttachmentInState(s.id, c), s.id && Se(s.id, {
542
+ sessionId: l.sessionId,
543
+ fileUrl: c.fileUrl,
544
+ gcsPath: c.gcsPath,
543
545
  lastUsedAt: Date.now()
544
- }).catch((h) => {
545
- f("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
546
+ }).catch((d) => {
547
+ w("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
546
548
  attachmentId: s.id,
547
- name: a.name,
548
- message: h instanceof Error ? h.message : String(h)
549
+ name: c.name,
550
+ message: d instanceof Error ? d.message : String(d)
549
551
  });
550
- }), i && a.gcsPath && this.send({
552
+ }), i && c.gcsPath && this.send({
551
553
  type: "attachment.upload_completed",
552
- sessionId: c.sessionId,
554
+ sessionId: l.sessionId,
553
555
  clientMessageId: n,
554
- attachment: a
555
- }), a;
556
+ attachment: c
557
+ }), c;
556
558
  }
557
559
  waitForSessionId() {
558
560
  return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
559
561
  const n = window.setTimeout(() => {
560
562
  r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
561
- }, ve), r = this.on("state", (i) => {
563
+ }, ks), r = this.on("state", (i) => {
562
564
  i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
563
565
  });
564
566
  });
@@ -576,18 +578,18 @@ class $t {
576
578
  }
577
579
  async prepareEmbedAttachmentUpload(t) {
578
580
  let s = !1;
579
- return await tt(async () => {
581
+ return await Rt(async () => {
580
582
  const n = await this.fetchEmbedAttachmentUpload(t);
581
583
  if (n.ok)
582
584
  return await n.json();
583
- if (bn(n.status) && this.options.tokenProvider && !s) {
585
+ if (Ir(n.status) && this.options.tokenProvider && !s) {
584
586
  s = !0;
585
587
  const r = await this.fetchEmbedAttachmentUpload(t);
586
588
  if (r.ok)
587
589
  return await r.json();
588
- throw new H("Failed to prepare attachment upload", r.status);
590
+ throw new st("Failed to prepare attachment upload", r.status);
589
591
  }
590
- throw new H("Failed to prepare attachment upload", n.status);
592
+ throw new st("Failed to prepare attachment upload", n.status);
591
593
  }, "Failed to prepare attachment upload");
592
594
  }
593
595
  async fetchEmbedAttachmentUpload(t) {
@@ -606,10 +608,10 @@ class $t {
606
608
  }
607
609
  startNewSession(t = {}) {
608
610
  const s = t.notifyTransport !== !1;
609
- !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, s && this.send({
611
+ !this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, s && this.send({
610
612
  type: "session.reset",
611
613
  sessionId: this.state.sessionId ?? void 0,
612
- page: w()
614
+ page: R()
613
615
  }), this.setState({
614
616
  sessionId: null,
615
617
  starterPrompts: [...this.state.starterPrompts],
@@ -624,15 +626,15 @@ class $t {
624
626
  });
625
627
  }
626
628
  listSessions(t = {}) {
627
- const s = q(), n = new Promise((i, o) => {
628
- const l = window.setTimeout(() => {
629
+ const s = Q(), n = new Promise((i, o) => {
630
+ const a = window.setTimeout(() => {
629
631
  this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
630
- }, Be);
631
- this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: l });
632
+ }, Es);
633
+ this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
632
634
  }), r = {
633
635
  type: "sessions.list",
634
636
  requestId: s,
635
- page: w(),
637
+ page: R(),
636
638
  ...t.cursor ? { cursor: t.cursor } : {},
637
639
  ...t.limit ? { limit: t.limit } : {}
638
640
  };
@@ -643,7 +645,7 @@ class $t {
643
645
  return n;
644
646
  }
645
647
  loadSession(t) {
646
- !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.clearThinkingWatchdog(), this.setState({
648
+ !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.clearThinkingWatchdog(), this.lastUserMessagePageUrl = null, this.setState({
647
649
  sessionId: t,
648
650
  assistantDraft: "",
649
651
  assistantDraftItemId: null,
@@ -656,11 +658,11 @@ class $t {
656
658
  }), this.send({
657
659
  type: "session.load",
658
660
  sessionId: t,
659
- page: w()
661
+ page: R()
660
662
  });
661
663
  }
662
664
  send(t) {
663
- this.sendNow(A(t)) || (this.queuedClientEvents.push(t), U(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
665
+ this.sendNow(_(t)) || (this.queuedClientEvents.push(t), W(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
664
666
  }
665
667
  async getUploadToken() {
666
668
  const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
@@ -675,7 +677,7 @@ class $t {
675
677
  try {
676
678
  return s.send(JSON.stringify(t)), !0;
677
679
  } catch (n) {
678
- return f("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
680
+ return w("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
679
681
  message: n instanceof Error ? n.message : String(n),
680
682
  queuedClientEventCount: this.queuedClientEvents.length,
681
683
  isThinking: this.state.isThinking
@@ -686,9 +688,9 @@ class $t {
686
688
  if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
687
689
  return;
688
690
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
689
- const t = hs();
691
+ const t = tn();
690
692
  this.sendNow(
691
- A({
693
+ _({
692
694
  type: "starter_prompts.page_context",
693
695
  pageUrl: t.pageUrl,
694
696
  pageTitle: t.pageTitle,
@@ -697,13 +699,13 @@ class $t {
697
699
  ) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
698
700
  }
699
701
  startStarterPromptUrlWatcher() {
700
- this.locationChangeCleanup || (this.locationChangeCleanup = ps(() => this.handleStarterPromptUrlChange()));
702
+ this.locationChangeCleanup || (this.locationChangeCleanup = en(() => this.handleStarterPromptUrlChange()));
701
703
  }
702
704
  handleStarterPromptUrlChange() {
703
705
  const t = location.href;
704
706
  t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
705
707
  this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
706
- }, je));
708
+ }, Ps));
707
709
  }
708
710
  refreshStarterPromptsForCurrentUrl() {
709
711
  this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
@@ -718,14 +720,14 @@ class $t {
718
720
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
719
721
  return;
720
722
  const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
721
- U(this.options.clientId, this.queuedClientEvents);
723
+ W(this.options.clientId, this.queuedClientEvents);
722
724
  for (let s = 0; s < t.length; s += 1) {
723
725
  const n = t[s];
724
- if (!this.sendNow(A(n))) {
725
- this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), U(this.options.clientId, this.queuedClientEvents);
726
+ if (!this.sendNow(_(n))) {
727
+ this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), W(this.options.clientId, this.queuedClientEvents);
726
728
  return;
727
729
  }
728
- U(this.options.clientId, this.queuedClientEvents);
730
+ W(this.options.clientId, this.queuedClientEvents);
729
731
  }
730
732
  }
731
733
  handleServerEvent(t) {
@@ -737,29 +739,29 @@ class $t {
737
739
  this.clearHeartbeatAckTimer();
738
740
  return;
739
741
  }
740
- if (Ke(t) && this.markThinkingProgress(), t.type === "auth.ok") {
742
+ if (vs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
741
743
  this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
742
- const s = Ts(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
743
- f("web-sdk.agent", "Received auth.ok appearance", {
744
+ const s = hn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
745
+ w("web-sdk.agent", "Received auth.ok appearance", {
744
746
  hasAppearance: n,
745
747
  rawAppearance: t.appearance,
746
748
  normalizedAppearance: s
747
- }), this.runtimeHelperJavascript = ws(t.runtimeHelpers)?.javascript ?? null;
748
- const r = bt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, l = {
749
- user: Es(t.user),
749
+ }), this.runtimeHelperJavascript = pn(t.runtimeHelpers)?.javascript ?? null;
750
+ const r = ue(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
751
+ user: yn(t.user),
750
752
  status: "connected"
751
753
  };
752
- (i || this.state.starterPrompts.length === 0) && (l.starterPrompts = r, l.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (l.appearance = s), this.setState(l), i && r.length === 0 && !o && !gs() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
754
+ (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !nn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
753
755
  type: "page.upsert",
754
756
  sessionId: this.state.sessionId,
755
- page: w(),
757
+ page: R(),
756
758
  model: this.options.model
757
759
  });
758
760
  return;
759
761
  }
760
762
  if (t.type === "starterPrompts.updated") {
761
763
  this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
762
- starterPrompts: bt(t, "starterPrompts"),
764
+ starterPrompts: ue(t, "starterPrompts"),
763
765
  starterPromptsLoading: !1
764
766
  });
765
767
  return;
@@ -767,36 +769,37 @@ class $t {
767
769
  if (t.type === "conversation.state") {
768
770
  const s = Array.isArray(t.items) ? t.items : [];
769
771
  this.rememberUserMessageClientMessageIds(s);
770
- const n = $s(s);
772
+ const n = Bn(s);
771
773
  if (n) {
772
- const a = zs(s, n);
774
+ const c = qn(s, n);
773
775
  this.retryAttemptsByClientMessageId[n] = Math.max(
774
776
  this.retryAttemptsByClientMessageId[n] ?? 0,
775
- a
777
+ c
776
778
  );
777
779
  }
778
- const r = s.filter((a) => {
779
- const h = D(a);
780
- return !Ut(h) && (!n || !it(h));
781
- }), i = vs(
780
+ const r = s.filter((c) => {
781
+ const d = x(c);
782
+ return !fe(d) && (!n || !Ut(d));
783
+ }), i = Pn(
782
784
  this.state.messages,
783
- Rs(r, this.options.backendUrl)
784
- ), o = Pt(i), l = s.some(
785
- (a) => Nt(
786
- D(a),
785
+ Tn(r, this.options.backendUrl)
786
+ ), o = pe(i), a = s.some(
787
+ (c) => me(
788
+ x(c),
787
789
  this.state.assistantDraft,
788
790
  this.state.assistantDraftItemId,
789
791
  this.state.assistantDraftRespondsToUserMessageId,
790
792
  this.state.assistantDraftRunId
791
793
  )
792
- ), u = o && (!this.state.assistantDraft || l);
793
- if (!o && js(this.state.messages, s))
794
+ ), u = o && (!this.state.assistantDraft || a);
795
+ if (!o && xn(this.state.messages, s))
794
796
  return;
795
- const c = u ? null : ot(s);
796
- if (this.latestRecoverableClientMessageId = c, Hs(i) && this.clearRetryTimers(), this.setState({
797
- sessionId: T(t.session, "id") ?? this.state.sessionId,
797
+ this.lastUserMessagePageUrl = Ln(s);
798
+ const l = u ? null : Dt(s);
799
+ if (this.latestRecoverableClientMessageId = l, On(i) && this.clearRetryTimers(), this.setState({
800
+ sessionId: E(t.session, "id") ?? this.state.sessionId,
798
801
  messages: i,
799
- ...l ? {
802
+ ...a ? {
800
803
  assistantDraft: "",
801
804
  assistantDraftItemId: null,
802
805
  assistantDraftPhase: null,
@@ -805,36 +808,36 @@ class $t {
805
808
  } : {},
806
809
  ...u ? {
807
810
  isThinking: !1
808
- } : c ? {
811
+ } : l ? {
809
812
  isThinking: !0,
810
813
  lastError: null
811
814
  } : {}
812
- }), u ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : c && (this.activeClientMessageId = c, this.markThinkingProgress()), n) {
813
- const a = T(t.session, "id") ?? this.state.sessionId;
814
- a && this.retryAfterInterruptedRun(a, n);
815
+ }), u ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : l && (this.activeClientMessageId = l, this.markThinkingProgress()), n) {
816
+ const c = E(t.session, "id") ?? this.state.sessionId;
817
+ c && this.retryAfterInterruptedRun(c, n);
815
818
  }
816
819
  return;
817
820
  }
818
821
  if (t.type === "sessions.page") {
819
822
  const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
820
823
  s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
821
- sessions: _s(t.sessions),
824
+ sessions: wn(t.sessions),
822
825
  nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
823
826
  }));
824
827
  return;
825
828
  }
826
829
  if (t.type === "session.updated") {
827
- this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: T(t.session, "id") ?? this.state.sessionId });
830
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: E(t.session, "id") ?? this.state.sessionId });
828
831
  return;
829
832
  }
830
833
  if (t.type === "session.item") {
831
834
  this.rememberUserMessageClientMessageIds([t.item]);
832
- const s = D(t.item);
833
- if (it(s)) {
835
+ const s = x(t.item);
836
+ if (Ut(s)) {
834
837
  typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
835
- const r = T(t.item, "sessionId") ?? this.state.sessionId, i = s ? R(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, l = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
836
- if (r && l) {
837
- this.retryAfterInterruptedRun(r, l);
838
+ const r = E(t.item, "sessionId") ?? this.state.sessionId, i = s ? O(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
839
+ if (r && a) {
840
+ this.retryAfterInterruptedRun(r, a);
838
841
  return;
839
842
  }
840
843
  if (r && i) {
@@ -842,23 +845,23 @@ class $t {
842
845
  return;
843
846
  }
844
847
  }
845
- if (Ut(s))
848
+ if (fe(s))
846
849
  return;
847
- const n = Gt(t.item, this.options.backendUrl);
850
+ const n = Ue(t.item, this.options.backendUrl);
848
851
  if (n) {
849
- N(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
852
+ j(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
850
853
  const r = t.item.data;
851
- Xs(r) && this.clearRunAckResyncRetryTimer();
852
- const i = Xt(this.state.messages, n), o = Pt(i), l = Nt(
854
+ Fn(r) && this.clearRunAckResyncRetryTimer();
855
+ const i = De(this.state.messages, n), o = pe(i), a = me(
853
856
  r,
854
857
  this.state.assistantDraft,
855
858
  this.state.assistantDraftItemId,
856
859
  this.state.assistantDraftRespondsToUserMessageId,
857
860
  this.state.assistantDraftRunId
858
- ), u = o && (!this.state.assistantDraft || l);
861
+ ), u = o && (!this.state.assistantDraft || a);
859
862
  this.setState({
860
863
  messages: i,
861
- ...l ? {
864
+ ...a ? {
862
865
  assistantDraft: "",
863
866
  assistantDraftItemId: null,
864
867
  assistantDraftPhase: null,
@@ -901,9 +904,9 @@ class $t {
901
904
  }
902
905
  if (t.type === "tool.call") {
903
906
  this.clearRunAckResyncRetryTimer();
904
- const s = Ls(t);
907
+ const s = Mn(t);
905
908
  if (s) {
906
- const n = Ns(
909
+ const n = Rn(
907
910
  this.state.messages,
908
911
  s
909
912
  );
@@ -932,14 +935,14 @@ class $t {
932
935
  return;
933
936
  }
934
937
  o && r && i && (this.retryableClientMessageId = i);
935
- const l = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = us(l.message);
938
+ const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), u = Zs(a.message);
936
939
  u && console.error(u), this.setState({
937
940
  status: "error",
938
941
  isThinking: !1,
939
- lastError: l.message,
942
+ lastError: a.message,
940
943
  lastErrorCode: typeof t.code == "string" ? t.code : null,
941
944
  lastErrorSecuritySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : null
942
- }), this.clearThinkingWatchdog(), this.emit("error", l);
945
+ }), this.clearThinkingWatchdog(), this.emit("error", a);
943
946
  }
944
947
  }
945
948
  retryAfterRetryableError(t) {
@@ -948,20 +951,20 @@ class $t {
948
951
  return !1;
949
952
  if (t.code === "run_still_active") {
950
953
  if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
951
- const l = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
954
+ const a = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
952
955
  this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
953
956
  delete this.retryTimersByClientMessageId[n], this.resyncThinkingSession(), this.markThinkingProgress();
954
- }, l);
957
+ }, a);
955
958
  }
956
959
  return !0;
957
960
  }
958
961
  if (this.retryTimersByClientMessageId[n] !== void 0)
959
962
  return !0;
960
963
  const i = this.retryAttemptsByClientMessageId[n] ?? 0;
961
- if (i >= L)
964
+ if (i >= K)
962
965
  return !1;
963
966
  this.retryAttemptsByClientMessageId[n] = i + 1;
964
- const o = B(
967
+ const o = V(
965
968
  i,
966
969
  typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
967
970
  );
@@ -978,7 +981,7 @@ class $t {
978
981
  if (this.retryTimersByClientMessageId[s] !== void 0)
979
982
  return;
980
983
  const n = this.retryAttemptsByClientMessageId[s] ?? 0;
981
- if (n >= L) {
984
+ if (n >= K) {
982
985
  this.retryableClientMessageId = s, this.setState({
983
986
  isThinking: !1,
984
987
  lastError: "Pluno could not finish this message. Try it again.",
@@ -988,7 +991,7 @@ class $t {
988
991
  }
989
992
  this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
990
993
  delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !0 });
991
- }, B(n));
994
+ }, V(n));
992
995
  }
993
996
  clearRetryTimers() {
994
997
  for (const t of Object.values(this.retryTimersByClientMessageId))
@@ -997,7 +1000,7 @@ class $t {
997
1000
  }
998
1001
  rememberUserMessageClientMessageIds(t) {
999
1002
  for (const s of t) {
1000
- const n = T(s, "id"), r = D(s);
1003
+ const n = E(s, "id"), r = x(s);
1001
1004
  n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
1002
1005
  }
1003
1006
  }
@@ -1007,7 +1010,7 @@ class $t {
1007
1010
  this.pendingSessionHistoryRequests.clear();
1008
1011
  }
1009
1012
  markThinkingProgress() {
1010
- !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(kt), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1013
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ie), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
1011
1014
  }
1012
1015
  scheduleThinkingWatchdog(t) {
1013
1016
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -1027,10 +1030,10 @@ class $t {
1027
1030
  scheduleRunAckWatchdog(t) {
1028
1031
  this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
1029
1032
  this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
1030
- }, De);
1033
+ }, ws);
1031
1034
  }
1032
1035
  recoverMissedRunAck(t) {
1033
- !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (f("web-sdk.agent", "Pluno run ack missed; resyncing session", {
1036
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (w("web-sdk.agent", "Pluno run ack missed; resyncing session", {
1034
1037
  sessionId: this.state.sessionId,
1035
1038
  clientMessageId: t
1036
1039
  }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
@@ -1038,12 +1041,12 @@ class $t {
1038
1041
  scheduleRunAckResyncRetry(t) {
1039
1042
  this.clearRunAckResyncRetryTimer();
1040
1043
  const s = this.retryAttemptsByClientMessageId[t] ?? 0;
1041
- s >= L || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1044
+ s >= K || (this.runAckResyncRetryTimer = window.setTimeout(() => {
1042
1045
  this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
1043
1046
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1044
1047
  isThinking: !0,
1045
1048
  lastError: null
1046
- }), f("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
1049
+ }), w("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
1047
1050
  sessionId: this.state.sessionId,
1048
1051
  clientMessageId: t
1049
1052
  }), this.state.sessionId ? this.send({
@@ -1051,8 +1054,8 @@ class $t {
1051
1054
  sessionId: this.state.sessionId,
1052
1055
  clientMessageId: t,
1053
1056
  automatic: !0
1054
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(kt)));
1055
- }, B(s, Ne)));
1057
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ie)));
1058
+ }, V(s, Is)));
1056
1059
  }
1057
1060
  clearRunAckResyncRetryTimer() {
1058
1061
  this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
@@ -1065,7 +1068,7 @@ class $t {
1065
1068
  return;
1066
1069
  const t = this.activeClientMessageId;
1067
1070
  if (!t) {
1068
- f("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
1071
+ w("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
1069
1072
  sessionId: this.state.sessionId
1070
1073
  }), this.setState({
1071
1074
  isThinking: !1,
@@ -1075,8 +1078,8 @@ class $t {
1075
1078
  return;
1076
1079
  }
1077
1080
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
1078
- if (n >= L) {
1079
- f("web-sdk.agent", "Pluno run recovery retry exhausted", {
1081
+ if (n >= K) {
1082
+ w("web-sdk.agent", "Pluno run recovery retry exhausted", {
1080
1083
  sessionId: this.state.sessionId,
1081
1084
  clientMessageId: t
1082
1085
  }), this.retryableClientMessageId = t, this.setState({
@@ -1087,18 +1090,18 @@ class $t {
1087
1090
  return;
1088
1091
  }
1089
1092
  if (s < 1) {
1090
- this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, f("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
1093
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, w("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
1091
1094
  sessionId: this.state.sessionId,
1092
1095
  clientMessageId: t,
1093
1096
  resyncAttempts: s + 1
1094
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ue);
1097
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ts);
1095
1098
  return;
1096
1099
  }
1097
1100
  this.setState({
1098
1101
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
1099
1102
  isThinking: !0,
1100
1103
  lastError: null
1101
- }), f("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
1104
+ }), w("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
1102
1105
  sessionId: this.state.sessionId,
1103
1106
  clientMessageId: t,
1104
1107
  retryAttempts: n + 1
@@ -1109,32 +1112,32 @@ class $t {
1109
1112
  clientMessageId: t,
1110
1113
  automatic: !0
1111
1114
  }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
1112
- }, B(n)));
1115
+ }, V(n)));
1113
1116
  }
1114
1117
  resyncThinkingSession() {
1115
1118
  this.state.sessionId ? this.send({
1116
1119
  type: "page.upsert",
1117
1120
  sessionId: this.state.sessionId,
1118
- page: w(),
1121
+ page: R(),
1119
1122
  model: this.options.model
1120
1123
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
1121
1124
  }
1122
1125
  async executeToolCall(t) {
1123
- const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = M(
1126
+ const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = L(
1124
1127
  typeof t.summary == "string" ? t.summary : "Running browser tool"
1125
1128
  ), o = t.rawInput;
1126
1129
  if (!s || !n || !r)
1127
1130
  return;
1128
- const l = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1129
- if (r !== "execute_code" && !l || !gn(o)) {
1131
+ const a = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
1132
+ if (r !== "execute_code" && !a || !cr(o)) {
1130
1133
  this.setToolMessageLoading(n, !1), this.send({
1131
1134
  type: "tool.result",
1132
1135
  sessionId: s,
1133
1136
  callId: n,
1134
1137
  toolName: r,
1135
1138
  summary: i,
1136
- rawInput: A(o),
1137
- rawOutput: A({
1139
+ rawInput: _(o),
1140
+ rawOutput: _({
1138
1141
  ok: !1,
1139
1142
  toolName: r,
1140
1143
  error: `Unsupported browser tool: ${r}`
@@ -1142,7 +1145,7 @@ class $t {
1142
1145
  });
1143
1146
  return;
1144
1147
  }
1145
- const u = Ye(this.state.messages);
1148
+ const u = Bs(this.state.messages);
1146
1149
  this.activeBrowserToolCalls.set(n, {
1147
1150
  event: {
1148
1151
  type: "tool.result",
@@ -1150,18 +1153,18 @@ class $t {
1150
1153
  callId: n,
1151
1154
  toolName: r,
1152
1155
  summary: i,
1153
- rawInput: A(o),
1156
+ rawInput: _(o),
1154
1157
  rawOutput: null
1155
1158
  },
1156
1159
  startedAtMs: Date.now(),
1157
1160
  startedAtUrl: location.href,
1158
1161
  startedAtOrigin: location.origin
1159
1162
  }), this.installSessionUserFilesApi(u);
1160
- let c = null, a;
1161
- c = await this.executeRuntimeHelper(), a = await _t(o).catch((h) => ({
1163
+ let l = null, c;
1164
+ l = await this.executeRuntimeHelper(), c = await ce(o).catch((d) => ({
1162
1165
  ok: !1,
1163
1166
  exception: {
1164
- message: h instanceof Error ? h.message : String(h)
1167
+ message: d instanceof Error ? d.message : String(d)
1165
1168
  }
1166
1169
  })), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
1167
1170
  type: "tool.result",
@@ -1169,12 +1172,12 @@ class $t {
1169
1172
  callId: n,
1170
1173
  toolName: r,
1171
1174
  summary: o.summary,
1172
- rawInput: A(o),
1173
- rawOutput: A(As(a, c))
1174
- }), nn(this.options.clientId, this.activeBrowserToolCalls.values());
1175
+ rawInput: _(o),
1176
+ rawOutput: _(fn(c, l))
1177
+ }), Yn(this.options.clientId, this.activeBrowserToolCalls.values());
1175
1178
  }
1176
1179
  setToolMessageLoading(t, s) {
1177
- const n = Os(
1180
+ const n = _n(
1178
1181
  this.state.messages,
1179
1182
  t,
1180
1183
  s
@@ -1185,50 +1188,50 @@ class $t {
1185
1188
  if (this.pageLifecycleCleanup)
1186
1189
  return;
1187
1190
  const t = () => {
1188
- Yt(this.options.clientId, this.activeBrowserToolCalls.values());
1191
+ Le(this.options.clientId, this.activeBrowserToolCalls.values());
1189
1192
  };
1190
1193
  window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
1191
1194
  window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
1192
1195
  };
1193
1196
  }
1194
1197
  installSessionUserFilesApi(t) {
1195
- this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Ze(t, this.attachmentFiles, this.attachmentBlobCache);
1198
+ this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = qs(t, this.attachmentFiles, this.attachmentBlobCache);
1196
1199
  }
1197
1200
  cleanupSessionUserFilesApi() {
1198
- this.sessionUserFilesApiCleanup && (os(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1201
+ this.sessionUserFilesApiCleanup && (Js(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
1199
1202
  }
1200
1203
  async executeRuntimeHelper() {
1201
1204
  if (!this.runtimeHelperJavascript?.trim())
1202
1205
  return null;
1203
- const t = await _t({
1206
+ const t = await ce({
1204
1207
  javascript: this.runtimeHelperJavascript
1205
1208
  });
1206
- return t.ok === !1 ? Ss(t) : null;
1209
+ return t.ok === !1 ? gn(t) : null;
1207
1210
  }
1208
1211
  enableNetworkCapture() {
1209
- this.networkCaptureCleanup || (this.networkCaptureCleanup = Ge((t) => {
1210
- An(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1212
+ this.networkCaptureCleanup || (this.networkCaptureCleanup = Ns((t) => {
1213
+ fr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
1211
1214
  }));
1212
1215
  }
1213
1216
  enqueueNetworkEvent(t) {
1214
- this.queuedNetworkEvents.length >= Le || (this.queuedNetworkEvents.push(wn(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1217
+ this.queuedNetworkEvents.length >= Ss || (this.queuedNetworkEvents.push(pr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
1215
1218
  this.networkBatchTimer = null;
1216
1219
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
1217
1220
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
1218
1221
  type: "network.batch",
1219
1222
  sessionId: this.state.sessionId ?? void 0,
1220
- page: w(),
1223
+ page: R(),
1221
1224
  events: s
1222
1225
  });
1223
- }, Oe)));
1226
+ }, As)));
1224
1227
  }
1225
1228
  scheduleReconnect() {
1226
1229
  if (this.reconnectTimer !== null || this.state.status === "closed")
1227
1230
  return;
1228
- const t = $e(this.reconnectAttempts);
1231
+ const t = Us(this.reconnectAttempts);
1229
1232
  this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
1230
1233
  this.reconnectTimer = null, this.connect().catch((s) => {
1231
- f("web-sdk.agent", "Pluno reconnect failed; retrying", {
1234
+ w("web-sdk.agent", "Pluno reconnect failed; retrying", {
1232
1235
  message: s instanceof Error ? s.message : String(s),
1233
1236
  queuedClientEventCount: this.queuedClientEvents.length,
1234
1237
  isThinking: this.state.isThinking
@@ -1240,9 +1243,9 @@ class $t {
1240
1243
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
1241
1244
  const t = this.socket;
1242
1245
  !t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
1243
- this.socket === t && (f("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1244
- }, _e));
1245
- }, Re);
1246
+ this.socket === t && (w("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
1247
+ }, ps));
1248
+ }, hs);
1246
1249
  }
1247
1250
  stopHeartbeat() {
1248
1251
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
@@ -1268,105 +1271,105 @@ class $t {
1268
1271
  ...t,
1269
1272
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
1270
1273
  ...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
1271
- }, en(this.options.clientId, this.state), this.emit("state", this.getState());
1274
+ }, Kn(this.options.clientId, this.state), this.emit("state", this.getState());
1272
1275
  }
1273
1276
  emit(t, s) {
1274
1277
  this.listeners[t]?.forEach((r) => r(s));
1275
1278
  }
1276
1279
  }
1277
- const Z = /* @__PURE__ */ new WeakMap();
1278
- function Ge(e) {
1279
- const t = window.__plunoProductAgentNetworkCapture ?? Xe();
1280
+ const Et = /* @__PURE__ */ new WeakMap();
1281
+ function Ns(e) {
1282
+ const t = window.__plunoProductAgentNetworkCapture ?? Os();
1280
1283
  return t.subscribers.add(e), () => {
1281
1284
  t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
1282
1285
  };
1283
1286
  }
1284
- function Xe() {
1285
- const e = /* @__PURE__ */ new Set(), t = (g) => {
1287
+ function Os() {
1288
+ const e = /* @__PURE__ */ new Set(), t = (m) => {
1286
1289
  e.forEach((p) => {
1287
1290
  try {
1288
- p(g);
1291
+ p(m);
1289
1292
  } catch {
1290
1293
  }
1291
1294
  });
1292
- }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, d) {
1293
- const m = Date.now();
1294
- let I;
1295
+ }, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, h) {
1296
+ const g = Date.now();
1297
+ let T;
1295
1298
  try {
1296
- I = s.call(this, p, d);
1299
+ T = s.call(this, p, h);
1297
1300
  } catch (y) {
1298
1301
  throw y;
1299
1302
  }
1300
1303
  try {
1301
- const y = p instanceof Request ? p : null, O = mn(p, y), C = te(d?.headers ?? y?.headers);
1302
- if (!b(O, C, d?.body)) {
1303
- const K = {
1304
- requestId: Q("fetch"),
1305
- url: k(O, Y),
1306
- method: (d?.method ?? y?.method ?? "GET").toUpperCase(),
1307
- requestHeaders: C,
1308
- requestBody: Bt(d?.body),
1304
+ const y = p instanceof Request ? p : null, N = lr(p, y), I = qe(h?.headers ?? y?.headers);
1305
+ if (!v(N, I, h?.body)) {
1306
+ const q = {
1307
+ requestId: bt("fetch"),
1308
+ url: C(N, St),
1309
+ method: (h?.method ?? y?.method ?? "GET").toUpperCase(),
1310
+ requestHeaders: I,
1311
+ requestBody: we(h?.body),
1309
1312
  resourceType: "fetch",
1310
- startedAt: new Date(m).toISOString()
1313
+ startedAt: new Date(g).toISOString()
1311
1314
  };
1312
- I.then(
1313
- (_) => {
1314
- yn(_, K, m, t).catch(() => {
1315
+ T.then(
1316
+ (b) => {
1317
+ ur(b, q, g, t).catch(() => {
1315
1318
  t({
1316
- ...K,
1317
- responseStatus: _.status,
1318
- durationMs: Date.now() - m
1319
+ ...q,
1320
+ responseStatus: b.status,
1321
+ durationMs: Date.now() - g
1319
1322
  });
1320
1323
  });
1321
1324
  },
1322
- (_) => {
1325
+ (b) => {
1323
1326
  t({
1324
- ...K,
1325
- errorText: k(_ instanceof Error ? _.message : String(_)),
1326
- durationMs: Date.now() - m
1327
+ ...q,
1328
+ errorText: C(b instanceof Error ? b.message : String(b)),
1329
+ durationMs: Date.now() - g
1327
1330
  });
1328
1331
  }
1329
1332
  );
1330
1333
  }
1331
1334
  } catch {
1332
1335
  }
1333
- return I;
1334
- }, l = function(p, d, m, I, y) {
1335
- const O = n.call(this, p, d, m ?? !0, I ?? void 0, y ?? void 0), C = typeof d == "string" ? d : d.toString();
1336
- return Z.set(this, {
1337
- requestId: Q("xhr"),
1336
+ return T;
1337
+ }, a = function(p, h, g, T, y) {
1338
+ const N = n.call(this, p, h, g ?? !0, T ?? void 0, y ?? void 0), I = typeof h == "string" ? h : h.toString();
1339
+ return Et.set(this, {
1340
+ requestId: bt("xhr"),
1338
1341
  method: String(p ?? "GET").toUpperCase(),
1339
- url: k(C, Y),
1342
+ url: C(I, St),
1340
1343
  requestHeaders: {},
1341
1344
  startedAtMs: Date.now(),
1342
1345
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
1343
- excluded: b(C)
1344
- }), O;
1345
- }, u = function(p, d) {
1346
- const m = r.call(this, p, d), I = Z.get(this);
1347
- return I && Object.keys(I.requestHeaders).length < ht && (I.requestHeaders[p] = Tt(p, d), I.excluded = I.excluded || b(I.url, I.requestHeaders)), m;
1348
- }, c = function(p) {
1346
+ excluded: v(I)
1347
+ }), N;
1348
+ }, u = function(p, h) {
1349
+ const g = r.call(this, p, h), T = Et.get(this);
1350
+ return T && Object.keys(T.requestHeaders).length < qt && (T.requestHeaders[p] = Gt(p, h), T.excluded = T.excluded || v(T.url, T.requestHeaders)), g;
1351
+ }, l = function(p) {
1349
1352
  try {
1350
- const d = Z.get(this);
1351
- d && (d.excluded = d.excluded || b(d.url, d.requestHeaders, p), d.requestBody = Bt(p), d.excluded || this.addEventListener(
1353
+ const h = Et.get(this);
1354
+ h && (h.excluded = h.excluded || v(h.url, h.requestHeaders, p), h.requestBody = we(p), h.excluded || this.addEventListener(
1352
1355
  "loadend",
1353
1356
  () => {
1354
1357
  queueMicrotask(() => {
1355
1358
  try {
1356
- const m = kn(this.getAllResponseHeaders());
1359
+ const g = mr(this.getAllResponseHeaders());
1357
1360
  t({
1358
- requestId: d.requestId,
1359
- url: d.url,
1360
- method: d.method,
1361
- requestHeaders: d.requestHeaders,
1362
- requestBody: d.requestBody,
1361
+ requestId: h.requestId,
1362
+ url: h.url,
1363
+ method: h.method,
1364
+ requestHeaders: h.requestHeaders,
1365
+ requestBody: h.requestBody,
1363
1366
  resourceType: "xhr",
1364
1367
  responseStatus: this.status,
1365
- responseHeaders: m,
1366
- responseBody: Tn(this, m),
1368
+ responseHeaders: g,
1369
+ responseBody: hr(this, g),
1367
1370
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
1368
- startedAt: d.startedAt,
1369
- durationMs: Date.now() - d.startedAtMs
1371
+ startedAt: h.startedAt,
1372
+ durationMs: Date.now() - h.startedAtMs
1370
1373
  });
1371
1374
  } catch {
1372
1375
  return;
@@ -1384,7 +1387,7 @@ function Xe() {
1384
1387
  } catch {
1385
1388
  }
1386
1389
  try {
1387
- XMLHttpRequest.prototype.open = l;
1390
+ XMLHttpRequest.prototype.open = a;
1388
1391
  } catch {
1389
1392
  }
1390
1393
  try {
@@ -1392,44 +1395,44 @@ function Xe() {
1392
1395
  } catch {
1393
1396
  }
1394
1397
  try {
1395
- XMLHttpRequest.prototype.send = c;
1398
+ XMLHttpRequest.prototype.send = l;
1396
1399
  } catch {
1397
1400
  }
1398
- let a = null;
1401
+ let c = null;
1399
1402
  if (typeof PerformanceObserver < "u") {
1400
- a = new PerformanceObserver((g) => {
1401
- for (const p of g.getEntries()) {
1402
- const d = p;
1403
- if (d.initiatorType === "fetch" || d.initiatorType === "xmlhttprequest" || b(d.name))
1403
+ c = new PerformanceObserver((m) => {
1404
+ for (const p of m.getEntries()) {
1405
+ const h = p;
1406
+ if (h.initiatorType === "fetch" || h.initiatorType === "xmlhttprequest" || v(h.name))
1404
1407
  continue;
1405
- const m = performance.timeOrigin + d.startTime;
1408
+ const g = performance.timeOrigin + h.startTime;
1406
1409
  t({
1407
- requestId: Q("resource"),
1408
- url: k(d.name, Y),
1410
+ requestId: bt("resource"),
1411
+ url: C(h.name, St),
1409
1412
  method: "GET",
1410
1413
  resourceType: "resource",
1411
- responseStatus: d.responseStatus,
1412
- startedAt: new Date(m).toISOString(),
1413
- durationMs: d.duration
1414
+ responseStatus: h.responseStatus,
1415
+ startedAt: new Date(g).toISOString(),
1416
+ durationMs: h.duration
1414
1417
  });
1415
1418
  }
1416
1419
  });
1417
1420
  try {
1418
- a.observe({ type: "resource", buffered: !0 });
1421
+ c.observe({ type: "resource", buffered: !0 });
1419
1422
  } catch {
1420
- a.disconnect(), a = null;
1423
+ c.disconnect(), c = null;
1421
1424
  }
1422
1425
  }
1423
- const h = {
1426
+ const d = {
1424
1427
  subscribers: e,
1425
1428
  destroy: () => {
1426
- a?.disconnect();
1429
+ c?.disconnect();
1427
1430
  try {
1428
1431
  window.fetch === o && (window.fetch = s);
1429
1432
  } catch {
1430
1433
  }
1431
1434
  try {
1432
- XMLHttpRequest.prototype.open === l && (XMLHttpRequest.prototype.open = n);
1435
+ XMLHttpRequest.prototype.open === a && (XMLHttpRequest.prototype.open = n);
1433
1436
  } catch {
1434
1437
  }
1435
1438
  try {
@@ -1437,14 +1440,14 @@ function Xe() {
1437
1440
  } catch {
1438
1441
  }
1439
1442
  try {
1440
- XMLHttpRequest.prototype.send === c && (XMLHttpRequest.prototype.send = i);
1443
+ XMLHttpRequest.prototype.send === l && (XMLHttpRequest.prototype.send = i);
1441
1444
  } catch {
1442
1445
  }
1443
1446
  }
1444
1447
  };
1445
- return window.__plunoProductAgentNetworkCapture = h, h;
1448
+ return window.__plunoProductAgentNetworkCapture = d, d;
1446
1449
  }
1447
- function f(e, t, s) {
1450
+ function w(e, t, s) {
1448
1451
  if (typeof window > "u")
1449
1452
  return;
1450
1453
  const n = window, r = {
@@ -1455,15 +1458,15 @@ function f(e, t, s) {
1455
1458
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
1456
1459
  i.push(r), i.length > 120 && i.splice(0, i.length - 120), n.__plunoProductAgentDiagnostics__ = i, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: r }));
1457
1460
  }
1458
- function Rt(e) {
1461
+ function ae(e) {
1459
1462
  const t = typeof e == "function" ? e() : e;
1460
1463
  return t && Object.keys(t).length > 0 ? t : void 0;
1461
1464
  }
1462
- function Ke(e) {
1465
+ function vs(e) {
1463
1466
  return e.type === "conversation.state" || e.type === "session.updated" || e.type === "session.item" || e.type === "chat.assistant_delta" || e.type === "chat.assistant_done" || e.type === "tool.call";
1464
1467
  }
1465
- const Je = 5e3, Ve = 12e4;
1466
- function Ye(e) {
1468
+ const Ls = 5e3, xs = 12e4;
1469
+ function Bs(e) {
1467
1470
  const t = [];
1468
1471
  for (const s of e)
1469
1472
  s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
@@ -1474,118 +1477,122 @@ function Ye(e) {
1474
1477
  });
1475
1478
  return t;
1476
1479
  }
1477
- function Ze(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1480
+ function qs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1478
1481
  const n = [
1479
- Qe(e, t, s),
1480
- ts()
1482
+ Fs(e, t, s),
1483
+ Ws(),
1484
+ Hs()
1481
1485
  ].filter((r) => typeof r == "function");
1482
1486
  return () => {
1483
1487
  for (const r of n.reverse())
1484
1488
  r();
1485
1489
  };
1486
1490
  }
1487
- function Qe(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1488
- const n = new Map(e.map((c) => [c.id, c])), r = (c) => ({
1489
- id: c.id,
1490
- name: c.name,
1491
- mimeType: c.mimeType,
1492
- sizeBytes: c.sizeBytes,
1493
- type: c.mimeType,
1494
- size: c.sizeBytes
1495
- }), i = (c) => {
1496
- const a = n.get(c);
1497
- if (!a)
1498
- throw new Error(`Unknown Pluno user file: ${c}`);
1499
- return a;
1500
- }, o = async (c) => {
1501
- const a = i(c), h = t.get(a.id);
1502
- if (h)
1503
- return h;
1504
- const g = s.get(a.id);
1505
- if (g)
1506
- return g;
1507
- const p = await le(a.id).then((y) => y?.blob ?? null).catch((y) => (f("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1508
- attachmentId: a.id,
1509
- name: a.name,
1491
+ function Hs() {
1492
+ return xt(globalThis, "getPageSnapshot", async () => Ft());
1493
+ }
1494
+ function Fs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
1495
+ const n = new Map(e.map((l) => [l.id, l])), r = (l) => ({
1496
+ id: l.id,
1497
+ name: l.name,
1498
+ mimeType: l.mimeType,
1499
+ sizeBytes: l.sizeBytes,
1500
+ type: l.mimeType,
1501
+ size: l.sizeBytes
1502
+ }), i = (l) => {
1503
+ const c = n.get(l);
1504
+ if (!c)
1505
+ throw new Error(`Unknown Pluno user file: ${l}`);
1506
+ return c;
1507
+ }, o = async (l) => {
1508
+ const c = i(l), d = t.get(c.id);
1509
+ if (d)
1510
+ return d;
1511
+ const m = s.get(c.id);
1512
+ if (m)
1513
+ return m;
1514
+ const p = await Ve(c.id).then((y) => y?.blob ?? null).catch((y) => (w("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
1515
+ attachmentId: c.id,
1516
+ name: c.name,
1510
1517
  message: y instanceof Error ? y.message : String(y)
1511
1518
  }), null));
1512
1519
  if (p)
1513
- return s.set(a.id, p), p;
1514
- if (!a.fileUrl)
1515
- throw new Error(`Pluno user file is missing content: ${c}`);
1516
- const d = await fetch(a.fileUrl, un(a.fileUrl));
1517
- if (!d.ok)
1518
- throw new Error(`Failed to load Pluno user file: ${c}`);
1519
- const m = await d.blob();
1520
- s.set(a.id, m);
1521
- const I = Date.now();
1522
- return qt({
1523
- attachmentId: a.id,
1524
- name: a.name,
1525
- mimeType: a.mimeType,
1526
- sizeBytes: a.sizeBytes,
1527
- blob: m,
1528
- fileUrl: a.fileUrl,
1529
- gcsPath: a.gcsPath,
1530
- createdAt: I,
1531
- lastUsedAt: I
1520
+ return s.set(c.id, p), p;
1521
+ if (!c.fileUrl)
1522
+ throw new Error(`Pluno user file is missing content: ${l}`);
1523
+ const h = await fetch(c.fileUrl, nr(c.fileUrl));
1524
+ if (!h.ok)
1525
+ throw new Error(`Failed to load Pluno user file: ${l}`);
1526
+ const g = await h.blob();
1527
+ s.set(c.id, g);
1528
+ const T = Date.now();
1529
+ return Ae({
1530
+ attachmentId: c.id,
1531
+ name: c.name,
1532
+ mimeType: c.mimeType,
1533
+ sizeBytes: c.sizeBytes,
1534
+ blob: g,
1535
+ fileUrl: c.fileUrl,
1536
+ gcsPath: c.gcsPath,
1537
+ createdAt: T,
1538
+ lastUsedAt: T
1532
1539
  }).catch((y) => {
1533
- f("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
1534
- attachmentId: a.id,
1535
- name: a.name,
1540
+ w("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
1541
+ attachmentId: c.id,
1542
+ name: c.name,
1536
1543
  message: y instanceof Error ? y.message : String(y)
1537
1544
  });
1538
- }), m;
1545
+ }), g;
1539
1546
  };
1540
- return Ht(globalThis, "userFiles", {
1547
+ return xt(globalThis, "userFiles", {
1541
1548
  list: () => e.map(r),
1542
- get: (c) => {
1543
- const a = n.get(c);
1544
- return a ? r(a) : null;
1549
+ get: (l) => {
1550
+ const c = n.get(l);
1551
+ return c ? r(c) : null;
1545
1552
  },
1546
- inspectImage: async (c) => {
1547
- const a = i(c), h = await o(c), g = a.mimeType.startsWith("image/") ? a.mimeType : h.type || a.mimeType;
1548
- if (!g.startsWith("image/"))
1549
- throw new Error(`Pluno user file is not an image: ${c}`);
1550
- const p = h.type === g ? h : new Blob([h], { type: g });
1551
- return as(g, p.size) > He ? {
1553
+ inspectImage: async (l) => {
1554
+ const c = i(l), d = await o(l), m = c.mimeType.startsWith("image/") ? c.mimeType : d.type || c.mimeType;
1555
+ if (!m.startsWith("image/"))
1556
+ throw new Error(`Pluno user file is not an image: ${l}`);
1557
+ const p = d.type === m ? d : new Blob([d], { type: m });
1558
+ return Ks(m, p.size) > Ms ? {
1552
1559
  type: "pluno.userFiles.inspectImage",
1553
- id: a.id,
1554
- name: a.name,
1555
- mimeType: g,
1556
- sizeBytes: a.sizeBytes,
1560
+ id: c.id,
1561
+ name: c.name,
1562
+ mimeType: m,
1563
+ sizeBytes: c.sizeBytes,
1557
1564
  imageAttached: !1,
1558
- imageAttachmentError: pt
1565
+ imageAttachmentError: Ht
1559
1566
  } : {
1560
1567
  type: "pluno.userFiles.inspectImage",
1561
- id: a.id,
1562
- name: a.name,
1563
- mimeType: g,
1564
- sizeBytes: a.sizeBytes,
1568
+ id: c.id,
1569
+ name: c.name,
1570
+ mimeType: m,
1571
+ sizeBytes: c.sizeBytes,
1565
1572
  imageAttached: !0,
1566
- dataUrl: await rt(p)
1573
+ dataUrl: await Pt(p)
1567
1574
  };
1568
1575
  },
1569
- getDataUrl: async (c) => (i(c), await rt(await o(c))),
1576
+ getDataUrl: async (l) => (i(l), await Pt(await o(l))),
1570
1577
  getBlob: o,
1571
- getArrayBuffer: async (c) => await (await o(c)).arrayBuffer(),
1572
- getFile: async (c) => {
1573
- const a = i(c);
1574
- return new File([await o(c)], a.name, { type: a.mimeType });
1578
+ getArrayBuffer: async (l) => await (await o(l)).arrayBuffer(),
1579
+ getFile: async (l) => {
1580
+ const c = i(l);
1581
+ return new File([await o(l)], c.name, { type: c.mimeType });
1575
1582
  }
1576
1583
  });
1577
1584
  }
1578
- function ts() {
1579
- return Ht(globalThis, "pageImages", {
1580
- inspectImage: async (t, s) => await es(t, s)
1585
+ function Ws() {
1586
+ return xt(globalThis, "pageImages", {
1587
+ inspectImage: async (t, s) => await $s(t, s)
1581
1588
  });
1582
1589
  }
1583
- async function es(e, t = {}) {
1584
- const s = is(t.name), n = await ss(e);
1590
+ async function $s(e, t = {}) {
1591
+ const s = Xs(t.name), n = await js(e);
1585
1592
  return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
1586
1593
  type: "pluno.pageImages.inspectImage",
1587
1594
  imageAttached: !1,
1588
- imageAttachmentError: pt
1595
+ imageAttachmentError: Ht
1589
1596
  } : {
1590
1597
  type: "pluno.pageImages.inspectImage",
1591
1598
  imageAttached: !0,
@@ -1599,26 +1606,26 @@ async function es(e, t = {}) {
1599
1606
  imageAttachmentError: n.error
1600
1607
  };
1601
1608
  }
1602
- async function ss(e) {
1603
- return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: pt } : {
1609
+ async function js(e) {
1610
+ return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: Ht } : {
1604
1611
  ok: !0,
1605
1612
  mimeType: e.type,
1606
1613
  sizeBytes: e.size,
1607
- dataUrl: await rt(e)
1608
- } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : ns(e);
1614
+ dataUrl: await Pt(e)
1615
+ } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : zs(e);
1609
1616
  }
1610
- function ns(e) {
1617
+ function zs(e) {
1611
1618
  if (!e.startsWith("data:") || !e.includes(","))
1612
1619
  return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
1613
- const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((l) => l.trim()).filter(Boolean), r = n[0] ?? "";
1620
+ const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
1614
1621
  if (!r.startsWith("image/"))
1615
1622
  return { ok: !1, error: "Page image MIME type must be image/*." };
1616
- if (!n.slice(1).some((l) => l.toLowerCase() === "base64"))
1623
+ if (!n.slice(1).some((a) => a.toLowerCase() === "base64"))
1617
1624
  return { ok: !1, error: "Page image data URL must be base64 encoded." };
1618
1625
  const i = s.replace(/[ \t\r\n\f]+/g, "");
1619
1626
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
1620
1627
  return { ok: !1, error: "Page image data URL has invalid base64." };
1621
- const o = rs(i);
1628
+ const o = Gs(i);
1622
1629
  return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
1623
1630
  ok: !0,
1624
1631
  mimeType: r,
@@ -1626,22 +1633,22 @@ function ns(e) {
1626
1633
  dataUrl: `data:${r};base64,${i}`
1627
1634
  };
1628
1635
  }
1629
- function rs(e) {
1636
+ function Gs(e) {
1630
1637
  if (e.length === 0 || e.length % 4 !== 0)
1631
1638
  return null;
1632
1639
  const t = e.length - e.replace(/=+$/, "").length;
1633
1640
  return t > 2 ? null : e.length / 4 * 3 - t;
1634
1641
  }
1635
- function is(e) {
1642
+ function Xs(e) {
1636
1643
  return (typeof e == "string" ? e.trim() : "") || "Page image";
1637
1644
  }
1638
- function os(e) {
1645
+ function Js(e) {
1639
1646
  try {
1640
1647
  e();
1641
1648
  } catch {
1642
1649
  }
1643
1650
  }
1644
- function rt(e) {
1651
+ function Pt(e) {
1645
1652
  return new Promise((t, s) => {
1646
1653
  const n = new FileReader();
1647
1654
  n.onload = () => {
@@ -1653,32 +1660,32 @@ function rt(e) {
1653
1660
  }, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
1654
1661
  });
1655
1662
  }
1656
- function as(e, t) {
1663
+ function Ks(e, t) {
1657
1664
  return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
1658
1665
  }
1659
- async function _t(e) {
1666
+ async function ce(e) {
1660
1667
  const t = Object.getPrototypeOf(async function() {
1661
- }).constructor, s = e.timeoutMs ?? Je, n = Date.now(), r = [];
1668
+ }).constructor, s = e.timeoutMs ?? Ls, n = Date.now(), r = [];
1662
1669
  let i;
1663
1670
  const o = {
1664
1671
  log: console.log,
1665
1672
  info: console.info,
1666
1673
  warn: console.warn,
1667
1674
  error: console.error
1668
- }, l = (u) => (...c) => {
1669
- r.push({ level: u, args: c }), o[u](...c);
1675
+ }, a = (u) => (...l) => {
1676
+ r.push({ level: u, args: l }), o[u](...l);
1670
1677
  };
1671
- console.log = l("log"), console.info = l("info"), console.warn = l("warn"), console.error = l("error");
1678
+ console.log = a("log"), console.info = a("info"), console.warn = a("warn"), console.error = a("error");
1672
1679
  try {
1673
- const u = /* @__PURE__ */ Symbol("execute_code_timeout"), c = await Promise.race([
1680
+ const u = /* @__PURE__ */ Symbol("execute_code_timeout"), l = await Promise.race([
1674
1681
  new t(e.javascript)(),
1675
- new Promise((a) => {
1676
- i = window.setTimeout(() => a(u), s);
1682
+ new Promise((c) => {
1683
+ i = window.setTimeout(() => c(u), s);
1677
1684
  })
1678
1685
  ]);
1679
- return c === u ? cs(s) : {
1686
+ return l === u ? Vs(s) : {
1680
1687
  ok: !0,
1681
- result: c,
1688
+ result: l,
1682
1689
  console: r,
1683
1690
  metadata: {
1684
1691
  durationMs: Date.now() - n,
@@ -1705,7 +1712,7 @@ async function _t(e) {
1705
1712
  i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
1706
1713
  }
1707
1714
  }
1708
- function cs(e) {
1715
+ function Vs(e) {
1709
1716
  return {
1710
1717
  ok: !1,
1711
1718
  exception: {
@@ -1719,18 +1726,18 @@ function cs(e) {
1719
1726
  }
1720
1727
  };
1721
1728
  }
1722
- function ls(e) {
1729
+ function Ys(e) {
1723
1730
  return e.replace(/\/+$/, "");
1724
1731
  }
1725
- function us(e, t = location.origin) {
1732
+ function Zs(e, t = location.origin) {
1726
1733
  return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
1727
1734
  }
1728
- function ds(e) {
1735
+ function Qs(e) {
1729
1736
  const t = new URL("/api/product-agent/embed/ws", e);
1730
1737
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
1731
1738
  }
1732
- function w() {
1733
- const e = zt();
1739
+ function R() {
1740
+ const e = Pe();
1734
1741
  return {
1735
1742
  url: location.href,
1736
1743
  title: document.title,
@@ -1738,21 +1745,21 @@ function w() {
1738
1745
  ...e ? { plunoProductAgentUi: e } : {}
1739
1746
  };
1740
1747
  }
1741
- function hs() {
1748
+ function tn() {
1742
1749
  return {
1743
1750
  pageUrl: location.href,
1744
1751
  pageTitle: document.title,
1745
- htmlContent: ms()
1752
+ htmlContent: Ft()
1746
1753
  };
1747
1754
  }
1748
- function ps(e) {
1749
- return F.add(e), v || (v = fs()), () => {
1750
- F.delete(e), F.size === 0 && (v?.(), v = null);
1755
+ function en(e) {
1756
+ return et.add(e), Y || (Y = sn()), () => {
1757
+ et.delete(e), et.size === 0 && (Y?.(), Y = null);
1751
1758
  };
1752
1759
  }
1753
- function fs() {
1760
+ function sn() {
1754
1761
  const e = () => {
1755
- for (const i of Array.from(F))
1762
+ for (const i of Array.from(et))
1756
1763
  i();
1757
1764
  }, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
1758
1765
  const o = t(...i);
@@ -1765,36 +1772,321 @@ function fs() {
1765
1772
  window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
1766
1773
  };
1767
1774
  }
1768
- function gs() {
1769
- return zt()?.surface === "browser_extension_sdk_preview";
1770
- }
1771
- function ms() {
1772
- const e = document.body?.cloneNode(!0);
1773
- return e instanceof HTMLElement ? (e.querySelectorAll(
1774
- [
1775
- "script",
1776
- "style",
1777
- "noscript",
1778
- "template",
1779
- "svg",
1780
- "canvas",
1781
- "iframe",
1782
- "input",
1783
- "textarea",
1784
- "select",
1785
- "option",
1786
- "[type='hidden']",
1787
- "[data-pluno-product-agent-widget]",
1788
- ".pluno-pa-widget"
1789
- ].join(",")
1790
- ).forEach((t) => t.remove()), e.querySelectorAll("*").forEach((t) => {
1791
- for (const s of Array.from(t.attributes))
1792
- s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
1793
- }), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
1794
- }
1795
- function zt() {
1796
- const e = document.querySelector(wt);
1797
- if (!(e ?? document.querySelector(st)))
1775
+ function nn() {
1776
+ return Pe()?.surface === "browser_extension_sdk_preview";
1777
+ }
1778
+ function Ft() {
1779
+ if (!document.body)
1780
+ return "";
1781
+ const e = [], t = [], s = (g, T) => {
1782
+ const y = B(T);
1783
+ !y || t.includes(y) || (e.push([g, y]), t.push(y));
1784
+ };
1785
+ s("Selected text", window.getSelection()?.toString() ?? "");
1786
+ const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
1787
+ (g) => _e(g) && !g.parentElement?.closest(n)
1788
+ );
1789
+ for (const g of r.slice(0, 3))
1790
+ s("Active overlay", kt($(g), t));
1791
+ const i = rn(), o = i ? kt($(i), t) : "";
1792
+ s("Main page content", o), s("Additional visible page text", kt($(document.body), t));
1793
+ const a = e.map(([g, T]) => `${g}:
1794
+ ${T}`).join(`
1795
+
1796
+ `).trim().slice(0, 12e3), u = on(r, i).trim(), l = `Simplified DOM outline:
1797
+ `, c = `
1798
+
1799
+ Visible page text:
1800
+ `, d = 12e3 - l.length - c.length, m = Math.min(a.length, 7900), p = u.slice(0, d - m), h = a.slice(0, d - p.length);
1801
+ return `${l}${p}${c}${h}`;
1802
+ }
1803
+ function $(e) {
1804
+ return e.innerText ?? e.textContent ?? "";
1805
+ }
1806
+ function B(e) {
1807
+ return (e ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
1808
+ `).split(`
1809
+ `).map((t) => t.replace(/[ \t]+/g, " ").trim()).join(`
1810
+ `).replace(/\n{3,}/g, `
1811
+
1812
+ `).trim();
1813
+ }
1814
+ function kt(e, t) {
1815
+ let s = B(e);
1816
+ for (const n of t)
1817
+ s = s.replace(n, "");
1818
+ return B(s);
1819
+ }
1820
+ function _e(e) {
1821
+ const t = window.getComputedStyle(e);
1822
+ return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
1823
+ }
1824
+ function rn() {
1825
+ return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(_e).sort((e, t) => $(t).length - $(e).length)[0] ?? null;
1826
+ }
1827
+ function on(e, t) {
1828
+ const s = /* @__PURE__ */ new Set([
1829
+ "main",
1830
+ "nav",
1831
+ "header",
1832
+ "footer",
1833
+ "section",
1834
+ "article",
1835
+ "aside",
1836
+ "form",
1837
+ "fieldset",
1838
+ "legend",
1839
+ "table",
1840
+ "tr",
1841
+ "th",
1842
+ "td",
1843
+ "ul",
1844
+ "ol",
1845
+ "li",
1846
+ "h1",
1847
+ "h2",
1848
+ "h3",
1849
+ "h4",
1850
+ "h5",
1851
+ "h6",
1852
+ "p",
1853
+ "a",
1854
+ "button",
1855
+ "label",
1856
+ "input",
1857
+ "textarea",
1858
+ "select",
1859
+ "option",
1860
+ "details",
1861
+ "summary",
1862
+ "dialog",
1863
+ "iframe",
1864
+ "canvas"
1865
+ ]), n = /* @__PURE__ */ new Set([
1866
+ "h1",
1867
+ "h2",
1868
+ "h3",
1869
+ "h4",
1870
+ "h5",
1871
+ "h6",
1872
+ "p",
1873
+ "a",
1874
+ "button",
1875
+ "label",
1876
+ "th",
1877
+ "td",
1878
+ "option",
1879
+ "summary"
1880
+ ]), r = /* @__PURE__ */ new Set(["tr", "th", "td", "li", "p", "label", "option", "a", "button"]), i = /* @__PURE__ */ new Set(["script", "style", "noscript", "template", "meta", "link", "svg", "path", "slot"]), o = /* @__PURE__ */ new Set(["none", "presentation", "tooltip", "status", "img"]), a = /* @__PURE__ */ new Set([
1881
+ "button",
1882
+ "link",
1883
+ "checkbox",
1884
+ "radio",
1885
+ "switch",
1886
+ "combobox",
1887
+ "textbox",
1888
+ "tab",
1889
+ "menuitem",
1890
+ "option"
1891
+ ]), u = [
1892
+ "role",
1893
+ "aria-label",
1894
+ "aria-current",
1895
+ "aria-selected",
1896
+ "aria-expanded",
1897
+ "aria-checked",
1898
+ "aria-pressed",
1899
+ "name",
1900
+ "type",
1901
+ "placeholder",
1902
+ "title",
1903
+ "data-testid",
1904
+ "data-test",
1905
+ "data-qa",
1906
+ "data-cy"
1907
+ ], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: c, priorityTargets: d } = an(), m = new Set(e);
1908
+ t && m.add(t);
1909
+ let p = 0;
1910
+ const h = (I) => {
1911
+ const U = I.getAttribute("role");
1912
+ return U && !o.has(U) ? U : "";
1913
+ }, g = (I) => {
1914
+ const U = I.getAttribute("data-testid") || I.getAttribute("data-test") || I.getAttribute("data-qa") || I.getAttribute("data-cy") || "";
1915
+ return `${I.tagName.toLowerCase()}|${h(I)}|${U}`;
1916
+ }, T = (I, U, q) => {
1917
+ const b = (S, ut) => {
1918
+ const k = S.tagName.toLowerCase(), dt = window.getComputedStyle(S), z = c.has(S);
1919
+ if (p >= 1e3 && !z || q.has(S) || i.has(k) || S.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || dt.display === "none" || dt.visibility === "hidden")
1920
+ return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
1921
+ p += 1;
1922
+ const Xt = h(S), G = Ce(S), Xe = a.has(Xt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(k) || k === "a" && S.hasAttribute("href"), ht = Array.from(S.children).filter((f) => f instanceof HTMLElement), X = /* @__PURE__ */ new Map();
1923
+ for (const f of ht) {
1924
+ const A = g(f);
1925
+ X.set(A, (X.get(A) ?? 0) + 1);
1926
+ }
1927
+ const pt = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Map();
1928
+ for (const f of ht) {
1929
+ const A = g(f), D = Jt.get(A) ?? 0;
1930
+ Jt.set(A, D + 1), (X.get(A) ?? 0) > 8 && D >= 6 && !c.has(f) && pt.set(A, (pt.get(A) ?? 0) + 1);
1931
+ }
1932
+ const Kt = /* @__PURE__ */ new Map(), Vt = /* @__PURE__ */ new Set(), ft = [], Yt = [];
1933
+ for (const f of ht) {
1934
+ const A = g(f), D = X.get(A) ?? 0, te = Kt.get(A) ?? 0;
1935
+ if (Kt.set(A, te + 1), D > 8 && te >= 6 && !c.has(f)) {
1936
+ Vt.has(A) || (ft.push([`… ${pt.get(A) ?? 0} similar siblings omitted`]), Vt.add(A));
1937
+ continue;
1938
+ }
1939
+ const ee = b(f, ut);
1940
+ Yt.push(ee), ft.push(ee.lines);
1941
+ }
1942
+ const gt = [];
1943
+ if (S.shadowRoot)
1944
+ for (const f of Array.from(S.shadowRoot.children))
1945
+ f instanceof HTMLElement && gt.push(b(f, ut + 1));
1946
+ const J = [...Yt, ...gt], mt = G.length > 0 || Xe || J.some((f) => f.hasUsefulContent), Zt = B(
1947
+ [G, ...J.map((f) => f.textPreview)].filter(Boolean).join(" ")
1948
+ ).slice(0, 180), Je = S.hasAttribute("contenteditable") && (G.length > 0 || !S.querySelector("[contenteditable]")), Qt = l.some((f) => S.hasAttribute(f)) || !!Xt || Je, yt = (S.getClientRects().length > 0 || dt.display === "contents") && (s.has(k) || Qt || z) && (mt || z) && (!r.has(k) || mt || Qt || z), Tt = yt ? 1 : 0, H = [];
1949
+ if (yt) {
1950
+ const f = J.some((D) => D.containsTextElement), A = n.has(k) && !f ? Zt : G;
1951
+ H.push(Me(S, u, o, A.slice(0, 180)));
1952
+ }
1953
+ for (const f of ft)
1954
+ H.push(...Z(f, Tt));
1955
+ const wt = gt.flatMap((f) => f.lines);
1956
+ if (wt.length > 0) {
1957
+ const f = wt.slice(0, 20);
1958
+ wt.length > f.length && f.push("… shadow DOM omitted");
1959
+ const A = k.includes("tooltip") || k.includes("popper") || k.includes("loader");
1960
+ if (ut < 2 && !A) {
1961
+ const D = yt ? "#shadow-root" : `${k} #shadow-root`;
1962
+ H.push(...Z([D, ...Z(f, 1)], Tt));
1963
+ } else
1964
+ H.push(...Z(f, Tt));
1965
+ }
1966
+ return {
1967
+ lines: H,
1968
+ hasUsefulContent: mt,
1969
+ textPreview: Zt,
1970
+ containsTextElement: n.has(k) || J.some((f) => f.containsTextElement)
1971
+ };
1972
+ };
1973
+ return [`--- ${U} ---`, ...b(I, 0).lines].join(`
1974
+ `);
1975
+ }, y = [], N = B(window.getSelection()?.toString() ?? "");
1976
+ N && y.push(`--- selected text ---
1977
+ ${JSON.stringify(N)}`), d.length > 0 && y.push(cn(d, s, u, o));
1978
+ for (const I of e.slice(0, 3))
1979
+ y.push(T(I, "active overlay DOM", /* @__PURE__ */ new Set()));
1980
+ if (t && y.push(T(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
1981
+ const I = t || e.length ? "other visible DOM" : "visible DOM";
1982
+ y.push(T(document.body, I, m));
1983
+ }
1984
+ return y.join(`
1985
+
1986
+ `);
1987
+ }
1988
+ function Me(e, t, s, n) {
1989
+ const r = e.tagName.toLowerCase();
1990
+ let i = r;
1991
+ const o = e.getAttribute("id");
1992
+ o && ln(o) && (i += `#${o}`);
1993
+ for (const a of t) {
1994
+ const u = e.getAttribute(a);
1995
+ u && u.length <= 160 && (a !== "role" || !s.has(u)) && (i += `[${a}=${JSON.stringify(u)}]`);
1996
+ }
1997
+ if (r === "a" || r === "iframe") {
1998
+ const a = e.getAttribute(r === "a" ? "href" : "src");
1999
+ a && (i += `[${r === "a" ? "href" : "src"}=${JSON.stringify(a.slice(0, 160))}]`);
2000
+ }
2001
+ for (const a of ["disabled", "checked", "selected", "open", "contenteditable"])
2002
+ e.hasAttribute(a) && (i += `[${a}]`);
2003
+ return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
2004
+ }
2005
+ function an() {
2006
+ const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, u) => {
2007
+ if (!a)
2008
+ return;
2009
+ const l = window.getComputedStyle(a);
2010
+ if (l.display === "none" || l.visibility === "hidden")
2011
+ return;
2012
+ const c = t.get(a) ?? /* @__PURE__ */ new Set();
2013
+ c.add(u), t.set(a, c);
2014
+ let d = a;
2015
+ for (; d; ) {
2016
+ e.add(d);
2017
+ const m = d.getRootNode();
2018
+ d = d.parentElement ?? (m instanceof ShadowRoot && m.host instanceof HTMLElement ? m.host : null);
2019
+ }
2020
+ };
2021
+ let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
2022
+ for (; n?.shadowRoot?.activeElement instanceof HTMLElement; )
2023
+ n = n.shadowRoot.activeElement;
2024
+ n !== document.body && n !== document.documentElement && s(n, "focused");
2025
+ const r = window.getSelection();
2026
+ r && !r.isCollapsed && (s(le(r.anchorNode), "selected text"), s(le(r.focusNode), "selected text"));
2027
+ const i = [
2028
+ ["[aria-selected='true']", "selected"],
2029
+ ["[aria-current]:not([aria-current='false'])", "current"],
2030
+ ["[aria-expanded='true']", "expanded"],
2031
+ ["[aria-checked='true'], :checked", "checked"],
2032
+ ["[aria-pressed='true']", "pressed"],
2033
+ ["[open]", "open"]
2034
+ ], o = [document];
2035
+ for (let a = 0; a < o.length; a += 1) {
2036
+ const u = o[a];
2037
+ for (const [l, c] of i)
2038
+ for (const d of Array.from(u.querySelectorAll(l)))
2039
+ s(d, c);
2040
+ for (const l of Array.from(u.querySelectorAll("*")))
2041
+ l.shadowRoot && o.push(l.shadowRoot);
2042
+ }
2043
+ return {
2044
+ priorityElements: e,
2045
+ priorityTargets: Array.from(t, ([a, u]) => ({ element: a, labels: Array.from(u) }))
2046
+ };
2047
+ }
2048
+ function cn(e, t, s, n) {
2049
+ const r = ["--- active/current elements ---"];
2050
+ for (const i of e) {
2051
+ const o = [];
2052
+ let a = i.element;
2053
+ for (; a; ) {
2054
+ const c = a.tagName.toLowerCase();
2055
+ (a === i.element || t.has(c) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
2056
+ const d = a.getRootNode();
2057
+ a = a.parentElement ?? (d instanceof ShadowRoot && d.host instanceof HTMLElement ? d.host : null);
2058
+ }
2059
+ const u = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = u.map((c, d) => Me(
2060
+ c,
2061
+ s,
2062
+ n,
2063
+ d === u.length - 1 ? Ce(c).slice(0, 180) : ""
2064
+ ));
2065
+ o.length > u.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
2066
+ }
2067
+ return r.join(`
2068
+ `);
2069
+ }
2070
+ function le(e) {
2071
+ return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
2072
+ }
2073
+ function Z(e, t) {
2074
+ if (t === 0)
2075
+ return e;
2076
+ const s = " ".repeat(t);
2077
+ return e.map((n) => `${s}${n}`);
2078
+ }
2079
+ function Ce(e) {
2080
+ return B(
2081
+ Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
2082
+ );
2083
+ }
2084
+ function ln(e) {
2085
+ return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
2086
+ }
2087
+ function Pe() {
2088
+ const e = document.querySelector(se);
2089
+ if (!(e ?? document.querySelector(Mt)))
1798
2090
  return;
1799
2091
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
1800
2092
  return {
@@ -1803,28 +2095,28 @@ function zt() {
1803
2095
  selectors: [
1804
2096
  {
1805
2097
  name: "widget_host",
1806
- selector: s === "browser_extension_sdk_preview" ? wt : st,
2098
+ selector: s === "browser_extension_sdk_preview" ? se : Mt,
1807
2099
  description: "Finds Pluno's shadow-host element in the host page DOM."
1808
2100
  },
1809
2101
  {
1810
2102
  name: "widget_root",
1811
- selector: we,
2103
+ selector: as,
1812
2104
  description: "Finds Pluno's widget root inside the widget host shadow root."
1813
2105
  },
1814
2106
  {
1815
2107
  name: "widget_panel",
1816
- selector: Ae,
2108
+ selector: cs,
1817
2109
  description: "Finds Pluno's open chat panel inside the widget host shadow root."
1818
2110
  },
1819
2111
  {
1820
2112
  name: "widget_timeline",
1821
- selector: Se,
2113
+ selector: ls,
1822
2114
  description: "Finds Pluno's chat timeline inside the widget host shadow root."
1823
2115
  }
1824
2116
  ]
1825
2117
  };
1826
2118
  }
1827
- function ys(e) {
2119
+ function un(e) {
1828
2120
  try {
1829
2121
  const t = JSON.parse(e);
1830
2122
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -1832,33 +2124,33 @@ function ys(e) {
1832
2124
  return { type: "error", message: "Invalid server event" };
1833
2125
  }
1834
2126
  }
1835
- function bt(e, t) {
2127
+ function ue(e, t) {
1836
2128
  if (!e || typeof e != "object")
1837
2129
  return [];
1838
2130
  const s = e[t];
1839
2131
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
1840
2132
  }
1841
- function Is(e) {
2133
+ function dn(e) {
1842
2134
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
1843
2135
  }
1844
- function Ts(e) {
2136
+ function hn(e) {
1845
2137
  if (!e || typeof e != "object")
1846
2138
  return null;
1847
- const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, l = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
1848
- return !r && !i && !o && l === null ? null : {
2139
+ const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = 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;
2140
+ return !r && !i && !o && a === null ? null : {
1849
2141
  ...r ? { accentColor: r } : {},
1850
2142
  ...i ? { colorScheme: i } : {},
1851
2143
  ...o ? { fontFamily: o } : {},
1852
- ...l !== null ? { scribbleStyle: l } : {}
2144
+ ...a !== null ? { scribbleStyle: a } : {}
1853
2145
  };
1854
2146
  }
1855
- function ws(e) {
2147
+ function pn(e) {
1856
2148
  if (!e || typeof e != "object")
1857
2149
  return null;
1858
2150
  const t = e.javascript;
1859
2151
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
1860
2152
  }
1861
- function As(e, t) {
2153
+ function fn(e, t) {
1862
2154
  return t ? e && typeof e == "object" ? {
1863
2155
  ...e,
1864
2156
  helperError: t
@@ -1868,23 +2160,23 @@ function As(e, t) {
1868
2160
  helperError: t
1869
2161
  } : e;
1870
2162
  }
1871
- function Ss(e) {
2163
+ function gn(e) {
1872
2164
  if (!e || typeof e != "object")
1873
2165
  return e;
1874
2166
  const t = e;
1875
2167
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
1876
2168
  }
1877
- function ks() {
2169
+ function mn() {
1878
2170
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
1879
2171
  if (t)
1880
2172
  return t;
1881
2173
  const s = crypto.randomUUID();
1882
2174
  return window.localStorage.setItem(e, s), s;
1883
2175
  }
1884
- function q() {
2176
+ function Q() {
1885
2177
  return crypto.randomUUID();
1886
2178
  }
1887
- function Es(e) {
2179
+ function yn(e) {
1888
2180
  if (!e || typeof e != "object")
1889
2181
  return null;
1890
2182
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -1895,23 +2187,23 @@ function Es(e) {
1895
2187
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
1896
2188
  } : null;
1897
2189
  }
1898
- function Rs(e, t) {
1899
- return Array.isArray(e) ? at(
1900
- ct(
1901
- e.map((s) => Gt(s, t)).filter((s) => s !== null)
2190
+ function Tn(e, t) {
2191
+ return Array.isArray(e) ? Nt(
2192
+ Ot(
2193
+ e.map((s) => Ue(s, t)).filter((s) => s !== null)
1902
2194
  )
1903
2195
  ) : [];
1904
2196
  }
1905
- function _s(e) {
2197
+ function wn(e) {
1906
2198
  return Array.isArray(e) ? e.flatMap((t) => {
1907
2199
  if (!t || typeof t != "object")
1908
2200
  return [];
1909
- const s = t, n = T(s, "id"), r = T(s, "createdAt"), i = T(s, "updatedAt"), o = T(s, "lastActiveAt");
2201
+ const s = t, n = E(s, "id"), r = E(s, "createdAt"), i = E(s, "updatedAt"), o = E(s, "lastActiveAt");
1910
2202
  return !n || !r || !i || !o ? [] : [
1911
2203
  {
1912
2204
  id: n,
1913
- title: T(s, "title"),
1914
- firstUserMessage: T(s, "firstUserMessage"),
2205
+ title: E(s, "title"),
2206
+ firstUserMessage: E(s, "firstUserMessage"),
1915
2207
  currentPage: s.currentPage ?? null,
1916
2208
  createdAt: r,
1917
2209
  updatedAt: i,
@@ -1921,7 +2213,7 @@ function _s(e) {
1921
2213
  ];
1922
2214
  }) : [];
1923
2215
  }
1924
- function Gt(e, t) {
2216
+ function Ue(e, t) {
1925
2217
  if (!e || typeof e != "object")
1926
2218
  return null;
1927
2219
  const s = e, n = s.data;
@@ -1937,11 +2229,11 @@ function Gt(e, t) {
1937
2229
  id: String(s.id ?? crypto.randomUUID()),
1938
2230
  role: i,
1939
2231
  ...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
1940
- content: Ds(r.content),
2232
+ content: bn(r.content),
1941
2233
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1942
- respondsToUserMessageId: R(r) ?? void 0,
1943
- ...S(r) ? { runId: S(r) } : {},
1944
- attachments: Zt(r.attachments, t)
2234
+ respondsToUserMessageId: O(r) ?? void 0,
2235
+ ...M(r) ? { runId: M(r) } : {},
2236
+ attachments: xe(r.attachments, t)
1945
2237
  };
1946
2238
  return typeof r.clientMessageId == "string" && Object.defineProperty(o, "clientMessageId", {
1947
2239
  value: r.clientMessageId,
@@ -1949,49 +2241,49 @@ function Gt(e, t) {
1949
2241
  }), o;
1950
2242
  }
1951
2243
  if (r.type === "function_call_output") {
1952
- const i = Ms(r.output);
2244
+ const i = An(r.output);
1953
2245
  return i ? {
1954
2246
  id: String(s.id ?? crypto.randomUUID()),
1955
2247
  role: "tool",
1956
2248
  content: `Connect ${i.appName} to continue`,
1957
2249
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1958
- respondsToUserMessageId: R(r) ?? void 0,
1959
- ...S(r) ? { runId: S(r) } : {},
2250
+ respondsToUserMessageId: O(r) ?? void 0,
2251
+ ...M(r) ? { runId: M(r) } : {},
1960
2252
  dataType: "function_call_output",
1961
2253
  toolName: "authenticate_pipedream_app",
1962
- callId: Mt(r) ?? void 0,
2254
+ callId: de(r) ?? void 0,
1963
2255
  integrationAuthRequest: i
1964
2256
  } : null;
1965
2257
  }
1966
2258
  return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
1967
2259
  id: String(s.id ?? crypto.randomUUID()),
1968
2260
  role: "tool",
1969
- content: r.type === "mcp_call" ? bs(r) : Ps(r),
2261
+ content: r.type === "mcp_call" ? In(r) : En(r),
1970
2262
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1971
- respondsToUserMessageId: R(r) ?? void 0,
1972
- ...S(r) ? { runId: S(r) } : {},
2263
+ respondsToUserMessageId: O(r) ?? void 0,
2264
+ ...M(r) ? { runId: M(r) } : {},
1973
2265
  dataType: String(r.type),
1974
2266
  toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
1975
- callId: Mt(r) ?? void 0,
2267
+ callId: de(r) ?? void 0,
1976
2268
  loading: r.localExecutionStatus === "running"
1977
2269
  } : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
1978
2270
  id: String(s.id ?? crypto.randomUUID()),
1979
2271
  role: "system",
1980
- content: Cs(r),
2272
+ content: Sn(r),
1981
2273
  createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
1982
- respondsToUserMessageId: R(r) ?? void 0,
1983
- ...S(r) ? { runId: S(r) } : {},
2274
+ respondsToUserMessageId: O(r) ?? void 0,
2275
+ ...M(r) ? { runId: M(r) } : {},
1984
2276
  dataType: String(r.type),
1985
2277
  loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
1986
2278
  ...typeof r.retryable == "boolean" ? { retryable: r.retryable } : {},
1987
2279
  ...typeof r.securitySettingsUrl == "string" ? { securitySettingsUrl: r.securitySettingsUrl } : {}
1988
2280
  } : null;
1989
2281
  }
1990
- function bs(e) {
2282
+ function In(e) {
1991
2283
  const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
1992
2284
  return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
1993
2285
  }
1994
- function Ms(e) {
2286
+ function An(e) {
1995
2287
  if (typeof e != "string")
1996
2288
  return null;
1997
2289
  try {
@@ -2008,10 +2300,10 @@ function Ms(e) {
2008
2300
  return null;
2009
2301
  }
2010
2302
  }
2011
- function Cs(e) {
2303
+ function Sn(e) {
2012
2304
  return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : "Pluno run status changed.";
2013
2305
  }
2014
- function Ps(e) {
2306
+ function En(e) {
2015
2307
  if (e.type === "web_search_call") {
2016
2308
  const t = e.action;
2017
2309
  if (t && typeof t == "object") {
@@ -2023,30 +2315,30 @@ function Ps(e) {
2023
2315
  }
2024
2316
  return "🔎 Searching the web";
2025
2317
  }
2026
- return Us(e);
2318
+ return kn(e);
2027
2319
  }
2028
- function Us(e) {
2320
+ function kn(e) {
2029
2321
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
2030
- return M(e.summary);
2322
+ return L(e.summary);
2031
2323
  if (typeof e.arguments == "string")
2032
2324
  try {
2033
2325
  const t = JSON.parse(e.arguments);
2034
2326
  if (typeof t.summary == "string" && t.summary.trim().length > 0)
2035
- return M(t.summary);
2327
+ return L(t.summary);
2036
2328
  } catch {
2037
- return typeof e.name == "string" && e.name.trim().length > 0 ? M(e.name) : "🛠️ Run tool";
2329
+ return typeof e.name == "string" && e.name.trim().length > 0 ? L(e.name) : "🛠️ Run tool";
2038
2330
  }
2039
- return typeof e.name == "string" && e.name.trim().length > 0 ? M(e.name) : "🛠️ Run tool";
2331
+ return typeof e.name == "string" && e.name.trim().length > 0 ? L(e.name) : "🛠️ Run tool";
2040
2332
  }
2041
- function M(e) {
2333
+ function L(e) {
2042
2334
  const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
2043
2335
  return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
2044
2336
  }
2045
- function Mt(e) {
2337
+ function de(e) {
2046
2338
  const t = e.callId ?? e.call_id;
2047
2339
  return typeof t == "string" && t ? t : null;
2048
2340
  }
2049
- function Ds(e) {
2341
+ function bn(e) {
2050
2342
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
2051
2343
  if (!t || typeof t != "object")
2052
2344
  return "";
@@ -2054,24 +2346,24 @@ function Ds(e) {
2054
2346
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
2055
2347
  }).filter(Boolean).join("") : "";
2056
2348
  }
2057
- function Xt(e, t) {
2058
- const s = Kt(e, t), n = Bs(
2059
- Fs(e, t),
2349
+ function De(e, t) {
2350
+ const s = Ne(e, t), n = Cn(
2351
+ Nn(e, t),
2060
2352
  s
2061
2353
  ), r = n.findIndex((o) => o.id === s.id);
2062
2354
  if (r === -1)
2063
- return at(
2064
- ct([...n, s])
2355
+ return Nt(
2356
+ Ot([...n, s])
2065
2357
  );
2066
2358
  const i = [...n];
2067
- return i[r] = s, at(ct(i));
2359
+ return i[r] = s, Nt(Ot(i));
2068
2360
  }
2069
- function Ns(e, t) {
2361
+ function Rn(e, t) {
2070
2362
  const s = e.findIndex(
2071
2363
  (r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
2072
2364
  );
2073
2365
  if (s === -1)
2074
- return Xt(e, t);
2366
+ return De(e, t);
2075
2367
  const n = [...e];
2076
2368
  return n[s] = {
2077
2369
  ...n[s],
@@ -2079,17 +2371,17 @@ function Ns(e, t) {
2079
2371
  loading: !0
2080
2372
  }, n;
2081
2373
  }
2082
- function Os(e, t, s) {
2374
+ function _n(e, t, s) {
2083
2375
  let n = !1;
2084
2376
  const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
2085
2377
  return n ? r : e;
2086
2378
  }
2087
- function Ls(e) {
2379
+ function Mn(e) {
2088
2380
  const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
2089
2381
  return !t || !s ? null : {
2090
2382
  id: `transient-activity:${t}`,
2091
2383
  role: "tool",
2092
- content: M(
2384
+ content: L(
2093
2385
  typeof e.summary == "string" ? e.summary : "Running browser tool"
2094
2386
  ),
2095
2387
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -2101,7 +2393,7 @@ function Ls(e) {
2101
2393
  loading: !0
2102
2394
  };
2103
2395
  }
2104
- function Bs(e, t) {
2396
+ function Cn(e, t) {
2105
2397
  if (t.id.startsWith("transient-activity:"))
2106
2398
  return e;
2107
2399
  const s = t.toolName === "tab_lifecycle";
@@ -2109,52 +2401,52 @@ function Bs(e, t) {
2109
2401
  (n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
2110
2402
  );
2111
2403
  }
2112
- function vs(e, t) {
2404
+ function Pn(e, t) {
2113
2405
  const s = t.map(
2114
- (n) => Kt(e, n)
2406
+ (n) => Ne(e, n)
2115
2407
  );
2116
- return t.length > 0 ? s : e.filter(ft);
2408
+ return t.length > 0 ? s : e.filter(Wt);
2117
2409
  }
2118
- function Kt(e, t) {
2410
+ function Ne(e, t) {
2119
2411
  if (t.role !== "user" || !t.attachments?.length)
2120
2412
  return t;
2121
2413
  const s = e.find(
2122
- (r) => r.role === "user" && (r.id === t.id || ft(r) && Jt(r, t))
2414
+ (r) => r.role === "user" && (r.id === t.id || Wt(r) && Oe(r, t))
2123
2415
  );
2124
2416
  if (!s?.attachments?.length)
2125
2417
  return t;
2126
2418
  const n = t.attachments.map((r) => {
2127
- const i = qs(s.attachments ?? [], r);
2128
- return i ? xs(r, i) : r;
2419
+ const i = Un(s.attachments ?? [], r);
2420
+ return i ? Dn(r, i) : r;
2129
2421
  });
2130
2422
  return { ...t, attachments: n };
2131
2423
  }
2132
- function qs(e, t) {
2424
+ function Un(e, t) {
2133
2425
  return t.id ? e.find((s) => s.id === t.id) ?? null : null;
2134
2426
  }
2135
- function xs(e, t) {
2427
+ function Dn(e, t) {
2136
2428
  const { previewUrl: s } = t;
2137
2429
  return s ? { ...e, previewUrl: s } : e;
2138
2430
  }
2139
- function Fs(e, t) {
2431
+ function Nn(e, t) {
2140
2432
  if (t.role !== "user")
2141
2433
  return e;
2142
2434
  const s = e.findIndex(
2143
- (r) => ft(r) && Jt(r, t)
2435
+ (r) => Wt(r) && Oe(r, t)
2144
2436
  );
2145
2437
  if (s === -1)
2146
2438
  return e;
2147
2439
  const n = [...e];
2148
2440
  return n.splice(s, 1), n;
2149
2441
  }
2150
- function Jt(e, t) {
2151
- const s = Ct(e), n = Ct(t);
2442
+ function Oe(e, t) {
2443
+ const s = he(e), n = he(t);
2152
2444
  return s && n ? s === n : e.content === t.content;
2153
2445
  }
2154
- function ft(e) {
2446
+ function Wt(e) {
2155
2447
  return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
2156
2448
  }
2157
- function Ct(e) {
2449
+ function he(e) {
2158
2450
  const t = e.clientMessageId;
2159
2451
  if (t)
2160
2452
  return t;
@@ -2163,13 +2455,13 @@ function Ct(e) {
2163
2455
  );
2164
2456
  return n ? e.id.slice(n.length) : null;
2165
2457
  }
2166
- function Pt(e) {
2167
- const t = Vt(e);
2458
+ function pe(e) {
2459
+ const t = ve(e);
2168
2460
  if (t === null)
2169
2461
  return !1;
2170
2462
  for (let s = e.length - 1; s > t; s -= 1) {
2171
2463
  const n = e[s];
2172
- if (N(n))
2464
+ if (j(n))
2173
2465
  return !0;
2174
2466
  if (n.role === "system") {
2175
2467
  if (n.dataType === "run_error")
@@ -2180,20 +2472,20 @@ function Pt(e) {
2180
2472
  }
2181
2473
  return !1;
2182
2474
  }
2183
- function Hs(e) {
2184
- const t = Vt(e);
2185
- return t === null ? e.some(N) : e.slice(t + 1).some(N);
2475
+ function On(e) {
2476
+ const t = ve(e);
2477
+ return t === null ? e.some(j) : e.slice(t + 1).some(j);
2186
2478
  }
2187
- function Vt(e) {
2479
+ function ve(e) {
2188
2480
  for (let t = e.length - 1; t >= 0; t -= 1)
2189
2481
  if (e[t].role === "user")
2190
2482
  return t;
2191
2483
  return null;
2192
2484
  }
2193
- function Ws(e) {
2194
- return N(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2485
+ function vn(e) {
2486
+ return j(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
2195
2487
  }
2196
- function gt(e) {
2488
+ function at(e) {
2197
2489
  for (let t = e.length - 1; t >= 0; t -= 1) {
2198
2490
  const s = e[t];
2199
2491
  if (!s || typeof s != "object")
@@ -2207,30 +2499,40 @@ function gt(e) {
2207
2499
  }
2208
2500
  return null;
2209
2501
  }
2210
- function D(e) {
2502
+ function Ln(e) {
2503
+ const t = at(e);
2504
+ if (t === null)
2505
+ return null;
2506
+ const n = x(e[t])?.page;
2507
+ if (!n || typeof n != "object")
2508
+ return null;
2509
+ const r = n.url;
2510
+ return typeof r == "string" ? r : null;
2511
+ }
2512
+ function x(e) {
2211
2513
  if (!e || typeof e != "object")
2212
2514
  return null;
2213
2515
  const t = e.data;
2214
2516
  return t && typeof t == "object" ? t : null;
2215
2517
  }
2216
- function it(e) {
2518
+ function Ut(e) {
2217
2519
  return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
2218
2520
  }
2219
- function Ut(e) {
2521
+ function fe(e) {
2220
2522
  return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
2221
2523
  }
2222
- function js(e, t) {
2223
- const s = gt(t);
2524
+ function xn(e, t) {
2525
+ const s = at(t);
2224
2526
  if (s === null)
2225
2527
  return !1;
2226
2528
  const n = t[s], r = n && typeof n == "object" ? n.id : null;
2227
2529
  if (typeof r != "string" || !r)
2228
2530
  return !1;
2229
2531
  const i = e.findIndex((o) => o.role === "user" && o.id === r);
2230
- return i === -1 ? !1 : e.slice(i + 1).some(Ws);
2532
+ return i === -1 ? !1 : e.slice(i + 1).some(vn);
2231
2533
  }
2232
- function ot(e) {
2233
- const t = gt(e);
2534
+ function Dt(e) {
2535
+ const t = at(e);
2234
2536
  if (t === null)
2235
2537
  return null;
2236
2538
  const s = e[t];
@@ -2242,8 +2544,8 @@ function ot(e) {
2242
2544
  const r = n.clientMessageId;
2243
2545
  return typeof r == "string" ? r : null;
2244
2546
  }
2245
- function $s(e) {
2246
- const t = gt(e);
2547
+ function Bn(e) {
2548
+ const t = at(e);
2247
2549
  if (t === null)
2248
2550
  return null;
2249
2551
  for (let s = e.length - 1; s > t; s -= 1) {
@@ -2257,22 +2559,22 @@ function $s(e) {
2257
2559
  if (i.type === "message" && i.role === "assistant")
2258
2560
  return null;
2259
2561
  if (i.type === "run_error")
2260
- return i.retryable !== !0 ? null : Dt(e, i) ?? ot(e);
2562
+ return i.retryable !== !0 ? null : ge(e, i) ?? Dt(e);
2261
2563
  if (i.type === "run_status")
2262
- return i.status === "interrupted" && i.retryable === !0 ? Dt(e, i) ?? ot(e) : null;
2564
+ return i.status === "interrupted" && i.retryable === !0 ? ge(e, i) ?? Dt(e) : null;
2263
2565
  }
2264
2566
  return null;
2265
2567
  }
2266
- function Dt(e, t) {
2568
+ function ge(e, t) {
2267
2569
  if (typeof t.clientMessageId == "string")
2268
2570
  return t.clientMessageId;
2269
- const s = R(t);
2571
+ const s = O(t);
2270
2572
  if (!s)
2271
2573
  return null;
2272
- const n = e.find((i) => T(i, "id") === s), r = D(n);
2574
+ const n = e.find((i) => E(i, "id") === s), r = x(n);
2273
2575
  return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
2274
2576
  }
2275
- function zs(e, t) {
2577
+ function qn(e, t) {
2276
2578
  let s = 0;
2277
2579
  for (const n of e) {
2278
2580
  if (!n || typeof n != "object")
@@ -2285,37 +2587,37 @@ function zs(e, t) {
2285
2587
  }
2286
2588
  return s;
2287
2589
  }
2288
- function Nt(e, t, s, n, r) {
2289
- if (!t || !Gs(e))
2590
+ function me(e, t, s, n, r) {
2591
+ if (!t || !Hn(e))
2290
2592
  return !1;
2291
2593
  const i = e;
2292
- return !(it(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && R(i) !== n || r !== null && S(i) !== r);
2594
+ return !(Ut(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && O(i) !== n || r !== null && M(i) !== r);
2293
2595
  }
2294
- function Gs(e) {
2596
+ function Hn(e) {
2295
2597
  if (!e || typeof e != "object")
2296
2598
  return !1;
2297
2599
  const t = e;
2298
2600
  return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted");
2299
2601
  }
2300
- function N(e) {
2602
+ function j(e) {
2301
2603
  return e.role === "assistant" && e.phase !== "commentary";
2302
2604
  }
2303
- function Xs(e) {
2605
+ function Fn(e) {
2304
2606
  if (!e || typeof e != "object")
2305
2607
  return !1;
2306
2608
  const t = e;
2307
2609
  return t.type === "message" && t.role === "user" ? !1 : t.type === "message" || t.type === "function_call" || t.type === "function_call_output" || t.type === "run_error" || t.type === "run_status";
2308
2610
  }
2309
- function at(e) {
2310
- return e.filter((t, s) => mt(t) ? !Qs(e, s) && !Ys(e, s) && !Zs(e, s) : Ks(t) ? t.retryable === !0 && Vs(e, s) ? !1 : !Js(e, s) : !0);
2611
+ function Nt(e) {
2612
+ return e.filter((t, s) => $t(t) ? !Xn(e, s) && !zn(e, s) && !Gn(e, s) : Wn(t) ? t.retryable === !0 && jn(e, s) ? !1 : !$n(e, s) : !0);
2311
2613
  }
2312
- function Ks(e) {
2614
+ function Wn(e) {
2313
2615
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
2314
2616
  }
2315
- function mt(e) {
2617
+ function $t(e) {
2316
2618
  return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
2317
2619
  }
2318
- function ct(e) {
2620
+ function Ot(e) {
2319
2621
  const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
2320
2622
  for (const i of e) {
2321
2623
  if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
@@ -2331,18 +2633,18 @@ function ct(e) {
2331
2633
  n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
2332
2634
  return r;
2333
2635
  }
2334
- function Js(e, t) {
2636
+ function $n(e, t) {
2335
2637
  const s = e[t];
2336
2638
  for (let n = t + 1; n < e.length; n += 1) {
2337
2639
  const r = e[n];
2338
2640
  if (r.role === "user")
2339
2641
  return !1;
2340
- if (r.role === "assistant" && G(s, r))
2642
+ if (r.role === "assistant" && ct(s, r))
2341
2643
  return !0;
2342
2644
  }
2343
2645
  return !1;
2344
2646
  }
2345
- function Vs(e, t) {
2647
+ function jn(e, t) {
2346
2648
  const s = e[t];
2347
2649
  if (!s.respondsToUserMessageId)
2348
2650
  return !1;
@@ -2350,47 +2652,47 @@ function Vs(e, t) {
2350
2652
  const r = e[n];
2351
2653
  if (r.role === "user")
2352
2654
  return !1;
2353
- if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || mt(r)))
2655
+ if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || $t(r)))
2354
2656
  return !0;
2355
2657
  }
2356
2658
  return !1;
2357
2659
  }
2358
- function Ys(e, t) {
2660
+ function zn(e, t) {
2359
2661
  const s = e[t];
2360
2662
  for (let n = t + 1; n < e.length; n += 1)
2361
- if (e[n].role === "assistant" && G(s, e[n]))
2663
+ if (e[n].role === "assistant" && ct(s, e[n]))
2362
2664
  return !0;
2363
2665
  return !1;
2364
2666
  }
2365
- function Zs(e, t) {
2667
+ function Gn(e, t) {
2366
2668
  const s = e[t];
2367
2669
  for (let n = t + 1; n < e.length; n += 1)
2368
- if (e[n].role === "tool" && G(s, e[n]))
2670
+ if (e[n].role === "tool" && ct(s, e[n]))
2369
2671
  return !0;
2370
2672
  return !1;
2371
2673
  }
2372
- function Qs(e, t) {
2674
+ function Xn(e, t) {
2373
2675
  const s = e[t];
2374
2676
  for (let n = t + 1; n < e.length; n += 1)
2375
- if (mt(e[n]) && G(s, e[n]))
2677
+ if ($t(e[n]) && ct(s, e[n]))
2376
2678
  return !0;
2377
2679
  return !1;
2378
2680
  }
2379
- function G(e, t) {
2681
+ function ct(e, t) {
2380
2682
  return !e.runId || !t.runId ? !0 : e.runId === t.runId;
2381
2683
  }
2382
- function T(e, t) {
2684
+ function E(e, t) {
2383
2685
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
2384
2686
  }
2385
- function tn(e, t) {
2687
+ function Jn(e, t) {
2386
2688
  try {
2387
- const s = window.localStorage.getItem(`${jt}${e}`);
2689
+ const s = window.localStorage.getItem(`${be}${e}`);
2388
2690
  if (!s)
2389
2691
  return null;
2390
2692
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
2391
2693
  if (t !== void 0 && r !== t)
2392
2694
  return null;
2393
- const i = Array.isArray(n.messages) ? n.messages.map(pn).filter((o) => !!o) : [];
2695
+ const i = Array.isArray(n.messages) ? n.messages.map(or).filter((o) => !!o) : [];
2394
2696
  return {
2395
2697
  sessionId: r,
2396
2698
  messages: i
@@ -2399,48 +2701,48 @@ function tn(e, t) {
2399
2701
  return null;
2400
2702
  }
2401
2703
  }
2402
- function en(e, t) {
2704
+ function Kn(e, t) {
2403
2705
  try {
2404
2706
  window.localStorage.setItem(
2405
- `${jt}${e}`,
2707
+ `${be}${e}`,
2406
2708
  JSON.stringify({
2407
2709
  sessionId: t.sessionId,
2408
- messages: t.messages.slice(-We).map(fn)
2710
+ messages: t.messages.slice(-Cs).map(ar)
2409
2711
  })
2410
2712
  );
2411
2713
  } catch {
2412
2714
  return;
2413
2715
  }
2414
2716
  }
2415
- function sn(e) {
2717
+ function Vn(e) {
2416
2718
  try {
2417
- const t = window.localStorage.getItem(`${nt}${e}`);
2719
+ const t = window.localStorage.getItem(`${Ct}${e}`);
2418
2720
  if (!t)
2419
2721
  return [];
2420
2722
  const s = JSON.parse(t);
2421
- return Array.isArray(s) ? s.filter(yt) : [];
2723
+ return Array.isArray(s) ? s.filter(jt) : [];
2422
2724
  } catch {
2423
2725
  return [];
2424
2726
  }
2425
2727
  }
2426
- function U(e, t) {
2728
+ function W(e, t) {
2427
2729
  try {
2428
- const s = t.filter(yt);
2730
+ const s = t.filter(jt);
2429
2731
  if (s.length === 0) {
2430
- window.localStorage.removeItem(`${nt}${e}`);
2732
+ window.localStorage.removeItem(`${Ct}${e}`);
2431
2733
  return;
2432
2734
  }
2433
2735
  window.localStorage.setItem(
2434
- `${nt}${e}`,
2736
+ `${Ct}${e}`,
2435
2737
  JSON.stringify(s.slice(-25))
2436
2738
  );
2437
2739
  } catch {
2438
2740
  return;
2439
2741
  }
2440
2742
  }
2441
- function Yt(e, t) {
2743
+ function Le(e, t) {
2442
2744
  try {
2443
- const s = `${z}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2745
+ const s = `${ot}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
2444
2746
  ...o,
2445
2747
  storedAt: Date.now(),
2446
2748
  unloadUrl: n,
@@ -2454,28 +2756,28 @@ function Yt(e, t) {
2454
2756
  } catch {
2455
2757
  }
2456
2758
  }
2457
- function nn(e, t) {
2759
+ function Yn(e, t) {
2458
2760
  try {
2459
- if (window.sessionStorage.getItem(`${z}${e}`) === null)
2761
+ if (window.sessionStorage.getItem(`${ot}${e}`) === null)
2460
2762
  return;
2461
2763
  } catch {
2462
2764
  return;
2463
2765
  }
2464
- Yt(e, t);
2766
+ Le(e, t);
2465
2767
  }
2466
- function rn(e) {
2768
+ function Zn(e) {
2467
2769
  try {
2468
- const t = `${z}${e}`, s = window.sessionStorage.getItem(t);
2770
+ const t = `${ot}${e}`, s = window.sessionStorage.getItem(t);
2469
2771
  if (window.sessionStorage.removeItem(t), !s)
2470
2772
  return [];
2471
2773
  const n = JSON.parse(s);
2472
- return Array.isArray(n) ? n.flatMap((r) => an(r) ? [{
2774
+ return Array.isArray(n) ? n.flatMap((r) => tr(r) ? [{
2473
2775
  ...r.event,
2474
- page: w(),
2776
+ page: R(),
2475
2777
  rawOutput: {
2476
2778
  pageContextRestarted: !0,
2477
2779
  outcome: "unknown",
2478
- message: on(location.href),
2780
+ message: Qn(location.href),
2479
2781
  currentUrl: location.href,
2480
2782
  console: [],
2481
2783
  metadata: {
@@ -2492,17 +2794,17 @@ function rn(e) {
2492
2794
  return [];
2493
2795
  }
2494
2796
  }
2495
- function on(e) {
2797
+ function Qn(e) {
2496
2798
  return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
2497
2799
  Current URL: ${e}`;
2498
2800
  }
2499
- function an(e) {
2801
+ function tr(e) {
2500
2802
  if (!e || typeof e != "object")
2501
2803
  return !1;
2502
2804
  const t = e, s = t.event;
2503
- return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && yt(s) && s.type === "tool.result";
2805
+ return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && jt(s) && s.type === "tool.result";
2504
2806
  }
2505
- function cn(e, t) {
2807
+ function er(e, t) {
2506
2808
  const s = new Set(
2507
2809
  e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
2508
2810
  );
@@ -2511,26 +2813,26 @@ function cn(e, t) {
2511
2813
  ...t.filter((n) => !s.has(n.callId))
2512
2814
  ];
2513
2815
  }
2514
- function ln(e) {
2816
+ function sr(e) {
2515
2817
  try {
2516
- window.sessionStorage.removeItem(`${z}${e}`);
2818
+ window.sessionStorage.removeItem(`${ot}${e}`);
2517
2819
  } catch {
2518
2820
  return;
2519
2821
  }
2520
2822
  }
2521
- function yt(e) {
2823
+ function jt(e) {
2522
2824
  if (!e || typeof e != "object")
2523
2825
  return !1;
2524
2826
  const t = e;
2525
- return t.type === "chat.user_message" ? typeof t.content == "string" && Ot(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? Ot(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
2827
+ return t.type === "chat.user_message" ? typeof t.content == "string" && ye(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? ye(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
2526
2828
  }
2527
- function Ot(e) {
2829
+ function ye(e) {
2528
2830
  if (!e || typeof e != "object")
2529
2831
  return !1;
2530
2832
  const t = e;
2531
2833
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
2532
2834
  }
2533
- function Zt(e, t) {
2835
+ function xe(e, t) {
2534
2836
  if (!Array.isArray(e))
2535
2837
  return;
2536
2838
  const s = e.filter((r) => {
@@ -2538,24 +2840,24 @@ function Zt(e, t) {
2538
2840
  return !1;
2539
2841
  const i = r;
2540
2842
  return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
2541
- }), n = t ? s.map((r) => Qt(r, t)) : s;
2843
+ }), n = t ? s.map((r) => Be(r, t)) : s;
2542
2844
  return n.length > 0 ? n : void 0;
2543
2845
  }
2544
- function Qt(e, t) {
2846
+ function Be(e, t) {
2545
2847
  return e.fileUrl?.startsWith("/") ? {
2546
2848
  ...e,
2547
2849
  fileUrl: new URL(e.fileUrl, t).toString()
2548
2850
  } : e;
2549
2851
  }
2550
- function un(e) {
2551
- if (dn(e))
2852
+ function nr(e) {
2853
+ if (rr(e))
2552
2854
  return {
2553
2855
  headers: {
2554
2856
  "ngrok-skip-browser-warning": "true"
2555
2857
  }
2556
2858
  };
2557
2859
  }
2558
- function dn(e) {
2860
+ function rr(e) {
2559
2861
  try {
2560
2862
  const t = new URL(e).hostname;
2561
2863
  return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
@@ -2563,14 +2865,14 @@ function dn(e) {
2563
2865
  return !1;
2564
2866
  }
2565
2867
  }
2566
- function Lt(e) {
2567
- return e.type || hn(e.name) || "application/octet-stream";
2868
+ function Te(e) {
2869
+ return e.type || ir(e.name) || "application/octet-stream";
2568
2870
  }
2569
- function hn(e) {
2871
+ function ir(e) {
2570
2872
  const t = e.toLowerCase();
2571
2873
  return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
2572
2874
  }
2573
- function pn(e) {
2875
+ function or(e) {
2574
2876
  if (!e || typeof e != "object")
2575
2877
  return null;
2576
2878
  const t = e;
@@ -2583,17 +2885,17 @@ function pn(e) {
2583
2885
  ...typeof t.runId == "string" ? { runId: t.runId } : {},
2584
2886
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
2585
2887
  securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
2586
- attachments: Zt(t.attachments)?.map(It),
2888
+ attachments: xe(t.attachments)?.map(zt),
2587
2889
  loading: typeof t.loading == "boolean" ? t.loading : void 0
2588
2890
  };
2589
2891
  }
2590
- function fn(e) {
2892
+ function ar(e) {
2591
2893
  return e.attachments?.length ? {
2592
2894
  ...e,
2593
- attachments: e.attachments.map(It)
2895
+ attachments: e.attachments.map(zt)
2594
2896
  } : e;
2595
2897
  }
2596
- function It(e) {
2898
+ function zt(e) {
2597
2899
  const {
2598
2900
  dataUrl: t,
2599
2901
  objectUrl: s,
@@ -2602,69 +2904,69 @@ function It(e) {
2602
2904
  } = e;
2603
2905
  return r;
2604
2906
  }
2605
- function R(e) {
2907
+ function O(e) {
2606
2908
  const t = e.respondsToUserMessageId;
2607
2909
  return typeof t == "string" && t ? t : null;
2608
2910
  }
2609
- function S(e) {
2911
+ function M(e) {
2610
2912
  const t = e.runId;
2611
2913
  return typeof t == "string" && t ? t : null;
2612
2914
  }
2613
- function gn(e) {
2915
+ function cr(e) {
2614
2916
  const t = e?.timeoutMs;
2615
- return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Ve);
2917
+ return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= xs);
2616
2918
  }
2617
- function te(e) {
2919
+ function qe(e) {
2618
2920
  const t = {};
2619
2921
  try {
2620
2922
  new Headers(e).forEach((s, n) => {
2621
- Object.keys(t).length < ht && (t[n] = Tt(n, s));
2923
+ Object.keys(t).length < qt && (t[n] = Gt(n, s));
2622
2924
  });
2623
2925
  } catch {
2624
2926
  return {};
2625
2927
  }
2626
2928
  return t;
2627
2929
  }
2628
- function Tt(e, t) {
2629
- return oe(e) ? X : k(j(t), xe);
2930
+ function Gt(e, t) {
2931
+ return ze(e) ? lt : C(rt(t), Rs);
2630
2932
  }
2631
- function mn(e, t) {
2933
+ function lr(e, t) {
2632
2934
  return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
2633
2935
  }
2634
- async function yn(e, t, s, n) {
2635
- const r = te(e.headers);
2936
+ async function ur(e, t, s, n) {
2937
+ const r = qe(e.headers);
2636
2938
  n({
2637
2939
  ...t,
2638
2940
  responseStatus: e.status,
2639
2941
  responseHeaders: r,
2640
- responseBody: await In(e),
2942
+ responseBody: await dr(e),
2641
2943
  durationMs: Date.now() - s
2642
2944
  });
2643
2945
  }
2644
- async function In(e) {
2645
- if (!ee(e.headers))
2946
+ async function dr(e) {
2947
+ if (!He(e.headers))
2646
2948
  return;
2647
2949
  let t = null, s = null;
2648
2950
  try {
2649
2951
  if (t = e.clone().body?.getReader() ?? null, !t)
2650
2952
  return;
2651
- const n = new Promise((l) => {
2953
+ const n = new Promise((a) => {
2652
2954
  s = window.setTimeout(() => {
2653
- t?.cancel(), l("timeout");
2654
- }, Fe);
2955
+ t?.cancel(), a("timeout");
2956
+ }, _s);
2655
2957
  }), r = new TextDecoder();
2656
2958
  let i = "", o = 0;
2657
2959
  for (; ; ) {
2658
- const l = await Promise.race([t.read(), n]);
2659
- if (l === "timeout")
2960
+ const a = await Promise.race([t.read(), n]);
2961
+ if (a === "timeout")
2660
2962
  return;
2661
- const { done: u, value: c } = l;
2963
+ const { done: u, value: l } = a;
2662
2964
  if (u)
2663
- return k(i + r.decode());
2664
- const a = dt - o;
2665
- if (c.byteLength > a)
2666
- return i += r.decode(c.subarray(0, Math.max(a, 0)), { stream: !0 }), t.cancel(), `${k(i)}... [truncated]`;
2667
- o += c.byteLength, i += r.decode(c, { stream: !0 });
2965
+ return C(i + r.decode());
2966
+ const c = Bt - o;
2967
+ if (l.byteLength > c)
2968
+ return i += r.decode(l.subarray(0, Math.max(c, 0)), { stream: !0 }), t.cancel(), `${C(i)}... [truncated]`;
2969
+ o += l.byteLength, i += r.decode(l, { stream: !0 });
2668
2970
  }
2669
2971
  } catch {
2670
2972
  t?.cancel();
@@ -2673,45 +2975,45 @@ async function In(e) {
2673
2975
  s !== null && window.clearTimeout(s);
2674
2976
  }
2675
2977
  }
2676
- function Tn(e, t) {
2677
- if (ee(new Headers(t)))
2978
+ function hr(e, t) {
2979
+ if (He(new Headers(t)))
2678
2980
  try {
2679
- return e.responseType === "" || e.responseType === "text" ? k(e.responseText ?? "") : void 0;
2981
+ return e.responseType === "" || e.responseType === "text" ? C(e.responseText ?? "") : void 0;
2680
2982
  } catch {
2681
2983
  return;
2682
2984
  }
2683
2985
  }
2684
- function Bt(e) {
2986
+ function we(e) {
2685
2987
  if (typeof e == "string")
2686
- return k(e);
2988
+ return C(e);
2687
2989
  }
2688
- function wn(e) {
2689
- return A({
2990
+ function pr(e) {
2991
+ return _({
2690
2992
  ...e,
2691
- requestBody: vt(e.requestBody),
2692
- responseBody: vt(e.responseBody)
2993
+ requestBody: Ie(e.requestBody),
2994
+ responseBody: Ie(e.responseBody)
2693
2995
  });
2694
2996
  }
2695
- function vt(e) {
2997
+ function Ie(e) {
2696
2998
  if (typeof e != "string")
2697
2999
  return e;
2698
3000
  const t = e.trim();
2699
3001
  if (!t.startsWith("{") && !t.startsWith("["))
2700
- return j(e);
3002
+ return rt(e);
2701
3003
  try {
2702
- return JSON.stringify(A(JSON.parse(e)));
3004
+ return JSON.stringify(_(JSON.parse(e)));
2703
3005
  } catch {
2704
- return j(e);
3006
+ return rt(e);
2705
3007
  }
2706
3008
  }
2707
- function ee(e) {
3009
+ function He(e) {
2708
3010
  if (!e)
2709
3011
  return !1;
2710
3012
  const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
2711
- return s !== null && Number.isInteger(n) && n >= 0 && n <= dt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
3013
+ return s !== null && Number.isInteger(n) && n >= 0 && n <= Bt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
2712
3014
  }
2713
- function b(e, t = {}, s) {
2714
- if (Sn(s))
3015
+ function v(e, t = {}, s) {
3016
+ if (gr(s))
2715
3017
  return !0;
2716
3018
  const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
2717
3019
  if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
@@ -2721,13 +3023,13 @@ function b(e, t = {}, s) {
2721
3023
  if (r.protocol !== "http:" && r.protocol !== "https:")
2722
3024
  return !0;
2723
3025
  const i = r.hostname.toLowerCase(), o = r.pathname.toLowerCase();
2724
- return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((l) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(l));
3026
+ return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((a) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(a));
2725
3027
  } catch {
2726
3028
  return !0;
2727
3029
  }
2728
3030
  }
2729
- function An(e, t) {
2730
- if (b(e))
3031
+ function fr(e, t) {
3032
+ if (v(e))
2731
3033
  return !0;
2732
3034
  try {
2733
3035
  const s = new URL(e, location.href), n = new URL(t);
@@ -2736,115 +3038,115 @@ function An(e, t) {
2736
3038
  return !0;
2737
3039
  }
2738
3040
  }
2739
- function Sn(e) {
3041
+ function gr(e) {
2740
3042
  return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
2741
3043
  }
2742
- function kn(e) {
3044
+ function mr(e) {
2743
3045
  const t = {};
2744
3046
  for (const s of e.trim().split(/[\r\n]+/)) {
2745
3047
  const n = s.indexOf(":");
2746
3048
  if (n <= 0)
2747
3049
  continue;
2748
- if (Object.keys(t).length >= ht)
3050
+ if (Object.keys(t).length >= qt)
2749
3051
  break;
2750
3052
  const r = s.slice(0, n).trim();
2751
- t[r] = Tt(r, s.slice(n + 1).trim());
3053
+ t[r] = Gt(r, s.slice(n + 1).trim());
2752
3054
  }
2753
3055
  return t;
2754
3056
  }
2755
- function k(e, t = dt) {
3057
+ function C(e, t = Bt) {
2756
3058
  return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
2757
3059
  }
2758
- function Q(e) {
3060
+ function bt(e) {
2759
3061
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
2760
3062
  }
2761
- class H extends Error {
3063
+ class st extends Error {
2762
3064
  constructor(t, s) {
2763
3065
  super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
2764
3066
  }
2765
3067
  status;
2766
3068
  }
2767
- async function tt(e, t) {
3069
+ async function Rt(e, t) {
2768
3070
  let s = null;
2769
- for (let n = 0; n < Et; n += 1)
3071
+ for (let n = 0; n < oe; n += 1)
2770
3072
  try {
2771
3073
  return await e();
2772
3074
  } catch (r) {
2773
- if (s = r, n >= Et - 1 || !Rn(r))
3075
+ if (s = r, n >= oe - 1 || !Tr(r))
2774
3076
  throw r;
2775
- await En(n);
3077
+ await yr(n);
2776
3078
  }
2777
3079
  throw s instanceof Error ? s : new Error(t);
2778
3080
  }
2779
- function En(e) {
3081
+ function yr(e) {
2780
3082
  return new Promise((t) => {
2781
- window.setTimeout(t, qe[e] ?? 0);
3083
+ window.setTimeout(t, bs[e] ?? 0);
2782
3084
  });
2783
3085
  }
2784
- function Rn(e) {
2785
- return e instanceof H ? _n(e.status) : e instanceof TypeError;
3086
+ function Tr(e) {
3087
+ return e instanceof st ? wr(e.status) : e instanceof TypeError;
2786
3088
  }
2787
- function _n(e) {
3089
+ function wr(e) {
2788
3090
  return e === 408 || e === 409 || e === 429 || e >= 500;
2789
3091
  }
2790
- function bn(e) {
3092
+ function Ir(e) {
2791
3093
  return e === 401 || e === 403;
2792
3094
  }
2793
- const X = "[REDACTED_SECRET]", E = "[REDACTED_TOKEN]", Mn = "[REDACTED_SIGNED_URL]", Cn = 20, Pn = /^(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, se = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ne = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, re = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, ie = /\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, Un = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Dn = /\bhttps?:\/\/[^\s"'<>]+/gi, Nn = /[),.;\]]+$/;
2794
- function A(e) {
2795
- return W(e, 0, /* @__PURE__ */ new WeakSet());
3095
+ const lt = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Ar = "[REDACTED_SIGNED_URL]", Sr = 20, Er = /^(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, Fe = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, We = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, $e = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, je = /\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, kr = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, br = /\bhttps?:\/\/[^\s"'<>]+/gi, Rr = /[),.;\]]+$/;
3096
+ function _(e) {
3097
+ return nt(e, 0, /* @__PURE__ */ new WeakSet());
2796
3098
  }
2797
- function W(e, t, s) {
3099
+ function nt(e, t, s) {
2798
3100
  if (typeof e == "string")
2799
- return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : j(e);
3101
+ return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : rt(e);
2800
3102
  if (e === null || typeof e != "object")
2801
3103
  return e;
2802
- if (t >= Cn)
3104
+ if (t >= Sr)
2803
3105
  return "[REDACTED_MAX_DEPTH]";
2804
3106
  if (s.has(e))
2805
3107
  return "[REDACTED_CIRCULAR]";
2806
3108
  if (s.add(e), Array.isArray(e))
2807
- return e.map((r) => W(r, t + 1, s));
3109
+ return e.map((r) => nt(r, t + 1, s));
2808
3110
  const n = {};
2809
3111
  for (const [r, i] of Object.entries(e))
2810
- oe(r) ? n[r] = X : n[r] = r.toLowerCase() === "url" ? On(i) : W(i, t + 1, s);
3112
+ r === "pageContent" ? n[r] = i : ze(r) ? n[r] = lt : n[r] = r.toLowerCase() === "url" ? _r(i) : nt(i, t + 1, s);
2811
3113
  return n;
2812
3114
  }
2813
- function oe(e) {
3115
+ function ze(e) {
2814
3116
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
2815
3117
  return t.includes("authorization") || t.includes("cookie") || t.includes("password") || t.includes("passwd") || t === "pwd" || t.includes("secret") || t === "token" || t.endsWith("token") || t.includes("apikey") || t.includes("csrf") || t.includes("xsrf") || t === "jwt" || t === "session" || t === "signature" || t.includes("privatekey");
2816
3118
  }
2817
- function On(e) {
2818
- return typeof e == "string" ? ae(e) : W(e, 0, /* @__PURE__ */ new WeakSet());
3119
+ function _r(e) {
3120
+ return typeof e == "string" ? Ge(e) : nt(e, 0, /* @__PURE__ */ new WeakSet());
2819
3121
  }
2820
- function ae(e) {
3122
+ function Ge(e) {
2821
3123
  try {
2822
3124
  const t = new URL(e, location.href);
2823
3125
  for (const s of Array.from(t.searchParams.keys()))
2824
- Pn.test(s) && t.searchParams.set(s, E);
2825
- return t.username && (t.username = E), t.password && (t.password = E), t.toString();
3126
+ Er.test(s) && t.searchParams.set(s, P);
3127
+ return t.username && (t.username = P), t.password && (t.password = P), t.toString();
2826
3128
  } catch {
2827
- return Ln(e);
3129
+ return Mr(e);
2828
3130
  }
2829
3131
  }
2830
- function j(e) {
2831
- return e.replace(Un, Mn).replace(Dn, Bn).replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
3132
+ function rt(e) {
3133
+ return e.replace(kr, Ar).replace(br, Cr).replace(Fe, `Bearer ${P}`).replace(We, `Basic ${P}`).replace($e, P).replace(je, (t, s) => `${s}: ${lt}`);
2832
3134
  }
2833
- function Ln(e) {
2834
- return e.replace(se, `Bearer ${E}`).replace(ne, `Basic ${E}`).replace(re, E).replace(ie, (t, s) => `${s}: ${X}`);
3135
+ function Mr(e) {
3136
+ return e.replace(Fe, `Bearer ${P}`).replace(We, `Basic ${P}`).replace($e, P).replace(je, (t, s) => `${s}: ${lt}`);
2835
3137
  }
2836
- function Bn(e) {
2837
- const t = e.match(Nn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
2838
- return `${ae(s)}${t}`;
3138
+ function Cr(e) {
3139
+ const t = e.match(Rr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
3140
+ return `${Ge(s)}${t}`;
2839
3141
  }
2840
3142
  export {
2841
- wt as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
2842
- st as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
2843
- Ae as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
2844
- we as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
2845
- Se as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
2846
- $t as PlunoProductAgent,
2847
- $e as calculateReconnectDelay,
2848
- $t as default,
2849
- us as getProductAgentOriginAccessErrorMessage
3143
+ se as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
3144
+ Mt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
3145
+ cs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
3146
+ as as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
3147
+ ls as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
3148
+ Re as PlunoProductAgent,
3149
+ Us as calculateReconnectDelay,
3150
+ Re as default,
3151
+ Zs as getProductAgentOriginAccessErrorMessage
2850
3152
  };