@pluno/product-agent-web 0.1.202 → 0.1.204
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/adapters/web/errorAdapter.d.ts +2 -0
- package/dist/core/browser-execution/contracts.d.ts +16 -0
- package/dist/core/conversation/contracts.d.ts +21 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/interactions/contracts.d.ts +8 -0
- package/dist/core/kernel/capabilities.d.ts +333 -0
- package/dist/core/kernel/commands.d.ts +7 -0
- package/dist/core/kernel/effects.d.ts +37 -0
- package/dist/core/kernel/events.d.ts +9 -0
- package/dist/core/kernel/reducer.d.ts +10 -0
- package/dist/core/kernel/selectors.d.ts +3 -0
- package/dist/core/kernel/state.d.ts +46 -0
- package/dist/core/model-selection/contracts.d.ts +6 -0
- package/dist/core/ports.d.ts +14 -0
- package/dist/core/protocol/errors.d.ts +9 -0
- package/dist/core/protocol/json.d.ts +6 -0
- package/dist/product-agent-sdk.js +603 -469
- package/dist/product-agent-widget.js +2426 -2283
- package/dist/public/operationRoutes.d.ts +99 -0
- package/dist/runtime/effectRunner.d.ts +19 -0
- package/dist/runtime/engine.d.ts +33 -0
- package/package.json +6 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const zs = "pluno-product-agent-attachments";
|
|
2
|
-
const
|
|
2
|
+
const it = "files";
|
|
3
3
|
async function Ks(s) {
|
|
4
4
|
const e = await mt();
|
|
5
5
|
await Vs(e, "readwrite", (t) => t.put(s));
|
|
@@ -27,7 +27,7 @@ function mt() {
|
|
|
27
27
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((s, e) => {
|
|
28
28
|
const t = indexedDB.open(zs, 1);
|
|
29
29
|
t.onupgradeneeded = () => {
|
|
30
|
-
const i = t.result.createObjectStore(
|
|
30
|
+
const i = t.result.createObjectStore(it, { keyPath: "attachmentId" });
|
|
31
31
|
i.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), i.createIndex("sessionId", "sessionId", { unique: !1 }), i.createIndex("origin", "origin", { unique: !1 });
|
|
32
32
|
}, t.onsuccess = () => s(t.result), t.onerror = () => e(t.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
33
33
|
});
|
|
@@ -37,7 +37,7 @@ async function Vs(s, e, t) {
|
|
|
37
37
|
}
|
|
38
38
|
function yt(s, e, t) {
|
|
39
39
|
return new Promise((n, i) => {
|
|
40
|
-
const r = s.transaction(
|
|
40
|
+
const r = s.transaction(it, e), o = r.objectStore(it);
|
|
41
41
|
let a, l = !1;
|
|
42
42
|
t(o).then((c) => {
|
|
43
43
|
a = c;
|
|
@@ -65,7 +65,7 @@ function It(s) {
|
|
|
65
65
|
function Xs(s) {
|
|
66
66
|
return s !== null && (typeof s == "object" || typeof s == "function");
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function hs(s, e, t) {
|
|
69
69
|
const n = Reflect.get(s, "pluno"), i = Xs(n) ? n : {};
|
|
70
70
|
if (i !== n && !Reflect.set(s, "pluno", i))
|
|
71
71
|
return null;
|
|
@@ -81,24 +81,24 @@ function ds(s, e, t) {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
const Js = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
84
|
-
function
|
|
84
|
+
function vt(s, e) {
|
|
85
85
|
return e ? s.replace(
|
|
86
86
|
Js,
|
|
87
87
|
(t, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
|
|
88
88
|
) : s;
|
|
89
89
|
}
|
|
90
|
-
const
|
|
90
|
+
const St = "suggest_share_on_socials";
|
|
91
91
|
function Ys(s) {
|
|
92
92
|
for (let e = s.length - 1; e >= 0; e -= 1) {
|
|
93
93
|
const t = s[e];
|
|
94
|
-
if (t.role !== "tool" || t.toolName !==
|
|
94
|
+
if (t.role !== "tool" || t.toolName !== St || t.sharePromptAllowed !== void 0)
|
|
95
95
|
continue;
|
|
96
96
|
if (en(s, e, t.callId) !== !0)
|
|
97
97
|
return null;
|
|
98
|
-
const n =
|
|
98
|
+
const n = Ut(s, e, "assistant");
|
|
99
99
|
if (!n)
|
|
100
100
|
return null;
|
|
101
|
-
const i =
|
|
101
|
+
const i = Ut(s, n.index, "user");
|
|
102
102
|
return i ? {
|
|
103
103
|
id: `share:${t.callId ?? t.id}`,
|
|
104
104
|
userPrompt: i.content,
|
|
@@ -128,7 +128,7 @@ function en(s, e, t) {
|
|
|
128
128
|
}
|
|
129
129
|
return null;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function Ut(s, e, t) {
|
|
132
132
|
for (let n = e - 1; n >= 0; n -= 1) {
|
|
133
133
|
const i = s[n];
|
|
134
134
|
if (i.role === t && i.content.trim())
|
|
@@ -144,54 +144,54 @@ function nn(s) {
|
|
|
144
144
|
return (s.type === "function_call" || s.type === "tool_call") && s.name === sn;
|
|
145
145
|
}
|
|
146
146
|
function rn(s, e, t) {
|
|
147
|
-
const n = e.map((
|
|
147
|
+
const n = e.map((h) => ({ item: h, identity: t(h) })), i = new Set(
|
|
148
148
|
n.flatMap(
|
|
149
|
-
({ identity:
|
|
149
|
+
({ identity: h }) => h.isActivity && !h.isTransient ? h.activityKeys ?? [] : []
|
|
150
150
|
)
|
|
151
151
|
), r = n.filter(
|
|
152
|
-
({ identity:
|
|
153
|
-
), o = new Map(r.map(({ item:
|
|
152
|
+
({ identity: h }) => !(h.isTransient && h.activityKeys?.some((p) => i.has(p)))
|
|
153
|
+
), o = new Map(r.map(({ item: h, identity: p }) => [p.id, h])), a = new Map(
|
|
154
154
|
r.flatMap(
|
|
155
|
-
({ item:
|
|
155
|
+
({ item: h, identity: p }) => p.optimisticKey ? [[p.optimisticKey, h]] : []
|
|
156
156
|
)
|
|
157
157
|
), l = new Map(
|
|
158
158
|
r.flatMap(
|
|
159
|
-
({ item:
|
|
159
|
+
({ item: h, identity: p }) => p.assistantDraftKey ? [[p.assistantDraftKey, h]] : []
|
|
160
160
|
)
|
|
161
161
|
), c = /* @__PURE__ */ new Map();
|
|
162
|
-
for (const { item:
|
|
162
|
+
for (const { item: h, identity: p } of r)
|
|
163
163
|
for (const y of p.activityKeys ?? []) {
|
|
164
|
-
const
|
|
165
|
-
(!
|
|
164
|
+
const m = c.get(y);
|
|
165
|
+
(!m || t(m).isTransient) && c.set(y, h);
|
|
166
166
|
}
|
|
167
|
-
const u = new Set(r.map(({ identity:
|
|
168
|
-
r.flatMap(({ identity:
|
|
169
|
-
),
|
|
170
|
-
for (const
|
|
171
|
-
const p = t(
|
|
167
|
+
const u = new Set(r.map(({ identity: h }) => h.id)), d = new Set(
|
|
168
|
+
r.flatMap(({ identity: h }) => h.runId ? [h.runId] : [])
|
|
169
|
+
), g = /* @__PURE__ */ new Set(), f = [];
|
|
170
|
+
for (const h of s) {
|
|
171
|
+
const p = t(h);
|
|
172
172
|
let y = o.get(p.id);
|
|
173
|
-
if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? y), y && !
|
|
174
|
-
|
|
173
|
+
if (p.isOptimistic && p.optimisticKey ? y = a.get(p.optimisticKey) : p.isAssistantDraft && p.assistantDraftKey ? y = l.get(p.assistantDraftKey) : p.isActivity && (y = p.activityKeys?.map((M) => c.get(M)).find((M) => M !== void 0) ?? y), y && !g.has(y)) {
|
|
174
|
+
f.push(y), g.add(y);
|
|
175
175
|
continue;
|
|
176
176
|
}
|
|
177
|
-
const
|
|
178
|
-
(p.isOptimistic || (p.isAssistantDraft || p.isActivity) &&
|
|
177
|
+
const m = p.respondsToUserMessageId !== void 0 && u.has(p.respondsToUserMessageId) || p.runId !== void 0 && d.has(p.runId);
|
|
178
|
+
(p.isOptimistic || (p.isAssistantDraft || p.isActivity) && m) && f.push(h);
|
|
179
179
|
}
|
|
180
|
-
for (const { item:
|
|
181
|
-
|
|
182
|
-
return
|
|
180
|
+
for (const { item: h } of r)
|
|
181
|
+
g.has(h) || f.push(h);
|
|
182
|
+
return f;
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function Dt(s, e, t, n) {
|
|
185
185
|
return s.filter((i) => {
|
|
186
186
|
const r = n(i);
|
|
187
187
|
return !r.isActivity || !r.isTransient ? !0 : e !== null && r.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId !== e : t === null || r.runId !== t;
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
const
|
|
190
|
+
const ze = "pluno.productAgent.transportId", on = "pluno.productAgent.transportIdentity", Ke = "pluno.productAgent.transportIdentity.event", an = 50, ln = globalThis.setTimeout.bind(globalThis);
|
|
191
191
|
let le = null;
|
|
192
|
-
const be = /* @__PURE__ */ new Set(),
|
|
192
|
+
const be = /* @__PURE__ */ new Set(), Ge = /* @__PURE__ */ new Map();
|
|
193
193
|
async function cn(s = ps()) {
|
|
194
|
-
const e = s.randomUUID(), t = s.storage.getItem(
|
|
194
|
+
const e = s.randomUUID(), t = s.storage.getItem(ze);
|
|
195
195
|
let n = t ?? s.randomUUID(), i = !1, r = !1;
|
|
196
196
|
const o = s.channel.subscribe((l) => {
|
|
197
197
|
if (!(l.senderId === e || l.transportId !== n)) {
|
|
@@ -209,7 +209,7 @@ async function cn(s = ps()) {
|
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
211
|
if (!t)
|
|
212
|
-
s.storage.setItem(
|
|
212
|
+
s.storage.setItem(ze, n), i = !0;
|
|
213
213
|
else if (s.skipStoredIdentityCollisionCheck)
|
|
214
214
|
i = !0;
|
|
215
215
|
else
|
|
@@ -218,7 +218,7 @@ async function cn(s = ps()) {
|
|
|
218
218
|
i = !0;
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
|
-
n = s.randomUUID(), s.storage.setItem(
|
|
221
|
+
n = s.randomUUID(), s.storage.setItem(ze, n);
|
|
222
222
|
}
|
|
223
223
|
let a = !1;
|
|
224
224
|
return {
|
|
@@ -267,13 +267,13 @@ function hn() {
|
|
|
267
267
|
return {
|
|
268
268
|
getItem: (s) => {
|
|
269
269
|
try {
|
|
270
|
-
return window.sessionStorage?.getItem(s) ??
|
|
270
|
+
return window.sessionStorage?.getItem(s) ?? Ge.get(s) ?? null;
|
|
271
271
|
} catch {
|
|
272
|
-
return
|
|
272
|
+
return Ge.get(s) ?? null;
|
|
273
273
|
}
|
|
274
274
|
},
|
|
275
275
|
setItem: (s, e) => {
|
|
276
|
-
|
|
276
|
+
Ge.set(s, e);
|
|
277
277
|
try {
|
|
278
278
|
window.sessionStorage?.setItem(s, e);
|
|
279
279
|
} catch {
|
|
@@ -297,7 +297,7 @@ function pn() {
|
|
|
297
297
|
}
|
|
298
298
|
function gn() {
|
|
299
299
|
const s = /* @__PURE__ */ new Set(), e = (t) => {
|
|
300
|
-
if (t.key !==
|
|
300
|
+
if (t.key !== Ke || !t.newValue)
|
|
301
301
|
return;
|
|
302
302
|
const n = JSON.parse(t.newValue);
|
|
303
303
|
for (const i of s)
|
|
@@ -306,9 +306,9 @@ function gn() {
|
|
|
306
306
|
return window.addEventListener("storage", e), {
|
|
307
307
|
postMessage: (t) => {
|
|
308
308
|
window.localStorage.setItem(
|
|
309
|
-
|
|
309
|
+
Ke,
|
|
310
310
|
JSON.stringify({ ...t, eventId: crypto.randomUUID() })
|
|
311
|
-
), window.localStorage.removeItem(
|
|
311
|
+
), window.localStorage.removeItem(Ke);
|
|
312
312
|
},
|
|
313
313
|
subscribe: (t) => (s.add(t), () => s.delete(t)),
|
|
314
314
|
close: () => {
|
|
@@ -343,12 +343,12 @@ const mn = [
|
|
|
343
343
|
], In = [
|
|
344
344
|
...mn,
|
|
345
345
|
...yn
|
|
346
|
-
],
|
|
347
|
-
function
|
|
346
|
+
], Qe = (s) => In.some((e) => e.value === s);
|
|
347
|
+
function qt(s, e) {
|
|
348
348
|
return s.filter((t, n) => {
|
|
349
|
-
const i =
|
|
349
|
+
const i = Ot(t);
|
|
350
350
|
return fs(i) ? !s.slice(n + 1).some((r) => {
|
|
351
|
-
const o =
|
|
351
|
+
const o = Ot(r);
|
|
352
352
|
return ms(i, o) && ys(i, o);
|
|
353
353
|
}) : !0;
|
|
354
354
|
});
|
|
@@ -359,7 +359,7 @@ function fs(s) {
|
|
|
359
359
|
function Sn(s, e) {
|
|
360
360
|
return s.reason === "task_tab_closed" && ys(s, e) && ms(s, e);
|
|
361
361
|
}
|
|
362
|
-
function
|
|
362
|
+
function Ot(s) {
|
|
363
363
|
return s.data && typeof s.data == "object" ? s.data : {};
|
|
364
364
|
}
|
|
365
365
|
function ms(s, e) {
|
|
@@ -379,7 +379,7 @@ function Re(s) {
|
|
|
379
379
|
updatedAt: null
|
|
380
380
|
};
|
|
381
381
|
}
|
|
382
|
-
class
|
|
382
|
+
class xt {
|
|
383
383
|
constructor(e, t, n = (i, r) => r) {
|
|
384
384
|
this.loader = t, this.merge = n, this.state = Re(e);
|
|
385
385
|
}
|
|
@@ -497,7 +497,7 @@ function To(s) {
|
|
|
497
497
|
}
|
|
498
498
|
class Mn {
|
|
499
499
|
constructor(e, t, n = 20) {
|
|
500
|
-
this.loadPage = t, this.limit = n, this.recentQuery = new
|
|
500
|
+
this.loadPage = t, this.limit = n, this.recentQuery = new xt(
|
|
501
501
|
`${e}:recent`,
|
|
502
502
|
async ({ cursor: i }) => ke(
|
|
503
503
|
await this.loadPage({ cursor: i, limit: this.limit, pinned: !1 }).then((r) => ({
|
|
@@ -506,7 +506,7 @@ class Mn {
|
|
|
506
506
|
}))
|
|
507
507
|
),
|
|
508
508
|
Tn
|
|
509
|
-
), this.pinnedQuery = new
|
|
509
|
+
), this.pinnedQuery = new xt(
|
|
510
510
|
`${e}:pinned`,
|
|
511
511
|
async () => ke({
|
|
512
512
|
entities: await this.loadAllPinned(),
|
|
@@ -650,7 +650,7 @@ function Ie(s) {
|
|
|
650
650
|
function bn(s, e) {
|
|
651
651
|
return s.status === "error" || e.status === "error" ? "error" : s.status === "loading" || e.status === "loading" ? "loading" : s.status === "refreshing" || e.status === "refreshing" ? "refreshing" : s.status === "loading_more" ? "loading_more" : s.status === "ready" || e.status === "ready" ? "ready" : "not_requested";
|
|
652
652
|
}
|
|
653
|
-
class
|
|
653
|
+
class Lt {
|
|
654
654
|
constructor(e) {
|
|
655
655
|
this.options = e;
|
|
656
656
|
}
|
|
@@ -749,7 +749,7 @@ class Rn {
|
|
|
749
749
|
class kn {
|
|
750
750
|
constructor(e, t = null) {
|
|
751
751
|
this.storage = e, t && (this.decisions = new Map(
|
|
752
|
-
t.filter(
|
|
752
|
+
t.filter(rt).map((n) => [this.getDecisionKey(n), n])
|
|
753
753
|
), this.initialized = !0);
|
|
754
754
|
}
|
|
755
755
|
storage;
|
|
@@ -761,7 +761,7 @@ class kn {
|
|
|
761
761
|
if (this.initialized) return;
|
|
762
762
|
const e = await this.storage.load();
|
|
763
763
|
this.decisions = new Map(
|
|
764
|
-
e.filter(
|
|
764
|
+
e.filter(rt).map((t) => [this.getDecisionKey(t), t])
|
|
765
765
|
), this.initialized = !0;
|
|
766
766
|
}
|
|
767
767
|
isEligible(e, t = Date.now()) {
|
|
@@ -825,14 +825,14 @@ class kn {
|
|
|
825
825
|
return null;
|
|
826
826
|
}
|
|
827
827
|
getDecisionKey(e) {
|
|
828
|
-
const t =
|
|
828
|
+
const t = Ve(e.scope);
|
|
829
829
|
return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
|
|
830
830
|
}
|
|
831
831
|
getExactKey(e) {
|
|
832
|
-
return `${
|
|
832
|
+
return `${Ve(e.scope)}:interaction:${e.key}`;
|
|
833
833
|
}
|
|
834
834
|
getCategoryKey(e) {
|
|
835
|
-
return `${
|
|
835
|
+
return `${Ve(e.scope)}:category:${e.category}`;
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
function wo(s, e) {
|
|
@@ -845,15 +845,15 @@ function En(s, e) {
|
|
|
845
845
|
const t = s.getItem(e);
|
|
846
846
|
if (!t) return [];
|
|
847
847
|
const n = JSON.parse(t);
|
|
848
|
-
return Array.isArray(n) ? n.filter(
|
|
848
|
+
return Array.isArray(n) ? n.filter(rt) : [];
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function Ve(s) {
|
|
851
851
|
return `${s.level}:${s.key}`;
|
|
852
852
|
}
|
|
853
853
|
function Ss(s) {
|
|
854
854
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
855
855
|
}
|
|
856
|
-
function
|
|
856
|
+
function rt(s) {
|
|
857
857
|
if (!s || typeof s != "object") return !1;
|
|
858
858
|
const e = s;
|
|
859
859
|
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Ss(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
@@ -965,7 +965,7 @@ function bo(s) {
|
|
|
965
965
|
}
|
|
966
966
|
class Ro {
|
|
967
967
|
constructor(e, t, n) {
|
|
968
|
-
this.adapter = t, this.state =
|
|
968
|
+
this.adapter = t, this.state = Xe(e), this.model = n;
|
|
969
969
|
}
|
|
970
970
|
adapter;
|
|
971
971
|
listeners = {};
|
|
@@ -986,12 +986,12 @@ class Ro {
|
|
|
986
986
|
return n.add(t), this.listeners[e] = n, () => n.delete(t);
|
|
987
987
|
}
|
|
988
988
|
getState() {
|
|
989
|
-
return
|
|
989
|
+
return Xe(this.state);
|
|
990
990
|
}
|
|
991
991
|
updateProjection(e, t, n, i, r) {
|
|
992
992
|
if (!this.destroyed) {
|
|
993
|
-
if (this.state =
|
|
994
|
-
this.sessionHistoryState =
|
|
993
|
+
if (this.state = Xe(e), t !== void 0 && (this.model = t), n) {
|
|
994
|
+
this.sessionHistoryState = Nt(n);
|
|
995
995
|
for (const o of this.sessionHistoryListeners)
|
|
996
996
|
o(this.getSessionHistoryState());
|
|
997
997
|
}
|
|
@@ -1067,9 +1067,9 @@ class Ro {
|
|
|
1067
1067
|
c.push(u);
|
|
1068
1068
|
continue;
|
|
1069
1069
|
}
|
|
1070
|
-
const
|
|
1071
|
-
if (!
|
|
1072
|
-
c.push(await this.adapter.uploadAttachment(
|
|
1070
|
+
const d = u.id ? this.attachmentFiles.get(u.id) : void 0;
|
|
1071
|
+
if (!d) throw new Error(`Attachment bytes are unavailable for ${u.name}`);
|
|
1072
|
+
c.push(await this.adapter.uploadAttachment(d, u, { clientMessageId: r }));
|
|
1073
1073
|
}
|
|
1074
1074
|
o = c;
|
|
1075
1075
|
}
|
|
@@ -1138,7 +1138,7 @@ class Ro {
|
|
|
1138
1138
|
};
|
|
1139
1139
|
}
|
|
1140
1140
|
getSessionHistoryState() {
|
|
1141
|
-
return
|
|
1141
|
+
return Nt(this.sessionHistoryState);
|
|
1142
1142
|
}
|
|
1143
1143
|
subscribeSessionHistory(e) {
|
|
1144
1144
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -1217,7 +1217,7 @@ class Ro {
|
|
|
1217
1217
|
for (const i of n ?? []) i(t);
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
|
-
function
|
|
1220
|
+
function Xe(s) {
|
|
1221
1221
|
return {
|
|
1222
1222
|
...s,
|
|
1223
1223
|
starterPrompts: [...s.starterPrompts],
|
|
@@ -1238,7 +1238,7 @@ function Ve(s) {
|
|
|
1238
1238
|
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
1239
1239
|
};
|
|
1240
1240
|
}
|
|
1241
|
-
function
|
|
1241
|
+
function Nt(s) {
|
|
1242
1242
|
return {
|
|
1243
1243
|
...s,
|
|
1244
1244
|
data: s.data ? ke({
|
|
@@ -1247,8 +1247,8 @@ function Lt(s) {
|
|
|
1247
1247
|
}) : null
|
|
1248
1248
|
};
|
|
1249
1249
|
}
|
|
1250
|
-
const vn = globalThis.fetch.bind(globalThis),
|
|
1251
|
-
class
|
|
1250
|
+
const vn = globalThis.fetch.bind(globalThis), Ht = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', Un = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Dn = ".pluno-pa-widget__panel", qn = ".pluno-pa-widget__timeline", On = "__plunoExtensionWidgetOwner";
|
|
1251
|
+
class X extends Error {
|
|
1252
1252
|
constructor(e, t, n, i) {
|
|
1253
1253
|
super(e), this.retryable = t, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
|
|
1254
1254
|
}
|
|
@@ -1260,9 +1260,9 @@ function xn(s) {
|
|
|
1260
1260
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
1261
1261
|
}
|
|
1262
1262
|
let Ln = 0;
|
|
1263
|
-
function
|
|
1263
|
+
function Bt(s) {
|
|
1264
1264
|
const e = {};
|
|
1265
|
-
for (const
|
|
1265
|
+
for (const l of [
|
|
1266
1266
|
"type",
|
|
1267
1267
|
"requestId",
|
|
1268
1268
|
"clientMessageId",
|
|
@@ -1270,12 +1270,16 @@ function Ht(s) {
|
|
|
1270
1270
|
"warmupId",
|
|
1271
1271
|
"runId",
|
|
1272
1272
|
"itemId",
|
|
1273
|
+
"callId",
|
|
1274
|
+
"responseId",
|
|
1275
|
+
"respondsToUserMessageId",
|
|
1276
|
+
"status",
|
|
1273
1277
|
"reason",
|
|
1274
1278
|
"phase",
|
|
1275
1279
|
"elapsedMs"
|
|
1276
1280
|
]) {
|
|
1277
|
-
const
|
|
1278
|
-
(typeof
|
|
1281
|
+
const c = s[l];
|
|
1282
|
+
(typeof c == "string" || typeof c == "number" || typeof c == "boolean" || c === null) && (e[l] = c);
|
|
1279
1283
|
}
|
|
1280
1284
|
const t = s.content;
|
|
1281
1285
|
typeof t == "string" && (e.contentLength = t.length);
|
|
@@ -1283,22 +1287,44 @@ function Ht(s) {
|
|
|
1283
1287
|
typeof n == "string" && (e.deltaLength = n.length);
|
|
1284
1288
|
const i = s.attachments;
|
|
1285
1289
|
Array.isArray(i) && (e.attachmentCount = i.length);
|
|
1286
|
-
const r =
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1290
|
+
const r = (l) => {
|
|
1291
|
+
if (!l || typeof l != "object")
|
|
1292
|
+
return null;
|
|
1293
|
+
const c = l, u = c.data, d = u && typeof u == "object" ? u : {}, g = ve(l);
|
|
1294
|
+
return {
|
|
1295
|
+
id: typeof c.id == "string" ? c.id : null,
|
|
1296
|
+
type: typeof d.type == "string" ? d.type : null,
|
|
1297
|
+
role: typeof d.role == "string" ? d.role : null,
|
|
1298
|
+
sessionId: typeof c.sessionId == "string" ? c.sessionId : null,
|
|
1299
|
+
runId: typeof d.runId == "string" ? d.runId : null,
|
|
1300
|
+
respondsToUserMessageId: typeof d.respondsToUserMessageId == "string" ? d.respondsToUserMessageId : null,
|
|
1301
|
+
status: typeof d.status == "string" ? d.status : null,
|
|
1302
|
+
stage: typeof d.stage == "string" ? d.stage : null,
|
|
1303
|
+
retryable: d.retryable === !0,
|
|
1304
|
+
visible: !!(g && !g.scheduledCheckInAt && g.toolName !== St && (d.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(d.status))))
|
|
1305
|
+
};
|
|
1306
|
+
}, o = r(s.item);
|
|
1307
|
+
if (o?.id && (e.itemId = o.id, o.type && (e.itemType = o.type), o.role && (e.itemRole = o.role), o.sessionId && typeof e.sessionId != "string" && (e.sessionId = o.sessionId), o.runId && typeof e.runId != "string" && (e.runId = o.runId), o.respondsToUserMessageId && typeof e.respondsToUserMessageId != "string" && (e.respondsToUserMessageId = o.respondsToUserMessageId), o.status && (e.itemStatus = o.status), o.stage && (e.itemStage = o.stage), o.retryable && (e.itemRetryable = !0), o.visible && (e.visibleItemId = o.id)), Array.isArray(s.items)) {
|
|
1308
|
+
const l = s.items.map(r).filter((c) => c !== null && c.visible && !!c.id).map((c) => c.id);
|
|
1309
|
+
e.visibleItemIds = JSON.stringify(l);
|
|
1310
|
+
}
|
|
1311
|
+
s.type === "chat.assistant_delta" && typeof s.itemId == "string" && (e.visibleItemId = s.itemId);
|
|
1312
|
+
const a = s.session;
|
|
1313
|
+
if (a && typeof a == "object") {
|
|
1314
|
+
const l = a;
|
|
1315
|
+
typeof l.id == "string" && (e.sessionId = l.id);
|
|
1316
|
+
const c = l.metadata;
|
|
1317
|
+
if (c && typeof c == "object") {
|
|
1318
|
+
const u = c.composerPreload;
|
|
1319
|
+
if (u && typeof u == "object") {
|
|
1320
|
+
const d = u.runId;
|
|
1321
|
+
e.composerPreloaded = !0, typeof d == "string" && (e.preloadRunId = d);
|
|
1296
1322
|
}
|
|
1297
1323
|
}
|
|
1298
1324
|
}
|
|
1299
1325
|
return e;
|
|
1300
1326
|
}
|
|
1301
|
-
function
|
|
1327
|
+
function Je(s, e, t) {
|
|
1302
1328
|
if (typeof window > "u")
|
|
1303
1329
|
return;
|
|
1304
1330
|
const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
|
|
@@ -1322,13 +1348,13 @@ class Se extends Error {
|
|
|
1322
1348
|
function Nn(s) {
|
|
1323
1349
|
return s === 408 || s === 425 || s === 429 || s >= 500;
|
|
1324
1350
|
}
|
|
1325
|
-
const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4,
|
|
1351
|
+
const Hn = "https://app.pluno.ai", Bn = 2e4, Wn = 1e4, Fn = 6e4, $n = 6e4, jn = 1e4, zn = 1e4, Kn = 3e3, Gn = 3e4, Qn = 1e3, ot = 3e4, Wt = 0.2, Vn = 6e4, Ft = 15e3, Xn = 8, Jn = "Browser connection was interrupted.", $t = 15e3, Yn = "Pluno could not send this message. Try it again.", Zn = "Still connecting to Pluno. Retrying automatically.", ei = 2e3, ti = 1e3, si = 100, jt = 8e3, zt = 3, ni = [300, 1e3], Ts = 50 * 1024 * 1024, ii = /* @__PURE__ */ new Set([
|
|
1326
1352
|
".jpeg:image/jpeg",
|
|
1327
1353
|
".jpg:image/jpeg",
|
|
1328
1354
|
".pdf:application/pdf",
|
|
1329
1355
|
".png:image/png",
|
|
1330
1356
|
".webp:image/webp"
|
|
1331
|
-
]), ko = ".pdf,.png,.jpg,.jpeg,.webp",
|
|
1357
|
+
]), ko = ".pdf,.png,.jpg,.jpeg,.webp", Tt = 64e3, Ye = 4e3, wt = 30, ri = 2e3, oi = 1e3, ws = "Image is too large for model vision input.", ai = 100, li = 20, As = "pluno.productAgent.state.", at = "pluno.productAgent.pendingEvents.", xe = "pluno.productAgent.activeToolCalls.", ci = 100;
|
|
1332
1358
|
function ui(s, e = 0) {
|
|
1333
1359
|
const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
|
|
1334
1360
|
return Math.max(e, t);
|
|
@@ -1336,8 +1362,8 @@ function ui(s, e = 0) {
|
|
|
1336
1362
|
const Ee = /* @__PURE__ */ new Set();
|
|
1337
1363
|
let Te = null;
|
|
1338
1364
|
function di(s, e = Math.random) {
|
|
1339
|
-
const t = Math.min(
|
|
1340
|
-
return Math.min(
|
|
1365
|
+
const t = Math.min(ot, Qn * 2 ** s), n = 1 - Wt + e() * Wt * 2;
|
|
1366
|
+
return Math.min(ot, Math.round(t * n));
|
|
1341
1367
|
}
|
|
1342
1368
|
function hi(s) {
|
|
1343
1369
|
const e = s.split(".")[1];
|
|
@@ -1351,7 +1377,7 @@ function hi(s) {
|
|
|
1351
1377
|
}
|
|
1352
1378
|
}
|
|
1353
1379
|
function pi(s) {
|
|
1354
|
-
if (s instanceof
|
|
1380
|
+
if (s instanceof X)
|
|
1355
1381
|
return s.retryable;
|
|
1356
1382
|
if (s && typeof s == "object") {
|
|
1357
1383
|
const e = s.status;
|
|
@@ -1372,12 +1398,12 @@ function gi(s) {
|
|
|
1372
1398
|
}
|
|
1373
1399
|
return new Error(String(s));
|
|
1374
1400
|
}
|
|
1375
|
-
class
|
|
1401
|
+
class Le {
|
|
1376
1402
|
constructor(e, t) {
|
|
1377
1403
|
this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new Mn(
|
|
1378
1404
|
e.clientId,
|
|
1379
1405
|
async ({ cursor: r, limit: o, pinned: a }) => await this.listSessions({ cursor: r, limit: o, pinned: a })
|
|
1380
|
-
), this.sessionRecoveryPoller = new
|
|
1406
|
+
), this.sessionRecoveryPoller = new Lt({
|
|
1381
1407
|
poll: async ({ sessionId: r }) => await this.fetchSessionHistoryPageOnce(
|
|
1382
1408
|
r,
|
|
1383
1409
|
"transcript",
|
|
@@ -1408,14 +1434,14 @@ class xe {
|
|
|
1408
1434
|
},
|
|
1409
1435
|
getItemId: (r) => A(r, "id"),
|
|
1410
1436
|
maxPagesPerPoll: 3
|
|
1411
|
-
}), this.sessionActivityRecoveryPoller = new
|
|
1437
|
+
}), this.sessionActivityRecoveryPoller = new Lt({
|
|
1412
1438
|
poll: async ({ sessionId: r }) => await this.sessionActivityRecovery.poll(r),
|
|
1413
1439
|
apply: async (r) => await this.sessionActivityRecovery.apply(r),
|
|
1414
1440
|
isActiveTurn: () => this.state.isThinking || this.state.pendingMessageStatus !== null,
|
|
1415
1441
|
activeIntervalMs: 3e3,
|
|
1416
1442
|
idleIntervalMs: 15e3,
|
|
1417
1443
|
maxFailureIntervalMs: 3e4
|
|
1418
|
-
}), this.personalModelSelectionOverride = e.productVariant === "personal" &&
|
|
1444
|
+
}), this.personalModelSelectionOverride = e.productVariant === "personal" && Qe(e.model) ? e.model : null, this.state = {
|
|
1419
1445
|
...this.state,
|
|
1420
1446
|
starterPrompts: Gi(e.initialStarterPrompts)
|
|
1421
1447
|
}, this.account = e.initialAccount ? { ...e.initialAccount } : null;
|
|
@@ -1440,7 +1466,7 @@ class xe {
|
|
|
1440
1466
|
taskStatus: null,
|
|
1441
1467
|
isRetrying: !1,
|
|
1442
1468
|
lastError: null
|
|
1443
|
-
}, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents =
|
|
1469
|
+
}, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = $r(
|
|
1444
1470
|
Hr(e.clientId),
|
|
1445
1471
|
Br(e.clientId)
|
|
1446
1472
|
);
|
|
@@ -1507,6 +1533,16 @@ class xe {
|
|
|
1507
1533
|
retryAttemptsByClientMessageId = {};
|
|
1508
1534
|
retryTimersByClientMessageId = {};
|
|
1509
1535
|
reportedHealthSignalKeys = /* @__PURE__ */ new Set();
|
|
1536
|
+
/** @internal */
|
|
1537
|
+
transportDiagnosticEpisodes = /* @__PURE__ */ new Map();
|
|
1538
|
+
/** @internal */
|
|
1539
|
+
pendingTransportDiagnostics = [];
|
|
1540
|
+
/** @internal */
|
|
1541
|
+
pendingHealthDiagnostics = [];
|
|
1542
|
+
/** @internal */
|
|
1543
|
+
clientDiagnosticsFlush = null;
|
|
1544
|
+
/** @internal */
|
|
1545
|
+
clientDiagnosticsRetryTimer = null;
|
|
1510
1546
|
clientMessageIdsByUserMessageItemId = /* @__PURE__ */ new Map();
|
|
1511
1547
|
backgroundSessionIds = /* @__PURE__ */ new Set();
|
|
1512
1548
|
backgroundClientMessageIds = /* @__PURE__ */ new Set();
|
|
@@ -1577,7 +1613,7 @@ class xe {
|
|
|
1577
1613
|
static async init(e) {
|
|
1578
1614
|
const t = e, n = await un(
|
|
1579
1615
|
t.skipStoredTransportIdentityCollisionCheck === !0
|
|
1580
|
-
), i = new
|
|
1616
|
+
), i = new Le({
|
|
1581
1617
|
...e,
|
|
1582
1618
|
backendUrl: Ui(e.backendUrl ?? Hn),
|
|
1583
1619
|
clientId: e.clientId ?? Yi(),
|
|
@@ -1631,7 +1667,7 @@ class xe {
|
|
|
1631
1667
|
return this.options.token;
|
|
1632
1668
|
if (!this.options.tokenProvider)
|
|
1633
1669
|
return this.token;
|
|
1634
|
-
const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs -
|
|
1670
|
+
const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - $n > n;
|
|
1635
1671
|
if (!t.forceRefresh && (i || t.preferCached && this.token !== null))
|
|
1636
1672
|
return this.token;
|
|
1637
1673
|
if (this.tokenRequest && !t.forceRefresh)
|
|
@@ -1643,8 +1679,8 @@ class xe {
|
|
|
1643
1679
|
let a = null;
|
|
1644
1680
|
const l = new Promise((c, u) => {
|
|
1645
1681
|
a = window.setTimeout(() => {
|
|
1646
|
-
r.abort(), u(new
|
|
1647
|
-
},
|
|
1682
|
+
r.abort(), u(new X("Pluno token provider timed out", !0));
|
|
1683
|
+
}, Fn);
|
|
1648
1684
|
});
|
|
1649
1685
|
try {
|
|
1650
1686
|
const c = await Promise.race([
|
|
@@ -1652,9 +1688,9 @@ class xe {
|
|
|
1652
1688
|
l
|
|
1653
1689
|
]);
|
|
1654
1690
|
if (r.signal.aborted || this.tokenAbortController !== r)
|
|
1655
|
-
throw new
|
|
1691
|
+
throw new X("Pluno token request was cancelled", !0);
|
|
1656
1692
|
if (!c)
|
|
1657
|
-
throw new
|
|
1693
|
+
throw new X("Pluno token provider did not return a token", !1);
|
|
1658
1694
|
return this.token = c, this.tokenExpiresAtMs = hi(c), c;
|
|
1659
1695
|
} finally {
|
|
1660
1696
|
a !== null && window.clearTimeout(a);
|
|
@@ -1679,10 +1715,10 @@ class xe {
|
|
|
1679
1715
|
if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
1680
1716
|
return;
|
|
1681
1717
|
if (!this.token && !this.options.webSocketFactory)
|
|
1682
|
-
throw new
|
|
1718
|
+
throw new X("Pluno requires a token or tokenProvider", !1);
|
|
1683
1719
|
const t = xi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
1684
1720
|
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
1685
|
-
this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
1721
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
|
|
1686
1722
|
}, jn), n.addEventListener("open", () => {
|
|
1687
1723
|
this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
|
|
1688
1724
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
@@ -1694,7 +1730,7 @@ class xe {
|
|
|
1694
1730
|
transportId: this.transportIdentity.transportId,
|
|
1695
1731
|
pageUrl: location.href
|
|
1696
1732
|
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
1697
|
-
this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.replaceTimedOutSocket(n));
|
|
1733
|
+
this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
|
|
1698
1734
|
}, zn));
|
|
1699
1735
|
}), n.addEventListener("message", (i) => {
|
|
1700
1736
|
this.socket === n && this.handleServerEvent(zi(i.data));
|
|
@@ -1712,12 +1748,15 @@ class xe {
|
|
|
1712
1748
|
wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
|
|
1713
1749
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1714
1750
|
isThinking: this.state.isThinking
|
|
1751
|
+
}), (typeof i?.code != "number" || i.code !== 1e3) && this.reportTransportDiagnostic("socket_closed", {
|
|
1752
|
+
closeCode: typeof i?.code == "number" ? i.code : void 0,
|
|
1753
|
+
wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : void 0
|
|
1715
1754
|
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
1716
1755
|
}), n.addEventListener("error", () => {
|
|
1717
1756
|
this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
1718
1757
|
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1719
1758
|
isThinking: this.state.isThinking
|
|
1720
|
-
}), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
1759
|
+
}), this.reportTransportDiagnostic("socket_error"), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close());
|
|
1721
1760
|
});
|
|
1722
1761
|
} catch (t) {
|
|
1723
1762
|
if (e !== this.connectionAttemptId || this.state.status === "closed")
|
|
@@ -1727,12 +1766,12 @@ class xe {
|
|
|
1727
1766
|
b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
|
|
1728
1767
|
message: n.message,
|
|
1729
1768
|
reconnectAttempt: this.reconnectAttempts
|
|
1730
|
-
}), this.setState({
|
|
1769
|
+
}), t instanceof X && this.reportTransportDiagnostic("auth_timeout"), this.setState({
|
|
1731
1770
|
status: "reconnecting",
|
|
1732
1771
|
lastError: Zn,
|
|
1733
1772
|
lastErrorCode: "connection_failed"
|
|
1734
1773
|
}), this.emit("error", n), this.scheduleReconnect(
|
|
1735
|
-
t instanceof
|
|
1774
|
+
t instanceof X ? t.retryAfterMs : void 0
|
|
1736
1775
|
);
|
|
1737
1776
|
return;
|
|
1738
1777
|
}
|
|
@@ -1746,7 +1785,7 @@ class xe {
|
|
|
1746
1785
|
}
|
|
1747
1786
|
}
|
|
1748
1787
|
disconnect() {
|
|
1749
|
-
this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
1788
|
+
this.stopSessionRecoveryPolling(), this.connectionAttemptId += 1, this.setState({ status: "closed", pendingMessageStatus: null, isThinking: !1, isRetrying: !1 }), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.clearStarterPromptUrlRefreshTimer(), this.clearRetryTimers(), this.clearThinkingWatchdog(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.clearSessionLoadRequest(), this.rejectPendingSessionHistoryRequests("Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionPinRequests, "Pluno disconnected."), this.rejectPendingSessionMutationRequests(this.pendingSessionRenameRequests, "Pluno disconnected."), this.tokenAbortController?.abort(), this.tokenAbortController = null, this.tokenRequest = null, this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null), this.clientDiagnosticsRetryTimer !== null && (window.clearTimeout(this.clientDiagnosticsRetryTimer), this.clientDiagnosticsRetryTimer = null), this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [], this.queuedClientEvents = [], this.pendingWidgetLifecycleEvents = [], this.clearPendingWarmupAckTimer(), this.pendingPassiveWarmupEvent = null, this.pendingComposerWarmup = null, this.activeComposerWarmupId = null, this.activeComposerWarmupScope = null, this.nonTranscriptToolCallIds.clear(), this.socket?.close(), this.socket = null;
|
|
1750
1789
|
}
|
|
1751
1790
|
destroy() {
|
|
1752
1791
|
this.disconnect(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), jr(this.options.clientId), this.transportIdentity.release(), this.networkCaptureCleanup?.(), this.networkCaptureCleanup = null, this.networkBatchTimer !== null && (window.clearTimeout(this.networkBatchTimer), this.networkBatchTimer = null), this.queuedNetworkEvents = [], this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear();
|
|
@@ -1794,7 +1833,7 @@ class xe {
|
|
|
1794
1833
|
0
|
|
1795
1834
|
) > Ts))
|
|
1796
1835
|
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
1797
|
-
let r = i.map(
|
|
1836
|
+
let r = i.map(De);
|
|
1798
1837
|
if (!n && r.length === 0)
|
|
1799
1838
|
return null;
|
|
1800
1839
|
if (this.pendingClientMessageId)
|
|
@@ -1807,13 +1846,13 @@ class xe {
|
|
|
1807
1846
|
phase: "final_answer",
|
|
1808
1847
|
content: l,
|
|
1809
1848
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1810
|
-
} : null,
|
|
1849
|
+
} : null, d = {
|
|
1811
1850
|
id: `local-${a}`,
|
|
1812
1851
|
role: "user",
|
|
1813
1852
|
content: n,
|
|
1814
1853
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1815
1854
|
...i.length > 0 ? { attachments: i } : {}
|
|
1816
|
-
},
|
|
1855
|
+
}, g = this.state.messages.some((S) => S.id === d.id || S.clientMessageId === a), f = this.state.isThinking, h = this.state.taskStatus, p = this.state.pendingMessageStatus, y = this.state.turnPhase, m = this.state.messages, M = g ? this.state.messages : [
|
|
1817
1856
|
...this.state.messages.map(
|
|
1818
1857
|
(S) => c && S.id === c.id ? {
|
|
1819
1858
|
...S,
|
|
@@ -1821,7 +1860,7 @@ class xe {
|
|
|
1821
1860
|
} : S
|
|
1822
1861
|
),
|
|
1823
1862
|
...!c && u ? [u] : [],
|
|
1824
|
-
|
|
1863
|
+
d
|
|
1825
1864
|
], w = {
|
|
1826
1865
|
assistantDraft: this.state.assistantDraft,
|
|
1827
1866
|
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
@@ -1832,7 +1871,7 @@ class xe {
|
|
|
1832
1871
|
};
|
|
1833
1872
|
this.setState({
|
|
1834
1873
|
messages: M,
|
|
1835
|
-
...
|
|
1874
|
+
...f ? {} : {
|
|
1836
1875
|
assistantDraft: "",
|
|
1837
1876
|
assistantDraftItemId: null,
|
|
1838
1877
|
assistantDraftPhase: null,
|
|
@@ -1840,23 +1879,23 @@ class xe {
|
|
|
1840
1879
|
assistantDraftRunId: null
|
|
1841
1880
|
},
|
|
1842
1881
|
pendingMessageStatus: "sending",
|
|
1843
|
-
turnPhase:
|
|
1844
|
-
isThinking:
|
|
1882
|
+
turnPhase: f ? y : "sending",
|
|
1883
|
+
isThinking: f,
|
|
1845
1884
|
taskStatus: "working",
|
|
1846
1885
|
isRetrying: !1,
|
|
1847
1886
|
lastError: null
|
|
1848
|
-
}),
|
|
1849
|
-
id:
|
|
1887
|
+
}), g || (this.sessionHistoryManager.addOptimistic({
|
|
1888
|
+
id: d.id,
|
|
1850
1889
|
title: null,
|
|
1851
1890
|
customTitle: null,
|
|
1852
|
-
firstUserMessage:
|
|
1891
|
+
firstUserMessage: d.content,
|
|
1853
1892
|
currentPage: o,
|
|
1854
|
-
createdAt:
|
|
1855
|
-
updatedAt:
|
|
1856
|
-
lastActiveAt:
|
|
1893
|
+
createdAt: d.createdAt,
|
|
1894
|
+
updatedAt: d.createdAt,
|
|
1895
|
+
lastActiveAt: d.createdAt,
|
|
1857
1896
|
isActive: !0,
|
|
1858
1897
|
isPinned: !1
|
|
1859
|
-
}), u && !c && this.emit("message", u), this.emit("message",
|
|
1898
|
+
}), u && !c && this.emit("message", u), this.emit("message", d));
|
|
1860
1899
|
try {
|
|
1861
1900
|
const S = [];
|
|
1862
1901
|
for (const T of r) {
|
|
@@ -1871,12 +1910,12 @@ class xe {
|
|
|
1871
1910
|
}
|
|
1872
1911
|
r = S;
|
|
1873
1912
|
} catch (S) {
|
|
1874
|
-
throw
|
|
1875
|
-
...
|
|
1876
|
-
...
|
|
1913
|
+
throw g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
|
|
1914
|
+
...g ? {} : { messages: m },
|
|
1915
|
+
...f ? {} : { ...w, isThinking: !1 },
|
|
1877
1916
|
pendingMessageStatus: p,
|
|
1878
1917
|
turnPhase: y,
|
|
1879
|
-
taskStatus:
|
|
1918
|
+
taskStatus: h
|
|
1880
1919
|
}), S;
|
|
1881
1920
|
}
|
|
1882
1921
|
this.retryableClientMessageId = null;
|
|
@@ -1889,11 +1928,11 @@ class xe {
|
|
|
1889
1928
|
entrySurface: this.options.entrySurface,
|
|
1890
1929
|
content: n,
|
|
1891
1930
|
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1892
|
-
pageContent: D &&
|
|
1893
|
-
attachments: r.length > 0 ? r.map(
|
|
1931
|
+
pageContent: D && At() || void 0,
|
|
1932
|
+
attachments: r.length > 0 ? r.map(De) : void 0,
|
|
1894
1933
|
page: o,
|
|
1895
1934
|
model: this.options.model,
|
|
1896
|
-
metadata:
|
|
1935
|
+
metadata: Kt(this.options.metadata)
|
|
1897
1936
|
};
|
|
1898
1937
|
return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
|
|
1899
1938
|
}
|
|
@@ -1901,7 +1940,7 @@ class xe {
|
|
|
1901
1940
|
return this.options.model;
|
|
1902
1941
|
}
|
|
1903
1942
|
setModel(e) {
|
|
1904
|
-
this.options.model = e, this.options.productVariant === "personal" &&
|
|
1943
|
+
this.options.model = e, this.options.productVariant === "personal" && Qe(e) && (this.personalModelSelectionOverride = e);
|
|
1905
1944
|
}
|
|
1906
1945
|
retryLastMessage() {
|
|
1907
1946
|
const e = this.state.sessionId, t = this.retryableClientMessageId;
|
|
@@ -1967,7 +2006,7 @@ class xe {
|
|
|
1967
2006
|
sizeBytes: e.size,
|
|
1968
2007
|
page: P(),
|
|
1969
2008
|
model: this.options.model,
|
|
1970
|
-
metadata:
|
|
2009
|
+
metadata: Kt(this.options.metadata),
|
|
1971
2010
|
entrySurface: this.options.entrySurface
|
|
1972
2011
|
};
|
|
1973
2012
|
let o;
|
|
@@ -2075,8 +2114,8 @@ class xe {
|
|
|
2075
2114
|
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
2076
2115
|
for (const [t, n] of this.activeBrowserToolCalls)
|
|
2077
2116
|
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
|
|
2078
|
-
|
|
2079
|
-
messages:
|
|
2117
|
+
ls(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
2118
|
+
messages: rs(
|
|
2080
2119
|
this.state.messages,
|
|
2081
2120
|
e.clientMessageId,
|
|
2082
2121
|
e.runId
|
|
@@ -2120,7 +2159,7 @@ class xe {
|
|
|
2120
2159
|
const t = x(), n = new Promise((r, o) => {
|
|
2121
2160
|
const a = window.setTimeout(() => {
|
|
2122
2161
|
this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
|
|
2123
|
-
},
|
|
2162
|
+
}, jt);
|
|
2124
2163
|
this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
|
|
2125
2164
|
}), i = {
|
|
2126
2165
|
type: "sessions.list",
|
|
@@ -2493,8 +2532,8 @@ class xe {
|
|
|
2493
2532
|
signal: AbortSignal.timeout(15e3)
|
|
2494
2533
|
});
|
|
2495
2534
|
if (!c.ok) {
|
|
2496
|
-
const
|
|
2497
|
-
throw Nn(c.status) ? new Error(
|
|
2535
|
+
const d = await c.text() || `History request failed (${c.status})`;
|
|
2536
|
+
throw Nn(c.status) ? new Error(d) : new Se(d);
|
|
2498
2537
|
}
|
|
2499
2538
|
const u = await c.json();
|
|
2500
2539
|
if (!u?.session || !Array.isArray(u.items))
|
|
@@ -2549,7 +2588,7 @@ class xe {
|
|
|
2549
2588
|
return !1;
|
|
2550
2589
|
const t = this.socket;
|
|
2551
2590
|
try {
|
|
2552
|
-
return t.send(JSON.stringify(e)),
|
|
2591
|
+
return t.send(JSON.stringify(e)), Je("client_event", e.type, Bt(e)), !0;
|
|
2553
2592
|
} catch (n) {
|
|
2554
2593
|
return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
2555
2594
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -2559,36 +2598,131 @@ class xe {
|
|
|
2559
2598
|
}
|
|
2560
2599
|
}
|
|
2561
2600
|
reportHealthSignal(e, t = {}) {
|
|
2562
|
-
if (!this.socket || this.socket.readyState !== WebSocket.OPEN)
|
|
2563
|
-
return;
|
|
2564
2601
|
const n = t.clientMessageId ?? this.activeResponseRunId;
|
|
2565
2602
|
if (n) {
|
|
2566
|
-
const
|
|
2567
|
-
if (this.reportedHealthSignalKeys.has(
|
|
2603
|
+
const r = `${e}:${n}`;
|
|
2604
|
+
if (this.reportedHealthSignalKeys.has(r))
|
|
2568
2605
|
return;
|
|
2569
|
-
this.reportedHealthSignalKeys.add(
|
|
2606
|
+
this.reportedHealthSignalKeys.add(r);
|
|
2607
|
+
}
|
|
2608
|
+
const i = {
|
|
2609
|
+
id: crypto.randomUUID(),
|
|
2610
|
+
name: e,
|
|
2611
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2612
|
+
source: "web_sdk",
|
|
2613
|
+
entrySurface: this.options.entrySurface,
|
|
2614
|
+
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
2615
|
+
...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
|
|
2616
|
+
...t
|
|
2617
|
+
};
|
|
2618
|
+
if (this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
2619
|
+
this.queueHealthDiagnostic(i);
|
|
2620
|
+
return;
|
|
2570
2621
|
}
|
|
2571
2622
|
try {
|
|
2572
2623
|
this.socket.send(JSON.stringify({
|
|
2573
2624
|
type: "runtime.health",
|
|
2574
|
-
signal:
|
|
2575
|
-
id: crypto.randomUUID(),
|
|
2576
|
-
name: e,
|
|
2577
|
-
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2578
|
-
source: "web_sdk",
|
|
2579
|
-
entrySurface: this.options.entrySurface,
|
|
2580
|
-
...this.state.sessionId ? { sessionId: this.state.sessionId } : {},
|
|
2581
|
-
...this.activeResponseRunId ? { runId: this.activeResponseRunId } : {},
|
|
2582
|
-
...t
|
|
2583
|
-
}
|
|
2625
|
+
signal: i
|
|
2584
2626
|
}));
|
|
2585
|
-
} catch (
|
|
2627
|
+
} catch (r) {
|
|
2586
2628
|
b("web-sdk.agent", "Pluno health signal send failed", {
|
|
2587
2629
|
name: e,
|
|
2588
|
-
message:
|
|
2630
|
+
message: r instanceof Error ? r.message : String(r)
|
|
2631
|
+
}), this.queueHealthDiagnostic(i);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
/** @internal */
|
|
2635
|
+
reportTransportDiagnostic(e, t = {}) {
|
|
2636
|
+
const n = typeof navigator > "u" ? "unknown" : navigator.onLine === !1 ? "offline" : "online", i = `${e}:${t.closeCode ?? "none"}:${n}`, r = (/* @__PURE__ */ new Date()).toISOString(), o = this.transportDiagnosticEpisodes.get(i), a = {
|
|
2637
|
+
id: o?.id ?? crypto.randomUUID(),
|
|
2638
|
+
phase: e,
|
|
2639
|
+
entrySurface: this.options.entrySurface,
|
|
2640
|
+
firstOccurredAt: o?.firstOccurredAt ?? r,
|
|
2641
|
+
lastOccurredAt: r,
|
|
2642
|
+
occurrenceCount: (o?.occurrenceCount ?? 0) + 1,
|
|
2643
|
+
maxReconnectAttempt: Math.max(o?.maxReconnectAttempt ?? 0, this.reconnectAttempts),
|
|
2644
|
+
connectivity: n,
|
|
2645
|
+
...t
|
|
2646
|
+
};
|
|
2647
|
+
this.transportDiagnosticEpisodes.set(i, a), [1, 3, 10, 30, 100].includes(a.occurrenceCount) && (this.pendingTransportDiagnostics = [
|
|
2648
|
+
...this.pendingTransportDiagnostics.filter((l) => l.id !== a.id),
|
|
2649
|
+
a
|
|
2650
|
+
], this.pendingTransportDiagnostics.splice(0, Math.max(0, this.pendingTransportDiagnostics.length - 20)), this.flushClientDiagnostics());
|
|
2651
|
+
}
|
|
2652
|
+
/** @internal */
|
|
2653
|
+
queueHealthDiagnostic(e) {
|
|
2654
|
+
this.pendingHealthDiagnostics.push(e), this.pendingHealthDiagnostics.splice(0, Math.max(0, this.pendingHealthDiagnostics.length - 20)), this.flushClientDiagnostics();
|
|
2655
|
+
}
|
|
2656
|
+
/** @internal */
|
|
2657
|
+
async flushClientDiagnostics() {
|
|
2658
|
+
if (this.clientDiagnosticsFlush)
|
|
2659
|
+
return await this.clientDiagnosticsFlush;
|
|
2660
|
+
if (this.clientDiagnosticsRetryTimer !== null || this.pendingTransportDiagnostics.length === 0 && this.pendingHealthDiagnostics.length === 0)
|
|
2661
|
+
return;
|
|
2662
|
+
const e = this.performClientDiagnosticsFlush();
|
|
2663
|
+
this.clientDiagnosticsFlush = e;
|
|
2664
|
+
try {
|
|
2665
|
+
await e;
|
|
2666
|
+
} finally {
|
|
2667
|
+
this.clientDiagnosticsFlush === e && (this.clientDiagnosticsFlush = null), this.clientDiagnosticsRetryTimer === null && (this.pendingTransportDiagnostics.length > 0 || this.pendingHealthDiagnostics.length > 0) && this.flushClientDiagnostics();
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
/** @internal */
|
|
2671
|
+
async performClientDiagnosticsFlush() {
|
|
2672
|
+
const e = this.token ?? this.options.token ?? null;
|
|
2673
|
+
if (!e) {
|
|
2674
|
+
if (!this.options.tokenProvider) {
|
|
2675
|
+
this.pendingTransportDiagnostics = [], this.pendingHealthDiagnostics = [];
|
|
2676
|
+
return;
|
|
2677
|
+
}
|
|
2678
|
+
this.scheduleClientDiagnosticsRetry();
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
const t = this.pendingTransportDiagnostics.slice(0, 20), n = this.pendingHealthDiagnostics.slice(0, 20), i = this.options.productVariant === "customer_embedded" ? "/api/product-agent/embed/diagnostics" : "/api/product-agent/runtime/diagnostics";
|
|
2682
|
+
try {
|
|
2683
|
+
const r = await fetch(new URL(i, this.options.backendUrl), {
|
|
2684
|
+
method: "POST",
|
|
2685
|
+
headers: {
|
|
2686
|
+
"content-type": "application/json",
|
|
2687
|
+
authorization: this.options.productVariant === "customer_embedded" ? `Bearer ${e}` : e
|
|
2688
|
+
},
|
|
2689
|
+
body: JSON.stringify({
|
|
2690
|
+
clientId: this.options.clientId,
|
|
2691
|
+
transportId: this.transportIdentity.transportId,
|
|
2692
|
+
transportEpisodes: t,
|
|
2693
|
+
healthSignals: n
|
|
2694
|
+
}),
|
|
2695
|
+
signal: AbortSignal.timeout(1e4)
|
|
2589
2696
|
});
|
|
2697
|
+
if (r.status === 401 || r.status === 403) {
|
|
2698
|
+
const l = new Set(t.map((u) => u.id)), c = new Set(n.map((u) => u.id));
|
|
2699
|
+
this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
|
|
2700
|
+
(u) => !l.has(u.id)
|
|
2701
|
+
), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
|
|
2702
|
+
(u) => !c.has(u.id)
|
|
2703
|
+
);
|
|
2704
|
+
return;
|
|
2705
|
+
}
|
|
2706
|
+
if (!r.ok)
|
|
2707
|
+
throw new Error(`Client diagnostic upload failed (${r.status})`);
|
|
2708
|
+
const o = new Map(
|
|
2709
|
+
t.map((l) => [l.id, l.occurrenceCount])
|
|
2710
|
+
), a = new Set(n.map((l) => l.id));
|
|
2711
|
+
this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
|
|
2712
|
+
(l) => !o.has(l.id) || l.occurrenceCount > (o.get(l.id) ?? 0)
|
|
2713
|
+
), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
|
|
2714
|
+
(l) => !a.has(l.id)
|
|
2715
|
+
);
|
|
2716
|
+
} catch {
|
|
2717
|
+
this.scheduleClientDiagnosticsRetry();
|
|
2590
2718
|
}
|
|
2591
2719
|
}
|
|
2720
|
+
/** @internal */
|
|
2721
|
+
scheduleClientDiagnosticsRetry() {
|
|
2722
|
+
this.clientDiagnosticsRetryTimer !== null || this.state.status === "closed" || (this.clientDiagnosticsRetryTimer = window.setTimeout(() => {
|
|
2723
|
+
this.clientDiagnosticsRetryTimer = null, this.flushClientDiagnostics();
|
|
2724
|
+
}, 3e4));
|
|
2725
|
+
}
|
|
2592
2726
|
requestTransientStarterPrompts() {
|
|
2593
2727
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
2594
2728
|
return;
|
|
@@ -2743,7 +2877,7 @@ class xe {
|
|
|
2743
2877
|
});
|
|
2744
2878
|
}
|
|
2745
2879
|
handleServerEvent(e) {
|
|
2746
|
-
if (
|
|
2880
|
+
if (Je("server_event", e.type, Bt(e)), e.type === "session.subscribed") {
|
|
2747
2881
|
const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
2748
2882
|
if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
2749
2883
|
const i = this.pendingSessionSubscription;
|
|
@@ -2810,7 +2944,7 @@ class xe {
|
|
|
2810
2944
|
return;
|
|
2811
2945
|
}
|
|
2812
2946
|
if (yi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
2813
|
-
this.clearSocketAuthTimer(), this.reconnectAttempts = 0;
|
|
2947
|
+
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear();
|
|
2814
2948
|
const t = Zi(e.user);
|
|
2815
2949
|
this.authenticatedSocket !== this.socket && this.authenticatedUserId && t && t.id !== this.authenticatedUserId && this.resetForAuthenticationScopeChange(), this.authenticatedUserId = t?.id ?? null, this.authenticatedSocket = this.socket, this.flushPendingWidgetLifecycleEvents(), this.flushPendingComposerWarmup(), this.flushQueuedClientEvents(), this.pendingClientMessageId && (this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(this.pendingClientMessageId)), this.flushPendingPassiveWarmup(), this.startHeartbeat();
|
|
2816
2950
|
const n = Qi(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
@@ -2819,7 +2953,7 @@ class xe {
|
|
|
2819
2953
|
rawAppearance: e.appearance,
|
|
2820
2954
|
normalizedAppearance: n
|
|
2821
2955
|
}), this.runtimeHelperJavascript = Vi(e.runtimeHelpers)?.javascript ?? null;
|
|
2822
|
-
const r =
|
|
2956
|
+
const r = Vt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
2823
2957
|
user: t,
|
|
2824
2958
|
status: "connected",
|
|
2825
2959
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
@@ -2828,7 +2962,7 @@ class xe {
|
|
|
2828
2962
|
type: "runtime.auth_ack",
|
|
2829
2963
|
connectionAttempt: this.connectionAttemptId,
|
|
2830
2964
|
entrySurface: this.options.entrySurface
|
|
2831
|
-
}), o && r.length === 0 && !a && !
|
|
2965
|
+
}), o && r.length === 0 && !a && !et() && this.requestTransientStarterPrompts(), this.state.sessionId && this.send({
|
|
2832
2966
|
type: "page.upsert",
|
|
2833
2967
|
sessionId: this.state.sessionId,
|
|
2834
2968
|
page: P(),
|
|
@@ -2838,21 +2972,21 @@ class xe {
|
|
|
2838
2972
|
}
|
|
2839
2973
|
if (e.type === "starterPrompts.updated") {
|
|
2840
2974
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
2841
|
-
starterPrompts:
|
|
2975
|
+
starterPrompts: Vt(e, "starterPrompts"),
|
|
2842
2976
|
starterPromptsLoading: !1
|
|
2843
2977
|
});
|
|
2844
2978
|
return;
|
|
2845
2979
|
}
|
|
2846
2980
|
if (e.type === "scheduled_follow_ups.updated") {
|
|
2847
2981
|
typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
|
|
2848
|
-
activeScheduledFollowUps:
|
|
2982
|
+
activeScheduledFollowUps: Xt(
|
|
2849
2983
|
e.activeScheduledFollowUps
|
|
2850
2984
|
)
|
|
2851
2985
|
});
|
|
2852
2986
|
return;
|
|
2853
2987
|
}
|
|
2854
2988
|
if (e.type === "conversation.state") {
|
|
2855
|
-
const t = Array.isArray(e.items) ? e.items : [], n =
|
|
2989
|
+
const t = Array.isArray(e.items) ? e.items : [], n = qt(t), i = Object.prototype.hasOwnProperty.call(
|
|
2856
2990
|
e,
|
|
2857
2991
|
"activeScheduledFollowUps"
|
|
2858
2992
|
), r = A(e.session, "id") ?? this.state.sessionId, o = typeof e.requestId == "string" ? e.requestId : null, a = this.state.isLoadingSession && this.sessionLoadRequestId === null && o === null && r === this.state.sessionId && this.canLoadSessionHistoryOverHttp();
|
|
@@ -2863,67 +2997,67 @@ class xe {
|
|
|
2863
2997
|
this.forgetSupersededTaskTabClosedTurn(r, C(U));
|
|
2864
2998
|
for (const U of n)
|
|
2865
2999
|
this.rememberDurablyStoppedTurn(r, U);
|
|
2866
|
-
const l = ie(n), c = l === null ? null : n[l], u = C(c),
|
|
3000
|
+
const l = ie(n), c = l === null ? null : n[l], u = C(c), d = this.findStoppedTurn(r, {
|
|
2867
3001
|
clientMessageId: u?.clientMessageId,
|
|
2868
3002
|
respondsToUserMessageId: A(c, "id"),
|
|
2869
3003
|
runId: u?.runId
|
|
2870
|
-
}),
|
|
2871
|
-
|
|
2872
|
-
let
|
|
3004
|
+
}), g = this.filterStoppedSnapshotItems(n, r), f = e.pendingMessageStatus === "sending" ? "sending" : e.pendingMessageStatus === "queued" ? "reconnecting" : null, h = typeof e.pendingClientMessageId == "string" ? e.pendingClientMessageId : null, p = e.isRetrying === !0, y = e.turnPhase === "sending" || e.turnPhase === "starting" || e.turnPhase === "thinking" ? e.turnPhase : null;
|
|
3005
|
+
f && h && (this.pendingClientMessageId = h);
|
|
3006
|
+
let m = ar(
|
|
2873
3007
|
e.assistantDraft
|
|
2874
3008
|
);
|
|
2875
|
-
|
|
2876
|
-
respondsToUserMessageId:
|
|
2877
|
-
runId:
|
|
2878
|
-
}) && (
|
|
2879
|
-
const M =
|
|
2880
|
-
this.rememberUserMessageClientMessageIds(
|
|
2881
|
-
const w = Tr(
|
|
3009
|
+
m && this.findStoppedTurn(r, {
|
|
3010
|
+
respondsToUserMessageId: m.respondsToUserMessageId,
|
|
3011
|
+
runId: m.runId
|
|
3012
|
+
}) && (m = void 0);
|
|
3013
|
+
const M = m !== void 0;
|
|
3014
|
+
this.rememberUserMessageClientMessageIds(g);
|
|
3015
|
+
const w = Tr(g), D = g.filter((U) => {
|
|
2882
3016
|
const q = C(U);
|
|
2883
|
-
return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(
|
|
3017
|
+
return Ir(q) ? !1 : !q || !w || !pe(q) ? !0 : dt(g, q) !== w;
|
|
2884
3018
|
}), S = lt(
|
|
2885
3019
|
this.state.messages,
|
|
2886
|
-
|
|
2887
|
-
), T =
|
|
2888
|
-
(U, q) =>
|
|
3020
|
+
st(D, this.options.backendUrl)
|
|
3021
|
+
), T = ss(S), N = M ? m?.content ?? "" : this.state.assistantDraft, v = M ? m?.itemId ?? null : this.state.assistantDraftItemId, re = M ? m?.respondsToUserMessageId ?? null : this.state.assistantDraftRespondsToUserMessageId, Y = M ? m?.runId ?? null : this.state.assistantDraftRunId, Z = g.some(
|
|
3022
|
+
(U, q) => ns(
|
|
2889
3023
|
C(U),
|
|
2890
3024
|
N,
|
|
2891
3025
|
v,
|
|
2892
3026
|
re,
|
|
2893
|
-
|
|
2894
|
-
wr(
|
|
3027
|
+
Y,
|
|
3028
|
+
wr(g, q)
|
|
2895
3029
|
)
|
|
2896
|
-
),
|
|
2897
|
-
if (!T && Sr(this.state.messages,
|
|
3030
|
+
), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), Q = mr(S), oe = B && Q ? "completed" : d ? "stopped" : B ? "failed" : null;
|
|
3031
|
+
if (!T && Sr(this.state.messages, g))
|
|
2898
3032
|
return;
|
|
2899
|
-
this.lastUserMessagePageUrl = yr(
|
|
2900
|
-
const j = B ||
|
|
3033
|
+
this.lastUserMessagePageUrl = yr(g);
|
|
3034
|
+
const j = B || d ? null : ut(g);
|
|
2901
3035
|
if (this.latestRecoverableClientMessageId = j, Q && this.clearRetryTimers(), this.setState({
|
|
2902
3036
|
sessionId: A(e.session, "id") ?? this.state.sessionId,
|
|
2903
3037
|
messages: S,
|
|
2904
3038
|
...i ? {
|
|
2905
|
-
activeScheduledFollowUps:
|
|
3039
|
+
activeScheduledFollowUps: Xt(
|
|
2906
3040
|
e.activeScheduledFollowUps
|
|
2907
3041
|
)
|
|
2908
3042
|
} : {},
|
|
2909
3043
|
isLoadingSession: !1,
|
|
2910
|
-
...
|
|
3044
|
+
...f ? { pendingMessageStatus: f } : {},
|
|
2911
3045
|
...y ? { turnPhase: y } : {},
|
|
2912
3046
|
isRetrying: p,
|
|
2913
3047
|
...y ? { taskStatus: "working" } : {},
|
|
2914
3048
|
...oe && this.state.taskStatus === "working" ? { taskStatus: oe } : {},
|
|
2915
|
-
...
|
|
3049
|
+
...Z ? {
|
|
2916
3050
|
assistantDraft: "",
|
|
2917
3051
|
assistantDraftItemId: null,
|
|
2918
3052
|
assistantDraftPhase: null,
|
|
2919
3053
|
assistantDraftRespondsToUserMessageId: null,
|
|
2920
3054
|
assistantDraftRunId: null
|
|
2921
3055
|
} : M ? {
|
|
2922
|
-
assistantDraft:
|
|
2923
|
-
assistantDraftItemId:
|
|
2924
|
-
assistantDraftPhase:
|
|
2925
|
-
assistantDraftRespondsToUserMessageId:
|
|
2926
|
-
assistantDraftRunId:
|
|
3056
|
+
assistantDraft: m?.content ?? "",
|
|
3057
|
+
assistantDraftItemId: m?.itemId ?? null,
|
|
3058
|
+
assistantDraftPhase: m?.phase ?? null,
|
|
3059
|
+
assistantDraftRespondsToUserMessageId: m?.respondsToUserMessageId ?? null,
|
|
3060
|
+
assistantDraftRunId: m?.runId ?? null
|
|
2927
3061
|
} : {},
|
|
2928
3062
|
...fe ? {
|
|
2929
3063
|
isThinking: !0,
|
|
@@ -2947,10 +3081,10 @@ class xe {
|
|
|
2947
3081
|
} : {}
|
|
2948
3082
|
}), B)
|
|
2949
3083
|
this.retryableClientMessageId = w, this.clearThinkingWatchdog();
|
|
2950
|
-
else if (!
|
|
3084
|
+
else if (!d && (fe || j)) {
|
|
2951
3085
|
if (j) {
|
|
2952
3086
|
this.activeClientMessageId = j;
|
|
2953
|
-
const U = ie(
|
|
3087
|
+
const U = ie(g), q = U === null ? null : g[U];
|
|
2954
3088
|
this.activeResponseUserMessageId = A(q, "id");
|
|
2955
3089
|
}
|
|
2956
3090
|
this.markThinkingProgress();
|
|
@@ -2964,7 +3098,7 @@ class xe {
|
|
|
2964
3098
|
const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
2965
3099
|
if (!t || n !== this.state.sessionId)
|
|
2966
3100
|
return;
|
|
2967
|
-
const i =
|
|
3101
|
+
const i = st(
|
|
2968
3102
|
Array.isArray(e.items) ? e.items : [],
|
|
2969
3103
|
this.options.backendUrl
|
|
2970
3104
|
);
|
|
@@ -3009,11 +3143,11 @@ class xe {
|
|
|
3009
3143
|
o && (this.retryableClientMessageId = o);
|
|
3010
3144
|
return;
|
|
3011
3145
|
}
|
|
3012
|
-
const n =
|
|
3146
|
+
const n = ve(e.item, this.options.backendUrl);
|
|
3013
3147
|
if (n) {
|
|
3014
3148
|
const i = Cr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
3015
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)),
|
|
3016
|
-
const o = de(this.state.messages, n), a =
|
|
3149
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), F(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Mr(t) && this.clearRunAckResyncRetryTimer();
|
|
3150
|
+
const o = de(this.state.messages, n), a = ss(o), l = ns(
|
|
3017
3151
|
t,
|
|
3018
3152
|
this.state.assistantDraft,
|
|
3019
3153
|
this.state.assistantDraftItemId,
|
|
@@ -3021,9 +3155,9 @@ class xe {
|
|
|
3021
3155
|
this.state.assistantDraftRunId,
|
|
3022
3156
|
_s(
|
|
3023
3157
|
o,
|
|
3024
|
-
o.findIndex((
|
|
3158
|
+
o.findIndex((d) => d.id === n.id)
|
|
3025
3159
|
)
|
|
3026
|
-
), c = a && (!this.state.assistantDraft || l), u =
|
|
3160
|
+
), c = a && (!this.state.assistantDraft || l), u = Ue(n) && (c || F(n) && !this.state.isThinking && this.activeClientMessageId === null);
|
|
3027
3161
|
this.setState({
|
|
3028
3162
|
messages: o,
|
|
3029
3163
|
...l ? {
|
|
@@ -3050,7 +3184,7 @@ class xe {
|
|
|
3050
3184
|
}
|
|
3051
3185
|
if (e.type === "chat.assistant_delta") {
|
|
3052
3186
|
this.clearRunAckResyncRetryTimer();
|
|
3053
|
-
const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((
|
|
3187
|
+
const t = typeof e.delta == "string" ? e.delta : "", n = typeof e.itemId == "string" ? e.itemId : null, i = n !== null && this.state.assistantDraftItemId !== n, r = `${i ? "" : this.state.assistantDraft}${t}`, o = n ?? this.state.assistantDraftItemId ?? "assistant-draft", a = this.state.messages.find((d) => d.id === o), l = e.phase === "commentary" || e.phase === "final_answer" ? e.phase : i ? null : this.state.assistantDraftPhase, c = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : this.state.assistantDraftRespondsToUserMessageId, u = typeof e.runId == "string" ? e.runId : this.state.assistantDraftRunId;
|
|
3054
3188
|
this.activeClientMessageId && (this.activeResponseUserMessageId = c, this.activeResponseRunId = u), this.setState({
|
|
3055
3189
|
messages: de(this.state.messages, {
|
|
3056
3190
|
id: o,
|
|
@@ -3081,7 +3215,7 @@ class xe {
|
|
|
3081
3215
|
const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, i = typeof e.runId == "string" ? e.runId : null;
|
|
3082
3216
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
|
|
3083
3217
|
return;
|
|
3084
|
-
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l =
|
|
3218
|
+
const o = n ? this.clientMessageIdsByUserMessageItemId.get(n) ?? null : null, a = !this.activeClientMessageId || (o ? o === this.activeClientMessageId : this.activeResponseUserMessageId ? !n || n === this.activeResponseUserMessageId : !this.activeResponseRunId || !i || i === this.activeResponseRunId), l = Dt(
|
|
3085
3219
|
this.state.messages.filter(
|
|
3086
3220
|
(c) => c.dataType !== "assistant_draft" || !Ae(
|
|
3087
3221
|
c,
|
|
@@ -3095,7 +3229,7 @@ class xe {
|
|
|
3095
3229
|
);
|
|
3096
3230
|
this.setState({
|
|
3097
3231
|
sessionId: t,
|
|
3098
|
-
messages:
|
|
3232
|
+
messages: Yt(
|
|
3099
3233
|
l,
|
|
3100
3234
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
3101
3235
|
n,
|
|
@@ -3118,9 +3252,9 @@ class xe {
|
|
|
3118
3252
|
if (t)
|
|
3119
3253
|
this.nonTranscriptToolCallIds.add(t);
|
|
3120
3254
|
else {
|
|
3121
|
-
const n =
|
|
3255
|
+
const n = ts(e);
|
|
3122
3256
|
if (n) {
|
|
3123
|
-
const i =
|
|
3257
|
+
const i = Zt(
|
|
3124
3258
|
this.state.messages,
|
|
3125
3259
|
n
|
|
3126
3260
|
);
|
|
@@ -3153,8 +3287,8 @@ class xe {
|
|
|
3153
3287
|
if (e.type === "error") {
|
|
3154
3288
|
if (e.code === "unauthorized" && e.reason === "token_expired" && e.retryable === !0 && this.options.tokenProvider) {
|
|
3155
3289
|
this.invalidateProviderToken(), this.clearSocketPhaseTimers(), this.stopHeartbeat();
|
|
3156
|
-
const
|
|
3157
|
-
this.socket = null, this.setReconnectingState(), this.scheduleReconnect(),
|
|
3290
|
+
const f = this.socket;
|
|
3291
|
+
this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), f?.close();
|
|
3158
3292
|
return;
|
|
3159
3293
|
}
|
|
3160
3294
|
const t = typeof e.requestId == "string" ? e.requestId : null;
|
|
@@ -3190,18 +3324,18 @@ class xe {
|
|
|
3190
3324
|
o && i && r && (this.retryableClientMessageId = r);
|
|
3191
3325
|
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Oi(a.message);
|
|
3192
3326
|
l && console.error(l);
|
|
3193
|
-
const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null,
|
|
3327
|
+
const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = rs(
|
|
3194
3328
|
this.state.messages,
|
|
3195
3329
|
c,
|
|
3196
3330
|
u
|
|
3197
|
-
),
|
|
3198
|
-
|
|
3331
|
+
), g = fr(
|
|
3332
|
+
d,
|
|
3199
3333
|
c,
|
|
3200
3334
|
u
|
|
3201
3335
|
);
|
|
3202
3336
|
if (this.setState({
|
|
3203
|
-
status:
|
|
3204
|
-
messages:
|
|
3337
|
+
status: g ? "connected" : "error",
|
|
3338
|
+
messages: d,
|
|
3205
3339
|
assistantDraft: "",
|
|
3206
3340
|
assistantDraftItemId: null,
|
|
3207
3341
|
assistantDraftPhase: null,
|
|
@@ -3210,13 +3344,13 @@ class xe {
|
|
|
3210
3344
|
isThinking: !1,
|
|
3211
3345
|
...this.state.taskStatus === "working" ? { taskStatus: "failed" } : {},
|
|
3212
3346
|
isRetrying: !1,
|
|
3213
|
-
lastError:
|
|
3214
|
-
lastErrorCode:
|
|
3215
|
-
lastErrorSecuritySettingsUrl:
|
|
3347
|
+
lastError: g ? null : a.message,
|
|
3348
|
+
lastErrorCode: g ? null : typeof e.code == "string" ? e.code : null,
|
|
3349
|
+
lastErrorSecuritySettingsUrl: g ? null : typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : null
|
|
3216
3350
|
}), this.clearThinkingWatchdog(), this.emit("error", a), e.code === "unauthorized") {
|
|
3217
3351
|
this.clearSocketPhaseTimers(), this.stopHeartbeat();
|
|
3218
|
-
const
|
|
3219
|
-
this.socket = null,
|
|
3352
|
+
const f = this.socket;
|
|
3353
|
+
this.socket = null, f?.close();
|
|
3220
3354
|
}
|
|
3221
3355
|
}
|
|
3222
3356
|
}
|
|
@@ -3238,7 +3372,7 @@ class xe {
|
|
|
3238
3372
|
if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
|
|
3239
3373
|
return;
|
|
3240
3374
|
const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
|
|
3241
|
-
this.options.model =
|
|
3375
|
+
this.options.model = Qe(n) ? n : "gpt-5.6-sol";
|
|
3242
3376
|
}
|
|
3243
3377
|
updateAccountFallbackFromSession(e) {
|
|
3244
3378
|
const t = e && typeof e == "object" ? e.metadata : null, n = An(t);
|
|
@@ -3261,9 +3395,9 @@ class xe {
|
|
|
3261
3395
|
return;
|
|
3262
3396
|
const n = this.sessionTimelineCache.get(t);
|
|
3263
3397
|
if (e.type === "conversation.state") {
|
|
3264
|
-
const i =
|
|
3398
|
+
const i = qt(
|
|
3265
3399
|
Array.isArray(e.items) ? e.items : []
|
|
3266
|
-
), r =
|
|
3400
|
+
), r = st(
|
|
3267
3401
|
this.filterStoppedSnapshotItems(i, t),
|
|
3268
3402
|
this.options.backendUrl
|
|
3269
3403
|
);
|
|
@@ -3278,15 +3412,15 @@ class xe {
|
|
|
3278
3412
|
const i = C(e.item);
|
|
3279
3413
|
if (pe(i))
|
|
3280
3414
|
return;
|
|
3281
|
-
const r =
|
|
3415
|
+
const r = ve(e.item, this.options.backendUrl);
|
|
3282
3416
|
r && this.rememberSessionTimeline(t, de(n, r));
|
|
3283
3417
|
return;
|
|
3284
3418
|
}
|
|
3285
3419
|
if (e.type === "tool.call") {
|
|
3286
|
-
const i = e.hiddenFromTranscript === !0 ? null :
|
|
3420
|
+
const i = e.hiddenFromTranscript === !0 ? null : ts(e);
|
|
3287
3421
|
i && this.rememberSessionTimeline(
|
|
3288
3422
|
t,
|
|
3289
|
-
|
|
3423
|
+
Zt(n, i)
|
|
3290
3424
|
);
|
|
3291
3425
|
return;
|
|
3292
3426
|
}
|
|
@@ -3298,7 +3432,7 @@ class xe {
|
|
|
3298
3432
|
return;
|
|
3299
3433
|
this.rememberSessionTimeline(
|
|
3300
3434
|
t,
|
|
3301
|
-
|
|
3435
|
+
es(
|
|
3302
3436
|
n,
|
|
3303
3437
|
e.callId,
|
|
3304
3438
|
i
|
|
@@ -3325,7 +3459,7 @@ class xe {
|
|
|
3325
3459
|
return;
|
|
3326
3460
|
}
|
|
3327
3461
|
if (e.type === "chat.assistant_done") {
|
|
3328
|
-
const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o =
|
|
3462
|
+
const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = Dt(
|
|
3329
3463
|
n.filter(
|
|
3330
3464
|
(a) => a.dataType !== "assistant_draft" || !Ae(a, i, r)
|
|
3331
3465
|
),
|
|
@@ -3335,7 +3469,7 @@ class xe {
|
|
|
3335
3469
|
);
|
|
3336
3470
|
this.rememberSessionTimeline(
|
|
3337
3471
|
t,
|
|
3338
|
-
|
|
3472
|
+
Yt(
|
|
3339
3473
|
o,
|
|
3340
3474
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
3341
3475
|
i,
|
|
@@ -3350,7 +3484,7 @@ class xe {
|
|
|
3350
3484
|
return;
|
|
3351
3485
|
this.rememberSessionTimeline(
|
|
3352
3486
|
t,
|
|
3353
|
-
|
|
3487
|
+
os(
|
|
3354
3488
|
n,
|
|
3355
3489
|
i,
|
|
3356
3490
|
null,
|
|
@@ -3359,7 +3493,7 @@ class xe {
|
|
|
3359
3493
|
);
|
|
3360
3494
|
return;
|
|
3361
3495
|
}
|
|
3362
|
-
e.type === "error" && typeof e.requestId != "string" && !
|
|
3496
|
+
e.type === "error" && typeof e.requestId != "string" && !is(e, t) && this.rememberSessionTimeline(
|
|
3363
3497
|
t,
|
|
3364
3498
|
kr(n, e)
|
|
3365
3499
|
);
|
|
@@ -3395,9 +3529,9 @@ class xe {
|
|
|
3395
3529
|
}
|
|
3396
3530
|
handleRetryableRecoveryError(e) {
|
|
3397
3531
|
const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
3398
|
-
if (!
|
|
3532
|
+
if (!is(e, t) || !n)
|
|
3399
3533
|
return !1;
|
|
3400
|
-
if (
|
|
3534
|
+
if (et())
|
|
3401
3535
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
3402
3536
|
if (this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.retryTimersByClientMessageId[n] === void 0) {
|
|
3403
3537
|
const i = typeof e.retryAfterMs == "number" ? e.retryAfterMs : 2e3;
|
|
@@ -3436,7 +3570,7 @@ class xe {
|
|
|
3436
3570
|
const i = new Promise((r, o) => {
|
|
3437
3571
|
const a = window.setTimeout(() => {
|
|
3438
3572
|
e.delete(t.requestId), o(new Error(n));
|
|
3439
|
-
},
|
|
3573
|
+
}, jt);
|
|
3440
3574
|
e.set(t.requestId, { resolve: r, reject: o, timeout: a });
|
|
3441
3575
|
});
|
|
3442
3576
|
if (!this.sendNow(t)) {
|
|
@@ -3515,7 +3649,7 @@ class xe {
|
|
|
3515
3649
|
return this.pendingClientMessageId === e && this.state.isThinking && this.activeClientMessageId !== null && this.activeClientMessageId !== e;
|
|
3516
3650
|
}
|
|
3517
3651
|
schedulePendingDeliveryAck(e) {
|
|
3518
|
-
this.clearPendingDeliveryTimers(), !
|
|
3652
|
+
this.clearPendingDeliveryTimers(), !et() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
3519
3653
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
3520
3654
|
}, $t));
|
|
3521
3655
|
}
|
|
@@ -3553,7 +3687,7 @@ class xe {
|
|
|
3553
3687
|
if (this.state.isThinking && t) {
|
|
3554
3688
|
const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
|
|
3555
3689
|
this.setState({
|
|
3556
|
-
messages:
|
|
3690
|
+
messages: os(
|
|
3557
3691
|
this.state.messages,
|
|
3558
3692
|
t,
|
|
3559
3693
|
n,
|
|
@@ -3585,7 +3719,7 @@ class xe {
|
|
|
3585
3719
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
3586
3720
|
sessionId: this.state.sessionId,
|
|
3587
3721
|
clientMessageId: e
|
|
3588
|
-
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
3722
|
+
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft));
|
|
3589
3723
|
}
|
|
3590
3724
|
clearRunAckResyncRetryTimer() {
|
|
3591
3725
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -3618,7 +3752,7 @@ class xe {
|
|
|
3618
3752
|
sessionId: this.state.sessionId,
|
|
3619
3753
|
clientMessageId: e,
|
|
3620
3754
|
resyncAttempts: t + 1
|
|
3621
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
3755
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(Ft);
|
|
3622
3756
|
}
|
|
3623
3757
|
resyncThinkingSession() {
|
|
3624
3758
|
this.state.sessionId ? this.send({
|
|
@@ -3682,13 +3816,13 @@ class xe {
|
|
|
3682
3816
|
startedAtOrigin: location.origin
|
|
3683
3817
|
}), this.installSessionBrowserApis();
|
|
3684
3818
|
let c = null, u;
|
|
3685
|
-
c = await this.executeRuntimeHelper(), u = await
|
|
3819
|
+
c = await this.executeRuntimeHelper(), u = await Gt(
|
|
3686
3820
|
o,
|
|
3687
3821
|
_i(e.runtimeContext, this.options.backendUrl)
|
|
3688
|
-
).catch((
|
|
3822
|
+
).catch((d) => ({
|
|
3689
3823
|
ok: !1,
|
|
3690
3824
|
exception: {
|
|
3691
|
-
message:
|
|
3825
|
+
message: d instanceof Error ? d.message : String(d)
|
|
3692
3826
|
}
|
|
3693
3827
|
})), this.activeBrowserToolCalls.has(n) && (this.activeBrowserToolCalls.delete(n), this.setToolMessageLoading(n, !1), this.send({
|
|
3694
3828
|
type: "tool.result",
|
|
@@ -3698,10 +3832,10 @@ class xe {
|
|
|
3698
3832
|
summary: o.summary,
|
|
3699
3833
|
rawInput: L(o),
|
|
3700
3834
|
rawOutput: L(Xi(u, c))
|
|
3701
|
-
}),
|
|
3835
|
+
}), ls(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
3702
3836
|
}
|
|
3703
3837
|
setToolMessageLoading(e, t) {
|
|
3704
|
-
const n =
|
|
3838
|
+
const n = es(
|
|
3705
3839
|
this.state.messages,
|
|
3706
3840
|
e,
|
|
3707
3841
|
t
|
|
@@ -3727,7 +3861,7 @@ class xe {
|
|
|
3727
3861
|
async executeRuntimeHelper() {
|
|
3728
3862
|
if (!this.runtimeHelperJavascript?.trim())
|
|
3729
3863
|
return null;
|
|
3730
|
-
const e = await
|
|
3864
|
+
const e = await Gt({
|
|
3731
3865
|
javascript: this.runtimeHelperJavascript
|
|
3732
3866
|
});
|
|
3733
3867
|
return e.ok === !1 ? Ji(e) : null;
|
|
@@ -3753,7 +3887,7 @@ class xe {
|
|
|
3753
3887
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
3754
3888
|
return;
|
|
3755
3889
|
const t = Math.min(
|
|
3756
|
-
|
|
3890
|
+
ot,
|
|
3757
3891
|
Math.max(di(this.reconnectAttempts), e)
|
|
3758
3892
|
);
|
|
3759
3893
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
@@ -3810,7 +3944,7 @@ class xe {
|
|
|
3810
3944
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
3811
3945
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
3812
3946
|
}, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null;
|
|
3813
|
-
this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()),
|
|
3947
|
+
this.state = o, o.sessionId && (o.sessionId === a && c !== l || o.sessionId !== a && c) && this.sessionHistoryManager.setActivity(o.sessionId, c), this.rebuildRuntimeInteractions(), e.messages !== void 0 && this.refreshRuntimeInteractions(), this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages), Nr(this.options.clientId, this.state), this.emit("state", this.getState()), Je("state", this.state.status, {
|
|
3814
3948
|
status: this.state.status,
|
|
3815
3949
|
sessionId: this.state.sessionId,
|
|
3816
3950
|
messageCount: this.state.messages.length,
|
|
@@ -3868,7 +4002,7 @@ class xe {
|
|
|
3868
4002
|
this.listeners[e]?.forEach((i) => i(t));
|
|
3869
4003
|
}
|
|
3870
4004
|
}
|
|
3871
|
-
const
|
|
4005
|
+
const Ze = /* @__PURE__ */ new WeakMap();
|
|
3872
4006
|
function fi(s) {
|
|
3873
4007
|
const e = window.__plunoProductAgentNetworkCapture ?? mi();
|
|
3874
4008
|
return e.subscribers.add(s), () => {
|
|
@@ -3876,30 +4010,30 @@ function fi(s) {
|
|
|
3876
4010
|
};
|
|
3877
4011
|
}
|
|
3878
4012
|
function mi() {
|
|
3879
|
-
const s = /* @__PURE__ */ new Set(), e = (
|
|
3880
|
-
s.forEach((
|
|
4013
|
+
const s = /* @__PURE__ */ new Set(), e = (g) => {
|
|
4014
|
+
s.forEach((f) => {
|
|
3881
4015
|
try {
|
|
3882
|
-
g
|
|
4016
|
+
f(g);
|
|
3883
4017
|
} catch {
|
|
3884
4018
|
}
|
|
3885
4019
|
});
|
|
3886
|
-
}, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(
|
|
4020
|
+
}, t = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, o = function(f, h) {
|
|
3887
4021
|
const p = Date.now();
|
|
3888
4022
|
let y;
|
|
3889
4023
|
try {
|
|
3890
|
-
y = t.call(this,
|
|
3891
|
-
} catch (
|
|
3892
|
-
throw
|
|
4024
|
+
y = t.call(this, f, h);
|
|
4025
|
+
} catch (m) {
|
|
4026
|
+
throw m;
|
|
3893
4027
|
}
|
|
3894
4028
|
try {
|
|
3895
|
-
const
|
|
3896
|
-
if (!te(M, w,
|
|
4029
|
+
const m = f instanceof Request ? f : null, M = Jr(f, m), w = xs(h?.headers ?? m?.headers);
|
|
4030
|
+
if (!te(M, w, h?.body)) {
|
|
3897
4031
|
const H = {
|
|
3898
|
-
requestId:
|
|
3899
|
-
url: W(M,
|
|
3900
|
-
method: (
|
|
4032
|
+
requestId: nt("fetch"),
|
|
4033
|
+
url: W(M, Ye),
|
|
4034
|
+
method: (h?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
3901
4035
|
requestHeaders: w,
|
|
3902
|
-
requestBody:
|
|
4036
|
+
requestBody: us(h?.body),
|
|
3903
4037
|
resourceType: "fetch",
|
|
3904
4038
|
startedAt: new Date(p).toISOString()
|
|
3905
4039
|
};
|
|
@@ -3925,42 +4059,42 @@ function mi() {
|
|
|
3925
4059
|
} catch {
|
|
3926
4060
|
}
|
|
3927
4061
|
return y;
|
|
3928
|
-
}, a = function(
|
|
3929
|
-
const M = n.call(this,
|
|
3930
|
-
return
|
|
3931
|
-
requestId:
|
|
3932
|
-
method: String(
|
|
3933
|
-
url: W(w,
|
|
4062
|
+
}, a = function(f, h, p, y, m) {
|
|
4063
|
+
const M = n.call(this, f, h, p ?? !0, y ?? void 0, m ?? void 0), w = typeof h == "string" ? h : h.toString();
|
|
4064
|
+
return Ze.set(this, {
|
|
4065
|
+
requestId: nt("xhr"),
|
|
4066
|
+
method: String(f ?? "GET").toUpperCase(),
|
|
4067
|
+
url: W(w, Ye),
|
|
3934
4068
|
requestHeaders: {},
|
|
3935
4069
|
startedAtMs: Date.now(),
|
|
3936
4070
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3937
4071
|
excluded: te(w)
|
|
3938
4072
|
}), M;
|
|
3939
|
-
}, l = function(
|
|
3940
|
-
const p = i.call(this,
|
|
3941
|
-
return y && Object.keys(y.requestHeaders).length <
|
|
3942
|
-
}, c = function(
|
|
4073
|
+
}, l = function(f, h) {
|
|
4074
|
+
const p = i.call(this, f, h), y = Ze.get(this);
|
|
4075
|
+
return y && Object.keys(y.requestHeaders).length < wt && (y.requestHeaders[f] = Rt(f, h), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
|
|
4076
|
+
}, c = function(f) {
|
|
3943
4077
|
try {
|
|
3944
|
-
const
|
|
3945
|
-
|
|
4078
|
+
const h = Ze.get(this);
|
|
4079
|
+
h && (h.excluded = h.excluded || te(h.url, h.requestHeaders, f), h.requestBody = us(f), h.excluded || this.addEventListener(
|
|
3946
4080
|
"loadend",
|
|
3947
4081
|
() => {
|
|
3948
4082
|
queueMicrotask(() => {
|
|
3949
4083
|
try {
|
|
3950
4084
|
const p = io(this.getAllResponseHeaders());
|
|
3951
4085
|
e({
|
|
3952
|
-
requestId:
|
|
3953
|
-
url:
|
|
3954
|
-
method:
|
|
3955
|
-
requestHeaders:
|
|
3956
|
-
requestBody:
|
|
4086
|
+
requestId: h.requestId,
|
|
4087
|
+
url: h.url,
|
|
4088
|
+
method: h.method,
|
|
4089
|
+
requestHeaders: h.requestHeaders,
|
|
4090
|
+
requestBody: h.requestBody,
|
|
3957
4091
|
resourceType: "xhr",
|
|
3958
4092
|
responseStatus: this.status,
|
|
3959
4093
|
responseHeaders: p,
|
|
3960
4094
|
responseBody: eo(this, p),
|
|
3961
4095
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
3962
|
-
startedAt:
|
|
3963
|
-
durationMs: Date.now() -
|
|
4096
|
+
startedAt: h.startedAt,
|
|
4097
|
+
durationMs: Date.now() - h.startedAtMs
|
|
3964
4098
|
});
|
|
3965
4099
|
} catch {
|
|
3966
4100
|
return;
|
|
@@ -3971,7 +4105,7 @@ function mi() {
|
|
|
3971
4105
|
));
|
|
3972
4106
|
} catch {
|
|
3973
4107
|
}
|
|
3974
|
-
return r.call(this,
|
|
4108
|
+
return r.call(this, f ?? null);
|
|
3975
4109
|
};
|
|
3976
4110
|
try {
|
|
3977
4111
|
window.fetch = o;
|
|
@@ -3991,20 +4125,20 @@ function mi() {
|
|
|
3991
4125
|
}
|
|
3992
4126
|
let u = null;
|
|
3993
4127
|
if (typeof PerformanceObserver < "u") {
|
|
3994
|
-
u = new PerformanceObserver((
|
|
3995
|
-
for (const
|
|
3996
|
-
const
|
|
3997
|
-
if (
|
|
4128
|
+
u = new PerformanceObserver((g) => {
|
|
4129
|
+
for (const f of g.getEntries()) {
|
|
4130
|
+
const h = f;
|
|
4131
|
+
if (h.initiatorType === "fetch" || h.initiatorType === "xmlhttprequest" || te(h.name))
|
|
3998
4132
|
continue;
|
|
3999
|
-
const p = performance.timeOrigin +
|
|
4133
|
+
const p = performance.timeOrigin + h.startTime;
|
|
4000
4134
|
e({
|
|
4001
|
-
requestId:
|
|
4002
|
-
url: W(
|
|
4135
|
+
requestId: nt("resource"),
|
|
4136
|
+
url: W(h.name, Ye),
|
|
4003
4137
|
method: "GET",
|
|
4004
4138
|
resourceType: "resource",
|
|
4005
|
-
responseStatus:
|
|
4139
|
+
responseStatus: h.responseStatus,
|
|
4006
4140
|
startedAt: new Date(p).toISOString(),
|
|
4007
|
-
durationMs:
|
|
4141
|
+
durationMs: h.duration
|
|
4008
4142
|
});
|
|
4009
4143
|
}
|
|
4010
4144
|
});
|
|
@@ -4014,7 +4148,7 @@ function mi() {
|
|
|
4014
4148
|
u.disconnect(), u = null;
|
|
4015
4149
|
}
|
|
4016
4150
|
}
|
|
4017
|
-
const
|
|
4151
|
+
const d = {
|
|
4018
4152
|
subscribers: s,
|
|
4019
4153
|
destroy: () => {
|
|
4020
4154
|
u?.disconnect();
|
|
@@ -4036,7 +4170,7 @@ function mi() {
|
|
|
4036
4170
|
}
|
|
4037
4171
|
}
|
|
4038
4172
|
};
|
|
4039
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
4173
|
+
return window.__plunoProductAgentNetworkCapture = d, d;
|
|
4040
4174
|
}
|
|
4041
4175
|
function b(s, e, t) {
|
|
4042
4176
|
if (typeof window > "u")
|
|
@@ -4049,7 +4183,7 @@ function b(s, e, t) {
|
|
|
4049
4183
|
}, r = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
4050
4184
|
r.push(i), r.length > 120 && r.splice(0, r.length - 120), n.__plunoProductAgentDiagnostics__ = r, n.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...r], window.dispatchEvent(new CustomEvent("product-agent:preview-diagnostic", { detail: i }));
|
|
4051
4185
|
}
|
|
4052
|
-
function
|
|
4186
|
+
function Kt(s) {
|
|
4053
4187
|
const e = typeof s == "function" ? s() : s;
|
|
4054
4188
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
4055
4189
|
}
|
|
@@ -4086,10 +4220,10 @@ function Ti() {
|
|
|
4086
4220
|
};
|
|
4087
4221
|
}
|
|
4088
4222
|
function wi() {
|
|
4089
|
-
return
|
|
4223
|
+
return hs(globalThis, "getPageSnapshot", async () => At());
|
|
4090
4224
|
}
|
|
4091
4225
|
function Ai() {
|
|
4092
|
-
return
|
|
4226
|
+
return hs(globalThis, "pageImages", {
|
|
4093
4227
|
inspectImage: async (e, t) => await Mi(e, t)
|
|
4094
4228
|
});
|
|
4095
4229
|
}
|
|
@@ -4166,7 +4300,7 @@ function Pi(s) {
|
|
|
4166
4300
|
}, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
|
|
4167
4301
|
});
|
|
4168
4302
|
}
|
|
4169
|
-
async function
|
|
4303
|
+
async function Gt(s, e) {
|
|
4170
4304
|
const t = Object.getPrototypeOf(async function() {
|
|
4171
4305
|
}).constructor, n = s.timeoutMs ?? Ii, i = Date.now(), r = [];
|
|
4172
4306
|
let o;
|
|
@@ -4182,8 +4316,8 @@ async function Kt(s, e) {
|
|
|
4182
4316
|
try {
|
|
4183
4317
|
const c = /* @__PURE__ */ Symbol("execute_code_timeout"), u = await Promise.race([
|
|
4184
4318
|
new t("sandboxFiles", s.javascript)(e?.value),
|
|
4185
|
-
new Promise((
|
|
4186
|
-
o = window.setTimeout(() =>
|
|
4319
|
+
new Promise((d) => {
|
|
4320
|
+
o = window.setTimeout(() => d(c), n);
|
|
4187
4321
|
})
|
|
4188
4322
|
]);
|
|
4189
4323
|
return u === c ? vi(n) : {
|
|
@@ -4248,8 +4382,8 @@ function _i(s, e) {
|
|
|
4248
4382
|
);
|
|
4249
4383
|
if (!l.ok)
|
|
4250
4384
|
throw new Error(`sandboxFiles.download failed (${l.status})`);
|
|
4251
|
-
const c = await l.blob(),
|
|
4252
|
-
return new File([c],
|
|
4385
|
+
const c = await l.blob(), d = (l.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
4386
|
+
return new File([c], d || a.split("/").pop() || "file", {
|
|
4253
4387
|
type: c.type
|
|
4254
4388
|
});
|
|
4255
4389
|
}
|
|
@@ -4311,7 +4445,7 @@ function Li() {
|
|
|
4311
4445
|
return {
|
|
4312
4446
|
pageUrl: location.href,
|
|
4313
4447
|
pageTitle: document.title,
|
|
4314
|
-
htmlContent:
|
|
4448
|
+
htmlContent: At()
|
|
4315
4449
|
};
|
|
4316
4450
|
}
|
|
4317
4451
|
function Ni(s) {
|
|
@@ -4334,24 +4468,24 @@ function Hi() {
|
|
|
4334
4468
|
window.history.pushState === n && (window.history.pushState = e), window.history.replaceState === i && (window.history.replaceState = t), window.removeEventListener("popstate", s), window.removeEventListener("hashchange", s);
|
|
4335
4469
|
};
|
|
4336
4470
|
}
|
|
4337
|
-
function
|
|
4471
|
+
function et() {
|
|
4338
4472
|
return ks()?.surface === "browser_extension_sdk_preview";
|
|
4339
4473
|
}
|
|
4340
|
-
function
|
|
4474
|
+
function At() {
|
|
4341
4475
|
if (!document.body)
|
|
4342
4476
|
return "";
|
|
4343
4477
|
const s = [], e = [], t = (p, y) => {
|
|
4344
|
-
const
|
|
4345
|
-
!
|
|
4478
|
+
const m = ne(y);
|
|
4479
|
+
!m || e.includes(m) || (s.push([p, m]), e.push(m));
|
|
4346
4480
|
};
|
|
4347
4481
|
t("Selected text", window.getSelection()?.toString() ?? "");
|
|
4348
4482
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
|
|
4349
4483
|
(p) => Ms(p) && !p.parentElement?.closest(n)
|
|
4350
4484
|
);
|
|
4351
4485
|
for (const p of i.slice(0, 3))
|
|
4352
|
-
t("Active overlay",
|
|
4353
|
-
const r = Bi(), o = r ?
|
|
4354
|
-
t("Main page content", o), t("Additional visible page text",
|
|
4486
|
+
t("Active overlay", tt(he(p), e));
|
|
4487
|
+
const r = Bi(), o = r ? tt(he(r), e) : "";
|
|
4488
|
+
t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
|
|
4355
4489
|
const a = s.map(([p, y]) => `${p}:
|
|
4356
4490
|
${y}`).join(`
|
|
4357
4491
|
|
|
@@ -4359,8 +4493,8 @@ ${y}`).join(`
|
|
|
4359
4493
|
`, u = `
|
|
4360
4494
|
|
|
4361
4495
|
Visible page text:
|
|
4362
|
-
`,
|
|
4363
|
-
return `${c}${
|
|
4496
|
+
`, d = 12e3 - c.length - u.length, g = Math.min(a.length, 7900), f = l.slice(0, d - g), h = a.slice(0, d - f.length);
|
|
4497
|
+
return `${c}${f}${u}${h}`;
|
|
4364
4498
|
}
|
|
4365
4499
|
function he(s) {
|
|
4366
4500
|
return s.innerText ?? s.textContent ?? "";
|
|
@@ -4373,7 +4507,7 @@ function ne(s) {
|
|
|
4373
4507
|
|
|
4374
4508
|
`).trim();
|
|
4375
4509
|
}
|
|
4376
|
-
function
|
|
4510
|
+
function tt(s, e) {
|
|
4377
4511
|
let t = ne(s);
|
|
4378
4512
|
for (const n of e)
|
|
4379
4513
|
t = t.replace(n, "");
|
|
@@ -4466,22 +4600,22 @@ function Wi(s, e) {
|
|
|
4466
4600
|
"data-test",
|
|
4467
4601
|
"data-qa",
|
|
4468
4602
|
"data-cy"
|
|
4469
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets:
|
|
4470
|
-
e &&
|
|
4471
|
-
let
|
|
4472
|
-
const
|
|
4603
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = Fi(), g = new Set(s);
|
|
4604
|
+
e && g.add(e);
|
|
4605
|
+
let f = 0;
|
|
4606
|
+
const h = (w) => {
|
|
4473
4607
|
const D = w.getAttribute("role");
|
|
4474
4608
|
return D && !o.has(D) ? D : "";
|
|
4475
4609
|
}, p = (w) => {
|
|
4476
4610
|
const D = w.getAttribute("data-testid") || w.getAttribute("data-test") || w.getAttribute("data-qa") || w.getAttribute("data-cy") || "";
|
|
4477
|
-
return `${w.tagName.toLowerCase()}|${
|
|
4611
|
+
return `${w.tagName.toLowerCase()}|${h(w)}|${D}`;
|
|
4478
4612
|
}, y = (w, D, H) => {
|
|
4479
4613
|
const S = (T, N) => {
|
|
4480
|
-
const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T),
|
|
4481
|
-
if (
|
|
4614
|
+
const v = T.tagName.toLowerCase(), re = window.getComputedStyle(T), Y = u.has(T);
|
|
4615
|
+
if (f >= 1e3 && !Y || H.has(T) || r.has(v) || T.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || re.display === "none" || re.visibility === "hidden")
|
|
4482
4616
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
4483
|
-
|
|
4484
|
-
const
|
|
4617
|
+
f += 1;
|
|
4618
|
+
const Z = h(T), ee = Rs(T), fe = a.has(Z) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(v) || v === "a" && T.hasAttribute("href"), B = Array.from(T.children).filter((I) => I instanceof HTMLElement), Q = /* @__PURE__ */ new Map();
|
|
4485
4619
|
for (const I of B) {
|
|
4486
4620
|
const R = p(I);
|
|
4487
4621
|
Q.set(R, (Q.get(R) ?? 0) + 1);
|
|
@@ -4491,59 +4625,59 @@ function Wi(s, e) {
|
|
|
4491
4625
|
const R = p(I), z = oe.get(R) ?? 0;
|
|
4492
4626
|
oe.set(R, z + 1), (Q.get(R) ?? 0) > 8 && z >= 6 && !u.has(I) && me.set(R, (me.get(R) ?? 0) + 1);
|
|
4493
4627
|
}
|
|
4494
|
-
const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [],
|
|
4628
|
+
const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], kt = [];
|
|
4495
4629
|
for (const I of B) {
|
|
4496
|
-
const R = p(I), z = Q.get(R) ?? 0,
|
|
4497
|
-
if (j.set(R,
|
|
4630
|
+
const R = p(I), z = Q.get(R) ?? 0, Pt = j.get(R) ?? 0;
|
|
4631
|
+
if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
|
|
4498
4632
|
U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
|
|
4499
4633
|
continue;
|
|
4500
4634
|
}
|
|
4501
|
-
const
|
|
4502
|
-
|
|
4635
|
+
const _t = S(I, N);
|
|
4636
|
+
kt.push(_t), q.push(_t.lines);
|
|
4503
4637
|
}
|
|
4504
|
-
const
|
|
4638
|
+
const Be = [];
|
|
4505
4639
|
if (T.shadowRoot)
|
|
4506
4640
|
for (const I of Array.from(T.shadowRoot.children))
|
|
4507
|
-
I instanceof HTMLElement &&
|
|
4508
|
-
const ye = [...
|
|
4509
|
-
[
|
|
4510
|
-
).slice(0, 180), js = T.hasAttribute("contenteditable") && (
|
|
4511
|
-
if (
|
|
4512
|
-
const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ?
|
|
4641
|
+
I instanceof HTMLElement && Be.push(S(I, N + 1));
|
|
4642
|
+
const ye = [...kt, ...Be], We = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Et = ne(
|
|
4643
|
+
[ee, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
4644
|
+
).slice(0, 180), js = T.hasAttribute("contenteditable") && (ee.length > 0 || !T.querySelector("[contenteditable]")), Ct = c.some((I) => T.hasAttribute(I)) || !!Z || js, Fe = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || Ct || Y) && (We || Y) && (!i.has(v) || We || Ct || Y), $e = Fe ? 1 : 0, ae = [];
|
|
4645
|
+
if (Fe) {
|
|
4646
|
+
const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Et : ee;
|
|
4513
4647
|
ae.push(bs(T, l, o, R.slice(0, 180)));
|
|
4514
4648
|
}
|
|
4515
4649
|
for (const I of q)
|
|
4516
4650
|
ae.push(...we(I, $e));
|
|
4517
|
-
const
|
|
4518
|
-
if (
|
|
4519
|
-
const I =
|
|
4520
|
-
|
|
4651
|
+
const je = Be.flatMap((I) => I.lines);
|
|
4652
|
+
if (je.length > 0) {
|
|
4653
|
+
const I = je.slice(0, 20);
|
|
4654
|
+
je.length > I.length && I.push("… shadow DOM omitted");
|
|
4521
4655
|
const R = v.includes("tooltip") || v.includes("popper") || v.includes("loader");
|
|
4522
4656
|
if (N < 2 && !R) {
|
|
4523
|
-
const z =
|
|
4657
|
+
const z = Fe ? "#shadow-root" : `${v} #shadow-root`;
|
|
4524
4658
|
ae.push(...we([z, ...we(I, 1)], $e));
|
|
4525
4659
|
} else
|
|
4526
4660
|
ae.push(...we(I, $e));
|
|
4527
4661
|
}
|
|
4528
4662
|
return {
|
|
4529
4663
|
lines: ae,
|
|
4530
|
-
hasUsefulContent:
|
|
4531
|
-
textPreview:
|
|
4664
|
+
hasUsefulContent: We,
|
|
4665
|
+
textPreview: Et,
|
|
4532
4666
|
containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
|
|
4533
4667
|
};
|
|
4534
4668
|
};
|
|
4535
4669
|
return [`--- ${D} ---`, ...S(w, 0).lines].join(`
|
|
4536
4670
|
`);
|
|
4537
|
-
},
|
|
4538
|
-
M &&
|
|
4539
|
-
${JSON.stringify(M)}`),
|
|
4671
|
+
}, m = [], M = ne(window.getSelection()?.toString() ?? "");
|
|
4672
|
+
M && m.push(`--- selected text ---
|
|
4673
|
+
${JSON.stringify(M)}`), d.length > 0 && m.push($i(d, t, l, o));
|
|
4540
4674
|
for (const w of s.slice(0, 3))
|
|
4541
|
-
|
|
4542
|
-
if (e &&
|
|
4675
|
+
m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
4676
|
+
if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
4543
4677
|
const w = e || s.length ? "other visible DOM" : "visible DOM";
|
|
4544
|
-
|
|
4678
|
+
m.push(y(document.body, w, g));
|
|
4545
4679
|
}
|
|
4546
|
-
return
|
|
4680
|
+
return m.join(`
|
|
4547
4681
|
|
|
4548
4682
|
`);
|
|
4549
4683
|
}
|
|
@@ -4564,7 +4698,7 @@ function bs(s, e, t, n) {
|
|
|
4564
4698
|
s.hasAttribute(a) && (r += `[${a}]`);
|
|
4565
4699
|
return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
4566
4700
|
}
|
|
4567
|
-
function
|
|
4701
|
+
function Fi() {
|
|
4568
4702
|
const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
|
|
4569
4703
|
if (!a)
|
|
4570
4704
|
return;
|
|
@@ -4573,11 +4707,11 @@ function $i() {
|
|
|
4573
4707
|
return;
|
|
4574
4708
|
const u = e.get(a) ?? /* @__PURE__ */ new Set();
|
|
4575
4709
|
u.add(l), e.set(a, u);
|
|
4576
|
-
let
|
|
4577
|
-
for (;
|
|
4578
|
-
s.add(
|
|
4579
|
-
const
|
|
4580
|
-
|
|
4710
|
+
let d = a;
|
|
4711
|
+
for (; d; ) {
|
|
4712
|
+
s.add(d);
|
|
4713
|
+
const g = d.getRootNode();
|
|
4714
|
+
d = d.parentElement ?? (g instanceof ShadowRoot && g.host instanceof HTMLElement ? g.host : null);
|
|
4581
4715
|
}
|
|
4582
4716
|
};
|
|
4583
4717
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -4585,7 +4719,7 @@ function $i() {
|
|
|
4585
4719
|
n = n.shadowRoot.activeElement;
|
|
4586
4720
|
n !== document.body && n !== document.documentElement && t(n, "focused");
|
|
4587
4721
|
const i = window.getSelection();
|
|
4588
|
-
i && !i.isCollapsed && (t(
|
|
4722
|
+
i && !i.isCollapsed && (t(Qt(i.anchorNode), "selected text"), t(Qt(i.focusNode), "selected text"));
|
|
4589
4723
|
const r = [
|
|
4590
4724
|
["[aria-selected='true']", "selected"],
|
|
4591
4725
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -4597,8 +4731,8 @@ function $i() {
|
|
|
4597
4731
|
for (let a = 0; a < o.length; a += 1) {
|
|
4598
4732
|
const l = o[a];
|
|
4599
4733
|
for (const [c, u] of r)
|
|
4600
|
-
for (const
|
|
4601
|
-
t(
|
|
4734
|
+
for (const d of Array.from(l.querySelectorAll(c)))
|
|
4735
|
+
t(d, u);
|
|
4602
4736
|
for (const c of Array.from(l.querySelectorAll("*")))
|
|
4603
4737
|
c.shadowRoot && o.push(c.shadowRoot);
|
|
4604
4738
|
}
|
|
@@ -4607,7 +4741,7 @@ function $i() {
|
|
|
4607
4741
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
4608
4742
|
};
|
|
4609
4743
|
}
|
|
4610
|
-
function
|
|
4744
|
+
function $i(s, e, t, n) {
|
|
4611
4745
|
const i = ["--- active/current elements ---"];
|
|
4612
4746
|
for (const r of s) {
|
|
4613
4747
|
const o = [];
|
|
@@ -4615,21 +4749,21 @@ function Fi(s, e, t, n) {
|
|
|
4615
4749
|
for (; a; ) {
|
|
4616
4750
|
const u = a.tagName.toLowerCase();
|
|
4617
4751
|
(a === r.element || e.has(u) || a.hasAttribute("id") || a.hasAttribute("role") || a.hasAttribute("aria-label")) && o.unshift(a);
|
|
4618
|
-
const
|
|
4619
|
-
a = a.parentElement ?? (
|
|
4752
|
+
const d = a.getRootNode();
|
|
4753
|
+
a = a.parentElement ?? (d instanceof ShadowRoot && d.host instanceof HTMLElement ? d.host : null);
|
|
4620
4754
|
}
|
|
4621
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u,
|
|
4755
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, d) => bs(
|
|
4622
4756
|
u,
|
|
4623
4757
|
t,
|
|
4624
4758
|
n,
|
|
4625
|
-
|
|
4759
|
+
d === l.length - 1 ? Rs(u).slice(0, 180) : ""
|
|
4626
4760
|
));
|
|
4627
4761
|
o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
|
|
4628
4762
|
}
|
|
4629
4763
|
return i.join(`
|
|
4630
4764
|
`);
|
|
4631
4765
|
}
|
|
4632
|
-
function
|
|
4766
|
+
function Qt(s) {
|
|
4633
4767
|
return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
|
|
4634
4768
|
}
|
|
4635
4769
|
function we(s, e) {
|
|
@@ -4647,7 +4781,7 @@ function ji(s) {
|
|
|
4647
4781
|
return s.length <= 64 && /^[A-Za-z_][A-Za-z0-9_:.-]*$/.test(s) && !/[a-f0-9]{12,}/i.test(s) && !/:r[0-9a-z]+:/i.test(s);
|
|
4648
4782
|
}
|
|
4649
4783
|
function ks() {
|
|
4650
|
-
const s = Array.from(document.querySelectorAll(
|
|
4784
|
+
const s = Array.from(document.querySelectorAll(Ht)), e = s.find(
|
|
4651
4785
|
(r) => typeof r[On] == "string"
|
|
4652
4786
|
);
|
|
4653
4787
|
if (!(e ?? s[0]))
|
|
@@ -4659,7 +4793,7 @@ function ks() {
|
|
|
4659
4793
|
selectors: [
|
|
4660
4794
|
{
|
|
4661
4795
|
name: "widget_host",
|
|
4662
|
-
selector:
|
|
4796
|
+
selector: Ht,
|
|
4663
4797
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
4664
4798
|
},
|
|
4665
4799
|
{
|
|
@@ -4698,13 +4832,13 @@ function Ki(s) {
|
|
|
4698
4832
|
return null;
|
|
4699
4833
|
}
|
|
4700
4834
|
}
|
|
4701
|
-
function
|
|
4835
|
+
function Vt(s, e) {
|
|
4702
4836
|
if (!s || typeof s != "object")
|
|
4703
4837
|
return [];
|
|
4704
4838
|
const t = s[e];
|
|
4705
4839
|
return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
4706
4840
|
}
|
|
4707
|
-
function
|
|
4841
|
+
function Xt(s) {
|
|
4708
4842
|
return Array.isArray(s) ? s.flatMap((e) => {
|
|
4709
4843
|
if (!e || typeof e != "object")
|
|
4710
4844
|
return [];
|
|
@@ -4769,9 +4903,9 @@ function Zi(s) {
|
|
|
4769
4903
|
avatarUrl: typeof e.avatarUrl == "string" ? e.avatarUrl : null
|
|
4770
4904
|
} : null;
|
|
4771
4905
|
}
|
|
4772
|
-
function
|
|
4906
|
+
function st(s, e) {
|
|
4773
4907
|
return Array.isArray(s) ? ht(
|
|
4774
|
-
s.map((t) =>
|
|
4908
|
+
s.map((t) => ve(t, e)).filter((t) => t !== null)
|
|
4775
4909
|
) : [];
|
|
4776
4910
|
}
|
|
4777
4911
|
function er(s) {
|
|
@@ -4795,7 +4929,7 @@ function er(s) {
|
|
|
4795
4929
|
];
|
|
4796
4930
|
}) : [];
|
|
4797
4931
|
}
|
|
4798
|
-
function
|
|
4932
|
+
function ve(s, e) {
|
|
4799
4933
|
if (!s || typeof s != "object")
|
|
4800
4934
|
return null;
|
|
4801
4935
|
const t = s, n = t.data;
|
|
@@ -4809,8 +4943,8 @@ function at(s, e) {
|
|
|
4809
4943
|
id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
|
|
4810
4944
|
role: "assistant",
|
|
4811
4945
|
...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
|
|
4812
|
-
content:
|
|
4813
|
-
|
|
4946
|
+
content: vt(
|
|
4947
|
+
Jt(i.content),
|
|
4814
4948
|
e
|
|
4815
4949
|
),
|
|
4816
4950
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4826,8 +4960,8 @@ function at(s, e) {
|
|
|
4826
4960
|
id: String(t.id ?? crypto.randomUUID()),
|
|
4827
4961
|
role: r,
|
|
4828
4962
|
...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
|
|
4829
|
-
content:
|
|
4830
|
-
|
|
4963
|
+
content: vt(
|
|
4964
|
+
Jt(i.content),
|
|
4831
4965
|
e
|
|
4832
4966
|
),
|
|
4833
4967
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -4861,7 +4995,7 @@ function at(s, e) {
|
|
|
4861
4995
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
4862
4996
|
...k(i) ? { runId: k(i) } : {},
|
|
4863
4997
|
dataType: "function_call_output",
|
|
4864
|
-
toolName:
|
|
4998
|
+
toolName: St,
|
|
4865
4999
|
callId: ue(i) ?? void 0,
|
|
4866
5000
|
sharePromptAllowed: r
|
|
4867
5001
|
};
|
|
@@ -5035,7 +5169,7 @@ function _(s) {
|
|
|
5035
5169
|
function E(s) {
|
|
5036
5170
|
return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
|
|
5037
5171
|
}
|
|
5038
|
-
function
|
|
5172
|
+
function Jt(s) {
|
|
5039
5173
|
return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
|
|
5040
5174
|
if (!e || typeof e != "object")
|
|
5041
5175
|
return "";
|
|
@@ -5046,7 +5180,7 @@ function Xt(s) {
|
|
|
5046
5180
|
function de(s, e) {
|
|
5047
5181
|
const t = Es(
|
|
5048
5182
|
s,
|
|
5049
|
-
|
|
5183
|
+
Mt(s, e)
|
|
5050
5184
|
), n = ur(
|
|
5051
5185
|
cr(
|
|
5052
5186
|
gr(
|
|
@@ -5064,7 +5198,7 @@ function de(s, e) {
|
|
|
5064
5198
|
const r = [...n];
|
|
5065
5199
|
return r[i] = t, ht(r);
|
|
5066
5200
|
}
|
|
5067
|
-
function
|
|
5201
|
+
function Mt(s, e, t = !0) {
|
|
5068
5202
|
const n = s.find(
|
|
5069
5203
|
(r) => r.id === e.id || e.callId !== void 0 && r.callId === e.callId || e.assistantDraftItemId !== void 0 && (r.id === e.assistantDraftItemId || r.assistantDraftItemId === e.assistantDraftItemId)
|
|
5070
5204
|
);
|
|
@@ -5094,7 +5228,7 @@ function cr(s, e) {
|
|
|
5094
5228
|
function Ae(s, e, t) {
|
|
5095
5229
|
return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
|
|
5096
5230
|
}
|
|
5097
|
-
function
|
|
5231
|
+
function Yt(s, e, t, n) {
|
|
5098
5232
|
if (t === null) return s;
|
|
5099
5233
|
let i = -1;
|
|
5100
5234
|
for (let o = s.length - 1; o >= 0; o -= 1) {
|
|
@@ -5111,7 +5245,7 @@ function Jt(s, e, t, n) {
|
|
|
5111
5245
|
respondsToUserMessageId: t
|
|
5112
5246
|
}, r;
|
|
5113
5247
|
}
|
|
5114
|
-
function
|
|
5248
|
+
function Zt(s, e) {
|
|
5115
5249
|
const t = s.findIndex(
|
|
5116
5250
|
(i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
|
|
5117
5251
|
);
|
|
@@ -5128,12 +5262,12 @@ function Yt(s, e) {
|
|
|
5128
5262
|
...n[t].runId ? {} : { runId: e.runId }
|
|
5129
5263
|
}, n;
|
|
5130
5264
|
}
|
|
5131
|
-
function
|
|
5265
|
+
function es(s, e, t) {
|
|
5132
5266
|
let n = !1;
|
|
5133
5267
|
const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
|
|
5134
5268
|
return n ? i : s;
|
|
5135
5269
|
}
|
|
5136
|
-
function
|
|
5270
|
+
function ts(s) {
|
|
5137
5271
|
if (s.hiddenFromTranscript === !0)
|
|
5138
5272
|
return null;
|
|
5139
5273
|
const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
|
|
@@ -5169,7 +5303,7 @@ function lt(s, e) {
|
|
|
5169
5303
|
t.push(
|
|
5170
5304
|
Es(
|
|
5171
5305
|
i,
|
|
5172
|
-
|
|
5306
|
+
Mt(i, n, !1)
|
|
5173
5307
|
)
|
|
5174
5308
|
);
|
|
5175
5309
|
}
|
|
@@ -5181,7 +5315,7 @@ function lt(s, e) {
|
|
|
5181
5315
|
}
|
|
5182
5316
|
function dr(s, e) {
|
|
5183
5317
|
const t = new Map(s.map((r) => [r.id, r])), n = e.map(
|
|
5184
|
-
(r) =>
|
|
5318
|
+
(r) => Mt(s, r, !1)
|
|
5185
5319
|
);
|
|
5186
5320
|
for (const r of n)
|
|
5187
5321
|
t.set(r.id, r);
|
|
@@ -5201,7 +5335,7 @@ function dr(s, e) {
|
|
|
5201
5335
|
return i;
|
|
5202
5336
|
}
|
|
5203
5337
|
function ct(s) {
|
|
5204
|
-
const e =
|
|
5338
|
+
const e = J(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
|
|
5205
5339
|
// Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
|
|
5206
5340
|
// from substituting the call for its output and then appending a duplicate output at the end of the timeline.
|
|
5207
5341
|
...s.callId ? [`${n ? "call-output" : "call"}:${s.callId}`] : [],
|
|
@@ -5214,7 +5348,7 @@ function ct(s) {
|
|
|
5214
5348
|
...i.length > 0 ? { activityKeys: i } : {},
|
|
5215
5349
|
...s.respondsToUserMessageId ? { respondsToUserMessageId: s.respondsToUserMessageId } : {},
|
|
5216
5350
|
...s.runId ? { runId: s.runId } : {},
|
|
5217
|
-
isOptimistic:
|
|
5351
|
+
isOptimistic: Ne(s),
|
|
5218
5352
|
isAssistantDraft: s.dataType === "assistant_draft",
|
|
5219
5353
|
isActivity: s.role === "tool" || s.phase === "commentary" || s.dataType === "assistant_draft",
|
|
5220
5354
|
isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
|
|
@@ -5224,14 +5358,14 @@ function Es(s, e) {
|
|
|
5224
5358
|
if (e.role !== "user" || !e.attachments?.length)
|
|
5225
5359
|
return e;
|
|
5226
5360
|
const t = s.find(
|
|
5227
|
-
(o) => o.role === "user" && (o.id === e.id ||
|
|
5361
|
+
(o) => o.role === "user" && (o.id === e.id || Ne(o) && Cs(o, e))
|
|
5228
5362
|
);
|
|
5229
5363
|
if (!t?.attachments?.length)
|
|
5230
5364
|
return e;
|
|
5231
5365
|
const n = e.attachments.map((o) => {
|
|
5232
5366
|
const a = hr(t.attachments ?? [], o);
|
|
5233
5367
|
return a ? pr(o, a) : o;
|
|
5234
|
-
}), i = { ...e, attachments: n }, r =
|
|
5368
|
+
}), i = { ...e, attachments: n }, r = J(e);
|
|
5235
5369
|
return r && Object.defineProperty(i, "clientMessageId", {
|
|
5236
5370
|
value: r,
|
|
5237
5371
|
enumerable: !1
|
|
@@ -5248,7 +5382,7 @@ function gr(s, e) {
|
|
|
5248
5382
|
if (e.role !== "user")
|
|
5249
5383
|
return s;
|
|
5250
5384
|
const t = s.findIndex(
|
|
5251
|
-
(i) =>
|
|
5385
|
+
(i) => Ne(i) && Cs(i, e)
|
|
5252
5386
|
);
|
|
5253
5387
|
if (t === -1)
|
|
5254
5388
|
return s;
|
|
@@ -5256,13 +5390,13 @@ function gr(s, e) {
|
|
|
5256
5390
|
return n.splice(t, 1), n;
|
|
5257
5391
|
}
|
|
5258
5392
|
function Cs(s, e) {
|
|
5259
|
-
const t =
|
|
5393
|
+
const t = J(s), n = J(e);
|
|
5260
5394
|
return t && n ? t === n : s.content === e.content;
|
|
5261
5395
|
}
|
|
5262
|
-
function
|
|
5396
|
+
function Ne(s) {
|
|
5263
5397
|
return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
|
|
5264
5398
|
}
|
|
5265
|
-
function
|
|
5399
|
+
function J(s) {
|
|
5266
5400
|
const e = s.clientMessageId;
|
|
5267
5401
|
if (e)
|
|
5268
5402
|
return e;
|
|
@@ -5271,19 +5405,19 @@ function X(s) {
|
|
|
5271
5405
|
);
|
|
5272
5406
|
return n ? s.id.slice(n.length) : null;
|
|
5273
5407
|
}
|
|
5274
|
-
function
|
|
5408
|
+
function ss(s) {
|
|
5275
5409
|
const e = Ps(s);
|
|
5276
5410
|
if (e === null)
|
|
5277
5411
|
return !1;
|
|
5278
5412
|
const t = s[e].id;
|
|
5279
5413
|
if (s.some(
|
|
5280
|
-
(i) => i.respondsToUserMessageId === t &&
|
|
5414
|
+
(i) => i.respondsToUserMessageId === t && Ue(i)
|
|
5281
5415
|
))
|
|
5282
5416
|
return !0;
|
|
5283
5417
|
for (let i = s.length - 1; i > e; i -= 1) {
|
|
5284
5418
|
const r = s[i];
|
|
5285
5419
|
if (!r.respondsToUserMessageId) {
|
|
5286
|
-
if (
|
|
5420
|
+
if (F(r))
|
|
5287
5421
|
return !0;
|
|
5288
5422
|
if (r.role === "system") {
|
|
5289
5423
|
if (r.dataType === "run_error")
|
|
@@ -5298,7 +5432,7 @@ function ts(s) {
|
|
|
5298
5432
|
function fr(s, e, t) {
|
|
5299
5433
|
const n = new Set(
|
|
5300
5434
|
s.filter(
|
|
5301
|
-
(i) => i.role === "user" && e !== null &&
|
|
5435
|
+
(i) => i.role === "user" && e !== null && J(i) === e
|
|
5302
5436
|
).map((i) => i.id)
|
|
5303
5437
|
);
|
|
5304
5438
|
return s.some((i, r) => {
|
|
@@ -5318,20 +5452,20 @@ function fr(s, e, t) {
|
|
|
5318
5452
|
function mr(s) {
|
|
5319
5453
|
const e = Ps(s);
|
|
5320
5454
|
if (e === null)
|
|
5321
|
-
return s.some(
|
|
5455
|
+
return s.some(F);
|
|
5322
5456
|
const t = s[e].id;
|
|
5323
5457
|
return s.some((n) => n.respondsToUserMessageId === t) ? s.some(
|
|
5324
|
-
(n) => n.respondsToUserMessageId === t &&
|
|
5325
|
-
) : s.slice(e + 1).some(
|
|
5458
|
+
(n) => n.respondsToUserMessageId === t && F(n)
|
|
5459
|
+
) : s.slice(e + 1).some(F);
|
|
5326
5460
|
}
|
|
5327
5461
|
function Ps(s) {
|
|
5328
5462
|
for (let e = s.length - 1; e >= 0; e -= 1)
|
|
5329
|
-
if (s[e].role === "user" && !
|
|
5463
|
+
if (s[e].role === "user" && !Ne(s[e]))
|
|
5330
5464
|
return e;
|
|
5331
5465
|
return null;
|
|
5332
5466
|
}
|
|
5333
|
-
function
|
|
5334
|
-
return
|
|
5467
|
+
function Ue(s) {
|
|
5468
|
+
return F(s) ? !0 : s.role !== "system" ? !1 : s.dataType === "run_error" ? !0 : s.dataType === "run_status" && s.loading !== !0;
|
|
5335
5469
|
}
|
|
5336
5470
|
function ie(s) {
|
|
5337
5471
|
for (let e = s.length - 1; e >= 0; e -= 1) {
|
|
@@ -5378,8 +5512,8 @@ function Sr(s, e) {
|
|
|
5378
5512
|
return !1;
|
|
5379
5513
|
const r = s.findIndex((o) => o.role === "user" && o.id === i);
|
|
5380
5514
|
return r === -1 ? !1 : s.some((o) => o.respondsToUserMessageId === i) ? s.some(
|
|
5381
|
-
(o) => o.respondsToUserMessageId === i &&
|
|
5382
|
-
) : s.slice(r + 1).some(
|
|
5515
|
+
(o) => o.respondsToUserMessageId === i && Ue(o)
|
|
5516
|
+
) : s.slice(r + 1).some(Ue);
|
|
5383
5517
|
}
|
|
5384
5518
|
function ut(s) {
|
|
5385
5519
|
const e = ie(s);
|
|
@@ -5424,7 +5558,7 @@ function dt(s, e) {
|
|
|
5424
5558
|
const n = s.find((r) => A(r, "id") === t), i = C(n);
|
|
5425
5559
|
return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
|
|
5426
5560
|
}
|
|
5427
|
-
function
|
|
5561
|
+
function ns(s, e, t, n, i, r) {
|
|
5428
5562
|
if (!e || !Ar(s))
|
|
5429
5563
|
return !1;
|
|
5430
5564
|
const o = s;
|
|
@@ -5453,7 +5587,7 @@ function Ar(s) {
|
|
|
5453
5587
|
const e = s;
|
|
5454
5588
|
return e.type === "message" && e.role === "assistant" ? !0 : e.type === "run_error" ? e.stage !== "tool_execution" : e.type === "run_status" && (e.status === "stopped" || e.status === "interrupted" || e.status === "failed");
|
|
5455
5589
|
}
|
|
5456
|
-
function
|
|
5590
|
+
function F(s) {
|
|
5457
5591
|
return s.role === "assistant" && s.phase !== "commentary";
|
|
5458
5592
|
}
|
|
5459
5593
|
function Mr(s) {
|
|
@@ -5477,7 +5611,7 @@ function pt(s) {
|
|
|
5477
5611
|
function Rr(s) {
|
|
5478
5612
|
return s.some(pt);
|
|
5479
5613
|
}
|
|
5480
|
-
function
|
|
5614
|
+
function is(s, e) {
|
|
5481
5615
|
return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
|
|
5482
5616
|
}
|
|
5483
5617
|
function kr(s, e) {
|
|
@@ -5491,7 +5625,7 @@ function Er(s, e, t, n) {
|
|
|
5491
5625
|
(l) => l.role === "user" && l.id === o
|
|
5492
5626
|
) : null;
|
|
5493
5627
|
return {
|
|
5494
|
-
clientMessageId: a ?
|
|
5628
|
+
clientMessageId: a ? J(a) : o ? null : n,
|
|
5495
5629
|
respondsToUserMessageId: o,
|
|
5496
5630
|
runId: t ?? r?.runId ?? null
|
|
5497
5631
|
};
|
|
@@ -5500,12 +5634,12 @@ function Ce(s) {
|
|
|
5500
5634
|
return s?.type === "run_status" && s.status === "stopped";
|
|
5501
5635
|
}
|
|
5502
5636
|
function Cr(s, e) {
|
|
5503
|
-
return
|
|
5637
|
+
return F(e) ? "completed" : Ce(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
|
|
5504
5638
|
}
|
|
5505
|
-
function
|
|
5639
|
+
function rs(s, e, t) {
|
|
5506
5640
|
const n = new Set(
|
|
5507
5641
|
s.filter(
|
|
5508
|
-
(i) => i.role === "user" && e !== null &&
|
|
5642
|
+
(i) => i.role === "user" && e !== null && J(i) === e
|
|
5509
5643
|
).map((i) => i.id)
|
|
5510
5644
|
);
|
|
5511
5645
|
return s.filter(
|
|
@@ -5532,9 +5666,9 @@ function Pr(s, e, t) {
|
|
|
5532
5666
|
return s[r].id === n.respondsToUserMessageId;
|
|
5533
5667
|
return !1;
|
|
5534
5668
|
}
|
|
5535
|
-
function
|
|
5669
|
+
function os(s, e, t, n) {
|
|
5536
5670
|
const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
|
|
5537
|
-
(l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e &&
|
|
5671
|
+
(l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && as(l) && !vr(
|
|
5538
5672
|
s,
|
|
5539
5673
|
l.respondsToUserMessageId
|
|
5540
5674
|
)
|
|
@@ -5545,7 +5679,7 @@ function rs(s, e, t, n) {
|
|
|
5545
5679
|
if (!i)
|
|
5546
5680
|
return s;
|
|
5547
5681
|
let r = !1;
|
|
5548
|
-
const o = s.map((l) => l.respondsToUserMessageId !== i || !
|
|
5682
|
+
const o = s.map((l) => l.respondsToUserMessageId !== i || !as(l) ? l : (r = !0, { ...l, steered: !0 }));
|
|
5549
5683
|
if (r)
|
|
5550
5684
|
return o;
|
|
5551
5685
|
const a = s.find(
|
|
@@ -5578,12 +5712,12 @@ function _r(s, e) {
|
|
|
5578
5712
|
return s[n].id;
|
|
5579
5713
|
return null;
|
|
5580
5714
|
}
|
|
5581
|
-
function
|
|
5715
|
+
function as(s) {
|
|
5582
5716
|
return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
|
|
5583
5717
|
}
|
|
5584
5718
|
function vr(s, e) {
|
|
5585
5719
|
return s.some(
|
|
5586
|
-
(t) => t.respondsToUserMessageId === e && (
|
|
5720
|
+
(t) => t.respondsToUserMessageId === e && (F(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
|
|
5587
5721
|
);
|
|
5588
5722
|
}
|
|
5589
5723
|
function Ur(s, e) {
|
|
@@ -5670,24 +5804,24 @@ function Nr(s, e) {
|
|
|
5670
5804
|
}
|
|
5671
5805
|
function Hr(s) {
|
|
5672
5806
|
try {
|
|
5673
|
-
const e = window.localStorage.getItem(`${
|
|
5807
|
+
const e = window.localStorage.getItem(`${at}${s}`);
|
|
5674
5808
|
if (!e)
|
|
5675
5809
|
return [];
|
|
5676
5810
|
const t = JSON.parse(e);
|
|
5677
|
-
return Array.isArray(t) ? t.filter(
|
|
5811
|
+
return Array.isArray(t) ? t.filter(bt) : [];
|
|
5678
5812
|
} catch {
|
|
5679
5813
|
return [];
|
|
5680
5814
|
}
|
|
5681
5815
|
}
|
|
5682
5816
|
function V(s, e) {
|
|
5683
5817
|
try {
|
|
5684
|
-
const t = e.filter(
|
|
5818
|
+
const t = e.filter(bt);
|
|
5685
5819
|
if (t.length === 0) {
|
|
5686
|
-
window.localStorage.removeItem(`${
|
|
5820
|
+
window.localStorage.removeItem(`${at}${s}`);
|
|
5687
5821
|
return;
|
|
5688
5822
|
}
|
|
5689
5823
|
window.localStorage.setItem(
|
|
5690
|
-
`${
|
|
5824
|
+
`${at}${s}`,
|
|
5691
5825
|
JSON.stringify(t.slice(-25))
|
|
5692
5826
|
);
|
|
5693
5827
|
} catch {
|
|
@@ -5696,7 +5830,7 @@ function V(s, e) {
|
|
|
5696
5830
|
}
|
|
5697
5831
|
function Us(s, e) {
|
|
5698
5832
|
try {
|
|
5699
|
-
const t = `${
|
|
5833
|
+
const t = `${xe}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
|
|
5700
5834
|
...o,
|
|
5701
5835
|
storedAt: Date.now(),
|
|
5702
5836
|
unloadUrl: n,
|
|
@@ -5710,9 +5844,9 @@ function Us(s, e) {
|
|
|
5710
5844
|
} catch {
|
|
5711
5845
|
}
|
|
5712
5846
|
}
|
|
5713
|
-
function
|
|
5847
|
+
function ls(s, e) {
|
|
5714
5848
|
try {
|
|
5715
|
-
if (window.sessionStorage.getItem(`${
|
|
5849
|
+
if (window.sessionStorage.getItem(`${xe}${s}`) === null)
|
|
5716
5850
|
return;
|
|
5717
5851
|
} catch {
|
|
5718
5852
|
return;
|
|
@@ -5721,11 +5855,11 @@ function as(s, e) {
|
|
|
5721
5855
|
}
|
|
5722
5856
|
function Br(s) {
|
|
5723
5857
|
try {
|
|
5724
|
-
const e = `${
|
|
5858
|
+
const e = `${xe}${s}`, t = window.sessionStorage.getItem(e);
|
|
5725
5859
|
if (window.sessionStorage.removeItem(e), !t)
|
|
5726
5860
|
return [];
|
|
5727
5861
|
const n = JSON.parse(t);
|
|
5728
|
-
return Array.isArray(n) ? n.flatMap((i) =>
|
|
5862
|
+
return Array.isArray(n) ? n.flatMap((i) => Fr(i) ? [{
|
|
5729
5863
|
...i.event,
|
|
5730
5864
|
page: P(),
|
|
5731
5865
|
rawOutput: {
|
|
@@ -5752,13 +5886,13 @@ function Wr(s) {
|
|
|
5752
5886
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
5753
5887
|
Current URL: ${s}`;
|
|
5754
5888
|
}
|
|
5755
|
-
function
|
|
5889
|
+
function Fr(s) {
|
|
5756
5890
|
if (!s || typeof s != "object")
|
|
5757
5891
|
return !1;
|
|
5758
5892
|
const e = s, t = e.event;
|
|
5759
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
5893
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && bt(t) && t.type === "tool.result";
|
|
5760
5894
|
}
|
|
5761
|
-
function
|
|
5895
|
+
function $r(s, e) {
|
|
5762
5896
|
const t = new Set(
|
|
5763
5897
|
s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
5764
5898
|
);
|
|
@@ -5769,18 +5903,18 @@ function Fr(s, e) {
|
|
|
5769
5903
|
}
|
|
5770
5904
|
function jr(s) {
|
|
5771
5905
|
try {
|
|
5772
|
-
window.sessionStorage.removeItem(`${
|
|
5906
|
+
window.sessionStorage.removeItem(`${xe}${s}`);
|
|
5773
5907
|
} catch {
|
|
5774
5908
|
return;
|
|
5775
5909
|
}
|
|
5776
5910
|
}
|
|
5777
|
-
function
|
|
5911
|
+
function bt(s) {
|
|
5778
5912
|
if (!s || typeof s != "object")
|
|
5779
5913
|
return !1;
|
|
5780
5914
|
const e = s;
|
|
5781
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
5915
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && cs(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? cs(e.page) : e.type === "tool.result" ? typeof e.sessionId == "string" && typeof e.callId == "string" && (e.toolName === "execute_code" || e.toolName === "execute_code_in_browser_tab") : e.type === "chat.retry_last_user_message" ? typeof e.sessionId == "string" && typeof e.clientMessageId == "string" : e.type === "run.stop" ? typeof e.sessionId == "string" && (e.reason === "user_requested" || e.reason === "new_chat" || e.reason === "session_switch") : !1;
|
|
5782
5916
|
}
|
|
5783
|
-
function
|
|
5917
|
+
function cs(s) {
|
|
5784
5918
|
if (!s || typeof s != "object")
|
|
5785
5919
|
return !1;
|
|
5786
5920
|
const e = s;
|
|
@@ -5846,17 +5980,17 @@ function Qr(s) {
|
|
|
5846
5980
|
scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
|
|
5847
5981
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
5848
5982
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
5849
|
-
attachments: Ds(e.attachments)?.map(
|
|
5983
|
+
attachments: Ds(e.attachments)?.map(De),
|
|
5850
5984
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
5851
5985
|
};
|
|
5852
5986
|
}
|
|
5853
5987
|
function Vr(s) {
|
|
5854
5988
|
return s.attachments?.length ? {
|
|
5855
5989
|
...s,
|
|
5856
|
-
attachments: s.attachments.map(
|
|
5990
|
+
attachments: s.attachments.map(De)
|
|
5857
5991
|
} : s;
|
|
5858
5992
|
}
|
|
5859
|
-
function
|
|
5993
|
+
function De(s) {
|
|
5860
5994
|
const {
|
|
5861
5995
|
dataUrl: e,
|
|
5862
5996
|
objectUrl: t,
|
|
@@ -5882,15 +6016,15 @@ function xs(s) {
|
|
|
5882
6016
|
const e = {};
|
|
5883
6017
|
try {
|
|
5884
6018
|
new Headers(s).forEach((t, n) => {
|
|
5885
|
-
Object.keys(e).length <
|
|
6019
|
+
Object.keys(e).length < wt && (e[n] = Rt(n, t));
|
|
5886
6020
|
});
|
|
5887
6021
|
} catch {
|
|
5888
6022
|
return {};
|
|
5889
6023
|
}
|
|
5890
6024
|
return e;
|
|
5891
6025
|
}
|
|
5892
|
-
function
|
|
5893
|
-
return
|
|
6026
|
+
function Rt(s, e) {
|
|
6027
|
+
return Fs(s) ? He : W(Oe(e), ri);
|
|
5894
6028
|
}
|
|
5895
6029
|
function Jr(s, e) {
|
|
5896
6030
|
return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
|
|
@@ -5925,7 +6059,7 @@ async function Zr(s) {
|
|
|
5925
6059
|
const { done: l, value: c } = a;
|
|
5926
6060
|
if (l)
|
|
5927
6061
|
return W(r + i.decode());
|
|
5928
|
-
const u =
|
|
6062
|
+
const u = Tt - o;
|
|
5929
6063
|
if (c.byteLength > u)
|
|
5930
6064
|
return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${W(r)}... [truncated]`;
|
|
5931
6065
|
o += c.byteLength, r += i.decode(c, { stream: !0 });
|
|
@@ -5945,34 +6079,34 @@ function eo(s, e) {
|
|
|
5945
6079
|
return;
|
|
5946
6080
|
}
|
|
5947
6081
|
}
|
|
5948
|
-
function
|
|
6082
|
+
function us(s) {
|
|
5949
6083
|
if (typeof s == "string")
|
|
5950
6084
|
return W(s);
|
|
5951
6085
|
}
|
|
5952
6086
|
function to(s) {
|
|
5953
6087
|
return L({
|
|
5954
6088
|
...s,
|
|
5955
|
-
requestBody:
|
|
5956
|
-
responseBody:
|
|
6089
|
+
requestBody: ds(s.requestBody),
|
|
6090
|
+
responseBody: ds(s.responseBody)
|
|
5957
6091
|
});
|
|
5958
6092
|
}
|
|
5959
|
-
function
|
|
6093
|
+
function ds(s) {
|
|
5960
6094
|
if (typeof s != "string")
|
|
5961
6095
|
return s;
|
|
5962
6096
|
const e = s.trim();
|
|
5963
6097
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
5964
|
-
return
|
|
6098
|
+
return Oe(s);
|
|
5965
6099
|
try {
|
|
5966
6100
|
return JSON.stringify(L(JSON.parse(s)));
|
|
5967
6101
|
} catch {
|
|
5968
|
-
return
|
|
6102
|
+
return Oe(s);
|
|
5969
6103
|
}
|
|
5970
6104
|
}
|
|
5971
6105
|
function Ls(s) {
|
|
5972
6106
|
if (!s)
|
|
5973
6107
|
return !1;
|
|
5974
6108
|
const e = s.get("content-type")?.toLowerCase() ?? "", t = s.get("content-length"), n = Number(t);
|
|
5975
|
-
return t !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
6109
|
+
return t !== null && Number.isInteger(n) && n >= 0 && n <= Tt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
5976
6110
|
}
|
|
5977
6111
|
function te(s, e = {}, t) {
|
|
5978
6112
|
if (no(t))
|
|
@@ -6009,17 +6143,17 @@ function io(s) {
|
|
|
6009
6143
|
const n = t.indexOf(":");
|
|
6010
6144
|
if (n <= 0)
|
|
6011
6145
|
continue;
|
|
6012
|
-
if (Object.keys(e).length >=
|
|
6146
|
+
if (Object.keys(e).length >= wt)
|
|
6013
6147
|
break;
|
|
6014
6148
|
const i = t.slice(0, n).trim();
|
|
6015
|
-
e[i] =
|
|
6149
|
+
e[i] = Rt(i, t.slice(n + 1).trim());
|
|
6016
6150
|
}
|
|
6017
6151
|
return e;
|
|
6018
6152
|
}
|
|
6019
|
-
function W(s, e =
|
|
6153
|
+
function W(s, e = Tt) {
|
|
6020
6154
|
return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
|
|
6021
6155
|
}
|
|
6022
|
-
function
|
|
6156
|
+
function nt(s) {
|
|
6023
6157
|
return `${s}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
6024
6158
|
}
|
|
6025
6159
|
class Pe extends Error {
|
|
@@ -6030,11 +6164,11 @@ class Pe extends Error {
|
|
|
6030
6164
|
}
|
|
6031
6165
|
async function Me(s, e) {
|
|
6032
6166
|
let t = null;
|
|
6033
|
-
for (let n = 0; n <
|
|
6167
|
+
for (let n = 0; n < zt; n += 1)
|
|
6034
6168
|
try {
|
|
6035
6169
|
return await s();
|
|
6036
6170
|
} catch (i) {
|
|
6037
|
-
if (t = i, n >=
|
|
6171
|
+
if (t = i, n >= zt - 1 || !oo(i))
|
|
6038
6172
|
throw i;
|
|
6039
6173
|
await ro(n);
|
|
6040
6174
|
}
|
|
@@ -6054,13 +6188,13 @@ function ao(s) {
|
|
|
6054
6188
|
function lo(s) {
|
|
6055
6189
|
return s === 401 || s === 403;
|
|
6056
6190
|
}
|
|
6057
|
-
const
|
|
6191
|
+
const He = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", co = "[REDACTED_SIGNED_URL]", uo = 20, ho = /^(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, Ns = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Hs = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Bs = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Ws = /\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, po = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, go = /\bhttps?:\/\/[^\s"'<>]+/gi, fo = /[),.;\]]+$/;
|
|
6058
6192
|
function L(s) {
|
|
6059
|
-
return
|
|
6193
|
+
return qe(s, 0, /* @__PURE__ */ new WeakSet());
|
|
6060
6194
|
}
|
|
6061
|
-
function
|
|
6195
|
+
function qe(s, e, t) {
|
|
6062
6196
|
if (typeof s == "string")
|
|
6063
|
-
return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s :
|
|
6197
|
+
return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : Oe(s);
|
|
6064
6198
|
if (s === null || typeof s != "object")
|
|
6065
6199
|
return s;
|
|
6066
6200
|
if (e >= uo)
|
|
@@ -6068,59 +6202,59 @@ function De(s, e, t) {
|
|
|
6068
6202
|
if (t.has(s))
|
|
6069
6203
|
return "[REDACTED_CIRCULAR]";
|
|
6070
6204
|
if (t.add(s), Array.isArray(s))
|
|
6071
|
-
return s.map((i) =>
|
|
6205
|
+
return s.map((i) => qe(i, e + 1, t));
|
|
6072
6206
|
const n = {};
|
|
6073
6207
|
for (const [i, r] of Object.entries(s))
|
|
6074
|
-
i === "pageContent" ? n[i] = r :
|
|
6208
|
+
i === "pageContent" ? n[i] = r : Fs(i) ? n[i] = He : n[i] = i.toLowerCase() === "url" ? mo(r) : qe(r, e + 1, t);
|
|
6075
6209
|
return n;
|
|
6076
6210
|
}
|
|
6077
|
-
function
|
|
6211
|
+
function Fs(s) {
|
|
6078
6212
|
const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
6079
6213
|
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");
|
|
6080
6214
|
}
|
|
6081
6215
|
function mo(s) {
|
|
6082
|
-
return typeof s == "string" ?
|
|
6216
|
+
return typeof s == "string" ? $s(s) : qe(s, 0, /* @__PURE__ */ new WeakSet());
|
|
6083
6217
|
}
|
|
6084
|
-
function
|
|
6218
|
+
function $s(s) {
|
|
6085
6219
|
try {
|
|
6086
6220
|
const e = new URL(s, location.href);
|
|
6087
6221
|
for (const t of Array.from(e.searchParams.keys()))
|
|
6088
|
-
ho.test(t) && e.searchParams.set(t,
|
|
6089
|
-
return e.username && (e.username =
|
|
6222
|
+
ho.test(t) && e.searchParams.set(t, $);
|
|
6223
|
+
return e.username && (e.username = $), e.password && (e.password = $), e.toString();
|
|
6090
6224
|
} catch {
|
|
6091
6225
|
return yo(s);
|
|
6092
6226
|
}
|
|
6093
6227
|
}
|
|
6094
|
-
function
|
|
6095
|
-
return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${
|
|
6228
|
+
function Oe(s) {
|
|
6229
|
+
return s.replace(po, co).replace(go, Io).replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
|
|
6096
6230
|
}
|
|
6097
6231
|
function yo(s) {
|
|
6098
|
-
return s.replace(Ns, `Bearer ${
|
|
6232
|
+
return s.replace(Ns, `Bearer ${$}`).replace(Hs, `Basic ${$}`).replace(Bs, $).replace(Ws, (e, t) => `${t}: ${He}`);
|
|
6099
6233
|
}
|
|
6100
6234
|
function Io(s) {
|
|
6101
6235
|
const e = s.match(fo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
|
|
6102
|
-
return `${
|
|
6236
|
+
return `${$s(t)}${e}`;
|
|
6103
6237
|
}
|
|
6104
6238
|
const Eo = Object.freeze({
|
|
6105
|
-
init: (s) =>
|
|
6239
|
+
init: (s) => Le.init(s)
|
|
6106
6240
|
});
|
|
6107
6241
|
function Co(s) {
|
|
6108
|
-
return
|
|
6242
|
+
return Le.init(s);
|
|
6109
6243
|
}
|
|
6110
6244
|
export {
|
|
6111
|
-
|
|
6245
|
+
Ht as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
6112
6246
|
Dn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
6113
6247
|
Un as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
6114
6248
|
qn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
6115
6249
|
ko as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
6116
6250
|
Eo as PlunoProductAgent,
|
|
6117
6251
|
kn as ProductAgentInteractionManager,
|
|
6118
|
-
|
|
6252
|
+
xt as ProductAgentQueryController,
|
|
6119
6253
|
Ro as ProductAgentRemoteRuntimeClient,
|
|
6120
|
-
|
|
6254
|
+
Le as ProductAgentSessionEngine,
|
|
6121
6255
|
Mn as ProductAgentSessionHistoryManager,
|
|
6122
6256
|
Ao as ProductAgentTaskPageTitleController,
|
|
6123
|
-
|
|
6257
|
+
X as ProductAgentTokenProviderError,
|
|
6124
6258
|
di as calculateReconnectDelay,
|
|
6125
6259
|
wo as createLocalStorageInteractionDecisionStorage,
|
|
6126
6260
|
Re as createProductAgentQueryState,
|
|
@@ -6132,7 +6266,7 @@ export {
|
|
|
6132
6266
|
bo as isProductAgentRuntimeCommand,
|
|
6133
6267
|
Tn as mergeProductAgentEntityPages,
|
|
6134
6268
|
ke as normalizeProductAgentEntityPage,
|
|
6135
|
-
|
|
6269
|
+
st as normalizeProductAgentSessionItems,
|
|
6136
6270
|
En as readLocalStorageInteractionDecisions,
|
|
6137
6271
|
To as resolveProductAgentComposerAction,
|
|
6138
6272
|
So as resolveProductAgentWidgetPresentation,
|