@pluno/product-agent-web 0.1.71 → 0.1.74
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 +674 -557
- package/dist/product-agent-widget.js +1193 -1125
- package/dist/widget.d.ts +9 -0
- 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,24 @@ 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
|
-
|
|
1821
|
+
function ds(e, t) {
|
|
1822
|
+
const s = t.map(
|
|
1823
|
+
(n) => Ot(e, n)
|
|
1824
|
+
);
|
|
1825
|
+
return t.length > 0 ? s : e.filter(
|
|
1826
|
+
(n) => n.role === "user" && n.id.startsWith("local-")
|
|
1827
|
+
);
|
|
1758
1828
|
}
|
|
1759
|
-
function
|
|
1829
|
+
function Ot(e, t) {
|
|
1760
1830
|
if (t.role !== "user" || !t.attachments?.length)
|
|
1761
1831
|
return t;
|
|
1762
1832
|
const s = e.find(
|
|
@@ -1765,19 +1835,19 @@ function Mt(e, t) {
|
|
|
1765
1835
|
if (!s?.attachments?.length)
|
|
1766
1836
|
return t;
|
|
1767
1837
|
const n = t.attachments.map((r) => {
|
|
1768
|
-
const i =
|
|
1769
|
-
return i ?
|
|
1838
|
+
const i = hs(s.attachments ?? [], r);
|
|
1839
|
+
return i ? ps(r, i) : r;
|
|
1770
1840
|
});
|
|
1771
1841
|
return { ...t, attachments: n };
|
|
1772
1842
|
}
|
|
1773
|
-
function
|
|
1843
|
+
function hs(e, t) {
|
|
1774
1844
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
1775
1845
|
}
|
|
1776
|
-
function
|
|
1846
|
+
function ps(e, t) {
|
|
1777
1847
|
const { previewUrl: s } = t;
|
|
1778
1848
|
return s ? { ...e, previewUrl: s } : e;
|
|
1779
1849
|
}
|
|
1780
|
-
function
|
|
1850
|
+
function gs(e, t) {
|
|
1781
1851
|
if (t.role !== "user")
|
|
1782
1852
|
return e;
|
|
1783
1853
|
const s = e.findIndex(
|
|
@@ -1788,24 +1858,37 @@ function ps(e, t) {
|
|
|
1788
1858
|
const n = [...e];
|
|
1789
1859
|
return n.splice(s, 1), n;
|
|
1790
1860
|
}
|
|
1791
|
-
function
|
|
1792
|
-
const t =
|
|
1793
|
-
|
|
1861
|
+
function At(e) {
|
|
1862
|
+
const t = vt(e);
|
|
1863
|
+
if (t === null)
|
|
1864
|
+
return !1;
|
|
1865
|
+
for (let s = e.length - 1; s > t; s -= 1) {
|
|
1866
|
+
const n = e[s];
|
|
1867
|
+
if (n.role === "assistant")
|
|
1868
|
+
return !0;
|
|
1869
|
+
if (n.role === "system") {
|
|
1870
|
+
if (n.dataType === "run_error")
|
|
1871
|
+
return !0;
|
|
1872
|
+
if (n.dataType === "run_status")
|
|
1873
|
+
return n.loading !== !0;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
return !1;
|
|
1794
1877
|
}
|
|
1795
|
-
function
|
|
1796
|
-
const t =
|
|
1878
|
+
function fs(e) {
|
|
1879
|
+
const t = vt(e);
|
|
1797
1880
|
return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
|
|
1798
1881
|
}
|
|
1799
|
-
function
|
|
1882
|
+
function vt(e) {
|
|
1800
1883
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
1801
1884
|
if (e[t].role === "user")
|
|
1802
1885
|
return t;
|
|
1803
1886
|
return null;
|
|
1804
1887
|
}
|
|
1805
|
-
function
|
|
1888
|
+
function ms(e) {
|
|
1806
1889
|
return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
1807
1890
|
}
|
|
1808
|
-
function
|
|
1891
|
+
function ct(e) {
|
|
1809
1892
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
1810
1893
|
const s = e[t];
|
|
1811
1894
|
if (!s || typeof s != "object")
|
|
@@ -1819,18 +1902,18 @@ function Ot(e) {
|
|
|
1819
1902
|
}
|
|
1820
1903
|
return null;
|
|
1821
1904
|
}
|
|
1822
|
-
function
|
|
1823
|
-
const s =
|
|
1905
|
+
function ys(e, t) {
|
|
1906
|
+
const s = ct(t);
|
|
1824
1907
|
if (s === null)
|
|
1825
1908
|
return !1;
|
|
1826
1909
|
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
1827
1910
|
if (typeof r != "string" || !r)
|
|
1828
1911
|
return !1;
|
|
1829
1912
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
1830
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
1913
|
+
return i === -1 ? !1 : e.slice(i + 1).some(ms);
|
|
1831
1914
|
}
|
|
1832
|
-
function
|
|
1833
|
-
const t =
|
|
1915
|
+
function et(e) {
|
|
1916
|
+
const t = ct(e);
|
|
1834
1917
|
if (t === null)
|
|
1835
1918
|
return null;
|
|
1836
1919
|
const s = e[t];
|
|
@@ -1842,22 +1925,56 @@ function ms(e) {
|
|
|
1842
1925
|
const r = n.clientMessageId;
|
|
1843
1926
|
return typeof r == "string" ? r : null;
|
|
1844
1927
|
}
|
|
1845
|
-
function
|
|
1928
|
+
function Ts(e) {
|
|
1929
|
+
const t = ct(e);
|
|
1930
|
+
if (t === null)
|
|
1931
|
+
return null;
|
|
1932
|
+
for (let s = e.length - 1; s > t; s -= 1) {
|
|
1933
|
+
const n = e[s];
|
|
1934
|
+
if (!n || typeof n != "object")
|
|
1935
|
+
continue;
|
|
1936
|
+
const r = n.data;
|
|
1937
|
+
if (!r || typeof r != "object")
|
|
1938
|
+
continue;
|
|
1939
|
+
const i = r;
|
|
1940
|
+
if (i.type === "message" && i.role === "assistant")
|
|
1941
|
+
return null;
|
|
1942
|
+
if (i.type === "run_error")
|
|
1943
|
+
return i.retryable !== !0 ? null : typeof i.clientMessageId == "string" ? i.clientMessageId : et(e);
|
|
1944
|
+
if (i.type === "run_status")
|
|
1945
|
+
return i.status === "interrupted" && i.retryable === !0 ? et(e) : null;
|
|
1946
|
+
}
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
function ws(e, t) {
|
|
1950
|
+
let s = 0;
|
|
1951
|
+
for (const n of e) {
|
|
1952
|
+
if (!n || typeof n != "object")
|
|
1953
|
+
continue;
|
|
1954
|
+
const r = n.data;
|
|
1955
|
+
if (!r || typeof r != "object")
|
|
1956
|
+
continue;
|
|
1957
|
+
const i = r;
|
|
1958
|
+
i.type === "run_status" && i.clientMessageId === t && typeof i.automaticRecoveryAttempts == "number" && Number.isInteger(i.automaticRecoveryAttempts) && i.automaticRecoveryAttempts >= 0 && (s = Math.max(s, i.automaticRecoveryAttempts));
|
|
1959
|
+
}
|
|
1960
|
+
return s;
|
|
1961
|
+
}
|
|
1962
|
+
function Is(e) {
|
|
1846
1963
|
if (!e || typeof e != "object")
|
|
1847
1964
|
return !1;
|
|
1848
1965
|
const t = e;
|
|
1849
1966
|
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
1967
|
}
|
|
1851
|
-
function
|
|
1852
|
-
return e.filter((t, s) =>
|
|
1968
|
+
function st(e) {
|
|
1969
|
+
return e.filter((t, s) => Lt(t) ? !Rs(e, s) && !ks(e, s) && !Es(e, s) : As(t) ? !Ss(e, s) : !0);
|
|
1853
1970
|
}
|
|
1854
|
-
function
|
|
1971
|
+
function As(e) {
|
|
1855
1972
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
1856
1973
|
}
|
|
1857
|
-
function
|
|
1974
|
+
function Lt(e) {
|
|
1858
1975
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
1859
1976
|
}
|
|
1860
|
-
function
|
|
1977
|
+
function nt(e) {
|
|
1861
1978
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
1862
1979
|
for (const i of e) {
|
|
1863
1980
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -1873,7 +1990,7 @@ function et(e) {
|
|
|
1873
1990
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
1874
1991
|
return r;
|
|
1875
1992
|
}
|
|
1876
|
-
function
|
|
1993
|
+
function Ss(e, t) {
|
|
1877
1994
|
const s = e[t];
|
|
1878
1995
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
1879
1996
|
const r = e[n];
|
|
@@ -1884,42 +2001,42 @@ function Ts(e, t) {
|
|
|
1884
2001
|
}
|
|
1885
2002
|
return !1;
|
|
1886
2003
|
}
|
|
1887
|
-
function
|
|
2004
|
+
function ks(e, t) {
|
|
1888
2005
|
const s = e[t];
|
|
1889
2006
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1890
2007
|
if (e[n].role === "assistant" && W(s, e[n]))
|
|
1891
2008
|
return !0;
|
|
1892
2009
|
return !1;
|
|
1893
2010
|
}
|
|
1894
|
-
function
|
|
2011
|
+
function Es(e, t) {
|
|
1895
2012
|
const s = e[t];
|
|
1896
2013
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1897
2014
|
if (e[n].role === "tool" && W(s, e[n]))
|
|
1898
2015
|
return !0;
|
|
1899
2016
|
return !1;
|
|
1900
2017
|
}
|
|
1901
|
-
function
|
|
2018
|
+
function Rs(e, t) {
|
|
1902
2019
|
const s = e[t];
|
|
1903
2020
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1904
|
-
if (
|
|
2021
|
+
if (Lt(e[n]) && W(s, e[n]))
|
|
1905
2022
|
return !0;
|
|
1906
2023
|
return !1;
|
|
1907
2024
|
}
|
|
1908
2025
|
function W(e, t) {
|
|
1909
2026
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
1910
2027
|
}
|
|
1911
|
-
function
|
|
2028
|
+
function S(e, t) {
|
|
1912
2029
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
1913
2030
|
}
|
|
1914
|
-
function
|
|
2031
|
+
function _s(e, t) {
|
|
1915
2032
|
try {
|
|
1916
|
-
const s = window.localStorage.getItem(`${
|
|
2033
|
+
const s = window.localStorage.getItem(`${Pt}${e}`);
|
|
1917
2034
|
if (!s)
|
|
1918
2035
|
return null;
|
|
1919
2036
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
1920
2037
|
if (t !== void 0 && r !== t)
|
|
1921
2038
|
return null;
|
|
1922
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2039
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Bs).filter((o) => !!o) : [];
|
|
1923
2040
|
return {
|
|
1924
2041
|
sessionId: r,
|
|
1925
2042
|
messages: i
|
|
@@ -1928,46 +2045,46 @@ function ks(e, t) {
|
|
|
1928
2045
|
return null;
|
|
1929
2046
|
}
|
|
1930
2047
|
}
|
|
1931
|
-
function
|
|
2048
|
+
function Cs(e, t) {
|
|
1932
2049
|
try {
|
|
1933
2050
|
window.localStorage.setItem(
|
|
1934
|
-
`${
|
|
2051
|
+
`${Pt}${e}`,
|
|
1935
2052
|
JSON.stringify({
|
|
1936
2053
|
sessionId: t.sessionId,
|
|
1937
|
-
messages: t.messages.slice(-
|
|
2054
|
+
messages: t.messages.slice(-be).map(qs)
|
|
1938
2055
|
})
|
|
1939
2056
|
);
|
|
1940
2057
|
} catch {
|
|
1941
2058
|
return;
|
|
1942
2059
|
}
|
|
1943
2060
|
}
|
|
1944
|
-
function
|
|
2061
|
+
function bs(e) {
|
|
1945
2062
|
try {
|
|
1946
|
-
const t = window.localStorage.getItem(`${
|
|
2063
|
+
const t = window.localStorage.getItem(`${tt}${e}`);
|
|
1947
2064
|
if (!t)
|
|
1948
2065
|
return [];
|
|
1949
2066
|
const s = JSON.parse(t);
|
|
1950
|
-
return Array.isArray(s) ? s.filter(
|
|
2067
|
+
return Array.isArray(s) ? s.filter(lt) : [];
|
|
1951
2068
|
} catch {
|
|
1952
2069
|
return [];
|
|
1953
2070
|
}
|
|
1954
2071
|
}
|
|
1955
|
-
function
|
|
2072
|
+
function P(e, t) {
|
|
1956
2073
|
try {
|
|
1957
|
-
const s = t.filter(
|
|
2074
|
+
const s = t.filter(lt);
|
|
1958
2075
|
if (s.length === 0) {
|
|
1959
|
-
window.localStorage.removeItem(`${
|
|
2076
|
+
window.localStorage.removeItem(`${tt}${e}`);
|
|
1960
2077
|
return;
|
|
1961
2078
|
}
|
|
1962
2079
|
window.localStorage.setItem(
|
|
1963
|
-
`${
|
|
2080
|
+
`${tt}${e}`,
|
|
1964
2081
|
JSON.stringify(s.slice(-25))
|
|
1965
2082
|
);
|
|
1966
2083
|
} catch {
|
|
1967
2084
|
return;
|
|
1968
2085
|
}
|
|
1969
2086
|
}
|
|
1970
|
-
function
|
|
2087
|
+
function Bt(e, t) {
|
|
1971
2088
|
try {
|
|
1972
2089
|
const s = `${F}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
1973
2090
|
...o,
|
|
@@ -1983,22 +2100,22 @@ function Lt(e, t) {
|
|
|
1983
2100
|
} catch {
|
|
1984
2101
|
}
|
|
1985
2102
|
}
|
|
1986
|
-
function
|
|
2103
|
+
function Ms(e, t) {
|
|
1987
2104
|
try {
|
|
1988
2105
|
if (window.sessionStorage.getItem(`${F}${e}`) === null)
|
|
1989
2106
|
return;
|
|
1990
2107
|
} catch {
|
|
1991
2108
|
return;
|
|
1992
2109
|
}
|
|
1993
|
-
|
|
2110
|
+
Bt(e, t);
|
|
1994
2111
|
}
|
|
1995
|
-
function
|
|
2112
|
+
function Ps(e) {
|
|
1996
2113
|
try {
|
|
1997
2114
|
const t = `${F}${e}`, s = window.sessionStorage.getItem(t);
|
|
1998
2115
|
if (window.sessionStorage.removeItem(t), !s)
|
|
1999
2116
|
return [];
|
|
2000
2117
|
const n = JSON.parse(s);
|
|
2001
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2118
|
+
return Array.isArray(n) ? n.flatMap((r) => Us(r) ? [{
|
|
2002
2119
|
...r.event,
|
|
2003
2120
|
rawOutput: {
|
|
2004
2121
|
ok: !0,
|
|
@@ -2022,13 +2139,13 @@ function Cs(e) {
|
|
|
2022
2139
|
return [];
|
|
2023
2140
|
}
|
|
2024
2141
|
}
|
|
2025
|
-
function
|
|
2142
|
+
function Us(e) {
|
|
2026
2143
|
if (!e || typeof e != "object")
|
|
2027
2144
|
return !1;
|
|
2028
2145
|
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" &&
|
|
2146
|
+
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
2147
|
}
|
|
2031
|
-
function
|
|
2148
|
+
function Ds(e, t) {
|
|
2032
2149
|
const s = new Set(
|
|
2033
2150
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2034
2151
|
);
|
|
@@ -2037,20 +2154,20 @@ function bs(e, t) {
|
|
|
2037
2154
|
...t.filter((n) => !s.has(n.callId))
|
|
2038
2155
|
];
|
|
2039
2156
|
}
|
|
2040
|
-
function
|
|
2157
|
+
function Ns(e) {
|
|
2041
2158
|
try {
|
|
2042
2159
|
window.sessionStorage.removeItem(`${F}${e}`);
|
|
2043
2160
|
} catch {
|
|
2044
2161
|
return;
|
|
2045
2162
|
}
|
|
2046
2163
|
}
|
|
2047
|
-
function
|
|
2164
|
+
function lt(e) {
|
|
2048
2165
|
if (!e || typeof e != "object")
|
|
2049
2166
|
return !1;
|
|
2050
2167
|
const t = e;
|
|
2051
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2168
|
+
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
2169
|
}
|
|
2053
|
-
function
|
|
2170
|
+
function St(e) {
|
|
2054
2171
|
if (!e || typeof e != "object")
|
|
2055
2172
|
return !1;
|
|
2056
2173
|
const t = e;
|
|
@@ -2064,24 +2181,24 @@ function qt(e, t) {
|
|
|
2064
2181
|
return !1;
|
|
2065
2182
|
const i = r;
|
|
2066
2183
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2067
|
-
}), n = t ? s.map((r) =>
|
|
2184
|
+
}), n = t ? s.map((r) => Ht(r, t)) : s;
|
|
2068
2185
|
return n.length > 0 ? n : void 0;
|
|
2069
2186
|
}
|
|
2070
|
-
function
|
|
2187
|
+
function Ht(e, t) {
|
|
2071
2188
|
return e.fileUrl?.startsWith("/") ? {
|
|
2072
2189
|
...e,
|
|
2073
2190
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2074
2191
|
} : e;
|
|
2075
2192
|
}
|
|
2076
|
-
function
|
|
2077
|
-
if (
|
|
2193
|
+
function Os(e) {
|
|
2194
|
+
if (vs(e))
|
|
2078
2195
|
return {
|
|
2079
2196
|
headers: {
|
|
2080
2197
|
"ngrok-skip-browser-warning": "true"
|
|
2081
2198
|
}
|
|
2082
2199
|
};
|
|
2083
2200
|
}
|
|
2084
|
-
function
|
|
2201
|
+
function vs(e) {
|
|
2085
2202
|
try {
|
|
2086
2203
|
const t = new URL(e).hostname;
|
|
2087
2204
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -2089,14 +2206,14 @@ function Ds(e) {
|
|
|
2089
2206
|
return !1;
|
|
2090
2207
|
}
|
|
2091
2208
|
}
|
|
2092
|
-
function
|
|
2093
|
-
return e.type ||
|
|
2209
|
+
function kt(e) {
|
|
2210
|
+
return e.type || Ls(e.name) || "application/octet-stream";
|
|
2094
2211
|
}
|
|
2095
|
-
function
|
|
2212
|
+
function Ls(e) {
|
|
2096
2213
|
const t = e.toLowerCase();
|
|
2097
2214
|
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
2215
|
}
|
|
2099
|
-
function
|
|
2216
|
+
function Bs(e) {
|
|
2100
2217
|
if (!e || typeof e != "object")
|
|
2101
2218
|
return null;
|
|
2102
2219
|
const t = e;
|
|
@@ -2108,17 +2225,17 @@ function Os(e) {
|
|
|
2108
2225
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
2109
2226
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2110
2227
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2111
|
-
attachments: qt(t.attachments)?.map(
|
|
2228
|
+
attachments: qt(t.attachments)?.map(ut),
|
|
2112
2229
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2113
2230
|
};
|
|
2114
2231
|
}
|
|
2115
|
-
function
|
|
2232
|
+
function qs(e) {
|
|
2116
2233
|
return e.attachments?.length ? {
|
|
2117
2234
|
...e,
|
|
2118
|
-
attachments: e.attachments.map(
|
|
2235
|
+
attachments: e.attachments.map(ut)
|
|
2119
2236
|
} : e;
|
|
2120
2237
|
}
|
|
2121
|
-
function
|
|
2238
|
+
function ut(e) {
|
|
2122
2239
|
const {
|
|
2123
2240
|
dataUrl: t,
|
|
2124
2241
|
objectUrl: s,
|
|
@@ -2127,7 +2244,7 @@ function at(e) {
|
|
|
2127
2244
|
} = e;
|
|
2128
2245
|
return r;
|
|
2129
2246
|
}
|
|
2130
|
-
function
|
|
2247
|
+
function J(e) {
|
|
2131
2248
|
const t = e.respondsToUserMessageId;
|
|
2132
2249
|
return typeof t == "string" && t ? t : null;
|
|
2133
2250
|
}
|
|
@@ -2135,59 +2252,59 @@ function C(e) {
|
|
|
2135
2252
|
const t = e.runId;
|
|
2136
2253
|
return typeof t == "string" && t ? t : null;
|
|
2137
2254
|
}
|
|
2138
|
-
function
|
|
2255
|
+
function Hs(e) {
|
|
2139
2256
|
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
|
|
2140
2257
|
}
|
|
2141
|
-
function
|
|
2258
|
+
function xt(e) {
|
|
2142
2259
|
const t = {};
|
|
2143
2260
|
try {
|
|
2144
2261
|
new Headers(e).forEach((s, n) => {
|
|
2145
|
-
Object.keys(t).length <
|
|
2262
|
+
Object.keys(t).length < at && (t[n] = dt(n, s));
|
|
2146
2263
|
});
|
|
2147
2264
|
} catch {
|
|
2148
2265
|
return {};
|
|
2149
2266
|
}
|
|
2150
2267
|
return t;
|
|
2151
2268
|
}
|
|
2152
|
-
function
|
|
2153
|
-
return
|
|
2269
|
+
function dt(e, t) {
|
|
2270
|
+
return Gt(e) ? j : k(H(t), Ee);
|
|
2154
2271
|
}
|
|
2155
|
-
function
|
|
2272
|
+
function xs(e, t) {
|
|
2156
2273
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2157
2274
|
}
|
|
2158
|
-
async function
|
|
2159
|
-
const r =
|
|
2275
|
+
async function Fs(e, t, s, n) {
|
|
2276
|
+
const r = xt(e.headers);
|
|
2160
2277
|
n({
|
|
2161
2278
|
...t,
|
|
2162
2279
|
responseStatus: e.status,
|
|
2163
2280
|
responseHeaders: r,
|
|
2164
|
-
responseBody: await
|
|
2281
|
+
responseBody: await Ws(e),
|
|
2165
2282
|
durationMs: Date.now() - s
|
|
2166
2283
|
});
|
|
2167
2284
|
}
|
|
2168
|
-
async function
|
|
2285
|
+
async function Ws(e) {
|
|
2169
2286
|
if (!Ft(e.headers))
|
|
2170
2287
|
return;
|
|
2171
2288
|
let t = null, s = null;
|
|
2172
2289
|
try {
|
|
2173
2290
|
if (t = e.clone().body?.getReader() ?? null, !t)
|
|
2174
2291
|
return;
|
|
2175
|
-
const n = new Promise((
|
|
2292
|
+
const n = new Promise((c) => {
|
|
2176
2293
|
s = window.setTimeout(() => {
|
|
2177
|
-
t?.cancel(),
|
|
2178
|
-
},
|
|
2294
|
+
t?.cancel(), c("timeout");
|
|
2295
|
+
}, Re);
|
|
2179
2296
|
}), r = new TextDecoder();
|
|
2180
2297
|
let i = "", o = 0;
|
|
2181
2298
|
for (; ; ) {
|
|
2182
|
-
const
|
|
2183
|
-
if (
|
|
2299
|
+
const c = await Promise.race([t.read(), n]);
|
|
2300
|
+
if (c === "timeout")
|
|
2184
2301
|
return;
|
|
2185
|
-
const { done: a, value: h } =
|
|
2302
|
+
const { done: a, value: h } = c;
|
|
2186
2303
|
if (a)
|
|
2187
|
-
return
|
|
2188
|
-
const g =
|
|
2304
|
+
return k(i + r.decode());
|
|
2305
|
+
const g = ot - o;
|
|
2189
2306
|
if (h.byteLength > g)
|
|
2190
|
-
return i += r.decode(h.subarray(0, Math.max(g, 0)), { stream: !0 }), t.cancel(), `${
|
|
2307
|
+
return i += r.decode(h.subarray(0, Math.max(g, 0)), { stream: !0 }), t.cancel(), `${k(i)}... [truncated]`;
|
|
2191
2308
|
o += h.byteLength, i += r.decode(h, { stream: !0 });
|
|
2192
2309
|
}
|
|
2193
2310
|
} catch {
|
|
@@ -2197,45 +2314,45 @@ async function Hs(e) {
|
|
|
2197
2314
|
s !== null && window.clearTimeout(s);
|
|
2198
2315
|
}
|
|
2199
2316
|
}
|
|
2200
|
-
function
|
|
2317
|
+
function js(e, t) {
|
|
2201
2318
|
if (Ft(new Headers(t)))
|
|
2202
2319
|
try {
|
|
2203
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
2320
|
+
return e.responseType === "" || e.responseType === "text" ? k(e.responseText ?? "") : void 0;
|
|
2204
2321
|
} catch {
|
|
2205
2322
|
return;
|
|
2206
2323
|
}
|
|
2207
2324
|
}
|
|
2208
|
-
function
|
|
2325
|
+
function Et(e) {
|
|
2209
2326
|
if (typeof e == "string")
|
|
2210
|
-
return
|
|
2327
|
+
return k(e);
|
|
2211
2328
|
}
|
|
2212
|
-
function
|
|
2213
|
-
return
|
|
2329
|
+
function $s(e) {
|
|
2330
|
+
return I({
|
|
2214
2331
|
...e,
|
|
2215
|
-
requestBody:
|
|
2216
|
-
responseBody:
|
|
2332
|
+
requestBody: Rt(e.requestBody),
|
|
2333
|
+
responseBody: Rt(e.responseBody)
|
|
2217
2334
|
});
|
|
2218
2335
|
}
|
|
2219
|
-
function
|
|
2336
|
+
function Rt(e) {
|
|
2220
2337
|
if (typeof e != "string")
|
|
2221
2338
|
return e;
|
|
2222
2339
|
const t = e.trim();
|
|
2223
2340
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
2224
|
-
return
|
|
2341
|
+
return H(e);
|
|
2225
2342
|
try {
|
|
2226
|
-
return JSON.stringify(
|
|
2343
|
+
return JSON.stringify(I(JSON.parse(e)));
|
|
2227
2344
|
} catch {
|
|
2228
|
-
return
|
|
2345
|
+
return H(e);
|
|
2229
2346
|
}
|
|
2230
2347
|
}
|
|
2231
2348
|
function Ft(e) {
|
|
2232
2349
|
if (!e)
|
|
2233
2350
|
return !1;
|
|
2234
2351
|
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 <=
|
|
2352
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= ot && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
2236
2353
|
}
|
|
2237
|
-
function
|
|
2238
|
-
if (
|
|
2354
|
+
function b(e, t = {}, s) {
|
|
2355
|
+
if (Gs(s))
|
|
2239
2356
|
return !0;
|
|
2240
2357
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
2241
2358
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -2245,13 +2362,13 @@ function P(e, t = {}, s) {
|
|
|
2245
2362
|
if (r.protocol !== "http:" && r.protocol !== "https:")
|
|
2246
2363
|
return !0;
|
|
2247
2364
|
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((
|
|
2365
|
+
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
2366
|
} catch {
|
|
2250
2367
|
return !0;
|
|
2251
2368
|
}
|
|
2252
2369
|
}
|
|
2253
|
-
function
|
|
2254
|
-
if (
|
|
2370
|
+
function zs(e, t) {
|
|
2371
|
+
if (b(e))
|
|
2255
2372
|
return !0;
|
|
2256
2373
|
try {
|
|
2257
2374
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -2260,70 +2377,70 @@ function xs(e, t) {
|
|
|
2260
2377
|
return !0;
|
|
2261
2378
|
}
|
|
2262
2379
|
}
|
|
2263
|
-
function
|
|
2380
|
+
function Gs(e) {
|
|
2264
2381
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
2265
2382
|
}
|
|
2266
|
-
function
|
|
2383
|
+
function Xs(e) {
|
|
2267
2384
|
const t = {};
|
|
2268
2385
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
2269
2386
|
const n = s.indexOf(":");
|
|
2270
2387
|
if (n <= 0)
|
|
2271
2388
|
continue;
|
|
2272
|
-
if (Object.keys(t).length >=
|
|
2389
|
+
if (Object.keys(t).length >= at)
|
|
2273
2390
|
break;
|
|
2274
2391
|
const r = s.slice(0, n).trim();
|
|
2275
|
-
t[r] =
|
|
2392
|
+
t[r] = dt(r, s.slice(n + 1).trim());
|
|
2276
2393
|
}
|
|
2277
2394
|
return t;
|
|
2278
2395
|
}
|
|
2279
|
-
function
|
|
2396
|
+
function k(e, t = ot) {
|
|
2280
2397
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
2281
2398
|
}
|
|
2282
|
-
function
|
|
2399
|
+
function V(e) {
|
|
2283
2400
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
2284
2401
|
}
|
|
2285
|
-
class
|
|
2402
|
+
class B extends Error {
|
|
2286
2403
|
constructor(t, s) {
|
|
2287
2404
|
super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
2288
2405
|
}
|
|
2289
2406
|
status;
|
|
2290
2407
|
}
|
|
2291
|
-
async function
|
|
2408
|
+
async function Y(e, t) {
|
|
2292
2409
|
let s = null;
|
|
2293
|
-
for (let n = 0; n <
|
|
2410
|
+
for (let n = 0; n < mt; n += 1)
|
|
2294
2411
|
try {
|
|
2295
2412
|
return await e();
|
|
2296
2413
|
} catch (r) {
|
|
2297
|
-
if (s = r, n >=
|
|
2414
|
+
if (s = r, n >= mt - 1 || !Js(r))
|
|
2298
2415
|
throw r;
|
|
2299
|
-
await
|
|
2416
|
+
await Ks(n);
|
|
2300
2417
|
}
|
|
2301
2418
|
throw s instanceof Error ? s : new Error(t);
|
|
2302
2419
|
}
|
|
2303
|
-
function
|
|
2420
|
+
function Ks(e) {
|
|
2304
2421
|
return new Promise((t) => {
|
|
2305
|
-
window.setTimeout(t,
|
|
2422
|
+
window.setTimeout(t, ke[e] ?? 0);
|
|
2306
2423
|
});
|
|
2307
2424
|
}
|
|
2308
|
-
function
|
|
2309
|
-
return e instanceof
|
|
2425
|
+
function Js(e) {
|
|
2426
|
+
return e instanceof B ? Vs(e.status) : e instanceof TypeError;
|
|
2310
2427
|
}
|
|
2311
|
-
function
|
|
2428
|
+
function Vs(e) {
|
|
2312
2429
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
2313
2430
|
}
|
|
2314
|
-
function
|
|
2431
|
+
function Ys(e) {
|
|
2315
2432
|
return e === 401 || e === 403;
|
|
2316
2433
|
}
|
|
2317
|
-
const
|
|
2318
|
-
function
|
|
2434
|
+
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 = /[),.;\]]+$/;
|
|
2435
|
+
function I(e) {
|
|
2319
2436
|
return q(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2320
2437
|
}
|
|
2321
2438
|
function q(e, t, s) {
|
|
2322
2439
|
if (typeof e == "string")
|
|
2323
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
2440
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : H(e);
|
|
2324
2441
|
if (e === null || typeof e != "object")
|
|
2325
2442
|
return e;
|
|
2326
|
-
if (t >=
|
|
2443
|
+
if (t >= Qs)
|
|
2327
2444
|
return "[REDACTED_MAX_DEPTH]";
|
|
2328
2445
|
if (s.has(e))
|
|
2329
2446
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -2331,44 +2448,44 @@ function q(e, t, s) {
|
|
|
2331
2448
|
return e.map((r) => q(r, t + 1, s));
|
|
2332
2449
|
const n = {};
|
|
2333
2450
|
for (const [r, i] of Object.entries(e))
|
|
2334
|
-
|
|
2451
|
+
Gt(r) ? n[r] = j : n[r] = r.toLowerCase() === "url" ? rn(i) : q(i, t + 1, s);
|
|
2335
2452
|
return n;
|
|
2336
2453
|
}
|
|
2337
|
-
function
|
|
2454
|
+
function Gt(e) {
|
|
2338
2455
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
2339
2456
|
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
2457
|
}
|
|
2341
|
-
function
|
|
2342
|
-
return typeof e == "string" ?
|
|
2458
|
+
function rn(e) {
|
|
2459
|
+
return typeof e == "string" ? Xt(e) : q(e, 0, /* @__PURE__ */ new WeakSet());
|
|
2343
2460
|
}
|
|
2344
|
-
function
|
|
2461
|
+
function Xt(e) {
|
|
2345
2462
|
try {
|
|
2346
2463
|
const t = new URL(e, location.href);
|
|
2347
2464
|
for (const s of Array.from(t.searchParams.keys()))
|
|
2348
|
-
|
|
2349
|
-
return t.username && (t.username =
|
|
2465
|
+
tn.test(s) && t.searchParams.set(s, E);
|
|
2466
|
+
return t.username && (t.username = E), t.password && (t.password = E), t.toString();
|
|
2350
2467
|
} catch {
|
|
2351
|
-
return
|
|
2468
|
+
return on(e);
|
|
2352
2469
|
}
|
|
2353
2470
|
}
|
|
2354
|
-
function
|
|
2355
|
-
return e.replace(
|
|
2471
|
+
function H(e) {
|
|
2472
|
+
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
2473
|
}
|
|
2357
|
-
function
|
|
2358
|
-
return e.replace(Wt, `Bearer ${
|
|
2474
|
+
function on(e) {
|
|
2475
|
+
return e.replace(Wt, `Bearer ${E}`).replace(jt, `Basic ${E}`).replace($t, E).replace(zt, (t, s) => `${s}: ${j}`);
|
|
2359
2476
|
}
|
|
2360
|
-
function
|
|
2361
|
-
const t = e.match(
|
|
2362
|
-
return `${
|
|
2477
|
+
function an(e) {
|
|
2478
|
+
const t = e.match(nn)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
2479
|
+
return `${Xt(s)}${t}`;
|
|
2363
2480
|
}
|
|
2364
2481
|
export {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2482
|
+
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
2483
|
+
Q as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
2484
|
+
oe as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
2485
|
+
ie as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
2486
|
+
ae as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
2487
|
+
Ut as PlunoProductAgent,
|
|
2488
|
+
Pe as calculateReconnectDelay,
|
|
2489
|
+
Ut as default,
|
|
2373
2490
|
We as getProductAgentOriginAccessErrorMessage
|
|
2374
2491
|
};
|