@pluno/product-agent-web 0.1.22 → 0.1.24

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,12 +1,11 @@
1
- const z = "https://app.pluno.ai", F = "gpt-5.4";
2
- const H = "pluno.productAgent.state.", k = "pluno.productAgent.pendingEvents.", R = "pluno.productAgent.transportId";
3
- class q {
1
+ const S = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', V = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Y = ".pluno-pa-widget__panel", Z = ".pluno-pa-widget__timeline", M = `${S}[data-pluno-sdk-preview-channel]`, Q = "https://app.pluno.ai", tt = "gpt-5.4", et = 2e4, st = 2e3, m = 6e4, nt = 15e3, rt = 2, it = 1e3, _ = 1e5, ot = 100, L = "pluno.productAgent.state.", E = "pluno.productAgent.pendingEvents.", N = "pluno.productAgent.transportId";
2
+ class W {
4
3
  constructor(t) {
5
- this.options = t, this.transportId = at(), this.state = {
4
+ this.options = t, this.transportId = _t(), this.state = {
6
5
  ...this.state,
7
- starterPrompts: et(t.initialStarterPrompts)
6
+ starterPrompts: ft(t.initialStarterPrompts)
8
7
  };
9
- const s = It(t.clientId);
8
+ const s = t.restorePersistedState === !1 ? null : qt(t.clientId, t.expectedPersistedSessionId);
10
9
  s && (this.state = {
11
10
  ...this.state,
12
11
  ...s,
@@ -15,7 +14,7 @@ class q {
15
14
  assistantDraft: "",
16
15
  isThinking: !1,
17
16
  lastError: null
18
- }), this.queuedClientEvents = Et(t.clientId);
17
+ }), this.queuedClientEvents = xt(t.clientId);
19
18
  }
20
19
  options;
21
20
  listeners = {};
@@ -45,14 +44,15 @@ class q {
45
44
  messages: [],
46
45
  assistantDraft: "",
47
46
  isThinking: !1,
48
- lastError: null
47
+ lastError: null,
48
+ lastErrorCode: null
49
49
  };
50
50
  static async init(t) {
51
- const s = new q({
51
+ const s = new W({
52
52
  ...t,
53
- backendUrl: V(t.backendUrl ?? z),
54
- clientId: t.clientId ?? ot(),
55
- model: t.model ?? F
53
+ backendUrl: ut(t.backendUrl ?? Q),
54
+ clientId: t.clientId ?? kt(),
55
+ model: t.model ?? tt
56
56
  });
57
57
  try {
58
58
  s.enableNetworkCapture(), t.autoConnect !== !1 && await s.connect();
@@ -78,9 +78,9 @@ class q {
78
78
  return;
79
79
  if (this.setState({ status: (this.state.status === "closed", "connecting"), lastError: null }), this.token = this.options.token ?? await this.options.tokenProvider?.() ?? null, !this.token && !this.options.webSocketFactory)
80
80
  throw new Error("Pluno requires a token or tokenProvider");
81
- const t = Z(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
81
+ const t = dt(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
82
82
  this.socket = s, s.addEventListener("open", () => {
83
- this.socket === s && (l("web-sdk.agent", "Pluno socket opened", {
83
+ this.socket === s && (u("web-sdk.agent", "Pluno socket opened", {
84
84
  queuedClientEventCount: this.queuedClientEvents.length,
85
85
  isThinking: this.state.isThinking
86
86
  }), this.token && this.sendNow({
@@ -90,9 +90,9 @@ class q {
90
90
  transportId: this.transportId
91
91
  }), this.flushQueuedClientEvents(), this.startHeartbeat(), this.setState({ status: "connected", lastError: null }));
92
92
  }), s.addEventListener("message", (n) => {
93
- this.socket === s && this.handleServerEvent(Q(n.data));
93
+ this.socket === s && this.handleServerEvent(pt(n.data));
94
94
  }), s.addEventListener("close", (n) => {
95
- this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (l("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
95
+ this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (u("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
96
96
  code: typeof n?.code == "number" ? n.code : null,
97
97
  reason: typeof n?.reason == "string" ? n.reason : "",
98
98
  wasClean: typeof n?.wasClean == "boolean" ? n.wasClean : null,
@@ -100,7 +100,7 @@ class q {
100
100
  isThinking: this.state.isThinking
101
101
  }), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
102
102
  }), s.addEventListener("error", () => {
103
- this.socket !== s || this.state.status === "closed" || (l("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
103
+ this.socket !== s || this.state.status === "closed" || (u("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
104
104
  queuedClientEventCount: this.queuedClientEvents.length,
105
105
  isThinking: this.state.isThinking
106
106
  }), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), s.readyState !== WebSocket.CLOSED && s.readyState !== WebSocket.CLOSING && s.close());
@@ -118,7 +118,7 @@ class q {
118
118
  const n = t.trim(), r = s.attachments ?? [];
119
119
  if (!n && r.length === 0)
120
120
  return;
121
- const i = g(), a = ct(), o = {
121
+ const i = g(), a = St(), o = {
122
122
  id: `local-${a}`,
123
123
  role: "user",
124
124
  content: n,
@@ -139,7 +139,7 @@ class q {
139
139
  attachments: r.length > 0 ? r : void 0,
140
140
  page: i,
141
141
  model: this.options.model,
142
- metadata: K(this.options.metadata)
142
+ metadata: at(this.options.metadata)
143
143
  };
144
144
  this.activeClientMessageId = a, this.activeUserMessageEvent = c, this.markThinkingProgress(), this.send(c);
145
145
  }
@@ -161,7 +161,7 @@ class q {
161
161
  });
162
162
  }
163
163
  send(t) {
164
- this.sendNow(f(t)) || (this.queuedClientEvents.push(t), m(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
164
+ this.sendNow(f(t)) || (this.queuedClientEvents.push(t), T(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
165
165
  }
166
166
  sendNow(t) {
167
167
  if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
@@ -170,7 +170,7 @@ class q {
170
170
  try {
171
171
  return s.send(JSON.stringify(t)), !0;
172
172
  } catch (n) {
173
- return l("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
173
+ return u("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
174
174
  message: n instanceof Error ? n.message : String(n),
175
175
  queuedClientEventCount: this.queuedClientEvents.length,
176
176
  isThinking: this.state.isThinking
@@ -181,26 +181,26 @@ class q {
181
181
  if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
182
182
  return;
183
183
  const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
184
- m(this.options.clientId, this.queuedClientEvents);
184
+ T(this.options.clientId, this.queuedClientEvents);
185
185
  for (let s = 0; s < t.length; s += 1) {
186
186
  const n = t[s];
187
187
  if (!this.sendNow(f(n))) {
188
- this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), m(this.options.clientId, this.queuedClientEvents);
188
+ this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), T(this.options.clientId, this.queuedClientEvents);
189
189
  return;
190
190
  }
191
- m(this.options.clientId, this.queuedClientEvents);
191
+ T(this.options.clientId, this.queuedClientEvents);
192
192
  }
193
193
  }
194
194
  handleServerEvent(t) {
195
- if (J(t) && this.markThinkingProgress(), t.type === "auth.ok") {
196
- const s = st(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
197
- l("web-sdk.agent", "Received auth.ok appearance", {
195
+ if (ct(t) && this.markThinkingProgress(), t.type === "auth.ok") {
196
+ const s = yt(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
197
+ u("web-sdk.agent", "Received auth.ok appearance", {
198
198
  hasAppearance: n,
199
199
  rawAppearance: t.appearance,
200
200
  normalizedAppearance: s
201
- }), this.runtimeHelperJavascript = nt(t.runtimeHelpers)?.javascript ?? null;
202
- const r = tt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), a = {
203
- user: ut(t.user),
201
+ }), this.runtimeHelperJavascript = mt(t.runtimeHelpers)?.javascript ?? null;
202
+ const r = gt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), a = {
203
+ user: Et(t.user),
204
204
  status: "connected"
205
205
  };
206
206
  (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r), (n || s) && (a.appearance = s), this.setState(a), this.state.sessionId && this.send({
@@ -213,21 +213,21 @@ class q {
213
213
  }
214
214
  if (t.type === "conversation.state") {
215
215
  const s = Array.isArray(t.items) ? t.items : [];
216
- Tt(s) && this.clearRetryTimers(), this.setState({
217
- sessionId: P(t.session, "id") ?? this.state.sessionId,
218
- messages: lt(s),
219
- ...b(s) ? { assistantDraft: "", isThinking: !1 } : {}
220
- }), b(s) && this.clearThinkingWatchdog();
216
+ Dt(s) && this.clearRetryTimers(), this.setState({
217
+ sessionId: q(t.session, "id") ?? this.state.sessionId,
218
+ messages: It(s),
219
+ ...O(s) ? { assistantDraft: "", isThinking: !1 } : {}
220
+ }), O(s) && this.clearThinkingWatchdog();
221
221
  return;
222
222
  }
223
223
  if (t.type === "session.updated") {
224
- this.setState({ sessionId: P(t.session, "id") ?? this.state.sessionId });
224
+ this.setState({ sessionId: q(t.session, "id") ?? this.state.sessionId });
225
225
  return;
226
226
  }
227
227
  if (t.type === "session.item") {
228
- const s = U(t.item);
228
+ const s = B(t.item);
229
229
  s && (s.role === "assistant" && this.clearRetryTimers(), this.setState({
230
- messages: yt(this.state.messages, s),
230
+ messages: Mt(this.state.messages, s),
231
231
  assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
232
232
  ...I(t.item.data) ? { assistantDraft: "", isThinking: !1 } : {}
233
233
  }), I(t.item.data) && this.clearThinkingWatchdog(), this.emit("message", s));
@@ -251,7 +251,12 @@ class q {
251
251
  if (this.retryAfterRetryableError(t))
252
252
  return;
253
253
  const s = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error");
254
- this.setState({ status: "error", isThinking: !1, lastError: s.message }), this.clearThinkingWatchdog(), this.emit("error", s);
254
+ this.setState({
255
+ status: "error",
256
+ isThinking: !1,
257
+ lastError: s.message,
258
+ lastErrorCode: typeof t.code == "string" ? t.code : null
259
+ }), this.clearThinkingWatchdog(), this.emit("error", s);
255
260
  }
256
261
  }
257
262
  retryAfterRetryableError(t) {
@@ -277,7 +282,7 @@ class q {
277
282
  this.retryTimersByClientMessageId = {};
278
283
  }
279
284
  markThinkingProgress() {
280
- !this.state.isThinking || this.state.status === "closed" || this.scheduleThinkingWatchdog(6e4);
285
+ !this.state.isThinking || this.state.status === "closed" || this.scheduleThinkingWatchdog(m);
281
286
  }
282
287
  scheduleThinkingWatchdog(t) {
283
288
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -292,33 +297,33 @@ class q {
292
297
  return;
293
298
  const t = this.activeClientMessageId;
294
299
  if (!t) {
295
- l("web-sdk.agent", "Pluno thinking watchdog resyncing without active message id", {
300
+ u("web-sdk.agent", "Pluno thinking watchdog resyncing without active message id", {
296
301
  sessionId: this.state.sessionId
297
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(6e4);
302
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(m);
298
303
  return;
299
304
  }
300
305
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.thinkingWatchdogRetryAttemptsByClientMessageId[t] ?? 0;
301
306
  if (s <= n) {
302
- this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, l("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
307
+ this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, u("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
303
308
  sessionId: this.state.sessionId,
304
309
  clientMessageId: t,
305
310
  resyncAttempts: s + 1
306
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(15e3);
311
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(nt);
307
312
  return;
308
313
  }
309
- if (n >= 2) {
310
- l("web-sdk.agent", "Pluno thinking watchdog retry limit reached; continuing resync", {
314
+ if (n >= rt) {
315
+ u("web-sdk.agent", "Pluno thinking watchdog retry limit reached; continuing resync", {
311
316
  sessionId: this.state.sessionId,
312
317
  clientMessageId: t,
313
318
  retryAttempts: n
314
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(6e4);
319
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(m);
315
320
  return;
316
321
  }
317
322
  this.thinkingWatchdogRetryAttemptsByClientMessageId[t] = n + 1, this.setState({
318
323
  status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
319
324
  isThinking: !0,
320
325
  lastError: null
321
- }), l("web-sdk.agent", "Pluno thinking watchdog retrying last user message", {
326
+ }), u("web-sdk.agent", "Pluno thinking watchdog retrying last user message", {
322
327
  sessionId: this.state.sessionId,
323
328
  clientMessageId: t,
324
329
  retryAttempts: n + 1
@@ -326,7 +331,7 @@ class q {
326
331
  type: "chat.retry_last_user_message",
327
332
  sessionId: this.state.sessionId,
328
333
  clientMessageId: t
329
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(6e4);
334
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(m);
330
335
  }
331
336
  resyncThinkingSession() {
332
337
  this.state.sessionId ? this.send({
@@ -338,9 +343,9 @@ class q {
338
343
  }
339
344
  async executeToolCall(t) {
340
345
  const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = t.rawInput;
341
- if (!s || !n || !Ct(r))
346
+ if (!s || !n || !Bt(r))
342
347
  return;
343
- const i = await this.executeRuntimeHelper(), a = await M(r).catch((o) => ({
348
+ const i = await this.executeRuntimeHelper(), a = await D(r).catch((o) => ({
344
349
  ok: !1,
345
350
  exception: {
346
351
  message: o instanceof Error ? o.message : String(o)
@@ -353,77 +358,77 @@ class q {
353
358
  toolName: "execute_code",
354
359
  summary: r.summary,
355
360
  rawInput: f(r),
356
- rawOutput: f(rt(a, i))
361
+ rawOutput: f(Tt(a, i))
357
362
  });
358
363
  }
359
364
  async executeRuntimeHelper() {
360
365
  if (!this.runtimeHelperJavascript?.trim())
361
366
  return null;
362
- const t = await M({
367
+ const t = await D({
363
368
  javascript: this.runtimeHelperJavascript
364
369
  });
365
- return t.ok === !1 ? it(t) : null;
370
+ return t.ok === !1 ? wt(t) : null;
366
371
  }
367
372
  enableNetworkCapture() {
368
373
  if (this.networkCaptureCleanup)
369
374
  return;
370
375
  const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
371
376
  window.fetch = async (i, a) => {
372
- const o = Date.now(), c = new Date(o).toISOString(), u = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : u?.url ?? "", w = (a?.method ?? u?.method ?? "GET").toUpperCase(), A = O(new Headers(a?.headers ?? u?.headers ?? void 0)), C = await Rt(u, a);
377
+ const o = Date.now(), c = new Date(o).toISOString(), l = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : l?.url ?? "", R = (a?.method ?? l?.method ?? "GET").toUpperCase(), b = x(new Headers(a?.headers ?? l?.headers ?? void 0)), P = await jt(l, a);
373
378
  try {
374
379
  const d = await t(i, a);
375
380
  return this.enqueueNetworkEvent({
376
- requestId: T("fetch"),
381
+ requestId: w("fetch"),
377
382
  url: y,
378
- method: w,
379
- requestHeaders: A,
380
- requestBody: C,
383
+ method: R,
384
+ requestHeaders: b,
385
+ requestBody: P,
381
386
  resourceType: "fetch",
382
387
  responseStatus: d.status,
383
- responseHeaders: O(d.headers),
384
- responseBody: await Mt(d),
388
+ responseHeaders: x(d.headers),
389
+ responseBody: await vt(d),
385
390
  startedAt: c,
386
391
  durationMs: Date.now() - o
387
392
  }), d;
388
393
  } catch (d) {
389
394
  throw this.enqueueNetworkEvent({
390
- requestId: T("fetch"),
395
+ requestId: w("fetch"),
391
396
  url: y,
392
- method: w,
393
- requestHeaders: A,
394
- requestBody: C,
397
+ method: R,
398
+ requestHeaders: b,
399
+ requestBody: P,
395
400
  resourceType: "fetch",
396
401
  errorText: d instanceof Error ? d.message : String(d),
397
402
  startedAt: c,
398
403
  durationMs: Date.now() - o
399
404
  }), d;
400
405
  }
401
- }, XMLHttpRequest.prototype.open = function(a, o, c, u, y) {
406
+ }, XMLHttpRequest.prototype.open = function(a, o, c, l, y) {
402
407
  return this.__plunoMeta = {
403
- requestId: T("xhr"),
408
+ requestId: w("xhr"),
404
409
  method: String(a ?? "GET").toUpperCase(),
405
410
  url: typeof o == "string" ? o : o.toString(),
406
411
  requestHeaders: {},
407
412
  startedAtMs: Date.now(),
408
413
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
409
- }, s.call(this, a, o, c ?? !0, u ?? void 0, y ?? void 0);
414
+ }, s.call(this, a, o, c ?? !0, l ?? void 0, y ?? void 0);
410
415
  }, XMLHttpRequest.prototype.setRequestHeader = function(a, o) {
411
416
  const c = this.__plunoMeta;
412
417
  if (c) {
413
- const u = c.requestHeaders ?? {};
414
- u[a] = o, c.requestHeaders = u;
418
+ const l = c.requestHeaders ?? {};
419
+ l[a] = o, c.requestHeaders = l;
415
420
  }
416
421
  return n.call(this, a, o);
417
422
  }, XMLHttpRequest.prototype.send = function(a) {
418
423
  const o = window.__plunoProductAgentInstance, c = this.__plunoMeta ?? {
419
- requestId: T("xhr"),
424
+ requestId: w("xhr"),
420
425
  method: "GET",
421
426
  url: "",
422
427
  requestHeaders: {},
423
428
  startedAtMs: Date.now(),
424
429
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
425
430
  };
426
- return c.requestBody = L(a), this.__plunoMeta = c, this.addEventListener(
431
+ return c.requestBody = G(a), this.__plunoMeta = c, this.addEventListener(
427
432
  "loadend",
428
433
  function() {
429
434
  !o || !this.__plunoMeta || o.enqueueNetworkEvent({
@@ -434,8 +439,8 @@ class q {
434
439
  requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
435
440
  resourceType: "xhr",
436
441
  responseStatus: this.status,
437
- responseHeaders: Nt(this.getAllResponseHeaders()),
438
- responseBody: bt(this),
442
+ responseHeaders: Gt(this.getAllResponseHeaders()),
443
+ responseBody: $t(this),
439
444
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
440
445
  startedAt: String(this.__plunoMeta.startedAt),
441
446
  durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
@@ -457,35 +462,39 @@ class q {
457
462
  page: g(),
458
463
  events: s
459
464
  });
460
- }, 1e3));
465
+ }, it));
461
466
  }
462
467
  scheduleReconnect() {
463
468
  this.reconnectTimer !== null || this.state.status === "closed" || (this.reconnectTimer = window.setTimeout(() => {
464
469
  this.reconnectTimer = null, this.connect().catch((t) => {
465
- l("web-sdk.agent", "Pluno reconnect failed; retrying", {
470
+ u("web-sdk.agent", "Pluno reconnect failed; retrying", {
466
471
  message: t instanceof Error ? t.message : String(t),
467
472
  queuedClientEventCount: this.queuedClientEvents.length,
468
473
  isThinking: this.state.isThinking
469
474
  }), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect();
470
475
  });
471
- }, 2e3));
476
+ }, st));
472
477
  }
473
478
  startHeartbeat() {
474
479
  this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
475
480
  this.sendNow({ type: "runtime.ping" });
476
- }, 2e4);
481
+ }, et);
477
482
  }
478
483
  stopHeartbeat() {
479
484
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
480
485
  }
481
486
  setState(t) {
482
- this.state = { ...this.state, ...t }, _t(this.options.clientId, this.state), this.emit("state", this.getState());
487
+ this.state = {
488
+ ...this.state,
489
+ ...t,
490
+ ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
491
+ }, Ht(this.options.clientId, this.state), this.emit("state", this.getState());
483
492
  }
484
493
  emit(t, s) {
485
494
  this.listeners[t]?.forEach((r) => r(s));
486
495
  }
487
496
  }
488
- function l(e, t, s) {
497
+ function u(e, t, s) {
489
498
  if (typeof window > "u")
490
499
  return;
491
500
  const n = window, r = {
@@ -496,17 +505,17 @@ function l(e, t, s) {
496
505
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
497
506
  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 }));
498
507
  }
499
- function K(e) {
508
+ function at(e) {
500
509
  const t = typeof e == "function" ? e() : e;
501
510
  return t && Object.keys(t).length > 0 ? t : void 0;
502
511
  }
503
- function J(e) {
512
+ function ct(e) {
504
513
  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";
505
514
  }
506
- const Y = 5e3;
507
- async function M(e) {
515
+ const lt = 5e3;
516
+ async function D(e) {
508
517
  const t = Object.getPrototypeOf(async function() {
509
- }).constructor, s = Y, n = Date.now(), r = [], i = {
518
+ }).constructor, s = lt, n = Date.now(), r = [], i = {
510
519
  log: console.log,
511
520
  info: console.info,
512
521
  warn: console.warn,
@@ -521,7 +530,7 @@ async function M(e) {
521
530
  result: await Promise.race([
522
531
  new t(e.javascript)(),
523
532
  new Promise(
524
- (c, u) => window.setTimeout(() => u(new Error(`execute_code timed out after ${s}ms`)), s)
533
+ (c, l) => window.setTimeout(() => l(new Error(`execute_code timed out after ${s}ms`)), s)
525
534
  )
526
535
  ]),
527
536
  console: r,
@@ -550,21 +559,55 @@ async function M(e) {
550
559
  console.log = i.log, console.info = i.info, console.warn = i.warn, console.error = i.error;
551
560
  }
552
561
  }
553
- function V(e) {
562
+ function ut(e) {
554
563
  return e.replace(/\/+$/, "");
555
564
  }
556
- function Z(e) {
565
+ function dt(e) {
557
566
  const t = new URL("/api/product-agent/embed/ws", e);
558
567
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
559
568
  }
560
569
  function g() {
570
+ const e = ht();
561
571
  return {
562
572
  url: location.href,
563
573
  title: document.title,
564
- origin: location.origin
574
+ origin: location.origin,
575
+ ...e ? { plunoProductAgentUi: e } : {}
576
+ };
577
+ }
578
+ function ht() {
579
+ const e = document.querySelector(M);
580
+ if (!(e ?? document.querySelector(S)))
581
+ return;
582
+ const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
583
+ return {
584
+ surface: s,
585
+ description: s === "browser_extension_sdk_preview" ? "Pluno browser-extension SDK preview widget embedded in the host page." : "Pluno Product Agent default widget embedded in the host page.",
586
+ selectors: [
587
+ {
588
+ name: "widget_host",
589
+ selector: s === "browser_extension_sdk_preview" ? M : S,
590
+ description: "Finds Pluno's shadow-host element in the host page DOM."
591
+ },
592
+ {
593
+ name: "widget_root",
594
+ selector: V,
595
+ description: "Finds Pluno's widget root inside the widget host shadow root."
596
+ },
597
+ {
598
+ name: "widget_panel",
599
+ selector: Y,
600
+ description: "Finds Pluno's open chat panel inside the widget host shadow root."
601
+ },
602
+ {
603
+ name: "widget_timeline",
604
+ selector: Z,
605
+ description: "Finds Pluno's chat timeline inside the widget host shadow root."
606
+ }
607
+ ]
565
608
  };
566
609
  }
567
- function Q(e) {
610
+ function pt(e) {
568
611
  try {
569
612
  const t = JSON.parse(e);
570
613
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -572,16 +615,16 @@ function Q(e) {
572
615
  return { type: "error", message: "Invalid server event" };
573
616
  }
574
617
  }
575
- function tt(e, t) {
618
+ function gt(e, t) {
576
619
  if (!e || typeof e != "object")
577
620
  return [];
578
621
  const s = e[t];
579
622
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
580
623
  }
581
- function et(e) {
624
+ function ft(e) {
582
625
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
583
626
  }
584
- function st(e) {
627
+ function yt(e) {
585
628
  if (!e || typeof e != "object")
586
629
  return null;
587
630
  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, a = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, o = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
@@ -592,13 +635,13 @@ function st(e) {
592
635
  ...o !== null ? { scribbleStyle: o } : {}
593
636
  };
594
637
  }
595
- function nt(e) {
638
+ function mt(e) {
596
639
  if (!e || typeof e != "object")
597
640
  return null;
598
641
  const t = e.javascript;
599
642
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
600
643
  }
601
- function rt(e, t) {
644
+ function Tt(e, t) {
602
645
  return t ? e && typeof e == "object" ? {
603
646
  ...e,
604
647
  helperError: t
@@ -608,30 +651,30 @@ function rt(e, t) {
608
651
  helperError: t
609
652
  } : e;
610
653
  }
611
- function it(e) {
654
+ function wt(e) {
612
655
  if (!e || typeof e != "object")
613
656
  return e;
614
657
  const t = e;
615
658
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
616
659
  }
617
- function ot() {
660
+ function kt() {
618
661
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
619
662
  if (t)
620
663
  return t;
621
664
  const s = crypto.randomUUID();
622
665
  return window.localStorage.setItem(e, s), s;
623
666
  }
624
- function at() {
625
- const e = window.sessionStorage.getItem(R);
667
+ function _t() {
668
+ const e = window.sessionStorage.getItem(N);
626
669
  if (e)
627
670
  return e;
628
671
  const t = crypto.randomUUID();
629
- return window.sessionStorage.setItem(R, t), t;
672
+ return window.sessionStorage.setItem(N, t), t;
630
673
  }
631
- function ct() {
674
+ function St() {
632
675
  return crypto.randomUUID();
633
676
  }
634
- function ut(e) {
677
+ function Et(e) {
635
678
  if (!e || typeof e != "object")
636
679
  return null;
637
680
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -642,12 +685,12 @@ function ut(e) {
642
685
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
643
686
  } : null;
644
687
  }
645
- function lt(e) {
646
- return Array.isArray(e) ? _(
647
- e.map(U).filter((t) => t !== null)
688
+ function It(e) {
689
+ return Array.isArray(e) ? A(
690
+ e.map(B).filter((t) => t !== null)
648
691
  ) : [];
649
692
  }
650
- function U(e) {
693
+ function B(e) {
651
694
  if (!e || typeof e != "object")
652
695
  return null;
653
696
  const t = e, s = t.data;
@@ -659,32 +702,32 @@ function U(e) {
659
702
  return {
660
703
  id: String(t.id ?? crypto.randomUUID()),
661
704
  role: r,
662
- content: ft(n.content),
705
+ content: Pt(n.content),
663
706
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
664
- attachments: B(n.attachments)
707
+ attachments: $(n.attachments)
665
708
  };
666
709
  }
667
710
  return n.type === "function_call" || n.type === "tool_call" || n.type === "web_search_call" ? {
668
711
  id: String(t.id ?? crypto.randomUUID()),
669
712
  role: "tool",
670
- content: ht(n),
713
+ content: Ct(n),
671
714
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
672
715
  dataType: String(n.type),
673
716
  toolName: typeof n.name == "string" ? n.name : void 0,
674
- callId: gt(n) ?? void 0,
717
+ callId: bt(n) ?? void 0,
675
718
  loading: n.localExecutionStatus === "running"
676
719
  } : n.type === "run_status" || n.type === "run_error" ? n.type === "run_status" && (n.status === "running" || n.status === "retrying") || n.type === "run_error" && n.stage === "tool_execution" ? null : {
677
720
  id: String(t.id ?? crypto.randomUUID()),
678
721
  role: "system",
679
- content: dt(n),
722
+ content: At(n),
680
723
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
681
724
  dataType: String(n.type)
682
725
  } : null;
683
726
  }
684
- function dt(e) {
727
+ function At(e) {
685
728
  return 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." : e.type === "run_status" && e.status === "stopped" ? "Pluno stopped." : "Pluno run status changed.";
686
729
  }
687
- function ht(e) {
730
+ function Ct(e) {
688
731
  if (e.type === "web_search_call") {
689
732
  const t = e.action;
690
733
  if (t && typeof t == "object") {
@@ -696,9 +739,9 @@ function ht(e) {
696
739
  }
697
740
  return "Searching the web";
698
741
  }
699
- return pt(e);
742
+ return Rt(e);
700
743
  }
701
- function pt(e) {
744
+ function Rt(e) {
702
745
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
703
746
  return e.summary;
704
747
  if (typeof e.arguments == "string")
@@ -711,11 +754,11 @@ function pt(e) {
711
754
  }
712
755
  return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
713
756
  }
714
- function gt(e) {
757
+ function bt(e) {
715
758
  const t = e.callId ?? e.call_id;
716
759
  return typeof t == "string" && t ? t : null;
717
760
  }
718
- function ft(e) {
761
+ function Pt(e) {
719
762
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
720
763
  if (!t || typeof t != "object")
721
764
  return "";
@@ -723,14 +766,14 @@ function ft(e) {
723
766
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
724
767
  }).filter(Boolean).join("") : "";
725
768
  }
726
- function yt(e, t) {
727
- const s = mt(e, t), n = s.findIndex((i) => i.id === t.id);
769
+ function Mt(e, t) {
770
+ const s = Nt(e, t), n = s.findIndex((i) => i.id === t.id);
728
771
  if (n === -1)
729
- return _([...s, t]);
772
+ return A([...s, t]);
730
773
  const r = [...s];
731
- return r[n] = t, _(r);
774
+ return r[n] = t, A(r);
732
775
  }
733
- function mt(e, t) {
776
+ function Nt(e, t) {
734
777
  if (t.role !== "user")
735
778
  return e;
736
779
  const s = e.findIndex(
@@ -741,15 +784,15 @@ function mt(e, t) {
741
784
  const n = [...e];
742
785
  return n.splice(s, 1), n;
743
786
  }
744
- function b(e) {
745
- const t = W(e);
787
+ function O(e) {
788
+ const t = j(e);
746
789
  return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : I(s.data));
747
790
  }
748
- function Tt(e) {
749
- const t = W(e);
750
- return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : N(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : N(s.data));
791
+ function Dt(e) {
792
+ const t = j(e);
793
+ return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : U(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : U(s.data));
751
794
  }
752
- function W(e) {
795
+ function j(e) {
753
796
  for (let t = e.length - 1; t >= 0; t -= 1) {
754
797
  const s = e[t];
755
798
  if (!s || typeof s != "object")
@@ -763,7 +806,7 @@ function W(e) {
763
806
  }
764
807
  return null;
765
808
  }
766
- function N(e) {
809
+ function U(e) {
767
810
  if (!e || typeof e != "object")
768
811
  return !1;
769
812
  const t = e;
@@ -775,13 +818,13 @@ function I(e) {
775
818
  const t = e;
776
819
  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");
777
820
  }
778
- function _(e) {
779
- return e.filter((t, s) => St(t) ? !kt(e, s) : !0);
821
+ function A(e) {
822
+ return e.filter((t, s) => Ot(t) ? !Ut(e, s) : !0);
780
823
  }
781
- function St(e) {
824
+ function Ot(e) {
782
825
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
783
826
  }
784
- function kt(e, t) {
827
+ function Ut(e, t) {
785
828
  for (let s = t + 1; s < e.length; s += 1) {
786
829
  const n = e[s];
787
830
  if (n.role === "user")
@@ -791,89 +834,92 @@ function kt(e, t) {
791
834
  }
792
835
  return !1;
793
836
  }
794
- function P(e, t) {
837
+ function q(e, t) {
795
838
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
796
839
  }
797
- function It(e) {
840
+ function qt(e, t) {
798
841
  try {
799
- const t = window.localStorage.getItem(`${H}${e}`);
800
- if (!t)
842
+ const s = window.localStorage.getItem(`${L}${e}`);
843
+ if (!s)
844
+ return null;
845
+ const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
846
+ if (t !== void 0 && r !== t)
801
847
  return null;
802
- const s = JSON.parse(t), n = Array.isArray(s.messages) ? s.messages.map(At).filter((r) => !!r) : [];
848
+ const i = Array.isArray(n.messages) ? n.messages.map(Wt).filter((a) => !!a) : [];
803
849
  return {
804
- sessionId: typeof s.sessionId == "string" ? s.sessionId : null,
805
- messages: n
850
+ sessionId: r,
851
+ messages: i
806
852
  };
807
853
  } catch {
808
854
  return null;
809
855
  }
810
856
  }
811
- function _t(e, t) {
857
+ function Ht(e, t) {
812
858
  try {
813
859
  window.localStorage.setItem(
814
- `${H}${e}`,
860
+ `${L}${e}`,
815
861
  JSON.stringify({
816
862
  sessionId: t.sessionId,
817
- messages: t.messages.slice(-100)
863
+ messages: t.messages.slice(-ot)
818
864
  })
819
865
  );
820
866
  } catch {
821
867
  return;
822
868
  }
823
869
  }
824
- function Et(e) {
870
+ function xt(e) {
825
871
  try {
826
- const t = window.localStorage.getItem(`${k}${e}`);
872
+ const t = window.localStorage.getItem(`${E}${e}`);
827
873
  if (!t)
828
874
  return [];
829
875
  const s = JSON.parse(t);
830
- return Array.isArray(s) ? s.filter(x) : [];
876
+ return Array.isArray(s) ? s.filter(v) : [];
831
877
  } catch {
832
878
  return [];
833
879
  }
834
880
  }
835
- function m(e, t) {
881
+ function T(e, t) {
836
882
  try {
837
- const s = t.filter(x);
883
+ const s = t.filter(v);
838
884
  if (s.length === 0) {
839
- window.localStorage.removeItem(`${k}${e}`);
885
+ window.localStorage.removeItem(`${E}${e}`);
840
886
  return;
841
887
  }
842
888
  window.localStorage.setItem(
843
- `${k}${e}`,
889
+ `${E}${e}`,
844
890
  JSON.stringify(s.slice(-25))
845
891
  );
846
892
  } catch {
847
893
  return;
848
894
  }
849
895
  }
850
- function x(e) {
896
+ function v(e) {
851
897
  if (!e || typeof e != "object")
852
898
  return !1;
853
899
  const t = e;
854
- return t.type === "chat.user_message" ? typeof t.content == "string" && D(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? D(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" : !1;
900
+ return t.type === "chat.user_message" ? typeof t.content == "string" && H(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? H(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" : !1;
855
901
  }
856
- function D(e) {
902
+ function H(e) {
857
903
  if (!e || typeof e != "object")
858
904
  return !1;
859
905
  const t = e;
860
906
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
861
907
  }
862
- function B(e) {
908
+ function $(e) {
863
909
  if (!Array.isArray(e))
864
910
  return;
865
911
  const t = e.filter((s) => {
866
912
  if (!s || typeof s != "object")
867
913
  return !1;
868
914
  const n = s;
869
- return typeof n.name == "string" && wt(n.mimeType) && typeof n.sizeBytes == "number" && typeof n.dataUrl == "string";
915
+ return typeof n.name == "string" && Lt(n.mimeType) && typeof n.sizeBytes == "number" && typeof n.dataUrl == "string";
870
916
  });
871
917
  return t.length > 0 ? t : void 0;
872
918
  }
873
- function wt(e) {
919
+ function Lt(e) {
874
920
  return e === "image/png" || e === "image/jpeg" || e === "image/webp" || e === "image/gif" || e === "application/pdf";
875
921
  }
876
- function At(e) {
922
+ function Wt(e) {
877
923
  if (!e || typeof e != "object")
878
924
  return null;
879
925
  const t = e;
@@ -883,22 +929,22 @@ function At(e) {
883
929
  content: t.content,
884
930
  createdAt: t.createdAt,
885
931
  dataType: typeof t.dataType == "string" ? t.dataType : void 0,
886
- attachments: B(t.attachments),
932
+ attachments: $(t.attachments),
887
933
  loading: typeof t.loading == "boolean" ? t.loading : void 0
888
934
  };
889
935
  }
890
- function Ct(e) {
936
+ function Bt(e) {
891
937
  return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
892
938
  }
893
- function O(e) {
939
+ function x(e) {
894
940
  const t = {};
895
941
  return e?.forEach((s, n) => {
896
942
  t[n] = s;
897
943
  }), t;
898
944
  }
899
- async function Rt(e, t) {
945
+ async function jt(e, t) {
900
946
  if (typeof t?.body < "u")
901
- return L(t.body);
947
+ return G(t.body);
902
948
  if (e)
903
949
  try {
904
950
  return p(await e.clone().text());
@@ -906,21 +952,21 @@ async function Rt(e, t) {
906
952
  return;
907
953
  }
908
954
  }
909
- async function Mt(e) {
955
+ async function vt(e) {
910
956
  try {
911
957
  return p(await e.clone().text());
912
958
  } catch (t) {
913
959
  return { error: t instanceof Error ? t.message : "unavailable" };
914
960
  }
915
961
  }
916
- function bt(e) {
962
+ function $t(e) {
917
963
  try {
918
964
  return e.responseType === "" || e.responseType === "text" ? p(e.responseText ?? "") : e.responseType === "json" ? p(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
919
965
  } catch (t) {
920
966
  return { error: t instanceof Error ? t.message : "unavailable" };
921
967
  }
922
968
  }
923
- function L(e) {
969
+ function G(e) {
924
970
  if (!(e === null || typeof e > "u")) {
925
971
  if (typeof e == "string")
926
972
  return p(e);
@@ -939,7 +985,7 @@ function L(e) {
939
985
  }
940
986
  }
941
987
  }
942
- function Nt(e) {
988
+ function Gt(e) {
943
989
  const t = {};
944
990
  for (const s of e.trim().split(/[\r\n]+/)) {
945
991
  const n = s.indexOf(":");
@@ -948,59 +994,64 @@ function Nt(e) {
948
994
  return t;
949
995
  }
950
996
  function p(e) {
951
- return e.length <= 1e5 ? e : `${e.slice(0, 1e5)}... [truncated ${e.length - 1e5} chars]`;
997
+ return e.length <= _ ? e : `${e.slice(0, _)}... [truncated ${e.length - _} chars]`;
952
998
  }
953
- function T(e) {
999
+ function w(e) {
954
1000
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
955
1001
  }
956
- const E = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Pt = "[REDACTED_SIGNED_URL]", Dt = 20, Ot = /^(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, j = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, G = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, v = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, $ = /\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, Ht = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, qt = /\bhttps?:\/\/[^\s"'<>]+/gi, Ut = /[),.;\]]+$/;
1002
+ const C = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Ft = "[REDACTED_SIGNED_URL]", zt = 20, Xt = /^(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, F = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, z = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, X = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, J = /\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, Jt = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Kt = /\bhttps?:\/\/[^\s"'<>]+/gi, Vt = /[),.;\]]+$/;
957
1003
  function f(e) {
958
- return S(e, 0, /* @__PURE__ */ new WeakSet());
1004
+ return k(e, 0, /* @__PURE__ */ new WeakSet());
959
1005
  }
960
- function S(e, t, s) {
1006
+ function k(e, t, s) {
961
1007
  if (typeof e == "string")
962
- return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : Bt(e);
1008
+ return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : Qt(e);
963
1009
  if (e === null || typeof e != "object")
964
1010
  return e;
965
- if (t >= Dt)
1011
+ if (t >= zt)
966
1012
  return "[REDACTED_MAX_DEPTH]";
967
1013
  if (s.has(e))
968
1014
  return "[REDACTED_CIRCULAR]";
969
1015
  if (s.add(e), Array.isArray(e))
970
- return e.map((r) => S(r, t + 1, s));
1016
+ return e.map((r) => k(r, t + 1, s));
971
1017
  const n = {};
972
1018
  for (const [r, i] of Object.entries(e))
973
- Wt(r) ? n[r] = E : n[r] = r.toLowerCase() === "url" ? xt(i) : S(i, t + 1, s);
1019
+ Yt(r) ? n[r] = C : n[r] = r.toLowerCase() === "url" ? Zt(i) : k(i, t + 1, s);
974
1020
  return n;
975
1021
  }
976
- function Wt(e) {
1022
+ function Yt(e) {
977
1023
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
978
1024
  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");
979
1025
  }
980
- function xt(e) {
981
- return typeof e == "string" ? X(e) : S(e, 0, /* @__PURE__ */ new WeakSet());
1026
+ function Zt(e) {
1027
+ return typeof e == "string" ? K(e) : k(e, 0, /* @__PURE__ */ new WeakSet());
982
1028
  }
983
- function X(e) {
1029
+ function K(e) {
984
1030
  try {
985
1031
  const t = new URL(e, location.href);
986
1032
  for (const s of Array.from(t.searchParams.keys()))
987
- Ot.test(s) && t.searchParams.set(s, h);
1033
+ Xt.test(s) && t.searchParams.set(s, h);
988
1034
  return t.username && (t.username = h), t.password && (t.password = h), t.toString();
989
1035
  } catch {
990
- return Lt(e);
1036
+ return te(e);
991
1037
  }
992
1038
  }
993
- function Bt(e) {
994
- return e.replace(Ht, Pt).replace(qt, jt).replace(j, `Bearer ${h}`).replace(G, `Basic ${h}`).replace(v, h).replace($, (t, s) => `${s}: ${E}`);
1039
+ function Qt(e) {
1040
+ return e.replace(Jt, Ft).replace(Kt, ee).replace(F, `Bearer ${h}`).replace(z, `Basic ${h}`).replace(X, h).replace(J, (t, s) => `${s}: ${C}`);
995
1041
  }
996
- function Lt(e) {
997
- return e.replace(j, `Bearer ${h}`).replace(G, `Basic ${h}`).replace(v, h).replace($, (t, s) => `${s}: ${E}`);
1042
+ function te(e) {
1043
+ return e.replace(F, `Bearer ${h}`).replace(z, `Basic ${h}`).replace(X, h).replace(J, (t, s) => `${s}: ${C}`);
998
1044
  }
999
- function jt(e) {
1000
- const t = e.match(Ut)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
1001
- return `${X(s)}${t}`;
1045
+ function ee(e) {
1046
+ const t = e.match(Vt)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
1047
+ return `${K(s)}${t}`;
1002
1048
  }
1003
1049
  export {
1004
- q as PlunoProductAgent,
1005
- q as default
1050
+ M as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
1051
+ S as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
1052
+ Y as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
1053
+ V as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
1054
+ Z as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
1055
+ W as PlunoProductAgent,
1056
+ W as default
1006
1057
  };