@pluno/product-agent-web 0.1.31 → 0.1.34
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/product-agent-sdk.js +238 -171
- package/dist/product-agent-widget.js +781 -680
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const I = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', V = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Y = ".pluno-pa-widget__panel", Z = ".pluno-pa-widget__timeline", N = `${I}[data-pluno-sdk-preview-channel]`, Q = "https://app.pluno.ai", tt = "gpt-5.4", et = 2e4, st = 2e3,
|
|
2
|
-
class
|
|
1
|
+
const I = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', V = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Y = ".pluno-pa-widget__panel", Z = ".pluno-pa-widget__timeline", N = `${I}[data-pluno-sdk-preview-channel]`, Q = "https://app.pluno.ai", tt = "gpt-5.4", et = 2e4, st = 2e3, f = 6e4, nt = 15e3, D = 2, rt = 15e3, it = 5e3, ot = 1e3, _ = 1e5, at = 100, x = "pluno.productAgent.state.", E = "pluno.productAgent.pendingEvents.", U = "pluno.productAgent.transportId";
|
|
2
|
+
class B {
|
|
3
3
|
constructor(t) {
|
|
4
|
-
this.options = t, this.transportId =
|
|
4
|
+
this.options = t, this.transportId = At(), this.state = {
|
|
5
5
|
...this.state,
|
|
6
|
-
starterPrompts:
|
|
6
|
+
starterPrompts: kt(t.initialStarterPrompts)
|
|
7
7
|
};
|
|
8
|
-
const s = t.restorePersistedState === !1 ? null :
|
|
8
|
+
const s = t.restorePersistedState === !1 ? null : jt(t.clientId, t.expectedPersistedSessionId);
|
|
9
9
|
s && (this.state = {
|
|
10
10
|
...this.state,
|
|
11
11
|
...s,
|
|
@@ -14,7 +14,7 @@ class L {
|
|
|
14
14
|
assistantDraft: "",
|
|
15
15
|
isThinking: !1,
|
|
16
16
|
lastError: null
|
|
17
|
-
}), this.queuedClientEvents =
|
|
17
|
+
}), this.queuedClientEvents = $t(t.clientId);
|
|
18
18
|
}
|
|
19
19
|
options;
|
|
20
20
|
listeners = {};
|
|
@@ -52,10 +52,10 @@ class L {
|
|
|
52
52
|
lastErrorCode: null
|
|
53
53
|
};
|
|
54
54
|
static async init(t) {
|
|
55
|
-
const s = new
|
|
55
|
+
const s = new B({
|
|
56
56
|
...t,
|
|
57
|
-
backendUrl:
|
|
58
|
-
clientId: t.clientId ??
|
|
57
|
+
backendUrl: gt(t.backendUrl ?? Q),
|
|
58
|
+
clientId: t.clientId ?? St(),
|
|
59
59
|
model: t.model ?? tt
|
|
60
60
|
});
|
|
61
61
|
try {
|
|
@@ -82,7 +82,7 @@ class L {
|
|
|
82
82
|
return;
|
|
83
83
|
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
84
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
85
|
-
const t =
|
|
85
|
+
const t = ft(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
86
86
|
this.socket = s, s.addEventListener("open", () => {
|
|
87
87
|
this.socket === s && (u("web-sdk.agent", "Pluno socket opened", {
|
|
88
88
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
@@ -94,7 +94,7 @@ class L {
|
|
|
94
94
|
transportId: this.transportId
|
|
95
95
|
}), this.flushQueuedClientEvents(), this.startHeartbeat(), this.setState({ status: "connected", lastError: null }));
|
|
96
96
|
}), s.addEventListener("message", (n) => {
|
|
97
|
-
this.socket === s && this.handleServerEvent(
|
|
97
|
+
this.socket === s && this.handleServerEvent(mt(n.data));
|
|
98
98
|
}), s.addEventListener("close", (n) => {
|
|
99
99
|
this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (u("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
100
100
|
code: typeof n?.code == "number" ? n.code : null,
|
|
@@ -122,7 +122,7 @@ class L {
|
|
|
122
122
|
const n = t.trim(), r = s.attachments ?? [];
|
|
123
123
|
if (!n && r.length === 0)
|
|
124
124
|
return;
|
|
125
|
-
const i =
|
|
125
|
+
const i = y(), a = Rt(), c = {
|
|
126
126
|
id: `local-${a}`,
|
|
127
127
|
role: "user",
|
|
128
128
|
content: n,
|
|
@@ -130,12 +130,12 @@ class L {
|
|
|
130
130
|
...r.length > 0 ? { attachments: r } : {}
|
|
131
131
|
};
|
|
132
132
|
this.setState({
|
|
133
|
-
messages: [...this.state.messages,
|
|
133
|
+
messages: [...this.state.messages, c],
|
|
134
134
|
assistantDraft: "",
|
|
135
135
|
isThinking: !0,
|
|
136
136
|
lastError: null
|
|
137
|
-
}), this.emit("message",
|
|
138
|
-
const
|
|
137
|
+
}), this.emit("message", c);
|
|
138
|
+
const o = {
|
|
139
139
|
type: "chat.user_message",
|
|
140
140
|
sessionId: this.state.sessionId ?? void 0,
|
|
141
141
|
clientMessageId: a,
|
|
@@ -145,7 +145,7 @@ class L {
|
|
|
145
145
|
model: this.options.model,
|
|
146
146
|
metadata: ct(this.options.metadata)
|
|
147
147
|
};
|
|
148
|
-
this.activeClientMessageId = a, this.activeUserMessageEvent =
|
|
148
|
+
this.activeClientMessageId = a, this.activeUserMessageEvent = o, this.markThinkingProgress(), this.send(o);
|
|
149
149
|
}
|
|
150
150
|
stop() {
|
|
151
151
|
this.state.sessionId && (this.send({ type: "run.stop", sessionId: this.state.sessionId }), this.setState({ isThinking: !1 }), this.clearThinkingWatchdog());
|
|
@@ -154,7 +154,7 @@ class L {
|
|
|
154
154
|
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
155
|
type: "session.reset",
|
|
156
156
|
sessionId: this.state.sessionId ?? void 0,
|
|
157
|
-
page:
|
|
157
|
+
page: y()
|
|
158
158
|
}), this.setState({
|
|
159
159
|
sessionId: null,
|
|
160
160
|
starterPrompts: [...this.state.starterPrompts],
|
|
@@ -165,7 +165,7 @@ class L {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
send(t) {
|
|
168
|
-
this.sendNow(
|
|
168
|
+
this.sendNow(m(t)) || (this.queuedClientEvents.push(t), T(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect());
|
|
169
169
|
}
|
|
170
170
|
sendNow(t) {
|
|
171
171
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
@@ -188,7 +188,7 @@ class L {
|
|
|
188
188
|
T(this.options.clientId, this.queuedClientEvents);
|
|
189
189
|
for (let s = 0; s < t.length; s += 1) {
|
|
190
190
|
const n = t[s];
|
|
191
|
-
if (!this.sendNow(
|
|
191
|
+
if (!this.sendNow(m(n))) {
|
|
192
192
|
this.queuedClientEvents.unshift(n, ...t.slice(s + 1)), T(this.options.clientId, this.queuedClientEvents);
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
@@ -201,44 +201,44 @@ class L {
|
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
if (lt(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
204
|
-
const s =
|
|
204
|
+
const s = wt(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
205
205
|
u("web-sdk.agent", "Received auth.ok appearance", {
|
|
206
206
|
hasAppearance: n,
|
|
207
207
|
rawAppearance: t.appearance,
|
|
208
208
|
normalizedAppearance: s
|
|
209
|
-
}), this.runtimeHelperJavascript =
|
|
210
|
-
const r =
|
|
211
|
-
user:
|
|
209
|
+
}), this.runtimeHelperJavascript = _t(t.runtimeHelpers)?.javascript ?? null;
|
|
210
|
+
const r = Tt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), a = {
|
|
211
|
+
user: Ct(t.user),
|
|
212
212
|
status: "connected"
|
|
213
213
|
};
|
|
214
214
|
(i || this.state.starterPrompts.length === 0) && (a.starterPrompts = r), (n || s) && (a.appearance = s), this.setState(a), this.state.sessionId && this.send({
|
|
215
215
|
type: "page.upsert",
|
|
216
216
|
sessionId: this.state.sessionId,
|
|
217
|
-
page:
|
|
217
|
+
page: y(),
|
|
218
218
|
model: this.options.model
|
|
219
219
|
});
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
if (t.type === "conversation.state") {
|
|
223
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
224
|
-
this.latestRecoverableClientMessageId = r,
|
|
225
|
-
sessionId:
|
|
226
|
-
messages:
|
|
223
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Wt(s), r = n ? null : Ht(s);
|
|
224
|
+
this.latestRecoverableClientMessageId = r, vt(s) && this.clearRetryTimers(), this.setState({
|
|
225
|
+
sessionId: W(t.session, "id") ?? this.state.sessionId,
|
|
226
|
+
messages: bt(s),
|
|
227
227
|
...n ? { assistantDraft: "", isThinking: !1 } : r ? { assistantDraft: "", isThinking: !0, lastError: null } : {}
|
|
228
228
|
}), n ? this.clearThinkingWatchdog() : r && (this.activeClientMessageId = r, this.markThinkingProgress());
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
if (t.type === "session.updated") {
|
|
232
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
232
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: W(t.session, "id") ?? this.state.sessionId });
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
if (t.type === "session.item") {
|
|
236
|
-
const s =
|
|
236
|
+
const s = L(t.item);
|
|
237
237
|
if (s) {
|
|
238
238
|
s.role === "assistant" && (this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
239
239
|
const n = t.item.data;
|
|
240
|
-
|
|
241
|
-
messages:
|
|
240
|
+
xt(n) && this.clearRunAckResyncRetryTimer(), this.setState({
|
|
241
|
+
messages: Ot(this.state.messages, s),
|
|
242
242
|
assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
|
|
243
243
|
...S(n) ? { assistantDraft: "", isThinking: !1 } : {}
|
|
244
244
|
}), S(n) && this.clearThinkingWatchdog(), this.emit("message", s);
|
|
@@ -295,7 +295,7 @@ class L {
|
|
|
295
295
|
this.retryTimersByClientMessageId = {};
|
|
296
296
|
}
|
|
297
297
|
markThinkingProgress() {
|
|
298
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
298
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(f), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
299
299
|
}
|
|
300
300
|
scheduleThinkingWatchdog(t) {
|
|
301
301
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -333,7 +333,7 @@ class L {
|
|
|
333
333
|
type: "chat.retry_last_user_message",
|
|
334
334
|
sessionId: this.state.sessionId,
|
|
335
335
|
clientMessageId: t
|
|
336
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
336
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(f)));
|
|
337
337
|
}, it);
|
|
338
338
|
}
|
|
339
339
|
clearRunAckResyncRetryTimer() {
|
|
@@ -349,7 +349,7 @@ class L {
|
|
|
349
349
|
if (!t) {
|
|
350
350
|
u("web-sdk.agent", "Pluno thinking watchdog resyncing without active message id", {
|
|
351
351
|
sessionId: this.state.sessionId
|
|
352
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
352
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(f);
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
355
|
const s = this.thinkingWatchdogResyncAttemptsByClientMessageId[t] ?? 0, n = this.thinkingWatchdogRetryAttemptsByClientMessageId[t] ?? 0;
|
|
@@ -366,7 +366,7 @@ class L {
|
|
|
366
366
|
sessionId: this.state.sessionId,
|
|
367
367
|
clientMessageId: t,
|
|
368
368
|
retryAttempts: n
|
|
369
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
369
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(f);
|
|
370
370
|
return;
|
|
371
371
|
}
|
|
372
372
|
this.thinkingWatchdogRetryAttemptsByClientMessageId[t] = n + 1, this.setState({
|
|
@@ -381,96 +381,102 @@ class L {
|
|
|
381
381
|
type: "chat.retry_last_user_message",
|
|
382
382
|
sessionId: this.state.sessionId,
|
|
383
383
|
clientMessageId: t
|
|
384
|
-
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(
|
|
384
|
+
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(f);
|
|
385
385
|
}
|
|
386
386
|
resyncThinkingSession() {
|
|
387
387
|
this.state.sessionId ? this.send({
|
|
388
388
|
type: "page.upsert",
|
|
389
389
|
sessionId: this.state.sessionId,
|
|
390
|
-
page:
|
|
390
|
+
page: y(),
|
|
391
391
|
model: this.options.model
|
|
392
392
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect());
|
|
393
393
|
}
|
|
394
394
|
async executeToolCall(t) {
|
|
395
395
|
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = t.rawInput;
|
|
396
|
-
if (!s || !n || !
|
|
396
|
+
if (!s || !n || !Xt(r))
|
|
397
397
|
return;
|
|
398
|
-
const i =
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
398
|
+
const i = dt(this.state.messages), a = ht(i);
|
|
399
|
+
let c = null, o;
|
|
400
|
+
try {
|
|
401
|
+
c = await this.executeRuntimeHelper(), o = await O(r).catch((l) => ({
|
|
402
|
+
ok: !1,
|
|
403
|
+
exception: {
|
|
404
|
+
message: l instanceof Error ? l.message : String(l)
|
|
405
|
+
}
|
|
406
|
+
}));
|
|
407
|
+
} finally {
|
|
408
|
+
a();
|
|
409
|
+
}
|
|
404
410
|
this.send({
|
|
405
411
|
type: "tool.result",
|
|
406
412
|
sessionId: s,
|
|
407
413
|
callId: n,
|
|
408
414
|
toolName: "execute_code",
|
|
409
415
|
summary: r.summary,
|
|
410
|
-
rawInput:
|
|
411
|
-
rawOutput:
|
|
416
|
+
rawInput: m(r),
|
|
417
|
+
rawOutput: m(It(o, c))
|
|
412
418
|
});
|
|
413
419
|
}
|
|
414
420
|
async executeRuntimeHelper() {
|
|
415
421
|
if (!this.runtimeHelperJavascript?.trim())
|
|
416
422
|
return null;
|
|
417
|
-
const t = await
|
|
423
|
+
const t = await O({
|
|
418
424
|
javascript: this.runtimeHelperJavascript
|
|
419
425
|
});
|
|
420
|
-
return t.ok === !1 ?
|
|
426
|
+
return t.ok === !1 ? Et(t) : null;
|
|
421
427
|
}
|
|
422
428
|
enableNetworkCapture() {
|
|
423
429
|
if (this.networkCaptureCleanup)
|
|
424
430
|
return;
|
|
425
431
|
const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
|
|
426
432
|
window.fetch = async (i, a) => {
|
|
427
|
-
const
|
|
433
|
+
const c = Date.now(), o = new Date(c).toISOString(), l = i instanceof Request ? i : null, g = typeof i == "string" ? i : i instanceof URL ? i.toString() : l?.url ?? "", b = (a?.method ?? l?.method ?? "GET").toUpperCase(), M = H(new Headers(a?.headers ?? l?.headers ?? void 0)), P = await Jt(l, a);
|
|
428
434
|
try {
|
|
429
435
|
const d = await t(i, a);
|
|
430
436
|
return this.enqueueNetworkEvent({
|
|
431
437
|
requestId: k("fetch"),
|
|
432
|
-
url:
|
|
438
|
+
url: g,
|
|
433
439
|
method: b,
|
|
434
440
|
requestHeaders: M,
|
|
435
441
|
requestBody: P,
|
|
436
442
|
resourceType: "fetch",
|
|
437
443
|
responseStatus: d.status,
|
|
438
444
|
responseHeaders: H(d.headers),
|
|
439
|
-
responseBody: await
|
|
440
|
-
startedAt:
|
|
441
|
-
durationMs: Date.now() -
|
|
445
|
+
responseBody: await Kt(d),
|
|
446
|
+
startedAt: o,
|
|
447
|
+
durationMs: Date.now() - c
|
|
442
448
|
}), d;
|
|
443
449
|
} catch (d) {
|
|
444
450
|
throw this.enqueueNetworkEvent({
|
|
445
451
|
requestId: k("fetch"),
|
|
446
|
-
url:
|
|
452
|
+
url: g,
|
|
447
453
|
method: b,
|
|
448
454
|
requestHeaders: M,
|
|
449
455
|
requestBody: P,
|
|
450
456
|
resourceType: "fetch",
|
|
451
457
|
errorText: d instanceof Error ? d.message : String(d),
|
|
452
|
-
startedAt:
|
|
453
|
-
durationMs: Date.now() -
|
|
458
|
+
startedAt: o,
|
|
459
|
+
durationMs: Date.now() - c
|
|
454
460
|
}), d;
|
|
455
461
|
}
|
|
456
|
-
}, XMLHttpRequest.prototype.open = function(a,
|
|
462
|
+
}, XMLHttpRequest.prototype.open = function(a, c, o, l, g) {
|
|
457
463
|
return this.__plunoMeta = {
|
|
458
464
|
requestId: k("xhr"),
|
|
459
465
|
method: String(a ?? "GET").toUpperCase(),
|
|
460
|
-
url: typeof
|
|
466
|
+
url: typeof c == "string" ? c : c.toString(),
|
|
461
467
|
requestHeaders: {},
|
|
462
468
|
startedAtMs: Date.now(),
|
|
463
469
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
464
|
-
}, s.call(this, a,
|
|
465
|
-
}, XMLHttpRequest.prototype.setRequestHeader = function(a,
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
const l =
|
|
469
|
-
l[a] =
|
|
470
|
+
}, s.call(this, a, c, o ?? !0, l ?? void 0, g ?? void 0);
|
|
471
|
+
}, XMLHttpRequest.prototype.setRequestHeader = function(a, c) {
|
|
472
|
+
const o = this.__plunoMeta;
|
|
473
|
+
if (o) {
|
|
474
|
+
const l = o.requestHeaders ?? {};
|
|
475
|
+
l[a] = c, o.requestHeaders = l;
|
|
470
476
|
}
|
|
471
|
-
return n.call(this, a,
|
|
477
|
+
return n.call(this, a, c);
|
|
472
478
|
}, XMLHttpRequest.prototype.send = function(a) {
|
|
473
|
-
const
|
|
479
|
+
const c = window.__plunoProductAgentInstance, o = this.__plunoMeta ?? {
|
|
474
480
|
requestId: k("xhr"),
|
|
475
481
|
method: "GET",
|
|
476
482
|
url: "",
|
|
@@ -478,10 +484,10 @@ class L {
|
|
|
478
484
|
startedAtMs: Date.now(),
|
|
479
485
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
480
486
|
};
|
|
481
|
-
return
|
|
487
|
+
return o.requestBody = $(a), this.__plunoMeta = o, this.addEventListener(
|
|
482
488
|
"loadend",
|
|
483
489
|
function() {
|
|
484
|
-
!
|
|
490
|
+
!c || !this.__plunoMeta || c.enqueueNetworkEvent({
|
|
485
491
|
requestId: String(this.__plunoMeta.requestId),
|
|
486
492
|
url: String(this.__plunoMeta.url ?? ""),
|
|
487
493
|
method: String(this.__plunoMeta.method ?? "GET"),
|
|
@@ -489,8 +495,8 @@ class L {
|
|
|
489
495
|
requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
|
|
490
496
|
resourceType: "xhr",
|
|
491
497
|
responseStatus: this.status,
|
|
492
|
-
responseHeaders:
|
|
493
|
-
responseBody:
|
|
498
|
+
responseHeaders: Yt(this.getAllResponseHeaders()),
|
|
499
|
+
responseBody: Vt(this),
|
|
494
500
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
495
501
|
startedAt: String(this.__plunoMeta.startedAt),
|
|
496
502
|
durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
|
|
@@ -503,13 +509,13 @@ class L {
|
|
|
503
509
|
};
|
|
504
510
|
}
|
|
505
511
|
enqueueNetworkEvent(t) {
|
|
506
|
-
this.queuedNetworkEvents.push(
|
|
512
|
+
this.queuedNetworkEvents.push(m(t)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
507
513
|
this.networkBatchTimer = null;
|
|
508
514
|
const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
509
515
|
s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
510
516
|
type: "network.batch",
|
|
511
517
|
sessionId: this.state.sessionId ?? void 0,
|
|
512
|
-
page:
|
|
518
|
+
page: y(),
|
|
513
519
|
events: s
|
|
514
520
|
});
|
|
515
521
|
}, ot));
|
|
@@ -538,7 +544,7 @@ class L {
|
|
|
538
544
|
...this.state,
|
|
539
545
|
...t,
|
|
540
546
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
541
|
-
},
|
|
547
|
+
}, Ft(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
542
548
|
}
|
|
543
549
|
emit(t, s) {
|
|
544
550
|
this.listeners[t]?.forEach((r) => r(s));
|
|
@@ -563,15 +569,76 @@ function lt(e) {
|
|
|
563
569
|
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";
|
|
564
570
|
}
|
|
565
571
|
const ut = 5e3;
|
|
566
|
-
|
|
572
|
+
function dt(e) {
|
|
573
|
+
const t = [];
|
|
574
|
+
for (const s of e)
|
|
575
|
+
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
576
|
+
t.push({
|
|
577
|
+
id: `${s.id}:attachment:${r}`,
|
|
578
|
+
...n
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
return t;
|
|
582
|
+
}
|
|
583
|
+
function ht(e) {
|
|
584
|
+
const t = new Map(e.map((o) => [o.id, o])), s = (o) => ({
|
|
585
|
+
id: o.id,
|
|
586
|
+
name: o.name,
|
|
587
|
+
mimeType: o.mimeType,
|
|
588
|
+
sizeBytes: o.sizeBytes
|
|
589
|
+
}), n = (o) => {
|
|
590
|
+
const l = t.get(o);
|
|
591
|
+
if (!l)
|
|
592
|
+
throw new Error(`Unknown Pluno user file: ${o}`);
|
|
593
|
+
return l;
|
|
594
|
+
}, r = async (o) => {
|
|
595
|
+
const l = n(o);
|
|
596
|
+
return pt(l.dataUrl, l.mimeType);
|
|
597
|
+
}, i = globalThis, a = i.pluno?.userFiles, c = Object.prototype.hasOwnProperty.call(i.pluno ?? {}, "userFiles");
|
|
598
|
+
return i.pluno = {
|
|
599
|
+
...i.pluno ?? {},
|
|
600
|
+
userFiles: {
|
|
601
|
+
list: () => e.map(s),
|
|
602
|
+
get: (o) => {
|
|
603
|
+
const l = t.get(o);
|
|
604
|
+
return l ? s(l) : null;
|
|
605
|
+
},
|
|
606
|
+
getDataUrl: async (o) => n(o).dataUrl,
|
|
607
|
+
getBlob: r,
|
|
608
|
+
getArrayBuffer: async (o) => await (await r(o)).arrayBuffer(),
|
|
609
|
+
getFile: async (o) => {
|
|
610
|
+
const l = n(o);
|
|
611
|
+
return new File([await r(o)], l.name, { type: l.mimeType });
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}, () => {
|
|
615
|
+
const o = i.pluno ?? {};
|
|
616
|
+
if (c) {
|
|
617
|
+
i.pluno = {
|
|
618
|
+
...o,
|
|
619
|
+
userFiles: a
|
|
620
|
+
};
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
const { userFiles: l, ...g } = o;
|
|
624
|
+
i.pluno = g;
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function pt(e, t) {
|
|
628
|
+
const s = e.indexOf(","), n = s >= 0 ? e.slice(s + 1) : e, r = atob(n), i = new Uint8Array(r.length);
|
|
629
|
+
for (let a = 0; a < r.length; a += 1)
|
|
630
|
+
i[a] = r.charCodeAt(a);
|
|
631
|
+
return new Blob([i], { type: t });
|
|
632
|
+
}
|
|
633
|
+
async function O(e) {
|
|
567
634
|
const t = Object.getPrototypeOf(async function() {
|
|
568
635
|
}).constructor, s = ut, n = Date.now(), r = [], i = {
|
|
569
636
|
log: console.log,
|
|
570
637
|
info: console.info,
|
|
571
638
|
warn: console.warn,
|
|
572
639
|
error: console.error
|
|
573
|
-
}, a = (
|
|
574
|
-
r.push({ level:
|
|
640
|
+
}, a = (c) => (...o) => {
|
|
641
|
+
r.push({ level: c, args: o }), i[c](...o);
|
|
575
642
|
};
|
|
576
643
|
console.log = a("log"), console.info = a("info"), console.warn = a("warn"), console.error = a("error");
|
|
577
644
|
try {
|
|
@@ -580,7 +647,7 @@ async function U(e) {
|
|
|
580
647
|
result: await Promise.race([
|
|
581
648
|
new t(e.javascript)(),
|
|
582
649
|
new Promise(
|
|
583
|
-
(
|
|
650
|
+
(o, l) => window.setTimeout(() => l(new Error(`execute_code timed out after ${s}ms`)), s)
|
|
584
651
|
)
|
|
585
652
|
]),
|
|
586
653
|
console: r,
|
|
@@ -590,14 +657,14 @@ async function U(e) {
|
|
|
590
657
|
origin: location.origin
|
|
591
658
|
}
|
|
592
659
|
};
|
|
593
|
-
} catch (
|
|
660
|
+
} catch (c) {
|
|
594
661
|
return {
|
|
595
662
|
ok: !1,
|
|
596
663
|
console: r,
|
|
597
664
|
exception: {
|
|
598
|
-
name:
|
|
599
|
-
message:
|
|
600
|
-
stack:
|
|
665
|
+
name: c instanceof Error ? c.name : "Error",
|
|
666
|
+
message: c instanceof Error ? c.message : String(c),
|
|
667
|
+
stack: c instanceof Error ? c.stack : void 0
|
|
601
668
|
},
|
|
602
669
|
metadata: {
|
|
603
670
|
durationMs: Date.now() - n,
|
|
@@ -609,15 +676,15 @@ async function U(e) {
|
|
|
609
676
|
console.log = i.log, console.info = i.info, console.warn = i.warn, console.error = i.error;
|
|
610
677
|
}
|
|
611
678
|
}
|
|
612
|
-
function
|
|
679
|
+
function gt(e) {
|
|
613
680
|
return e.replace(/\/+$/, "");
|
|
614
681
|
}
|
|
615
|
-
function
|
|
682
|
+
function ft(e) {
|
|
616
683
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
617
684
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
618
685
|
}
|
|
619
|
-
function
|
|
620
|
-
const e =
|
|
686
|
+
function y() {
|
|
687
|
+
const e = yt();
|
|
621
688
|
return {
|
|
622
689
|
url: location.href,
|
|
623
690
|
title: document.title,
|
|
@@ -625,7 +692,7 @@ function f() {
|
|
|
625
692
|
...e ? { plunoProductAgentUi: e } : {}
|
|
626
693
|
};
|
|
627
694
|
}
|
|
628
|
-
function
|
|
695
|
+
function yt() {
|
|
629
696
|
const e = document.querySelector(N);
|
|
630
697
|
if (!(e ?? document.querySelector(I)))
|
|
631
698
|
return;
|
|
@@ -657,7 +724,7 @@ function gt() {
|
|
|
657
724
|
]
|
|
658
725
|
};
|
|
659
726
|
}
|
|
660
|
-
function
|
|
727
|
+
function mt(e) {
|
|
661
728
|
try {
|
|
662
729
|
const t = JSON.parse(e);
|
|
663
730
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -665,33 +732,33 @@ function pt(e) {
|
|
|
665
732
|
return { type: "error", message: "Invalid server event" };
|
|
666
733
|
}
|
|
667
734
|
}
|
|
668
|
-
function
|
|
735
|
+
function Tt(e, t) {
|
|
669
736
|
if (!e || typeof e != "object")
|
|
670
737
|
return [];
|
|
671
738
|
const s = e[t];
|
|
672
739
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
673
740
|
}
|
|
674
|
-
function
|
|
741
|
+
function kt(e) {
|
|
675
742
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
676
743
|
}
|
|
677
|
-
function
|
|
744
|
+
function wt(e) {
|
|
678
745
|
if (!e || typeof e != "object")
|
|
679
746
|
return null;
|
|
680
|
-
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, a = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null,
|
|
681
|
-
return !r && !i && !a &&
|
|
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, a = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, c = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
748
|
+
return !r && !i && !a && c === null ? null : {
|
|
682
749
|
...r ? { accentColor: r } : {},
|
|
683
750
|
...i ? { colorScheme: i } : {},
|
|
684
751
|
...a ? { fontFamily: a } : {},
|
|
685
|
-
...
|
|
752
|
+
...c !== null ? { scribbleStyle: c } : {}
|
|
686
753
|
};
|
|
687
754
|
}
|
|
688
|
-
function
|
|
755
|
+
function _t(e) {
|
|
689
756
|
if (!e || typeof e != "object")
|
|
690
757
|
return null;
|
|
691
758
|
const t = e.javascript;
|
|
692
759
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
693
760
|
}
|
|
694
|
-
function
|
|
761
|
+
function It(e, t) {
|
|
695
762
|
return t ? e && typeof e == "object" ? {
|
|
696
763
|
...e,
|
|
697
764
|
helperError: t
|
|
@@ -701,30 +768,30 @@ function kt(e, t) {
|
|
|
701
768
|
helperError: t
|
|
702
769
|
} : e;
|
|
703
770
|
}
|
|
704
|
-
function
|
|
771
|
+
function Et(e) {
|
|
705
772
|
if (!e || typeof e != "object")
|
|
706
773
|
return e;
|
|
707
774
|
const t = e;
|
|
708
775
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
709
776
|
}
|
|
710
|
-
function
|
|
777
|
+
function St() {
|
|
711
778
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
712
779
|
if (t)
|
|
713
780
|
return t;
|
|
714
781
|
const s = crypto.randomUUID();
|
|
715
782
|
return window.localStorage.setItem(e, s), s;
|
|
716
783
|
}
|
|
717
|
-
function
|
|
718
|
-
const e = window.sessionStorage.getItem(
|
|
784
|
+
function At() {
|
|
785
|
+
const e = window.sessionStorage.getItem(U);
|
|
719
786
|
if (e)
|
|
720
787
|
return e;
|
|
721
788
|
const t = crypto.randomUUID();
|
|
722
|
-
return window.sessionStorage.setItem(
|
|
789
|
+
return window.sessionStorage.setItem(U, t), t;
|
|
723
790
|
}
|
|
724
|
-
function
|
|
791
|
+
function Rt() {
|
|
725
792
|
return crypto.randomUUID();
|
|
726
793
|
}
|
|
727
|
-
function
|
|
794
|
+
function Ct(e) {
|
|
728
795
|
if (!e || typeof e != "object")
|
|
729
796
|
return null;
|
|
730
797
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -735,12 +802,12 @@ function St(e) {
|
|
|
735
802
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
736
803
|
} : null;
|
|
737
804
|
}
|
|
738
|
-
function
|
|
805
|
+
function bt(e) {
|
|
739
806
|
return Array.isArray(e) ? A(
|
|
740
|
-
e.map(
|
|
807
|
+
e.map(L).filter((t) => t !== null)
|
|
741
808
|
) : [];
|
|
742
809
|
}
|
|
743
|
-
function
|
|
810
|
+
function L(e) {
|
|
744
811
|
if (!e || typeof e != "object")
|
|
745
812
|
return null;
|
|
746
813
|
const t = e, s = t.data;
|
|
@@ -752,32 +819,32 @@ function B(e) {
|
|
|
752
819
|
return {
|
|
753
820
|
id: String(t.id ?? crypto.randomUUID()),
|
|
754
821
|
role: r,
|
|
755
|
-
content:
|
|
822
|
+
content: Ut(n.content),
|
|
756
823
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
757
|
-
attachments:
|
|
824
|
+
attachments: F(n.attachments)
|
|
758
825
|
};
|
|
759
826
|
}
|
|
760
827
|
return n.type === "function_call" || n.type === "tool_call" || n.type === "web_search_call" ? {
|
|
761
828
|
id: String(t.id ?? crypto.randomUUID()),
|
|
762
829
|
role: "tool",
|
|
763
|
-
content:
|
|
830
|
+
content: Pt(n),
|
|
764
831
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
765
832
|
dataType: String(n.type),
|
|
766
833
|
toolName: typeof n.name == "string" ? n.name : void 0,
|
|
767
|
-
callId:
|
|
834
|
+
callId: Dt(n) ?? void 0,
|
|
768
835
|
loading: n.localExecutionStatus === "running"
|
|
769
836
|
} : 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 : {
|
|
770
837
|
id: String(t.id ?? crypto.randomUUID()),
|
|
771
838
|
role: "system",
|
|
772
|
-
content:
|
|
839
|
+
content: Mt(n),
|
|
773
840
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
774
841
|
dataType: String(n.type)
|
|
775
842
|
} : null;
|
|
776
843
|
}
|
|
777
|
-
function
|
|
844
|
+
function Mt(e) {
|
|
778
845
|
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.";
|
|
779
846
|
}
|
|
780
|
-
function
|
|
847
|
+
function Pt(e) {
|
|
781
848
|
if (e.type === "web_search_call") {
|
|
782
849
|
const t = e.action;
|
|
783
850
|
if (t && typeof t == "object") {
|
|
@@ -789,9 +856,9 @@ function Ct(e) {
|
|
|
789
856
|
}
|
|
790
857
|
return "Searching the web";
|
|
791
858
|
}
|
|
792
|
-
return
|
|
859
|
+
return Nt(e);
|
|
793
860
|
}
|
|
794
|
-
function
|
|
861
|
+
function Nt(e) {
|
|
795
862
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
796
863
|
return e.summary;
|
|
797
864
|
if (typeof e.arguments == "string")
|
|
@@ -804,11 +871,11 @@ function bt(e) {
|
|
|
804
871
|
}
|
|
805
872
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
806
873
|
}
|
|
807
|
-
function
|
|
874
|
+
function Dt(e) {
|
|
808
875
|
const t = e.callId ?? e.call_id;
|
|
809
876
|
return typeof t == "string" && t ? t : null;
|
|
810
877
|
}
|
|
811
|
-
function
|
|
878
|
+
function Ut(e) {
|
|
812
879
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
813
880
|
if (!t || typeof t != "object")
|
|
814
881
|
return "";
|
|
@@ -816,14 +883,14 @@ function Pt(e) {
|
|
|
816
883
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
817
884
|
}).filter(Boolean).join("") : "";
|
|
818
885
|
}
|
|
819
|
-
function
|
|
820
|
-
const s =
|
|
886
|
+
function Ot(e, t) {
|
|
887
|
+
const s = qt(e, t), n = s.findIndex((i) => i.id === t.id);
|
|
821
888
|
if (n === -1)
|
|
822
889
|
return A([...s, t]);
|
|
823
890
|
const r = [...s];
|
|
824
891
|
return r[n] = t, A(r);
|
|
825
892
|
}
|
|
826
|
-
function
|
|
893
|
+
function qt(e, t) {
|
|
827
894
|
if (t.role !== "user")
|
|
828
895
|
return e;
|
|
829
896
|
const s = e.findIndex(
|
|
@@ -834,13 +901,13 @@ function Dt(e, t) {
|
|
|
834
901
|
const n = [...e];
|
|
835
902
|
return n.splice(s, 1), n;
|
|
836
903
|
}
|
|
837
|
-
function
|
|
904
|
+
function Wt(e) {
|
|
838
905
|
const t = R(e);
|
|
839
906
|
return t === null ? !1 : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : S(s.data));
|
|
840
907
|
}
|
|
841
|
-
function
|
|
908
|
+
function vt(e) {
|
|
842
909
|
const t = R(e);
|
|
843
|
-
return t === null ? e.some((s) => !s || typeof s != "object" ? !1 :
|
|
910
|
+
return t === null ? e.some((s) => !s || typeof s != "object" ? !1 : q(s.data)) : e.slice(t + 1).some((s) => !s || typeof s != "object" ? !1 : q(s.data));
|
|
844
911
|
}
|
|
845
912
|
function R(e) {
|
|
846
913
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
@@ -856,7 +923,7 @@ function R(e) {
|
|
|
856
923
|
}
|
|
857
924
|
return null;
|
|
858
925
|
}
|
|
859
|
-
function
|
|
926
|
+
function Ht(e) {
|
|
860
927
|
const t = R(e);
|
|
861
928
|
if (t === null)
|
|
862
929
|
return null;
|
|
@@ -869,7 +936,7 @@ function Wt(e) {
|
|
|
869
936
|
const r = n.clientMessageId;
|
|
870
937
|
return typeof r == "string" ? r : null;
|
|
871
938
|
}
|
|
872
|
-
function
|
|
939
|
+
function q(e) {
|
|
873
940
|
if (!e || typeof e != "object")
|
|
874
941
|
return !1;
|
|
875
942
|
const t = e;
|
|
@@ -881,19 +948,19 @@ function S(e) {
|
|
|
881
948
|
const t = e;
|
|
882
949
|
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");
|
|
883
950
|
}
|
|
884
|
-
function
|
|
951
|
+
function xt(e) {
|
|
885
952
|
if (!e || typeof e != "object")
|
|
886
953
|
return !1;
|
|
887
954
|
const t = e;
|
|
888
955
|
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";
|
|
889
956
|
}
|
|
890
957
|
function A(e) {
|
|
891
|
-
return e.filter((t, s) =>
|
|
958
|
+
return e.filter((t, s) => Bt(t) ? !Lt(e, s) : !0);
|
|
892
959
|
}
|
|
893
|
-
function
|
|
960
|
+
function Bt(e) {
|
|
894
961
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
895
962
|
}
|
|
896
|
-
function
|
|
963
|
+
function Lt(e, t) {
|
|
897
964
|
for (let s = t + 1; s < e.length; s += 1) {
|
|
898
965
|
const n = e[s];
|
|
899
966
|
if (n.role === "user")
|
|
@@ -903,10 +970,10 @@ function Ht(e, t) {
|
|
|
903
970
|
}
|
|
904
971
|
return !1;
|
|
905
972
|
}
|
|
906
|
-
function
|
|
973
|
+
function W(e, t) {
|
|
907
974
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
908
975
|
}
|
|
909
|
-
function
|
|
976
|
+
function jt(e, t) {
|
|
910
977
|
try {
|
|
911
978
|
const s = window.localStorage.getItem(`${x}${e}`);
|
|
912
979
|
if (!s)
|
|
@@ -914,7 +981,7 @@ function xt(e, t) {
|
|
|
914
981
|
const n = JSON.parse(s), r = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
915
982
|
if (t !== void 0 && r !== t)
|
|
916
983
|
return null;
|
|
917
|
-
const i = Array.isArray(n.messages) ? n.messages.map(
|
|
984
|
+
const i = Array.isArray(n.messages) ? n.messages.map(zt).filter((a) => !!a) : [];
|
|
918
985
|
return {
|
|
919
986
|
sessionId: r,
|
|
920
987
|
messages: i
|
|
@@ -923,7 +990,7 @@ function xt(e, t) {
|
|
|
923
990
|
return null;
|
|
924
991
|
}
|
|
925
992
|
}
|
|
926
|
-
function
|
|
993
|
+
function Ft(e, t) {
|
|
927
994
|
try {
|
|
928
995
|
window.localStorage.setItem(
|
|
929
996
|
`${x}${e}`,
|
|
@@ -936,7 +1003,7 @@ function Lt(e, t) {
|
|
|
936
1003
|
return;
|
|
937
1004
|
}
|
|
938
1005
|
}
|
|
939
|
-
function
|
|
1006
|
+
function $t(e) {
|
|
940
1007
|
try {
|
|
941
1008
|
const t = window.localStorage.getItem(`${E}${e}`);
|
|
942
1009
|
if (!t)
|
|
@@ -974,21 +1041,21 @@ function v(e) {
|
|
|
974
1041
|
const t = e;
|
|
975
1042
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
976
1043
|
}
|
|
977
|
-
function
|
|
1044
|
+
function F(e) {
|
|
978
1045
|
if (!Array.isArray(e))
|
|
979
1046
|
return;
|
|
980
1047
|
const t = e.filter((s) => {
|
|
981
1048
|
if (!s || typeof s != "object")
|
|
982
1049
|
return !1;
|
|
983
1050
|
const n = s;
|
|
984
|
-
return typeof n.name == "string" &&
|
|
1051
|
+
return typeof n.name == "string" && Gt(n.mimeType) && typeof n.sizeBytes == "number" && typeof n.dataUrl == "string";
|
|
985
1052
|
});
|
|
986
1053
|
return t.length > 0 ? t : void 0;
|
|
987
1054
|
}
|
|
988
|
-
function
|
|
1055
|
+
function Gt(e) {
|
|
989
1056
|
return e === "image/png" || e === "image/jpeg" || e === "image/webp" || e === "image/gif" || e === "application/pdf";
|
|
990
1057
|
}
|
|
991
|
-
function
|
|
1058
|
+
function zt(e) {
|
|
992
1059
|
if (!e || typeof e != "object")
|
|
993
1060
|
return null;
|
|
994
1061
|
const t = e;
|
|
@@ -998,11 +1065,11 @@ function $t(e) {
|
|
|
998
1065
|
content: t.content,
|
|
999
1066
|
createdAt: t.createdAt,
|
|
1000
1067
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
1001
|
-
attachments:
|
|
1068
|
+
attachments: F(t.attachments),
|
|
1002
1069
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
1003
1070
|
};
|
|
1004
1071
|
}
|
|
1005
|
-
function
|
|
1072
|
+
function Xt(e) {
|
|
1006
1073
|
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
|
|
1007
1074
|
}
|
|
1008
1075
|
function H(e) {
|
|
@@ -1011,50 +1078,50 @@ function H(e) {
|
|
|
1011
1078
|
t[n] = s;
|
|
1012
1079
|
}), t;
|
|
1013
1080
|
}
|
|
1014
|
-
async function
|
|
1081
|
+
async function Jt(e, t) {
|
|
1015
1082
|
if (typeof t?.body < "u")
|
|
1016
|
-
return
|
|
1083
|
+
return $(t.body);
|
|
1017
1084
|
if (e)
|
|
1018
1085
|
try {
|
|
1019
|
-
return
|
|
1086
|
+
return p(await e.clone().text());
|
|
1020
1087
|
} catch {
|
|
1021
1088
|
return;
|
|
1022
1089
|
}
|
|
1023
1090
|
}
|
|
1024
|
-
async function
|
|
1091
|
+
async function Kt(e) {
|
|
1025
1092
|
try {
|
|
1026
|
-
return
|
|
1093
|
+
return p(await e.clone().text());
|
|
1027
1094
|
} catch (t) {
|
|
1028
1095
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1029
1096
|
}
|
|
1030
1097
|
}
|
|
1031
|
-
function
|
|
1098
|
+
function Vt(e) {
|
|
1032
1099
|
try {
|
|
1033
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
1100
|
+
return e.responseType === "" || e.responseType === "text" ? p(e.responseText ?? "") : e.responseType === "json" ? p(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
|
|
1034
1101
|
} catch (t) {
|
|
1035
1102
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1036
1103
|
}
|
|
1037
1104
|
}
|
|
1038
|
-
function
|
|
1105
|
+
function $(e) {
|
|
1039
1106
|
if (!(e === null || typeof e > "u")) {
|
|
1040
1107
|
if (typeof e == "string")
|
|
1041
|
-
return
|
|
1108
|
+
return p(e);
|
|
1042
1109
|
if (e instanceof URLSearchParams)
|
|
1043
|
-
return
|
|
1110
|
+
return p(e.toString());
|
|
1044
1111
|
if (e instanceof FormData) {
|
|
1045
1112
|
const t = [];
|
|
1046
|
-
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])),
|
|
1113
|
+
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])), p(JSON.stringify(t));
|
|
1047
1114
|
}
|
|
1048
1115
|
if (e instanceof Blob)
|
|
1049
1116
|
return `[blob:${e.type || "application/octet-stream"}:${e.size}]`;
|
|
1050
1117
|
try {
|
|
1051
|
-
return
|
|
1118
|
+
return p(JSON.stringify(e));
|
|
1052
1119
|
} catch {
|
|
1053
1120
|
return `[unserializable body: ${Object.prototype.toString.call(e)}]`;
|
|
1054
1121
|
}
|
|
1055
1122
|
}
|
|
1056
1123
|
}
|
|
1057
|
-
function
|
|
1124
|
+
function Yt(e) {
|
|
1058
1125
|
const t = {};
|
|
1059
1126
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
1060
1127
|
const n = s.indexOf(":");
|
|
@@ -1062,22 +1129,22 @@ function Jt(e) {
|
|
|
1062
1129
|
}
|
|
1063
1130
|
return t;
|
|
1064
1131
|
}
|
|
1065
|
-
function
|
|
1132
|
+
function p(e) {
|
|
1066
1133
|
return e.length <= _ ? e : `${e.slice(0, _)}... [truncated ${e.length - _} chars]`;
|
|
1067
1134
|
}
|
|
1068
1135
|
function k(e) {
|
|
1069
1136
|
return `${e}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1070
1137
|
}
|
|
1071
|
-
const C = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]",
|
|
1072
|
-
function
|
|
1138
|
+
const C = "[REDACTED_SECRET]", h = "[REDACTED_TOKEN]", Zt = "[REDACTED_SIGNED_URL]", Qt = 20, te = /^(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, G = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, z = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, X = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, J = /\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, ee = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, se = /\bhttps?:\/\/[^\s"'<>]+/gi, ne = /[),.;\]]+$/;
|
|
1139
|
+
function m(e) {
|
|
1073
1140
|
return w(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1074
1141
|
}
|
|
1075
1142
|
function w(e, t, s) {
|
|
1076
1143
|
if (typeof e == "string")
|
|
1077
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
1144
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : oe(e);
|
|
1078
1145
|
if (e === null || typeof e != "object")
|
|
1079
1146
|
return e;
|
|
1080
|
-
if (t >=
|
|
1147
|
+
if (t >= Qt)
|
|
1081
1148
|
return "[REDACTED_MAX_DEPTH]";
|
|
1082
1149
|
if (s.has(e))
|
|
1083
1150
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -1085,34 +1152,34 @@ function w(e, t, s) {
|
|
|
1085
1152
|
return e.map((r) => w(r, t + 1, s));
|
|
1086
1153
|
const n = {};
|
|
1087
1154
|
for (const [r, i] of Object.entries(e))
|
|
1088
|
-
|
|
1155
|
+
re(r) ? n[r] = C : n[r] = r.toLowerCase() === "url" ? ie(i) : w(i, t + 1, s);
|
|
1089
1156
|
return n;
|
|
1090
1157
|
}
|
|
1091
|
-
function
|
|
1158
|
+
function re(e) {
|
|
1092
1159
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
1093
1160
|
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");
|
|
1094
1161
|
}
|
|
1095
|
-
function
|
|
1162
|
+
function ie(e) {
|
|
1096
1163
|
return typeof e == "string" ? K(e) : w(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1097
1164
|
}
|
|
1098
1165
|
function K(e) {
|
|
1099
1166
|
try {
|
|
1100
1167
|
const t = new URL(e, location.href);
|
|
1101
1168
|
for (const s of Array.from(t.searchParams.keys()))
|
|
1102
|
-
|
|
1169
|
+
te.test(s) && t.searchParams.set(s, h);
|
|
1103
1170
|
return t.username && (t.username = h), t.password && (t.password = h), t.toString();
|
|
1104
1171
|
} catch {
|
|
1105
|
-
return
|
|
1172
|
+
return ae(e);
|
|
1106
1173
|
}
|
|
1107
1174
|
}
|
|
1108
|
-
function
|
|
1109
|
-
return e.replace(
|
|
1175
|
+
function oe(e) {
|
|
1176
|
+
return e.replace(ee, Zt).replace(se, ce).replace(G, `Bearer ${h}`).replace(z, `Basic ${h}`).replace(X, h).replace(J, (t, s) => `${s}: ${C}`);
|
|
1110
1177
|
}
|
|
1111
|
-
function
|
|
1112
|
-
return e.replace(
|
|
1178
|
+
function ae(e) {
|
|
1179
|
+
return e.replace(G, `Bearer ${h}`).replace(z, `Basic ${h}`).replace(X, h).replace(J, (t, s) => `${s}: ${C}`);
|
|
1113
1180
|
}
|
|
1114
|
-
function
|
|
1115
|
-
const t = e.match(
|
|
1181
|
+
function ce(e) {
|
|
1182
|
+
const t = e.match(ne)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
1116
1183
|
return `${K(s)}${t}`;
|
|
1117
1184
|
}
|
|
1118
1185
|
export {
|
|
@@ -1121,6 +1188,6 @@ export {
|
|
|
1121
1188
|
Y as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
1122
1189
|
V as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
1123
1190
|
Z as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
1124
|
-
|
|
1125
|
-
|
|
1191
|
+
B as PlunoProductAgent,
|
|
1192
|
+
B as default
|
|
1126
1193
|
};
|