@pluno/product-agent-web 0.1.27 → 0.1.28

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.
package/dist/index.d.ts CHANGED
@@ -105,8 +105,12 @@ export declare class PlunoProductAgent {
105
105
  private retryAttemptsByClientMessageId;
106
106
  private retryTimersByClientMessageId;
107
107
  private thinkingWatchdogTimer;
108
+ private runAckWatchdogTimer;
109
+ private runAckResyncRetryTimer;
108
110
  private activeClientMessageId;
109
111
  private activeUserMessageEvent;
112
+ private latestRecoverableClientMessageId;
113
+ private runAckRecoveryRetryAttemptsByClientMessageId;
110
114
  private thinkingWatchdogResyncAttemptsByClientMessageId;
111
115
  private thinkingWatchdogRetryAttemptsByClientMessageId;
112
116
  private runtimeHelperJavascript;
@@ -132,6 +136,12 @@ export declare class PlunoProductAgent {
132
136
  private markThinkingProgress;
133
137
  private scheduleThinkingWatchdog;
134
138
  private clearThinkingWatchdog;
139
+ private handleRunAck;
140
+ private scheduleRunAckWatchdog;
141
+ private recoverMissedRunAck;
142
+ private scheduleRunAckResyncRetry;
143
+ private clearRunAckResyncRetryTimer;
144
+ private clearRunAckTimers;
135
145
  private recoverStuckThinking;
136
146
  private resyncThinkingSession;
137
147
  private executeToolCall;
@@ -1,11 +1,11 @@
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 {
1
+ const I = '.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", N = `${I}[data-pluno-sdk-preview-channel]`, Q = "https://app.pluno.ai", tt = "gpt-5.4", et = 2e4, st = 2e3, p = 6e4, nt = 15e3, D = 2, rt = 15e3, it = 5e3, ot = 1e3, _ = 1e5, at = 100, x = "pluno.productAgent.state.", E = "pluno.productAgent.pendingEvents.", O = "pluno.productAgent.transportId";
2
+ class L {
3
3
  constructor(t) {
4
- this.options = t, this.transportId = _t(), this.state = {
4
+ this.options = t, this.transportId = It(), this.state = {
5
5
  ...this.state,
6
- starterPrompts: ft(t.initialStarterPrompts)
6
+ starterPrompts: yt(t.initialStarterPrompts)
7
7
  };
8
- const s = t.restorePersistedState === !1 ? null : qt(t.clientId, t.expectedPersistedSessionId);
8
+ const s = t.restorePersistedState === !1 ? null : xt(t.clientId, t.expectedPersistedSessionId);
9
9
  s && (this.state = {
10
10
  ...this.state,
11
11
  ...s,
@@ -14,7 +14,7 @@ class W {
14
14
  assistantDraft: "",
15
15
  isThinking: !1,
16
16
  lastError: null
17
- }), this.queuedClientEvents = xt(t.clientId);
17
+ }), this.queuedClientEvents = Bt(t.clientId);
18
18
  }
19
19
  options;
20
20
  listeners = {};
@@ -30,8 +30,12 @@ class W {
30
30
  retryAttemptsByClientMessageId = {};
31
31
  retryTimersByClientMessageId = {};
32
32
  thinkingWatchdogTimer = null;
33
+ runAckWatchdogTimer = null;
34
+ runAckResyncRetryTimer = null;
33
35
  activeClientMessageId = null;
34
36
  activeUserMessageEvent = null;
37
+ latestRecoverableClientMessageId = null;
38
+ runAckRecoveryRetryAttemptsByClientMessageId = {};
35
39
  thinkingWatchdogResyncAttemptsByClientMessageId = {};
36
40
  thinkingWatchdogRetryAttemptsByClientMessageId = {};
37
41
  runtimeHelperJavascript = null;
@@ -48,10 +52,10 @@ class W {
48
52
  lastErrorCode: null
49
53
  };
50
54
  static async init(t) {
51
- const s = new W({
55
+ const s = new L({
52
56
  ...t,
53
- backendUrl: ut(t.backendUrl ?? Q),
54
- clientId: t.clientId ?? kt(),
57
+ backendUrl: dt(t.backendUrl ?? Q),
58
+ clientId: t.clientId ?? _t(),
55
59
  model: t.model ?? tt
56
60
  });
57
61
  try {
@@ -78,7 +82,7 @@ class W {
78
82
  return;
79
83
  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
84
  throw new Error("Pluno requires a token or tokenProvider");
81
- const t = dt(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
85
+ const t = ht(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
82
86
  this.socket = s, s.addEventListener("open", () => {
83
87
  this.socket === s && (u("web-sdk.agent", "Pluno socket opened", {
84
88
  queuedClientEventCount: this.queuedClientEvents.length,
@@ -118,7 +122,7 @@ class W {
118
122
  const n = t.trim(), r = s.attachments ?? [];
119
123
  if (!n && r.length === 0)
120
124
  return;
121
- const i = g(), a = St(), o = {
125
+ const i = f(), a = Et(), o = {
122
126
  id: `local-${a}`,
123
127
  role: "user",
124
128
  content: n,
@@ -139,7 +143,7 @@ class W {
139
143
  attachments: r.length > 0 ? r : void 0,
140
144
  page: i,
141
145
  model: this.options.model,
142
- metadata: at(this.options.metadata)
146
+ metadata: ct(this.options.metadata)
143
147
  };
144
148
  this.activeClientMessageId = a, this.activeUserMessageEvent = c, this.markThinkingProgress(), this.send(c);
145
149
  }
@@ -150,7 +154,7 @@ class W {
150
154
  this.state.sessionId && this.state.isThinking && this.sendNow({ type: "run.stop", sessionId: this.state.sessionId }), this.queuedClientEvents = this.queuedClientEvents.filter((t) => t.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.send({
151
155
  type: "session.reset",
152
156
  sessionId: this.state.sessionId ?? void 0,
153
- page: g()
157
+ page: f()
154
158
  }), this.setState({
155
159
  sessionId: null,
156
160
  starterPrompts: [...this.state.starterPrompts],
@@ -161,7 +165,7 @@ class W {
161
165
  });
162
166
  }
163
167
  send(t) {
164
- this.sendNow(f(t)) || (this.queuedClientEvents.push(t), T(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
168
+ this.sendNow(y(t)) || (this.queuedClientEvents.push(t), T(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
165
169
  }
166
170
  sendNow(t) {
167
171
  if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
@@ -184,7 +188,7 @@ class W {
184
188
  T(this.options.clientId, this.queuedClientEvents);
185
189
  for (let s = 0; s < t.length; s += 1) {
186
190
  const n = t[s];
187
- if (!this.sendNow(f(n))) {
191
+ if (!this.sendNow(y(n))) {
188
192
  this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), T(this.options.clientId, this.queuedClientEvents);
189
193
  return;
190
194
  }
@@ -192,48 +196,57 @@ class W {
192
196
  }
193
197
  }
194
198
  handleServerEvent(t) {
195
- if (ct(t) && this.markThinkingProgress(), t.type === "auth.ok") {
196
- const s = yt(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
199
+ if (t.type === "run.ack") {
200
+ this.handleRunAck(t);
201
+ return;
202
+ }
203
+ if (lt(t) && this.markThinkingProgress(), t.type === "auth.ok") {
204
+ const s = mt(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
197
205
  u("web-sdk.agent", "Received auth.ok appearance", {
198
206
  hasAppearance: n,
199
207
  rawAppearance: t.appearance,
200
208
  normalizedAppearance: s
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),
209
+ }), this.runtimeHelperJavascript = Tt(t.runtimeHelpers)?.javascript ?? null;
210
+ const r = ft(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), a = {
211
+ user: St(t.user),
204
212
  status: "connected"
205
213
  };
206
214
  (i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r), (n || s) && (a.appearance = s), this.setState(a), this.state.sessionId && this.send({
207
215
  type: "page.upsert",
208
216
  sessionId: this.state.sessionId,
209
- page: g(),
217
+ page: f(),
210
218
  model: this.options.model
211
219
  });
212
220
  return;
213
221
  }
214
222
  if (t.type === "conversation.state") {
215
- const s = Array.isArray(t.items) ? t.items : [];
216
- Dt(s) && this.clearRetryTimers(), this.setState({
223
+ const s = Array.isArray(t.items) ? t.items : [], n = Ot(s), r = n ? null : Wt(s);
224
+ this.latestRecoverableClientMessageId = r, Ut(s) && this.clearRetryTimers(), this.setState({
217
225
  sessionId: q(t.session, "id") ?? this.state.sessionId,
218
- messages: It(s),
219
- ...O(s) ? { assistantDraft: "", isThinking: !1 } : {}
220
- }), O(s) && this.clearThinkingWatchdog();
226
+ messages: At(s),
227
+ ...n ? { assistantDraft: "", isThinking: !1 } : r ? { assistantDraft: "", isThinking: !0, lastError: null } : {}
228
+ }), n ? this.clearThinkingWatchdog() : r && (this.activeClientMessageId = r, this.markThinkingProgress());
221
229
  return;
222
230
  }
223
231
  if (t.type === "session.updated") {
224
- this.setState({ sessionId: q(t.session, "id") ?? this.state.sessionId });
232
+ this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: q(t.session, "id") ?? this.state.sessionId });
225
233
  return;
226
234
  }
227
235
  if (t.type === "session.item") {
228
236
  const s = B(t.item);
229
- s && (s.role === "assistant" && this.clearRetryTimers(), this.setState({
230
- messages: Mt(this.state.messages, s),
231
- assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
232
- ...I(t.item.data) ? { assistantDraft: "", isThinking: !1 } : {}
233
- }), I(t.item.data) && this.clearThinkingWatchdog(), this.emit("message", s));
237
+ if (s) {
238
+ s.role === "assistant" && (this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
239
+ const n = t.item.data;
240
+ qt(n) && this.clearRunAckResyncRetryTimer(), this.setState({
241
+ messages: Nt(this.state.messages, s),
242
+ assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
243
+ ...S(n) ? { assistantDraft: "", isThinking: !1 } : {}
244
+ }), S(n) && this.clearThinkingWatchdog(), this.emit("message", s);
245
+ }
234
246
  return;
235
247
  }
236
248
  if (t.type === "chat.assistant_delta") {
249
+ this.clearRunAckResyncRetryTimer();
237
250
  const s = typeof t.delta == "string" ? t.delta : "";
238
251
  this.setState({ assistantDraft: `${this.state.assistantDraft}${s}`, isThinking: !0 }), this.markThinkingProgress(), this.emit("delta", s);
239
252
  return;
@@ -244,7 +257,7 @@ class W {
244
257
  return;
245
258
  }
246
259
  if (t.type === "tool.call") {
247
- this.executeToolCall(t);
260
+ this.clearRunAckResyncRetryTimer(), this.executeToolCall(t);
248
261
  return;
249
262
  }
250
263
  if (t.type === "error") {
@@ -282,7 +295,7 @@ class W {
282
295
  this.retryTimersByClientMessageId = {};
283
296
  }
284
297
  markThinkingProgress() {
285
- !this.state.isThinking || this.state.status === "closed" || this.scheduleThinkingWatchdog(m);
298
+ !this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(p), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
286
299
  }
287
300
  scheduleThinkingWatchdog(t) {
288
301
  this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
@@ -290,7 +303,44 @@ class W {
290
303
  }, t);
291
304
  }
292
305
  clearThinkingWatchdog() {
293
- this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.activeClientMessageId = null, this.activeUserMessageEvent = null;
306
+ this.thinkingWatchdogTimer !== null && (window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = null), this.clearRunAckTimers(), this.activeClientMessageId = null, this.activeUserMessageEvent = null;
307
+ }
308
+ handleRunAck(t) {
309
+ const s = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
310
+ !this.state.isThinking || !s || s !== this.activeClientMessageId || (this.clearRunAckResyncRetryTimer(), this.scheduleRunAckWatchdog(s));
311
+ }
312
+ scheduleRunAckWatchdog(t) {
313
+ this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
314
+ this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
315
+ }, rt);
316
+ }
317
+ recoverMissedRunAck(t) {
318
+ !this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (u("web-sdk.agent", "Pluno run ack missed; resyncing session", {
319
+ sessionId: this.state.sessionId,
320
+ clientMessageId: t
321
+ }), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
322
+ }
323
+ scheduleRunAckResyncRetry(t) {
324
+ this.clearRunAckResyncRetryTimer(), this.runAckResyncRetryTimer = window.setTimeout(() => {
325
+ this.runAckResyncRetryTimer = null, !((this.runAckRecoveryRetryAttemptsByClientMessageId[t] ?? 0) >= 1) && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.runAckRecoveryRetryAttemptsByClientMessageId[t] = 1, this.thinkingWatchdogRetryAttemptsByClientMessageId[t] = D, this.setState({
326
+ status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
327
+ isThinking: !0,
328
+ lastError: null
329
+ }), u("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
330
+ sessionId: this.state.sessionId,
331
+ clientMessageId: t
332
+ }), this.state.sessionId ? this.send({
333
+ type: "chat.retry_last_user_message",
334
+ sessionId: this.state.sessionId,
335
+ clientMessageId: t
336
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(p)));
337
+ }, it);
338
+ }
339
+ clearRunAckResyncRetryTimer() {
340
+ this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
341
+ }
342
+ clearRunAckTimers() {
343
+ this.runAckWatchdogTimer !== null && (window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = null), this.clearRunAckResyncRetryTimer(), this.latestRecoverableClientMessageId = null;
294
344
  }
295
345
  recoverStuckThinking() {
296
346
  if (!this.state.isThinking || this.state.status === "closed")
@@ -299,7 +349,7 @@ class W {
299
349
  if (!t) {
300
350
  u("web-sdk.agent", "Pluno thinking watchdog resyncing without active message id", {
301
351
  sessionId: this.state.sessionId
302
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(m);
352
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(p);
303
353
  return;
304
354
  }
305
355
  const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.thinkingWatchdogRetryAttemptsByClientMessageId[t] ?? 0;
@@ -311,12 +361,12 @@ class W {
311
361
  }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(nt);
312
362
  return;
313
363
  }
314
- if (n >= rt) {
364
+ if (n >= D) {
315
365
  u("web-sdk.agent", "Pluno thinking watchdog retry limit reached; continuing resync", {
316
366
  sessionId: this.state.sessionId,
317
367
  clientMessageId: t,
318
368
  retryAttempts: n
319
- }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(m);
369
+ }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(p);
320
370
  return;
321
371
  }
322
372
  this.thinkingWatchdogRetryAttemptsByClientMessageId[t] = n + 1, this.setState({
@@ -331,21 +381,21 @@ class W {
331
381
  type: "chat.retry_last_user_message",
332
382
  sessionId: this.state.sessionId,
333
383
  clientMessageId: t
334
- }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(m);
384
+ }) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(p);
335
385
  }
336
386
  resyncThinkingSession() {
337
387
  this.state.sessionId ? this.send({
338
388
  type: "page.upsert",
339
389
  sessionId: this.state.sessionId,
340
- page: g(),
390
+ page: f(),
341
391
  model: this.options.model
342
392
  }) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
343
393
  }
344
394
  async executeToolCall(t) {
345
395
  const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = t.rawInput;
346
- if (!s || !n || !Bt(r))
396
+ if (!s || !n || !Gt(r))
347
397
  return;
348
- const i = await this.executeRuntimeHelper(), a = await D(r).catch((o) => ({
398
+ const i = await this.executeRuntimeHelper(), a = await U(r).catch((o) => ({
349
399
  ok: !1,
350
400
  exception: {
351
401
  message: o instanceof Error ? o.message : String(o)
@@ -357,14 +407,14 @@ class W {
357
407
  callId: n,
358
408
  toolName: "execute_code",
359
409
  summary: r.summary,
360
- rawInput: f(r),
361
- rawOutput: f(Tt(a, i))
410
+ rawInput: y(r),
411
+ rawOutput: y(kt(a, i))
362
412
  });
363
413
  }
364
414
  async executeRuntimeHelper() {
365
415
  if (!this.runtimeHelperJavascript?.trim())
366
416
  return null;
367
- const t = await D({
417
+ const t = await U({
368
418
  javascript: this.runtimeHelperJavascript
369
419
  });
370
420
  return t.ok === !1 ? wt(t) : null;
@@ -374,28 +424,28 @@ class W {
374
424
  return;
375
425
  const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
376
426
  window.fetch = async (i, 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);
427
+ const o = Date.now(), c = new Date(o).toISOString(), l = i instanceof Request ? i : null, m = typeof i == "string" ? i : i instanceof URL ? i.toString() : l?.url ?? "", b = (a?.method ?? l?.method ?? "GET").toUpperCase(), M = H(new Headers(a?.headers ?? l?.headers ?? void 0)), P = await Ft(l, a);
378
428
  try {
379
429
  const d = await t(i, a);
380
430
  return this.enqueueNetworkEvent({
381
- requestId: w("fetch"),
382
- url: y,
383
- method: R,
384
- requestHeaders: b,
431
+ requestId: k("fetch"),
432
+ url: m,
433
+ method: b,
434
+ requestHeaders: M,
385
435
  requestBody: P,
386
436
  resourceType: "fetch",
387
437
  responseStatus: d.status,
388
- responseHeaders: x(d.headers),
389
- responseBody: await vt(d),
438
+ responseHeaders: H(d.headers),
439
+ responseBody: await zt(d),
390
440
  startedAt: c,
391
441
  durationMs: Date.now() - o
392
442
  }), d;
393
443
  } catch (d) {
394
444
  throw this.enqueueNetworkEvent({
395
- requestId: w("fetch"),
396
- url: y,
397
- method: R,
398
- requestHeaders: b,
445
+ requestId: k("fetch"),
446
+ url: m,
447
+ method: b,
448
+ requestHeaders: M,
399
449
  requestBody: P,
400
450
  resourceType: "fetch",
401
451
  errorText: d instanceof Error ? d.message : String(d),
@@ -403,15 +453,15 @@ class W {
403
453
  durationMs: Date.now() - o
404
454
  }), d;
405
455
  }
406
- }, XMLHttpRequest.prototype.open = function(a, o, c, l, y) {
456
+ }, XMLHttpRequest.prototype.open = function(a, o, c, l, m) {
407
457
  return this.__plunoMeta = {
408
- requestId: w("xhr"),
458
+ requestId: k("xhr"),
409
459
  method: String(a ?? "GET").toUpperCase(),
410
460
  url: typeof o == "string" ? o : o.toString(),
411
461
  requestHeaders: {},
412
462
  startedAtMs: Date.now(),
413
463
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
414
- }, s.call(this, a, o, c ?? !0, l ?? void 0, y ?? void 0);
464
+ }, s.call(this, a, o, c ?? !0, l ?? void 0, m ?? void 0);
415
465
  }, XMLHttpRequest.prototype.setRequestHeader = function(a, o) {
416
466
  const c = this.__plunoMeta;
417
467
  if (c) {
@@ -421,7 +471,7 @@ class W {
421
471
  return n.call(this, a, o);
422
472
  }, XMLHttpRequest.prototype.send = function(a) {
423
473
  const o = window.__plunoProductAgentInstance, c = this.__plunoMeta ?? {
424
- requestId: w("xhr"),
474
+ requestId: k("xhr"),
425
475
  method: "GET",
426
476
  url: "",
427
477
  requestHeaders: {},
@@ -439,8 +489,8 @@ class W {
439
489
  requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
440
490
  resourceType: "xhr",
441
491
  responseStatus: this.status,
442
- responseHeaders: Gt(this.getAllResponseHeaders()),
443
- responseBody: $t(this),
492
+ responseHeaders: Jt(this.getAllResponseHeaders()),
493
+ responseBody: Xt(this),
444
494
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
445
495
  startedAt: String(this.__plunoMeta.startedAt),
446
496
  durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
@@ -453,16 +503,16 @@ class W {
453
503
  };
454
504
  }
455
505
  enqueueNetworkEvent(t) {
456
- this.queuedNetworkEvents.push(f(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
506
+ this.queuedNetworkEvents.push(y(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
457
507
  this.networkBatchTimer = null;
458
508
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
459
509
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
460
510
  type: "network.batch",
461
511
  sessionId: this.state.sessionId ?? void 0,
462
- page: g(),
512
+ page: f(),
463
513
  events: s
464
514
  });
465
- }, it));
515
+ }, ot));
466
516
  }
467
517
  scheduleReconnect() {
468
518
  this.reconnectTimer !== null || this.state.status === "closed" || (this.reconnectTimer = window.setTimeout(() => {
@@ -488,7 +538,7 @@ class W {
488
538
  ...this.state,
489
539
  ...t,
490
540
  ...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
491
- }, Ht(this.options.clientId, this.state), this.emit("state", this.getState());
541
+ }, Lt(this.options.clientId, this.state), this.emit("state", this.getState());
492
542
  }
493
543
  emit(t, s) {
494
544
  this.listeners[t]?.forEach((r) => r(s));
@@ -505,17 +555,17 @@ function u(e, t, s) {
505
555
  }, i = n.__plunoProductAgentDiagnostics__ ?? [];
506
556
  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 }));
507
557
  }
508
- function at(e) {
558
+ function ct(e) {
509
559
  const t = typeof e == "function" ? e() : e;
510
560
  return t && Object.keys(t).length > 0 ? t : void 0;
511
561
  }
512
- function ct(e) {
562
+ function lt(e) {
513
563
  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";
514
564
  }
515
- const lt = 5e3;
516
- async function D(e) {
565
+ const ut = 5e3;
566
+ async function U(e) {
517
567
  const t = Object.getPrototypeOf(async function() {
518
- }).constructor, s = lt, n = Date.now(), r = [], i = {
568
+ }).constructor, s = ut, n = Date.now(), r = [], i = {
519
569
  log: console.log,
520
570
  info: console.info,
521
571
  warn: console.warn,
@@ -559,15 +609,15 @@ async function D(e) {
559
609
  console.log = i.log, console.info = i.info, console.warn = i.warn, console.error = i.error;
560
610
  }
561
611
  }
562
- function ut(e) {
612
+ function dt(e) {
563
613
  return e.replace(/\/+$/, "");
564
614
  }
565
- function dt(e) {
615
+ function ht(e) {
566
616
  const t = new URL("/api/product-agent/embed/ws", e);
567
617
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
568
618
  }
569
- function g() {
570
- const e = ht();
619
+ function f() {
620
+ const e = gt();
571
621
  return {
572
622
  url: location.href,
573
623
  title: document.title,
@@ -575,9 +625,9 @@ function g() {
575
625
  ...e ? { plunoProductAgentUi: e } : {}
576
626
  };
577
627
  }
578
- function ht() {
579
- const e = document.querySelector(M);
580
- if (!(e ?? document.querySelector(S)))
628
+ function gt() {
629
+ const e = document.querySelector(N);
630
+ if (!(e ?? document.querySelector(I)))
581
631
  return;
582
632
  const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
583
633
  return {
@@ -586,7 +636,7 @@ function ht() {
586
636
  selectors: [
587
637
  {
588
638
  name: "widget_host",
589
- selector: s === "browser_extension_sdk_preview" ? M : S,
639
+ selector: s === "browser_extension_sdk_preview" ? N : I,
590
640
  description: "Finds Pluno's shadow-host element in the host page DOM."
591
641
  },
592
642
  {
@@ -615,16 +665,16 @@ function pt(e) {
615
665
  return { type: "error", message: "Invalid server event" };
616
666
  }
617
667
  }
618
- function gt(e, t) {
668
+ function ft(e, t) {
619
669
  if (!e || typeof e != "object")
620
670
  return [];
621
671
  const s = e[t];
622
672
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
623
673
  }
624
- function ft(e) {
674
+ function yt(e) {
625
675
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
626
676
  }
627
- function yt(e) {
677
+ function mt(e) {
628
678
  if (!e || typeof e != "object")
629
679
  return null;
630
680
  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;
@@ -635,13 +685,13 @@ function yt(e) {
635
685
  ...o !== null ? { scribbleStyle: o } : {}
636
686
  };
637
687
  }
638
- function mt(e) {
688
+ function Tt(e) {
639
689
  if (!e || typeof e != "object")
640
690
  return null;
641
691
  const t = e.javascript;
642
692
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
643
693
  }
644
- function Tt(e, t) {
694
+ function kt(e, t) {
645
695
  return t ? e && typeof e == "object" ? {
646
696
  ...e,
647
697
  helperError: t
@@ -657,24 +707,24 @@ function wt(e) {
657
707
  const t = e;
658
708
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
659
709
  }
660
- function kt() {
710
+ function _t() {
661
711
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
662
712
  if (t)
663
713
  return t;
664
714
  const s = crypto.randomUUID();
665
715
  return window.localStorage.setItem(e, s), s;
666
716
  }
667
- function _t() {
668
- const e = window.sessionStorage.getItem(N);
717
+ function It() {
718
+ const e = window.sessionStorage.getItem(O);
669
719
  if (e)
670
720
  return e;
671
721
  const t = crypto.randomUUID();
672
- return window.sessionStorage.setItem(N, t), t;
722
+ return window.sessionStorage.setItem(O, t), t;
673
723
  }
674
- function St() {
724
+ function Et() {
675
725
  return crypto.randomUUID();
676
726
  }
677
- function Et(e) {
727
+ function St(e) {
678
728
  if (!e || typeof e != "object")
679
729
  return null;
680
730
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -685,7 +735,7 @@ function Et(e) {
685
735
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
686
736
  } : null;
687
737
  }
688
- function It(e) {
738
+ function At(e) {
689
739
  return Array.isArray(e) ? A(
690
740
  e.map(B).filter((t) => t !== null)
691
741
  ) : [];
@@ -714,17 +764,17 @@ function B(e) {
714
764
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
715
765
  dataType: String(n.type),
716
766
  toolName: typeof n.name == "string" ? n.name : void 0,
717
- callId: bt(n) ?? void 0,
767
+ callId: Mt(n) ?? void 0,
718
768
  loading: n.localExecutionStatus === "running"
719
769
  } : 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 : {
720
770
  id: String(t.id ?? crypto.randomUUID()),
721
771
  role: "system",
722
- content: At(n),
772
+ content: Rt(n),
723
773
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
724
774
  dataType: String(n.type)
725
775
  } : null;
726
776
  }
727
- function At(e) {
777
+ function Rt(e) {
728
778
  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.";
729
779
  }
730
780
  function Ct(e) {
@@ -739,9 +789,9 @@ function Ct(e) {
739
789
  }
740
790
  return "Searching the web";
741
791
  }
742
- return Rt(e);
792
+ return bt(e);
743
793
  }
744
- function Rt(e) {
794
+ function bt(e) {
745
795
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
746
796
  return e.summary;
747
797
  if (typeof e.arguments == "string")
@@ -754,7 +804,7 @@ function Rt(e) {
754
804
  }
755
805
  return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
756
806
  }
757
- function bt(e) {
807
+ function Mt(e) {
758
808
  const t = e.callId ?? e.call_id;
759
809
  return typeof t == "string" && t ? t : null;
760
810
  }
@@ -766,14 +816,14 @@ function Pt(e) {
766
816
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
767
817
  }).filter(Boolean).join("") : "";
768
818
  }
769
- function Mt(e, t) {
770
- const s = Nt(e, t), n = s.findIndex((i) => i.id === t.id);
819
+ function Nt(e, t) {
820
+ const s = Dt(e, t), n = s.findIndex((i) => i.id === t.id);
771
821
  if (n === -1)
772
822
  return A([...s, t]);
773
823
  const r = [...s];
774
824
  return r[n] = t, A(r);
775
825
  }
776
- function Nt(e, t) {
826
+ function Dt(e, t) {
777
827
  if (t.role !== "user")
778
828
  return e;
779
829
  const s = e.findIndex(
@@ -784,15 +834,15 @@ function Nt(e, t) {
784
834
  const n = [...e];
785
835
  return n.splice(s, 1), n;
786
836
  }
787
- function O(e) {
788
- const t = j(e);
789
- return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : I(s.data));
837
+ function Ot(e) {
838
+ const t = R(e);
839
+ return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : S(s.data));
790
840
  }
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));
841
+ function Ut(e) {
842
+ const t = R(e);
843
+ return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : W(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : W(s.data));
794
844
  }
795
- function j(e) {
845
+ function R(e) {
796
846
  for (let t = e.length - 1; t >= 0; t -= 1) {
797
847
  const s = e[t];
798
848
  if (!s || typeof s != "object")
@@ -806,25 +856,44 @@ function j(e) {
806
856
  }
807
857
  return null;
808
858
  }
809
- function U(e) {
859
+ function Wt(e) {
860
+ const t = R(e);
861
+ if (t === null)
862
+ return null;
863
+ const s = e[t];
864
+ if (!s || typeof s != "object")
865
+ return null;
866
+ const n = s.data;
867
+ if (!n || typeof n != "object")
868
+ return null;
869
+ const r = n.clientMessageId;
870
+ return typeof r == "string" ? r : null;
871
+ }
872
+ function W(e) {
810
873
  if (!e || typeof e != "object")
811
874
  return !1;
812
875
  const t = e;
813
876
  return t.type === "message" && t.role === "assistant";
814
877
  }
815
- function I(e) {
878
+ function S(e) {
816
879
  if (!e || typeof e != "object")
817
880
  return !1;
818
881
  const t = e;
819
882
  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");
820
883
  }
884
+ function qt(e) {
885
+ if (!e || typeof e != "object")
886
+ return !1;
887
+ const t = e;
888
+ 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";
889
+ }
821
890
  function A(e) {
822
- return e.filter((t, s) => Ot(t) ? !Ut(e, s) : !0);
891
+ return e.filter((t, s) => vt(t) ? !Ht(e, s) : !0);
823
892
  }
824
- function Ot(e) {
893
+ function vt(e) {
825
894
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
826
895
  }
827
- function Ut(e, t) {
896
+ function Ht(e, t) {
828
897
  for (let s = t + 1; s < e.length; s += 1) {
829
898
  const n = e[s];
830
899
  if (n.role === "user")
@@ -837,15 +906,15 @@ function Ut(e, t) {
837
906
  function q(e, t) {
838
907
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
839
908
  }
840
- function qt(e, t) {
909
+ function xt(e, t) {
841
910
  try {
842
- const s = window.localStorage.getItem(`${L}${e}`);
911
+ const s = window.localStorage.getItem(`${x}${e}`);
843
912
  if (!s)
844
913
  return null;
845
914
  const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
846
915
  if (t !== void 0 && r !== t)
847
916
  return null;
848
- const i = Array.isArray(n.messages) ? n.messages.map(Wt).filter((a) => !!a) : [];
917
+ const i = Array.isArray(n.messages) ? n.messages.map($t).filter((a) => !!a) : [];
849
918
  return {
850
919
  sessionId: r,
851
920
  messages: i
@@ -854,33 +923,33 @@ function qt(e, t) {
854
923
  return null;
855
924
  }
856
925
  }
857
- function Ht(e, t) {
926
+ function Lt(e, t) {
858
927
  try {
859
928
  window.localStorage.setItem(
860
- `${L}${e}`,
929
+ `${x}${e}`,
861
930
  JSON.stringify({
862
931
  sessionId: t.sessionId,
863
- messages: t.messages.slice(-ot)
932
+ messages: t.messages.slice(-at)
864
933
  })
865
934
  );
866
935
  } catch {
867
936
  return;
868
937
  }
869
938
  }
870
- function xt(e) {
939
+ function Bt(e) {
871
940
  try {
872
941
  const t = window.localStorage.getItem(`${E}${e}`);
873
942
  if (!t)
874
943
  return [];
875
944
  const s = JSON.parse(t);
876
- return Array.isArray(s) ? s.filter(v) : [];
945
+ return Array.isArray(s) ? s.filter(j) : [];
877
946
  } catch {
878
947
  return [];
879
948
  }
880
949
  }
881
950
  function T(e, t) {
882
951
  try {
883
- const s = t.filter(v);
952
+ const s = t.filter(j);
884
953
  if (s.length === 0) {
885
954
  window.localStorage.removeItem(`${E}${e}`);
886
955
  return;
@@ -893,13 +962,13 @@ function T(e, t) {
893
962
  return;
894
963
  }
895
964
  }
896
- function v(e) {
965
+ function j(e) {
897
966
  if (!e || typeof e != "object")
898
967
  return !1;
899
968
  const t = e;
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;
969
+ return t.type === "chat.user_message" ? typeof t.content == "string" && v(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? v(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;
901
970
  }
902
- function H(e) {
971
+ function v(e) {
903
972
  if (!e || typeof e != "object")
904
973
  return !1;
905
974
  const t = e;
@@ -912,14 +981,14 @@ function $(e) {
912
981
  if (!s || typeof s != "object")
913
982
  return !1;
914
983
  const n = s;
915
- return typeof n.name == "string" && Lt(n.mimeType) && typeof n.sizeBytes == "number" && typeof n.dataUrl == "string";
984
+ return typeof n.name == "string" && jt(n.mimeType) && typeof n.sizeBytes == "number" && typeof n.dataUrl == "string";
916
985
  });
917
986
  return t.length > 0 ? t : void 0;
918
987
  }
919
- function Lt(e) {
988
+ function jt(e) {
920
989
  return e === "image/png" || e === "image/jpeg" || e === "image/webp" || e === "image/gif" || e === "application/pdf";
921
990
  }
922
- function Wt(e) {
991
+ function $t(e) {
923
992
  if (!e || typeof e != "object")
924
993
  return null;
925
994
  const t = e;
@@ -933,35 +1002,35 @@ function Wt(e) {
933
1002
  loading: typeof t.loading == "boolean" ? t.loading : void 0
934
1003
  };
935
1004
  }
936
- function Bt(e) {
1005
+ function Gt(e) {
937
1006
  return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
938
1007
  }
939
- function x(e) {
1008
+ function H(e) {
940
1009
  const t = {};
941
1010
  return e?.forEach((s, n) => {
942
1011
  t[n] = s;
943
1012
  }), t;
944
1013
  }
945
- async function jt(e, t) {
1014
+ async function Ft(e, t) {
946
1015
  if (typeof t?.body < "u")
947
1016
  return G(t.body);
948
1017
  if (e)
949
1018
  try {
950
- return p(await e.clone().text());
1019
+ return g(await e.clone().text());
951
1020
  } catch {
952
1021
  return;
953
1022
  }
954
1023
  }
955
- async function vt(e) {
1024
+ async function zt(e) {
956
1025
  try {
957
- return p(await e.clone().text());
1026
+ return g(await e.clone().text());
958
1027
  } catch (t) {
959
1028
  return { error: t instanceof Error ? t.message : "unavailable" };
960
1029
  }
961
1030
  }
962
- function $t(e) {
1031
+ function Xt(e) {
963
1032
  try {
964
- return e.responseType === "" || e.responseType === "text" ? p(e.responseText ?? "") : e.responseType === "json" ? p(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
1033
+ return e.responseType === "" || e.responseType === "text" ? g(e.responseText ?? "") : e.responseType === "json" ? g(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
965
1034
  } catch (t) {
966
1035
  return { error: t instanceof Error ? t.message : "unavailable" };
967
1036
  }
@@ -969,23 +1038,23 @@ function $t(e) {
969
1038
  function G(e) {
970
1039
  if (!(e === null || typeof e > "u")) {
971
1040
  if (typeof e == "string")
972
- return p(e);
1041
+ return g(e);
973
1042
  if (e instanceof URLSearchParams)
974
- return p(e.toString());
1043
+ return g(e.toString());
975
1044
  if (e instanceof FormData) {
976
1045
  const t = [];
977
- return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])), p(JSON.stringify(t));
1046
+ return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])), g(JSON.stringify(t));
978
1047
  }
979
1048
  if (e instanceof Blob)
980
1049
  return `[blob:${e.type || "application/octet-stream"}:${e.size}]`;
981
1050
  try {
982
- return p(JSON.stringify(e));
1051
+ return g(JSON.stringify(e));
983
1052
  } catch {
984
1053
  return `[unserializable body: ${Object.prototype.toString.call(e)}]`;
985
1054
  }
986
1055
  }
987
1056
  }
988
- function Gt(e) {
1057
+ function Jt(e) {
989
1058
  const t = {};
990
1059
  for (const s of e.trim().split(/[\r\n]+/)) {
991
1060
  const n = s.indexOf(":");
@@ -993,65 +1062,65 @@ function Gt(e) {
993
1062
  }
994
1063
  return t;
995
1064
  }
996
- function p(e) {
1065
+ function g(e) {
997
1066
  return e.length <= _ ? e : `${e.slice(0, _)}... [truncated ${e.length - _} chars]`;
998
1067
  }
999
- function w(e) {
1068
+ function k(e) {
1000
1069
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
1001
1070
  }
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 = /[),.;\]]+$/;
1003
- function f(e) {
1004
- return k(e, 0, /* @__PURE__ */ new WeakSet());
1071
+ const C = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Kt = "[REDACTED_SIGNED_URL]", Vt = 20, Yt = /^(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, Zt = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Qt = /\bhttps?:\/\/[^\s"'<>]+/gi, te = /[),.;\]]+$/;
1072
+ function y(e) {
1073
+ return w(e, 0, /* @__PURE__ */ new WeakSet());
1005
1074
  }
1006
- function k(e, t, s) {
1075
+ function w(e, t, s) {
1007
1076
  if (typeof e == "string")
1008
- return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : Qt(e);
1077
+ return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : ne(e);
1009
1078
  if (e === null || typeof e != "object")
1010
1079
  return e;
1011
- if (t >= zt)
1080
+ if (t >= Vt)
1012
1081
  return "[REDACTED_MAX_DEPTH]";
1013
1082
  if (s.has(e))
1014
1083
  return "[REDACTED_CIRCULAR]";
1015
1084
  if (s.add(e), Array.isArray(e))
1016
- return e.map((r) => k(r, t + 1, s));
1085
+ return e.map((r) => w(r, t + 1, s));
1017
1086
  const n = {};
1018
1087
  for (const [r, i] of Object.entries(e))
1019
- Yt(r) ? n[r] = C : n[r] = r.toLowerCase() === "url" ? Zt(i) : k(i, t + 1, s);
1088
+ ee(r) ? n[r] = C : n[r] = r.toLowerCase() === "url" ? se(i) : w(i, t + 1, s);
1020
1089
  return n;
1021
1090
  }
1022
- function Yt(e) {
1091
+ function ee(e) {
1023
1092
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
1024
1093
  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");
1025
1094
  }
1026
- function Zt(e) {
1027
- return typeof e == "string" ? K(e) : k(e, 0, /* @__PURE__ */ new WeakSet());
1095
+ function se(e) {
1096
+ return typeof e == "string" ? K(e) : w(e, 0, /* @__PURE__ */ new WeakSet());
1028
1097
  }
1029
1098
  function K(e) {
1030
1099
  try {
1031
1100
  const t = new URL(e, location.href);
1032
1101
  for (const s of Array.from(t.searchParams.keys()))
1033
- Xt.test(s) && t.searchParams.set(s, h);
1102
+ Yt.test(s) && t.searchParams.set(s, h);
1034
1103
  return t.username && (t.username = h), t.password && (t.password = h), t.toString();
1035
1104
  } catch {
1036
- return te(e);
1105
+ return re(e);
1037
1106
  }
1038
1107
  }
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}`);
1108
+ function ne(e) {
1109
+ return e.replace(Zt, Kt).replace(Qt, ie).replace(F, `Bearer ${h}`).replace(z, `Basic ${h}`).replace(X, h).replace(J, (t, s) => `${s}: ${C}`);
1041
1110
  }
1042
- function te(e) {
1111
+ function re(e) {
1043
1112
  return e.replace(F, `Bearer ${h}`).replace(z, `Basic ${h}`).replace(X, h).replace(J, (t, s) => `${s}: ${C}`);
1044
1113
  }
1045
- function ee(e) {
1046
- const t = e.match(Vt)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
1114
+ function ie(e) {
1115
+ const t = e.match(te)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
1047
1116
  return `${K(s)}${t}`;
1048
1117
  }
1049
1118
  export {
1050
- M as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
1051
- S as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
1119
+ N as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
1120
+ I as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
1052
1121
  Y as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
1053
1122
  V as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
1054
1123
  Z as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
1055
- W as PlunoProductAgent,
1056
- W as default
1124
+ L as PlunoProductAgent,
1125
+ L as default
1057
1126
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",