@pluno/product-agent-web 0.1.58 → 0.1.60
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 +202 -189
- package/dist/product-agent-widget.js +1114 -977
- package/dist/widget.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _t = "pluno-product-agent-attachments";
|
|
2
2
|
const H = "files";
|
|
3
3
|
async function it(e) {
|
|
4
4
|
const t = await U();
|
|
5
5
|
await at(t, "readwrite", (s) => s.put(e));
|
|
6
6
|
}
|
|
7
|
-
async function
|
|
7
|
+
async function Pt(e) {
|
|
8
8
|
const t = await U(), s = await at(
|
|
9
9
|
t,
|
|
10
10
|
"readonly",
|
|
@@ -27,7 +27,7 @@ async function ot(e, t) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
30
|
+
async function Mt(e = 864e5) {
|
|
31
31
|
const t = await U(), s = Date.now() - e;
|
|
32
32
|
await v(t, "readwrite", async (n) => {
|
|
33
33
|
const r = n.index("lastUsedAt");
|
|
@@ -36,7 +36,7 @@ async function _t(e = 864e5) {
|
|
|
36
36
|
}
|
|
37
37
|
function U() {
|
|
38
38
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((e, t) => {
|
|
39
|
-
const s = indexedDB.open(
|
|
39
|
+
const s = indexedDB.open(_t, 1);
|
|
40
40
|
s.onupgradeneeded = () => {
|
|
41
41
|
const r = s.result.createObjectStore(H, { keyPath: "attachmentId" });
|
|
42
42
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
@@ -73,14 +73,14 @@ function j(e) {
|
|
|
73
73
|
e.onsuccess = () => t(e.result), e.onerror = () => s(e.error ?? new Error("Product Agent attachment storage request failed"));
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
const B = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]',
|
|
76
|
+
const B = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', bt = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Ut = ".pluno-pa-widget__panel", Ct = ".pluno-pa-widget__timeline", X = `${B}[data-pluno-sdk-preview-channel]`, Dt = "https://app.pluno.ai", Nt = "gpt-5.4", qt = 2e4, Ot = 2e3, E = 6e4, Ft = 15e3, K = 2, Ht = 15e3, Bt = 5e3, Lt = 1e3, Wt = 8e3, xt = 15e3, J = 3, vt = [300, 1e3], q = 1e5, jt = 200 * 1024 * 1024, $t = "Image is too large for model vision input.", zt = 100, ct = "pluno.productAgent.state.", L = "pluno.productAgent.pendingEvents.", V = "pluno.productAgent.transportId";
|
|
77
77
|
class ut {
|
|
78
78
|
constructor(t) {
|
|
79
|
-
this.options = t, this.transportId =
|
|
79
|
+
this.options = t, this.transportId = de(), this.state = {
|
|
80
80
|
...this.state,
|
|
81
|
-
starterPrompts:
|
|
81
|
+
starterPrompts: ie(t.initialStarterPrompts)
|
|
82
82
|
};
|
|
83
|
-
const s = t.restorePersistedState === !1 ? null :
|
|
83
|
+
const s = t.restorePersistedState === !1 ? null : qe(t.clientId, t.expectedPersistedSessionId);
|
|
84
84
|
s && (this.state = {
|
|
85
85
|
...this.state,
|
|
86
86
|
...s,
|
|
@@ -91,7 +91,7 @@ class ut {
|
|
|
91
91
|
assistantDraftRunId: null,
|
|
92
92
|
isThinking: !1,
|
|
93
93
|
lastError: null
|
|
94
|
-
}), this.queuedClientEvents =
|
|
94
|
+
}), this.queuedClientEvents = Fe(t.clientId);
|
|
95
95
|
}
|
|
96
96
|
options;
|
|
97
97
|
listeners = {};
|
|
@@ -140,12 +140,12 @@ class ut {
|
|
|
140
140
|
static async init(t) {
|
|
141
141
|
const s = new ut({
|
|
142
142
|
...t,
|
|
143
|
-
backendUrl:
|
|
144
|
-
clientId: t.clientId ??
|
|
145
|
-
model: t.model ??
|
|
143
|
+
backendUrl: Qt(t.backendUrl ?? Dt),
|
|
144
|
+
clientId: t.clientId ?? le(),
|
|
145
|
+
model: t.model ?? Nt
|
|
146
146
|
});
|
|
147
147
|
try {
|
|
148
|
-
|
|
148
|
+
Mt().catch((n) => {
|
|
149
149
|
g("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
150
150
|
message: n instanceof Error ? n.message : String(n)
|
|
151
151
|
});
|
|
@@ -172,7 +172,7 @@ class ut {
|
|
|
172
172
|
return;
|
|
173
173
|
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)
|
|
174
174
|
throw new Error("Pluno requires a token or tokenProvider");
|
|
175
|
-
const t =
|
|
175
|
+
const t = te(this.options.backendUrl), s = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
176
176
|
this.socket = s, s.addEventListener("open", () => {
|
|
177
177
|
this.socket === s && (g("web-sdk.agent", "Pluno socket opened", {
|
|
178
178
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
@@ -184,7 +184,7 @@ class ut {
|
|
|
184
184
|
transportId: this.transportId
|
|
185
185
|
}), this.flushQueuedClientEvents(), this.startHeartbeat(), this.setState({ status: "connected", lastError: null }));
|
|
186
186
|
}), s.addEventListener("message", (n) => {
|
|
187
|
-
this.socket === s && this.handleServerEvent(
|
|
187
|
+
this.socket === s && this.handleServerEvent(re(n.data));
|
|
188
188
|
}), s.addEventListener("close", (n) => {
|
|
189
189
|
this.socket === s && (this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (g("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
190
190
|
code: typeof n?.code == "number" ? n.code : null,
|
|
@@ -330,7 +330,7 @@ class ut {
|
|
|
330
330
|
throw new M("Failed to upload attachment", u.status);
|
|
331
331
|
return u;
|
|
332
332
|
}, "Failed to upload attachment"), this.setState({ sessionId: d.sessionId });
|
|
333
|
-
const h =
|
|
333
|
+
const h = wt(d.attachment, this.options.backendUrl);
|
|
334
334
|
return this.updateAttachmentInState(s.id, h), s.id && ot(s.id, {
|
|
335
335
|
sessionId: d.sessionId,
|
|
336
336
|
fileUrl: h.fileUrl,
|
|
@@ -353,7 +353,7 @@ class ut {
|
|
|
353
353
|
return this.state.sessionId ? Promise.resolve(this.state.sessionId) : new Promise((t, s) => {
|
|
354
354
|
const n = window.setTimeout(() => {
|
|
355
355
|
r(), s(new Error("Timed out waiting for Pluno session before persisting attachment"));
|
|
356
|
-
},
|
|
356
|
+
}, xt), r = this.on("state", (i) => {
|
|
357
357
|
i.sessionId && (window.clearTimeout(n), r(), t(i.sessionId));
|
|
358
358
|
});
|
|
359
359
|
});
|
|
@@ -375,7 +375,7 @@ class ut {
|
|
|
375
375
|
const n = await this.fetchEmbedAttachmentUpload(t);
|
|
376
376
|
if (n.ok)
|
|
377
377
|
return await n.json();
|
|
378
|
-
if (
|
|
378
|
+
if (Ve(n.status) && this.options.tokenProvider && !s) {
|
|
379
379
|
s = !0;
|
|
380
380
|
const r = await this.fetchEmbedAttachmentUpload(t);
|
|
381
381
|
if (r.ok)
|
|
@@ -419,7 +419,7 @@ class ut {
|
|
|
419
419
|
const s = R(), n = new Promise((i, o) => {
|
|
420
420
|
const c = window.setTimeout(() => {
|
|
421
421
|
this.pendingSessionHistoryRequests.delete(s), o(new Error("Session history did not respond in time"));
|
|
422
|
-
},
|
|
422
|
+
}, Wt);
|
|
423
423
|
this.pendingSessionHistoryRequests.set(s, { resolve: i, reject: o, timeout: c });
|
|
424
424
|
}), r = {
|
|
425
425
|
type: "sessions.list",
|
|
@@ -476,7 +476,7 @@ class ut {
|
|
|
476
476
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
477
477
|
return;
|
|
478
478
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
479
|
-
const t =
|
|
479
|
+
const t = ee();
|
|
480
480
|
this.sendNow(
|
|
481
481
|
w({
|
|
482
482
|
type: "starter_prompts.page_context",
|
|
@@ -505,18 +505,18 @@ class ut {
|
|
|
505
505
|
this.handleRunAck(t);
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
508
|
-
if (
|
|
509
|
-
const s =
|
|
508
|
+
if (Gt(t) && this.markThinkingProgress(), t.type === "auth.ok") {
|
|
509
|
+
const s = oe(t), n = Object.prototype.hasOwnProperty.call(t, "appearance");
|
|
510
510
|
g("web-sdk.agent", "Received auth.ok appearance", {
|
|
511
511
|
hasAppearance: n,
|
|
512
512
|
rawAppearance: t.appearance,
|
|
513
513
|
normalizedAppearance: s
|
|
514
|
-
}), this.runtimeHelperJavascript =
|
|
514
|
+
}), this.runtimeHelperJavascript = ae(t.runtimeHelpers)?.javascript ?? null;
|
|
515
515
|
const r = tt(t, "starterPrompts"), i = Object.prototype.hasOwnProperty.call(t, "starterPrompts"), o = t.starterPromptsLoading === !0, c = {
|
|
516
|
-
user:
|
|
516
|
+
user: he(t.user),
|
|
517
517
|
status: "connected"
|
|
518
518
|
};
|
|
519
|
-
(i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !
|
|
519
|
+
(i || this.state.starterPrompts.length === 0) && (c.starterPrompts = r, c.starterPromptsLoading = r.length > 0 ? !1 : o), i && r.length > 0 && (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0), (n || s) && (c.appearance = s), this.setState(c), i && r.length === 0 && !o && !se() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
520
520
|
type: "page.upsert",
|
|
521
521
|
sessionId: this.state.sessionId,
|
|
522
522
|
page: y(),
|
|
@@ -532,12 +532,15 @@ class ut {
|
|
|
532
532
|
return;
|
|
533
533
|
}
|
|
534
534
|
if (t.type === "conversation.state") {
|
|
535
|
-
const s = Array.isArray(t.items) ? t.items : [], n =
|
|
535
|
+
const s = Array.isArray(t.items) ? t.items : [], n = Ae(
|
|
536
536
|
this.state.messages,
|
|
537
|
-
|
|
538
|
-
), r = et(n)
|
|
539
|
-
|
|
540
|
-
|
|
537
|
+
pe(s, this.options.backendUrl)
|
|
538
|
+
), r = et(n);
|
|
539
|
+
if (!r && _e(this.state.messages, s))
|
|
540
|
+
return;
|
|
541
|
+
const i = r ? null : Pe(s);
|
|
542
|
+
this.latestRecoverableClientMessageId = i, Re(n) && this.clearRetryTimers(), this.setState({
|
|
543
|
+
sessionId: I(t.session, "id") ?? this.state.sessionId,
|
|
541
544
|
messages: n,
|
|
542
545
|
...r ? { assistantDraft: "", assistantDraftRespondsToUserMessageId: null, assistantDraftRunId: null, isThinking: !1 } : i ? {
|
|
543
546
|
assistantDraft: "",
|
|
@@ -552,13 +555,13 @@ class ut {
|
|
|
552
555
|
if (t.type === "sessions.page") {
|
|
553
556
|
const s = typeof t.requestId == "string" ? t.requestId : null, n = s ? this.pendingSessionHistoryRequests.get(s) : null;
|
|
554
557
|
s && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(s), n.resolve({
|
|
555
|
-
sessions:
|
|
558
|
+
sessions: ge(t.sessions),
|
|
556
559
|
nextCursor: typeof t.nextCursor == "string" ? t.nextCursor : null
|
|
557
560
|
}));
|
|
558
561
|
return;
|
|
559
562
|
}
|
|
560
563
|
if (t.type === "session.updated") {
|
|
561
|
-
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId:
|
|
564
|
+
this.clearRunAckResyncRetryTimer(), this.setState({ sessionId: I(t.session, "id") ?? this.state.sessionId });
|
|
562
565
|
return;
|
|
563
566
|
}
|
|
564
567
|
if (t.type === "session.item") {
|
|
@@ -566,8 +569,8 @@ class ut {
|
|
|
566
569
|
if (s) {
|
|
567
570
|
s.role === "assistant" && (this.clearRetryTimers(), this.clearRunAckResyncRetryTimer());
|
|
568
571
|
const n = t.item.data;
|
|
569
|
-
|
|
570
|
-
const r =
|
|
572
|
+
Me(n) && this.clearRunAckResyncRetryTimer();
|
|
573
|
+
const r = Ie(this.state.messages, s), i = et(r);
|
|
571
574
|
this.setState({
|
|
572
575
|
messages: r,
|
|
573
576
|
assistantDraft: s.role === "assistant" ? "" : this.state.assistantDraft,
|
|
@@ -666,7 +669,7 @@ class ut {
|
|
|
666
669
|
scheduleRunAckWatchdog(t) {
|
|
667
670
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
668
671
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(t);
|
|
669
|
-
},
|
|
672
|
+
}, Ht);
|
|
670
673
|
}
|
|
671
674
|
recoverMissedRunAck(t) {
|
|
672
675
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== t || (g("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
@@ -688,7 +691,7 @@ class ut {
|
|
|
688
691
|
sessionId: this.state.sessionId,
|
|
689
692
|
clientMessageId: t
|
|
690
693
|
}) : this.activeUserMessageEvent && this.send(this.activeUserMessageEvent), this.scheduleThinkingWatchdog(E)));
|
|
691
|
-
},
|
|
694
|
+
}, Bt);
|
|
692
695
|
}
|
|
693
696
|
clearRunAckResyncRetryTimer() {
|
|
694
697
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -712,7 +715,7 @@ class ut {
|
|
|
712
715
|
sessionId: this.state.sessionId,
|
|
713
716
|
clientMessageId: t,
|
|
714
717
|
resyncAttempts: s + 1
|
|
715
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
718
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft);
|
|
716
719
|
return;
|
|
717
720
|
}
|
|
718
721
|
if (n >= K) {
|
|
@@ -749,7 +752,7 @@ class ut {
|
|
|
749
752
|
const s = typeof t.sessionId == "string" ? t.sessionId : null, n = typeof t.callId == "string" ? t.callId : null, r = typeof t.toolName == "string" ? t.toolName : null, i = typeof t.summary == "string" ? t.summary : "Running browser tool", o = t.rawInput;
|
|
750
753
|
if (!s || !n || !r)
|
|
751
754
|
return;
|
|
752
|
-
if (r !== "execute_code" || !
|
|
755
|
+
if (r !== "execute_code" || !ve(o)) {
|
|
753
756
|
this.send({
|
|
754
757
|
type: "tool.result",
|
|
755
758
|
sessionId: s,
|
|
@@ -765,7 +768,7 @@ class ut {
|
|
|
765
768
|
});
|
|
766
769
|
return;
|
|
767
770
|
}
|
|
768
|
-
const c =
|
|
771
|
+
const c = Kt(this.state.messages);
|
|
769
772
|
this.installSessionUserFilesApi(c);
|
|
770
773
|
let a = null, d;
|
|
771
774
|
a = await this.executeRuntimeHelper(), d = await Q(o).catch((h) => ({
|
|
@@ -780,14 +783,14 @@ class ut {
|
|
|
780
783
|
toolName: r,
|
|
781
784
|
summary: o.summary,
|
|
782
785
|
rawInput: w(o),
|
|
783
|
-
rawOutput: w(
|
|
786
|
+
rawOutput: w(ce(d, a))
|
|
784
787
|
});
|
|
785
788
|
}
|
|
786
789
|
installSessionUserFilesApi(t) {
|
|
787
|
-
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup =
|
|
790
|
+
this.cleanupSessionUserFilesApi(), this.sessionUserFilesApiCleanup = Jt(t, this.attachmentFiles, this.attachmentBlobCache);
|
|
788
791
|
}
|
|
789
792
|
cleanupSessionUserFilesApi() {
|
|
790
|
-
this.sessionUserFilesApiCleanup && (
|
|
793
|
+
this.sessionUserFilesApiCleanup && (Vt(this.sessionUserFilesApiCleanup), this.sessionUserFilesApiCleanup = null);
|
|
791
794
|
}
|
|
792
795
|
async executeRuntimeHelper() {
|
|
793
796
|
if (!this.runtimeHelperJavascript?.trim())
|
|
@@ -795,14 +798,14 @@ class ut {
|
|
|
795
798
|
const t = await Q({
|
|
796
799
|
javascript: this.runtimeHelperJavascript
|
|
797
800
|
});
|
|
798
|
-
return t.ok === !1 ?
|
|
801
|
+
return t.ok === !1 ? ue(t) : null;
|
|
799
802
|
}
|
|
800
803
|
enableNetworkCapture() {
|
|
801
804
|
if (this.networkCaptureCleanup)
|
|
802
805
|
return;
|
|
803
806
|
const t = window.fetch.bind(window), s = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send;
|
|
804
807
|
window.fetch = async (i, o) => {
|
|
805
|
-
const c = Date.now(), a = new Date(c).toISOString(), d = i instanceof Request ? i : null, h = typeof i == "string" ? i : i instanceof URL ? i.toString() : d?.url ?? "", u = (o?.method ?? d?.method ?? "GET").toUpperCase(), l = rt(new Headers(o?.headers ?? d?.headers ?? void 0)), f = await
|
|
808
|
+
const c = Date.now(), a = new Date(c).toISOString(), d = i instanceof Request ? i : null, h = typeof i == "string" ? i : i instanceof URL ? i.toString() : d?.url ?? "", u = (o?.method ?? d?.method ?? "GET").toUpperCase(), l = rt(new Headers(o?.headers ?? d?.headers ?? void 0)), f = await je(d, o);
|
|
806
809
|
try {
|
|
807
810
|
const p = await t(i, o);
|
|
808
811
|
return this.enqueueNetworkEvent({
|
|
@@ -814,7 +817,7 @@ class ut {
|
|
|
814
817
|
resourceType: "fetch",
|
|
815
818
|
responseStatus: p.status,
|
|
816
819
|
responseHeaders: rt(p.headers),
|
|
817
|
-
responseBody: await
|
|
820
|
+
responseBody: await $e(p),
|
|
818
821
|
startedAt: a,
|
|
819
822
|
durationMs: Date.now() - c
|
|
820
823
|
}), p;
|
|
@@ -856,7 +859,7 @@ class ut {
|
|
|
856
859
|
startedAtMs: Date.now(),
|
|
857
860
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
858
861
|
};
|
|
859
|
-
return a.requestBody =
|
|
862
|
+
return a.requestBody = It(o), this.__plunoMeta = a, this.addEventListener(
|
|
860
863
|
"loadend",
|
|
861
864
|
function() {
|
|
862
865
|
!c || !this.__plunoMeta || c.enqueueNetworkEvent({
|
|
@@ -867,8 +870,8 @@ class ut {
|
|
|
867
870
|
requestBody: typeof this.__plunoMeta.requestBody == "string" ? this.__plunoMeta.requestBody : void 0,
|
|
868
871
|
resourceType: "xhr",
|
|
869
872
|
responseStatus: this.status,
|
|
870
|
-
responseHeaders:
|
|
871
|
-
responseBody:
|
|
873
|
+
responseHeaders: Ge(this.getAllResponseHeaders()),
|
|
874
|
+
responseBody: ze(this),
|
|
872
875
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
873
876
|
startedAt: String(this.__plunoMeta.startedAt),
|
|
874
877
|
durationMs: Date.now() - Number(this.__plunoMeta.startedAtMs ?? Date.now())
|
|
@@ -890,7 +893,7 @@ class ut {
|
|
|
890
893
|
page: y(),
|
|
891
894
|
events: s
|
|
892
895
|
});
|
|
893
|
-
},
|
|
896
|
+
}, Lt));
|
|
894
897
|
}
|
|
895
898
|
scheduleReconnect() {
|
|
896
899
|
this.reconnectTimer !== null || this.state.status === "closed" || (this.reconnectTimer = window.setTimeout(() => {
|
|
@@ -901,12 +904,12 @@ class ut {
|
|
|
901
904
|
isThinking: this.state.isThinking
|
|
902
905
|
}), this.setState({ status: "reconnecting", lastError: null }), this.scheduleReconnect();
|
|
903
906
|
});
|
|
904
|
-
},
|
|
907
|
+
}, Ot));
|
|
905
908
|
}
|
|
906
909
|
startHeartbeat() {
|
|
907
910
|
this.stopHeartbeat(), this.heartbeatTimer = window.setInterval(() => {
|
|
908
911
|
this.sendNow({ type: "runtime.ping" });
|
|
909
|
-
},
|
|
912
|
+
}, qt);
|
|
910
913
|
}
|
|
911
914
|
stopHeartbeat() {
|
|
912
915
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null);
|
|
@@ -916,7 +919,7 @@ class ut {
|
|
|
916
919
|
...this.state,
|
|
917
920
|
...t,
|
|
918
921
|
...t.lastError === null && t.lastErrorCode === void 0 ? { lastErrorCode: null } : {}
|
|
919
|
-
},
|
|
922
|
+
}, Oe(this.options.clientId, this.state), this.emit("state", this.getState());
|
|
920
923
|
}
|
|
921
924
|
emit(t, s) {
|
|
922
925
|
this.listeners[t]?.forEach((r) => r(s));
|
|
@@ -937,11 +940,11 @@ function Y(e) {
|
|
|
937
940
|
const t = typeof e == "function" ? e() : e;
|
|
938
941
|
return t && Object.keys(t).length > 0 ? t : void 0;
|
|
939
942
|
}
|
|
940
|
-
function
|
|
943
|
+
function Gt(e) {
|
|
941
944
|
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";
|
|
942
945
|
}
|
|
943
|
-
const
|
|
944
|
-
function
|
|
946
|
+
const Xt = 5e3;
|
|
947
|
+
function Kt(e) {
|
|
945
948
|
const t = [];
|
|
946
949
|
for (const s of e)
|
|
947
950
|
s.role !== "user" || !s.attachments?.length || s.attachments.forEach((n, r) => {
|
|
@@ -952,7 +955,7 @@ function Gt(e) {
|
|
|
952
955
|
});
|
|
953
956
|
return t;
|
|
954
957
|
}
|
|
955
|
-
function
|
|
958
|
+
function Jt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
956
959
|
const n = new Map(e.map((u) => [u.id, u])), r = (u) => ({
|
|
957
960
|
id: u.id,
|
|
958
961
|
name: u.name,
|
|
@@ -972,7 +975,7 @@ function Xt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
972
975
|
const p = s.get(l.id);
|
|
973
976
|
if (p)
|
|
974
977
|
return p;
|
|
975
|
-
const S = await
|
|
978
|
+
const S = await Pt(l.id).then((m) => m?.blob ?? null).catch((m) => (g("web-sdk.attachments", "Failed to load Product Agent attachment from IndexedDB", {
|
|
976
979
|
attachmentId: l.id,
|
|
977
980
|
name: l.name,
|
|
978
981
|
message: m instanceof Error ? m.message : String(m)
|
|
@@ -981,7 +984,7 @@ function Xt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
981
984
|
return s.set(l.id, S), S;
|
|
982
985
|
if (!l.fileUrl)
|
|
983
986
|
throw new Error(`Pluno user file is missing content: ${u}`);
|
|
984
|
-
const D = await fetch(l.fileUrl,
|
|
987
|
+
const D = await fetch(l.fileUrl, He(l.fileUrl));
|
|
985
988
|
if (!D.ok)
|
|
986
989
|
throw new Error(`Failed to load Pluno user file: ${u}`);
|
|
987
990
|
const N = await D.blob();
|
|
@@ -1009,14 +1012,14 @@ function Xt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1009
1012
|
if (!p.startsWith("image/"))
|
|
1010
1013
|
throw new Error(`Pluno user file is not an image: ${u}`);
|
|
1011
1014
|
const S = f.type === p ? f : new Blob([f], { type: p });
|
|
1012
|
-
return
|
|
1015
|
+
return Yt(p, S.size) > jt ? {
|
|
1013
1016
|
type: "pluno.userFiles.inspectImage",
|
|
1014
1017
|
id: l.id,
|
|
1015
1018
|
name: l.name,
|
|
1016
1019
|
mimeType: p,
|
|
1017
1020
|
sizeBytes: l.sizeBytes,
|
|
1018
1021
|
imageAttached: !1,
|
|
1019
|
-
imageAttachmentError:
|
|
1022
|
+
imageAttachmentError: $t
|
|
1020
1023
|
} : {
|
|
1021
1024
|
type: "pluno.userFiles.inspectImage",
|
|
1022
1025
|
id: l.id,
|
|
@@ -1057,7 +1060,7 @@ function Xt(e, t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map()) {
|
|
|
1057
1060
|
a.pluno = f;
|
|
1058
1061
|
};
|
|
1059
1062
|
}
|
|
1060
|
-
function
|
|
1063
|
+
function Vt(e) {
|
|
1061
1064
|
try {
|
|
1062
1065
|
e();
|
|
1063
1066
|
} catch {
|
|
@@ -1075,12 +1078,12 @@ function Z(e) {
|
|
|
1075
1078
|
}, n.onerror = () => s(n.error ?? new Error("Failed to read Pluno user file")), n.readAsDataURL(e);
|
|
1076
1079
|
});
|
|
1077
1080
|
}
|
|
1078
|
-
function
|
|
1081
|
+
function Yt(e, t) {
|
|
1079
1082
|
return `data:${e};base64,`.length + Math.ceil(t / 3) * 4;
|
|
1080
1083
|
}
|
|
1081
1084
|
async function Q(e) {
|
|
1082
1085
|
const t = Object.getPrototypeOf(async function() {
|
|
1083
|
-
}).constructor, s = e.timeoutMs ??
|
|
1086
|
+
}).constructor, s = e.timeoutMs ?? Xt, n = Date.now(), r = [];
|
|
1084
1087
|
let i;
|
|
1085
1088
|
const o = {
|
|
1086
1089
|
log: console.log,
|
|
@@ -1098,7 +1101,7 @@ async function Q(e) {
|
|
|
1098
1101
|
i = window.setTimeout(() => h(a), s);
|
|
1099
1102
|
})
|
|
1100
1103
|
]);
|
|
1101
|
-
return d === a ?
|
|
1104
|
+
return d === a ? Zt(s) : {
|
|
1102
1105
|
ok: !0,
|
|
1103
1106
|
result: d,
|
|
1104
1107
|
console: r,
|
|
@@ -1127,7 +1130,7 @@ async function Q(e) {
|
|
|
1127
1130
|
i !== void 0 && window.clearTimeout(i), console.log = o.log, console.info = o.info, console.warn = o.warn, console.error = o.error;
|
|
1128
1131
|
}
|
|
1129
1132
|
}
|
|
1130
|
-
function
|
|
1133
|
+
function Zt(e) {
|
|
1131
1134
|
return {
|
|
1132
1135
|
ok: !1,
|
|
1133
1136
|
exception: {
|
|
@@ -1141,10 +1144,10 @@ function Vt(e) {
|
|
|
1141
1144
|
}
|
|
1142
1145
|
};
|
|
1143
1146
|
}
|
|
1144
|
-
function
|
|
1147
|
+
function Qt(e) {
|
|
1145
1148
|
return e.replace(/\/+$/, "");
|
|
1146
1149
|
}
|
|
1147
|
-
function
|
|
1150
|
+
function te(e) {
|
|
1148
1151
|
const t = new URL("/api/product-agent/embed/ws", e);
|
|
1149
1152
|
return t.protocol = t.protocol === "https:" ? "wss:" : "ws:", t.toString();
|
|
1150
1153
|
}
|
|
@@ -1157,17 +1160,17 @@ function y() {
|
|
|
1157
1160
|
...e ? { plunoProductAgentUi: e } : {}
|
|
1158
1161
|
};
|
|
1159
1162
|
}
|
|
1160
|
-
function
|
|
1163
|
+
function ee() {
|
|
1161
1164
|
return {
|
|
1162
1165
|
pageUrl: location.href,
|
|
1163
1166
|
pageTitle: document.title,
|
|
1164
|
-
htmlContent:
|
|
1167
|
+
htmlContent: ne()
|
|
1165
1168
|
};
|
|
1166
1169
|
}
|
|
1167
|
-
function
|
|
1170
|
+
function se() {
|
|
1168
1171
|
return lt()?.surface === "browser_extension_sdk_preview";
|
|
1169
1172
|
}
|
|
1170
|
-
function
|
|
1173
|
+
function ne() {
|
|
1171
1174
|
const e = document.body?.cloneNode(!0);
|
|
1172
1175
|
return e instanceof HTMLElement ? (e.querySelectorAll(
|
|
1173
1176
|
[
|
|
@@ -1207,23 +1210,23 @@ function lt() {
|
|
|
1207
1210
|
},
|
|
1208
1211
|
{
|
|
1209
1212
|
name: "widget_root",
|
|
1210
|
-
selector:
|
|
1213
|
+
selector: bt,
|
|
1211
1214
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
1212
1215
|
},
|
|
1213
1216
|
{
|
|
1214
1217
|
name: "widget_panel",
|
|
1215
|
-
selector:
|
|
1218
|
+
selector: Ut,
|
|
1216
1219
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
1217
1220
|
},
|
|
1218
1221
|
{
|
|
1219
1222
|
name: "widget_timeline",
|
|
1220
|
-
selector:
|
|
1223
|
+
selector: Ct,
|
|
1221
1224
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
1222
1225
|
}
|
|
1223
1226
|
]
|
|
1224
1227
|
};
|
|
1225
1228
|
}
|
|
1226
|
-
function
|
|
1229
|
+
function re(e) {
|
|
1227
1230
|
try {
|
|
1228
1231
|
const t = JSON.parse(e);
|
|
1229
1232
|
return t && typeof t == "object" ? t : { type: "error", message: "Invalid server event" };
|
|
@@ -1237,10 +1240,10 @@ function tt(e, t) {
|
|
|
1237
1240
|
const s = e[t];
|
|
1238
1241
|
return Array.isArray(s) ? s.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
1239
1242
|
}
|
|
1240
|
-
function
|
|
1243
|
+
function ie(e) {
|
|
1241
1244
|
return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.trim().length > 0) : [];
|
|
1242
1245
|
}
|
|
1243
|
-
function
|
|
1246
|
+
function oe(e) {
|
|
1244
1247
|
if (!e || typeof e != "object")
|
|
1245
1248
|
return null;
|
|
1246
1249
|
const t = e, s = t.appearance, n = s && typeof s == "object" ? s : t, r = typeof n.accentColor == "string" ? n.accentColor : null, i = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, c = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -1251,13 +1254,13 @@ function re(e) {
|
|
|
1251
1254
|
...c !== null ? { scribbleStyle: c } : {}
|
|
1252
1255
|
};
|
|
1253
1256
|
}
|
|
1254
|
-
function
|
|
1257
|
+
function ae(e) {
|
|
1255
1258
|
if (!e || typeof e != "object")
|
|
1256
1259
|
return null;
|
|
1257
1260
|
const t = e.javascript;
|
|
1258
1261
|
return typeof t != "string" || !t.trim() ? null : { javascript: t };
|
|
1259
1262
|
}
|
|
1260
|
-
function
|
|
1263
|
+
function ce(e, t) {
|
|
1261
1264
|
return t ? e && typeof e == "object" ? {
|
|
1262
1265
|
...e,
|
|
1263
1266
|
helperError: t
|
|
@@ -1267,20 +1270,20 @@ function oe(e, t) {
|
|
|
1267
1270
|
helperError: t
|
|
1268
1271
|
} : e;
|
|
1269
1272
|
}
|
|
1270
|
-
function
|
|
1273
|
+
function ue(e) {
|
|
1271
1274
|
if (!e || typeof e != "object")
|
|
1272
1275
|
return e;
|
|
1273
1276
|
const t = e;
|
|
1274
1277
|
return typeof t.exception?.message == "string" ? t.exception.message : typeof t.error == "string" ? t.error : e;
|
|
1275
1278
|
}
|
|
1276
|
-
function
|
|
1279
|
+
function le() {
|
|
1277
1280
|
const e = "pluno.productAgent.clientId", t = window.localStorage.getItem(e);
|
|
1278
1281
|
if (t)
|
|
1279
1282
|
return t;
|
|
1280
1283
|
const s = crypto.randomUUID();
|
|
1281
1284
|
return window.localStorage.setItem(e, s), s;
|
|
1282
1285
|
}
|
|
1283
|
-
function
|
|
1286
|
+
function de() {
|
|
1284
1287
|
const e = window.sessionStorage.getItem(V);
|
|
1285
1288
|
if (e)
|
|
1286
1289
|
return e;
|
|
@@ -1290,7 +1293,7 @@ function ue() {
|
|
|
1290
1293
|
function R() {
|
|
1291
1294
|
return crypto.randomUUID();
|
|
1292
1295
|
}
|
|
1293
|
-
function
|
|
1296
|
+
function he(e) {
|
|
1294
1297
|
if (!e || typeof e != "object")
|
|
1295
1298
|
return null;
|
|
1296
1299
|
const t = e, s = typeof t.id == "string" ? t.id : null;
|
|
@@ -1301,23 +1304,23 @@ function le(e) {
|
|
|
1301
1304
|
avatarUrl: typeof t.avatarUrl == "string" ? t.avatarUrl : null
|
|
1302
1305
|
} : null;
|
|
1303
1306
|
}
|
|
1304
|
-
function
|
|
1305
|
-
return Array.isArray(e) ?
|
|
1307
|
+
function pe(e, t) {
|
|
1308
|
+
return Array.isArray(e) ? W(
|
|
1306
1309
|
x(
|
|
1307
1310
|
e.map((s) => dt(s, t)).filter((s) => s !== null)
|
|
1308
1311
|
)
|
|
1309
1312
|
) : [];
|
|
1310
1313
|
}
|
|
1311
|
-
function
|
|
1314
|
+
function ge(e) {
|
|
1312
1315
|
return Array.isArray(e) ? e.flatMap((t) => {
|
|
1313
1316
|
if (!t || typeof t != "object")
|
|
1314
1317
|
return [];
|
|
1315
|
-
const s = t, n =
|
|
1318
|
+
const s = t, n = I(s, "id"), r = I(s, "createdAt"), i = I(s, "updatedAt"), o = I(s, "lastActiveAt");
|
|
1316
1319
|
return !n || !r || !i || !o ? [] : [
|
|
1317
1320
|
{
|
|
1318
1321
|
id: n,
|
|
1319
|
-
title:
|
|
1320
|
-
firstUserMessage:
|
|
1322
|
+
title: I(s, "title"),
|
|
1323
|
+
firstUserMessage: I(s, "firstUserMessage"),
|
|
1321
1324
|
currentPage: s.currentPage ?? null,
|
|
1322
1325
|
createdAt: r,
|
|
1323
1326
|
updatedAt: i,
|
|
@@ -1338,28 +1341,28 @@ function dt(e, t) {
|
|
|
1338
1341
|
return {
|
|
1339
1342
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1340
1343
|
role: i,
|
|
1341
|
-
content:
|
|
1344
|
+
content: we(r.content),
|
|
1342
1345
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1343
1346
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
1344
1347
|
...k(r) ? { runId: k(r) } : {},
|
|
1345
|
-
attachments:
|
|
1348
|
+
attachments: Tt(r.attachments, t)
|
|
1346
1349
|
};
|
|
1347
1350
|
}
|
|
1348
1351
|
return r.type === "function_call" || r.type === "tool_call" || r.type === "web_search_call" ? {
|
|
1349
1352
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1350
1353
|
role: "tool",
|
|
1351
|
-
content:
|
|
1354
|
+
content: me(r),
|
|
1352
1355
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1353
1356
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
1354
1357
|
...k(r) ? { runId: k(r) } : {},
|
|
1355
1358
|
dataType: String(r.type),
|
|
1356
1359
|
toolName: typeof r.name == "string" ? r.name : void 0,
|
|
1357
|
-
callId:
|
|
1360
|
+
callId: Te(r) ?? void 0,
|
|
1358
1361
|
loading: r.localExecutionStatus === "running"
|
|
1359
1362
|
} : r.type === "run_status" || r.type === "run_error" ? r.type === "run_error" && r.stage === "tool_execution" ? null : {
|
|
1360
1363
|
id: String(s.id ?? crypto.randomUUID()),
|
|
1361
1364
|
role: "system",
|
|
1362
|
-
content:
|
|
1365
|
+
content: fe(r),
|
|
1363
1366
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
1364
1367
|
respondsToUserMessageId: O(r) ?? void 0,
|
|
1365
1368
|
...k(r) ? { runId: k(r) } : {},
|
|
@@ -1367,10 +1370,10 @@ function dt(e, t) {
|
|
|
1367
1370
|
loading: r.type === "run_status" && (r.status === "running" || r.status === "retrying")
|
|
1368
1371
|
} : null;
|
|
1369
1372
|
}
|
|
1370
|
-
function
|
|
1373
|
+
function fe(e) {
|
|
1371
1374
|
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.";
|
|
1372
1375
|
}
|
|
1373
|
-
function
|
|
1376
|
+
function me(e) {
|
|
1374
1377
|
if (e.type === "web_search_call") {
|
|
1375
1378
|
const t = e.action;
|
|
1376
1379
|
if (t && typeof t == "object") {
|
|
@@ -1382,9 +1385,9 @@ function ge(e) {
|
|
|
1382
1385
|
}
|
|
1383
1386
|
return "Searching the web";
|
|
1384
1387
|
}
|
|
1385
|
-
return
|
|
1388
|
+
return ye(e);
|
|
1386
1389
|
}
|
|
1387
|
-
function
|
|
1390
|
+
function ye(e) {
|
|
1388
1391
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
1389
1392
|
return e.summary;
|
|
1390
1393
|
if (typeof e.arguments == "string")
|
|
@@ -1397,11 +1400,11 @@ function fe(e) {
|
|
|
1397
1400
|
}
|
|
1398
1401
|
return typeof e.name == "string" && e.name.trim().length > 0 ? e.name : "Run tool";
|
|
1399
1402
|
}
|
|
1400
|
-
function
|
|
1403
|
+
function Te(e) {
|
|
1401
1404
|
const t = e.callId ?? e.call_id;
|
|
1402
1405
|
return typeof t == "string" && t ? t : null;
|
|
1403
1406
|
}
|
|
1404
|
-
function
|
|
1407
|
+
function we(e) {
|
|
1405
1408
|
return typeof e == "string" ? e : Array.isArray(e) ? e.map((t) => {
|
|
1406
1409
|
if (!t || typeof t != "object")
|
|
1407
1410
|
return "";
|
|
@@ -1409,16 +1412,16 @@ function ye(e) {
|
|
|
1409
1412
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
1410
1413
|
}).filter(Boolean).join("") : "";
|
|
1411
1414
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const s = ht(e, t), n =
|
|
1415
|
+
function Ie(e, t) {
|
|
1416
|
+
const s = ht(e, t), n = Ee(e, t), r = n.findIndex((o) => o.id === s.id);
|
|
1414
1417
|
if (r === -1)
|
|
1415
|
-
return
|
|
1418
|
+
return W(
|
|
1416
1419
|
x([...n, s])
|
|
1417
1420
|
);
|
|
1418
1421
|
const i = [...n];
|
|
1419
|
-
return i[r] = s,
|
|
1422
|
+
return i[r] = s, W(x(i));
|
|
1420
1423
|
}
|
|
1421
|
-
function
|
|
1424
|
+
function Ae(e, t) {
|
|
1422
1425
|
return t.map((s) => ht(e, s));
|
|
1423
1426
|
}
|
|
1424
1427
|
function ht(e, t) {
|
|
@@ -1430,19 +1433,19 @@ function ht(e, t) {
|
|
|
1430
1433
|
if (!s?.attachments?.length)
|
|
1431
1434
|
return t;
|
|
1432
1435
|
const n = t.attachments.map((r) => {
|
|
1433
|
-
const i =
|
|
1434
|
-
return i ?
|
|
1436
|
+
const i = Se(s.attachments ?? [], r);
|
|
1437
|
+
return i ? ke(r, i) : r;
|
|
1435
1438
|
});
|
|
1436
1439
|
return { ...t, attachments: n };
|
|
1437
1440
|
}
|
|
1438
|
-
function
|
|
1441
|
+
function Se(e, t) {
|
|
1439
1442
|
return t.id ? e.find((s) => s.id === t.id) ?? null : null;
|
|
1440
1443
|
}
|
|
1441
|
-
function
|
|
1444
|
+
function ke(e, t) {
|
|
1442
1445
|
const { previewUrl: s } = t;
|
|
1443
1446
|
return s ? { ...e, previewUrl: s } : e;
|
|
1444
1447
|
}
|
|
1445
|
-
function
|
|
1448
|
+
function Ee(e, t) {
|
|
1446
1449
|
if (t.role !== "user")
|
|
1447
1450
|
return e;
|
|
1448
1451
|
const s = e.findIndex(
|
|
@@ -1455,9 +1458,9 @@ function Se(e, t) {
|
|
|
1455
1458
|
}
|
|
1456
1459
|
function et(e) {
|
|
1457
1460
|
const t = pt(e);
|
|
1458
|
-
return t === null ? !1 : e.slice(t + 1).some(
|
|
1461
|
+
return t === null ? !1 : e.slice(t + 1).some(gt);
|
|
1459
1462
|
}
|
|
1460
|
-
function
|
|
1463
|
+
function Re(e) {
|
|
1461
1464
|
const t = pt(e);
|
|
1462
1465
|
return t === null ? e.some((s) => s.role === "assistant") : e.slice(t + 1).some((s) => s.role === "assistant");
|
|
1463
1466
|
}
|
|
@@ -1467,10 +1470,10 @@ function pt(e) {
|
|
|
1467
1470
|
return t;
|
|
1468
1471
|
return null;
|
|
1469
1472
|
}
|
|
1470
|
-
function
|
|
1473
|
+
function gt(e) {
|
|
1471
1474
|
return e.role === "assistant" ? !0 : e.role !== "system" ? !1 : e.dataType === "run_error" ? !0 : e.dataType === "run_status" && e.loading !== !0;
|
|
1472
1475
|
}
|
|
1473
|
-
function
|
|
1476
|
+
function ft(e) {
|
|
1474
1477
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
1475
1478
|
const s = e[t];
|
|
1476
1479
|
if (!s || typeof s != "object")
|
|
@@ -1484,8 +1487,18 @@ function Re(e) {
|
|
|
1484
1487
|
}
|
|
1485
1488
|
return null;
|
|
1486
1489
|
}
|
|
1487
|
-
function _e(e) {
|
|
1488
|
-
const
|
|
1490
|
+
function _e(e, t) {
|
|
1491
|
+
const s = ft(t);
|
|
1492
|
+
if (s === null)
|
|
1493
|
+
return !1;
|
|
1494
|
+
const n = t[s], r = n && typeof n == "object" ? n.id : null;
|
|
1495
|
+
if (typeof r != "string" || !r)
|
|
1496
|
+
return !1;
|
|
1497
|
+
const i = e.findIndex((o) => o.role === "user" && o.id === r);
|
|
1498
|
+
return i === -1 ? !1 : e.slice(i + 1).some(gt);
|
|
1499
|
+
}
|
|
1500
|
+
function Pe(e) {
|
|
1501
|
+
const t = ft(e);
|
|
1489
1502
|
if (t === null)
|
|
1490
1503
|
return null;
|
|
1491
1504
|
const s = e[t];
|
|
@@ -1497,19 +1510,19 @@ function _e(e) {
|
|
|
1497
1510
|
const r = n.clientMessageId;
|
|
1498
1511
|
return typeof r == "string" ? r : null;
|
|
1499
1512
|
}
|
|
1500
|
-
function
|
|
1513
|
+
function Me(e) {
|
|
1501
1514
|
if (!e || typeof e != "object")
|
|
1502
1515
|
return !1;
|
|
1503
1516
|
const t = e;
|
|
1504
1517
|
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";
|
|
1505
1518
|
}
|
|
1506
|
-
function
|
|
1507
|
-
return e.filter((t, s) =>
|
|
1519
|
+
function W(e) {
|
|
1520
|
+
return e.filter((t, s) => mt(t) ? !Ne(e, s) && !Ce(e, s) && !De(e, s) : be(t) ? !Ue(e, s) : !0);
|
|
1508
1521
|
}
|
|
1509
|
-
function
|
|
1522
|
+
function be(e) {
|
|
1510
1523
|
return e.role === "system" && (e.dataType === "run_status" || e.dataType === "run_error");
|
|
1511
1524
|
}
|
|
1512
|
-
function
|
|
1525
|
+
function mt(e) {
|
|
1513
1526
|
return e.role === "system" && e.dataType === "run_status" && e.loading === !0;
|
|
1514
1527
|
}
|
|
1515
1528
|
function x(e) {
|
|
@@ -1528,7 +1541,7 @@ function x(e) {
|
|
|
1528
1541
|
n.has(i.id) || (r.push(i), i.role === "user" && r.push(...s.get(i.id) ?? []));
|
|
1529
1542
|
return r;
|
|
1530
1543
|
}
|
|
1531
|
-
function
|
|
1544
|
+
function Ue(e, t) {
|
|
1532
1545
|
const s = e[t];
|
|
1533
1546
|
for (let n = t + 1; n < e.length; n += 1) {
|
|
1534
1547
|
const r = e[n];
|
|
@@ -1539,34 +1552,34 @@ function be(e, t) {
|
|
|
1539
1552
|
}
|
|
1540
1553
|
return !1;
|
|
1541
1554
|
}
|
|
1542
|
-
function
|
|
1555
|
+
function Ce(e, t) {
|
|
1543
1556
|
const s = e[t];
|
|
1544
1557
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1545
1558
|
if (e[n].role === "assistant" && C(s, e[n]))
|
|
1546
1559
|
return !0;
|
|
1547
1560
|
return !1;
|
|
1548
1561
|
}
|
|
1549
|
-
function
|
|
1562
|
+
function De(e, t) {
|
|
1550
1563
|
const s = e[t];
|
|
1551
1564
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1552
1565
|
if (e[n].role === "tool" && C(s, e[n]))
|
|
1553
1566
|
return !0;
|
|
1554
1567
|
return !1;
|
|
1555
1568
|
}
|
|
1556
|
-
function
|
|
1569
|
+
function Ne(e, t) {
|
|
1557
1570
|
const s = e[t];
|
|
1558
1571
|
for (let n = t + 1; n < e.length; n += 1)
|
|
1559
|
-
if (
|
|
1572
|
+
if (mt(e[n]) && C(s, e[n]))
|
|
1560
1573
|
return !0;
|
|
1561
1574
|
return !1;
|
|
1562
1575
|
}
|
|
1563
1576
|
function C(e, t) {
|
|
1564
1577
|
return !e.runId || !t.runId ? !0 : e.runId === t.runId;
|
|
1565
1578
|
}
|
|
1566
|
-
function
|
|
1579
|
+
function I(e, t) {
|
|
1567
1580
|
return e && typeof e == "object" && typeof e[t] == "string" ? e[t] : null;
|
|
1568
1581
|
}
|
|
1569
|
-
function
|
|
1582
|
+
function qe(e, t) {
|
|
1570
1583
|
try {
|
|
1571
1584
|
const s = window.localStorage.getItem(`${ct}${e}`);
|
|
1572
1585
|
if (!s)
|
|
@@ -1583,46 +1596,46 @@ function Ne(e, t) {
|
|
|
1583
1596
|
return null;
|
|
1584
1597
|
}
|
|
1585
1598
|
}
|
|
1586
|
-
function
|
|
1599
|
+
function Oe(e, t) {
|
|
1587
1600
|
try {
|
|
1588
1601
|
window.localStorage.setItem(
|
|
1589
1602
|
`${ct}${e}`,
|
|
1590
1603
|
JSON.stringify({
|
|
1591
1604
|
sessionId: t.sessionId,
|
|
1592
|
-
messages: t.messages.slice(-
|
|
1605
|
+
messages: t.messages.slice(-zt).map(xe)
|
|
1593
1606
|
})
|
|
1594
1607
|
);
|
|
1595
1608
|
} catch {
|
|
1596
1609
|
return;
|
|
1597
1610
|
}
|
|
1598
1611
|
}
|
|
1599
|
-
function
|
|
1612
|
+
function Fe(e) {
|
|
1600
1613
|
try {
|
|
1601
|
-
const t = window.localStorage.getItem(`${
|
|
1614
|
+
const t = window.localStorage.getItem(`${L}${e}`);
|
|
1602
1615
|
if (!t)
|
|
1603
1616
|
return [];
|
|
1604
1617
|
const s = JSON.parse(t);
|
|
1605
|
-
return Array.isArray(s) ? s.filter(
|
|
1618
|
+
return Array.isArray(s) ? s.filter(yt) : [];
|
|
1606
1619
|
} catch {
|
|
1607
1620
|
return [];
|
|
1608
1621
|
}
|
|
1609
1622
|
}
|
|
1610
1623
|
function _(e, t) {
|
|
1611
1624
|
try {
|
|
1612
|
-
const s = t.filter(
|
|
1625
|
+
const s = t.filter(yt);
|
|
1613
1626
|
if (s.length === 0) {
|
|
1614
|
-
window.localStorage.removeItem(`${
|
|
1627
|
+
window.localStorage.removeItem(`${L}${e}`);
|
|
1615
1628
|
return;
|
|
1616
1629
|
}
|
|
1617
1630
|
window.localStorage.setItem(
|
|
1618
|
-
`${
|
|
1631
|
+
`${L}${e}`,
|
|
1619
1632
|
JSON.stringify(s.slice(-25))
|
|
1620
1633
|
);
|
|
1621
1634
|
} catch {
|
|
1622
1635
|
return;
|
|
1623
1636
|
}
|
|
1624
1637
|
}
|
|
1625
|
-
function
|
|
1638
|
+
function yt(e) {
|
|
1626
1639
|
if (!e || typeof e != "object")
|
|
1627
1640
|
return !1;
|
|
1628
1641
|
const t = e;
|
|
@@ -1634,7 +1647,7 @@ function st(e) {
|
|
|
1634
1647
|
const t = e;
|
|
1635
1648
|
return typeof t.url == "string" && typeof t.title == "string" && typeof t.origin == "string";
|
|
1636
1649
|
}
|
|
1637
|
-
function
|
|
1650
|
+
function Tt(e, t) {
|
|
1638
1651
|
if (!Array.isArray(e))
|
|
1639
1652
|
return;
|
|
1640
1653
|
const s = e.filter((r) => {
|
|
@@ -1642,24 +1655,24 @@ function mt(e, t) {
|
|
|
1642
1655
|
return !1;
|
|
1643
1656
|
const i = r;
|
|
1644
1657
|
return typeof i.name == "string" && typeof i.mimeType == "string" && typeof i.sizeBytes == "number";
|
|
1645
|
-
}), n = t ? s.map((r) =>
|
|
1658
|
+
}), n = t ? s.map((r) => wt(r, t)) : s;
|
|
1646
1659
|
return n.length > 0 ? n : void 0;
|
|
1647
1660
|
}
|
|
1648
|
-
function
|
|
1661
|
+
function wt(e, t) {
|
|
1649
1662
|
return e.fileUrl?.startsWith("/") ? {
|
|
1650
1663
|
...e,
|
|
1651
1664
|
fileUrl: new URL(e.fileUrl, t).toString()
|
|
1652
1665
|
} : e;
|
|
1653
1666
|
}
|
|
1654
|
-
function
|
|
1655
|
-
if (
|
|
1667
|
+
function He(e) {
|
|
1668
|
+
if (Be(e))
|
|
1656
1669
|
return {
|
|
1657
1670
|
headers: {
|
|
1658
1671
|
"ngrok-skip-browser-warning": "true"
|
|
1659
1672
|
}
|
|
1660
1673
|
};
|
|
1661
1674
|
}
|
|
1662
|
-
function
|
|
1675
|
+
function Be(e) {
|
|
1663
1676
|
try {
|
|
1664
1677
|
const t = new URL(e).hostname;
|
|
1665
1678
|
return t.endsWith(".ngrok-free.dev") || t.endsWith(".ngrok-free.app") || t.endsWith(".ngrok.app") || t.endsWith(".ngrok.io");
|
|
@@ -1668,9 +1681,9 @@ function He(e) {
|
|
|
1668
1681
|
}
|
|
1669
1682
|
}
|
|
1670
1683
|
function nt(e) {
|
|
1671
|
-
return e.type ||
|
|
1684
|
+
return e.type || Le(e.name) || "application/octet-stream";
|
|
1672
1685
|
}
|
|
1673
|
-
function
|
|
1686
|
+
function Le(e) {
|
|
1674
1687
|
const t = e.toLowerCase();
|
|
1675
1688
|
return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
|
|
1676
1689
|
}
|
|
@@ -1686,11 +1699,11 @@ function We(e) {
|
|
|
1686
1699
|
respondsToUserMessageId: typeof t.respondsToUserMessageId == "string" ? t.respondsToUserMessageId : void 0,
|
|
1687
1700
|
...typeof t.runId == "string" ? { runId: t.runId } : {},
|
|
1688
1701
|
dataType: typeof t.dataType == "string" ? t.dataType : void 0,
|
|
1689
|
-
attachments:
|
|
1702
|
+
attachments: Tt(t.attachments)?.map($),
|
|
1690
1703
|
loading: typeof t.loading == "boolean" ? t.loading : void 0
|
|
1691
1704
|
};
|
|
1692
1705
|
}
|
|
1693
|
-
function
|
|
1706
|
+
function xe(e) {
|
|
1694
1707
|
return e.attachments?.length ? {
|
|
1695
1708
|
...e,
|
|
1696
1709
|
attachments: e.attachments.map($)
|
|
@@ -1713,7 +1726,7 @@ function k(e) {
|
|
|
1713
1726
|
const t = e.runId;
|
|
1714
1727
|
return typeof t == "string" && t ? t : null;
|
|
1715
1728
|
}
|
|
1716
|
-
function
|
|
1729
|
+
function ve(e) {
|
|
1717
1730
|
return !!e && typeof e == "object" && typeof e.summary == "string" && typeof e.javascript == "string";
|
|
1718
1731
|
}
|
|
1719
1732
|
function rt(e) {
|
|
@@ -1722,50 +1735,50 @@ function rt(e) {
|
|
|
1722
1735
|
t[n] = s;
|
|
1723
1736
|
}), t;
|
|
1724
1737
|
}
|
|
1725
|
-
async function
|
|
1738
|
+
async function je(e, t) {
|
|
1726
1739
|
if (typeof t?.body < "u")
|
|
1727
|
-
return
|
|
1740
|
+
return It(t.body);
|
|
1728
1741
|
if (e)
|
|
1729
1742
|
try {
|
|
1730
|
-
return
|
|
1743
|
+
return A(await e.clone().text());
|
|
1731
1744
|
} catch {
|
|
1732
1745
|
return;
|
|
1733
1746
|
}
|
|
1734
1747
|
}
|
|
1735
|
-
async function
|
|
1748
|
+
async function $e(e) {
|
|
1736
1749
|
try {
|
|
1737
|
-
return
|
|
1750
|
+
return A(await e.clone().text());
|
|
1738
1751
|
} catch (t) {
|
|
1739
1752
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1740
1753
|
}
|
|
1741
1754
|
}
|
|
1742
|
-
function
|
|
1755
|
+
function ze(e) {
|
|
1743
1756
|
try {
|
|
1744
|
-
return e.responseType === "" || e.responseType === "text" ?
|
|
1757
|
+
return e.responseType === "" || e.responseType === "text" ? A(e.responseText ?? "") : e.responseType === "json" ? A(JSON.stringify(e.response)) : `[unsupported xhr responseType: ${e.responseType || "unknown"}]`;
|
|
1745
1758
|
} catch (t) {
|
|
1746
1759
|
return { error: t instanceof Error ? t.message : "unavailable" };
|
|
1747
1760
|
}
|
|
1748
1761
|
}
|
|
1749
|
-
function
|
|
1762
|
+
function It(e) {
|
|
1750
1763
|
if (!(e === null || typeof e > "u")) {
|
|
1751
1764
|
if (typeof e == "string")
|
|
1752
|
-
return
|
|
1765
|
+
return A(e);
|
|
1753
1766
|
if (e instanceof URLSearchParams)
|
|
1754
|
-
return
|
|
1767
|
+
return A(e.toString());
|
|
1755
1768
|
if (e instanceof FormData) {
|
|
1756
1769
|
const t = [];
|
|
1757
|
-
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])),
|
|
1770
|
+
return e.forEach((s, n) => t.push([n, s instanceof File ? `[file:${s.name}]` : String(s)])), A(JSON.stringify(t));
|
|
1758
1771
|
}
|
|
1759
1772
|
if (e instanceof Blob)
|
|
1760
1773
|
return `[blob:${e.type || "application/octet-stream"}:${e.size}]`;
|
|
1761
1774
|
try {
|
|
1762
|
-
return
|
|
1775
|
+
return A(JSON.stringify(e));
|
|
1763
1776
|
} catch {
|
|
1764
1777
|
return `[unserializable body: ${Object.prototype.toString.call(e)}]`;
|
|
1765
1778
|
}
|
|
1766
1779
|
}
|
|
1767
1780
|
}
|
|
1768
|
-
function
|
|
1781
|
+
function Ge(e) {
|
|
1769
1782
|
const t = {};
|
|
1770
1783
|
for (const s of e.trim().split(/[\r\n]+/)) {
|
|
1771
1784
|
const n = s.indexOf(":");
|
|
@@ -1773,7 +1786,7 @@ function ze(e) {
|
|
|
1773
1786
|
}
|
|
1774
1787
|
return t;
|
|
1775
1788
|
}
|
|
1776
|
-
function
|
|
1789
|
+
function A(e) {
|
|
1777
1790
|
return e.length <= q ? e : `${e.slice(0, q)}... [truncated ${e.length - q} chars]`;
|
|
1778
1791
|
}
|
|
1779
1792
|
function P(e) {
|
|
@@ -1791,36 +1804,36 @@ async function F(e, t) {
|
|
|
1791
1804
|
try {
|
|
1792
1805
|
return await e();
|
|
1793
1806
|
} catch (r) {
|
|
1794
|
-
if (s = r, n >= J - 1 || !
|
|
1807
|
+
if (s = r, n >= J - 1 || !Ke(r))
|
|
1795
1808
|
throw r;
|
|
1796
|
-
await
|
|
1809
|
+
await Xe(n);
|
|
1797
1810
|
}
|
|
1798
1811
|
throw s instanceof Error ? s : new Error(t);
|
|
1799
1812
|
}
|
|
1800
|
-
function
|
|
1813
|
+
function Xe(e) {
|
|
1801
1814
|
return new Promise((t) => {
|
|
1802
|
-
window.setTimeout(t,
|
|
1815
|
+
window.setTimeout(t, vt[e] ?? 0);
|
|
1803
1816
|
});
|
|
1804
1817
|
}
|
|
1805
|
-
function Xe(e) {
|
|
1806
|
-
return e instanceof M ? Ke(e.status) : e instanceof TypeError;
|
|
1807
|
-
}
|
|
1808
1818
|
function Ke(e) {
|
|
1809
|
-
return e
|
|
1819
|
+
return e instanceof M ? Je(e.status) : e instanceof TypeError;
|
|
1810
1820
|
}
|
|
1811
1821
|
function Je(e) {
|
|
1822
|
+
return e === 408 || e === 409 || e === 429 || e >= 500;
|
|
1823
|
+
}
|
|
1824
|
+
function Ve(e) {
|
|
1812
1825
|
return e === 401 || e === 403;
|
|
1813
1826
|
}
|
|
1814
|
-
const z = "[REDACTED_SECRET]", T = "[REDACTED_TOKEN]",
|
|
1827
|
+
const z = "[REDACTED_SECRET]", T = "[REDACTED_TOKEN]", Ye = "[REDACTED_SIGNED_URL]", Ze = 20, Qe = /^(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, At = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, St = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, kt = /\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, ts = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, es = /\bhttps?:\/\/[^\s"'<>]+/gi, ss = /[),.;\]]+$/;
|
|
1815
1828
|
function w(e) {
|
|
1816
1829
|
return b(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1817
1830
|
}
|
|
1818
1831
|
function b(e, t, s) {
|
|
1819
1832
|
if (typeof e == "string")
|
|
1820
|
-
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e :
|
|
1833
|
+
return e.startsWith("data:image/") || e.startsWith("data:application/pdf;") ? e : is(e);
|
|
1821
1834
|
if (e === null || typeof e != "object")
|
|
1822
1835
|
return e;
|
|
1823
|
-
if (t >=
|
|
1836
|
+
if (t >= Ze)
|
|
1824
1837
|
return "[REDACTED_MAX_DEPTH]";
|
|
1825
1838
|
if (s.has(e))
|
|
1826
1839
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -1828,42 +1841,42 @@ function b(e, t, s) {
|
|
|
1828
1841
|
return e.map((r) => b(r, t + 1, s));
|
|
1829
1842
|
const n = {};
|
|
1830
1843
|
for (const [r, i] of Object.entries(e))
|
|
1831
|
-
|
|
1844
|
+
ns(r) ? n[r] = z : n[r] = r.toLowerCase() === "url" ? rs(i) : b(i, t + 1, s);
|
|
1832
1845
|
return n;
|
|
1833
1846
|
}
|
|
1834
|
-
function
|
|
1847
|
+
function ns(e) {
|
|
1835
1848
|
const t = e.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
1836
1849
|
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");
|
|
1837
1850
|
}
|
|
1838
|
-
function
|
|
1839
|
-
return typeof e == "string" ?
|
|
1851
|
+
function rs(e) {
|
|
1852
|
+
return typeof e == "string" ? Rt(e) : b(e, 0, /* @__PURE__ */ new WeakSet());
|
|
1840
1853
|
}
|
|
1841
|
-
function
|
|
1854
|
+
function Rt(e) {
|
|
1842
1855
|
try {
|
|
1843
1856
|
const t = new URL(e, location.href);
|
|
1844
1857
|
for (const s of Array.from(t.searchParams.keys()))
|
|
1845
|
-
|
|
1858
|
+
Qe.test(s) && t.searchParams.set(s, T);
|
|
1846
1859
|
return t.username && (t.username = T), t.password && (t.password = T), t.toString();
|
|
1847
1860
|
} catch {
|
|
1848
|
-
return
|
|
1861
|
+
return os(e);
|
|
1849
1862
|
}
|
|
1850
1863
|
}
|
|
1851
|
-
function rs(e) {
|
|
1852
|
-
return e.replace(Qe, Ve).replace(ts, os).replace(wt, `Bearer ${T}`).replace(At, `Basic ${T}`).replace(It, T).replace(St, (t, s) => `${s}: ${z}`);
|
|
1853
|
-
}
|
|
1854
1864
|
function is(e) {
|
|
1855
|
-
return e.replace(
|
|
1865
|
+
return e.replace(ts, Ye).replace(es, as).replace(At, `Bearer ${T}`).replace(St, `Basic ${T}`).replace(kt, T).replace(Et, (t, s) => `${s}: ${z}`);
|
|
1856
1866
|
}
|
|
1857
1867
|
function os(e) {
|
|
1858
|
-
|
|
1859
|
-
|
|
1868
|
+
return e.replace(At, `Bearer ${T}`).replace(St, `Basic ${T}`).replace(kt, T).replace(Et, (t, s) => `${s}: ${z}`);
|
|
1869
|
+
}
|
|
1870
|
+
function as(e) {
|
|
1871
|
+
const t = e.match(ss)?.[0] ?? "", s = t ? e.slice(0, -t.length) : e;
|
|
1872
|
+
return `${Rt(s)}${t}`;
|
|
1860
1873
|
}
|
|
1861
1874
|
export {
|
|
1862
1875
|
X as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
1863
1876
|
B as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1877
|
+
Ut as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
1878
|
+
bt as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
1879
|
+
Ct as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
1867
1880
|
ut as PlunoProductAgent,
|
|
1868
1881
|
ut as default
|
|
1869
1882
|
};
|