@pluno/product-agent-web 0.1.40 → 0.1.44
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/boltIcon.d.ts +16 -0
- package/dist/index.d.ts +24 -0
- package/dist/product-agent-sdk.js +400 -273
- package/dist/product-agent-widget.js +1280 -901
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
1
|
+
const _ = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Q = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', tt = ".pluno-pa-widget__panel", et = ".pluno-pa-widget__timeline", N = `${_}[data-pluno-sdk-preview-channel]`, st = "https://app.pluno.ai", nt = "gpt-5.4", rt = 2e4, it = 2e3, T = 6e4, ot = 15e3, U = 2, at = 15e3, ct = 5e3, lt = 1e3, ut = 8e3, I = 1e5, dt = 100, B = "pluno.productAgent.state.", E = "pluno.productAgent.pendingEvents.", D = "pluno.productAgent.transportId";
|
|
2
|
+
class j {
|
|
3
3
|
constructor(t) {
|
|
4
|
-
this.options = t, this.transportId =
|
|
4
|
+
this.options = t, this.transportId = Mt(), this.state = {
|
|
5
5
|
...this.state,
|
|
6
|
-
starterPrompts:
|
|
6
|
+
starterPrompts: Et(t.initialStarterPrompts)
|
|
7
7
|
};
|
|
8
|
-
const s = t.restorePersistedState === !1 ? null :
|
|
8
|
+
const s = t.restorePersistedState === !1 ? null : Xt(t.clientId, t.expectedPersistedSessionId);
|
|
9
9
|
s && (this.state = {
|
|
10
10
|
...this.state,
|
|
11
11
|
...s,
|
|
@@ -14,7 +14,7 @@ class B {
|
|
|
14
14
|
assistantDraft: "",
|
|
15
15
|
isThinking: !1,
|
|
16
16
|
lastError: null
|
|
17
|
-
}), this.queuedClientEvents =
|
|
17
|
+
}), this.queuedClientEvents = Kt(t.clientId);
|
|
18
18
|
}
|
|
19
19
|
options;
|
|
20
20
|
listeners = {};
|
|
@@ -26,6 +26,7 @@ class B {
|
|
|
26
26
|
networkBatchTimer = null;
|
|
27
27
|
queuedNetworkEvents = [];
|
|
28
28
|
queuedClientEvents = [];
|
|
29
|
+
pendingSessionHistoryRequests = /* @__PURE__ */ new Map();
|
|
29
30
|
transportId;
|
|
30
31
|
retryAttemptsByClientMessageId = {};
|
|
31
32
|
retryTimersByClientMessageId = {};
|
|
@@ -39,11 +40,14 @@ class B {
|
|
|
39
40
|
thinkingWatchdogResyncAttemptsByClientMessageId = {};
|
|
40
41
|
thinkingWatchdogRetryAttemptsByClientMessageId = {};
|
|
41
42
|
runtimeHelperJavascript = null;
|
|
43
|
+
transientStarterPromptsRequestInFlight = !1;
|
|
44
|
+
transientStarterPromptsRequestAttempted = !1;
|
|
42
45
|
state = {
|
|
43
46
|
status: "idle",
|
|
44
47
|
user: null,
|
|
45
48
|
sessionId: null,
|
|
46
49
|
starterPrompts: [],
|
|
50
|
+
starterPromptsLoading: !1,
|
|
47
51
|
appearance: null,
|
|
48
52
|
messages: [],
|
|
49
53
|
assistantDraft: "",
|
|
@@ -52,11 +56,11 @@ class B {
|
|
|
52
56
|
lastErrorCode: null
|
|
53
57
|
};
|
|
54
58
|
static async init(t) {
|
|
55
|
-
const s = new
|
|
59
|
+
const s = new j({
|
|
56
60
|
...t,
|
|
57
|
-
backendUrl:
|
|
58
|
-
clientId: t.clientId ??
|
|
59
|
-
model: t.model ??
|
|
61
|
+
backendUrl: Tt(t.backendUrl ?? st),
|
|
62
|
+
clientId: t.clientId ?? bt(),
|
|
63
|
+
model: t.model ?? nt
|
|
60
64
|
});
|
|
61
65
|
try {
|
|
62
66
|
s.enableNetworkCapture(), t.autoConnect !== !1 && await s.connect();
|
|
@@ -82,7 +86,7 @@ class B {
|
|
|
82
86
|
return;
|
|
83
87
|
if (this.setState({ status: (this.state.status === "closed", "connecting"), lastError: null }), this.token = this.options.token ?? await this.options.tokenProvider?.() ?? null, !this.token && !this.options.webSocketFactory)
|
|
84
88
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
85
|
-
const t =
|
|
89
|
+
const t = kt(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
86
90
|
this.socket = s, s.addEventListener("open", () => {
|
|
87
91
|
this.socket === s && (u("web-sdk.agent", "Pluno socket opened", {
|
|
88
92
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
@@ -94,7 +98,7 @@ class B {
|
|
|
94
98
|
transportId: this.transportId
|
|
95
99
|
}), this.flushQueuedClientEvents(), this.startHeartbeat(), this.setState({ status: "connected", lastError: null }));
|
|
96
100
|
}), s.addEventListener("message", (n) => {
|
|
97
|
-
this.socket === s && this.handleServerEvent(
|
|
101
|
+
this.socket === s && this.handleServerEvent(_t(n.data));
|
|
98
102
|
}), s.addEventListener("close", (n) => {
|
|
99
103
|
this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (u("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
100
104
|
code: typeof n?.code == "number" ? n.code : null,
|
|
@@ -111,7 +115,7 @@ class B {
|
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
117
|
disconnect() {
|
|
114
|
-
this.setState({ status: "closed", isThinking: !1 }), this.stopHeartbeat(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.socket?.close(), this.socket = null;
|
|
118
|
+
this.setState({ status: "closed", isThinking: !1 }), this.stopHeartbeat(), 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;
|
|
115
119
|
}
|
|
116
120
|
destroy() {
|
|
117
121
|
this.disconnect(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null;
|
|
@@ -122,30 +126,30 @@ class B {
|
|
|
122
126
|
const n = t.trim(), r = s.attachments ?? [];
|
|
123
127
|
if (!n && r.length === 0)
|
|
124
128
|
return;
|
|
125
|
-
const i =
|
|
126
|
-
id: `local-${
|
|
129
|
+
const i = f(), o = W(), a = {
|
|
130
|
+
id: `local-${o}`,
|
|
127
131
|
role: "user",
|
|
128
132
|
content: n,
|
|
129
133
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
130
134
|
...r.length > 0 ? { attachments: r } : {}
|
|
131
135
|
};
|
|
132
136
|
this.setState({
|
|
133
|
-
messages: [...this.state.messages,
|
|
137
|
+
messages: [...this.state.messages, a],
|
|
134
138
|
assistantDraft: "",
|
|
135
139
|
isThinking: !0,
|
|
136
140
|
lastError: null
|
|
137
|
-
}), this.emit("message",
|
|
138
|
-
const
|
|
141
|
+
}), this.emit("message", a);
|
|
142
|
+
const c = {
|
|
139
143
|
type: "chat.user_message",
|
|
140
144
|
sessionId: this.state.sessionId ?? void 0,
|
|
141
|
-
clientMessageId:
|
|
145
|
+
clientMessageId: o,
|
|
142
146
|
content: n,
|
|
143
147
|
attachments: r.length > 0 ? r : void 0,
|
|
144
148
|
page: i,
|
|
145
149
|
model: this.options.model,
|
|
146
|
-
metadata:
|
|
150
|
+
metadata: ht(this.options.metadata)
|
|
147
151
|
};
|
|
148
|
-
this.activeClientMessageId =
|
|
152
|
+
this.activeClientMessageId = o, this.activeUserMessageEvent = c, this.markThinkingProgress(), this.send(c);
|
|
149
153
|
}
|
|
150
154
|
stop() {
|
|
151
155
|
this.state.sessionId && (this.send({ type: "run.stop", sessionId: this.state.sessionId }), this.setState({ isThinking: !1 }), this.clearThinkingWatchdog());
|
|
@@ -154,7 +158,7 @@ class B {
|
|
|
154
158
|
this.state.sessionId && this.state.isThinking && this.sendNow({ type: "run.stop", sessionId: this.state.sessionId }), this.queuedClientEvents = this.queuedClientEvents.filter((t) => t.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.send({
|
|
155
159
|
type: "session.reset",
|
|
156
160
|
sessionId: this.state.sessionId ?? void 0,
|
|
157
|
-
page:
|
|
161
|
+
page: f()
|
|
158
162
|
}), this.setState({
|
|
159
163
|
sessionId: null,
|
|
160
164
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -164,8 +168,40 @@ class B {
|
|
|
164
168
|
lastError: null
|
|
165
169
|
});
|
|
166
170
|
}
|
|
171
|
+
listSessions(t = {}) {
|
|
172
|
+
const s = W(), n = new Promise((i, o) => {
|
|
173
|
+
const a = window.setTimeout(() => {
|
|
174
|
+
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
175
|
+
}, ut);
|
|
176
|
+
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: a });
|
|
177
|
+
}), r = {
|
|
178
|
+
type: "sessions.list",
|
|
179
|
+
requestId: s,
|
|
180
|
+
page: f(),
|
|
181
|
+
...t.cursor ? { cursor: t.cursor } : {},
|
|
182
|
+
...t.limit ? { limit: t.limit } : {}
|
|
183
|
+
};
|
|
184
|
+
if (!this.sendNow(r)) {
|
|
185
|
+
const i = this.pendingSessionHistoryRequests.get(s);
|
|
186
|
+
return i && (window.clearTimeout(i.timeout), this.pendingSessionHistoryRequests.delete(s)), this.setState({ status: "reconnecting" }), this.scheduleReconnect(), Promise.reject(new Error("Pluno is reconnecting. Please try again."));
|
|
187
|
+
}
|
|
188
|
+
return n;
|
|
189
|
+
}
|
|
190
|
+
loadSession(t) {
|
|
191
|
+
this.state.sessionId && this.state.isThinking && this.sendNow({ type: "run.stop", sessionId: this.state.sessionId }), this.clearThinkingWatchdog(), this.setState({
|
|
192
|
+
sessionId: t,
|
|
193
|
+
assistantDraft: "",
|
|
194
|
+
isThinking: !1,
|
|
195
|
+
lastError: null,
|
|
196
|
+
lastErrorCode: null
|
|
197
|
+
}), this.send({
|
|
198
|
+
type: "session.load",
|
|
199
|
+
sessionId: t,
|
|
200
|
+
page: f()
|
|
201
|
+
});
|
|
202
|
+
}
|
|
167
203
|
send(t) {
|
|
168
|
-
this.sendNow(m(t)) || (this.queuedClientEvents.push(t),
|
|
204
|
+
this.sendNow(m(t)) || (this.queuedClientEvents.push(t), k(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
169
205
|
}
|
|
170
206
|
sendNow(t) {
|
|
171
207
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
@@ -181,18 +217,32 @@ class B {
|
|
|
181
217
|
}), this.socket === s && (this.stopHeartbeat(), this.socket = null, this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect()), s.readyState !== WebSocket.CLOSED && s.readyState !== WebSocket.CLOSING && s.close(), !1;
|
|
182
218
|
}
|
|
183
219
|
}
|
|
220
|
+
requestTransientStarterPrompts() {
|
|
221
|
+
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
222
|
+
return;
|
|
223
|
+
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
224
|
+
const t = wt();
|
|
225
|
+
this.sendNow(
|
|
226
|
+
m({
|
|
227
|
+
type: "starter_prompts.page_context",
|
|
228
|
+
pageUrl: t.pageUrl,
|
|
229
|
+
pageTitle: t.pageTitle,
|
|
230
|
+
htmlContent: t.htmlContent
|
|
231
|
+
})
|
|
232
|
+
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
233
|
+
}
|
|
184
234
|
flushQueuedClientEvents() {
|
|
185
235
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
186
236
|
return;
|
|
187
237
|
const t = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
188
|
-
|
|
238
|
+
k(this.options.clientId, this.queuedClientEvents);
|
|
189
239
|
for (let s = 0; s < t.length; s += 1) {
|
|
190
240
|
const n = t[s];
|
|
191
241
|
if (!this.sendNow(m(n))) {
|
|
192
|
-
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)),
|
|
242
|
+
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), k(this.options.clientId, this.queuedClientEvents);
|
|
193
243
|
return;
|
|
194
244
|
}
|
|
195
|
-
|
|
245
|
+
k(this.options.clientId, this.queuedClientEvents);
|
|
196
246
|
}
|
|
197
247
|
}
|
|
198
248
|
handleServerEvent(t) {
|
|
@@ -200,48 +250,63 @@ class B {
|
|
|
200
250
|
this.handleRunAck(t);
|
|
201
251
|
return;
|
|
202
252
|
}
|
|
203
|
-
if (
|
|
204
|
-
const s =
|
|
253
|
+
if (pt(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
254
|
+
const s = At(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
205
255
|
u("web-sdk.agent", "Received auth.ok appearance", {
|
|
206
256
|
hasAppearance: n,
|
|
207
257
|
rawAppearance: t.appearance,
|
|
208
258
|
normalizedAppearance: s
|
|
209
|
-
}), this.runtimeHelperJavascript =
|
|
210
|
-
const r =
|
|
211
|
-
user:
|
|
259
|
+
}), this.runtimeHelperJavascript = Rt(t.runtimeHelpers)?.javascript ?? null;
|
|
260
|
+
const r = H(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, a = {
|
|
261
|
+
user: qt(t.user),
|
|
212
262
|
status: "connected"
|
|
213
263
|
};
|
|
214
|
-
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r), (n || s) && (a.appearance = s), this.setState(a), this.state.sessionId && this.send({
|
|
264
|
+
(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 && !St() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
215
265
|
type: "page.upsert",
|
|
216
266
|
sessionId: this.state.sessionId,
|
|
217
|
-
page:
|
|
267
|
+
page: f(),
|
|
218
268
|
model: this.options.model
|
|
219
269
|
});
|
|
220
270
|
return;
|
|
221
271
|
}
|
|
272
|
+
if (t.type === "starterPrompts.updated") {
|
|
273
|
+
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
274
|
+
starterPrompts: H(t, "starterPrompts"),
|
|
275
|
+
starterPromptsLoading: !1
|
|
276
|
+
});
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
222
279
|
if (t.type === "conversation.state") {
|
|
223
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
224
|
-
this.latestRecoverableClientMessageId = r,
|
|
225
|
-
sessionId:
|
|
226
|
-
messages:
|
|
280
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Bt(s), r = n ? null : Ft(s);
|
|
281
|
+
this.latestRecoverableClientMessageId = r, jt(s) && this.clearRetryTimers(), this.setState({
|
|
282
|
+
sessionId: p(t.session, "id") ?? this.state.sessionId,
|
|
283
|
+
messages: Nt(s),
|
|
227
284
|
...n ? { assistantDraft: "", isThinking: !1 } : r ? { assistantDraft: "", isThinking: !0, lastError: null } : {}
|
|
228
285
|
}), n ? this.clearThinkingWatchdog() : r && (this.activeClientMessageId = r, this.markThinkingProgress());
|
|
229
286
|
return;
|
|
230
287
|
}
|
|
288
|
+
if (t.type === "sessions.page") {
|
|
289
|
+
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
290
|
+
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
291
|
+
sessions: Ut(t.sessions),
|
|
292
|
+
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
293
|
+
}));
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
231
296
|
if (t.type === "session.updated") {
|
|
232
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
297
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: p(t.session, "id") ?? this.state.sessionId });
|
|
233
298
|
return;
|
|
234
299
|
}
|
|
235
300
|
if (t.type === "session.item") {
|
|
236
|
-
const s =
|
|
301
|
+
const s = $(t.item);
|
|
237
302
|
if (s) {
|
|
238
303
|
s.role === "assistant" && (this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
239
304
|
const n = t.item.data;
|
|
240
|
-
|
|
241
|
-
messages:
|
|
305
|
+
$t(n) && this.clearRunAckResyncRetryTimer(), this.setState({
|
|
306
|
+
messages: Lt(this.state.messages, s),
|
|
242
307
|
assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
|
|
243
|
-
...
|
|
244
|
-
}),
|
|
308
|
+
...A(n) ? { assistantDraft: "", isThinking: !1 } : {}
|
|
309
|
+
}), A(n) && this.clearThinkingWatchdog(), this.emit("message", s);
|
|
245
310
|
}
|
|
246
311
|
return;
|
|
247
312
|
}
|
|
@@ -261,15 +326,20 @@ class B {
|
|
|
261
326
|
return;
|
|
262
327
|
}
|
|
263
328
|
if (t.type === "error") {
|
|
329
|
+
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
330
|
+
if (s && n) {
|
|
331
|
+
window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.reject(new Error(typeof t.message == "string" ? t.message : "Pluno error"));
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
264
334
|
if (this.retryAfterRetryableError(t))
|
|
265
335
|
return;
|
|
266
|
-
const
|
|
336
|
+
const r = new Error(typeof t.message == "string" ? t.message.replace(/Product Agent/g, "Pluno") : "Pluno error");
|
|
267
337
|
this.setState({
|
|
268
338
|
status: "error",
|
|
269
339
|
isThinking: !1,
|
|
270
|
-
lastError:
|
|
340
|
+
lastError: r.message,
|
|
271
341
|
lastErrorCode: typeof t.code == "string" ? t.code : null
|
|
272
|
-
}), this.clearThinkingWatchdog(), this.emit("error",
|
|
342
|
+
}), this.clearThinkingWatchdog(), this.emit("error", r);
|
|
273
343
|
}
|
|
274
344
|
}
|
|
275
345
|
retryAfterRetryableError(t) {
|
|
@@ -280,22 +350,27 @@ class B {
|
|
|
280
350
|
if (i >= 1)
|
|
281
351
|
return !1;
|
|
282
352
|
this.retryAttemptsByClientMessageId[n] = i + 1;
|
|
283
|
-
const
|
|
353
|
+
const o = typeof t.retryAfterMs == "number" ? t.retryAfterMs : 2e3;
|
|
284
354
|
return this.setState({ status: "reconnecting", isThinking: !0, lastError: null }), this.retryTimersByClientMessageId[n] = window.setTimeout(() => {
|
|
285
355
|
delete this.retryTimersByClientMessageId[n], this.setState({ status: "connected", isThinking: !0, lastError: null }), this.markThinkingProgress(), this.send({
|
|
286
356
|
type: "chat.retry_last_user_message",
|
|
287
357
|
sessionId: s,
|
|
288
358
|
clientMessageId: n
|
|
289
359
|
});
|
|
290
|
-
},
|
|
360
|
+
}, o), !0;
|
|
291
361
|
}
|
|
292
362
|
clearRetryTimers() {
|
|
293
363
|
for (const t of Object.values(this.retryTimersByClientMessageId))
|
|
294
364
|
window.clearTimeout(t);
|
|
295
365
|
this.retryTimersByClientMessageId = {};
|
|
296
366
|
}
|
|
367
|
+
rejectPendingSessionHistoryRequests(t) {
|
|
368
|
+
for (const s of this.pendingSessionHistoryRequests.values())
|
|
369
|
+
window.clearTimeout(s.timeout), s.reject(new Error(t));
|
|
370
|
+
this.pendingSessionHistoryRequests.clear();
|
|
371
|
+
}
|
|
297
372
|
markThinkingProgress() {
|
|
298
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
373
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(T), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
299
374
|
}
|
|
300
375
|
scheduleThinkingWatchdog(t) {
|
|
301
376
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -312,7 +387,7 @@ class B {
|
|
|
312
387
|
scheduleRunAckWatchdog(t) {
|
|
313
388
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
314
389
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
315
|
-
},
|
|
390
|
+
}, at);
|
|
316
391
|
}
|
|
317
392
|
recoverMissedRunAck(t) {
|
|
318
393
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (u("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -322,7 +397,7 @@ class B {
|
|
|
322
397
|
}
|
|
323
398
|
scheduleRunAckResyncRetry(t) {
|
|
324
399
|
this.clearRunAckResyncRetryTimer(), this.runAckResyncRetryTimer = window.setTimeout(() => {
|
|
325
|
-
this.runAckResyncRetryTimer = null, !((this.runAckRecoveryRetryAttemptsByClientMessageId[t] ?? 0) >= 1) && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.runAckRecoveryRetryAttemptsByClientMessageId[t] = 1, this.thinkingWatchdogRetryAttemptsByClientMessageId[t] =
|
|
400
|
+
this.runAckResyncRetryTimer = null, !((this.runAckRecoveryRetryAttemptsByClientMessageId[t] ?? 0) >= 1) && (!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || this.latestRecoverableClientMessageId !== t || (this.runAckRecoveryRetryAttemptsByClientMessageId[t] = 1, this.thinkingWatchdogRetryAttemptsByClientMessageId[t] = U, this.setState({
|
|
326
401
|
status: this.state.status === "reconnecting" ? "reconnecting" : "connected",
|
|
327
402
|
isThinking: !0,
|
|
328
403
|
lastError: null
|
|
@@ -333,8 +408,8 @@ class B {
|
|
|
333
408
|
type: "chat.retry_last_user_message",
|
|
334
409
|
sessionId: this.state.sessionId,
|
|
335
410
|
clientMessageId: t
|
|
336
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
337
|
-
},
|
|
411
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(T)));
|
|
412
|
+
}, ct);
|
|
338
413
|
}
|
|
339
414
|
clearRunAckResyncRetryTimer() {
|
|
340
415
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -349,7 +424,7 @@ class B {
|
|
|
349
424
|
if (!t) {
|
|
350
425
|
u("web-sdk.agent", "Pluno thinking watchdog resyncing without active message id", {
|
|
351
426
|
sessionId: this.state.sessionId
|
|
352
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
427
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(T);
|
|
353
428
|
return;
|
|
354
429
|
}
|
|
355
430
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.thinkingWatchdogRetryAttemptsByClientMessageId[t] ?? 0;
|
|
@@ -358,15 +433,15 @@ class B {
|
|
|
358
433
|
sessionId: this.state.sessionId,
|
|
359
434
|
clientMessageId: t,
|
|
360
435
|
resyncAttempts: s + 1
|
|
361
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
436
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(ot);
|
|
362
437
|
return;
|
|
363
438
|
}
|
|
364
|
-
if (n >=
|
|
439
|
+
if (n >= U) {
|
|
365
440
|
u("web-sdk.agent", "Pluno thinking watchdog retry limit reached; continuing resync", {
|
|
366
441
|
sessionId: this.state.sessionId,
|
|
367
442
|
clientMessageId: t,
|
|
368
443
|
retryAttempts: n
|
|
369
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
444
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(T);
|
|
370
445
|
return;
|
|
371
446
|
}
|
|
372
447
|
this.thinkingWatchdogRetryAttemptsByClientMessageId[t] = n + 1, this.setState({
|
|
@@ -381,31 +456,31 @@ class B {
|
|
|
381
456
|
type: "chat.retry_last_user_message",
|
|
382
457
|
sessionId: this.state.sessionId,
|
|
383
458
|
clientMessageId: t
|
|
384
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
459
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(T);
|
|
385
460
|
}
|
|
386
461
|
resyncThinkingSession() {
|
|
387
462
|
this.state.sessionId ? this.send({
|
|
388
463
|
type: "page.upsert",
|
|
389
464
|
sessionId: this.state.sessionId,
|
|
390
|
-
page:
|
|
465
|
+
page: f(),
|
|
391
466
|
model: this.options.model
|
|
392
467
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
393
468
|
}
|
|
394
469
|
async executeToolCall(t) {
|
|
395
470
|
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = t.rawInput;
|
|
396
|
-
if (!s || !n || !
|
|
471
|
+
if (!s || !n || !Yt(r))
|
|
397
472
|
return;
|
|
398
|
-
const i =
|
|
399
|
-
let
|
|
473
|
+
const i = ft(this.state.messages), o = yt(i);
|
|
474
|
+
let a = null, c;
|
|
400
475
|
try {
|
|
401
|
-
|
|
476
|
+
a = await this.executeRuntimeHelper(), c = await O(r).catch((l) => ({
|
|
402
477
|
ok: !1,
|
|
403
478
|
exception: {
|
|
404
479
|
message: l instanceof Error ? l.message : String(l)
|
|
405
480
|
}
|
|
406
481
|
}));
|
|
407
482
|
} finally {
|
|
408
|
-
|
|
483
|
+
o();
|
|
409
484
|
}
|
|
410
485
|
this.send({
|
|
411
486
|
type: "tool.result",
|
|
@@ -414,7 +489,7 @@ class B {
|
|
|
414
489
|
toolName: "execute_code",
|
|
415
490
|
summary: r.summary,
|
|
416
491
|
rawInput: m(r),
|
|
417
|
-
rawOutput: m(
|
|
492
|
+
rawOutput: m(Ct(c, a))
|
|
418
493
|
});
|
|
419
494
|
}
|
|
420
495
|
async executeRuntimeHelper() {
|
|
@@ -423,71 +498,71 @@ class B {
|
|
|
423
498
|
const t = await O({
|
|
424
499
|
javascript: this.runtimeHelperJavascript
|
|
425
500
|
});
|
|
426
|
-
return t.ok === !1 ?
|
|
501
|
+
return t.ok === !1 ? Pt(t) : null;
|
|
427
502
|
}
|
|
428
503
|
enableNetworkCapture() {
|
|
429
504
|
if (this.networkCaptureCleanup)
|
|
430
505
|
return;
|
|
431
506
|
const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
|
|
432
|
-
window.fetch = async (i,
|
|
433
|
-
const
|
|
507
|
+
window.fetch = async (i, o) => {
|
|
508
|
+
const a = Date.now(), c = new Date(a).toISOString(), l = i instanceof Request ? i : null, y = typeof i == "string" ? i : i instanceof URL ? i.toString() : l?.url ?? "", b = (o?.method ?? l?.method ?? "GET").toUpperCase(), M = v(new Headers(o?.headers ?? l?.headers ?? void 0)), q = await Qt(l, o);
|
|
434
509
|
try {
|
|
435
|
-
const d = await t(i,
|
|
510
|
+
const d = await t(i, o);
|
|
436
511
|
return this.enqueueNetworkEvent({
|
|
437
|
-
requestId:
|
|
438
|
-
url:
|
|
512
|
+
requestId: w("fetch"),
|
|
513
|
+
url: y,
|
|
439
514
|
method: b,
|
|
440
515
|
requestHeaders: M,
|
|
441
|
-
requestBody:
|
|
516
|
+
requestBody: q,
|
|
442
517
|
resourceType: "fetch",
|
|
443
518
|
responseStatus: d.status,
|
|
444
|
-
responseHeaders:
|
|
445
|
-
responseBody: await
|
|
446
|
-
startedAt:
|
|
447
|
-
durationMs: Date.now() -
|
|
519
|
+
responseHeaders: v(d.headers),
|
|
520
|
+
responseBody: await te(d),
|
|
521
|
+
startedAt: c,
|
|
522
|
+
durationMs: Date.now() - a
|
|
448
523
|
}), d;
|
|
449
524
|
} catch (d) {
|
|
450
525
|
throw this.enqueueNetworkEvent({
|
|
451
|
-
requestId:
|
|
452
|
-
url:
|
|
526
|
+
requestId: w("fetch"),
|
|
527
|
+
url: y,
|
|
453
528
|
method: b,
|
|
454
529
|
requestHeaders: M,
|
|
455
|
-
requestBody:
|
|
530
|
+
requestBody: q,
|
|
456
531
|
resourceType: "fetch",
|
|
457
532
|
errorText: d instanceof Error ? d.message : String(d),
|
|
458
|
-
startedAt:
|
|
459
|
-
durationMs: Date.now() -
|
|
533
|
+
startedAt: c,
|
|
534
|
+
durationMs: Date.now() - a
|
|
460
535
|
}), d;
|
|
461
536
|
}
|
|
462
|
-
}, XMLHttpRequest.prototype.open = function(a, c,
|
|
537
|
+
}, XMLHttpRequest.prototype.open = function(o, a, c, l, y) {
|
|
463
538
|
return this.__plunoMeta = {
|
|
464
|
-
requestId:
|
|
465
|
-
method: String(
|
|
466
|
-
url: typeof
|
|
539
|
+
requestId: w("xhr"),
|
|
540
|
+
method: String(o ?? "GET").toUpperCase(),
|
|
541
|
+
url: typeof a == "string" ? a : a.toString(),
|
|
467
542
|
requestHeaders: {},
|
|
468
543
|
startedAtMs: Date.now(),
|
|
469
544
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
470
|
-
}, s.call(this, a, c
|
|
471
|
-
}, XMLHttpRequest.prototype.setRequestHeader = function(
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
474
|
-
const l =
|
|
475
|
-
l[
|
|
545
|
+
}, s.call(this, o, a, c ?? !0, l ?? void 0, y ?? void 0);
|
|
546
|
+
}, XMLHttpRequest.prototype.setRequestHeader = function(o, a) {
|
|
547
|
+
const c = this.__plunoMeta;
|
|
548
|
+
if (c) {
|
|
549
|
+
const l = c.requestHeaders ?? {};
|
|
550
|
+
l[o] = a, c.requestHeaders = l;
|
|
476
551
|
}
|
|
477
|
-
return n.call(this,
|
|
478
|
-
}, XMLHttpRequest.prototype.send = function(
|
|
479
|
-
const
|
|
480
|
-
requestId:
|
|
552
|
+
return n.call(this, o, a);
|
|
553
|
+
}, XMLHttpRequest.prototype.send = function(o) {
|
|
554
|
+
const a = window.__plunoProductAgentInstance, c = this.__plunoMeta ?? {
|
|
555
|
+
requestId: w("xhr"),
|
|
481
556
|
method: "GET",
|
|
482
557
|
url: "",
|
|
483
558
|
requestHeaders: {},
|
|
484
559
|
startedAtMs: Date.now(),
|
|
485
560
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
486
561
|
};
|
|
487
|
-
return
|
|
562
|
+
return c.requestBody = X(o), this.__plunoMeta = c, this.addEventListener(
|
|
488
563
|
"loadend",
|
|
489
564
|
function() {
|
|
490
|
-
!
|
|
565
|
+
!a || !this.__plunoMeta || a.enqueueNetworkEvent({
|
|
491
566
|
requestId: String(this.__plunoMeta.requestId),
|
|
492
567
|
url: String(this.__plunoMeta.url ?? ""),
|
|
493
568
|
method: String(this.__plunoMeta.method ?? "GET"),
|
|
@@ -495,15 +570,15 @@ class B {
|
|
|
495
570
|
requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
|
|
496
571
|
resourceType: "xhr",
|
|
497
572
|
responseStatus: this.status,
|
|
498
|
-
responseHeaders:
|
|
499
|
-
responseBody:
|
|
573
|
+
responseHeaders: se(this.getAllResponseHeaders()),
|
|
574
|
+
responseBody: ee(this),
|
|
500
575
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
501
576
|
startedAt: String(this.__plunoMeta.startedAt),
|
|
502
577
|
durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
|
|
503
578
|
});
|
|
504
579
|
},
|
|
505
580
|
{ once: !0 }
|
|
506
|
-
), r.call(this,
|
|
581
|
+
), r.call(this, o ?? null);
|
|
507
582
|
}, window.__plunoProductAgentInstance = this, this.networkCaptureCleanup = () => {
|
|
508
583
|
window.fetch = t, XMLHttpRequest.prototype.open = s, XMLHttpRequest.prototype.setRequestHeader = n, XMLHttpRequest.prototype.send = r, window.__plunoProductAgentInstance === this && delete window.__plunoProductAgentInstance;
|
|
509
584
|
};
|
|
@@ -515,10 +590,10 @@ class B {
|
|
|
515
590
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
516
591
|
type: "network.batch",
|
|
517
592
|
sessionId: this.state.sessionId ?? void 0,
|
|
518
|
-
page:
|
|
593
|
+
page: f(),
|
|
519
594
|
events: s
|
|
520
595
|
});
|
|
521
|
-
},
|
|
596
|
+
}, lt));
|
|
522
597
|
}
|
|
523
598
|
scheduleReconnect() {
|
|
524
599
|
this.reconnectTimer !== null || this.state.status === "closed" || (this.reconnectTimer = window.setTimeout(() => {
|
|
@@ -529,12 +604,12 @@ class B {
|
|
|
529
604
|
isThinking: this.state.isThinking
|
|
530
605
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect();
|
|
531
606
|
});
|
|
532
|
-
},
|
|
607
|
+
}, it));
|
|
533
608
|
}
|
|
534
609
|
startHeartbeat() {
|
|
535
610
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
536
611
|
this.sendNow({ type: "runtime.ping" });
|
|
537
|
-
},
|
|
612
|
+
}, rt);
|
|
538
613
|
}
|
|
539
614
|
stopHeartbeat() {
|
|
540
615
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
|
|
@@ -544,7 +619,7 @@ class B {
|
|
|
544
619
|
...this.state,
|
|
545
620
|
...t,
|
|
546
621
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
547
|
-
},
|
|
622
|
+
}, Jt(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
548
623
|
}
|
|
549
624
|
emit(t, s) {
|
|
550
625
|
this.listeners[t]?.forEach((r) => r(s));
|
|
@@ -561,15 +636,15 @@ function u(e, t, s) {
|
|
|
561
636
|
}, i = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
562
637
|
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 }));
|
|
563
638
|
}
|
|
564
|
-
function
|
|
639
|
+
function ht(e) {
|
|
565
640
|
const t = typeof e == "function" ? e() : e;
|
|
566
641
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
567
642
|
}
|
|
568
|
-
function
|
|
643
|
+
function pt(e) {
|
|
569
644
|
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";
|
|
570
645
|
}
|
|
571
|
-
const
|
|
572
|
-
function
|
|
646
|
+
const gt = 5e3;
|
|
647
|
+
function ft(e) {
|
|
573
648
|
const t = [];
|
|
574
649
|
for (const s of e)
|
|
575
650
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -580,74 +655,74 @@ function dt(e) {
|
|
|
580
655
|
});
|
|
581
656
|
return t;
|
|
582
657
|
}
|
|
583
|
-
function
|
|
584
|
-
const t = new Map(e.map((
|
|
585
|
-
id:
|
|
586
|
-
name:
|
|
587
|
-
mimeType:
|
|
588
|
-
sizeBytes:
|
|
589
|
-
}), n = (
|
|
590
|
-
const l = t.get(
|
|
658
|
+
function yt(e) {
|
|
659
|
+
const t = new Map(e.map((c) => [c.id, c])), s = (c) => ({
|
|
660
|
+
id: c.id,
|
|
661
|
+
name: c.name,
|
|
662
|
+
mimeType: c.mimeType,
|
|
663
|
+
sizeBytes: c.sizeBytes
|
|
664
|
+
}), n = (c) => {
|
|
665
|
+
const l = t.get(c);
|
|
591
666
|
if (!l)
|
|
592
|
-
throw new Error(`Unknown Pluno user file: ${
|
|
667
|
+
throw new Error(`Unknown Pluno user file: ${c}`);
|
|
593
668
|
return l;
|
|
594
|
-
}, r = async (
|
|
595
|
-
const l = n(
|
|
596
|
-
return
|
|
597
|
-
}, i = globalThis,
|
|
669
|
+
}, r = async (c) => {
|
|
670
|
+
const l = n(c);
|
|
671
|
+
return mt(l.dataUrl, l.mimeType);
|
|
672
|
+
}, i = globalThis, o = i.pluno?.userFiles, a = Object.prototype.hasOwnProperty.call(i.pluno ?? {}, "userFiles");
|
|
598
673
|
return i.pluno = {
|
|
599
674
|
...i.pluno ?? {},
|
|
600
675
|
userFiles: {
|
|
601
676
|
list: () => e.map(s),
|
|
602
|
-
get: (
|
|
603
|
-
const l = t.get(
|
|
677
|
+
get: (c) => {
|
|
678
|
+
const l = t.get(c);
|
|
604
679
|
return l ? s(l) : null;
|
|
605
680
|
},
|
|
606
|
-
getDataUrl: async (
|
|
681
|
+
getDataUrl: async (c) => n(c).dataUrl,
|
|
607
682
|
getBlob: r,
|
|
608
|
-
getArrayBuffer: async (
|
|
609
|
-
getFile: async (
|
|
610
|
-
const l = n(
|
|
611
|
-
return new File([await r(
|
|
683
|
+
getArrayBuffer: async (c) => await (await r(c)).arrayBuffer(),
|
|
684
|
+
getFile: async (c) => {
|
|
685
|
+
const l = n(c);
|
|
686
|
+
return new File([await r(c)], l.name, { type: l.mimeType });
|
|
612
687
|
}
|
|
613
688
|
}
|
|
614
689
|
}, () => {
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
690
|
+
const c = i.pluno ?? {};
|
|
691
|
+
if (a) {
|
|
617
692
|
i.pluno = {
|
|
618
|
-
...
|
|
619
|
-
userFiles:
|
|
693
|
+
...c,
|
|
694
|
+
userFiles: o
|
|
620
695
|
};
|
|
621
696
|
return;
|
|
622
697
|
}
|
|
623
|
-
const { userFiles: l, ...
|
|
624
|
-
i.pluno =
|
|
698
|
+
const { userFiles: l, ...y } = c;
|
|
699
|
+
i.pluno = y;
|
|
625
700
|
};
|
|
626
701
|
}
|
|
627
|
-
function
|
|
702
|
+
function mt(e, t) {
|
|
628
703
|
const s = e.indexOf(","), n = s >= 0 ? e.slice(s + 1) : e, r = atob(n), i = new Uint8Array(r.length);
|
|
629
|
-
for (let
|
|
630
|
-
i[
|
|
704
|
+
for (let o = 0; o < r.length; o += 1)
|
|
705
|
+
i[o] = r.charCodeAt(o);
|
|
631
706
|
return new Blob([i], { type: t });
|
|
632
707
|
}
|
|
633
708
|
async function O(e) {
|
|
634
709
|
const t = Object.getPrototypeOf(async function() {
|
|
635
|
-
}).constructor, s =
|
|
710
|
+
}).constructor, s = gt, n = Date.now(), r = [], i = {
|
|
636
711
|
log: console.log,
|
|
637
712
|
info: console.info,
|
|
638
713
|
warn: console.warn,
|
|
639
714
|
error: console.error
|
|
640
|
-
},
|
|
641
|
-
r.push({ level:
|
|
715
|
+
}, o = (a) => (...c) => {
|
|
716
|
+
r.push({ level: a, args: c }), i[a](...c);
|
|
642
717
|
};
|
|
643
|
-
console.log =
|
|
718
|
+
console.log = o("log"), console.info = o("info"), console.warn = o("warn"), console.error = o("error");
|
|
644
719
|
try {
|
|
645
720
|
return {
|
|
646
721
|
ok: !0,
|
|
647
722
|
result: await Promise.race([
|
|
648
723
|
new t(e.javascript)(),
|
|
649
724
|
new Promise(
|
|
650
|
-
(
|
|
725
|
+
(c, l) => window.setTimeout(() => l(new Error(`execute_code timed out after ${s}ms`)), s)
|
|
651
726
|
)
|
|
652
727
|
]),
|
|
653
728
|
console: r,
|
|
@@ -657,14 +732,14 @@ async function O(e) {
|
|
|
657
732
|
origin: location.origin
|
|
658
733
|
}
|
|
659
734
|
};
|
|
660
|
-
} catch (
|
|
735
|
+
} catch (a) {
|
|
661
736
|
return {
|
|
662
737
|
ok: !1,
|
|
663
738
|
console: r,
|
|
664
739
|
exception: {
|
|
665
|
-
name:
|
|
666
|
-
message:
|
|
667
|
-
stack:
|
|
740
|
+
name: a instanceof Error ? a.name : "Error",
|
|
741
|
+
message: a instanceof Error ? a.message : String(a),
|
|
742
|
+
stack: a instanceof Error ? a.stack : void 0
|
|
668
743
|
},
|
|
669
744
|
metadata: {
|
|
670
745
|
durationMs: Date.now() - n,
|
|
@@ -676,15 +751,15 @@ async function O(e) {
|
|
|
676
751
|
console.log = i.log, console.info = i.info, console.warn = i.warn, console.error = i.error;
|
|
677
752
|
}
|
|
678
753
|
}
|
|
679
|
-
function
|
|
754
|
+
function Tt(e) {
|
|
680
755
|
return e.replace(/\/+$/, "");
|
|
681
756
|
}
|
|
682
|
-
function
|
|
757
|
+
function kt(e) {
|
|
683
758
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
684
759
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
685
760
|
}
|
|
686
|
-
function
|
|
687
|
-
const e =
|
|
761
|
+
function f() {
|
|
762
|
+
const e = F();
|
|
688
763
|
return {
|
|
689
764
|
url: location.href,
|
|
690
765
|
title: document.title,
|
|
@@ -692,9 +767,43 @@ function y() {
|
|
|
692
767
|
...e ? { plunoProductAgentUi: e } : {}
|
|
693
768
|
};
|
|
694
769
|
}
|
|
695
|
-
function
|
|
770
|
+
function wt() {
|
|
771
|
+
return {
|
|
772
|
+
pageUrl: location.href,
|
|
773
|
+
pageTitle: document.title,
|
|
774
|
+
htmlContent: It()
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function St() {
|
|
778
|
+
return F()?.surface === "browser_extension_sdk_preview";
|
|
779
|
+
}
|
|
780
|
+
function It() {
|
|
781
|
+
const e = document.body?.cloneNode(!0);
|
|
782
|
+
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
783
|
+
[
|
|
784
|
+
"script",
|
|
785
|
+
"style",
|
|
786
|
+
"noscript",
|
|
787
|
+
"template",
|
|
788
|
+
"svg",
|
|
789
|
+
"canvas",
|
|
790
|
+
"iframe",
|
|
791
|
+
"input",
|
|
792
|
+
"textarea",
|
|
793
|
+
"select",
|
|
794
|
+
"option",
|
|
795
|
+
"[type='hidden']",
|
|
796
|
+
"[data-pluno-product-agent-widget]",
|
|
797
|
+
".pluno-pa-widget"
|
|
798
|
+
].join(",")
|
|
799
|
+
).forEach((t) => t.remove()), e.querySelectorAll("*").forEach((t) => {
|
|
800
|
+
for (const s of Array.from(t.attributes))
|
|
801
|
+
s.name === "href" || s.name === "aria-label" || s.name === "role" || t.removeAttribute(s.name);
|
|
802
|
+
}), e.textContent?.replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[email]").replace(/\b(?:\d[ -]*?){13,19}\b/g, "[number]").replace(/\b(?:sk|pk|tok|key|secret|token)_[A-Za-z0-9_-]{8,}\b/gi, "[secret]").replace(/\s+/g, " ").trim().slice(0, 12e3) ?? "") : "";
|
|
803
|
+
}
|
|
804
|
+
function F() {
|
|
696
805
|
const e = document.querySelector(N);
|
|
697
|
-
if (!(e ?? document.querySelector(
|
|
806
|
+
if (!(e ?? document.querySelector(_)))
|
|
698
807
|
return;
|
|
699
808
|
const s = e ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
700
809
|
return {
|
|
@@ -703,28 +812,28 @@ function yt() {
|
|
|
703
812
|
selectors: [
|
|
704
813
|
{
|
|
705
814
|
name: "widget_host",
|
|
706
|
-
selector: s === "browser_extension_sdk_preview" ? N :
|
|
815
|
+
selector: s === "browser_extension_sdk_preview" ? N : _,
|
|
707
816
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
708
817
|
},
|
|
709
818
|
{
|
|
710
819
|
name: "widget_root",
|
|
711
|
-
selector:
|
|
820
|
+
selector: Q,
|
|
712
821
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
713
822
|
},
|
|
714
823
|
{
|
|
715
824
|
name: "widget_panel",
|
|
716
|
-
selector:
|
|
825
|
+
selector: tt,
|
|
717
826
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
718
827
|
},
|
|
719
828
|
{
|
|
720
829
|
name: "widget_timeline",
|
|
721
|
-
selector:
|
|
830
|
+
selector: et,
|
|
722
831
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
723
832
|
}
|
|
724
833
|
]
|
|
725
834
|
};
|
|
726
835
|
}
|
|
727
|
-
function
|
|
836
|
+
function _t(e) {
|
|
728
837
|
try {
|
|
729
838
|
const t = JSON.parse(e);
|
|
730
839
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -732,33 +841,33 @@ function mt(e) {
|
|
|
732
841
|
return { type: "error", message: "Invalid server event" };
|
|
733
842
|
}
|
|
734
843
|
}
|
|
735
|
-
function
|
|
844
|
+
function H(e, t) {
|
|
736
845
|
if (!e || typeof e != "object")
|
|
737
846
|
return [];
|
|
738
847
|
const s = e[t];
|
|
739
848
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
740
849
|
}
|
|
741
|
-
function
|
|
850
|
+
function Et(e) {
|
|
742
851
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
743
852
|
}
|
|
744
|
-
function
|
|
853
|
+
function At(e) {
|
|
745
854
|
if (!e || typeof e != "object")
|
|
746
855
|
return null;
|
|
747
|
-
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,
|
|
748
|
-
return !r && !i && !
|
|
856
|
+
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;
|
|
857
|
+
return !r && !i && !o && a === null ? null : {
|
|
749
858
|
...r ? { accentColor: r } : {},
|
|
750
859
|
...i ? { colorScheme: i } : {},
|
|
751
|
-
...
|
|
752
|
-
...
|
|
860
|
+
...o ? { fontFamily: o } : {},
|
|
861
|
+
...a !== null ? { scribbleStyle: a } : {}
|
|
753
862
|
};
|
|
754
863
|
}
|
|
755
|
-
function
|
|
864
|
+
function Rt(e) {
|
|
756
865
|
if (!e || typeof e != "object")
|
|
757
866
|
return null;
|
|
758
867
|
const t = e.javascript;
|
|
759
868
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
760
869
|
}
|
|
761
|
-
function
|
|
870
|
+
function Ct(e, t) {
|
|
762
871
|
return t ? e && typeof e == "object" ? {
|
|
763
872
|
...e,
|
|
764
873
|
helperError: t
|
|
@@ -768,30 +877,30 @@ function It(e, t) {
|
|
|
768
877
|
helperError: t
|
|
769
878
|
} : e;
|
|
770
879
|
}
|
|
771
|
-
function
|
|
880
|
+
function Pt(e) {
|
|
772
881
|
if (!e || typeof e != "object")
|
|
773
882
|
return e;
|
|
774
883
|
const t = e;
|
|
775
884
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
776
885
|
}
|
|
777
|
-
function
|
|
886
|
+
function bt() {
|
|
778
887
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
779
888
|
if (t)
|
|
780
889
|
return t;
|
|
781
890
|
const s = crypto.randomUUID();
|
|
782
891
|
return window.localStorage.setItem(e, s), s;
|
|
783
892
|
}
|
|
784
|
-
function
|
|
785
|
-
const e = window.sessionStorage.getItem(
|
|
893
|
+
function Mt() {
|
|
894
|
+
const e = window.sessionStorage.getItem(D);
|
|
786
895
|
if (e)
|
|
787
896
|
return e;
|
|
788
897
|
const t = crypto.randomUUID();
|
|
789
|
-
return window.sessionStorage.setItem(
|
|
898
|
+
return window.sessionStorage.setItem(D, t), t;
|
|
790
899
|
}
|
|
791
|
-
function
|
|
900
|
+
function W() {
|
|
792
901
|
return crypto.randomUUID();
|
|
793
902
|
}
|
|
794
|
-
function
|
|
903
|
+
function qt(e) {
|
|
795
904
|
if (!e || typeof e != "object")
|
|
796
905
|
return null;
|
|
797
906
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -802,12 +911,30 @@ function Ct(e) {
|
|
|
802
911
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
803
912
|
} : null;
|
|
804
913
|
}
|
|
805
|
-
function
|
|
806
|
-
return Array.isArray(e) ?
|
|
807
|
-
e.map(
|
|
914
|
+
function Nt(e) {
|
|
915
|
+
return Array.isArray(e) ? R(
|
|
916
|
+
e.map($).filter((t) => t !== null)
|
|
808
917
|
) : [];
|
|
809
918
|
}
|
|
810
|
-
function
|
|
919
|
+
function Ut(e) {
|
|
920
|
+
return Array.isArray(e) ? e.flatMap((t) => {
|
|
921
|
+
if (!t || typeof t != "object")
|
|
922
|
+
return [];
|
|
923
|
+
const s = t, n = p(s, "id"), r = p(s, "createdAt"), i = p(s, "updatedAt"), o = p(s, "lastActiveAt");
|
|
924
|
+
return !n || !r || !i || !o ? [] : [
|
|
925
|
+
{
|
|
926
|
+
id: n,
|
|
927
|
+
title: p(s, "title"),
|
|
928
|
+
firstUserMessage: p(s, "firstUserMessage"),
|
|
929
|
+
currentPage: s.currentPage ?? null,
|
|
930
|
+
createdAt: r,
|
|
931
|
+
updatedAt: i,
|
|
932
|
+
lastActiveAt: o
|
|
933
|
+
}
|
|
934
|
+
];
|
|
935
|
+
}) : [];
|
|
936
|
+
}
|
|
937
|
+
function $(e) {
|
|
811
938
|
if (!e || typeof e != "object")
|
|
812
939
|
return null;
|
|
813
940
|
const t = e, s = t.data;
|
|
@@ -819,32 +946,32 @@ function L(e) {
|
|
|
819
946
|
return {
|
|
820
947
|
id: String(t.id ?? crypto.randomUUID()),
|
|
821
948
|
role: r,
|
|
822
|
-
content:
|
|
949
|
+
content: xt(n.content),
|
|
823
950
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
824
|
-
attachments:
|
|
951
|
+
attachments: z(n.attachments)
|
|
825
952
|
};
|
|
826
953
|
}
|
|
827
954
|
return n.type === "function_call" || n.type === "tool_call" || n.type === "web_search_call" ? {
|
|
828
955
|
id: String(t.id ?? crypto.randomUUID()),
|
|
829
956
|
role: "tool",
|
|
830
|
-
content:
|
|
957
|
+
content: Ot(n),
|
|
831
958
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
832
959
|
dataType: String(n.type),
|
|
833
960
|
toolName: typeof n.name == "string" ? n.name : void 0,
|
|
834
|
-
callId:
|
|
961
|
+
callId: Wt(n) ?? void 0,
|
|
835
962
|
loading: n.localExecutionStatus === "running"
|
|
836
963
|
} : n.type === "run_status" || n.type === "run_error" ? n.type === "run_status" && (n.status === "running" || n.status === "retrying") || n.type === "run_error" && n.stage === "tool_execution" ? null : {
|
|
837
964
|
id: String(t.id ?? crypto.randomUUID()),
|
|
838
965
|
role: "system",
|
|
839
|
-
content:
|
|
966
|
+
content: Dt(n),
|
|
840
967
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
841
968
|
dataType: String(n.type)
|
|
842
969
|
} : null;
|
|
843
970
|
}
|
|
844
|
-
function
|
|
971
|
+
function Dt(e) {
|
|
845
972
|
return typeof e.message == "string" && e.message.trim().length > 0 ? e.message.replace(/Product Agent/g, "Pluno") : e.type === "run_status" && e.status === "interrupted" ? "Pluno was interrupted before it could finish this message." : e.type === "run_status" && e.status === "stopped" ? "Pluno stopped." : "Pluno run status changed.";
|
|
846
973
|
}
|
|
847
|
-
function
|
|
974
|
+
function Ot(e) {
|
|
848
975
|
if (e.type === "web_search_call") {
|
|
849
976
|
const t = e.action;
|
|
850
977
|
if (t && typeof t == "object") {
|
|
@@ -856,9 +983,9 @@ function Pt(e) {
|
|
|
856
983
|
}
|
|
857
984
|
return "Searching the web";
|
|
858
985
|
}
|
|
859
|
-
return
|
|
986
|
+
return Ht(e);
|
|
860
987
|
}
|
|
861
|
-
function
|
|
988
|
+
function Ht(e) {
|
|
862
989
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
863
990
|
return e.summary;
|
|
864
991
|
if (typeof e.arguments == "string")
|
|
@@ -871,11 +998,11 @@ function Nt(e) {
|
|
|
871
998
|
}
|
|
872
999
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
873
1000
|
}
|
|
874
|
-
function
|
|
1001
|
+
function Wt(e) {
|
|
875
1002
|
const t = e.callId ?? e.call_id;
|
|
876
1003
|
return typeof t == "string" && t ? t : null;
|
|
877
1004
|
}
|
|
878
|
-
function
|
|
1005
|
+
function xt(e) {
|
|
879
1006
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
880
1007
|
if (!t || typeof t != "object")
|
|
881
1008
|
return "";
|
|
@@ -883,14 +1010,14 @@ function Ut(e) {
|
|
|
883
1010
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
884
1011
|
}).filter(Boolean).join("") : "";
|
|
885
1012
|
}
|
|
886
|
-
function
|
|
887
|
-
const s =
|
|
1013
|
+
function Lt(e, t) {
|
|
1014
|
+
const s = vt(e, t), n = s.findIndex((i) => i.id === t.id);
|
|
888
1015
|
if (n === -1)
|
|
889
|
-
return
|
|
1016
|
+
return R([...s, t]);
|
|
890
1017
|
const r = [...s];
|
|
891
|
-
return r[n] = t,
|
|
1018
|
+
return r[n] = t, R(r);
|
|
892
1019
|
}
|
|
893
|
-
function
|
|
1020
|
+
function vt(e, t) {
|
|
894
1021
|
if (t.role !== "user")
|
|
895
1022
|
return e;
|
|
896
1023
|
const s = e.findIndex(
|
|
@@ -901,15 +1028,15 @@ function qt(e, t) {
|
|
|
901
1028
|
const n = [...e];
|
|
902
1029
|
return n.splice(s, 1), n;
|
|
903
1030
|
}
|
|
904
|
-
function
|
|
905
|
-
const t =
|
|
906
|
-
return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 :
|
|
1031
|
+
function Bt(e) {
|
|
1032
|
+
const t = C(e);
|
|
1033
|
+
return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : A(s.data));
|
|
907
1034
|
}
|
|
908
|
-
function
|
|
909
|
-
const t =
|
|
910
|
-
return t === null ? e.some((s) => !s || typeof s != "object" ? !1 :
|
|
1035
|
+
function jt(e) {
|
|
1036
|
+
const t = C(e);
|
|
1037
|
+
return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : x(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : x(s.data));
|
|
911
1038
|
}
|
|
912
|
-
function
|
|
1039
|
+
function C(e) {
|
|
913
1040
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
914
1041
|
const s = e[t];
|
|
915
1042
|
if (!s || typeof s != "object")
|
|
@@ -923,8 +1050,8 @@ function R(e) {
|
|
|
923
1050
|
}
|
|
924
1051
|
return null;
|
|
925
1052
|
}
|
|
926
|
-
function
|
|
927
|
-
const t =
|
|
1053
|
+
function Ft(e) {
|
|
1054
|
+
const t = C(e);
|
|
928
1055
|
if (t === null)
|
|
929
1056
|
return null;
|
|
930
1057
|
const s = e[t];
|
|
@@ -936,31 +1063,31 @@ function Ht(e) {
|
|
|
936
1063
|
const r = n.clientMessageId;
|
|
937
1064
|
return typeof r == "string" ? r : null;
|
|
938
1065
|
}
|
|
939
|
-
function
|
|
1066
|
+
function x(e) {
|
|
940
1067
|
if (!e || typeof e != "object")
|
|
941
1068
|
return !1;
|
|
942
1069
|
const t = e;
|
|
943
1070
|
return t.type === "message" && t.role === "assistant";
|
|
944
1071
|
}
|
|
945
|
-
function
|
|
1072
|
+
function A(e) {
|
|
946
1073
|
if (!e || typeof e != "object")
|
|
947
1074
|
return !1;
|
|
948
1075
|
const t = e;
|
|
949
1076
|
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");
|
|
950
1077
|
}
|
|
951
|
-
function
|
|
1078
|
+
function $t(e) {
|
|
952
1079
|
if (!e || typeof e != "object")
|
|
953
1080
|
return !1;
|
|
954
1081
|
const t = e;
|
|
955
1082
|
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";
|
|
956
1083
|
}
|
|
957
|
-
function
|
|
958
|
-
return e.filter((t, s) =>
|
|
1084
|
+
function R(e) {
|
|
1085
|
+
return e.filter((t, s) => Gt(t) ? !zt(e, s) : !0);
|
|
959
1086
|
}
|
|
960
|
-
function
|
|
1087
|
+
function Gt(e) {
|
|
961
1088
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
962
1089
|
}
|
|
963
|
-
function
|
|
1090
|
+
function zt(e, t) {
|
|
964
1091
|
for (let s = t + 1; s < e.length; s += 1) {
|
|
965
1092
|
const n = e[s];
|
|
966
1093
|
if (n.role === "user")
|
|
@@ -970,18 +1097,18 @@ function Lt(e, t) {
|
|
|
970
1097
|
}
|
|
971
1098
|
return !1;
|
|
972
1099
|
}
|
|
973
|
-
function
|
|
1100
|
+
function p(e, t) {
|
|
974
1101
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
975
1102
|
}
|
|
976
|
-
function
|
|
1103
|
+
function Xt(e, t) {
|
|
977
1104
|
try {
|
|
978
|
-
const s = window.localStorage.getItem(`${
|
|
1105
|
+
const s = window.localStorage.getItem(`${B}${e}`);
|
|
979
1106
|
if (!s)
|
|
980
1107
|
return null;
|
|
981
1108
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
982
1109
|
if (t !== void 0 && r !== t)
|
|
983
1110
|
return null;
|
|
984
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
1111
|
+
const i = Array.isArray(n.messages) ? n.messages.map(Vt).filter((o) => !!o) : [];
|
|
985
1112
|
return {
|
|
986
1113
|
sessionId: r,
|
|
987
1114
|
messages: i
|
|
@@ -990,33 +1117,33 @@ function jt(e, t) {
|
|
|
990
1117
|
return null;
|
|
991
1118
|
}
|
|
992
1119
|
}
|
|
993
|
-
function
|
|
1120
|
+
function Jt(e, t) {
|
|
994
1121
|
try {
|
|
995
1122
|
window.localStorage.setItem(
|
|
996
|
-
`${
|
|
1123
|
+
`${B}${e}`,
|
|
997
1124
|
JSON.stringify({
|
|
998
1125
|
sessionId: t.sessionId,
|
|
999
|
-
messages: t.messages.slice(-
|
|
1126
|
+
messages: t.messages.slice(-dt)
|
|
1000
1127
|
})
|
|
1001
1128
|
);
|
|
1002
1129
|
} catch {
|
|
1003
1130
|
return;
|
|
1004
1131
|
}
|
|
1005
1132
|
}
|
|
1006
|
-
function
|
|
1133
|
+
function Kt(e) {
|
|
1007
1134
|
try {
|
|
1008
1135
|
const t = window.localStorage.getItem(`${E}${e}`);
|
|
1009
1136
|
if (!t)
|
|
1010
1137
|
return [];
|
|
1011
1138
|
const s = JSON.parse(t);
|
|
1012
|
-
return Array.isArray(s) ? s.filter(
|
|
1139
|
+
return Array.isArray(s) ? s.filter(G) : [];
|
|
1013
1140
|
} catch {
|
|
1014
1141
|
return [];
|
|
1015
1142
|
}
|
|
1016
1143
|
}
|
|
1017
|
-
function
|
|
1144
|
+
function k(e, t) {
|
|
1018
1145
|
try {
|
|
1019
|
-
const s = t.filter(
|
|
1146
|
+
const s = t.filter(G);
|
|
1020
1147
|
if (s.length === 0) {
|
|
1021
1148
|
window.localStorage.removeItem(`${E}${e}`);
|
|
1022
1149
|
return;
|
|
@@ -1029,33 +1156,33 @@ function T(e, t) {
|
|
|
1029
1156
|
return;
|
|
1030
1157
|
}
|
|
1031
1158
|
}
|
|
1032
|
-
function
|
|
1159
|
+
function G(e) {
|
|
1033
1160
|
if (!e || typeof e != "object")
|
|
1034
1161
|
return !1;
|
|
1035
1162
|
const t = e;
|
|
1036
|
-
return t.type === "chat.user_message" ? typeof t.content == "string" &&
|
|
1163
|
+
return t.type === "chat.user_message" ? typeof t.content == "string" && L(t.page) : t.type === "page.upsert" || t.type === "session.reset" || t.type === "network.batch" ? L(t.page) : t.type === "tool.result" ? typeof t.sessionId == "string" && typeof t.callId == "string" && t.toolName === "execute_code" : t.type === "chat.retry_last_user_message" ? typeof t.sessionId == "string" && typeof t.clientMessageId == "string" : t.type === "run.stop" ? typeof t.sessionId == "string" : !1;
|
|
1037
1164
|
}
|
|
1038
|
-
function
|
|
1165
|
+
function L(e) {
|
|
1039
1166
|
if (!e || typeof e != "object")
|
|
1040
1167
|
return !1;
|
|
1041
1168
|
const t = e;
|
|
1042
1169
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
1043
1170
|
}
|
|
1044
|
-
function
|
|
1171
|
+
function z(e) {
|
|
1045
1172
|
if (!Array.isArray(e))
|
|
1046
1173
|
return;
|
|
1047
1174
|
const t = e.filter((s) => {
|
|
1048
1175
|
if (!s || typeof s != "object")
|
|
1049
1176
|
return !1;
|
|
1050
1177
|
const n = s;
|
|
1051
|
-
return typeof n.name == "string" &&
|
|
1178
|
+
return typeof n.name == "string" && Zt(n.mimeType) && typeof n.sizeBytes == "number" && typeof n.dataUrl == "string";
|
|
1052
1179
|
});
|
|
1053
1180
|
return t.length > 0 ? t : void 0;
|
|
1054
1181
|
}
|
|
1055
|
-
function
|
|
1182
|
+
function Zt(e) {
|
|
1056
1183
|
return e === "image/png" || e === "image/jpeg" || e === "image/webp" || e === "image/gif" || e === "application/pdf";
|
|
1057
1184
|
}
|
|
1058
|
-
function
|
|
1185
|
+
function Vt(e) {
|
|
1059
1186
|
if (!e || typeof e != "object")
|
|
1060
1187
|
return null;
|
|
1061
1188
|
const t = e;
|
|
@@ -1065,63 +1192,63 @@ function zt(e) {
|
|
|
1065
1192
|
content: t.content,
|
|
1066
1193
|
createdAt: t.createdAt,
|
|
1067
1194
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
1068
|
-
attachments:
|
|
1195
|
+
attachments: z(t.attachments),
|
|
1069
1196
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
1070
1197
|
};
|
|
1071
1198
|
}
|
|
1072
|
-
function
|
|
1199
|
+
function Yt(e) {
|
|
1073
1200
|
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
|
|
1074
1201
|
}
|
|
1075
|
-
function
|
|
1202
|
+
function v(e) {
|
|
1076
1203
|
const t = {};
|
|
1077
1204
|
return e?.forEach((s, n) => {
|
|
1078
1205
|
t[n] = s;
|
|
1079
1206
|
}), t;
|
|
1080
1207
|
}
|
|
1081
|
-
async function
|
|
1208
|
+
async function Qt(e, t) {
|
|
1082
1209
|
if (typeof t?.body < "u")
|
|
1083
|
-
return
|
|
1210
|
+
return X(t.body);
|
|
1084
1211
|
if (e)
|
|
1085
1212
|
try {
|
|
1086
|
-
return
|
|
1213
|
+
return g(await e.clone().text());
|
|
1087
1214
|
} catch {
|
|
1088
1215
|
return;
|
|
1089
1216
|
}
|
|
1090
1217
|
}
|
|
1091
|
-
async function
|
|
1218
|
+
async function te(e) {
|
|
1092
1219
|
try {
|
|
1093
|
-
return
|
|
1220
|
+
return g(await e.clone().text());
|
|
1094
1221
|
} catch (t) {
|
|
1095
1222
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1096
1223
|
}
|
|
1097
1224
|
}
|
|
1098
|
-
function
|
|
1225
|
+
function ee(e) {
|
|
1099
1226
|
try {
|
|
1100
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
1227
|
+
return e.responseType === "" || e.responseType === "text" ? g(e.responseText ?? "") : e.responseType === "json" ? g(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
|
|
1101
1228
|
} catch (t) {
|
|
1102
1229
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1103
1230
|
}
|
|
1104
1231
|
}
|
|
1105
|
-
function
|
|
1232
|
+
function X(e) {
|
|
1106
1233
|
if (!(e === null || typeof e > "u")) {
|
|
1107
1234
|
if (typeof e == "string")
|
|
1108
|
-
return
|
|
1235
|
+
return g(e);
|
|
1109
1236
|
if (e instanceof URLSearchParams)
|
|
1110
|
-
return
|
|
1237
|
+
return g(e.toString());
|
|
1111
1238
|
if (e instanceof FormData) {
|
|
1112
1239
|
const t = [];
|
|
1113
|
-
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])),
|
|
1240
|
+
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])), g(JSON.stringify(t));
|
|
1114
1241
|
}
|
|
1115
1242
|
if (e instanceof Blob)
|
|
1116
1243
|
return `[blob:${e.type || "application/octet-stream"}:${e.size}]`;
|
|
1117
1244
|
try {
|
|
1118
|
-
return
|
|
1245
|
+
return g(JSON.stringify(e));
|
|
1119
1246
|
} catch {
|
|
1120
1247
|
return `[unserializable body: ${Object.prototype.toString.call(e)}]`;
|
|
1121
1248
|
}
|
|
1122
1249
|
}
|
|
1123
1250
|
}
|
|
1124
|
-
function
|
|
1251
|
+
function se(e) {
|
|
1125
1252
|
const t = {};
|
|
1126
1253
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
1127
1254
|
const n = s.indexOf(":");
|
|
@@ -1129,65 +1256,65 @@ function Yt(e) {
|
|
|
1129
1256
|
}
|
|
1130
1257
|
return t;
|
|
1131
1258
|
}
|
|
1132
|
-
function
|
|
1133
|
-
return e.length <=
|
|
1259
|
+
function g(e) {
|
|
1260
|
+
return e.length <= I ? e : `${e.slice(0, I)}... [truncated ${e.length - I} chars]`;
|
|
1134
1261
|
}
|
|
1135
|
-
function
|
|
1262
|
+
function w(e) {
|
|
1136
1263
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1137
1264
|
}
|
|
1138
|
-
const
|
|
1265
|
+
const P = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", ne = "[REDACTED_SIGNED_URL]", re = 20, ie = /^(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, J = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, K = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Z = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, V = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, oe = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, ae = /\bhttps?:\/\/[^\s"'<>]+/gi, ce = /[),.;\]]+$/;
|
|
1139
1266
|
function m(e) {
|
|
1140
|
-
return
|
|
1267
|
+
return S(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1141
1268
|
}
|
|
1142
|
-
function
|
|
1269
|
+
function S(e, t, s) {
|
|
1143
1270
|
if (typeof e == "string")
|
|
1144
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
1271
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : de(e);
|
|
1145
1272
|
if (e === null || typeof e != "object")
|
|
1146
1273
|
return e;
|
|
1147
|
-
if (t >=
|
|
1274
|
+
if (t >= re)
|
|
1148
1275
|
return "[REDACTED_MAX_DEPTH]";
|
|
1149
1276
|
if (s.has(e))
|
|
1150
1277
|
return "[REDACTED_CIRCULAR]";
|
|
1151
1278
|
if (s.add(e), Array.isArray(e))
|
|
1152
|
-
return e.map((r) =>
|
|
1279
|
+
return e.map((r) => S(r, t + 1, s));
|
|
1153
1280
|
const n = {};
|
|
1154
1281
|
for (const [r, i] of Object.entries(e))
|
|
1155
|
-
|
|
1282
|
+
le(r) ? n[r] = P : n[r] = r.toLowerCase() === "url" ? ue(i) : S(i, t + 1, s);
|
|
1156
1283
|
return n;
|
|
1157
1284
|
}
|
|
1158
|
-
function
|
|
1285
|
+
function le(e) {
|
|
1159
1286
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
1160
1287
|
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");
|
|
1161
1288
|
}
|
|
1162
|
-
function
|
|
1163
|
-
return typeof e == "string" ?
|
|
1289
|
+
function ue(e) {
|
|
1290
|
+
return typeof e == "string" ? Y(e) : S(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1164
1291
|
}
|
|
1165
|
-
function
|
|
1292
|
+
function Y(e) {
|
|
1166
1293
|
try {
|
|
1167
1294
|
const t = new URL(e, location.href);
|
|
1168
1295
|
for (const s of Array.from(t.searchParams.keys()))
|
|
1169
|
-
|
|
1296
|
+
ie.test(s) && t.searchParams.set(s, h);
|
|
1170
1297
|
return t.username && (t.username = h), t.password && (t.password = h), t.toString();
|
|
1171
1298
|
} catch {
|
|
1172
|
-
return
|
|
1299
|
+
return he(e);
|
|
1173
1300
|
}
|
|
1174
1301
|
}
|
|
1175
|
-
function
|
|
1176
|
-
return e.replace(
|
|
1302
|
+
function de(e) {
|
|
1303
|
+
return e.replace(oe, ne).replace(ae, pe).replace(J, `Bearer ${h}`).replace(K, `Basic ${h}`).replace(Z, h).replace(V, (t, s) => `${s}: ${P}`);
|
|
1177
1304
|
}
|
|
1178
|
-
function
|
|
1179
|
-
return e.replace(
|
|
1305
|
+
function he(e) {
|
|
1306
|
+
return e.replace(J, `Bearer ${h}`).replace(K, `Basic ${h}`).replace(Z, h).replace(V, (t, s) => `${s}: ${P}`);
|
|
1180
1307
|
}
|
|
1181
|
-
function
|
|
1182
|
-
const t = e.match(
|
|
1183
|
-
return `${
|
|
1308
|
+
function pe(e) {
|
|
1309
|
+
const t = e.match(ce)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
1310
|
+
return `${Y(s)}${t}`;
|
|
1184
1311
|
}
|
|
1185
1312
|
export {
|
|
1186
1313
|
N as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1314
|
+
_ as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
1315
|
+
tt as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
1316
|
+
Q as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
1317
|
+
et as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
1318
|
+
j as PlunoProductAgent,
|
|
1319
|
+
j as default
|
|
1193
1320
|
};
|