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