@pluno/product-agent-web 0.1.57 → 0.1.59
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/product-agent-sdk.js +230 -219
- package/dist/product-agent-widget.js +1114 -977
- package/dist/widget.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const Et = "pluno-product-agent-attachments";
|
|
2
|
-
const
|
|
2
|
+
const H = "files";
|
|
3
3
|
async function it(e) {
|
|
4
4
|
const t = await U();
|
|
5
5
|
await at(t, "readwrite", (s) => s.put(e));
|
|
@@ -17,8 +17,8 @@ async function Rt(e) {
|
|
|
17
17
|
}
|
|
18
18
|
async function ot(e, t) {
|
|
19
19
|
const s = await U();
|
|
20
|
-
await
|
|
21
|
-
const r = await
|
|
20
|
+
await v(s, "readwrite", async (n) => {
|
|
21
|
+
const r = await j(
|
|
22
22
|
n.get(e)
|
|
23
23
|
);
|
|
24
24
|
r && n.put({
|
|
@@ -29,26 +29,26 @@ async function ot(e, t) {
|
|
|
29
29
|
}
|
|
30
30
|
async function _t(e = 864e5) {
|
|
31
31
|
const t = await U(), s = Date.now() - e;
|
|
32
|
-
await
|
|
32
|
+
await v(t, "readwrite", async (n) => {
|
|
33
33
|
const r = n.index("lastUsedAt");
|
|
34
|
-
(await
|
|
34
|
+
(await j(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
function U() {
|
|
38
38
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
39
39
|
const s = indexedDB.open(Et, 1);
|
|
40
40
|
s.onupgradeneeded = () => {
|
|
41
|
-
const r = s.result.createObjectStore(
|
|
41
|
+
const r = s.result.createObjectStore(H, { keyPath: "attachmentId" });
|
|
42
42
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
43
43
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
async function at(e, t, s) {
|
|
47
|
-
return await
|
|
47
|
+
return await v(e, t, async (n) => await j(s(n)));
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function v(e, t, s) {
|
|
50
50
|
return new Promise((n, r) => {
|
|
51
|
-
const i = e.transaction(
|
|
51
|
+
const i = e.transaction(H, t), o = i.objectStore(H);
|
|
52
52
|
let c, a = !1;
|
|
53
53
|
s(o).then((d) => {
|
|
54
54
|
c = d;
|
|
@@ -68,19 +68,19 @@ function L(e, t, s) {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function j(e) {
|
|
72
72
|
return new Promise((t, s) => {
|
|
73
73
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
const
|
|
76
|
+
const B = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Pt = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Mt = ".pluno-pa-widget__panel", bt = ".pluno-pa-widget__timeline", X = `${B}[data-pluno-sdk-preview-channel]`, Ut = "https://app.pluno.ai", Ct = "gpt-5.4", Dt = 2e4, Nt = 2e3, E = 6e4, qt = 15e3, K = 2, Ot = 15e3, Ft = 5e3, Ht = 1e3, Bt = 8e3, Wt = 15e3, J = 3, Lt = [300, 1e3], q = 1e5, xt = 200 * 1024 * 1024, vt = "Image is too large for model vision input.", jt = 100, ct = "pluno.productAgent.state.", W = "pluno.productAgent.pendingEvents.", V = "pluno.productAgent.transportId";
|
|
77
77
|
class ut {
|
|
78
78
|
constructor(t) {
|
|
79
|
-
this.options = t, this.transportId =
|
|
79
|
+
this.options = t, this.transportId = ue(), this.state = {
|
|
80
80
|
...this.state,
|
|
81
|
-
starterPrompts:
|
|
81
|
+
starterPrompts: ne(t.initialStarterPrompts)
|
|
82
82
|
};
|
|
83
|
-
const s = t.restorePersistedState === !1 ? null :
|
|
83
|
+
const s = t.restorePersistedState === !1 ? null : Ne(t.clientId, t.expectedPersistedSessionId);
|
|
84
84
|
s && (this.state = {
|
|
85
85
|
...this.state,
|
|
86
86
|
...s,
|
|
@@ -91,7 +91,7 @@ class ut {
|
|
|
91
91
|
assistantDraftRunId: null,
|
|
92
92
|
isThinking: !1,
|
|
93
93
|
lastError: null
|
|
94
|
-
}), this.queuedClientEvents =
|
|
94
|
+
}), this.queuedClientEvents = Oe(t.clientId);
|
|
95
95
|
}
|
|
96
96
|
options;
|
|
97
97
|
listeners = {};
|
|
@@ -140,13 +140,13 @@ class ut {
|
|
|
140
140
|
static async init(t) {
|
|
141
141
|
const s = new ut({
|
|
142
142
|
...t,
|
|
143
|
-
backendUrl:
|
|
144
|
-
clientId: t.clientId ??
|
|
143
|
+
backendUrl: Yt(t.backendUrl ?? Ut),
|
|
144
|
+
clientId: t.clientId ?? ce(),
|
|
145
145
|
model: t.model ?? Ct
|
|
146
146
|
});
|
|
147
147
|
try {
|
|
148
148
|
_t().catch((n) => {
|
|
149
|
-
|
|
149
|
+
g("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
150
150
|
message: n instanceof Error ? n.message : String(n)
|
|
151
151
|
});
|
|
152
152
|
}), s.enableNetworkCapture(), t.autoConnect !== !1 && await s.connect();
|
|
@@ -172,9 +172,9 @@ class ut {
|
|
|
172
172
|
return;
|
|
173
173
|
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)
|
|
174
174
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
175
|
-
const t =
|
|
175
|
+
const t = Zt(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
176
176
|
this.socket = s, s.addEventListener("open", () => {
|
|
177
|
-
this.socket === s && (
|
|
177
|
+
this.socket === s && (g("web-sdk.agent", "Pluno socket opened", {
|
|
178
178
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
179
179
|
isThinking: this.state.isThinking
|
|
180
180
|
}), this.token && this.sendNow({
|
|
@@ -184,9 +184,9 @@ class ut {
|
|
|
184
184
|
transportId: this.transportId
|
|
185
185
|
}), this.flushQueuedClientEvents(), this.startHeartbeat(), this.setState({ status: "connected", lastError: null }));
|
|
186
186
|
}), s.addEventListener("message", (n) => {
|
|
187
|
-
this.socket === s && this.handleServerEvent(
|
|
187
|
+
this.socket === s && this.handleServerEvent(se(n.data));
|
|
188
188
|
}), s.addEventListener("close", (n) => {
|
|
189
|
-
this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
189
|
+
this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (g("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
190
190
|
code: typeof n?.code == "number" ? n.code : null,
|
|
191
191
|
reason: typeof n?.reason == "string" ? n.reason : "",
|
|
192
192
|
wasClean: typeof n?.wasClean == "boolean" ? n.wasClean : null,
|
|
@@ -194,7 +194,7 @@ class ut {
|
|
|
194
194
|
isThinking: this.state.isThinking
|
|
195
195
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
|
|
196
196
|
}), s.addEventListener("error", () => {
|
|
197
|
-
this.socket !== s || this.state.status === "closed" || (
|
|
197
|
+
this.socket !== s || this.state.status === "closed" || (g("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
198
198
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
199
199
|
isThinking: this.state.isThinking
|
|
200
200
|
}), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), s.readyState !== WebSocket.CLOSED && s.readyState !== WebSocket.CLOSING && s.close());
|
|
@@ -209,7 +209,7 @@ class ut {
|
|
|
209
209
|
t?.clear();
|
|
210
210
|
}
|
|
211
211
|
sendMessage(t, s = {}) {
|
|
212
|
-
const n = t.trim(), r = s.attachments ?? [], i = r.map(
|
|
212
|
+
const n = t.trim(), r = s.attachments ?? [], i = r.map($);
|
|
213
213
|
if (!n && i.length === 0)
|
|
214
214
|
return null;
|
|
215
215
|
const o = y(), c = R(), a = {
|
|
@@ -261,7 +261,7 @@ class ut {
|
|
|
261
261
|
createdAt: r,
|
|
262
262
|
lastUsedAt: r
|
|
263
263
|
}).catch((i) => {
|
|
264
|
-
|
|
264
|
+
g("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
265
265
|
attachmentId: s,
|
|
266
266
|
name: n.name,
|
|
267
267
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -290,7 +290,7 @@ class ut {
|
|
|
290
290
|
waitForSession: !0,
|
|
291
291
|
notifyCompletion: !0
|
|
292
292
|
}).catch((i) => {
|
|
293
|
-
|
|
293
|
+
g("web-sdk.agent", "Attachment background upload failed", {
|
|
294
294
|
attachmentId: n.id,
|
|
295
295
|
name: n.name,
|
|
296
296
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -316,11 +316,11 @@ class ut {
|
|
|
316
316
|
page: y(),
|
|
317
317
|
model: this.options.model,
|
|
318
318
|
metadata: Y(this.options.metadata)
|
|
319
|
-
}, d = this.options.prepareAttachmentUpload ? await
|
|
319
|
+
}, d = this.options.prepareAttachmentUpload ? await F(
|
|
320
320
|
() => this.options.prepareAttachmentUpload(a),
|
|
321
321
|
"Failed to prepare attachment upload"
|
|
322
322
|
) : await this.prepareEmbedAttachmentUpload(a);
|
|
323
|
-
await
|
|
323
|
+
await F(async () => {
|
|
324
324
|
const u = await fetch(d.uploadUrl, {
|
|
325
325
|
method: d.uploadMethod,
|
|
326
326
|
headers: d.uploadHeaders,
|
|
@@ -337,7 +337,7 @@ class ut {
|
|
|
337
337
|
gcsPath: h.gcsPath,
|
|
338
338
|
lastUsedAt: Date.now()
|
|
339
339
|
}).catch((u) => {
|
|
340
|
-
|
|
340
|
+
g("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
341
341
|
attachmentId: s.id,
|
|
342
342
|
name: h.name,
|
|
343
343
|
message: u instanceof Error ? u.message : String(u)
|
|
@@ -371,11 +371,11 @@ class ut {
|
|
|
371
371
|
}
|
|
372
372
|
async prepareEmbedAttachmentUpload(t) {
|
|
373
373
|
let s = !1;
|
|
374
|
-
return await
|
|
374
|
+
return await F(async () => {
|
|
375
375
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
376
376
|
if (n.ok)
|
|
377
377
|
return await n.json();
|
|
378
|
-
if (
|
|
378
|
+
if (Je(n.status) && this.options.tokenProvider && !s) {
|
|
379
379
|
s = !0;
|
|
380
380
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
381
381
|
if (r.ok)
|
|
@@ -465,7 +465,7 @@ class ut {
|
|
|
465
465
|
try {
|
|
466
466
|
return s.send(JSON.stringify(t)), !0;
|
|
467
467
|
} catch (n) {
|
|
468
|
-
return
|
|
468
|
+
return g("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
469
469
|
message: n instanceof Error ? n.message : String(n),
|
|
470
470
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
471
471
|
isThinking: this.state.isThinking
|
|
@@ -476,7 +476,7 @@ class ut {
|
|
|
476
476
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
477
477
|
return;
|
|
478
478
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
479
|
-
const t =
|
|
479
|
+
const t = Qt();
|
|
480
480
|
this.sendNow(
|
|
481
481
|
w({
|
|
482
482
|
type: "starter_prompts.page_context",
|
|
@@ -505,18 +505,18 @@ class ut {
|
|
|
505
505
|
this.handleRunAck(t);
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
508
|
-
if (
|
|
509
|
-
const s =
|
|
510
|
-
|
|
508
|
+
if ($t(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
509
|
+
const s = re(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
510
|
+
g("web-sdk.agent", "Received auth.ok appearance", {
|
|
511
511
|
hasAppearance: n,
|
|
512
512
|
rawAppearance: t.appearance,
|
|
513
513
|
normalizedAppearance: s
|
|
514
|
-
}), this.runtimeHelperJavascript =
|
|
514
|
+
}), this.runtimeHelperJavascript = ie(t.runtimeHelpers)?.javascript ?? null;
|
|
515
515
|
const r = tt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
|
|
516
|
-
user:
|
|
516
|
+
user: le(t.user),
|
|
517
517
|
status: "connected"
|
|
518
518
|
};
|
|
519
|
-
(i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !
|
|
519
|
+
(i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !te() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
520
520
|
type: "page.upsert",
|
|
521
521
|
sessionId: this.state.sessionId,
|
|
522
522
|
page: y(),
|
|
@@ -532,12 +532,12 @@ class ut {
|
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
534
|
if (t.type === "conversation.state") {
|
|
535
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
535
|
+
const s = Array.isArray(t.items) ? t.items : [], n = we(
|
|
536
536
|
this.state.messages,
|
|
537
|
-
|
|
538
|
-
), r = et(n), i = r ? null :
|
|
539
|
-
this.latestRecoverableClientMessageId = i,
|
|
540
|
-
sessionId:
|
|
537
|
+
de(s, this.options.backendUrl)
|
|
538
|
+
), r = et(n), i = r ? null : _e(s);
|
|
539
|
+
this.latestRecoverableClientMessageId = i, ke(n) && this.clearRetryTimers(), this.setState({
|
|
540
|
+
sessionId: A(t.session, "id") ?? this.state.sessionId,
|
|
541
541
|
messages: n,
|
|
542
542
|
...r ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : i ? {
|
|
543
543
|
assistantDraft: "",
|
|
@@ -552,13 +552,13 @@ class ut {
|
|
|
552
552
|
if (t.type === "sessions.page") {
|
|
553
553
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
554
554
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
555
|
-
sessions:
|
|
555
|
+
sessions: he(t.sessions),
|
|
556
556
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
557
557
|
}));
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
560
560
|
if (t.type === "session.updated") {
|
|
561
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
561
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: A(t.session, "id") ?? this.state.sessionId });
|
|
562
562
|
return;
|
|
563
563
|
}
|
|
564
564
|
if (t.type === "session.item") {
|
|
@@ -566,8 +566,8 @@ class ut {
|
|
|
566
566
|
if (s) {
|
|
567
567
|
s.role === "assistant" && (this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
568
568
|
const n = t.item.data;
|
|
569
|
-
|
|
570
|
-
const r =
|
|
569
|
+
Pe(n) && this.clearRunAckResyncRetryTimer();
|
|
570
|
+
const r = Te(this.state.messages, s), i = et(r);
|
|
571
571
|
this.setState({
|
|
572
572
|
messages: r,
|
|
573
573
|
assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
|
|
@@ -669,7 +669,7 @@ class ut {
|
|
|
669
669
|
}, Ot);
|
|
670
670
|
}
|
|
671
671
|
recoverMissedRunAck(t) {
|
|
672
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (
|
|
672
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (g("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
673
673
|
sessionId: this.state.sessionId,
|
|
674
674
|
clientMessageId: t
|
|
675
675
|
}), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
|
|
@@ -680,7 +680,7 @@ class ut {
|
|
|
680
680
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
681
681
|
isThinking: !0,
|
|
682
682
|
lastError: null
|
|
683
|
-
}),
|
|
683
|
+
}), g("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
684
684
|
sessionId: this.state.sessionId,
|
|
685
685
|
clientMessageId: t
|
|
686
686
|
}), this.state.sessionId ? this.send({
|
|
@@ -701,14 +701,14 @@ class ut {
|
|
|
701
701
|
return;
|
|
702
702
|
const t = this.activeClientMessageId;
|
|
703
703
|
if (!t) {
|
|
704
|
-
|
|
704
|
+
g("web-sdk.agent", "Pluno thinking watchdog resyncing without active message id", {
|
|
705
705
|
sessionId: this.state.sessionId
|
|
706
706
|
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(E);
|
|
707
707
|
return;
|
|
708
708
|
}
|
|
709
709
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.thinkingWatchdogRetryAttemptsByClientMessageId[t] ?? 0;
|
|
710
710
|
if (s <= n) {
|
|
711
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1,
|
|
711
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, g("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
712
712
|
sessionId: this.state.sessionId,
|
|
713
713
|
clientMessageId: t,
|
|
714
714
|
resyncAttempts: s + 1
|
|
@@ -716,7 +716,7 @@ class ut {
|
|
|
716
716
|
return;
|
|
717
717
|
}
|
|
718
718
|
if (n >= K) {
|
|
719
|
-
|
|
719
|
+
g("web-sdk.agent", "Pluno thinking watchdog retry limit reached; continuing resync", {
|
|
720
720
|
sessionId: this.state.sessionId,
|
|
721
721
|
clientMessageId: t,
|
|
722
722
|
retryAttempts: n
|
|
@@ -727,7 +727,7 @@ class ut {
|
|
|
727
727
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
728
728
|
isThinking: !0,
|
|
729
729
|
lastError: null
|
|
730
|
-
}),
|
|
730
|
+
}), g("web-sdk.agent", "Pluno thinking watchdog retrying last user message", {
|
|
731
731
|
sessionId: this.state.sessionId,
|
|
732
732
|
clientMessageId: t,
|
|
733
733
|
retryAttempts: n + 1
|
|
@@ -749,7 +749,7 @@ class ut {
|
|
|
749
749
|
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = typeof t.summary == "string" ? t.summary : "Running browser tool", o = t.rawInput;
|
|
750
750
|
if (!s || !n || !r)
|
|
751
751
|
return;
|
|
752
|
-
if (r !== "execute_code" || !
|
|
752
|
+
if (r !== "execute_code" || !xe(o)) {
|
|
753
753
|
this.send({
|
|
754
754
|
type: "tool.result",
|
|
755
755
|
sessionId: s,
|
|
@@ -765,7 +765,7 @@ class ut {
|
|
|
765
765
|
});
|
|
766
766
|
return;
|
|
767
767
|
}
|
|
768
|
-
const c =
|
|
768
|
+
const c = Gt(this.state.messages);
|
|
769
769
|
this.installSessionUserFilesApi(c);
|
|
770
770
|
let a = null, d;
|
|
771
771
|
a = await this.executeRuntimeHelper(), d = await Q(o).catch((h) => ({
|
|
@@ -780,14 +780,14 @@ class ut {
|
|
|
780
780
|
toolName: r,
|
|
781
781
|
summary: o.summary,
|
|
782
782
|
rawInput: w(o),
|
|
783
|
-
rawOutput: w(
|
|
783
|
+
rawOutput: w(oe(d, a))
|
|
784
784
|
});
|
|
785
785
|
}
|
|
786
786
|
installSessionUserFilesApi(t) {
|
|
787
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
787
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Xt(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
788
788
|
}
|
|
789
789
|
cleanupSessionUserFilesApi() {
|
|
790
|
-
this.sessionUserFilesApiCleanup && (
|
|
790
|
+
this.sessionUserFilesApiCleanup && (Kt(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
791
791
|
}
|
|
792
792
|
async executeRuntimeHelper() {
|
|
793
793
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -795,16 +795,16 @@ class ut {
|
|
|
795
795
|
const t = await Q({
|
|
796
796
|
javascript: this.runtimeHelperJavascript
|
|
797
797
|
});
|
|
798
|
-
return t.ok === !1 ?
|
|
798
|
+
return t.ok === !1 ? ae(t) : null;
|
|
799
799
|
}
|
|
800
800
|
enableNetworkCapture() {
|
|
801
801
|
if (this.networkCaptureCleanup)
|
|
802
802
|
return;
|
|
803
803
|
const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
|
|
804
804
|
window.fetch = async (i, o) => {
|
|
805
|
-
const c = Date.now(), a = new Date(c).toISOString(), d = i instanceof Request ? i : null, h = typeof i == "string" ? i : i instanceof URL ? i.toString() : d?.url ?? "", u = (o?.method ?? d?.method ?? "GET").toUpperCase(), l = rt(new Headers(o?.headers ?? d?.headers ?? void 0)), f = await
|
|
805
|
+
const c = Date.now(), a = new Date(c).toISOString(), d = i instanceof Request ? i : null, h = typeof i == "string" ? i : i instanceof URL ? i.toString() : d?.url ?? "", u = (o?.method ?? d?.method ?? "GET").toUpperCase(), l = rt(new Headers(o?.headers ?? d?.headers ?? void 0)), f = await ve(d, o);
|
|
806
806
|
try {
|
|
807
|
-
const
|
|
807
|
+
const p = await t(i, o);
|
|
808
808
|
return this.enqueueNetworkEvent({
|
|
809
809
|
requestId: P("fetch"),
|
|
810
810
|
url: h,
|
|
@@ -812,13 +812,13 @@ class ut {
|
|
|
812
812
|
requestHeaders: l,
|
|
813
813
|
requestBody: f,
|
|
814
814
|
resourceType: "fetch",
|
|
815
|
-
responseStatus:
|
|
816
|
-
responseHeaders: rt(
|
|
817
|
-
responseBody: await
|
|
815
|
+
responseStatus: p.status,
|
|
816
|
+
responseHeaders: rt(p.headers),
|
|
817
|
+
responseBody: await je(p),
|
|
818
818
|
startedAt: a,
|
|
819
819
|
durationMs: Date.now() - c
|
|
820
|
-
}),
|
|
821
|
-
} catch (
|
|
820
|
+
}), p;
|
|
821
|
+
} catch (p) {
|
|
822
822
|
throw this.enqueueNetworkEvent({
|
|
823
823
|
requestId: P("fetch"),
|
|
824
824
|
url: h,
|
|
@@ -826,10 +826,10 @@ class ut {
|
|
|
826
826
|
requestHeaders: l,
|
|
827
827
|
requestBody: f,
|
|
828
828
|
resourceType: "fetch",
|
|
829
|
-
errorText:
|
|
829
|
+
errorText: p instanceof Error ? p.message : String(p),
|
|
830
830
|
startedAt: a,
|
|
831
831
|
durationMs: Date.now() - c
|
|
832
|
-
}),
|
|
832
|
+
}), p;
|
|
833
833
|
}
|
|
834
834
|
}, XMLHttpRequest.prototype.open = function(o, c, a, d, h) {
|
|
835
835
|
return this.__plunoMeta = {
|
|
@@ -867,8 +867,8 @@ class ut {
|
|
|
867
867
|
requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
|
|
868
868
|
resourceType: "xhr",
|
|
869
869
|
responseStatus: this.status,
|
|
870
|
-
responseHeaders:
|
|
871
|
-
responseBody:
|
|
870
|
+
responseHeaders: ze(this.getAllResponseHeaders()),
|
|
871
|
+
responseBody: $e(this),
|
|
872
872
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
873
873
|
startedAt: String(this.__plunoMeta.startedAt),
|
|
874
874
|
durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
|
|
@@ -895,7 +895,7 @@ class ut {
|
|
|
895
895
|
scheduleReconnect() {
|
|
896
896
|
this.reconnectTimer !== null || this.state.status === "closed" || (this.reconnectTimer = window.setTimeout(() => {
|
|
897
897
|
this.reconnectTimer = null, this.connect().catch((t) => {
|
|
898
|
-
|
|
898
|
+
g("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
899
899
|
message: t instanceof Error ? t.message : String(t),
|
|
900
900
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
901
901
|
isThinking: this.state.isThinking
|
|
@@ -916,13 +916,13 @@ class ut {
|
|
|
916
916
|
...this.state,
|
|
917
917
|
...t,
|
|
918
918
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
919
|
-
},
|
|
919
|
+
}, qe(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
920
920
|
}
|
|
921
921
|
emit(t, s) {
|
|
922
922
|
this.listeners[t]?.forEach((r) => r(s));
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
|
-
function
|
|
925
|
+
function g(e, t, s) {
|
|
926
926
|
if (typeof window > "u")
|
|
927
927
|
return;
|
|
928
928
|
const n = window, r = {
|
|
@@ -937,11 +937,11 @@ function Y(e) {
|
|
|
937
937
|
const t = typeof e == "function" ? e() : e;
|
|
938
938
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
939
939
|
}
|
|
940
|
-
function
|
|
940
|
+
function $t(e) {
|
|
941
941
|
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";
|
|
942
942
|
}
|
|
943
|
-
const
|
|
944
|
-
function
|
|
943
|
+
const zt = 5e3;
|
|
944
|
+
function Gt(e) {
|
|
945
945
|
const t = [];
|
|
946
946
|
for (const s of e)
|
|
947
947
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -952,7 +952,7 @@ function $t(e) {
|
|
|
952
952
|
});
|
|
953
953
|
return t;
|
|
954
954
|
}
|
|
955
|
-
function
|
|
955
|
+
function Xt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
956
956
|
const n = new Map(e.map((u) => [u.id, u])), r = (u) => ({
|
|
957
957
|
id: u.id,
|
|
958
958
|
name: u.name,
|
|
@@ -969,10 +969,10 @@ function zt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
969
969
|
const l = i(u), f = t.get(l.id);
|
|
970
970
|
if (f)
|
|
971
971
|
return f;
|
|
972
|
-
const
|
|
973
|
-
if (
|
|
974
|
-
return
|
|
975
|
-
const S = await Rt(l.id).then((m) => m?.blob ?? null).catch((m) => (
|
|
972
|
+
const p = s.get(l.id);
|
|
973
|
+
if (p)
|
|
974
|
+
return p;
|
|
975
|
+
const S = await Rt(l.id).then((m) => m?.blob ?? null).catch((m) => (g("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
976
976
|
attachmentId: l.id,
|
|
977
977
|
name: l.name,
|
|
978
978
|
message: m instanceof Error ? m.message : String(m)
|
|
@@ -981,39 +981,47 @@ function zt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
981
981
|
return s.set(l.id, S), S;
|
|
982
982
|
if (!l.fileUrl)
|
|
983
983
|
throw new Error(`Pluno user file is missing content: ${u}`);
|
|
984
|
-
const
|
|
985
|
-
if (!
|
|
984
|
+
const D = await fetch(l.fileUrl, Fe(l.fileUrl));
|
|
985
|
+
if (!D.ok)
|
|
986
986
|
throw new Error(`Failed to load Pluno user file: ${u}`);
|
|
987
|
-
const
|
|
988
|
-
s.set(l.id,
|
|
987
|
+
const N = await D.blob();
|
|
988
|
+
s.set(l.id, N);
|
|
989
989
|
const G = Date.now();
|
|
990
990
|
return it({
|
|
991
991
|
attachmentId: l.id,
|
|
992
992
|
name: l.name,
|
|
993
993
|
mimeType: l.mimeType,
|
|
994
994
|
sizeBytes: l.sizeBytes,
|
|
995
|
-
blob:
|
|
995
|
+
blob: N,
|
|
996
996
|
fileUrl: l.fileUrl,
|
|
997
997
|
gcsPath: l.gcsPath,
|
|
998
998
|
createdAt: G,
|
|
999
999
|
lastUsedAt: G
|
|
1000
1000
|
}).catch((m) => {
|
|
1001
|
-
|
|
1001
|
+
g("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
|
|
1002
1002
|
attachmentId: l.id,
|
|
1003
1003
|
name: l.name,
|
|
1004
1004
|
message: m instanceof Error ? m.message : String(m)
|
|
1005
1005
|
});
|
|
1006
|
-
}),
|
|
1006
|
+
}), N;
|
|
1007
1007
|
}, c = async (u) => {
|
|
1008
|
-
const l = i(u), f = await o(u),
|
|
1009
|
-
if (!
|
|
1008
|
+
const l = i(u), f = await o(u), p = l.mimeType.startsWith("image/") ? l.mimeType : f.type || l.mimeType;
|
|
1009
|
+
if (!p.startsWith("image/"))
|
|
1010
1010
|
throw new Error(`Pluno user file is not an image: ${u}`);
|
|
1011
|
-
const S = f.type ===
|
|
1012
|
-
return {
|
|
1011
|
+
const S = f.type === p ? f : new Blob([f], { type: p });
|
|
1012
|
+
return Jt(p, S.size) > xt ? {
|
|
1013
|
+
type: "pluno.userFiles.inspectImage",
|
|
1014
|
+
id: l.id,
|
|
1015
|
+
name: l.name,
|
|
1016
|
+
mimeType: p,
|
|
1017
|
+
sizeBytes: l.sizeBytes,
|
|
1018
|
+
imageAttached: !1,
|
|
1019
|
+
imageAttachmentError: vt
|
|
1020
|
+
} : {
|
|
1013
1021
|
type: "pluno.userFiles.inspectImage",
|
|
1014
1022
|
id: l.id,
|
|
1015
1023
|
name: l.name,
|
|
1016
|
-
mimeType:
|
|
1024
|
+
mimeType: p,
|
|
1017
1025
|
sizeBytes: l.sizeBytes,
|
|
1018
1026
|
imageAttached: !0,
|
|
1019
1027
|
dataUrl: await Z(S)
|
|
@@ -1049,7 +1057,7 @@ function zt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1049
1057
|
a.pluno = f;
|
|
1050
1058
|
};
|
|
1051
1059
|
}
|
|
1052
|
-
function
|
|
1060
|
+
function Kt(e) {
|
|
1053
1061
|
try {
|
|
1054
1062
|
e();
|
|
1055
1063
|
} catch {
|
|
@@ -1067,9 +1075,12 @@ function Z(e) {
|
|
|
1067
1075
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1068
1076
|
});
|
|
1069
1077
|
}
|
|
1078
|
+
function Jt(e, t) {
|
|
1079
|
+
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1080
|
+
}
|
|
1070
1081
|
async function Q(e) {
|
|
1071
1082
|
const t = Object.getPrototypeOf(async function() {
|
|
1072
|
-
}).constructor, s = e.timeoutMs ??
|
|
1083
|
+
}).constructor, s = e.timeoutMs ?? zt, n = Date.now(), r = [];
|
|
1073
1084
|
let i;
|
|
1074
1085
|
const o = {
|
|
1075
1086
|
log: console.log,
|
|
@@ -1087,7 +1098,7 @@ async function Q(e) {
|
|
|
1087
1098
|
i = window.setTimeout(() => h(a), s);
|
|
1088
1099
|
})
|
|
1089
1100
|
]);
|
|
1090
|
-
return d === a ?
|
|
1101
|
+
return d === a ? Vt(s) : {
|
|
1091
1102
|
ok: !0,
|
|
1092
1103
|
result: d,
|
|
1093
1104
|
console: r,
|
|
@@ -1116,7 +1127,7 @@ async function Q(e) {
|
|
|
1116
1127
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1117
1128
|
}
|
|
1118
1129
|
}
|
|
1119
|
-
function
|
|
1130
|
+
function Vt(e) {
|
|
1120
1131
|
return {
|
|
1121
1132
|
ok: !1,
|
|
1122
1133
|
exception: {
|
|
@@ -1130,10 +1141,10 @@ function Xt(e) {
|
|
|
1130
1141
|
}
|
|
1131
1142
|
};
|
|
1132
1143
|
}
|
|
1133
|
-
function
|
|
1144
|
+
function Yt(e) {
|
|
1134
1145
|
return e.replace(/\/+$/, "");
|
|
1135
1146
|
}
|
|
1136
|
-
function
|
|
1147
|
+
function Zt(e) {
|
|
1137
1148
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1138
1149
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1139
1150
|
}
|
|
@@ -1146,17 +1157,17 @@ function y() {
|
|
|
1146
1157
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1147
1158
|
};
|
|
1148
1159
|
}
|
|
1149
|
-
function
|
|
1160
|
+
function Qt() {
|
|
1150
1161
|
return {
|
|
1151
1162
|
pageUrl: location.href,
|
|
1152
1163
|
pageTitle: document.title,
|
|
1153
|
-
htmlContent:
|
|
1164
|
+
htmlContent: ee()
|
|
1154
1165
|
};
|
|
1155
1166
|
}
|
|
1156
|
-
function
|
|
1167
|
+
function te() {
|
|
1157
1168
|
return lt()?.surface === "browser_extension_sdk_preview";
|
|
1158
1169
|
}
|
|
1159
|
-
function
|
|
1170
|
+
function ee() {
|
|
1160
1171
|
const e = document.body?.cloneNode(!0);
|
|
1161
1172
|
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
1162
1173
|
[
|
|
@@ -1182,7 +1193,7 @@ function Zt() {
|
|
|
1182
1193
|
}
|
|
1183
1194
|
function lt() {
|
|
1184
1195
|
const e = document.querySelector(X);
|
|
1185
|
-
if (!(e ?? document.querySelector(
|
|
1196
|
+
if (!(e ?? document.querySelector(B)))
|
|
1186
1197
|
return;
|
|
1187
1198
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
1188
1199
|
return {
|
|
@@ -1191,7 +1202,7 @@ function lt() {
|
|
|
1191
1202
|
selectors: [
|
|
1192
1203
|
{
|
|
1193
1204
|
name: "widget_host",
|
|
1194
|
-
selector: s === "browser_extension_sdk_preview" ? X :
|
|
1205
|
+
selector: s === "browser_extension_sdk_preview" ? X : B,
|
|
1195
1206
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
1196
1207
|
},
|
|
1197
1208
|
{
|
|
@@ -1212,7 +1223,7 @@ function lt() {
|
|
|
1212
1223
|
]
|
|
1213
1224
|
};
|
|
1214
1225
|
}
|
|
1215
|
-
function
|
|
1226
|
+
function se(e) {
|
|
1216
1227
|
try {
|
|
1217
1228
|
const t = JSON.parse(e);
|
|
1218
1229
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -1226,10 +1237,10 @@ function tt(e, t) {
|
|
|
1226
1237
|
const s = e[t];
|
|
1227
1238
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
1228
1239
|
}
|
|
1229
|
-
function
|
|
1240
|
+
function ne(e) {
|
|
1230
1241
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
1231
1242
|
}
|
|
1232
|
-
function
|
|
1243
|
+
function re(e) {
|
|
1233
1244
|
if (!e || typeof e != "object")
|
|
1234
1245
|
return null;
|
|
1235
1246
|
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, c = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -1240,13 +1251,13 @@ function ee(e) {
|
|
|
1240
1251
|
...c !== null ? { scribbleStyle: c } : {}
|
|
1241
1252
|
};
|
|
1242
1253
|
}
|
|
1243
|
-
function
|
|
1254
|
+
function ie(e) {
|
|
1244
1255
|
if (!e || typeof e != "object")
|
|
1245
1256
|
return null;
|
|
1246
1257
|
const t = e.javascript;
|
|
1247
1258
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
1248
1259
|
}
|
|
1249
|
-
function
|
|
1260
|
+
function oe(e, t) {
|
|
1250
1261
|
return t ? e && typeof e == "object" ? {
|
|
1251
1262
|
...e,
|
|
1252
1263
|
helperError: t
|
|
@@ -1256,20 +1267,20 @@ function ne(e, t) {
|
|
|
1256
1267
|
helperError: t
|
|
1257
1268
|
} : e;
|
|
1258
1269
|
}
|
|
1259
|
-
function
|
|
1270
|
+
function ae(e) {
|
|
1260
1271
|
if (!e || typeof e != "object")
|
|
1261
1272
|
return e;
|
|
1262
1273
|
const t = e;
|
|
1263
1274
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
1264
1275
|
}
|
|
1265
|
-
function
|
|
1276
|
+
function ce() {
|
|
1266
1277
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
1267
1278
|
if (t)
|
|
1268
1279
|
return t;
|
|
1269
1280
|
const s = crypto.randomUUID();
|
|
1270
1281
|
return window.localStorage.setItem(e, s), s;
|
|
1271
1282
|
}
|
|
1272
|
-
function
|
|
1283
|
+
function ue() {
|
|
1273
1284
|
const e = window.sessionStorage.getItem(V);
|
|
1274
1285
|
if (e)
|
|
1275
1286
|
return e;
|
|
@@ -1279,7 +1290,7 @@ function oe() {
|
|
|
1279
1290
|
function R() {
|
|
1280
1291
|
return crypto.randomUUID();
|
|
1281
1292
|
}
|
|
1282
|
-
function
|
|
1293
|
+
function le(e) {
|
|
1283
1294
|
if (!e || typeof e != "object")
|
|
1284
1295
|
return null;
|
|
1285
1296
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -1290,23 +1301,23 @@ function ae(e) {
|
|
|
1290
1301
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
1291
1302
|
} : null;
|
|
1292
1303
|
}
|
|
1293
|
-
function
|
|
1294
|
-
return Array.isArray(e) ?
|
|
1304
|
+
function de(e, t) {
|
|
1305
|
+
return Array.isArray(e) ? L(
|
|
1295
1306
|
x(
|
|
1296
1307
|
e.map((s) => dt(s, t)).filter((s) => s !== null)
|
|
1297
1308
|
)
|
|
1298
1309
|
) : [];
|
|
1299
1310
|
}
|
|
1300
|
-
function
|
|
1311
|
+
function he(e) {
|
|
1301
1312
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
1302
1313
|
if (!t || typeof t != "object")
|
|
1303
1314
|
return [];
|
|
1304
|
-
const s = t, n =
|
|
1315
|
+
const s = t, n = A(s, "id"), r = A(s, "createdAt"), i = A(s, "updatedAt"), o = A(s, "lastActiveAt");
|
|
1305
1316
|
return !n || !r || !i || !o ? [] : [
|
|
1306
1317
|
{
|
|
1307
1318
|
id: n,
|
|
1308
|
-
title:
|
|
1309
|
-
firstUserMessage:
|
|
1319
|
+
title: A(s, "title"),
|
|
1320
|
+
firstUserMessage: A(s, "firstUserMessage"),
|
|
1310
1321
|
currentPage: s.currentPage ?? null,
|
|
1311
1322
|
createdAt: r,
|
|
1312
1323
|
updatedAt: i,
|
|
@@ -1327,9 +1338,9 @@ function dt(e, t) {
|
|
|
1327
1338
|
return {
|
|
1328
1339
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1329
1340
|
role: i,
|
|
1330
|
-
content:
|
|
1341
|
+
content: ye(r.content),
|
|
1331
1342
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1332
|
-
respondsToUserMessageId:
|
|
1343
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
1333
1344
|
...k(r) ? { runId: k(r) } : {},
|
|
1334
1345
|
attachments: mt(r.attachments, t)
|
|
1335
1346
|
};
|
|
@@ -1337,29 +1348,29 @@ function dt(e, t) {
|
|
|
1337
1348
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" ? {
|
|
1338
1349
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1339
1350
|
role: "tool",
|
|
1340
|
-
content:
|
|
1351
|
+
content: ge(r),
|
|
1341
1352
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1342
|
-
respondsToUserMessageId:
|
|
1353
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
1343
1354
|
...k(r) ? { runId: k(r) } : {},
|
|
1344
1355
|
dataType: String(r.type),
|
|
1345
1356
|
toolName: typeof r.name == "string" ? r.name : void 0,
|
|
1346
|
-
callId:
|
|
1357
|
+
callId: me(r) ?? void 0,
|
|
1347
1358
|
loading: r.localExecutionStatus === "running"
|
|
1348
1359
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
1349
1360
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1350
1361
|
role: "system",
|
|
1351
|
-
content:
|
|
1362
|
+
content: pe(r),
|
|
1352
1363
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1353
|
-
respondsToUserMessageId:
|
|
1364
|
+
respondsToUserMessageId: O(r) ?? void 0,
|
|
1354
1365
|
...k(r) ? { runId: k(r) } : {},
|
|
1355
1366
|
dataType: String(r.type),
|
|
1356
1367
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying")
|
|
1357
1368
|
} : null;
|
|
1358
1369
|
}
|
|
1359
|
-
function
|
|
1370
|
+
function pe(e) {
|
|
1360
1371
|
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.";
|
|
1361
1372
|
}
|
|
1362
|
-
function
|
|
1373
|
+
function ge(e) {
|
|
1363
1374
|
if (e.type === "web_search_call") {
|
|
1364
1375
|
const t = e.action;
|
|
1365
1376
|
if (t && typeof t == "object") {
|
|
@@ -1371,9 +1382,9 @@ function de(e) {
|
|
|
1371
1382
|
}
|
|
1372
1383
|
return "Searching the web";
|
|
1373
1384
|
}
|
|
1374
|
-
return
|
|
1385
|
+
return fe(e);
|
|
1375
1386
|
}
|
|
1376
|
-
function
|
|
1387
|
+
function fe(e) {
|
|
1377
1388
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
1378
1389
|
return e.summary;
|
|
1379
1390
|
if (typeof e.arguments == "string")
|
|
@@ -1386,11 +1397,11 @@ function he(e) {
|
|
|
1386
1397
|
}
|
|
1387
1398
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
1388
1399
|
}
|
|
1389
|
-
function
|
|
1400
|
+
function me(e) {
|
|
1390
1401
|
const t = e.callId ?? e.call_id;
|
|
1391
1402
|
return typeof t == "string" && t ? t : null;
|
|
1392
1403
|
}
|
|
1393
|
-
function
|
|
1404
|
+
function ye(e) {
|
|
1394
1405
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
1395
1406
|
if (!t || typeof t != "object")
|
|
1396
1407
|
return "";
|
|
@@ -1398,16 +1409,16 @@ function ge(e) {
|
|
|
1398
1409
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
1399
1410
|
}).filter(Boolean).join("") : "";
|
|
1400
1411
|
}
|
|
1401
|
-
function
|
|
1402
|
-
const s = ht(e, t), n =
|
|
1412
|
+
function Te(e, t) {
|
|
1413
|
+
const s = ht(e, t), n = Se(e, t), r = n.findIndex((o) => o.id === s.id);
|
|
1403
1414
|
if (r === -1)
|
|
1404
|
-
return
|
|
1415
|
+
return L(
|
|
1405
1416
|
x([...n, s])
|
|
1406
1417
|
);
|
|
1407
1418
|
const i = [...n];
|
|
1408
|
-
return i[r] = s,
|
|
1419
|
+
return i[r] = s, L(x(i));
|
|
1409
1420
|
}
|
|
1410
|
-
function
|
|
1421
|
+
function we(e, t) {
|
|
1411
1422
|
return t.map((s) => ht(e, s));
|
|
1412
1423
|
}
|
|
1413
1424
|
function ht(e, t) {
|
|
@@ -1419,19 +1430,19 @@ function ht(e, t) {
|
|
|
1419
1430
|
if (!s?.attachments?.length)
|
|
1420
1431
|
return t;
|
|
1421
1432
|
const n = t.attachments.map((r) => {
|
|
1422
|
-
const i =
|
|
1423
|
-
return i ?
|
|
1433
|
+
const i = Ae(s.attachments ?? [], r);
|
|
1434
|
+
return i ? Ie(r, i) : r;
|
|
1424
1435
|
});
|
|
1425
1436
|
return { ...t, attachments: n };
|
|
1426
1437
|
}
|
|
1427
|
-
function
|
|
1438
|
+
function Ae(e, t) {
|
|
1428
1439
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
1429
1440
|
}
|
|
1430
|
-
function
|
|
1441
|
+
function Ie(e, t) {
|
|
1431
1442
|
const { previewUrl: s } = t;
|
|
1432
1443
|
return s ? { ...e, previewUrl: s } : e;
|
|
1433
1444
|
}
|
|
1434
|
-
function
|
|
1445
|
+
function Se(e, t) {
|
|
1435
1446
|
if (t.role !== "user")
|
|
1436
1447
|
return e;
|
|
1437
1448
|
const s = e.findIndex(
|
|
@@ -1444,9 +1455,9 @@ function we(e, t) {
|
|
|
1444
1455
|
}
|
|
1445
1456
|
function et(e) {
|
|
1446
1457
|
const t = pt(e);
|
|
1447
|
-
return t === null ? !1 : e.slice(t + 1).some(
|
|
1458
|
+
return t === null ? !1 : e.slice(t + 1).some(Ee);
|
|
1448
1459
|
}
|
|
1449
|
-
function
|
|
1460
|
+
function ke(e) {
|
|
1450
1461
|
const t = pt(e);
|
|
1451
1462
|
return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
|
|
1452
1463
|
}
|
|
@@ -1456,10 +1467,10 @@ function pt(e) {
|
|
|
1456
1467
|
return t;
|
|
1457
1468
|
return null;
|
|
1458
1469
|
}
|
|
1459
|
-
function
|
|
1470
|
+
function Ee(e) {
|
|
1460
1471
|
return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
1461
1472
|
}
|
|
1462
|
-
function
|
|
1473
|
+
function Re(e) {
|
|
1463
1474
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
1464
1475
|
const s = e[t];
|
|
1465
1476
|
if (!s || typeof s != "object")
|
|
@@ -1473,8 +1484,8 @@ function ke(e) {
|
|
|
1473
1484
|
}
|
|
1474
1485
|
return null;
|
|
1475
1486
|
}
|
|
1476
|
-
function
|
|
1477
|
-
const t =
|
|
1487
|
+
function _e(e) {
|
|
1488
|
+
const t = Re(e);
|
|
1478
1489
|
if (t === null)
|
|
1479
1490
|
return null;
|
|
1480
1491
|
const s = e[t];
|
|
@@ -1486,16 +1497,16 @@ function Se(e) {
|
|
|
1486
1497
|
const r = n.clientMessageId;
|
|
1487
1498
|
return typeof r == "string" ? r : null;
|
|
1488
1499
|
}
|
|
1489
|
-
function
|
|
1500
|
+
function Pe(e) {
|
|
1490
1501
|
if (!e || typeof e != "object")
|
|
1491
1502
|
return !1;
|
|
1492
1503
|
const t = e;
|
|
1493
1504
|
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";
|
|
1494
1505
|
}
|
|
1495
|
-
function
|
|
1496
|
-
return e.filter((t, s) => gt(t) ? !
|
|
1506
|
+
function L(e) {
|
|
1507
|
+
return e.filter((t, s) => gt(t) ? !De(e, s) && !Ue(e, s) && !Ce(e, s) : Me(t) ? !be(e, s) : !0);
|
|
1497
1508
|
}
|
|
1498
|
-
function
|
|
1509
|
+
function Me(e) {
|
|
1499
1510
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
1500
1511
|
}
|
|
1501
1512
|
function gt(e) {
|
|
@@ -1517,7 +1528,7 @@ function x(e) {
|
|
|
1517
1528
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
1518
1529
|
return r;
|
|
1519
1530
|
}
|
|
1520
|
-
function
|
|
1531
|
+
function be(e, t) {
|
|
1521
1532
|
const s = e[t];
|
|
1522
1533
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
1523
1534
|
const r = e[n];
|
|
@@ -1528,21 +1539,21 @@ function _e(e, t) {
|
|
|
1528
1539
|
}
|
|
1529
1540
|
return !1;
|
|
1530
1541
|
}
|
|
1531
|
-
function
|
|
1542
|
+
function Ue(e, t) {
|
|
1532
1543
|
const s = e[t];
|
|
1533
1544
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1534
1545
|
if (e[n].role === "assistant" && C(s, e[n]))
|
|
1535
1546
|
return !0;
|
|
1536
1547
|
return !1;
|
|
1537
1548
|
}
|
|
1538
|
-
function
|
|
1549
|
+
function Ce(e, t) {
|
|
1539
1550
|
const s = e[t];
|
|
1540
1551
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1541
1552
|
if (e[n].role === "tool" && C(s, e[n]))
|
|
1542
1553
|
return !0;
|
|
1543
1554
|
return !1;
|
|
1544
1555
|
}
|
|
1545
|
-
function
|
|
1556
|
+
function De(e, t) {
|
|
1546
1557
|
const s = e[t];
|
|
1547
1558
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1548
1559
|
if (gt(e[n]) && C(s, e[n]))
|
|
@@ -1552,10 +1563,10 @@ function be(e, t) {
|
|
|
1552
1563
|
function C(e, t) {
|
|
1553
1564
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
1554
1565
|
}
|
|
1555
|
-
function
|
|
1566
|
+
function A(e, t) {
|
|
1556
1567
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
1557
1568
|
}
|
|
1558
|
-
function
|
|
1569
|
+
function Ne(e, t) {
|
|
1559
1570
|
try {
|
|
1560
1571
|
const s = window.localStorage.getItem(`${ct}${e}`);
|
|
1561
1572
|
if (!s)
|
|
@@ -1563,7 +1574,7 @@ function Ue(e, t) {
|
|
|
1563
1574
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
1564
1575
|
if (t !== void 0 && r !== t)
|
|
1565
1576
|
return null;
|
|
1566
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
1577
|
+
const i = Array.isArray(n.messages) ? n.messages.map(We).filter((o) => !!o) : [];
|
|
1567
1578
|
return {
|
|
1568
1579
|
sessionId: r,
|
|
1569
1580
|
messages: i
|
|
@@ -1572,22 +1583,22 @@ function Ue(e, t) {
|
|
|
1572
1583
|
return null;
|
|
1573
1584
|
}
|
|
1574
1585
|
}
|
|
1575
|
-
function
|
|
1586
|
+
function qe(e, t) {
|
|
1576
1587
|
try {
|
|
1577
1588
|
window.localStorage.setItem(
|
|
1578
1589
|
`${ct}${e}`,
|
|
1579
1590
|
JSON.stringify({
|
|
1580
1591
|
sessionId: t.sessionId,
|
|
1581
|
-
messages: t.messages.slice(-
|
|
1592
|
+
messages: t.messages.slice(-jt).map(Le)
|
|
1582
1593
|
})
|
|
1583
1594
|
);
|
|
1584
1595
|
} catch {
|
|
1585
1596
|
return;
|
|
1586
1597
|
}
|
|
1587
1598
|
}
|
|
1588
|
-
function
|
|
1599
|
+
function Oe(e) {
|
|
1589
1600
|
try {
|
|
1590
|
-
const t = window.localStorage.getItem(`${
|
|
1601
|
+
const t = window.localStorage.getItem(`${W}${e}`);
|
|
1591
1602
|
if (!t)
|
|
1592
1603
|
return [];
|
|
1593
1604
|
const s = JSON.parse(t);
|
|
@@ -1600,11 +1611,11 @@ function _(e, t) {
|
|
|
1600
1611
|
try {
|
|
1601
1612
|
const s = t.filter(ft);
|
|
1602
1613
|
if (s.length === 0) {
|
|
1603
|
-
window.localStorage.removeItem(`${
|
|
1614
|
+
window.localStorage.removeItem(`${W}${e}`);
|
|
1604
1615
|
return;
|
|
1605
1616
|
}
|
|
1606
1617
|
window.localStorage.setItem(
|
|
1607
|
-
`${
|
|
1618
|
+
`${W}${e}`,
|
|
1608
1619
|
JSON.stringify(s.slice(-25))
|
|
1609
1620
|
);
|
|
1610
1621
|
} catch {
|
|
@@ -1640,15 +1651,15 @@ function yt(e, t) {
|
|
|
1640
1651
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
1641
1652
|
} : e;
|
|
1642
1653
|
}
|
|
1643
|
-
function
|
|
1644
|
-
if (
|
|
1654
|
+
function Fe(e) {
|
|
1655
|
+
if (He(e))
|
|
1645
1656
|
return {
|
|
1646
1657
|
headers: {
|
|
1647
1658
|
"ngrok-skip-browser-warning": "true"
|
|
1648
1659
|
}
|
|
1649
1660
|
};
|
|
1650
1661
|
}
|
|
1651
|
-
function
|
|
1662
|
+
function He(e) {
|
|
1652
1663
|
try {
|
|
1653
1664
|
const t = new URL(e).hostname;
|
|
1654
1665
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -1657,13 +1668,13 @@ function qe(e) {
|
|
|
1657
1668
|
}
|
|
1658
1669
|
}
|
|
1659
1670
|
function nt(e) {
|
|
1660
|
-
return e.type ||
|
|
1671
|
+
return e.type || Be(e.name) || "application/octet-stream";
|
|
1661
1672
|
}
|
|
1662
|
-
function
|
|
1673
|
+
function Be(e) {
|
|
1663
1674
|
const t = e.toLowerCase();
|
|
1664
1675
|
return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
|
|
1665
1676
|
}
|
|
1666
|
-
function
|
|
1677
|
+
function We(e) {
|
|
1667
1678
|
if (!e || typeof e != "object")
|
|
1668
1679
|
return null;
|
|
1669
1680
|
const t = e;
|
|
@@ -1675,17 +1686,17 @@ function Fe(e) {
|
|
|
1675
1686
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
1676
1687
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
1677
1688
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
1678
|
-
attachments: mt(t.attachments)?.map(
|
|
1689
|
+
attachments: mt(t.attachments)?.map($),
|
|
1679
1690
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
1680
1691
|
};
|
|
1681
1692
|
}
|
|
1682
|
-
function
|
|
1693
|
+
function Le(e) {
|
|
1683
1694
|
return e.attachments?.length ? {
|
|
1684
1695
|
...e,
|
|
1685
|
-
attachments: e.attachments.map(
|
|
1696
|
+
attachments: e.attachments.map($)
|
|
1686
1697
|
} : e;
|
|
1687
1698
|
}
|
|
1688
|
-
function
|
|
1699
|
+
function $(e) {
|
|
1689
1700
|
const {
|
|
1690
1701
|
dataUrl: t,
|
|
1691
1702
|
objectUrl: s,
|
|
@@ -1694,7 +1705,7 @@ function j(e) {
|
|
|
1694
1705
|
} = e;
|
|
1695
1706
|
return r;
|
|
1696
1707
|
}
|
|
1697
|
-
function
|
|
1708
|
+
function O(e) {
|
|
1698
1709
|
const t = e.respondsToUserMessageId;
|
|
1699
1710
|
return typeof t == "string" && t ? t : null;
|
|
1700
1711
|
}
|
|
@@ -1702,7 +1713,7 @@ function k(e) {
|
|
|
1702
1713
|
const t = e.runId;
|
|
1703
1714
|
return typeof t == "string" && t ? t : null;
|
|
1704
1715
|
}
|
|
1705
|
-
function
|
|
1716
|
+
function xe(e) {
|
|
1706
1717
|
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
|
|
1707
1718
|
}
|
|
1708
1719
|
function rt(e) {
|
|
@@ -1711,26 +1722,26 @@ function rt(e) {
|
|
|
1711
1722
|
t[n] = s;
|
|
1712
1723
|
}), t;
|
|
1713
1724
|
}
|
|
1714
|
-
async function
|
|
1725
|
+
async function ve(e, t) {
|
|
1715
1726
|
if (typeof t?.body < "u")
|
|
1716
1727
|
return Tt(t.body);
|
|
1717
1728
|
if (e)
|
|
1718
1729
|
try {
|
|
1719
|
-
return
|
|
1730
|
+
return I(await e.clone().text());
|
|
1720
1731
|
} catch {
|
|
1721
1732
|
return;
|
|
1722
1733
|
}
|
|
1723
1734
|
}
|
|
1724
|
-
async function
|
|
1735
|
+
async function je(e) {
|
|
1725
1736
|
try {
|
|
1726
|
-
return
|
|
1737
|
+
return I(await e.clone().text());
|
|
1727
1738
|
} catch (t) {
|
|
1728
1739
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1729
1740
|
}
|
|
1730
1741
|
}
|
|
1731
|
-
function
|
|
1742
|
+
function $e(e) {
|
|
1732
1743
|
try {
|
|
1733
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
1744
|
+
return e.responseType === "" || e.responseType === "text" ? I(e.responseText ?? "") : e.responseType === "json" ? I(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
|
|
1734
1745
|
} catch (t) {
|
|
1735
1746
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1736
1747
|
}
|
|
@@ -1738,23 +1749,23 @@ function Le(e) {
|
|
|
1738
1749
|
function Tt(e) {
|
|
1739
1750
|
if (!(e === null || typeof e > "u")) {
|
|
1740
1751
|
if (typeof e == "string")
|
|
1741
|
-
return
|
|
1752
|
+
return I(e);
|
|
1742
1753
|
if (e instanceof URLSearchParams)
|
|
1743
|
-
return
|
|
1754
|
+
return I(e.toString());
|
|
1744
1755
|
if (e instanceof FormData) {
|
|
1745
1756
|
const t = [];
|
|
1746
|
-
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])),
|
|
1757
|
+
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])), I(JSON.stringify(t));
|
|
1747
1758
|
}
|
|
1748
1759
|
if (e instanceof Blob)
|
|
1749
1760
|
return `[blob:${e.type || "application/octet-stream"}:${e.size}]`;
|
|
1750
1761
|
try {
|
|
1751
|
-
return
|
|
1762
|
+
return I(JSON.stringify(e));
|
|
1752
1763
|
} catch {
|
|
1753
1764
|
return `[unserializable body: ${Object.prototype.toString.call(e)}]`;
|
|
1754
1765
|
}
|
|
1755
1766
|
}
|
|
1756
1767
|
}
|
|
1757
|
-
function
|
|
1768
|
+
function ze(e) {
|
|
1758
1769
|
const t = {};
|
|
1759
1770
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
1760
1771
|
const n = s.indexOf(":");
|
|
@@ -1762,8 +1773,8 @@ function ve(e) {
|
|
|
1762
1773
|
}
|
|
1763
1774
|
return t;
|
|
1764
1775
|
}
|
|
1765
|
-
function
|
|
1766
|
-
return e.length <=
|
|
1776
|
+
function I(e) {
|
|
1777
|
+
return e.length <= q ? e : `${e.slice(0, q)}... [truncated ${e.length - q} chars]`;
|
|
1767
1778
|
}
|
|
1768
1779
|
function P(e) {
|
|
1769
1780
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
@@ -1774,42 +1785,42 @@ class M extends Error {
|
|
|
1774
1785
|
}
|
|
1775
1786
|
status;
|
|
1776
1787
|
}
|
|
1777
|
-
async function
|
|
1788
|
+
async function F(e, t) {
|
|
1778
1789
|
let s = null;
|
|
1779
1790
|
for (let n = 0; n < J; n += 1)
|
|
1780
1791
|
try {
|
|
1781
1792
|
return await e();
|
|
1782
1793
|
} catch (r) {
|
|
1783
|
-
if (s = r, n >= J - 1 ||
|
|
1794
|
+
if (s = r, n >= J - 1 || !Xe(r))
|
|
1784
1795
|
throw r;
|
|
1785
|
-
await
|
|
1796
|
+
await Ge(n);
|
|
1786
1797
|
}
|
|
1787
1798
|
throw s instanceof Error ? s : new Error(t);
|
|
1788
1799
|
}
|
|
1789
|
-
function
|
|
1800
|
+
function Ge(e) {
|
|
1790
1801
|
return new Promise((t) => {
|
|
1791
|
-
window.setTimeout(t,
|
|
1802
|
+
window.setTimeout(t, Lt[e] ?? 0);
|
|
1792
1803
|
});
|
|
1793
1804
|
}
|
|
1794
|
-
function
|
|
1795
|
-
return e instanceof M ?
|
|
1805
|
+
function Xe(e) {
|
|
1806
|
+
return e instanceof M ? Ke(e.status) : e instanceof TypeError;
|
|
1796
1807
|
}
|
|
1797
|
-
function
|
|
1808
|
+
function Ke(e) {
|
|
1798
1809
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
1799
1810
|
}
|
|
1800
|
-
function
|
|
1811
|
+
function Je(e) {
|
|
1801
1812
|
return e === 401 || e === 403;
|
|
1802
1813
|
}
|
|
1803
|
-
const
|
|
1814
|
+
const z = "[REDACTED_SECRET]", T = "[REDACTED_TOKEN]", Ve = "[REDACTED_SIGNED_URL]", Ye = 20, Ze = /^(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, wt = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, At = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, It = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, St = /\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, Qe = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ts = /\bhttps?:\/\/[^\s"'<>]+/gi, es = /[),.;\]]+$/;
|
|
1804
1815
|
function w(e) {
|
|
1805
1816
|
return b(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1806
1817
|
}
|
|
1807
1818
|
function b(e, t, s) {
|
|
1808
1819
|
if (typeof e == "string")
|
|
1809
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
1820
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : rs(e);
|
|
1810
1821
|
if (e === null || typeof e != "object")
|
|
1811
1822
|
return e;
|
|
1812
|
-
if (t >=
|
|
1823
|
+
if (t >= Ye)
|
|
1813
1824
|
return "[REDACTED_MAX_DEPTH]";
|
|
1814
1825
|
if (s.has(e))
|
|
1815
1826
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -1817,39 +1828,39 @@ function b(e, t, s) {
|
|
|
1817
1828
|
return e.map((r) => b(r, t + 1, s));
|
|
1818
1829
|
const n = {};
|
|
1819
1830
|
for (const [r, i] of Object.entries(e))
|
|
1820
|
-
|
|
1831
|
+
ss(r) ? n[r] = z : n[r] = r.toLowerCase() === "url" ? ns(i) : b(i, t + 1, s);
|
|
1821
1832
|
return n;
|
|
1822
1833
|
}
|
|
1823
|
-
function
|
|
1834
|
+
function ss(e) {
|
|
1824
1835
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
1825
1836
|
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");
|
|
1826
1837
|
}
|
|
1827
|
-
function
|
|
1828
|
-
return typeof e == "string" ?
|
|
1838
|
+
function ns(e) {
|
|
1839
|
+
return typeof e == "string" ? kt(e) : b(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1829
1840
|
}
|
|
1830
|
-
function
|
|
1841
|
+
function kt(e) {
|
|
1831
1842
|
try {
|
|
1832
1843
|
const t = new URL(e, location.href);
|
|
1833
1844
|
for (const s of Array.from(t.searchParams.keys()))
|
|
1834
|
-
|
|
1845
|
+
Ze.test(s) && t.searchParams.set(s, T);
|
|
1835
1846
|
return t.username && (t.username = T), t.password && (t.password = T), t.toString();
|
|
1836
1847
|
} catch {
|
|
1837
|
-
return
|
|
1848
|
+
return is(e);
|
|
1838
1849
|
}
|
|
1839
1850
|
}
|
|
1840
|
-
function
|
|
1841
|
-
return e.replace(
|
|
1851
|
+
function rs(e) {
|
|
1852
|
+
return e.replace(Qe, Ve).replace(ts, os).replace(wt, `Bearer ${T}`).replace(At, `Basic ${T}`).replace(It, T).replace(St, (t, s) => `${s}: ${z}`);
|
|
1842
1853
|
}
|
|
1843
|
-
function
|
|
1844
|
-
return e.replace(wt, `Bearer ${T}`).replace(
|
|
1854
|
+
function is(e) {
|
|
1855
|
+
return e.replace(wt, `Bearer ${T}`).replace(At, `Basic ${T}`).replace(It, T).replace(St, (t, s) => `${s}: ${z}`);
|
|
1845
1856
|
}
|
|
1846
|
-
function
|
|
1847
|
-
const t = e.match(
|
|
1848
|
-
return `${
|
|
1857
|
+
function os(e) {
|
|
1858
|
+
const t = e.match(es)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
1859
|
+
return `${kt(s)}${t}`;
|
|
1849
1860
|
}
|
|
1850
1861
|
export {
|
|
1851
1862
|
X as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
1852
|
-
|
|
1863
|
+
B as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
1853
1864
|
Mt as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
1854
1865
|
Pt as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
1855
1866
|
bt as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|