@pluno/product-agent-web 0.1.210 → 0.1.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +192 -175
- package/dist/product-agent-sdk.js +1308 -1087
- package/dist/product-agent-widget.js +3547 -3289
- package/dist/runtime/composition.d.ts +27 -0
- package/dist/runtimeClient.d.ts +1 -0
- package/dist/uiInvariants.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,16 +1,187 @@
|
|
|
1
|
-
|
|
1
|
+
class Qs {
|
|
2
|
+
constructor(e, t, n) {
|
|
3
|
+
this.handlers = e, this.accept = t, this.errorAdapter = n;
|
|
4
|
+
}
|
|
5
|
+
handlers;
|
|
6
|
+
accept;
|
|
7
|
+
errorAdapter;
|
|
8
|
+
disposed = !1;
|
|
9
|
+
run(e) {
|
|
10
|
+
for (const t of e) this.runEffect(t);
|
|
11
|
+
}
|
|
12
|
+
dispose() {
|
|
13
|
+
this.disposed = !0;
|
|
14
|
+
}
|
|
15
|
+
runEffect(e) {
|
|
16
|
+
const t = this.handlers[e.kind];
|
|
17
|
+
Promise.resolve().then(() => {
|
|
18
|
+
if (!this.disposed)
|
|
19
|
+
return t(e.input);
|
|
20
|
+
}).then(
|
|
21
|
+
(n) => {
|
|
22
|
+
this.disposed || this.accept({
|
|
23
|
+
type: "effect.completed",
|
|
24
|
+
effectId: e.id,
|
|
25
|
+
effectKind: e.kind,
|
|
26
|
+
output: n
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
(n) => {
|
|
30
|
+
this.disposed || this.accept({
|
|
31
|
+
type: "effect.failed",
|
|
32
|
+
effectId: e.id,
|
|
33
|
+
effectKind: e.kind,
|
|
34
|
+
error: this.errorAdapter(n)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
class Js {
|
|
41
|
+
state;
|
|
42
|
+
reducer;
|
|
43
|
+
selector;
|
|
44
|
+
effectRunner;
|
|
45
|
+
listeners = /* @__PURE__ */ new Set();
|
|
46
|
+
queue = [];
|
|
47
|
+
draining = !1;
|
|
48
|
+
disposed = !1;
|
|
49
|
+
constructor(e) {
|
|
50
|
+
this.state = e.initialState, this.reducer = e.reducer, this.selector = e.selector, this.effectRunner = new Qs(
|
|
51
|
+
e.effectHandlers,
|
|
52
|
+
(t) => this.acceptEffectResult(t),
|
|
53
|
+
e.errorAdapter
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
dispatch(e) {
|
|
57
|
+
return this.disposed ? Promise.reject(new Error("Product Agent engine is disposed.")) : new Promise((t, n) => {
|
|
58
|
+
this.queue.push({ source: "command", value: e, resolve: t, reject: n }), this.drain();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
accept(e) {
|
|
62
|
+
this.disposed || (this.queue.push({ source: "event", value: e }), this.drain());
|
|
63
|
+
}
|
|
64
|
+
getState() {
|
|
65
|
+
return this.state;
|
|
66
|
+
}
|
|
67
|
+
getProjection() {
|
|
68
|
+
return this.selector(this.state);
|
|
69
|
+
}
|
|
70
|
+
subscribe(e) {
|
|
71
|
+
if (this.disposed) throw new Error("Product Agent engine is disposed.");
|
|
72
|
+
return this.listeners.add(e), e(this.getProjection()), () => this.listeners.delete(e);
|
|
73
|
+
}
|
|
74
|
+
dispose() {
|
|
75
|
+
if (this.disposed) return;
|
|
76
|
+
this.disposed = !0, this.effectRunner.dispose(), this.listeners.clear();
|
|
77
|
+
const e = this.queue.splice(0);
|
|
78
|
+
for (const t of e)
|
|
79
|
+
t.source === "command" && t.reject(new Error("Product Agent engine is disposed."));
|
|
80
|
+
}
|
|
81
|
+
acceptEffectResult(e) {
|
|
82
|
+
this.disposed || (this.queue.push({ source: "event", value: e }), this.drain());
|
|
83
|
+
}
|
|
84
|
+
drain() {
|
|
85
|
+
if (!(this.draining || this.disposed)) {
|
|
86
|
+
this.draining = !0;
|
|
87
|
+
try {
|
|
88
|
+
for (; this.queue.length > 0 && !this.disposed; ) {
|
|
89
|
+
const e = this.queue.shift();
|
|
90
|
+
if (e)
|
|
91
|
+
try {
|
|
92
|
+
const t = this.reducer(this.state, {
|
|
93
|
+
source: e.source,
|
|
94
|
+
value: e.value
|
|
95
|
+
}), n = t.state !== this.state;
|
|
96
|
+
this.state = t.state, n && this.publish(), this.effectRunner.run(t.effects), e.source === "command" && e.resolve();
|
|
97
|
+
} catch (t) {
|
|
98
|
+
if (e.source === "command") e.reject(t);
|
|
99
|
+
else throw t;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
} finally {
|
|
103
|
+
this.draining = !1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
publish() {
|
|
108
|
+
const e = this.getProjection();
|
|
109
|
+
for (const t of this.listeners) t(e);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function it(s) {
|
|
113
|
+
if (s === null || typeof s == "string" || typeof s == "boolean") return !0;
|
|
114
|
+
if (typeof s == "number") return Number.isFinite(s);
|
|
115
|
+
if (Array.isArray(s)) return s.every(it);
|
|
116
|
+
if (typeof s != "object") return !1;
|
|
117
|
+
const e = Object.getPrototypeOf(s);
|
|
118
|
+
return e !== Object.prototype && e !== null ? !1 : Object.values(s).every(it);
|
|
119
|
+
}
|
|
120
|
+
function Xs(s) {
|
|
121
|
+
if (s.details !== void 0 && !it(s.details))
|
|
122
|
+
throw new TypeError("Product Agent transported error details must be JSON-safe.");
|
|
123
|
+
return {
|
|
124
|
+
code: s.code,
|
|
125
|
+
message: s.message,
|
|
126
|
+
retryable: s.retryable,
|
|
127
|
+
...s.details === void 0 ? {} : { details: s.details }
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const Ys = Object.freeze({
|
|
131
|
+
modelSelection: "legacy",
|
|
132
|
+
directory: "legacy",
|
|
133
|
+
conversation: "legacy",
|
|
134
|
+
account: "legacy",
|
|
135
|
+
interactions: "legacy",
|
|
136
|
+
browserExecution: "legacy"
|
|
137
|
+
});
|
|
138
|
+
function Ut(s, e) {
|
|
139
|
+
const t = Ys[s], n = e[t];
|
|
140
|
+
if (!n) throw new Error(`No ${t} implementation for ${s}.`);
|
|
141
|
+
return n();
|
|
142
|
+
}
|
|
143
|
+
class Zs {
|
|
144
|
+
// Stage 3 installs the Stage 1 engine/runner without shadow copies of legacy product slices.
|
|
145
|
+
engine = new Js({
|
|
146
|
+
initialState: Object.freeze({ revision: 0, slices: Object.freeze({}) }),
|
|
147
|
+
reducer: (e) => ({ state: e, effects: [] }),
|
|
148
|
+
selector: (e) => e,
|
|
149
|
+
effectHandlers: {},
|
|
150
|
+
errorAdapter: (e) => Xs({
|
|
151
|
+
code: "runtime_error",
|
|
152
|
+
message: e instanceof Error ? e.message : String(e),
|
|
153
|
+
retryable: !1
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
disposed = !1;
|
|
157
|
+
get isDisposed() {
|
|
158
|
+
return this.disposed;
|
|
159
|
+
}
|
|
160
|
+
route(e, t) {
|
|
161
|
+
if (this.disposed) throw new Error("Product Agent runtime is disposed.");
|
|
162
|
+
return Ut(e, t);
|
|
163
|
+
}
|
|
164
|
+
project(e, t) {
|
|
165
|
+
return Ut(e, t);
|
|
166
|
+
}
|
|
167
|
+
dispose() {
|
|
168
|
+
this.disposed = !0, this.engine.dispose();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const Dt = 500;
|
|
172
|
+
function fs(s) {
|
|
2
173
|
const e = s.replace(/\n\s*at\s[\s\S]*$/, "").replace(/-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?(?:-----END [^-]*PRIVATE KEY-----|$)/g, "[REDACTED]").replace(/\b(?:set-cookie|cookie)\s*[:=]\s*[^\n]+/gi, "cookie=[REDACTED]").replace(/\bdata:[^\s<>"']+/gi, "[DATA]").replace(/\b(?:https?:\/\/|www\.)[^\s<>"']+/gi, "[URL]").replace(/\b(?:Bearer|Basic)\s+[^\s,;"']+/gi, "[REDACTED]").replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?/g, "[REDACTED]").replace(/\b(?:sk|pk|ghp|gho|github_pat|xoxb|xoxp)[-_][A-Za-z0-9_-]{8,}/g, "[REDACTED]").replace(/\b((?:access|refresh|id|auth)[_-]?token|api[_-]?key|client[_-]?secret|password|passwd|pwd|secret|token|jwt|authorization|cookie|set-cookie)\b["']?\s*[:=]\s*(?:"[^"]*"|'[^']*'|[^\s,;}&]+)/gi, "$1=[REDACTED]").replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi, "[EMAIL]").replace(/(?:[A-Z]:[\\/]|\\\\|(?:~|\.\.?)?\/|[\w.-]+[\\/])[^\s<>"']+/gi, "[FILE]").replace(new RegExp("(?<![\\w.])(?:[\\w.-]+\\.[A-Z][A-Z0-9]{0,15}|\\.[A-Z][\\w.-]*)\\b", "gi"), "[FILE]").replace(/\s+/g, " ").trim();
|
|
3
|
-
return e.length >
|
|
174
|
+
return e.length > Dt ? `${e.slice(0, Dt - 1)}…` : e;
|
|
4
175
|
}
|
|
5
|
-
const
|
|
6
|
-
async function
|
|
7
|
-
const e = await
|
|
8
|
-
await
|
|
176
|
+
const en = "pluno-product-agent-attachments", tn = 1, rt = "files", sn = 1440 * 60 * 1e3;
|
|
177
|
+
async function nn(s) {
|
|
178
|
+
const e = await yt();
|
|
179
|
+
await an(e, "readwrite", (t) => t.put(s));
|
|
9
180
|
}
|
|
10
|
-
async function
|
|
11
|
-
const t = await
|
|
12
|
-
await
|
|
13
|
-
const i = await
|
|
181
|
+
async function rn(s, e) {
|
|
182
|
+
const t = await yt();
|
|
183
|
+
await It(t, "readwrite", async (n) => {
|
|
184
|
+
const i = await St(
|
|
14
185
|
n.get(s)
|
|
15
186
|
);
|
|
16
187
|
i && n.put({
|
|
@@ -19,28 +190,28 @@ async function Xs(s, e) {
|
|
|
19
190
|
});
|
|
20
191
|
});
|
|
21
192
|
}
|
|
22
|
-
async function
|
|
23
|
-
const e = await
|
|
24
|
-
await
|
|
193
|
+
async function on(s = sn) {
|
|
194
|
+
const e = await yt(), t = Date.now() - s;
|
|
195
|
+
await It(e, "readwrite", async (n) => {
|
|
25
196
|
const i = n.index("lastUsedAt");
|
|
26
|
-
(await
|
|
197
|
+
(await St(i.getAllKeys(IDBKeyRange.upperBound(t)))).forEach((o) => n.delete(o));
|
|
27
198
|
});
|
|
28
199
|
}
|
|
29
|
-
function
|
|
200
|
+
function yt() {
|
|
30
201
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((s, e) => {
|
|
31
|
-
const t = indexedDB.open(
|
|
202
|
+
const t = indexedDB.open(en, tn);
|
|
32
203
|
t.onupgradeneeded = () => {
|
|
33
|
-
const i = t.result.createObjectStore(
|
|
204
|
+
const i = t.result.createObjectStore(rt, { keyPath: "attachmentId" });
|
|
34
205
|
i.createIndex("lastUsedAt", "lastUsedAt", { unique: !1 }), i.createIndex("sessionId", "sessionId", { unique: !1 }), i.createIndex("origin", "origin", { unique: !1 });
|
|
35
206
|
}, t.onsuccess = () => s(t.result), t.onerror = () => e(t.error ?? new Error("Failed to open Product Agent attachment storage"));
|
|
36
207
|
});
|
|
37
208
|
}
|
|
38
|
-
async function
|
|
39
|
-
return await
|
|
209
|
+
async function an(s, e, t) {
|
|
210
|
+
return await It(s, e, async (n) => await St(t(n)));
|
|
40
211
|
}
|
|
41
|
-
function
|
|
212
|
+
function It(s, e, t) {
|
|
42
213
|
return new Promise((n, i) => {
|
|
43
|
-
const r = s.transaction(
|
|
214
|
+
const r = s.transaction(rt, e), o = r.objectStore(rt);
|
|
44
215
|
let a, l = !1;
|
|
45
216
|
t(o).then((c) => {
|
|
46
217
|
a = c;
|
|
@@ -60,16 +231,16 @@ function yt(s, e, t) {
|
|
|
60
231
|
};
|
|
61
232
|
});
|
|
62
233
|
}
|
|
63
|
-
function
|
|
234
|
+
function St(s) {
|
|
64
235
|
return new Promise((e, t) => {
|
|
65
236
|
s.onsuccess = () => e(s.result), s.onerror = () => t(s.error ?? new Error("Product Agent attachment storage request failed"));
|
|
66
237
|
});
|
|
67
238
|
}
|
|
68
|
-
function
|
|
239
|
+
function ln(s) {
|
|
69
240
|
return s !== null && (typeof s == "object" || typeof s == "function");
|
|
70
241
|
}
|
|
71
|
-
function
|
|
72
|
-
const n = Reflect.get(s, "pluno"), i =
|
|
242
|
+
function ms(s, e, t) {
|
|
243
|
+
const n = Reflect.get(s, "pluno"), i = ln(n) ? n : {};
|
|
73
244
|
if (i !== n && !Reflect.set(s, "pluno", i))
|
|
74
245
|
return null;
|
|
75
246
|
const r = Object.getOwnPropertyDescriptor(i, e);
|
|
@@ -83,25 +254,25 @@ function ps(s, e, t) {
|
|
|
83
254
|
}
|
|
84
255
|
};
|
|
85
256
|
}
|
|
86
|
-
const
|
|
87
|
-
function
|
|
257
|
+
const cn = /(\]\()(\/api\/product-agent\/attachments\/download\?[^)\s]+)(\))/g;
|
|
258
|
+
function qt(s, e) {
|
|
88
259
|
return e ? s.replace(
|
|
89
|
-
|
|
260
|
+
cn,
|
|
90
261
|
(t, n, i, r) => `${n}${new URL(i, e).toString()}${r}`
|
|
91
262
|
) : s;
|
|
92
263
|
}
|
|
93
|
-
const
|
|
94
|
-
function
|
|
264
|
+
const Tt = "suggest_share_on_socials";
|
|
265
|
+
function un(s) {
|
|
95
266
|
for (let e = s.length - 1; e >= 0; e -= 1) {
|
|
96
267
|
const t = s[e];
|
|
97
|
-
if (t.role !== "tool" || t.toolName !==
|
|
268
|
+
if (t.role !== "tool" || t.toolName !== Tt || t.sharePromptAllowed !== void 0)
|
|
98
269
|
continue;
|
|
99
|
-
if (
|
|
270
|
+
if (hn(s, e, t.callId) !== !0)
|
|
100
271
|
return null;
|
|
101
|
-
const n =
|
|
272
|
+
const n = Ot(s, e, "assistant");
|
|
102
273
|
if (!n)
|
|
103
274
|
return null;
|
|
104
|
-
const i =
|
|
275
|
+
const i = Ot(s, n.index, "user");
|
|
105
276
|
return i ? {
|
|
106
277
|
id: `share:${t.callId ?? t.id}`,
|
|
107
278
|
userPrompt: i.content,
|
|
@@ -110,7 +281,7 @@ function tn(s) {
|
|
|
110
281
|
}
|
|
111
282
|
return null;
|
|
112
283
|
}
|
|
113
|
-
function
|
|
284
|
+
function dn(s) {
|
|
114
285
|
let e = s;
|
|
115
286
|
if (typeof s == "string")
|
|
116
287
|
try {
|
|
@@ -118,10 +289,10 @@ function sn(s) {
|
|
|
118
289
|
} catch {
|
|
119
290
|
return null;
|
|
120
291
|
}
|
|
121
|
-
const t =
|
|
292
|
+
const t = pn(e);
|
|
122
293
|
return t ? typeof t.showSharePrompt == "boolean" ? t.showSharePrompt : t.ok === !0 && typeof t.message == "string" && t.message.includes("social-sharing prompt") ? !0 : null : null;
|
|
123
294
|
}
|
|
124
|
-
function
|
|
295
|
+
function hn(s, e, t) {
|
|
125
296
|
if (!t)
|
|
126
297
|
return null;
|
|
127
298
|
for (let n = e + 1; n < s.length; n += 1) {
|
|
@@ -131,7 +302,7 @@ function nn(s, e, t) {
|
|
|
131
302
|
}
|
|
132
303
|
return null;
|
|
133
304
|
}
|
|
134
|
-
function
|
|
305
|
+
function Ot(s, e, t) {
|
|
135
306
|
for (let n = e - 1; n >= 0; n -= 1) {
|
|
136
307
|
const i = s[n];
|
|
137
308
|
if (i.role === t && i.content.trim())
|
|
@@ -139,14 +310,14 @@ function Ut(s, e, t) {
|
|
|
139
310
|
}
|
|
140
311
|
return null;
|
|
141
312
|
}
|
|
142
|
-
function
|
|
313
|
+
function pn(s) {
|
|
143
314
|
return s && typeof s == "object" && !Array.isArray(s) ? s : null;
|
|
144
315
|
}
|
|
145
|
-
const
|
|
146
|
-
function
|
|
147
|
-
return (s.type === "function_call" || s.type === "tool_call") && s.name ===
|
|
316
|
+
const gn = "save_runtime_captured_skill";
|
|
317
|
+
function fn(s) {
|
|
318
|
+
return (s.type === "function_call" || s.type === "tool_call") && s.name === gn;
|
|
148
319
|
}
|
|
149
|
-
function
|
|
320
|
+
function mn(s, e, t) {
|
|
150
321
|
const n = e.map((h) => ({ item: h, identity: t(h) })), i = new Set(
|
|
151
322
|
n.flatMap(
|
|
152
323
|
({ identity: h }) => h.isActivity && !h.isTransient ? h.activityKeys ?? [] : []
|
|
@@ -184,16 +355,16 @@ function ln(s, e, t) {
|
|
|
184
355
|
g.has(h) || f.push(h);
|
|
185
356
|
return f;
|
|
186
357
|
}
|
|
187
|
-
function
|
|
358
|
+
function xt(s, e, t, n) {
|
|
188
359
|
return s.filter((i) => {
|
|
189
360
|
const r = n(i);
|
|
190
361
|
return !r.isActivity || !r.isTransient ? !0 : e !== null && r.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId !== e : t === null || r.runId !== t;
|
|
191
362
|
});
|
|
192
363
|
}
|
|
193
|
-
const Ke = "pluno.productAgent.transportId",
|
|
364
|
+
const Ke = "pluno.productAgent.transportId", yn = "pluno.productAgent.transportIdentity", Ge = "pluno.productAgent.transportIdentity.event", In = 50, Sn = globalThis.setTimeout.bind(globalThis);
|
|
194
365
|
let le = null;
|
|
195
|
-
const Re = /* @__PURE__ */ new Set(),
|
|
196
|
-
async function
|
|
366
|
+
const Re = /* @__PURE__ */ new Set(), Ve = /* @__PURE__ */ new Map();
|
|
367
|
+
async function Tn(s = ys()) {
|
|
197
368
|
const e = s.randomUUID(), t = s.storage.getItem(Ke);
|
|
198
369
|
let n = t ?? s.randomUUID(), i = !1, r = !1;
|
|
199
370
|
const o = s.channel.subscribe((l) => {
|
|
@@ -231,9 +402,9 @@ async function hn(s = gs()) {
|
|
|
231
402
|
}
|
|
232
403
|
};
|
|
233
404
|
}
|
|
234
|
-
async function
|
|
235
|
-
le || (le =
|
|
236
|
-
...
|
|
405
|
+
async function wn(s = !1) {
|
|
406
|
+
le || (le = Tn({
|
|
407
|
+
...ys(),
|
|
237
408
|
skipStoredIdentityCollisionCheck: s
|
|
238
409
|
}), le.then((i) => {
|
|
239
410
|
const r = (o) => {
|
|
@@ -241,7 +412,7 @@ async function pn(s = !1) {
|
|
|
241
412
|
};
|
|
242
413
|
window.addEventListener("pagehide", r);
|
|
243
414
|
}));
|
|
244
|
-
const e = await le, t =
|
|
415
|
+
const e = await le, t = An();
|
|
245
416
|
Re.add(t);
|
|
246
417
|
let n = !1;
|
|
247
418
|
return {
|
|
@@ -252,31 +423,31 @@ async function pn(s = !1) {
|
|
|
252
423
|
}
|
|
253
424
|
};
|
|
254
425
|
}
|
|
255
|
-
function
|
|
426
|
+
function An() {
|
|
256
427
|
let s = 0;
|
|
257
428
|
for (; Re.has(s); )
|
|
258
429
|
s += 1;
|
|
259
430
|
return s;
|
|
260
431
|
}
|
|
261
|
-
function
|
|
432
|
+
function ys() {
|
|
262
433
|
return {
|
|
263
|
-
storage:
|
|
264
|
-
channel:
|
|
434
|
+
storage: Mn(),
|
|
435
|
+
channel: bn(),
|
|
265
436
|
randomUUID: () => crypto.randomUUID(),
|
|
266
|
-
settle: () => new Promise((s) =>
|
|
437
|
+
settle: () => new Promise((s) => Sn(s, In))
|
|
267
438
|
};
|
|
268
439
|
}
|
|
269
|
-
function
|
|
440
|
+
function Mn() {
|
|
270
441
|
return {
|
|
271
442
|
getItem: (s) => {
|
|
272
443
|
try {
|
|
273
|
-
return window.sessionStorage?.getItem(s) ??
|
|
444
|
+
return window.sessionStorage?.getItem(s) ?? Ve.get(s) ?? null;
|
|
274
445
|
} catch {
|
|
275
|
-
return
|
|
446
|
+
return Ve.get(s) ?? null;
|
|
276
447
|
}
|
|
277
448
|
},
|
|
278
449
|
setItem: (s, e) => {
|
|
279
|
-
|
|
450
|
+
Ve.set(s, e);
|
|
280
451
|
try {
|
|
281
452
|
window.sessionStorage?.setItem(s, e);
|
|
282
453
|
} catch {
|
|
@@ -284,9 +455,9 @@ function fn() {
|
|
|
284
455
|
}
|
|
285
456
|
};
|
|
286
457
|
}
|
|
287
|
-
function
|
|
458
|
+
function bn() {
|
|
288
459
|
if (typeof BroadcastChannel < "u") {
|
|
289
|
-
const s = new BroadcastChannel(
|
|
460
|
+
const s = new BroadcastChannel(yn);
|
|
290
461
|
return {
|
|
291
462
|
postMessage: (e) => s.postMessage(e),
|
|
292
463
|
subscribe: (e) => {
|
|
@@ -296,9 +467,9 @@ function mn() {
|
|
|
296
467
|
close: () => s.close()
|
|
297
468
|
};
|
|
298
469
|
}
|
|
299
|
-
return
|
|
470
|
+
return Rn();
|
|
300
471
|
}
|
|
301
|
-
function
|
|
472
|
+
function Rn() {
|
|
302
473
|
const s = /* @__PURE__ */ new Set(), e = (t) => {
|
|
303
474
|
if (t.key !== Ge || !t.newValue)
|
|
304
475
|
return;
|
|
@@ -319,8 +490,8 @@ function yn() {
|
|
|
319
490
|
}
|
|
320
491
|
};
|
|
321
492
|
}
|
|
322
|
-
const
|
|
323
|
-
function
|
|
493
|
+
const Is = "schedule_follow_up";
|
|
494
|
+
function kn(s) {
|
|
324
495
|
let e = s;
|
|
325
496
|
if (typeof e == "string")
|
|
326
497
|
try {
|
|
@@ -331,48 +502,48 @@ function In(s) {
|
|
|
331
502
|
if (!e || typeof e != "object")
|
|
332
503
|
return null;
|
|
333
504
|
const t = e;
|
|
334
|
-
return t.ok !== !0 || t.toolName !==
|
|
505
|
+
return t.ok !== !0 || t.toolName !== Is || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? null : {
|
|
335
506
|
id: typeof t.taskId == "string" && t.taskId ? t.taskId : null,
|
|
336
507
|
dueAt: t.dueAt
|
|
337
508
|
};
|
|
338
509
|
}
|
|
339
|
-
const
|
|
510
|
+
const En = [
|
|
340
511
|
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol", price: "$$" },
|
|
341
512
|
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5", price: "$$" },
|
|
342
513
|
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash", price: "$" }
|
|
343
|
-
],
|
|
514
|
+
], Cn = [
|
|
344
515
|
{ value: "anthropic/claude-opus-5", label: "Claude Opus 5", price: "$$$" },
|
|
345
516
|
{ value: "gpt-5.6-terra", label: "gpt-5.6-terra", price: "$$" }
|
|
346
|
-
],
|
|
347
|
-
...
|
|
348
|
-
...
|
|
349
|
-
],
|
|
350
|
-
function
|
|
517
|
+
], _n = [
|
|
518
|
+
...En,
|
|
519
|
+
...Cn
|
|
520
|
+
], Qe = (s) => _n.some((e) => e.value === s);
|
|
521
|
+
function Lt(s, e) {
|
|
351
522
|
return s.filter((t, n) => {
|
|
352
|
-
const i =
|
|
353
|
-
return
|
|
354
|
-
const o =
|
|
355
|
-
return
|
|
523
|
+
const i = Nt(t);
|
|
524
|
+
return Ss(i) ? !s.slice(n + 1).some((r) => {
|
|
525
|
+
const o = Nt(r);
|
|
526
|
+
return Ts(i, o) && ws(i, o);
|
|
356
527
|
}) : !0;
|
|
357
528
|
});
|
|
358
529
|
}
|
|
359
|
-
function
|
|
530
|
+
function Ss(s) {
|
|
360
531
|
return s.type === "run_status" && s.status === "stopped" && s.reason === "task_tab_closed";
|
|
361
532
|
}
|
|
362
|
-
function
|
|
363
|
-
return s.reason === "task_tab_closed" &&
|
|
533
|
+
function Pn(s, e) {
|
|
534
|
+
return s.reason === "task_tab_closed" && ws(s, e) && Ts(s, e);
|
|
364
535
|
}
|
|
365
|
-
function
|
|
536
|
+
function Nt(s) {
|
|
366
537
|
return s.data && typeof s.data == "object" ? s.data : {};
|
|
367
538
|
}
|
|
368
|
-
function
|
|
539
|
+
function Ts(s, e) {
|
|
369
540
|
const t = typeof s.runId == "string" ? s.runId : null, n = typeof e.runId == "string" ? e.runId : null;
|
|
370
|
-
return t && n && t === n ? !1 : e.type === "message" ? e.role === "assistant" : e.type === "run_status" ? !
|
|
541
|
+
return t && n && t === n ? !1 : e.type === "message" ? e.role === "assistant" : e.type === "run_status" ? !Ss(e) : e.type === "run_error";
|
|
371
542
|
}
|
|
372
|
-
function
|
|
543
|
+
function ws(s, e) {
|
|
373
544
|
return typeof s.respondsToUserMessageId == "string" && typeof e.respondsToUserMessageId == "string" ? s.respondsToUserMessageId === e.respondsToUserMessageId : typeof s.clientMessageId == "string" && typeof e.clientMessageId == "string" ? s.clientMessageId === e.clientMessageId : typeof s.runId == "string" && typeof e.runId == "string" && s.runId === e.runId;
|
|
374
545
|
}
|
|
375
|
-
function
|
|
546
|
+
function ke(s) {
|
|
376
547
|
return {
|
|
377
548
|
key: s,
|
|
378
549
|
status: "not_requested",
|
|
@@ -382,9 +553,9 @@ function Ee(s) {
|
|
|
382
553
|
updatedAt: null
|
|
383
554
|
};
|
|
384
555
|
}
|
|
385
|
-
class
|
|
556
|
+
class Ht {
|
|
386
557
|
constructor(e, t, n = (i, r) => r) {
|
|
387
|
-
this.loader = t, this.merge = n, this.state =
|
|
558
|
+
this.loader = t, this.merge = n, this.state = ke(e);
|
|
388
559
|
}
|
|
389
560
|
loader;
|
|
390
561
|
merge;
|
|
@@ -399,10 +570,10 @@ class xt {
|
|
|
399
570
|
return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
|
|
400
571
|
}
|
|
401
572
|
setKey(e) {
|
|
402
|
-
e !== this.state.key && (this.state =
|
|
573
|
+
e !== this.state.key && (this.state = ke(e), this.trailingLoad = null, this.publish());
|
|
403
574
|
}
|
|
404
575
|
reset() {
|
|
405
|
-
this.state =
|
|
576
|
+
this.state = ke(this.state.key), this.trailingLoad = null, this.publish();
|
|
406
577
|
}
|
|
407
578
|
invalidate() {
|
|
408
579
|
this.state = {
|
|
@@ -457,7 +628,7 @@ class xt {
|
|
|
457
628
|
for (const e of this.listeners) e(this.state);
|
|
458
629
|
}
|
|
459
630
|
}
|
|
460
|
-
function
|
|
631
|
+
function Ee(s) {
|
|
461
632
|
const e = {}, t = [];
|
|
462
633
|
for (const n of s.entities)
|
|
463
634
|
e[n.id] || t.push(n.id), e[n.id] = n;
|
|
@@ -467,28 +638,28 @@ function ke(s) {
|
|
|
467
638
|
nextCursor: s.nextCursor
|
|
468
639
|
};
|
|
469
640
|
}
|
|
470
|
-
function
|
|
641
|
+
function vn(s, e, t) {
|
|
471
642
|
if (t === "replace" || s === null) return e;
|
|
472
643
|
const n = { ...s.entitiesById, ...e.entitiesById }, i = [...s.ids];
|
|
473
644
|
for (const r of e.ids)
|
|
474
645
|
s.entitiesById[r] || i.push(r);
|
|
475
646
|
return { entitiesById: n, ids: i, nextCursor: e.nextCursor };
|
|
476
647
|
}
|
|
477
|
-
function
|
|
648
|
+
function As(s) {
|
|
478
649
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
479
650
|
}
|
|
480
|
-
function
|
|
651
|
+
function Oo(s) {
|
|
481
652
|
return s.visible ? s.minimized ? { state: "minimized" } : { state: s.open ? "visible_open" : "visible_closed" } : { state: "hidden" };
|
|
482
653
|
}
|
|
483
|
-
function
|
|
654
|
+
function Un(s, e) {
|
|
484
655
|
return e === "limit_exceeded" ? { allowed: !1, reason: "credits_exhausted", actions: ["upgrade", "earn_credits"] } : e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required" ? { allowed: !1, reason: "payment_issue", actions: ["upgrade"] } : s ?? { allowed: !0, reason: "allowed", actions: [] };
|
|
485
656
|
}
|
|
486
|
-
function
|
|
657
|
+
function Dn(s) {
|
|
487
658
|
if (!s || typeof s != "object") return !1;
|
|
488
659
|
const e = s.paidCreditFallbackModel;
|
|
489
660
|
return typeof e == "string" && e.length > 0;
|
|
490
661
|
}
|
|
491
|
-
function
|
|
662
|
+
function xo(s) {
|
|
492
663
|
const e = s.hasDraftMessage || s.hasPreSubmittedAttachment;
|
|
493
664
|
return s.hasRunningAssistantTurn && !e ? {
|
|
494
665
|
action: "stop",
|
|
@@ -498,20 +669,20 @@ function Co(s) {
|
|
|
498
669
|
disabled: !e || !s.canSubmitMessage
|
|
499
670
|
};
|
|
500
671
|
}
|
|
501
|
-
class
|
|
672
|
+
class qn {
|
|
502
673
|
constructor(e, t, n = 20) {
|
|
503
|
-
this.loadPage = t, this.limit = n, this.recentQuery = new
|
|
674
|
+
this.loadPage = t, this.limit = n, this.recentQuery = new Ht(
|
|
504
675
|
`${e}:recent`,
|
|
505
|
-
async ({ cursor: i }) =>
|
|
676
|
+
async ({ cursor: i }) => Ee(
|
|
506
677
|
await this.loadPage({ cursor: i, limit: this.limit, pinned: !1 }).then((r) => ({
|
|
507
678
|
entities: r.sessions,
|
|
508
679
|
nextCursor: r.nextCursor
|
|
509
680
|
}))
|
|
510
681
|
),
|
|
511
|
-
|
|
512
|
-
), this.pinnedQuery = new
|
|
682
|
+
vn
|
|
683
|
+
), this.pinnedQuery = new Ht(
|
|
513
684
|
`${e}:pinned`,
|
|
514
|
-
async () =>
|
|
685
|
+
async () => Ee({
|
|
515
686
|
entities: await this.loadAllPinned(),
|
|
516
687
|
nextCursor: null
|
|
517
688
|
})
|
|
@@ -535,13 +706,13 @@ class En {
|
|
|
535
706
|
...Ie(e.data)
|
|
536
707
|
], i = new Map(n.map((l) => [l.id, l])), r = Array.from(i.values()).map(
|
|
537
708
|
(l) => this.applyOverrides(l, this.completedRefreshSequence)
|
|
538
|
-
), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ?
|
|
709
|
+
), o = Array.from(this.optimisticEntities.values()).filter((l) => !i.has(l.id)).reverse(), a = e.data || t.data || o.length > 0 ? Ee({
|
|
539
710
|
entities: [...o, ...r],
|
|
540
711
|
nextCursor: e.data?.nextCursor ?? null
|
|
541
712
|
}) : null;
|
|
542
713
|
return {
|
|
543
714
|
key: e.key.slice(0, -7),
|
|
544
|
-
status:
|
|
715
|
+
status: On(e, t),
|
|
545
716
|
data: a,
|
|
546
717
|
error: e.error ?? t.error,
|
|
547
718
|
requestId: Math.max(e.requestId, t.requestId),
|
|
@@ -650,10 +821,10 @@ class En {
|
|
|
650
821
|
function Ie(s) {
|
|
651
822
|
return s ? s.ids.map((e) => s.entitiesById[e]).filter((e) => !!e) : [];
|
|
652
823
|
}
|
|
653
|
-
function
|
|
824
|
+
function On(s, e) {
|
|
654
825
|
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";
|
|
655
826
|
}
|
|
656
|
-
class
|
|
827
|
+
class Bt {
|
|
657
828
|
constructor(e) {
|
|
658
829
|
this.options = e;
|
|
659
830
|
}
|
|
@@ -697,7 +868,7 @@ class Lt {
|
|
|
697
868
|
this.schedule(r, e);
|
|
698
869
|
}
|
|
699
870
|
}
|
|
700
|
-
class
|
|
871
|
+
class xn {
|
|
701
872
|
constructor(e) {
|
|
702
873
|
this.options = e;
|
|
703
874
|
}
|
|
@@ -749,10 +920,10 @@ class Cn {
|
|
|
749
920
|
);
|
|
750
921
|
}
|
|
751
922
|
}
|
|
752
|
-
class
|
|
923
|
+
class Ln {
|
|
753
924
|
constructor(e, t = null) {
|
|
754
925
|
this.storage = e, t && (this.decisions = new Map(
|
|
755
|
-
t.filter(
|
|
926
|
+
t.filter(ot).map((n) => [this.getDecisionKey(n), n])
|
|
756
927
|
), this.initialized = !0);
|
|
757
928
|
}
|
|
758
929
|
storage;
|
|
@@ -764,7 +935,7 @@ class _n {
|
|
|
764
935
|
if (this.initialized) return;
|
|
765
936
|
const e = await this.storage.load();
|
|
766
937
|
this.decisions = new Map(
|
|
767
|
-
e.filter(
|
|
938
|
+
e.filter(ot).map((t) => [this.getDecisionKey(t), t])
|
|
768
939
|
), this.initialized = !0;
|
|
769
940
|
}
|
|
770
941
|
isEligible(e, t = Date.now()) {
|
|
@@ -802,7 +973,7 @@ class _n {
|
|
|
802
973
|
async applyAction(e, t, n) {
|
|
803
974
|
if (!e.allowedActions.includes(t))
|
|
804
975
|
throw new Error(`Interaction ${e.key} does not allow ${t}.`);
|
|
805
|
-
if (!
|
|
976
|
+
if (!Ms(t))
|
|
806
977
|
throw new Error(`Interaction action ${t} is not a persistence decision.`);
|
|
807
978
|
const i = n.now ?? /* @__PURE__ */ new Date(), r = {
|
|
808
979
|
promptKey: e.key,
|
|
@@ -828,51 +999,51 @@ class _n {
|
|
|
828
999
|
return null;
|
|
829
1000
|
}
|
|
830
1001
|
getDecisionKey(e) {
|
|
831
|
-
const t =
|
|
1002
|
+
const t = Je(e.scope);
|
|
832
1003
|
return e.action === "dont_show_again" ? `${t}:category:${e.category}` : `${t}:interaction:${e.promptKey}`;
|
|
833
1004
|
}
|
|
834
1005
|
getExactKey(e) {
|
|
835
|
-
return `${
|
|
1006
|
+
return `${Je(e.scope)}:interaction:${e.key}`;
|
|
836
1007
|
}
|
|
837
1008
|
getCategoryKey(e) {
|
|
838
|
-
return `${
|
|
1009
|
+
return `${Je(e.scope)}:category:${e.category}`;
|
|
839
1010
|
}
|
|
840
1011
|
}
|
|
841
|
-
function
|
|
1012
|
+
function Lo(s, e) {
|
|
842
1013
|
return {
|
|
843
|
-
load: async () =>
|
|
1014
|
+
load: async () => Nn(s, e),
|
|
844
1015
|
save: async (t) => s.setItem(e, JSON.stringify(t))
|
|
845
1016
|
};
|
|
846
1017
|
}
|
|
847
|
-
function
|
|
1018
|
+
function Nn(s, e) {
|
|
848
1019
|
const t = s.getItem(e);
|
|
849
1020
|
if (!t) return [];
|
|
850
1021
|
const n = JSON.parse(t);
|
|
851
|
-
return Array.isArray(n) ? n.filter(
|
|
1022
|
+
return Array.isArray(n) ? n.filter(ot) : [];
|
|
852
1023
|
}
|
|
853
|
-
function
|
|
1024
|
+
function Je(s) {
|
|
854
1025
|
return `${s.level}:${s.key}`;
|
|
855
1026
|
}
|
|
856
|
-
function
|
|
1027
|
+
function Ms(s) {
|
|
857
1028
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
858
1029
|
}
|
|
859
|
-
function
|
|
1030
|
+
function ot(s) {
|
|
860
1031
|
if (!s || typeof s != "object") return !1;
|
|
861
1032
|
const e = s;
|
|
862
|
-
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") &&
|
|
1033
|
+
return typeof e.promptKey == "string" && typeof e.category == "string" && typeof e.decidedAt == "string" && (e.nextEligibleAt === null || typeof e.nextEligibleAt == "string") && Ms(e.action) && !!(e.scope && typeof e.scope == "object" && typeof e.scope.level == "string" && typeof e.scope.key == "string");
|
|
863
1034
|
}
|
|
864
|
-
const
|
|
1035
|
+
const Hn = {
|
|
865
1036
|
working: "⏳",
|
|
866
1037
|
completed: "✅",
|
|
867
1038
|
failed: "❗",
|
|
868
1039
|
stopped: "⏹️"
|
|
869
|
-
},
|
|
870
|
-
function
|
|
1040
|
+
}, Bn = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
1041
|
+
function Fn(s, e) {
|
|
871
1042
|
if (!e) return ve(s);
|
|
872
|
-
const t = ve(s), n = `${
|
|
1043
|
+
const t = ve(s), n = `${Hn[e]} Pluno`;
|
|
873
1044
|
return t ? `${n}: ${t}` : n;
|
|
874
1045
|
}
|
|
875
|
-
class
|
|
1046
|
+
class No {
|
|
876
1047
|
constructor(e) {
|
|
877
1048
|
this.titleDocument = e;
|
|
878
1049
|
}
|
|
@@ -906,11 +1077,11 @@ class Po {
|
|
|
906
1077
|
applyTitle() {
|
|
907
1078
|
if (!this.status)
|
|
908
1079
|
return;
|
|
909
|
-
const e =
|
|
1080
|
+
const e = Fn(this.baseTitle, this.status);
|
|
910
1081
|
this.lastAppliedTitle = e, this.titleDocument.getTitle() !== e && this.titleDocument.setTitle(e);
|
|
911
1082
|
}
|
|
912
1083
|
}
|
|
913
|
-
function
|
|
1084
|
+
function Ho(s) {
|
|
914
1085
|
return {
|
|
915
1086
|
getTitle: () => s.title,
|
|
916
1087
|
setTitle: (e) => {
|
|
@@ -927,9 +1098,9 @@ function vo(s) {
|
|
|
927
1098
|
};
|
|
928
1099
|
}
|
|
929
1100
|
function ve(s) {
|
|
930
|
-
return s.replace(
|
|
1101
|
+
return s.replace(Bn, "");
|
|
931
1102
|
}
|
|
932
|
-
const
|
|
1103
|
+
const Wn = {
|
|
933
1104
|
"duplicate-message-item": "A canonical message rendered more than once.",
|
|
934
1105
|
"duplicate-canonical-item": "A canonical session item rendered more than once.",
|
|
935
1106
|
"duplicate-tool-call": "A tool call rendered more than once.",
|
|
@@ -938,12 +1109,14 @@ const qn = {
|
|
|
938
1109
|
"foreign-session-item-visible": "The visible transcript contains state owned by another session.",
|
|
939
1110
|
"terminal-response-reactivated": "A terminal response became active again.",
|
|
940
1111
|
"terminal-history-not-append-only": "An established terminal outcome disappeared or changed order.",
|
|
941
|
-
"runtime-transcript-not-rendered": "A nonempty runtime transcript is displaying starter prompts."
|
|
1112
|
+
"runtime-transcript-not-rendered": "A nonempty runtime transcript is displaying starter prompts.",
|
|
1113
|
+
"thinking-groups-without-user-message": "Multiple thinking groups appeared without a user message between them.",
|
|
1114
|
+
"thinking-without-progress": "Thinking remained visible without progress for five minutes."
|
|
942
1115
|
};
|
|
943
|
-
function
|
|
944
|
-
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(
|
|
1116
|
+
function $n(s) {
|
|
1117
|
+
return typeof s == "string" && s.startsWith("ui_invariant:") && Object.prototype.hasOwnProperty.call(Wn, s.slice(13));
|
|
945
1118
|
}
|
|
946
|
-
function
|
|
1119
|
+
function Bo(s) {
|
|
947
1120
|
if (!s || typeof s != "object" || !("type" in s)) return !1;
|
|
948
1121
|
const e = s;
|
|
949
1122
|
switch (e.type) {
|
|
@@ -957,7 +1130,7 @@ function Uo(s) {
|
|
|
957
1130
|
case "runtime.report_displayed_error":
|
|
958
1131
|
return (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
|
|
959
1132
|
case "runtime.report_invalid_state_transition":
|
|
960
|
-
return (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" ||
|
|
1133
|
+
return (e.reason === "submitted_turn_returned_to_welcome_without_new_chat" || e.reason === "new_messages_button_without_user_scroll" || $n(e.reason)) && (e.clientMessageId === void 0 || typeof e.clientMessageId == "string");
|
|
961
1134
|
case "runtime.widget_lifecycle":
|
|
962
1135
|
return (e.action === "opened" || e.action === "closed" || e.action === "minimized") && typeof e.trigger == "string";
|
|
963
1136
|
case "session.load":
|
|
@@ -984,9 +1157,9 @@ function Uo(s) {
|
|
|
984
1157
|
return !1;
|
|
985
1158
|
}
|
|
986
1159
|
}
|
|
987
|
-
class
|
|
1160
|
+
class Fo {
|
|
988
1161
|
constructor(e, t, n) {
|
|
989
|
-
this.adapter = t, this.state =
|
|
1162
|
+
this.adapter = t, this.state = Xe(e), this.model = n;
|
|
990
1163
|
}
|
|
991
1164
|
adapter;
|
|
992
1165
|
listeners = {};
|
|
@@ -995,11 +1168,12 @@ class Do {
|
|
|
995
1168
|
interactionListeners = /* @__PURE__ */ new Set();
|
|
996
1169
|
accountListeners = /* @__PURE__ */ new Set();
|
|
997
1170
|
state;
|
|
998
|
-
sessionHistoryState =
|
|
1171
|
+
sessionHistoryState = ke("unavailable");
|
|
999
1172
|
model;
|
|
1000
1173
|
interactions = [];
|
|
1001
1174
|
account = null;
|
|
1002
1175
|
stagedProactiveSuggestionClientMessageId = null;
|
|
1176
|
+
unacknowledgedSubmissions = /* @__PURE__ */ new Map();
|
|
1003
1177
|
operationQueue = Promise.resolve();
|
|
1004
1178
|
destroyed = !1;
|
|
1005
1179
|
on(e, t) {
|
|
@@ -1007,12 +1181,22 @@ class Do {
|
|
|
1007
1181
|
return n.add(t), this.listeners[e] = n, () => n.delete(t);
|
|
1008
1182
|
}
|
|
1009
1183
|
getState() {
|
|
1010
|
-
return
|
|
1184
|
+
return Xe(this.state);
|
|
1011
1185
|
}
|
|
1012
1186
|
updateProjection(e, t, n, i, r) {
|
|
1013
1187
|
if (!this.destroyed) {
|
|
1014
|
-
|
|
1015
|
-
|
|
1188
|
+
this.state = Xe(e);
|
|
1189
|
+
for (const [o, a] of this.unacknowledgedSubmissions) {
|
|
1190
|
+
if (e.user?.id !== a.userId || a.sessionId !== null && e.sessionId !== a.sessionId || e.messages.some(
|
|
1191
|
+
(l) => l.clientMessageId === o
|
|
1192
|
+
)) {
|
|
1193
|
+
this.unacknowledgedSubmissions.delete(o);
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
a.sessionId ??= e.sessionId, this.state.messages.push(a.message), this.state.pendingMessageStatus = "sending", this.state.turnPhase ??= "sending", this.state.taskStatus ??= "working";
|
|
1197
|
+
}
|
|
1198
|
+
if (t !== void 0 && (this.model = t), n) {
|
|
1199
|
+
this.sessionHistoryState = Ft(n);
|
|
1016
1200
|
for (const o of this.sessionHistoryListeners)
|
|
1017
1201
|
o(this.getSessionHistoryState());
|
|
1018
1202
|
}
|
|
@@ -1032,7 +1216,7 @@ class Do {
|
|
|
1032
1216
|
}
|
|
1033
1217
|
destroy() {
|
|
1034
1218
|
if (!this.destroyed) {
|
|
1035
|
-
this.destroyed = !0, this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
1219
|
+
this.destroyed = !0, this.unacknowledgedSubmissions.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
1036
1220
|
for (const e of Object.values(this.listeners)) e?.clear();
|
|
1037
1221
|
this.adapter.onDisconnect?.();
|
|
1038
1222
|
}
|
|
@@ -1057,7 +1241,7 @@ class Do {
|
|
|
1057
1241
|
type: "runtime.report_displayed_error",
|
|
1058
1242
|
reason: e,
|
|
1059
1243
|
errorFingerprint: t,
|
|
1060
|
-
...n ? { displayedMessage:
|
|
1244
|
+
...n ? { displayedMessage: fs(n) } : {}
|
|
1061
1245
|
}).catch(() => {
|
|
1062
1246
|
});
|
|
1063
1247
|
}
|
|
@@ -1072,7 +1256,11 @@ class Do {
|
|
|
1072
1256
|
...i.length > 0 ? { attachments: i } : {},
|
|
1073
1257
|
clientMessageId: r
|
|
1074
1258
|
};
|
|
1075
|
-
return this.
|
|
1259
|
+
return this.unacknowledgedSubmissions.set(r, {
|
|
1260
|
+
message: { ...l, attachments: l.attachments?.map((c) => ({ ...c })) },
|
|
1261
|
+
sessionId: a.sessionId,
|
|
1262
|
+
userId: a.user?.id
|
|
1263
|
+
}), this.state = {
|
|
1076
1264
|
...this.state,
|
|
1077
1265
|
messages: [...this.state.messages, l],
|
|
1078
1266
|
pendingMessageStatus: "sending",
|
|
@@ -1125,7 +1313,7 @@ class Do {
|
|
|
1125
1313
|
c.id && this.attachmentFiles.delete(c.id);
|
|
1126
1314
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), l?.clientMessageId ?? r;
|
|
1127
1315
|
} catch (l) {
|
|
1128
|
-
throw this.state = {
|
|
1316
|
+
throw this.unacknowledgedSubmissions.delete(r), this.state = {
|
|
1129
1317
|
...this.state,
|
|
1130
1318
|
messages: this.state.messages.filter(
|
|
1131
1319
|
(c) => c.id !== `local-${r}` && c.id !== `optimistic-user-message:${r}`
|
|
@@ -1161,23 +1349,23 @@ class Do {
|
|
|
1161
1349
|
};
|
|
1162
1350
|
}
|
|
1163
1351
|
stop() {
|
|
1164
|
-
return this.dispatch({ type: "run.stop" }).then(() => {
|
|
1352
|
+
return this.unacknowledgedSubmissions.clear(), this.dispatch({ type: "run.stop" }).then(() => {
|
|
1165
1353
|
});
|
|
1166
1354
|
}
|
|
1167
1355
|
startNewSession(e = {}) {
|
|
1168
|
-
return e.notifyTransport === !1 ? Promise.resolve() : this.dispatch({ type: "session.new" }).then(() => {
|
|
1356
|
+
return this.unacknowledgedSubmissions.clear(), e.notifyTransport === !1 ? Promise.resolve() : this.dispatch({ type: "session.new" }).then(() => {
|
|
1169
1357
|
});
|
|
1170
1358
|
}
|
|
1171
1359
|
async listSessions(e = {}) {
|
|
1172
1360
|
await this.dispatch({ type: "session.list", ...e });
|
|
1173
1361
|
const t = this.sessionHistoryState.data;
|
|
1174
1362
|
return {
|
|
1175
|
-
sessions:
|
|
1363
|
+
sessions: As(t),
|
|
1176
1364
|
nextCursor: t?.nextCursor ?? null
|
|
1177
1365
|
};
|
|
1178
1366
|
}
|
|
1179
1367
|
getSessionHistoryState() {
|
|
1180
|
-
return
|
|
1368
|
+
return Ft(this.sessionHistoryState);
|
|
1181
1369
|
}
|
|
1182
1370
|
subscribeSessionHistory(e) {
|
|
1183
1371
|
return this.sessionHistoryListeners.add(e), e(this.getSessionHistoryState()), () => this.sessionHistoryListeners.delete(e);
|
|
@@ -1225,7 +1413,7 @@ class Do {
|
|
|
1225
1413
|
return Promise.resolve();
|
|
1226
1414
|
}
|
|
1227
1415
|
loadSession(e) {
|
|
1228
|
-
return this.dispatch({ type: "session.load", sessionId: e }).then(() => {
|
|
1416
|
+
return this.unacknowledgedSubmissions.clear(), this.dispatch({ type: "session.load", sessionId: e }).then(() => {
|
|
1229
1417
|
});
|
|
1230
1418
|
}
|
|
1231
1419
|
stageProactiveSuggestionQuestion(e) {
|
|
@@ -1256,7 +1444,7 @@ class Do {
|
|
|
1256
1444
|
for (const i of n ?? []) i(t);
|
|
1257
1445
|
}
|
|
1258
1446
|
}
|
|
1259
|
-
function
|
|
1447
|
+
function Xe(s) {
|
|
1260
1448
|
return {
|
|
1261
1449
|
...s,
|
|
1262
1450
|
starterPrompts: [...s.starterPrompts],
|
|
@@ -1280,17 +1468,17 @@ function Je(s) {
|
|
|
1280
1468
|
activeScheduledFollowUps: s.activeScheduledFollowUps?.map((e) => ({ ...e })) ?? null
|
|
1281
1469
|
};
|
|
1282
1470
|
}
|
|
1283
|
-
function
|
|
1471
|
+
function Ft(s) {
|
|
1284
1472
|
return {
|
|
1285
1473
|
...s,
|
|
1286
|
-
data: s.data ?
|
|
1287
|
-
entities:
|
|
1474
|
+
data: s.data ? Ee({
|
|
1475
|
+
entities: As(s.data).map((e) => ({ ...e })),
|
|
1288
1476
|
nextCursor: s.data.nextCursor
|
|
1289
1477
|
}) : null
|
|
1290
1478
|
};
|
|
1291
1479
|
}
|
|
1292
|
-
const
|
|
1293
|
-
class
|
|
1480
|
+
const jn = globalThis.fetch.bind(globalThis), Wt = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', zn = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', Kn = ".pluno-pa-widget__panel", Gn = ".pluno-pa-widget__timeline", Vn = "__plunoExtensionWidgetOwner";
|
|
1481
|
+
class J extends Error {
|
|
1294
1482
|
constructor(e, t, n, i) {
|
|
1295
1483
|
super(e), this.retryable = t, this.status = n, this.retryAfterMs = i, this.name = "ProductAgentTokenProviderError";
|
|
1296
1484
|
}
|
|
@@ -1298,11 +1486,11 @@ class X extends Error {
|
|
|
1298
1486
|
status;
|
|
1299
1487
|
retryAfterMs;
|
|
1300
1488
|
}
|
|
1301
|
-
function
|
|
1489
|
+
function Qn(s) {
|
|
1302
1490
|
return s === "dismiss" || s === "later" || s === "snooze" || s === "never" || s === "dont_show_again";
|
|
1303
1491
|
}
|
|
1304
|
-
let
|
|
1305
|
-
function
|
|
1492
|
+
let Jn = 0;
|
|
1493
|
+
function $t(s) {
|
|
1306
1494
|
const e = {};
|
|
1307
1495
|
for (const l of [
|
|
1308
1496
|
"type",
|
|
@@ -1345,7 +1533,7 @@ function Bt(s) {
|
|
|
1345
1533
|
stage: typeof d.stage == "string" ? d.stage : null,
|
|
1346
1534
|
retryable: d.retryable === !0,
|
|
1347
1535
|
visible: !!(g && // Recovery-only failures are intentionally hidden, not missing transcript items.
|
|
1348
|
-
!(d.type === "run_error" && d.retryable === !0) && !g.scheduledCheckInAt && g.toolName !==
|
|
1536
|
+
!(d.type === "run_error" && d.retryable === !0) && !g.scheduledCheckInAt && g.toolName !== Tt && (d.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(d.status))))
|
|
1349
1537
|
};
|
|
1350
1538
|
}, o = r(s.item);
|
|
1351
1539
|
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, o.streamId && (e.visibleItemAliases = JSON.stringify([[o.streamId, o.id]])))), Array.isArray(s.items)) {
|
|
@@ -1380,7 +1568,7 @@ function Se(s, e, t) {
|
|
|
1380
1568
|
source: "web_sdk",
|
|
1381
1569
|
category: s,
|
|
1382
1570
|
name: e,
|
|
1383
|
-
sequence: ++
|
|
1571
|
+
sequence: ++Jn,
|
|
1384
1572
|
wallTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1385
1573
|
monotonicMs: performance.now(),
|
|
1386
1574
|
data: t
|
|
@@ -1389,27 +1577,27 @@ function Se(s, e, t) {
|
|
|
1389
1577
|
}
|
|
1390
1578
|
class Te extends Error {
|
|
1391
1579
|
}
|
|
1392
|
-
function
|
|
1580
|
+
function Xn(s) {
|
|
1393
1581
|
return s === 408 || s === 425 || s === 429 || s >= 500;
|
|
1394
1582
|
}
|
|
1395
|
-
const
|
|
1583
|
+
const Yn = "https://app.pluno.ai", Zn = 2e4, ei = 1e4, ti = 6e4, si = 6e4, ni = 1e4, ii = 1e4, ri = 3e3, oi = 3e4, ai = 1e3, at = 3e4, jt = 0.2, li = 6e4, zt = 15e3, ci = 6e4, ui = 8, di = "Browser connection was interrupted.", Kt = 15e3, hi = "Pluno could not send this message. Try it again.", pi = "Still connecting to Pluno. Retrying automatically.", gi = 2e3, fi = 1e3, mi = 100, Gt = 8e3, Vt = 3, yi = [300, 1e3], bs = 50 * 1024 * 1024, Ii = /* @__PURE__ */ new Set([
|
|
1396
1584
|
".jpeg:image/jpeg",
|
|
1397
1585
|
".jpg:image/jpeg",
|
|
1398
1586
|
".pdf:application/pdf",
|
|
1399
1587
|
".png:image/png",
|
|
1400
1588
|
".webp:image/webp"
|
|
1401
|
-
]),
|
|
1402
|
-
function
|
|
1589
|
+
]), Wo = ".pdf,.png,.jpg,.jpeg,.webp", wt = 64e3, Ye = 4e3, At = 30, Si = 2e3, Ti = 1e3, Rs = "Image is too large for model vision input.", wi = 100, Ai = 20, ks = "pluno.productAgent.state.", lt = "pluno.productAgent.pendingEvents.", Le = "pluno.productAgent.activeToolCalls.", Mi = 100;
|
|
1590
|
+
function bi(s, e = 0) {
|
|
1403
1591
|
const t = s === 0 ? 0 : Math.min(3e4, 1e3 * 2 ** (s - 1));
|
|
1404
1592
|
return Math.max(e, t);
|
|
1405
1593
|
}
|
|
1406
1594
|
const Ce = /* @__PURE__ */ new Set();
|
|
1407
1595
|
let we = null;
|
|
1408
|
-
function
|
|
1409
|
-
const t = Math.min(
|
|
1410
|
-
return Math.min(
|
|
1596
|
+
function Ri(s, e = Math.random) {
|
|
1597
|
+
const t = Math.min(at, ai * 2 ** s), n = 1 - jt + e() * jt * 2;
|
|
1598
|
+
return Math.min(at, Math.round(t * n));
|
|
1411
1599
|
}
|
|
1412
|
-
function
|
|
1600
|
+
function ki(s) {
|
|
1413
1601
|
const e = s.split(".")[1];
|
|
1414
1602
|
if (!e)
|
|
1415
1603
|
return null;
|
|
@@ -1420,8 +1608,8 @@ function Ii(s) {
|
|
|
1420
1608
|
return null;
|
|
1421
1609
|
}
|
|
1422
1610
|
}
|
|
1423
|
-
function
|
|
1424
|
-
if (s instanceof
|
|
1611
|
+
function Ei(s) {
|
|
1612
|
+
if (s instanceof J)
|
|
1425
1613
|
return s.retryable;
|
|
1426
1614
|
if (s && typeof s == "object") {
|
|
1427
1615
|
const e = s.status;
|
|
@@ -1430,7 +1618,7 @@ function Si(s) {
|
|
|
1430
1618
|
}
|
|
1431
1619
|
return !0;
|
|
1432
1620
|
}
|
|
1433
|
-
function
|
|
1621
|
+
function Ci(s) {
|
|
1434
1622
|
if (s instanceof Error)
|
|
1435
1623
|
return s;
|
|
1436
1624
|
if (s && typeof s == "object") {
|
|
@@ -1444,10 +1632,10 @@ function Ti(s) {
|
|
|
1444
1632
|
}
|
|
1445
1633
|
class Ne {
|
|
1446
1634
|
constructor(e, t) {
|
|
1447
|
-
this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new
|
|
1635
|
+
this.options = e, this.transportIdentity = t, this.sessionHistoryManager = new qn(
|
|
1448
1636
|
e.clientId,
|
|
1449
1637
|
async ({ cursor: r, limit: o, pinned: a }) => await this.listSessions({ cursor: r, limit: o, pinned: a })
|
|
1450
|
-
), this.sessionRecoveryPoller = new
|
|
1638
|
+
), this.sessionRecoveryPoller = new Bt({
|
|
1451
1639
|
poll: async ({ sessionId: r }) => await this.fetchSessionHistoryPageOnce(
|
|
1452
1640
|
r,
|
|
1453
1641
|
"transcript",
|
|
@@ -1459,7 +1647,7 @@ class Ne {
|
|
|
1459
1647
|
activeIntervalMs: 3e3,
|
|
1460
1648
|
idleIntervalMs: 15e3,
|
|
1461
1649
|
maxFailureIntervalMs: 3e4
|
|
1462
|
-
}), this.sessionActivityRecovery = new
|
|
1650
|
+
}), this.sessionActivityRecovery = new xn({
|
|
1463
1651
|
fetchPage: async (r, o) => await this.fetchSessionHistoryPageOnce(
|
|
1464
1652
|
r,
|
|
1465
1653
|
"activity",
|
|
@@ -1478,24 +1666,24 @@ class Ne {
|
|
|
1478
1666
|
},
|
|
1479
1667
|
getItemId: (r) => A(r, "id"),
|
|
1480
1668
|
maxPagesPerPoll: 3
|
|
1481
|
-
}), this.sessionActivityRecoveryPoller = new
|
|
1669
|
+
}), this.sessionActivityRecoveryPoller = new Bt({
|
|
1482
1670
|
poll: async ({ sessionId: r }) => await this.sessionActivityRecovery.poll(r),
|
|
1483
1671
|
apply: async (r) => await this.sessionActivityRecovery.apply(r),
|
|
1484
1672
|
isActiveTurn: () => this.state.isThinking || this.state.pendingMessageStatus !== null,
|
|
1485
1673
|
activeIntervalMs: 3e3,
|
|
1486
1674
|
idleIntervalMs: 15e3,
|
|
1487
1675
|
maxFailureIntervalMs: 3e4
|
|
1488
|
-
}), this.personalModelSelectionOverride = e.productVariant === "personal" &&
|
|
1676
|
+
}), this.personalModelSelectionOverride = e.productVariant === "personal" && Qe(e.model) ? e.model : null, this.state = {
|
|
1489
1677
|
...this.state,
|
|
1490
|
-
starterPrompts:
|
|
1678
|
+
starterPrompts: cr(e.initialStarterPrompts)
|
|
1491
1679
|
}, this.account = e.initialAccount ? { ...e.initialAccount } : null;
|
|
1492
|
-
const n = e.restorePersistedState === !1 ? null :
|
|
1680
|
+
const n = e.restorePersistedState === !1 ? null : Zr(e.clientId, e.expectedPersistedSessionId);
|
|
1493
1681
|
n && (this.state = {
|
|
1494
1682
|
...this.state,
|
|
1495
1683
|
...n,
|
|
1496
1684
|
// Paint the readable same-session cache immediately while the complete transcript is revalidated. Tool
|
|
1497
1685
|
// activity is deliberately not restored here because it hydrates after the transcript is visible.
|
|
1498
|
-
messages: n.messages.filter(
|
|
1686
|
+
messages: n.messages.filter(ft),
|
|
1499
1687
|
isLoadingSession: n.sessionId !== null,
|
|
1500
1688
|
status: "idle",
|
|
1501
1689
|
user: null,
|
|
@@ -1510,16 +1698,17 @@ class Ne {
|
|
|
1510
1698
|
taskStatus: null,
|
|
1511
1699
|
isRetrying: !1,
|
|
1512
1700
|
lastError: null
|
|
1513
|
-
}, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents =
|
|
1514
|
-
|
|
1515
|
-
|
|
1701
|
+
}, n.sessionId && this.rememberSessionTimeline(n.sessionId, this.state.messages)), this.queuedClientEvents = ro(
|
|
1702
|
+
to(e.clientId),
|
|
1703
|
+
so(e.clientId)
|
|
1516
1704
|
);
|
|
1517
1705
|
const i = [...this.queuedClientEvents].reverse().find(
|
|
1518
1706
|
(r) => r.type === "chat.user_message" && typeof r.clientMessageId == "string"
|
|
1519
1707
|
);
|
|
1520
|
-
i?.clientMessageId && (this.pendingClientMessageId = i.clientMessageId, this.pendingUserMessageEvent = i, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"),
|
|
1708
|
+
i?.clientMessageId && (this.pendingClientMessageId = i.clientMessageId, this.pendingUserMessageEvent = i, this.state.pendingMessageStatus = "reconnecting", this.state.turnPhase = "sending"), Q(e.clientId, this.queuedClientEvents);
|
|
1521
1709
|
}
|
|
1522
1710
|
options;
|
|
1711
|
+
clientRuntime = new Zs();
|
|
1523
1712
|
listeners = {};
|
|
1524
1713
|
socket = null;
|
|
1525
1714
|
reconnectTimer = null;
|
|
@@ -1558,7 +1747,7 @@ class Ne {
|
|
|
1558
1747
|
accountRefresh = null;
|
|
1559
1748
|
runtimeInteractions = [];
|
|
1560
1749
|
interactionListeners = /* @__PURE__ */ new Set();
|
|
1561
|
-
interactionManager = new
|
|
1750
|
+
interactionManager = new Ln(
|
|
1562
1751
|
{ load: async () => [], save: async () => {
|
|
1563
1752
|
} },
|
|
1564
1753
|
[]
|
|
@@ -1658,17 +1847,17 @@ class Ne {
|
|
|
1658
1847
|
lastErrorSecuritySettingsUrl: null
|
|
1659
1848
|
};
|
|
1660
1849
|
static async init(e) {
|
|
1661
|
-
const t = e, n = await
|
|
1850
|
+
const t = e, n = await wn(
|
|
1662
1851
|
t.skipStoredTransportIdentityCollisionCheck === !0
|
|
1663
1852
|
), i = new Ne({
|
|
1664
1853
|
...e,
|
|
1665
|
-
backendUrl:
|
|
1666
|
-
clientId: e.clientId ??
|
|
1854
|
+
backendUrl: Vi(e.backendUrl ?? Yn),
|
|
1855
|
+
clientId: e.clientId ?? gr(),
|
|
1667
1856
|
productVariant: e.productVariant ?? "customer_embedded",
|
|
1668
|
-
entrySurface:
|
|
1857
|
+
entrySurface: Qi(e.entrySurface)
|
|
1669
1858
|
}, n);
|
|
1670
1859
|
try {
|
|
1671
|
-
|
|
1860
|
+
on().catch((r) => {
|
|
1672
1861
|
b("web-sdk.attachments", "Failed to delete stale Product Agent attachments", {
|
|
1673
1862
|
message: r instanceof Error ? r.message : String(r)
|
|
1674
1863
|
});
|
|
@@ -1683,28 +1872,30 @@ class Ne {
|
|
|
1683
1872
|
return n.add(t), this.listeners[e] = n, () => n.delete(t);
|
|
1684
1873
|
}
|
|
1685
1874
|
getState() {
|
|
1686
|
-
return {
|
|
1875
|
+
return this.clientRuntime.project("conversation", { legacy: () => ({
|
|
1687
1876
|
...this.state,
|
|
1688
1877
|
activeResponseUserMessageId: this.activeResponseUserMessageId,
|
|
1689
1878
|
starterPrompts: [...this.state.starterPrompts],
|
|
1690
1879
|
appearance: this.state.appearance ? { ...this.state.appearance } : null,
|
|
1691
1880
|
messages: [...this.state.messages]
|
|
1692
|
-
};
|
|
1881
|
+
}) });
|
|
1693
1882
|
}
|
|
1694
1883
|
stageProactiveSuggestionQuestion(e) {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1884
|
+
return this.clientRuntime.route("conversation", { legacy: () => {
|
|
1885
|
+
const t = e.trim();
|
|
1886
|
+
if (!t)
|
|
1887
|
+
return;
|
|
1888
|
+
const n = this.stagedProactiveSuggestionQuestionMessageId ?? `local-proactive-suggestion-edit-${x()}`;
|
|
1889
|
+
this.stagedProactiveSuggestionQuestionMessageId = n;
|
|
1890
|
+
const i = {
|
|
1891
|
+
id: n,
|
|
1892
|
+
role: "assistant",
|
|
1893
|
+
phase: "final_answer",
|
|
1894
|
+
content: t,
|
|
1895
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1896
|
+
}, r = this.state.messages.findIndex((a) => a.id === n), o = [...this.state.messages];
|
|
1897
|
+
r >= 0 ? o[r] = i : o.push(i), this.setState({ messages: o }), this.emit("message", i);
|
|
1898
|
+
} });
|
|
1708
1899
|
}
|
|
1709
1900
|
invalidateProviderToken() {
|
|
1710
1901
|
this.options.token || (this.token = null, this.tokenExpiresAtMs = null);
|
|
@@ -1714,7 +1905,7 @@ class Ne {
|
|
|
1714
1905
|
return this.options.token;
|
|
1715
1906
|
if (!this.options.tokenProvider)
|
|
1716
1907
|
return this.token;
|
|
1717
|
-
const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs -
|
|
1908
|
+
const n = Date.now(), i = this.token !== null && this.tokenExpiresAtMs !== null && this.tokenExpiresAtMs - si > n;
|
|
1718
1909
|
if (!t.forceRefresh && (i || t.preferCached && this.token !== null))
|
|
1719
1910
|
return this.token;
|
|
1720
1911
|
if (this.tokenRequest && !t.forceRefresh)
|
|
@@ -1726,8 +1917,8 @@ class Ne {
|
|
|
1726
1917
|
let a = null;
|
|
1727
1918
|
const l = new Promise((c, u) => {
|
|
1728
1919
|
a = window.setTimeout(() => {
|
|
1729
|
-
r.abort(), u(new
|
|
1730
|
-
},
|
|
1920
|
+
r.abort(), u(new J("Pluno token provider timed out", !0));
|
|
1921
|
+
}, ti);
|
|
1731
1922
|
});
|
|
1732
1923
|
try {
|
|
1733
1924
|
const c = await Promise.race([
|
|
@@ -1735,10 +1926,10 @@ class Ne {
|
|
|
1735
1926
|
l
|
|
1736
1927
|
]);
|
|
1737
1928
|
if (r.signal.aborted || this.tokenAbortController !== r)
|
|
1738
|
-
throw new
|
|
1929
|
+
throw new J("Pluno token request was cancelled", !0);
|
|
1739
1930
|
if (!c)
|
|
1740
|
-
throw new
|
|
1741
|
-
return this.token = c, this.tokenExpiresAtMs =
|
|
1931
|
+
throw new J("Pluno token provider did not return a token", !1);
|
|
1932
|
+
return this.token = c, this.tokenExpiresAtMs = ki(c), c;
|
|
1742
1933
|
} finally {
|
|
1743
1934
|
a !== null && window.clearTimeout(a);
|
|
1744
1935
|
}
|
|
@@ -1751,112 +1942,120 @@ class Ne {
|
|
|
1751
1942
|
}
|
|
1752
1943
|
}
|
|
1753
1944
|
async connect() {
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null, this.reconnectAttempts = 0), this.connectionInProgress = !0;
|
|
1757
|
-
const e = ++this.connectionAttemptId;
|
|
1758
|
-
this.setState(
|
|
1759
|
-
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
1760
|
-
);
|
|
1761
|
-
try {
|
|
1762
|
-
if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
1945
|
+
return this.clientRuntime.route("conversation", { legacy: async () => {
|
|
1946
|
+
if (this.connectionInProgress || this.socket?.readyState === WebSocket.OPEN || this.socket?.readyState === WebSocket.CONNECTING)
|
|
1763
1947
|
return;
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
this.
|
|
1771
|
-
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1772
|
-
isThinking: this.state.isThinking
|
|
1773
|
-
}), !(this.token ? this.sendNow({
|
|
1774
|
-
type: "auth.session",
|
|
1775
|
-
token: this.token,
|
|
1776
|
-
clientId: this.options.clientId,
|
|
1777
|
-
transportId: this.transportIdentity.transportId,
|
|
1778
|
-
pageUrl: location.href
|
|
1779
|
-
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
1780
|
-
this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
|
|
1781
|
-
}, Xn));
|
|
1782
|
-
}), n.addEventListener("message", (i) => {
|
|
1783
|
-
this.socket === n && this.handleServerEvent(Zi(i.data));
|
|
1784
|
-
}), n.addEventListener("sendfailure", (i) => {
|
|
1785
|
-
if (this.socket !== n)
|
|
1948
|
+
this.reconnectTimer !== null && (window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null, this.reconnectAttempts = 0), this.connectionInProgress = !0;
|
|
1949
|
+
const e = ++this.connectionAttemptId;
|
|
1950
|
+
this.setState(
|
|
1951
|
+
this.state.status === "reconnecting" ? { status: "reconnecting" } : { status: "connecting", lastError: null }
|
|
1952
|
+
);
|
|
1953
|
+
try {
|
|
1954
|
+
if (this.token = await this.acquireToken("connect"), e !== this.connectionAttemptId || this.state.status === "closed")
|
|
1786
1955
|
return;
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1956
|
+
if (!this.token && !this.options.webSocketFactory)
|
|
1957
|
+
throw new J("Pluno requires a token or tokenProvider", !1);
|
|
1958
|
+
const t = Yi(this.options.backendUrl), n = this.options.webSocketFactory?.(t) ?? new WebSocket(t);
|
|
1959
|
+
this.socket = n, this.socketConnectTimer = window.setTimeout(() => {
|
|
1960
|
+
this.socket === n && n.readyState === WebSocket.CONNECTING && (b("web-sdk.agent", "Pluno socket opening timed out; reconnecting"), this.reportTransportDiagnostic("connect_timeout"), this.replaceTimedOutSocket(n));
|
|
1961
|
+
}, ni), n.addEventListener("open", () => {
|
|
1962
|
+
this.socket !== n || (this.clearSocketConnectTimer(), b("web-sdk.agent", "Pluno socket opened", {
|
|
1963
|
+
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1964
|
+
isThinking: this.state.isThinking
|
|
1965
|
+
}), !(this.token ? this.sendNow({
|
|
1966
|
+
type: "auth.session",
|
|
1967
|
+
token: this.token,
|
|
1968
|
+
clientId: this.options.clientId,
|
|
1969
|
+
transportId: this.transportIdentity.transportId,
|
|
1970
|
+
pageUrl: location.href
|
|
1971
|
+
}) : !0)) || (this.socketAuthTimer = window.setTimeout(() => {
|
|
1972
|
+
this.socket === n && (b("web-sdk.agent", "Pluno socket authentication timed out; reconnecting"), this.reportTransportDiagnostic("auth_timeout"), this.replaceTimedOutSocket(n));
|
|
1973
|
+
}, ii));
|
|
1974
|
+
}), n.addEventListener("message", (i) => {
|
|
1975
|
+
this.socket === n && this.handleServerEvent(ar(i.data));
|
|
1976
|
+
}), n.addEventListener("sendfailure", (i) => {
|
|
1977
|
+
if (this.socket !== n)
|
|
1978
|
+
return;
|
|
1979
|
+
const r = lr(i?.detail?.data);
|
|
1980
|
+
r?.type === "chat.user_message" && r.clientMessageId === this.pendingClientMessageId && !this.queuedClientEvents.some(
|
|
1981
|
+
(o) => o.type === "chat.user_message" && o.clientMessageId === r.clientMessageId
|
|
1982
|
+
) && (this.queuedClientEvents.push(r), Q(this.options.clientId, this.queuedClientEvents), this.setState({ pendingMessageStatus: "reconnecting" })), this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), n.readyState !== WebSocket.CLOSED && n.readyState !== WebSocket.CLOSING && n.close();
|
|
1983
|
+
}), n.addEventListener("close", (i) => {
|
|
1984
|
+
this.socket === n && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (b("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
1985
|
+
code: typeof i?.code == "number" ? i.code : null,
|
|
1986
|
+
reason: typeof i?.reason == "string" ? i.reason : "",
|
|
1987
|
+
wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : null,
|
|
1988
|
+
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1989
|
+
isThinking: this.state.isThinking
|
|
1990
|
+
}), (typeof i?.code != "number" || i.code !== 1e3) && this.reportTransportDiagnostic("socket_closed", {
|
|
1991
|
+
closeCode: typeof i?.code == "number" ? i.code : void 0,
|
|
1992
|
+
wasClean: typeof i?.wasClean == "boolean" ? i.wasClean : void 0
|
|
1993
|
+
}), this.setReconnectingState(), this.scheduleReconnect()));
|
|
1994
|
+
}), n.addEventListener("error", () => {
|
|
1995
|
+
this.socket !== n || this.state.status === "closed" || (b("web-sdk.agent", "Pluno socket error; scheduling reconnect", {
|
|
1996
|
+
queuedClientEventCount: this.queuedClientEvents.length,
|
|
1997
|
+
isThinking: this.state.isThinking
|
|
1998
|
+
}), 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());
|
|
1999
|
+
});
|
|
2000
|
+
} catch (t) {
|
|
2001
|
+
if (e !== this.connectionAttemptId || this.state.status === "closed")
|
|
2002
|
+
return;
|
|
2003
|
+
const n = Ci(t);
|
|
2004
|
+
if (Ei(t)) {
|
|
2005
|
+
b("web-sdk.agent", "Pluno connection attempt failed; retrying", {
|
|
2006
|
+
message: n.message,
|
|
2007
|
+
reconnectAttempt: this.reconnectAttempts
|
|
2008
|
+
}), t instanceof J && this.reportTransportDiagnostic("auth_timeout"), this.setState({
|
|
2009
|
+
status: "reconnecting",
|
|
2010
|
+
lastError: pi,
|
|
2011
|
+
lastErrorCode: "connection_failed"
|
|
2012
|
+
}), this.emit("error", n), this.scheduleReconnect(
|
|
2013
|
+
t instanceof J ? t.retryAfterMs : void 0
|
|
2014
|
+
);
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
2017
|
+
throw this.setState({
|
|
2018
|
+
status: "error",
|
|
2019
|
+
lastError: n.message,
|
|
1819
2020
|
lastErrorCode: "connection_failed"
|
|
1820
|
-
}), this.emit("error", n),
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
return;
|
|
2021
|
+
}), this.emit("error", n), n;
|
|
2022
|
+
} finally {
|
|
2023
|
+
this.connectionInProgress = !1;
|
|
1824
2024
|
}
|
|
1825
|
-
|
|
1826
|
-
status: "error",
|
|
1827
|
-
lastError: n.message,
|
|
1828
|
-
lastErrorCode: "connection_failed"
|
|
1829
|
-
}), this.emit("error", n), n;
|
|
1830
|
-
} finally {
|
|
1831
|
-
this.connectionInProgress = !1;
|
|
1832
|
-
}
|
|
2025
|
+
} });
|
|
1833
2026
|
}
|
|
1834
2027
|
disconnect() {
|
|
1835
|
-
|
|
2028
|
+
return this.clientRuntime.route("conversation", { legacy: () => {
|
|
2029
|
+
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.clearAllFirstResponseTimers(), 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;
|
|
2030
|
+
} });
|
|
1836
2031
|
}
|
|
1837
2032
|
destroy() {
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
e
|
|
1841
|
-
|
|
2033
|
+
if (!this.clientRuntime.isDisposed) {
|
|
2034
|
+
this.disconnect(), this.clearAllFirstResponseTimers(), this.locationChangeCleanup?.(), this.locationChangeCleanup = null, this.cleanupSessionBrowserApis(), this.pageLifecycleCleanup?.(), this.pageLifecycleCleanup = null, this.activeBrowserToolCalls.clear(), oo(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();
|
|
2035
|
+
for (const e of Object.values(this.listeners))
|
|
2036
|
+
e?.clear();
|
|
2037
|
+
this.accountListeners.clear(), this.interactionListeners.clear(), this.clientRuntime.dispose();
|
|
2038
|
+
}
|
|
1842
2039
|
}
|
|
1843
2040
|
warmup(e = "panel_open") {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
if (
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
2041
|
+
return this.clientRuntime.route("conversation", { legacy: () => {
|
|
2042
|
+
const t = _(), n = `${this.state.sessionId ?? "draft"}:${t.url}`, i = e === "composer_input" && this.pendingComposerWarmup?.scope === n ? this.pendingComposerWarmup : null, r = {
|
|
2043
|
+
type: "runtime.warmup",
|
|
2044
|
+
reason: e,
|
|
2045
|
+
...e === "composer_input" ? { warmupId: i?.event.warmupId ?? x() } : {},
|
|
2046
|
+
entrySurface: this.options.entrySurface,
|
|
2047
|
+
sessionId: this.state.sessionId ?? void 0,
|
|
2048
|
+
page: t,
|
|
2049
|
+
model: this.options.model
|
|
2050
|
+
};
|
|
2051
|
+
if (e === "composer_input") {
|
|
2052
|
+
if (this.options.productVariant === "customer_embedded") {
|
|
2053
|
+
this.sendNow(r) || (this.pendingPassiveWarmupEvent = r);
|
|
2054
|
+
return;
|
|
2055
|
+
}
|
|
2056
|
+
i || (this.clearPendingComposerWarmup(), this.pendingComposerWarmup = { event: r, scope: n, retryAttempt: 0, acknowledged: !1 }, this.activeComposerWarmupId = r.warmupId ?? null, this.activeComposerWarmupScope = n), this.flushPendingComposerWarmup();
|
|
2057
|
+
} else this.sendNow(r) || (this.pendingPassiveWarmupEvent = r);
|
|
2058
|
+
} });
|
|
1860
2059
|
}
|
|
1861
2060
|
recordWidgetLifecycle(e, t) {
|
|
1862
2061
|
const n = {
|
|
@@ -1874,114 +2073,116 @@ class Ne {
|
|
|
1874
2073
|
this.authenticatedSocket === this.socket && this.sendNow(n) || (this.pendingWidgetLifecycleEvents.push(n), this.pendingWidgetLifecycleEvents.length > 20 && this.pendingWidgetLifecycleEvents.splice(0, this.pendingWidgetLifecycleEvents.length - 20));
|
|
1875
2074
|
}
|
|
1876
2075
|
async sendMessage(e, t = {}) {
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
(
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
(
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
const
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2076
|
+
return this.clientRuntime.route("conversation", { legacy: async () => {
|
|
2077
|
+
const n = e.trim(), i = t.attachments ?? [];
|
|
2078
|
+
if (this.options.productVariant === "customer_embedded" && (i.forEach(Hs), i.reduce(
|
|
2079
|
+
(T, N) => T + N.sizeBytes,
|
|
2080
|
+
0
|
|
2081
|
+
) > bs))
|
|
2082
|
+
throw new Error("Embedded attachments must total at most 50 MB per message");
|
|
2083
|
+
let r = i.map(qe);
|
|
2084
|
+
if (!n && r.length === 0)
|
|
2085
|
+
return null;
|
|
2086
|
+
if (this.pendingClientMessageId)
|
|
2087
|
+
throw new Error("Wait for the current message to finish sending before sending another.");
|
|
2088
|
+
const o = _(), a = t.clientMessageId ?? x(), l = t.proactiveSuggestionQuestion?.trim(), c = this.stagedProactiveSuggestionQuestionMessageId ? this.state.messages.find(
|
|
2089
|
+
(S) => S.id === this.stagedProactiveSuggestionQuestionMessageId
|
|
2090
|
+
) ?? null : null, u = l ? {
|
|
2091
|
+
id: `local-proactive-suggestion-question-${a}`,
|
|
2092
|
+
role: "assistant",
|
|
2093
|
+
phase: "final_answer",
|
|
2094
|
+
content: l,
|
|
2095
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2096
|
+
} : null, d = {
|
|
2097
|
+
id: `local-${a}`,
|
|
2098
|
+
role: "user",
|
|
2099
|
+
content: n,
|
|
2100
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2101
|
+
...i.length > 0 ? { attachments: i } : {}
|
|
2102
|
+
}, 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 : [
|
|
2103
|
+
...this.state.messages.map(
|
|
2104
|
+
(S) => c && S.id === c.id ? {
|
|
2105
|
+
...S,
|
|
2106
|
+
id: `local-proactive-suggestion-question-${a}`
|
|
2107
|
+
} : S
|
|
2108
|
+
),
|
|
2109
|
+
...!c && u ? [u] : [],
|
|
2110
|
+
d
|
|
2111
|
+
], w = {
|
|
2112
|
+
assistantDraft: this.state.assistantDraft,
|
|
2113
|
+
assistantDraftItemId: this.state.assistantDraftItemId,
|
|
2114
|
+
assistantDraftPhase: this.state.assistantDraftPhase,
|
|
2115
|
+
assistantDraftRespondsToUserMessageId: this.state.assistantDraftRespondsToUserMessageId,
|
|
2116
|
+
assistantDraftRunId: this.state.assistantDraftRunId,
|
|
2117
|
+
lastError: this.state.lastError
|
|
2118
|
+
};
|
|
2119
|
+
this.setState({
|
|
2120
|
+
messages: M,
|
|
2121
|
+
...f ? {} : {
|
|
2122
|
+
assistantDraft: "",
|
|
2123
|
+
assistantDraftItemId: null,
|
|
2124
|
+
assistantDraftPhase: null,
|
|
2125
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
2126
|
+
assistantDraftRunId: null
|
|
2127
|
+
},
|
|
2128
|
+
pendingMessageStatus: "sending",
|
|
2129
|
+
turnPhase: f ? y : "sending",
|
|
2130
|
+
isThinking: f,
|
|
2131
|
+
taskStatus: "working",
|
|
2132
|
+
isRetrying: !1,
|
|
2133
|
+
lastError: null
|
|
2134
|
+
}), this.startFirstResponseTimer(a, t.submittedAt), g || (this.sessionHistoryManager.addOptimistic({
|
|
2135
|
+
id: d.id,
|
|
2136
|
+
title: null,
|
|
2137
|
+
customTitle: null,
|
|
2138
|
+
firstUserMessage: d.content,
|
|
2139
|
+
currentPage: o,
|
|
2140
|
+
createdAt: d.createdAt,
|
|
2141
|
+
updatedAt: d.createdAt,
|
|
2142
|
+
lastActiveAt: d.createdAt,
|
|
2143
|
+
isActive: !0,
|
|
2144
|
+
isPinned: !1
|
|
2145
|
+
}), u && !c && this.emit("message", u), this.emit("message", d));
|
|
2146
|
+
try {
|
|
2147
|
+
const S = [];
|
|
2148
|
+
for (const T of r) {
|
|
2149
|
+
const N = T.id ? this.attachmentFiles.get(T.id) : void 0;
|
|
2150
|
+
if (T.sandboxPath || T.storageKey) {
|
|
2151
|
+
S.push(T);
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
if (!N)
|
|
2155
|
+
throw new Error(`Attachment bytes are unavailable for ${T.name}`);
|
|
2156
|
+
S.push(await this.uploadAttachmentForMessage({ file: N, attachment: T }));
|
|
1953
2157
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
2158
|
+
r = S;
|
|
2159
|
+
} catch (S) {
|
|
2160
|
+
throw this.clearFirstResponseTimer(a), g || this.sessionHistoryManager.removeOptimistic(d.id), this.setState({
|
|
2161
|
+
...g ? {} : { messages: m },
|
|
2162
|
+
...f ? {} : { ...w, isThinking: !1 },
|
|
2163
|
+
pendingMessageStatus: p,
|
|
2164
|
+
turnPhase: y,
|
|
2165
|
+
taskStatus: h
|
|
2166
|
+
}), S;
|
|
1957
2167
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
content: n,
|
|
1977
|
-
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
1978
|
-
pageContent: D && At() || void 0,
|
|
1979
|
-
attachments: r.length > 0 ? r.map(qe) : void 0,
|
|
1980
|
-
page: o,
|
|
1981
|
-
model: this.options.model,
|
|
1982
|
-
metadata: Kt(this.options.metadata)
|
|
1983
|
-
};
|
|
1984
|
-
return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
|
|
2168
|
+
this.retryableClientMessageId = null;
|
|
2169
|
+
const D = !t.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== o.url, H = {
|
|
2170
|
+
type: "chat.user_message",
|
|
2171
|
+
sessionId: this.state.sessionId ?? void 0,
|
|
2172
|
+
clientMessageId: a,
|
|
2173
|
+
initiatedBy: t.initiatedBy,
|
|
2174
|
+
invocation: Ji(t.invocation ?? t.initiatedBy),
|
|
2175
|
+
entrySurface: this.options.entrySurface,
|
|
2176
|
+
content: n,
|
|
2177
|
+
proactiveSuggestionQuestion: t.proactiveSuggestionQuestion,
|
|
2178
|
+
pageContent: D && Mt() || void 0,
|
|
2179
|
+
attachments: r.length > 0 ? r.map(qe) : void 0,
|
|
2180
|
+
page: o,
|
|
2181
|
+
model: this.options.model,
|
|
2182
|
+
metadata: Qt(this.options.metadata)
|
|
2183
|
+
};
|
|
2184
|
+
return t.initiatedBy || (this.lastUserMessagePageUrl = o.url), this.pendingClientMessageId = a, this.pendingUserMessageEvent = H, this.stagedProactiveSuggestionQuestionMessageId = null, this.send(H), this.schedulePendingDeliveryAck(a), a;
|
|
2185
|
+
} });
|
|
1985
2186
|
}
|
|
1986
2187
|
reportInvalidStateTransition(e, t) {
|
|
1987
2188
|
this.reportHealthSignal("invalid_state_transition", {
|
|
@@ -1993,41 +2194,45 @@ class Ne {
|
|
|
1993
2194
|
this.reportHealthSignal("user_visible_error", {
|
|
1994
2195
|
reason: e,
|
|
1995
2196
|
errorFingerprint: t,
|
|
1996
|
-
...n ? { displayedMessage:
|
|
2197
|
+
...n ? { displayedMessage: fs(n) } : {}
|
|
1997
2198
|
});
|
|
1998
2199
|
}
|
|
1999
2200
|
getModel() {
|
|
2000
|
-
return this.options.model;
|
|
2201
|
+
return this.clientRuntime.project("modelSelection", { legacy: () => this.options.model });
|
|
2001
2202
|
}
|
|
2002
2203
|
setModel(e) {
|
|
2003
|
-
|
|
2204
|
+
return this.clientRuntime.route("modelSelection", { legacy: () => {
|
|
2205
|
+
this.options.model = e, this.options.productVariant === "personal" && Qe(e) && (this.personalModelSelectionOverride = e);
|
|
2206
|
+
} });
|
|
2004
2207
|
}
|
|
2005
2208
|
retryLastMessage() {
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2209
|
+
return this.clientRuntime.route("conversation", { legacy: () => {
|
|
2210
|
+
const e = this.state.sessionId, t = this.retryableClientMessageId;
|
|
2211
|
+
if (!t)
|
|
2212
|
+
return !1;
|
|
2213
|
+
if (this.failedUserMessageEvent?.clientMessageId === t) {
|
|
2214
|
+
const n = this.failedUserMessageEvent;
|
|
2215
|
+
return this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.retryAttemptsByClientMessageId[t] = 0, this.pendingClientMessageId = t, this.pendingUserMessageEvent = n, this.setState({
|
|
2216
|
+
status: "connected",
|
|
2217
|
+
pendingMessageStatus: "sending",
|
|
2218
|
+
lastError: null,
|
|
2219
|
+
lastErrorCode: null
|
|
2220
|
+
}), this.send(n), this.schedulePendingDeliveryAck(t), !0;
|
|
2221
|
+
}
|
|
2222
|
+
return e ? (this.retryAttemptsByClientMessageId[t] = 0, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.activeClientMessageId = t, this.latestRecoverableClientMessageId = t, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), this.markThinkingProgress(), this.send({ type: "chat.retry_last_user_message", sessionId: e, clientMessageId: t, automatic: !1 }), !0) : !1;
|
|
2223
|
+
} });
|
|
2019
2224
|
}
|
|
2020
2225
|
createLocalAttachment(e) {
|
|
2021
|
-
this.options.productVariant === "customer_embedded" &&
|
|
2226
|
+
this.options.productVariant === "customer_embedded" && ao(e);
|
|
2022
2227
|
const t = x(), n = {
|
|
2023
2228
|
id: t,
|
|
2024
2229
|
name: e.name || "attachment",
|
|
2025
|
-
mimeType:
|
|
2230
|
+
mimeType: mt(e),
|
|
2026
2231
|
sizeBytes: e.size
|
|
2027
2232
|
};
|
|
2028
2233
|
this.attachmentFiles.set(t, e);
|
|
2029
2234
|
const i = Date.now();
|
|
2030
|
-
return
|
|
2235
|
+
return nn({
|
|
2031
2236
|
attachmentId: t,
|
|
2032
2237
|
name: n.name,
|
|
2033
2238
|
mimeType: n.mimeType,
|
|
@@ -2056,7 +2261,7 @@ class Ne {
|
|
|
2056
2261
|
file: e,
|
|
2057
2262
|
attachment: t
|
|
2058
2263
|
}) {
|
|
2059
|
-
const n = this.state.sessionId, i =
|
|
2264
|
+
const n = this.state.sessionId, i = mt(e), r = {
|
|
2060
2265
|
sessionId: n ?? void 0,
|
|
2061
2266
|
attachmentId: t.id,
|
|
2062
2267
|
clientId: this.options.clientId,
|
|
@@ -2066,7 +2271,7 @@ class Ne {
|
|
|
2066
2271
|
sizeBytes: e.size,
|
|
2067
2272
|
page: _(),
|
|
2068
2273
|
model: this.options.model,
|
|
2069
|
-
metadata:
|
|
2274
|
+
metadata: Qt(this.options.metadata),
|
|
2070
2275
|
entrySurface: this.options.entrySurface
|
|
2071
2276
|
};
|
|
2072
2277
|
let o;
|
|
@@ -2092,8 +2297,8 @@ class Ne {
|
|
|
2092
2297
|
}, "Failed to upload attachment"), o = l;
|
|
2093
2298
|
}
|
|
2094
2299
|
this.setState({ sessionId: o.sessionId });
|
|
2095
|
-
const a =
|
|
2096
|
-
return this.updateAttachmentInState(t.id, a), t.id &&
|
|
2300
|
+
const a = Ns(o.attachment, this.options.backendUrl);
|
|
2301
|
+
return this.updateAttachmentInState(t.id, a), t.id && rn(t.id, {
|
|
2097
2302
|
sessionId: o.sessionId,
|
|
2098
2303
|
fileUrl: a.fileUrl,
|
|
2099
2304
|
sandboxPath: a.sandboxPath,
|
|
@@ -2124,7 +2329,7 @@ class Ne {
|
|
|
2124
2329
|
const n = await this.fetchEmbedAttachmentUpload(e, !1);
|
|
2125
2330
|
if (n.ok)
|
|
2126
2331
|
return await n.json();
|
|
2127
|
-
if (
|
|
2332
|
+
if (Ro(n.status) && this.options.tokenProvider && !t) {
|
|
2128
2333
|
t = !0;
|
|
2129
2334
|
const i = await this.fetchEmbedAttachmentUpload(e, !0);
|
|
2130
2335
|
if (i.ok)
|
|
@@ -2146,174 +2351,188 @@ class Ne {
|
|
|
2146
2351
|
});
|
|
2147
2352
|
}
|
|
2148
2353
|
stop() {
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
this.state.assistantDraftRespondsToUserMessageId,
|
|
2155
|
-
this.state.assistantDraftRunId,
|
|
2156
|
-
this.activeClientMessageId
|
|
2157
|
-
);
|
|
2158
|
-
this.stoppedTurns.push({
|
|
2159
|
-
sessionId: this.state.sessionId,
|
|
2160
|
-
...e,
|
|
2161
|
-
reason: "user_requested",
|
|
2162
|
-
stoppedItemId: null,
|
|
2163
|
-
stoppedAt: null,
|
|
2164
|
-
stoppedCausalSequence: null,
|
|
2165
|
-
toolCallIds: new Set(
|
|
2166
|
-
this.state.messages.filter(
|
|
2167
|
-
(t) => Me(
|
|
2168
|
-
t,
|
|
2169
|
-
e.respondsToUserMessageId,
|
|
2170
|
-
e.runId
|
|
2171
|
-
)
|
|
2172
|
-
).map((t) => t.callId).filter((t) => typeof t == "string")
|
|
2173
|
-
)
|
|
2174
|
-
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
2175
|
-
for (const [t, n] of this.activeBrowserToolCalls)
|
|
2176
|
-
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
|
|
2177
|
-
ls(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
2178
|
-
messages: rs(
|
|
2354
|
+
return this.clientRuntime.route("conversation", { legacy: () => {
|
|
2355
|
+
if (!this.state.sessionId)
|
|
2356
|
+
return;
|
|
2357
|
+
this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "user_requested" });
|
|
2358
|
+
const e = $r(
|
|
2179
2359
|
this.state.messages,
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2360
|
+
this.state.assistantDraftRespondsToUserMessageId,
|
|
2361
|
+
this.state.assistantDraftRunId,
|
|
2362
|
+
this.activeClientMessageId
|
|
2363
|
+
);
|
|
2364
|
+
this.stoppedTurns.push({
|
|
2365
|
+
sessionId: this.state.sessionId,
|
|
2366
|
+
...e,
|
|
2367
|
+
reason: "user_requested",
|
|
2368
|
+
stoppedItemId: null,
|
|
2369
|
+
stoppedAt: null,
|
|
2370
|
+
stoppedCausalSequence: null,
|
|
2371
|
+
toolCallIds: new Set(
|
|
2372
|
+
this.state.messages.filter(
|
|
2373
|
+
(t) => Me(
|
|
2374
|
+
t,
|
|
2375
|
+
e.respondsToUserMessageId,
|
|
2376
|
+
e.runId
|
|
2377
|
+
)
|
|
2378
|
+
).map((t) => t.callId).filter((t) => typeof t == "string")
|
|
2379
|
+
)
|
|
2380
|
+
}), this.stoppedTurns.splice(0, Math.max(0, this.stoppedTurns.length - 20));
|
|
2381
|
+
for (const [t, n] of this.activeBrowserToolCalls)
|
|
2382
|
+
n.event.sessionId === this.state.sessionId && this.activeBrowserToolCalls.delete(t);
|
|
2383
|
+
ds(this.options.clientId, this.activeBrowserToolCalls.values()), this.setState({
|
|
2384
|
+
messages: ls(
|
|
2385
|
+
this.state.messages,
|
|
2386
|
+
e.clientMessageId,
|
|
2387
|
+
e.runId
|
|
2388
|
+
),
|
|
2389
|
+
pendingMessageStatus: null,
|
|
2390
|
+
isThinking: !1,
|
|
2391
|
+
...this.state.taskStatus === "working" ? { taskStatus: "stopped" } : {},
|
|
2392
|
+
isRetrying: !1,
|
|
2393
|
+
lastError: null,
|
|
2394
|
+
lastErrorCode: null,
|
|
2395
|
+
lastErrorSecuritySettingsUrl: null
|
|
2396
|
+
}), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.clearThinkingWatchdog();
|
|
2397
|
+
} });
|
|
2191
2398
|
}
|
|
2192
2399
|
startNewSession(e = {}) {
|
|
2193
|
-
this.
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
type: "
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2400
|
+
return this.clientRuntime.route("directory", { legacy: () => {
|
|
2401
|
+
this.stopSessionRecoveryPolling();
|
|
2402
|
+
const t = e.notifyTransport !== !1, n = this.activeComposerWarmupId;
|
|
2403
|
+
!this.options.keepRunsActiveOnSessionNavigation && t && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "new_chat" }), this.rememberCurrentRunAsBackground(), this.rememberCurrentRunAsDetached(), this.clearPendingComposerWarmup(), this.cleanupSessionBrowserApis(), this.queuedClientEvents = this.queuedClientEvents.filter((i) => i.type !== "chat.user_message"), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.retryableClientMessageId = null, this.stagedProactiveSuggestionQuestionMessageId = null, this.lastUserMessagePageUrl = null, this.clearSessionLoadRequest(), this.sessionActivityRequestId = null, this.retryAttemptsByClientMessageId = {}, this.thinkingWatchdogResyncAttemptsByClientMessageId = {}, this.nonTranscriptToolCallIds.clear(), this.options.productVariant === "personal" && (this.personalModelSelectionOverride = null, this.options.model = void 0), t && this.send({
|
|
2404
|
+
type: "session.reset",
|
|
2405
|
+
sessionId: this.state.sessionId ?? void 0,
|
|
2406
|
+
warmupId: n ?? void 0,
|
|
2407
|
+
page: _()
|
|
2408
|
+
}), this.setState({
|
|
2409
|
+
sessionId: null,
|
|
2410
|
+
starterPrompts: [...this.state.starterPrompts],
|
|
2411
|
+
messages: [],
|
|
2412
|
+
activeScheduledFollowUps: null,
|
|
2413
|
+
isLoadingSession: !1,
|
|
2414
|
+
assistantDraft: "",
|
|
2415
|
+
assistantDraftItemId: null,
|
|
2416
|
+
assistantDraftPhase: null,
|
|
2417
|
+
assistantDraftRespondsToUserMessageId: null,
|
|
2418
|
+
assistantDraftRunId: null,
|
|
2419
|
+
pendingMessageStatus: null,
|
|
2420
|
+
isThinking: !1,
|
|
2421
|
+
taskStatus: null,
|
|
2422
|
+
isRetrying: !1,
|
|
2423
|
+
lastError: null
|
|
2424
|
+
});
|
|
2425
|
+
} });
|
|
2217
2426
|
}
|
|
2218
2427
|
listSessions(e = {}) {
|
|
2219
|
-
|
|
2220
|
-
const
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2428
|
+
return this.clientRuntime.route("directory", { legacy: () => {
|
|
2429
|
+
const t = x(), n = new Promise((r, o) => {
|
|
2430
|
+
const a = window.setTimeout(() => {
|
|
2431
|
+
this.pendingSessionHistoryRequests.delete(t), o(new Error("Session history did not respond in time"));
|
|
2432
|
+
}, Gt);
|
|
2433
|
+
this.pendingSessionHistoryRequests.set(t, { resolve: r, reject: o, timeout: a });
|
|
2434
|
+
}), i = {
|
|
2435
|
+
type: "sessions.list",
|
|
2436
|
+
requestId: t,
|
|
2437
|
+
page: _(),
|
|
2438
|
+
...e.cursor ? { cursor: e.cursor } : {},
|
|
2439
|
+
...e.limit ? { limit: e.limit } : {},
|
|
2440
|
+
...typeof e.pinned == "boolean" ? { pinned: e.pinned } : {}
|
|
2441
|
+
};
|
|
2442
|
+
if (!this.sendNow(i)) {
|
|
2443
|
+
const r = this.pendingSessionHistoryRequests.get(t);
|
|
2444
|
+
return r && (window.clearTimeout(r.timeout), this.pendingSessionHistoryRequests.delete(t)), this.setState({ status: "reconnecting" }), this.scheduleReconnect(), Promise.reject(new Error("Pluno is reconnecting. Please try again."));
|
|
2445
|
+
}
|
|
2446
|
+
return n;
|
|
2447
|
+
} });
|
|
2237
2448
|
}
|
|
2238
2449
|
getSessionHistoryState() {
|
|
2239
|
-
return this.sessionHistoryManager.getState();
|
|
2450
|
+
return this.clientRuntime.project("directory", { legacy: () => this.sessionHistoryManager.getState() });
|
|
2240
2451
|
}
|
|
2241
2452
|
subscribeSessionHistory(e) {
|
|
2242
|
-
return this.sessionHistoryManager.subscribe(e);
|
|
2453
|
+
return this.clientRuntime.project("directory", { legacy: () => this.sessionHistoryManager.subscribe(e) });
|
|
2243
2454
|
}
|
|
2244
2455
|
refreshSessionHistory() {
|
|
2245
|
-
return this.sessionHistoryManager.refresh();
|
|
2456
|
+
return this.clientRuntime.route("directory", { legacy: () => this.sessionHistoryManager.refresh() });
|
|
2246
2457
|
}
|
|
2247
2458
|
loadMoreSessionHistory() {
|
|
2248
|
-
|
|
2249
|
-
|
|
2459
|
+
return this.clientRuntime.route("directory", { legacy: () => {
|
|
2460
|
+
const e = this.sessionHistoryManager.getState().data?.nextCursor ?? null;
|
|
2461
|
+
return e ? this.sessionHistoryManager.loadMore(e) : Promise.resolve();
|
|
2462
|
+
} });
|
|
2250
2463
|
}
|
|
2251
2464
|
setSessionPinned(e, t) {
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
this.
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2465
|
+
return this.clientRuntime.route("directory", { legacy: () => {
|
|
2466
|
+
const n = this.sessionHistoryManager.getEntity(e)?.isPinned === !0, i = this.sessionHistoryManager.setPinned(e, t);
|
|
2467
|
+
return this.sendSessionMutation(
|
|
2468
|
+
this.pendingSessionPinRequests,
|
|
2469
|
+
{ type: "session.pin", requestId: x(), sessionId: e, pinned: t },
|
|
2470
|
+
"Session pin did not respond in time"
|
|
2471
|
+
).then(() => {
|
|
2472
|
+
this.sessionHistoryManager.confirmPinned(e, i), this.sessionHistoryManager.refresh();
|
|
2473
|
+
}).catch((r) => {
|
|
2474
|
+
throw this.sessionHistoryManager.rollbackPinned(e, i, n), r;
|
|
2475
|
+
});
|
|
2476
|
+
} });
|
|
2262
2477
|
}
|
|
2263
2478
|
renameSession(e, t) {
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
this.
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2479
|
+
return this.clientRuntime.route("directory", { legacy: () => {
|
|
2480
|
+
const n = this.sessionHistoryManager.getEntity(e)?.customTitle ?? null;
|
|
2481
|
+
return this.sessionHistoryManager.setTitle(e, t), this.sendSessionMutation(
|
|
2482
|
+
this.pendingSessionRenameRequests,
|
|
2483
|
+
{ type: "session.rename", requestId: x(), sessionId: e, title: t },
|
|
2484
|
+
"Session rename did not respond in time"
|
|
2485
|
+
).then(() => {
|
|
2486
|
+
this.sessionHistoryManager.confirmTitle(e), this.sessionHistoryManager.refresh();
|
|
2487
|
+
}).catch((i) => {
|
|
2488
|
+
throw this.sessionHistoryManager.setTitle(e, n), this.sessionHistoryManager.confirmTitle(e), i;
|
|
2489
|
+
});
|
|
2490
|
+
} });
|
|
2274
2491
|
}
|
|
2275
2492
|
getInteractions() {
|
|
2276
|
-
return this.runtimeInteractions.map((e) => ({ ...e }));
|
|
2493
|
+
return this.clientRuntime.project("interactions", { legacy: () => this.runtimeInteractions.map((e) => ({ ...e })) });
|
|
2277
2494
|
}
|
|
2278
2495
|
subscribeInteractions(e) {
|
|
2279
|
-
return this.interactionListeners.add(e), e(this.getInteractions()), this.refreshRuntimeInteractions(), () => this.interactionListeners.delete(e);
|
|
2496
|
+
return this.clientRuntime.project("interactions", { legacy: () => (this.interactionListeners.add(e), e(this.getInteractions()), this.refreshRuntimeInteractions(), () => this.interactionListeners.delete(e)) });
|
|
2280
2497
|
}
|
|
2281
2498
|
async actOnInteraction(e, t, n, i = {}) {
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
o.authRequestId,
|
|
2306
|
-
|
|
2307
|
-
|
|
2499
|
+
return this.clientRuntime.route("interactions", { legacy: async () => {
|
|
2500
|
+
const r = this.runtimeInteractions.find((o) => o.id === e);
|
|
2501
|
+
if (!r || r.revision !== n || r.status !== "presentable")
|
|
2502
|
+
throw new Error("This interaction is no longer available.");
|
|
2503
|
+
if (!r.allowedActions.includes(t))
|
|
2504
|
+
throw new Error("This action is not available for the interaction.");
|
|
2505
|
+
if (Qn(t) && await this.interactionManager.act(
|
|
2506
|
+
{
|
|
2507
|
+
key: r.id,
|
|
2508
|
+
category: r.category,
|
|
2509
|
+
scope: r.scope,
|
|
2510
|
+
allowedActions: r.allowedActions
|
|
2511
|
+
},
|
|
2512
|
+
t,
|
|
2513
|
+
{ snoozeUntil: i.snoozeUntil ? new Date(i.snoozeUntil) : void 0 }
|
|
2514
|
+
), r.kind === "integration_connection" && t === "connect") {
|
|
2515
|
+
const o = r.payload.request;
|
|
2516
|
+
this.integrationAuthStatusByRequestId.set(o.authRequestId, "checking"), this.integrationAuthErrorByRequestId.delete(o.authRequestId), this.rebuildRuntimeInteractions();
|
|
2517
|
+
try {
|
|
2518
|
+
await this.options.runtimeAdapters?.integrationAuthHandler?.(o);
|
|
2519
|
+
const a = await this.options.runtimeAdapters?.integrationAuthStatusLoader?.(o) ?? "completed";
|
|
2520
|
+
this.integrationAuthStatusByRequestId.set(o.authRequestId, a);
|
|
2521
|
+
} catch (a) {
|
|
2522
|
+
this.integrationAuthStatusByRequestId.set(o.authRequestId, "error"), this.integrationAuthErrorByRequestId.set(
|
|
2523
|
+
o.authRequestId,
|
|
2524
|
+
a instanceof Error ? a.message : "Connection failed"
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
this.rebuildRuntimeInteractions();
|
|
2528
|
+
return;
|
|
2308
2529
|
}
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
}
|
|
2316
|
-
r.kind === "tab_group_permission" && (t === "enable" && await this.options.runtimeAdapters?.tabGroups?.enable(), t === "later" && await this.options.runtimeAdapters?.tabGroups?.dismiss()), await this.refreshRuntimeInteractions();
|
|
2530
|
+
if (r.kind === "personal_channel_connection" && t === "connect") {
|
|
2531
|
+
const o = r.payload.request;
|
|
2532
|
+
await this.options.runtimeAdapters?.personalChannelConnectionHandler?.(o);
|
|
2533
|
+
}
|
|
2534
|
+
r.kind === "tab_group_permission" && (t === "enable" && await this.options.runtimeAdapters?.tabGroups?.enable(), t === "later" && await this.options.runtimeAdapters?.tabGroups?.dismiss()), await this.refreshRuntimeInteractions();
|
|
2535
|
+
} });
|
|
2317
2536
|
}
|
|
2318
2537
|
async refreshRuntimeInteractions() {
|
|
2319
2538
|
const e = this.options.runtimeAdapters?.tabGroups;
|
|
@@ -2335,7 +2554,7 @@ class Ne {
|
|
|
2335
2554
|
this.rebuildRuntimeInteractions();
|
|
2336
2555
|
}
|
|
2337
2556
|
rebuildRuntimeInteractions() {
|
|
2338
|
-
const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ?
|
|
2557
|
+
const e = [], t = this.options.productVariant === "personal" && (this.options.entrySurface === "main_web_chat" || this.options.entrySurface === "automation") ? un(this.state.messages) : null;
|
|
2339
2558
|
if (t) {
|
|
2340
2559
|
const r = {
|
|
2341
2560
|
key: t.id,
|
|
@@ -2442,13 +2661,13 @@ class Ne {
|
|
|
2442
2661
|
for (const r of this.interactionListeners) r(this.getInteractions());
|
|
2443
2662
|
}
|
|
2444
2663
|
getAccount() {
|
|
2445
|
-
return this.account ? { ...this.account } : null;
|
|
2664
|
+
return this.clientRuntime.project("account", { legacy: () => this.account ? { ...this.account } : null });
|
|
2446
2665
|
}
|
|
2447
2666
|
subscribeAccount(e) {
|
|
2448
|
-
return this.accountListeners.add(e), e(this.getAccount()), () => this.accountListeners.delete(e);
|
|
2667
|
+
return this.clientRuntime.project("account", { legacy: () => (this.accountListeners.add(e), e(this.getAccount()), () => this.accountListeners.delete(e)) });
|
|
2449
2668
|
}
|
|
2450
2669
|
refreshAccount() {
|
|
2451
|
-
return this.options.accountLoader ? this.accountRefresh ? this.accountRefresh : (this.accountRefresh = this.options.accountLoader().then((e) => {
|
|
2670
|
+
return this.clientRuntime.route("account", { legacy: () => this.options.accountLoader ? this.accountRefresh ? this.accountRefresh : (this.accountRefresh = this.options.accountLoader().then((e) => {
|
|
2452
2671
|
e && (this.account = {
|
|
2453
2672
|
...e,
|
|
2454
2673
|
usingPaidCreditFallback: this.usingPaidCreditFallback
|
|
@@ -2456,40 +2675,42 @@ class Ne {
|
|
|
2456
2675
|
for (const t of this.accountListeners) t(this.getAccount());
|
|
2457
2676
|
}).finally(() => {
|
|
2458
2677
|
this.accountRefresh = null;
|
|
2459
|
-
}), this.accountRefresh) : Promise.resolve();
|
|
2678
|
+
}), this.accountRefresh) : Promise.resolve() });
|
|
2460
2679
|
}
|
|
2461
2680
|
loadSession(e) {
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
type: "
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
sessionId
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2681
|
+
return this.clientRuntime.route("directory", { legacy: () => {
|
|
2682
|
+
const t = x(), n = this.activeComposerWarmupId;
|
|
2683
|
+
this.state.sessionId && this.rememberSessionTimeline(this.state.sessionId, this.state.messages);
|
|
2684
|
+
const i = this.getCachedSessionTimeline(e), r = [...i ?? []].reverse().find((a) => a.dataType === "assistant_draft" && a.steered !== !0), o = Fr(i ?? []);
|
|
2685
|
+
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.rememberCurrentRunAsDetached(), this.detachedSessionIds.delete(e), this.deferredDetachedSessionEvents.delete(e), !this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId && (this.state.isThinking || this.state.pendingMessageStatus !== null) && this.send({ type: "run.stop", sessionId: this.state.sessionId, reason: "session_switch" }), this.options.keepRunsActiveOnSessionNavigation && (this.rememberCurrentRunAsBackground(), this.backgroundSessionIds.delete(e), this.deferredSessionUpdatedSessionIds.delete(e)), this.clearPendingComposerWarmup(), n && this.send({
|
|
2686
|
+
type: "session.reset",
|
|
2687
|
+
warmupId: n,
|
|
2688
|
+
page: _()
|
|
2689
|
+
}), this.clearThinkingWatchdog(), this.clearAllFirstResponseTimers(), this.clearPendingDeliveryTimers(), this.pendingClientMessageId = null, this.pendingUserMessageEvent = null, this.failedUserMessageEvent = null, this.lastUserMessagePageUrl = null, this.options.productVariant === "personal" && this.state.sessionId !== e && (this.personalModelSelectionOverride = null, this.options.model = void 0), this.clearSessionLoadRequest(), this.sessionLoadRequestId = t, this.sessionActivityRequestId = null, this.setState({
|
|
2690
|
+
sessionId: e,
|
|
2691
|
+
// A session-keyed timeline can render immediately while the subscription handshake and authoritative
|
|
2692
|
+
// history reload preserve the live-event race guarantees for this selected chat.
|
|
2693
|
+
messages: i ?? [],
|
|
2694
|
+
activeScheduledFollowUps: null,
|
|
2695
|
+
isLoadingSession: !0,
|
|
2696
|
+
assistantDraft: r?.content ?? "",
|
|
2697
|
+
assistantDraftItemId: r?.id ?? null,
|
|
2698
|
+
assistantDraftPhase: r?.phase ?? null,
|
|
2699
|
+
assistantDraftRespondsToUserMessageId: r?.respondsToUserMessageId ?? null,
|
|
2700
|
+
assistantDraftRunId: r?.runId ?? null,
|
|
2701
|
+
pendingMessageStatus: null,
|
|
2702
|
+
isThinking: o,
|
|
2703
|
+
taskStatus: o ? "working" : null,
|
|
2704
|
+
isRetrying: !1,
|
|
2705
|
+
lastError: null,
|
|
2706
|
+
lastErrorCode: null
|
|
2707
|
+
}), this.canLoadSessionHistoryOverHttp() ? (this.state.status === "reconnecting" && this.startSessionRecoveryPolling(), this.loadSessionHistoryOverHttp(e, t)) : this.send({
|
|
2708
|
+
type: "session.load",
|
|
2709
|
+
requestId: t,
|
|
2710
|
+
sessionId: e,
|
|
2711
|
+
page: _()
|
|
2712
|
+
});
|
|
2713
|
+
} });
|
|
2493
2714
|
}
|
|
2494
2715
|
canLoadSessionHistoryOverHttp() {
|
|
2495
2716
|
return !this.options.token && !this.options.tokenProvider ? !1 : this.options.productVariant === "customer_embedded" || !!this.options.runtimeCommunityId;
|
|
@@ -2595,7 +2816,7 @@ class Ne {
|
|
|
2595
2816
|
});
|
|
2596
2817
|
if (!c.ok) {
|
|
2597
2818
|
const d = await c.text() || `History request failed (${c.status})`;
|
|
2598
|
-
throw
|
|
2819
|
+
throw Xn(c.status) ? new Error(d) : new Te(d);
|
|
2599
2820
|
}
|
|
2600
2821
|
const u = await c.json();
|
|
2601
2822
|
if (!u?.session || !Array.isArray(u.items))
|
|
@@ -2632,7 +2853,7 @@ class Ne {
|
|
|
2632
2853
|
send(e) {
|
|
2633
2854
|
this.sendNow(L(e)) || (e.type === "chat.user_message" && typeof e.clientMessageId == "string" && this.queuedClientEvents.some(
|
|
2634
2855
|
(i) => i.type === "chat.user_message" && i.clientMessageId === e.clientMessageId
|
|
2635
|
-
) || this.queuedClientEvents.push(e),
|
|
2856
|
+
) || this.queuedClientEvents.push(e), Q(this.options.clientId, this.queuedClientEvents), this.setState({
|
|
2636
2857
|
status: "reconnecting",
|
|
2637
2858
|
...e.type === "chat.user_message" && e.clientMessageId === this.pendingClientMessageId ? { pendingMessageStatus: "reconnecting" } : {}
|
|
2638
2859
|
}), this.scheduleReconnect());
|
|
@@ -2650,7 +2871,7 @@ class Ne {
|
|
|
2650
2871
|
return !1;
|
|
2651
2872
|
const t = this.socket;
|
|
2652
2873
|
try {
|
|
2653
|
-
return t.send(JSON.stringify(e)), Se("client_event", e.type,
|
|
2874
|
+
return t.send(JSON.stringify(e)), Se("client_event", e.type, $t(e)), !0;
|
|
2654
2875
|
} catch (n) {
|
|
2655
2876
|
return b("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
|
|
2656
2877
|
message: n instanceof Error ? n.message : String(n),
|
|
@@ -2700,7 +2921,7 @@ class Ne {
|
|
|
2700
2921
|
clientMessageId: e,
|
|
2701
2922
|
durationMs: Date.now() - n
|
|
2702
2923
|
});
|
|
2703
|
-
}, Math.max(0,
|
|
2924
|
+
}, Math.max(0, ci - (Date.now() - n)));
|
|
2704
2925
|
this.firstResponseTimersByClientMessageId.set(e, { submittedAt: n, timer: i });
|
|
2705
2926
|
}
|
|
2706
2927
|
clearFirstResponseTimer(e) {
|
|
@@ -2810,7 +3031,7 @@ class Ne {
|
|
|
2810
3031
|
if (this.state.starterPromptsLoading || this.transientStarterPromptsRequestInFlight || this.transientStarterPromptsRequestAttempted)
|
|
2811
3032
|
return;
|
|
2812
3033
|
this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
|
|
2813
|
-
const e =
|
|
3034
|
+
const e = Zi();
|
|
2814
3035
|
this.sendNow(
|
|
2815
3036
|
L({
|
|
2816
3037
|
type: "starter_prompts.page_context",
|
|
@@ -2821,13 +3042,13 @@ class Ne {
|
|
|
2821
3042
|
) || (this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !1, this.setState({ starterPromptsLoading: !1 }));
|
|
2822
3043
|
}
|
|
2823
3044
|
startStarterPromptUrlWatcher() {
|
|
2824
|
-
this.locationChangeCleanup || (this.locationChangeCleanup =
|
|
3045
|
+
this.locationChangeCleanup || (this.locationChangeCleanup = er(() => this.handleStarterPromptUrlChange()));
|
|
2825
3046
|
}
|
|
2826
3047
|
handleStarterPromptUrlChange() {
|
|
2827
3048
|
const e = location.href;
|
|
2828
3049
|
e !== this.lastStarterPromptPageUrl && (this.activeComposerWarmupScope && !this.activeComposerWarmupScope.endsWith(`:${e}`) && this.clearPendingComposerWarmup(), this.lastStarterPromptPageUrl = e, this.clearStarterPromptUrlRefreshTimer(), this.starterPromptUrlRefreshTimer = window.setTimeout(() => {
|
|
2829
3050
|
this.starterPromptUrlRefreshTimer = null, this.refreshStarterPromptsForCurrentUrl();
|
|
2830
|
-
},
|
|
3051
|
+
}, Mi));
|
|
2831
3052
|
}
|
|
2832
3053
|
refreshStarterPromptsForCurrentUrl() {
|
|
2833
3054
|
this.socket?.readyState !== WebSocket.OPEN || this.state.status === "closed" || (this.setState({ starterPromptsLoading: this.state.messages.length === 0 }), this.sendNow({
|
|
@@ -2842,22 +3063,22 @@ class Ne {
|
|
|
2842
3063
|
if (this.socket?.readyState !== WebSocket.OPEN || this.queuedClientEvents.length === 0)
|
|
2843
3064
|
return;
|
|
2844
3065
|
const e = this.queuedClientEvents.splice(0, this.queuedClientEvents.length);
|
|
2845
|
-
|
|
3066
|
+
Q(this.options.clientId, this.queuedClientEvents);
|
|
2846
3067
|
for (let t = 0; t < e.length; t += 1) {
|
|
2847
3068
|
const n = e[t];
|
|
2848
3069
|
if (!this.sendNow(L(n))) {
|
|
2849
|
-
this.queuedClientEvents.unshift(n, ...e.slice(t + 1)),
|
|
3070
|
+
this.queuedClientEvents.unshift(n, ...e.slice(t + 1)), Q(this.options.clientId, this.queuedClientEvents);
|
|
2850
3071
|
return;
|
|
2851
3072
|
}
|
|
2852
|
-
|
|
3073
|
+
Q(this.options.clientId, this.queuedClientEvents);
|
|
2853
3074
|
}
|
|
2854
3075
|
}
|
|
2855
3076
|
resetForAuthenticationScopeChange() {
|
|
2856
|
-
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [],
|
|
3077
|
+
this.startNewSession({ notifyTransport: !1 }), this.queuedClientEvents = [], Q(this.options.clientId, this.queuedClientEvents), this.pendingWidgetLifecycleEvents = [], this.backgroundSessionIds.clear(), this.backgroundClientMessageIds.clear(), this.deferredSessionUpdatedSessionIds.clear(), this.detachedSessionIds.clear(), this.detachedClientMessageIds.clear(), this.deferredDetachedSessionEvents.clear(), this.sessionTimelineCache.clear();
|
|
2857
3078
|
}
|
|
2858
3079
|
rememberSessionTimeline(e, t) {
|
|
2859
3080
|
const n = [...t];
|
|
2860
|
-
for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size >
|
|
3081
|
+
for (this.sessionTimelineCache.delete(e), this.sessionTimelineCache.set(e, n); this.sessionTimelineCache.size > Ai; ) {
|
|
2861
3082
|
const i = this.sessionTimelineCache.keys().next().value;
|
|
2862
3083
|
if (!i)
|
|
2863
3084
|
break;
|
|
@@ -2887,8 +3108,8 @@ class Ne {
|
|
|
2887
3108
|
return;
|
|
2888
3109
|
this.clearPendingWarmupAckTimer();
|
|
2889
3110
|
const t = Math.min(
|
|
2890
|
-
|
|
2891
|
-
|
|
3111
|
+
ri * 2 ** e.retryAttempt,
|
|
3112
|
+
oi
|
|
2892
3113
|
);
|
|
2893
3114
|
e.retryAttempt += 1, this.pendingWarmupAckTimer = window.setTimeout(() => {
|
|
2894
3115
|
this.pendingWarmupAckTimer = null, this.flushPendingComposerWarmup();
|
|
@@ -2911,7 +3132,7 @@ class Ne {
|
|
|
2911
3132
|
const n = C(t);
|
|
2912
3133
|
if (!e || !n || !_e(n) || this.findStoppedTurn(e, n))
|
|
2913
3134
|
return;
|
|
2914
|
-
const i = O(n), r =
|
|
3135
|
+
const i = O(n), r = k(n), o = typeof n.clientMessageId == "string" ? n.clientMessageId : i ? this.clientMessageIdsByUserMessageItemId.get(i) ?? null : null;
|
|
2915
3136
|
this.stoppedTurns.push({
|
|
2916
3137
|
sessionId: e,
|
|
2917
3138
|
clientMessageId: o,
|
|
@@ -2932,7 +3153,7 @@ class Ne {
|
|
|
2932
3153
|
if (!e || !t)
|
|
2933
3154
|
return;
|
|
2934
3155
|
const n = this.findStoppedTurn(e, t);
|
|
2935
|
-
!n || n.reason !== "task_tab_closed" ||
|
|
3156
|
+
!n || n.reason !== "task_tab_closed" || Pn(n, t) && (this.stoppedTurns.splice(this.stoppedTurns.indexOf(n), 1), n.stoppedItemId && this.setState({
|
|
2936
3157
|
messages: this.state.messages.filter((i) => i.id !== n.stoppedItemId)
|
|
2937
3158
|
}));
|
|
2938
3159
|
}
|
|
@@ -2960,7 +3181,7 @@ class Ne {
|
|
|
2960
3181
|
});
|
|
2961
3182
|
}
|
|
2962
3183
|
handleServerEvent(e) {
|
|
2963
|
-
if (Se("server_event", e.type,
|
|
3184
|
+
if (Se("server_event", e.type, $t(e)), e.type === "session.subscribed") {
|
|
2964
3185
|
const t = typeof e.requestId == "string" ? e.requestId : null, n = typeof e.sessionId == "string" ? e.sessionId : null;
|
|
2965
3186
|
if (t && n && t === this.pendingSessionSubscription?.requestId && n === this.pendingSessionSubscription.sessionId) {
|
|
2966
3187
|
const i = this.pendingSessionSubscription;
|
|
@@ -3011,7 +3232,7 @@ class Ne {
|
|
|
3011
3232
|
}
|
|
3012
3233
|
}
|
|
3013
3234
|
if (!this.shouldIgnoreStoppedTurnEvent(e) && (this.updateInactiveSessionTimelineCache(e), !this.shouldIgnoreBackgroundSessionEvent(e))) {
|
|
3014
|
-
if (
|
|
3235
|
+
if (Ui(e) && this.clearFirstResponseTimer(this.activeClientMessageId), e.type === "run.steered") {
|
|
3015
3236
|
this.handleRunSteered(e);
|
|
3016
3237
|
return;
|
|
3017
3238
|
}
|
|
@@ -3026,17 +3247,17 @@ class Ne {
|
|
|
3026
3247
|
this.activeResponseRunId = t, this.setState({ turnPhase: "thinking", lastError: null }), this.markThinkingProgress();
|
|
3027
3248
|
return;
|
|
3028
3249
|
}
|
|
3029
|
-
if (
|
|
3250
|
+
if (vi(e) && this.markThinkingProgress(), e.type === "auth.ok") {
|
|
3030
3251
|
this.clearSocketAuthTimer(), this.reconnectAttempts = 0, this.transportDiagnosticEpisodes.clear();
|
|
3031
|
-
const t =
|
|
3252
|
+
const t = fr(e.user);
|
|
3032
3253
|
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();
|
|
3033
|
-
const n =
|
|
3254
|
+
const n = ur(e), i = Object.prototype.hasOwnProperty.call(e, "appearance");
|
|
3034
3255
|
b("web-sdk.agent", "Received auth.ok appearance", {
|
|
3035
3256
|
hasAppearance: i,
|
|
3036
3257
|
rawAppearance: e.appearance,
|
|
3037
3258
|
normalizedAppearance: n
|
|
3038
|
-
}), this.runtimeHelperJavascript =
|
|
3039
|
-
const r =
|
|
3259
|
+
}), this.runtimeHelperJavascript = dr(e.runtimeHelpers)?.javascript ?? null;
|
|
3260
|
+
const r = Yt(e, "starterPrompts"), o = Object.prototype.hasOwnProperty.call(e, "starterPrompts"), a = e.starterPromptsLoading === !0, l = {
|
|
3040
3261
|
user: t,
|
|
3041
3262
|
status: "connected",
|
|
3042
3263
|
...this.state.lastErrorCode === "connection_failed" ? { lastError: null, lastErrorCode: null } : {}
|
|
@@ -3055,21 +3276,21 @@ class Ne {
|
|
|
3055
3276
|
}
|
|
3056
3277
|
if (e.type === "starterPrompts.updated") {
|
|
3057
3278
|
this.transientStarterPromptsRequestInFlight = !1, this.transientStarterPromptsRequestAttempted = !0, this.setState({
|
|
3058
|
-
starterPrompts:
|
|
3279
|
+
starterPrompts: Yt(e, "starterPrompts"),
|
|
3059
3280
|
starterPromptsLoading: !1
|
|
3060
3281
|
});
|
|
3061
3282
|
return;
|
|
3062
3283
|
}
|
|
3063
3284
|
if (e.type === "scheduled_follow_ups.updated") {
|
|
3064
3285
|
typeof e.sessionId == "string" && e.sessionId === this.state.sessionId && this.setState({
|
|
3065
|
-
activeScheduledFollowUps:
|
|
3286
|
+
activeScheduledFollowUps: Zt(
|
|
3066
3287
|
e.activeScheduledFollowUps
|
|
3067
3288
|
)
|
|
3068
3289
|
});
|
|
3069
3290
|
return;
|
|
3070
3291
|
}
|
|
3071
3292
|
if (e.type === "conversation.state") {
|
|
3072
|
-
const t = Array.isArray(e.items) ? e.items : [], n =
|
|
3293
|
+
const t = Array.isArray(e.items) ? e.items : [], n = Lt(t), i = Object.prototype.hasOwnProperty.call(
|
|
3073
3294
|
e,
|
|
3074
3295
|
"activeScheduledFollowUps"
|
|
3075
3296
|
), 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();
|
|
@@ -3086,7 +3307,7 @@ class Ne {
|
|
|
3086
3307
|
runId: u?.runId
|
|
3087
3308
|
}), 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;
|
|
3088
3309
|
f && h && (this.pendingClientMessageId = h);
|
|
3089
|
-
let m =
|
|
3310
|
+
let m = Mr(
|
|
3090
3311
|
e.assistantDraft
|
|
3091
3312
|
);
|
|
3092
3313
|
m && this.findStoppedTurn(r, {
|
|
@@ -3095,31 +3316,31 @@ class Ne {
|
|
|
3095
3316
|
}) && (m = void 0);
|
|
3096
3317
|
const M = m !== void 0;
|
|
3097
3318
|
this.rememberUserMessageClientMessageIds(g);
|
|
3098
|
-
const w =
|
|
3319
|
+
const w = xr(g), D = g.filter((U) => {
|
|
3099
3320
|
const q = C(U);
|
|
3100
|
-
return
|
|
3101
|
-
}), S =
|
|
3321
|
+
return qr(q) ? !1 : !q || !w || !pe(q) ? !0 : ht(g, q) !== w;
|
|
3322
|
+
}), S = ct(
|
|
3102
3323
|
this.state.messages,
|
|
3103
3324
|
st(D, this.options.backendUrl)
|
|
3104
|
-
), T =
|
|
3105
|
-
(U, q) =>
|
|
3325
|
+
), T = rs(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(
|
|
3326
|
+
(U, q) => os(
|
|
3106
3327
|
C(U),
|
|
3107
3328
|
N,
|
|
3108
3329
|
v,
|
|
3109
3330
|
re,
|
|
3110
3331
|
Y,
|
|
3111
|
-
|
|
3332
|
+
Lr(g, q)
|
|
3112
3333
|
)
|
|
3113
|
-
), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z),
|
|
3114
|
-
if (!T &&
|
|
3334
|
+
), ee = M ? m?.content ?? "" : this.state.assistantDraft, fe = !!m?.content && !Z, B = T && (!ee || Z), V = Ur(S), oe = B && V ? "completed" : d ? "stopped" : B ? "failed" : null;
|
|
3335
|
+
if (!T && Or(this.state.messages, g))
|
|
3115
3336
|
return;
|
|
3116
|
-
this.lastUserMessagePageUrl =
|
|
3117
|
-
const j = B || d ? null :
|
|
3118
|
-
if (this.latestRecoverableClientMessageId = j,
|
|
3337
|
+
this.lastUserMessagePageUrl = Dr(g);
|
|
3338
|
+
const j = B || d ? null : dt(g);
|
|
3339
|
+
if (this.latestRecoverableClientMessageId = j, V && this.clearRetryTimers(), this.setState({
|
|
3119
3340
|
sessionId: A(e.session, "id") ?? this.state.sessionId,
|
|
3120
3341
|
messages: S,
|
|
3121
3342
|
...i ? {
|
|
3122
|
-
activeScheduledFollowUps:
|
|
3343
|
+
activeScheduledFollowUps: Zt(
|
|
3123
3344
|
e.activeScheduledFollowUps
|
|
3124
3345
|
)
|
|
3125
3346
|
} : {},
|
|
@@ -3186,14 +3407,14 @@ class Ne {
|
|
|
3186
3407
|
this.options.backendUrl
|
|
3187
3408
|
);
|
|
3188
3409
|
t === this.sessionActivityRequestId && (this.sessionActivityRequestId = null), this.setState({
|
|
3189
|
-
messages:
|
|
3410
|
+
messages: Er(this.state.messages, i)
|
|
3190
3411
|
});
|
|
3191
3412
|
return;
|
|
3192
3413
|
}
|
|
3193
3414
|
if (e.type === "sessions.page") {
|
|
3194
3415
|
const t = typeof e.requestId == "string" ? e.requestId : null, n = t ? this.pendingSessionHistoryRequests.get(t) : null;
|
|
3195
3416
|
t && n && (window.clearTimeout(n.timeout), this.pendingSessionHistoryRequests.delete(t), n.resolve({
|
|
3196
|
-
sessions:
|
|
3417
|
+
sessions: mr(e.sessions),
|
|
3197
3418
|
nextCursor: typeof e.nextCursor == "string" ? e.nextCursor : null
|
|
3198
3419
|
}));
|
|
3199
3420
|
return;
|
|
@@ -3228,15 +3449,15 @@ class Ne {
|
|
|
3228
3449
|
}
|
|
3229
3450
|
const n = Ue(e.item, this.options.backendUrl);
|
|
3230
3451
|
if (n) {
|
|
3231
|
-
const i =
|
|
3232
|
-
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()),
|
|
3233
|
-
const o = de(this.state.messages, n), a =
|
|
3452
|
+
const i = jr(t, n), r = n.callId ? this.pendingToolLoadingByCallId.get(n.callId) : void 0;
|
|
3453
|
+
n.callId && r !== void 0 && (n.loading = r, this.pendingToolLoadingByCallId.delete(n.callId)), W(n) && (this.retryableClientMessageId = null, this.clearRetryTimers(), this.clearRunAckResyncRetryTimer()), Hr(t) && this.clearRunAckResyncRetryTimer();
|
|
3454
|
+
const o = de(this.state.messages, n), a = rs(o), l = os(
|
|
3234
3455
|
t,
|
|
3235
3456
|
this.state.assistantDraft,
|
|
3236
3457
|
this.state.assistantDraftItemId,
|
|
3237
3458
|
this.state.assistantDraftRespondsToUserMessageId,
|
|
3238
3459
|
this.state.assistantDraftRunId,
|
|
3239
|
-
|
|
3460
|
+
qs(
|
|
3240
3461
|
o,
|
|
3241
3462
|
o.findIndex((d) => d.id === n.id)
|
|
3242
3463
|
)
|
|
@@ -3298,7 +3519,7 @@ class Ne {
|
|
|
3298
3519
|
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;
|
|
3299
3520
|
if (!(n && this.state.assistantDraftRespondsToUserMessageId ? n === this.state.assistantDraftRespondsToUserMessageId : !i || !this.state.assistantDraftRunId || i === this.state.assistantDraftRunId))
|
|
3300
3521
|
return;
|
|
3301
|
-
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 =
|
|
3522
|
+
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 = xt(
|
|
3302
3523
|
this.state.messages.filter(
|
|
3303
3524
|
(c) => c.dataType !== "assistant_draft" || !Me(
|
|
3304
3525
|
c,
|
|
@@ -3308,11 +3529,11 @@ class Ne {
|
|
|
3308
3529
|
),
|
|
3309
3530
|
n,
|
|
3310
3531
|
i,
|
|
3311
|
-
|
|
3532
|
+
ut
|
|
3312
3533
|
);
|
|
3313
3534
|
this.setState({
|
|
3314
3535
|
sessionId: t,
|
|
3315
|
-
messages:
|
|
3536
|
+
messages: ts(
|
|
3316
3537
|
l,
|
|
3317
3538
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
3318
3539
|
n,
|
|
@@ -3335,9 +3556,9 @@ class Ne {
|
|
|
3335
3556
|
if (t)
|
|
3336
3557
|
this.nonTranscriptToolCallIds.add(t);
|
|
3337
3558
|
else {
|
|
3338
|
-
const n =
|
|
3559
|
+
const n = is(e);
|
|
3339
3560
|
if (n) {
|
|
3340
|
-
const i =
|
|
3561
|
+
const i = ss(
|
|
3341
3562
|
this.state.messages,
|
|
3342
3563
|
n
|
|
3343
3564
|
);
|
|
@@ -3405,13 +3626,13 @@ class Ne {
|
|
|
3405
3626
|
return;
|
|
3406
3627
|
}
|
|
3407
3628
|
o && i && r && (this.retryableClientMessageId = r);
|
|
3408
|
-
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l =
|
|
3629
|
+
const a = new Error(typeof e.message == "string" ? e.message : "Pluno error"), l = Xi(a.message);
|
|
3409
3630
|
l && console.error(l);
|
|
3410
|
-
const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d =
|
|
3631
|
+
const c = r ?? this.activeClientMessageId, u = typeof e.runId == "string" ? e.runId : null, d = ls(
|
|
3411
3632
|
this.state.messages,
|
|
3412
3633
|
c,
|
|
3413
3634
|
u
|
|
3414
|
-
), g =
|
|
3635
|
+
), g = vr(
|
|
3415
3636
|
d,
|
|
3416
3637
|
c,
|
|
3417
3638
|
u
|
|
@@ -3442,7 +3663,7 @@ class Ne {
|
|
|
3442
3663
|
}
|
|
3443
3664
|
applyAccountSubmissionError(e) {
|
|
3444
3665
|
if (!this.account || !e) return;
|
|
3445
|
-
const t =
|
|
3666
|
+
const t = Un(this.account.submissionGate, e);
|
|
3446
3667
|
if (!(t === this.account.submissionGate || t.allowed)) {
|
|
3447
3668
|
this.account = {
|
|
3448
3669
|
...this.account,
|
|
@@ -3455,10 +3676,10 @@ class Ne {
|
|
|
3455
3676
|
if (this.options.productVariant !== "personal" || !e || typeof e != "object" || this.personalModelSelectionOverride !== null)
|
|
3456
3677
|
return;
|
|
3457
3678
|
const t = e.metadata, n = t && typeof t == "object" ? t.model : void 0;
|
|
3458
|
-
this.options.model =
|
|
3679
|
+
this.options.model = Qe(n) ? n : "gpt-5.6-sol";
|
|
3459
3680
|
}
|
|
3460
3681
|
updateAccountFallbackFromSession(e) {
|
|
3461
|
-
const t = e && typeof e == "object" ? e.metadata : null, n =
|
|
3682
|
+
const t = e && typeof e == "object" ? e.metadata : null, n = Dn(t);
|
|
3462
3683
|
if (this.usingPaidCreditFallback !== n && (this.usingPaidCreditFallback = n, !!this.account)) {
|
|
3463
3684
|
this.account = { ...this.account, usingPaidCreditFallback: n };
|
|
3464
3685
|
for (const i of this.accountListeners) i(this.getAccount());
|
|
@@ -3478,7 +3699,7 @@ class Ne {
|
|
|
3478
3699
|
return;
|
|
3479
3700
|
const n = this.sessionTimelineCache.get(t);
|
|
3480
3701
|
if (e.type === "conversation.state") {
|
|
3481
|
-
const i =
|
|
3702
|
+
const i = Lt(
|
|
3482
3703
|
Array.isArray(e.items) ? e.items : []
|
|
3483
3704
|
), r = st(
|
|
3484
3705
|
this.filterStoppedSnapshotItems(i, t),
|
|
@@ -3486,7 +3707,7 @@ class Ne {
|
|
|
3486
3707
|
);
|
|
3487
3708
|
(n || r.length > 0) && this.rememberSessionTimeline(
|
|
3488
3709
|
t,
|
|
3489
|
-
n ?
|
|
3710
|
+
n ? ct(n, r) : r
|
|
3490
3711
|
);
|
|
3491
3712
|
return;
|
|
3492
3713
|
}
|
|
@@ -3500,10 +3721,10 @@ class Ne {
|
|
|
3500
3721
|
return;
|
|
3501
3722
|
}
|
|
3502
3723
|
if (e.type === "tool.call") {
|
|
3503
|
-
const i = e.hiddenFromTranscript === !0 ? null :
|
|
3724
|
+
const i = e.hiddenFromTranscript === !0 ? null : is(e);
|
|
3504
3725
|
i && this.rememberSessionTimeline(
|
|
3505
3726
|
t,
|
|
3506
|
-
|
|
3727
|
+
ss(n, i)
|
|
3507
3728
|
);
|
|
3508
3729
|
return;
|
|
3509
3730
|
}
|
|
@@ -3515,7 +3736,7 @@ class Ne {
|
|
|
3515
3736
|
return;
|
|
3516
3737
|
this.rememberSessionTimeline(
|
|
3517
3738
|
t,
|
|
3518
|
-
|
|
3739
|
+
ns(
|
|
3519
3740
|
n,
|
|
3520
3741
|
e.callId,
|
|
3521
3742
|
i
|
|
@@ -3542,17 +3763,17 @@ class Ne {
|
|
|
3542
3763
|
return;
|
|
3543
3764
|
}
|
|
3544
3765
|
if (e.type === "chat.assistant_done") {
|
|
3545
|
-
const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o =
|
|
3766
|
+
const i = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : null, r = typeof e.runId == "string" ? e.runId : null, o = xt(
|
|
3546
3767
|
n.filter(
|
|
3547
3768
|
(a) => a.dataType !== "assistant_draft" || !Me(a, i, r)
|
|
3548
3769
|
),
|
|
3549
3770
|
i,
|
|
3550
3771
|
r,
|
|
3551
|
-
|
|
3772
|
+
ut
|
|
3552
3773
|
);
|
|
3553
3774
|
this.rememberSessionTimeline(
|
|
3554
3775
|
t,
|
|
3555
|
-
|
|
3776
|
+
ts(
|
|
3556
3777
|
o,
|
|
3557
3778
|
typeof e.responseId == "string" ? e.responseId : null,
|
|
3558
3779
|
i,
|
|
@@ -3567,7 +3788,7 @@ class Ne {
|
|
|
3567
3788
|
return;
|
|
3568
3789
|
this.rememberSessionTimeline(
|
|
3569
3790
|
t,
|
|
3570
|
-
|
|
3791
|
+
cs(
|
|
3571
3792
|
n,
|
|
3572
3793
|
i,
|
|
3573
3794
|
null,
|
|
@@ -3576,9 +3797,9 @@ class Ne {
|
|
|
3576
3797
|
);
|
|
3577
3798
|
return;
|
|
3578
3799
|
}
|
|
3579
|
-
e.type === "error" && typeof e.requestId != "string" && !
|
|
3800
|
+
e.type === "error" && typeof e.requestId != "string" && !as(e, t) && this.rememberSessionTimeline(
|
|
3580
3801
|
t,
|
|
3581
|
-
|
|
3802
|
+
Wr(n, e)
|
|
3582
3803
|
);
|
|
3583
3804
|
}
|
|
3584
3805
|
}
|
|
@@ -3612,7 +3833,7 @@ class Ne {
|
|
|
3612
3833
|
}
|
|
3613
3834
|
handleRetryableRecoveryError(e) {
|
|
3614
3835
|
const t = typeof e.sessionId == "string" ? e.sessionId : this.state.sessionId, n = typeof e.clientMessageId == "string" ? e.clientMessageId : null;
|
|
3615
|
-
if (!
|
|
3836
|
+
if (!as(e, t) || !n)
|
|
3616
3837
|
return !1;
|
|
3617
3838
|
if (et())
|
|
3618
3839
|
return this.retryableClientMessageId = n, this.activeClientMessageId = n, this.latestRecoverableClientMessageId = n, this.setState({ status: "connected", isThinking: !0, isRetrying: !0, lastError: null, lastErrorCode: null }), !0;
|
|
@@ -3653,7 +3874,7 @@ class Ne {
|
|
|
3653
3874
|
const i = new Promise((r, o) => {
|
|
3654
3875
|
const a = window.setTimeout(() => {
|
|
3655
3876
|
e.delete(t.requestId), o(new Error(n));
|
|
3656
|
-
},
|
|
3877
|
+
}, Gt);
|
|
3657
3878
|
e.set(t.requestId, { resolve: r, reject: o, timeout: a });
|
|
3658
3879
|
});
|
|
3659
3880
|
if (!this.sendNow(t)) {
|
|
@@ -3676,7 +3897,7 @@ class Ne {
|
|
|
3676
3897
|
e.clear();
|
|
3677
3898
|
}
|
|
3678
3899
|
markThinkingProgress() {
|
|
3679
|
-
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(
|
|
3900
|
+
!this.state.isThinking || this.state.status === "closed" || (this.scheduleThinkingWatchdog(li), this.activeClientMessageId && this.scheduleRunAckWatchdog(this.activeClientMessageId));
|
|
3680
3901
|
}
|
|
3681
3902
|
scheduleThinkingWatchdog(e) {
|
|
3682
3903
|
this.thinkingWatchdogTimer !== null && window.clearTimeout(this.thinkingWatchdogTimer), this.thinkingWatchdogTimer = window.setTimeout(() => {
|
|
@@ -3734,19 +3955,19 @@ class Ne {
|
|
|
3734
3955
|
schedulePendingDeliveryAck(e) {
|
|
3735
3956
|
this.clearPendingDeliveryTimers(), !et() && (this.pendingDeliveryAckTimer = window.setTimeout(() => {
|
|
3736
3957
|
this.pendingDeliveryAckTimer = null, this.retryPendingDelivery(e);
|
|
3737
|
-
},
|
|
3958
|
+
}, Kt));
|
|
3738
3959
|
}
|
|
3739
3960
|
retryPendingDelivery(e) {
|
|
3740
3961
|
if (this.state.status === "closed" || this.pendingClientMessageId !== e || !this.pendingUserMessageEvent)
|
|
3741
3962
|
return;
|
|
3742
3963
|
const t = this.retryAttemptsByClientMessageId[e] ?? 0;
|
|
3743
|
-
if (t >=
|
|
3964
|
+
if (t >= ui) {
|
|
3744
3965
|
this.failPendingDelivery(e);
|
|
3745
3966
|
return;
|
|
3746
3967
|
}
|
|
3747
3968
|
t === 0 && this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.retryAttemptsByClientMessageId[e] = t + 1, this.setState({ pendingMessageStatus: "reconnecting" }), this.pendingDeliveryRetryTimer = window.setTimeout(() => {
|
|
3748
3969
|
this.pendingDeliveryRetryTimer = null, !(this.pendingClientMessageId !== e || !this.pendingUserMessageEvent) && (this.send(this.pendingUserMessageEvent), this.setState({ pendingMessageStatus: "sending" }), this.schedulePendingDeliveryAck(e));
|
|
3749
|
-
},
|
|
3970
|
+
}, bi(t, gi));
|
|
3750
3971
|
}
|
|
3751
3972
|
failPendingDelivery(e) {
|
|
3752
3973
|
if (this.pendingClientMessageId !== e)
|
|
@@ -3759,7 +3980,7 @@ class Ne {
|
|
|
3759
3980
|
...this.state.isThinking ? {} : { turnPhase: null },
|
|
3760
3981
|
isRetrying: !1,
|
|
3761
3982
|
...this.state.isThinking ? {} : { taskStatus: "failed" },
|
|
3762
|
-
lastError:
|
|
3983
|
+
lastError: hi,
|
|
3763
3984
|
lastErrorCode: "message_delivery_failed"
|
|
3764
3985
|
});
|
|
3765
3986
|
}
|
|
@@ -3771,7 +3992,7 @@ class Ne {
|
|
|
3771
3992
|
if (this.state.isThinking && t) {
|
|
3772
3993
|
const r = this.state.assistantDraftRespondsToUserMessageId !== null && this.state.assistantDraftRespondsToUserMessageId !== t;
|
|
3773
3994
|
this.setState({
|
|
3774
|
-
messages:
|
|
3995
|
+
messages: cs(
|
|
3775
3996
|
this.state.messages,
|
|
3776
3997
|
t,
|
|
3777
3998
|
n,
|
|
@@ -3797,13 +4018,13 @@ class Ne {
|
|
|
3797
4018
|
scheduleRunAckWatchdog(e) {
|
|
3798
4019
|
this.runAckWatchdogTimer !== null && window.clearTimeout(this.runAckWatchdogTimer), this.runAckWatchdogTimer = window.setTimeout(() => {
|
|
3799
4020
|
this.runAckWatchdogTimer = null, this.recoverMissedRunAck(e);
|
|
3800
|
-
},
|
|
4021
|
+
}, Kt);
|
|
3801
4022
|
}
|
|
3802
4023
|
recoverMissedRunAck(e) {
|
|
3803
4024
|
!this.state.isThinking || this.state.status === "closed" || this.activeClientMessageId !== e || (b("web-sdk.agent", "Pluno run ack missed; resyncing session", {
|
|
3804
4025
|
sessionId: this.state.sessionId,
|
|
3805
4026
|
clientMessageId: e
|
|
3806
|
-
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
4027
|
+
}), this.reportHealthSignal("run_ack_missed", { clientMessageId: e }), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(zt));
|
|
3807
4028
|
}
|
|
3808
4029
|
clearRunAckResyncRetryTimer() {
|
|
3809
4030
|
this.runAckResyncRetryTimer !== null && (window.clearTimeout(this.runAckResyncRetryTimer), this.runAckResyncRetryTimer = null);
|
|
@@ -3826,7 +4047,7 @@ class Ne {
|
|
|
3826
4047
|
),
|
|
3827
4048
|
isThinking: !1,
|
|
3828
4049
|
taskStatus: "failed",
|
|
3829
|
-
lastError:
|
|
4050
|
+
lastError: di,
|
|
3830
4051
|
lastErrorCode: "run_recovery_exhausted"
|
|
3831
4052
|
}), this.clearThinkingWatchdog();
|
|
3832
4053
|
return;
|
|
@@ -3836,7 +4057,7 @@ class Ne {
|
|
|
3836
4057
|
sessionId: this.state.sessionId,
|
|
3837
4058
|
clientMessageId: e,
|
|
3838
4059
|
resyncAttempts: t + 1
|
|
3839
|
-
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(
|
|
4060
|
+
}), this.resyncThinkingSession(), this.scheduleThinkingWatchdog(zt);
|
|
3840
4061
|
}
|
|
3841
4062
|
resyncThinkingSession() {
|
|
3842
4063
|
this.state.sessionId ? this.send({
|
|
@@ -3853,7 +4074,7 @@ class Ne {
|
|
|
3853
4074
|
if (!t || !n || !i)
|
|
3854
4075
|
return;
|
|
3855
4076
|
const a = i === "execute_code", l = i === "execute_code_in_browser_tab" && o !== null && typeof o == "object" && o.tabId === "local:current";
|
|
3856
|
-
if (!a && !l || !
|
|
4077
|
+
if (!a && !l || !po(o)) {
|
|
3857
4078
|
this.setToolMessageLoading(n, !1), this.send({
|
|
3858
4079
|
type: "tool.result",
|
|
3859
4080
|
sessionId: t,
|
|
@@ -3900,9 +4121,9 @@ class Ne {
|
|
|
3900
4121
|
startedAtOrigin: location.origin
|
|
3901
4122
|
}), this.installSessionBrowserApis();
|
|
3902
4123
|
let c = null, u;
|
|
3903
|
-
c = await this.executeRuntimeHelper(), u = await
|
|
4124
|
+
c = await this.executeRuntimeHelper(), u = await Jt(
|
|
3904
4125
|
o,
|
|
3905
|
-
|
|
4126
|
+
Ki(e.runtimeContext, this.options.backendUrl)
|
|
3906
4127
|
).catch((d) => ({
|
|
3907
4128
|
ok: !1,
|
|
3908
4129
|
exception: {
|
|
@@ -3915,11 +4136,11 @@ class Ne {
|
|
|
3915
4136
|
toolName: i,
|
|
3916
4137
|
summary: o.summary,
|
|
3917
4138
|
rawInput: L(o),
|
|
3918
|
-
rawOutput: L(
|
|
3919
|
-
}),
|
|
4139
|
+
rawOutput: L(hr(u, c))
|
|
4140
|
+
}), ds(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
3920
4141
|
}
|
|
3921
4142
|
setToolMessageLoading(e, t) {
|
|
3922
|
-
const n =
|
|
4143
|
+
const n = ns(
|
|
3923
4144
|
this.state.messages,
|
|
3924
4145
|
e,
|
|
3925
4146
|
t
|
|
@@ -3930,33 +4151,33 @@ class Ne {
|
|
|
3930
4151
|
if (this.pageLifecycleCleanup)
|
|
3931
4152
|
return;
|
|
3932
4153
|
const e = () => {
|
|
3933
|
-
|
|
4154
|
+
xs(this.options.clientId, this.activeBrowserToolCalls.values());
|
|
3934
4155
|
};
|
|
3935
4156
|
window.addEventListener("pagehide", e), window.addEventListener("beforeunload", e), this.pageLifecycleCleanup = () => {
|
|
3936
4157
|
window.removeEventListener("pagehide", e), window.removeEventListener("beforeunload", e);
|
|
3937
4158
|
};
|
|
3938
4159
|
}
|
|
3939
4160
|
installSessionBrowserApis() {
|
|
3940
|
-
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup =
|
|
4161
|
+
this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = xi();
|
|
3941
4162
|
}
|
|
3942
4163
|
cleanupSessionBrowserApis() {
|
|
3943
|
-
this.sessionBrowserApisCleanup && (
|
|
4164
|
+
this.sessionBrowserApisCleanup && (ji(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
|
|
3944
4165
|
}
|
|
3945
4166
|
async executeRuntimeHelper() {
|
|
3946
4167
|
if (!this.runtimeHelperJavascript?.trim())
|
|
3947
4168
|
return null;
|
|
3948
|
-
const e = await
|
|
4169
|
+
const e = await Jt({
|
|
3949
4170
|
javascript: this.runtimeHelperJavascript
|
|
3950
4171
|
});
|
|
3951
|
-
return e.ok === !1 ?
|
|
4172
|
+
return e.ok === !1 ? pr(e) : null;
|
|
3952
4173
|
}
|
|
3953
4174
|
enableNetworkCapture() {
|
|
3954
|
-
this.networkCaptureCleanup || (this.networkCaptureCleanup =
|
|
3955
|
-
|
|
4175
|
+
this.networkCaptureCleanup || (this.networkCaptureCleanup = _i((e) => {
|
|
4176
|
+
So(e.url, this.options.backendUrl) || this.enqueueNetworkEvent(e);
|
|
3956
4177
|
}));
|
|
3957
4178
|
}
|
|
3958
4179
|
enqueueNetworkEvent(e) {
|
|
3959
|
-
this.queuedNetworkEvents.length >=
|
|
4180
|
+
this.queuedNetworkEvents.length >= mi || (this.queuedNetworkEvents.push(Io(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
|
|
3960
4181
|
this.networkBatchTimer = null;
|
|
3961
4182
|
const t = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
|
|
3962
4183
|
t.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
|
|
@@ -3965,14 +4186,14 @@ class Ne {
|
|
|
3965
4186
|
page: _(),
|
|
3966
4187
|
events: t
|
|
3967
4188
|
});
|
|
3968
|
-
},
|
|
4189
|
+
}, fi)));
|
|
3969
4190
|
}
|
|
3970
4191
|
scheduleReconnect(e = 0) {
|
|
3971
4192
|
if (this.reconnectTimer !== null || this.state.status === "closed")
|
|
3972
4193
|
return;
|
|
3973
4194
|
const t = Math.min(
|
|
3974
|
-
|
|
3975
|
-
Math.max(
|
|
4195
|
+
at,
|
|
4196
|
+
Math.max(Ri(this.reconnectAttempts), e)
|
|
3976
4197
|
);
|
|
3977
4198
|
this.reconnectAttempts += 1, this.reconnectTimer = window.setTimeout(() => {
|
|
3978
4199
|
this.reconnectTimer = null, this.connect().catch((n) => {
|
|
@@ -3989,8 +4210,8 @@ class Ne {
|
|
|
3989
4210
|
const e = this.socket;
|
|
3990
4211
|
!e || !this.sendNow({ type: "runtime.ping" }) || (this.clearHeartbeatAckTimer(), this.heartbeatAckTimer = window.setTimeout(() => {
|
|
3991
4212
|
this.socket === e && (b("web-sdk.agent", "Pluno heartbeat acknowledgement timed out; reconnecting"), this.replaceTimedOutSocket(e));
|
|
3992
|
-
},
|
|
3993
|
-
},
|
|
4213
|
+
}, ei));
|
|
4214
|
+
}, Zn);
|
|
3994
4215
|
}
|
|
3995
4216
|
stopHeartbeat() {
|
|
3996
4217
|
this.heartbeatTimer !== null && (window.clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.clearHeartbeatAckTimer();
|
|
@@ -4028,12 +4249,12 @@ class Ne {
|
|
|
4028
4249
|
...e.lastError === null && e.lastErrorCode === void 0 ? { lastErrorCode: null } : {},
|
|
4029
4250
|
...e.lastError !== void 0 && e.lastErrorSecuritySettingsUrl === void 0 ? { lastErrorSecuritySettingsUrl: null } : {}
|
|
4030
4251
|
}, a = this.state.sessionId, l = this.state.isThinking || this.state.pendingMessageStatus !== null, c = o.isThinking || o.pendingMessageStatus !== null, u = this.activeClientMessageId ?? this.pendingClientMessageId;
|
|
4031
|
-
u && u === this.lastProjectedTurnClientMessageId && c &&
|
|
4252
|
+
u && u === this.lastProjectedTurnClientMessageId && c && Di(this.lastProjectedTurnPhase, o.turnPhase) && this.reportHealthSignal("invalid_state_transition", {
|
|
4032
4253
|
clientMessageId: u,
|
|
4033
4254
|
reason: "active_turn_phase_moved_backward",
|
|
4034
4255
|
previousPhase: this.lastProjectedTurnPhase,
|
|
4035
4256
|
nextPhase: o.turnPhase
|
|
4036
|
-
}), this.state = o, this.lastProjectedTurnClientMessageId = u, this.lastProjectedTurnPhase = o.turnPhase, 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),
|
|
4257
|
+
}), this.state = o, this.lastProjectedTurnClientMessageId = u, this.lastProjectedTurnPhase = o.turnPhase, 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), eo(this.options.clientId, this.state), this.emit("state", this.getState()), Se("state", this.state.status, {
|
|
4037
4258
|
status: this.state.status,
|
|
4038
4259
|
sessionId: this.state.sessionId,
|
|
4039
4260
|
messageCount: this.state.messages.length,
|
|
@@ -4061,7 +4282,7 @@ class Ne {
|
|
|
4061
4282
|
this.transportIdentity.transportId
|
|
4062
4283
|
].join(":"), n = `${e}:${t}`;
|
|
4063
4284
|
if (this.sessionRecoveryScope !== n) {
|
|
4064
|
-
const i = [...this.state.messages].reverse().find((r) => !
|
|
4285
|
+
const i = [...this.state.messages].reverse().find((r) => !ft(r) && !r.id.startsWith("transient-activity:"));
|
|
4065
4286
|
this.sessionActivityRecovery.reset(i?.id ?? null), this.sessionRecoveryScope = n;
|
|
4066
4287
|
}
|
|
4067
4288
|
this.sessionRecoveryPoller.start(e, t), this.sessionActivityRecoveryPoller.start(e, t);
|
|
@@ -4092,13 +4313,13 @@ class Ne {
|
|
|
4092
4313
|
}
|
|
4093
4314
|
}
|
|
4094
4315
|
const Ze = /* @__PURE__ */ new WeakMap();
|
|
4095
|
-
function
|
|
4096
|
-
const e = window.__plunoProductAgentNetworkCapture ??
|
|
4316
|
+
function _i(s) {
|
|
4317
|
+
const e = window.__plunoProductAgentNetworkCapture ?? Pi();
|
|
4097
4318
|
return e.subscribers.add(s), () => {
|
|
4098
4319
|
e.subscribers.delete(s), !(e.subscribers.size > 0) && (e.destroy(), window.__plunoProductAgentNetworkCapture === e && delete window.__plunoProductAgentNetworkCapture);
|
|
4099
4320
|
};
|
|
4100
4321
|
}
|
|
4101
|
-
function
|
|
4322
|
+
function Pi() {
|
|
4102
4323
|
const s = /* @__PURE__ */ new Set(), e = (g) => {
|
|
4103
4324
|
s.forEach((f) => {
|
|
4104
4325
|
try {
|
|
@@ -4115,20 +4336,20 @@ function Ai() {
|
|
|
4115
4336
|
throw m;
|
|
4116
4337
|
}
|
|
4117
4338
|
try {
|
|
4118
|
-
const m = f instanceof Request ? f : null, M =
|
|
4339
|
+
const m = f instanceof Request ? f : null, M = go(f, m), w = Bs(h?.headers ?? m?.headers);
|
|
4119
4340
|
if (!te(M, w, h?.body)) {
|
|
4120
4341
|
const H = {
|
|
4121
4342
|
requestId: nt("fetch"),
|
|
4122
4343
|
url: F(M, Ye),
|
|
4123
4344
|
method: (h?.method ?? m?.method ?? "GET").toUpperCase(),
|
|
4124
4345
|
requestHeaders: w,
|
|
4125
|
-
requestBody:
|
|
4346
|
+
requestBody: ps(h?.body),
|
|
4126
4347
|
resourceType: "fetch",
|
|
4127
4348
|
startedAt: new Date(p).toISOString()
|
|
4128
4349
|
};
|
|
4129
4350
|
y.then(
|
|
4130
4351
|
(S) => {
|
|
4131
|
-
|
|
4352
|
+
fo(S, H, p, e).catch(() => {
|
|
4132
4353
|
e({
|
|
4133
4354
|
...H,
|
|
4134
4355
|
responseStatus: S.status,
|
|
@@ -4161,16 +4382,16 @@ function Ai() {
|
|
|
4161
4382
|
}), M;
|
|
4162
4383
|
}, l = function(f, h) {
|
|
4163
4384
|
const p = i.call(this, f, h), y = Ze.get(this);
|
|
4164
|
-
return y && Object.keys(y.requestHeaders).length <
|
|
4385
|
+
return y && Object.keys(y.requestHeaders).length < At && (y.requestHeaders[f] = kt(f, h), y.excluded = y.excluded || te(y.url, y.requestHeaders)), p;
|
|
4165
4386
|
}, c = function(f) {
|
|
4166
4387
|
try {
|
|
4167
4388
|
const h = Ze.get(this);
|
|
4168
|
-
h && (h.excluded = h.excluded || te(h.url, h.requestHeaders, f), h.requestBody =
|
|
4389
|
+
h && (h.excluded = h.excluded || te(h.url, h.requestHeaders, f), h.requestBody = ps(f), h.excluded || this.addEventListener(
|
|
4169
4390
|
"loadend",
|
|
4170
4391
|
() => {
|
|
4171
4392
|
queueMicrotask(() => {
|
|
4172
4393
|
try {
|
|
4173
|
-
const p =
|
|
4394
|
+
const p = wo(this.getAllResponseHeaders());
|
|
4174
4395
|
e({
|
|
4175
4396
|
requestId: h.requestId,
|
|
4176
4397
|
url: h.url,
|
|
@@ -4180,7 +4401,7 @@ function Ai() {
|
|
|
4180
4401
|
resourceType: "xhr",
|
|
4181
4402
|
responseStatus: this.status,
|
|
4182
4403
|
responseHeaders: p,
|
|
4183
|
-
responseBody:
|
|
4404
|
+
responseBody: yo(this, p),
|
|
4184
4405
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
4185
4406
|
startedAt: h.startedAt,
|
|
4186
4407
|
durationMs: Date.now() - h.startedAtMs
|
|
@@ -4272,14 +4493,14 @@ function b(s, e, t) {
|
|
|
4272
4493
|
}, r = n.__plunoProductAgentDiagnostics__ ?? [];
|
|
4273
4494
|
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 }));
|
|
4274
4495
|
}
|
|
4275
|
-
function
|
|
4496
|
+
function Qt(s) {
|
|
4276
4497
|
const e = typeof s == "function" ? s() : s;
|
|
4277
4498
|
return e && Object.keys(e).length > 0 ? e : void 0;
|
|
4278
4499
|
}
|
|
4279
|
-
function
|
|
4500
|
+
function vi(s) {
|
|
4280
4501
|
return s.type === "run.model_started" || s.type === "conversation.state" || s.type === "session.updated" || s.type === "session.item" || s.type === "chat.assistant_delta" || s.type === "chat.assistant_done" || s.type === "tool.call";
|
|
4281
4502
|
}
|
|
4282
|
-
function
|
|
4503
|
+
function Ui(s) {
|
|
4283
4504
|
if (s.type === "chat.assistant_delta")
|
|
4284
4505
|
return typeof s.delta == "string" && s.delta.trim().length > 0;
|
|
4285
4506
|
if (s.type === "tool.call")
|
|
@@ -4289,7 +4510,7 @@ function bi(s) {
|
|
|
4289
4510
|
const e = C(s.item);
|
|
4290
4511
|
return e ? e.type === "message" && e.role === "assistant" ? typeof e.content == "string" && e.content.trim().length > 0 : e.type === "tool_call" || e.type === "function_call" : !1;
|
|
4291
4512
|
}
|
|
4292
|
-
function
|
|
4513
|
+
function Di(s, e) {
|
|
4293
4514
|
if (!s || !e)
|
|
4294
4515
|
return !1;
|
|
4295
4516
|
const t = {
|
|
@@ -4317,31 +4538,31 @@ function K(s) {
|
|
|
4317
4538
|
}
|
|
4318
4539
|
return null;
|
|
4319
4540
|
}
|
|
4320
|
-
const
|
|
4321
|
-
function
|
|
4541
|
+
const qi = 5e3, Oi = 12e4;
|
|
4542
|
+
function xi() {
|
|
4322
4543
|
const s = [
|
|
4323
|
-
|
|
4324
|
-
|
|
4544
|
+
Ni(),
|
|
4545
|
+
Li()
|
|
4325
4546
|
].filter((e) => typeof e == "function");
|
|
4326
4547
|
return () => {
|
|
4327
4548
|
for (const e of s.reverse())
|
|
4328
4549
|
e();
|
|
4329
4550
|
};
|
|
4330
4551
|
}
|
|
4331
|
-
function
|
|
4332
|
-
return
|
|
4552
|
+
function Li() {
|
|
4553
|
+
return ms(globalThis, "getPageSnapshot", async () => Mt());
|
|
4333
4554
|
}
|
|
4334
|
-
function
|
|
4335
|
-
return
|
|
4336
|
-
inspectImage: async (e, t) => await
|
|
4555
|
+
function Ni() {
|
|
4556
|
+
return ms(globalThis, "pageImages", {
|
|
4557
|
+
inspectImage: async (e, t) => await Hi(e, t)
|
|
4337
4558
|
});
|
|
4338
4559
|
}
|
|
4339
|
-
async function
|
|
4340
|
-
const t =
|
|
4560
|
+
async function Hi(s, e = {}) {
|
|
4561
|
+
const t = $i(e.name), n = await Bi(s);
|
|
4341
4562
|
return n.ok ? n.sizeBytes > 8 * 1024 * 1024 ? {
|
|
4342
4563
|
type: "pluno.pageImages.inspectImage",
|
|
4343
4564
|
imageAttached: !1,
|
|
4344
|
-
imageAttachmentError:
|
|
4565
|
+
imageAttachmentError: Rs
|
|
4345
4566
|
} : {
|
|
4346
4567
|
type: "pluno.pageImages.inspectImage",
|
|
4347
4568
|
imageAttached: !0,
|
|
@@ -4355,15 +4576,15 @@ async function vi(s, e = {}) {
|
|
|
4355
4576
|
imageAttachmentError: n.error
|
|
4356
4577
|
};
|
|
4357
4578
|
}
|
|
4358
|
-
async function
|
|
4359
|
-
return s instanceof Blob ? s.type.startsWith("image/") ? s.size === 0 ? { ok: !1, error: "Page image is empty." } : s.size > 8 * 1024 * 1024 ? { ok: !1, error:
|
|
4579
|
+
async function Bi(s) {
|
|
4580
|
+
return s instanceof Blob ? s.type.startsWith("image/") ? s.size === 0 ? { ok: !1, error: "Page image is empty." } : s.size > 8 * 1024 * 1024 ? { ok: !1, error: Rs } : {
|
|
4360
4581
|
ok: !0,
|
|
4361
4582
|
mimeType: s.type,
|
|
4362
4583
|
sizeBytes: s.size,
|
|
4363
|
-
dataUrl: await
|
|
4364
|
-
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } :
|
|
4584
|
+
dataUrl: await zi(s)
|
|
4585
|
+
} : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof s != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Fi(s);
|
|
4365
4586
|
}
|
|
4366
|
-
function
|
|
4587
|
+
function Fi(s) {
|
|
4367
4588
|
if (!s.startsWith("data:") || !s.includes(","))
|
|
4368
4589
|
return { ok: !1, error: "Page image must be a complete data:image/* URL, not bare base64." };
|
|
4369
4590
|
const [e, t] = s.slice(5).split(",", 2), n = e.split(";").map((a) => a.trim()).filter(Boolean), i = n[0] ?? "";
|
|
@@ -4374,7 +4595,7 @@ function Di(s) {
|
|
|
4374
4595
|
const r = t.replace(/[ \t\r\n\f]+/g, "");
|
|
4375
4596
|
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(r))
|
|
4376
4597
|
return { ok: !1, error: "Page image data URL has invalid base64." };
|
|
4377
|
-
const o =
|
|
4598
|
+
const o = Wi(r);
|
|
4378
4599
|
return o === null ? { ok: !1, error: "Page image data URL has invalid base64." } : o === 0 ? { ok: !1, error: "Page image is empty." } : {
|
|
4379
4600
|
ok: !0,
|
|
4380
4601
|
mimeType: i,
|
|
@@ -4382,22 +4603,22 @@ function Di(s) {
|
|
|
4382
4603
|
dataUrl: `data:${i};base64,${r}`
|
|
4383
4604
|
};
|
|
4384
4605
|
}
|
|
4385
|
-
function
|
|
4606
|
+
function Wi(s) {
|
|
4386
4607
|
if (s.length === 0 || s.length % 4 !== 0)
|
|
4387
4608
|
return null;
|
|
4388
4609
|
const e = s.length - s.replace(/=+$/, "").length;
|
|
4389
4610
|
return e > 2 ? null : s.length / 4 * 3 - e;
|
|
4390
4611
|
}
|
|
4391
|
-
function
|
|
4612
|
+
function $i(s) {
|
|
4392
4613
|
return (typeof s == "string" ? s.trim() : "") || "Page image";
|
|
4393
4614
|
}
|
|
4394
|
-
function
|
|
4615
|
+
function ji(s) {
|
|
4395
4616
|
try {
|
|
4396
4617
|
s();
|
|
4397
4618
|
} catch {
|
|
4398
4619
|
}
|
|
4399
4620
|
}
|
|
4400
|
-
function
|
|
4621
|
+
function zi(s) {
|
|
4401
4622
|
return new Promise((e, t) => {
|
|
4402
4623
|
const n = new FileReader();
|
|
4403
4624
|
n.onload = () => {
|
|
@@ -4409,9 +4630,9 @@ function Li(s) {
|
|
|
4409
4630
|
}, n.onerror = () => t(n.error ?? new Error("Failed to read page image")), n.readAsDataURL(s);
|
|
4410
4631
|
});
|
|
4411
4632
|
}
|
|
4412
|
-
async function
|
|
4633
|
+
async function Jt(s, e) {
|
|
4413
4634
|
const t = Object.getPrototypeOf(async function() {
|
|
4414
|
-
}).constructor, n = s.timeoutMs ??
|
|
4635
|
+
}).constructor, n = s.timeoutMs ?? qi, i = Date.now(), r = [];
|
|
4415
4636
|
let o;
|
|
4416
4637
|
const a = {
|
|
4417
4638
|
log: console.log,
|
|
@@ -4429,7 +4650,7 @@ async function Gt(s, e) {
|
|
|
4429
4650
|
o = window.setTimeout(() => d(c), n);
|
|
4430
4651
|
})
|
|
4431
4652
|
]);
|
|
4432
|
-
return u === c ?
|
|
4653
|
+
return u === c ? Gi(n) : {
|
|
4433
4654
|
ok: !0,
|
|
4434
4655
|
result: u,
|
|
4435
4656
|
console: r,
|
|
@@ -4458,7 +4679,7 @@ async function Gt(s, e) {
|
|
|
4458
4679
|
e?.deactivate(), o !== void 0 && window.clearTimeout(o), console.log = a.log, console.info = a.info, console.warn = a.warn, console.error = a.error;
|
|
4459
4680
|
}
|
|
4460
4681
|
}
|
|
4461
|
-
function
|
|
4682
|
+
function Ki(s, e) {
|
|
4462
4683
|
if (!s || typeof s != "object")
|
|
4463
4684
|
return;
|
|
4464
4685
|
const t = s.sandboxFilesToken;
|
|
@@ -4468,7 +4689,7 @@ function Ni(s, e) {
|
|
|
4468
4689
|
const i = () => {
|
|
4469
4690
|
if (!n)
|
|
4470
4691
|
throw new Error("sandboxFiles is only available during browser-code execution");
|
|
4471
|
-
}, r = async (a, l) => await
|
|
4692
|
+
}, r = async (a, l) => await jn(`${e.replace(/\/$/, "")}${a}`, l);
|
|
4472
4693
|
return {
|
|
4473
4694
|
value: Object.freeze({
|
|
4474
4695
|
upload: async (a) => {
|
|
@@ -4502,7 +4723,7 @@ function Ni(s, e) {
|
|
|
4502
4723
|
}
|
|
4503
4724
|
};
|
|
4504
4725
|
}
|
|
4505
|
-
function
|
|
4726
|
+
function Gi(s) {
|
|
4506
4727
|
return {
|
|
4507
4728
|
ok: !1,
|
|
4508
4729
|
exception: {
|
|
@@ -4516,10 +4737,10 @@ function Hi(s) {
|
|
|
4516
4737
|
}
|
|
4517
4738
|
};
|
|
4518
4739
|
}
|
|
4519
|
-
function
|
|
4740
|
+
function Vi(s) {
|
|
4520
4741
|
return s.replace(/\/+$/, "");
|
|
4521
4742
|
}
|
|
4522
|
-
function
|
|
4743
|
+
function Qi(s) {
|
|
4523
4744
|
const e = {
|
|
4524
4745
|
sidepanel: "extension_sidepanel",
|
|
4525
4746
|
browser_extension_page_ui: "extension_widget",
|
|
@@ -4531,18 +4752,18 @@ function Fi(s) {
|
|
|
4531
4752
|
};
|
|
4532
4753
|
return s && s in e ? e[s] : s ?? "embedded_custom_ui";
|
|
4533
4754
|
}
|
|
4534
|
-
function
|
|
4755
|
+
function Ji(s) {
|
|
4535
4756
|
return s === "pluno" ? "scheduled_continuation" : s ?? "user";
|
|
4536
4757
|
}
|
|
4537
|
-
function
|
|
4758
|
+
function Xi(s, e = location.origin) {
|
|
4538
4759
|
return /origin (?:is not allowed|does not match browser origin)/i.test(s) ? `Pluno widget blocked on ${e}: this domain is not allowed. Add ${e} in Pluno under Integration > Domains.` : null;
|
|
4539
4760
|
}
|
|
4540
|
-
function
|
|
4761
|
+
function Yi(s) {
|
|
4541
4762
|
const e = new URL("/api/product-agent/embed/ws", s);
|
|
4542
4763
|
return e.protocol = e.protocol === "https:" ? "wss:" : "ws:", e.toString();
|
|
4543
4764
|
}
|
|
4544
4765
|
function _() {
|
|
4545
|
-
const s =
|
|
4766
|
+
const s = Ps();
|
|
4546
4767
|
return {
|
|
4547
4768
|
url: location.href,
|
|
4548
4769
|
title: document.title,
|
|
@@ -4550,19 +4771,19 @@ function _() {
|
|
|
4550
4771
|
...s ? { plunoProductAgentUi: s } : {}
|
|
4551
4772
|
};
|
|
4552
4773
|
}
|
|
4553
|
-
function
|
|
4774
|
+
function Zi() {
|
|
4554
4775
|
return {
|
|
4555
4776
|
pageUrl: location.href,
|
|
4556
4777
|
pageTitle: document.title,
|
|
4557
|
-
htmlContent:
|
|
4778
|
+
htmlContent: Mt()
|
|
4558
4779
|
};
|
|
4559
4780
|
}
|
|
4560
|
-
function
|
|
4561
|
-
return Ce.add(s), we || (we =
|
|
4781
|
+
function er(s) {
|
|
4782
|
+
return Ce.add(s), we || (we = tr()), () => {
|
|
4562
4783
|
Ce.delete(s), Ce.size === 0 && (we?.(), we = null);
|
|
4563
4784
|
};
|
|
4564
4785
|
}
|
|
4565
|
-
function
|
|
4786
|
+
function tr() {
|
|
4566
4787
|
const s = () => {
|
|
4567
4788
|
for (const r of Array.from(Ce))
|
|
4568
4789
|
r();
|
|
@@ -4578,9 +4799,9 @@ function Gi() {
|
|
|
4578
4799
|
};
|
|
4579
4800
|
}
|
|
4580
4801
|
function et() {
|
|
4581
|
-
return
|
|
4802
|
+
return Ps()?.surface === "browser_extension_sdk_preview";
|
|
4582
4803
|
}
|
|
4583
|
-
function
|
|
4804
|
+
function Mt() {
|
|
4584
4805
|
if (!document.body)
|
|
4585
4806
|
return "";
|
|
4586
4807
|
const s = [], e = [], t = (p, y) => {
|
|
@@ -4589,16 +4810,16 @@ function At() {
|
|
|
4589
4810
|
};
|
|
4590
4811
|
t("Selected text", window.getSelection()?.toString() ?? "");
|
|
4591
4812
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
|
|
4592
|
-
(p) =>
|
|
4813
|
+
(p) => Es(p) && !p.parentElement?.closest(n)
|
|
4593
4814
|
);
|
|
4594
4815
|
for (const p of i.slice(0, 3))
|
|
4595
4816
|
t("Active overlay", tt(he(p), e));
|
|
4596
|
-
const r =
|
|
4817
|
+
const r = sr(), o = r ? tt(he(r), e) : "";
|
|
4597
4818
|
t("Main page content", o), t("Additional visible page text", tt(he(document.body), e));
|
|
4598
4819
|
const a = s.map(([p, y]) => `${p}:
|
|
4599
4820
|
${y}`).join(`
|
|
4600
4821
|
|
|
4601
|
-
`).trim().slice(0, 12e3), l =
|
|
4822
|
+
`).trim().slice(0, 12e3), l = nr(i, r).trim(), c = `Simplified DOM outline:
|
|
4602
4823
|
`, u = `
|
|
4603
4824
|
|
|
4604
4825
|
Visible page text:
|
|
@@ -4622,14 +4843,14 @@ function tt(s, e) {
|
|
|
4622
4843
|
t = t.replace(n, "");
|
|
4623
4844
|
return ne(t);
|
|
4624
4845
|
}
|
|
4625
|
-
function
|
|
4846
|
+
function Es(s) {
|
|
4626
4847
|
const e = window.getComputedStyle(s);
|
|
4627
4848
|
return e.display !== "none" && e.visibility !== "hidden" && s.getClientRects().length > 0;
|
|
4628
4849
|
}
|
|
4629
|
-
function
|
|
4630
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(
|
|
4850
|
+
function sr() {
|
|
4851
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Es).sort((s, e) => he(e).length - he(s).length)[0] ?? null;
|
|
4631
4852
|
}
|
|
4632
|
-
function
|
|
4853
|
+
function nr(s, e) {
|
|
4633
4854
|
const t = /* @__PURE__ */ new Set([
|
|
4634
4855
|
"main",
|
|
4635
4856
|
"nav",
|
|
@@ -4709,7 +4930,7 @@ function Vi(s, e) {
|
|
|
4709
4930
|
"data-test",
|
|
4710
4931
|
"data-qa",
|
|
4711
4932
|
"data-cy"
|
|
4712
|
-
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } =
|
|
4933
|
+
], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = ir(), g = new Set(s);
|
|
4713
4934
|
e && g.add(e);
|
|
4714
4935
|
let f = 0;
|
|
4715
4936
|
const h = (w) => {
|
|
@@ -4724,36 +4945,36 @@ function Vi(s, e) {
|
|
|
4724
4945
|
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")
|
|
4725
4946
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
4726
4947
|
f += 1;
|
|
4727
|
-
const Z = h(T), ee =
|
|
4948
|
+
const Z = h(T), ee = _s(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), V = /* @__PURE__ */ new Map();
|
|
4728
4949
|
for (const I of B) {
|
|
4729
4950
|
const R = p(I);
|
|
4730
|
-
|
|
4951
|
+
V.set(R, (V.get(R) ?? 0) + 1);
|
|
4731
4952
|
}
|
|
4732
4953
|
const me = /* @__PURE__ */ new Map(), oe = /* @__PURE__ */ new Map();
|
|
4733
4954
|
for (const I of B) {
|
|
4734
4955
|
const R = p(I), z = oe.get(R) ?? 0;
|
|
4735
|
-
oe.set(R, z + 1), (
|
|
4956
|
+
oe.set(R, z + 1), (V.get(R) ?? 0) > 8 && z >= 6 && !u.has(I) && me.set(R, (me.get(R) ?? 0) + 1);
|
|
4736
4957
|
}
|
|
4737
4958
|
const j = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), q = [], Et = [];
|
|
4738
4959
|
for (const I of B) {
|
|
4739
|
-
const R = p(I), z =
|
|
4740
|
-
if (j.set(R,
|
|
4960
|
+
const R = p(I), z = V.get(R) ?? 0, Pt = j.get(R) ?? 0;
|
|
4961
|
+
if (j.set(R, Pt + 1), z > 8 && Pt >= 6 && !u.has(I)) {
|
|
4741
4962
|
U.has(R) || (q.push([`… ${me.get(R) ?? 0} similar siblings omitted`]), U.add(R));
|
|
4742
4963
|
continue;
|
|
4743
4964
|
}
|
|
4744
|
-
const
|
|
4745
|
-
Et.push(
|
|
4965
|
+
const vt = S(I, N);
|
|
4966
|
+
Et.push(vt), q.push(vt.lines);
|
|
4746
4967
|
}
|
|
4747
4968
|
const Fe = [];
|
|
4748
4969
|
if (T.shadowRoot)
|
|
4749
4970
|
for (const I of Array.from(T.shadowRoot.children))
|
|
4750
4971
|
I instanceof HTMLElement && Fe.push(S(I, N + 1));
|
|
4751
|
-
const ye = [...Et, ...Fe], We = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent),
|
|
4972
|
+
const ye = [...Et, ...Fe], We = ee.length > 0 || fe || ye.some((I) => I.hasUsefulContent), Ct = ne(
|
|
4752
4973
|
[ee, ...ye.map((I) => I.textPreview)].filter(Boolean).join(" ")
|
|
4753
|
-
).slice(0, 180),
|
|
4974
|
+
).slice(0, 180), Vs = T.hasAttribute("contenteditable") && (ee.length > 0 || !T.querySelector("[contenteditable]")), _t = c.some((I) => T.hasAttribute(I)) || !!Z || Vs, $e = (T.getClientRects().length > 0 || re.display === "contents") && (t.has(v) || _t || Y) && (We || Y) && (!i.has(v) || We || _t || Y), je = $e ? 1 : 0, ae = [];
|
|
4754
4975
|
if ($e) {
|
|
4755
|
-
const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ?
|
|
4756
|
-
ae.push(
|
|
4976
|
+
const I = ye.some((z) => z.containsTextElement), R = n.has(v) && !I ? Ct : ee;
|
|
4977
|
+
ae.push(Cs(T, l, o, R.slice(0, 180)));
|
|
4757
4978
|
}
|
|
4758
4979
|
for (const I of q)
|
|
4759
4980
|
ae.push(...Ae(I, je));
|
|
@@ -4771,7 +4992,7 @@ function Vi(s, e) {
|
|
|
4771
4992
|
return {
|
|
4772
4993
|
lines: ae,
|
|
4773
4994
|
hasUsefulContent: We,
|
|
4774
|
-
textPreview:
|
|
4995
|
+
textPreview: Ct,
|
|
4775
4996
|
containsTextElement: n.has(v) || ye.some((I) => I.containsTextElement)
|
|
4776
4997
|
};
|
|
4777
4998
|
};
|
|
@@ -4779,7 +5000,7 @@ function Vi(s, e) {
|
|
|
4779
5000
|
`);
|
|
4780
5001
|
}, m = [], M = ne(window.getSelection()?.toString() ?? "");
|
|
4781
5002
|
M && m.push(`--- selected text ---
|
|
4782
|
-
${JSON.stringify(M)}`), d.length > 0 && m.push(
|
|
5003
|
+
${JSON.stringify(M)}`), d.length > 0 && m.push(rr(d, t, l, o));
|
|
4783
5004
|
for (const w of s.slice(0, 3))
|
|
4784
5005
|
m.push(y(w, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
4785
5006
|
if (e && m.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -4790,11 +5011,11 @@ ${JSON.stringify(M)}`), d.length > 0 && m.push(Ji(d, t, l, o));
|
|
|
4790
5011
|
|
|
4791
5012
|
`);
|
|
4792
5013
|
}
|
|
4793
|
-
function
|
|
5014
|
+
function Cs(s, e, t, n) {
|
|
4794
5015
|
const i = s.tagName.toLowerCase();
|
|
4795
5016
|
let r = i;
|
|
4796
5017
|
const o = s.getAttribute("id");
|
|
4797
|
-
o &&
|
|
5018
|
+
o && or(o) && (r += `#${o}`);
|
|
4798
5019
|
for (const a of e) {
|
|
4799
5020
|
const l = s.getAttribute(a);
|
|
4800
5021
|
l && l.length <= 160 && (a !== "role" || !t.has(l)) && (r += `[${a}=${JSON.stringify(l)}]`);
|
|
@@ -4807,7 +5028,7 @@ function Rs(s, e, t, n) {
|
|
|
4807
5028
|
s.hasAttribute(a) && (r += `[${a}]`);
|
|
4808
5029
|
return `${r}${n ? ` ${JSON.stringify(n)}` : ""}`;
|
|
4809
5030
|
}
|
|
4810
|
-
function
|
|
5031
|
+
function ir() {
|
|
4811
5032
|
const s = /* @__PURE__ */ new Set(), e = /* @__PURE__ */ new Map(), t = (a, l) => {
|
|
4812
5033
|
if (!a)
|
|
4813
5034
|
return;
|
|
@@ -4828,7 +5049,7 @@ function Xi() {
|
|
|
4828
5049
|
n = n.shadowRoot.activeElement;
|
|
4829
5050
|
n !== document.body && n !== document.documentElement && t(n, "focused");
|
|
4830
5051
|
const i = window.getSelection();
|
|
4831
|
-
i && !i.isCollapsed && (t(
|
|
5052
|
+
i && !i.isCollapsed && (t(Xt(i.anchorNode), "selected text"), t(Xt(i.focusNode), "selected text"));
|
|
4832
5053
|
const r = [
|
|
4833
5054
|
["[aria-selected='true']", "selected"],
|
|
4834
5055
|
["[aria-current]:not([aria-current='false'])", "current"],
|
|
@@ -4850,7 +5071,7 @@ function Xi() {
|
|
|
4850
5071
|
priorityTargets: Array.from(e, ([a, l]) => ({ element: a, labels: Array.from(l) }))
|
|
4851
5072
|
};
|
|
4852
5073
|
}
|
|
4853
|
-
function
|
|
5074
|
+
function rr(s, e, t, n) {
|
|
4854
5075
|
const i = ["--- active/current elements ---"];
|
|
4855
5076
|
for (const r of s) {
|
|
4856
5077
|
const o = [];
|
|
@@ -4861,18 +5082,18 @@ function Ji(s, e, t, n) {
|
|
|
4861
5082
|
const d = a.getRootNode();
|
|
4862
5083
|
a = a.parentElement ?? (d instanceof ShadowRoot && d.host instanceof HTMLElement ? d.host : null);
|
|
4863
5084
|
}
|
|
4864
|
-
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, d) =>
|
|
5085
|
+
const l = o.length > 6 ? [o[0], ...o.slice(-5)] : o, c = l.map((u, d) => Cs(
|
|
4865
5086
|
u,
|
|
4866
5087
|
t,
|
|
4867
5088
|
n,
|
|
4868
|
-
d === l.length - 1 ?
|
|
5089
|
+
d === l.length - 1 ? _s(u).slice(0, 180) : ""
|
|
4869
5090
|
));
|
|
4870
5091
|
o.length > l.length && c.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${c.join(" > ")}`);
|
|
4871
5092
|
}
|
|
4872
5093
|
return i.join(`
|
|
4873
5094
|
`);
|
|
4874
5095
|
}
|
|
4875
|
-
function
|
|
5096
|
+
function Xt(s) {
|
|
4876
5097
|
return s instanceof HTMLElement ? s : s?.parentElement instanceof HTMLElement ? s.parentElement : null;
|
|
4877
5098
|
}
|
|
4878
5099
|
function Ae(s, e) {
|
|
@@ -4881,17 +5102,17 @@ function Ae(s, e) {
|
|
|
4881
5102
|
const t = " ".repeat(e);
|
|
4882
5103
|
return s.map((n) => `${t}${n}`);
|
|
4883
5104
|
}
|
|
4884
|
-
function
|
|
5105
|
+
function _s(s) {
|
|
4885
5106
|
return ne(
|
|
4886
5107
|
Array.from(s.childNodes).filter((e) => e.nodeType === Node.TEXT_NODE).map((e) => e.textContent ?? "").join(" ")
|
|
4887
5108
|
);
|
|
4888
5109
|
}
|
|
4889
|
-
function
|
|
5110
|
+
function or(s) {
|
|
4890
5111
|
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);
|
|
4891
5112
|
}
|
|
4892
|
-
function
|
|
4893
|
-
const s = Array.from(document.querySelectorAll(
|
|
4894
|
-
(r) => typeof r[
|
|
5113
|
+
function Ps() {
|
|
5114
|
+
const s = Array.from(document.querySelectorAll(Wt)), e = s.find(
|
|
5115
|
+
(r) => typeof r[Vn] == "string"
|
|
4895
5116
|
);
|
|
4896
5117
|
if (!(e ?? s[0]))
|
|
4897
5118
|
return;
|
|
@@ -4902,28 +5123,28 @@ function ks() {
|
|
|
4902
5123
|
selectors: [
|
|
4903
5124
|
{
|
|
4904
5125
|
name: "widget_host",
|
|
4905
|
-
selector:
|
|
5126
|
+
selector: Wt,
|
|
4906
5127
|
description: "Finds Pluno's shadow-host element in the host page DOM."
|
|
4907
5128
|
},
|
|
4908
5129
|
{
|
|
4909
5130
|
name: "widget_root",
|
|
4910
|
-
selector:
|
|
5131
|
+
selector: zn,
|
|
4911
5132
|
description: "Finds Pluno's widget root inside the widget host shadow root."
|
|
4912
5133
|
},
|
|
4913
5134
|
{
|
|
4914
5135
|
name: "widget_panel",
|
|
4915
|
-
selector:
|
|
5136
|
+
selector: Kn,
|
|
4916
5137
|
description: "Finds Pluno's open chat panel inside the widget host shadow root."
|
|
4917
5138
|
},
|
|
4918
5139
|
{
|
|
4919
5140
|
name: "widget_timeline",
|
|
4920
|
-
selector:
|
|
5141
|
+
selector: Gn,
|
|
4921
5142
|
description: "Finds Pluno's chat timeline inside the widget host shadow root."
|
|
4922
5143
|
}
|
|
4923
5144
|
]
|
|
4924
5145
|
};
|
|
4925
5146
|
}
|
|
4926
|
-
function
|
|
5147
|
+
function ar(s) {
|
|
4927
5148
|
try {
|
|
4928
5149
|
const e = JSON.parse(s);
|
|
4929
5150
|
return e && typeof e == "object" ? e : { type: "error", message: "Invalid server event" };
|
|
@@ -4931,7 +5152,7 @@ function Zi(s) {
|
|
|
4931
5152
|
return { type: "error", message: "Invalid server event" };
|
|
4932
5153
|
}
|
|
4933
5154
|
}
|
|
4934
|
-
function
|
|
5155
|
+
function lr(s) {
|
|
4935
5156
|
if (typeof s != "string")
|
|
4936
5157
|
return null;
|
|
4937
5158
|
try {
|
|
@@ -4941,13 +5162,13 @@ function er(s) {
|
|
|
4941
5162
|
return null;
|
|
4942
5163
|
}
|
|
4943
5164
|
}
|
|
4944
|
-
function
|
|
5165
|
+
function Yt(s, e) {
|
|
4945
5166
|
if (!s || typeof s != "object")
|
|
4946
5167
|
return [];
|
|
4947
5168
|
const t = s[e];
|
|
4948
5169
|
return Array.isArray(t) ? t.filter((n) => typeof n == "string" && n.trim().length > 0) : [];
|
|
4949
5170
|
}
|
|
4950
|
-
function
|
|
5171
|
+
function Zt(s) {
|
|
4951
5172
|
return Array.isArray(s) ? s.flatMap((e) => {
|
|
4952
5173
|
if (!e || typeof e != "object")
|
|
4953
5174
|
return [];
|
|
@@ -4955,10 +5176,10 @@ function Xt(s) {
|
|
|
4955
5176
|
return typeof t.taskId != "string" || !t.taskId || typeof t.dueAt != "string" || Number.isNaN(Date.parse(t.dueAt)) ? [] : [{ taskId: t.taskId, dueAt: t.dueAt }];
|
|
4956
5177
|
}) : [];
|
|
4957
5178
|
}
|
|
4958
|
-
function
|
|
5179
|
+
function cr(s) {
|
|
4959
5180
|
return Array.isArray(s) ? s.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
4960
5181
|
}
|
|
4961
|
-
function
|
|
5182
|
+
function ur(s) {
|
|
4962
5183
|
if (!s || typeof s != "object")
|
|
4963
5184
|
return null;
|
|
4964
5185
|
const e = s, t = e.appearance, n = t && typeof t == "object" ? t : e, i = typeof n.accentColor == "string" ? n.accentColor : null, r = n.colorScheme === "dark" ? "dark" : n.colorScheme === "light" ? "light" : null, o = typeof n.fontFamily == "string" && n.fontFamily.trim() ? n.fontFamily : null, a = typeof n.scribbleStyle == "boolean" ? n.scribbleStyle : null;
|
|
@@ -4969,13 +5190,13 @@ function sr(s) {
|
|
|
4969
5190
|
...a !== null ? { scribbleStyle: a } : {}
|
|
4970
5191
|
};
|
|
4971
5192
|
}
|
|
4972
|
-
function
|
|
5193
|
+
function dr(s) {
|
|
4973
5194
|
if (!s || typeof s != "object")
|
|
4974
5195
|
return null;
|
|
4975
5196
|
const e = s.javascript;
|
|
4976
5197
|
return typeof e != "string" || !e.trim() ? null : { javascript: e };
|
|
4977
5198
|
}
|
|
4978
|
-
function
|
|
5199
|
+
function hr(s, e) {
|
|
4979
5200
|
return e ? s && typeof s == "object" ? {
|
|
4980
5201
|
...s,
|
|
4981
5202
|
helperError: e
|
|
@@ -4985,13 +5206,13 @@ function ir(s, e) {
|
|
|
4985
5206
|
helperError: e
|
|
4986
5207
|
} : s;
|
|
4987
5208
|
}
|
|
4988
|
-
function
|
|
5209
|
+
function pr(s) {
|
|
4989
5210
|
if (!s || typeof s != "object")
|
|
4990
5211
|
return s;
|
|
4991
5212
|
const e = s;
|
|
4992
5213
|
return typeof e.exception?.message == "string" ? e.exception.message : typeof e.error == "string" ? e.error : s;
|
|
4993
5214
|
}
|
|
4994
|
-
function
|
|
5215
|
+
function gr() {
|
|
4995
5216
|
const s = "pluno.productAgent.clientId", e = window.localStorage.getItem(s);
|
|
4996
5217
|
if (e)
|
|
4997
5218
|
return e;
|
|
@@ -5001,7 +5222,7 @@ function or() {
|
|
|
5001
5222
|
function x() {
|
|
5002
5223
|
return crypto.randomUUID();
|
|
5003
5224
|
}
|
|
5004
|
-
function
|
|
5225
|
+
function fr(s) {
|
|
5005
5226
|
if (!s || typeof s != "object")
|
|
5006
5227
|
return null;
|
|
5007
5228
|
const e = s, t = typeof e.id == "string" ? e.id : null;
|
|
@@ -5013,11 +5234,11 @@ function ar(s) {
|
|
|
5013
5234
|
} : null;
|
|
5014
5235
|
}
|
|
5015
5236
|
function st(s, e) {
|
|
5016
|
-
return Array.isArray(s) ?
|
|
5237
|
+
return Array.isArray(s) ? pt(
|
|
5017
5238
|
s.map((t) => Ue(t, e)).filter((t) => t !== null)
|
|
5018
5239
|
) : [];
|
|
5019
5240
|
}
|
|
5020
|
-
function
|
|
5241
|
+
function mr(s) {
|
|
5021
5242
|
return Array.isArray(s) ? s.flatMap((e) => {
|
|
5022
5243
|
if (!e || typeof e != "object")
|
|
5023
5244
|
return [];
|
|
@@ -5045,22 +5266,22 @@ function Ue(s, e) {
|
|
|
5045
5266
|
if (!n || typeof n != "object")
|
|
5046
5267
|
return null;
|
|
5047
5268
|
const i = n;
|
|
5048
|
-
if (i.hiddenFromTranscript === !0 ||
|
|
5269
|
+
if (i.hiddenFromTranscript === !0 || fn(i) || i.type === "tab_lifecycle_decision" && i.decision === "keep")
|
|
5049
5270
|
return null;
|
|
5050
5271
|
if (i.type === "assistant_draft")
|
|
5051
5272
|
return {
|
|
5052
5273
|
id: typeof i.id == "string" ? i.id : String(t.id ?? crypto.randomUUID()),
|
|
5053
5274
|
role: "assistant",
|
|
5054
5275
|
...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
|
|
5055
|
-
content:
|
|
5056
|
-
|
|
5276
|
+
content: qt(
|
|
5277
|
+
es(i.content),
|
|
5057
5278
|
e
|
|
5058
5279
|
),
|
|
5059
5280
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5060
|
-
...
|
|
5281
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5061
5282
|
...P(i) !== null ? { causalSequence: P(i) } : {},
|
|
5062
5283
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5063
|
-
...
|
|
5284
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5064
5285
|
dataType: "assistant_draft",
|
|
5065
5286
|
...i.steered === !0 ? { steered: !0 } : {}
|
|
5066
5287
|
};
|
|
@@ -5069,16 +5290,16 @@ function Ue(s, e) {
|
|
|
5069
5290
|
id: String(t.id ?? crypto.randomUUID()),
|
|
5070
5291
|
role: r,
|
|
5071
5292
|
...i.phase === "commentary" || i.phase === "final_answer" ? { phase: i.phase } : {},
|
|
5072
|
-
content:
|
|
5073
|
-
|
|
5293
|
+
content: qt(
|
|
5294
|
+
es(i.content),
|
|
5074
5295
|
e
|
|
5075
5296
|
),
|
|
5076
5297
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5077
|
-
...
|
|
5298
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5078
5299
|
...P(i) !== null ? { causalSequence: P(i) } : {},
|
|
5079
5300
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5080
|
-
...
|
|
5081
|
-
attachments:
|
|
5301
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5302
|
+
attachments: Ls(i.attachments, e),
|
|
5082
5303
|
...i.steered === !0 ? { steered: !0 } : {}
|
|
5083
5304
|
};
|
|
5084
5305
|
return r === "assistant" && typeof i.id == "string" && Object.defineProperty(o, "assistantDraftItemId", {
|
|
@@ -5093,47 +5314,47 @@ function Ue(s, e) {
|
|
|
5093
5314
|
}), o;
|
|
5094
5315
|
}
|
|
5095
5316
|
if (i.type === "function_call_output") {
|
|
5096
|
-
const r =
|
|
5317
|
+
const r = dn(i.output);
|
|
5097
5318
|
if (r !== null)
|
|
5098
5319
|
return {
|
|
5099
5320
|
id: String(t.id ?? crypto.randomUUID()),
|
|
5100
5321
|
role: "tool",
|
|
5101
5322
|
content: "",
|
|
5102
5323
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5103
|
-
...
|
|
5324
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5104
5325
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5105
|
-
...
|
|
5326
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5106
5327
|
dataType: "function_call_output",
|
|
5107
|
-
toolName:
|
|
5328
|
+
toolName: Tt,
|
|
5108
5329
|
callId: ue(i) ?? void 0,
|
|
5109
5330
|
sharePromptAllowed: r
|
|
5110
5331
|
};
|
|
5111
|
-
const o =
|
|
5332
|
+
const o = kn(i.output);
|
|
5112
5333
|
if (o)
|
|
5113
5334
|
return {
|
|
5114
5335
|
id: String(t.id ?? crypto.randomUUID()),
|
|
5115
5336
|
role: "tool",
|
|
5116
5337
|
content: "",
|
|
5117
5338
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5118
|
-
...
|
|
5339
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5119
5340
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5120
|
-
...
|
|
5341
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5121
5342
|
dataType: "scheduled_check_in",
|
|
5122
|
-
toolName:
|
|
5343
|
+
toolName: Is,
|
|
5123
5344
|
callId: ue(i) ?? void 0,
|
|
5124
5345
|
scheduledCheckInId: o.id ?? void 0,
|
|
5125
5346
|
scheduledCheckInAt: o.dueAt
|
|
5126
5347
|
};
|
|
5127
|
-
const a =
|
|
5348
|
+
const a = Ir(i.output), l = Sr(i.output);
|
|
5128
5349
|
return a ? {
|
|
5129
5350
|
id: String(t.id ?? crypto.randomUUID()),
|
|
5130
5351
|
role: "tool",
|
|
5131
5352
|
content: `Connect ${a.appName} to continue`,
|
|
5132
5353
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5133
|
-
...
|
|
5354
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5134
5355
|
...P(i) !== null ? { causalSequence: P(i) } : {},
|
|
5135
5356
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5136
|
-
...
|
|
5357
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5137
5358
|
dataType: "function_call_output",
|
|
5138
5359
|
toolName: "authenticate_pipedream_app",
|
|
5139
5360
|
callId: ue(i) ?? void 0,
|
|
@@ -5143,10 +5364,10 @@ function Ue(s, e) {
|
|
|
5143
5364
|
role: "tool",
|
|
5144
5365
|
content: "Connect WhatsApp to continue",
|
|
5145
5366
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5146
|
-
...
|
|
5367
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5147
5368
|
...P(i) !== null ? { causalSequence: P(i) } : {},
|
|
5148
5369
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5149
|
-
...
|
|
5370
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5150
5371
|
dataType: "function_call_output",
|
|
5151
5372
|
toolName: "request_personal_channel_connection",
|
|
5152
5373
|
callId: ue(i) ?? void 0,
|
|
@@ -5156,12 +5377,12 @@ function Ue(s, e) {
|
|
|
5156
5377
|
return i.type === "function_call" || i.type === "tool_call" || i.type === "web_search_call" || i.type === "mcp_call" || i.type === "tab_lifecycle_decision" ? {
|
|
5157
5378
|
id: String(t.id ?? crypto.randomUUID()),
|
|
5158
5379
|
role: "tool",
|
|
5159
|
-
content: i.type === "mcp_call" ?
|
|
5380
|
+
content: i.type === "mcp_call" ? yr(i) : wr(i),
|
|
5160
5381
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5161
|
-
...
|
|
5382
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5162
5383
|
...P(i) !== null ? { causalSequence: P(i) } : {},
|
|
5163
5384
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5164
|
-
...
|
|
5385
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5165
5386
|
dataType: String(i.type),
|
|
5166
5387
|
toolName: i.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof i.name == "string" ? i.name : void 0,
|
|
5167
5388
|
callId: ue(i) ?? void 0,
|
|
@@ -5170,12 +5391,12 @@ function Ue(s, e) {
|
|
|
5170
5391
|
} : i.type === "run_status" || i.type === "run_error" ? i.type === "run_error" && i.stage === "tool_execution" ? null : {
|
|
5171
5392
|
id: String(t.id ?? crypto.randomUUID()),
|
|
5172
5393
|
role: "system",
|
|
5173
|
-
content:
|
|
5394
|
+
content: Tr(i),
|
|
5174
5395
|
createdAt: typeof t.createdAt == "string" ? t.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
5175
|
-
...
|
|
5396
|
+
...E(i) !== null ? { displaySequence: E(i) } : {},
|
|
5176
5397
|
...P(i) !== null ? { causalSequence: P(i) } : {},
|
|
5177
5398
|
respondsToUserMessageId: O(i) ?? void 0,
|
|
5178
|
-
...
|
|
5399
|
+
...k(i) ? { runId: k(i) } : {},
|
|
5179
5400
|
dataType: String(i.type),
|
|
5180
5401
|
loading: i.steered !== !0 && i.type === "run_status" && (i.status === "running" || i.status === "retrying"),
|
|
5181
5402
|
...i.steered === !0 || i.type === "run_status" && i.status === "steered" ? { steered: !0 } : {},
|
|
@@ -5183,11 +5404,11 @@ function Ue(s, e) {
|
|
|
5183
5404
|
...typeof i.securitySettingsUrl == "string" ? { securitySettingsUrl: i.securitySettingsUrl } : {}
|
|
5184
5405
|
} : null;
|
|
5185
5406
|
}
|
|
5186
|
-
function
|
|
5407
|
+
function yr(s) {
|
|
5187
5408
|
const t = (typeof s.server_label == "string" ? s.server_label : "").replace(/^pipedream_/, "").split(/[_-]+/).filter(Boolean).map((n) => `${n.charAt(0).toUpperCase()}${n.slice(1)}`).join(" ");
|
|
5188
5409
|
return t ? `🔌 Using ${t}` : "🔌 Using connected integration";
|
|
5189
5410
|
}
|
|
5190
|
-
function
|
|
5411
|
+
function Ir(s) {
|
|
5191
5412
|
if (typeof s != "string")
|
|
5192
5413
|
return null;
|
|
5193
5414
|
try {
|
|
@@ -5204,7 +5425,7 @@ function ur(s) {
|
|
|
5204
5425
|
return null;
|
|
5205
5426
|
}
|
|
5206
5427
|
}
|
|
5207
|
-
function
|
|
5428
|
+
function Sr(s) {
|
|
5208
5429
|
if (typeof s != "string")
|
|
5209
5430
|
return null;
|
|
5210
5431
|
try {
|
|
@@ -5219,10 +5440,10 @@ function dr(s) {
|
|
|
5219
5440
|
return null;
|
|
5220
5441
|
}
|
|
5221
5442
|
}
|
|
5222
|
-
function
|
|
5443
|
+
function Tr(s) {
|
|
5223
5444
|
return s.type === "run_status" && s.status === "steered" ? "Steered" : typeof s.message == "string" && s.message.trim().length > 0 ? s.message : "";
|
|
5224
5445
|
}
|
|
5225
|
-
function
|
|
5446
|
+
function wr(s) {
|
|
5226
5447
|
if (s.type === "web_search_call") {
|
|
5227
5448
|
const e = s.action;
|
|
5228
5449
|
if (e && typeof e == "object") {
|
|
@@ -5234,9 +5455,9 @@ function pr(s) {
|
|
|
5234
5455
|
}
|
|
5235
5456
|
return "🔎 Searching the web";
|
|
5236
5457
|
}
|
|
5237
|
-
return
|
|
5458
|
+
return Ar(s);
|
|
5238
5459
|
}
|
|
5239
|
-
function
|
|
5460
|
+
function Ar(s) {
|
|
5240
5461
|
if (typeof s.summary == "string" && s.summary.trim().length > 0)
|
|
5241
5462
|
return se(s.summary);
|
|
5242
5463
|
if (typeof s.arguments == "string")
|
|
@@ -5253,7 +5474,7 @@ function se(s) {
|
|
|
5253
5474
|
const e = s.trim() || "Run tool", t = e.codePointAt(0) ?? 0;
|
|
5254
5475
|
return t >= 126976 && t <= 129791 || t >= 9728 && t <= 10175 || t >= 127462 && t <= 127487 ? e : `🛠️ ${e}`;
|
|
5255
5476
|
}
|
|
5256
|
-
function
|
|
5477
|
+
function Mr(s) {
|
|
5257
5478
|
if (s == null)
|
|
5258
5479
|
return s;
|
|
5259
5480
|
if (typeof s != "object")
|
|
@@ -5275,10 +5496,10 @@ function ue(s) {
|
|
|
5275
5496
|
function P(s) {
|
|
5276
5497
|
return typeof s.causalSequence == "number" && Number.isSafeInteger(s.causalSequence) ? s.causalSequence : null;
|
|
5277
5498
|
}
|
|
5278
|
-
function
|
|
5499
|
+
function E(s) {
|
|
5279
5500
|
return typeof s.displaySequence == "number" && Number.isSafeInteger(s.displaySequence) ? s.displaySequence : null;
|
|
5280
5501
|
}
|
|
5281
|
-
function
|
|
5502
|
+
function es(s) {
|
|
5282
5503
|
return typeof s == "string" ? s : Array.isArray(s) ? s.map((e) => {
|
|
5283
5504
|
if (!e || typeof e != "object")
|
|
5284
5505
|
return "";
|
|
@@ -5287,13 +5508,13 @@ function Jt(s) {
|
|
|
5287
5508
|
}).filter(Boolean).join("") : "";
|
|
5288
5509
|
}
|
|
5289
5510
|
function de(s, e) {
|
|
5290
|
-
const t =
|
|
5511
|
+
const t = vs(
|
|
5291
5512
|
s,
|
|
5292
|
-
|
|
5293
|
-
), n =
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5513
|
+
bt(s, e)
|
|
5514
|
+
), n = kr(
|
|
5515
|
+
Rr(
|
|
5516
|
+
Pr(
|
|
5517
|
+
br(s, e),
|
|
5297
5518
|
e
|
|
5298
5519
|
),
|
|
5299
5520
|
t
|
|
@@ -5301,13 +5522,13 @@ function de(s, e) {
|
|
|
5301
5522
|
t
|
|
5302
5523
|
), i = n.findIndex((o) => o.id === t.id);
|
|
5303
5524
|
if (i === -1)
|
|
5304
|
-
return
|
|
5525
|
+
return pt(
|
|
5305
5526
|
[...n, t]
|
|
5306
5527
|
);
|
|
5307
5528
|
const r = [...n];
|
|
5308
|
-
return r[i] = t,
|
|
5529
|
+
return r[i] = t, pt(r);
|
|
5309
5530
|
}
|
|
5310
|
-
function
|
|
5531
|
+
function bt(s, e, t = !0) {
|
|
5311
5532
|
const n = s.find(
|
|
5312
5533
|
(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)
|
|
5313
5534
|
);
|
|
@@ -5318,7 +5539,7 @@ function Mt(s, e, t = !0) {
|
|
|
5318
5539
|
const i = s.flatMap((r) => (e.respondsToUserMessageId !== void 0 ? r.respondsToUserMessageId === e.respondsToUserMessageId : e.runId !== void 0 && r.respondsToUserMessageId === void 0 && r.runId === e.runId) && r.displaySequence !== void 0 ? [r.displaySequence] : []);
|
|
5319
5540
|
return e.displaySequence = (i.length > 0 ? Math.max(...i) : 0) + 1, e;
|
|
5320
5541
|
}
|
|
5321
|
-
function
|
|
5542
|
+
function br(s, e) {
|
|
5322
5543
|
const t = e.proactiveSuggestionClientMessageId;
|
|
5323
5544
|
if (!t)
|
|
5324
5545
|
return s;
|
|
@@ -5328,7 +5549,7 @@ function mr(s, e) {
|
|
|
5328
5549
|
const r = [...s];
|
|
5329
5550
|
return r[i] = e, r;
|
|
5330
5551
|
}
|
|
5331
|
-
function
|
|
5552
|
+
function Rr(s, e) {
|
|
5332
5553
|
const t = e.assistantDraftItemId;
|
|
5333
5554
|
return t ? s.map(
|
|
5334
5555
|
(n) => n.dataType === "assistant_draft" && n.id === t ? e : n
|
|
@@ -5337,7 +5558,7 @@ function yr(s, e) {
|
|
|
5337
5558
|
function Me(s, e, t) {
|
|
5338
5559
|
return e !== null ? s.respondsToUserMessageId === e : t !== null && s.runId === t;
|
|
5339
5560
|
}
|
|
5340
|
-
function
|
|
5561
|
+
function ts(s, e, t, n) {
|
|
5341
5562
|
if (t === null) return s;
|
|
5342
5563
|
let i = -1;
|
|
5343
5564
|
for (let o = s.length - 1; o >= 0; o -= 1) {
|
|
@@ -5354,7 +5575,7 @@ function Yt(s, e, t, n) {
|
|
|
5354
5575
|
respondsToUserMessageId: t
|
|
5355
5576
|
}, r;
|
|
5356
5577
|
}
|
|
5357
|
-
function
|
|
5578
|
+
function ss(s, e) {
|
|
5358
5579
|
const t = s.findIndex(
|
|
5359
5580
|
(i) => !i.id.startsWith("transient-activity:") && i.callId === e.callId
|
|
5360
5581
|
);
|
|
@@ -5371,12 +5592,12 @@ function Zt(s, e) {
|
|
|
5371
5592
|
...n[t].runId ? {} : { runId: e.runId }
|
|
5372
5593
|
}, n;
|
|
5373
5594
|
}
|
|
5374
|
-
function
|
|
5595
|
+
function ns(s, e, t) {
|
|
5375
5596
|
let n = !1;
|
|
5376
5597
|
const i = s.map((r) => r.callId !== e || r.loading === t ? r : (n = !0, { ...r, loading: t }));
|
|
5377
5598
|
return n ? i : s;
|
|
5378
5599
|
}
|
|
5379
|
-
function
|
|
5600
|
+
function is(s) {
|
|
5380
5601
|
if (s.hiddenFromTranscript === !0)
|
|
5381
5602
|
return null;
|
|
5382
5603
|
const e = typeof s.callId == "string" ? s.callId : null, t = typeof s.toolName == "string" ? s.toolName : null;
|
|
@@ -5396,7 +5617,7 @@ function ts(s) {
|
|
|
5396
5617
|
loading: !0
|
|
5397
5618
|
};
|
|
5398
5619
|
}
|
|
5399
|
-
function
|
|
5620
|
+
function kr(s, e) {
|
|
5400
5621
|
if (e.id.startsWith("transient-activity:"))
|
|
5401
5622
|
return s;
|
|
5402
5623
|
const t = e.toolName === "tab_lifecycle";
|
|
@@ -5405,30 +5626,30 @@ function Ir(s, e) {
|
|
|
5405
5626
|
const n = (r) => r.id === `transient-activity:${e.callId}` && r.callId === e.callId || t && r.id.startsWith("transient-activity:") && r.toolName === "browser_tabs" && !!r.runId && r.runId === e.runId, i = s.findIndex(n);
|
|
5406
5627
|
return i === -1 ? s : s.flatMap((r, o) => n(r) ? o === i ? [e] : [] : r.id === e.id ? [] : [r]);
|
|
5407
5628
|
}
|
|
5408
|
-
function
|
|
5629
|
+
function ct(s, e) {
|
|
5409
5630
|
const t = [];
|
|
5410
5631
|
for (const n of e) {
|
|
5411
5632
|
const i = [...s, ...t];
|
|
5412
5633
|
t.push(
|
|
5413
|
-
|
|
5634
|
+
vs(
|
|
5414
5635
|
i,
|
|
5415
|
-
|
|
5636
|
+
bt(i, n, !1)
|
|
5416
5637
|
)
|
|
5417
5638
|
);
|
|
5418
5639
|
}
|
|
5419
|
-
return
|
|
5640
|
+
return mn(
|
|
5420
5641
|
s,
|
|
5421
5642
|
t,
|
|
5422
|
-
|
|
5643
|
+
ut
|
|
5423
5644
|
);
|
|
5424
5645
|
}
|
|
5425
|
-
function
|
|
5646
|
+
function Er(s, e) {
|
|
5426
5647
|
const t = new Map(s.map((r) => [r.id, r])), n = e.map(
|
|
5427
|
-
(r) =>
|
|
5648
|
+
(r) => bt(s, r, !1)
|
|
5428
5649
|
);
|
|
5429
5650
|
for (const r of n)
|
|
5430
5651
|
t.set(r.id, r);
|
|
5431
|
-
const i =
|
|
5652
|
+
const i = ct(
|
|
5432
5653
|
s,
|
|
5433
5654
|
[...t.values()]
|
|
5434
5655
|
);
|
|
@@ -5443,8 +5664,8 @@ function Sr(s, e) {
|
|
|
5443
5664
|
}
|
|
5444
5665
|
return i;
|
|
5445
5666
|
}
|
|
5446
|
-
function
|
|
5447
|
-
const e =
|
|
5667
|
+
function ut(s) {
|
|
5668
|
+
const e = X(s) ?? void 0, t = s.assistantDraftItemId, n = s.dataType === "function_call_output" || s.dataType === "scheduled_check_in", i = [
|
|
5448
5669
|
// Output-backed cards and their visible calls are separate durable rows. A distinct key keeps activity hydration
|
|
5449
5670
|
// from substituting the call for its output and then appending a duplicate output at the end of the timeline.
|
|
5450
5671
|
...s.callId ? [`${n ? "call-output" : "call"}:${s.callId}`] : [],
|
|
@@ -5463,49 +5684,49 @@ function ct(s) {
|
|
|
5463
5684
|
isTransient: s.id.startsWith("transient-activity:") || s.dataType === "assistant_draft"
|
|
5464
5685
|
};
|
|
5465
5686
|
}
|
|
5466
|
-
function
|
|
5687
|
+
function vs(s, e) {
|
|
5467
5688
|
if (e.role !== "user" || !e.attachments?.length)
|
|
5468
5689
|
return e;
|
|
5469
5690
|
const t = s.find(
|
|
5470
|
-
(o) => o.role === "user" && (o.id === e.id || He(o) &&
|
|
5691
|
+
(o) => o.role === "user" && (o.id === e.id || He(o) && Us(o, e))
|
|
5471
5692
|
);
|
|
5472
5693
|
if (!t?.attachments?.length)
|
|
5473
5694
|
return e;
|
|
5474
5695
|
const n = e.attachments.map((o) => {
|
|
5475
|
-
const a =
|
|
5476
|
-
return a ?
|
|
5477
|
-
}), i = { ...e, attachments: n }, r =
|
|
5696
|
+
const a = Cr(t.attachments ?? [], o);
|
|
5697
|
+
return a ? _r(o, a) : o;
|
|
5698
|
+
}), i = { ...e, attachments: n }, r = X(e);
|
|
5478
5699
|
return r && Object.defineProperty(i, "clientMessageId", {
|
|
5479
5700
|
value: r,
|
|
5480
5701
|
enumerable: !1
|
|
5481
5702
|
}), i;
|
|
5482
5703
|
}
|
|
5483
|
-
function
|
|
5704
|
+
function Cr(s, e) {
|
|
5484
5705
|
return e.id ? s.find((t) => t.id === e.id) ?? null : null;
|
|
5485
5706
|
}
|
|
5486
|
-
function
|
|
5707
|
+
function _r(s, e) {
|
|
5487
5708
|
const { previewUrl: t } = e;
|
|
5488
5709
|
return t ? { ...s, previewUrl: t } : s;
|
|
5489
5710
|
}
|
|
5490
|
-
function
|
|
5711
|
+
function Pr(s, e) {
|
|
5491
5712
|
if (e.role !== "user")
|
|
5492
5713
|
return s;
|
|
5493
5714
|
const t = s.findIndex(
|
|
5494
|
-
(i) => He(i) &&
|
|
5715
|
+
(i) => He(i) && Us(i, e)
|
|
5495
5716
|
);
|
|
5496
5717
|
if (t === -1)
|
|
5497
5718
|
return s;
|
|
5498
5719
|
const n = [...s];
|
|
5499
5720
|
return n.splice(t, 1), n;
|
|
5500
5721
|
}
|
|
5501
|
-
function
|
|
5502
|
-
const t =
|
|
5722
|
+
function Us(s, e) {
|
|
5723
|
+
const t = X(s), n = X(e);
|
|
5503
5724
|
return t && n ? t === n : s.content === e.content;
|
|
5504
5725
|
}
|
|
5505
5726
|
function He(s) {
|
|
5506
5727
|
return s.role === "user" && (s.id.startsWith("local-") || s.id.startsWith("optimistic-user-message:"));
|
|
5507
5728
|
}
|
|
5508
|
-
function
|
|
5729
|
+
function X(s) {
|
|
5509
5730
|
const e = s.clientMessageId;
|
|
5510
5731
|
if (e)
|
|
5511
5732
|
return e;
|
|
@@ -5514,8 +5735,8 @@ function J(s) {
|
|
|
5514
5735
|
);
|
|
5515
5736
|
return n ? s.id.slice(n.length) : null;
|
|
5516
5737
|
}
|
|
5517
|
-
function
|
|
5518
|
-
const e =
|
|
5738
|
+
function rs(s) {
|
|
5739
|
+
const e = Ds(s);
|
|
5519
5740
|
if (e === null)
|
|
5520
5741
|
return !1;
|
|
5521
5742
|
const t = s[e].id;
|
|
@@ -5538,10 +5759,10 @@ function ss(s) {
|
|
|
5538
5759
|
}
|
|
5539
5760
|
return !1;
|
|
5540
5761
|
}
|
|
5541
|
-
function
|
|
5762
|
+
function vr(s, e, t) {
|
|
5542
5763
|
const n = new Set(
|
|
5543
5764
|
s.filter(
|
|
5544
|
-
(i) => i.role === "user" && e !== null &&
|
|
5765
|
+
(i) => i.role === "user" && e !== null && X(i) === e
|
|
5545
5766
|
).map((i) => i.id)
|
|
5546
5767
|
);
|
|
5547
5768
|
return s.some((i, r) => {
|
|
@@ -5552,14 +5773,14 @@ function Mr(s, e, t) {
|
|
|
5552
5773
|
if (t && i.runId === t) {
|
|
5553
5774
|
if (n.size === 0)
|
|
5554
5775
|
return !0;
|
|
5555
|
-
const o =
|
|
5776
|
+
const o = qs(s, r);
|
|
5556
5777
|
return !i.respondsToUserMessageId && o !== null && n.has(o);
|
|
5557
5778
|
}
|
|
5558
5779
|
return !1;
|
|
5559
5780
|
});
|
|
5560
5781
|
}
|
|
5561
|
-
function
|
|
5562
|
-
const e =
|
|
5782
|
+
function Ur(s) {
|
|
5783
|
+
const e = Ds(s);
|
|
5563
5784
|
if (e === null)
|
|
5564
5785
|
return s.some(W);
|
|
5565
5786
|
const t = s[e].id;
|
|
@@ -5567,7 +5788,7 @@ function br(s) {
|
|
|
5567
5788
|
(n) => n.respondsToUserMessageId === t && W(n)
|
|
5568
5789
|
) : s.slice(e + 1).some(W);
|
|
5569
5790
|
}
|
|
5570
|
-
function
|
|
5791
|
+
function Ds(s) {
|
|
5571
5792
|
for (let e = s.length - 1; e >= 0; e -= 1)
|
|
5572
5793
|
if (s[e].role === "user" && !He(s[e]))
|
|
5573
5794
|
return e;
|
|
@@ -5590,7 +5811,7 @@ function ie(s) {
|
|
|
5590
5811
|
}
|
|
5591
5812
|
return null;
|
|
5592
5813
|
}
|
|
5593
|
-
function
|
|
5814
|
+
function Dr(s) {
|
|
5594
5815
|
const e = ie(s);
|
|
5595
5816
|
if (e === null)
|
|
5596
5817
|
return null;
|
|
@@ -5609,10 +5830,10 @@ function C(s) {
|
|
|
5609
5830
|
function pe(s) {
|
|
5610
5831
|
return s?.retryable !== !0 ? !1 : s.type === "run_error" ? !0 : s.type === "run_status" && s.status === "interrupted";
|
|
5611
5832
|
}
|
|
5612
|
-
function
|
|
5833
|
+
function qr(s) {
|
|
5613
5834
|
return s?.type === "run_status" && s.status === "interrupted" && s.reason === "backend_restart";
|
|
5614
5835
|
}
|
|
5615
|
-
function
|
|
5836
|
+
function Or(s, e) {
|
|
5616
5837
|
const t = ie(e);
|
|
5617
5838
|
if (t === null)
|
|
5618
5839
|
return !1;
|
|
@@ -5624,7 +5845,7 @@ function kr(s, e) {
|
|
|
5624
5845
|
(o) => o.respondsToUserMessageId === i && De(o)
|
|
5625
5846
|
) : s.slice(r + 1).some(De);
|
|
5626
5847
|
}
|
|
5627
|
-
function
|
|
5848
|
+
function dt(s) {
|
|
5628
5849
|
const e = ie(s);
|
|
5629
5850
|
if (e === null)
|
|
5630
5851
|
return null;
|
|
@@ -5637,7 +5858,7 @@ function ut(s) {
|
|
|
5637
5858
|
const i = n.clientMessageId;
|
|
5638
5859
|
return typeof i == "string" ? i : null;
|
|
5639
5860
|
}
|
|
5640
|
-
function
|
|
5861
|
+
function xr(s) {
|
|
5641
5862
|
const e = ie(s);
|
|
5642
5863
|
if (e === null)
|
|
5643
5864
|
return null;
|
|
@@ -5652,13 +5873,13 @@ function Cr(s) {
|
|
|
5652
5873
|
if (r.type === "message" && r.role === "assistant")
|
|
5653
5874
|
return null;
|
|
5654
5875
|
if (r.type === "run_error")
|
|
5655
|
-
return r.retryable !== !0 ? null :
|
|
5876
|
+
return r.retryable !== !0 ? null : ht(s, r) ?? dt(s);
|
|
5656
5877
|
if (r.type === "run_status")
|
|
5657
|
-
return r.status === "interrupted" && r.retryable === !0 ?
|
|
5878
|
+
return r.status === "interrupted" && r.retryable === !0 ? ht(s, r) ?? dt(s) : null;
|
|
5658
5879
|
}
|
|
5659
5880
|
return null;
|
|
5660
5881
|
}
|
|
5661
|
-
function
|
|
5882
|
+
function ht(s, e) {
|
|
5662
5883
|
if (typeof e.clientMessageId == "string")
|
|
5663
5884
|
return e.clientMessageId;
|
|
5664
5885
|
const t = O(e);
|
|
@@ -5667,16 +5888,16 @@ function dt(s, e) {
|
|
|
5667
5888
|
const n = s.find((r) => A(r, "id") === t), i = C(n);
|
|
5668
5889
|
return i?.type === "message" && i.role === "user" && typeof i.clientMessageId == "string" ? i.clientMessageId : null;
|
|
5669
5890
|
}
|
|
5670
|
-
function
|
|
5671
|
-
if (!e || !
|
|
5891
|
+
function os(s, e, t, n, i, r) {
|
|
5892
|
+
if (!e || !Nr(s))
|
|
5672
5893
|
return !1;
|
|
5673
5894
|
const o = s;
|
|
5674
5895
|
if (pe(o) || t !== null && typeof o.id == "string" && o.id !== t)
|
|
5675
5896
|
return !1;
|
|
5676
5897
|
const a = O(o);
|
|
5677
|
-
return n !== null ? a !== null ? a === n : i !== null &&
|
|
5898
|
+
return n !== null ? a !== null ? a === n : i !== null && k(o) === i && r === n : i === null || k(o) === i;
|
|
5678
5899
|
}
|
|
5679
|
-
function
|
|
5900
|
+
function Lr(s, e) {
|
|
5680
5901
|
for (let t = e - 1; t >= 0; t -= 1) {
|
|
5681
5902
|
const n = C(s[t]);
|
|
5682
5903
|
if (n?.type === "message" && n.role === "user")
|
|
@@ -5684,13 +5905,13 @@ function _r(s, e) {
|
|
|
5684
5905
|
}
|
|
5685
5906
|
return null;
|
|
5686
5907
|
}
|
|
5687
|
-
function
|
|
5908
|
+
function qs(s, e) {
|
|
5688
5909
|
for (let t = e - 1; t >= 0; t -= 1)
|
|
5689
5910
|
if (s[t].role === "user")
|
|
5690
5911
|
return s[t].id;
|
|
5691
5912
|
return null;
|
|
5692
5913
|
}
|
|
5693
|
-
function
|
|
5914
|
+
function Nr(s) {
|
|
5694
5915
|
if (!s || typeof s != "object")
|
|
5695
5916
|
return !1;
|
|
5696
5917
|
const e = s;
|
|
@@ -5699,42 +5920,42 @@ function Pr(s) {
|
|
|
5699
5920
|
function W(s) {
|
|
5700
5921
|
return s.role === "assistant" && s.phase !== "commentary";
|
|
5701
5922
|
}
|
|
5702
|
-
function
|
|
5923
|
+
function Hr(s) {
|
|
5703
5924
|
if (!s || typeof s != "object")
|
|
5704
5925
|
return !1;
|
|
5705
5926
|
const e = s;
|
|
5706
5927
|
return e.type === "message" && e.role === "user" ? !1 : e.type === "message" || e.type === "function_call" || e.type === "function_call_output" || e.type === "run_error" || e.type === "run_status";
|
|
5707
5928
|
}
|
|
5708
|
-
function
|
|
5709
|
-
return s.filter((e, t) => G(e) ? !
|
|
5929
|
+
function pt(s) {
|
|
5930
|
+
return s.filter((e, t) => G(e) ? !Yr(s, t) && !Os(s, t) && !Jr(s, t) && !Xr(s, t) : Br(e) ? e.retryable === !0 && Qr(s, t) ? !1 : !Vr(s, t) : !0);
|
|
5710
5931
|
}
|
|
5711
|
-
function
|
|
5932
|
+
function Br(s) {
|
|
5712
5933
|
return s.role === "system" && (s.dataType === "run_error" || s.dataType === "run_status" && s.steered !== !0);
|
|
5713
5934
|
}
|
|
5714
5935
|
function G(s) {
|
|
5715
5936
|
return s.role === "system" && s.dataType === "run_status" && s.loading === !0;
|
|
5716
5937
|
}
|
|
5717
|
-
function
|
|
5938
|
+
function gt(s) {
|
|
5718
5939
|
return s.steered !== !0 && (s.dataType === "assistant_draft" || s.loading === !0);
|
|
5719
5940
|
}
|
|
5720
|
-
function
|
|
5721
|
-
return s.some(
|
|
5941
|
+
function Fr(s) {
|
|
5942
|
+
return s.some(gt);
|
|
5722
5943
|
}
|
|
5723
|
-
function
|
|
5944
|
+
function as(s, e) {
|
|
5724
5945
|
return (s.retryable === !0 || s.code === "transient_model_error") && s.code !== "run_recovery_exhausted" && e !== null && typeof s.clientMessageId == "string";
|
|
5725
5946
|
}
|
|
5726
|
-
function
|
|
5727
|
-
const t = [...s].reverse().find(
|
|
5728
|
-
return s.flatMap((r) => (n ? r.respondsToUserMessageId === n || !r.respondsToUserMessageId && i !== null && r.runId === i : i ? r.runId === i :
|
|
5947
|
+
function Wr(s, e) {
|
|
5948
|
+
const t = [...s].reverse().find(gt), n = typeof e.respondsToUserMessageId == "string" ? e.respondsToUserMessageId : t?.respondsToUserMessageId ?? null, i = typeof e.runId == "string" ? e.runId : t?.runId ?? null;
|
|
5949
|
+
return s.flatMap((r) => (n ? r.respondsToUserMessageId === n || !r.respondsToUserMessageId && i !== null && r.runId === i : i ? r.runId === i : gt(r)) ? r.dataType === "assistant_draft" || G(r) ? [] : r.loading === !0 ? [{ ...r, loading: !1 }] : [r] : [r]);
|
|
5729
5950
|
}
|
|
5730
|
-
function
|
|
5951
|
+
function $r(s, e, t, n) {
|
|
5731
5952
|
const i = s.findIndex(
|
|
5732
|
-
(l, c) => G(l) && !
|
|
5953
|
+
(l, c) => G(l) && !Os(s, c)
|
|
5733
5954
|
), r = i === -1 ? null : s[i], o = e ?? r?.respondsToUserMessageId ?? null, a = o ? s.find(
|
|
5734
5955
|
(l) => l.role === "user" && l.id === o
|
|
5735
5956
|
) : null;
|
|
5736
5957
|
return {
|
|
5737
|
-
clientMessageId: a ?
|
|
5958
|
+
clientMessageId: a ? X(a) : o ? null : n,
|
|
5738
5959
|
respondsToUserMessageId: o,
|
|
5739
5960
|
runId: t ?? r?.runId ?? null
|
|
5740
5961
|
};
|
|
@@ -5742,29 +5963,29 @@ function Or(s, e, t, n) {
|
|
|
5742
5963
|
function _e(s) {
|
|
5743
5964
|
return s?.type === "run_status" && s.status === "stopped";
|
|
5744
5965
|
}
|
|
5745
|
-
function
|
|
5966
|
+
function jr(s, e) {
|
|
5746
5967
|
return W(e) ? "completed" : _e(s) ? "stopped" : !pe(s) && (s?.type === "run_error" || s?.type === "run_status" && (s.status === "failed" || s.status === "interrupted")) ? "failed" : null;
|
|
5747
5968
|
}
|
|
5748
|
-
function
|
|
5969
|
+
function ls(s, e, t) {
|
|
5749
5970
|
const n = new Set(
|
|
5750
5971
|
s.filter(
|
|
5751
|
-
(i) => i.role === "user" && e !== null &&
|
|
5972
|
+
(i) => i.role === "user" && e !== null && X(i) === e
|
|
5752
5973
|
).map((i) => i.id)
|
|
5753
5974
|
);
|
|
5754
5975
|
return s.filter(
|
|
5755
5976
|
(i) => !G(i) || (n.size > 0 ? !i.respondsToUserMessageId || !n.has(i.respondsToUserMessageId) : !t || i.runId !== t)
|
|
5756
5977
|
);
|
|
5757
5978
|
}
|
|
5758
|
-
function
|
|
5979
|
+
function Os(s, e) {
|
|
5759
5980
|
return s.some(
|
|
5760
|
-
(t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) &&
|
|
5981
|
+
(t, n) => n !== e && t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0 && t.steered !== !0) && zr(
|
|
5761
5982
|
s,
|
|
5762
5983
|
e,
|
|
5763
5984
|
n
|
|
5764
5985
|
)
|
|
5765
5986
|
);
|
|
5766
5987
|
}
|
|
5767
|
-
function
|
|
5988
|
+
function zr(s, e, t) {
|
|
5768
5989
|
const n = s[e], i = s[t];
|
|
5769
5990
|
if (ge(n, i))
|
|
5770
5991
|
return !0;
|
|
@@ -5775,20 +5996,20 @@ function Lr(s, e, t) {
|
|
|
5775
5996
|
return s[r].id === n.respondsToUserMessageId;
|
|
5776
5997
|
return !1;
|
|
5777
5998
|
}
|
|
5778
|
-
function
|
|
5999
|
+
function cs(s, e, t, n) {
|
|
5779
6000
|
const i = (t && t !== e ? t : null) ?? [...s].reverse().find(
|
|
5780
|
-
(l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e &&
|
|
6001
|
+
(l) => l.respondsToUserMessageId !== void 0 && l.respondsToUserMessageId !== e && us(l) && !Gr(
|
|
5781
6002
|
s,
|
|
5782
6003
|
l.respondsToUserMessageId
|
|
5783
6004
|
)
|
|
5784
|
-
)?.respondsToUserMessageId ??
|
|
6005
|
+
)?.respondsToUserMessageId ?? Kr(
|
|
5785
6006
|
s,
|
|
5786
6007
|
e
|
|
5787
6008
|
);
|
|
5788
6009
|
if (!i)
|
|
5789
6010
|
return s;
|
|
5790
6011
|
let r = !1;
|
|
5791
|
-
const o = s.map((l) => l.respondsToUserMessageId !== i || !
|
|
6012
|
+
const o = s.map((l) => l.respondsToUserMessageId !== i || !us(l) ? l : (r = !0, { ...l, steered: !0 }));
|
|
5792
6013
|
if (r)
|
|
5793
6014
|
return o;
|
|
5794
6015
|
const a = s.find(
|
|
@@ -5810,7 +6031,7 @@ function os(s, e, t, n) {
|
|
|
5810
6031
|
}
|
|
5811
6032
|
];
|
|
5812
6033
|
}
|
|
5813
|
-
function
|
|
6034
|
+
function Kr(s, e) {
|
|
5814
6035
|
const t = s.findIndex(
|
|
5815
6036
|
(n) => n.role === "user" && n.id === e
|
|
5816
6037
|
);
|
|
@@ -5821,15 +6042,15 @@ function Nr(s, e) {
|
|
|
5821
6042
|
return s[n].id;
|
|
5822
6043
|
return null;
|
|
5823
6044
|
}
|
|
5824
|
-
function
|
|
6045
|
+
function us(s) {
|
|
5825
6046
|
return s.role === "tool" || G(s) ? !0 : s.role === "assistant" && s.phase === "commentary";
|
|
5826
6047
|
}
|
|
5827
|
-
function
|
|
6048
|
+
function Gr(s, e) {
|
|
5828
6049
|
return s.some(
|
|
5829
6050
|
(t) => t.respondsToUserMessageId === e && (W(t) || t.role === "system" && (t.dataType === "run_error" || t.dataType === "run_status" && t.loading !== !0))
|
|
5830
6051
|
);
|
|
5831
6052
|
}
|
|
5832
|
-
function
|
|
6053
|
+
function Vr(s, e) {
|
|
5833
6054
|
const t = s[e];
|
|
5834
6055
|
for (let n = e + 1; n < s.length; n += 1) {
|
|
5835
6056
|
const i = s[n];
|
|
@@ -5838,7 +6059,7 @@ function Br(s, e) {
|
|
|
5838
6059
|
}
|
|
5839
6060
|
return !1;
|
|
5840
6061
|
}
|
|
5841
|
-
function
|
|
6062
|
+
function Qr(s, e) {
|
|
5842
6063
|
const t = s[e];
|
|
5843
6064
|
if (!t.respondsToUserMessageId)
|
|
5844
6065
|
return !1;
|
|
@@ -5851,19 +6072,19 @@ function Fr(s, e) {
|
|
|
5851
6072
|
}
|
|
5852
6073
|
return !1;
|
|
5853
6074
|
}
|
|
5854
|
-
function
|
|
6075
|
+
function Jr(s, e) {
|
|
5855
6076
|
const t = s[e];
|
|
5856
6077
|
return s.some(
|
|
5857
6078
|
(n, i) => i !== e && n.role === "assistant" && ge(t, n)
|
|
5858
6079
|
);
|
|
5859
6080
|
}
|
|
5860
|
-
function
|
|
6081
|
+
function Xr(s, e) {
|
|
5861
6082
|
const t = s[e];
|
|
5862
6083
|
return s.some(
|
|
5863
6084
|
(n, i) => i !== e && n.role === "tool" && ge(t, n)
|
|
5864
6085
|
);
|
|
5865
6086
|
}
|
|
5866
|
-
function
|
|
6087
|
+
function Yr(s, e) {
|
|
5867
6088
|
const t = s[e];
|
|
5868
6089
|
for (let n = e + 1; n < s.length; n += 1)
|
|
5869
6090
|
if (G(s[n]) && ge(t, s[n]))
|
|
@@ -5876,15 +6097,15 @@ function ge(s, e) {
|
|
|
5876
6097
|
function A(s, e) {
|
|
5877
6098
|
return s && typeof s == "object" && typeof s[e] == "string" ? s[e] : null;
|
|
5878
6099
|
}
|
|
5879
|
-
function
|
|
6100
|
+
function Zr(s, e) {
|
|
5880
6101
|
try {
|
|
5881
|
-
const t = window.localStorage.getItem(`${
|
|
6102
|
+
const t = window.localStorage.getItem(`${ks}${s}`);
|
|
5882
6103
|
if (!t)
|
|
5883
6104
|
return null;
|
|
5884
6105
|
const n = JSON.parse(t), i = typeof n.sessionId == "string" ? n.sessionId : null;
|
|
5885
6106
|
if (e !== void 0 && i !== e)
|
|
5886
6107
|
return null;
|
|
5887
|
-
const r = Array.isArray(n.messages) ? n.messages.map(
|
|
6108
|
+
const r = Array.isArray(n.messages) ? n.messages.map(uo).filter((o) => !!o) : [];
|
|
5888
6109
|
return {
|
|
5889
6110
|
sessionId: i,
|
|
5890
6111
|
messages: r
|
|
@@ -5893,51 +6114,51 @@ function zr(s, e) {
|
|
|
5893
6114
|
return null;
|
|
5894
6115
|
}
|
|
5895
6116
|
}
|
|
5896
|
-
function
|
|
6117
|
+
function ft(s) {
|
|
5897
6118
|
return s.role === "user" || s.role === "assistant" || // Live activity is part of the readable conversation cache. Keeping it across host navigation prevents a
|
|
5898
6119
|
// running tool or commentary history from disappearing while authoritative hydration is still in flight.
|
|
5899
6120
|
s.role === "tool" || s.dataType === "run_status" || s.dataType === "run_error";
|
|
5900
6121
|
}
|
|
5901
|
-
function
|
|
6122
|
+
function eo(s, e) {
|
|
5902
6123
|
try {
|
|
5903
6124
|
window.localStorage.setItem(
|
|
5904
|
-
`${
|
|
6125
|
+
`${ks}${s}`,
|
|
5905
6126
|
JSON.stringify({
|
|
5906
6127
|
sessionId: e.sessionId,
|
|
5907
|
-
messages: e.messages.filter(
|
|
6128
|
+
messages: e.messages.filter(ft).slice(-wi).map(ho)
|
|
5908
6129
|
})
|
|
5909
6130
|
);
|
|
5910
6131
|
} catch {
|
|
5911
6132
|
return;
|
|
5912
6133
|
}
|
|
5913
6134
|
}
|
|
5914
|
-
function
|
|
6135
|
+
function to(s) {
|
|
5915
6136
|
try {
|
|
5916
|
-
const e = window.localStorage.getItem(`${
|
|
6137
|
+
const e = window.localStorage.getItem(`${lt}${s}`);
|
|
5917
6138
|
if (!e)
|
|
5918
6139
|
return [];
|
|
5919
6140
|
const t = JSON.parse(e);
|
|
5920
|
-
return Array.isArray(t) ? t.filter(
|
|
6141
|
+
return Array.isArray(t) ? t.filter(Rt) : [];
|
|
5921
6142
|
} catch {
|
|
5922
6143
|
return [];
|
|
5923
6144
|
}
|
|
5924
6145
|
}
|
|
5925
|
-
function
|
|
6146
|
+
function Q(s, e) {
|
|
5926
6147
|
try {
|
|
5927
|
-
const t = e.filter(
|
|
6148
|
+
const t = e.filter(Rt);
|
|
5928
6149
|
if (t.length === 0) {
|
|
5929
|
-
window.localStorage.removeItem(`${
|
|
6150
|
+
window.localStorage.removeItem(`${lt}${s}`);
|
|
5930
6151
|
return;
|
|
5931
6152
|
}
|
|
5932
6153
|
window.localStorage.setItem(
|
|
5933
|
-
`${
|
|
6154
|
+
`${lt}${s}`,
|
|
5934
6155
|
JSON.stringify(t.slice(-25))
|
|
5935
6156
|
);
|
|
5936
6157
|
} catch {
|
|
5937
6158
|
return;
|
|
5938
6159
|
}
|
|
5939
6160
|
}
|
|
5940
|
-
function
|
|
6161
|
+
function xs(s, e) {
|
|
5941
6162
|
try {
|
|
5942
6163
|
const t = `${Le}${s}`, n = location.href, i = location.origin, r = Array.from(e, (o) => ({
|
|
5943
6164
|
...o,
|
|
@@ -5953,28 +6174,28 @@ function Ds(s, e) {
|
|
|
5953
6174
|
} catch {
|
|
5954
6175
|
}
|
|
5955
6176
|
}
|
|
5956
|
-
function
|
|
6177
|
+
function ds(s, e) {
|
|
5957
6178
|
try {
|
|
5958
6179
|
if (window.sessionStorage.getItem(`${Le}${s}`) === null)
|
|
5959
6180
|
return;
|
|
5960
6181
|
} catch {
|
|
5961
6182
|
return;
|
|
5962
6183
|
}
|
|
5963
|
-
|
|
6184
|
+
xs(s, e);
|
|
5964
6185
|
}
|
|
5965
|
-
function
|
|
6186
|
+
function so(s) {
|
|
5966
6187
|
try {
|
|
5967
6188
|
const e = `${Le}${s}`, t = window.sessionStorage.getItem(e);
|
|
5968
6189
|
if (window.sessionStorage.removeItem(e), !t)
|
|
5969
6190
|
return [];
|
|
5970
6191
|
const n = JSON.parse(t);
|
|
5971
|
-
return Array.isArray(n) ? n.flatMap((i) =>
|
|
6192
|
+
return Array.isArray(n) ? n.flatMap((i) => io(i) ? [{
|
|
5972
6193
|
...i.event,
|
|
5973
6194
|
page: _(),
|
|
5974
6195
|
rawOutput: {
|
|
5975
6196
|
pageContextRestarted: !0,
|
|
5976
6197
|
outcome: "unknown",
|
|
5977
|
-
message:
|
|
6198
|
+
message: no(location.href),
|
|
5978
6199
|
currentUrl: location.href,
|
|
5979
6200
|
console: [],
|
|
5980
6201
|
metadata: {
|
|
@@ -5991,17 +6212,17 @@ function Qr(s) {
|
|
|
5991
6212
|
return [];
|
|
5992
6213
|
}
|
|
5993
6214
|
}
|
|
5994
|
-
function
|
|
6215
|
+
function no(s) {
|
|
5995
6216
|
return `The page context restarted. This is expected when the action included page navigation. Otherwise, it's unknown whether the action completed.
|
|
5996
6217
|
Current URL: ${s}`;
|
|
5997
6218
|
}
|
|
5998
|
-
function
|
|
6219
|
+
function io(s) {
|
|
5999
6220
|
if (!s || typeof s != "object")
|
|
6000
6221
|
return !1;
|
|
6001
6222
|
const e = s, t = e.event;
|
|
6002
|
-
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" &&
|
|
6223
|
+
return typeof e.startedAtMs == "number" && typeof e.startedAtUrl == "string" && e.startedAtOrigin === location.origin && e.unloadOrigin === location.origin && typeof e.unloadUrl == "string" && Rt(t) && t.type === "tool.result";
|
|
6003
6224
|
}
|
|
6004
|
-
function
|
|
6225
|
+
function ro(s, e) {
|
|
6005
6226
|
const t = new Set(
|
|
6006
6227
|
s.flatMap((n) => n.type === "tool.result" ? [n.callId] : [])
|
|
6007
6228
|
);
|
|
@@ -6010,26 +6231,26 @@ function Jr(s, e) {
|
|
|
6010
6231
|
...e.filter((n) => !t.has(n.callId))
|
|
6011
6232
|
];
|
|
6012
6233
|
}
|
|
6013
|
-
function
|
|
6234
|
+
function oo(s) {
|
|
6014
6235
|
try {
|
|
6015
6236
|
window.sessionStorage.removeItem(`${Le}${s}`);
|
|
6016
6237
|
} catch {
|
|
6017
6238
|
return;
|
|
6018
6239
|
}
|
|
6019
6240
|
}
|
|
6020
|
-
function
|
|
6241
|
+
function Rt(s) {
|
|
6021
6242
|
if (!s || typeof s != "object")
|
|
6022
6243
|
return !1;
|
|
6023
6244
|
const e = s;
|
|
6024
|
-
return e.type === "chat.user_message" ? typeof e.content == "string" &&
|
|
6245
|
+
return e.type === "chat.user_message" ? typeof e.content == "string" && hs(e.page) : e.type === "page.upsert" || e.type === "session.reset" || e.type === "network.batch" ? hs(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;
|
|
6025
6246
|
}
|
|
6026
|
-
function
|
|
6247
|
+
function hs(s) {
|
|
6027
6248
|
if (!s || typeof s != "object")
|
|
6028
6249
|
return !1;
|
|
6029
6250
|
const e = s;
|
|
6030
6251
|
return typeof e.url == "string" && typeof e.title == "string" && typeof e.origin == "string";
|
|
6031
6252
|
}
|
|
6032
|
-
function
|
|
6253
|
+
function Ls(s, e) {
|
|
6033
6254
|
if (!Array.isArray(s))
|
|
6034
6255
|
return;
|
|
6035
6256
|
const t = s.filter((i) => {
|
|
@@ -6037,41 +6258,41 @@ function qs(s, e) {
|
|
|
6037
6258
|
return !1;
|
|
6038
6259
|
const r = i;
|
|
6039
6260
|
return typeof r.name == "string" && typeof r.mimeType == "string" && typeof r.sizeBytes == "number";
|
|
6040
|
-
}), n = e ? t.map((i) =>
|
|
6261
|
+
}), n = e ? t.map((i) => Ns(i, e)) : t;
|
|
6041
6262
|
return n.length > 0 ? n : void 0;
|
|
6042
6263
|
}
|
|
6043
|
-
function
|
|
6264
|
+
function Ns(s, e) {
|
|
6044
6265
|
return s.fileUrl?.startsWith("/") ? {
|
|
6045
6266
|
...s,
|
|
6046
6267
|
fileUrl: new URL(s.fileUrl, e).toString()
|
|
6047
6268
|
} : s;
|
|
6048
6269
|
}
|
|
6049
|
-
function
|
|
6050
|
-
return s.type ||
|
|
6270
|
+
function mt(s) {
|
|
6271
|
+
return s.type || co(s.name) || "application/octet-stream";
|
|
6051
6272
|
}
|
|
6052
|
-
function
|
|
6053
|
-
|
|
6273
|
+
function ao(s) {
|
|
6274
|
+
Hs({
|
|
6054
6275
|
name: s.name,
|
|
6055
|
-
mimeType:
|
|
6276
|
+
mimeType: mt(s),
|
|
6056
6277
|
sizeBytes: s.size
|
|
6057
6278
|
});
|
|
6058
6279
|
}
|
|
6059
|
-
function
|
|
6060
|
-
const e =
|
|
6061
|
-
if (!
|
|
6280
|
+
function Hs(s) {
|
|
6281
|
+
const e = lo(s.name), t = s.mimeType.trim().toLowerCase();
|
|
6282
|
+
if (!Ii.has(`${e}:${t}`))
|
|
6062
6283
|
throw new Error("This attachment type is not supported by the embedded model provider");
|
|
6063
|
-
if (s.sizeBytes <= 0 || s.sizeBytes >=
|
|
6284
|
+
if (s.sizeBytes <= 0 || s.sizeBytes >= bs)
|
|
6064
6285
|
throw new Error("Embedded attachments must be between 1 byte and less than 50 MB");
|
|
6065
6286
|
}
|
|
6066
|
-
function
|
|
6287
|
+
function lo(s) {
|
|
6067
6288
|
const e = s.trim().toLowerCase(), t = e.lastIndexOf(".");
|
|
6068
6289
|
return t >= 0 ? e.slice(t) : "";
|
|
6069
6290
|
}
|
|
6070
|
-
function
|
|
6291
|
+
function co(s) {
|
|
6071
6292
|
const e = s.toLowerCase();
|
|
6072
6293
|
return e.endsWith(".png") ? "image/png" : e.endsWith(".jpg") || e.endsWith(".jpeg") ? "image/jpeg" : e.endsWith(".webp") ? "image/webp" : e.endsWith(".gif") ? "image/gif" : e.endsWith(".pdf") ? "application/pdf" : null;
|
|
6073
6294
|
}
|
|
6074
|
-
function
|
|
6295
|
+
function uo(s) {
|
|
6075
6296
|
if (!s || typeof s != "object")
|
|
6076
6297
|
return null;
|
|
6077
6298
|
const e = s;
|
|
@@ -6089,11 +6310,11 @@ function so(s) {
|
|
|
6089
6310
|
scheduledCheckInId: typeof e.scheduledCheckInId == "string" ? e.scheduledCheckInId : void 0,
|
|
6090
6311
|
scheduledCheckInAt: typeof e.scheduledCheckInAt == "string" ? e.scheduledCheckInAt : void 0,
|
|
6091
6312
|
securitySettingsUrl: typeof e.securitySettingsUrl == "string" ? e.securitySettingsUrl : void 0,
|
|
6092
|
-
attachments:
|
|
6313
|
+
attachments: Ls(e.attachments)?.map(qe),
|
|
6093
6314
|
loading: typeof e.loading == "boolean" ? e.loading : void 0
|
|
6094
6315
|
};
|
|
6095
6316
|
}
|
|
6096
|
-
function
|
|
6317
|
+
function ho(s) {
|
|
6097
6318
|
return s.attachments?.length ? {
|
|
6098
6319
|
...s,
|
|
6099
6320
|
attachments: s.attachments.map(qe)
|
|
@@ -6113,43 +6334,43 @@ function O(s) {
|
|
|
6113
6334
|
const e = s.respondsToUserMessageId;
|
|
6114
6335
|
return typeof e == "string" && e ? e : null;
|
|
6115
6336
|
}
|
|
6116
|
-
function
|
|
6337
|
+
function k(s) {
|
|
6117
6338
|
const e = s.runId;
|
|
6118
6339
|
return typeof e == "string" && e ? e : null;
|
|
6119
6340
|
}
|
|
6120
|
-
function
|
|
6341
|
+
function po(s) {
|
|
6121
6342
|
const e = s?.timeoutMs;
|
|
6122
|
-
return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <=
|
|
6343
|
+
return !!s && typeof s == "object" && typeof s.summary == "string" && typeof s.javascript == "string" && (e === void 0 || typeof e == "number" && Number.isInteger(e) && e > 0 && e <= Oi);
|
|
6123
6344
|
}
|
|
6124
|
-
function
|
|
6345
|
+
function Bs(s) {
|
|
6125
6346
|
const e = {};
|
|
6126
6347
|
try {
|
|
6127
6348
|
new Headers(s).forEach((t, n) => {
|
|
6128
|
-
Object.keys(e).length <
|
|
6349
|
+
Object.keys(e).length < At && (e[n] = kt(n, t));
|
|
6129
6350
|
});
|
|
6130
6351
|
} catch {
|
|
6131
6352
|
return {};
|
|
6132
6353
|
}
|
|
6133
6354
|
return e;
|
|
6134
6355
|
}
|
|
6135
|
-
function
|
|
6136
|
-
return
|
|
6356
|
+
function kt(s, e) {
|
|
6357
|
+
return Ks(s) ? Be : F(xe(e), Si);
|
|
6137
6358
|
}
|
|
6138
|
-
function
|
|
6359
|
+
function go(s, e) {
|
|
6139
6360
|
return typeof s == "string" ? s : s instanceof URL ? s.toString() : e?.url ?? "";
|
|
6140
6361
|
}
|
|
6141
|
-
async function
|
|
6142
|
-
const i =
|
|
6362
|
+
async function fo(s, e, t, n) {
|
|
6363
|
+
const i = Bs(s.headers);
|
|
6143
6364
|
n({
|
|
6144
6365
|
...e,
|
|
6145
6366
|
responseStatus: s.status,
|
|
6146
6367
|
responseHeaders: i,
|
|
6147
|
-
responseBody: await
|
|
6368
|
+
responseBody: await mo(s),
|
|
6148
6369
|
durationMs: Date.now() - t
|
|
6149
6370
|
});
|
|
6150
6371
|
}
|
|
6151
|
-
async function
|
|
6152
|
-
if (!
|
|
6372
|
+
async function mo(s) {
|
|
6373
|
+
if (!Fs(s.headers))
|
|
6153
6374
|
return;
|
|
6154
6375
|
let e = null, t = null;
|
|
6155
6376
|
try {
|
|
@@ -6158,7 +6379,7 @@ async function ao(s) {
|
|
|
6158
6379
|
const n = new Promise((a) => {
|
|
6159
6380
|
t = window.setTimeout(() => {
|
|
6160
6381
|
e?.cancel(), a("timeout");
|
|
6161
|
-
},
|
|
6382
|
+
}, Ti);
|
|
6162
6383
|
}), i = new TextDecoder();
|
|
6163
6384
|
let r = "", o = 0;
|
|
6164
6385
|
for (; ; ) {
|
|
@@ -6168,7 +6389,7 @@ async function ao(s) {
|
|
|
6168
6389
|
const { done: l, value: c } = a;
|
|
6169
6390
|
if (l)
|
|
6170
6391
|
return F(r + i.decode());
|
|
6171
|
-
const u =
|
|
6392
|
+
const u = wt - o;
|
|
6172
6393
|
if (c.byteLength > u)
|
|
6173
6394
|
return r += i.decode(c.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${F(r)}... [truncated]`;
|
|
6174
6395
|
o += c.byteLength, r += i.decode(c, { stream: !0 });
|
|
@@ -6180,26 +6401,26 @@ async function ao(s) {
|
|
|
6180
6401
|
t !== null && window.clearTimeout(t);
|
|
6181
6402
|
}
|
|
6182
6403
|
}
|
|
6183
|
-
function
|
|
6184
|
-
if (
|
|
6404
|
+
function yo(s, e) {
|
|
6405
|
+
if (Fs(new Headers(e)))
|
|
6185
6406
|
try {
|
|
6186
6407
|
return s.responseType === "" || s.responseType === "text" ? F(s.responseText ?? "") : void 0;
|
|
6187
6408
|
} catch {
|
|
6188
6409
|
return;
|
|
6189
6410
|
}
|
|
6190
6411
|
}
|
|
6191
|
-
function
|
|
6412
|
+
function ps(s) {
|
|
6192
6413
|
if (typeof s == "string")
|
|
6193
6414
|
return F(s);
|
|
6194
6415
|
}
|
|
6195
|
-
function
|
|
6416
|
+
function Io(s) {
|
|
6196
6417
|
return L({
|
|
6197
6418
|
...s,
|
|
6198
|
-
requestBody:
|
|
6199
|
-
responseBody:
|
|
6419
|
+
requestBody: gs(s.requestBody),
|
|
6420
|
+
responseBody: gs(s.responseBody)
|
|
6200
6421
|
});
|
|
6201
6422
|
}
|
|
6202
|
-
function
|
|
6423
|
+
function gs(s) {
|
|
6203
6424
|
if (typeof s != "string")
|
|
6204
6425
|
return s;
|
|
6205
6426
|
const e = s.trim();
|
|
@@ -6211,14 +6432,14 @@ function ds(s) {
|
|
|
6211
6432
|
return xe(s);
|
|
6212
6433
|
}
|
|
6213
6434
|
}
|
|
6214
|
-
function
|
|
6435
|
+
function Fs(s) {
|
|
6215
6436
|
if (!s)
|
|
6216
6437
|
return !1;
|
|
6217
6438
|
const e = s.get("content-type")?.toLowerCase() ?? "", t = s.get("content-length"), n = Number(t);
|
|
6218
|
-
return t !== null && Number.isInteger(n) && n >= 0 && n <=
|
|
6439
|
+
return t !== null && Number.isInteger(n) && n >= 0 && n <= wt && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
|
|
6219
6440
|
}
|
|
6220
6441
|
function te(s, e = {}, t) {
|
|
6221
|
-
if (
|
|
6442
|
+
if (To(t))
|
|
6222
6443
|
return !0;
|
|
6223
6444
|
const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
|
|
6224
6445
|
if (n?.includes("multipart/form-data") || n?.includes("application/octet-stream"))
|
|
@@ -6233,7 +6454,7 @@ function te(s, e = {}, t) {
|
|
|
6233
6454
|
return !0;
|
|
6234
6455
|
}
|
|
6235
6456
|
}
|
|
6236
|
-
function
|
|
6457
|
+
function So(s, e) {
|
|
6237
6458
|
if (te(s))
|
|
6238
6459
|
return !0;
|
|
6239
6460
|
try {
|
|
@@ -6243,23 +6464,23 @@ function uo(s, e) {
|
|
|
6243
6464
|
return !0;
|
|
6244
6465
|
}
|
|
6245
6466
|
}
|
|
6246
|
-
function
|
|
6467
|
+
function To(s) {
|
|
6247
6468
|
return s instanceof FormData || s instanceof Blob || s instanceof ArrayBuffer || ArrayBuffer.isView(s) || typeof ReadableStream < "u" && s instanceof ReadableStream;
|
|
6248
6469
|
}
|
|
6249
|
-
function
|
|
6470
|
+
function wo(s) {
|
|
6250
6471
|
const e = {};
|
|
6251
6472
|
for (const t of s.trim().split(/[\r\n]+/)) {
|
|
6252
6473
|
const n = t.indexOf(":");
|
|
6253
6474
|
if (n <= 0)
|
|
6254
6475
|
continue;
|
|
6255
|
-
if (Object.keys(e).length >=
|
|
6476
|
+
if (Object.keys(e).length >= At)
|
|
6256
6477
|
break;
|
|
6257
6478
|
const i = t.slice(0, n).trim();
|
|
6258
|
-
e[i] =
|
|
6479
|
+
e[i] = kt(i, t.slice(n + 1).trim());
|
|
6259
6480
|
}
|
|
6260
6481
|
return e;
|
|
6261
6482
|
}
|
|
6262
|
-
function F(s, e =
|
|
6483
|
+
function F(s, e = wt) {
|
|
6263
6484
|
return s.length <= e ? s : `${s.slice(0, e)}... [truncated ${s.length - e} chars]`;
|
|
6264
6485
|
}
|
|
6265
6486
|
function nt(s) {
|
|
@@ -6273,31 +6494,31 @@ class Pe extends Error {
|
|
|
6273
6494
|
}
|
|
6274
6495
|
async function be(s, e) {
|
|
6275
6496
|
let t = null;
|
|
6276
|
-
for (let n = 0; n <
|
|
6497
|
+
for (let n = 0; n < Vt; n += 1)
|
|
6277
6498
|
try {
|
|
6278
6499
|
return await s();
|
|
6279
6500
|
} catch (i) {
|
|
6280
|
-
if (t = i, n >=
|
|
6501
|
+
if (t = i, n >= Vt - 1 || !Mo(i))
|
|
6281
6502
|
throw i;
|
|
6282
|
-
await
|
|
6503
|
+
await Ao(n);
|
|
6283
6504
|
}
|
|
6284
6505
|
throw t instanceof Error ? t : new Error(e);
|
|
6285
6506
|
}
|
|
6286
|
-
function
|
|
6507
|
+
function Ao(s) {
|
|
6287
6508
|
return new Promise((e) => {
|
|
6288
|
-
window.setTimeout(e,
|
|
6509
|
+
window.setTimeout(e, yi[s] ?? 0);
|
|
6289
6510
|
});
|
|
6290
6511
|
}
|
|
6291
|
-
function
|
|
6292
|
-
return s instanceof Pe ?
|
|
6512
|
+
function Mo(s) {
|
|
6513
|
+
return s instanceof Pe ? bo(s.status) : s instanceof TypeError;
|
|
6293
6514
|
}
|
|
6294
|
-
function
|
|
6515
|
+
function bo(s) {
|
|
6295
6516
|
return s === 408 || s === 409 || s === 429 || s >= 500;
|
|
6296
6517
|
}
|
|
6297
|
-
function
|
|
6518
|
+
function Ro(s) {
|
|
6298
6519
|
return s === 401 || s === 403;
|
|
6299
6520
|
}
|
|
6300
|
-
const Be = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]",
|
|
6521
|
+
const Be = "[REDACTED_SECRET]", $ = "[REDACTED_TOKEN]", ko = "[REDACTED_SIGNED_URL]", Eo = 20, Co = /^(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, Ws = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, $s = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, js = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, zs = /\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, _o = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Po = /\bhttps?:\/\/[^\s"'<>]+/gi, vo = /[),.;\]]+$/;
|
|
6301
6522
|
function L(s) {
|
|
6302
6523
|
return Oe(s, 0, /* @__PURE__ */ new WeakSet());
|
|
6303
6524
|
}
|
|
@@ -6306,7 +6527,7 @@ function Oe(s, e, t) {
|
|
|
6306
6527
|
return s.startsWith("data:image/") || s.startsWith("data:application/pdf;") ? s : xe(s);
|
|
6307
6528
|
if (s === null || typeof s != "object")
|
|
6308
6529
|
return s;
|
|
6309
|
-
if (e >=
|
|
6530
|
+
if (e >= Eo)
|
|
6310
6531
|
return "[REDACTED_MAX_DEPTH]";
|
|
6311
6532
|
if (t.has(s))
|
|
6312
6533
|
return "[REDACTED_CIRCULAR]";
|
|
@@ -6314,71 +6535,71 @@ function Oe(s, e, t) {
|
|
|
6314
6535
|
return s.map((i) => Oe(i, e + 1, t));
|
|
6315
6536
|
const n = {};
|
|
6316
6537
|
for (const [i, r] of Object.entries(s))
|
|
6317
|
-
i === "pageContent" ? n[i] = r :
|
|
6538
|
+
i === "pageContent" ? n[i] = r : Ks(i) ? n[i] = Be : n[i] = i.toLowerCase() === "url" ? Uo(r) : Oe(r, e + 1, t);
|
|
6318
6539
|
return n;
|
|
6319
6540
|
}
|
|
6320
|
-
function
|
|
6541
|
+
function Ks(s) {
|
|
6321
6542
|
const e = s.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
6322
6543
|
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");
|
|
6323
6544
|
}
|
|
6324
|
-
function
|
|
6325
|
-
return typeof s == "string" ?
|
|
6545
|
+
function Uo(s) {
|
|
6546
|
+
return typeof s == "string" ? Gs(s) : Oe(s, 0, /* @__PURE__ */ new WeakSet());
|
|
6326
6547
|
}
|
|
6327
|
-
function
|
|
6548
|
+
function Gs(s) {
|
|
6328
6549
|
try {
|
|
6329
6550
|
const e = new URL(s, location.href);
|
|
6330
6551
|
for (const t of Array.from(e.searchParams.keys()))
|
|
6331
|
-
|
|
6552
|
+
Co.test(t) && e.searchParams.set(t, $);
|
|
6332
6553
|
return e.username && (e.username = $), e.password && (e.password = $), e.toString();
|
|
6333
6554
|
} catch {
|
|
6334
|
-
return
|
|
6555
|
+
return Do(s);
|
|
6335
6556
|
}
|
|
6336
6557
|
}
|
|
6337
6558
|
function xe(s) {
|
|
6338
|
-
return s.replace(
|
|
6559
|
+
return s.replace(_o, ko).replace(Po, qo).replace(Ws, `Bearer ${$}`).replace($s, `Basic ${$}`).replace(js, $).replace(zs, (e, t) => `${t}: ${Be}`);
|
|
6339
6560
|
}
|
|
6340
|
-
function
|
|
6341
|
-
return s.replace(
|
|
6561
|
+
function Do(s) {
|
|
6562
|
+
return s.replace(Ws, `Bearer ${$}`).replace($s, `Basic ${$}`).replace(js, $).replace(zs, (e, t) => `${t}: ${Be}`);
|
|
6342
6563
|
}
|
|
6343
|
-
function
|
|
6344
|
-
const e = s.match(
|
|
6345
|
-
return `${
|
|
6564
|
+
function qo(s) {
|
|
6565
|
+
const e = s.match(vo)?.[0] ?? "", t = e ? s.slice(0, -e.length) : s;
|
|
6566
|
+
return `${Gs(t)}${e}`;
|
|
6346
6567
|
}
|
|
6347
|
-
const
|
|
6568
|
+
const $o = Object.freeze({
|
|
6348
6569
|
init: (s) => Ne.init(s)
|
|
6349
6570
|
});
|
|
6350
|
-
function
|
|
6571
|
+
function jo(s) {
|
|
6351
6572
|
return Ne.init(s);
|
|
6352
6573
|
}
|
|
6353
6574
|
export {
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6575
|
+
Wt as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
6576
|
+
Kn as PLUNO_PRODUCT_AGENT_WIDGET_PANEL_SELECTOR,
|
|
6577
|
+
zn as PLUNO_PRODUCT_AGENT_WIDGET_ROOT_SELECTOR,
|
|
6578
|
+
Gn as PLUNO_PRODUCT_AGENT_WIDGET_TIMELINE_SELECTOR,
|
|
6579
|
+
Wo as PRODUCT_AGENT_PROVIDER_INPUT_ATTACHMENT_ACCEPT,
|
|
6580
|
+
$o as PlunoProductAgent,
|
|
6581
|
+
Ln as ProductAgentInteractionManager,
|
|
6582
|
+
Ht as ProductAgentQueryController,
|
|
6583
|
+
Fo as ProductAgentRemoteRuntimeClient,
|
|
6363
6584
|
Ne as ProductAgentSessionEngine,
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6585
|
+
qn as ProductAgentSessionHistoryManager,
|
|
6586
|
+
No as ProductAgentTaskPageTitleController,
|
|
6587
|
+
J as ProductAgentTokenProviderError,
|
|
6588
|
+
Ri as calculateReconnectDelay,
|
|
6589
|
+
Lo as createLocalStorageInteractionDecisionStorage,
|
|
6590
|
+
ke as createProductAgentQueryState,
|
|
6591
|
+
jo as createProductAgentRuntime,
|
|
6592
|
+
Ho as createProductAgentTaskPageTitleDocument,
|
|
6593
|
+
$o as default,
|
|
6594
|
+
Fn as formatProductAgentTaskPageTitle,
|
|
6595
|
+
Xi as getProductAgentOriginAccessErrorMessage,
|
|
6596
|
+
Bo as isProductAgentRuntimeCommand,
|
|
6597
|
+
vn as mergeProductAgentEntityPages,
|
|
6598
|
+
Ee as normalizeProductAgentEntityPage,
|
|
6378
6599
|
st as normalizeProductAgentSessionItems,
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6600
|
+
Nn as readLocalStorageInteractionDecisions,
|
|
6601
|
+
xo as resolveProductAgentComposerAction,
|
|
6602
|
+
Oo as resolveProductAgentWidgetPresentation,
|
|
6603
|
+
As as selectProductAgentQueryEntities,
|
|
6604
|
+
ao as validateProductAgentProviderInputFile
|
|
6384
6605
|
};
|