@pluno/product-agent-web 0.1.70 → 0.1.72
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 +3 -2
- package/dist/product-agent-sdk.js +669 -557
- package/dist/product-agent-widget.js +639 -617
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const t = await
|
|
1
|
+
const Kt = "pluno-product-agent-attachments";
|
|
2
|
+
const Z = "files";
|
|
3
|
+
async function _t(e) {
|
|
4
|
+
const t = await x();
|
|
5
|
+
await bt(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function Jt(e) {
|
|
8
|
+
const t = await x(), s = await bt(
|
|
9
9
|
t,
|
|
10
10
|
"readonly",
|
|
11
11
|
(r) => r.get(e)
|
|
@@ -13,12 +13,12 @@ async function Kt(e) {
|
|
|
13
13
|
if (!s)
|
|
14
14
|
return null;
|
|
15
15
|
const n = Date.now();
|
|
16
|
-
return await
|
|
16
|
+
return await Ct(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
17
17
|
}
|
|
18
|
-
async function
|
|
19
|
-
const s = await
|
|
20
|
-
await
|
|
21
|
-
const r = await
|
|
18
|
+
async function Ct(e, t) {
|
|
19
|
+
const s = await x();
|
|
20
|
+
await rt(s, "readwrite", async (n) => {
|
|
21
|
+
const r = await it(
|
|
22
22
|
n.get(e)
|
|
23
23
|
);
|
|
24
24
|
r && n.put({
|
|
@@ -27,31 +27,31 @@ async function Et(e, t) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
const t = await
|
|
32
|
-
await
|
|
30
|
+
async function Vt(e = 864e5) {
|
|
31
|
+
const t = await x(), s = Date.now() - e;
|
|
32
|
+
await rt(t, "readwrite", async (n) => {
|
|
33
33
|
const r = n.index("lastUsedAt");
|
|
34
|
-
(await
|
|
34
|
+
(await it(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function x() {
|
|
38
38
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
39
|
-
const s = indexedDB.open(
|
|
39
|
+
const s = indexedDB.open(Kt, 1);
|
|
40
40
|
s.onupgradeneeded = () => {
|
|
41
|
-
const r = s.result.createObjectStore(
|
|
41
|
+
const r = s.result.createObjectStore(Z, { 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
|
-
async function
|
|
47
|
-
return await
|
|
46
|
+
async function bt(e, t, s) {
|
|
47
|
+
return await rt(e, t, async (n) => await it(s(n)));
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function rt(e, t, s) {
|
|
50
50
|
return new Promise((n, r) => {
|
|
51
|
-
const i = e.transaction(
|
|
52
|
-
let
|
|
51
|
+
const i = e.transaction(Z, t), o = i.objectStore(Z);
|
|
52
|
+
let c, a = !1;
|
|
53
53
|
s(o).then((h) => {
|
|
54
|
-
|
|
54
|
+
c = h;
|
|
55
55
|
}).catch((h) => {
|
|
56
56
|
a = !0;
|
|
57
57
|
try {
|
|
@@ -60,7 +60,7 @@ function st(e, t, s) {
|
|
|
60
60
|
}
|
|
61
61
|
r(h);
|
|
62
62
|
}), i.oncomplete = () => {
|
|
63
|
-
a || n(
|
|
63
|
+
a || n(c);
|
|
64
64
|
}, i.onerror = () => {
|
|
65
65
|
a || (a = !0, r(i.error ?? new Error("Product Agent attachment storage transaction failed")));
|
|
66
66
|
}, i.onabort = () => {
|
|
@@ -68,16 +68,16 @@ function st(e, t, s) {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function it(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
|
|
77
|
-
let
|
|
78
|
-
const
|
|
79
|
-
async function
|
|
80
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
76
|
+
const z = "pluno.productAgent.transportId", Yt = "pluno.productAgent.transportIdentity", G = "pluno.productAgent.transportIdentity.event", Zt = 50, Qt = globalThis.setTimeout.bind(globalThis);
|
|
77
|
+
let M = null;
|
|
78
|
+
const v = /* @__PURE__ */ new Set();
|
|
79
|
+
async function te(e = Mt()) {
|
|
80
|
+
const t = e.randomUUID(), s = e.storage.getItem(z);
|
|
81
81
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
82
82
|
const o = e.channel.subscribe((a) => {
|
|
83
83
|
if (!(a.senderId === t || a.transportId !== n)) {
|
|
@@ -95,58 +95,58 @@ async function Qt(e = _t()) {
|
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
if (!s)
|
|
98
|
-
e.storage.setItem(
|
|
98
|
+
e.storage.setItem(z, n), r = !0;
|
|
99
99
|
else
|
|
100
100
|
for (; ; ) {
|
|
101
101
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
102
102
|
r = !0;
|
|
103
103
|
break;
|
|
104
104
|
}
|
|
105
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
105
|
+
n = e.randomUUID(), e.storage.setItem(z, n);
|
|
106
106
|
}
|
|
107
|
-
let
|
|
107
|
+
let c = !1;
|
|
108
108
|
return {
|
|
109
109
|
transportId: n,
|
|
110
110
|
release: () => {
|
|
111
|
-
|
|
111
|
+
c || (c = !0, o(), e.channel.close());
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
async function
|
|
116
|
-
|
|
115
|
+
async function ee() {
|
|
116
|
+
M || (M = te(Mt()), M.then((n) => {
|
|
117
117
|
const r = (i) => {
|
|
118
|
-
i.persisted || (n.release(),
|
|
118
|
+
i.persisted || (n.release(), M = null, v.clear(), window.removeEventListener("pagehide", r));
|
|
119
119
|
};
|
|
120
120
|
window.addEventListener("pagehide", r);
|
|
121
121
|
}));
|
|
122
|
-
const e = await
|
|
123
|
-
|
|
122
|
+
const e = await M, t = se();
|
|
123
|
+
v.add(t);
|
|
124
124
|
let s = !1;
|
|
125
125
|
return {
|
|
126
126
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
127
127
|
transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
|
|
128
128
|
release: () => {
|
|
129
|
-
s || (s = !0,
|
|
129
|
+
s || (s = !0, v.delete(t));
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function se() {
|
|
134
134
|
let e = 0;
|
|
135
|
-
for (;
|
|
135
|
+
for (; v.has(e); )
|
|
136
136
|
e += 1;
|
|
137
137
|
return e;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function Mt() {
|
|
140
140
|
return {
|
|
141
141
|
storage: window.sessionStorage,
|
|
142
|
-
channel:
|
|
142
|
+
channel: ne(),
|
|
143
143
|
randomUUID: () => crypto.randomUUID(),
|
|
144
|
-
settle: () => new Promise((e) =>
|
|
144
|
+
settle: () => new Promise((e) => Qt(e, Zt))
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function ne() {
|
|
148
148
|
if (typeof BroadcastChannel < "u") {
|
|
149
|
-
const e = new BroadcastChannel(
|
|
149
|
+
const e = new BroadcastChannel(Yt);
|
|
150
150
|
return {
|
|
151
151
|
postMessage: (t) => e.postMessage(t),
|
|
152
152
|
subscribe: (t) => {
|
|
@@ -156,11 +156,11 @@ function se() {
|
|
|
156
156
|
close: () => e.close()
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
-
return
|
|
159
|
+
return re();
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function re() {
|
|
162
162
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
163
|
-
if (s.key !==
|
|
163
|
+
if (s.key !== G || !s.newValue)
|
|
164
164
|
return;
|
|
165
165
|
const n = JSON.parse(s.newValue);
|
|
166
166
|
for (const r of e)
|
|
@@ -169,9 +169,9 @@ function ne() {
|
|
|
169
169
|
return window.addEventListener("storage", t), {
|
|
170
170
|
postMessage: (s) => {
|
|
171
171
|
window.localStorage.setItem(
|
|
172
|
-
|
|
172
|
+
G,
|
|
173
173
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
174
|
-
), window.localStorage.removeItem(
|
|
174
|
+
), window.localStorage.removeItem(G);
|
|
175
175
|
},
|
|
176
176
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
177
177
|
close: () => {
|
|
@@ -179,11 +179,15 @@ function ne() {
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
const Q = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', ie = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', oe = ".pluno-pa-widget__panel", ae = ".pluno-pa-widget__timeline", ht = `${Q}[data-pluno-sdk-preview-channel]`, ce = "https://app.pluno.ai", le = "gpt-5.6-terra", ue = 2e4, de = 1e4, he = 1e4, pe = 1e4, ge = 1e4, fe = 1e3, pt = 3e4, gt = 0.2, ft = 6e4, me = 15e3, U = 3, ye = 2e3, Te = 15e3, we = 1e3, Ie = 100, Ae = 8e3, Se = 15e3, mt = 3, ke = [300, 1e3], ot = 64e3, X = 4e3, at = 30, Ee = 2e3, Re = 1e3, _e = 200 * 1024 * 1024, Ce = "Image is too large for model vision input.", be = 100, Pt = "pluno.productAgent.state.", tt = "pluno.productAgent.pendingEvents.", F = "pluno.productAgent.activeToolCalls.", Me = 100;
|
|
183
|
+
function D(e, t = 0) {
|
|
184
|
+
return Math.max(t, ye * 4 ** e);
|
|
185
|
+
}
|
|
186
|
+
const L = /* @__PURE__ */ new Set();
|
|
187
|
+
let N = null;
|
|
188
|
+
function Pe(e, t = Math.random) {
|
|
189
|
+
const s = Math.min(pt, fe * 2 ** e), n = 1 - gt + t() * gt * 2;
|
|
190
|
+
return Math.min(pt, Math.round(s * n));
|
|
187
191
|
}
|
|
188
192
|
function Ue(e, t, s) {
|
|
189
193
|
return new Promise((n, r) => {
|
|
@@ -198,13 +202,13 @@ function Ue(e, t, s) {
|
|
|
198
202
|
);
|
|
199
203
|
});
|
|
200
204
|
}
|
|
201
|
-
class
|
|
205
|
+
class Ut {
|
|
202
206
|
constructor(t, s) {
|
|
203
207
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
204
208
|
...this.state,
|
|
205
|
-
starterPrompts:
|
|
209
|
+
starterPrompts: Ve(t.initialStarterPrompts)
|
|
206
210
|
};
|
|
207
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
211
|
+
const n = t.restorePersistedState === !1 ? null : _s(t.clientId, t.expectedPersistedSessionId);
|
|
208
212
|
n && (this.state = {
|
|
209
213
|
...this.state,
|
|
210
214
|
...n,
|
|
@@ -215,10 +219,10 @@ class Pt {
|
|
|
215
219
|
assistantDraftRunId: null,
|
|
216
220
|
isThinking: !1,
|
|
217
221
|
lastError: null
|
|
218
|
-
}), this.queuedClientEvents =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
),
|
|
222
|
+
}), this.queuedClientEvents = Ds(
|
|
223
|
+
bs(t.clientId),
|
|
224
|
+
Ps(t.clientId)
|
|
225
|
+
), P(t.clientId, this.queuedClientEvents);
|
|
222
226
|
}
|
|
223
227
|
options;
|
|
224
228
|
listeners = {};
|
|
@@ -246,9 +250,8 @@ class Pt {
|
|
|
246
250
|
activeClientMessageId = null;
|
|
247
251
|
activeUserMessageEvent = null;
|
|
248
252
|
latestRecoverableClientMessageId = null;
|
|
249
|
-
runAckRecoveryRetryAttemptsByClientMessageId = {};
|
|
250
253
|
thinkingWatchdogResyncAttemptsByClientMessageId = {};
|
|
251
|
-
|
|
254
|
+
retryableClientMessageId = null;
|
|
252
255
|
runtimeHelperJavascript = null;
|
|
253
256
|
attachmentFiles = /* @__PURE__ */ new Map();
|
|
254
257
|
attachmentBlobCache = /* @__PURE__ */ new Map();
|
|
@@ -276,14 +279,14 @@ class Pt {
|
|
|
276
279
|
lastErrorCode: null
|
|
277
280
|
};
|
|
278
281
|
static async init(t) {
|
|
279
|
-
const s = await
|
|
282
|
+
const s = await ee(), n = new Ut({
|
|
280
283
|
...t,
|
|
281
|
-
backendUrl: Fe(t.backendUrl ??
|
|
282
|
-
clientId: t.clientId ??
|
|
283
|
-
model: t.model ??
|
|
284
|
+
backendUrl: Fe(t.backendUrl ?? ce),
|
|
285
|
+
clientId: t.clientId ?? es(),
|
|
286
|
+
model: t.model ?? le
|
|
284
287
|
}, s);
|
|
285
288
|
try {
|
|
286
|
-
|
|
289
|
+
Vt().catch((r) => {
|
|
287
290
|
f("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
288
291
|
message: r instanceof Error ? r.message : String(r)
|
|
289
292
|
});
|
|
@@ -315,7 +318,7 @@ class Pt {
|
|
|
315
318
|
lastError: null
|
|
316
319
|
});
|
|
317
320
|
try {
|
|
318
|
-
this.token = this.options.token ?? (this.options.tokenProvider ? await Ue(this.options.tokenProvider(),
|
|
321
|
+
this.token = this.options.token ?? (this.options.tokenProvider ? await Ue(this.options.tokenProvider(), he, "Pluno token provider timed out") : null);
|
|
319
322
|
} finally {
|
|
320
323
|
this.connectionInProgress = !1;
|
|
321
324
|
}
|
|
@@ -323,10 +326,10 @@ class Pt {
|
|
|
323
326
|
return;
|
|
324
327
|
if (!this.token && !this.options.webSocketFactory)
|
|
325
328
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
326
|
-
const s =
|
|
329
|
+
const s = je(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
327
330
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
328
331
|
this.socket !== n || n.readyState !== WebSocket.CONNECTING || (f("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
329
|
-
},
|
|
332
|
+
}, pe), n.addEventListener("open", () => {
|
|
330
333
|
this.socket !== n || (this.clearSocketConnectTimer(), f("web-sdk.agent", "Pluno socket opened", {
|
|
331
334
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
332
335
|
isThinking: this.state.isThinking
|
|
@@ -338,9 +341,9 @@ class Pt {
|
|
|
338
341
|
pageUrl: location.href
|
|
339
342
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
340
343
|
this.socket === n && (f("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
341
|
-
},
|
|
344
|
+
}, ge));
|
|
342
345
|
}), n.addEventListener("message", (r) => {
|
|
343
|
-
this.socket === n && this.handleServerEvent(
|
|
346
|
+
this.socket === n && this.handleServerEvent(Je(r.data));
|
|
344
347
|
}), n.addEventListener("close", (r) => {
|
|
345
348
|
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (f("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
346
349
|
code: typeof r?.code == "number" ? r.code : null,
|
|
@@ -360,16 +363,18 @@ class Pt {
|
|
|
360
363
|
this.connectionAttemptId += 1, this.setState({ status: "closed", isThinking: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
|
|
361
364
|
}
|
|
362
365
|
destroy() {
|
|
363
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
366
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), Ns(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
364
367
|
for (const t of Object.values(this.listeners))
|
|
365
368
|
t?.clear();
|
|
366
369
|
}
|
|
367
370
|
sendMessage(t, s = {}) {
|
|
368
|
-
const n = t.trim(), r = s.attachments ?? [], i = r.map(
|
|
371
|
+
const n = t.trim(), r = s.attachments ?? [], i = r.map(ut);
|
|
369
372
|
if (!n && i.length === 0)
|
|
370
373
|
return null;
|
|
371
|
-
const o =
|
|
372
|
-
|
|
374
|
+
const o = A(), c = O();
|
|
375
|
+
this.retryableClientMessageId = null;
|
|
376
|
+
const a = {
|
|
377
|
+
id: `local-${c}`,
|
|
373
378
|
role: "user",
|
|
374
379
|
content: n,
|
|
375
380
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -388,31 +393,35 @@ class Pt {
|
|
|
388
393
|
const h = {
|
|
389
394
|
type: "chat.user_message",
|
|
390
395
|
sessionId: this.state.sessionId ?? void 0,
|
|
391
|
-
clientMessageId:
|
|
396
|
+
clientMessageId: c,
|
|
392
397
|
content: n,
|
|
393
398
|
attachments: i.length > 0 ? i : void 0,
|
|
394
399
|
page: o,
|
|
395
400
|
model: this.options.model,
|
|
396
|
-
metadata:
|
|
401
|
+
metadata: yt(this.options.metadata)
|
|
397
402
|
};
|
|
398
|
-
return this.activeClientMessageId =
|
|
403
|
+
return this.activeClientMessageId = c, this.activeUserMessageEvent = h, this.markThinkingProgress(), this.send(h), this.startBackgroundAttachmentUploads(c, i), c;
|
|
404
|
+
}
|
|
405
|
+
retryLastMessage() {
|
|
406
|
+
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
407
|
+
return !t || !s ? !1 : (this.retryAttemptsByClientMessageId[s] = 0, this.retryableClientMessageId = null, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !1 }), !0);
|
|
399
408
|
}
|
|
400
409
|
createLocalAttachment(t) {
|
|
401
|
-
const s =
|
|
410
|
+
const s = O(), n = {
|
|
402
411
|
id: s,
|
|
403
412
|
name: t.name || "attachment",
|
|
404
|
-
mimeType:
|
|
413
|
+
mimeType: kt(t),
|
|
405
414
|
sizeBytes: t.size
|
|
406
415
|
};
|
|
407
416
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
408
417
|
const r = Date.now();
|
|
409
|
-
return
|
|
418
|
+
return _t({
|
|
410
419
|
attachmentId: s,
|
|
411
420
|
name: n.name,
|
|
412
421
|
mimeType: n.mimeType,
|
|
413
422
|
sizeBytes: n.sizeBytes,
|
|
414
423
|
blob: t,
|
|
415
|
-
origin:
|
|
424
|
+
origin: A().origin,
|
|
416
425
|
sessionId: this.state.sessionId ?? void 0,
|
|
417
426
|
createdAt: r,
|
|
418
427
|
lastUsedAt: r
|
|
@@ -429,7 +438,7 @@ class Pt {
|
|
|
429
438
|
return await this.uploadAttachmentForMessage({
|
|
430
439
|
file: t,
|
|
431
440
|
attachment: s,
|
|
432
|
-
clientMessageId:
|
|
441
|
+
clientMessageId: O(),
|
|
433
442
|
waitForSession: !1,
|
|
434
443
|
notifyCompletion: !1
|
|
435
444
|
});
|
|
@@ -461,42 +470,42 @@ class Pt {
|
|
|
461
470
|
waitForSession: r,
|
|
462
471
|
notifyCompletion: i
|
|
463
472
|
}) {
|
|
464
|
-
const o = r ? await this.waitForSessionId() : this.state.sessionId,
|
|
473
|
+
const o = r ? await this.waitForSessionId() : this.state.sessionId, c = kt(t), a = {
|
|
465
474
|
sessionId: o ?? void 0,
|
|
466
475
|
attachmentId: s.id,
|
|
467
476
|
clientId: this.options.clientId,
|
|
468
477
|
transportId: this.transportIdentity.transportId,
|
|
469
478
|
name: t.name || "attachment",
|
|
470
|
-
mimeType:
|
|
479
|
+
mimeType: c,
|
|
471
480
|
sizeBytes: t.size,
|
|
472
|
-
page:
|
|
481
|
+
page: A(),
|
|
473
482
|
model: this.options.model,
|
|
474
|
-
metadata:
|
|
475
|
-
}, h = this.options.prepareAttachmentUpload ? await
|
|
483
|
+
metadata: yt(this.options.metadata)
|
|
484
|
+
}, h = this.options.prepareAttachmentUpload ? await Y(
|
|
476
485
|
() => this.options.prepareAttachmentUpload(a),
|
|
477
486
|
"Failed to prepare attachment upload"
|
|
478
487
|
) : await this.prepareEmbedAttachmentUpload(a);
|
|
479
|
-
await
|
|
480
|
-
const
|
|
488
|
+
await Y(async () => {
|
|
489
|
+
const d = await fetch(h.uploadUrl, {
|
|
481
490
|
method: h.uploadMethod,
|
|
482
491
|
headers: h.uploadHeaders,
|
|
483
492
|
body: t
|
|
484
493
|
});
|
|
485
|
-
if (!
|
|
486
|
-
throw new
|
|
487
|
-
return
|
|
494
|
+
if (!d.ok)
|
|
495
|
+
throw new B("Failed to upload attachment", d.status);
|
|
496
|
+
return d;
|
|
488
497
|
}, "Failed to upload attachment"), this.setState({ sessionId: h.sessionId });
|
|
489
|
-
const g =
|
|
490
|
-
return this.updateAttachmentInState(s.id, g), s.id &&
|
|
498
|
+
const g = Ht(h.attachment, this.options.backendUrl);
|
|
499
|
+
return this.updateAttachmentInState(s.id, g), s.id && Ct(s.id, {
|
|
491
500
|
sessionId: h.sessionId,
|
|
492
501
|
fileUrl: g.fileUrl,
|
|
493
502
|
gcsPath: g.gcsPath,
|
|
494
503
|
lastUsedAt: Date.now()
|
|
495
|
-
}).catch((
|
|
504
|
+
}).catch((d) => {
|
|
496
505
|
f("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
497
506
|
attachmentId: s.id,
|
|
498
507
|
name: g.name,
|
|
499
|
-
message:
|
|
508
|
+
message: d instanceof Error ? d.message : String(d)
|
|
500
509
|
});
|
|
501
510
|
}), i && g.gcsPath && this.send({
|
|
502
511
|
type: "attachment.upload_completed",
|
|
@@ -509,7 +518,7 @@ class Pt {
|
|
|
509
518
|
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
510
519
|
const n = window.setTimeout(() => {
|
|
511
520
|
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
512
|
-
},
|
|
521
|
+
}, Se), r = this.on("state", (i) => {
|
|
513
522
|
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
514
523
|
});
|
|
515
524
|
});
|
|
@@ -527,18 +536,18 @@ class Pt {
|
|
|
527
536
|
}
|
|
528
537
|
async prepareEmbedAttachmentUpload(t) {
|
|
529
538
|
let s = !1;
|
|
530
|
-
return await
|
|
539
|
+
return await Y(async () => {
|
|
531
540
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
532
541
|
if (n.ok)
|
|
533
542
|
return await n.json();
|
|
534
|
-
if (
|
|
543
|
+
if (Ys(n.status) && this.options.tokenProvider && !s) {
|
|
535
544
|
s = !0;
|
|
536
545
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
537
546
|
if (r.ok)
|
|
538
547
|
return await r.json();
|
|
539
|
-
throw new
|
|
548
|
+
throw new B("Failed to prepare attachment upload", r.status);
|
|
540
549
|
}
|
|
541
|
-
throw new
|
|
550
|
+
throw new B("Failed to prepare attachment upload", n.status);
|
|
542
551
|
}, "Failed to prepare attachment upload");
|
|
543
552
|
}
|
|
544
553
|
async fetchEmbedAttachmentUpload(t) {
|
|
@@ -557,10 +566,10 @@ class Pt {
|
|
|
557
566
|
}
|
|
558
567
|
startNewSession(t = {}) {
|
|
559
568
|
const s = t.notifyTransport !== !1;
|
|
560
|
-
s && this.state.sessionId && this.state.isThinking && this.sendNow({ type: "run.stop", sessionId: this.state.sessionId }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), s && this.send({
|
|
569
|
+
s && this.state.sessionId && this.state.isThinking && this.sendNow({ type: "run.stop", sessionId: this.state.sessionId }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, s && this.send({
|
|
561
570
|
type: "session.reset",
|
|
562
571
|
sessionId: this.state.sessionId ?? void 0,
|
|
563
|
-
page:
|
|
572
|
+
page: A()
|
|
564
573
|
}), this.setState({
|
|
565
574
|
sessionId: null,
|
|
566
575
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -573,15 +582,15 @@ class Pt {
|
|
|
573
582
|
});
|
|
574
583
|
}
|
|
575
584
|
listSessions(t = {}) {
|
|
576
|
-
const s =
|
|
577
|
-
const
|
|
585
|
+
const s = O(), n = new Promise((i, o) => {
|
|
586
|
+
const c = window.setTimeout(() => {
|
|
578
587
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
579
588
|
}, Ae);
|
|
580
|
-
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout:
|
|
589
|
+
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: c });
|
|
581
590
|
}), r = {
|
|
582
591
|
type: "sessions.list",
|
|
583
592
|
requestId: s,
|
|
584
|
-
page:
|
|
593
|
+
page: A(),
|
|
585
594
|
...t.cursor ? { cursor: t.cursor } : {},
|
|
586
595
|
...t.limit ? { limit: t.limit } : {}
|
|
587
596
|
};
|
|
@@ -603,11 +612,11 @@ class Pt {
|
|
|
603
612
|
}), this.send({
|
|
604
613
|
type: "session.load",
|
|
605
614
|
sessionId: t,
|
|
606
|
-
page:
|
|
615
|
+
page: A()
|
|
607
616
|
});
|
|
608
617
|
}
|
|
609
618
|
send(t) {
|
|
610
|
-
this.sendNow(
|
|
619
|
+
this.sendNow(I(t)) || (this.queuedClientEvents.push(t), P(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
611
620
|
}
|
|
612
621
|
async getUploadToken() {
|
|
613
622
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -633,9 +642,9 @@ class Pt {
|
|
|
633
642
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
634
643
|
return;
|
|
635
644
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
636
|
-
const t =
|
|
645
|
+
const t = $e();
|
|
637
646
|
this.sendNow(
|
|
638
|
-
|
|
647
|
+
I({
|
|
639
648
|
type: "starter_prompts.page_context",
|
|
640
649
|
pageUrl: t.pageUrl,
|
|
641
650
|
pageTitle: t.pageTitle,
|
|
@@ -644,13 +653,13 @@ class Pt {
|
|
|
644
653
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
645
654
|
}
|
|
646
655
|
startStarterPromptUrlWatcher() {
|
|
647
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
656
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = ze(() => this.handleStarterPromptUrlChange()));
|
|
648
657
|
}
|
|
649
658
|
handleStarterPromptUrlChange() {
|
|
650
659
|
const t = location.href;
|
|
651
660
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
652
661
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
653
|
-
},
|
|
662
|
+
}, Me));
|
|
654
663
|
}
|
|
655
664
|
refreshStarterPromptsForCurrentUrl() {
|
|
656
665
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -665,14 +674,14 @@ class Pt {
|
|
|
665
674
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
666
675
|
return;
|
|
667
676
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
668
|
-
|
|
677
|
+
P(this.options.clientId, this.queuedClientEvents);
|
|
669
678
|
for (let s = 0; s < t.length; s += 1) {
|
|
670
679
|
const n = t[s];
|
|
671
|
-
if (!this.sendNow(
|
|
672
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
680
|
+
if (!this.sendNow(I(n))) {
|
|
681
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), P(this.options.clientId, this.queuedClientEvents);
|
|
673
682
|
return;
|
|
674
683
|
}
|
|
675
|
-
|
|
684
|
+
P(this.options.clientId, this.queuedClientEvents);
|
|
676
685
|
}
|
|
677
686
|
}
|
|
678
687
|
handleServerEvent(t) {
|
|
@@ -684,73 +693,84 @@ class Pt {
|
|
|
684
693
|
this.clearHeartbeatAckTimer();
|
|
685
694
|
return;
|
|
686
695
|
}
|
|
687
|
-
if (
|
|
696
|
+
if (Oe(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
688
697
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
689
|
-
const s =
|
|
698
|
+
const s = Ye(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
690
699
|
f("web-sdk.agent", "Received auth.ok appearance", {
|
|
691
700
|
hasAppearance: n,
|
|
692
701
|
rawAppearance: t.appearance,
|
|
693
702
|
normalizedAppearance: s
|
|
694
|
-
}), this.runtimeHelperJavascript =
|
|
695
|
-
const r =
|
|
696
|
-
user:
|
|
703
|
+
}), this.runtimeHelperJavascript = Ze(t.runtimeHelpers)?.javascript ?? null;
|
|
704
|
+
const r = It(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
|
|
705
|
+
user: ss(t.user),
|
|
697
706
|
status: "connected"
|
|
698
707
|
};
|
|
699
|
-
(i || this.state.starterPrompts.length === 0) && (
|
|
708
|
+
(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 && !Xe() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
700
709
|
type: "page.upsert",
|
|
701
710
|
sessionId: this.state.sessionId,
|
|
702
|
-
page:
|
|
711
|
+
page: A(),
|
|
703
712
|
model: this.options.model
|
|
704
713
|
});
|
|
705
714
|
return;
|
|
706
715
|
}
|
|
707
716
|
if (t.type === "starterPrompts.updated") {
|
|
708
717
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
709
|
-
starterPrompts:
|
|
718
|
+
starterPrompts: It(t, "starterPrompts"),
|
|
710
719
|
starterPromptsLoading: !1
|
|
711
720
|
});
|
|
712
721
|
return;
|
|
713
722
|
}
|
|
714
723
|
if (t.type === "conversation.state") {
|
|
715
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
724
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Ts(s);
|
|
725
|
+
if (n) {
|
|
726
|
+
const c = ws(s, n);
|
|
727
|
+
this.retryAttemptsByClientMessageId[n] = Math.max(
|
|
728
|
+
this.retryAttemptsByClientMessageId[n] ?? 0,
|
|
729
|
+
c
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
const r = ds(
|
|
716
733
|
this.state.messages,
|
|
717
|
-
|
|
718
|
-
),
|
|
719
|
-
if (!
|
|
734
|
+
ns(s, this.options.backendUrl)
|
|
735
|
+
), i = At(r);
|
|
736
|
+
if (!i && ys(this.state.messages, s))
|
|
720
737
|
return;
|
|
721
|
-
const
|
|
722
|
-
this.latestRecoverableClientMessageId =
|
|
723
|
-
sessionId:
|
|
724
|
-
messages:
|
|
725
|
-
...
|
|
738
|
+
const o = i ? null : et(s);
|
|
739
|
+
if (this.latestRecoverableClientMessageId = o, fs(r) && this.clearRetryTimers(), this.setState({
|
|
740
|
+
sessionId: S(t.session, "id") ?? this.state.sessionId,
|
|
741
|
+
messages: r,
|
|
742
|
+
...i ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : o ? {
|
|
726
743
|
assistantDraft: "",
|
|
727
744
|
assistantDraftRespondsToUserMessageId: null,
|
|
728
745
|
assistantDraftRunId: null,
|
|
729
746
|
isThinking: !0,
|
|
730
747
|
lastError: null
|
|
731
748
|
} : {}
|
|
732
|
-
}),
|
|
749
|
+
}), i ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : o && (this.activeClientMessageId = o, this.markThinkingProgress()), n) {
|
|
750
|
+
const c = S(t.session, "id") ?? this.state.sessionId;
|
|
751
|
+
c && this.retryAfterInterruptedRun(c, n);
|
|
752
|
+
}
|
|
733
753
|
return;
|
|
734
754
|
}
|
|
735
755
|
if (t.type === "sessions.page") {
|
|
736
756
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
737
757
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
738
|
-
sessions:
|
|
758
|
+
sessions: rs(t.sessions),
|
|
739
759
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
740
760
|
}));
|
|
741
761
|
return;
|
|
742
762
|
}
|
|
743
763
|
if (t.type === "session.updated") {
|
|
744
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
764
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: S(t.session, "id") ?? this.state.sessionId });
|
|
745
765
|
return;
|
|
746
766
|
}
|
|
747
767
|
if (t.type === "session.item") {
|
|
748
|
-
const s =
|
|
768
|
+
const s = Nt(t.item, this.options.backendUrl);
|
|
749
769
|
if (s) {
|
|
750
|
-
s.role === "assistant" && (this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
770
|
+
s.role === "assistant" && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
751
771
|
const n = t.item.data;
|
|
752
|
-
|
|
753
|
-
const r =
|
|
772
|
+
Is(n) && this.clearRunAckResyncRetryTimer();
|
|
773
|
+
const r = us(this.state.messages, s), i = At(r);
|
|
754
774
|
this.setState({
|
|
755
775
|
messages: r,
|
|
756
776
|
assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
|
|
@@ -773,6 +793,7 @@ class Pt {
|
|
|
773
793
|
return;
|
|
774
794
|
}
|
|
775
795
|
if (t.type === "chat.assistant_done") {
|
|
796
|
+
this.retryableClientMessageId = null;
|
|
776
797
|
const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId;
|
|
777
798
|
this.setState({
|
|
778
799
|
sessionId: s,
|
|
@@ -793,34 +814,65 @@ class Pt {
|
|
|
793
814
|
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof t.message == "string" ? t.message : "Pluno error"));
|
|
794
815
|
return;
|
|
795
816
|
}
|
|
817
|
+
const r = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, i = typeof t.clientMessageId == "string" ? t.clientMessageId : null, o = t.retryable === !0 || t.code === "transient_model_error";
|
|
796
818
|
if (this.retryAfterRetryableError(t))
|
|
797
819
|
return;
|
|
798
|
-
|
|
799
|
-
|
|
820
|
+
o && r && i && (this.retryableClientMessageId = i);
|
|
821
|
+
const c = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), a = We(c.message);
|
|
822
|
+
a && console.error(a), this.setState({
|
|
800
823
|
status: "error",
|
|
801
824
|
isThinking: !1,
|
|
802
|
-
lastError:
|
|
825
|
+
lastError: c.message,
|
|
803
826
|
lastErrorCode: typeof t.code == "string" ? t.code : null
|
|
804
|
-
}), this.clearThinkingWatchdog(), this.emit("error",
|
|
827
|
+
}), this.clearThinkingWatchdog(), this.emit("error", c);
|
|
805
828
|
}
|
|
806
829
|
}
|
|
807
830
|
retryAfterRetryableError(t) {
|
|
808
831
|
const s = typeof t.sessionId == "string" ? t.sessionId : this.state.sessionId, n = typeof t.clientMessageId == "string" ? t.clientMessageId : null;
|
|
809
|
-
if (!(t.retryable === !0 || t.code === "transient_model_error") || !s || !n)
|
|
832
|
+
if (!(t.retryable === !0 || t.code === "transient_model_error") || !s || !n || t.code === "run_recovery_exhausted")
|
|
810
833
|
return !1;
|
|
834
|
+
if (t.code === "run_still_active") {
|
|
835
|
+
if (this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
836
|
+
const c = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
|
|
837
|
+
this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
|
|
838
|
+
delete this.retryTimersByClientMessageId[n], this.resyncThinkingSession(), this.markThinkingProgress();
|
|
839
|
+
}, c);
|
|
840
|
+
}
|
|
841
|
+
return !0;
|
|
842
|
+
}
|
|
811
843
|
const i = this.retryAttemptsByClientMessageId[n] ?? 0;
|
|
812
|
-
if (i >=
|
|
844
|
+
if (i >= U)
|
|
813
845
|
return !1;
|
|
814
846
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
815
|
-
const o =
|
|
847
|
+
const o = D(
|
|
848
|
+
i,
|
|
849
|
+
typeof t.retryAfterMs == "number" ? t.retryAfterMs : 0
|
|
850
|
+
);
|
|
816
851
|
return this.setState({ status: "reconnecting", isThinking: !0, lastError: null }), this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
|
|
817
852
|
delete this.retryTimersByClientMessageId[n], this.setState({ status: "connected", isThinking: !0, lastError: null }), this.markThinkingProgress(), this.send({
|
|
818
853
|
type: "chat.retry_last_user_message",
|
|
819
854
|
sessionId: s,
|
|
820
|
-
clientMessageId: n
|
|
855
|
+
clientMessageId: n,
|
|
856
|
+
automatic: !0
|
|
821
857
|
});
|
|
822
858
|
}, o), !0;
|
|
823
859
|
}
|
|
860
|
+
retryAfterInterruptedRun(t, s) {
|
|
861
|
+
if (this.retryTimersByClientMessageId[s] !== void 0)
|
|
862
|
+
return;
|
|
863
|
+
const n = this.retryAttemptsByClientMessageId[s] ?? 0;
|
|
864
|
+
if (n >= U) {
|
|
865
|
+
this.retryableClientMessageId = s, this.setState({
|
|
866
|
+
isThinking: !1,
|
|
867
|
+
lastError: "Pluno could not finish this message. Try it again.",
|
|
868
|
+
lastErrorCode: "run_recovery_exhausted"
|
|
869
|
+
}), this.clearThinkingWatchdog();
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
this.retryAttemptsByClientMessageId[s] = n + 1, this.activeClientMessageId = s, this.latestRecoverableClientMessageId = s, this.setState({ status: "reconnecting", isThinking: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[s] = window.setTimeout(() => {
|
|
873
|
+
delete this.retryTimersByClientMessageId[s], this.setState({ status: "connected", isThinking: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: t, clientMessageId: s, automatic: !0 });
|
|
874
|
+
}, D(n));
|
|
875
|
+
}
|
|
824
876
|
clearRetryTimers() {
|
|
825
877
|
for (const t of Object.values(this.retryTimersByClientMessageId))
|
|
826
878
|
window.clearTimeout(t);
|
|
@@ -832,7 +884,7 @@ class Pt {
|
|
|
832
884
|
this.pendingSessionHistoryRequests.clear();
|
|
833
885
|
}
|
|
834
886
|
markThinkingProgress() {
|
|
835
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
887
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ft), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
836
888
|
}
|
|
837
889
|
scheduleThinkingWatchdog(t) {
|
|
838
890
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -849,7 +901,7 @@ class Pt {
|
|
|
849
901
|
scheduleRunAckWatchdog(t) {
|
|
850
902
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
851
903
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
852
|
-
},
|
|
904
|
+
}, Te);
|
|
853
905
|
}
|
|
854
906
|
recoverMissedRunAck(t) {
|
|
855
907
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (f("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -858,8 +910,10 @@ class Pt {
|
|
|
858
910
|
}), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
|
|
859
911
|
}
|
|
860
912
|
scheduleRunAckResyncRetry(t) {
|
|
861
|
-
this.clearRunAckResyncRetryTimer()
|
|
862
|
-
|
|
913
|
+
this.clearRunAckResyncRetryTimer();
|
|
914
|
+
const s = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
915
|
+
s >= U || (this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
916
|
+
this.runAckResyncRetryTimer = null, (this.retryAttemptsByClientMessageId[t] ?? 0) === s && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.retryAttemptsByClientMessageId[t] = s + 1, this.setState({
|
|
863
917
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
864
918
|
isThinking: !0,
|
|
865
919
|
lastError: null
|
|
@@ -869,9 +923,10 @@ class Pt {
|
|
|
869
923
|
}), this.state.sessionId ? this.send({
|
|
870
924
|
type: "chat.retry_last_user_message",
|
|
871
925
|
sessionId: this.state.sessionId,
|
|
872
|
-
clientMessageId: t
|
|
873
|
-
|
|
874
|
-
|
|
926
|
+
clientMessageId: t,
|
|
927
|
+
automatic: !0
|
|
928
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ft)));
|
|
929
|
+
}, D(s)));
|
|
875
930
|
}
|
|
876
931
|
clearRunAckResyncRetryTimer() {
|
|
877
932
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -884,47 +939,57 @@ class Pt {
|
|
|
884
939
|
return;
|
|
885
940
|
const t = this.activeClientMessageId;
|
|
886
941
|
if (!t) {
|
|
887
|
-
f("web-sdk.agent", "Pluno thinking watchdog
|
|
942
|
+
f("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
888
943
|
sessionId: this.state.sessionId
|
|
889
|
-
}), this.
|
|
944
|
+
}), this.setState({
|
|
945
|
+
isThinking: !1,
|
|
946
|
+
lastError: "Pluno could not finish this message. Please send it again.",
|
|
947
|
+
lastErrorCode: "run_recovery_exhausted"
|
|
948
|
+
}), this.clearThinkingWatchdog();
|
|
890
949
|
return;
|
|
891
950
|
}
|
|
892
|
-
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.
|
|
893
|
-
if (
|
|
894
|
-
|
|
951
|
+
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
952
|
+
if (n >= U) {
|
|
953
|
+
f("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
895
954
|
sessionId: this.state.sessionId,
|
|
896
|
-
clientMessageId: t
|
|
897
|
-
|
|
898
|
-
|
|
955
|
+
clientMessageId: t
|
|
956
|
+
}), this.retryableClientMessageId = t, this.setState({
|
|
957
|
+
isThinking: !1,
|
|
958
|
+
lastError: "Pluno could not finish this message. Try it again.",
|
|
959
|
+
lastErrorCode: "run_recovery_exhausted"
|
|
960
|
+
}), this.clearThinkingWatchdog();
|
|
899
961
|
return;
|
|
900
962
|
}
|
|
901
|
-
if (
|
|
902
|
-
f("web-sdk.agent", "Pluno thinking watchdog
|
|
963
|
+
if (s < 1) {
|
|
964
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, f("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
903
965
|
sessionId: this.state.sessionId,
|
|
904
966
|
clientMessageId: t,
|
|
905
|
-
|
|
906
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
967
|
+
resyncAttempts: s + 1
|
|
968
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(me);
|
|
907
969
|
return;
|
|
908
970
|
}
|
|
909
|
-
this.
|
|
971
|
+
this.setState({
|
|
910
972
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
911
973
|
isThinking: !0,
|
|
912
974
|
lastError: null
|
|
913
|
-
}), f("web-sdk.agent", "Pluno thinking watchdog
|
|
975
|
+
}), f("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
914
976
|
sessionId: this.state.sessionId,
|
|
915
977
|
clientMessageId: t,
|
|
916
978
|
retryAttempts: n + 1
|
|
917
|
-
}), this.
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
979
|
+
}), this.retryTimersByClientMessageId[t] === void 0 && (this.retryAttemptsByClientMessageId[t] = n + 1, this.retryTimersByClientMessageId[t] = window.setTimeout(() => {
|
|
980
|
+
delete this.retryTimersByClientMessageId[t], this.state.sessionId ? this.send({
|
|
981
|
+
type: "chat.retry_last_user_message",
|
|
982
|
+
sessionId: this.state.sessionId,
|
|
983
|
+
clientMessageId: t,
|
|
984
|
+
automatic: !0
|
|
985
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.markThinkingProgress();
|
|
986
|
+
}, D(n)));
|
|
922
987
|
}
|
|
923
988
|
resyncThinkingSession() {
|
|
924
989
|
this.state.sessionId ? this.send({
|
|
925
990
|
type: "page.upsert",
|
|
926
991
|
sessionId: this.state.sessionId,
|
|
927
|
-
page:
|
|
992
|
+
page: A(),
|
|
928
993
|
model: this.options.model
|
|
929
994
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
930
995
|
}
|
|
@@ -932,15 +997,15 @@ class Pt {
|
|
|
932
997
|
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;
|
|
933
998
|
if (!s || !n || !r)
|
|
934
999
|
return;
|
|
935
|
-
if (r !== "execute_code" || !
|
|
1000
|
+
if (r !== "execute_code" || !Hs(o)) {
|
|
936
1001
|
this.send({
|
|
937
1002
|
type: "tool.result",
|
|
938
1003
|
sessionId: s,
|
|
939
1004
|
callId: n,
|
|
940
1005
|
toolName: r,
|
|
941
1006
|
summary: i,
|
|
942
|
-
rawInput:
|
|
943
|
-
rawOutput:
|
|
1007
|
+
rawInput: I(o),
|
|
1008
|
+
rawOutput: I({
|
|
944
1009
|
ok: !1,
|
|
945
1010
|
toolName: r,
|
|
946
1011
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -948,7 +1013,7 @@ class Pt {
|
|
|
948
1013
|
});
|
|
949
1014
|
return;
|
|
950
1015
|
}
|
|
951
|
-
const
|
|
1016
|
+
const c = Le(this.state.messages);
|
|
952
1017
|
this.activeBrowserToolCalls.set(n, {
|
|
953
1018
|
event: {
|
|
954
1019
|
type: "tool.result",
|
|
@@ -956,15 +1021,15 @@ class Pt {
|
|
|
956
1021
|
callId: n,
|
|
957
1022
|
toolName: r,
|
|
958
1023
|
summary: o.summary,
|
|
959
|
-
rawInput:
|
|
1024
|
+
rawInput: I(o),
|
|
960
1025
|
rawOutput: null
|
|
961
1026
|
},
|
|
962
1027
|
startedAtMs: Date.now(),
|
|
963
1028
|
startedAtUrl: location.href,
|
|
964
1029
|
startedAtOrigin: location.origin
|
|
965
|
-
}), this.installSessionUserFilesApi(
|
|
1030
|
+
}), this.installSessionUserFilesApi(c);
|
|
966
1031
|
let a = null, h;
|
|
967
|
-
a = await this.executeRuntimeHelper(), h = await
|
|
1032
|
+
a = await this.executeRuntimeHelper(), h = await wt(o).catch((g) => ({
|
|
968
1033
|
ok: !1,
|
|
969
1034
|
exception: {
|
|
970
1035
|
message: g instanceof Error ? g.message : String(g)
|
|
@@ -975,22 +1040,22 @@ class Pt {
|
|
|
975
1040
|
callId: n,
|
|
976
1041
|
toolName: r,
|
|
977
1042
|
summary: o.summary,
|
|
978
|
-
rawInput:
|
|
979
|
-
rawOutput:
|
|
980
|
-
}),
|
|
1043
|
+
rawInput: I(o),
|
|
1044
|
+
rawOutput: I(Qe(h, a))
|
|
1045
|
+
}), Ms(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
981
1046
|
}
|
|
982
1047
|
startPageLifecycleRecovery() {
|
|
983
1048
|
if (this.pageLifecycleCleanup)
|
|
984
1049
|
return;
|
|
985
1050
|
const t = () => {
|
|
986
|
-
|
|
1051
|
+
Bt(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
987
1052
|
};
|
|
988
1053
|
window.addEventListener("pagehide", t), window.addEventListener("beforeunload", t), this.pageLifecycleCleanup = () => {
|
|
989
1054
|
window.removeEventListener("pagehide", t), window.removeEventListener("beforeunload", t);
|
|
990
1055
|
};
|
|
991
1056
|
}
|
|
992
1057
|
installSessionUserFilesApi(t) {
|
|
993
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1058
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Be(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
994
1059
|
}
|
|
995
1060
|
cleanupSessionUserFilesApi() {
|
|
996
1061
|
this.sessionUserFilesApiCleanup && (qe(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
@@ -998,24 +1063,24 @@ class Pt {
|
|
|
998
1063
|
async executeRuntimeHelper() {
|
|
999
1064
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1000
1065
|
return null;
|
|
1001
|
-
const t = await
|
|
1066
|
+
const t = await wt({
|
|
1002
1067
|
javascript: this.runtimeHelperJavascript
|
|
1003
1068
|
});
|
|
1004
|
-
return t.ok === !1 ?
|
|
1069
|
+
return t.ok === !1 ? ts(t) : null;
|
|
1005
1070
|
}
|
|
1006
1071
|
enableNetworkCapture() {
|
|
1007
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1008
|
-
|
|
1072
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = De((t) => {
|
|
1073
|
+
zs(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1009
1074
|
}));
|
|
1010
1075
|
}
|
|
1011
1076
|
enqueueNetworkEvent(t) {
|
|
1012
|
-
this.queuedNetworkEvents.length >=
|
|
1077
|
+
this.queuedNetworkEvents.length >= Ie || (this.queuedNetworkEvents.push($s(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1013
1078
|
this.networkBatchTimer = null;
|
|
1014
1079
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1015
1080
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1016
1081
|
type: "network.batch",
|
|
1017
1082
|
sessionId: this.state.sessionId ?? void 0,
|
|
1018
|
-
page:
|
|
1083
|
+
page: A(),
|
|
1019
1084
|
events: s
|
|
1020
1085
|
});
|
|
1021
1086
|
}, we)));
|
|
@@ -1023,7 +1088,7 @@ class Pt {
|
|
|
1023
1088
|
scheduleReconnect() {
|
|
1024
1089
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1025
1090
|
return;
|
|
1026
|
-
const t =
|
|
1091
|
+
const t = Pe(this.reconnectAttempts);
|
|
1027
1092
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1028
1093
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1029
1094
|
f("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
@@ -1039,8 +1104,8 @@ class Pt {
|
|
|
1039
1104
|
const t = this.socket;
|
|
1040
1105
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1041
1106
|
this.socket === t && (f("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1042
|
-
},
|
|
1043
|
-
},
|
|
1107
|
+
}, de));
|
|
1108
|
+
}, ue);
|
|
1044
1109
|
}
|
|
1045
1110
|
stopHeartbeat() {
|
|
1046
1111
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1065,52 +1130,52 @@ class Pt {
|
|
|
1065
1130
|
...this.state,
|
|
1066
1131
|
...t,
|
|
1067
1132
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
1068
|
-
},
|
|
1133
|
+
}, Cs(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1069
1134
|
}
|
|
1070
1135
|
emit(t, s) {
|
|
1071
1136
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1072
1137
|
}
|
|
1073
1138
|
}
|
|
1074
|
-
const
|
|
1075
|
-
function
|
|
1076
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1139
|
+
const K = /* @__PURE__ */ new WeakMap();
|
|
1140
|
+
function De(e) {
|
|
1141
|
+
const t = window.__plunoProductAgentNetworkCapture ?? Ne();
|
|
1077
1142
|
return t.subscribers.add(e), () => {
|
|
1078
1143
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1079
1144
|
};
|
|
1080
1145
|
}
|
|
1081
|
-
function
|
|
1082
|
-
const e = /* @__PURE__ */ new Set(), t = (
|
|
1146
|
+
function Ne() {
|
|
1147
|
+
const e = /* @__PURE__ */ new Set(), t = (l) => {
|
|
1083
1148
|
e.forEach((p) => {
|
|
1084
1149
|
try {
|
|
1085
|
-
p(
|
|
1150
|
+
p(l);
|
|
1086
1151
|
} catch {
|
|
1087
1152
|
}
|
|
1088
1153
|
});
|
|
1089
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p,
|
|
1154
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(p, u) {
|
|
1090
1155
|
const m = Date.now();
|
|
1091
1156
|
let y;
|
|
1092
1157
|
try {
|
|
1093
|
-
y = s.call(this, p,
|
|
1094
|
-
} catch (
|
|
1095
|
-
throw
|
|
1158
|
+
y = s.call(this, p, u);
|
|
1159
|
+
} catch (w) {
|
|
1160
|
+
throw w;
|
|
1096
1161
|
}
|
|
1097
1162
|
try {
|
|
1098
|
-
const
|
|
1099
|
-
if (!
|
|
1100
|
-
const
|
|
1101
|
-
requestId:
|
|
1102
|
-
url:
|
|
1103
|
-
method: (
|
|
1104
|
-
requestHeaders:
|
|
1105
|
-
requestBody:
|
|
1163
|
+
const w = p instanceof Request ? p : null, R = xs(p, w), T = xt(u?.headers ?? w?.headers);
|
|
1164
|
+
if (!b(R, T, u?.body)) {
|
|
1165
|
+
const $ = {
|
|
1166
|
+
requestId: V("fetch"),
|
|
1167
|
+
url: k(R, X),
|
|
1168
|
+
method: (u?.method ?? w?.method ?? "GET").toUpperCase(),
|
|
1169
|
+
requestHeaders: T,
|
|
1170
|
+
requestBody: Et(u?.body),
|
|
1106
1171
|
resourceType: "fetch",
|
|
1107
1172
|
startedAt: new Date(m).toISOString()
|
|
1108
1173
|
};
|
|
1109
1174
|
y.then(
|
|
1110
1175
|
(_) => {
|
|
1111
|
-
|
|
1176
|
+
Fs(_, $, m, t).catch(() => {
|
|
1112
1177
|
t({
|
|
1113
|
-
|
|
1178
|
+
...$,
|
|
1114
1179
|
responseStatus: _.status,
|
|
1115
1180
|
durationMs: Date.now() - m
|
|
1116
1181
|
});
|
|
@@ -1118,8 +1183,8 @@ function De() {
|
|
|
1118
1183
|
},
|
|
1119
1184
|
(_) => {
|
|
1120
1185
|
t({
|
|
1121
|
-
|
|
1122
|
-
errorText:
|
|
1186
|
+
...$,
|
|
1187
|
+
errorText: k(_ instanceof Error ? _.message : String(_)),
|
|
1123
1188
|
durationMs: Date.now() - m
|
|
1124
1189
|
});
|
|
1125
1190
|
}
|
|
@@ -1128,42 +1193,42 @@ function De() {
|
|
|
1128
1193
|
} catch {
|
|
1129
1194
|
}
|
|
1130
1195
|
return y;
|
|
1131
|
-
},
|
|
1132
|
-
const R = n.call(this, p,
|
|
1133
|
-
return
|
|
1134
|
-
requestId:
|
|
1196
|
+
}, c = function(p, u, m, y, w) {
|
|
1197
|
+
const R = n.call(this, p, u, m ?? !0, y ?? void 0, w ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
1198
|
+
return K.set(this, {
|
|
1199
|
+
requestId: V("xhr"),
|
|
1135
1200
|
method: String(p ?? "GET").toUpperCase(),
|
|
1136
|
-
url:
|
|
1201
|
+
url: k(T, X),
|
|
1137
1202
|
requestHeaders: {},
|
|
1138
1203
|
startedAtMs: Date.now(),
|
|
1139
1204
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1140
|
-
excluded:
|
|
1205
|
+
excluded: b(T)
|
|
1141
1206
|
}), R;
|
|
1142
|
-
}, a = function(p,
|
|
1143
|
-
const m = r.call(this, p,
|
|
1144
|
-
return y && Object.keys(y.requestHeaders).length <
|
|
1207
|
+
}, a = function(p, u) {
|
|
1208
|
+
const m = r.call(this, p, u), y = K.get(this);
|
|
1209
|
+
return y && Object.keys(y.requestHeaders).length < at && (y.requestHeaders[p] = dt(p, u), y.excluded = y.excluded || b(y.url, y.requestHeaders)), m;
|
|
1145
1210
|
}, h = function(p) {
|
|
1146
1211
|
try {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1212
|
+
const u = K.get(this);
|
|
1213
|
+
u && (u.excluded = u.excluded || b(u.url, u.requestHeaders, p), u.requestBody = Et(p), u.excluded || this.addEventListener(
|
|
1149
1214
|
"loadend",
|
|
1150
1215
|
() => {
|
|
1151
1216
|
queueMicrotask(() => {
|
|
1152
1217
|
try {
|
|
1153
|
-
const m =
|
|
1218
|
+
const m = Xs(this.getAllResponseHeaders());
|
|
1154
1219
|
t({
|
|
1155
|
-
requestId:
|
|
1156
|
-
url:
|
|
1157
|
-
method:
|
|
1158
|
-
requestHeaders:
|
|
1159
|
-
requestBody:
|
|
1220
|
+
requestId: u.requestId,
|
|
1221
|
+
url: u.url,
|
|
1222
|
+
method: u.method,
|
|
1223
|
+
requestHeaders: u.requestHeaders,
|
|
1224
|
+
requestBody: u.requestBody,
|
|
1160
1225
|
resourceType: "xhr",
|
|
1161
1226
|
responseStatus: this.status,
|
|
1162
1227
|
responseHeaders: m,
|
|
1163
|
-
responseBody:
|
|
1228
|
+
responseBody: js(this, m),
|
|
1164
1229
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1165
|
-
startedAt:
|
|
1166
|
-
durationMs: Date.now() -
|
|
1230
|
+
startedAt: u.startedAt,
|
|
1231
|
+
durationMs: Date.now() - u.startedAtMs
|
|
1167
1232
|
});
|
|
1168
1233
|
} catch {
|
|
1169
1234
|
return;
|
|
@@ -1181,7 +1246,7 @@ function De() {
|
|
|
1181
1246
|
} catch {
|
|
1182
1247
|
}
|
|
1183
1248
|
try {
|
|
1184
|
-
XMLHttpRequest.prototype.open =
|
|
1249
|
+
XMLHttpRequest.prototype.open = c;
|
|
1185
1250
|
} catch {
|
|
1186
1251
|
}
|
|
1187
1252
|
try {
|
|
@@ -1194,20 +1259,20 @@ function De() {
|
|
|
1194
1259
|
}
|
|
1195
1260
|
let g = null;
|
|
1196
1261
|
if (typeof PerformanceObserver < "u") {
|
|
1197
|
-
g = new PerformanceObserver((
|
|
1198
|
-
for (const p of
|
|
1199
|
-
const
|
|
1200
|
-
if (
|
|
1262
|
+
g = new PerformanceObserver((l) => {
|
|
1263
|
+
for (const p of l.getEntries()) {
|
|
1264
|
+
const u = p;
|
|
1265
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || b(u.name))
|
|
1201
1266
|
continue;
|
|
1202
|
-
const m = performance.timeOrigin +
|
|
1267
|
+
const m = performance.timeOrigin + u.startTime;
|
|
1203
1268
|
t({
|
|
1204
|
-
requestId:
|
|
1205
|
-
url:
|
|
1269
|
+
requestId: V("resource"),
|
|
1270
|
+
url: k(u.name, X),
|
|
1206
1271
|
method: "GET",
|
|
1207
1272
|
resourceType: "resource",
|
|
1208
|
-
responseStatus:
|
|
1273
|
+
responseStatus: u.responseStatus,
|
|
1209
1274
|
startedAt: new Date(m).toISOString(),
|
|
1210
|
-
durationMs:
|
|
1275
|
+
durationMs: u.duration
|
|
1211
1276
|
});
|
|
1212
1277
|
}
|
|
1213
1278
|
});
|
|
@@ -1217,7 +1282,7 @@ function De() {
|
|
|
1217
1282
|
g.disconnect(), g = null;
|
|
1218
1283
|
}
|
|
1219
1284
|
}
|
|
1220
|
-
const
|
|
1285
|
+
const d = {
|
|
1221
1286
|
subscribers: e,
|
|
1222
1287
|
destroy: () => {
|
|
1223
1288
|
g?.disconnect();
|
|
@@ -1226,7 +1291,7 @@ function De() {
|
|
|
1226
1291
|
} catch {
|
|
1227
1292
|
}
|
|
1228
1293
|
try {
|
|
1229
|
-
XMLHttpRequest.prototype.open ===
|
|
1294
|
+
XMLHttpRequest.prototype.open === c && (XMLHttpRequest.prototype.open = n);
|
|
1230
1295
|
} catch {
|
|
1231
1296
|
}
|
|
1232
1297
|
try {
|
|
@@ -1239,7 +1304,7 @@ function De() {
|
|
|
1239
1304
|
}
|
|
1240
1305
|
}
|
|
1241
1306
|
};
|
|
1242
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
1307
|
+
return window.__plunoProductAgentNetworkCapture = d, d;
|
|
1243
1308
|
}
|
|
1244
1309
|
function f(e, t, s) {
|
|
1245
1310
|
if (typeof window > "u")
|
|
@@ -1252,15 +1317,15 @@ function f(e, t, s) {
|
|
|
1252
1317
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1253
1318
|
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 }));
|
|
1254
1319
|
}
|
|
1255
|
-
function
|
|
1320
|
+
function yt(e) {
|
|
1256
1321
|
const t = typeof e == "function" ? e() : e;
|
|
1257
1322
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1258
1323
|
}
|
|
1259
|
-
function
|
|
1324
|
+
function Oe(e) {
|
|
1260
1325
|
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";
|
|
1261
1326
|
}
|
|
1262
|
-
const
|
|
1263
|
-
function
|
|
1327
|
+
const ve = 5e3;
|
|
1328
|
+
function Le(e) {
|
|
1264
1329
|
const t = [];
|
|
1265
1330
|
for (const s of e)
|
|
1266
1331
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1271,108 +1336,108 @@ function ve(e) {
|
|
|
1271
1336
|
});
|
|
1272
1337
|
return t;
|
|
1273
1338
|
}
|
|
1274
|
-
function
|
|
1275
|
-
const n = new Map(e.map((
|
|
1276
|
-
id:
|
|
1277
|
-
name:
|
|
1278
|
-
mimeType:
|
|
1279
|
-
sizeBytes:
|
|
1280
|
-
type:
|
|
1281
|
-
size:
|
|
1282
|
-
}), i = (
|
|
1283
|
-
const
|
|
1284
|
-
if (!
|
|
1285
|
-
throw new Error(`Unknown Pluno user file: ${
|
|
1286
|
-
return
|
|
1287
|
-
}, o = async (
|
|
1288
|
-
const
|
|
1339
|
+
function Be(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1340
|
+
const n = new Map(e.map((d) => [d.id, d])), r = (d) => ({
|
|
1341
|
+
id: d.id,
|
|
1342
|
+
name: d.name,
|
|
1343
|
+
mimeType: d.mimeType,
|
|
1344
|
+
sizeBytes: d.sizeBytes,
|
|
1345
|
+
type: d.mimeType,
|
|
1346
|
+
size: d.sizeBytes
|
|
1347
|
+
}), i = (d) => {
|
|
1348
|
+
const l = n.get(d);
|
|
1349
|
+
if (!l)
|
|
1350
|
+
throw new Error(`Unknown Pluno user file: ${d}`);
|
|
1351
|
+
return l;
|
|
1352
|
+
}, o = async (d) => {
|
|
1353
|
+
const l = i(d), p = t.get(l.id);
|
|
1289
1354
|
if (p)
|
|
1290
1355
|
return p;
|
|
1291
|
-
const
|
|
1292
|
-
if (
|
|
1293
|
-
return
|
|
1294
|
-
const m = await
|
|
1295
|
-
attachmentId:
|
|
1296
|
-
name:
|
|
1297
|
-
message:
|
|
1356
|
+
const u = s.get(l.id);
|
|
1357
|
+
if (u)
|
|
1358
|
+
return u;
|
|
1359
|
+
const m = await Jt(l.id).then((T) => T?.blob ?? null).catch((T) => (f("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
1360
|
+
attachmentId: l.id,
|
|
1361
|
+
name: l.name,
|
|
1362
|
+
message: T instanceof Error ? T.message : String(T)
|
|
1298
1363
|
}), null));
|
|
1299
1364
|
if (m)
|
|
1300
|
-
return s.set(
|
|
1301
|
-
if (!
|
|
1302
|
-
throw new Error(`Pluno user file is missing content: ${
|
|
1303
|
-
const y = await fetch(
|
|
1365
|
+
return s.set(l.id, m), m;
|
|
1366
|
+
if (!l.fileUrl)
|
|
1367
|
+
throw new Error(`Pluno user file is missing content: ${d}`);
|
|
1368
|
+
const y = await fetch(l.fileUrl, Os(l.fileUrl));
|
|
1304
1369
|
if (!y.ok)
|
|
1305
|
-
throw new Error(`Failed to load Pluno user file: ${
|
|
1306
|
-
const
|
|
1307
|
-
s.set(
|
|
1370
|
+
throw new Error(`Failed to load Pluno user file: ${d}`);
|
|
1371
|
+
const w = await y.blob();
|
|
1372
|
+
s.set(l.id, w);
|
|
1308
1373
|
const R = Date.now();
|
|
1309
|
-
return
|
|
1310
|
-
attachmentId:
|
|
1311
|
-
name:
|
|
1312
|
-
mimeType:
|
|
1313
|
-
sizeBytes:
|
|
1314
|
-
blob:
|
|
1315
|
-
fileUrl:
|
|
1316
|
-
gcsPath:
|
|
1374
|
+
return _t({
|
|
1375
|
+
attachmentId: l.id,
|
|
1376
|
+
name: l.name,
|
|
1377
|
+
mimeType: l.mimeType,
|
|
1378
|
+
sizeBytes: l.sizeBytes,
|
|
1379
|
+
blob: w,
|
|
1380
|
+
fileUrl: l.fileUrl,
|
|
1381
|
+
gcsPath: l.gcsPath,
|
|
1317
1382
|
createdAt: R,
|
|
1318
1383
|
lastUsedAt: R
|
|
1319
|
-
}).catch((
|
|
1384
|
+
}).catch((T) => {
|
|
1320
1385
|
f("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
|
|
1321
|
-
attachmentId:
|
|
1322
|
-
name:
|
|
1323
|
-
message:
|
|
1386
|
+
attachmentId: l.id,
|
|
1387
|
+
name: l.name,
|
|
1388
|
+
message: T instanceof Error ? T.message : String(T)
|
|
1324
1389
|
});
|
|
1325
|
-
}),
|
|
1326
|
-
},
|
|
1327
|
-
const
|
|
1328
|
-
if (!
|
|
1329
|
-
throw new Error(`Pluno user file is not an image: ${
|
|
1330
|
-
const m = p.type ===
|
|
1331
|
-
return
|
|
1390
|
+
}), w;
|
|
1391
|
+
}, c = async (d) => {
|
|
1392
|
+
const l = i(d), p = await o(d), u = l.mimeType.startsWith("image/") ? l.mimeType : p.type || l.mimeType;
|
|
1393
|
+
if (!u.startsWith("image/"))
|
|
1394
|
+
throw new Error(`Pluno user file is not an image: ${d}`);
|
|
1395
|
+
const m = p.type === u ? p : new Blob([p], { type: u });
|
|
1396
|
+
return He(u, m.size) > _e ? {
|
|
1332
1397
|
type: "pluno.userFiles.inspectImage",
|
|
1333
|
-
id:
|
|
1334
|
-
name:
|
|
1335
|
-
mimeType:
|
|
1336
|
-
sizeBytes:
|
|
1398
|
+
id: l.id,
|
|
1399
|
+
name: l.name,
|
|
1400
|
+
mimeType: u,
|
|
1401
|
+
sizeBytes: l.sizeBytes,
|
|
1337
1402
|
imageAttached: !1,
|
|
1338
|
-
imageAttachmentError:
|
|
1403
|
+
imageAttachmentError: Ce
|
|
1339
1404
|
} : {
|
|
1340
1405
|
type: "pluno.userFiles.inspectImage",
|
|
1341
|
-
id:
|
|
1342
|
-
name:
|
|
1343
|
-
mimeType:
|
|
1344
|
-
sizeBytes:
|
|
1406
|
+
id: l.id,
|
|
1407
|
+
name: l.name,
|
|
1408
|
+
mimeType: u,
|
|
1409
|
+
sizeBytes: l.sizeBytes,
|
|
1345
1410
|
imageAttached: !0,
|
|
1346
|
-
dataUrl: await
|
|
1411
|
+
dataUrl: await Tt(m)
|
|
1347
1412
|
};
|
|
1348
1413
|
}, a = globalThis, h = a.pluno?.userFiles, g = Object.prototype.hasOwnProperty.call(a.pluno ?? {}, "userFiles");
|
|
1349
1414
|
return a.pluno = {
|
|
1350
1415
|
...a.pluno ?? {},
|
|
1351
1416
|
userFiles: {
|
|
1352
1417
|
list: () => e.map(r),
|
|
1353
|
-
get: (
|
|
1354
|
-
const
|
|
1355
|
-
return
|
|
1418
|
+
get: (d) => {
|
|
1419
|
+
const l = n.get(d);
|
|
1420
|
+
return l ? r(l) : null;
|
|
1356
1421
|
},
|
|
1357
|
-
inspectImage:
|
|
1358
|
-
getDataUrl: async (
|
|
1422
|
+
inspectImage: c,
|
|
1423
|
+
getDataUrl: async (d) => (i(d), await Tt(await o(d))),
|
|
1359
1424
|
getBlob: o,
|
|
1360
|
-
getArrayBuffer: async (
|
|
1361
|
-
getFile: async (
|
|
1362
|
-
const
|
|
1363
|
-
return new File([await o(
|
|
1425
|
+
getArrayBuffer: async (d) => await (await o(d)).arrayBuffer(),
|
|
1426
|
+
getFile: async (d) => {
|
|
1427
|
+
const l = i(d);
|
|
1428
|
+
return new File([await o(d)], l.name, { type: l.mimeType });
|
|
1364
1429
|
}
|
|
1365
1430
|
}
|
|
1366
1431
|
}, () => {
|
|
1367
|
-
const
|
|
1432
|
+
const d = a.pluno ?? {};
|
|
1368
1433
|
if (g) {
|
|
1369
1434
|
a.pluno = {
|
|
1370
|
-
...
|
|
1435
|
+
...d,
|
|
1371
1436
|
userFiles: h
|
|
1372
1437
|
};
|
|
1373
1438
|
return;
|
|
1374
1439
|
}
|
|
1375
|
-
const { userFiles:
|
|
1440
|
+
const { userFiles: l, ...p } = d;
|
|
1376
1441
|
a.pluno = p;
|
|
1377
1442
|
};
|
|
1378
1443
|
}
|
|
@@ -1382,7 +1447,7 @@ function qe(e) {
|
|
|
1382
1447
|
} catch {
|
|
1383
1448
|
}
|
|
1384
1449
|
}
|
|
1385
|
-
function
|
|
1450
|
+
function Tt(e) {
|
|
1386
1451
|
return new Promise((t, s) => {
|
|
1387
1452
|
const n = new FileReader();
|
|
1388
1453
|
n.onload = () => {
|
|
@@ -1394,22 +1459,22 @@ function ft(e) {
|
|
|
1394
1459
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1395
1460
|
});
|
|
1396
1461
|
}
|
|
1397
|
-
function
|
|
1462
|
+
function He(e, t) {
|
|
1398
1463
|
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1399
1464
|
}
|
|
1400
|
-
async function
|
|
1465
|
+
async function wt(e) {
|
|
1401
1466
|
const t = Object.getPrototypeOf(async function() {
|
|
1402
|
-
}).constructor, s = e.timeoutMs ??
|
|
1467
|
+
}).constructor, s = e.timeoutMs ?? ve, n = Date.now(), r = [];
|
|
1403
1468
|
let i;
|
|
1404
1469
|
const o = {
|
|
1405
1470
|
log: console.log,
|
|
1406
1471
|
info: console.info,
|
|
1407
1472
|
warn: console.warn,
|
|
1408
1473
|
error: console.error
|
|
1409
|
-
},
|
|
1474
|
+
}, c = (a) => (...h) => {
|
|
1410
1475
|
r.push({ level: a, args: h }), o[a](...h);
|
|
1411
1476
|
};
|
|
1412
|
-
console.log =
|
|
1477
|
+
console.log = c("log"), console.info = c("info"), console.warn = c("warn"), console.error = c("error");
|
|
1413
1478
|
try {
|
|
1414
1479
|
const a = /* @__PURE__ */ Symbol("execute_code_timeout"), h = await Promise.race([
|
|
1415
1480
|
new t(e.javascript)(),
|
|
@@ -1417,7 +1482,7 @@ async function mt(e) {
|
|
|
1417
1482
|
i = window.setTimeout(() => g(a), s);
|
|
1418
1483
|
})
|
|
1419
1484
|
]);
|
|
1420
|
-
return h === a ?
|
|
1485
|
+
return h === a ? xe(s) : {
|
|
1421
1486
|
ok: !0,
|
|
1422
1487
|
result: h,
|
|
1423
1488
|
console: r,
|
|
@@ -1446,7 +1511,7 @@ async function mt(e) {
|
|
|
1446
1511
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1447
1512
|
}
|
|
1448
1513
|
}
|
|
1449
|
-
function
|
|
1514
|
+
function xe(e) {
|
|
1450
1515
|
return {
|
|
1451
1516
|
ok: !1,
|
|
1452
1517
|
exception: {
|
|
@@ -1466,12 +1531,12 @@ function Fe(e) {
|
|
|
1466
1531
|
function We(e, t = location.origin) {
|
|
1467
1532
|
return /origin (?:is not allowed|does not match browser origin)/i.test(e) ? `Pluno widget blocked on ${t}: this domain is not allowed. Add ${t} in Pluno under Integration > Domains.` : null;
|
|
1468
1533
|
}
|
|
1469
|
-
function
|
|
1534
|
+
function je(e) {
|
|
1470
1535
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1471
1536
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1472
1537
|
}
|
|
1473
|
-
function
|
|
1474
|
-
const e =
|
|
1538
|
+
function A() {
|
|
1539
|
+
const e = Dt();
|
|
1475
1540
|
return {
|
|
1476
1541
|
url: location.href,
|
|
1477
1542
|
title: document.title,
|
|
@@ -1479,21 +1544,21 @@ function I() {
|
|
|
1479
1544
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1480
1545
|
};
|
|
1481
1546
|
}
|
|
1482
|
-
function
|
|
1547
|
+
function $e() {
|
|
1483
1548
|
return {
|
|
1484
1549
|
pageUrl: location.href,
|
|
1485
1550
|
pageTitle: document.title,
|
|
1486
|
-
htmlContent:
|
|
1551
|
+
htmlContent: Ke()
|
|
1487
1552
|
};
|
|
1488
1553
|
}
|
|
1489
|
-
function
|
|
1490
|
-
return
|
|
1491
|
-
|
|
1554
|
+
function ze(e) {
|
|
1555
|
+
return L.add(e), N || (N = Ge()), () => {
|
|
1556
|
+
L.delete(e), L.size === 0 && (N?.(), N = null);
|
|
1492
1557
|
};
|
|
1493
1558
|
}
|
|
1494
|
-
function
|
|
1559
|
+
function Ge() {
|
|
1495
1560
|
const e = () => {
|
|
1496
|
-
for (const i of Array.from(
|
|
1561
|
+
for (const i of Array.from(L))
|
|
1497
1562
|
i();
|
|
1498
1563
|
}, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
1499
1564
|
const o = t(...i);
|
|
@@ -1506,10 +1571,10 @@ function ze() {
|
|
|
1506
1571
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1507
1572
|
};
|
|
1508
1573
|
}
|
|
1509
|
-
function Ge() {
|
|
1510
|
-
return bt()?.surface === "browser_extension_sdk_preview";
|
|
1511
|
-
}
|
|
1512
1574
|
function Xe() {
|
|
1575
|
+
return Dt()?.surface === "browser_extension_sdk_preview";
|
|
1576
|
+
}
|
|
1577
|
+
function Ke() {
|
|
1513
1578
|
const e = document.body?.cloneNode(!0);
|
|
1514
1579
|
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
1515
1580
|
[
|
|
@@ -1533,9 +1598,9 @@ function Xe() {
|
|
|
1533
1598
|
s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
|
|
1534
1599
|
}), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
|
|
1535
1600
|
}
|
|
1536
|
-
function
|
|
1537
|
-
const e = document.querySelector(
|
|
1538
|
-
if (!(e ?? document.querySelector(
|
|
1601
|
+
function Dt() {
|
|
1602
|
+
const e = document.querySelector(ht);
|
|
1603
|
+
if (!(e ?? document.querySelector(Q)))
|
|
1539
1604
|
return;
|
|
1540
1605
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
1541
1606
|
return {
|
|
@@ -1544,28 +1609,28 @@ function bt() {
|
|
|
1544
1609
|
selectors: [
|
|
1545
1610
|
{
|
|
1546
1611
|
name: "widget_host",
|
|
1547
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
1612
|
+
selector: s === "browser_extension_sdk_preview" ? ht : Q,
|
|
1548
1613
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
1549
1614
|
},
|
|
1550
1615
|
{
|
|
1551
1616
|
name: "widget_root",
|
|
1552
|
-
selector:
|
|
1617
|
+
selector: ie,
|
|
1553
1618
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
1554
1619
|
},
|
|
1555
1620
|
{
|
|
1556
1621
|
name: "widget_panel",
|
|
1557
|
-
selector:
|
|
1622
|
+
selector: oe,
|
|
1558
1623
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
1559
1624
|
},
|
|
1560
1625
|
{
|
|
1561
1626
|
name: "widget_timeline",
|
|
1562
|
-
selector:
|
|
1627
|
+
selector: ae,
|
|
1563
1628
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
1564
1629
|
}
|
|
1565
1630
|
]
|
|
1566
1631
|
};
|
|
1567
1632
|
}
|
|
1568
|
-
function
|
|
1633
|
+
function Je(e) {
|
|
1569
1634
|
try {
|
|
1570
1635
|
const t = JSON.parse(e);
|
|
1571
1636
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -1573,33 +1638,33 @@ function Ke(e) {
|
|
|
1573
1638
|
return { type: "error", message: "Invalid server event" };
|
|
1574
1639
|
}
|
|
1575
1640
|
}
|
|
1576
|
-
function
|
|
1641
|
+
function It(e, t) {
|
|
1577
1642
|
if (!e || typeof e != "object")
|
|
1578
1643
|
return [];
|
|
1579
1644
|
const s = e[t];
|
|
1580
1645
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
1581
1646
|
}
|
|
1582
|
-
function
|
|
1647
|
+
function Ve(e) {
|
|
1583
1648
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
1584
1649
|
}
|
|
1585
|
-
function
|
|
1650
|
+
function Ye(e) {
|
|
1586
1651
|
if (!e || typeof e != "object")
|
|
1587
1652
|
return null;
|
|
1588
|
-
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,
|
|
1589
|
-
return !r && !i && !o &&
|
|
1653
|
+
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;
|
|
1654
|
+
return !r && !i && !o && c === null ? null : {
|
|
1590
1655
|
...r ? { accentColor: r } : {},
|
|
1591
1656
|
...i ? { colorScheme: i } : {},
|
|
1592
1657
|
...o ? { fontFamily: o } : {},
|
|
1593
|
-
...
|
|
1658
|
+
...c !== null ? { scribbleStyle: c } : {}
|
|
1594
1659
|
};
|
|
1595
1660
|
}
|
|
1596
|
-
function
|
|
1661
|
+
function Ze(e) {
|
|
1597
1662
|
if (!e || typeof e != "object")
|
|
1598
1663
|
return null;
|
|
1599
1664
|
const t = e.javascript;
|
|
1600
1665
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
1601
1666
|
}
|
|
1602
|
-
function
|
|
1667
|
+
function Qe(e, t) {
|
|
1603
1668
|
return t ? e && typeof e == "object" ? {
|
|
1604
1669
|
...e,
|
|
1605
1670
|
helperError: t
|
|
@@ -1609,23 +1674,23 @@ function Ze(e, t) {
|
|
|
1609
1674
|
helperError: t
|
|
1610
1675
|
} : e;
|
|
1611
1676
|
}
|
|
1612
|
-
function
|
|
1677
|
+
function ts(e) {
|
|
1613
1678
|
if (!e || typeof e != "object")
|
|
1614
1679
|
return e;
|
|
1615
1680
|
const t = e;
|
|
1616
1681
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
1617
1682
|
}
|
|
1618
|
-
function
|
|
1683
|
+
function es() {
|
|
1619
1684
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
1620
1685
|
if (t)
|
|
1621
1686
|
return t;
|
|
1622
1687
|
const s = crypto.randomUUID();
|
|
1623
1688
|
return window.localStorage.setItem(e, s), s;
|
|
1624
1689
|
}
|
|
1625
|
-
function
|
|
1690
|
+
function O() {
|
|
1626
1691
|
return crypto.randomUUID();
|
|
1627
1692
|
}
|
|
1628
|
-
function
|
|
1693
|
+
function ss(e) {
|
|
1629
1694
|
if (!e || typeof e != "object")
|
|
1630
1695
|
return null;
|
|
1631
1696
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -1636,23 +1701,23 @@ function es(e) {
|
|
|
1636
1701
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
1637
1702
|
} : null;
|
|
1638
1703
|
}
|
|
1639
|
-
function
|
|
1640
|
-
return Array.isArray(e) ?
|
|
1641
|
-
|
|
1642
|
-
e.map((s) =>
|
|
1704
|
+
function ns(e, t) {
|
|
1705
|
+
return Array.isArray(e) ? st(
|
|
1706
|
+
nt(
|
|
1707
|
+
e.map((s) => Nt(s, t)).filter((s) => s !== null)
|
|
1643
1708
|
)
|
|
1644
1709
|
) : [];
|
|
1645
1710
|
}
|
|
1646
|
-
function
|
|
1711
|
+
function rs(e) {
|
|
1647
1712
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
1648
1713
|
if (!t || typeof t != "object")
|
|
1649
1714
|
return [];
|
|
1650
|
-
const s = t, n =
|
|
1715
|
+
const s = t, n = S(s, "id"), r = S(s, "createdAt"), i = S(s, "updatedAt"), o = S(s, "lastActiveAt");
|
|
1651
1716
|
return !n || !r || !i || !o ? [] : [
|
|
1652
1717
|
{
|
|
1653
1718
|
id: n,
|
|
1654
|
-
title:
|
|
1655
|
-
firstUserMessage:
|
|
1719
|
+
title: S(s, "title"),
|
|
1720
|
+
firstUserMessage: S(s, "firstUserMessage"),
|
|
1656
1721
|
currentPage: s.currentPage ?? null,
|
|
1657
1722
|
createdAt: r,
|
|
1658
1723
|
updatedAt: i,
|
|
@@ -1661,7 +1726,7 @@ function ns(e) {
|
|
|
1661
1726
|
];
|
|
1662
1727
|
}) : [];
|
|
1663
1728
|
}
|
|
1664
|
-
function
|
|
1729
|
+
function Nt(e, t) {
|
|
1665
1730
|
if (!e || typeof e != "object")
|
|
1666
1731
|
return null;
|
|
1667
1732
|
const s = e, n = s.data;
|
|
@@ -1673,9 +1738,9 @@ function Ut(e, t) {
|
|
|
1673
1738
|
return {
|
|
1674
1739
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1675
1740
|
role: i,
|
|
1676
|
-
content:
|
|
1741
|
+
content: ls(r.content),
|
|
1677
1742
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1678
|
-
respondsToUserMessageId:
|
|
1743
|
+
respondsToUserMessageId: J(r) ?? void 0,
|
|
1679
1744
|
...C(r) ? { runId: C(r) } : {},
|
|
1680
1745
|
attachments: qt(r.attachments, t)
|
|
1681
1746
|
};
|
|
@@ -1683,29 +1748,29 @@ function Ut(e, t) {
|
|
|
1683
1748
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" ? {
|
|
1684
1749
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1685
1750
|
role: "tool",
|
|
1686
|
-
content:
|
|
1751
|
+
content: os(r),
|
|
1687
1752
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1688
|
-
respondsToUserMessageId:
|
|
1753
|
+
respondsToUserMessageId: J(r) ?? void 0,
|
|
1689
1754
|
...C(r) ? { runId: C(r) } : {},
|
|
1690
1755
|
dataType: String(r.type),
|
|
1691
1756
|
toolName: typeof r.name == "string" ? r.name : void 0,
|
|
1692
|
-
callId:
|
|
1757
|
+
callId: cs(r) ?? void 0,
|
|
1693
1758
|
loading: r.localExecutionStatus === "running"
|
|
1694
1759
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
1695
1760
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1696
1761
|
role: "system",
|
|
1697
|
-
content:
|
|
1762
|
+
content: is(r),
|
|
1698
1763
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1699
|
-
respondsToUserMessageId:
|
|
1764
|
+
respondsToUserMessageId: J(r) ?? void 0,
|
|
1700
1765
|
...C(r) ? { runId: C(r) } : {},
|
|
1701
1766
|
dataType: String(r.type),
|
|
1702
1767
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying")
|
|
1703
1768
|
} : null;
|
|
1704
1769
|
}
|
|
1705
|
-
function
|
|
1770
|
+
function is(e) {
|
|
1706
1771
|
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.";
|
|
1707
1772
|
}
|
|
1708
|
-
function
|
|
1773
|
+
function os(e) {
|
|
1709
1774
|
if (e.type === "web_search_call") {
|
|
1710
1775
|
const t = e.action;
|
|
1711
1776
|
if (t && typeof t == "object") {
|
|
@@ -1717,9 +1782,9 @@ function is(e) {
|
|
|
1717
1782
|
}
|
|
1718
1783
|
return "Searching the web";
|
|
1719
1784
|
}
|
|
1720
|
-
return
|
|
1785
|
+
return as(e);
|
|
1721
1786
|
}
|
|
1722
|
-
function
|
|
1787
|
+
function as(e) {
|
|
1723
1788
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
1724
1789
|
return e.summary;
|
|
1725
1790
|
if (typeof e.arguments == "string")
|
|
@@ -1732,11 +1797,11 @@ function os(e) {
|
|
|
1732
1797
|
}
|
|
1733
1798
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
1734
1799
|
}
|
|
1735
|
-
function
|
|
1800
|
+
function cs(e) {
|
|
1736
1801
|
const t = e.callId ?? e.call_id;
|
|
1737
1802
|
return typeof t == "string" && t ? t : null;
|
|
1738
1803
|
}
|
|
1739
|
-
function
|
|
1804
|
+
function ls(e) {
|
|
1740
1805
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
1741
1806
|
if (!t || typeof t != "object")
|
|
1742
1807
|
return "";
|
|
@@ -1744,19 +1809,19 @@ function cs(e) {
|
|
|
1744
1809
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
1745
1810
|
}).filter(Boolean).join("") : "";
|
|
1746
1811
|
}
|
|
1747
|
-
function
|
|
1748
|
-
const s =
|
|
1812
|
+
function us(e, t) {
|
|
1813
|
+
const s = Ot(e, t), n = gs(e, t), r = n.findIndex((o) => o.id === s.id);
|
|
1749
1814
|
if (r === -1)
|
|
1750
|
-
return
|
|
1751
|
-
|
|
1815
|
+
return st(
|
|
1816
|
+
nt([...n, s])
|
|
1752
1817
|
);
|
|
1753
1818
|
const i = [...n];
|
|
1754
|
-
return i[r] = s,
|
|
1819
|
+
return i[r] = s, st(nt(i));
|
|
1755
1820
|
}
|
|
1756
|
-
function
|
|
1757
|
-
return t.map((s) =>
|
|
1821
|
+
function ds(e, t) {
|
|
1822
|
+
return t.map((s) => Ot(e, s));
|
|
1758
1823
|
}
|
|
1759
|
-
function
|
|
1824
|
+
function Ot(e, t) {
|
|
1760
1825
|
if (t.role !== "user" || !t.attachments?.length)
|
|
1761
1826
|
return t;
|
|
1762
1827
|
const s = e.find(
|
|
@@ -1765,19 +1830,19 @@ function Mt(e, t) {
|
|
|
1765
1830
|
if (!s?.attachments?.length)
|
|
1766
1831
|
return t;
|
|
1767
1832
|
const n = t.attachments.map((r) => {
|
|
1768
|
-
const i =
|
|
1769
|
-
return i ?
|
|
1833
|
+
const i = hs(s.attachments ?? [], r);
|
|
1834
|
+
return i ? ps(r, i) : r;
|
|
1770
1835
|
});
|
|
1771
1836
|
return { ...t, attachments: n };
|
|
1772
1837
|
}
|
|
1773
|
-
function
|
|
1838
|
+
function hs(e, t) {
|
|
1774
1839
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
1775
1840
|
}
|
|
1776
|
-
function
|
|
1841
|
+
function ps(e, t) {
|
|
1777
1842
|
const { previewUrl: s } = t;
|
|
1778
1843
|
return s ? { ...e, previewUrl: s } : e;
|
|
1779
1844
|
}
|
|
1780
|
-
function
|
|
1845
|
+
function gs(e, t) {
|
|
1781
1846
|
if (t.role !== "user")
|
|
1782
1847
|
return e;
|
|
1783
1848
|
const s = e.findIndex(
|
|
@@ -1788,24 +1853,37 @@ function ps(e, t) {
|
|
|
1788
1853
|
const n = [...e];
|
|
1789
1854
|
return n.splice(s, 1), n;
|
|
1790
1855
|
}
|
|
1791
|
-
function
|
|
1792
|
-
const t =
|
|
1793
|
-
|
|
1856
|
+
function At(e) {
|
|
1857
|
+
const t = vt(e);
|
|
1858
|
+
if (t === null)
|
|
1859
|
+
return !1;
|
|
1860
|
+
for (let s = e.length - 1; s > t; s -= 1) {
|
|
1861
|
+
const n = e[s];
|
|
1862
|
+
if (n.role === "assistant")
|
|
1863
|
+
return !0;
|
|
1864
|
+
if (n.role === "system") {
|
|
1865
|
+
if (n.dataType === "run_error")
|
|
1866
|
+
return !0;
|
|
1867
|
+
if (n.dataType === "run_status")
|
|
1868
|
+
return n.loading !== !0;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
return !1;
|
|
1794
1872
|
}
|
|
1795
|
-
function
|
|
1796
|
-
const t =
|
|
1873
|
+
function fs(e) {
|
|
1874
|
+
const t = vt(e);
|
|
1797
1875
|
return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
|
|
1798
1876
|
}
|
|
1799
|
-
function
|
|
1877
|
+
function vt(e) {
|
|
1800
1878
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
1801
1879
|
if (e[t].role === "user")
|
|
1802
1880
|
return t;
|
|
1803
1881
|
return null;
|
|
1804
1882
|
}
|
|
1805
|
-
function
|
|
1883
|
+
function ms(e) {
|
|
1806
1884
|
return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
1807
1885
|
}
|
|
1808
|
-
function
|
|
1886
|
+
function ct(e) {
|
|
1809
1887
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
1810
1888
|
const s = e[t];
|
|
1811
1889
|
if (!s || typeof s != "object")
|
|
@@ -1819,18 +1897,18 @@ function Ot(e) {
|
|
|
1819
1897
|
}
|
|
1820
1898
|
return null;
|
|
1821
1899
|
}
|
|
1822
|
-
function
|
|
1823
|
-
const s =
|
|
1900
|
+
function ys(e, t) {
|
|
1901
|
+
const s = ct(t);
|
|
1824
1902
|
if (s === null)
|
|
1825
1903
|
return !1;
|
|
1826
1904
|
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
1827
1905
|
if (typeof r != "string" || !r)
|
|
1828
1906
|
return !1;
|
|
1829
1907
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
1830
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
1908
|
+
return i === -1 ? !1 : e.slice(i + 1).some(ms);
|
|
1831
1909
|
}
|
|
1832
|
-
function
|
|
1833
|
-
const t =
|
|
1910
|
+
function et(e) {
|
|
1911
|
+
const t = ct(e);
|
|
1834
1912
|
if (t === null)
|
|
1835
1913
|
return null;
|
|
1836
1914
|
const s = e[t];
|
|
@@ -1842,22 +1920,56 @@ function ms(e) {
|
|
|
1842
1920
|
const r = n.clientMessageId;
|
|
1843
1921
|
return typeof r == "string" ? r : null;
|
|
1844
1922
|
}
|
|
1845
|
-
function
|
|
1923
|
+
function Ts(e) {
|
|
1924
|
+
const t = ct(e);
|
|
1925
|
+
if (t === null)
|
|
1926
|
+
return null;
|
|
1927
|
+
for (let s = e.length - 1; s > t; s -= 1) {
|
|
1928
|
+
const n = e[s];
|
|
1929
|
+
if (!n || typeof n != "object")
|
|
1930
|
+
continue;
|
|
1931
|
+
const r = n.data;
|
|
1932
|
+
if (!r || typeof r != "object")
|
|
1933
|
+
continue;
|
|
1934
|
+
const i = r;
|
|
1935
|
+
if (i.type === "message" && i.role === "assistant")
|
|
1936
|
+
return null;
|
|
1937
|
+
if (i.type === "run_error")
|
|
1938
|
+
return i.retryable !== !0 ? null : typeof i.clientMessageId == "string" ? i.clientMessageId : et(e);
|
|
1939
|
+
if (i.type === "run_status")
|
|
1940
|
+
return i.status === "interrupted" && i.retryable === !0 ? et(e) : null;
|
|
1941
|
+
}
|
|
1942
|
+
return null;
|
|
1943
|
+
}
|
|
1944
|
+
function ws(e, t) {
|
|
1945
|
+
let s = 0;
|
|
1946
|
+
for (const n of e) {
|
|
1947
|
+
if (!n || typeof n != "object")
|
|
1948
|
+
continue;
|
|
1949
|
+
const r = n.data;
|
|
1950
|
+
if (!r || typeof r != "object")
|
|
1951
|
+
continue;
|
|
1952
|
+
const i = r;
|
|
1953
|
+
i.type === "run_status" && i.clientMessageId === t && typeof i.automaticRecoveryAttempts == "number" && Number.isInteger(i.automaticRecoveryAttempts) && i.automaticRecoveryAttempts >= 0 && (s = Math.max(s, i.automaticRecoveryAttempts));
|
|
1954
|
+
}
|
|
1955
|
+
return s;
|
|
1956
|
+
}
|
|
1957
|
+
function Is(e) {
|
|
1846
1958
|
if (!e || typeof e != "object")
|
|
1847
1959
|
return !1;
|
|
1848
1960
|
const t = e;
|
|
1849
1961
|
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";
|
|
1850
1962
|
}
|
|
1851
|
-
function
|
|
1852
|
-
return e.filter((t, s) =>
|
|
1963
|
+
function st(e) {
|
|
1964
|
+
return e.filter((t, s) => Lt(t) ? !Rs(e, s) && !ks(e, s) && !Es(e, s) : As(t) ? !Ss(e, s) : !0);
|
|
1853
1965
|
}
|
|
1854
|
-
function
|
|
1966
|
+
function As(e) {
|
|
1855
1967
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
1856
1968
|
}
|
|
1857
|
-
function
|
|
1969
|
+
function Lt(e) {
|
|
1858
1970
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
1859
1971
|
}
|
|
1860
|
-
function
|
|
1972
|
+
function nt(e) {
|
|
1861
1973
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
1862
1974
|
for (const i of e) {
|
|
1863
1975
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -1873,7 +1985,7 @@ function et(e) {
|
|
|
1873
1985
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
1874
1986
|
return r;
|
|
1875
1987
|
}
|
|
1876
|
-
function
|
|
1988
|
+
function Ss(e, t) {
|
|
1877
1989
|
const s = e[t];
|
|
1878
1990
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
1879
1991
|
const r = e[n];
|
|
@@ -1884,42 +1996,42 @@ function Ts(e, t) {
|
|
|
1884
1996
|
}
|
|
1885
1997
|
return !1;
|
|
1886
1998
|
}
|
|
1887
|
-
function
|
|
1999
|
+
function ks(e, t) {
|
|
1888
2000
|
const s = e[t];
|
|
1889
2001
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1890
2002
|
if (e[n].role === "assistant" && W(s, e[n]))
|
|
1891
2003
|
return !0;
|
|
1892
2004
|
return !1;
|
|
1893
2005
|
}
|
|
1894
|
-
function
|
|
2006
|
+
function Es(e, t) {
|
|
1895
2007
|
const s = e[t];
|
|
1896
2008
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1897
2009
|
if (e[n].role === "tool" && W(s, e[n]))
|
|
1898
2010
|
return !0;
|
|
1899
2011
|
return !1;
|
|
1900
2012
|
}
|
|
1901
|
-
function
|
|
2013
|
+
function Rs(e, t) {
|
|
1902
2014
|
const s = e[t];
|
|
1903
2015
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1904
|
-
if (
|
|
2016
|
+
if (Lt(e[n]) && W(s, e[n]))
|
|
1905
2017
|
return !0;
|
|
1906
2018
|
return !1;
|
|
1907
2019
|
}
|
|
1908
2020
|
function W(e, t) {
|
|
1909
2021
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
1910
2022
|
}
|
|
1911
|
-
function
|
|
2023
|
+
function S(e, t) {
|
|
1912
2024
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
1913
2025
|
}
|
|
1914
|
-
function
|
|
2026
|
+
function _s(e, t) {
|
|
1915
2027
|
try {
|
|
1916
|
-
const s = window.localStorage.getItem(`${
|
|
2028
|
+
const s = window.localStorage.getItem(`${Pt}${e}`);
|
|
1917
2029
|
if (!s)
|
|
1918
2030
|
return null;
|
|
1919
2031
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
1920
2032
|
if (t !== void 0 && r !== t)
|
|
1921
2033
|
return null;
|
|
1922
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2034
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Bs).filter((o) => !!o) : [];
|
|
1923
2035
|
return {
|
|
1924
2036
|
sessionId: r,
|
|
1925
2037
|
messages: i
|
|
@@ -1928,46 +2040,46 @@ function ks(e, t) {
|
|
|
1928
2040
|
return null;
|
|
1929
2041
|
}
|
|
1930
2042
|
}
|
|
1931
|
-
function
|
|
2043
|
+
function Cs(e, t) {
|
|
1932
2044
|
try {
|
|
1933
2045
|
window.localStorage.setItem(
|
|
1934
|
-
`${
|
|
2046
|
+
`${Pt}${e}`,
|
|
1935
2047
|
JSON.stringify({
|
|
1936
2048
|
sessionId: t.sessionId,
|
|
1937
|
-
messages: t.messages.slice(-
|
|
2049
|
+
messages: t.messages.slice(-be).map(qs)
|
|
1938
2050
|
})
|
|
1939
2051
|
);
|
|
1940
2052
|
} catch {
|
|
1941
2053
|
return;
|
|
1942
2054
|
}
|
|
1943
2055
|
}
|
|
1944
|
-
function
|
|
2056
|
+
function bs(e) {
|
|
1945
2057
|
try {
|
|
1946
|
-
const t = window.localStorage.getItem(`${
|
|
2058
|
+
const t = window.localStorage.getItem(`${tt}${e}`);
|
|
1947
2059
|
if (!t)
|
|
1948
2060
|
return [];
|
|
1949
2061
|
const s = JSON.parse(t);
|
|
1950
|
-
return Array.isArray(s) ? s.filter(
|
|
2062
|
+
return Array.isArray(s) ? s.filter(lt) : [];
|
|
1951
2063
|
} catch {
|
|
1952
2064
|
return [];
|
|
1953
2065
|
}
|
|
1954
2066
|
}
|
|
1955
|
-
function
|
|
2067
|
+
function P(e, t) {
|
|
1956
2068
|
try {
|
|
1957
|
-
const s = t.filter(
|
|
2069
|
+
const s = t.filter(lt);
|
|
1958
2070
|
if (s.length === 0) {
|
|
1959
|
-
window.localStorage.removeItem(`${
|
|
2071
|
+
window.localStorage.removeItem(`${tt}${e}`);
|
|
1960
2072
|
return;
|
|
1961
2073
|
}
|
|
1962
2074
|
window.localStorage.setItem(
|
|
1963
|
-
`${
|
|
2075
|
+
`${tt}${e}`,
|
|
1964
2076
|
JSON.stringify(s.slice(-25))
|
|
1965
2077
|
);
|
|
1966
2078
|
} catch {
|
|
1967
2079
|
return;
|
|
1968
2080
|
}
|
|
1969
2081
|
}
|
|
1970
|
-
function
|
|
2082
|
+
function Bt(e, t) {
|
|
1971
2083
|
try {
|
|
1972
2084
|
const s = `${F}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
1973
2085
|
...o,
|
|
@@ -1983,22 +2095,22 @@ function Lt(e, t) {
|
|
|
1983
2095
|
} catch {
|
|
1984
2096
|
}
|
|
1985
2097
|
}
|
|
1986
|
-
function
|
|
2098
|
+
function Ms(e, t) {
|
|
1987
2099
|
try {
|
|
1988
2100
|
if (window.sessionStorage.getItem(`${F}${e}`) === null)
|
|
1989
2101
|
return;
|
|
1990
2102
|
} catch {
|
|
1991
2103
|
return;
|
|
1992
2104
|
}
|
|
1993
|
-
|
|
2105
|
+
Bt(e, t);
|
|
1994
2106
|
}
|
|
1995
|
-
function
|
|
2107
|
+
function Ps(e) {
|
|
1996
2108
|
try {
|
|
1997
2109
|
const t = `${F}${e}`, s = window.sessionStorage.getItem(t);
|
|
1998
2110
|
if (window.sessionStorage.removeItem(t), !s)
|
|
1999
2111
|
return [];
|
|
2000
2112
|
const n = JSON.parse(s);
|
|
2001
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2113
|
+
return Array.isArray(n) ? n.flatMap((r) => Us(r) ? [{
|
|
2002
2114
|
...r.event,
|
|
2003
2115
|
rawOutput: {
|
|
2004
2116
|
ok: !0,
|
|
@@ -2022,13 +2134,13 @@ function Cs(e) {
|
|
|
2022
2134
|
return [];
|
|
2023
2135
|
}
|
|
2024
2136
|
}
|
|
2025
|
-
function
|
|
2137
|
+
function Us(e) {
|
|
2026
2138
|
if (!e || typeof e != "object")
|
|
2027
2139
|
return !1;
|
|
2028
2140
|
const t = e, s = t.event;
|
|
2029
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
2141
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && lt(s) && s.type === "tool.result";
|
|
2030
2142
|
}
|
|
2031
|
-
function
|
|
2143
|
+
function Ds(e, t) {
|
|
2032
2144
|
const s = new Set(
|
|
2033
2145
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2034
2146
|
);
|
|
@@ -2037,20 +2149,20 @@ function bs(e, t) {
|
|
|
2037
2149
|
...t.filter((n) => !s.has(n.callId))
|
|
2038
2150
|
];
|
|
2039
2151
|
}
|
|
2040
|
-
function
|
|
2152
|
+
function Ns(e) {
|
|
2041
2153
|
try {
|
|
2042
2154
|
window.sessionStorage.removeItem(`${F}${e}`);
|
|
2043
2155
|
} catch {
|
|
2044
2156
|
return;
|
|
2045
2157
|
}
|
|
2046
2158
|
}
|
|
2047
|
-
function
|
|
2159
|
+
function lt(e) {
|
|
2048
2160
|
if (!e || typeof e != "object")
|
|
2049
2161
|
return !1;
|
|
2050
2162
|
const t = e;
|
|
2051
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2163
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && St(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? St(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;
|
|
2052
2164
|
}
|
|
2053
|
-
function
|
|
2165
|
+
function St(e) {
|
|
2054
2166
|
if (!e || typeof e != "object")
|
|
2055
2167
|
return !1;
|
|
2056
2168
|
const t = e;
|
|
@@ -2064,24 +2176,24 @@ function qt(e, t) {
|
|
|
2064
2176
|
return !1;
|
|
2065
2177
|
const i = r;
|
|
2066
2178
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2067
|
-
}), n = t ? s.map((r) =>
|
|
2179
|
+
}), n = t ? s.map((r) => Ht(r, t)) : s;
|
|
2068
2180
|
return n.length > 0 ? n : void 0;
|
|
2069
2181
|
}
|
|
2070
|
-
function
|
|
2182
|
+
function Ht(e, t) {
|
|
2071
2183
|
return e.fileUrl?.startsWith("/") ? {
|
|
2072
2184
|
...e,
|
|
2073
2185
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2074
2186
|
} : e;
|
|
2075
2187
|
}
|
|
2076
|
-
function
|
|
2077
|
-
if (
|
|
2188
|
+
function Os(e) {
|
|
2189
|
+
if (vs(e))
|
|
2078
2190
|
return {
|
|
2079
2191
|
headers: {
|
|
2080
2192
|
"ngrok-skip-browser-warning": "true"
|
|
2081
2193
|
}
|
|
2082
2194
|
};
|
|
2083
2195
|
}
|
|
2084
|
-
function
|
|
2196
|
+
function vs(e) {
|
|
2085
2197
|
try {
|
|
2086
2198
|
const t = new URL(e).hostname;
|
|
2087
2199
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -2089,14 +2201,14 @@ function Ds(e) {
|
|
|
2089
2201
|
return !1;
|
|
2090
2202
|
}
|
|
2091
2203
|
}
|
|
2092
|
-
function
|
|
2093
|
-
return e.type ||
|
|
2204
|
+
function kt(e) {
|
|
2205
|
+
return e.type || Ls(e.name) || "application/octet-stream";
|
|
2094
2206
|
}
|
|
2095
|
-
function
|
|
2207
|
+
function Ls(e) {
|
|
2096
2208
|
const t = e.toLowerCase();
|
|
2097
2209
|
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;
|
|
2098
2210
|
}
|
|
2099
|
-
function
|
|
2211
|
+
function Bs(e) {
|
|
2100
2212
|
if (!e || typeof e != "object")
|
|
2101
2213
|
return null;
|
|
2102
2214
|
const t = e;
|
|
@@ -2108,17 +2220,17 @@ function Os(e) {
|
|
|
2108
2220
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
2109
2221
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2110
2222
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2111
|
-
attachments: qt(t.attachments)?.map(
|
|
2223
|
+
attachments: qt(t.attachments)?.map(ut),
|
|
2112
2224
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2113
2225
|
};
|
|
2114
2226
|
}
|
|
2115
|
-
function
|
|
2227
|
+
function qs(e) {
|
|
2116
2228
|
return e.attachments?.length ? {
|
|
2117
2229
|
...e,
|
|
2118
|
-
attachments: e.attachments.map(
|
|
2230
|
+
attachments: e.attachments.map(ut)
|
|
2119
2231
|
} : e;
|
|
2120
2232
|
}
|
|
2121
|
-
function
|
|
2233
|
+
function ut(e) {
|
|
2122
2234
|
const {
|
|
2123
2235
|
dataUrl: t,
|
|
2124
2236
|
objectUrl: s,
|
|
@@ -2127,7 +2239,7 @@ function at(e) {
|
|
|
2127
2239
|
} = e;
|
|
2128
2240
|
return r;
|
|
2129
2241
|
}
|
|
2130
|
-
function
|
|
2242
|
+
function J(e) {
|
|
2131
2243
|
const t = e.respondsToUserMessageId;
|
|
2132
2244
|
return typeof t == "string" && t ? t : null;
|
|
2133
2245
|
}
|
|
@@ -2135,59 +2247,59 @@ function C(e) {
|
|
|
2135
2247
|
const t = e.runId;
|
|
2136
2248
|
return typeof t == "string" && t ? t : null;
|
|
2137
2249
|
}
|
|
2138
|
-
function
|
|
2250
|
+
function Hs(e) {
|
|
2139
2251
|
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
|
|
2140
2252
|
}
|
|
2141
|
-
function
|
|
2253
|
+
function xt(e) {
|
|
2142
2254
|
const t = {};
|
|
2143
2255
|
try {
|
|
2144
2256
|
new Headers(e).forEach((s, n) => {
|
|
2145
|
-
Object.keys(t).length <
|
|
2257
|
+
Object.keys(t).length < at && (t[n] = dt(n, s));
|
|
2146
2258
|
});
|
|
2147
2259
|
} catch {
|
|
2148
2260
|
return {};
|
|
2149
2261
|
}
|
|
2150
2262
|
return t;
|
|
2151
2263
|
}
|
|
2152
|
-
function
|
|
2153
|
-
return
|
|
2264
|
+
function dt(e, t) {
|
|
2265
|
+
return Gt(e) ? j : k(H(t), Ee);
|
|
2154
2266
|
}
|
|
2155
|
-
function
|
|
2267
|
+
function xs(e, t) {
|
|
2156
2268
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2157
2269
|
}
|
|
2158
|
-
async function
|
|
2159
|
-
const r =
|
|
2270
|
+
async function Fs(e, t, s, n) {
|
|
2271
|
+
const r = xt(e.headers);
|
|
2160
2272
|
n({
|
|
2161
2273
|
...t,
|
|
2162
2274
|
responseStatus: e.status,
|
|
2163
2275
|
responseHeaders: r,
|
|
2164
|
-
responseBody: await
|
|
2276
|
+
responseBody: await Ws(e),
|
|
2165
2277
|
durationMs: Date.now() - s
|
|
2166
2278
|
});
|
|
2167
2279
|
}
|
|
2168
|
-
async function
|
|
2280
|
+
async function Ws(e) {
|
|
2169
2281
|
if (!Ft(e.headers))
|
|
2170
2282
|
return;
|
|
2171
2283
|
let t = null, s = null;
|
|
2172
2284
|
try {
|
|
2173
2285
|
if (t = e.clone().body?.getReader() ?? null, !t)
|
|
2174
2286
|
return;
|
|
2175
|
-
const n = new Promise((
|
|
2287
|
+
const n = new Promise((c) => {
|
|
2176
2288
|
s = window.setTimeout(() => {
|
|
2177
|
-
t?.cancel(),
|
|
2178
|
-
},
|
|
2289
|
+
t?.cancel(), c("timeout");
|
|
2290
|
+
}, Re);
|
|
2179
2291
|
}), r = new TextDecoder();
|
|
2180
2292
|
let i = "", o = 0;
|
|
2181
2293
|
for (; ; ) {
|
|
2182
|
-
const
|
|
2183
|
-
if (
|
|
2294
|
+
const c = await Promise.race([t.read(), n]);
|
|
2295
|
+
if (c === "timeout")
|
|
2184
2296
|
return;
|
|
2185
|
-
const { done: a, value: h } =
|
|
2297
|
+
const { done: a, value: h } = c;
|
|
2186
2298
|
if (a)
|
|
2187
|
-
return
|
|
2188
|
-
const g =
|
|
2299
|
+
return k(i + r.decode());
|
|
2300
|
+
const g = ot - o;
|
|
2189
2301
|
if (h.byteLength > g)
|
|
2190
|
-
return i += r.decode(h.subarray(0, Math.max(g, 0)), { stream: !0 }), t.cancel(), `${
|
|
2302
|
+
return i += r.decode(h.subarray(0, Math.max(g, 0)), { stream: !0 }), t.cancel(), `${k(i)}... [truncated]`;
|
|
2191
2303
|
o += h.byteLength, i += r.decode(h, { stream: !0 });
|
|
2192
2304
|
}
|
|
2193
2305
|
} catch {
|
|
@@ -2197,45 +2309,45 @@ async function Hs(e) {
|
|
|
2197
2309
|
s !== null && window.clearTimeout(s);
|
|
2198
2310
|
}
|
|
2199
2311
|
}
|
|
2200
|
-
function
|
|
2312
|
+
function js(e, t) {
|
|
2201
2313
|
if (Ft(new Headers(t)))
|
|
2202
2314
|
try {
|
|
2203
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
2315
|
+
return e.responseType === "" || e.responseType === "text" ? k(e.responseText ?? "") : void 0;
|
|
2204
2316
|
} catch {
|
|
2205
2317
|
return;
|
|
2206
2318
|
}
|
|
2207
2319
|
}
|
|
2208
|
-
function
|
|
2320
|
+
function Et(e) {
|
|
2209
2321
|
if (typeof e == "string")
|
|
2210
|
-
return
|
|
2322
|
+
return k(e);
|
|
2211
2323
|
}
|
|
2212
|
-
function
|
|
2213
|
-
return
|
|
2324
|
+
function $s(e) {
|
|
2325
|
+
return I({
|
|
2214
2326
|
...e,
|
|
2215
|
-
requestBody:
|
|
2216
|
-
responseBody:
|
|
2327
|
+
requestBody: Rt(e.requestBody),
|
|
2328
|
+
responseBody: Rt(e.responseBody)
|
|
2217
2329
|
});
|
|
2218
2330
|
}
|
|
2219
|
-
function
|
|
2331
|
+
function Rt(e) {
|
|
2220
2332
|
if (typeof e != "string")
|
|
2221
2333
|
return e;
|
|
2222
2334
|
const t = e.trim();
|
|
2223
2335
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
2224
|
-
return
|
|
2336
|
+
return H(e);
|
|
2225
2337
|
try {
|
|
2226
|
-
return JSON.stringify(
|
|
2338
|
+
return JSON.stringify(I(JSON.parse(e)));
|
|
2227
2339
|
} catch {
|
|
2228
|
-
return
|
|
2340
|
+
return H(e);
|
|
2229
2341
|
}
|
|
2230
2342
|
}
|
|
2231
2343
|
function Ft(e) {
|
|
2232
2344
|
if (!e)
|
|
2233
2345
|
return !1;
|
|
2234
2346
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
2235
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
2347
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= ot && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
2236
2348
|
}
|
|
2237
|
-
function
|
|
2238
|
-
if (
|
|
2349
|
+
function b(e, t = {}, s) {
|
|
2350
|
+
if (Gs(s))
|
|
2239
2351
|
return !0;
|
|
2240
2352
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
2241
2353
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -2245,13 +2357,13 @@ function P(e, t = {}, s) {
|
|
|
2245
2357
|
if (r.protocol !== "http:" && r.protocol !== "https:")
|
|
2246
2358
|
return !0;
|
|
2247
2359
|
const i = r.hostname.toLowerCase(), o = r.pathname.toLowerCase();
|
|
2248
|
-
return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((
|
|
2360
|
+
return i === "pluno.ai" || i.endsWith(".pluno.ai") || o === "/api/product-agent" || o.startsWith("/api/product-agent/") || /(^|\/)(auth|oauth|login|logout)(\/|$)/.test(o) || /(^|\/)[^/]*token[^/]*(\/|$)/.test(o) || /(^|\/)(upload|uploads|attachments)(\/|$)/.test(o) || [...r.searchParams.keys()].some((c) => /^(x-amz-signature|x-goog-signature|signature|sig)$/i.test(c));
|
|
2249
2361
|
} catch {
|
|
2250
2362
|
return !0;
|
|
2251
2363
|
}
|
|
2252
2364
|
}
|
|
2253
|
-
function
|
|
2254
|
-
if (
|
|
2365
|
+
function zs(e, t) {
|
|
2366
|
+
if (b(e))
|
|
2255
2367
|
return !0;
|
|
2256
2368
|
try {
|
|
2257
2369
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -2260,70 +2372,70 @@ function xs(e, t) {
|
|
|
2260
2372
|
return !0;
|
|
2261
2373
|
}
|
|
2262
2374
|
}
|
|
2263
|
-
function
|
|
2375
|
+
function Gs(e) {
|
|
2264
2376
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
2265
2377
|
}
|
|
2266
|
-
function
|
|
2378
|
+
function Xs(e) {
|
|
2267
2379
|
const t = {};
|
|
2268
2380
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
2269
2381
|
const n = s.indexOf(":");
|
|
2270
2382
|
if (n <= 0)
|
|
2271
2383
|
continue;
|
|
2272
|
-
if (Object.keys(t).length >=
|
|
2384
|
+
if (Object.keys(t).length >= at)
|
|
2273
2385
|
break;
|
|
2274
2386
|
const r = s.slice(0, n).trim();
|
|
2275
|
-
t[r] =
|
|
2387
|
+
t[r] = dt(r, s.slice(n + 1).trim());
|
|
2276
2388
|
}
|
|
2277
2389
|
return t;
|
|
2278
2390
|
}
|
|
2279
|
-
function
|
|
2391
|
+
function k(e, t = ot) {
|
|
2280
2392
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
2281
2393
|
}
|
|
2282
|
-
function
|
|
2394
|
+
function V(e) {
|
|
2283
2395
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2284
2396
|
}
|
|
2285
|
-
class
|
|
2397
|
+
class B extends Error {
|
|
2286
2398
|
constructor(t, s) {
|
|
2287
2399
|
super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
2288
2400
|
}
|
|
2289
2401
|
status;
|
|
2290
2402
|
}
|
|
2291
|
-
async function
|
|
2403
|
+
async function Y(e, t) {
|
|
2292
2404
|
let s = null;
|
|
2293
|
-
for (let n = 0; n <
|
|
2405
|
+
for (let n = 0; n < mt; n += 1)
|
|
2294
2406
|
try {
|
|
2295
2407
|
return await e();
|
|
2296
2408
|
} catch (r) {
|
|
2297
|
-
if (s = r, n >=
|
|
2409
|
+
if (s = r, n >= mt - 1 || !Js(r))
|
|
2298
2410
|
throw r;
|
|
2299
|
-
await
|
|
2411
|
+
await Ks(n);
|
|
2300
2412
|
}
|
|
2301
2413
|
throw s instanceof Error ? s : new Error(t);
|
|
2302
2414
|
}
|
|
2303
|
-
function
|
|
2415
|
+
function Ks(e) {
|
|
2304
2416
|
return new Promise((t) => {
|
|
2305
|
-
window.setTimeout(t,
|
|
2417
|
+
window.setTimeout(t, ke[e] ?? 0);
|
|
2306
2418
|
});
|
|
2307
2419
|
}
|
|
2308
|
-
function
|
|
2309
|
-
return e instanceof
|
|
2420
|
+
function Js(e) {
|
|
2421
|
+
return e instanceof B ? Vs(e.status) : e instanceof TypeError;
|
|
2310
2422
|
}
|
|
2311
|
-
function
|
|
2423
|
+
function Vs(e) {
|
|
2312
2424
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
2313
2425
|
}
|
|
2314
|
-
function
|
|
2426
|
+
function Ys(e) {
|
|
2315
2427
|
return e === 401 || e === 403;
|
|
2316
2428
|
}
|
|
2317
|
-
const
|
|
2318
|
-
function
|
|
2429
|
+
const j = "[REDACTED_SECRET]", E = "[REDACTED_TOKEN]", Zs = "[REDACTED_SIGNED_URL]", Qs = 20, tn = /^(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, jt = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, $t = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, zt = /\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, en = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, sn = /\bhttps?:\/\/[^\s"'<>]+/gi, nn = /[),.;\]]+$/;
|
|
2430
|
+
function I(e) {
|
|
2319
2431
|
return q(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2320
2432
|
}
|
|
2321
2433
|
function q(e, t, s) {
|
|
2322
2434
|
if (typeof e == "string")
|
|
2323
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
2435
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : H(e);
|
|
2324
2436
|
if (e === null || typeof e != "object")
|
|
2325
2437
|
return e;
|
|
2326
|
-
if (t >=
|
|
2438
|
+
if (t >= Qs)
|
|
2327
2439
|
return "[REDACTED_MAX_DEPTH]";
|
|
2328
2440
|
if (s.has(e))
|
|
2329
2441
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -2331,44 +2443,44 @@ function q(e, t, s) {
|
|
|
2331
2443
|
return e.map((r) => q(r, t + 1, s));
|
|
2332
2444
|
const n = {};
|
|
2333
2445
|
for (const [r, i] of Object.entries(e))
|
|
2334
|
-
|
|
2446
|
+
Gt(r) ? n[r] = j : n[r] = r.toLowerCase() === "url" ? rn(i) : q(i, t + 1, s);
|
|
2335
2447
|
return n;
|
|
2336
2448
|
}
|
|
2337
|
-
function
|
|
2449
|
+
function Gt(e) {
|
|
2338
2450
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
2339
2451
|
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");
|
|
2340
2452
|
}
|
|
2341
|
-
function
|
|
2342
|
-
return typeof e == "string" ?
|
|
2453
|
+
function rn(e) {
|
|
2454
|
+
return typeof e == "string" ? Xt(e) : q(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2343
2455
|
}
|
|
2344
|
-
function
|
|
2456
|
+
function Xt(e) {
|
|
2345
2457
|
try {
|
|
2346
2458
|
const t = new URL(e, location.href);
|
|
2347
2459
|
for (const s of Array.from(t.searchParams.keys()))
|
|
2348
|
-
|
|
2349
|
-
return t.username && (t.username =
|
|
2460
|
+
tn.test(s) && t.searchParams.set(s, E);
|
|
2461
|
+
return t.username && (t.username = E), t.password && (t.password = E), t.toString();
|
|
2350
2462
|
} catch {
|
|
2351
|
-
return
|
|
2463
|
+
return on(e);
|
|
2352
2464
|
}
|
|
2353
2465
|
}
|
|
2354
|
-
function
|
|
2355
|
-
return e.replace(
|
|
2466
|
+
function H(e) {
|
|
2467
|
+
return e.replace(en, Zs).replace(sn, an).replace(Wt, `Bearer ${E}`).replace(jt, `Basic ${E}`).replace($t, E).replace(zt, (t, s) => `${s}: ${j}`);
|
|
2356
2468
|
}
|
|
2357
|
-
function
|
|
2358
|
-
return e.replace(Wt, `Bearer ${
|
|
2469
|
+
function on(e) {
|
|
2470
|
+
return e.replace(Wt, `Bearer ${E}`).replace(jt, `Basic ${E}`).replace($t, E).replace(zt, (t, s) => `${s}: ${j}`);
|
|
2359
2471
|
}
|
|
2360
|
-
function
|
|
2361
|
-
const t = e.match(
|
|
2362
|
-
return `${
|
|
2472
|
+
function an(e) {
|
|
2473
|
+
const t = e.match(nn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
2474
|
+
return `${Xt(s)}${t}`;
|
|
2363
2475
|
}
|
|
2364
2476
|
export {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2477
|
+
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
2478
|
+
Q as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
2479
|
+
oe as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
2480
|
+
ie as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
2481
|
+
ae as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
2482
|
+
Ut as PlunoProductAgent,
|
|
2483
|
+
Pe as calculateReconnectDelay,
|
|
2484
|
+
Ut as default,
|
|
2373
2485
|
We as getProductAgentOriginAccessErrorMessage
|
|
2374
2486
|
};
|