@pluno/product-agent-web 0.1.172 → 0.1.174
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 +175 -171
- package/dist/product-agent-widget.js +2702 -2569
- package/dist/widget.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const gs = "pluno-product-agent-attachments";
|
|
2
|
-
const
|
|
2
|
+
const $e = "files";
|
|
3
3
|
async function fs(t) {
|
|
4
|
-
const e = await
|
|
4
|
+
const e = await Je();
|
|
5
5
|
await Is(e, "readwrite", (s) => s.put(t));
|
|
6
6
|
}
|
|
7
7
|
async function ms(t, e) {
|
|
8
|
-
const s = await
|
|
9
|
-
await
|
|
10
|
-
const r = await
|
|
8
|
+
const s = await Je();
|
|
9
|
+
await Ye(s, "readwrite", async (n) => {
|
|
10
|
+
const r = await Qe(
|
|
11
11
|
n.get(t)
|
|
12
12
|
);
|
|
13
13
|
r && n.put({
|
|
@@ -17,27 +17,27 @@ async function ms(t, e) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
async function ys(t = 864e5) {
|
|
20
|
-
const e = await
|
|
21
|
-
await
|
|
20
|
+
const e = await Je(), s = Date.now() - t;
|
|
21
|
+
await Ye(e, "readwrite", async (n) => {
|
|
22
22
|
const r = n.index("lastUsedAt");
|
|
23
|
-
(await
|
|
23
|
+
(await Qe(r.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((o) => n.delete(o));
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Je() {
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
28
28
|
const s = indexedDB.open(gs, 1);
|
|
29
29
|
s.onupgradeneeded = () => {
|
|
30
|
-
const r = s.result.createObjectStore(
|
|
30
|
+
const r = s.result.createObjectStore($e, { keyPath: "attachmentId" });
|
|
31
31
|
r.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), r.createIndex("sessionId", "sessionId", { unique: !1 }), r.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, s.onsuccess = () => t(s.result), s.onerror = () => e(s.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
async function Is(t, e, s) {
|
|
36
|
-
return await
|
|
36
|
+
return await Ye(t, e, async (n) => await Qe(s(n)));
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ye(t, e, s) {
|
|
39
39
|
return new Promise((n, r) => {
|
|
40
|
-
const i = t.transaction(
|
|
40
|
+
const i = t.transaction($e, e), o = i.objectStore($e);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
s(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -57,7 +57,7 @@ function Je(t, e, s) {
|
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Qe(t) {
|
|
61
61
|
return new Promise((e, s) => {
|
|
62
62
|
t.onsuccess = () => e(t.result), t.onerror = () => s(t.error ?? new Error("Product Agent attachment storage request failed"));
|
|
63
63
|
});
|
|
@@ -135,11 +135,11 @@ function Es(t, e, s, n) {
|
|
|
135
135
|
return !i.isActivity || !i.isTransient ? !0 : e !== null && i.respondsToUserMessageId !== void 0 ? i.respondsToUserMessageId !== e : s === null || i.runId !== s;
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const ve = "pluno.productAgent.transportId", ks = "pluno.productAgent.transportIdentity", Oe = "pluno.productAgent.transportIdentity.event", Cs = 50, _s = globalThis.setTimeout.bind(globalThis);
|
|
139
139
|
let ne = null;
|
|
140
|
-
const fe = /* @__PURE__ */ new Set(),
|
|
140
|
+
const fe = /* @__PURE__ */ new Set(), Le = /* @__PURE__ */ new Map();
|
|
141
141
|
async function bs(t = xt()) {
|
|
142
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
142
|
+
const e = t.randomUUID(), s = t.storage.getItem(ve);
|
|
143
143
|
let n = s ?? t.randomUUID(), r = !1, i = !1;
|
|
144
144
|
const o = t.channel.subscribe((l) => {
|
|
145
145
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -157,14 +157,14 @@ async function bs(t = xt()) {
|
|
|
157
157
|
}
|
|
158
158
|
});
|
|
159
159
|
if (!s)
|
|
160
|
-
t.storage.setItem(
|
|
160
|
+
t.storage.setItem(ve, n), r = !0;
|
|
161
161
|
else
|
|
162
162
|
for (; ; ) {
|
|
163
163
|
if (i = !1, t.channel.postMessage({ type: "probe", transportId: n, senderId: e }), await t.settle(), !i) {
|
|
164
164
|
r = !0;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
167
|
+
n = t.randomUUID(), t.storage.setItem(ve, n);
|
|
168
168
|
}
|
|
169
169
|
let a = !1;
|
|
170
170
|
return {
|
|
@@ -210,13 +210,13 @@ function Ds() {
|
|
|
210
210
|
return {
|
|
211
211
|
getItem: (t) => {
|
|
212
212
|
try {
|
|
213
|
-
return window.sessionStorage?.getItem(t) ??
|
|
213
|
+
return window.sessionStorage?.getItem(t) ?? Le.get(t) ?? null;
|
|
214
214
|
} catch {
|
|
215
|
-
return
|
|
215
|
+
return Le.get(t) ?? null;
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
218
|
setItem: (t, e) => {
|
|
219
|
-
|
|
219
|
+
Le.set(t, e);
|
|
220
220
|
try {
|
|
221
221
|
window.sessionStorage?.setItem(t, e);
|
|
222
222
|
} catch {
|
|
@@ -240,7 +240,7 @@ function vs() {
|
|
|
240
240
|
}
|
|
241
241
|
function Os() {
|
|
242
242
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
243
|
-
if (s.key !==
|
|
243
|
+
if (s.key !== Oe || !s.newValue)
|
|
244
244
|
return;
|
|
245
245
|
const n = JSON.parse(s.newValue);
|
|
246
246
|
for (const r of t)
|
|
@@ -249,9 +249,9 @@ function Os() {
|
|
|
249
249
|
return window.addEventListener("storage", e), {
|
|
250
250
|
postMessage: (s) => {
|
|
251
251
|
window.localStorage.setItem(
|
|
252
|
-
|
|
252
|
+
Oe,
|
|
253
253
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
254
|
-
), window.localStorage.removeItem(
|
|
254
|
+
), window.localStorage.removeItem(Oe);
|
|
255
255
|
},
|
|
256
256
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
257
257
|
close: () => {
|
|
@@ -273,7 +273,7 @@ function Ls(t) {
|
|
|
273
273
|
const s = e;
|
|
274
274
|
return s.ok !== !0 || s.toolName !== Bt || typeof s.dueAt != "string" || Number.isNaN(Date.parse(s.dueAt)) ? null : s.dueAt;
|
|
275
275
|
}
|
|
276
|
-
const qs = globalThis.fetch.bind(globalThis),
|
|
276
|
+
const qs = globalThis.fetch.bind(globalThis), je = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Ns = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', xs = ".pluno-pa-widget__panel", Bs = ".pluno-pa-widget__timeline", ht = `${je}[data-pluno-sdk-preview-channel]`;
|
|
277
277
|
let Ws = 0;
|
|
278
278
|
function pt(t) {
|
|
279
279
|
const e = {};
|
|
@@ -313,7 +313,7 @@ function pt(t) {
|
|
|
313
313
|
}
|
|
314
314
|
return e;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function qe(t, e, s) {
|
|
317
317
|
if (typeof window > "u")
|
|
318
318
|
return;
|
|
319
319
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -338,7 +338,7 @@ const Hs = "https://app.pluno.ai", $s = "gpt-5.6-terra", js = 2e4, Fs = 1e4, zs
|
|
|
338
338
|
".pdf:application/pdf",
|
|
339
339
|
".png:image/png",
|
|
340
340
|
".webp:image/webp"
|
|
341
|
-
]), yi = ".pdf,.png,.jpg,.jpeg,.webp",
|
|
341
|
+
]), yi = ".pdf,.png,.jpg,.jpeg,.webp", Ze = 64e3, Ne = 4e3, et = 30, nn = 2e3, rn = 1e3, Ht = "Image is too large for model vision input.", on = 100, $t = "pluno.productAgent.state.", Fe = "pluno.productAgent.pendingEvents.", Re = "pluno.productAgent.activeToolCalls.", an = 100;
|
|
342
342
|
function ie(t, e = 0) {
|
|
343
343
|
const s = t === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (t - 1));
|
|
344
344
|
return Math.max(e, s);
|
|
@@ -642,7 +642,7 @@ class jt {
|
|
|
642
642
|
0
|
|
643
643
|
) > Wt))
|
|
644
644
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
645
|
-
let i = r.map(
|
|
645
|
+
let i = r.map(we);
|
|
646
646
|
if (!n && i.length === 0)
|
|
647
647
|
return null;
|
|
648
648
|
if (this.pendingClientMessageId)
|
|
@@ -708,8 +708,8 @@ class jt {
|
|
|
708
708
|
invocation: Pn(s.invocation ?? s.initiatedBy),
|
|
709
709
|
entrySurface: this.options.entrySurface,
|
|
710
710
|
content: n,
|
|
711
|
-
pageContent: T &&
|
|
712
|
-
attachments: i.length > 0 ? i : void 0,
|
|
711
|
+
pageContent: T && tt() || void 0,
|
|
712
|
+
attachments: i.length > 0 ? i.map(we) : void 0,
|
|
713
713
|
page: o,
|
|
714
714
|
model: this.options.model,
|
|
715
715
|
metadata: At(this.options.metadata)
|
|
@@ -736,7 +736,7 @@ class jt {
|
|
|
736
736
|
const s = j(), n = {
|
|
737
737
|
id: s,
|
|
738
738
|
name: e.name || "attachment",
|
|
739
|
-
mimeType:
|
|
739
|
+
mimeType: Ve(e),
|
|
740
740
|
sizeBytes: e.size
|
|
741
741
|
};
|
|
742
742
|
this.attachmentFiles.set(s, e);
|
|
@@ -770,7 +770,7 @@ class jt {
|
|
|
770
770
|
file: e,
|
|
771
771
|
attachment: s
|
|
772
772
|
}) {
|
|
773
|
-
const n = this.state.sessionId, r =
|
|
773
|
+
const n = this.state.sessionId, r = Ve(e), i = {
|
|
774
774
|
sessionId: n ?? void 0,
|
|
775
775
|
attachmentId: s.id,
|
|
776
776
|
clientId: this.options.clientId,
|
|
@@ -876,7 +876,7 @@ class jt {
|
|
|
876
876
|
stoppedCausalSequence: null,
|
|
877
877
|
toolCallIds: new Set(
|
|
878
878
|
this.state.messages.filter(
|
|
879
|
-
(s) =>
|
|
879
|
+
(s) => We(
|
|
880
880
|
s,
|
|
881
881
|
e.respondsToUserMessageId,
|
|
882
882
|
e.runId
|
|
@@ -1028,7 +1028,7 @@ class jt {
|
|
|
1028
1028
|
return !1;
|
|
1029
1029
|
const s = this.socket;
|
|
1030
1030
|
try {
|
|
1031
|
-
return s.send(JSON.stringify(e)),
|
|
1031
|
+
return s.send(JSON.stringify(e)), qe("client_event", e.type, pt(e)), !0;
|
|
1032
1032
|
} catch (n) {
|
|
1033
1033
|
return A("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
1034
1034
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -1169,7 +1169,7 @@ class jt {
|
|
|
1169
1169
|
stoppedCausalSequence: v(s),
|
|
1170
1170
|
toolCallIds: new Set(
|
|
1171
1171
|
this.state.messages.filter(
|
|
1172
|
-
(a) =>
|
|
1172
|
+
(a) => We(a, r, i)
|
|
1173
1173
|
).map((a) => a.callId).filter((a) => typeof a == "string")
|
|
1174
1174
|
)
|
|
1175
1175
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
@@ -1198,7 +1198,7 @@ class jt {
|
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
1200
|
handleServerEvent(e) {
|
|
1201
|
-
if (
|
|
1201
|
+
if (qe("server_event", e.type, pt(e)), e.type === "session.item" && this.rememberDurablyStoppedTurn(
|
|
1202
1202
|
S(e.item, "sessionId") ?? this.state.sessionId,
|
|
1203
1203
|
P(e.item),
|
|
1204
1204
|
S(e.item, "createdAt")
|
|
@@ -1303,7 +1303,7 @@ class jt {
|
|
|
1303
1303
|
}
|
|
1304
1304
|
const T = c.filter((E) => {
|
|
1305
1305
|
const O = P(E);
|
|
1306
|
-
return bt(O) ? !1 : !O || !g || !Se(O) ? !0 :
|
|
1306
|
+
return bt(O) ? !1 : !O || !g || !Se(O) ? !0 : Ge(c, O) !== g;
|
|
1307
1307
|
}), k = dr(
|
|
1308
1308
|
this.state.messages,
|
|
1309
1309
|
Ct(T, this.options.backendUrl)
|
|
@@ -1320,11 +1320,11 @@ class jt {
|
|
|
1320
1320
|
ee,
|
|
1321
1321
|
Mr(c, O)
|
|
1322
1322
|
)
|
|
1323
|
-
), te = d ? u?.content ?? "" : this.state.assistantDraft, z = !!u?.content && !C, H = w && (!te || C), K = yr(m),
|
|
1323
|
+
), te = d ? u?.content ?? "" : this.state.assistantDraft, z = !!u?.content && !C, H = w && (!te || C), K = yr(m), V = H && K ? "completed" : l ? "stopped" : H ? "failed" : null;
|
|
1324
1324
|
if (!w && Tr(this.state.messages, c))
|
|
1325
1325
|
return;
|
|
1326
1326
|
this.lastUserMessagePageUrl = Ir(c);
|
|
1327
|
-
const q = H || l ? null :
|
|
1327
|
+
const q = H || l ? null : Ke(c);
|
|
1328
1328
|
if (this.latestRecoverableClientMessageId = q, K && this.clearRetryTimers(), this.setState({
|
|
1329
1329
|
sessionId: S(e.session, "id") ?? this.state.sessionId,
|
|
1330
1330
|
messages: m,
|
|
@@ -1334,7 +1334,7 @@ class jt {
|
|
|
1334
1334
|
...h ? { pendingMessageStatus: h } : {},
|
|
1335
1335
|
...f ? { turnPhase: f } : {},
|
|
1336
1336
|
isRetrying: I,
|
|
1337
|
-
...
|
|
1337
|
+
...V && this.state.taskStatus === "working" ? { taskStatus: V } : {},
|
|
1338
1338
|
...C ? {
|
|
1339
1339
|
assistantDraft: "",
|
|
1340
1340
|
assistantDraftItemId: null,
|
|
@@ -1444,7 +1444,7 @@ class jt {
|
|
|
1444
1444
|
if (n) {
|
|
1445
1445
|
const r = Cr(s, n), i = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
1446
1446
|
n.callId && i !== void 0 && (n.loading = i, this.pendingToolLoadingByCallId.delete(n.callId)), B(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Rr(s) && this.clearRunAckResyncRetryTimer();
|
|
1447
|
-
const o =
|
|
1447
|
+
const o = ze(this.state.messages, n), a = _t(o), l = Pt(
|
|
1448
1448
|
s,
|
|
1449
1449
|
this.state.assistantDraft,
|
|
1450
1450
|
this.state.assistantDraftItemId,
|
|
@@ -1483,7 +1483,7 @@ class jt {
|
|
|
1483
1483
|
this.clearRunAckResyncRetryTimer();
|
|
1484
1484
|
const s = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, r = n !== null && this.state.assistantDraftItemId !== n, i = `${r ? "" : this.state.assistantDraft}${s}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((p) => p.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : r ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, h = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
1485
1485
|
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = h), this.setState({
|
|
1486
|
-
messages:
|
|
1486
|
+
messages: ze(this.state.messages, {
|
|
1487
1487
|
id: o,
|
|
1488
1488
|
role: "assistant",
|
|
1489
1489
|
content: i,
|
|
@@ -1514,7 +1514,7 @@ class jt {
|
|
|
1514
1514
|
return;
|
|
1515
1515
|
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !r || r === this.activeResponseRunId), l = Es(
|
|
1516
1516
|
this.state.messages.filter(
|
|
1517
|
-
(c) => c.dataType !== "assistant_draft" || !
|
|
1517
|
+
(c) => c.dataType !== "assistant_draft" || !We(
|
|
1518
1518
|
c,
|
|
1519
1519
|
n,
|
|
1520
1520
|
r
|
|
@@ -1956,7 +1956,7 @@ class jt {
|
|
|
1956
1956
|
}) : (!this.socket || this.socket.readyState !== WebSocket.OPEN) && (this.setReconnectingState(), this.scheduleReconnect());
|
|
1957
1957
|
}
|
|
1958
1958
|
async executeToolCall(e) {
|
|
1959
|
-
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i =
|
|
1959
|
+
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, r = typeof e.toolName == "string" ? e.toolName : null, i = Y(
|
|
1960
1960
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
1961
1961
|
), o = e.rawInput;
|
|
1962
1962
|
if (!s || !n || !r)
|
|
@@ -2134,7 +2134,7 @@ class jt {
|
|
|
2134
2134
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
2135
2135
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
2136
2136
|
};
|
|
2137
|
-
this.state = o, Nr(this.options.clientId, this.state), this.emit("state", this.getState()),
|
|
2137
|
+
this.state = o, Nr(this.options.clientId, this.state), this.emit("state", this.getState()), qe("state", this.state.status, {
|
|
2138
2138
|
status: this.state.status,
|
|
2139
2139
|
sessionId: this.state.sessionId,
|
|
2140
2140
|
messageCount: this.state.messages.length,
|
|
@@ -2156,7 +2156,7 @@ class jt {
|
|
|
2156
2156
|
this.listeners[e]?.forEach((r) => r(s));
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
|
-
const
|
|
2159
|
+
const xe = /* @__PURE__ */ new WeakMap();
|
|
2160
2160
|
function un(t) {
|
|
2161
2161
|
const e = window.__plunoProductAgentNetworkCapture ?? dn();
|
|
2162
2162
|
return e.subscribers.add(t), () => {
|
|
@@ -2181,10 +2181,10 @@ function dn() {
|
|
|
2181
2181
|
}
|
|
2182
2182
|
try {
|
|
2183
2183
|
const T = f instanceof Request ? f : null, k = Jr(f, T), m = is(u?.headers ?? T?.headers);
|
|
2184
|
-
if (!
|
|
2184
|
+
if (!J(k, m, u?.body)) {
|
|
2185
2185
|
const U = {
|
|
2186
|
-
requestId:
|
|
2187
|
-
url: x(k,
|
|
2186
|
+
requestId: He("fetch"),
|
|
2187
|
+
url: x(k, Ne),
|
|
2188
2188
|
method: (u?.method ?? T?.method ?? "GET").toUpperCase(),
|
|
2189
2189
|
requestHeaders: m,
|
|
2190
2190
|
requestBody: Lt(u?.body),
|
|
@@ -2215,22 +2215,22 @@ function dn() {
|
|
|
2215
2215
|
return g;
|
|
2216
2216
|
}, a = function(f, u, d, g, T) {
|
|
2217
2217
|
const k = n.call(this, f, u, d ?? !0, g ?? void 0, T ?? void 0), m = typeof u == "string" ? u : u.toString();
|
|
2218
|
-
return
|
|
2219
|
-
requestId:
|
|
2218
|
+
return xe.set(this, {
|
|
2219
|
+
requestId: He("xhr"),
|
|
2220
2220
|
method: String(f ?? "GET").toUpperCase(),
|
|
2221
|
-
url: x(m,
|
|
2221
|
+
url: x(m, Ne),
|
|
2222
2222
|
requestHeaders: {},
|
|
2223
2223
|
startedAtMs: Date.now(),
|
|
2224
2224
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2225
|
-
excluded:
|
|
2225
|
+
excluded: J(m)
|
|
2226
2226
|
}), k;
|
|
2227
2227
|
}, l = function(f, u) {
|
|
2228
|
-
const d = r.call(this, f, u), g =
|
|
2229
|
-
return g && Object.keys(g.requestHeaders).length <
|
|
2228
|
+
const d = r.call(this, f, u), g = xe.get(this);
|
|
2229
|
+
return g && Object.keys(g.requestHeaders).length < et && (g.requestHeaders[f] = nt(f, u), g.excluded = g.excluded || J(g.url, g.requestHeaders)), d;
|
|
2230
2230
|
}, c = function(f) {
|
|
2231
2231
|
try {
|
|
2232
|
-
const u =
|
|
2233
|
-
u && (u.excluded = u.excluded ||
|
|
2232
|
+
const u = xe.get(this);
|
|
2233
|
+
u && (u.excluded = u.excluded || J(u.url, u.requestHeaders, f), u.requestBody = Lt(f), u.excluded || this.addEventListener(
|
|
2234
2234
|
"loadend",
|
|
2235
2235
|
() => {
|
|
2236
2236
|
queueMicrotask(() => {
|
|
@@ -2282,12 +2282,12 @@ function dn() {
|
|
|
2282
2282
|
h = new PerformanceObserver((I) => {
|
|
2283
2283
|
for (const f of I.getEntries()) {
|
|
2284
2284
|
const u = f;
|
|
2285
|
-
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" ||
|
|
2285
|
+
if (u.initiatorType === "fetch" || u.initiatorType === "xmlhttprequest" || J(u.name))
|
|
2286
2286
|
continue;
|
|
2287
2287
|
const d = performance.timeOrigin + u.startTime;
|
|
2288
2288
|
e({
|
|
2289
|
-
requestId:
|
|
2290
|
-
url: x(u.name,
|
|
2289
|
+
requestId: He("resource"),
|
|
2290
|
+
url: x(u.name, Ne),
|
|
2291
2291
|
method: "GET",
|
|
2292
2292
|
resourceType: "resource",
|
|
2293
2293
|
responseStatus: u.responseStatus,
|
|
@@ -2374,7 +2374,7 @@ function mn() {
|
|
|
2374
2374
|
};
|
|
2375
2375
|
}
|
|
2376
2376
|
function yn() {
|
|
2377
|
-
return Nt(globalThis, "getPageSnapshot", async () =>
|
|
2377
|
+
return Nt(globalThis, "getPageSnapshot", async () => tt());
|
|
2378
2378
|
}
|
|
2379
2379
|
function In() {
|
|
2380
2380
|
return Nt(globalThis, "pageImages", {
|
|
@@ -2599,7 +2599,7 @@ function vn() {
|
|
|
2599
2599
|
return {
|
|
2600
2600
|
pageUrl: location.href,
|
|
2601
2601
|
pageTitle: document.title,
|
|
2602
|
-
htmlContent:
|
|
2602
|
+
htmlContent: tt()
|
|
2603
2603
|
};
|
|
2604
2604
|
}
|
|
2605
2605
|
function On(t) {
|
|
@@ -2625,11 +2625,11 @@ function Ln() {
|
|
|
2625
2625
|
function de() {
|
|
2626
2626
|
return Gt()?.surface === "browser_extension_sdk_preview";
|
|
2627
2627
|
}
|
|
2628
|
-
function
|
|
2628
|
+
function tt() {
|
|
2629
2629
|
if (!document.body)
|
|
2630
2630
|
return "";
|
|
2631
2631
|
const t = [], e = [], s = (d, g) => {
|
|
2632
|
-
const T =
|
|
2632
|
+
const T = Q(g);
|
|
2633
2633
|
!T || e.includes(T) || (t.push([d, T]), e.push(T));
|
|
2634
2634
|
};
|
|
2635
2635
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
@@ -2637,9 +2637,9 @@ function et() {
|
|
|
2637
2637
|
(d) => Ft(d) && !d.parentElement?.closest(n)
|
|
2638
2638
|
);
|
|
2639
2639
|
for (const d of r.slice(0, 3))
|
|
2640
|
-
s("Active overlay",
|
|
2641
|
-
const i = qn(), o = i ?
|
|
2642
|
-
s("Main page content", o), s("Additional visible page text",
|
|
2640
|
+
s("Active overlay", Be(oe(d), e));
|
|
2641
|
+
const i = qn(), o = i ? Be(oe(i), e) : "";
|
|
2642
|
+
s("Main page content", o), s("Additional visible page text", Be(oe(document.body), e));
|
|
2643
2643
|
const a = t.map(([d, g]) => `${d}:
|
|
2644
2644
|
${g}`).join(`
|
|
2645
2645
|
|
|
@@ -2653,7 +2653,7 @@ Visible page text:
|
|
|
2653
2653
|
function oe(t) {
|
|
2654
2654
|
return t.innerText ?? t.textContent ?? "";
|
|
2655
2655
|
}
|
|
2656
|
-
function
|
|
2656
|
+
function Q(t) {
|
|
2657
2657
|
return (t ?? "").replace(/\u00a0/g, " ").replace(/\r\n?/g, `
|
|
2658
2658
|
`).split(`
|
|
2659
2659
|
`).map((e) => e.replace(/[ \t]+/g, " ").trim()).join(`
|
|
@@ -2661,11 +2661,11 @@ function Y(t) {
|
|
|
2661
2661
|
|
|
2662
2662
|
`).trim();
|
|
2663
2663
|
}
|
|
2664
|
-
function
|
|
2665
|
-
let s =
|
|
2664
|
+
function Be(t, e) {
|
|
2665
|
+
let s = Q(t);
|
|
2666
2666
|
for (const n of e)
|
|
2667
2667
|
s = s.replace(n, "");
|
|
2668
|
-
return
|
|
2668
|
+
return Q(s);
|
|
2669
2669
|
}
|
|
2670
2670
|
function Ft(t) {
|
|
2671
2671
|
const e = window.getComputedStyle(t);
|
|
@@ -2769,60 +2769,60 @@ function Nn(t, e) {
|
|
|
2769
2769
|
if (f >= 1e3 && !z || U.has(R) || i.has(C) || R.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || te.display === "none" || te.visibility === "hidden")
|
|
2770
2770
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
2771
2771
|
f += 1;
|
|
2772
|
-
const H = u(R), K = Kt(R), rt = a.has(H) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && R.hasAttribute("href"),
|
|
2773
|
-
for (const y of
|
|
2772
|
+
const H = u(R), K = Kt(R), rt = a.has(H) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(C) || C === "a" && R.hasAttribute("href"), V = Array.from(R.children).filter((y) => y instanceof HTMLElement), q = /* @__PURE__ */ new Map();
|
|
2773
|
+
for (const y of V) {
|
|
2774
2774
|
const M = d(y);
|
|
2775
2775
|
q.set(M, (q.get(M) ?? 0) + 1);
|
|
2776
2776
|
}
|
|
2777
2777
|
const E = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
|
|
2778
|
-
for (const y of
|
|
2778
|
+
for (const y of V) {
|
|
2779
2779
|
const M = d(y), $ = O.get(M) ?? 0;
|
|
2780
2780
|
O.set(M, $ + 1), (q.get(M) ?? 0) > 8 && $ >= 6 && !h.has(y) && E.set(M, (E.get(M) ?? 0) + 1);
|
|
2781
2781
|
}
|
|
2782
|
-
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(),
|
|
2783
|
-
for (const y of
|
|
2782
|
+
const it = /* @__PURE__ */ new Map(), ot = /* @__PURE__ */ new Set(), Ce = [], at = [];
|
|
2783
|
+
for (const y of V) {
|
|
2784
2784
|
const M = d(y), $ = q.get(M) ?? 0, ut = it.get(M) ?? 0;
|
|
2785
2785
|
if (it.set(M, ut + 1), $ > 8 && ut >= 6 && !h.has(y)) {
|
|
2786
|
-
ot.has(M) || (
|
|
2786
|
+
ot.has(M) || (Ce.push([`… ${E.get(M) ?? 0} similar siblings omitted`]), ot.add(M));
|
|
2787
2787
|
continue;
|
|
2788
2788
|
}
|
|
2789
2789
|
const dt = D(y, ee);
|
|
2790
|
-
at.push(dt),
|
|
2790
|
+
at.push(dt), Ce.push(dt.lines);
|
|
2791
2791
|
}
|
|
2792
|
-
const
|
|
2792
|
+
const _e = [];
|
|
2793
2793
|
if (R.shadowRoot)
|
|
2794
2794
|
for (const y of Array.from(R.shadowRoot.children))
|
|
2795
|
-
y instanceof HTMLElement &&
|
|
2796
|
-
const le = [...at, ...
|
|
2795
|
+
y instanceof HTMLElement && _e.push(D(y, ee + 1));
|
|
2796
|
+
const le = [...at, ..._e], be = K.length > 0 || rt || le.some((y) => y.hasUsefulContent), lt = Q(
|
|
2797
2797
|
[K, ...le.map((y) => y.textPreview)].filter(Boolean).join(" ")
|
|
2798
|
-
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (K.length > 0 || !R.querySelector("[contenteditable]")), ct = c.some((y) => R.hasAttribute(y)) || !!H || ps,
|
|
2799
|
-
if (
|
|
2798
|
+
).slice(0, 180), ps = R.hasAttribute("contenteditable") && (K.length > 0 || !R.querySelector("[contenteditable]")), ct = c.some((y) => R.hasAttribute(y)) || !!H || ps, Pe = (R.getClientRects().length > 0 || te.display === "contents") && (s.has(C) || ct || z) && (be || z) && (!r.has(C) || be || ct || z), Ue = Pe ? 1 : 0, se = [];
|
|
2799
|
+
if (Pe) {
|
|
2800
2800
|
const y = le.some(($) => $.containsTextElement), M = n.has(C) && !y ? lt : K;
|
|
2801
2801
|
se.push(zt(R, l, o, M.slice(0, 180)));
|
|
2802
2802
|
}
|
|
2803
|
-
for (const y of
|
|
2804
|
-
se.push(...he(y,
|
|
2805
|
-
const
|
|
2806
|
-
if (
|
|
2807
|
-
const y =
|
|
2808
|
-
|
|
2803
|
+
for (const y of Ce)
|
|
2804
|
+
se.push(...he(y, Ue));
|
|
2805
|
+
const De = _e.flatMap((y) => y.lines);
|
|
2806
|
+
if (De.length > 0) {
|
|
2807
|
+
const y = De.slice(0, 20);
|
|
2808
|
+
De.length > y.length && y.push("… shadow DOM omitted");
|
|
2809
2809
|
const M = C.includes("tooltip") || C.includes("popper") || C.includes("loader");
|
|
2810
2810
|
if (ee < 2 && !M) {
|
|
2811
|
-
const $ =
|
|
2812
|
-
se.push(...he([$, ...he(y, 1)],
|
|
2811
|
+
const $ = Pe ? "#shadow-root" : `${C} #shadow-root`;
|
|
2812
|
+
se.push(...he([$, ...he(y, 1)], Ue));
|
|
2813
2813
|
} else
|
|
2814
|
-
se.push(...he(y,
|
|
2814
|
+
se.push(...he(y, Ue));
|
|
2815
2815
|
}
|
|
2816
2816
|
return {
|
|
2817
2817
|
lines: se,
|
|
2818
|
-
hasUsefulContent:
|
|
2818
|
+
hasUsefulContent: be,
|
|
2819
2819
|
textPreview: lt,
|
|
2820
2820
|
containsTextElement: n.has(C) || le.some((y) => y.containsTextElement)
|
|
2821
2821
|
};
|
|
2822
2822
|
};
|
|
2823
2823
|
return [`--- ${w} ---`, ...D(m, 0).lines].join(`
|
|
2824
2824
|
`);
|
|
2825
|
-
}, T = [], k =
|
|
2825
|
+
}, T = [], k = Q(window.getSelection()?.toString() ?? "");
|
|
2826
2826
|
k && T.push(`--- selected text ---
|
|
2827
2827
|
${JSON.stringify(k)}`), p.length > 0 && T.push(Bn(p, s, l, o));
|
|
2828
2828
|
for (const m of t.slice(0, 3))
|
|
@@ -2927,7 +2927,7 @@ function he(t, e) {
|
|
|
2927
2927
|
return t.map((n) => `${s}${n}`);
|
|
2928
2928
|
}
|
|
2929
2929
|
function Kt(t) {
|
|
2930
|
-
return
|
|
2930
|
+
return Q(
|
|
2931
2931
|
Array.from(t.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
2932
2932
|
);
|
|
2933
2933
|
}
|
|
@@ -2936,7 +2936,7 @@ function Wn(t) {
|
|
|
2936
2936
|
}
|
|
2937
2937
|
function Gt() {
|
|
2938
2938
|
const t = document.querySelector(ht);
|
|
2939
|
-
if (!(t ?? document.querySelector(
|
|
2939
|
+
if (!(t ?? document.querySelector(je)))
|
|
2940
2940
|
return;
|
|
2941
2941
|
const s = t ? "browser_extension_sdk_preview" : "embedded_widget";
|
|
2942
2942
|
return {
|
|
@@ -2945,7 +2945,7 @@ function Gt() {
|
|
|
2945
2945
|
selectors: [
|
|
2946
2946
|
{
|
|
2947
2947
|
name: "widget_host",
|
|
2948
|
-
selector: s === "browser_extension_sdk_preview" ? ht :
|
|
2948
|
+
selector: s === "browser_extension_sdk_preview" ? ht : je,
|
|
2949
2949
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
2950
2950
|
},
|
|
2951
2951
|
{
|
|
@@ -3048,7 +3048,7 @@ function Vn(t) {
|
|
|
3048
3048
|
} : null;
|
|
3049
3049
|
}
|
|
3050
3050
|
function Ct(t, e) {
|
|
3051
|
-
return Array.isArray(t) ?
|
|
3051
|
+
return Array.isArray(t) ? Xe(
|
|
3052
3052
|
t.map((s) => Xt(s, e)).filter((s) => s !== null)
|
|
3053
3053
|
) : [];
|
|
3054
3054
|
}
|
|
@@ -3229,18 +3229,18 @@ function tr(t) {
|
|
|
3229
3229
|
}
|
|
3230
3230
|
function sr(t) {
|
|
3231
3231
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
3232
|
-
return
|
|
3232
|
+
return Y(t.summary);
|
|
3233
3233
|
if (typeof t.arguments == "string")
|
|
3234
3234
|
try {
|
|
3235
3235
|
const e = JSON.parse(t.arguments);
|
|
3236
3236
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
3237
|
-
return
|
|
3237
|
+
return Y(e.summary);
|
|
3238
3238
|
} catch {
|
|
3239
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3239
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? Y(t.name) : "🛠️ Run tool";
|
|
3240
3240
|
}
|
|
3241
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
3241
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? Y(t.name) : "🛠️ Run tool";
|
|
3242
3242
|
}
|
|
3243
|
-
function
|
|
3243
|
+
function Y(t) {
|
|
3244
3244
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
3245
3245
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
3246
3246
|
}
|
|
@@ -3274,7 +3274,7 @@ function rr(t) {
|
|
|
3274
3274
|
return typeof s.text == "string" ? s.text : typeof s.content == "string" ? s.content : "";
|
|
3275
3275
|
}).filter(Boolean).join("") : "";
|
|
3276
3276
|
}
|
|
3277
|
-
function
|
|
3277
|
+
function ze(t, e) {
|
|
3278
3278
|
const s = Jt(t, e), n = ur(
|
|
3279
3279
|
ir(
|
|
3280
3280
|
fr(t, e),
|
|
@@ -3283,11 +3283,11 @@ function Fe(t, e) {
|
|
|
3283
3283
|
s
|
|
3284
3284
|
), r = n.findIndex((o) => o.id === s.id);
|
|
3285
3285
|
if (r === -1)
|
|
3286
|
-
return
|
|
3286
|
+
return Xe(
|
|
3287
3287
|
[...n, s]
|
|
3288
3288
|
);
|
|
3289
3289
|
const i = [...n];
|
|
3290
|
-
return i[r] = s,
|
|
3290
|
+
return i[r] = s, Xe(i);
|
|
3291
3291
|
}
|
|
3292
3292
|
function ir(t, e) {
|
|
3293
3293
|
const s = e.assistantDraftItemId;
|
|
@@ -3295,7 +3295,7 @@ function ir(t, e) {
|
|
|
3295
3295
|
(n) => n.dataType === "assistant_draft" && n.id === s ? e : n
|
|
3296
3296
|
) : t;
|
|
3297
3297
|
}
|
|
3298
|
-
function
|
|
3298
|
+
function We(t, e, s) {
|
|
3299
3299
|
return e !== null ? t.respondsToUserMessageId === e : s !== null && t.runId === s;
|
|
3300
3300
|
}
|
|
3301
3301
|
function or(t, e, s, n) {
|
|
@@ -3320,7 +3320,7 @@ function ar(t, e) {
|
|
|
3320
3320
|
(r) => !r.id.startsWith("transient-activity:") && r.callId === e.callId
|
|
3321
3321
|
);
|
|
3322
3322
|
if (s === -1)
|
|
3323
|
-
return
|
|
3323
|
+
return ze(t, e);
|
|
3324
3324
|
const n = [...t];
|
|
3325
3325
|
return n[s] = {
|
|
3326
3326
|
...n[s],
|
|
@@ -3344,7 +3344,7 @@ function cr(t) {
|
|
|
3344
3344
|
return !e || !s ? null : {
|
|
3345
3345
|
id: `transient-activity:${e}`,
|
|
3346
3346
|
role: "tool",
|
|
3347
|
-
content:
|
|
3347
|
+
content: Y(
|
|
3348
3348
|
typeof t.summary == "string" ? t.summary : "Running browser tool"
|
|
3349
3349
|
),
|
|
3350
3350
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3383,7 +3383,7 @@ function hr(t, e, s) {
|
|
|
3383
3383
|
];
|
|
3384
3384
|
}
|
|
3385
3385
|
function Vt(t) {
|
|
3386
|
-
const e =
|
|
3386
|
+
const e = X(t) ?? void 0, s = t.assistantDraftItemId, n = [
|
|
3387
3387
|
...t.callId ? [`call:${t.callId}`] : [],
|
|
3388
3388
|
...t.runId && (t.toolName === "browser_tabs" || t.toolName === "tab_lifecycle") ? [`tab-lifecycle:${t.runId}`] : []
|
|
3389
3389
|
];
|
|
@@ -3394,7 +3394,7 @@ function Vt(t) {
|
|
|
3394
3394
|
...n.length > 0 ? { activityKeys: n } : {},
|
|
3395
3395
|
...t.respondsToUserMessageId ? { respondsToUserMessageId: t.respondsToUserMessageId } : {},
|
|
3396
3396
|
...t.runId ? { runId: t.runId } : {},
|
|
3397
|
-
isOptimistic:
|
|
3397
|
+
isOptimistic: Ee(t),
|
|
3398
3398
|
isAssistantDraft: t.dataType === "assistant_draft",
|
|
3399
3399
|
isActivity: t.role === "tool" || t.phase === "commentary" || t.dataType === "assistant_draft",
|
|
3400
3400
|
isTransient: t.id.startsWith("transient-activity:") || t.dataType === "assistant_draft"
|
|
@@ -3404,15 +3404,18 @@ function Jt(t, e) {
|
|
|
3404
3404
|
if (e.role !== "user" || !e.attachments?.length)
|
|
3405
3405
|
return e;
|
|
3406
3406
|
const s = t.find(
|
|
3407
|
-
(
|
|
3407
|
+
(o) => o.role === "user" && (o.id === e.id || Ee(o) && Yt(o, e))
|
|
3408
3408
|
);
|
|
3409
3409
|
if (!s?.attachments?.length)
|
|
3410
3410
|
return e;
|
|
3411
|
-
const n = e.attachments.map((
|
|
3412
|
-
const
|
|
3413
|
-
return
|
|
3414
|
-
});
|
|
3415
|
-
return
|
|
3411
|
+
const n = e.attachments.map((o) => {
|
|
3412
|
+
const a = pr(s.attachments ?? [], o);
|
|
3413
|
+
return a ? gr(o, a) : o;
|
|
3414
|
+
}), r = { ...e, attachments: n }, i = X(e);
|
|
3415
|
+
return i && Object.defineProperty(r, "clientMessageId", {
|
|
3416
|
+
value: i,
|
|
3417
|
+
enumerable: !1
|
|
3418
|
+
}), r;
|
|
3416
3419
|
}
|
|
3417
3420
|
function pr(t, e) {
|
|
3418
3421
|
return e.id ? t.find((s) => s.id === e.id) ?? null : null;
|
|
@@ -3425,7 +3428,7 @@ function fr(t, e) {
|
|
|
3425
3428
|
if (e.role !== "user")
|
|
3426
3429
|
return t;
|
|
3427
3430
|
const s = t.findIndex(
|
|
3428
|
-
(r) =>
|
|
3431
|
+
(r) => Ee(r) && Yt(r, e)
|
|
3429
3432
|
);
|
|
3430
3433
|
if (s === -1)
|
|
3431
3434
|
return t;
|
|
@@ -3433,13 +3436,13 @@ function fr(t, e) {
|
|
|
3433
3436
|
return n.splice(s, 1), n;
|
|
3434
3437
|
}
|
|
3435
3438
|
function Yt(t, e) {
|
|
3436
|
-
const s =
|
|
3439
|
+
const s = X(t), n = X(e);
|
|
3437
3440
|
return s && n ? s === n : t.content === e.content;
|
|
3438
3441
|
}
|
|
3439
|
-
function
|
|
3442
|
+
function Ee(t) {
|
|
3440
3443
|
return t.role === "user" && (t.id.startsWith("local-") || t.id.startsWith("optimistic-user-message:"));
|
|
3441
3444
|
}
|
|
3442
|
-
function
|
|
3445
|
+
function X(t) {
|
|
3443
3446
|
const e = t.clientMessageId;
|
|
3444
3447
|
if (e)
|
|
3445
3448
|
return e;
|
|
@@ -3475,7 +3478,7 @@ function _t(t) {
|
|
|
3475
3478
|
function mr(t, e, s) {
|
|
3476
3479
|
const n = new Set(
|
|
3477
3480
|
t.filter(
|
|
3478
|
-
(r) => r.role === "user" && e !== null &&
|
|
3481
|
+
(r) => r.role === "user" && e !== null && X(r) === e
|
|
3479
3482
|
).map((r) => r.id)
|
|
3480
3483
|
);
|
|
3481
3484
|
return t.some((r, i) => {
|
|
@@ -3503,7 +3506,7 @@ function yr(t) {
|
|
|
3503
3506
|
}
|
|
3504
3507
|
function Qt(t) {
|
|
3505
3508
|
for (let e = t.length - 1; e >= 0; e -= 1)
|
|
3506
|
-
if (t[e].role === "user" && !
|
|
3509
|
+
if (t[e].role === "user" && !Ee(t[e]))
|
|
3507
3510
|
return e;
|
|
3508
3511
|
return null;
|
|
3509
3512
|
}
|
|
@@ -3558,7 +3561,7 @@ function Tr(t, e) {
|
|
|
3558
3561
|
(o) => o.respondsToUserMessageId === r && Te(o)
|
|
3559
3562
|
) : t.slice(i + 1).some(Te);
|
|
3560
3563
|
}
|
|
3561
|
-
function
|
|
3564
|
+
function Ke(t) {
|
|
3562
3565
|
const e = Z(t);
|
|
3563
3566
|
if (e === null)
|
|
3564
3567
|
return null;
|
|
@@ -3586,13 +3589,13 @@ function Sr(t) {
|
|
|
3586
3589
|
if (i.type === "message" && i.role === "assistant")
|
|
3587
3590
|
return null;
|
|
3588
3591
|
if (i.type === "run_error")
|
|
3589
|
-
return i.retryable !== !0 ? null :
|
|
3592
|
+
return i.retryable !== !0 ? null : Ge(t, i) ?? Ke(t);
|
|
3590
3593
|
if (i.type === "run_status")
|
|
3591
|
-
return i.status === "interrupted" && i.retryable === !0 ?
|
|
3594
|
+
return i.status === "interrupted" && i.retryable === !0 ? Ge(t, i) ?? Ke(t) : null;
|
|
3592
3595
|
}
|
|
3593
3596
|
return null;
|
|
3594
3597
|
}
|
|
3595
|
-
function
|
|
3598
|
+
function Ge(t, e) {
|
|
3596
3599
|
if (typeof e.clientMessageId == "string")
|
|
3597
3600
|
return e.clientMessageId;
|
|
3598
3601
|
const s = N(e);
|
|
@@ -3652,7 +3655,7 @@ function Rr(t) {
|
|
|
3652
3655
|
const e = t;
|
|
3653
3656
|
return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
|
|
3654
3657
|
}
|
|
3655
|
-
function
|
|
3658
|
+
function Xe(t) {
|
|
3656
3659
|
return t.filter((e, s) => F(e) ? !Lr(t, s) && !es(t, s) && !vr(t, s) && !Or(t, s) : Er(e) ? e.retryable === !0 && Dr(t, s) ? !1 : !Ur(t, s) : !0);
|
|
3657
3660
|
}
|
|
3658
3661
|
function Er(t) {
|
|
@@ -3668,7 +3671,7 @@ function kr(t, e, s, n) {
|
|
|
3668
3671
|
(l) => l.role === "user" && l.id === o
|
|
3669
3672
|
) : null;
|
|
3670
3673
|
return {
|
|
3671
|
-
clientMessageId: a ?
|
|
3674
|
+
clientMessageId: a ? X(a) : o ? null : n,
|
|
3672
3675
|
respondsToUserMessageId: o,
|
|
3673
3676
|
runId: s ?? i?.runId ?? null
|
|
3674
3677
|
};
|
|
@@ -3682,7 +3685,7 @@ function Cr(t, e) {
|
|
|
3682
3685
|
function Ut(t, e, s) {
|
|
3683
3686
|
const n = new Set(
|
|
3684
3687
|
t.filter(
|
|
3685
|
-
(r) => r.role === "user" && e !== null &&
|
|
3688
|
+
(r) => r.role === "user" && e !== null && X(r) === e
|
|
3686
3689
|
).map((r) => r.id)
|
|
3687
3690
|
);
|
|
3688
3691
|
return t.filter(
|
|
@@ -3807,24 +3810,24 @@ function Nr(t, e) {
|
|
|
3807
3810
|
}
|
|
3808
3811
|
function xr(t) {
|
|
3809
3812
|
try {
|
|
3810
|
-
const e = window.localStorage.getItem(`${
|
|
3813
|
+
const e = window.localStorage.getItem(`${Fe}${t}`);
|
|
3811
3814
|
if (!e)
|
|
3812
3815
|
return [];
|
|
3813
3816
|
const s = JSON.parse(e);
|
|
3814
|
-
return Array.isArray(s) ? s.filter(
|
|
3817
|
+
return Array.isArray(s) ? s.filter(st) : [];
|
|
3815
3818
|
} catch {
|
|
3816
3819
|
return [];
|
|
3817
3820
|
}
|
|
3818
3821
|
}
|
|
3819
3822
|
function G(t, e) {
|
|
3820
3823
|
try {
|
|
3821
|
-
const s = e.filter(
|
|
3824
|
+
const s = e.filter(st);
|
|
3822
3825
|
if (s.length === 0) {
|
|
3823
|
-
window.localStorage.removeItem(`${
|
|
3826
|
+
window.localStorage.removeItem(`${Fe}${t}`);
|
|
3824
3827
|
return;
|
|
3825
3828
|
}
|
|
3826
3829
|
window.localStorage.setItem(
|
|
3827
|
-
`${
|
|
3830
|
+
`${Fe}${t}`,
|
|
3828
3831
|
JSON.stringify(s.slice(-25))
|
|
3829
3832
|
);
|
|
3830
3833
|
} catch {
|
|
@@ -3833,7 +3836,7 @@ function G(t, e) {
|
|
|
3833
3836
|
}
|
|
3834
3837
|
function ts(t, e) {
|
|
3835
3838
|
try {
|
|
3836
|
-
const s = `${
|
|
3839
|
+
const s = `${Re}${t}`, n = location.href, r = location.origin, i = Array.from(e, (o) => ({
|
|
3837
3840
|
...o,
|
|
3838
3841
|
storedAt: Date.now(),
|
|
3839
3842
|
unloadUrl: n,
|
|
@@ -3849,7 +3852,7 @@ function ts(t, e) {
|
|
|
3849
3852
|
}
|
|
3850
3853
|
function vt(t, e) {
|
|
3851
3854
|
try {
|
|
3852
|
-
if (window.sessionStorage.getItem(`${
|
|
3855
|
+
if (window.sessionStorage.getItem(`${Re}${t}`) === null)
|
|
3853
3856
|
return;
|
|
3854
3857
|
} catch {
|
|
3855
3858
|
return;
|
|
@@ -3858,7 +3861,7 @@ function vt(t, e) {
|
|
|
3858
3861
|
}
|
|
3859
3862
|
function Br(t) {
|
|
3860
3863
|
try {
|
|
3861
|
-
const e = `${
|
|
3864
|
+
const e = `${Re}${t}`, s = window.sessionStorage.getItem(e);
|
|
3862
3865
|
if (window.sessionStorage.removeItem(e), !s)
|
|
3863
3866
|
return [];
|
|
3864
3867
|
const n = JSON.parse(s);
|
|
@@ -3893,7 +3896,7 @@ function Hr(t) {
|
|
|
3893
3896
|
if (!t || typeof t != "object")
|
|
3894
3897
|
return !1;
|
|
3895
3898
|
const e = t, s = e.event;
|
|
3896
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
3899
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && st(s) && s.type === "tool.result";
|
|
3897
3900
|
}
|
|
3898
3901
|
function $r(t, e) {
|
|
3899
3902
|
const s = new Set(
|
|
@@ -3906,12 +3909,12 @@ function $r(t, e) {
|
|
|
3906
3909
|
}
|
|
3907
3910
|
function jr(t) {
|
|
3908
3911
|
try {
|
|
3909
|
-
window.sessionStorage.removeItem(`${
|
|
3912
|
+
window.sessionStorage.removeItem(`${Re}${t}`);
|
|
3910
3913
|
} catch {
|
|
3911
3914
|
return;
|
|
3912
3915
|
}
|
|
3913
3916
|
}
|
|
3914
|
-
function
|
|
3917
|
+
function st(t) {
|
|
3915
3918
|
if (!t || typeof t != "object")
|
|
3916
3919
|
return !1;
|
|
3917
3920
|
const e = t;
|
|
@@ -3940,13 +3943,13 @@ function ns(t, e) {
|
|
|
3940
3943
|
fileUrl: new URL(t.fileUrl, e).toString()
|
|
3941
3944
|
} : t;
|
|
3942
3945
|
}
|
|
3943
|
-
function
|
|
3946
|
+
function Ve(t) {
|
|
3944
3947
|
return t.type || Kr(t.name) || "application/octet-stream";
|
|
3945
3948
|
}
|
|
3946
3949
|
function Fr(t) {
|
|
3947
3950
|
rs({
|
|
3948
3951
|
name: t.name,
|
|
3949
|
-
mimeType:
|
|
3952
|
+
mimeType: Ve(t),
|
|
3950
3953
|
sizeBytes: t.size
|
|
3951
3954
|
});
|
|
3952
3955
|
}
|
|
@@ -3982,24 +3985,25 @@ function Gr(t) {
|
|
|
3982
3985
|
dataType: typeof e.dataType == "string" ? e.dataType : void 0,
|
|
3983
3986
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
3984
3987
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
3985
|
-
attachments: ss(e.attachments)?.map(
|
|
3988
|
+
attachments: ss(e.attachments)?.map(we),
|
|
3986
3989
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
3987
3990
|
};
|
|
3988
3991
|
}
|
|
3989
3992
|
function Xr(t) {
|
|
3990
3993
|
return t.attachments?.length ? {
|
|
3991
3994
|
...t,
|
|
3992
|
-
attachments: t.attachments.map(
|
|
3995
|
+
attachments: t.attachments.map(we)
|
|
3993
3996
|
} : t;
|
|
3994
3997
|
}
|
|
3995
|
-
function
|
|
3998
|
+
function we(t) {
|
|
3996
3999
|
const {
|
|
3997
4000
|
dataUrl: e,
|
|
3998
4001
|
objectUrl: s,
|
|
3999
4002
|
previewUrl: n,
|
|
4000
|
-
|
|
4003
|
+
fileUrl: r,
|
|
4004
|
+
...i
|
|
4001
4005
|
} = t;
|
|
4002
|
-
return
|
|
4006
|
+
return i;
|
|
4003
4007
|
}
|
|
4004
4008
|
function N(t) {
|
|
4005
4009
|
const e = t.respondsToUserMessageId;
|
|
@@ -4017,7 +4021,7 @@ function is(t) {
|
|
|
4017
4021
|
const e = {};
|
|
4018
4022
|
try {
|
|
4019
4023
|
new Headers(t).forEach((s, n) => {
|
|
4020
|
-
Object.keys(e).length <
|
|
4024
|
+
Object.keys(e).length < et && (e[n] = nt(n, s));
|
|
4021
4025
|
});
|
|
4022
4026
|
} catch {
|
|
4023
4027
|
return {};
|
|
@@ -4025,7 +4029,7 @@ function is(t) {
|
|
|
4025
4029
|
return e;
|
|
4026
4030
|
}
|
|
4027
4031
|
function nt(t, e) {
|
|
4028
|
-
return ds(t) ?
|
|
4032
|
+
return ds(t) ? ke : x(Ae(e), nn);
|
|
4029
4033
|
}
|
|
4030
4034
|
function Jr(t, e) {
|
|
4031
4035
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
@@ -4060,7 +4064,7 @@ async function Qr(t) {
|
|
|
4060
4064
|
const { done: l, value: c } = a;
|
|
4061
4065
|
if (l)
|
|
4062
4066
|
return x(i + r.decode());
|
|
4063
|
-
const h =
|
|
4067
|
+
const h = Ze - o;
|
|
4064
4068
|
if (c.byteLength > h)
|
|
4065
4069
|
return i += r.decode(c.subarray(0, Math.max(h, 0)), { stream: !0 }), e.cancel(), `${x(i)}... [truncated]`;
|
|
4066
4070
|
o += c.byteLength, i += r.decode(c, { stream: !0 });
|
|
@@ -4096,20 +4100,20 @@ function qt(t) {
|
|
|
4096
4100
|
return t;
|
|
4097
4101
|
const e = t.trim();
|
|
4098
4102
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
4099
|
-
return
|
|
4103
|
+
return Ae(t);
|
|
4100
4104
|
try {
|
|
4101
4105
|
return JSON.stringify(L(JSON.parse(t)));
|
|
4102
4106
|
} catch {
|
|
4103
|
-
return
|
|
4107
|
+
return Ae(t);
|
|
4104
4108
|
}
|
|
4105
4109
|
}
|
|
4106
4110
|
function os(t) {
|
|
4107
4111
|
if (!t)
|
|
4108
4112
|
return !1;
|
|
4109
4113
|
const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
|
|
4110
|
-
return s !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
4114
|
+
return s !== null && Number.isInteger(n) && n >= 0 && n <= Ze && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
4111
4115
|
}
|
|
4112
|
-
function
|
|
4116
|
+
function J(t, e = {}, s) {
|
|
4113
4117
|
if (si(s))
|
|
4114
4118
|
return !0;
|
|
4115
4119
|
const n = Object.entries(e).find(([r]) => r.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
@@ -4126,7 +4130,7 @@ function V(t, e = {}, s) {
|
|
|
4126
4130
|
}
|
|
4127
4131
|
}
|
|
4128
4132
|
function ti(t, e) {
|
|
4129
|
-
if (
|
|
4133
|
+
if (J(t))
|
|
4130
4134
|
return !0;
|
|
4131
4135
|
try {
|
|
4132
4136
|
const s = new URL(t, location.href), n = new URL(e);
|
|
@@ -4144,17 +4148,17 @@ function ni(t) {
|
|
|
4144
4148
|
const n = s.indexOf(":");
|
|
4145
4149
|
if (n <= 0)
|
|
4146
4150
|
continue;
|
|
4147
|
-
if (Object.keys(e).length >=
|
|
4151
|
+
if (Object.keys(e).length >= et)
|
|
4148
4152
|
break;
|
|
4149
4153
|
const r = s.slice(0, n).trim();
|
|
4150
4154
|
e[r] = nt(r, s.slice(n + 1).trim());
|
|
4151
4155
|
}
|
|
4152
4156
|
return e;
|
|
4153
4157
|
}
|
|
4154
|
-
function x(t, e =
|
|
4158
|
+
function x(t, e = Ze) {
|
|
4155
4159
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
4156
4160
|
}
|
|
4157
|
-
function
|
|
4161
|
+
function He(t) {
|
|
4158
4162
|
return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
4159
4163
|
}
|
|
4160
4164
|
class Ie extends Error {
|
|
@@ -4189,13 +4193,13 @@ function oi(t) {
|
|
|
4189
4193
|
function ai(t) {
|
|
4190
4194
|
return t === 401 || t === 403;
|
|
4191
4195
|
}
|
|
4192
|
-
const
|
|
4196
|
+
const ke = "[REDACTED_SECRET]", W = "[REDACTED_TOKEN]", li = "[REDACTED_SIGNED_URL]", ci = 20, ui = /^(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, as = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, ls = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, cs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, us = /\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, di = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, hi = /\bhttps?:\/\/[^\s"'<>]+/gi, pi = /[),.;\]]+$/;
|
|
4193
4197
|
function L(t) {
|
|
4194
|
-
return
|
|
4198
|
+
return Me(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4195
4199
|
}
|
|
4196
|
-
function
|
|
4200
|
+
function Me(t, e, s) {
|
|
4197
4201
|
if (typeof t == "string")
|
|
4198
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
4202
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Ae(t);
|
|
4199
4203
|
if (t === null || typeof t != "object")
|
|
4200
4204
|
return t;
|
|
4201
4205
|
if (e >= ci)
|
|
@@ -4203,10 +4207,10 @@ function we(t, e, s) {
|
|
|
4203
4207
|
if (s.has(t))
|
|
4204
4208
|
return "[REDACTED_CIRCULAR]";
|
|
4205
4209
|
if (s.add(t), Array.isArray(t))
|
|
4206
|
-
return t.map((r) =>
|
|
4210
|
+
return t.map((r) => Me(r, e + 1, s));
|
|
4207
4211
|
const n = {};
|
|
4208
4212
|
for (const [r, i] of Object.entries(t))
|
|
4209
|
-
r === "pageContent" ? n[r] = i : ds(r) ? n[r] =
|
|
4213
|
+
r === "pageContent" ? n[r] = i : ds(r) ? n[r] = ke : n[r] = r.toLowerCase() === "url" ? gi(i) : Me(i, e + 1, s);
|
|
4210
4214
|
return n;
|
|
4211
4215
|
}
|
|
4212
4216
|
function ds(t) {
|
|
@@ -4214,7 +4218,7 @@ function ds(t) {
|
|
|
4214
4218
|
return e.includes("authorization") || e.includes("cookie") || e.includes("password") || e.includes("passwd") || e === "pwd" || e.includes("secret") || e === "token" || e.endsWith("token") || e.includes("apikey") || e.includes("csrf") || e.includes("xsrf") || e === "jwt" || e === "session" || e === "signature" || e.includes("privatekey");
|
|
4215
4219
|
}
|
|
4216
4220
|
function gi(t) {
|
|
4217
|
-
return typeof t == "string" ? hs(t) :
|
|
4221
|
+
return typeof t == "string" ? hs(t) : Me(t, 0, /* @__PURE__ */ new WeakSet());
|
|
4218
4222
|
}
|
|
4219
4223
|
function hs(t) {
|
|
4220
4224
|
try {
|
|
@@ -4226,11 +4230,11 @@ function hs(t) {
|
|
|
4226
4230
|
return fi(t);
|
|
4227
4231
|
}
|
|
4228
4232
|
}
|
|
4229
|
-
function
|
|
4230
|
-
return t.replace(di, li).replace(hi, mi).replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(cs, W).replace(us, (e, s) => `${s}: ${
|
|
4233
|
+
function Ae(t) {
|
|
4234
|
+
return t.replace(di, li).replace(hi, mi).replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(cs, W).replace(us, (e, s) => `${s}: ${ke}`);
|
|
4231
4235
|
}
|
|
4232
4236
|
function fi(t) {
|
|
4233
|
-
return t.replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(cs, W).replace(us, (e, s) => `${s}: ${
|
|
4237
|
+
return t.replace(as, `Bearer ${W}`).replace(ls, `Basic ${W}`).replace(cs, W).replace(us, (e, s) => `${s}: ${ke}`);
|
|
4234
4238
|
}
|
|
4235
4239
|
function mi(t) {
|
|
4236
4240
|
const e = t.match(pi)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
@@ -4238,7 +4242,7 @@ function mi(t) {
|
|
|
4238
4242
|
}
|
|
4239
4243
|
export {
|
|
4240
4244
|
ht as PLUNO_PRODUCT_AGENT_SDK_PREVIEW_HOST_SELECTOR,
|
|
4241
|
-
|
|
4245
|
+
je as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
4242
4246
|
xs as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
4243
4247
|
Ns as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
4244
4248
|
Bs as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|