@pluno/product-agent-web 0.1.135 → 0.1.140

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