@pluno/product-agent-web 0.1.13 → 0.1.15

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,4 +1,5 @@
1
1
  export declare function createProductAgentCharacterSvg(primaryColor: string): string;
2
2
  export declare function createProductAgentCharacterDataUri(primaryColor: string): string;
3
+ export declare function getScribbleVisibleAccentColor(primaryColor: string): string;
3
4
  export declare function createScribbleProductAgentCharacterSvg(primaryColor: string): string;
4
5
  export declare function createScribbleProductAgentCharacterDataUri(primaryColor: string): string;
package/dist/index.d.ts CHANGED
@@ -40,7 +40,7 @@ export type ProductAgentInitOptions = {
40
40
  backendUrl?: string;
41
41
  model?: ProductAgentModel;
42
42
  clientId?: string;
43
- metadata?: Record<string, unknown>;
43
+ metadata?: Record<string, unknown> | (() => Record<string, unknown> | undefined);
44
44
  autoConnect?: boolean;
45
45
  initialStarterPrompts?: string[];
46
46
  webSocketFactory?: ProductAgentWebSocketFactory;
@@ -2,11 +2,11 @@ const X = "https://app.pluno.ai";
2
2
  const O = "pluno.productAgent.state.", k = "pluno.productAgent.pendingEvents.", R = "pluno.productAgent.transportId";
3
3
  class q {
4
4
  constructor(t) {
5
- this.options = t, this.transportId = rt(), this.state = {
5
+ this.options = t, this.transportId = it(), this.state = {
6
6
  ...this.state,
7
- starterPrompts: Z(t.initialStarterPrompts)
7
+ starterPrompts: Q(t.initialStarterPrompts)
8
8
  };
9
- const s = mt(t.clientId);
9
+ const s = Tt(t.clientId);
10
10
  s && (this.state = {
11
11
  ...this.state,
12
12
  ...s,
@@ -15,7 +15,7 @@ class q {
15
15
  assistantDraft: "",
16
16
  isThinking: !1,
17
17
  lastError: null
18
- }), this.queuedClientEvents = St(t.clientId);
18
+ }), this.queuedClientEvents = kt(t.clientId);
19
19
  }
20
20
  options;
21
21
  listeners = {};
@@ -50,8 +50,8 @@ class q {
50
50
  static async init(t) {
51
51
  const s = new q({
52
52
  ...t,
53
- backendUrl: K(t.backendUrl ?? X),
54
- clientId: t.clientId ?? nt()
53
+ backendUrl: J(t.backendUrl ?? X),
54
+ clientId: t.clientId ?? rt()
55
55
  });
56
56
  try {
57
57
  s.enableNetworkCapture(), t.autoConnect !== !1 && await s.connect();
@@ -77,7 +77,7 @@ class q {
77
77
  return;
78
78
  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)
79
79
  throw new Error("Product Agent requires a token or tokenProvider");
80
- const t = J(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
80
+ const t = Y(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
81
81
  this.socket = s, s.addEventListener("open", () => {
82
82
  this.socket === s && (l("web-sdk.agent", "Product Agent socket opened", {
83
83
  queuedClientEventCount: this.queuedClientEvents.length,
@@ -89,7 +89,7 @@ class q {
89
89
  transportId: this.transportId
90
90
  }), this.flushQueuedClientEvents(), this.startHeartbeat(), this.setState({ status: "connected", lastError: null }));
91
91
  }), s.addEventListener("message", (n) => {
92
- this.socket === s && this.handleServerEvent(Y(n.data));
92
+ this.socket === s && this.handleServerEvent(V(n.data));
93
93
  }), s.addEventListener("close", (n) => {
94
94
  this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (l("web-sdk.agent", "Product Agent socket closed; scheduling reconnect", {
95
95
  code: typeof n?.code == "number" ? n.code : null,
@@ -117,7 +117,7 @@ class q {
117
117
  const s = t.trim();
118
118
  if (!s)
119
119
  return;
120
- const n = g(), r = it(), i = {
120
+ const n = g(), r = ot(), i = {
121
121
  id: `local-${r}`,
122
122
  role: "user",
123
123
  content: s,
@@ -136,7 +136,7 @@ class q {
136
136
  content: s,
137
137
  page: n,
138
138
  model: this.options.model,
139
- metadata: this.options.metadata
139
+ metadata: F(this.options.metadata)
140
140
  };
141
141
  this.activeClientMessageId = r, this.activeUserMessageEvent = o, this.markThinkingProgress(), this.send(o);
142
142
  }
@@ -189,15 +189,15 @@ class q {
189
189
  }
190
190
  }
191
191
  handleServerEvent(t) {
192
- if (F(t) && this.markThinkingProgress(), t.type === "auth.ok") {
193
- const s = Q(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
192
+ if (z(t) && this.markThinkingProgress(), t.type === "auth.ok") {
193
+ const s = tt(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
194
194
  l("web-sdk.agent", "Received auth.ok appearance", {
195
195
  hasAppearance: n,
196
196
  rawAppearance: t.appearance,
197
197
  normalizedAppearance: s
198
- }), this.runtimeHelperJavascript = tt(t.runtimeHelpers)?.javascript ?? null;
199
- const r = V(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = {
200
- user: ot(t.user),
198
+ }), this.runtimeHelperJavascript = et(t.runtimeHelpers)?.javascript ?? null;
199
+ const r = Z(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = {
200
+ user: at(t.user),
201
201
  status: "connected"
202
202
  };
203
203
  (i || this.state.starterPrompts.length === 0) && (o.starterPrompts = r), (n || s) && (o.appearance = s), this.setState(o), this.state.sessionId && this.send({
@@ -210,9 +210,9 @@ class q {
210
210
  }
211
211
  if (t.type === "conversation.state") {
212
212
  const s = Array.isArray(t.items) ? t.items : [];
213
- gt(s) && this.clearRetryTimers(), this.setState({
213
+ ft(s) && this.clearRetryTimers(), this.setState({
214
214
  sessionId: P(t.session, "id") ?? this.state.sessionId,
215
- messages: at(s),
215
+ messages: ct(s),
216
216
  ...b(s) ? { assistantDraft: "", isThinking: !1 } : {}
217
217
  }), b(s) && this.clearThinkingWatchdog();
218
218
  return;
@@ -224,7 +224,7 @@ class q {
224
224
  if (t.type === "session.item") {
225
225
  const s = U(t.item);
226
226
  s && (s.role === "assistant" && this.clearRetryTimers(), this.setState({
227
- messages: ht(this.state.messages, s),
227
+ messages: pt(this.state.messages, s),
228
228
  assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
229
229
  ...I(t.item.data) ? { assistantDraft: "", isThinking: !1 } : {}
230
230
  }), I(t.item.data) && this.clearThinkingWatchdog(), this.emit("message", s));
@@ -335,7 +335,7 @@ class q {
335
335
  }
336
336
  async executeToolCall(t) {
337
337
  const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = t.rawInput;
338
- if (!s || !n || !It(r))
338
+ if (!s || !n || !_t(r))
339
339
  return;
340
340
  const i = await this.executeRuntimeHelper(), o = await M(r).catch((a) => ({
341
341
  ok: !1,
@@ -350,7 +350,7 @@ class q {
350
350
  toolName: "execute_code",
351
351
  summary: r.summary,
352
352
  rawInput: f(r),
353
- rawOutput: f(et(o, i))
353
+ rawOutput: f(st(o, i))
354
354
  });
355
355
  }
356
356
  async executeRuntimeHelper() {
@@ -359,14 +359,14 @@ class q {
359
359
  const t = await M({
360
360
  javascript: this.runtimeHelperJavascript
361
361
  });
362
- return t.ok === !1 ? st(t) : null;
362
+ return t.ok === !1 ? nt(t) : null;
363
363
  }
364
364
  enableNetworkCapture() {
365
365
  if (this.networkCaptureCleanup)
366
366
  return;
367
367
  const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
368
368
  window.fetch = async (i, o) => {
369
- const a = Date.now(), c = new Date(a).toISOString(), u = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : u?.url ?? "", w = (o?.method ?? u?.method ?? "GET").toUpperCase(), A = H(new Headers(o?.headers ?? u?.headers ?? void 0)), C = await _t(u, o);
369
+ const a = Date.now(), c = new Date(a).toISOString(), u = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : u?.url ?? "", w = (o?.method ?? u?.method ?? "GET").toUpperCase(), A = H(new Headers(o?.headers ?? u?.headers ?? void 0)), C = await Et(u, o);
370
370
  try {
371
371
  const d = await t(i, o);
372
372
  return this.enqueueNetworkEvent({
@@ -378,7 +378,7 @@ class q {
378
378
  resourceType: "fetch",
379
379
  responseStatus: d.status,
380
380
  responseHeaders: H(d.headers),
381
- responseBody: await Et(d),
381
+ responseBody: await wt(d),
382
382
  startedAt: c,
383
383
  durationMs: Date.now() - a
384
384
  }), d;
@@ -431,8 +431,8 @@ class q {
431
431
  requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
432
432
  resourceType: "xhr",
433
433
  responseStatus: this.status,
434
- responseHeaders: At(this.getAllResponseHeaders()),
435
- responseBody: wt(this),
434
+ responseHeaders: Ct(this.getAllResponseHeaders()),
435
+ responseBody: At(this),
436
436
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
437
437
  startedAt: String(this.__plunoMeta.startedAt),
438
438
  durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
@@ -476,7 +476,7 @@ class q {
476
476
  this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
477
477
  }
478
478
  setState(t) {
479
- this.state = { ...this.state, ...t }, Tt(this.options.clientId, this.state), this.emit("state", this.getState());
479
+ this.state = { ...this.state, ...t }, St(this.options.clientId, this.state), this.emit("state", this.getState());
480
480
  }
481
481
  emit(t, s) {
482
482
  this.listeners[t]?.forEach((r) => r(s));
@@ -494,12 +494,16 @@ function l(e, t, s) {
494
494
  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 }));
495
495
  }
496
496
  function F(e) {
497
+ const t = typeof e == "function" ? e() : e;
498
+ return t && Object.keys(t).length > 0 ? t : void 0;
499
+ }
500
+ function z(e) {
497
501
  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";
498
502
  }
499
- const z = 5e3;
503
+ const K = 5e3;
500
504
  async function M(e) {
501
505
  const t = Object.getPrototypeOf(async function() {
502
- }).constructor, s = z, n = Date.now(), r = [], i = {
506
+ }).constructor, s = K, n = Date.now(), r = [], i = {
503
507
  log: console.log,
504
508
  info: console.info,
505
509
  warn: console.warn,
@@ -543,10 +547,10 @@ async function M(e) {
543
547
  console.log = i.log, console.info = i.info, console.warn = i.warn, console.error = i.error;
544
548
  }
545
549
  }
546
- function K(e) {
550
+ function J(e) {
547
551
  return e.replace(/\/+$/, "");
548
552
  }
549
- function J(e) {
553
+ function Y(e) {
550
554
  const t = new URL("/api/product-agent/embed/ws", e);
551
555
  return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
552
556
  }
@@ -557,7 +561,7 @@ function g() {
557
561
  origin: location.origin
558
562
  };
559
563
  }
560
- function Y(e) {
564
+ function V(e) {
561
565
  try {
562
566
  const t = JSON.parse(e);
563
567
  return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
@@ -565,16 +569,16 @@ function Y(e) {
565
569
  return { type: "error", message: "Invalid server event" };
566
570
  }
567
571
  }
568
- function V(e, t) {
572
+ function Z(e, t) {
569
573
  if (!e || typeof e != "object")
570
574
  return [];
571
575
  const s = e[t];
572
576
  return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
573
577
  }
574
- function Z(e) {
578
+ function Q(e) {
575
579
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
576
580
  }
577
- function Q(e) {
581
+ function tt(e) {
578
582
  if (!e || typeof e != "object")
579
583
  return null;
580
584
  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;
@@ -584,13 +588,13 @@ function Q(e) {
584
588
  ...o ? { fontFamily: o } : {}
585
589
  };
586
590
  }
587
- function tt(e) {
591
+ function et(e) {
588
592
  if (!e || typeof e != "object")
589
593
  return null;
590
594
  const t = e.javascript;
591
595
  return typeof t != "string" || !t.trim() ? null : { javascript: t };
592
596
  }
593
- function et(e, t) {
597
+ function st(e, t) {
594
598
  return t ? e && typeof e == "object" ? {
595
599
  ...e,
596
600
  helperError: t
@@ -600,30 +604,30 @@ function et(e, t) {
600
604
  helperError: t
601
605
  } : e;
602
606
  }
603
- function st(e) {
607
+ function nt(e) {
604
608
  if (!e || typeof e != "object")
605
609
  return e;
606
610
  const t = e;
607
611
  return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
608
612
  }
609
- function nt() {
613
+ function rt() {
610
614
  const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
611
615
  if (t)
612
616
  return t;
613
617
  const s = crypto.randomUUID();
614
618
  return window.localStorage.setItem(e, s), s;
615
619
  }
616
- function rt() {
620
+ function it() {
617
621
  const e = window.sessionStorage.getItem(R);
618
622
  if (e)
619
623
  return e;
620
624
  const t = crypto.randomUUID();
621
625
  return window.sessionStorage.setItem(R, t), t;
622
626
  }
623
- function it() {
627
+ function ot() {
624
628
  return crypto.randomUUID();
625
629
  }
626
- function ot(e) {
630
+ function at(e) {
627
631
  if (!e || typeof e != "object")
628
632
  return null;
629
633
  const t = e, s = typeof t.id == "string" ? t.id : null;
@@ -634,7 +638,7 @@ function ot(e) {
634
638
  avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
635
639
  } : null;
636
640
  }
637
- function at(e) {
641
+ function ct(e) {
638
642
  return Array.isArray(e) ? _(
639
643
  e.map(U).filter((t) => t !== null)
640
644
  ) : [];
@@ -651,29 +655,29 @@ function U(e) {
651
655
  return {
652
656
  id: String(t.id ?? crypto.randomUUID()),
653
657
  role: r,
654
- content: dt(n.content),
658
+ content: ht(n.content),
655
659
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString()
656
660
  };
657
661
  }
658
662
  return n.type === "function_call" || n.type === "tool_call" || n.type === "web_search_call" ? {
659
663
  id: String(t.id ?? crypto.randomUUID()),
660
664
  role: "tool",
661
- content: ut(n),
665
+ content: lt(n),
662
666
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
663
667
  dataType: String(n.type),
664
668
  loading: n.localExecutionStatus === "running"
665
669
  } : 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 : {
666
670
  id: String(t.id ?? crypto.randomUUID()),
667
671
  role: "system",
668
- content: ct(n),
672
+ content: ut(n),
669
673
  createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
670
674
  dataType: String(n.type)
671
675
  } : null;
672
676
  }
673
- function ct(e) {
677
+ function ut(e) {
674
678
  return typeof e.message == "string" && e.message.trim().length > 0 ? e.message : e.type === "run_status" && e.status === "interrupted" ? "Product Agent was interrupted before it could finish this message." : e.type === "run_status" && e.status === "stopped" ? "Product Agent stopped." : "Product Agent run status changed.";
675
679
  }
676
- function ut(e) {
680
+ function lt(e) {
677
681
  if (e.type === "web_search_call") {
678
682
  const t = e.action;
679
683
  if (t && typeof t == "object") {
@@ -685,9 +689,9 @@ function ut(e) {
685
689
  }
686
690
  return "Searching the web";
687
691
  }
688
- return lt(e);
692
+ return dt(e);
689
693
  }
690
- function lt(e) {
694
+ function dt(e) {
691
695
  if (typeof e.summary == "string" && e.summary.trim().length > 0)
692
696
  return e.summary;
693
697
  if (typeof e.arguments == "string")
@@ -700,7 +704,7 @@ function lt(e) {
700
704
  }
701
705
  return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
702
706
  }
703
- function dt(e) {
707
+ function ht(e) {
704
708
  return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
705
709
  if (!t || typeof t != "object")
706
710
  return "";
@@ -708,14 +712,14 @@ function dt(e) {
708
712
  return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
709
713
  }).filter(Boolean).join("") : "";
710
714
  }
711
- function ht(e, t) {
712
- const s = pt(e, t), n = s.findIndex((i) => i.id === t.id);
715
+ function pt(e, t) {
716
+ const s = gt(e, t), n = s.findIndex((i) => i.id === t.id);
713
717
  if (n === -1)
714
718
  return _([...s, t]);
715
719
  const r = [...s];
716
720
  return r[n] = t, _(r);
717
721
  }
718
- function pt(e, t) {
722
+ function gt(e, t) {
719
723
  if (t.role !== "user")
720
724
  return e;
721
725
  const s = e.findIndex(
@@ -730,7 +734,7 @@ function b(e) {
730
734
  const t = W(e);
731
735
  return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : I(s.data));
732
736
  }
733
- function gt(e) {
737
+ function ft(e) {
734
738
  const t = W(e);
735
739
  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));
736
740
  }
@@ -761,12 +765,12 @@ function I(e) {
761
765
  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");
762
766
  }
763
767
  function _(e) {
764
- return e.filter((t, s) => ft(t) ? !yt(e, s) : !0);
768
+ return e.filter((t, s) => yt(t) ? !mt(e, s) : !0);
765
769
  }
766
- function ft(e) {
770
+ function yt(e) {
767
771
  return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
768
772
  }
769
- function yt(e, t) {
773
+ function mt(e, t) {
770
774
  for (let s = t + 1; s < e.length; s += 1) {
771
775
  const n = e[s];
772
776
  if (n.role === "user")
@@ -779,12 +783,12 @@ function yt(e, t) {
779
783
  function P(e, t) {
780
784
  return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
781
785
  }
782
- function mt(e) {
786
+ function Tt(e) {
783
787
  try {
784
788
  const t = window.localStorage.getItem(`${O}${e}`);
785
789
  if (!t)
786
790
  return null;
787
- const s = JSON.parse(t), n = Array.isArray(s.messages) ? s.messages.map(kt).filter((r) => !!r) : [];
791
+ const s = JSON.parse(t), n = Array.isArray(s.messages) ? s.messages.map(It).filter((r) => !!r) : [];
788
792
  return {
789
793
  sessionId: typeof s.sessionId == "string" ? s.sessionId : null,
790
794
  messages: n
@@ -793,7 +797,7 @@ function mt(e) {
793
797
  return null;
794
798
  }
795
799
  }
796
- function Tt(e, t) {
800
+ function St(e, t) {
797
801
  try {
798
802
  window.localStorage.setItem(
799
803
  `${O}${e}`,
@@ -806,7 +810,7 @@ function Tt(e, t) {
806
810
  return;
807
811
  }
808
812
  }
809
- function St(e) {
813
+ function kt(e) {
810
814
  try {
811
815
  const t = window.localStorage.getItem(`${k}${e}`);
812
816
  if (!t)
@@ -844,7 +848,7 @@ function D(e) {
844
848
  const t = e;
845
849
  return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
846
850
  }
847
- function kt(e) {
851
+ function It(e) {
848
852
  if (!e || typeof e != "object")
849
853
  return null;
850
854
  const t = e;
@@ -857,7 +861,7 @@ function kt(e) {
857
861
  loading: typeof t.loading == "boolean" ? t.loading : void 0
858
862
  };
859
863
  }
860
- function It(e) {
864
+ function _t(e) {
861
865
  return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
862
866
  }
863
867
  function H(e) {
@@ -866,7 +870,7 @@ function H(e) {
866
870
  t[n] = s;
867
871
  }), t;
868
872
  }
869
- async function _t(e, t) {
873
+ async function Et(e, t) {
870
874
  if (typeof t?.body < "u")
871
875
  return B(t.body);
872
876
  if (e)
@@ -876,14 +880,14 @@ async function _t(e, t) {
876
880
  return;
877
881
  }
878
882
  }
879
- async function Et(e) {
883
+ async function wt(e) {
880
884
  try {
881
885
  return p(await e.clone().text());
882
886
  } catch (t) {
883
887
  return { error: t instanceof Error ? t.message : "unavailable" };
884
888
  }
885
889
  }
886
- function wt(e) {
890
+ function At(e) {
887
891
  try {
888
892
  return e.responseType === "" || e.responseType === "text" ? p(e.responseText ?? "") : e.responseType === "json" ? p(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
889
893
  } catch (t) {
@@ -909,7 +913,7 @@ function B(e) {
909
913
  }
910
914
  }
911
915
  }
912
- function At(e) {
916
+ function Ct(e) {
913
917
  const t = {};
914
918
  for (const s of e.trim().split(/[\r\n]+/)) {
915
919
  const n = s.indexOf(":");
@@ -923,16 +927,16 @@ function p(e) {
923
927
  function T(e) {
924
928
  return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
925
929
  }
926
- const E = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Ct = "[REDACTED_SIGNED_URL]", Rt = 20, Mt = /^(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, L = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, j = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, G = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, v = /\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, bt = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Nt = /\bhttps?:\/\/[^\s"'<>]+/gi, Pt = /[),.;\]]+$/;
930
+ const E = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Rt = "[REDACTED_SIGNED_URL]", Mt = 20, bt = /^(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, L = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, j = /\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, 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, Nt = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Pt = /\bhttps?:\/\/[^\s"'<>]+/gi, Dt = /[),.;\]]+$/;
927
931
  function f(e) {
928
932
  return S(e, 0, /* @__PURE__ */ new WeakSet());
929
933
  }
930
934
  function S(e, t, s) {
931
935
  if (typeof e == "string")
932
- return Ot(e);
936
+ return qt(e);
933
937
  if (e === null || typeof e != "object")
934
938
  return e;
935
- if (t >= Rt)
939
+ if (t >= Mt)
936
940
  return "[REDACTED_MAX_DEPTH]";
937
941
  if (s.has(e))
938
942
  return "[REDACTED_CIRCULAR]";
@@ -940,34 +944,34 @@ function S(e, t, s) {
940
944
  return e.map((r) => S(r, t + 1, s));
941
945
  const n = {};
942
946
  for (const [r, i] of Object.entries(e))
943
- Dt(r) ? n[r] = E : n[r] = r.toLowerCase() === "url" ? Ht(i) : S(i, t + 1, s);
947
+ Ht(r) ? n[r] = E : n[r] = r.toLowerCase() === "url" ? Ot(i) : S(i, t + 1, s);
944
948
  return n;
945
949
  }
946
- function Dt(e) {
950
+ function Ht(e) {
947
951
  const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
948
952
  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");
949
953
  }
950
- function Ht(e) {
954
+ function Ot(e) {
951
955
  return typeof e == "string" ? $(e) : S(e, 0, /* @__PURE__ */ new WeakSet());
952
956
  }
953
957
  function $(e) {
954
958
  try {
955
959
  const t = new URL(e, location.href);
956
960
  for (const s of Array.from(t.searchParams.keys()))
957
- Mt.test(s) && t.searchParams.set(s, h);
961
+ bt.test(s) && t.searchParams.set(s, h);
958
962
  return t.username && (t.username = h), t.password && (t.password = h), t.toString();
959
963
  } catch {
960
- return qt(e);
964
+ return Ut(e);
961
965
  }
962
966
  }
963
- function Ot(e) {
964
- return e.replace(bt, Ct).replace(Nt, Ut).replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(G, h).replace(v, (t, s) => `${s}: ${E}`);
965
- }
966
967
  function qt(e) {
967
- return e.replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(G, h).replace(v, (t, s) => `${s}: ${E}`);
968
+ return e.replace(Nt, Rt).replace(Pt, Wt).replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(v, h).replace(G, (t, s) => `${s}: ${E}`);
968
969
  }
969
970
  function Ut(e) {
970
- const t = e.match(Pt)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
971
+ return e.replace(L, `Bearer ${h}`).replace(j, `Basic ${h}`).replace(v, h).replace(G, (t, s) => `${s}: ${E}`);
972
+ }
973
+ function Wt(e) {
974
+ const t = e.match(Dt)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
971
975
  return `${$(s)}${t}`;
972
976
  }
973
977
  export {