@pluno/product-agent-web 0.1.125 → 0.1.132
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/attachmentStorage.d.ts +2 -2
- package/dist/index.d.ts +10 -4
- package/dist/product-agent-sdk.js +905 -930
- package/dist/product-agent-widget.js +1479 -1454
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
async function
|
|
4
|
-
const t = await
|
|
5
|
-
await
|
|
6
|
-
}
|
|
7
|
-
async function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
(r) => r.get(e)
|
|
12
|
-
);
|
|
13
|
-
if (!s)
|
|
14
|
-
return null;
|
|
15
|
-
const n = Date.now();
|
|
16
|
-
return await Ee(e, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
17
|
-
}
|
|
18
|
-
async function Ee(e, t) {
|
|
19
|
-
const s = await it();
|
|
20
|
-
await Lt(s, "readwrite", async (n) => {
|
|
21
|
-
const r = await xt(
|
|
1
|
+
const Ge = "pluno-product-agent-attachments";
|
|
2
|
+
const _t = "files";
|
|
3
|
+
async function Xe(e) {
|
|
4
|
+
const t = await vt();
|
|
5
|
+
await Ve(t, "readwrite", (s) => s.put(e));
|
|
6
|
+
}
|
|
7
|
+
async function Je(e, t) {
|
|
8
|
+
const s = await vt();
|
|
9
|
+
await Ot(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Nt(
|
|
22
11
|
n.get(e)
|
|
23
12
|
);
|
|
24
13
|
r && n.put({
|
|
@@ -27,57 +16,57 @@ async function Ee(e, t) {
|
|
|
27
16
|
});
|
|
28
17
|
});
|
|
29
18
|
}
|
|
30
|
-
async function
|
|
31
|
-
const t = await
|
|
32
|
-
await
|
|
19
|
+
async function Ke(e = 864e5) {
|
|
20
|
+
const t = await vt(), s = Date.now() - e;
|
|
21
|
+
await Ot(t, "readwrite", async (n) => {
|
|
33
22
|
const r = n.index("lastUsedAt");
|
|
34
|
-
(await
|
|
23
|
+
(await Nt(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
|
-
function
|
|
26
|
+
function vt() {
|
|
38
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
39
|
-
const s = indexedDB.open(
|
|
28
|
+
const s = indexedDB.open(Ge, 1);
|
|
40
29
|
s.onupgradeneeded = () => {
|
|
41
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore(_t, { keyPath: "attachmentId" });
|
|
42
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
43
32
|
}, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
44
33
|
});
|
|
45
34
|
}
|
|
46
|
-
async function
|
|
47
|
-
return await
|
|
35
|
+
async function Ve(e, t, s) {
|
|
36
|
+
return await Ot(e, t, async (n) => await Nt(s(n)));
|
|
48
37
|
}
|
|
49
|
-
function
|
|
38
|
+
function Ot(e, t, s) {
|
|
50
39
|
return new Promise((n, r) => {
|
|
51
|
-
const i = e.transaction(
|
|
52
|
-
let a,
|
|
53
|
-
s(o).then((
|
|
54
|
-
a =
|
|
55
|
-
}).catch((
|
|
56
|
-
|
|
40
|
+
const i = e.transaction(_t, t), o = i.objectStore(_t);
|
|
41
|
+
let a, c = !1;
|
|
42
|
+
s(o).then((l) => {
|
|
43
|
+
a = l;
|
|
44
|
+
}).catch((l) => {
|
|
45
|
+
c = !0;
|
|
57
46
|
try {
|
|
58
47
|
i.abort();
|
|
59
48
|
} catch {
|
|
60
49
|
}
|
|
61
|
-
r(
|
|
50
|
+
r(l);
|
|
62
51
|
}), i.oncomplete = () => {
|
|
63
|
-
|
|
52
|
+
c || n(a);
|
|
64
53
|
}, i.onerror = () => {
|
|
65
|
-
|
|
54
|
+
c || (c = !0, r(i.error ?? new Error("Product Agent attachment storage transaction failed")));
|
|
66
55
|
}, i.onabort = () => {
|
|
67
|
-
|
|
56
|
+
c || (c = !0, r(i.error ?? new Error("Product Agent attachment storage transaction aborted")));
|
|
68
57
|
};
|
|
69
58
|
});
|
|
70
59
|
}
|
|
71
|
-
function
|
|
60
|
+
function Nt(e) {
|
|
72
61
|
return new Promise((t, s) => {
|
|
73
62
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
74
63
|
});
|
|
75
64
|
}
|
|
76
|
-
function
|
|
65
|
+
function Ye(e) {
|
|
77
66
|
return e !== null && (typeof e == "object" || typeof e == "function");
|
|
78
67
|
}
|
|
79
|
-
function
|
|
80
|
-
const n = Reflect.get(e, "pluno"), r =
|
|
68
|
+
function Te(e, t, s) {
|
|
69
|
+
const n = Reflect.get(e, "pluno"), r = Ye(n) ? n : {};
|
|
81
70
|
if (r !== n && !Reflect.set(e, "pluno", r))
|
|
82
71
|
return null;
|
|
83
72
|
const i = Object.getOwnPropertyDescriptor(r, t);
|
|
@@ -91,36 +80,36 @@ function Bt(e, t, s) {
|
|
|
91
80
|
}
|
|
92
81
|
};
|
|
93
82
|
}
|
|
94
|
-
const
|
|
95
|
-
let
|
|
96
|
-
const
|
|
97
|
-
async function
|
|
98
|
-
const t = e.randomUUID(), s = e.storage.getItem(
|
|
83
|
+
const It = "pluno.productAgent.transportId", Ze = "pluno.productAgent.transportIdentity", Tt = "pluno.productAgent.transportIdentity.event", Qe = 50, ts = globalThis.setTimeout.bind(globalThis);
|
|
84
|
+
let $ = null;
|
|
85
|
+
const Q = /* @__PURE__ */ new Set(), wt = /* @__PURE__ */ new Map();
|
|
86
|
+
async function es(e = we()) {
|
|
87
|
+
const t = e.randomUUID(), s = e.storage.getItem(It);
|
|
99
88
|
let n = s ?? e.randomUUID(), r = !1, i = !1;
|
|
100
|
-
const o = e.channel.subscribe((
|
|
101
|
-
if (!(
|
|
102
|
-
if (
|
|
89
|
+
const o = e.channel.subscribe((c) => {
|
|
90
|
+
if (!(c.senderId === t || c.transportId !== n)) {
|
|
91
|
+
if (c.type === "probe") {
|
|
103
92
|
e.channel.postMessage({
|
|
104
93
|
type: "contender",
|
|
105
94
|
transportId: n,
|
|
106
95
|
senderId: t,
|
|
107
|
-
targetId:
|
|
96
|
+
targetId: c.senderId,
|
|
108
97
|
established: r
|
|
109
|
-
}), !r && t >
|
|
98
|
+
}), !r && t > c.senderId && (i = !0);
|
|
110
99
|
return;
|
|
111
100
|
}
|
|
112
|
-
|
|
101
|
+
c.targetId === t && (c.established || t > c.senderId) && (i = !0);
|
|
113
102
|
}
|
|
114
103
|
});
|
|
115
104
|
if (!s)
|
|
116
|
-
e.storage.setItem(
|
|
105
|
+
e.storage.setItem(It, n), r = !0;
|
|
117
106
|
else
|
|
118
107
|
for (; ; ) {
|
|
119
108
|
if (i = !1, e.channel.postMessage({ type: "probe", transportId: n, senderId: t }), await e.settle(), !i) {
|
|
120
109
|
r = !0;
|
|
121
110
|
break;
|
|
122
111
|
}
|
|
123
|
-
n = e.randomUUID(), e.storage.setItem(
|
|
112
|
+
n = e.randomUUID(), e.storage.setItem(It, n);
|
|
124
113
|
}
|
|
125
114
|
let a = !1;
|
|
126
115
|
return {
|
|
@@ -130,49 +119,49 @@ async function ns(e = be()) {
|
|
|
130
119
|
}
|
|
131
120
|
};
|
|
132
121
|
}
|
|
133
|
-
async function
|
|
134
|
-
|
|
122
|
+
async function ss() {
|
|
123
|
+
$ || ($ = es(we()), $.then((n) => {
|
|
135
124
|
const r = (i) => {
|
|
136
|
-
i.persisted || (n.release(),
|
|
125
|
+
i.persisted || (n.release(), $ = null, Q.clear(), window.removeEventListener("pagehide", r));
|
|
137
126
|
};
|
|
138
127
|
window.addEventListener("pagehide", r);
|
|
139
128
|
}));
|
|
140
|
-
const e = await
|
|
141
|
-
|
|
129
|
+
const e = await $, t = ns();
|
|
130
|
+
Q.add(t);
|
|
142
131
|
let s = !1;
|
|
143
132
|
return {
|
|
144
133
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
145
134
|
transportId: t === 0 ? e.transportId : `${e.transportId}.${t}`,
|
|
146
135
|
release: () => {
|
|
147
|
-
s || (s = !0,
|
|
136
|
+
s || (s = !0, Q.delete(t));
|
|
148
137
|
}
|
|
149
138
|
};
|
|
150
139
|
}
|
|
151
|
-
function
|
|
140
|
+
function ns() {
|
|
152
141
|
let e = 0;
|
|
153
|
-
for (;
|
|
142
|
+
for (; Q.has(e); )
|
|
154
143
|
e += 1;
|
|
155
144
|
return e;
|
|
156
145
|
}
|
|
157
|
-
function
|
|
146
|
+
function we() {
|
|
158
147
|
return {
|
|
159
|
-
storage:
|
|
160
|
-
channel:
|
|
148
|
+
storage: rs(),
|
|
149
|
+
channel: is(),
|
|
161
150
|
randomUUID: () => crypto.randomUUID(),
|
|
162
|
-
settle: () => new Promise((e) =>
|
|
151
|
+
settle: () => new Promise((e) => ts(e, Qe))
|
|
163
152
|
};
|
|
164
153
|
}
|
|
165
|
-
function
|
|
154
|
+
function rs() {
|
|
166
155
|
return {
|
|
167
156
|
getItem: (e) => {
|
|
168
157
|
try {
|
|
169
|
-
return window.sessionStorage?.getItem(e) ??
|
|
158
|
+
return window.sessionStorage?.getItem(e) ?? wt.get(e) ?? null;
|
|
170
159
|
} catch {
|
|
171
|
-
return
|
|
160
|
+
return wt.get(e) ?? null;
|
|
172
161
|
}
|
|
173
162
|
},
|
|
174
163
|
setItem: (e, t) => {
|
|
175
|
-
|
|
164
|
+
wt.set(e, t);
|
|
176
165
|
try {
|
|
177
166
|
window.sessionStorage?.setItem(e, t);
|
|
178
167
|
} catch {
|
|
@@ -180,9 +169,9 @@ function os() {
|
|
|
180
169
|
}
|
|
181
170
|
};
|
|
182
171
|
}
|
|
183
|
-
function
|
|
172
|
+
function is() {
|
|
184
173
|
if (typeof BroadcastChannel < "u") {
|
|
185
|
-
const e = new BroadcastChannel(
|
|
174
|
+
const e = new BroadcastChannel(Ze);
|
|
186
175
|
return {
|
|
187
176
|
postMessage: (t) => e.postMessage(t),
|
|
188
177
|
subscribe: (t) => {
|
|
@@ -192,11 +181,11 @@ function as() {
|
|
|
192
181
|
close: () => e.close()
|
|
193
182
|
};
|
|
194
183
|
}
|
|
195
|
-
return
|
|
184
|
+
return os();
|
|
196
185
|
}
|
|
197
|
-
function
|
|
186
|
+
function os() {
|
|
198
187
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
199
|
-
if (s.key !==
|
|
188
|
+
if (s.key !== Tt || !s.newValue)
|
|
200
189
|
return;
|
|
201
190
|
const n = JSON.parse(s.newValue);
|
|
202
191
|
for (const r of e)
|
|
@@ -205,9 +194,9 @@ function cs() {
|
|
|
205
194
|
return window.addEventListener("storage", t), {
|
|
206
195
|
postMessage: (s) => {
|
|
207
196
|
window.localStorage.setItem(
|
|
208
|
-
|
|
197
|
+
Tt,
|
|
209
198
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
210
|
-
), window.localStorage.removeItem(
|
|
199
|
+
), window.localStorage.removeItem(Tt);
|
|
211
200
|
},
|
|
212
201
|
subscribe: (s) => (e.add(s), () => e.delete(s)),
|
|
213
202
|
close: () => {
|
|
@@ -215,18 +204,18 @@ function cs() {
|
|
|
215
204
|
}
|
|
216
205
|
};
|
|
217
206
|
}
|
|
218
|
-
const
|
|
207
|
+
const as = globalThis.fetch.bind(globalThis), Mt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', cs = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', ls = ".pluno-pa-widget__panel", us = ".pluno-pa-widget__timeline", te = `${Mt}[data-pluno-sdk-preview-channel]`, ds = "https://app.pluno.ai", hs = "gpt-5.6-terra", ps = 2e4, fs = 1e4, gs = 1e4, ms = 1e4, ys = 1e4, Is = 1e3, ee = 3e4, se = 0.2, ne = 6e4, Ts = 15e3, K = 8, ws = 15e3, Ss = 2e3, As = 1e3, bs = 100, Es = 8e3, re = 3, ks = [300, 1e3], Lt = 64e3, St = 4e3, Bt = 30, Rs = 2e3, _s = 1e3, Se = "Image is too large for model vision input.", Ms = 100, Ae = "pluno.productAgent.state.", Ct = "pluno.productAgent.pendingEvents.", rt = "pluno.productAgent.activeToolCalls.", Cs = 100;
|
|
219
208
|
function V(e, t = 0) {
|
|
220
209
|
const s = e === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (e - 1));
|
|
221
210
|
return Math.max(t, s);
|
|
222
211
|
}
|
|
223
|
-
const
|
|
212
|
+
const tt = /* @__PURE__ */ new Set();
|
|
224
213
|
let Y = null;
|
|
225
|
-
function
|
|
226
|
-
const s = Math.min(
|
|
227
|
-
return Math.min(
|
|
214
|
+
function Ps(e, t = Math.random) {
|
|
215
|
+
const s = Math.min(ee, Is * 2 ** e), n = 1 - se + t() * se * 2;
|
|
216
|
+
return Math.min(ee, Math.round(s * n));
|
|
228
217
|
}
|
|
229
|
-
function
|
|
218
|
+
function Us(e, t, s) {
|
|
230
219
|
return new Promise((n, r) => {
|
|
231
220
|
const i = setTimeout(() => r(new Error(s)), t);
|
|
232
221
|
e.then(
|
|
@@ -239,13 +228,13 @@ function Os(e, t, s) {
|
|
|
239
228
|
);
|
|
240
229
|
});
|
|
241
230
|
}
|
|
242
|
-
class
|
|
231
|
+
class be {
|
|
243
232
|
constructor(t, s) {
|
|
244
233
|
this.options = t, this.transportIdentity = s, this.state = {
|
|
245
234
|
...this.state,
|
|
246
|
-
starterPrompts:
|
|
235
|
+
starterPrompts: hn(t.initialStarterPrompts)
|
|
247
236
|
};
|
|
248
|
-
const n = t.restorePersistedState === !1 ? null :
|
|
237
|
+
const n = t.restorePersistedState === !1 ? null : Vn(t.clientId, t.expectedPersistedSessionId);
|
|
249
238
|
n && (this.state = {
|
|
250
239
|
...this.state,
|
|
251
240
|
...n,
|
|
@@ -258,9 +247,9 @@ class _e {
|
|
|
258
247
|
assistantDraftRunId: null,
|
|
259
248
|
isThinking: !1,
|
|
260
249
|
lastError: null
|
|
261
|
-
}), this.queuedClientEvents =
|
|
262
|
-
|
|
263
|
-
|
|
250
|
+
}), this.queuedClientEvents = nr(
|
|
251
|
+
Zn(t.clientId),
|
|
252
|
+
tr(t.clientId)
|
|
264
253
|
), W(t.clientId, this.queuedClientEvents);
|
|
265
254
|
}
|
|
266
255
|
options;
|
|
@@ -301,6 +290,8 @@ class _e {
|
|
|
301
290
|
attachmentBlobCache = /* @__PURE__ */ new Map();
|
|
302
291
|
sessionUserFilesApiCleanup = null;
|
|
303
292
|
activeBrowserToolCalls = /* @__PURE__ */ new Map();
|
|
293
|
+
pendingToolLoadingByCallId = /* @__PURE__ */ new Map();
|
|
294
|
+
terminalToolCallIds = /* @__PURE__ */ new Set();
|
|
304
295
|
pageLifecycleCleanup = null;
|
|
305
296
|
transientStarterPromptsRequestInFlight = !1;
|
|
306
297
|
transientStarterPromptsRequestAttempted = !1;
|
|
@@ -326,15 +317,16 @@ class _e {
|
|
|
326
317
|
lastErrorSecuritySettingsUrl: null
|
|
327
318
|
};
|
|
328
319
|
static async init(t) {
|
|
329
|
-
const s = await
|
|
320
|
+
const s = await ss(), n = new be({
|
|
330
321
|
...t,
|
|
331
|
-
backendUrl:
|
|
332
|
-
clientId: t.clientId ??
|
|
333
|
-
model: t.model ??
|
|
322
|
+
backendUrl: Vs(t.backendUrl ?? ds),
|
|
323
|
+
clientId: t.clientId ?? yn(),
|
|
324
|
+
model: t.model ?? hs,
|
|
325
|
+
entrySurface: Ys(t.entrySurface)
|
|
334
326
|
}, s);
|
|
335
327
|
try {
|
|
336
|
-
|
|
337
|
-
|
|
328
|
+
Ke().catch((r) => {
|
|
329
|
+
S("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
338
330
|
message: r instanceof Error ? r.message : String(r)
|
|
339
331
|
});
|
|
340
332
|
}), t.disableNetworkCapture || n.enableNetworkCapture(), n.startPageLifecycleRecovery(), n.startStarterPromptUrlWatcher(), t.autoConnect !== !1 && await n.connect();
|
|
@@ -365,15 +357,15 @@ class _e {
|
|
|
365
357
|
lastError: null
|
|
366
358
|
});
|
|
367
359
|
try {
|
|
368
|
-
if (this.token = this.options.token ?? (this.options.tokenProvider ? await
|
|
360
|
+
if (this.token = this.options.token ?? (this.options.tokenProvider ? await Us(this.options.tokenProvider(), gs, "Pluno token provider timed out") : null), t !== this.connectionAttemptId || this.state.status === "closed")
|
|
369
361
|
return;
|
|
370
362
|
if (!this.token && !this.options.webSocketFactory)
|
|
371
363
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
372
|
-
const s =
|
|
364
|
+
const s = tn(this.options.backendUrl), n = this.options.webSocketFactory?.(s) ?? new WebSocket(s);
|
|
373
365
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
374
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (
|
|
375
|
-
},
|
|
376
|
-
this.socket !== n || (this.clearSocketConnectTimer(),
|
|
366
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (S("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
367
|
+
}, ms), n.addEventListener("open", () => {
|
|
368
|
+
this.socket !== n || (this.clearSocketConnectTimer(), S("web-sdk.agent", "Pluno socket opened", {
|
|
377
369
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
378
370
|
isThinking: this.state.isThinking
|
|
379
371
|
}), !(this.token ? this.sendNow({
|
|
@@ -383,12 +375,12 @@ class _e {
|
|
|
383
375
|
transportId: this.transportIdentity.transportId,
|
|
384
376
|
pageUrl: location.href
|
|
385
377
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
386
|
-
this.socket === n && (
|
|
387
|
-
},
|
|
378
|
+
this.socket === n && (S("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
379
|
+
}, ys));
|
|
388
380
|
}), n.addEventListener("message", (r) => {
|
|
389
|
-
this.socket === n && this.handleServerEvent(
|
|
381
|
+
this.socket === n && this.handleServerEvent(dn(r.data));
|
|
390
382
|
}), n.addEventListener("close", (r) => {
|
|
391
|
-
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (
|
|
383
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (S("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
392
384
|
code: typeof r?.code == "number" ? r.code : null,
|
|
393
385
|
reason: typeof r?.reason == "string" ? r.reason : "",
|
|
394
386
|
wasClean: typeof r?.wasClean == "boolean" ? r.wasClean : null,
|
|
@@ -396,7 +388,7 @@ class _e {
|
|
|
396
388
|
isThinking: this.state.isThinking
|
|
397
389
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()));
|
|
398
390
|
}), n.addEventListener("error", () => {
|
|
399
|
-
this.socket !== n || this.state.status === "closed" || (
|
|
391
|
+
this.socket !== n || this.state.status === "closed" || (S("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
400
392
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
401
393
|
isThinking: this.state.isThinking
|
|
402
394
|
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
@@ -419,26 +411,32 @@ class _e {
|
|
|
419
411
|
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;
|
|
420
412
|
}
|
|
421
413
|
destroy() {
|
|
422
|
-
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(),
|
|
414
|
+
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionUserFilesApi(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), rr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [];
|
|
423
415
|
for (const t of Object.values(this.listeners))
|
|
424
416
|
t?.clear();
|
|
425
417
|
}
|
|
426
|
-
sendMessage(t, s = {}) {
|
|
427
|
-
const n = t.trim(), r = s.attachments ?? []
|
|
418
|
+
async sendMessage(t, s = {}) {
|
|
419
|
+
const n = t.trim(), r = s.attachments ?? [];
|
|
420
|
+
let i = r.map(Wt);
|
|
428
421
|
if (!n && i.length === 0)
|
|
429
422
|
return null;
|
|
430
|
-
const o =
|
|
431
|
-
this.retryableClientMessageId = null;
|
|
432
|
-
const u = {
|
|
423
|
+
const o = _(), a = s.clientMessageId ?? Et(), c = {
|
|
433
424
|
id: `local-${a}`,
|
|
434
425
|
role: "user",
|
|
435
426
|
content: n,
|
|
436
427
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
437
428
|
...r.length > 0 ? { attachments: r } : {}
|
|
438
|
-
},
|
|
429
|
+
}, l = this.state.messages.some((u) => u.id === c.id || u.clientMessageId === a), d = this.state.isThinking, p = {
|
|
430
|
+
assistantDraft: this.state.assistantDraft,
|
|
431
|
+
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
432
|
+
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
433
|
+
assistantDraftRespondsToUserMessageId: this.state.assistantDraftRespondsToUserMessageId,
|
|
434
|
+
assistantDraftRunId: this.state.assistantDraftRunId,
|
|
435
|
+
lastError: this.state.lastError
|
|
436
|
+
};
|
|
439
437
|
this.setState({
|
|
440
|
-
|
|
441
|
-
...
|
|
438
|
+
...l ? {} : { messages: [...this.state.messages, c] },
|
|
439
|
+
...d ? {} : {
|
|
442
440
|
assistantDraft: "",
|
|
443
441
|
assistantDraftItemId: null,
|
|
444
442
|
assistantDraftPhase: null,
|
|
@@ -447,46 +445,68 @@ class _e {
|
|
|
447
445
|
},
|
|
448
446
|
isThinking: !0,
|
|
449
447
|
lastError: null
|
|
450
|
-
}),
|
|
451
|
-
|
|
448
|
+
}), l || this.emit("message", c);
|
|
449
|
+
try {
|
|
450
|
+
const u = [];
|
|
451
|
+
for (const h of i) {
|
|
452
|
+
const f = h.id ? this.attachmentFiles.get(h.id) : void 0;
|
|
453
|
+
if (h.sandboxPath) {
|
|
454
|
+
u.push(h);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (!f)
|
|
458
|
+
throw new Error(`Attachment bytes are unavailable for ${h.name}`);
|
|
459
|
+
u.push(await this.uploadAttachmentForMessage({ file: f, attachment: h }));
|
|
460
|
+
}
|
|
461
|
+
i = u;
|
|
462
|
+
} catch (u) {
|
|
463
|
+
throw this.setState({
|
|
464
|
+
...l ? {} : { messages: this.state.messages.filter((h) => h.id !== c.id) },
|
|
465
|
+
...d ? {} : { ...p, isThinking: !1 }
|
|
466
|
+
}), u;
|
|
467
|
+
}
|
|
468
|
+
this.retryableClientMessageId = null;
|
|
469
|
+
const y = !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, m = {
|
|
452
470
|
type: "chat.user_message",
|
|
453
471
|
sessionId: this.state.sessionId ?? void 0,
|
|
454
472
|
clientMessageId: a,
|
|
455
473
|
initiatedBy: s.initiatedBy,
|
|
474
|
+
invocation: Zs(s.invocation ?? s.initiatedBy),
|
|
475
|
+
entrySurface: this.options.entrySurface,
|
|
456
476
|
content: n,
|
|
457
|
-
pageContent:
|
|
477
|
+
pageContent: y && qt() || void 0,
|
|
458
478
|
attachments: i.length > 0 ? i : void 0,
|
|
459
479
|
page: o,
|
|
460
480
|
model: this.options.model,
|
|
461
|
-
metadata:
|
|
481
|
+
metadata: ie(this.options.metadata)
|
|
462
482
|
};
|
|
463
|
-
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent =
|
|
483
|
+
return s.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.activeClientMessageId = a, this.activeUserMessageEvent = m, this.markThinkingProgress(), this.send(m), a;
|
|
464
484
|
}
|
|
465
485
|
retryLastMessage() {
|
|
466
486
|
const t = this.state.sessionId, s = this.retryableClientMessageId;
|
|
467
487
|
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);
|
|
468
488
|
}
|
|
469
489
|
createLocalAttachment(t) {
|
|
470
|
-
const s =
|
|
490
|
+
const s = Et(), n = {
|
|
471
491
|
id: s,
|
|
472
492
|
name: t.name || "attachment",
|
|
473
|
-
mimeType:
|
|
493
|
+
mimeType: me(t),
|
|
474
494
|
sizeBytes: t.size
|
|
475
495
|
};
|
|
476
496
|
this.attachmentFiles.set(s, t), this.attachmentBlobCache.set(s, t);
|
|
477
497
|
const r = Date.now();
|
|
478
|
-
return
|
|
498
|
+
return Xe({
|
|
479
499
|
attachmentId: s,
|
|
480
500
|
name: n.name,
|
|
481
501
|
mimeType: n.mimeType,
|
|
482
502
|
sizeBytes: n.sizeBytes,
|
|
483
503
|
blob: t,
|
|
484
|
-
origin:
|
|
504
|
+
origin: _().origin,
|
|
485
505
|
sessionId: this.state.sessionId ?? void 0,
|
|
486
506
|
createdAt: r,
|
|
487
507
|
lastUsedAt: r
|
|
488
508
|
}).catch((i) => {
|
|
489
|
-
|
|
509
|
+
S("web-sdk.attachments", "Failed to store Product Agent attachment", {
|
|
490
510
|
attachmentId: s,
|
|
491
511
|
name: n.name,
|
|
492
512
|
message: i instanceof Error ? i.message : String(i)
|
|
@@ -497,91 +517,52 @@ class _e {
|
|
|
497
517
|
const s = this.createLocalAttachment(t);
|
|
498
518
|
return await this.uploadAttachmentForMessage({
|
|
499
519
|
file: t,
|
|
500
|
-
attachment: s
|
|
501
|
-
clientMessageId: Q(),
|
|
502
|
-
waitForSession: !1,
|
|
503
|
-
notifyCompletion: !1
|
|
520
|
+
attachment: s
|
|
504
521
|
});
|
|
505
522
|
}
|
|
506
|
-
startBackgroundAttachmentUploads(t, s) {
|
|
507
|
-
for (const n of s) {
|
|
508
|
-
if (!n.id || n.gcsPath || !this.attachmentFiles.has(n.id))
|
|
509
|
-
continue;
|
|
510
|
-
const r = this.attachmentFiles.get(n.id);
|
|
511
|
-
r && this.uploadAttachmentForMessage({
|
|
512
|
-
file: r,
|
|
513
|
-
attachment: n,
|
|
514
|
-
clientMessageId: t,
|
|
515
|
-
waitForSession: !0,
|
|
516
|
-
notifyCompletion: !0
|
|
517
|
-
}).catch((i) => {
|
|
518
|
-
I("web-sdk.agent", "Attachment background upload failed", {
|
|
519
|
-
attachmentId: n.id,
|
|
520
|
-
name: n.name,
|
|
521
|
-
message: i instanceof Error ? i.message : String(i)
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
523
|
async uploadAttachmentForMessage({
|
|
527
524
|
file: t,
|
|
528
|
-
attachment: s
|
|
529
|
-
clientMessageId: n,
|
|
530
|
-
waitForSession: r,
|
|
531
|
-
notifyCompletion: i
|
|
525
|
+
attachment: s
|
|
532
526
|
}) {
|
|
533
|
-
const
|
|
534
|
-
sessionId:
|
|
527
|
+
const n = this.state.sessionId, r = me(t), i = {
|
|
528
|
+
sessionId: n ?? void 0,
|
|
535
529
|
attachmentId: s.id,
|
|
536
530
|
clientId: this.options.clientId,
|
|
537
531
|
transportId: this.transportIdentity.transportId,
|
|
538
532
|
name: t.name || "attachment",
|
|
539
|
-
mimeType:
|
|
533
|
+
mimeType: r,
|
|
540
534
|
sizeBytes: t.size,
|
|
541
|
-
page:
|
|
535
|
+
page: _(),
|
|
542
536
|
model: this.options.model,
|
|
543
|
-
metadata:
|
|
544
|
-
|
|
545
|
-
|
|
537
|
+
metadata: ie(this.options.metadata),
|
|
538
|
+
entrySurface: this.options.entrySurface
|
|
539
|
+
}, o = this.options.prepareAttachmentUpload ? await Rt(
|
|
540
|
+
() => this.options.prepareAttachmentUpload(i),
|
|
546
541
|
"Failed to prepare attachment upload"
|
|
547
|
-
) : await this.prepareEmbedAttachmentUpload(
|
|
548
|
-
await
|
|
549
|
-
const
|
|
550
|
-
method:
|
|
551
|
-
headers:
|
|
542
|
+
) : await this.prepareEmbedAttachmentUpload(i);
|
|
543
|
+
await Rt(async () => {
|
|
544
|
+
const c = await fetch(new URL(o.uploadUrl, this.options.backendUrl), {
|
|
545
|
+
method: o.uploadMethod,
|
|
546
|
+
headers: o.uploadHeaders,
|
|
552
547
|
body: t
|
|
553
548
|
});
|
|
554
|
-
if (!
|
|
555
|
-
throw new
|
|
556
|
-
return
|
|
557
|
-
}, "Failed to upload attachment"), this.setState({ sessionId:
|
|
558
|
-
const
|
|
559
|
-
return this.updateAttachmentInState(s.id,
|
|
560
|
-
sessionId:
|
|
561
|
-
fileUrl:
|
|
562
|
-
|
|
549
|
+
if (!c.ok)
|
|
550
|
+
throw new et("Failed to upload attachment", c.status);
|
|
551
|
+
return c;
|
|
552
|
+
}, "Failed to upload attachment"), this.setState({ sessionId: o.sessionId });
|
|
553
|
+
const a = Oe(o.attachment, this.options.backendUrl);
|
|
554
|
+
return this.updateAttachmentInState(s.id, a), s.id && Je(s.id, {
|
|
555
|
+
sessionId: o.sessionId,
|
|
556
|
+
fileUrl: a.fileUrl,
|
|
557
|
+
sandboxPath: a.sandboxPath,
|
|
563
558
|
lastUsedAt: Date.now()
|
|
564
|
-
}).catch((
|
|
565
|
-
|
|
559
|
+
}).catch((c) => {
|
|
560
|
+
S("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
566
561
|
attachmentId: s.id,
|
|
567
|
-
name:
|
|
568
|
-
message:
|
|
569
|
-
});
|
|
570
|
-
}), i && l.gcsPath && this.send({
|
|
571
|
-
type: "attachment.upload_completed",
|
|
572
|
-
sessionId: c.sessionId,
|
|
573
|
-
clientMessageId: n,
|
|
574
|
-
attachment: l
|
|
575
|
-
}), l;
|
|
576
|
-
}
|
|
577
|
-
waitForSessionId() {
|
|
578
|
-
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
579
|
-
const n = window.setTimeout(() => {
|
|
580
|
-
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
581
|
-
}, Rs), r = this.on("state", (i) => {
|
|
582
|
-
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
562
|
+
name: a.name,
|
|
563
|
+
message: c instanceof Error ? c.message : String(c)
|
|
583
564
|
});
|
|
584
|
-
});
|
|
565
|
+
}), a;
|
|
585
566
|
}
|
|
586
567
|
updateAttachmentInState(t, s) {
|
|
587
568
|
if (!t)
|
|
@@ -596,18 +577,18 @@ class _e {
|
|
|
596
577
|
}
|
|
597
578
|
async prepareEmbedAttachmentUpload(t) {
|
|
598
579
|
let s = !1;
|
|
599
|
-
return await
|
|
580
|
+
return await Rt(async () => {
|
|
600
581
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
601
582
|
if (n.ok)
|
|
602
583
|
return await n.json();
|
|
603
|
-
if (
|
|
584
|
+
if (wr(n.status) && this.options.tokenProvider && !s) {
|
|
604
585
|
s = !0;
|
|
605
586
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
606
587
|
if (r.ok)
|
|
607
588
|
return await r.json();
|
|
608
|
-
throw new
|
|
589
|
+
throw new et("Failed to prepare attachment upload", r.status);
|
|
609
590
|
}
|
|
610
|
-
throw new
|
|
591
|
+
throw new et("Failed to prepare attachment upload", n.status);
|
|
611
592
|
}, "Failed to prepare attachment upload");
|
|
612
593
|
}
|
|
613
594
|
async fetchEmbedAttachmentUpload(t) {
|
|
@@ -629,7 +610,7 @@ class _e {
|
|
|
629
610
|
!this.options.keepRunsActiveOnSessionNavigation && s && this.state.sessionId && this.state.isThinking && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.cleanupSessionUserFilesApi(), this.queuedClientEvents = this.queuedClientEvents.filter((n) => n.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.retryableClientMessageId = null, this.lastUserMessagePageUrl = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, s && this.send({
|
|
630
611
|
type: "session.reset",
|
|
631
612
|
sessionId: this.state.sessionId ?? void 0,
|
|
632
|
-
page:
|
|
613
|
+
page: _()
|
|
633
614
|
}), this.setState({
|
|
634
615
|
sessionId: null,
|
|
635
616
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -644,15 +625,15 @@ class _e {
|
|
|
644
625
|
});
|
|
645
626
|
}
|
|
646
627
|
listSessions(t = {}) {
|
|
647
|
-
const s =
|
|
628
|
+
const s = Et(), n = new Promise((i, o) => {
|
|
648
629
|
const a = window.setTimeout(() => {
|
|
649
630
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
650
|
-
},
|
|
631
|
+
}, Es);
|
|
651
632
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
652
633
|
}), r = {
|
|
653
634
|
type: "sessions.list",
|
|
654
635
|
requestId: s,
|
|
655
|
-
page:
|
|
636
|
+
page: _(),
|
|
656
637
|
...t.cursor ? { cursor: t.cursor } : {},
|
|
657
638
|
...t.limit ? { limit: t.limit } : {}
|
|
658
639
|
};
|
|
@@ -676,11 +657,11 @@ class _e {
|
|
|
676
657
|
}), this.send({
|
|
677
658
|
type: "session.load",
|
|
678
659
|
sessionId: t,
|
|
679
|
-
page:
|
|
660
|
+
page: _()
|
|
680
661
|
});
|
|
681
662
|
}
|
|
682
663
|
send(t) {
|
|
683
|
-
this.sendNow(
|
|
664
|
+
this.sendNow(k(t)) || (this.queuedClientEvents.push(t), W(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
684
665
|
}
|
|
685
666
|
async getUploadToken() {
|
|
686
667
|
const t = this.options.token ?? await this.options.tokenProvider?.() ?? this.token ?? null;
|
|
@@ -695,7 +676,7 @@ class _e {
|
|
|
695
676
|
try {
|
|
696
677
|
return s.send(JSON.stringify(t)), !0;
|
|
697
678
|
} catch (n) {
|
|
698
|
-
return
|
|
679
|
+
return S("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
699
680
|
message: n instanceof Error ? n.message : String(n),
|
|
700
681
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
701
682
|
isThinking: this.state.isThinking
|
|
@@ -706,9 +687,9 @@ class _e {
|
|
|
706
687
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
707
688
|
return;
|
|
708
689
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
709
|
-
const t =
|
|
690
|
+
const t = en();
|
|
710
691
|
this.sendNow(
|
|
711
|
-
|
|
692
|
+
k({
|
|
712
693
|
type: "starter_prompts.page_context",
|
|
713
694
|
pageUrl: t.pageUrl,
|
|
714
695
|
pageTitle: t.pageTitle,
|
|
@@ -717,13 +698,13 @@ class _e {
|
|
|
717
698
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
718
699
|
}
|
|
719
700
|
startStarterPromptUrlWatcher() {
|
|
720
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
701
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = sn(() => this.handleStarterPromptUrlChange()));
|
|
721
702
|
}
|
|
722
703
|
handleStarterPromptUrlChange() {
|
|
723
704
|
const t = location.href;
|
|
724
705
|
t !== this.lastStarterPromptPageUrl && (this.lastStarterPromptPageUrl = t, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
725
706
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
726
|
-
},
|
|
707
|
+
}, Cs));
|
|
727
708
|
}
|
|
728
709
|
refreshStarterPromptsForCurrentUrl() {
|
|
729
710
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -741,7 +722,7 @@ class _e {
|
|
|
741
722
|
W(this.options.clientId, this.queuedClientEvents);
|
|
742
723
|
for (let s = 0; s < t.length; s += 1) {
|
|
743
724
|
const n = t[s];
|
|
744
|
-
if (!this.sendNow(
|
|
725
|
+
if (!this.sendNow(k(n))) {
|
|
745
726
|
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), W(this.options.clientId, this.queuedClientEvents);
|
|
746
727
|
return;
|
|
747
728
|
}
|
|
@@ -757,67 +738,67 @@ class _e {
|
|
|
757
738
|
this.clearHeartbeatAckTimer();
|
|
758
739
|
return;
|
|
759
740
|
}
|
|
760
|
-
if (
|
|
741
|
+
if (vs(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
761
742
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.flushQueuedClientEvents(), this.startHeartbeat();
|
|
762
|
-
const s =
|
|
763
|
-
|
|
743
|
+
const s = pn(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
744
|
+
S("web-sdk.agent", "Received auth.ok appearance", {
|
|
764
745
|
hasAppearance: n,
|
|
765
746
|
rawAppearance: t.appearance,
|
|
766
747
|
normalizedAppearance: s
|
|
767
|
-
}), this.runtimeHelperJavascript =
|
|
768
|
-
const r =
|
|
748
|
+
}), this.runtimeHelperJavascript = fn(t.runtimeHelpers)?.javascript ?? null;
|
|
749
|
+
const r = ce(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
769
750
|
user: In(t.user),
|
|
770
751
|
status: "connected"
|
|
771
752
|
};
|
|
772
|
-
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !
|
|
753
|
+
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r, a.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (a.appearance = s), this.setState(a), i && r.length === 0 && !o && !rn() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
773
754
|
type: "page.upsert",
|
|
774
755
|
sessionId: this.state.sessionId,
|
|
775
|
-
page:
|
|
756
|
+
page: _(),
|
|
776
757
|
model: this.options.model
|
|
777
758
|
});
|
|
778
759
|
return;
|
|
779
760
|
}
|
|
780
761
|
if (t.type === "starterPrompts.updated") {
|
|
781
762
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
782
|
-
starterPrompts:
|
|
763
|
+
starterPrompts: ce(t, "starterPrompts"),
|
|
783
764
|
starterPromptsLoading: !1
|
|
784
765
|
});
|
|
785
766
|
return;
|
|
786
767
|
}
|
|
787
768
|
if (t.type === "conversation.state") {
|
|
788
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
769
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Rn(
|
|
789
770
|
t.assistantDraft
|
|
790
771
|
), r = n !== void 0;
|
|
791
772
|
this.rememberUserMessageClientMessageIds(s);
|
|
792
|
-
const i =
|
|
773
|
+
const i = Hn(s);
|
|
793
774
|
if (i) {
|
|
794
|
-
const
|
|
775
|
+
const f = Fn(s, i);
|
|
795
776
|
this.retryAttemptsByClientMessageId[i] = Math.max(
|
|
796
777
|
this.retryAttemptsByClientMessageId[i] ?? 0,
|
|
797
|
-
|
|
778
|
+
f
|
|
798
779
|
);
|
|
799
780
|
}
|
|
800
|
-
const o = s.filter((
|
|
801
|
-
const
|
|
802
|
-
return !
|
|
803
|
-
}), a =
|
|
781
|
+
const o = s.filter((f) => {
|
|
782
|
+
const I = L(f);
|
|
783
|
+
return !he(I) && (!i || !Pt(I));
|
|
784
|
+
}), a = Dn(
|
|
804
785
|
this.state.messages,
|
|
805
|
-
|
|
806
|
-
),
|
|
807
|
-
(
|
|
808
|
-
|
|
786
|
+
Tn(o, this.options.backendUrl)
|
|
787
|
+
), c = de(a), l = !r && s.some(
|
|
788
|
+
(f) => fe(
|
|
789
|
+
L(f),
|
|
809
790
|
this.state.assistantDraft,
|
|
810
791
|
this.state.assistantDraftItemId,
|
|
811
792
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
812
793
|
this.state.assistantDraftRunId
|
|
813
794
|
)
|
|
814
|
-
),
|
|
815
|
-
if (!
|
|
795
|
+
), d = r ? n?.content ?? "" : this.state.assistantDraft, p = !!n?.content, y = c && (!d || l), m = Nn(a), u = y && m;
|
|
796
|
+
if (!c && qn(this.state.messages, s))
|
|
816
797
|
return;
|
|
817
|
-
this.lastUserMessagePageUrl =
|
|
818
|
-
const
|
|
819
|
-
if (this.latestRecoverableClientMessageId =
|
|
820
|
-
sessionId:
|
|
798
|
+
this.lastUserMessagePageUrl = Bn(s);
|
|
799
|
+
const h = y ? null : Ut(s);
|
|
800
|
+
if (this.latestRecoverableClientMessageId = h, m && this.clearRetryTimers(), this.setState({
|
|
801
|
+
sessionId: b(t.session, "id") ?? this.state.sessionId,
|
|
821
802
|
messages: a,
|
|
822
803
|
...r ? {
|
|
823
804
|
assistantDraft: n?.content ?? "",
|
|
@@ -825,46 +806,52 @@ class _e {
|
|
|
825
806
|
assistantDraftPhase: n?.phase ?? null,
|
|
826
807
|
assistantDraftRespondsToUserMessageId: n?.respondsToUserMessageId ?? null,
|
|
827
808
|
assistantDraftRunId: n?.runId ?? null
|
|
828
|
-
} :
|
|
809
|
+
} : l ? {
|
|
829
810
|
assistantDraft: "",
|
|
830
811
|
assistantDraftItemId: null,
|
|
831
812
|
assistantDraftPhase: null,
|
|
832
813
|
assistantDraftRespondsToUserMessageId: null,
|
|
833
814
|
assistantDraftRunId: null
|
|
834
815
|
} : {},
|
|
835
|
-
...
|
|
816
|
+
...p ? {
|
|
836
817
|
isThinking: !0,
|
|
837
818
|
lastError: null
|
|
838
|
-
} :
|
|
839
|
-
isThinking: !1
|
|
840
|
-
|
|
819
|
+
} : y ? {
|
|
820
|
+
isThinking: !1,
|
|
821
|
+
...u ? {
|
|
822
|
+
status: "connected",
|
|
823
|
+
lastError: null,
|
|
824
|
+
lastErrorCode: null,
|
|
825
|
+
lastErrorSecuritySettingsUrl: null
|
|
826
|
+
} : {}
|
|
827
|
+
} : h ? {
|
|
841
828
|
isThinking: !0,
|
|
842
829
|
lastError: null
|
|
843
830
|
} : {}
|
|
844
|
-
}),
|
|
845
|
-
const
|
|
846
|
-
|
|
831
|
+
}), y ? (this.retryableClientMessageId = null, this.clearThinkingWatchdog()) : (p || h) && (h && (this.activeClientMessageId = h), this.markThinkingProgress()), i) {
|
|
832
|
+
const f = b(t.session, "id") ?? this.state.sessionId;
|
|
833
|
+
f && this.retryAfterInterruptedRun(f, i);
|
|
847
834
|
}
|
|
848
835
|
return;
|
|
849
836
|
}
|
|
850
837
|
if (t.type === "sessions.page") {
|
|
851
838
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
852
839
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
853
|
-
sessions:
|
|
840
|
+
sessions: wn(t.sessions),
|
|
854
841
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
855
842
|
}));
|
|
856
843
|
return;
|
|
857
844
|
}
|
|
858
845
|
if (t.type === "session.updated") {
|
|
859
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
846
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: b(t.session, "id") ?? this.state.sessionId });
|
|
860
847
|
return;
|
|
861
848
|
}
|
|
862
849
|
if (t.type === "session.item") {
|
|
863
850
|
this.rememberUserMessageClientMessageIds([t.item]);
|
|
864
|
-
const s =
|
|
865
|
-
if (
|
|
851
|
+
const s = L(t.item);
|
|
852
|
+
if (Pt(s)) {
|
|
866
853
|
typeof s?.runId == "string" && this.retryableFailureRunIdsAwaitingDone.add(s.runId);
|
|
867
|
-
const r =
|
|
854
|
+
const r = b(t.item, "sessionId") ?? this.state.sessionId, i = s ? v(s) : null, o = i ? this.clientMessageIdsByUserMessageItemId.get(i) : null, a = typeof s?.clientMessageId == "string" ? s.clientMessageId : o ?? (i ? null : this.activeClientMessageId ?? this.latestRecoverableClientMessageId);
|
|
868
855
|
if (r && a) {
|
|
869
856
|
this.retryAfterInterruptedRun(r, a);
|
|
870
857
|
return;
|
|
@@ -874,31 +861,40 @@ class _e {
|
|
|
874
861
|
return;
|
|
875
862
|
}
|
|
876
863
|
}
|
|
877
|
-
if (
|
|
864
|
+
if (he(s))
|
|
878
865
|
return;
|
|
879
|
-
const n =
|
|
866
|
+
const n = Me(t.item, this.options.backendUrl);
|
|
880
867
|
if (n) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
868
|
+
const r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
869
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), q(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
870
|
+
const i = t.item.data;
|
|
871
|
+
Wn(i) && this.clearRunAckResyncRetryTimer();
|
|
872
|
+
const o = Ce(this.state.messages, n), a = de(o), c = fe(
|
|
873
|
+
i,
|
|
886
874
|
this.state.assistantDraft,
|
|
887
875
|
this.state.assistantDraftItemId,
|
|
888
876
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
889
877
|
this.state.assistantDraftRunId
|
|
890
|
-
),
|
|
878
|
+
), l = a && (!this.state.assistantDraft || c), d = l && q(n);
|
|
891
879
|
this.setState({
|
|
892
|
-
messages:
|
|
893
|
-
...
|
|
880
|
+
messages: o,
|
|
881
|
+
...c ? {
|
|
894
882
|
assistantDraft: "",
|
|
895
883
|
assistantDraftItemId: null,
|
|
896
884
|
assistantDraftPhase: null,
|
|
897
885
|
assistantDraftRespondsToUserMessageId: null,
|
|
898
886
|
assistantDraftRunId: null
|
|
899
887
|
} : {},
|
|
900
|
-
...
|
|
901
|
-
|
|
888
|
+
...l ? {
|
|
889
|
+
isThinking: !1
|
|
890
|
+
} : {},
|
|
891
|
+
...d ? {
|
|
892
|
+
status: "connected",
|
|
893
|
+
lastError: null,
|
|
894
|
+
lastErrorCode: null,
|
|
895
|
+
lastErrorSecuritySettingsUrl: null
|
|
896
|
+
} : {}
|
|
897
|
+
}), l && this.clearThinkingWatchdog(), this.emit("message", n);
|
|
902
898
|
}
|
|
903
899
|
return;
|
|
904
900
|
}
|
|
@@ -933,9 +929,9 @@ class _e {
|
|
|
933
929
|
}
|
|
934
930
|
if (t.type === "tool.call") {
|
|
935
931
|
this.clearRunAckResyncRetryTimer();
|
|
936
|
-
const s =
|
|
932
|
+
const s = Pn(t);
|
|
937
933
|
if (s) {
|
|
938
|
-
const n =
|
|
934
|
+
const n = Mn(
|
|
939
935
|
this.state.messages,
|
|
940
936
|
s
|
|
941
937
|
);
|
|
@@ -952,6 +948,18 @@ class _e {
|
|
|
952
948
|
this.executeToolCall(t);
|
|
953
949
|
return;
|
|
954
950
|
}
|
|
951
|
+
if (t.type === "tool.status") {
|
|
952
|
+
const s = typeof t.callId == "string" ? t.callId : null;
|
|
953
|
+
if (!s)
|
|
954
|
+
return;
|
|
955
|
+
const n = t.status === "queued" || t.status === "running";
|
|
956
|
+
if (n && this.terminalToolCallIds.has(s))
|
|
957
|
+
return;
|
|
958
|
+
n || this.terminalToolCallIds.add(s), this.state.messages.some(
|
|
959
|
+
(i) => i.callId === s
|
|
960
|
+
) ? this.setToolMessageLoading(s, n) : this.pendingToolLoadingByCallId.set(s, n);
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
955
963
|
if (t.type === "error") {
|
|
956
964
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
957
965
|
if (s && n) {
|
|
@@ -964,8 +972,8 @@ class _e {
|
|
|
964
972
|
return;
|
|
965
973
|
}
|
|
966
974
|
o && r && i && (this.retryableClientMessageId = i);
|
|
967
|
-
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"),
|
|
968
|
-
|
|
975
|
+
const a = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error"), c = Qs(a.message);
|
|
976
|
+
c && console.error(c), this.setState({
|
|
969
977
|
status: "error",
|
|
970
978
|
isThinking: !1,
|
|
971
979
|
lastError: a.message,
|
|
@@ -1029,7 +1037,7 @@ class _e {
|
|
|
1029
1037
|
}
|
|
1030
1038
|
rememberUserMessageClientMessageIds(t) {
|
|
1031
1039
|
for (const s of t) {
|
|
1032
|
-
const n =
|
|
1040
|
+
const n = b(s, "id"), r = L(s);
|
|
1033
1041
|
n && r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" && this.clientMessageIdsByUserMessageItemId.set(n, r.clientMessageId);
|
|
1034
1042
|
}
|
|
1035
1043
|
}
|
|
@@ -1039,7 +1047,7 @@ class _e {
|
|
|
1039
1047
|
this.pendingSessionHistoryRequests.clear();
|
|
1040
1048
|
}
|
|
1041
1049
|
markThinkingProgress() {
|
|
1042
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
1050
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(ne), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
1043
1051
|
}
|
|
1044
1052
|
scheduleThinkingWatchdog(t) {
|
|
1045
1053
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -1059,10 +1067,10 @@ class _e {
|
|
|
1059
1067
|
scheduleRunAckWatchdog(t) {
|
|
1060
1068
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
1061
1069
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
1062
|
-
},
|
|
1070
|
+
}, ws);
|
|
1063
1071
|
}
|
|
1064
1072
|
recoverMissedRunAck(t) {
|
|
1065
|
-
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (
|
|
1073
|
+
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (S("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
1066
1074
|
sessionId: this.state.sessionId,
|
|
1067
1075
|
clientMessageId: t
|
|
1068
1076
|
}), this.resyncThinkingSession(), this.scheduleRunAckResyncRetry(t));
|
|
@@ -1075,7 +1083,7 @@ class _e {
|
|
|
1075
1083
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1076
1084
|
isThinking: !0,
|
|
1077
1085
|
lastError: null
|
|
1078
|
-
}),
|
|
1086
|
+
}), S("web-sdk.agent", "Pluno run ack recovery retrying last user message", {
|
|
1079
1087
|
sessionId: this.state.sessionId,
|
|
1080
1088
|
clientMessageId: t
|
|
1081
1089
|
}), this.state.sessionId ? this.send({
|
|
@@ -1083,7 +1091,7 @@ class _e {
|
|
|
1083
1091
|
sessionId: this.state.sessionId,
|
|
1084
1092
|
clientMessageId: t,
|
|
1085
1093
|
automatic: !0
|
|
1086
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
1094
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(ne)));
|
|
1087
1095
|
}, V(s, Ss)));
|
|
1088
1096
|
}
|
|
1089
1097
|
clearRunAckResyncRetryTimer() {
|
|
@@ -1097,7 +1105,7 @@ class _e {
|
|
|
1097
1105
|
return;
|
|
1098
1106
|
const t = this.activeClientMessageId;
|
|
1099
1107
|
if (!t) {
|
|
1100
|
-
|
|
1108
|
+
S("web-sdk.agent", "Pluno thinking watchdog stopped without a recoverable message id", {
|
|
1101
1109
|
sessionId: this.state.sessionId
|
|
1102
1110
|
}), this.setState({
|
|
1103
1111
|
isThinking: !1,
|
|
@@ -1108,7 +1116,7 @@ class _e {
|
|
|
1108
1116
|
}
|
|
1109
1117
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.retryAttemptsByClientMessageId[t] ?? 0;
|
|
1110
1118
|
if (n >= K) {
|
|
1111
|
-
|
|
1119
|
+
S("web-sdk.agent", "Pluno run recovery retry exhausted", {
|
|
1112
1120
|
sessionId: this.state.sessionId,
|
|
1113
1121
|
clientMessageId: t
|
|
1114
1122
|
}), this.retryableClientMessageId = t, this.setState({
|
|
@@ -1119,18 +1127,18 @@ class _e {
|
|
|
1119
1127
|
return;
|
|
1120
1128
|
}
|
|
1121
1129
|
if (s < 1) {
|
|
1122
|
-
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1,
|
|
1130
|
+
this.thinkingWatchdogResyncAttemptsByClientMessageId[t] = s + 1, S("web-sdk.agent", "Pluno thinking watchdog resyncing session", {
|
|
1123
1131
|
sessionId: this.state.sessionId,
|
|
1124
1132
|
clientMessageId: t,
|
|
1125
1133
|
resyncAttempts: s + 1
|
|
1126
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
1134
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ts);
|
|
1127
1135
|
return;
|
|
1128
1136
|
}
|
|
1129
1137
|
this.setState({
|
|
1130
1138
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
1131
1139
|
isThinking: !0,
|
|
1132
1140
|
lastError: null
|
|
1133
|
-
}),
|
|
1141
|
+
}), S("web-sdk.agent", "Pluno thinking watchdog scheduling retry for last user message", {
|
|
1134
1142
|
sessionId: this.state.sessionId,
|
|
1135
1143
|
clientMessageId: t,
|
|
1136
1144
|
retryAttempts: n + 1
|
|
@@ -1147,26 +1155,26 @@ class _e {
|
|
|
1147
1155
|
this.state.sessionId ? this.send({
|
|
1148
1156
|
type: "page.upsert",
|
|
1149
1157
|
sessionId: this.state.sessionId,
|
|
1150
|
-
page:
|
|
1158
|
+
page: _(),
|
|
1151
1159
|
model: this.options.model
|
|
1152
1160
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
1153
1161
|
}
|
|
1154
1162
|
async executeToolCall(t) {
|
|
1155
|
-
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 =
|
|
1163
|
+
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 = N(
|
|
1156
1164
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
1157
1165
|
), o = t.rawInput;
|
|
1158
1166
|
if (!s || !n || !r)
|
|
1159
1167
|
return;
|
|
1160
1168
|
const a = r === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
1161
|
-
if (r !== "execute_code" && !a || !
|
|
1169
|
+
if (r !== "execute_code" && !a || !cr(o)) {
|
|
1162
1170
|
this.setToolMessageLoading(n, !1), this.send({
|
|
1163
1171
|
type: "tool.result",
|
|
1164
1172
|
sessionId: s,
|
|
1165
1173
|
callId: n,
|
|
1166
1174
|
toolName: r,
|
|
1167
1175
|
summary: i,
|
|
1168
|
-
rawInput:
|
|
1169
|
-
rawOutput:
|
|
1176
|
+
rawInput: k(o),
|
|
1177
|
+
rawOutput: k({
|
|
1170
1178
|
ok: !1,
|
|
1171
1179
|
toolName: r,
|
|
1172
1180
|
error: `Unsupported browser tool: ${r}`
|
|
@@ -1174,7 +1182,23 @@ class _e {
|
|
|
1174
1182
|
});
|
|
1175
1183
|
return;
|
|
1176
1184
|
}
|
|
1177
|
-
|
|
1185
|
+
if (typeof o.frameId == "string") {
|
|
1186
|
+
this.setToolMessageLoading(n, !1), this.send({
|
|
1187
|
+
type: "tool.result",
|
|
1188
|
+
sessionId: s,
|
|
1189
|
+
callId: n,
|
|
1190
|
+
toolName: r,
|
|
1191
|
+
summary: i,
|
|
1192
|
+
rawInput: k(o),
|
|
1193
|
+
rawOutput: {
|
|
1194
|
+
ok: !1,
|
|
1195
|
+
toolName: r,
|
|
1196
|
+
error: "Frame-targeted execution requires browser debugger access and is unavailable in embedded sessions."
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
return;
|
|
1200
|
+
}
|
|
1201
|
+
const c = Ls(this.state.messages);
|
|
1178
1202
|
this.activeBrowserToolCalls.set(n, {
|
|
1179
1203
|
event: {
|
|
1180
1204
|
type: "tool.result",
|
|
@@ -1182,18 +1206,21 @@ class _e {
|
|
|
1182
1206
|
callId: n,
|
|
1183
1207
|
toolName: r,
|
|
1184
1208
|
summary: i,
|
|
1185
|
-
rawInput:
|
|
1209
|
+
rawInput: k(o),
|
|
1186
1210
|
rawOutput: null
|
|
1187
1211
|
},
|
|
1188
1212
|
startedAtMs: Date.now(),
|
|
1189
1213
|
startedAtUrl: location.href,
|
|
1190
1214
|
startedAtOrigin: location.origin
|
|
1191
|
-
}), this.installSessionUserFilesApi(
|
|
1192
|
-
let
|
|
1193
|
-
|
|
1215
|
+
}), this.installSessionUserFilesApi(c);
|
|
1216
|
+
let l = null, d;
|
|
1217
|
+
l = await this.executeRuntimeHelper(), d = await oe(
|
|
1218
|
+
o,
|
|
1219
|
+
Js(t.runtimeContext, this.options.backendUrl)
|
|
1220
|
+
).catch((p) => ({
|
|
1194
1221
|
ok: !1,
|
|
1195
1222
|
exception: {
|
|
1196
|
-
message:
|
|
1223
|
+
message: p instanceof Error ? p.message : String(p)
|
|
1197
1224
|
}
|
|
1198
1225
|
})), this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
1199
1226
|
type: "tool.result",
|
|
@@ -1201,12 +1228,12 @@ class _e {
|
|
|
1201
1228
|
callId: n,
|
|
1202
1229
|
toolName: r,
|
|
1203
1230
|
summary: o.summary,
|
|
1204
|
-
rawInput:
|
|
1205
|
-
rawOutput:
|
|
1206
|
-
}),
|
|
1231
|
+
rawInput: k(o),
|
|
1232
|
+
rawOutput: k(gn(d, l))
|
|
1233
|
+
}), Qn(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
1207
1234
|
}
|
|
1208
1235
|
setToolMessageLoading(t, s) {
|
|
1209
|
-
const n =
|
|
1236
|
+
const n = Cn(
|
|
1210
1237
|
this.state.messages,
|
|
1211
1238
|
t,
|
|
1212
1239
|
s
|
|
@@ -1224,43 +1251,43 @@ class _e {
|
|
|
1224
1251
|
};
|
|
1225
1252
|
}
|
|
1226
1253
|
installSessionUserFilesApi(t) {
|
|
1227
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
1254
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Bs(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
1228
1255
|
}
|
|
1229
1256
|
cleanupSessionUserFilesApi() {
|
|
1230
|
-
this.sessionUserFilesApiCleanup && (
|
|
1257
|
+
this.sessionUserFilesApiCleanup && (Gs(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
1231
1258
|
}
|
|
1232
1259
|
async executeRuntimeHelper() {
|
|
1233
1260
|
if (!this.runtimeHelperJavascript?.trim())
|
|
1234
1261
|
return null;
|
|
1235
|
-
const t = await
|
|
1262
|
+
const t = await oe({
|
|
1236
1263
|
javascript: this.runtimeHelperJavascript
|
|
1237
1264
|
});
|
|
1238
|
-
return t.ok === !1 ?
|
|
1265
|
+
return t.ok === !1 ? mn(t) : null;
|
|
1239
1266
|
}
|
|
1240
1267
|
enableNetworkCapture() {
|
|
1241
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
1242
|
-
|
|
1268
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = Ds((t) => {
|
|
1269
|
+
fr(t.url, this.options.backendUrl) || this.enqueueNetworkEvent(t);
|
|
1243
1270
|
}));
|
|
1244
1271
|
}
|
|
1245
1272
|
enqueueNetworkEvent(t) {
|
|
1246
|
-
this.queuedNetworkEvents.length >=
|
|
1273
|
+
this.queuedNetworkEvents.length >= bs || (this.queuedNetworkEvents.push(pr(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
1247
1274
|
this.networkBatchTimer = null;
|
|
1248
1275
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
1249
1276
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
1250
1277
|
type: "network.batch",
|
|
1251
1278
|
sessionId: this.state.sessionId ?? void 0,
|
|
1252
|
-
page:
|
|
1279
|
+
page: _(),
|
|
1253
1280
|
events: s
|
|
1254
1281
|
});
|
|
1255
|
-
},
|
|
1282
|
+
}, As)));
|
|
1256
1283
|
}
|
|
1257
1284
|
scheduleReconnect() {
|
|
1258
1285
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
1259
1286
|
return;
|
|
1260
|
-
const t =
|
|
1287
|
+
const t = Ps(this.reconnectAttempts);
|
|
1261
1288
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
1262
1289
|
this.reconnectTimer = null, this.connect().catch((s) => {
|
|
1263
|
-
|
|
1290
|
+
S("web-sdk.agent", "Pluno reconnect failed; retrying", {
|
|
1264
1291
|
message: s instanceof Error ? s.message : String(s),
|
|
1265
1292
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1266
1293
|
isThinking: this.state.isThinking
|
|
@@ -1272,9 +1299,9 @@ class _e {
|
|
|
1272
1299
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
1273
1300
|
const t = this.socket;
|
|
1274
1301
|
!t || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
1275
|
-
this.socket === t && (
|
|
1276
|
-
},
|
|
1277
|
-
},
|
|
1302
|
+
this.socket === t && (S("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(t));
|
|
1303
|
+
}, fs));
|
|
1304
|
+
}, ps);
|
|
1278
1305
|
}
|
|
1279
1306
|
stopHeartbeat() {
|
|
1280
1307
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -1300,105 +1327,105 @@ class _e {
|
|
|
1300
1327
|
...t,
|
|
1301
1328
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
1302
1329
|
...t.lastError !== void 0 && t.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
1303
|
-
},
|
|
1330
|
+
}, Yn(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
1304
1331
|
}
|
|
1305
1332
|
emit(t, s) {
|
|
1306
1333
|
this.listeners[t]?.forEach((r) => r(s));
|
|
1307
1334
|
}
|
|
1308
1335
|
}
|
|
1309
|
-
const
|
|
1310
|
-
function
|
|
1311
|
-
const t = window.__plunoProductAgentNetworkCapture ??
|
|
1336
|
+
const At = /* @__PURE__ */ new WeakMap();
|
|
1337
|
+
function Ds(e) {
|
|
1338
|
+
const t = window.__plunoProductAgentNetworkCapture ?? xs();
|
|
1312
1339
|
return t.subscribers.add(e), () => {
|
|
1313
1340
|
t.subscribers.delete(e), !(t.subscribers.size > 0) && (t.destroy(), window.__plunoProductAgentNetworkCapture === t && delete window.__plunoProductAgentNetworkCapture);
|
|
1314
1341
|
};
|
|
1315
1342
|
}
|
|
1316
|
-
function
|
|
1317
|
-
const e = /* @__PURE__ */ new Set(), t = (
|
|
1318
|
-
e.forEach((
|
|
1343
|
+
function xs() {
|
|
1344
|
+
const e = /* @__PURE__ */ new Set(), t = (y) => {
|
|
1345
|
+
e.forEach((m) => {
|
|
1319
1346
|
try {
|
|
1320
|
-
|
|
1347
|
+
m(y);
|
|
1321
1348
|
} catch {
|
|
1322
1349
|
}
|
|
1323
1350
|
});
|
|
1324
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(
|
|
1325
|
-
const
|
|
1326
|
-
let
|
|
1351
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, r = XMLHttpRequest.prototype.setRequestHeader, i = XMLHttpRequest.prototype.send, o = function(m, u) {
|
|
1352
|
+
const h = Date.now();
|
|
1353
|
+
let f;
|
|
1327
1354
|
try {
|
|
1328
|
-
|
|
1329
|
-
} catch (
|
|
1330
|
-
throw
|
|
1355
|
+
f = s.call(this, m, u);
|
|
1356
|
+
} catch (I) {
|
|
1357
|
+
throw I;
|
|
1331
1358
|
}
|
|
1332
1359
|
try {
|
|
1333
|
-
const
|
|
1334
|
-
if (!
|
|
1335
|
-
const
|
|
1336
|
-
requestId:
|
|
1337
|
-
url: C(
|
|
1338
|
-
method: (
|
|
1339
|
-
requestHeaders:
|
|
1340
|
-
requestBody:
|
|
1360
|
+
const I = m instanceof Request ? m : null, x = lr(m, I), T = Ne(u?.headers ?? I?.headers);
|
|
1361
|
+
if (!O(x, T, u?.body)) {
|
|
1362
|
+
const H = {
|
|
1363
|
+
requestId: kt("fetch"),
|
|
1364
|
+
url: C(x, St),
|
|
1365
|
+
method: (u?.method ?? I?.method ?? "GET").toUpperCase(),
|
|
1366
|
+
requestHeaders: T,
|
|
1367
|
+
requestBody: ye(u?.body),
|
|
1341
1368
|
resourceType: "fetch",
|
|
1342
|
-
startedAt: new Date(
|
|
1369
|
+
startedAt: new Date(h).toISOString()
|
|
1343
1370
|
};
|
|
1344
|
-
|
|
1345
|
-
(
|
|
1346
|
-
|
|
1371
|
+
f.then(
|
|
1372
|
+
(R) => {
|
|
1373
|
+
ur(R, H, h, t).catch(() => {
|
|
1347
1374
|
t({
|
|
1348
|
-
...
|
|
1349
|
-
responseStatus:
|
|
1350
|
-
durationMs: Date.now() -
|
|
1375
|
+
...H,
|
|
1376
|
+
responseStatus: R.status,
|
|
1377
|
+
durationMs: Date.now() - h
|
|
1351
1378
|
});
|
|
1352
1379
|
});
|
|
1353
1380
|
},
|
|
1354
|
-
(
|
|
1381
|
+
(R) => {
|
|
1355
1382
|
t({
|
|
1356
|
-
...
|
|
1357
|
-
errorText: C(
|
|
1358
|
-
durationMs: Date.now() -
|
|
1383
|
+
...H,
|
|
1384
|
+
errorText: C(R instanceof Error ? R.message : String(R)),
|
|
1385
|
+
durationMs: Date.now() - h
|
|
1359
1386
|
});
|
|
1360
1387
|
}
|
|
1361
1388
|
);
|
|
1362
1389
|
}
|
|
1363
1390
|
} catch {
|
|
1364
1391
|
}
|
|
1365
|
-
return
|
|
1366
|
-
}, a = function(
|
|
1367
|
-
const
|
|
1368
|
-
return
|
|
1369
|
-
requestId:
|
|
1370
|
-
method: String(
|
|
1371
|
-
url: C(
|
|
1392
|
+
return f;
|
|
1393
|
+
}, a = function(m, u, h, f, I) {
|
|
1394
|
+
const x = n.call(this, m, u, h ?? !0, f ?? void 0, I ?? void 0), T = typeof u == "string" ? u : u.toString();
|
|
1395
|
+
return At.set(this, {
|
|
1396
|
+
requestId: kt("xhr"),
|
|
1397
|
+
method: String(m ?? "GET").toUpperCase(),
|
|
1398
|
+
url: C(T, St),
|
|
1372
1399
|
requestHeaders: {},
|
|
1373
1400
|
startedAtMs: Date.now(),
|
|
1374
1401
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1375
|
-
excluded:
|
|
1376
|
-
}),
|
|
1377
|
-
},
|
|
1378
|
-
const
|
|
1379
|
-
return
|
|
1380
|
-
},
|
|
1402
|
+
excluded: O(T)
|
|
1403
|
+
}), x;
|
|
1404
|
+
}, c = function(m, u) {
|
|
1405
|
+
const h = r.call(this, m, u), f = At.get(this);
|
|
1406
|
+
return f && Object.keys(f.requestHeaders).length < Bt && (f.requestHeaders[m] = jt(m, u), f.excluded = f.excluded || O(f.url, f.requestHeaders)), h;
|
|
1407
|
+
}, l = function(m) {
|
|
1381
1408
|
try {
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1409
|
+
const u = At.get(this);
|
|
1410
|
+
u && (u.excluded = u.excluded || O(u.url, u.requestHeaders, m), u.requestBody = ye(m), u.excluded || this.addEventListener(
|
|
1384
1411
|
"loadend",
|
|
1385
1412
|
() => {
|
|
1386
1413
|
queueMicrotask(() => {
|
|
1387
1414
|
try {
|
|
1388
|
-
const
|
|
1415
|
+
const h = mr(this.getAllResponseHeaders());
|
|
1389
1416
|
t({
|
|
1390
|
-
requestId:
|
|
1391
|
-
url:
|
|
1392
|
-
method:
|
|
1393
|
-
requestHeaders:
|
|
1394
|
-
requestBody:
|
|
1417
|
+
requestId: u.requestId,
|
|
1418
|
+
url: u.url,
|
|
1419
|
+
method: u.method,
|
|
1420
|
+
requestHeaders: u.requestHeaders,
|
|
1421
|
+
requestBody: u.requestBody,
|
|
1395
1422
|
resourceType: "xhr",
|
|
1396
1423
|
responseStatus: this.status,
|
|
1397
|
-
responseHeaders:
|
|
1398
|
-
responseBody:
|
|
1424
|
+
responseHeaders: h,
|
|
1425
|
+
responseBody: hr(this, h),
|
|
1399
1426
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
1400
|
-
startedAt:
|
|
1401
|
-
durationMs: Date.now() -
|
|
1427
|
+
startedAt: u.startedAt,
|
|
1428
|
+
durationMs: Date.now() - u.startedAtMs
|
|
1402
1429
|
});
|
|
1403
1430
|
} catch {
|
|
1404
1431
|
return;
|
|
@@ -1409,7 +1436,7 @@ function Ls() {
|
|
|
1409
1436
|
));
|
|
1410
1437
|
} catch {
|
|
1411
1438
|
}
|
|
1412
|
-
return i.call(this,
|
|
1439
|
+
return i.call(this, m ?? null);
|
|
1413
1440
|
};
|
|
1414
1441
|
try {
|
|
1415
1442
|
window.fetch = o;
|
|
@@ -1420,42 +1447,42 @@ function Ls() {
|
|
|
1420
1447
|
} catch {
|
|
1421
1448
|
}
|
|
1422
1449
|
try {
|
|
1423
|
-
XMLHttpRequest.prototype.setRequestHeader =
|
|
1450
|
+
XMLHttpRequest.prototype.setRequestHeader = c;
|
|
1424
1451
|
} catch {
|
|
1425
1452
|
}
|
|
1426
1453
|
try {
|
|
1427
|
-
XMLHttpRequest.prototype.send =
|
|
1454
|
+
XMLHttpRequest.prototype.send = l;
|
|
1428
1455
|
} catch {
|
|
1429
1456
|
}
|
|
1430
|
-
let
|
|
1457
|
+
let d = null;
|
|
1431
1458
|
if (typeof PerformanceObserver < "u") {
|
|
1432
|
-
|
|
1433
|
-
for (const
|
|
1434
|
-
const
|
|
1435
|
-
if (
|
|
1459
|
+
d = new PerformanceObserver((y) => {
|
|
1460
|
+
for (const m of y.getEntries()) {
|
|
1461
|
+
const u = m;
|
|
1462
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || O(u.name))
|
|
1436
1463
|
continue;
|
|
1437
|
-
const
|
|
1464
|
+
const h = performance.timeOrigin + u.startTime;
|
|
1438
1465
|
t({
|
|
1439
|
-
requestId:
|
|
1440
|
-
url: C(
|
|
1466
|
+
requestId: kt("resource"),
|
|
1467
|
+
url: C(u.name, St),
|
|
1441
1468
|
method: "GET",
|
|
1442
1469
|
resourceType: "resource",
|
|
1443
|
-
responseStatus:
|
|
1444
|
-
startedAt: new Date(
|
|
1445
|
-
durationMs:
|
|
1470
|
+
responseStatus: u.responseStatus,
|
|
1471
|
+
startedAt: new Date(h).toISOString(),
|
|
1472
|
+
durationMs: u.duration
|
|
1446
1473
|
});
|
|
1447
1474
|
}
|
|
1448
1475
|
});
|
|
1449
1476
|
try {
|
|
1450
|
-
|
|
1477
|
+
d.observe({ type: "resource", buffered: !0 });
|
|
1451
1478
|
} catch {
|
|
1452
|
-
|
|
1479
|
+
d.disconnect(), d = null;
|
|
1453
1480
|
}
|
|
1454
1481
|
}
|
|
1455
|
-
const
|
|
1482
|
+
const p = {
|
|
1456
1483
|
subscribers: e,
|
|
1457
1484
|
destroy: () => {
|
|
1458
|
-
|
|
1485
|
+
d?.disconnect();
|
|
1459
1486
|
try {
|
|
1460
1487
|
window.fetch === o && (window.fetch = s);
|
|
1461
1488
|
} catch {
|
|
@@ -1465,18 +1492,18 @@ function Ls() {
|
|
|
1465
1492
|
} catch {
|
|
1466
1493
|
}
|
|
1467
1494
|
try {
|
|
1468
|
-
XMLHttpRequest.prototype.setRequestHeader ===
|
|
1495
|
+
XMLHttpRequest.prototype.setRequestHeader === c && (XMLHttpRequest.prototype.setRequestHeader = r);
|
|
1469
1496
|
} catch {
|
|
1470
1497
|
}
|
|
1471
1498
|
try {
|
|
1472
|
-
XMLHttpRequest.prototype.send ===
|
|
1499
|
+
XMLHttpRequest.prototype.send === l && (XMLHttpRequest.prototype.send = i);
|
|
1473
1500
|
} catch {
|
|
1474
1501
|
}
|
|
1475
1502
|
}
|
|
1476
1503
|
};
|
|
1477
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
1504
|
+
return window.__plunoProductAgentNetworkCapture = p, p;
|
|
1478
1505
|
}
|
|
1479
|
-
function
|
|
1506
|
+
function S(e, t, s) {
|
|
1480
1507
|
if (typeof window > "u")
|
|
1481
1508
|
return;
|
|
1482
1509
|
const n = window, r = {
|
|
@@ -1487,15 +1514,15 @@ function I(e, t, s) {
|
|
|
1487
1514
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
1488
1515
|
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 }));
|
|
1489
1516
|
}
|
|
1490
|
-
function
|
|
1517
|
+
function ie(e) {
|
|
1491
1518
|
const t = typeof e == "function" ? e() : e;
|
|
1492
1519
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
1493
1520
|
}
|
|
1494
|
-
function
|
|
1521
|
+
function vs(e) {
|
|
1495
1522
|
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";
|
|
1496
1523
|
}
|
|
1497
|
-
const
|
|
1498
|
-
function
|
|
1524
|
+
const Os = 5e3, Ns = 12e4;
|
|
1525
|
+
function Ls(e) {
|
|
1499
1526
|
const t = [];
|
|
1500
1527
|
for (const s of e)
|
|
1501
1528
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -1506,122 +1533,30 @@ function Hs(e) {
|
|
|
1506
1533
|
});
|
|
1507
1534
|
return t;
|
|
1508
1535
|
}
|
|
1509
|
-
function
|
|
1536
|
+
function Bs(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1510
1537
|
const n = [
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
Ws()
|
|
1538
|
+
Hs(),
|
|
1539
|
+
qs()
|
|
1514
1540
|
].filter((r) => typeof r == "function");
|
|
1515
1541
|
return () => {
|
|
1516
1542
|
for (const r of n.reverse())
|
|
1517
1543
|
r();
|
|
1518
1544
|
};
|
|
1519
1545
|
}
|
|
1520
|
-
function
|
|
1521
|
-
return
|
|
1522
|
-
}
|
|
1523
|
-
function $s(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
1524
|
-
const n = new Map(e.map((c) => [c.id, c])), r = (c) => ({
|
|
1525
|
-
id: c.id,
|
|
1526
|
-
name: c.name,
|
|
1527
|
-
mimeType: c.mimeType,
|
|
1528
|
-
sizeBytes: c.sizeBytes,
|
|
1529
|
-
type: c.mimeType,
|
|
1530
|
-
size: c.sizeBytes
|
|
1531
|
-
}), i = (c) => {
|
|
1532
|
-
const l = n.get(c);
|
|
1533
|
-
if (!l)
|
|
1534
|
-
throw new Error(`Unknown Pluno user file: ${c}`);
|
|
1535
|
-
return l;
|
|
1536
|
-
}, o = async (c) => {
|
|
1537
|
-
const l = i(c), h = t.get(l.id);
|
|
1538
|
-
if (h)
|
|
1539
|
-
return h;
|
|
1540
|
-
const f = s.get(l.id);
|
|
1541
|
-
if (f)
|
|
1542
|
-
return f;
|
|
1543
|
-
const p = await Ye(l.id).then((y) => y?.blob ?? null).catch((y) => (I("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
1544
|
-
attachmentId: l.id,
|
|
1545
|
-
name: l.name,
|
|
1546
|
-
message: y instanceof Error ? y.message : String(y)
|
|
1547
|
-
}), null));
|
|
1548
|
-
if (p)
|
|
1549
|
-
return s.set(l.id, p), p;
|
|
1550
|
-
if (!l.fileUrl)
|
|
1551
|
-
throw new Error(`Pluno user file is missing content: ${c}`);
|
|
1552
|
-
const d = await fetch(l.fileUrl, or(l.fileUrl));
|
|
1553
|
-
if (!d.ok)
|
|
1554
|
-
throw new Error(`Failed to load Pluno user file: ${c}`);
|
|
1555
|
-
const g = await d.blob();
|
|
1556
|
-
s.set(l.id, g);
|
|
1557
|
-
const T = Date.now();
|
|
1558
|
-
return Se({
|
|
1559
|
-
attachmentId: l.id,
|
|
1560
|
-
name: l.name,
|
|
1561
|
-
mimeType: l.mimeType,
|
|
1562
|
-
sizeBytes: l.sizeBytes,
|
|
1563
|
-
blob: g,
|
|
1564
|
-
fileUrl: l.fileUrl,
|
|
1565
|
-
gcsPath: l.gcsPath,
|
|
1566
|
-
createdAt: T,
|
|
1567
|
-
lastUsedAt: T
|
|
1568
|
-
}).catch((y) => {
|
|
1569
|
-
I("web-sdk.attachments", "Failed to cache Product Agent attachment from fileUrl", {
|
|
1570
|
-
attachmentId: l.id,
|
|
1571
|
-
name: l.name,
|
|
1572
|
-
message: y instanceof Error ? y.message : String(y)
|
|
1573
|
-
});
|
|
1574
|
-
}), g;
|
|
1575
|
-
};
|
|
1576
|
-
return Bt(globalThis, "userFiles", {
|
|
1577
|
-
list: () => e.map(r),
|
|
1578
|
-
get: (c) => {
|
|
1579
|
-
const l = n.get(c);
|
|
1580
|
-
return l ? r(l) : null;
|
|
1581
|
-
},
|
|
1582
|
-
inspectImage: async (c) => {
|
|
1583
|
-
const l = i(c), h = await o(c), f = l.mimeType.startsWith("image/") ? l.mimeType : h.type || l.mimeType;
|
|
1584
|
-
if (!f.startsWith("image/"))
|
|
1585
|
-
throw new Error(`Pluno user file is not an image: ${c}`);
|
|
1586
|
-
const p = h.type === f ? h : new Blob([h], { type: f });
|
|
1587
|
-
return Ys(f, p.size) > Ps ? {
|
|
1588
|
-
type: "pluno.userFiles.inspectImage",
|
|
1589
|
-
id: l.id,
|
|
1590
|
-
name: l.name,
|
|
1591
|
-
mimeType: f,
|
|
1592
|
-
sizeBytes: l.sizeBytes,
|
|
1593
|
-
imageAttached: !1,
|
|
1594
|
-
imageAttachmentError: Ft
|
|
1595
|
-
} : {
|
|
1596
|
-
type: "pluno.userFiles.inspectImage",
|
|
1597
|
-
id: l.id,
|
|
1598
|
-
name: l.name,
|
|
1599
|
-
mimeType: f,
|
|
1600
|
-
sizeBytes: l.sizeBytes,
|
|
1601
|
-
imageAttached: !0,
|
|
1602
|
-
dataUrl: await Ut(p)
|
|
1603
|
-
};
|
|
1604
|
-
},
|
|
1605
|
-
getDataUrl: async (c) => (i(c), await Ut(await o(c))),
|
|
1606
|
-
getBlob: o,
|
|
1607
|
-
getArrayBuffer: async (c) => await (await o(c)).arrayBuffer(),
|
|
1608
|
-
getFile: async (c) => {
|
|
1609
|
-
const l = i(c);
|
|
1610
|
-
return new File([await o(c)], l.name, { type: l.mimeType });
|
|
1611
|
-
}
|
|
1612
|
-
});
|
|
1546
|
+
function qs() {
|
|
1547
|
+
return Te(globalThis, "getPageSnapshot", async () => qt());
|
|
1613
1548
|
}
|
|
1614
|
-
function
|
|
1615
|
-
return
|
|
1616
|
-
inspectImage: async (t, s) => await
|
|
1549
|
+
function Hs() {
|
|
1550
|
+
return Te(globalThis, "pageImages", {
|
|
1551
|
+
inspectImage: async (t, s) => await Fs(t, s)
|
|
1617
1552
|
});
|
|
1618
1553
|
}
|
|
1619
|
-
async function
|
|
1620
|
-
const s =
|
|
1554
|
+
async function Fs(e, t = {}) {
|
|
1555
|
+
const s = zs(t.name), n = await $s(e);
|
|
1621
1556
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
1622
1557
|
type: "pluno.pageImages.inspectImage",
|
|
1623
1558
|
imageAttached: !1,
|
|
1624
|
-
imageAttachmentError:
|
|
1559
|
+
imageAttachmentError: Se
|
|
1625
1560
|
} : {
|
|
1626
1561
|
type: "pluno.pageImages.inspectImage",
|
|
1627
1562
|
imageAttached: !0,
|
|
@@ -1635,15 +1570,15 @@ async function zs(e, t = {}) {
|
|
|
1635
1570
|
imageAttachmentError: n.error
|
|
1636
1571
|
};
|
|
1637
1572
|
}
|
|
1638
|
-
async function
|
|
1639
|
-
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
1573
|
+
async function $s(e) {
|
|
1574
|
+
return e instanceof Blob ? e.type.startsWith("image/") ? e.size === 0 ? { ok: !1, error: "Page image is empty." } : e.size > 8 * 1024 * 1024 ? { ok: !1, error: Se } : {
|
|
1640
1575
|
ok: !0,
|
|
1641
1576
|
mimeType: e.type,
|
|
1642
1577
|
sizeBytes: e.size,
|
|
1643
|
-
dataUrl: await
|
|
1644
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
1578
|
+
dataUrl: await Xs(e)
|
|
1579
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof e != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Ws(e);
|
|
1645
1580
|
}
|
|
1646
|
-
function
|
|
1581
|
+
function Ws(e) {
|
|
1647
1582
|
if (!e.startsWith("data:") || !e.includes(","))
|
|
1648
1583
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
1649
1584
|
const [t, s] = e.slice(5).split(",", 2), n = t.split(";").map((a) => a.trim()).filter(Boolean), r = n[0] ?? "";
|
|
@@ -1654,7 +1589,7 @@ function Xs(e) {
|
|
|
1654
1589
|
const i = s.replace(/[ \t\r\n\f]+/g, "");
|
|
1655
1590
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(i))
|
|
1656
1591
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
1657
|
-
const o =
|
|
1592
|
+
const o = js(i);
|
|
1658
1593
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
1659
1594
|
ok: !0,
|
|
1660
1595
|
mimeType: r,
|
|
@@ -1662,22 +1597,22 @@ function Xs(e) {
|
|
|
1662
1597
|
dataUrl: `data:${r};base64,${i}`
|
|
1663
1598
|
};
|
|
1664
1599
|
}
|
|
1665
|
-
function
|
|
1600
|
+
function js(e) {
|
|
1666
1601
|
if (e.length === 0 || e.length % 4 !== 0)
|
|
1667
1602
|
return null;
|
|
1668
1603
|
const t = e.length - e.replace(/=+$/, "").length;
|
|
1669
1604
|
return t > 2 ? null : e.length / 4 * 3 - t;
|
|
1670
1605
|
}
|
|
1671
|
-
function
|
|
1606
|
+
function zs(e) {
|
|
1672
1607
|
return (typeof e == "string" ? e.trim() : "") || "Page image";
|
|
1673
1608
|
}
|
|
1674
|
-
function
|
|
1609
|
+
function Gs(e) {
|
|
1675
1610
|
try {
|
|
1676
1611
|
e();
|
|
1677
1612
|
} catch {
|
|
1678
1613
|
}
|
|
1679
1614
|
}
|
|
1680
|
-
function
|
|
1615
|
+
function Xs(e) {
|
|
1681
1616
|
return new Promise((t, s) => {
|
|
1682
1617
|
const n = new FileReader();
|
|
1683
1618
|
n.onload = () => {
|
|
@@ -1689,59 +1624,100 @@ function Ut(e) {
|
|
|
1689
1624
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1690
1625
|
});
|
|
1691
1626
|
}
|
|
1692
|
-
function
|
|
1693
|
-
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1696
|
-
const
|
|
1697
|
-
}).constructor, s = e.timeoutMs ?? Bs, n = Date.now(), r = [];
|
|
1698
|
-
let i;
|
|
1699
|
-
const o = {
|
|
1627
|
+
async function oe(e, t) {
|
|
1628
|
+
const s = Object.getPrototypeOf(async function() {
|
|
1629
|
+
}).constructor, n = e.timeoutMs ?? Os, r = Date.now(), i = [];
|
|
1630
|
+
let o;
|
|
1631
|
+
const a = {
|
|
1700
1632
|
log: console.log,
|
|
1701
1633
|
info: console.info,
|
|
1702
1634
|
warn: console.warn,
|
|
1703
1635
|
error: console.error
|
|
1704
|
-
},
|
|
1705
|
-
|
|
1636
|
+
}, c = (l) => (...d) => {
|
|
1637
|
+
i.push({ level: l, args: d }), a[l](...d);
|
|
1706
1638
|
};
|
|
1707
|
-
console.log =
|
|
1639
|
+
console.log = c("log"), console.info = c("info"), console.warn = c("warn"), console.error = c("error");
|
|
1708
1640
|
try {
|
|
1709
|
-
const
|
|
1710
|
-
new
|
|
1711
|
-
new Promise((
|
|
1712
|
-
|
|
1641
|
+
const l = /* @__PURE__ */ Symbol("execute_code_timeout"), d = await Promise.race([
|
|
1642
|
+
new s("sandboxFiles", e.javascript)(t?.value),
|
|
1643
|
+
new Promise((p) => {
|
|
1644
|
+
o = window.setTimeout(() => p(l), n);
|
|
1713
1645
|
})
|
|
1714
1646
|
]);
|
|
1715
|
-
return
|
|
1647
|
+
return d === l ? Ks(n) : {
|
|
1716
1648
|
ok: !0,
|
|
1717
|
-
result:
|
|
1718
|
-
console:
|
|
1649
|
+
result: d,
|
|
1650
|
+
console: i,
|
|
1719
1651
|
metadata: {
|
|
1720
|
-
durationMs: Date.now() -
|
|
1652
|
+
durationMs: Date.now() - r,
|
|
1721
1653
|
url: location.href,
|
|
1722
1654
|
origin: location.origin
|
|
1723
1655
|
}
|
|
1724
1656
|
};
|
|
1725
|
-
} catch (
|
|
1657
|
+
} catch (l) {
|
|
1726
1658
|
return {
|
|
1727
1659
|
ok: !1,
|
|
1728
|
-
console:
|
|
1660
|
+
console: i,
|
|
1729
1661
|
exception: {
|
|
1730
|
-
name:
|
|
1731
|
-
message:
|
|
1732
|
-
stack:
|
|
1662
|
+
name: l instanceof Error ? l.name : "Error",
|
|
1663
|
+
message: l instanceof Error ? l.message : String(l),
|
|
1664
|
+
stack: l instanceof Error ? l.stack : void 0
|
|
1733
1665
|
},
|
|
1734
1666
|
metadata: {
|
|
1735
|
-
durationMs: Date.now() -
|
|
1667
|
+
durationMs: Date.now() - r,
|
|
1736
1668
|
url: location.href,
|
|
1737
1669
|
origin: location.origin
|
|
1738
1670
|
}
|
|
1739
1671
|
};
|
|
1740
1672
|
} finally {
|
|
1741
|
-
|
|
1673
|
+
t?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
1742
1674
|
}
|
|
1743
1675
|
}
|
|
1744
|
-
function
|
|
1676
|
+
function Js(e, t) {
|
|
1677
|
+
if (!e || typeof e != "object")
|
|
1678
|
+
return;
|
|
1679
|
+
const s = e.sandboxFilesToken;
|
|
1680
|
+
if (typeof s != "string" || !s)
|
|
1681
|
+
return;
|
|
1682
|
+
let n = !0;
|
|
1683
|
+
const r = () => {
|
|
1684
|
+
if (!n)
|
|
1685
|
+
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
1686
|
+
}, i = async (a, c) => await as(`${t.replace(/\/$/, "")}${a}`, c);
|
|
1687
|
+
return {
|
|
1688
|
+
value: Object.freeze({
|
|
1689
|
+
upload: async (a) => {
|
|
1690
|
+
if (r(), !(a instanceof Blob))
|
|
1691
|
+
throw new TypeError("sandboxFiles.upload expects a File or Blob");
|
|
1692
|
+
const c = a instanceof File && a.name ? a.name : "file", l = `?name=${encodeURIComponent(c)}&size_bytes=${a.size}`, d = await i(`/api/product-agent/attachments/sandbox-files${l}`, {
|
|
1693
|
+
method: "PUT",
|
|
1694
|
+
headers: { Authorization: `Bearer ${s}` },
|
|
1695
|
+
body: a
|
|
1696
|
+
});
|
|
1697
|
+
if (!d.ok)
|
|
1698
|
+
throw new Error(`sandboxFiles.upload failed (${d.status})`);
|
|
1699
|
+
return String((await d.json()).path);
|
|
1700
|
+
},
|
|
1701
|
+
download: async (a) => {
|
|
1702
|
+
r();
|
|
1703
|
+
const c = await i(
|
|
1704
|
+
`/api/product-agent/attachments/sandbox-files?path=${encodeURIComponent(a)}`,
|
|
1705
|
+
{ headers: { Authorization: `Bearer ${s}` } }
|
|
1706
|
+
);
|
|
1707
|
+
if (!c.ok)
|
|
1708
|
+
throw new Error(`sandboxFiles.download failed (${c.status})`);
|
|
1709
|
+
const l = await c.blob(), p = (c.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
1710
|
+
return new File([l], p || a.split("/").pop() || "file", {
|
|
1711
|
+
type: l.type
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
}),
|
|
1715
|
+
deactivate: () => {
|
|
1716
|
+
n = !1;
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1719
|
+
}
|
|
1720
|
+
function Ks(e) {
|
|
1745
1721
|
return {
|
|
1746
1722
|
ok: !1,
|
|
1747
1723
|
exception: {
|
|
@@ -1755,18 +1731,33 @@ function Zs(e) {
|
|
|
1755
1731
|
}
|
|
1756
1732
|
};
|
|
1757
1733
|
}
|
|
1758
|
-
function
|
|
1734
|
+
function Vs(e) {
|
|
1759
1735
|
return e.replace(/\/+$/, "");
|
|
1760
1736
|
}
|
|
1761
|
-
function
|
|
1737
|
+
function Ys(e) {
|
|
1738
|
+
const t = {
|
|
1739
|
+
sidepanel: "extension_sidepanel",
|
|
1740
|
+
browser_extension_page_ui: "extension_widget",
|
|
1741
|
+
sdk_preview_widget: "extension_widget",
|
|
1742
|
+
browser_extension_sdk_preview: "extension_widget",
|
|
1743
|
+
"sdk-preview": "extension_widget",
|
|
1744
|
+
main_chat: "main_web_chat",
|
|
1745
|
+
automation_run: "automation"
|
|
1746
|
+
};
|
|
1747
|
+
return e && e in t ? t[e] : e ?? "embedded_custom_ui";
|
|
1748
|
+
}
|
|
1749
|
+
function Zs(e) {
|
|
1750
|
+
return e === "pluno" ? "scheduled_continuation" : e ?? "user";
|
|
1751
|
+
}
|
|
1752
|
+
function Qs(e, t = location.origin) {
|
|
1762
1753
|
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;
|
|
1763
1754
|
}
|
|
1764
|
-
function
|
|
1755
|
+
function tn(e) {
|
|
1765
1756
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1766
1757
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1767
1758
|
}
|
|
1768
|
-
function
|
|
1769
|
-
const e =
|
|
1759
|
+
function _() {
|
|
1760
|
+
const e = _e();
|
|
1770
1761
|
return {
|
|
1771
1762
|
url: location.href,
|
|
1772
1763
|
title: document.title,
|
|
@@ -1774,21 +1765,21 @@ function R() {
|
|
|
1774
1765
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1775
1766
|
};
|
|
1776
1767
|
}
|
|
1777
|
-
function
|
|
1768
|
+
function en() {
|
|
1778
1769
|
return {
|
|
1779
1770
|
pageUrl: location.href,
|
|
1780
1771
|
pageTitle: document.title,
|
|
1781
|
-
htmlContent:
|
|
1772
|
+
htmlContent: qt()
|
|
1782
1773
|
};
|
|
1783
1774
|
}
|
|
1784
|
-
function
|
|
1785
|
-
return
|
|
1786
|
-
|
|
1775
|
+
function sn(e) {
|
|
1776
|
+
return tt.add(e), Y || (Y = nn()), () => {
|
|
1777
|
+
tt.delete(e), tt.size === 0 && (Y?.(), Y = null);
|
|
1787
1778
|
};
|
|
1788
1779
|
}
|
|
1789
|
-
function
|
|
1780
|
+
function nn() {
|
|
1790
1781
|
const e = () => {
|
|
1791
|
-
for (const i of Array.from(
|
|
1782
|
+
for (const i of Array.from(tt))
|
|
1792
1783
|
i();
|
|
1793
1784
|
}, t = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...i) => {
|
|
1794
1785
|
const o = t(...i);
|
|
@@ -1801,35 +1792,35 @@ function rn() {
|
|
|
1801
1792
|
window.history.pushState === n && (window.history.pushState = t), window.history.replaceState === r && (window.history.replaceState = s), window.removeEventListener("popstate", e), window.removeEventListener("hashchange", e);
|
|
1802
1793
|
};
|
|
1803
1794
|
}
|
|
1804
|
-
function
|
|
1805
|
-
return
|
|
1795
|
+
function rn() {
|
|
1796
|
+
return _e()?.surface === "browser_extension_sdk_preview";
|
|
1806
1797
|
}
|
|
1807
|
-
function
|
|
1798
|
+
function qt() {
|
|
1808
1799
|
if (!document.body)
|
|
1809
1800
|
return "";
|
|
1810
|
-
const e = [], t = [], s = (
|
|
1811
|
-
const
|
|
1812
|
-
!
|
|
1801
|
+
const e = [], t = [], s = (h, f) => {
|
|
1802
|
+
const I = B(f);
|
|
1803
|
+
!I || t.includes(I) || (e.push([h, I]), t.push(I));
|
|
1813
1804
|
};
|
|
1814
1805
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
1815
1806
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", r = Array.from(document.querySelectorAll(n)).filter(
|
|
1816
|
-
(
|
|
1807
|
+
(h) => Ee(h) && !h.parentElement?.closest(n)
|
|
1817
1808
|
);
|
|
1818
|
-
for (const
|
|
1819
|
-
s("Active overlay", bt(
|
|
1820
|
-
const i =
|
|
1821
|
-
s("Main page content", o), s("Additional visible page text", bt(
|
|
1822
|
-
const a = e.map(([
|
|
1823
|
-
${
|
|
1809
|
+
for (const h of r.slice(0, 3))
|
|
1810
|
+
s("Active overlay", bt(j(h), t));
|
|
1811
|
+
const i = on(), o = i ? bt(j(i), t) : "";
|
|
1812
|
+
s("Main page content", o), s("Additional visible page text", bt(j(document.body), t));
|
|
1813
|
+
const a = e.map(([h, f]) => `${h}:
|
|
1814
|
+
${f}`).join(`
|
|
1824
1815
|
|
|
1825
|
-
`).trim().slice(0, 12e3),
|
|
1826
|
-
`,
|
|
1816
|
+
`).trim().slice(0, 12e3), c = an(r, i).trim(), l = `Simplified DOM outline:
|
|
1817
|
+
`, d = `
|
|
1827
1818
|
|
|
1828
1819
|
Visible page text:
|
|
1829
|
-
`,
|
|
1830
|
-
return `${
|
|
1820
|
+
`, p = 12e3 - l.length - d.length, y = Math.min(a.length, 7900), m = c.slice(0, p - y), u = a.slice(0, p - m.length);
|
|
1821
|
+
return `${l}${m}${d}${u}`;
|
|
1831
1822
|
}
|
|
1832
|
-
function
|
|
1823
|
+
function j(e) {
|
|
1833
1824
|
return e.innerText ?? e.textContent ?? "";
|
|
1834
1825
|
}
|
|
1835
1826
|
function B(e) {
|
|
@@ -1846,14 +1837,14 @@ function bt(e, t) {
|
|
|
1846
1837
|
s = s.replace(n, "");
|
|
1847
1838
|
return B(s);
|
|
1848
1839
|
}
|
|
1849
|
-
function
|
|
1840
|
+
function Ee(e) {
|
|
1850
1841
|
const t = window.getComputedStyle(e);
|
|
1851
1842
|
return t.display !== "none" && t.visibility !== "hidden" && e.getClientRects().length > 0;
|
|
1852
1843
|
}
|
|
1853
|
-
function
|
|
1854
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
1844
|
+
function on() {
|
|
1845
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Ee).sort((e, t) => j(t).length - j(e).length)[0] ?? null;
|
|
1855
1846
|
}
|
|
1856
|
-
function
|
|
1847
|
+
function an(e, t) {
|
|
1857
1848
|
const s = /* @__PURE__ */ new Set([
|
|
1858
1849
|
"main",
|
|
1859
1850
|
"nav",
|
|
@@ -1917,7 +1908,7 @@ function cn(e, t) {
|
|
|
1917
1908
|
"tab",
|
|
1918
1909
|
"menuitem",
|
|
1919
1910
|
"option"
|
|
1920
|
-
]),
|
|
1911
|
+
]), c = [
|
|
1921
1912
|
"role",
|
|
1922
1913
|
"aria-label",
|
|
1923
1914
|
"aria-current",
|
|
@@ -1933,95 +1924,95 @@ function cn(e, t) {
|
|
|
1933
1924
|
"data-test",
|
|
1934
1925
|
"data-qa",
|
|
1935
1926
|
"data-cy"
|
|
1936
|
-
],
|
|
1937
|
-
t &&
|
|
1938
|
-
let
|
|
1939
|
-
const
|
|
1940
|
-
const U =
|
|
1927
|
+
], l = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: d, priorityTargets: p } = cn(), y = new Set(e);
|
|
1928
|
+
t && y.add(t);
|
|
1929
|
+
let m = 0;
|
|
1930
|
+
const u = (T) => {
|
|
1931
|
+
const U = T.getAttribute("role");
|
|
1941
1932
|
return U && !o.has(U) ? U : "";
|
|
1942
|
-
},
|
|
1943
|
-
const U =
|
|
1944
|
-
return `${
|
|
1945
|
-
},
|
|
1946
|
-
const
|
|
1947
|
-
const
|
|
1948
|
-
if (
|
|
1933
|
+
}, h = (T) => {
|
|
1934
|
+
const U = T.getAttribute("data-testid") || T.getAttribute("data-test") || T.getAttribute("data-qa") || T.getAttribute("data-cy") || "";
|
|
1935
|
+
return `${T.tagName.toLowerCase()}|${u(T)}|${U}`;
|
|
1936
|
+
}, f = (T, U, H) => {
|
|
1937
|
+
const R = (A, ct) => {
|
|
1938
|
+
const E = A.tagName.toLowerCase(), lt = window.getComputedStyle(A), z = d.has(A);
|
|
1939
|
+
if (m >= 1e3 && !z || H.has(A) || i.has(E) || A.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || lt.display === "none" || lt.visibility === "hidden")
|
|
1949
1940
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
1950
|
-
|
|
1951
|
-
const
|
|
1952
|
-
for (const
|
|
1953
|
-
const
|
|
1954
|
-
X.set(
|
|
1941
|
+
m += 1;
|
|
1942
|
+
const zt = u(A), G = Re(A), je = a.has(zt) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(E) || E === "a" && A.hasAttribute("href"), ut = Array.from(A.children).filter((g) => g instanceof HTMLElement), X = /* @__PURE__ */ new Map();
|
|
1943
|
+
for (const g of ut) {
|
|
1944
|
+
const w = h(g);
|
|
1945
|
+
X.set(w, (X.get(w) ?? 0) + 1);
|
|
1955
1946
|
}
|
|
1956
|
-
const
|
|
1957
|
-
for (const
|
|
1958
|
-
const
|
|
1959
|
-
|
|
1947
|
+
const dt = /* @__PURE__ */ new Map(), Gt = /* @__PURE__ */ new Map();
|
|
1948
|
+
for (const g of ut) {
|
|
1949
|
+
const w = h(g), D = Gt.get(w) ?? 0;
|
|
1950
|
+
Gt.set(w, D + 1), (X.get(w) ?? 0) > 8 && D >= 6 && !d.has(g) && dt.set(w, (dt.get(w) ?? 0) + 1);
|
|
1960
1951
|
}
|
|
1961
|
-
const
|
|
1962
|
-
for (const
|
|
1963
|
-
const
|
|
1964
|
-
if (
|
|
1965
|
-
|
|
1952
|
+
const Xt = /* @__PURE__ */ new Map(), Jt = /* @__PURE__ */ new Set(), ht = [], Kt = [];
|
|
1953
|
+
for (const g of ut) {
|
|
1954
|
+
const w = h(g), D = X.get(w) ?? 0, Zt = Xt.get(w) ?? 0;
|
|
1955
|
+
if (Xt.set(w, Zt + 1), D > 8 && Zt >= 6 && !d.has(g)) {
|
|
1956
|
+
Jt.has(w) || (ht.push([`… ${dt.get(w) ?? 0} similar siblings omitted`]), Jt.add(w));
|
|
1966
1957
|
continue;
|
|
1967
1958
|
}
|
|
1968
|
-
const
|
|
1969
|
-
|
|
1959
|
+
const Qt = R(g, ct);
|
|
1960
|
+
Kt.push(Qt), ht.push(Qt.lines);
|
|
1970
1961
|
}
|
|
1971
|
-
const
|
|
1972
|
-
if (
|
|
1973
|
-
for (const
|
|
1974
|
-
|
|
1975
|
-
const J = [...
|
|
1976
|
-
[G, ...J.map((
|
|
1977
|
-
).slice(0, 180),
|
|
1978
|
-
if (
|
|
1979
|
-
const
|
|
1980
|
-
|
|
1962
|
+
const pt = [];
|
|
1963
|
+
if (A.shadowRoot)
|
|
1964
|
+
for (const g of Array.from(A.shadowRoot.children))
|
|
1965
|
+
g instanceof HTMLElement && pt.push(R(g, ct + 1));
|
|
1966
|
+
const J = [...Kt, ...pt], ft = G.length > 0 || je || J.some((g) => g.hasUsefulContent), Vt = B(
|
|
1967
|
+
[G, ...J.map((g) => g.textPreview)].filter(Boolean).join(" ")
|
|
1968
|
+
).slice(0, 180), ze = A.hasAttribute("contenteditable") && (G.length > 0 || !A.querySelector("[contenteditable]")), Yt = l.some((g) => A.hasAttribute(g)) || !!zt || ze, gt = (A.getClientRects().length > 0 || lt.display === "contents") && (s.has(E) || Yt || z) && (ft || z) && (!r.has(E) || ft || Yt || z), mt = gt ? 1 : 0, F = [];
|
|
1969
|
+
if (gt) {
|
|
1970
|
+
const g = J.some((D) => D.containsTextElement), w = n.has(E) && !g ? Vt : G;
|
|
1971
|
+
F.push(ke(A, c, o, w.slice(0, 180)));
|
|
1981
1972
|
}
|
|
1982
|
-
for (const
|
|
1983
|
-
|
|
1984
|
-
const
|
|
1985
|
-
if (
|
|
1986
|
-
const
|
|
1987
|
-
|
|
1988
|
-
const
|
|
1989
|
-
if (
|
|
1990
|
-
const D =
|
|
1991
|
-
|
|
1973
|
+
for (const g of ht)
|
|
1974
|
+
F.push(...Z(g, mt));
|
|
1975
|
+
const yt = pt.flatMap((g) => g.lines);
|
|
1976
|
+
if (yt.length > 0) {
|
|
1977
|
+
const g = yt.slice(0, 20);
|
|
1978
|
+
yt.length > g.length && g.push("… shadow DOM omitted");
|
|
1979
|
+
const w = E.includes("tooltip") || E.includes("popper") || E.includes("loader");
|
|
1980
|
+
if (ct < 2 && !w) {
|
|
1981
|
+
const D = gt ? "#shadow-root" : `${E} #shadow-root`;
|
|
1982
|
+
F.push(...Z([D, ...Z(g, 1)], mt));
|
|
1992
1983
|
} else
|
|
1993
|
-
|
|
1984
|
+
F.push(...Z(g, mt));
|
|
1994
1985
|
}
|
|
1995
1986
|
return {
|
|
1996
|
-
lines:
|
|
1997
|
-
hasUsefulContent:
|
|
1998
|
-
textPreview:
|
|
1999
|
-
containsTextElement: n.has(
|
|
1987
|
+
lines: F,
|
|
1988
|
+
hasUsefulContent: ft,
|
|
1989
|
+
textPreview: Vt,
|
|
1990
|
+
containsTextElement: n.has(E) || J.some((g) => g.containsTextElement)
|
|
2000
1991
|
};
|
|
2001
1992
|
};
|
|
2002
|
-
return [`--- ${U} ---`, ...
|
|
1993
|
+
return [`--- ${U} ---`, ...R(T, 0).lines].join(`
|
|
2003
1994
|
`);
|
|
2004
|
-
},
|
|
2005
|
-
|
|
2006
|
-
${JSON.stringify(
|
|
2007
|
-
for (const
|
|
2008
|
-
|
|
2009
|
-
if (t &&
|
|
2010
|
-
const
|
|
2011
|
-
|
|
2012
|
-
}
|
|
2013
|
-
return
|
|
1995
|
+
}, I = [], x = B(window.getSelection()?.toString() ?? "");
|
|
1996
|
+
x && I.push(`--- selected text ---
|
|
1997
|
+
${JSON.stringify(x)}`), p.length > 0 && I.push(ln(p, s, c, o));
|
|
1998
|
+
for (const T of e.slice(0, 3))
|
|
1999
|
+
I.push(f(T, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
2000
|
+
if (t && I.push(f(t, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
2001
|
+
const T = t || e.length ? "other visible DOM" : "visible DOM";
|
|
2002
|
+
I.push(f(document.body, T, y));
|
|
2003
|
+
}
|
|
2004
|
+
return I.join(`
|
|
2014
2005
|
|
|
2015
2006
|
`);
|
|
2016
2007
|
}
|
|
2017
|
-
function
|
|
2008
|
+
function ke(e, t, s, n) {
|
|
2018
2009
|
const r = e.tagName.toLowerCase();
|
|
2019
2010
|
let i = r;
|
|
2020
2011
|
const o = e.getAttribute("id");
|
|
2021
|
-
o &&
|
|
2012
|
+
o && un(o) && (i += `#${o}`);
|
|
2022
2013
|
for (const a of t) {
|
|
2023
|
-
const
|
|
2024
|
-
|
|
2014
|
+
const c = e.getAttribute(a);
|
|
2015
|
+
c && c.length <= 160 && (a !== "role" || !s.has(c)) && (i += `[${a}=${JSON.stringify(c)}]`);
|
|
2025
2016
|
}
|
|
2026
2017
|
if (r === "a" || r === "iframe") {
|
|
2027
2018
|
const a = e.getAttribute(r === "a" ? "href" : "src");
|
|
@@ -2031,20 +2022,20 @@ function Ce(e, t, s, n) {
|
|
|
2031
2022
|
e.hasAttribute(a) && (i += `[${a}]`);
|
|
2032
2023
|
return `${i}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
2033
2024
|
}
|
|
2034
|
-
function
|
|
2035
|
-
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a,
|
|
2025
|
+
function cn() {
|
|
2026
|
+
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), s = (a, c) => {
|
|
2036
2027
|
if (!a)
|
|
2037
2028
|
return;
|
|
2038
|
-
const
|
|
2039
|
-
if (
|
|
2029
|
+
const l = window.getComputedStyle(a);
|
|
2030
|
+
if (l.display === "none" || l.visibility === "hidden")
|
|
2040
2031
|
return;
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2043
|
-
let
|
|
2044
|
-
for (;
|
|
2045
|
-
e.add(
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2032
|
+
const d = t.get(a) ?? /* @__PURE__ */ new Set();
|
|
2033
|
+
d.add(c), t.set(a, d);
|
|
2034
|
+
let p = a;
|
|
2035
|
+
for (; p; ) {
|
|
2036
|
+
e.add(p);
|
|
2037
|
+
const y = p.getRootNode();
|
|
2038
|
+
p = p.parentElement ?? (y instanceof ShadowRoot && y.host instanceof HTMLElement ? y.host : null);
|
|
2048
2039
|
}
|
|
2049
2040
|
};
|
|
2050
2041
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -2052,7 +2043,7 @@ function ln() {
|
|
|
2052
2043
|
n = n.shadowRoot.activeElement;
|
|
2053
2044
|
n !== document.body && n !== document.documentElement && s(n, "focused");
|
|
2054
2045
|
const r = window.getSelection();
|
|
2055
|
-
r && !r.isCollapsed && (s(
|
|
2046
|
+
r && !r.isCollapsed && (s(ae(r.anchorNode), "selected text"), s(ae(r.focusNode), "selected text"));
|
|
2056
2047
|
const i = [
|
|
2057
2048
|
["[aria-selected='true']", "selected"],
|
|
2058
2049
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -2062,41 +2053,41 @@ function ln() {
|
|
|
2062
2053
|
["[open]", "open"]
|
|
2063
2054
|
], o = [document];
|
|
2064
2055
|
for (let a = 0; a < o.length; a += 1) {
|
|
2065
|
-
const
|
|
2066
|
-
for (const [
|
|
2067
|
-
for (const
|
|
2068
|
-
s(
|
|
2069
|
-
for (const
|
|
2070
|
-
|
|
2056
|
+
const c = o[a];
|
|
2057
|
+
for (const [l, d] of i)
|
|
2058
|
+
for (const p of Array.from(c.querySelectorAll(l)))
|
|
2059
|
+
s(p, d);
|
|
2060
|
+
for (const l of Array.from(c.querySelectorAll("*")))
|
|
2061
|
+
l.shadowRoot && o.push(l.shadowRoot);
|
|
2071
2062
|
}
|
|
2072
2063
|
return {
|
|
2073
2064
|
priorityElements: e,
|
|
2074
|
-
priorityTargets: Array.from(t, ([a,
|
|
2065
|
+
priorityTargets: Array.from(t, ([a, c]) => ({ element: a, labels: Array.from(c) }))
|
|
2075
2066
|
};
|
|
2076
2067
|
}
|
|
2077
|
-
function
|
|
2068
|
+
function ln(e, t, s, n) {
|
|
2078
2069
|
const r = ["--- active/current elements ---"];
|
|
2079
2070
|
for (const i of e) {
|
|
2080
2071
|
const o = [];
|
|
2081
2072
|
let a = i.element;
|
|
2082
2073
|
for (; a; ) {
|
|
2083
|
-
const
|
|
2084
|
-
(a === i.element || t.has(
|
|
2085
|
-
const
|
|
2086
|
-
a = a.parentElement ?? (
|
|
2074
|
+
const d = a.tagName.toLowerCase();
|
|
2075
|
+
(a === i.element || t.has(d) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
2076
|
+
const p = a.getRootNode();
|
|
2077
|
+
a = a.parentElement ?? (p instanceof ShadowRoot && p.host instanceof HTMLElement ? p.host : null);
|
|
2087
2078
|
}
|
|
2088
|
-
const
|
|
2089
|
-
|
|
2079
|
+
const c = o.length > 6 ? [o[0], ...o.slice(-5)] : o, l = c.map((d, p) => ke(
|
|
2080
|
+
d,
|
|
2090
2081
|
s,
|
|
2091
2082
|
n,
|
|
2092
|
-
|
|
2083
|
+
p === c.length - 1 ? Re(d).slice(0, 180) : ""
|
|
2093
2084
|
));
|
|
2094
|
-
o.length >
|
|
2085
|
+
o.length > c.length && l.splice(1, 0, "…"), r.push(`${i.labels.join(", ")}: ${l.join(" > ")}`);
|
|
2095
2086
|
}
|
|
2096
2087
|
return r.join(`
|
|
2097
2088
|
`);
|
|
2098
2089
|
}
|
|
2099
|
-
function
|
|
2090
|
+
function ae(e) {
|
|
2100
2091
|
return e instanceof HTMLElement ? e : e?.parentElement instanceof HTMLElement ? e.parentElement : null;
|
|
2101
2092
|
}
|
|
2102
2093
|
function Z(e, t) {
|
|
@@ -2105,17 +2096,17 @@ function Z(e, t) {
|
|
|
2105
2096
|
const s = " ".repeat(t);
|
|
2106
2097
|
return e.map((n) => `${s}${n}`);
|
|
2107
2098
|
}
|
|
2108
|
-
function
|
|
2099
|
+
function Re(e) {
|
|
2109
2100
|
return B(
|
|
2110
2101
|
Array.from(e.childNodes).filter((t) => t.nodeType === Node.TEXT_NODE).map((t) => t.textContent ?? "").join(" ")
|
|
2111
2102
|
);
|
|
2112
2103
|
}
|
|
2113
|
-
function
|
|
2104
|
+
function un(e) {
|
|
2114
2105
|
return e.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(e) && !/[a-f0-9]{12,}/i.test(e) && !/:r[0-9a-z]+:/i.test(e);
|
|
2115
2106
|
}
|
|
2116
|
-
function
|
|
2117
|
-
const e = document.querySelector(
|
|
2118
|
-
if (!(e ?? document.querySelector(
|
|
2107
|
+
function _e() {
|
|
2108
|
+
const e = document.querySelector(te);
|
|
2109
|
+
if (!(e ?? document.querySelector(Mt)))
|
|
2119
2110
|
return;
|
|
2120
2111
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2121
2112
|
return {
|
|
@@ -2124,28 +2115,28 @@ function Ue() {
|
|
|
2124
2115
|
selectors: [
|
|
2125
2116
|
{
|
|
2126
2117
|
name: "widget_host",
|
|
2127
|
-
selector: s === "browser_extension_sdk_preview" ?
|
|
2118
|
+
selector: s === "browser_extension_sdk_preview" ? te : Mt,
|
|
2128
2119
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2129
2120
|
},
|
|
2130
2121
|
{
|
|
2131
2122
|
name: "widget_root",
|
|
2132
|
-
selector:
|
|
2123
|
+
selector: cs,
|
|
2133
2124
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
2134
2125
|
},
|
|
2135
2126
|
{
|
|
2136
2127
|
name: "widget_panel",
|
|
2137
|
-
selector:
|
|
2128
|
+
selector: ls,
|
|
2138
2129
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
2139
2130
|
},
|
|
2140
2131
|
{
|
|
2141
2132
|
name: "widget_timeline",
|
|
2142
|
-
selector:
|
|
2133
|
+
selector: us,
|
|
2143
2134
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
2144
2135
|
}
|
|
2145
2136
|
]
|
|
2146
2137
|
};
|
|
2147
2138
|
}
|
|
2148
|
-
function
|
|
2139
|
+
function dn(e) {
|
|
2149
2140
|
try {
|
|
2150
2141
|
const t = JSON.parse(e);
|
|
2151
2142
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -2153,16 +2144,16 @@ function hn(e) {
|
|
|
2153
2144
|
return { type: "error", message: "Invalid server event" };
|
|
2154
2145
|
}
|
|
2155
2146
|
}
|
|
2156
|
-
function
|
|
2147
|
+
function ce(e, t) {
|
|
2157
2148
|
if (!e || typeof e != "object")
|
|
2158
2149
|
return [];
|
|
2159
2150
|
const s = e[t];
|
|
2160
2151
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
2161
2152
|
}
|
|
2162
|
-
function
|
|
2153
|
+
function hn(e) {
|
|
2163
2154
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
2164
2155
|
}
|
|
2165
|
-
function
|
|
2156
|
+
function pn(e) {
|
|
2166
2157
|
if (!e || typeof e != "object")
|
|
2167
2158
|
return null;
|
|
2168
2159
|
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, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -2173,13 +2164,13 @@ function fn(e) {
|
|
|
2173
2164
|
...a !== null ? { scribbleStyle: a } : {}
|
|
2174
2165
|
};
|
|
2175
2166
|
}
|
|
2176
|
-
function
|
|
2167
|
+
function fn(e) {
|
|
2177
2168
|
if (!e || typeof e != "object")
|
|
2178
2169
|
return null;
|
|
2179
2170
|
const t = e.javascript;
|
|
2180
2171
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
2181
2172
|
}
|
|
2182
|
-
function
|
|
2173
|
+
function gn(e, t) {
|
|
2183
2174
|
return t ? e && typeof e == "object" ? {
|
|
2184
2175
|
...e,
|
|
2185
2176
|
helperError: t
|
|
@@ -2189,20 +2180,20 @@ function mn(e, t) {
|
|
|
2189
2180
|
helperError: t
|
|
2190
2181
|
} : e;
|
|
2191
2182
|
}
|
|
2192
|
-
function
|
|
2183
|
+
function mn(e) {
|
|
2193
2184
|
if (!e || typeof e != "object")
|
|
2194
2185
|
return e;
|
|
2195
2186
|
const t = e;
|
|
2196
2187
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
2197
2188
|
}
|
|
2198
|
-
function
|
|
2189
|
+
function yn() {
|
|
2199
2190
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
2200
2191
|
if (t)
|
|
2201
2192
|
return t;
|
|
2202
2193
|
const s = crypto.randomUUID();
|
|
2203
2194
|
return window.localStorage.setItem(e, s), s;
|
|
2204
2195
|
}
|
|
2205
|
-
function
|
|
2196
|
+
function Et() {
|
|
2206
2197
|
return crypto.randomUUID();
|
|
2207
2198
|
}
|
|
2208
2199
|
function In(e) {
|
|
@@ -2216,23 +2207,23 @@ function In(e) {
|
|
|
2216
2207
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
2217
2208
|
} : null;
|
|
2218
2209
|
}
|
|
2219
|
-
function
|
|
2220
|
-
return Array.isArray(e) ?
|
|
2221
|
-
|
|
2222
|
-
e.map((s) =>
|
|
2210
|
+
function Tn(e, t) {
|
|
2211
|
+
return Array.isArray(e) ? Dt(
|
|
2212
|
+
xt(
|
|
2213
|
+
e.map((s) => Me(s, t)).filter((s) => s !== null)
|
|
2223
2214
|
)
|
|
2224
2215
|
) : [];
|
|
2225
2216
|
}
|
|
2226
|
-
function
|
|
2217
|
+
function wn(e) {
|
|
2227
2218
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
2228
2219
|
if (!t || typeof t != "object")
|
|
2229
2220
|
return [];
|
|
2230
|
-
const s = t, n =
|
|
2221
|
+
const s = t, n = b(s, "id"), r = b(s, "createdAt"), i = b(s, "updatedAt"), o = b(s, "lastActiveAt");
|
|
2231
2222
|
return !n || !r || !i || !o ? [] : [
|
|
2232
2223
|
{
|
|
2233
2224
|
id: n,
|
|
2234
|
-
title:
|
|
2235
|
-
firstUserMessage:
|
|
2225
|
+
title: b(s, "title"),
|
|
2226
|
+
firstUserMessage: b(s, "firstUserMessage"),
|
|
2236
2227
|
currentPage: s.currentPage ?? null,
|
|
2237
2228
|
createdAt: r,
|
|
2238
2229
|
updatedAt: i,
|
|
@@ -2242,7 +2233,7 @@ function An(e) {
|
|
|
2242
2233
|
];
|
|
2243
2234
|
}) : [];
|
|
2244
2235
|
}
|
|
2245
|
-
function
|
|
2236
|
+
function Me(e, t) {
|
|
2246
2237
|
if (!e || typeof e != "object")
|
|
2247
2238
|
return null;
|
|
2248
2239
|
const s = e, n = s.data;
|
|
@@ -2258,11 +2249,11 @@ function De(e, t) {
|
|
|
2258
2249
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2259
2250
|
role: i,
|
|
2260
2251
|
...r.phase === "commentary" || r.phase === "final_answer" ? { phase: r.phase } : {},
|
|
2261
|
-
content:
|
|
2252
|
+
content: _n(r.content),
|
|
2262
2253
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2263
|
-
respondsToUserMessageId:
|
|
2254
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2264
2255
|
...M(r) ? { runId: M(r) } : {},
|
|
2265
|
-
attachments:
|
|
2256
|
+
attachments: ve(r.attachments, t)
|
|
2266
2257
|
};
|
|
2267
2258
|
return i === "assistant" && typeof r.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
2268
2259
|
value: r.id,
|
|
@@ -2273,37 +2264,37 @@ function De(e, t) {
|
|
|
2273
2264
|
}), o;
|
|
2274
2265
|
}
|
|
2275
2266
|
if (r.type === "function_call_output") {
|
|
2276
|
-
const i =
|
|
2267
|
+
const i = An(r.output);
|
|
2277
2268
|
return i ? {
|
|
2278
2269
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2279
2270
|
role: "tool",
|
|
2280
2271
|
content: `Connect ${i.appName} to continue`,
|
|
2281
2272
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2282
|
-
respondsToUserMessageId:
|
|
2273
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2283
2274
|
...M(r) ? { runId: M(r) } : {},
|
|
2284
2275
|
dataType: "function_call_output",
|
|
2285
2276
|
toolName: "authenticate_pipedream_app",
|
|
2286
|
-
callId:
|
|
2277
|
+
callId: le(r) ?? void 0,
|
|
2287
2278
|
integrationAuthRequest: i
|
|
2288
2279
|
} : null;
|
|
2289
2280
|
}
|
|
2290
2281
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" || r.type === "mcp_call" || r.type === "tab_lifecycle_decision" ? {
|
|
2291
2282
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2292
2283
|
role: "tool",
|
|
2293
|
-
content: r.type === "mcp_call" ? Sn(r) :
|
|
2284
|
+
content: r.type === "mcp_call" ? Sn(r) : En(r),
|
|
2294
2285
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2295
|
-
respondsToUserMessageId:
|
|
2286
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2296
2287
|
...M(r) ? { runId: M(r) } : {},
|
|
2297
2288
|
dataType: String(r.type),
|
|
2298
2289
|
toolName: r.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof r.name == "string" ? r.name : void 0,
|
|
2299
|
-
callId:
|
|
2300
|
-
loading: r.localExecutionStatus === "running"
|
|
2290
|
+
callId: le(r) ?? void 0,
|
|
2291
|
+
loading: r.localExecutionStatus === "queued" || r.localExecutionStatus === "running" ? !0 : typeof r.localExecutionStatus == "string" ? !1 : void 0
|
|
2301
2292
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
2302
2293
|
id: String(s.id ?? crypto.randomUUID()),
|
|
2303
2294
|
role: "system",
|
|
2304
|
-
content:
|
|
2295
|
+
content: bn(r),
|
|
2305
2296
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
2306
|
-
respondsToUserMessageId:
|
|
2297
|
+
respondsToUserMessageId: v(r) ?? void 0,
|
|
2307
2298
|
...M(r) ? { runId: M(r) } : {},
|
|
2308
2299
|
dataType: String(r.type),
|
|
2309
2300
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying"),
|
|
@@ -2315,7 +2306,7 @@ function Sn(e) {
|
|
|
2315
2306
|
const s = (typeof e.server_label == "string" ? e.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
2316
2307
|
return s ? `🔌 Using ${s}` : "🔌 Using connected integration";
|
|
2317
2308
|
}
|
|
2318
|
-
function
|
|
2309
|
+
function An(e) {
|
|
2319
2310
|
if (typeof e != "string")
|
|
2320
2311
|
return null;
|
|
2321
2312
|
try {
|
|
@@ -2332,10 +2323,10 @@ function En(e) {
|
|
|
2332
2323
|
return null;
|
|
2333
2324
|
}
|
|
2334
2325
|
}
|
|
2335
|
-
function
|
|
2326
|
+
function bn(e) {
|
|
2336
2327
|
return e.type === "run_status" && e.status === "stopped" ? "Run stopped by user" : 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." : "Pluno run status changed.";
|
|
2337
2328
|
}
|
|
2338
|
-
function
|
|
2329
|
+
function En(e) {
|
|
2339
2330
|
if (e.type === "web_search_call") {
|
|
2340
2331
|
const t = e.action;
|
|
2341
2332
|
if (t && typeof t == "object") {
|
|
@@ -2347,26 +2338,26 @@ function bn(e) {
|
|
|
2347
2338
|
}
|
|
2348
2339
|
return "🔎 Searching the web";
|
|
2349
2340
|
}
|
|
2350
|
-
return
|
|
2341
|
+
return kn(e);
|
|
2351
2342
|
}
|
|
2352
|
-
function
|
|
2343
|
+
function kn(e) {
|
|
2353
2344
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
2354
|
-
return
|
|
2345
|
+
return N(e.summary);
|
|
2355
2346
|
if (typeof e.arguments == "string")
|
|
2356
2347
|
try {
|
|
2357
2348
|
const t = JSON.parse(e.arguments);
|
|
2358
2349
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
2359
|
-
return
|
|
2350
|
+
return N(t.summary);
|
|
2360
2351
|
} catch {
|
|
2361
|
-
return typeof e.name == "string" && e.name.trim().length > 0 ?
|
|
2352
|
+
return typeof e.name == "string" && e.name.trim().length > 0 ? N(e.name) : "🛠️ Run tool";
|
|
2362
2353
|
}
|
|
2363
|
-
return typeof e.name == "string" && e.name.trim().length > 0 ?
|
|
2354
|
+
return typeof e.name == "string" && e.name.trim().length > 0 ? N(e.name) : "🛠️ Run tool";
|
|
2364
2355
|
}
|
|
2365
|
-
function
|
|
2356
|
+
function N(e) {
|
|
2366
2357
|
const t = e.trim() || "Run tool", s = t.codePointAt(0) ?? 0;
|
|
2367
2358
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? t : `🛠️ ${t}`;
|
|
2368
2359
|
}
|
|
2369
|
-
function
|
|
2360
|
+
function Rn(e) {
|
|
2370
2361
|
if (e == null)
|
|
2371
2362
|
return e;
|
|
2372
2363
|
if (typeof e != "object")
|
|
@@ -2381,11 +2372,11 @@ function _n(e) {
|
|
|
2381
2372
|
runId: typeof t.runId == "string" ? t.runId : null
|
|
2382
2373
|
};
|
|
2383
2374
|
}
|
|
2384
|
-
function
|
|
2375
|
+
function le(e) {
|
|
2385
2376
|
const t = e.callId ?? e.call_id;
|
|
2386
2377
|
return typeof t == "string" && t ? t : null;
|
|
2387
2378
|
}
|
|
2388
|
-
function
|
|
2379
|
+
function _n(e) {
|
|
2389
2380
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
2390
2381
|
if (!t || typeof t != "object")
|
|
2391
2382
|
return "";
|
|
@@ -2393,24 +2384,24 @@ function Mn(e) {
|
|
|
2393
2384
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
2394
2385
|
}).filter(Boolean).join("") : "";
|
|
2395
2386
|
}
|
|
2396
|
-
function
|
|
2397
|
-
const s =
|
|
2398
|
-
|
|
2387
|
+
function Ce(e, t) {
|
|
2388
|
+
const s = Pe(e, t), n = Un(
|
|
2389
|
+
On(e, t),
|
|
2399
2390
|
s
|
|
2400
2391
|
), r = n.findIndex((o) => o.id === s.id);
|
|
2401
2392
|
if (r === -1)
|
|
2402
|
-
return
|
|
2403
|
-
|
|
2393
|
+
return Dt(
|
|
2394
|
+
xt([...n, s])
|
|
2404
2395
|
);
|
|
2405
2396
|
const i = [...n];
|
|
2406
|
-
return i[r] = s,
|
|
2397
|
+
return i[r] = s, Dt(xt(i));
|
|
2407
2398
|
}
|
|
2408
|
-
function
|
|
2399
|
+
function Mn(e, t) {
|
|
2409
2400
|
const s = e.findIndex(
|
|
2410
2401
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === t.callId
|
|
2411
2402
|
);
|
|
2412
2403
|
if (s === -1)
|
|
2413
|
-
return
|
|
2404
|
+
return Ce(e, t);
|
|
2414
2405
|
const n = [...e];
|
|
2415
2406
|
return n[s] = {
|
|
2416
2407
|
...n[s],
|
|
@@ -2418,17 +2409,17 @@ function Cn(e, t) {
|
|
|
2418
2409
|
loading: !0
|
|
2419
2410
|
}, n;
|
|
2420
2411
|
}
|
|
2421
|
-
function
|
|
2412
|
+
function Cn(e, t, s) {
|
|
2422
2413
|
let n = !1;
|
|
2423
2414
|
const r = e.map((i) => i.callId !== t || i.loading === s ? i : (n = !0, { ...i, loading: s }));
|
|
2424
2415
|
return n ? r : e;
|
|
2425
2416
|
}
|
|
2426
|
-
function
|
|
2417
|
+
function Pn(e) {
|
|
2427
2418
|
const t = typeof e.callId == "string" ? e.callId : null, s = typeof e.toolName == "string" ? e.toolName : null;
|
|
2428
2419
|
return !t || !s ? null : {
|
|
2429
2420
|
id: `transient-activity:${t}`,
|
|
2430
2421
|
role: "tool",
|
|
2431
|
-
content:
|
|
2422
|
+
content: N(
|
|
2432
2423
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
2433
2424
|
),
|
|
2434
2425
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -2440,7 +2431,7 @@ function Un(e) {
|
|
|
2440
2431
|
loading: !0
|
|
2441
2432
|
};
|
|
2442
2433
|
}
|
|
2443
|
-
function
|
|
2434
|
+
function Un(e, t) {
|
|
2444
2435
|
if (t.id.startsWith("transient-activity:"))
|
|
2445
2436
|
return e;
|
|
2446
2437
|
const s = t.toolName === "tab_lifecycle";
|
|
@@ -2448,52 +2439,52 @@ function Dn(e, t) {
|
|
|
2448
2439
|
(n) => !(n.id === `transient-activity:${t.callId}` && n.callId === t.callId || s && n.id.startsWith("transient-activity:") && n.toolName === "browser_tabs" && n.runId === t.runId && n.respondsToUserMessageId === t.respondsToUserMessageId)
|
|
2449
2440
|
);
|
|
2450
2441
|
}
|
|
2451
|
-
function
|
|
2442
|
+
function Dn(e, t) {
|
|
2452
2443
|
const s = t.map(
|
|
2453
|
-
(n) =>
|
|
2444
|
+
(n) => Pe(e, n)
|
|
2454
2445
|
);
|
|
2455
|
-
return t.length > 0 ? s : e.filter(
|
|
2446
|
+
return t.length > 0 ? s : e.filter(Ht);
|
|
2456
2447
|
}
|
|
2457
|
-
function
|
|
2448
|
+
function Pe(e, t) {
|
|
2458
2449
|
if (t.role !== "user" || !t.attachments?.length)
|
|
2459
2450
|
return t;
|
|
2460
2451
|
const s = e.find(
|
|
2461
|
-
(r) => r.role === "user" && (r.id === t.id ||
|
|
2452
|
+
(r) => r.role === "user" && (r.id === t.id || Ht(r) && Ue(r, t))
|
|
2462
2453
|
);
|
|
2463
2454
|
if (!s?.attachments?.length)
|
|
2464
2455
|
return t;
|
|
2465
2456
|
const n = t.attachments.map((r) => {
|
|
2466
|
-
const i =
|
|
2457
|
+
const i = xn(s.attachments ?? [], r);
|
|
2467
2458
|
return i ? vn(r, i) : r;
|
|
2468
2459
|
});
|
|
2469
2460
|
return { ...t, attachments: n };
|
|
2470
2461
|
}
|
|
2471
|
-
function
|
|
2462
|
+
function xn(e, t) {
|
|
2472
2463
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
2473
2464
|
}
|
|
2474
2465
|
function vn(e, t) {
|
|
2475
2466
|
const { previewUrl: s } = t;
|
|
2476
2467
|
return s ? { ...e, previewUrl: s } : e;
|
|
2477
2468
|
}
|
|
2478
|
-
function
|
|
2469
|
+
function On(e, t) {
|
|
2479
2470
|
if (t.role !== "user")
|
|
2480
2471
|
return e;
|
|
2481
2472
|
const s = e.findIndex(
|
|
2482
|
-
(r) =>
|
|
2473
|
+
(r) => Ht(r) && Ue(r, t)
|
|
2483
2474
|
);
|
|
2484
2475
|
if (s === -1)
|
|
2485
2476
|
return e;
|
|
2486
2477
|
const n = [...e];
|
|
2487
2478
|
return n.splice(s, 1), n;
|
|
2488
2479
|
}
|
|
2489
|
-
function
|
|
2490
|
-
const s =
|
|
2480
|
+
function Ue(e, t) {
|
|
2481
|
+
const s = ue(e), n = ue(t);
|
|
2491
2482
|
return s && n ? s === n : e.content === t.content;
|
|
2492
2483
|
}
|
|
2493
|
-
function
|
|
2484
|
+
function Ht(e) {
|
|
2494
2485
|
return e.role === "user" && (e.id.startsWith("local-") || e.id.startsWith("optimistic-user-message:"));
|
|
2495
2486
|
}
|
|
2496
|
-
function
|
|
2487
|
+
function ue(e) {
|
|
2497
2488
|
const t = e.clientMessageId;
|
|
2498
2489
|
if (t)
|
|
2499
2490
|
return t;
|
|
@@ -2502,13 +2493,13 @@ function pe(e) {
|
|
|
2502
2493
|
);
|
|
2503
2494
|
return n ? e.id.slice(n.length) : null;
|
|
2504
2495
|
}
|
|
2505
|
-
function
|
|
2506
|
-
const t =
|
|
2496
|
+
function de(e) {
|
|
2497
|
+
const t = De(e);
|
|
2507
2498
|
if (t === null)
|
|
2508
2499
|
return !1;
|
|
2509
2500
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
2510
2501
|
const n = e[s];
|
|
2511
|
-
if (
|
|
2502
|
+
if (q(n))
|
|
2512
2503
|
return !0;
|
|
2513
2504
|
if (n.role === "system") {
|
|
2514
2505
|
if (n.dataType === "run_error")
|
|
@@ -2519,20 +2510,20 @@ function fe(e) {
|
|
|
2519
2510
|
}
|
|
2520
2511
|
return !1;
|
|
2521
2512
|
}
|
|
2522
|
-
function
|
|
2523
|
-
const t =
|
|
2524
|
-
return t === null ? e.some(
|
|
2513
|
+
function Nn(e) {
|
|
2514
|
+
const t = De(e);
|
|
2515
|
+
return t === null ? e.some(q) : e.slice(t + 1).some(q);
|
|
2525
2516
|
}
|
|
2526
|
-
function
|
|
2517
|
+
function De(e) {
|
|
2527
2518
|
for (let t = e.length - 1; t >= 0; t -= 1)
|
|
2528
2519
|
if (e[t].role === "user")
|
|
2529
2520
|
return t;
|
|
2530
2521
|
return null;
|
|
2531
2522
|
}
|
|
2532
|
-
function
|
|
2533
|
-
return
|
|
2523
|
+
function Ln(e) {
|
|
2524
|
+
return q(e) ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
2534
2525
|
}
|
|
2535
|
-
function
|
|
2526
|
+
function it(e) {
|
|
2536
2527
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
2537
2528
|
const s = e[t];
|
|
2538
2529
|
if (!s || typeof s != "object")
|
|
@@ -2546,40 +2537,40 @@ function at(e) {
|
|
|
2546
2537
|
}
|
|
2547
2538
|
return null;
|
|
2548
2539
|
}
|
|
2549
|
-
function
|
|
2550
|
-
const t =
|
|
2540
|
+
function Bn(e) {
|
|
2541
|
+
const t = it(e);
|
|
2551
2542
|
if (t === null)
|
|
2552
2543
|
return null;
|
|
2553
|
-
const n =
|
|
2544
|
+
const n = L(e[t])?.page;
|
|
2554
2545
|
if (!n || typeof n != "object")
|
|
2555
2546
|
return null;
|
|
2556
2547
|
const r = n.url;
|
|
2557
2548
|
return typeof r == "string" ? r : null;
|
|
2558
2549
|
}
|
|
2559
|
-
function
|
|
2550
|
+
function L(e) {
|
|
2560
2551
|
if (!e || typeof e != "object")
|
|
2561
2552
|
return null;
|
|
2562
2553
|
const t = e.data;
|
|
2563
2554
|
return t && typeof t == "object" ? t : null;
|
|
2564
2555
|
}
|
|
2565
|
-
function
|
|
2556
|
+
function Pt(e) {
|
|
2566
2557
|
return e?.retryable !== !0 ? !1 : e.type === "run_error" ? !0 : e.type === "run_status" && e.status === "interrupted";
|
|
2567
2558
|
}
|
|
2568
|
-
function
|
|
2559
|
+
function he(e) {
|
|
2569
2560
|
return e?.type === "run_status" && e.status === "interrupted" && e.reason === "backend_restart";
|
|
2570
2561
|
}
|
|
2571
|
-
function
|
|
2572
|
-
const s =
|
|
2562
|
+
function qn(e, t) {
|
|
2563
|
+
const s = it(t);
|
|
2573
2564
|
if (s === null)
|
|
2574
2565
|
return !1;
|
|
2575
2566
|
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
2576
2567
|
if (typeof r != "string" || !r)
|
|
2577
2568
|
return !1;
|
|
2578
2569
|
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
2579
|
-
return i === -1 ? !1 : e.slice(i + 1).some(
|
|
2570
|
+
return i === -1 ? !1 : e.slice(i + 1).some(Ln);
|
|
2580
2571
|
}
|
|
2581
|
-
function
|
|
2582
|
-
const t =
|
|
2572
|
+
function Ut(e) {
|
|
2573
|
+
const t = it(e);
|
|
2583
2574
|
if (t === null)
|
|
2584
2575
|
return null;
|
|
2585
2576
|
const s = e[t];
|
|
@@ -2591,8 +2582,8 @@ function Nt(e) {
|
|
|
2591
2582
|
const r = n.clientMessageId;
|
|
2592
2583
|
return typeof r == "string" ? r : null;
|
|
2593
2584
|
}
|
|
2594
|
-
function
|
|
2595
|
-
const t =
|
|
2585
|
+
function Hn(e) {
|
|
2586
|
+
const t = it(e);
|
|
2596
2587
|
if (t === null)
|
|
2597
2588
|
return null;
|
|
2598
2589
|
for (let s = e.length - 1; s > t; s -= 1) {
|
|
@@ -2606,22 +2597,22 @@ function Fn(e) {
|
|
|
2606
2597
|
if (i.type === "message" && i.role === "assistant")
|
|
2607
2598
|
return null;
|
|
2608
2599
|
if (i.type === "run_error")
|
|
2609
|
-
return i.retryable !== !0 ? null :
|
|
2600
|
+
return i.retryable !== !0 ? null : pe(e, i) ?? Ut(e);
|
|
2610
2601
|
if (i.type === "run_status")
|
|
2611
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
2602
|
+
return i.status === "interrupted" && i.retryable === !0 ? pe(e, i) ?? Ut(e) : null;
|
|
2612
2603
|
}
|
|
2613
2604
|
return null;
|
|
2614
2605
|
}
|
|
2615
|
-
function
|
|
2606
|
+
function pe(e, t) {
|
|
2616
2607
|
if (typeof t.clientMessageId == "string")
|
|
2617
2608
|
return t.clientMessageId;
|
|
2618
|
-
const s =
|
|
2609
|
+
const s = v(t);
|
|
2619
2610
|
if (!s)
|
|
2620
2611
|
return null;
|
|
2621
|
-
const n = e.find((i) =>
|
|
2612
|
+
const n = e.find((i) => b(i, "id") === s), r = L(n);
|
|
2622
2613
|
return r?.type === "message" && r.role === "user" && typeof r.clientMessageId == "string" ? r.clientMessageId : null;
|
|
2623
2614
|
}
|
|
2624
|
-
function
|
|
2615
|
+
function Fn(e, t) {
|
|
2625
2616
|
let s = 0;
|
|
2626
2617
|
for (const n of e) {
|
|
2627
2618
|
if (!n || typeof n != "object")
|
|
@@ -2634,11 +2625,11 @@ function Wn(e, t) {
|
|
|
2634
2625
|
}
|
|
2635
2626
|
return s;
|
|
2636
2627
|
}
|
|
2637
|
-
function
|
|
2628
|
+
function fe(e, t, s, n, r) {
|
|
2638
2629
|
if (!t || !$n(e))
|
|
2639
2630
|
return !1;
|
|
2640
2631
|
const i = e;
|
|
2641
|
-
return !(
|
|
2632
|
+
return !(Pt(i) || s !== null && typeof i.id == "string" && i.id !== s || n !== null && v(i) !== n || r !== null && M(i) !== r);
|
|
2642
2633
|
}
|
|
2643
2634
|
function $n(e) {
|
|
2644
2635
|
if (!e || typeof e != "object")
|
|
@@ -2646,25 +2637,25 @@ function $n(e) {
|
|
|
2646
2637
|
const t = e;
|
|
2647
2638
|
return t.type === "message" && t.role === "assistant" ? !0 : t.type === "run_error" ? t.stage !== "tool_execution" : t.type === "run_status" && (t.status === "stopped" || t.status === "interrupted");
|
|
2648
2639
|
}
|
|
2649
|
-
function
|
|
2640
|
+
function q(e) {
|
|
2650
2641
|
return e.role === "assistant" && e.phase !== "commentary";
|
|
2651
2642
|
}
|
|
2652
|
-
function
|
|
2643
|
+
function Wn(e) {
|
|
2653
2644
|
if (!e || typeof e != "object")
|
|
2654
2645
|
return !1;
|
|
2655
2646
|
const t = e;
|
|
2656
2647
|
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";
|
|
2657
2648
|
}
|
|
2658
|
-
function
|
|
2659
|
-
return e.filter((t, s) =>
|
|
2649
|
+
function Dt(e) {
|
|
2650
|
+
return e.filter((t, s) => Ft(t) ? !Kn(e, s) && !Xn(e, s) && !Jn(e, s) : jn(t) ? t.retryable === !0 && Gn(e, s) ? !1 : !zn(e, s) : !0);
|
|
2660
2651
|
}
|
|
2661
|
-
function
|
|
2652
|
+
function jn(e) {
|
|
2662
2653
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
2663
2654
|
}
|
|
2664
|
-
function
|
|
2655
|
+
function Ft(e) {
|
|
2665
2656
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
2666
2657
|
}
|
|
2667
|
-
function
|
|
2658
|
+
function xt(e) {
|
|
2668
2659
|
const t = new Set(e.filter((i) => i.role === "user").map((i) => i.id)), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
2669
2660
|
for (const i of e) {
|
|
2670
2661
|
if (i.role === "user" || !i.respondsToUserMessageId || !t.has(i.respondsToUserMessageId))
|
|
@@ -2680,18 +2671,18 @@ function vt(e) {
|
|
|
2680
2671
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
2681
2672
|
return r;
|
|
2682
2673
|
}
|
|
2683
|
-
function
|
|
2674
|
+
function zn(e, t) {
|
|
2684
2675
|
const s = e[t];
|
|
2685
2676
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
2686
2677
|
const r = e[n];
|
|
2687
2678
|
if (r.role === "user")
|
|
2688
2679
|
return !1;
|
|
2689
|
-
if (r.role === "assistant" &&
|
|
2680
|
+
if (r.role === "assistant" && ot(s, r))
|
|
2690
2681
|
return !0;
|
|
2691
2682
|
}
|
|
2692
2683
|
return !1;
|
|
2693
2684
|
}
|
|
2694
|
-
function
|
|
2685
|
+
function Gn(e, t) {
|
|
2695
2686
|
const s = e[t];
|
|
2696
2687
|
if (!s.respondsToUserMessageId)
|
|
2697
2688
|
return !1;
|
|
@@ -2699,47 +2690,47 @@ function Xn(e, t) {
|
|
|
2699
2690
|
const r = e[n];
|
|
2700
2691
|
if (r.role === "user")
|
|
2701
2692
|
return !1;
|
|
2702
|
-
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" ||
|
|
2693
|
+
if (r.respondsToUserMessageId === s.respondsToUserMessageId && (r.role === "assistant" || r.role === "tool" || Ft(r)))
|
|
2703
2694
|
return !0;
|
|
2704
2695
|
}
|
|
2705
2696
|
return !1;
|
|
2706
2697
|
}
|
|
2707
|
-
function
|
|
2698
|
+
function Xn(e, t) {
|
|
2708
2699
|
const s = e[t];
|
|
2709
2700
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2710
|
-
if (e[n].role === "assistant" &&
|
|
2701
|
+
if (e[n].role === "assistant" && ot(s, e[n]))
|
|
2711
2702
|
return !0;
|
|
2712
2703
|
return !1;
|
|
2713
2704
|
}
|
|
2714
|
-
function
|
|
2705
|
+
function Jn(e, t) {
|
|
2715
2706
|
const s = e[t];
|
|
2716
2707
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2717
|
-
if (e[n].role === "tool" &&
|
|
2708
|
+
if (e[n].role === "tool" && ot(s, e[n]))
|
|
2718
2709
|
return !0;
|
|
2719
2710
|
return !1;
|
|
2720
2711
|
}
|
|
2721
|
-
function
|
|
2712
|
+
function Kn(e, t) {
|
|
2722
2713
|
const s = e[t];
|
|
2723
2714
|
for (let n = t + 1; n < e.length; n += 1)
|
|
2724
|
-
if (
|
|
2715
|
+
if (Ft(e[n]) && ot(s, e[n]))
|
|
2725
2716
|
return !0;
|
|
2726
2717
|
return !1;
|
|
2727
2718
|
}
|
|
2728
|
-
function
|
|
2719
|
+
function ot(e, t) {
|
|
2729
2720
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
2730
2721
|
}
|
|
2731
|
-
function
|
|
2722
|
+
function b(e, t) {
|
|
2732
2723
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
2733
2724
|
}
|
|
2734
|
-
function
|
|
2725
|
+
function Vn(e, t) {
|
|
2735
2726
|
try {
|
|
2736
|
-
const s = window.localStorage.getItem(`${
|
|
2727
|
+
const s = window.localStorage.getItem(`${Ae}${e}`);
|
|
2737
2728
|
if (!s)
|
|
2738
2729
|
return null;
|
|
2739
2730
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
2740
2731
|
if (t !== void 0 && r !== t)
|
|
2741
2732
|
return null;
|
|
2742
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
2733
|
+
const i = Array.isArray(n.messages) ? n.messages.map(or).filter((o) => !!o) : [];
|
|
2743
2734
|
return {
|
|
2744
2735
|
sessionId: r,
|
|
2745
2736
|
messages: i
|
|
@@ -2748,39 +2739,39 @@ function Yn(e, t) {
|
|
|
2748
2739
|
return null;
|
|
2749
2740
|
}
|
|
2750
2741
|
}
|
|
2751
|
-
function
|
|
2742
|
+
function Yn(e, t) {
|
|
2752
2743
|
try {
|
|
2753
2744
|
window.localStorage.setItem(
|
|
2754
|
-
`${
|
|
2745
|
+
`${Ae}${e}`,
|
|
2755
2746
|
JSON.stringify({
|
|
2756
2747
|
sessionId: t.sessionId,
|
|
2757
|
-
messages: t.messages.slice(-
|
|
2748
|
+
messages: t.messages.slice(-Ms).map(ar)
|
|
2758
2749
|
})
|
|
2759
2750
|
);
|
|
2760
2751
|
} catch {
|
|
2761
2752
|
return;
|
|
2762
2753
|
}
|
|
2763
2754
|
}
|
|
2764
|
-
function
|
|
2755
|
+
function Zn(e) {
|
|
2765
2756
|
try {
|
|
2766
|
-
const t = window.localStorage.getItem(`${
|
|
2757
|
+
const t = window.localStorage.getItem(`${Ct}${e}`);
|
|
2767
2758
|
if (!t)
|
|
2768
2759
|
return [];
|
|
2769
2760
|
const s = JSON.parse(t);
|
|
2770
|
-
return Array.isArray(s) ? s.filter(
|
|
2761
|
+
return Array.isArray(s) ? s.filter($t) : [];
|
|
2771
2762
|
} catch {
|
|
2772
2763
|
return [];
|
|
2773
2764
|
}
|
|
2774
2765
|
}
|
|
2775
2766
|
function W(e, t) {
|
|
2776
2767
|
try {
|
|
2777
|
-
const s = t.filter(
|
|
2768
|
+
const s = t.filter($t);
|
|
2778
2769
|
if (s.length === 0) {
|
|
2779
|
-
window.localStorage.removeItem(`${
|
|
2770
|
+
window.localStorage.removeItem(`${Ct}${e}`);
|
|
2780
2771
|
return;
|
|
2781
2772
|
}
|
|
2782
2773
|
window.localStorage.setItem(
|
|
2783
|
-
`${
|
|
2774
|
+
`${Ct}${e}`,
|
|
2784
2775
|
JSON.stringify(s.slice(-25))
|
|
2785
2776
|
);
|
|
2786
2777
|
} catch {
|
|
@@ -2789,7 +2780,7 @@ function W(e, t) {
|
|
|
2789
2780
|
}
|
|
2790
2781
|
function xe(e, t) {
|
|
2791
2782
|
try {
|
|
2792
|
-
const s = `${
|
|
2783
|
+
const s = `${rt}${e}`, n = location.href, r = location.origin, i = Array.from(t, (o) => ({
|
|
2793
2784
|
...o,
|
|
2794
2785
|
storedAt: Date.now(),
|
|
2795
2786
|
unloadUrl: n,
|
|
@@ -2803,28 +2794,28 @@ function xe(e, t) {
|
|
|
2803
2794
|
} catch {
|
|
2804
2795
|
}
|
|
2805
2796
|
}
|
|
2806
|
-
function
|
|
2797
|
+
function Qn(e, t) {
|
|
2807
2798
|
try {
|
|
2808
|
-
if (window.sessionStorage.getItem(`${
|
|
2799
|
+
if (window.sessionStorage.getItem(`${rt}${e}`) === null)
|
|
2809
2800
|
return;
|
|
2810
2801
|
} catch {
|
|
2811
2802
|
return;
|
|
2812
2803
|
}
|
|
2813
2804
|
xe(e, t);
|
|
2814
2805
|
}
|
|
2815
|
-
function
|
|
2806
|
+
function tr(e) {
|
|
2816
2807
|
try {
|
|
2817
|
-
const t = `${
|
|
2808
|
+
const t = `${rt}${e}`, s = window.sessionStorage.getItem(t);
|
|
2818
2809
|
if (window.sessionStorage.removeItem(t), !s)
|
|
2819
2810
|
return [];
|
|
2820
2811
|
const n = JSON.parse(s);
|
|
2821
|
-
return Array.isArray(n) ? n.flatMap((r) =>
|
|
2812
|
+
return Array.isArray(n) ? n.flatMap((r) => sr(r) ? [{
|
|
2822
2813
|
...r.event,
|
|
2823
|
-
page:
|
|
2814
|
+
page: _(),
|
|
2824
2815
|
rawOutput: {
|
|
2825
2816
|
pageContextRestarted: !0,
|
|
2826
2817
|
outcome: "unknown",
|
|
2827
|
-
message:
|
|
2818
|
+
message: er(location.href),
|
|
2828
2819
|
currentUrl: location.href,
|
|
2829
2820
|
console: [],
|
|
2830
2821
|
metadata: {
|
|
@@ -2841,17 +2832,17 @@ function er(e) {
|
|
|
2841
2832
|
return [];
|
|
2842
2833
|
}
|
|
2843
2834
|
}
|
|
2844
|
-
function
|
|
2835
|
+
function er(e) {
|
|
2845
2836
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
2846
2837
|
Current URL: ${e}`;
|
|
2847
2838
|
}
|
|
2848
|
-
function
|
|
2839
|
+
function sr(e) {
|
|
2849
2840
|
if (!e || typeof e != "object")
|
|
2850
2841
|
return !1;
|
|
2851
2842
|
const t = e, s = t.event;
|
|
2852
|
-
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" &&
|
|
2843
|
+
return typeof t.startedAtMs == "number" && typeof t.startedAtUrl == "string" && t.startedAtOrigin === location.origin && t.unloadOrigin === location.origin && typeof t.unloadUrl == "string" && $t(s) && s.type === "tool.result";
|
|
2853
2844
|
}
|
|
2854
|
-
function
|
|
2845
|
+
function nr(e, t) {
|
|
2855
2846
|
const s = new Set(
|
|
2856
2847
|
e.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
2857
2848
|
);
|
|
@@ -2860,26 +2851,26 @@ function rr(e, t) {
|
|
|
2860
2851
|
...t.filter((n) => !s.has(n.callId))
|
|
2861
2852
|
];
|
|
2862
2853
|
}
|
|
2863
|
-
function
|
|
2854
|
+
function rr(e) {
|
|
2864
2855
|
try {
|
|
2865
|
-
window.sessionStorage.removeItem(`${
|
|
2856
|
+
window.sessionStorage.removeItem(`${rt}${e}`);
|
|
2866
2857
|
} catch {
|
|
2867
2858
|
return;
|
|
2868
2859
|
}
|
|
2869
2860
|
}
|
|
2870
|
-
function
|
|
2861
|
+
function $t(e) {
|
|
2871
2862
|
if (!e || typeof e != "object")
|
|
2872
2863
|
return !1;
|
|
2873
2864
|
const t = e;
|
|
2874
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
2865
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && ge(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? ge(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && (t.toolName === "execute_code" || t.toolName === "execute_code_in_browser_tab") : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" && (t.reason === "user_requested" || t.reason === "new_chat" || t.reason === "session_switch") : !1;
|
|
2875
2866
|
}
|
|
2876
|
-
function
|
|
2867
|
+
function ge(e) {
|
|
2877
2868
|
if (!e || typeof e != "object")
|
|
2878
2869
|
return !1;
|
|
2879
2870
|
const t = e;
|
|
2880
2871
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
2881
2872
|
}
|
|
2882
|
-
function
|
|
2873
|
+
function ve(e, t) {
|
|
2883
2874
|
if (!Array.isArray(e))
|
|
2884
2875
|
return;
|
|
2885
2876
|
const s = e.filter((r) => {
|
|
@@ -2887,39 +2878,23 @@ function Be(e, t) {
|
|
|
2887
2878
|
return !1;
|
|
2888
2879
|
const i = r;
|
|
2889
2880
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
2890
|
-
}), n = t ? s.map((r) =>
|
|
2881
|
+
}), n = t ? s.map((r) => Oe(r, t)) : s;
|
|
2891
2882
|
return n.length > 0 ? n : void 0;
|
|
2892
2883
|
}
|
|
2893
|
-
function
|
|
2884
|
+
function Oe(e, t) {
|
|
2894
2885
|
return e.fileUrl?.startsWith("/") ? {
|
|
2895
2886
|
...e,
|
|
2896
2887
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
2897
2888
|
} : e;
|
|
2898
2889
|
}
|
|
2899
|
-
function
|
|
2900
|
-
|
|
2901
|
-
return {
|
|
2902
|
-
headers: {
|
|
2903
|
-
"ngrok-skip-browser-warning": "true"
|
|
2904
|
-
}
|
|
2905
|
-
};
|
|
2890
|
+
function me(e) {
|
|
2891
|
+
return e.type || ir(e.name) || "application/octet-stream";
|
|
2906
2892
|
}
|
|
2907
|
-
function
|
|
2908
|
-
try {
|
|
2909
|
-
const t = new URL(e).hostname;
|
|
2910
|
-
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
2911
|
-
} catch {
|
|
2912
|
-
return !1;
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
function Ie(e) {
|
|
2916
|
-
return e.type || cr(e.name) || "application/octet-stream";
|
|
2917
|
-
}
|
|
2918
|
-
function cr(e) {
|
|
2893
|
+
function ir(e) {
|
|
2919
2894
|
const t = e.toLowerCase();
|
|
2920
2895
|
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;
|
|
2921
2896
|
}
|
|
2922
|
-
function
|
|
2897
|
+
function or(e) {
|
|
2923
2898
|
if (!e || typeof e != "object")
|
|
2924
2899
|
return null;
|
|
2925
2900
|
const t = e;
|
|
@@ -2932,17 +2907,17 @@ function lr(e) {
|
|
|
2932
2907
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
2933
2908
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
2934
2909
|
securitySettingsUrl: typeof t.securitySettingsUrl == "string" ? t.securitySettingsUrl : void 0,
|
|
2935
|
-
attachments:
|
|
2910
|
+
attachments: ve(t.attachments)?.map(Wt),
|
|
2936
2911
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
2937
2912
|
};
|
|
2938
2913
|
}
|
|
2939
|
-
function
|
|
2914
|
+
function ar(e) {
|
|
2940
2915
|
return e.attachments?.length ? {
|
|
2941
2916
|
...e,
|
|
2942
|
-
attachments: e.attachments.map(
|
|
2917
|
+
attachments: e.attachments.map(Wt)
|
|
2943
2918
|
} : e;
|
|
2944
2919
|
}
|
|
2945
|
-
function
|
|
2920
|
+
function Wt(e) {
|
|
2946
2921
|
const {
|
|
2947
2922
|
dataUrl: t,
|
|
2948
2923
|
objectUrl: s,
|
|
@@ -2951,7 +2926,7 @@ function Gt(e) {
|
|
|
2951
2926
|
} = e;
|
|
2952
2927
|
return r;
|
|
2953
2928
|
}
|
|
2954
|
-
function
|
|
2929
|
+
function v(e) {
|
|
2955
2930
|
const t = e.respondsToUserMessageId;
|
|
2956
2931
|
return typeof t == "string" && t ? t : null;
|
|
2957
2932
|
}
|
|
@@ -2959,39 +2934,39 @@ function M(e) {
|
|
|
2959
2934
|
const t = e.runId;
|
|
2960
2935
|
return typeof t == "string" && t ? t : null;
|
|
2961
2936
|
}
|
|
2962
|
-
function
|
|
2937
|
+
function cr(e) {
|
|
2963
2938
|
const t = e?.timeoutMs;
|
|
2964
|
-
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <=
|
|
2939
|
+
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string" && (t === void 0 || typeof t == "number" && Number.isInteger(t) && t > 0 && t <= Ns);
|
|
2965
2940
|
}
|
|
2966
|
-
function
|
|
2941
|
+
function Ne(e) {
|
|
2967
2942
|
const t = {};
|
|
2968
2943
|
try {
|
|
2969
2944
|
new Headers(e).forEach((s, n) => {
|
|
2970
|
-
Object.keys(t).length <
|
|
2945
|
+
Object.keys(t).length < Bt && (t[n] = jt(n, s));
|
|
2971
2946
|
});
|
|
2972
2947
|
} catch {
|
|
2973
2948
|
return {};
|
|
2974
2949
|
}
|
|
2975
2950
|
return t;
|
|
2976
2951
|
}
|
|
2977
|
-
function
|
|
2978
|
-
return
|
|
2952
|
+
function jt(e, t) {
|
|
2953
|
+
return $e(e) ? at : C(nt(t), Rs);
|
|
2979
2954
|
}
|
|
2980
|
-
function
|
|
2955
|
+
function lr(e, t) {
|
|
2981
2956
|
return typeof e == "string" ? e : e instanceof URL ? e.toString() : t?.url ?? "";
|
|
2982
2957
|
}
|
|
2983
|
-
async function
|
|
2984
|
-
const r =
|
|
2958
|
+
async function ur(e, t, s, n) {
|
|
2959
|
+
const r = Ne(e.headers);
|
|
2985
2960
|
n({
|
|
2986
2961
|
...t,
|
|
2987
2962
|
responseStatus: e.status,
|
|
2988
2963
|
responseHeaders: r,
|
|
2989
|
-
responseBody: await
|
|
2964
|
+
responseBody: await dr(e),
|
|
2990
2965
|
durationMs: Date.now() - s
|
|
2991
2966
|
});
|
|
2992
2967
|
}
|
|
2993
|
-
async function
|
|
2994
|
-
if (!
|
|
2968
|
+
async function dr(e) {
|
|
2969
|
+
if (!Le(e.headers))
|
|
2995
2970
|
return;
|
|
2996
2971
|
let t = null, s = null;
|
|
2997
2972
|
try {
|
|
@@ -3000,20 +2975,20 @@ async function fr(e) {
|
|
|
3000
2975
|
const n = new Promise((a) => {
|
|
3001
2976
|
s = window.setTimeout(() => {
|
|
3002
2977
|
t?.cancel(), a("timeout");
|
|
3003
|
-
},
|
|
2978
|
+
}, _s);
|
|
3004
2979
|
}), r = new TextDecoder();
|
|
3005
2980
|
let i = "", o = 0;
|
|
3006
2981
|
for (; ; ) {
|
|
3007
2982
|
const a = await Promise.race([t.read(), n]);
|
|
3008
2983
|
if (a === "timeout")
|
|
3009
2984
|
return;
|
|
3010
|
-
const { done:
|
|
3011
|
-
if (
|
|
2985
|
+
const { done: c, value: l } = a;
|
|
2986
|
+
if (c)
|
|
3012
2987
|
return C(i + r.decode());
|
|
3013
|
-
const
|
|
3014
|
-
if (
|
|
3015
|
-
return i += r.decode(
|
|
3016
|
-
o +=
|
|
2988
|
+
const d = Lt - o;
|
|
2989
|
+
if (l.byteLength > d)
|
|
2990
|
+
return i += r.decode(l.subarray(0, Math.max(d, 0)), { stream: !0 }), t.cancel(), `${C(i)}... [truncated]`;
|
|
2991
|
+
o += l.byteLength, i += r.decode(l, { stream: !0 });
|
|
3017
2992
|
}
|
|
3018
2993
|
} catch {
|
|
3019
2994
|
t?.cancel();
|
|
@@ -3022,45 +2997,45 @@ async function fr(e) {
|
|
|
3022
2997
|
s !== null && window.clearTimeout(s);
|
|
3023
2998
|
}
|
|
3024
2999
|
}
|
|
3025
|
-
function
|
|
3026
|
-
if (
|
|
3000
|
+
function hr(e, t) {
|
|
3001
|
+
if (Le(new Headers(t)))
|
|
3027
3002
|
try {
|
|
3028
3003
|
return e.responseType === "" || e.responseType === "text" ? C(e.responseText ?? "") : void 0;
|
|
3029
3004
|
} catch {
|
|
3030
3005
|
return;
|
|
3031
3006
|
}
|
|
3032
3007
|
}
|
|
3033
|
-
function
|
|
3008
|
+
function ye(e) {
|
|
3034
3009
|
if (typeof e == "string")
|
|
3035
3010
|
return C(e);
|
|
3036
3011
|
}
|
|
3037
|
-
function
|
|
3038
|
-
return
|
|
3012
|
+
function pr(e) {
|
|
3013
|
+
return k({
|
|
3039
3014
|
...e,
|
|
3040
|
-
requestBody:
|
|
3041
|
-
responseBody:
|
|
3015
|
+
requestBody: Ie(e.requestBody),
|
|
3016
|
+
responseBody: Ie(e.responseBody)
|
|
3042
3017
|
});
|
|
3043
3018
|
}
|
|
3044
|
-
function
|
|
3019
|
+
function Ie(e) {
|
|
3045
3020
|
if (typeof e != "string")
|
|
3046
3021
|
return e;
|
|
3047
3022
|
const t = e.trim();
|
|
3048
3023
|
if (!t.startsWith("{") && !t.startsWith("["))
|
|
3049
|
-
return
|
|
3024
|
+
return nt(e);
|
|
3050
3025
|
try {
|
|
3051
|
-
return JSON.stringify(
|
|
3026
|
+
return JSON.stringify(k(JSON.parse(e)));
|
|
3052
3027
|
} catch {
|
|
3053
|
-
return
|
|
3028
|
+
return nt(e);
|
|
3054
3029
|
}
|
|
3055
3030
|
}
|
|
3056
|
-
function
|
|
3031
|
+
function Le(e) {
|
|
3057
3032
|
if (!e)
|
|
3058
3033
|
return !1;
|
|
3059
3034
|
const t = e.get("content-type")?.toLowerCase() ?? "", s = e.get("content-length"), n = Number(s);
|
|
3060
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
3035
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Lt && (t.startsWith("text/") || t.includes("json") || t.includes("javascript"));
|
|
3061
3036
|
}
|
|
3062
|
-
function
|
|
3063
|
-
if (
|
|
3037
|
+
function O(e, t = {}, s) {
|
|
3038
|
+
if (gr(s))
|
|
3064
3039
|
return !0;
|
|
3065
3040
|
const n = Object.entries(t).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
3066
3041
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -3075,8 +3050,8 @@ function v(e, t = {}, s) {
|
|
|
3075
3050
|
return !0;
|
|
3076
3051
|
}
|
|
3077
3052
|
}
|
|
3078
|
-
function
|
|
3079
|
-
if (
|
|
3053
|
+
function fr(e, t) {
|
|
3054
|
+
if (O(e))
|
|
3080
3055
|
return !0;
|
|
3081
3056
|
try {
|
|
3082
3057
|
const s = new URL(e, location.href), n = new URL(t);
|
|
@@ -3085,115 +3060,115 @@ function yr(e, t) {
|
|
|
3085
3060
|
return !0;
|
|
3086
3061
|
}
|
|
3087
3062
|
}
|
|
3088
|
-
function
|
|
3063
|
+
function gr(e) {
|
|
3089
3064
|
return e instanceof FormData || e instanceof Blob || e instanceof ArrayBuffer || ArrayBuffer.isView(e) || typeof ReadableStream < "u" && e instanceof ReadableStream;
|
|
3090
3065
|
}
|
|
3091
|
-
function
|
|
3066
|
+
function mr(e) {
|
|
3092
3067
|
const t = {};
|
|
3093
3068
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
3094
3069
|
const n = s.indexOf(":");
|
|
3095
3070
|
if (n <= 0)
|
|
3096
3071
|
continue;
|
|
3097
|
-
if (Object.keys(t).length >=
|
|
3072
|
+
if (Object.keys(t).length >= Bt)
|
|
3098
3073
|
break;
|
|
3099
3074
|
const r = s.slice(0, n).trim();
|
|
3100
|
-
t[r] =
|
|
3075
|
+
t[r] = jt(r, s.slice(n + 1).trim());
|
|
3101
3076
|
}
|
|
3102
3077
|
return t;
|
|
3103
3078
|
}
|
|
3104
|
-
function C(e, t =
|
|
3079
|
+
function C(e, t = Lt) {
|
|
3105
3080
|
return e.length <= t ? e : `${e.slice(0, t)}... [truncated ${e.length - t} chars]`;
|
|
3106
3081
|
}
|
|
3107
|
-
function
|
|
3082
|
+
function kt(e) {
|
|
3108
3083
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3109
3084
|
}
|
|
3110
|
-
class
|
|
3085
|
+
class et extends Error {
|
|
3111
3086
|
constructor(t, s) {
|
|
3112
3087
|
super(`${t} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError";
|
|
3113
3088
|
}
|
|
3114
3089
|
status;
|
|
3115
3090
|
}
|
|
3116
|
-
async function
|
|
3091
|
+
async function Rt(e, t) {
|
|
3117
3092
|
let s = null;
|
|
3118
|
-
for (let n = 0; n <
|
|
3093
|
+
for (let n = 0; n < re; n += 1)
|
|
3119
3094
|
try {
|
|
3120
3095
|
return await e();
|
|
3121
3096
|
} catch (r) {
|
|
3122
|
-
if (s = r, n >=
|
|
3097
|
+
if (s = r, n >= re - 1 || !Ir(r))
|
|
3123
3098
|
throw r;
|
|
3124
|
-
await
|
|
3099
|
+
await yr(n);
|
|
3125
3100
|
}
|
|
3126
3101
|
throw s instanceof Error ? s : new Error(t);
|
|
3127
3102
|
}
|
|
3128
|
-
function
|
|
3103
|
+
function yr(e) {
|
|
3129
3104
|
return new Promise((t) => {
|
|
3130
|
-
window.setTimeout(t,
|
|
3105
|
+
window.setTimeout(t, ks[e] ?? 0);
|
|
3131
3106
|
});
|
|
3132
3107
|
}
|
|
3133
|
-
function
|
|
3134
|
-
return e instanceof
|
|
3108
|
+
function Ir(e) {
|
|
3109
|
+
return e instanceof et ? Tr(e.status) : e instanceof TypeError;
|
|
3135
3110
|
}
|
|
3136
|
-
function
|
|
3111
|
+
function Tr(e) {
|
|
3137
3112
|
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
3138
3113
|
}
|
|
3139
|
-
function
|
|
3114
|
+
function wr(e) {
|
|
3140
3115
|
return e === 401 || e === 403;
|
|
3141
3116
|
}
|
|
3142
|
-
const
|
|
3143
|
-
function
|
|
3144
|
-
return
|
|
3117
|
+
const at = "[REDACTED_SECRET]", P = "[REDACTED_TOKEN]", Sr = "[REDACTED_SIGNED_URL]", Ar = 20, br = /^(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, Be = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, qe = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, He = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Fe = /\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, Er = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, kr = /\bhttps?:\/\/[^\s"'<>]+/gi, Rr = /[),.;\]]+$/;
|
|
3118
|
+
function k(e) {
|
|
3119
|
+
return st(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3145
3120
|
}
|
|
3146
|
-
function
|
|
3121
|
+
function st(e, t, s) {
|
|
3147
3122
|
if (typeof e == "string")
|
|
3148
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
3123
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : nt(e);
|
|
3149
3124
|
if (e === null || typeof e != "object")
|
|
3150
3125
|
return e;
|
|
3151
|
-
if (t >=
|
|
3126
|
+
if (t >= Ar)
|
|
3152
3127
|
return "[REDACTED_MAX_DEPTH]";
|
|
3153
3128
|
if (s.has(e))
|
|
3154
3129
|
return "[REDACTED_CIRCULAR]";
|
|
3155
3130
|
if (s.add(e), Array.isArray(e))
|
|
3156
|
-
return e.map((r) =>
|
|
3131
|
+
return e.map((r) => st(r, t + 1, s));
|
|
3157
3132
|
const n = {};
|
|
3158
3133
|
for (const [r, i] of Object.entries(e))
|
|
3159
|
-
r === "pageContent" ? n[r] = i :
|
|
3134
|
+
r === "pageContent" ? n[r] = i : $e(r) ? n[r] = at : n[r] = r.toLowerCase() === "url" ? _r(i) : st(i, t + 1, s);
|
|
3160
3135
|
return n;
|
|
3161
3136
|
}
|
|
3162
|
-
function
|
|
3137
|
+
function $e(e) {
|
|
3163
3138
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
3164
3139
|
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");
|
|
3165
3140
|
}
|
|
3166
|
-
function
|
|
3167
|
-
return typeof e == "string" ?
|
|
3141
|
+
function _r(e) {
|
|
3142
|
+
return typeof e == "string" ? We(e) : st(e, 0, /* @__PURE__ */ new WeakSet());
|
|
3168
3143
|
}
|
|
3169
|
-
function
|
|
3144
|
+
function We(e) {
|
|
3170
3145
|
try {
|
|
3171
3146
|
const t = new URL(e, location.href);
|
|
3172
3147
|
for (const s of Array.from(t.searchParams.keys()))
|
|
3173
|
-
|
|
3148
|
+
br.test(s) && t.searchParams.set(s, P);
|
|
3174
3149
|
return t.username && (t.username = P), t.password && (t.password = P), t.toString();
|
|
3175
3150
|
} catch {
|
|
3176
|
-
return
|
|
3151
|
+
return Mr(e);
|
|
3177
3152
|
}
|
|
3178
3153
|
}
|
|
3179
|
-
function
|
|
3180
|
-
return e.replace(
|
|
3154
|
+
function nt(e) {
|
|
3155
|
+
return e.replace(Er, Sr).replace(kr, Cr).replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
|
|
3181
3156
|
}
|
|
3182
|
-
function
|
|
3183
|
-
return e.replace(
|
|
3157
|
+
function Mr(e) {
|
|
3158
|
+
return e.replace(Be, `Bearer ${P}`).replace(qe, `Basic ${P}`).replace(He, P).replace(Fe, (t, s) => `${s}: ${at}`);
|
|
3184
3159
|
}
|
|
3185
|
-
function
|
|
3186
|
-
const t = e.match(
|
|
3187
|
-
return `${
|
|
3160
|
+
function Cr(e) {
|
|
3161
|
+
const t = e.match(Rr)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
3162
|
+
return `${We(s)}${t}`;
|
|
3188
3163
|
}
|
|
3189
3164
|
export {
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3165
|
+
te as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
3166
|
+
Mt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
3167
|
+
ls as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
3168
|
+
cs as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
3169
|
+
us as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
3170
|
+
be as PlunoProductAgent,
|
|
3171
|
+
Ps as calculateReconnectDelay,
|
|
3172
|
+
be as default,
|
|
3173
|
+
Qs as getProductAgentOriginAccessErrorMessage
|
|
3199
3174
|
};
|