@pluno/product-agent-web 0.1.290 → 0.1.292
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +211 -202
- package/dist/product-agent-sdk.js +863 -854
- package/dist/product-agent-widget.js +1813 -1807
- package/dist/runtimeClient.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ts = [
|
|
2
2
|
{ value: "gpt-5.6-sol", label: "gpt-5.6-sol", price: "$$" },
|
|
3
3
|
{ value: "anthropic/claude-sonnet-5", label: "Claude Sonnet 5", price: "$$" },
|
|
4
4
|
{ value: "deepseek/deepseek-v4-flash", label: "DeepSeek V4 Flash", price: "$" }
|
|
5
5
|
];
|
|
6
|
-
function
|
|
6
|
+
function It(t, e, s) {
|
|
7
7
|
t.throwIfAborted();
|
|
8
8
|
let n, i = () => {
|
|
9
9
|
};
|
|
@@ -25,7 +25,7 @@ function zr(t, e) {
|
|
|
25
25
|
if (!xs.includes(e)) throw new Error("Unknown device hint.");
|
|
26
26
|
t.setItem(Ps, JSON.stringify({ ...Ds(t), [e]: !0 }));
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function ss(t, e, s, n) {
|
|
29
29
|
if (s.authorityId !== t.account.authority?.authorityId || s.generation !== t.account.authority.generation) return t;
|
|
30
30
|
const i = {};
|
|
31
31
|
let r = t.interactions.openingGeneration;
|
|
@@ -33,7 +33,7 @@ function ts(t, e, s, n) {
|
|
|
33
33
|
if (t.interactions.closedScopes[a]) continue;
|
|
34
34
|
const o = s.selections[a];
|
|
35
35
|
if (!o) continue;
|
|
36
|
-
const c = o.sessionId ? e.sessions[o.sessionId] : void 0, d = c?.execution?.user_message_ids ?? [],
|
|
36
|
+
const c = o.sessionId ? e.sessions[o.sessionId] : void 0, d = c?.execution?.user_message_ids ?? [], u = ["queued", "thinking", "steering"].includes(c?.execution?.phase ?? "idle"), l = t.interactions.openings[a], h = l && (l.sessionId === o.sessionId || l.sessionId === null) ? { ...l, sessionId: o.sessionId } : { sessionId: o.sessionId, generation: ++r, openedAt: n, awaitingBaseline: o.sessionId !== null && !c?.execution, ignoredTurns: d, turns: {}, shown: {} };
|
|
37
37
|
if (h.awaitingBaseline && c?.execution) {
|
|
38
38
|
const m = d.filter((p) => {
|
|
39
39
|
const y = e.submissions[p];
|
|
@@ -43,10 +43,10 @@ function ts(t, e, s, n) {
|
|
|
43
43
|
}
|
|
44
44
|
const f = {};
|
|
45
45
|
for (const [m, p] of Object.entries(h.turns)) {
|
|
46
|
-
const y =
|
|
46
|
+
const y = u && d.includes(m), b = y && !p.active ? n : p.startedAt;
|
|
47
47
|
f[m] = { ...p, startedAt: b, active: y, notifications: !p.notificationsSuppressed && (p.notifications || y && n - b >= 1e4) };
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
49
|
+
if (u)
|
|
50
50
|
for (const m of d) !h.ignoredTurns.includes(m) && !f[m] && (f[m] = { startedAt: n, active: !0, notifications: !1, tab_grouping: (t.interactions.crossTabTurns[o.sessionId] ?? []).includes(m) });
|
|
51
51
|
i[a] = { ...h, turns: f };
|
|
52
52
|
}
|
|
@@ -56,7 +56,7 @@ function Mi(t, e, s) {
|
|
|
56
56
|
const n = t.interactions.openings[e];
|
|
57
57
|
return n?.sessionId ? n.shown[s] ?? Object.entries(n.turns).find(([, i]) => i.active && i[s])?.[0] ?? null : null;
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function xt(t, e) {
|
|
60
60
|
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"] } : t ?? { allowed: !0, reason: "allowed", actions: [] };
|
|
61
61
|
}
|
|
62
62
|
const Oi = {
|
|
@@ -239,7 +239,7 @@ function fe(t) {
|
|
|
239
239
|
if (!e) throw new Error("Display timestamps must retain the backend UTC precision.");
|
|
240
240
|
return `${e[1]}.${(e[2] ?? "").padEnd(6, "0")}`;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function Pt(t) {
|
|
243
243
|
return "revision" in t.data ? t.data.revision : null;
|
|
244
244
|
}
|
|
245
245
|
function ye(t) {
|
|
@@ -267,7 +267,7 @@ function Ue(t, e) {
|
|
|
267
267
|
updatedAt: s ? t.updatedAt : null
|
|
268
268
|
};
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function ns(t, e) {
|
|
271
271
|
return t.key !== e.key || t.requestId !== e.requestId ? t : {
|
|
272
272
|
...t,
|
|
273
273
|
status: "ready",
|
|
@@ -325,26 +325,26 @@ function Ie(t, e, s) {
|
|
|
325
325
|
return U < H ? -1 : U > H ? 1 : S.id < O.id ? -1 : S.id > O.id ? 1 : 0;
|
|
326
326
|
}), c = a.filter((S) => (!S.cancelled || S.conversationScopeId === s && (S.sessionId === null || S.sessionId === i || i === null && S === a[a.length - 1])) && !r?.items[S.userMessageId] && !r?.removedItems[S.userMessageId]), d = {};
|
|
327
327
|
for (const S of o) {
|
|
328
|
-
const O =
|
|
328
|
+
const O = Pt(S);
|
|
329
329
|
if (O === null) continue;
|
|
330
330
|
const U = r?.streams[S.id];
|
|
331
331
|
d[S.id] = U ? U.state === "open" ? "open" : O < U.revision ? "awaiting_content" : U.state : "open";
|
|
332
332
|
}
|
|
333
|
-
const
|
|
333
|
+
const u = [];
|
|
334
334
|
for (const S of o)
|
|
335
335
|
if (S.type === "user_message")
|
|
336
|
-
|
|
336
|
+
u.push({ id: S.id, userMessageId: S.id, activityIds: [], outcomeIds: [], collapsed: !1 });
|
|
337
337
|
else {
|
|
338
|
-
|
|
339
|
-
const O =
|
|
340
|
-
|
|
338
|
+
u.length || u.push({ id: `leading:${S.id}`, userMessageId: null, activityIds: [], outcomeIds: [], collapsed: !1 });
|
|
339
|
+
const O = u.length - 1, U = u[O], H = S.type === "commentary" || S.type === "tool_summary" ? "activityIds" : "outcomeIds";
|
|
340
|
+
u[O] = { ...U, [H]: [...U[H], S.id] };
|
|
341
341
|
}
|
|
342
342
|
for (const S of c) {
|
|
343
|
-
const O =
|
|
343
|
+
const O = u.findIndex((U) => {
|
|
344
344
|
const H = a.find((at) => at.userMessageId === U.userMessageId), $e = r?.items[U.userMessageId ?? U.activityIds[0] ?? U.outcomeIds[0]];
|
|
345
345
|
return (H?.submittedAt ?? ($e ? Date.parse($e.created_at) : 1 / 0)) > S.submittedAt;
|
|
346
346
|
});
|
|
347
|
-
|
|
347
|
+
u.splice(O < 0 ? u.length : O, 0, {
|
|
348
348
|
id: S.userMessageId,
|
|
349
349
|
userMessageId: S.userMessageId,
|
|
350
350
|
activityIds: [],
|
|
@@ -352,14 +352,14 @@ function Ie(t, e, s) {
|
|
|
352
352
|
collapsed: !1
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
|
-
const
|
|
356
|
-
let k = y ? "submitting" : b ? "awaiting_execution" :
|
|
357
|
-
const R = Object.entries(t.stops).filter(([S]) => S === s || i !== null && e.selections[S]?.sessionId === i).map(([, S]) => S).find((S) => (!a.length || S.userMessageIds.includes(a[a.length - 1].userMessageId) || !y && !b && le(
|
|
358
|
-
R && g && !y && (!
|
|
355
|
+
const l = r?.execution, h = a.filter((S) => !S.cancelled && S.delivery !== "failed"), f = h.filter((S) => S.delivery !== "accepted" && S.executionVersion === null), m = h.filter((S) => S.delivery === "accepted" && S.executionVersion === null), p = h[h.length - 1], y = f.length > 0, b = p !== void 0 && m.includes(p);
|
|
356
|
+
let k = y ? "submitting" : b ? "awaiting_execution" : l?.phase ?? "idle";
|
|
357
|
+
const R = Object.entries(t.stops).filter(([S]) => S === s || i !== null && e.selections[S]?.sessionId === i).map(([, S]) => S).find((S) => (!a.length || S.userMessageIds.includes(a[a.length - 1].userMessageId) || !y && !b && le(l).some((O) => S.userMessageIds.includes(O))) && (!l || l.version <= S.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(l.phase) || a.some((O) => O.cancelled && O.executionVersion === null && S.userMessageIds.includes(O.userMessageId)))), g = l && ["thinking", "steering", "queued", "stopping"].includes(l.phase) || a.some((S) => S.delivery === "accepted" && S.executionVersion === null && R?.userMessageIds.includes(S.userMessageId));
|
|
358
|
+
R && g && !y && (!l || !["thinking", "steering", "queued", "stopping"].includes(l.phase) || le(l).every((S) => R.userMessageIds.includes(S))) && (k = "stopping"), R && !g && !y && a.some((S) => S.cancelled && S.executionVersion === null && R.userMessageIds.includes(S.userMessageId)) && (k = a.some((S) => R.userMessageIds.includes(S.userMessageId) && ["sending", "uncertain"].includes(S.delivery)) ? "stopping" : "stopped");
|
|
359
359
|
const v = ["thinking", "steering", "queued"].includes(k), I = t.stops[s] ?? R, w = I?.userMessageIds.filter((S) => !["completed", "failed"].includes(r?.executionByUserMessage[S]?.phase ?? "")) ?? [], A = w.some((S) => {
|
|
360
360
|
const O = a.find((H) => H.userMessageId === S);
|
|
361
|
-
return !Object.values(t.operations).some((H) => H.command.type === "run.stop" && H.command.payload.expectedUserMessageId === S && H.phase === "done") && (O?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(O.delivery) || !!(
|
|
362
|
-
}), _ =
|
|
361
|
+
return !Object.values(t.operations).some((H) => H.command.type === "run.stop" && H.command.payload.expectedUserMessageId === S && H.phase === "done") && (O?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(O.delivery) || !!(l && le(l).includes(S) && ["thinking", "steering", "queued", "stopping"].includes(l.phase)));
|
|
362
|
+
}), _ = l?.user_message_ids ?? [], T = y || b ? p?.userMessageId ?? null : _[_.length - 1] ?? null, E = u.find((S) => S.userMessageId === T), C = v ? [...E?.activityIds ?? []].reverse().find((S) => d[S] === "open") ?? null : null, M = i !== null && !!e.selections[s]?.provisionalId && o.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
|
|
363
363
|
(!r?.execution || r.execution.phase === "idle" && r.execution.user_message_ids.length === 0) && Object.values(t.operations).some((S) => S.conversationScopeId === s && S.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(S.command.type) && !S.command.payload.sessionId && S.result?.sessionId === i);
|
|
364
364
|
return G({
|
|
365
365
|
historyRefreshFailure: r?.historyRefreshFailure ?? null,
|
|
@@ -379,8 +379,8 @@ function Ie(t, e, s) {
|
|
|
379
379
|
streamStates: d,
|
|
380
380
|
preparation: r?.preparation ?? null,
|
|
381
381
|
stop: I ? { ...I, userMessageIds: w, pending: A } : null,
|
|
382
|
-
segments:
|
|
383
|
-
activity: { phase: k, activeItemId: C, userMessageId: T, executionKey: JSON.stringify([...le(
|
|
382
|
+
segments: u.map((S, O) => ({ ...S, collapsed: v ? S.userMessageId !== T : O < u.length - 1 || S.activityIds.length > 0 })),
|
|
383
|
+
activity: { phase: k, activeItemId: C, userMessageId: T, executionKey: JSON.stringify([...le(l)].sort()) },
|
|
384
384
|
// Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
|
|
385
385
|
// the same submitted text in the optimistic transcript and composer during delivery.
|
|
386
386
|
receipts: n.filter((S) => !S.cancelled && e.clients[S.clientScopeId] === s).map((S) => ({ viewId: S.viewId, userMessageId: S.userMessageId, acceptedRendererRevision: S.rendererRevision, durable: t.durableSubmissionIds.includes(S.userMessageId) || S.delivery === "accepted" }))
|
|
@@ -419,7 +419,7 @@ function ji(t) {
|
|
|
419
419
|
function ln(t) {
|
|
420
420
|
if (!{ social_share: ["dismiss", "shared"], proactive_suggestion: ["not_now", "never"], morning_report: ["snooze"] }[t.category]?.some((s) => s === t.action)) throw new Error("Unsupported category action.");
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function is(t, e) {
|
|
423
423
|
const s = { ...t.decisions };
|
|
424
424
|
for (const n of e) {
|
|
425
425
|
if (ln(n.request), n.decisionKey !== ji(n.request)) throw new Error("Decision scope does not match its category.");
|
|
@@ -446,12 +446,12 @@ function Jr(t, e, s) {
|
|
|
446
446
|
const n = t.account.authority;
|
|
447
447
|
if (!n) return [];
|
|
448
448
|
const i = X(n.profile, "canShowPersonalFeatures"), r = [], a = t.features.now, o = (c) => {
|
|
449
|
-
const d = Object.values(t.features.pending).filter((f) => f.mode === "mutation" && c.includes(f.key)),
|
|
450
|
-
return { status:
|
|
449
|
+
const d = Object.values(t.features.pending).filter((f) => f.mode === "mutation" && c.includes(f.key)), u = d.some((f) => f.status === "pending"), l = d[d.length - 1], h = l?.status === "error" ? l.error : null;
|
|
450
|
+
return { status: u ? "pending" : h ? "error" : "presentable", error: h };
|
|
451
451
|
};
|
|
452
452
|
if (n.profile === "main_web_chat") for (const [c, d] of Object.entries(t.interactions.deviceHints)) {
|
|
453
453
|
if (d) continue;
|
|
454
|
-
const
|
|
454
|
+
const u = Object.values(t.interactions.actions).filter((l) => l.interactionId === c).slice(-1)[0];
|
|
455
455
|
r.push({
|
|
456
456
|
id: c,
|
|
457
457
|
category: "device_hint",
|
|
@@ -462,8 +462,8 @@ function Jr(t, e, s) {
|
|
|
462
462
|
sourceVersion: null,
|
|
463
463
|
decisionRevision: 0,
|
|
464
464
|
actions: ["dismiss"],
|
|
465
|
-
status:
|
|
466
|
-
error:
|
|
465
|
+
status: u?.status === "pending" ? "pending" : u?.status === "error" ? "error" : "presentable",
|
|
466
|
+
error: u?.error ?? null,
|
|
467
467
|
payload: {},
|
|
468
468
|
nextEligibleAt: null
|
|
469
469
|
});
|
|
@@ -472,11 +472,11 @@ function Jr(t, e, s) {
|
|
|
472
472
|
for (const c of ["notifications", "tab_grouping"]) {
|
|
473
473
|
const d = c === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
|
|
474
474
|
if (!X(n.profile, d)) continue;
|
|
475
|
-
const
|
|
476
|
-
if (!s.sessionId || !
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
const p = f.pending || Object.values(t.interactions.devicePending).some((k) => k.feature === c), y = o([m, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), b = y.error ?? t.interactions.deviceErrors[c] ?? (
|
|
475
|
+
const u = s.conversationScopeId ? t.interactions.openings[s.conversationScopeId] : void 0;
|
|
476
|
+
if (!s.sessionId || !u || u.sessionId !== s.sessionId || !Mi(t, s.conversationScopeId, c) || t.features.refreshRequired && !u.shown[c] || n.profile === "main_web_chat" && !t.interactions.bridgeReady && !u.shown[c]) continue;
|
|
477
|
+
const l = wt(t, c), h = t.interactions.preferencePrompts[c], f = t.interactions.deviceFacts[c], m = `preference:${c}`;
|
|
478
|
+
if (l === !1 || t.features.desiredPreferences[c] === !1 || l === !0 && ["granted", "unknown"].includes(f.permission) || f.permission === "unsupported" || h.snoozedUntil && Date.parse(h.snoozedUntil) > a || f.snoozedUntil && Date.parse(f.snoozedUntil) > a) continue;
|
|
479
|
+
const p = f.pending || Object.values(t.interactions.devicePending).some((k) => k.feature === c), y = o([m, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), b = y.error ?? t.interactions.deviceErrors[c] ?? (u.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
|
|
480
480
|
r.push({
|
|
481
481
|
id: m,
|
|
482
482
|
category: "preference",
|
|
@@ -484,12 +484,12 @@ function Jr(t, e, s) {
|
|
|
484
484
|
sourceId: null,
|
|
485
485
|
conversationId: null,
|
|
486
486
|
userMessageId: null,
|
|
487
|
-
sourceVersion:
|
|
487
|
+
sourceVersion: u.generation,
|
|
488
488
|
decisionRevision: h.revision,
|
|
489
489
|
actions: ["enable", "not_now", "dont_enable"],
|
|
490
490
|
status: p ? "pending" : b ? "error" : y.status,
|
|
491
491
|
error: b,
|
|
492
|
-
payload: { feature: c, openingGeneration:
|
|
492
|
+
payload: { feature: c, openingGeneration: u.generation },
|
|
493
493
|
nextEligibleAt: h.snoozedUntil ?? f.snoozedUntil
|
|
494
494
|
});
|
|
495
495
|
}
|
|
@@ -503,7 +503,7 @@ function Jr(t, e, s) {
|
|
|
503
503
|
if (d.wait_for_terminal && (!m || !Ni(m, c.user_message_id)) || (n.profile.startsWith("extension_") ? t.interactions.localSharing[c.id]?.resolved : Bn(t.interactions.decisions[`prompt:social_share:${c.id}`], a))) continue;
|
|
504
504
|
}
|
|
505
505
|
if (d.kind === "integration_auth" && !X(n.profile, "canManageIntegrationAuth") || d.kind === "personal_channel" && !i) continue;
|
|
506
|
-
const
|
|
506
|
+
const u = d.kind === "integration_auth" && c.lifecycle === "pending" && Date.parse(d.expires_at) <= a ? "expired" : c.lifecycle, l = t.interactions.decisions[`prompt:social_share:${c.id}`], h = t.interactions.localSharing[c.id], f = Object.values(t.interactions.actions).filter((m) => m.interactionId === c.id && m.sourceVersion === c.version && (m.operation.kind !== "connect" || m.operation.source.conversation_id === c.conversation_id)).slice(-1)[0];
|
|
507
507
|
r.push({
|
|
508
508
|
id: c.id,
|
|
509
509
|
category: d.kind,
|
|
@@ -512,20 +512,20 @@ function Jr(t, e, s) {
|
|
|
512
512
|
conversationId: c.conversation_id,
|
|
513
513
|
userMessageId: c.user_message_id,
|
|
514
514
|
sourceVersion: c.version,
|
|
515
|
-
decisionRevision: n.profile.startsWith("extension_") ? h?.revision ?? 0 :
|
|
515
|
+
decisionRevision: n.profile.startsWith("extension_") ? h?.revision ?? 0 : l?.revision ?? 0,
|
|
516
516
|
actions: d.kind === "sharing" ? ["copy", "share", "dismiss"] : d.kind === "integration_auth" ? ["connect"] : ["pair"],
|
|
517
|
-
...d.kind === "integration_auth" ? { actionLabels: { connect: f?.status === "error" ? "Try again" :
|
|
517
|
+
...d.kind === "integration_auth" ? { actionLabels: { connect: f?.status === "error" ? "Try again" : u === "pending" ? "Connect" : "Reconnect" } } : {},
|
|
518
518
|
...o([`prompt:social_share:${c.id}`]),
|
|
519
519
|
...f?.status === "pending" || f?.status === "error" ? { status: f.status, error: f.error } : {},
|
|
520
|
-
payload: d.kind === "integration_auth" ? { ...d, lifecycle:
|
|
520
|
+
payload: d.kind === "integration_auth" ? { ...d, lifecycle: u } : d,
|
|
521
521
|
nextEligibleAt: null
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
524
|
if (i && s.newChat && !s.sessionId && !s.submissionStarted && !t.features.refreshRequired)
|
|
525
525
|
for (const c of Object.values(t.interactions.welcome)) {
|
|
526
|
-
const d = c.category === "morning_report" ? "canManageMorningReport" : "canManageProactiveSuggestions",
|
|
527
|
-
if (c.clientScopeId && c.clientScopeId !== s.clientScopeId || !c.eligible || c.expiresAt !== void 0 && c.expiresAt <= a || !X(n.profile, d) || Bn(t.interactions.decisions[
|
|
528
|
-
const
|
|
526
|
+
const d = c.category === "morning_report" ? "canManageMorningReport" : "canManageProactiveSuggestions", u = c.category === "morning_report" ? "category:morning_report" : `prompt:proactive_suggestion:${c.sourceSuggestionId ?? c.id}`;
|
|
527
|
+
if (c.clientScopeId && c.clientScopeId !== s.clientScopeId || !c.eligible || c.expiresAt !== void 0 && c.expiresAt <= a || !X(n.profile, d) || Bn(t.interactions.decisions[u], a)) continue;
|
|
528
|
+
const l = o([u]), h = Bi(t, c.id, s), f = l.status === "pending" || h?.status === "pending" ? "pending" : l.error || h?.status === "error" ? "error" : "presentable";
|
|
529
529
|
r.push({
|
|
530
530
|
id: c.id,
|
|
531
531
|
category: c.category,
|
|
@@ -534,12 +534,12 @@ function Jr(t, e, s) {
|
|
|
534
534
|
conversationId: null,
|
|
535
535
|
userMessageId: null,
|
|
536
536
|
sourceVersion: null,
|
|
537
|
-
decisionRevision: t.interactions.decisions[
|
|
537
|
+
decisionRevision: t.interactions.decisions[u]?.revision ?? 0,
|
|
538
538
|
actions: c.category === "morning_report" ? ["run", "snooze"] : ["run", "edit", "not_now", "never", "feedback"],
|
|
539
539
|
status: f,
|
|
540
|
-
error:
|
|
540
|
+
error: l.error ?? (h?.status === "error" ? h.error : null),
|
|
541
541
|
payload: { text: c.text, tasks: c.tasks, sourceSuggestionId: c.sourceSuggestionId ?? c.id },
|
|
542
|
-
nextEligibleAt: t.interactions.decisions[
|
|
542
|
+
nextEligibleAt: t.interactions.decisions[u]?.nextEligibleAt ?? null
|
|
543
543
|
});
|
|
544
544
|
}
|
|
545
545
|
return r;
|
|
@@ -552,16 +552,16 @@ function Li(t, e, s, n) {
|
|
|
552
552
|
}
|
|
553
553
|
function Qr(t, e, s, n) {
|
|
554
554
|
let i = t;
|
|
555
|
-
const r = [], a = i.account.authority, o = (
|
|
556
|
-
i = { ...i, interactions: { ...i.interactions, actions: { ...i.interactions.actions, [
|
|
557
|
-
}, d = (
|
|
558
|
-
r.push({ kind: "stage7.platform", id: o(
|
|
555
|
+
const r = [], a = i.account.authority, o = (u, l) => JSON.stringify(["stage7.platform", a.authorityId, a.generation, u, l]), c = (u, l) => {
|
|
556
|
+
i = { ...i, interactions: { ...i.interactions, actions: { ...i.interactions.actions, [u]: l } } };
|
|
557
|
+
}, d = (u, l, h) => {
|
|
558
|
+
r.push({ kind: "stage7.platform", id: o(u, h), input: { authority: a, requestId: u, operation: l } });
|
|
559
559
|
};
|
|
560
560
|
if (e.type === "stage7.act") {
|
|
561
|
-
const
|
|
562
|
-
if (
|
|
561
|
+
const u = i.interactions.actions[e.requestId];
|
|
562
|
+
if (u) {
|
|
563
563
|
const p = i.interactions.welcome[e.interactionId], y = p?.category === "morning_report" ? p.tasks[e.taskIndex ?? 0] : p?.text;
|
|
564
|
-
if (
|
|
564
|
+
if (u.interactionId !== e.interactionId || u.action !== e.action || u.expectedRevision !== e.expectedRevision || u.sourceVersion !== (e.sourceVersion ?? null) || u.clientScopeId !== e.clientScopeId || u.taskIndex !== (e.taskIndex ?? null) || (u.operation.kind === "run" || u.operation.kind === "edit") && u.operation.text !== y) throw new Error("Action request changed.");
|
|
565
565
|
return { state: i, effects: r, command: null };
|
|
566
566
|
}
|
|
567
567
|
if (e.action === "feedback") {
|
|
@@ -581,56 +581,56 @@ function Qr(t, e, s, n) {
|
|
|
581
581
|
}
|
|
582
582
|
} };
|
|
583
583
|
}
|
|
584
|
-
const
|
|
585
|
-
if (!
|
|
586
|
-
if (
|
|
587
|
-
const p =
|
|
584
|
+
const l = Li(i, s, n, e.clientScopeId).find((p) => p.id === e.interactionId);
|
|
585
|
+
if (!l || !l.actions.includes(e.action) || l.decisionRevision !== e.expectedRevision || l.sourceVersion !== e.sourceVersion || l.status === "pending") throw new Error("Interaction changed or action is unavailable.");
|
|
586
|
+
if (l.category === "preference" || l.category === "permission") {
|
|
587
|
+
const p = l.payload.feature;
|
|
588
588
|
if (p !== "notifications" && p !== "tab_grouping") throw new Error("Missing preference feature.");
|
|
589
|
-
if (i = { ...i, interactions: { ...i.interactions, promptActions: { ...i.interactions.promptActions, [e.requestId]: { scope: n.clients[e.clientScopeId], openingGeneration:
|
|
589
|
+
if (i = { ...i, interactions: { ...i.interactions, promptActions: { ...i.interactions.promptActions, [e.requestId]: { scope: n.clients[e.clientScopeId], openingGeneration: l.sourceVersion, expectedRevision: e.expectedRevision, feature: p, action: e.action } } } }, e.action === "enable" || l.category === "permission") return { state: i, effects: r, command: { type: "stage7.permission", authority: a, now: e.now, requestId: e.requestId, feature: p, action: e.action === "enable" ? "allow" : e.action, settings: !1 } };
|
|
590
590
|
const y = e.action === "not_now" ? { kind: "preferenceSnooze", feature: p, expectedRevision: e.expectedRevision } : { kind: "preference", feature: p, enabled: !1 };
|
|
591
591
|
return { state: i, effects: r, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: y } };
|
|
592
592
|
}
|
|
593
593
|
if (["not_now", "never", "snooze"].includes(e.action)) {
|
|
594
|
-
const p =
|
|
594
|
+
const p = l.category === "morning_report" ? { kind: "decision", category: "morning_report", action: "snooze", promptKey: l.id, expectedRevision: e.expectedRevision } : { kind: "decision", category: "proactive_suggestion", action: e.action, promptKey: i.interactions.welcome[l.id].sourceSuggestionId ?? l.id, expectedRevision: e.expectedRevision };
|
|
595
595
|
return { state: i, effects: r, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: p } };
|
|
596
596
|
}
|
|
597
|
-
const h = Object.values(i.interactions.sources).find((p) => p.id ===
|
|
597
|
+
const h = Object.values(i.interactions.sources).find((p) => p.id === l.sourceId && p.conversation_id === l.conversationId);
|
|
598
598
|
let f;
|
|
599
|
-
if (
|
|
600
|
-
f = { kind: "saveHint", interactionId:
|
|
599
|
+
if (l.category === "device_hint")
|
|
600
|
+
f = { kind: "saveHint", interactionId: l.id };
|
|
601
601
|
else if (e.action === "dismiss") {
|
|
602
602
|
if (!a.profile.startsWith("extension_")) return { state: i, effects: r, command: {
|
|
603
603
|
type: "stage7.mutate",
|
|
604
604
|
authority: a,
|
|
605
605
|
now: e.now,
|
|
606
606
|
requestId: e.requestId,
|
|
607
|
-
mutation: { kind: "decision", category: "social_share", promptKey:
|
|
607
|
+
mutation: { kind: "decision", category: "social_share", promptKey: l.id, action: "dismiss", expectedRevision: e.expectedRevision }
|
|
608
608
|
} };
|
|
609
|
-
f = { kind: "saveSharing", interactionId:
|
|
609
|
+
f = { kind: "saveSharing", interactionId: l.id, expectedRevision: e.expectedRevision };
|
|
610
610
|
} else if (e.action === "copy" || e.action === "share") {
|
|
611
611
|
if (h?.payload.kind !== "sharing") throw new Error("Missing sharing source.");
|
|
612
|
-
const p = Object.values(i.interactions.actions).find((y) => y.interactionId ===
|
|
612
|
+
const p = Object.values(i.interactions.actions).find((y) => y.interactionId === l.id && y.step === "perform" && y.status === "error" && (y.operation.kind === "copy" || y.operation.kind === "share"));
|
|
613
613
|
if (p && p.error?.code !== "interaction_not_started") throw new Error("The previous sharing action has an uncertain outcome.");
|
|
614
|
-
f = { kind: e.action, interactionId:
|
|
614
|
+
f = { kind: e.action, interactionId: l.id, variant: h.payload.variant, ...e.sharePlatform ? { platform: e.sharePlatform } : {} };
|
|
615
615
|
} else if (e.action === "connect") {
|
|
616
616
|
if (h?.payload.kind !== "integration_auth") throw new Error("Missing integration request.");
|
|
617
|
-
f = { kind: "connect", interactionId:
|
|
617
|
+
f = { kind: "connect", interactionId: l.id, authRequestId: h.payload.request_id, source: h };
|
|
618
618
|
} else if (e.action === "pair") {
|
|
619
619
|
if (h?.payload.kind !== "personal_channel") throw new Error("Missing channel request.");
|
|
620
|
-
f = { kind: "pair", interactionId:
|
|
620
|
+
f = { kind: "pair", interactionId: l.id, requestId: h.payload.request_id, managementUrl: h.payload.management_url };
|
|
621
621
|
} else {
|
|
622
|
-
const p = Bi(i,
|
|
622
|
+
const p = Bi(i, l.id, { clientScopeId: e.clientScopeId, conversationScopeId: n.clients[e.clientScopeId] });
|
|
623
623
|
if (p?.status === "error" && p.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
|
|
624
624
|
if (e.action !== "edit") {
|
|
625
625
|
if (a.profile.startsWith("extension_") && !e.origin) throw new Error("Task submission requires the current page origin.");
|
|
626
626
|
const k = xi(i.account, "send_message", e.origin ?? null);
|
|
627
627
|
if (!k.allowed) throw new Error(`Task submission unavailable: ${k.reason}.`);
|
|
628
628
|
}
|
|
629
|
-
const y = i.interactions.welcome[
|
|
629
|
+
const y = i.interactions.welcome[l.id], b = y.category === "morning_report" ? y.tasks[e.taskIndex ?? 0] : y.text;
|
|
630
630
|
if (!b) throw new Error("Missing selected task.");
|
|
631
631
|
f = {
|
|
632
632
|
kind: e.action === "edit" ? "edit" : "run",
|
|
633
|
-
interactionId:
|
|
633
|
+
interactionId: l.id,
|
|
634
634
|
text: b,
|
|
635
635
|
clientScopeId: e.clientScopeId,
|
|
636
636
|
conversationScopeId: n.clients[e.clientScopeId],
|
|
@@ -640,7 +640,7 @@ function Qr(t, e, s, n) {
|
|
|
640
640
|
}
|
|
641
641
|
const m = f.kind === "saveSharing" || f.kind === "saveHint" ? "persist" : "perform";
|
|
642
642
|
c(e.requestId, {
|
|
643
|
-
interactionId:
|
|
643
|
+
interactionId: l.id,
|
|
644
644
|
clientScopeId: e.clientScopeId,
|
|
645
645
|
conversationScopeId: n.clients[e.clientScopeId] ?? null,
|
|
646
646
|
taskIndex: e.taskIndex ?? null,
|
|
@@ -653,29 +653,29 @@ function Qr(t, e, s, n) {
|
|
|
653
653
|
error: null
|
|
654
654
|
}), d(e.requestId, f, m);
|
|
655
655
|
} else if (e.type === "stage7.retry_action") {
|
|
656
|
-
const
|
|
657
|
-
if (!
|
|
658
|
-
if (c(e.requestId, { ...
|
|
656
|
+
const u = i.interactions.actions[e.requestId];
|
|
657
|
+
if (!u || u.step !== "persist" || u.status !== "error") throw new Error("An uncertain browser action cannot be replayed.");
|
|
658
|
+
if (c(e.requestId, { ...u, status: "pending", error: null }), !a.profile.startsWith("extension_") && (u.operation.kind === "copy" || u.operation.kind === "share"))
|
|
659
659
|
return { state: i, effects: r, command: { type: "stage7.retry", authority: a, now: e.now, requestId: `sharing:${e.requestId}` } };
|
|
660
|
-
d(e.requestId,
|
|
660
|
+
d(e.requestId, u.operation, "persist");
|
|
661
661
|
} else {
|
|
662
|
-
const
|
|
663
|
-
if (!
|
|
664
|
-
const [
|
|
665
|
-
if (e.type === "effect.failed") c(
|
|
662
|
+
const u = Object.entries(i.interactions.actions).find(([f, m]) => o(f, m.step) === e.effectId && m.status === "pending");
|
|
663
|
+
if (!u) return { state: i, effects: r, command: null };
|
|
664
|
+
const [l, h] = u;
|
|
665
|
+
if (e.type === "effect.failed") c(l, { ...h, status: "error", error: e.error });
|
|
666
666
|
else if (h.operation.kind === "copy" || h.operation.kind === "share") {
|
|
667
667
|
if (!a.profile.startsWith("extension_"))
|
|
668
|
-
return c(
|
|
668
|
+
return c(l, { ...h, step: "persist", status: "pending" }), { state: i, effects: r, command: {
|
|
669
669
|
type: "stage7.mutate",
|
|
670
670
|
authority: a,
|
|
671
671
|
now: e.output.completedAt,
|
|
672
|
-
requestId: `sharing:${
|
|
672
|
+
requestId: `sharing:${l}`,
|
|
673
673
|
mutation: { kind: "decision", category: "social_share", promptKey: h.interactionId, action: "shared", expectedRevision: h.expectedRevision }
|
|
674
674
|
} };
|
|
675
675
|
const f = { kind: "saveSharing", interactionId: h.interactionId, expectedRevision: h.expectedRevision };
|
|
676
|
-
c(
|
|
676
|
+
c(l, { ...h, operation: f, step: "persist" }), d(l, f, "persist");
|
|
677
677
|
} else
|
|
678
|
-
c(
|
|
678
|
+
c(l, { ...h, status: "done" }), h.operation.kind === "saveHint" && (i = { ...i, interactions: { ...i.interactions, deviceHints: { ...i.interactions.deviceHints, [h.interactionId]: !0 } } }), h.operation.kind === "saveSharing" && (i = { ...i, interactions: { ...i.interactions, localSharing: {
|
|
679
679
|
...i.interactions.localSharing,
|
|
680
680
|
[h.interactionId]: { revision: e.output.revision, resolved: !0 }
|
|
681
681
|
} } });
|
|
@@ -688,35 +688,35 @@ function Fi(t) {
|
|
|
688
688
|
}
|
|
689
689
|
function Xr(t, e, s, n) {
|
|
690
690
|
let i = t;
|
|
691
|
-
const r = [], a = (
|
|
692
|
-
i = { ...i, ...
|
|
693
|
-
}, o = (
|
|
694
|
-
const h = i.pending[
|
|
695
|
-
a({ pending: { ...i.pending, [
|
|
691
|
+
const r = [], a = (l) => {
|
|
692
|
+
i = { ...i, ...l };
|
|
693
|
+
}, o = (l, h, f) => JSON.stringify(["stage7", e.authorityId, e.generation, l, h, ...f === void 0 ? [] : [f]]), c = (l, h) => Fi(l) && "origin" in l && l.origin === h, d = (l) => Object.values(i.pending).some((h) => h.mode === "mutation" && ["pending", "queued"].includes(h.status) && c(h.operation, l)), u = (l) => {
|
|
694
|
+
const h = i.pending[l];
|
|
695
|
+
a({ pending: { ...i.pending, [l]: { ...h, status: "pending" } } }), r.push({ kind: "stage7.query", id: l, input: { authority: e, requestId: h.requestId, query: h.operation } });
|
|
696
696
|
};
|
|
697
697
|
if (s.type === "stage7.query" && s.query.kind === "appearance") {
|
|
698
|
-
const
|
|
698
|
+
const l = { ...s.query, kind: "appearance" }, h = n(l);
|
|
699
699
|
if (Object.values(i.pending).some((p) => p.mode === "query" && p.key === h)) return { state: i, effects: r };
|
|
700
|
-
const f = o("query", s.requestId, i.appearanceEpochs[
|
|
701
|
-
if (m && m.fingerprint !== JSON.stringify(
|
|
700
|
+
const f = o("query", s.requestId, i.appearanceEpochs[l.origin] ?? 0), m = i.pending[f];
|
|
701
|
+
if (m && m.fingerprint !== JSON.stringify(l)) throw new Error("Query request ID changed payload.");
|
|
702
702
|
a({
|
|
703
|
-
appearanceQueries: { ...i.appearanceQueries, [h]:
|
|
703
|
+
appearanceQueries: { ...i.appearanceQueries, [h]: l },
|
|
704
704
|
queries: { ...i.queries, [h]: Ue(i.queries[h] ?? ye(h), { key: h, requestId: oe(s.requestId), mode: "replace" }) },
|
|
705
705
|
pending: { ...i.pending, [f]: {
|
|
706
706
|
requestId: s.requestId,
|
|
707
707
|
effectId: f,
|
|
708
|
-
fingerprint: JSON.stringify(
|
|
708
|
+
fingerprint: JSON.stringify(l),
|
|
709
709
|
key: h,
|
|
710
710
|
generation: e.generation,
|
|
711
|
-
operation:
|
|
711
|
+
operation: l,
|
|
712
712
|
mode: "query",
|
|
713
713
|
status: "queued",
|
|
714
714
|
error: null,
|
|
715
715
|
result: null
|
|
716
716
|
} }
|
|
717
|
-
}), d(
|
|
717
|
+
}), d(l.origin) || u(f);
|
|
718
718
|
} else if (s.type === "stage7.mutate" && (s.mutation.kind === "sampleStyle" || s.mutation.kind === "saveStyle" || s.mutation.kind === "scribble" || s.mutation.kind === "deleteStyle")) {
|
|
719
|
-
const
|
|
719
|
+
const l = s.mutation, h = l.origin, f = o("mutate", s.requestId), m = i.pending[f], p = JSON.stringify(l);
|
|
720
720
|
if (m) {
|
|
721
721
|
if (m.fingerprint !== p) throw new Error("Request ID was reused with a different payload.");
|
|
722
722
|
return { state: i, effects: r };
|
|
@@ -734,36 +734,36 @@ function Xr(t, e, s, n) {
|
|
|
734
734
|
fingerprint: p,
|
|
735
735
|
key: `appearance:${h}`,
|
|
736
736
|
generation: e.generation,
|
|
737
|
-
operation:
|
|
737
|
+
operation: l,
|
|
738
738
|
startedAt: s.now,
|
|
739
739
|
mode: "mutation",
|
|
740
740
|
status: y ? "queued" : "pending",
|
|
741
741
|
error: null,
|
|
742
742
|
result: null
|
|
743
|
-
}, a({ pending: k, appearanceEpochs: { ...i.appearanceEpochs, [h]: b } }), y || r.push({ kind: "stage7.mutate", id: f, input: { authority: e, requestId: s.requestId, mutation:
|
|
743
|
+
}, a({ pending: k, appearanceEpochs: { ...i.appearanceEpochs, [h]: b } }), y || r.push({ kind: "stage7.mutate", id: f, input: { authority: e, requestId: s.requestId, mutation: l } });
|
|
744
744
|
} else if (s.type === "effect.completed" || s.type === "effect.failed") {
|
|
745
|
-
const
|
|
746
|
-
if (!
|
|
747
|
-
const h =
|
|
745
|
+
const l = i.pending[s.effectId];
|
|
746
|
+
if (!l || l.status !== "pending" || !("origin" in l.operation)) return { state: i, effects: r };
|
|
747
|
+
const h = l.operation.origin;
|
|
748
748
|
if (s.effectKind !== "stage7.query" && s.effectKind !== "stage7.mutate") return { state: i, effects: r };
|
|
749
749
|
const f = s.type === "effect.completed" ? s.output.data : null;
|
|
750
750
|
if (f && (f.kind !== "appearance" || f.origin !== h)) throw new Error("Appearance response does not match its origin.");
|
|
751
751
|
const m = { ...i.pending }, p = { ...i.queries };
|
|
752
|
-
if (
|
|
752
|
+
if (l.mode === "query") {
|
|
753
753
|
delete m[s.effectId];
|
|
754
|
-
const y = p[
|
|
755
|
-
y?.requestId ===
|
|
756
|
-
} else if (m[s.effectId] = { ...
|
|
754
|
+
const y = p[l.key];
|
|
755
|
+
y?.requestId === l.requestId && (p[l.key] = s.type === "effect.failed" ? { ...y, status: "error", error: s.error, requestId: null } : { ...y, status: "ready", data: f, error: null, requestId: null, updatedAt: s.output.completedAt });
|
|
756
|
+
} else if (m[s.effectId] = { ...l, status: f ? "done" : "error", result: f, error: s.type === "effect.failed" ? s.error : null }, f && s.type === "effect.completed") {
|
|
757
757
|
for (const [y, b] of Object.entries(i.appearanceQueries))
|
|
758
758
|
b.origin === h && (p[y] = { ...p[y], status: "ready", data: f, requestId: null, error: null, updatedAt: s.output.completedAt });
|
|
759
759
|
for (const [y, b] of Object.entries(m)) b.mode === "query" && c(b.operation, h) && delete m[y];
|
|
760
760
|
} else if (s.type === "effect.failed")
|
|
761
761
|
for (const [y, b] of Object.entries(m)) b.mode === "mutation" && b.status === "queued" && c(b.operation, h) && (m[y] = { ...b, status: "error", error: { code: "appearance_write_cancelled", message: "Refresh appearance before saving again.", retryable: !1 } });
|
|
762
|
-
if (a({ pending: m, queries: p }),
|
|
762
|
+
if (a({ pending: m, queries: p }), l.mode === "mutation") {
|
|
763
763
|
const y = Object.values(i.pending).find((b) => b.mode === "mutation" && b.status === "queued" && c(b.operation, h));
|
|
764
764
|
if (y && (y.operation.kind === "sampleStyle" || y.operation.kind === "saveStyle" || y.operation.kind === "scribble" || y.operation.kind === "deleteStyle"))
|
|
765
765
|
a({ pending: { ...i.pending, [y.effectId]: { ...y, status: "pending" } } }), r.push({ kind: "stage7.mutate", id: y.effectId, input: { authority: e, requestId: y.requestId, mutation: y.operation } });
|
|
766
|
-
else for (const [b, k] of Object.entries(i.pending)) k.mode === "query" && k.status === "queued" && c(k.operation, h) &&
|
|
766
|
+
else for (const [b, k] of Object.entries(i.pending)) k.mode === "query" && k.status === "queued" && c(k.operation, h) && u(b);
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
return { state: i, effects: r };
|
|
@@ -817,7 +817,7 @@ function ie(t, e) {
|
|
|
817
817
|
"runId" in e ? e.runId : null
|
|
818
818
|
]);
|
|
819
819
|
}
|
|
820
|
-
function
|
|
820
|
+
function wt(t, e) {
|
|
821
821
|
return t.account.preferences?.[e === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"] ?? null;
|
|
822
822
|
}
|
|
823
823
|
const Zr = {
|
|
@@ -910,12 +910,12 @@ function Fs(t, e, s) {
|
|
|
910
910
|
const v = Fs(g.state, g.command, s);
|
|
911
911
|
return { state: v.state, effects: [...g.effects, ...v.effects] };
|
|
912
912
|
}
|
|
913
|
-
const
|
|
913
|
+
const u = (g, v, I) => {
|
|
914
914
|
const w = g === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
|
|
915
|
-
if (!X(o.profile, w) || n.features.desiredPreferences[g] === !1 || v === "check" &&
|
|
915
|
+
if (!X(o.profile, w) || n.features.desiredPreferences[g] === !1 || v === "check" && wt(n, g) !== !0 || Object.values(n.interactions.devicePending).some((T) => T.feature === g && (v === "check" || T.action !== "check"))) return;
|
|
916
916
|
const A = Se(o, "device", I), _ = { ...n.interactions.deviceErrors };
|
|
917
917
|
delete _[g], a({ deviceErrors: _, devicePending: { ...n.interactions.devicePending, [A]: { feature: g, requestId: I, generation: o.generation, desired: !0, action: v } } }), i.push({ kind: "stage7.device", id: A, input: { authority: o, requestId: I, feature: g, action: v, now: n.features.now } });
|
|
918
|
-
},
|
|
918
|
+
}, l = (g, v) => {
|
|
919
919
|
const I = v ? n.interactions.promptActions[v.replace(/:ack$/, "")] : void 0, w = { ...n.interactions.openings };
|
|
920
920
|
for (const [A, _] of Object.entries(w)) {
|
|
921
921
|
if (I?.scope === A && I.openingGeneration === _.generation && ["enable", "allow"].includes(I.action)) continue;
|
|
@@ -931,17 +931,17 @@ function Fs(t, e, s) {
|
|
|
931
931
|
if (g.kind === "preferences" && n.account.preferences && g.value.preferencesVersion > n.account.preferences.preferencesVersion)
|
|
932
932
|
for (const I of ["notifications", "tab_grouping"]) {
|
|
933
933
|
const w = I === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled";
|
|
934
|
-
g.value[w] !== n.account.preferences[w] &&
|
|
934
|
+
g.value[w] !== n.account.preferences[w] && l(I, v);
|
|
935
935
|
}
|
|
936
936
|
if (g.kind === "preferencePrompts" || g.kind === "preferencePrompt")
|
|
937
937
|
for (const I of ["notifications", "tab_grouping"]) {
|
|
938
938
|
const w = g.kind === "preferencePrompts" ? g.value[I] : g.feature === I ? g.value : null;
|
|
939
|
-
w && w.revision > n.interactions.preferencePrompts[I].revision &&
|
|
939
|
+
w && w.revision > n.interactions.preferencePrompts[I].revision && l(I, w.requestId);
|
|
940
940
|
}
|
|
941
|
-
g.kind === "preferences" && (n = { ...n, account: Yr(n.account, g.value) }), g.kind === "preferencePrompts" && (n = { ...n, interactions: jn(n.interactions, g.value) }), g.kind === "preferencePrompt" && (n = { ...n, interactions: jn(n.interactions, { ...n.interactions.preferencePrompts, [g.feature]: g.value }) }), g.kind === "decisions" && (n = { ...n, interactions:
|
|
941
|
+
g.kind === "preferences" && (n = { ...n, account: Yr(n.account, g.value) }), g.kind === "preferencePrompts" && (n = { ...n, interactions: jn(n.interactions, g.value) }), g.kind === "preferencePrompt" && (n = { ...n, interactions: jn(n.interactions, { ...n.interactions.preferencePrompts, [g.feature]: g.value }) }), g.kind === "decisions" && (n = { ...n, interactions: is(n.interactions, g.decisions) }), g.kind === "decision" && (n = { ...n, interactions: is(n.interactions, [g.value]) });
|
|
942
942
|
}, f = (g, v) => {
|
|
943
943
|
const I = n.interactions.deviceFacts[g];
|
|
944
|
-
if (!(v.revision <= I.revision) && ((
|
|
944
|
+
if (!(v.revision <= I.revision) && ((wt(n, g) === !0 || n.features.desiredPreferences[g] === !0) && (v.permission === "granted" && I.permission !== "granted" || v.snoozedUntil && v.snoozedUntil !== I.snoozedUntil) && l(g, null), a({ deviceFacts: { ...n.interactions.deviceFacts, [g]: v } }), n.features.desiredPreferences[g] === !0 && wt(n, g) !== !0)) {
|
|
945
945
|
const w = Object.values(n.features.pending).filter((A) => A.mode === "mutation" && A.key === `preference:${g}`);
|
|
946
946
|
if (v.permission === "granted" && !w.some((A) => A.status === "pending" || A.status === "error"))
|
|
947
947
|
p({ kind: "preference", feature: g, enabled: !0 }, `permission:${g}:${v.revision}`);
|
|
@@ -1030,7 +1030,7 @@ function Fs(t, e, s) {
|
|
|
1030
1030
|
};
|
|
1031
1031
|
switch (e.type) {
|
|
1032
1032
|
case "stage7.account_refusal": {
|
|
1033
|
-
const g =
|
|
1033
|
+
const g = xt(void 0, e.code);
|
|
1034
1034
|
if (g.allowed) return { state: n, effects: i };
|
|
1035
1035
|
const v = { ...n.features.queries }, I = { ...n.features.pending }, w = [];
|
|
1036
1036
|
for (const [A, _] of Object.entries(I)) {
|
|
@@ -1082,7 +1082,7 @@ function Fs(t, e, s) {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
break;
|
|
1084
1084
|
case "stage7.observe_work":
|
|
1085
|
-
n =
|
|
1085
|
+
n = ss(n, s.conversation, s.directory, e.now);
|
|
1086
1086
|
break;
|
|
1087
1087
|
case "stage7.bridge_ready":
|
|
1088
1088
|
a({ bridgeReady: e.ready, bridgeError: e.ready ? null : e.error ?? null });
|
|
@@ -1097,7 +1097,7 @@ function Fs(t, e, s) {
|
|
|
1097
1097
|
const g = s.directory.clients[e.clientScopeId];
|
|
1098
1098
|
if (!g) break;
|
|
1099
1099
|
const v = { ...n.interactions.openings };
|
|
1100
|
-
e.open || delete v[g], a({ openings: v, closedScopes: { ...n.interactions.closedScopes, [g]: !e.open } }), n =
|
|
1100
|
+
e.open || delete v[g], a({ openings: v, closedScopes: { ...n.interactions.closedScopes, [g]: !e.open } }), n = ss(n, s.conversation, s.directory, e.now);
|
|
1101
1101
|
break;
|
|
1102
1102
|
}
|
|
1103
1103
|
case "stage7.prompt_shown": {
|
|
@@ -1124,7 +1124,7 @@ function Fs(t, e, s) {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
const g = n.interactions.deviceFacts[e.feature].snoozedUntil;
|
|
1126
1126
|
if (!e.settings && g && Date.parse(g) > e.now) break;
|
|
1127
|
-
|
|
1127
|
+
u(e.feature, e.action, e.requestId);
|
|
1128
1128
|
break;
|
|
1129
1129
|
}
|
|
1130
1130
|
case "stage7.device_fact":
|
|
@@ -1132,7 +1132,7 @@ function Fs(t, e, s) {
|
|
|
1132
1132
|
break;
|
|
1133
1133
|
case "stage7.import_legacy_decisions":
|
|
1134
1134
|
if (!o.profile.startsWith("extension_") || e.decisions.some((g) => g.revision !== 0)) throw new Error("Invalid legacy decision import.");
|
|
1135
|
-
n = { ...n, interactions:
|
|
1135
|
+
n = { ...n, interactions: is(n.interactions, e.decisions) };
|
|
1136
1136
|
break;
|
|
1137
1137
|
case "stage7.device_hints": {
|
|
1138
1138
|
if (o.profile !== "main_web_chat") throw new Error("Main-web hints unavailable.");
|
|
@@ -1195,7 +1195,7 @@ function Fs(t, e, s) {
|
|
|
1195
1195
|
if (e.effectKind === "stage7.wait") {
|
|
1196
1196
|
if (e.effectId !== n.features.timerId) break;
|
|
1197
1197
|
if (r({ timerId: null, timerDeadline: null, schedulerError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed") {
|
|
1198
|
-
r({ now: e.output.now }), n =
|
|
1198
|
+
r({ now: e.output.now }), n = ss(n, s.conversation, s.directory, e.output.now);
|
|
1199
1199
|
for (const [I, w] of Object.entries(n.features.polls)) {
|
|
1200
1200
|
if (w.deadline > e.output.now) continue;
|
|
1201
1201
|
Object.values(n.features.pending).some((_) => _.mode === "query" && _.key === I && _.status === "pending") || m(w.query.kind === "originContext" ? { ...w.query, trigger: "poll" } : w.query, `poll:${I}:${e.output.now}`, !0);
|
|
@@ -1213,7 +1213,7 @@ function Fs(t, e, s) {
|
|
|
1213
1213
|
if (delete w[e.effectId], a({ devicePending: w }), e.type === "effect.completed") {
|
|
1214
1214
|
if (I.action !== "check" && n.interactions.promptActions[I.requestId] && !n.features.pending[Se(o, "mutate", `${I.requestId}:ack`)]) {
|
|
1215
1215
|
const A = n.interactions.promptActions[I.requestId];
|
|
1216
|
-
|
|
1216
|
+
l(A.feature, I.requestId), p({
|
|
1217
1217
|
kind: "preferenceAcknowledge",
|
|
1218
1218
|
feature: A.feature,
|
|
1219
1219
|
action: A.action,
|
|
@@ -1243,7 +1243,7 @@ function Fs(t, e, s) {
|
|
|
1243
1243
|
r({ queries: { ...n.features.queries, [g.key]: dt(w, { key: g.key, requestId: oe(g.requestId), error: e.error }) } }), g.operation.kind === "account" && (n = { ...n, account: { ...n.account, query: dt(n.account.query, { key: g.key, requestId: oe(g.requestId), error: e.error }) } });
|
|
1244
1244
|
else {
|
|
1245
1245
|
if (e.output.data.kind !== g.operation.kind) throw new Error("Feature response kind does not match the query.");
|
|
1246
|
-
r({ now: e.output.completedAt, queries: { ...n.features.queries, [g.key]:
|
|
1246
|
+
r({ now: e.output.completedAt, queries: { ...n.features.queries, [g.key]: ns(w, { key: g.key, requestId: oe(g.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } }), h(e.output.data, g.requestId), e.output.data.kind === "account" && (n = { ...n, account: { ...n.account, refusal: null, query: ns(n.account.query, { key: g.key, requestId: oe(g.requestId), data: e.output.data.value, cursor: null, updatedAt: e.output.completedAt }) } });
|
|
1247
1247
|
}
|
|
1248
1248
|
} else if (!v)
|
|
1249
1249
|
r({ now: e.output.completedAt }), h(e.output.data, g.requestId);
|
|
@@ -1259,7 +1259,7 @@ function Fs(t, e, s) {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
if (!v && g.mode === "mutation" && g.operation.kind === "preference" && n.interactions.promptActions[g.requestId]) {
|
|
1261
1261
|
const I = n.interactions.promptActions[g.requestId];
|
|
1262
|
-
|
|
1262
|
+
l(I.feature, g.requestId), p({
|
|
1263
1263
|
kind: "preferenceAcknowledge",
|
|
1264
1264
|
feature: I.feature,
|
|
1265
1265
|
action: I.action,
|
|
@@ -1268,7 +1268,7 @@ function Fs(t, e, s) {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
if (b(e.effectId, v), g.operation.kind === "generatePrompts") {
|
|
1270
1270
|
const I = { kind: "starterPrompts", ...g.operation.page, includeUserSuggestions: g.operation.includeUserSuggestions ?? !1 }, w = ie(o, I), A = n.features.queries[w];
|
|
1271
|
-
A?.requestId === g.requestId && r({ queries: { ...n.features.queries, [w]: v ? dt(A, { key: w, requestId: oe(g.requestId), error: e.error }) :
|
|
1271
|
+
A?.requestId === g.requestId && r({ queries: { ...n.features.queries, [w]: v ? dt(A, { key: w, requestId: oe(g.requestId), error: e.error }) : ns(A, { key: w, requestId: oe(g.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } });
|
|
1272
1272
|
}
|
|
1273
1273
|
if (!v && e.output.data.kind === "originContext") {
|
|
1274
1274
|
const I = e.output.data, w = g.operation.kind === "originContext" || g.operation.kind === "refreshContext" ? g.operation.origin : null;
|
|
@@ -1344,7 +1344,7 @@ function Fs(t, e, s) {
|
|
|
1344
1344
|
delete A[I], r({ desiredPreferences: A });
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
|
-
if (!v && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"])
|
|
1347
|
+
if (!v && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) u(I, "check", `preference:${g.requestId}:${I}`);
|
|
1348
1348
|
n.features.refreshRequired && !n.features.refreshBatch && !n.features.refreshQueuedRequestId && ["account", "preferences", "preferencePrompts", "decisions"].every((I) => Object.values(n.features.queries).some((w) => w.data?.kind === I && w.status === "ready")) && r({ refreshRequired: !1 });
|
|
1349
1349
|
break;
|
|
1350
1350
|
}
|
|
@@ -1365,11 +1365,11 @@ function Fs(t, e, s) {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
return { state: n, effects: i };
|
|
1367
1367
|
}
|
|
1368
|
-
function
|
|
1368
|
+
function Dt(t, e) {
|
|
1369
1369
|
return t.account.authority ? t.features.queries[ie(t.account.authority, e)] ?? null : null;
|
|
1370
1370
|
}
|
|
1371
1371
|
function eo(t, e) {
|
|
1372
|
-
const s =
|
|
1372
|
+
const s = Dt(t, e);
|
|
1373
1373
|
return s?.status === "loading" || s?.status === "refreshing" || !!(t.account.authority && t.features.polls[ie(t.account.authority, e)]);
|
|
1374
1374
|
}
|
|
1375
1375
|
const to = {
|
|
@@ -1386,13 +1386,13 @@ function so(t, e, s, n) {
|
|
|
1386
1386
|
const a = (d) => {
|
|
1387
1387
|
if (JSON.stringify(s()) !== JSON.stringify(d)) throw new Error("Feature authority retired.");
|
|
1388
1388
|
}, o = (d) => {
|
|
1389
|
-
const
|
|
1390
|
-
return i =
|
|
1391
|
-
}),
|
|
1389
|
+
const u = i.then(() => e.exclusive ? e.exclusive("local", d) : d());
|
|
1390
|
+
return i = u.catch(() => {
|
|
1391
|
+
}), u;
|
|
1392
1392
|
}, c = (d) => {
|
|
1393
1393
|
if (r) return;
|
|
1394
1394
|
r = !0;
|
|
1395
|
-
const
|
|
1395
|
+
const u = async () => {
|
|
1396
1396
|
for (; ; ) {
|
|
1397
1397
|
a(d);
|
|
1398
1398
|
const h = (await o(() => e.load(d.userId)))?.pending[0];
|
|
@@ -1404,8 +1404,8 @@ function so(t, e, s, n) {
|
|
|
1404
1404
|
});
|
|
1405
1405
|
}
|
|
1406
1406
|
};
|
|
1407
|
-
(e.exclusive ? e.exclusive("sync",
|
|
1408
|
-
console.warn("Product Agent preference backup remains pending",
|
|
1407
|
+
(e.exclusive ? e.exclusive("sync", u) : u()).catch((l) => {
|
|
1408
|
+
console.warn("Product Agent preference backup remains pending", l);
|
|
1409
1409
|
}).finally(() => {
|
|
1410
1410
|
r = !1;
|
|
1411
1411
|
});
|
|
@@ -1414,17 +1414,17 @@ function so(t, e, s, n) {
|
|
|
1414
1414
|
"stage7.query": async (d) => {
|
|
1415
1415
|
if (d.query.kind !== "preferences") return t["stage7.query"](d);
|
|
1416
1416
|
a(d.authority), Ce(d.authority, d.query);
|
|
1417
|
-
const
|
|
1418
|
-
let
|
|
1419
|
-
if (!
|
|
1417
|
+
const u = d.query.refreshSecurity;
|
|
1418
|
+
let l = await o(() => e.load(d.authority.userId));
|
|
1419
|
+
if (!l || u) {
|
|
1420
1420
|
const h = await t["stage7.query"](d);
|
|
1421
1421
|
if (h.data.kind !== "preferences") throw new Error("Invalid preference result.");
|
|
1422
1422
|
const f = h.data.value;
|
|
1423
|
-
|
|
1423
|
+
l = await o(async () => {
|
|
1424
1424
|
a(d.authority);
|
|
1425
1425
|
const m = await e.load(d.authority.userId);
|
|
1426
1426
|
if (m) {
|
|
1427
|
-
if (!
|
|
1427
|
+
if (!u || (f.securityPolicyVersion ?? 1) < (m.value.securityPolicyVersion ?? 1)) return m;
|
|
1428
1428
|
const y = { ...m, value: {
|
|
1429
1429
|
...m.value,
|
|
1430
1430
|
blockedOrigins: f.blockedOrigins,
|
|
@@ -1437,12 +1437,12 @@ function so(t, e, s, n) {
|
|
|
1437
1437
|
return await e.save(d.authority.userId, p), p;
|
|
1438
1438
|
});
|
|
1439
1439
|
}
|
|
1440
|
-
return a(d.authority), c(d.authority), { data: { kind: "preferences", value:
|
|
1440
|
+
return a(d.authority), c(d.authority), { data: { kind: "preferences", value: l.value }, completedAt: n() };
|
|
1441
1441
|
},
|
|
1442
1442
|
"stage7.mutate": async (d) => {
|
|
1443
1443
|
a(d.authority), Ce(d.authority, d.mutation);
|
|
1444
|
-
const
|
|
1445
|
-
if (
|
|
1444
|
+
const u = d.mutation;
|
|
1445
|
+
if (u.kind === "blockedOrigins" || u.kind === "personalInstructions") {
|
|
1446
1446
|
const h = async (f) => {
|
|
1447
1447
|
if (f.data.kind !== "preferences") throw new Error("Invalid preference result.");
|
|
1448
1448
|
const m = f.data.value;
|
|
@@ -1450,23 +1450,23 @@ function so(t, e, s, n) {
|
|
|
1450
1450
|
a(d.authority);
|
|
1451
1451
|
const y = await e.load(d.authority.userId), b = {
|
|
1452
1452
|
...y?.value ?? m,
|
|
1453
|
-
...
|
|
1453
|
+
...u.kind === "personalInstructions" ? { personalInstructions: m.personalInstructions } : { blockedOrigins: m.blockedOrigins, securityPolicyVersion: m.securityPolicyVersion },
|
|
1454
1454
|
preferencesVersion: Math.max(y?.value.preferencesVersion ?? 0, m.preferencesVersion) + 1
|
|
1455
1455
|
};
|
|
1456
1456
|
return await e.save(d.authority.userId, { value: b, pending: y?.pending ?? [] }), b;
|
|
1457
1457
|
}) }, completedAt: n() };
|
|
1458
1458
|
};
|
|
1459
1459
|
return t["stage7.mutate"](d).then(h, async (f) => {
|
|
1460
|
-
throw
|
|
1460
|
+
throw u.kind === "personalInstructions" || await h(await t["stage7.query"]({ authority: d.authority, requestId: d.requestId, query: { kind: "preferences" } })), f;
|
|
1461
1461
|
});
|
|
1462
1462
|
}
|
|
1463
|
-
if (
|
|
1464
|
-
const
|
|
1463
|
+
if (u.kind !== "preference" && u.kind !== "scribblePreference") return t["stage7.mutate"](d);
|
|
1464
|
+
const l = await o(async () => {
|
|
1465
1465
|
a(d.authority);
|
|
1466
|
-
const h = await e.load(d.authority.userId), f = h?.value ?? to, m =
|
|
1467
|
-
return await e.save(d.authority.userId, { value: p, pending: [...h?.pending ?? [],
|
|
1466
|
+
const h = await e.load(d.authority.userId), f = h?.value ?? to, m = u.kind === "preference" ? { [u.feature === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"]: u.enabled } : { scribbleStyleEnabled: u.enabled }, p = { ...f, ...m, preferencesVersion: f.preferencesVersion + 1 };
|
|
1467
|
+
return await e.save(d.authority.userId, { value: p, pending: [...h?.pending ?? [], u] }), p;
|
|
1468
1468
|
});
|
|
1469
|
-
return a(d.authority), c(d.authority), { data: { kind: "preferences", value:
|
|
1469
|
+
return a(d.authority), c(d.authority), { data: { kind: "preferences", value: l }, completedAt: n() };
|
|
1470
1470
|
}
|
|
1471
1471
|
};
|
|
1472
1472
|
}
|
|
@@ -1528,14 +1528,14 @@ function Be(t) {
|
|
|
1528
1528
|
if (typeof t != "boolean") throw new Error("Invalid feature response boolean.");
|
|
1529
1529
|
return t;
|
|
1530
1530
|
}
|
|
1531
|
-
function
|
|
1531
|
+
function rs(t) {
|
|
1532
1532
|
return t === null ? null : Be(t);
|
|
1533
1533
|
}
|
|
1534
|
-
function
|
|
1534
|
+
function _t(t) {
|
|
1535
1535
|
if (!Array.isArray(t)) throw new Error("Invalid feature string list.");
|
|
1536
1536
|
return t.map(P);
|
|
1537
1537
|
}
|
|
1538
|
-
function
|
|
1538
|
+
function Ut(t) {
|
|
1539
1539
|
const e = de(t);
|
|
1540
1540
|
if (e !== null && !Number.isFinite(Date.parse(e))) throw new Error("Invalid feature deadline.");
|
|
1541
1541
|
return e;
|
|
@@ -1543,31 +1543,31 @@ function Dt(t) {
|
|
|
1543
1543
|
function He(t) {
|
|
1544
1544
|
const e = N(t);
|
|
1545
1545
|
return {
|
|
1546
|
-
taskNotificationsEnabled:
|
|
1547
|
-
tabGroupingEnabled:
|
|
1546
|
+
taskNotificationsEnabled: rs(e.taskNotificationsEnabled),
|
|
1547
|
+
tabGroupingEnabled: rs(e.tabGroupingEnabled),
|
|
1548
1548
|
preferencesVersion: Oe(e.preferencesVersion),
|
|
1549
|
-
scribbleStyleEnabled:
|
|
1550
|
-
blockedOrigins:
|
|
1549
|
+
scribbleStyleEnabled: rs(e.scribbleStyleEnabled),
|
|
1550
|
+
blockedOrigins: _t(e.blockedServiceOrigins),
|
|
1551
1551
|
personalInstructions: de(e.personalInstructions),
|
|
1552
1552
|
securityPolicyVersion: Oe(e.securityPolicyVersion)
|
|
1553
1553
|
};
|
|
1554
1554
|
}
|
|
1555
|
-
function
|
|
1555
|
+
function Nt(t) {
|
|
1556
1556
|
const e = N(t);
|
|
1557
|
-
return { eligibleSince:
|
|
1557
|
+
return { eligibleSince: Ut(e.eligibleSince), revision: Oe(e.revision), requestId: de(e.requestId), snoozedUntil: Ut(e.snoozedUntil) };
|
|
1558
1558
|
}
|
|
1559
1559
|
function io(t) {
|
|
1560
1560
|
const e = N(t);
|
|
1561
|
-
return { notifications:
|
|
1561
|
+
return { notifications: Nt(e.notifications), tab_grouping: Nt(e.tabGrouping) };
|
|
1562
1562
|
}
|
|
1563
1563
|
function Fn(t) {
|
|
1564
1564
|
const e = N(t), s = N(e.request), n = P(s.category), i = P(s.action), r = { category: n, action: i, promptKey: P(s.promptKey), expectedRevision: Oe(s.expectedRevision) };
|
|
1565
1565
|
ln(r);
|
|
1566
1566
|
const a = P(e.outcome);
|
|
1567
1567
|
if (!["resolved", "snoozed", "suppressed"].includes(a)) throw new Error("Invalid decision outcome.");
|
|
1568
|
-
const o =
|
|
1568
|
+
const o = Ut(e.decidedAt);
|
|
1569
1569
|
if (o === null) throw new Error("Missing decision acceptance time.");
|
|
1570
|
-
const c =
|
|
1570
|
+
const c = Ut(e.nextEligibleAt);
|
|
1571
1571
|
if (a === "snoozed" && c === null) throw new Error("Missing decision deadline.");
|
|
1572
1572
|
return {
|
|
1573
1573
|
decisionKey: P(e.decisionKey),
|
|
@@ -1578,7 +1578,7 @@ function Fn(t) {
|
|
|
1578
1578
|
nextEligibleAt: c
|
|
1579
1579
|
};
|
|
1580
1580
|
}
|
|
1581
|
-
function
|
|
1581
|
+
function os(t) {
|
|
1582
1582
|
const e = N(t);
|
|
1583
1583
|
return {
|
|
1584
1584
|
eventTypeRegex: P(e.eventTypeRegex),
|
|
@@ -1591,14 +1591,14 @@ function rs(t) {
|
|
|
1591
1591
|
function ro(t) {
|
|
1592
1592
|
const e = N(t), s = N(e.condition), n = { id: P(e.id), suggestedQuery: P(e.suggestedQuery) };
|
|
1593
1593
|
if (s.template === "page_visit") return { ...n, condition: { template: s.template, urlRegex: P(s.urlRegex) } };
|
|
1594
|
-
if (s.template === "semantic_interaction") return { ...n, condition: { template: s.template, event:
|
|
1594
|
+
if (s.template === "semantic_interaction") return { ...n, condition: { template: s.template, event: os(s.event) } };
|
|
1595
1595
|
if (s.template === "event_sequence") {
|
|
1596
1596
|
if (!Array.isArray(s.steps)) throw new Error("Invalid proactive sequence.");
|
|
1597
|
-
return { ...n, condition: { template: s.template, steps: s.steps.map(
|
|
1597
|
+
return { ...n, condition: { template: s.template, steps: s.steps.map(os), withinSeconds: Oe(s.withinSeconds) } };
|
|
1598
1598
|
}
|
|
1599
1599
|
if (s.template === "page_state_after_event") {
|
|
1600
1600
|
const i = N(s.state);
|
|
1601
|
-
return { ...n, condition: { template: s.template, event:
|
|
1601
|
+
return { ...n, condition: { template: s.template, event: os(s.event), withinSeconds: Oe(s.withinSeconds), state: {
|
|
1602
1602
|
urlRegex: P(i.urlRegex),
|
|
1603
1603
|
...i.textRegex == null ? {} : { textRegex: P(i.textRegex) },
|
|
1604
1604
|
...i.roleRegex == null ? {} : { roleRegex: P(i.roleRegex) },
|
|
@@ -1634,7 +1634,7 @@ function ut(t) {
|
|
|
1634
1634
|
if (!Be(e.success)) throw new Error(de(e.message) ?? "Failed to submit feedback");
|
|
1635
1635
|
return { kind: "ack", success: !0 };
|
|
1636
1636
|
}
|
|
1637
|
-
function
|
|
1637
|
+
function as(t) {
|
|
1638
1638
|
const e = t.page;
|
|
1639
1639
|
return {
|
|
1640
1640
|
community_id: t.communityId,
|
|
@@ -1664,7 +1664,7 @@ function oo(t) {
|
|
|
1664
1664
|
}, s = {
|
|
1665
1665
|
"stage7.query": async ({ authority: n, query: i, requestId: r }) => {
|
|
1666
1666
|
e(n), Ce(n, i);
|
|
1667
|
-
const a = n.profile.startsWith("embedded_"), o = (d,
|
|
1667
|
+
const a = n.profile.startsWith("embedded_"), o = (d, u = {}) => t.http.request(d, u, void 0, "GET", a ? "embed" : "runtime");
|
|
1668
1668
|
let c;
|
|
1669
1669
|
switch (i.kind) {
|
|
1670
1670
|
case "account":
|
|
@@ -1684,7 +1684,7 @@ function oo(t) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
case "starterPrompts": {
|
|
1686
1686
|
const d = N(await o("/starter-prompts", a ? { page_url: i.pageUrl } : { origin: i.origin, page_url: i.pageUrl, include_user_suggestions: i.includeUserSuggestions }));
|
|
1687
|
-
c = { kind: "starterPrompts", origin: i.origin, prompts:
|
|
1687
|
+
c = { kind: "starterPrompts", origin: i.origin, prompts: _t(d.starterPrompts), ...d.runtimeHelpers === void 0 ? {} : { runtimeHelpersJavascript: d.runtimeHelpers === null ? null : de(N(d.runtimeHelpers).javascript) } };
|
|
1688
1688
|
break;
|
|
1689
1689
|
}
|
|
1690
1690
|
case "userSuggestedTasks": {
|
|
@@ -1692,7 +1692,7 @@ function oo(t) {
|
|
|
1692
1692
|
if (!Array.isArray(d.proactiveSuggestions)) throw new Error("Invalid proactive suggestions.");
|
|
1693
1693
|
c = {
|
|
1694
1694
|
kind: "userSuggestedTasks",
|
|
1695
|
-
prompts:
|
|
1695
|
+
prompts: _t(d.starterPrompts),
|
|
1696
1696
|
morningReportOpening: de(d.morningReportOpening),
|
|
1697
1697
|
signupAt: P(d.signupAt),
|
|
1698
1698
|
proactiveSuggestions: d.proactiveSuggestions.map(ro)
|
|
@@ -1701,9 +1701,9 @@ function oo(t) {
|
|
|
1701
1701
|
}
|
|
1702
1702
|
case "originContext": {
|
|
1703
1703
|
const d = { requestId: r, origin: i.origin, trigger: i.trigger ?? "page" };
|
|
1704
|
-
t.onContextStatusRead?.({ ...d, phase: "started" }), c = await o("/context/status", { origin: i.origin, community_id: n.communityId }).then((
|
|
1705
|
-
const
|
|
1706
|
-
throw t.onContextStatusRead?.({ ...d, phase: "failed", code:
|
|
1704
|
+
t.onContextStatusRead?.({ ...d, phase: "started" }), c = await o("/context/status", { origin: i.origin, community_id: n.communityId }).then((u) => Ve("originContext", u)).then((u) => (t.onContextStatusRead?.({ ...d, phase: "ready" }), u), (u) => {
|
|
1705
|
+
const l = Y(u);
|
|
1706
|
+
throw t.onContextStatusRead?.({ ...d, phase: "failed", code: l.code, retryable: l.retryable }), u;
|
|
1707
1707
|
});
|
|
1708
1708
|
break;
|
|
1709
1709
|
}
|
|
@@ -1724,7 +1724,7 @@ function oo(t) {
|
|
|
1724
1724
|
},
|
|
1725
1725
|
"stage7.mutate": async ({ authority: n, mutation: i, requestId: r }) => {
|
|
1726
1726
|
e(n), Ce(n, i);
|
|
1727
|
-
const a = n.profile.startsWith("embedded_"), o = (d,
|
|
1727
|
+
const a = n.profile.startsWith("embedded_"), o = (d, u, l = "POST", h = {}) => t.http.request(d, h, u, l, a ? "embed" : "runtime", { readOnly: !1 });
|
|
1728
1728
|
let c;
|
|
1729
1729
|
switch (i.kind) {
|
|
1730
1730
|
case "preference":
|
|
@@ -1740,20 +1740,20 @@ function oo(t) {
|
|
|
1740
1740
|
c = { kind: "preferences", value: He(await o("/preferences", { blocked_service_origins: i.origins, security_policy_version: i.expectedSecurityVersion }, "PATCH")) };
|
|
1741
1741
|
break;
|
|
1742
1742
|
case "preferenceAcknowledge":
|
|
1743
|
-
c = { kind: "preferencePrompt", feature: i.feature, value:
|
|
1743
|
+
c = { kind: "preferencePrompt", feature: i.feature, value: Nt(await o(`/preference-prompts/${i.feature}/acknowledge`, { request_id: r, expected_revision: i.expectedRevision, action: i.action })) };
|
|
1744
1744
|
break;
|
|
1745
1745
|
case "preferenceSnooze":
|
|
1746
|
-
c = { kind: "preferencePrompt", feature: i.feature, value:
|
|
1746
|
+
c = { kind: "preferencePrompt", feature: i.feature, value: Nt(await o(`/preference-prompts/${i.feature}/snooze`, { request_id: r, expected_revision: i.expectedRevision })) };
|
|
1747
1747
|
break;
|
|
1748
1748
|
case "decision":
|
|
1749
1749
|
c = { kind: "decision", value: Fn(await o("/interaction-decisions", { category: i.category, prompt_key: i.promptKey, action: i.action, request_id: r, expected_revision: i.expectedRevision })) };
|
|
1750
1750
|
break;
|
|
1751
1751
|
case "feedback":
|
|
1752
|
-
c = ut(a ? { success: await t.embedded.feedback(i.message) } : await o("/feedback", { ...
|
|
1752
|
+
c = ut(a ? { success: await t.embedded.feedback(i.message) } : await o("/feedback", { ...as(i.context), feedback_type: "general", message: i.message }));
|
|
1753
1753
|
break;
|
|
1754
1754
|
case "proactiveFeedback":
|
|
1755
1755
|
c = ut(await o("/feedback", {
|
|
1756
|
-
...
|
|
1756
|
+
...as(i.context),
|
|
1757
1757
|
feedback_type: "proactive_suggestion",
|
|
1758
1758
|
proactive_suggestion_action: "feedback",
|
|
1759
1759
|
proactive_suggestion_id: i.suggestionId,
|
|
@@ -1766,17 +1766,17 @@ function oo(t) {
|
|
|
1766
1766
|
c = ut(await o("/feedback/target", { feedback_type: "target_rating", target_id: i.targetId, rating: i.rating, ...i.comment === void 0 ? {} : { comment: i.comment } }));
|
|
1767
1767
|
break;
|
|
1768
1768
|
case "report":
|
|
1769
|
-
c = ut(await o("/feedback", { ...
|
|
1769
|
+
c = ut(await o("/feedback", { ...as(i.context), feedback_type: "chat_report", session_id: i.sessionId, message: i.message, ui_evidence: i.uiEvidence, widget_evidence_available: i.widgetEvidenceAvailable }));
|
|
1770
1770
|
break;
|
|
1771
1771
|
case "generatePrompts": {
|
|
1772
1772
|
const d = N(await o("/starter-prompts", { page_url: i.page.pageUrl, html_content: i.htmlContent, page_title: i.pageTitle }, "POST", a ? {} : { origin: i.page.origin, include_user_suggestions: i.includeUserSuggestions ?? !1 }));
|
|
1773
|
-
c = { kind: "starterPrompts", origin: i.page.origin, prompts:
|
|
1773
|
+
c = { kind: "starterPrompts", origin: i.page.origin, prompts: _t(d.starterPrompts) };
|
|
1774
1774
|
break;
|
|
1775
1775
|
}
|
|
1776
1776
|
case "refreshContext": {
|
|
1777
|
-
const d = N(await o("/context/refresh", { origin: i.origin, community_id: i.communityId })),
|
|
1778
|
-
if (
|
|
1779
|
-
c = { ...
|
|
1777
|
+
const d = N(await o("/context/refresh", { origin: i.origin, community_id: i.communityId })), u = Ve("originContext", d.status);
|
|
1778
|
+
if (u.kind !== "originContext") throw new Error("Invalid origin context result.");
|
|
1779
|
+
c = { ...u, value: { ...u.value, runId: P(d.runId), status: d.queued === !0 ? "queued" : u.value.status } };
|
|
1780
1780
|
break;
|
|
1781
1781
|
}
|
|
1782
1782
|
case "refreshUserContext":
|
|
@@ -1842,7 +1842,7 @@ function co(t, e) {
|
|
|
1842
1842
|
async function lo(t, e, s) {
|
|
1843
1843
|
await t.engine.dispatch({ type: "stage7.initialize", authority: e, now: s }), await t.engine.dispatch({ type: "stage7.reconcile", authority: e, now: s, requestId: crypto.randomUUID(), reason: "startup" });
|
|
1844
1844
|
}
|
|
1845
|
-
function
|
|
1845
|
+
function cs(t, e, s = {}) {
|
|
1846
1846
|
return $i(t, { type: "stage7.query", query: e, force: s.force });
|
|
1847
1847
|
}
|
|
1848
1848
|
function uo(t, e, s) {
|
|
@@ -1853,11 +1853,11 @@ function $i(t, e, s) {
|
|
|
1853
1853
|
if (!n || t.isDisposed) return Promise.reject(new Error("Product Agent is not authenticated."));
|
|
1854
1854
|
const r = (e.type === "stage7.mutate" && ["generatePrompts", "sampleStyle"].includes(e.mutation.kind) ? Object.values(t.engine.getState().slices.features.pending).find((a) => a.status === "pending" && a.mode === "mutation" && a.fingerprint === JSON.stringify(e.mutation)) : null)?.requestId ?? crypto.randomUUID();
|
|
1855
1855
|
return new Promise((a, o) => {
|
|
1856
|
-
let c = !1, d = !1,
|
|
1857
|
-
},
|
|
1856
|
+
let c = !1, d = !1, u = () => {
|
|
1857
|
+
}, l = () => {
|
|
1858
1858
|
};
|
|
1859
1859
|
const h = (m, p) => {
|
|
1860
|
-
d || (d = !0,
|
|
1860
|
+
d || (d = !0, u(), l(), m ? o(m) : a(p));
|
|
1861
1861
|
}, f = () => {
|
|
1862
1862
|
if (!c) return;
|
|
1863
1863
|
const m = t.engine.getState().slices;
|
|
@@ -1871,12 +1871,12 @@ function $i(t, e, s) {
|
|
|
1871
1871
|
}
|
|
1872
1872
|
const p = Object.values(m.features.pending).find((y) => y.requestId === r);
|
|
1873
1873
|
if (!p && e.type === "stage7.query") {
|
|
1874
|
-
const y =
|
|
1874
|
+
const y = Dt(m, e.query);
|
|
1875
1875
|
y?.status === "error" ? h(y.error) : y?.status === "ready" && y.data && h(null, y.data);
|
|
1876
1876
|
}
|
|
1877
1877
|
p?.status === "error" ? h(p.error) : p?.status === "done" && h(null, p.result);
|
|
1878
1878
|
};
|
|
1879
|
-
|
|
1879
|
+
u = t.engine.subscribe(f), l = t.onDispose(() => h(new Error("Feature runtime disposed."))), t.engine.dispatch({ ...e, authority: n, requestId: r, now: Date.now() }).then(() => {
|
|
1880
1880
|
c = !0, f();
|
|
1881
1881
|
}, (m) => h(m));
|
|
1882
1882
|
});
|
|
@@ -1886,11 +1886,11 @@ async function ho(t, e, s = crypto.randomUUID()) {
|
|
|
1886
1886
|
if (!n || t.isDisposed) throw new Error("Product Agent is not authenticated.");
|
|
1887
1887
|
const i = Object.entries(t.engine.getState().slices.interactions.actions).find(([, a]) => a.clientScopeId === e.clientScopeId && a.sourceVersion === (e.expectedSourceVersion ?? null) && a.interactionId === e.interactionId && a.action === e.action && a.expectedRevision === e.expectedRevision && a.status === "error" && a.step === "persist"), r = i?.[0] ?? s;
|
|
1888
1888
|
await new Promise((a, o) => {
|
|
1889
|
-
let c = !1, d = !1,
|
|
1890
|
-
},
|
|
1889
|
+
let c = !1, d = !1, u = () => {
|
|
1890
|
+
}, l = () => {
|
|
1891
1891
|
};
|
|
1892
1892
|
const h = (p) => {
|
|
1893
|
-
d || (d = !0,
|
|
1893
|
+
d || (d = !0, u(), l(), p ? o(p) : a());
|
|
1894
1894
|
}, f = () => {
|
|
1895
1895
|
if (!c) return;
|
|
1896
1896
|
const p = t.engine.getState().slices;
|
|
@@ -1909,7 +1909,7 @@ async function ho(t, e, s = crypto.randomUUID()) {
|
|
|
1909
1909
|
const k = e.interactionId === "preference:notifications" ? "notifications" : e.interactionId === "preference:tab_grouping" ? "tab_grouping" : null;
|
|
1910
1910
|
h(k ? p.interactions.deviceErrors[k] : void 0);
|
|
1911
1911
|
};
|
|
1912
|
-
|
|
1912
|
+
u = t.engine.subscribe(f), l = t.onDispose(() => h(new Error("Feature runtime disposed.")));
|
|
1913
1913
|
const m = i ? { type: "stage7.retry_action", authority: n, now: Date.now(), requestId: r } : { type: "stage7.act", authority: n, now: Date.now(), requestId: r, ...e, sourceVersion: e.expectedSourceVersion ?? null };
|
|
1914
1914
|
t.engine.dispatch(m).then(() => {
|
|
1915
1915
|
c = !0, f();
|
|
@@ -1918,7 +1918,7 @@ async function ho(t, e, s = crypto.randomUUID()) {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
function po(t, e, s, n) {
|
|
1920
1920
|
return Li(t, e, s, n).map((i) => {
|
|
1921
|
-
const r = i.sourceId ? Object.values(t.interactions.sources).find((f) => f.id === i.sourceId && f.conversation_id === i.conversationId) : null, a = r?.payload, o = i.payload.feature, c = i.category === "sharing" ? "social_share" : i.category === "integration_auth" ? "integration_connection" : i.category === "personal_channel" ? "personal_channel_connection" : o === "notifications" ? "task_notifications" : o === "tab_grouping" ? "tab_group_permission" : i.category, d = c === "integration_connection" && a?.kind === "integration_auth" ? `Connect ${a.app_name}` : c === "personal_channel_connection" ? "Connect WhatsApp" : null,
|
|
1921
|
+
const r = i.sourceId ? Object.values(t.interactions.sources).find((f) => f.id === i.sourceId && f.conversation_id === i.conversationId) : null, a = r?.payload, o = i.payload.feature, c = i.category === "sharing" ? "social_share" : i.category === "integration_auth" ? "integration_connection" : i.category === "personal_channel" ? "personal_channel_connection" : o === "notifications" ? "task_notifications" : o === "tab_grouping" ? "tab_group_permission" : i.category, d = c === "integration_connection" && a?.kind === "integration_auth" ? `Connect ${a.app_name}` : c === "personal_channel_connection" ? "Connect WhatsApp" : null, u = o === "notifications" ? "Get notified when Pluno finishes a task?" : o === "tab_grouping" ? "Group tabs used by Pluno?" : i.category === "sharing" ? "Share what Pluno helped you accomplish." : String(i.payload.text ?? d ?? ""), l = Object.fromEntries(i.actions.map((f) => [f, i.actionLabels?.[f] ?? { enable: "Yes", not_now: "Not now", dont_enable: "Don't ask again", allow: "Allow", run: i.category === "proactive_suggestion" ? "Yes" : "Start", edit: "Edit", never: "Never", snooze: "Snooze morning report", pair: "Pair WhatsApp", dismiss: "Dismiss", copy: "Copy", share: "Share", feedback: "Send feedback" }[f] ?? f])), h = a?.kind === "integration_auth" ? { type: "pipedream_auth_required", authRequestId: a.request_id, appSlug: a.app_slug, appName: a.app_name, appLogo: a.app_logo, expiresAt: a.expires_at } : a?.kind === "personal_channel" ? { type: "personal_channel_connection_required", requestId: a.request_id, channel: a.channel, managementUrl: a.management_url } : null;
|
|
1922
1922
|
return {
|
|
1923
1923
|
id: i.id,
|
|
1924
1924
|
kind: c,
|
|
@@ -1935,7 +1935,7 @@ function po(t, e, s, n) {
|
|
|
1935
1935
|
placement: i.placement,
|
|
1936
1936
|
userMessageId: i.userMessageId,
|
|
1937
1937
|
sourceVersion: i.sourceVersion,
|
|
1938
|
-
presentation: { title: d, body:
|
|
1938
|
+
presentation: { title: d, body: u, actionLabels: l },
|
|
1939
1939
|
eligible: !0,
|
|
1940
1940
|
status: i.status,
|
|
1941
1941
|
allowedActions: i.actions,
|
|
@@ -1980,10 +1980,10 @@ function go(t, e = null) {
|
|
|
1980
1980
|
} : void 0);
|
|
1981
1981
|
return { ...n, ...o ? { auth: o } : {}, submissionGate: a, usingPaidCreditFallback: e ? t.paidFallbackBySession[e] ?? !1 : !1 };
|
|
1982
1982
|
}
|
|
1983
|
-
const mo = "0.1.
|
|
1983
|
+
const mo = "0.1.292", Ft = {
|
|
1984
1984
|
version: mo
|
|
1985
1985
|
}, zi = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, yo = (t, e) => t.scopes[e];
|
|
1986
|
-
function
|
|
1986
|
+
function $t(t) {
|
|
1987
1987
|
if (!Number.isSafeInteger(t) || t < 0) throw new Error("Invalid conversation revision.");
|
|
1988
1988
|
}
|
|
1989
1989
|
function $s(t, e) {
|
|
@@ -1991,14 +1991,14 @@ function $s(t, e) {
|
|
|
1991
1991
|
if (t.removedItems[e.id]) return t;
|
|
1992
1992
|
const s = fe(e.created_at);
|
|
1993
1993
|
fe(e.updated_at);
|
|
1994
|
-
const n =
|
|
1995
|
-
n !== null &&
|
|
1994
|
+
const n = Pt(e);
|
|
1995
|
+
n !== null && $t(n);
|
|
1996
1996
|
const i = t.streams[e.id];
|
|
1997
1997
|
if (n !== null && i && (i.state === "stopped" || i.state === "finished") && n > i.revision) return t;
|
|
1998
1998
|
const r = t.items[e.id];
|
|
1999
1999
|
if (r) {
|
|
2000
2000
|
if (fe(r.created_at) !== s) throw new Error("Display shell timestamp changed.");
|
|
2001
|
-
const a =
|
|
2001
|
+
const a = Pt(r);
|
|
2002
2002
|
if (a !== null && n !== null) {
|
|
2003
2003
|
if (n <= a) return t;
|
|
2004
2004
|
} else if (fe(e.updated_at) <= fe(r.updated_at)) return t;
|
|
@@ -2006,13 +2006,13 @@ function $s(t, e) {
|
|
|
2006
2006
|
return { ...t, items: { ...t.items, [e.id]: { ...e, created_at: r?.created_at ?? e.created_at } } };
|
|
2007
2007
|
}
|
|
2008
2008
|
function Hi(t, e) {
|
|
2009
|
-
if (
|
|
2009
|
+
if ($t(e.revision), t.removedItems[e.item_id]) return t;
|
|
2010
2010
|
const s = t.streams[e.item_id];
|
|
2011
2011
|
return s && (s.state === "stopped" || e.revision < s.revision || s.state !== "open" && (e.state === "open" || e.revision === s.revision) || s.state === e.state && s.revision === e.revision) ? t : { ...t, streams: { ...t.streams, [e.item_id]: e } };
|
|
2012
2012
|
}
|
|
2013
2013
|
function zs(t, e) {
|
|
2014
2014
|
if (e.conversation_id !== t.sessionId) throw new Error("Execution belongs to another conversation.");
|
|
2015
|
-
if (
|
|
2015
|
+
if ($t(e.version), t.execution && e.version <= t.execution.version) return t;
|
|
2016
2016
|
const s = { ...t.executionByUserMessage };
|
|
2017
2017
|
for (const n of le(e)) s[n] = {
|
|
2018
2018
|
version: e.version,
|
|
@@ -2024,19 +2024,19 @@ function zs(t, e) {
|
|
|
2024
2024
|
function vo(t) {
|
|
2025
2025
|
const e = /* @__PURE__ */ new Set();
|
|
2026
2026
|
for (const s of Object.values(t.items)) {
|
|
2027
|
-
const n =
|
|
2027
|
+
const n = Pt(s), i = t.streams[s.id];
|
|
2028
2028
|
n !== null && (!i || i.state === "open" || n < i.revision) && e.add(s.id);
|
|
2029
2029
|
}
|
|
2030
2030
|
for (const s of [...Object.keys(t.streams), ...Object.values(t.removedItems)])
|
|
2031
2031
|
!t.items[s] && !t.removedItems[s] && e.add(s);
|
|
2032
2032
|
return [...e];
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
2034
|
+
function ds(t, e) {
|
|
2035
2035
|
switch (e.type) {
|
|
2036
2036
|
case "conversation.interaction.updated":
|
|
2037
2037
|
return t;
|
|
2038
2038
|
case "conversation.follow_ups.updated":
|
|
2039
|
-
return
|
|
2039
|
+
return $t(e.version), e.version > t.followUpsVersion ? { ...t, followUps: e.follow_ups, followUpsVersion: e.version } : t;
|
|
2040
2040
|
case "conversation.item.updated":
|
|
2041
2041
|
return $s(t, e.item);
|
|
2042
2042
|
case "conversation.execution.updated":
|
|
@@ -2113,11 +2113,11 @@ function bo(t, e, s, n) {
|
|
|
2113
2113
|
let c = t.sessions[o.sessionId];
|
|
2114
2114
|
const d = c.queries[o.lane];
|
|
2115
2115
|
if (d.requestId !== o.requestId) return { state: t, effects: r };
|
|
2116
|
-
const
|
|
2117
|
-
o.lane === "current" && (c = { ...c, historyRefreshFailure:
|
|
2116
|
+
const u = e.type === "effect.failed" && Di(e.error.code), l = e.type === "effect.failed" && Number(e.error.details?.successfulRequests ?? 0) > 0 ? null : c.historyRefreshFailure;
|
|
2117
|
+
o.lane === "current" && (c = { ...c, historyRefreshFailure: u ? {
|
|
2118
2118
|
sessionId: o.sessionId,
|
|
2119
|
-
episodeId:
|
|
2120
|
-
consecutiveFailures: (
|
|
2119
|
+
episodeId: l?.episodeId ?? `${t.generation}:${o.sessionId}:${o.requestId}`,
|
|
2120
|
+
consecutiveFailures: (l?.consecutiveFailures ?? 0) + 1,
|
|
2121
2121
|
...e.type === "effect.failed" && typeof e.error.details?.transportCode == "string" ? { transportCode: e.error.details.transportCode } : {},
|
|
2122
2122
|
...e.type === "effect.failed" && typeof e.error.details?.requestId == "string" ? { requestId: e.error.details.requestId } : {},
|
|
2123
2123
|
...e.type === "effect.failed" && typeof e.error.details?.durationMs == "number" ? { durationMs: e.error.details.durationMs } : {}
|
|
@@ -2145,10 +2145,10 @@ function bo(t, e, s, n) {
|
|
|
2145
2145
|
o.lane === "current" && (c = { ...c, preparation: null });
|
|
2146
2146
|
const p = c.queries.history, y = o.lane === "current" && (p.status === "not_requested" || m.next_cursor !== null && !c.items[m.next_cursor]);
|
|
2147
2147
|
if (m.conversation_id !== o.sessionId) throw new Error("Snapshot belongs to another conversation.");
|
|
2148
|
-
for (const b of m.removed_items) c =
|
|
2148
|
+
for (const b of m.removed_items) c = ds(c, b);
|
|
2149
2149
|
for (const b of m.items) c = $s(c, b);
|
|
2150
2150
|
for (const b of m.streams) c = Hi(c, b);
|
|
2151
|
-
if (c = zs(c, m.execution), c =
|
|
2151
|
+
if (c = zs(c, m.execution), c = ds(c, {
|
|
2152
2152
|
type: "conversation.follow_ups.updated",
|
|
2153
2153
|
conversation_id: m.conversation_id,
|
|
2154
2154
|
version: m.follow_ups_version,
|
|
@@ -2207,7 +2207,7 @@ function bo(t, e, s, n) {
|
|
|
2207
2207
|
}
|
|
2208
2208
|
case "conversation.submission_stage": {
|
|
2209
2209
|
if (s.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
|
|
2210
|
-
const { type: o, authorityId: c, generation: d, prepareContext:
|
|
2210
|
+
const { type: o, authorityId: c, generation: d, prepareContext: u, reconcileAcceptance: l, waitForAuthentication: h, ...f } = e, m = t.submissions[e.userMessageId];
|
|
2211
2211
|
if (m) {
|
|
2212
2212
|
const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled: A, cancellationReason: _, error: T, executionVersion: E, ...C } = m;
|
|
2213
2213
|
if (ht(C) !== ht(f)) throw new Error("User-message identity cannot be reused with different input.");
|
|
@@ -2215,7 +2215,7 @@ function bo(t, e, s, n) {
|
|
|
2215
2215
|
}
|
|
2216
2216
|
const p = s.selections[e.conversationScopeId], y = Object.values(t.submissions).find((g) => g.conversationScopeId === e.conversationScopeId && !g.cancelled && g.sessionId !== null), b = n.scopes[e.clientScopeId], k = {
|
|
2217
2217
|
...Z(f),
|
|
2218
|
-
...
|
|
2218
|
+
...u ? { contextPreparation: null } : {},
|
|
2219
2219
|
// Extension staging can await page context after the picker has already changed.
|
|
2220
2220
|
requestedModel: b?.submissions[e.userMessageId] ? b.submissions[e.userMessageId].requestedModel ?? null : b ? zi(b) ?? null : null,
|
|
2221
2221
|
sessionId: p.sessionId ?? y?.sessionId ?? null,
|
|
@@ -2241,9 +2241,9 @@ function bo(t, e, s, n) {
|
|
|
2241
2241
|
}
|
|
2242
2242
|
case "conversation.stop": {
|
|
2243
2243
|
if (s.clients[e.clientScopeId] !== e.conversationScopeId) return { state: t, effects: r };
|
|
2244
|
-
const o = s.selections[e.conversationScopeId].sessionId, c = o ? t.sessions[o]?.execution : null, d = Object.values(t.submissions).filter((p) => (o ? p.sessionId === o : p.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(p.userMessageId))),
|
|
2245
|
-
if (!
|
|
2246
|
-
const f = Array.from(new Set(e.userMessageIds ?? [...
|
|
2244
|
+
const o = s.selections[e.conversationScopeId].sessionId, c = o ? t.sessions[o]?.execution : null, d = Object.values(t.submissions).filter((p) => (o ? p.sessionId === o : p.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(p.userMessageId))), u = d.filter((p) => !p.cancelled && (p.delivery !== "failed" || t.deliveries[p.userMessageId]?.phase === "paused" || e.userMessageIds?.includes(p.userMessageId) && t.deliveries[p.userMessageId]?.acceptance === "unissued") && (p.delivery !== "accepted" || p.executionVersion === null)), l = u.length > 0, h = c && ["queued", "thinking", "steering", "stopping"].includes(c.phase) && (!e.userMessageIds || le(c).some((p) => e.userMessageIds.includes(p)));
|
|
2245
|
+
if (!l && !h && (c || !e.userMessageIds?.length)) return { state: t, effects: r };
|
|
2246
|
+
const f = Array.from(new Set(e.userMessageIds ?? [...u.map((p) => p.userMessageId), ...h ? le(c) : []])), m = { ...t.submissions };
|
|
2247
2247
|
for (const p of d)
|
|
2248
2248
|
f.includes(p.userMessageId) && p.delivery !== "accepted" && (m[p.userMessageId] = { ...p, cancelled: !0, cancellationReason: e.reason ?? "user_requested" });
|
|
2249
2249
|
i = { ...t, submissions: m, stops: { ...t.stops, [e.conversationScopeId]: {
|
|
@@ -2263,19 +2263,19 @@ function bo(t, e, s, n) {
|
|
|
2263
2263
|
sessionId: c,
|
|
2264
2264
|
sources: o.type === "conversation.interaction.updated" ? [o.interaction] : []
|
|
2265
2265
|
});
|
|
2266
|
-
const
|
|
2267
|
-
|
|
2266
|
+
const u = i.sessions[c] ?? Ns(c), l = ds(u, o);
|
|
2267
|
+
l !== u && (i = { ...i, sessions: { ...i.sessions, [c]: l } });
|
|
2268
2268
|
break;
|
|
2269
2269
|
}
|
|
2270
2270
|
case "conversation.observation_released": {
|
|
2271
2271
|
const o = t.sessions[e.sessionId];
|
|
2272
2272
|
if (!o) return { state: t, effects: r };
|
|
2273
2273
|
const c = { ...t.requests }, d = { ...o.queries };
|
|
2274
|
-
for (const [
|
|
2275
|
-
if (
|
|
2276
|
-
delete c[
|
|
2277
|
-
const h = d[
|
|
2278
|
-
d[
|
|
2274
|
+
for (const [u, l] of Object.entries(c)) {
|
|
2275
|
+
if (l.sessionId !== e.sessionId) continue;
|
|
2276
|
+
delete c[u];
|
|
2277
|
+
const h = d[l.lane];
|
|
2278
|
+
d[l.lane] = { ...h, requestId: null, status: h.data === null ? "not_requested" : "ready" };
|
|
2279
2279
|
}
|
|
2280
2280
|
d.history = ye(d.history.key), i = { ...t, requests: c, sessions: { ...t.sessions, [e.sessionId]: { ...o, queries: d } } };
|
|
2281
2281
|
break;
|
|
@@ -2293,11 +2293,11 @@ function bo(t, e, s, n) {
|
|
|
2293
2293
|
before: e.lane === "history" ? c.cursor : null,
|
|
2294
2294
|
refreshItemIds: vo(o),
|
|
2295
2295
|
retryPreparation: c.error?.code === "history_preparation_failed"
|
|
2296
|
-
},
|
|
2296
|
+
}, u = Object.values(t.submissions).filter((f) => f.sessionId === e.sessionId && f.delivery === "accepted" && f.executionVersion === null).map((f) => f.userMessageId), l = t.requestSequence + 1, h = `conversation:${t.generation}:${l}`;
|
|
2297
2297
|
i = {
|
|
2298
2298
|
...t,
|
|
2299
|
-
requestSequence:
|
|
2300
|
-
requests: { ...t.requests, [h]: { ...d, acceptedUserMessageIds:
|
|
2299
|
+
requestSequence: l,
|
|
2300
|
+
requests: { ...t.requests, [h]: { ...d, acceptedUserMessageIds: u } },
|
|
2301
2301
|
sessions: { ...t.sessions, [e.sessionId]: { ...o, queries: {
|
|
2302
2302
|
...o.queries,
|
|
2303
2303
|
[e.lane]: Ue(c, { key: c.key, requestId: e.requestId, mode: d.before === null ? "replace" : "append" })
|
|
@@ -2327,34 +2327,34 @@ const $n = (t, e) => ({
|
|
|
2327
2327
|
command: null
|
|
2328
2328
|
});
|
|
2329
2329
|
function un(t, e) {
|
|
2330
|
-
const s = new Set(Object.values(e.clients)), n = Object.values(t.operations).filter((
|
|
2331
|
-
const h =
|
|
2332
|
-
if (
|
|
2333
|
-
if (
|
|
2334
|
-
if (
|
|
2335
|
-
const f =
|
|
2336
|
-
return
|
|
2337
|
-
}
|
|
2338
|
-
return !
|
|
2339
|
-
}).map(([
|
|
2330
|
+
const s = new Set(Object.values(e.clients)), n = Object.values(t.operations).filter((u) => u.command.type === "run.stop"), i = (u) => n.some((l) => l.command.payload.expectedUserMessageId === u && l.phase === "done"), r = Object.fromEntries(Object.entries(t.submissions).filter(([u, l]) => {
|
|
2331
|
+
const h = l.sessionId ? t.sessions[l.sessionId] : void 0;
|
|
2332
|
+
if (l.cancelled && s.has(l.conversationScopeId) && t.stops[l.conversationScopeId]?.userMessageIds.includes(u) && !h?.items[u] && !h?.removedItems[u]) return !0;
|
|
2333
|
+
if (l.delivery === "accepted") {
|
|
2334
|
+
if (l.cancelled) return !i(u);
|
|
2335
|
+
const f = l.sessionId ? t.sessions[l.sessionId] : void 0;
|
|
2336
|
+
return l.executionVersion === null || !(f?.items[u] || f?.removedItems[u]);
|
|
2337
|
+
}
|
|
2338
|
+
return !l.cancelled || we(t, u) || t.deliveries[u]?.phase === "running";
|
|
2339
|
+
}).map(([u, l]) => [u, l.delivery === "accepted" || l.cancelled ? { ...l, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } } : l])), a = Object.fromEntries(Object.entries(t.deliveries).filter(([u]) => u in r).map(([u, l]) => [u, r[u].delivery === "accepted" ? { ...l, phase: "done", effectId: null, command: null, uploads: [], completedUploads: 0 } : r[u].cancelled ? { ...l, command: null } : l])), o = Object.fromEntries(Object.entries(t.stops).filter(([u, l]) => l.userMessageIds.some((h) => {
|
|
2340
2340
|
if (r[h]) return !0;
|
|
2341
2341
|
if (!i(h)) return n.some((m) => m.command.payload.expectedUserMessageId === h && m.phase !== "done");
|
|
2342
2342
|
const f = Object.values(t.sessions).find((m) => m.executionByUserMessage[h])?.executionByUserMessage[h];
|
|
2343
|
-
return s.has(
|
|
2344
|
-
}))), c = new Set(Object.values(o).flatMap((
|
|
2345
|
-
if (!["done", "failed"].includes(
|
|
2346
|
-
if (
|
|
2347
|
-
if (
|
|
2348
|
-
if (
|
|
2349
|
-
if (
|
|
2350
|
-
const
|
|
2351
|
-
return !Object.values(t.submissions).some((h) => h.conversationScopeId ===
|
|
2343
|
+
return s.has(u) && (!f || f.version <= l.executionVersion || !["completed", "failed", "stopped"].includes(f.phase));
|
|
2344
|
+
}))), c = new Set(Object.values(o).flatMap((u) => u.userMessageIds)), d = Object.fromEntries(Object.entries(t.operations).filter(([, u]) => {
|
|
2345
|
+
if (!["done", "failed"].includes(u.phase)) return !0;
|
|
2346
|
+
if (u.command.type === "run.stop") return c.has(String(u.command.payload.expectedUserMessageId)) || Object.values(r).some((h) => h.cancelled && h.userMessageId === u.command.payload.expectedUserMessageId);
|
|
2347
|
+
if (u.phase !== "done" || !u.conversationScopeId || !s.has(u.conversationScopeId)) return !1;
|
|
2348
|
+
if (u.command.type === "runtime.warmup") return e.selections[u.conversationScopeId]?.sessionId !== u.result?.sessionId;
|
|
2349
|
+
if (u.command.type !== "attachment.prepare") return !1;
|
|
2350
|
+
const l = u.command.payload.source;
|
|
2351
|
+
return !Object.values(t.submissions).some((h) => h.conversationScopeId === u.conversationScopeId && h.delivery === "accepted" && h.attachments.some((f) => f.sourceId === l.sourceId));
|
|
2352
2352
|
}));
|
|
2353
2353
|
return G({
|
|
2354
2354
|
schema: 1,
|
|
2355
2355
|
authorityId: t.authorityId,
|
|
2356
2356
|
submissions: r,
|
|
2357
|
-
submissionOrder: t.submissionOrder.filter((
|
|
2357
|
+
submissionOrder: t.submissionOrder.filter((u) => u in r),
|
|
2358
2358
|
deliveries: a,
|
|
2359
2359
|
operations: d,
|
|
2360
2360
|
stops: o,
|
|
@@ -2425,13 +2425,13 @@ function Js(t) {
|
|
|
2425
2425
|
const m = e.submissions[f];
|
|
2426
2426
|
return (m.conversationScopeId === c.conversationScopeId || c.sessionId !== null && m.sessionId === c.sessionId) && m.delivery !== "accepted" && (m.delivery !== "failed" || e.deliveries[f]?.acceptance === "uncertain") && (!m.cancelled || we(e, f));
|
|
2427
2427
|
})) continue;
|
|
2428
|
-
const
|
|
2429
|
-
let
|
|
2430
|
-
c.cancelled || d.step === "receipt" ? (
|
|
2431
|
-
request_id:
|
|
2428
|
+
const u = i();
|
|
2429
|
+
let l, h = d.command;
|
|
2430
|
+
c.cancelled || d.step === "receipt" ? (l = "receipt", s.push({ id: u, kind: "conversation.receipt", input: { ...n, userMessageId: o, sessionId: c.sessionId } })) : d.uploads.length < c.attachments.length ? (l = "upload", s.push({ id: u, kind: "conversation.upload", input: { ...n, submission: c, source: c.attachments[d.uploads.length], previousAllocation: d.allocation } })) : (l = d.completedUploads < d.uploads.length ? "complete" : "send", l === "complete" && (d.step !== "complete" || !h) ? h = {
|
|
2431
|
+
request_id: u,
|
|
2432
2432
|
type: "attachment.upload_completed",
|
|
2433
2433
|
payload: { sessionId: c.sessionId, clientMessageId: o, attachment: d.uploads[d.completedUploads] }
|
|
2434
|
-
} :
|
|
2434
|
+
} : l === "send" && (d.step !== "send" || !h) && (h = {
|
|
2435
2435
|
request_id: c.requestId,
|
|
2436
2436
|
type: "chat.user_message",
|
|
2437
2437
|
payload: {
|
|
@@ -2444,25 +2444,25 @@ function Js(t) {
|
|
|
2444
2444
|
entrySurface: c.entrySurface,
|
|
2445
2445
|
attachments: d.uploads
|
|
2446
2446
|
}
|
|
2447
|
-
}), s.push({ id:
|
|
2447
|
+
}), s.push({ id: u, kind: "conversation.command", input: { ...n, command: h, previousAcceptance: d.acceptance } })), e = {
|
|
2448
2448
|
...e,
|
|
2449
|
-
deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId:
|
|
2449
|
+
deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId: u, step: l, command: h, acceptance: l === "send" ? "uncertain" : d.acceptance, allocation: l === "upload" && c.sessionId === null ? "uncertain" : d.allocation } },
|
|
2450
2450
|
submissions: { ...e.submissions, [o]: { ...c, delivery: "sending", error: null } }
|
|
2451
2451
|
};
|
|
2452
2452
|
}
|
|
2453
|
-
const a = (o, c, d,
|
|
2453
|
+
const a = (o, c, d, u = "user_requested") => {
|
|
2454
2454
|
if (e.operations[o]) return;
|
|
2455
|
-
const
|
|
2455
|
+
const l = i();
|
|
2456
2456
|
e = { ...e, operations: { ...e.operations, [o]: Gs({
|
|
2457
|
-
request_id:
|
|
2457
|
+
request_id: l,
|
|
2458
2458
|
type: "run.stop",
|
|
2459
|
-
payload: { sessionId: c, expectedUserMessageId: d, reason:
|
|
2459
|
+
payload: { sessionId: c, expectedUserMessageId: d, reason: u }
|
|
2460
2460
|
}) } };
|
|
2461
2461
|
};
|
|
2462
2462
|
for (const [o, c] of Object.entries(e.stops))
|
|
2463
2463
|
for (const d of c.userMessageIds) {
|
|
2464
|
-
const
|
|
2465
|
-
|
|
2464
|
+
const u = e.submissions[d], l = u?.sessionId ?? Object.values(e.sessions).find((f) => le(f.execution).includes(d))?.sessionId, h = u?.delivery === "accepted" || l && le(e.sessions[l]?.execution).includes(d);
|
|
2465
|
+
l && h && a(`stop:${o}:${c.requestId}:${d}`, l, d, c.reason);
|
|
2466
2466
|
}
|
|
2467
2467
|
for (const o of Object.values(e.submissions))
|
|
2468
2468
|
o.cancelled && o.delivery === "accepted" && o.sessionId && (Object.values(e.operations).some((d) => d.command.type === "run.stop" && d.command.payload.sessionId === o.sessionId && d.command.payload.expectedUserMessageId === o.userMessageId) || a(
|
|
@@ -2473,13 +2473,13 @@ function Js(t) {
|
|
|
2473
2473
|
));
|
|
2474
2474
|
for (const [o, c] of Object.entries(e.operations)) {
|
|
2475
2475
|
if (c.phase !== "waiting" || c.conversationScopeId && Object.values(e.pendingRestoration).includes(c.conversationScopeId)) continue;
|
|
2476
|
-
const d = Object.values(e.operations).filter((p) => p !== c && p.conversationScopeId === c.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(p.command.type)),
|
|
2476
|
+
const d = Object.values(e.operations).filter((p) => p !== c && p.conversationScopeId === c.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(p.command.type)), u = d.find((p) => p.phase === "done" && p.result?.sessionId), l = u?.result, h = c.command.payload.sessionId ?? l?.sessionId ?? Object.values(e.submissions).find((p) => p.conversationScopeId === c.conversationScopeId && !p.cancelled && p.sessionId)?.sessionId ?? null;
|
|
2477
2477
|
if (c.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(c.command.type) && !h && (d.some((p) => p.phase === "running" || p.phase === "uncertain") || Object.values(e.submissions).some((p) => p.conversationScopeId === c.conversationScopeId && e.deliveries[p.userMessageId]?.phase === "running"))) continue;
|
|
2478
|
-
if (c.command.type === "runtime.warmup" &&
|
|
2479
|
-
e = { ...e, operations: { ...e.operations, [o]: { ...c, phase: "done", result:
|
|
2478
|
+
if (c.command.type === "runtime.warmup" && l && !c.command.payload.sessionId && u?.command.type === "runtime.warmup" && u.command.payload.model === c.command.payload.model) {
|
|
2479
|
+
e = { ...e, operations: { ...e.operations, [o]: { ...c, phase: "done", result: l } } };
|
|
2480
2480
|
continue;
|
|
2481
2481
|
}
|
|
2482
|
-
const f = c.command.type === "runtime.warmup" &&
|
|
2482
|
+
const f = c.command.type === "runtime.warmup" && l && !c.command.payload.sessionId ? { ...c.command, payload: { ...c.command.payload, sessionId: l.sessionId } } : c.command, m = i();
|
|
2483
2483
|
e = { ...e, operations: { ...e.operations, [o]: { ...c, command: f, phase: "running", effectId: m } } }, f.type === "attachment.prepare" ? s.push({ id: m, kind: "conversation.upload", input: {
|
|
2484
2484
|
...n,
|
|
2485
2485
|
preparationId: o,
|
|
@@ -2500,9 +2500,9 @@ function wo(t, e, s, n) {
|
|
|
2500
2500
|
let i = t, r = e;
|
|
2501
2501
|
if (e.type === "effect.completed" || e.type === "effect.failed") {
|
|
2502
2502
|
e.effectKind === "conversation.checkpoint" && e.effectId === t.checkpointEffectId && (i = { ...i, checkpointEffectId: null, checkpointError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed" && e.effectKind === "conversation.checkpoint" && e.output && e.output.authorityId === t.authorityId && e.output.generation === t.generation && (i = { ...i, durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...e.output.submissionIds])].filter((f) => !!t.submissions[f]) });
|
|
2503
|
-
const
|
|
2504
|
-
if (
|
|
2505
|
-
const f = t.deliveries[
|
|
2503
|
+
const l = Object.keys(t.deliveries).find((f) => t.deliveries[f].effectId === e.effectId), h = Object.keys(t.operations).find((f) => t.operations[f].effectId === e.effectId);
|
|
2504
|
+
if (l) {
|
|
2505
|
+
const f = t.deliveries[l], m = t.submissions[l];
|
|
2506
2506
|
let p = { ...f, phase: "waiting", effectId: null };
|
|
2507
2507
|
if (e.type === "effect.failed") {
|
|
2508
2508
|
const y = e.error.details?.acceptance === "unissued" && f.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : f.acceptance, b = e.error.details?.allocation === "unissued" ? "unissued" : f.allocation, k = e.effectKind === "conversation.command" && f.step === "send" && y === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", R = e.effectKind === "conversation.prepare" || k ? "failed" : y === "uncertain" || b === "uncertain" || e.error.retryable ? "uncertain" : "failed";
|
|
@@ -2514,14 +2514,14 @@ function wo(t, e, s, n) {
|
|
|
2514
2514
|
...f.handoffRecovery && f.step === "send" ? { step: "receipt" } : {}
|
|
2515
2515
|
}, !m.cancelled && m.delivery !== "accepted" && (i = { ...i, submissions: {
|
|
2516
2516
|
...i.submissions,
|
|
2517
|
-
[
|
|
2517
|
+
[l]: { ...m, delivery: R, error: e.error }
|
|
2518
2518
|
} });
|
|
2519
2519
|
} else if (e.effectKind === "conversation.prepare")
|
|
2520
|
-
m.cancelled ? p = { ...p, phase: "failed" } : (p = { ...p, prepared: !0 }, i = { ...i, submissions: { ...i.submissions, [
|
|
2520
|
+
m.cancelled ? p = { ...p, phase: "failed" } : (p = { ...p, prepared: !0 }, i = { ...i, submissions: { ...i.submissions, [l]: {
|
|
2521
2521
|
...m,
|
|
2522
2522
|
...m.contextPreparation === null ? { contextPreparation: { pageContent: e.output.pageContent, sessionTabs: e.output.sessionTabs } } : {}
|
|
2523
|
-
} } }, f.recoveryDeadline !== null && e.output.now >= f.recoveryDeadline && (p = { ...p, phase: "paused" }, i = { ...i, submissions: { ...i.submissions, [
|
|
2524
|
-
...i.submissions[
|
|
2523
|
+
} } }, f.recoveryDeadline !== null && e.output.now >= f.recoveryDeadline && (p = { ...p, phase: "paused" }, i = { ...i, submissions: { ...i.submissions, [l]: {
|
|
2524
|
+
...i.submissions[l],
|
|
2525
2525
|
delivery: "failed",
|
|
2526
2526
|
error: { code: "message_delivery_failed", message: "Pluno could not send this message. Try it again.", retryable: !0 }
|
|
2527
2527
|
} } }));
|
|
@@ -2532,41 +2532,41 @@ function wo(t, e, s, n) {
|
|
|
2532
2532
|
p = { ...p, allocation: "resolved", uploads: [...f.uploads, y.attachment] };
|
|
2533
2533
|
const k = Object.fromEntries(Object.entries(i.submissions).map(([R, g]) => [
|
|
2534
2534
|
R,
|
|
2535
|
-
g.conversationScopeId === m.conversationScopeId && (R ===
|
|
2535
|
+
g.conversationScopeId === m.conversationScopeId && (R === l || !g.cancelled && !m.cancelled) ? { ...g, sessionId: y.sessionId } : g
|
|
2536
2536
|
]));
|
|
2537
2537
|
i = { ...i, submissions: k };
|
|
2538
2538
|
} else if (e.effectKind === "conversation.receipt")
|
|
2539
2539
|
if (e.output === null && f.handoffRecovery && !m.cancelled)
|
|
2540
2540
|
p = { ...p, phase: "waiting", step: null };
|
|
2541
2541
|
else if (e.output === null)
|
|
2542
|
-
p = { ...p, phase: m.cancelled ? "uncertain" : "paused" }, m.cancelled || (i = { ...i, submissions: { ...i.submissions, [
|
|
2542
|
+
p = { ...p, phase: m.cancelled ? "uncertain" : "paused" }, m.cancelled || (i = { ...i, submissions: { ...i.submissions, [l]: {
|
|
2543
2543
|
...m,
|
|
2544
2544
|
delivery: "failed",
|
|
2545
2545
|
error: { code: "message_acceptance_unconfirmed", message: "Pluno could not confirm whether this message was accepted. Try again.", retryable: !0 }
|
|
2546
2546
|
} } });
|
|
2547
2547
|
else {
|
|
2548
|
-
const y = zn(e.output,
|
|
2548
|
+
const y = zn(e.output, l);
|
|
2549
2549
|
p = { ...p, phase: "done", acceptance: "accepted" }, r = {
|
|
2550
2550
|
type: "conversation.submission_accepted",
|
|
2551
2551
|
authorityId: t.authorityId,
|
|
2552
2552
|
generation: t.generation,
|
|
2553
|
-
userMessageId:
|
|
2553
|
+
userMessageId: l,
|
|
2554
2554
|
sessionId: y.sessionId
|
|
2555
2555
|
};
|
|
2556
2556
|
}
|
|
2557
2557
|
else if (e.effectKind === "conversation.command" && f.step === "complete")
|
|
2558
2558
|
p = { ...p, completedUploads: f.completedUploads + 1, command: null };
|
|
2559
2559
|
else if (e.effectKind === "conversation.command" && f.step === "send") {
|
|
2560
|
-
const y = zn(e.output,
|
|
2560
|
+
const y = zn(e.output, l);
|
|
2561
2561
|
p = { ...p, phase: "done", acceptance: "accepted" }, r = {
|
|
2562
2562
|
type: "conversation.submission_accepted",
|
|
2563
2563
|
authorityId: t.authorityId,
|
|
2564
2564
|
generation: t.generation,
|
|
2565
|
-
userMessageId:
|
|
2565
|
+
userMessageId: l,
|
|
2566
2566
|
sessionId: y.sessionId
|
|
2567
2567
|
};
|
|
2568
2568
|
}
|
|
2569
|
-
i = { ...i, deliveries: { ...i.deliveries, [
|
|
2569
|
+
i = { ...i, deliveries: { ...i.deliveries, [l]: p } };
|
|
2570
2570
|
} else if (h) {
|
|
2571
2571
|
const f = t.operations[h];
|
|
2572
2572
|
if (i = { ...i, operations: { ...i.operations, [h]: {
|
|
@@ -2592,27 +2592,27 @@ function wo(t, e, s, n) {
|
|
|
2592
2592
|
}
|
|
2593
2593
|
}
|
|
2594
2594
|
} else if (e.authorityId === t.authorityId && e.generation === t.generation && s.authorityId) {
|
|
2595
|
-
if (e.type === "conversation.enable_effects" && (i = { ...t, effectsEnabled: !0 }), e.type === "conversation.authentication_restored" && (i = { ...t, submissions: Object.fromEntries(Object.entries(t.submissions).map(([
|
|
2596
|
-
|
|
2595
|
+
if (e.type === "conversation.enable_effects" && (i = { ...t, effectsEnabled: !0 }), e.type === "conversation.authentication_restored" && (i = { ...t, submissions: Object.fromEntries(Object.entries(t.submissions).map(([l, h]) => [
|
|
2596
|
+
l,
|
|
2597
2597
|
!h.cancelled && h.delivery === "failed" && ["unauthorized", "401", "auth_reconnecting"].includes(h.error?.code ?? "") ? { ...h, error: { code: "message_delivery_failed", message: "Pluno is connected. Retry this message to send it.", retryable: !0 } } : h
|
|
2598
2598
|
])) }), e.type === "conversation.restore_delivery") {
|
|
2599
|
-
const
|
|
2600
|
-
if (
|
|
2599
|
+
const l = Z(e.checkpoint), h = t.submissionOrder.every((g) => t.deliveries[g]?.acceptance === "unissued" && t.submissions[g].delivery === "failed" && ["unauthorized", "auth_reconnecting"].includes(t.submissions[g].error?.code ?? ""));
|
|
2600
|
+
if (l.schema !== 1 || l.authorityId !== t.authorityId || !h || Object.keys(t.operations).length)
|
|
2601
2601
|
throw new Error("Delivery restoration requires an empty engine with the same authenticated authority.");
|
|
2602
|
-
const f = { ...t.submissions, ...
|
|
2602
|
+
const f = { ...t.submissions, ...l.submissions };
|
|
2603
2603
|
for (const [g, v] of Object.entries(t.submissions))
|
|
2604
2604
|
v.cancelled && (f[g] = { ...f[g], cancelled: !0, cancellationReason: v.cancellationReason });
|
|
2605
2605
|
const m = {
|
|
2606
|
-
...
|
|
2606
|
+
...l,
|
|
2607
2607
|
submissions: f,
|
|
2608
|
-
stops: { ...
|
|
2609
|
-
deliveries: { ...t.deliveries, ...
|
|
2610
|
-
submissionOrder: [.../* @__PURE__ */ new Set([...
|
|
2608
|
+
stops: { ...l.stops, ...t.stops },
|
|
2609
|
+
deliveries: { ...t.deliveries, ...l.deliveries },
|
|
2610
|
+
submissionOrder: [.../* @__PURE__ */ new Set([...l.submissionOrder, ...t.submissionOrder])]
|
|
2611
2611
|
}, { schema: p, authorityId: y, ...b } = m, k = Z(e.pendingRestoration ?? {}), R = (g) => !s.clients[g.clientScopeId] && k[g.clientScopeId] === g.conversationScopeId;
|
|
2612
2612
|
i = {
|
|
2613
2613
|
...t,
|
|
2614
2614
|
...b,
|
|
2615
|
-
durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...Object.keys(
|
|
2615
|
+
durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...Object.keys(l.submissions)])],
|
|
2616
2616
|
pendingRestoration: k,
|
|
2617
2617
|
requestSequence: Math.max(t.requestSequence, m.requestSequence),
|
|
2618
2618
|
effectsEnabled: !0,
|
|
@@ -2647,35 +2647,35 @@ function wo(t, e, s, n) {
|
|
|
2647
2647
|
};
|
|
2648
2648
|
}
|
|
2649
2649
|
if (e.type === "conversation.restoration_resolved") {
|
|
2650
|
-
const
|
|
2651
|
-
delete
|
|
2650
|
+
const l = { ...i.pendingRestoration };
|
|
2651
|
+
delete l[e.clientScopeId], i = Ks({ ...i, pendingRestoration: l }, s);
|
|
2652
2652
|
}
|
|
2653
2653
|
if (e.type === "conversation.recover" && (i = {
|
|
2654
2654
|
...t,
|
|
2655
|
-
deliveries: Object.fromEntries(Object.entries(t.deliveries).map(([
|
|
2656
|
-
|
|
2657
|
-
h.phase === "uncertain" && we(t,
|
|
2655
|
+
deliveries: Object.fromEntries(Object.entries(t.deliveries).map(([l, h]) => [
|
|
2656
|
+
l,
|
|
2657
|
+
h.phase === "uncertain" && we(t, l) ? { ...h, phase: "waiting", prepared: !1 } : h
|
|
2658
2658
|
])),
|
|
2659
|
-
operations: Object.fromEntries(Object.entries(t.operations).map(([
|
|
2660
|
-
|
|
2659
|
+
operations: Object.fromEntries(Object.entries(t.operations).map(([l, h]) => [
|
|
2660
|
+
l,
|
|
2661
2661
|
h.phase === "uncertain" && Vi(h) ? { ...h, phase: "waiting" } : h
|
|
2662
2662
|
]))
|
|
2663
2663
|
}), e.type === "conversation.submit") {
|
|
2664
|
-
const
|
|
2665
|
-
if (!
|
|
2664
|
+
const l = t.submissions[e.userMessageId];
|
|
2665
|
+
if (!l) throw new Error("Stage the immutable submission before sending.");
|
|
2666
2666
|
const h = t.deliveries[e.userMessageId];
|
|
2667
|
-
if (h && !
|
|
2667
|
+
if (h && !l.cancelled && l.delivery !== "accepted" && (h.phase === "uncertain" || e.manualRetry && ["paused", "failed"].includes(h.phase))) {
|
|
2668
2668
|
const m = (h.acceptance === "unissued" || h.acceptance === "rejected") && h.allocation !== "uncertain" ? Math.max(t.requestSequence, ...Object.values(t.deliveries).map((p) => p.queuePosition)) + 1 : h.queuePosition;
|
|
2669
2669
|
i = {
|
|
2670
2670
|
...t,
|
|
2671
2671
|
effectsEnabled: !0,
|
|
2672
2672
|
requestSequence: Math.max(t.requestSequence, m),
|
|
2673
|
-
submissions: { ...t.submissions, [e.userMessageId]: { ...
|
|
2673
|
+
submissions: { ...t.submissions, [e.userMessageId]: { ...l, delivery: "staged", error: null } },
|
|
2674
2674
|
deliveries: { ...t.deliveries, [e.userMessageId]: {
|
|
2675
2675
|
...h,
|
|
2676
2676
|
phase: "waiting",
|
|
2677
2677
|
effectId: null,
|
|
2678
|
-
...e.manualRetry &&
|
|
2678
|
+
...e.manualRetry && l.error?.code === "message_acceptance_unconfirmed" ? { step: "send" } : {},
|
|
2679
2679
|
prepared: !1,
|
|
2680
2680
|
queuePosition: m,
|
|
2681
2681
|
command: h.acceptance === "unissued" && h.step === "send" ? null : h.command,
|
|
@@ -2685,12 +2685,12 @@ function wo(t, e, s, n) {
|
|
|
2685
2685
|
}
|
|
2686
2686
|
}
|
|
2687
2687
|
if (e.type === "conversation.recover" || e.type === "conversation.submit")
|
|
2688
|
-
for (const [
|
|
2689
|
-
const f = i.submissions[
|
|
2688
|
+
for (const [l, h] of Object.entries(i.deliveries)) {
|
|
2689
|
+
const f = i.submissions[l];
|
|
2690
2690
|
h.phase !== "waiting" || f.cancelled || h.recoveryDeadline === null || e.now < h.recoveryDeadline || (i = {
|
|
2691
2691
|
...i,
|
|
2692
|
-
deliveries: { ...i.deliveries, [
|
|
2693
|
-
submissions: { ...i.submissions, [
|
|
2692
|
+
deliveries: { ...i.deliveries, [l]: { ...h, phase: "paused" } },
|
|
2693
|
+
submissions: { ...i.submissions, [l]: { ...f, delivery: "failed", error: {
|
|
2694
2694
|
code: "message_delivery_failed",
|
|
2695
2695
|
message: "Pluno could not send this message. Try it again.",
|
|
2696
2696
|
retryable: !0
|
|
@@ -2698,27 +2698,27 @@ function wo(t, e, s, n) {
|
|
|
2698
2698
|
});
|
|
2699
2699
|
}
|
|
2700
2700
|
if (e.type === "conversation.operation") {
|
|
2701
|
-
const
|
|
2702
|
-
if (
|
|
2703
|
-
if (
|
|
2704
|
-
if (
|
|
2705
|
-
const h = t.operations[
|
|
2706
|
-
if (h && (JSON.stringify(h.command) !== JSON.stringify(
|
|
2701
|
+
const l = e.command;
|
|
2702
|
+
if (l.type === "attachment.prepare" && !e.conversationScopeId) throw new Error("Attachment preparation requires a conversation scope.");
|
|
2703
|
+
if (l.type === "chat.user_message") throw new Error("Messages must use the immutable submission pipeline.");
|
|
2704
|
+
if (l.type === "run.stop" && !l.payload.expectedUserMessageId) throw new Error("Stop requires message correlation.");
|
|
2705
|
+
const h = t.operations[l.request_id];
|
|
2706
|
+
if (h && (JSON.stringify(h.command) !== JSON.stringify(l) || h.conversationScopeId !== (e.conversationScopeId ?? null))) throw new Error("Command identity changed.");
|
|
2707
2707
|
if (!h) {
|
|
2708
|
-
const f =
|
|
2709
|
-
if (s.selections[m]?.sessionId !==
|
|
2710
|
-
const y = p.userMessageIds.filter((b) => b !==
|
|
2708
|
+
const f = l.type === "chat.retry_last_user_message" ? Object.fromEntries(Object.entries(t.stops).flatMap(([m, p]) => {
|
|
2709
|
+
if (s.selections[m]?.sessionId !== l.payload.sessionId) return [[m, p]];
|
|
2710
|
+
const y = p.userMessageIds.filter((b) => b !== l.payload.clientMessageId);
|
|
2711
2711
|
return y.length ? [[m, { ...p, userMessageIds: y }]] : [];
|
|
2712
2712
|
})) : t.stops;
|
|
2713
2713
|
i = { ...t, stops: f, effectsEnabled: !0, operations: {
|
|
2714
2714
|
...t.operations,
|
|
2715
|
-
[
|
|
2715
|
+
[l.request_id]: Gs(l, e.conversationScopeId ?? null)
|
|
2716
2716
|
} };
|
|
2717
2717
|
}
|
|
2718
2718
|
}
|
|
2719
2719
|
if (e.type === "conversation.retry_operation") {
|
|
2720
|
-
const
|
|
2721
|
-
|
|
2720
|
+
const l = t.operations[e.requestId];
|
|
2721
|
+
l?.phase === "uncertain" && (i = { ...t, operations: { ...t.operations, [e.requestId]: { ...l, phase: "waiting" } } });
|
|
2722
2722
|
}
|
|
2723
2723
|
}
|
|
2724
2724
|
const a = bo(i, r, s, n);
|
|
@@ -2734,37 +2734,37 @@ function wo(t, e, s, n) {
|
|
|
2734
2734
|
...e.waitForAuthentication ? { phase: "failed" } : {}
|
|
2735
2735
|
} }
|
|
2736
2736
|
};
|
|
2737
|
-
const
|
|
2737
|
+
const l = o.submissions[e.userMessageId], h = o.deliveries[e.userMessageId];
|
|
2738
2738
|
h.phase === "waiting" && (o = { ...o, deliveries: Object.fromEntries(Object.entries(o.deliveries).map(([f, m]) => {
|
|
2739
2739
|
const p = o.submissions[f];
|
|
2740
|
-
return m.queuePosition < h.queuePosition && (p.conversationScopeId ===
|
|
2740
|
+
return m.queuePosition < h.queuePosition && (p.conversationScopeId === l.conversationScopeId || l.sessionId !== null && p.sessionId === l.sessionId) && m.acceptance === "uncertain" && ["uncertain", "paused"].includes(m.phase) && p.error?.code !== "message_acceptance_unconfirmed" ? [f, { ...m, phase: "waiting", effectId: null, prepared: !0, step: "receipt" }] : [f, m];
|
|
2741
2741
|
})) });
|
|
2742
2742
|
}
|
|
2743
|
-
for (const [
|
|
2744
|
-
const f = o.deliveries[
|
|
2743
|
+
for (const [l, h] of Object.entries(o.submissions)) {
|
|
2744
|
+
const f = o.deliveries[l];
|
|
2745
2745
|
f && (h.delivery === "accepted" && f.acceptance !== "accepted" ? o = {
|
|
2746
2746
|
...o,
|
|
2747
|
-
deliveries: { ...o.deliveries, [
|
|
2747
|
+
deliveries: { ...o.deliveries, [l]: { ...f, acceptance: "accepted", phase: "done", effectId: null } }
|
|
2748
2748
|
} : (h.cancelled || h.delivery === "failed") && f.phase === "running" && !f.prepared && (o = {
|
|
2749
2749
|
...o,
|
|
2750
2750
|
// Stop retires readiness work, but a previously issued message still needs receipt reconciliation.
|
|
2751
|
-
deliveries: { ...o.deliveries, [
|
|
2751
|
+
deliveries: { ...o.deliveries, [l]: {
|
|
2752
2752
|
...f,
|
|
2753
|
-
phase: h.cancelled && we(o,
|
|
2753
|
+
phase: h.cancelled && we(o, l) ? "waiting" : "failed",
|
|
2754
2754
|
prepared: h.cancelled,
|
|
2755
2755
|
effectId: null
|
|
2756
2756
|
} }
|
|
2757
2757
|
}));
|
|
2758
2758
|
}
|
|
2759
|
-
for (const [
|
|
2760
|
-
h.phase === "paused" && o.submissions[
|
|
2761
|
-
const c = o.pendingDurabilityIds.filter((
|
|
2762
|
-
const h = o.submissions[
|
|
2763
|
-
return h && !h.cancelled && !["accepted", "failed"].includes(h.delivery) && !o.durableSubmissionIds.includes(
|
|
2759
|
+
for (const [l, h] of Object.entries(o.deliveries))
|
|
2760
|
+
h.phase === "paused" && o.submissions[l].cancelled && we(o, l) && (o = { ...o, deliveries: { ...o.deliveries, [l]: { ...h, phase: "waiting" } } });
|
|
2761
|
+
const c = o.pendingDurabilityIds.filter((l) => {
|
|
2762
|
+
const h = o.submissions[l];
|
|
2763
|
+
return h && !h.cancelled && !["accepted", "failed"].includes(h.delivery) && !o.durableSubmissionIds.includes(l);
|
|
2764
2764
|
});
|
|
2765
2765
|
c.length !== o.pendingDurabilityIds.length && (o = { ...o, pendingDurabilityIds: c });
|
|
2766
|
-
const d = Js(o),
|
|
2767
|
-
return { state:
|
|
2766
|
+
const d = Js(o), u = Ws(t, d.state, s, e.type === "conversation.recover" && t.checkpointError !== null);
|
|
2767
|
+
return { state: u.state, effects: [...u.effects, ...a.effects, ...d.effects], interactionSources: a.interactionSources };
|
|
2768
2768
|
}
|
|
2769
2769
|
const _o = [
|
|
2770
2770
|
"submit",
|
|
@@ -2910,12 +2910,12 @@ function Ao(t) {
|
|
|
2910
2910
|
}), r = (a, o) => {
|
|
2911
2911
|
const c = Object.entries(a.operations).filter(([, m]) => m.command.type === "run.stop"), d = Object.entries(a.submissions).filter(([, m]) => m.cancelled);
|
|
2912
2912
|
if (!o && !d.length && !c.some(([, m]) => m.phase !== "done" && m.phase !== "failed")) return Promise.resolve();
|
|
2913
|
-
const
|
|
2913
|
+
const u = c[c.length - 1]?.[1].command, l = Q(u ? t.onTiming : void 0, {
|
|
2914
2914
|
operation: "stop",
|
|
2915
2915
|
layer: "http",
|
|
2916
|
-
requestId:
|
|
2917
|
-
clientMessageId:
|
|
2918
|
-
sessionId:
|
|
2916
|
+
requestId: u?.request_id ?? "cancellation",
|
|
2917
|
+
clientMessageId: u ? String(u.payload.expectedUserMessageId) : null,
|
|
2918
|
+
sessionId: u ? String(u.payload.sessionId) : null
|
|
2919
2919
|
}), h = e, f = async () => {
|
|
2920
2920
|
if (!t.isCurrent() || a.authorityId !== t.authorityId) throw new Error("Cancellation authority was retired.");
|
|
2921
2921
|
if (!o && s && a.requestSequence <= s.requestSequence) return;
|
|
@@ -2935,10 +2935,10 @@ function Ao(t) {
|
|
|
2935
2935
|
}
|
|
2936
2936
|
if (!(!m && !Object.keys(p.cancelled).length && !Object.keys(p.operations).length && !Object.keys(p.stops).length) && !(JSON.stringify(m?.cancelled ?? {}) === JSON.stringify(p.cancelled) && JSON.stringify(m?.operations ?? {}) === JSON.stringify(p.operations) && JSON.stringify(m?.stops ?? {}) === JSON.stringify(p.stops))) {
|
|
2937
2937
|
if (!t.isCurrent()) throw new Error("Cancellation authority was retired.");
|
|
2938
|
-
await
|
|
2938
|
+
await l.measure("cancellation_write", () => t.write(p)), n = Promise.resolve(p);
|
|
2939
2939
|
}
|
|
2940
2940
|
};
|
|
2941
|
-
return e =
|
|
2941
|
+
return e = l.measure("cancellation_queue", () => h.then(() => {
|
|
2942
2942
|
}, () => {
|
|
2943
2943
|
})).then(f), e;
|
|
2944
2944
|
};
|
|
@@ -2952,16 +2952,16 @@ function Ao(t) {
|
|
|
2952
2952
|
if (a.authorityId !== t.authorityId || o && o.authorityId !== t.authorityId) throw new Error("Cancellation checkpoint authority mismatch.");
|
|
2953
2953
|
if (s = a, !o || a.requestSequence >= o.requestSequence) return a;
|
|
2954
2954
|
const c = { ...o.cancelled, ...a.submissions }, d = { ...a.operations, ...o.operations };
|
|
2955
|
-
for (const [
|
|
2956
|
-
(
|
|
2955
|
+
for (const [u, l] of Object.entries(a.operations))
|
|
2956
|
+
(l.phase === "done" || l.phase === "failed") && JSON.stringify(l.command) === JSON.stringify(o.operations[u]?.command) && (d[u] = l);
|
|
2957
2957
|
return {
|
|
2958
2958
|
...a,
|
|
2959
2959
|
requestSequence: Math.max(a.requestSequence, o.requestSequence),
|
|
2960
|
-
submissions: Object.fromEntries(Object.entries(c).map(([
|
|
2961
|
-
|
|
2962
|
-
|
|
2960
|
+
submissions: Object.fromEntries(Object.entries(c).map(([u, l]) => [
|
|
2961
|
+
u,
|
|
2962
|
+
u in o.cancelled ? { ...l, cancelled: !0, cancellationReason: o.cancelled[u].cancellationReason } : l
|
|
2963
2963
|
])),
|
|
2964
|
-
submissionOrder: [...a.submissionOrder, ...Object.keys(o.cancelled).filter((
|
|
2964
|
+
submissionOrder: [...a.submissionOrder, ...Object.keys(o.cancelled).filter((u) => !a.submissionOrder.includes(u))],
|
|
2965
2965
|
operations: d,
|
|
2966
2966
|
stops: { ...a.stops, ...o.stops }
|
|
2967
2967
|
};
|
|
@@ -3058,7 +3058,7 @@ function Ji(t, e, s, n, i = {}) {
|
|
|
3058
3058
|
...j(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
|
|
3059
3059
|
code: r ? j(t.lastErrorCode) : null,
|
|
3060
3060
|
...it(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
|
|
3061
|
-
builds: { sdk:
|
|
3061
|
+
builds: { sdk: Ft.version, ...i }
|
|
3062
3062
|
};
|
|
3063
3063
|
}
|
|
3064
3064
|
function xo(t, e = "runtime") {
|
|
@@ -3175,7 +3175,7 @@ function jo(t, e) {
|
|
|
3175
3175
|
}
|
|
3176
3176
|
return { schema: 1, authorityId: t.authorityId, operations: t.operations, stops: t.stops, requestSequence: t.requestSequence, submissions: s, submissionOrder: Object.keys(s), deliveries: n };
|
|
3177
3177
|
}
|
|
3178
|
-
function
|
|
3178
|
+
function ls(t) {
|
|
3179
3179
|
try {
|
|
3180
3180
|
return window.sessionStorage.getItem(t);
|
|
3181
3181
|
} catch (e) {
|
|
@@ -3258,9 +3258,9 @@ pe.pong = "3";
|
|
|
3258
3258
|
pe.message = "4";
|
|
3259
3259
|
pe.upgrade = "5";
|
|
3260
3260
|
pe.noop = "6";
|
|
3261
|
-
const
|
|
3261
|
+
const St = /* @__PURE__ */ Object.create(null);
|
|
3262
3262
|
Object.keys(pe).forEach((t) => {
|
|
3263
|
-
|
|
3263
|
+
St[pe[t]] = t;
|
|
3264
3264
|
});
|
|
3265
3265
|
const Qs = { type: "error", data: "parser error" }, Qi = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", Xi = typeof ArrayBuffer == "function", Yi = (t) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t) : t && t.buffer instanceof ArrayBuffer, mn = ({ type: t, data: e }, s, n) => Qi && e instanceof Blob ? s ? n(e) : Wn(e, n) : Xi && (e instanceof ArrayBuffer || Yi(e)) ? s ? n(e) : Wn(new Blob([e]), n) : n(pe[t] + (e || "")), Wn = (t, e) => {
|
|
3266
3266
|
const s = new FileReader();
|
|
@@ -3272,14 +3272,14 @@ const Qs = { type: "error", data: "parser error" }, Qi = typeof Blob == "functio
|
|
|
3272
3272
|
function Gn(t) {
|
|
3273
3273
|
return t instanceof Uint8Array ? t : t instanceof ArrayBuffer ? new Uint8Array(t) : new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
3274
3274
|
}
|
|
3275
|
-
let
|
|
3275
|
+
let us;
|
|
3276
3276
|
function Lo(t, e) {
|
|
3277
3277
|
if (Qi && t.data instanceof Blob)
|
|
3278
3278
|
return t.data.arrayBuffer().then(Gn).then(e);
|
|
3279
3279
|
if (Xi && (t.data instanceof ArrayBuffer || Yi(t.data)))
|
|
3280
3280
|
return e(Gn(t.data));
|
|
3281
3281
|
mn(t, !1, (s) => {
|
|
3282
|
-
|
|
3282
|
+
us || (us = new TextEncoder()), e(us.encode(s));
|
|
3283
3283
|
});
|
|
3284
3284
|
}
|
|
3285
3285
|
const Jn = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ze = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
@@ -3288,9 +3288,9 @@ for (let t = 0; t < Jn.length; t++)
|
|
|
3288
3288
|
const Fo = (t) => {
|
|
3289
3289
|
let e = t.length * 0.75, s = t.length, n, i = 0, r, a, o, c;
|
|
3290
3290
|
t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
|
|
3291
|
-
const d = new ArrayBuffer(e),
|
|
3291
|
+
const d = new ArrayBuffer(e), u = new Uint8Array(d);
|
|
3292
3292
|
for (n = 0; n < s; n += 4)
|
|
3293
|
-
r = Ze[t.charCodeAt(n)], a = Ze[t.charCodeAt(n + 1)], o = Ze[t.charCodeAt(n + 2)], c = Ze[t.charCodeAt(n + 3)],
|
|
3293
|
+
r = Ze[t.charCodeAt(n)], a = Ze[t.charCodeAt(n + 1)], o = Ze[t.charCodeAt(n + 2)], c = Ze[t.charCodeAt(n + 3)], u[i++] = r << 2 | a >> 4, u[i++] = (a & 15) << 4 | o >> 2, u[i++] = (o & 3) << 6 | c & 63;
|
|
3294
3294
|
return d;
|
|
3295
3295
|
}, $o = typeof ArrayBuffer == "function", yn = (t, e) => {
|
|
3296
3296
|
if (typeof t != "string")
|
|
@@ -3302,11 +3302,11 @@ const Fo = (t) => {
|
|
|
3302
3302
|
return s === "b" ? {
|
|
3303
3303
|
type: "message",
|
|
3304
3304
|
data: zo(t.substring(1), e)
|
|
3305
|
-
} :
|
|
3306
|
-
type:
|
|
3305
|
+
} : St[s] ? t.length > 1 ? {
|
|
3306
|
+
type: St[s],
|
|
3307
3307
|
data: t.substring(1)
|
|
3308
3308
|
} : {
|
|
3309
|
-
type:
|
|
3309
|
+
type: St[s]
|
|
3310
3310
|
} : Qs;
|
|
3311
3311
|
}, zo = (t, e) => {
|
|
3312
3312
|
if ($o) {
|
|
@@ -3353,7 +3353,7 @@ function Ko() {
|
|
|
3353
3353
|
}
|
|
3354
3354
|
});
|
|
3355
3355
|
}
|
|
3356
|
-
let
|
|
3356
|
+
let hs;
|
|
3357
3357
|
function pt(t) {
|
|
3358
3358
|
return t.reduce((e, s) => e + s.length, 0);
|
|
3359
3359
|
}
|
|
@@ -3367,7 +3367,7 @@ function ft(t, e) {
|
|
|
3367
3367
|
return t.length && n < t[0].length && (t[0] = t[0].slice(n)), s;
|
|
3368
3368
|
}
|
|
3369
3369
|
function Wo(t, e) {
|
|
3370
|
-
|
|
3370
|
+
hs || (hs = new TextDecoder());
|
|
3371
3371
|
const s = [];
|
|
3372
3372
|
let n = 0, i = -1, r = !1;
|
|
3373
3373
|
return new TransformStream({
|
|
@@ -3386,17 +3386,17 @@ function Wo(t, e) {
|
|
|
3386
3386
|
} else if (n === 2) {
|
|
3387
3387
|
if (pt(s) < 8)
|
|
3388
3388
|
break;
|
|
3389
|
-
const c = ft(s, 8), d = new DataView(c.buffer, c.byteOffset, c.length),
|
|
3390
|
-
if (
|
|
3389
|
+
const c = ft(s, 8), d = new DataView(c.buffer, c.byteOffset, c.length), u = d.getUint32(0);
|
|
3390
|
+
if (u > Math.pow(2, 21) - 1) {
|
|
3391
3391
|
o.enqueue(Qs);
|
|
3392
3392
|
break;
|
|
3393
3393
|
}
|
|
3394
|
-
i =
|
|
3394
|
+
i = u * Math.pow(2, 32) + d.getUint32(4), n = 3;
|
|
3395
3395
|
} else {
|
|
3396
3396
|
if (pt(s) < i)
|
|
3397
3397
|
break;
|
|
3398
3398
|
const c = ft(s, i);
|
|
3399
|
-
o.enqueue(yn(r ? c :
|
|
3399
|
+
o.enqueue(yn(r ? c : hs.decode(c), e)), n = 0;
|
|
3400
3400
|
}
|
|
3401
3401
|
if (i === 0 || i > t) {
|
|
3402
3402
|
o.enqueue(Qs);
|
|
@@ -3456,12 +3456,12 @@ F.prototype.listeners = function(t) {
|
|
|
3456
3456
|
F.prototype.hasListeners = function(t) {
|
|
3457
3457
|
return !!this.listeners(t).length;
|
|
3458
3458
|
};
|
|
3459
|
-
const
|
|
3459
|
+
const zt = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, s) => s(e, 0), re = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Jo = "arraybuffer";
|
|
3460
3460
|
function sr(t, ...e) {
|
|
3461
3461
|
return e.reduce((s, n) => (t.hasOwnProperty(n) && (s[n] = t[n]), s), {});
|
|
3462
3462
|
}
|
|
3463
3463
|
const Qo = re.setTimeout, Xo = re.clearTimeout;
|
|
3464
|
-
function
|
|
3464
|
+
function Ht(t, e) {
|
|
3465
3465
|
e.useNativeTimers ? (t.setTimeoutFn = Qo.bind(re), t.clearTimeoutFn = Xo.bind(re)) : (t.setTimeoutFn = re.setTimeout.bind(re), t.clearTimeoutFn = re.clearTimeout.bind(re));
|
|
3466
3466
|
}
|
|
3467
3467
|
const Yo = 1.33;
|
|
@@ -3504,7 +3504,7 @@ class vn extends F {
|
|
|
3504
3504
|
* @protected
|
|
3505
3505
|
*/
|
|
3506
3506
|
constructor(e) {
|
|
3507
|
-
super(), this.writable = !1,
|
|
3507
|
+
super(), this.writable = !1, Ht(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
3508
3508
|
}
|
|
3509
3509
|
/**
|
|
3510
3510
|
* Emits an error.
|
|
@@ -3736,7 +3736,7 @@ class aa extends ia {
|
|
|
3736
3736
|
}), this.pollXhr = e;
|
|
3737
3737
|
}
|
|
3738
3738
|
}
|
|
3739
|
-
let Ne = class
|
|
3739
|
+
let Ne = class kt extends F {
|
|
3740
3740
|
/**
|
|
3741
3741
|
* Request constructor
|
|
3742
3742
|
*
|
|
@@ -3744,7 +3744,7 @@ let Ne = class St extends F {
|
|
|
3744
3744
|
* @package
|
|
3745
3745
|
*/
|
|
3746
3746
|
constructor(e, s, n) {
|
|
3747
|
-
super(), this.createRequest = e,
|
|
3747
|
+
super(), this.createRequest = e, Ht(this, n), this._opts = n, this._method = n.method || "GET", this._uri = s, this._data = n.data !== void 0 ? n.data : null, this._create();
|
|
3748
3748
|
}
|
|
3749
3749
|
/**
|
|
3750
3750
|
* Creates the XHR object and sends the request.
|
|
@@ -3790,7 +3790,7 @@ let Ne = class St extends F {
|
|
|
3790
3790
|
}, 0);
|
|
3791
3791
|
return;
|
|
3792
3792
|
}
|
|
3793
|
-
typeof document < "u" && (this._index =
|
|
3793
|
+
typeof document < "u" && (this._index = kt.requestsCount++, kt.requests[this._index] = this);
|
|
3794
3794
|
}
|
|
3795
3795
|
/**
|
|
3796
3796
|
* Called upon error.
|
|
@@ -3812,7 +3812,7 @@ let Ne = class St extends F {
|
|
|
3812
3812
|
this._xhr.abort();
|
|
3813
3813
|
} catch {
|
|
3814
3814
|
}
|
|
3815
|
-
typeof document < "u" && delete
|
|
3815
|
+
typeof document < "u" && delete kt.requests[this._index], this._xhr = null;
|
|
3816
3816
|
}
|
|
3817
3817
|
}
|
|
3818
3818
|
/**
|
|
@@ -3913,7 +3913,7 @@ class la extends vn {
|
|
|
3913
3913
|
this.doWrite(n, r);
|
|
3914
3914
|
} catch {
|
|
3915
3915
|
}
|
|
3916
|
-
i &&
|
|
3916
|
+
i && zt(() => {
|
|
3917
3917
|
this.writable = !0, this.emitReserved("drain");
|
|
3918
3918
|
}, this.setTimeoutFn);
|
|
3919
3919
|
});
|
|
@@ -3933,10 +3933,10 @@ class la extends vn {
|
|
|
3933
3933
|
return this.opts.timestampRequests && (s[this.opts.timestampParam] = nr()), this.supportsBinary || (s.b64 = 1), this.createUri(e, s);
|
|
3934
3934
|
}
|
|
3935
3935
|
}
|
|
3936
|
-
const
|
|
3936
|
+
const ps = re.WebSocket || re.MozWebSocket;
|
|
3937
3937
|
class ua extends la {
|
|
3938
3938
|
createSocket(e, s, n) {
|
|
3939
|
-
return or ? new
|
|
3939
|
+
return or ? new ps(e, s, n) : s ? new ps(e, s) : new ps(e);
|
|
3940
3940
|
}
|
|
3941
3941
|
doWrite(e, s) {
|
|
3942
3942
|
this.ws.send(s);
|
|
@@ -3977,7 +3977,7 @@ class ha extends vn {
|
|
|
3977
3977
|
for (let s = 0; s < e.length; s++) {
|
|
3978
3978
|
const n = e[s], i = s === e.length - 1;
|
|
3979
3979
|
this._writer.write(n).then(() => {
|
|
3980
|
-
i &&
|
|
3980
|
+
i && zt(() => {
|
|
3981
3981
|
this.writable = !0, this.emitReserved("drain");
|
|
3982
3982
|
}, this.setTimeoutFn);
|
|
3983
3983
|
});
|
|
@@ -4028,9 +4028,9 @@ function ya(t, e) {
|
|
|
4028
4028
|
i && (s[i] = r);
|
|
4029
4029
|
}), s;
|
|
4030
4030
|
}
|
|
4031
|
-
const Ys = typeof addEventListener == "function" && typeof removeEventListener == "function",
|
|
4031
|
+
const Ys = typeof addEventListener == "function" && typeof removeEventListener == "function", Rt = [];
|
|
4032
4032
|
Ys && addEventListener("offline", () => {
|
|
4033
|
-
|
|
4033
|
+
Rt.forEach((t) => t());
|
|
4034
4034
|
}, !1);
|
|
4035
4035
|
class _e extends F {
|
|
4036
4036
|
/**
|
|
@@ -4044,7 +4044,7 @@ class _e extends F {
|
|
|
4044
4044
|
const n = Xs(e);
|
|
4045
4045
|
s.hostname = n.host, s.secure = n.protocol === "https" || n.protocol === "wss", s.port = n.port, n.query && (s.query = n.query);
|
|
4046
4046
|
} else s.host && (s.hostname = Xs(s.host).host);
|
|
4047
|
-
|
|
4047
|
+
Ht(this, s), this.secure = s.secure != null ? s.secure : typeof location < "u" && location.protocol === "https:", s.hostname && !s.port && (s.port = this.secure ? "443" : "80"), this.hostname = s.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = s.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, s.transports.forEach((n) => {
|
|
4048
4048
|
const i = n.prototype.name;
|
|
4049
4049
|
this.transports.push(i), this._transportsByName[i] = n;
|
|
4050
4050
|
}), this.opts = Object.assign({
|
|
@@ -4067,7 +4067,7 @@ class _e extends F {
|
|
|
4067
4067
|
this._onClose("transport close", {
|
|
4068
4068
|
description: "network connection lost"
|
|
4069
4069
|
});
|
|
4070
|
-
},
|
|
4070
|
+
}, Rt.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
4071
4071
|
}
|
|
4072
4072
|
/**
|
|
4073
4073
|
* Creates transport of the given type.
|
|
@@ -4216,7 +4216,7 @@ class _e extends F {
|
|
|
4216
4216
|
if (!this._pingTimeoutTime)
|
|
4217
4217
|
return !0;
|
|
4218
4218
|
const e = Date.now() > this._pingTimeoutTime;
|
|
4219
|
-
return e && (this._pingTimeoutTime = 0,
|
|
4219
|
+
return e && (this._pingTimeoutTime = 0, zt(() => {
|
|
4220
4220
|
this._onClose("ping timeout");
|
|
4221
4221
|
}, this.setTimeoutFn)), e;
|
|
4222
4222
|
}
|
|
@@ -4295,8 +4295,8 @@ class _e extends F {
|
|
|
4295
4295
|
_onClose(e, s) {
|
|
4296
4296
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
4297
4297
|
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Ys && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
4298
|
-
const n =
|
|
4299
|
-
n !== -1 &&
|
|
4298
|
+
const n = Rt.indexOf(this._offlineEventListener);
|
|
4299
|
+
n !== -1 && Rt.splice(n, 1);
|
|
4300
4300
|
}
|
|
4301
4301
|
this.readyState = "closed", this.id = null, this.emitReserved("close", e, s), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
4302
4302
|
}
|
|
@@ -4322,13 +4322,13 @@ class va extends _e {
|
|
|
4322
4322
|
let s = this.createTransport(e), n = !1;
|
|
4323
4323
|
_e.priorWebsocketSuccess = !1;
|
|
4324
4324
|
const i = () => {
|
|
4325
|
-
n || (s.send([{ type: "ping", data: "probe" }]), s.once("packet", (
|
|
4325
|
+
n || (s.send([{ type: "ping", data: "probe" }]), s.once("packet", (l) => {
|
|
4326
4326
|
if (!n)
|
|
4327
|
-
if (
|
|
4327
|
+
if (l.type === "pong" && l.data === "probe") {
|
|
4328
4328
|
if (this.upgrading = !0, this.emitReserved("upgrading", s), !s)
|
|
4329
4329
|
return;
|
|
4330
4330
|
_e.priorWebsocketSuccess = s.name === "websocket", this.transport.pause(() => {
|
|
4331
|
-
n || this.readyState !== "closed" && (
|
|
4331
|
+
n || this.readyState !== "closed" && (u(), this.setTransport(s), s.send([{ type: "upgrade" }]), this.emitReserved("upgrade", s), s = null, this.upgrading = !1, this.flush());
|
|
4332
4332
|
});
|
|
4333
4333
|
} else {
|
|
4334
4334
|
const h = new Error("probe error");
|
|
@@ -4337,10 +4337,10 @@ class va extends _e {
|
|
|
4337
4337
|
}));
|
|
4338
4338
|
};
|
|
4339
4339
|
function r() {
|
|
4340
|
-
n || (n = !0,
|
|
4340
|
+
n || (n = !0, u(), s.close(), s = null);
|
|
4341
4341
|
}
|
|
4342
|
-
const a = (
|
|
4343
|
-
const h = new Error("probe error: " +
|
|
4342
|
+
const a = (l) => {
|
|
4343
|
+
const h = new Error("probe error: " + l);
|
|
4344
4344
|
h.transport = s.name, r(), this.emitReserved("upgradeError", h);
|
|
4345
4345
|
};
|
|
4346
4346
|
function o() {
|
|
@@ -4349,10 +4349,10 @@ class va extends _e {
|
|
|
4349
4349
|
function c() {
|
|
4350
4350
|
a("socket closed");
|
|
4351
4351
|
}
|
|
4352
|
-
function d(
|
|
4353
|
-
s &&
|
|
4352
|
+
function d(l) {
|
|
4353
|
+
s && l.name !== s.name && r();
|
|
4354
4354
|
}
|
|
4355
|
-
const
|
|
4355
|
+
const u = () => {
|
|
4356
4356
|
s.removeListener("open", i), s.removeListener("error", a), s.removeListener("close", o), this.off("close", c), this.off("upgrading", d);
|
|
4357
4357
|
};
|
|
4358
4358
|
s.once("open", i), s.once("error", a), s.once("close", o), this.once("close", c), this.once("upgrading", d), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
|
|
@@ -4391,29 +4391,29 @@ const wa = typeof ArrayBuffer == "function", _a = (t) => typeof ArrayBuffer.isVi
|
|
|
4391
4391
|
function bn(t) {
|
|
4392
4392
|
return wa && (t instanceof ArrayBuffer || _a(t)) || Sa && t instanceof Blob || ka && t instanceof File;
|
|
4393
4393
|
}
|
|
4394
|
-
function
|
|
4394
|
+
function At(t, e) {
|
|
4395
4395
|
if (!t || typeof t != "object")
|
|
4396
4396
|
return !1;
|
|
4397
4397
|
if (Array.isArray(t)) {
|
|
4398
4398
|
for (let s = 0, n = t.length; s < n; s++)
|
|
4399
|
-
if (
|
|
4399
|
+
if (At(t[s]))
|
|
4400
4400
|
return !0;
|
|
4401
4401
|
return !1;
|
|
4402
4402
|
}
|
|
4403
4403
|
if (bn(t))
|
|
4404
4404
|
return !0;
|
|
4405
4405
|
if (t.toJSON && typeof t.toJSON == "function" && arguments.length === 1)
|
|
4406
|
-
return
|
|
4406
|
+
return At(t.toJSON(), !0);
|
|
4407
4407
|
for (const s in t)
|
|
4408
|
-
if (Object.prototype.hasOwnProperty.call(t, s) &&
|
|
4408
|
+
if (Object.prototype.hasOwnProperty.call(t, s) && At(t[s]))
|
|
4409
4409
|
return !0;
|
|
4410
4410
|
return !1;
|
|
4411
4411
|
}
|
|
4412
4412
|
function Ra(t) {
|
|
4413
4413
|
const e = [], s = t.data, n = t;
|
|
4414
|
-
return n.data =
|
|
4414
|
+
return n.data = Et(s, e), n.attachments = e.length, { packet: n, buffers: e };
|
|
4415
4415
|
}
|
|
4416
|
-
function
|
|
4416
|
+
function Et(t, e, s) {
|
|
4417
4417
|
if (!t)
|
|
4418
4418
|
return t;
|
|
4419
4419
|
if (bn(t)) {
|
|
@@ -4422,14 +4422,14 @@ function At(t, e, s) {
|
|
|
4422
4422
|
} else if (Array.isArray(t)) {
|
|
4423
4423
|
const n = new Array(t.length);
|
|
4424
4424
|
for (let i = 0; i < t.length; i++)
|
|
4425
|
-
n[i] =
|
|
4425
|
+
n[i] = Et(t[i], e);
|
|
4426
4426
|
return n;
|
|
4427
4427
|
} else if (typeof t == "object" && !(t instanceof Date)) {
|
|
4428
4428
|
if (t.toJSON && typeof t.toJSON == "function" && !s)
|
|
4429
|
-
return
|
|
4429
|
+
return Et(t.toJSON(), e, !0);
|
|
4430
4430
|
const n = {};
|
|
4431
4431
|
for (const i in t)
|
|
4432
|
-
Object.prototype.hasOwnProperty.call(t, i) && (n[i] =
|
|
4432
|
+
Object.prototype.hasOwnProperty.call(t, i) && (n[i] = Et(t[i], e));
|
|
4433
4433
|
return n;
|
|
4434
4434
|
}
|
|
4435
4435
|
return t;
|
|
@@ -4486,7 +4486,7 @@ class qa {
|
|
|
4486
4486
|
* @param {Object} obj - packet object
|
|
4487
4487
|
*/
|
|
4488
4488
|
encode(e) {
|
|
4489
|
-
return (e.type === x.EVENT || e.type === x.ACK) &&
|
|
4489
|
+
return (e.type === x.EVENT || e.type === x.ACK) && At(e) ? this.encodeAsBinary({
|
|
4490
4490
|
type: e.type === x.EVENT ? x.BINARY_EVENT : x.BINARY_ACK,
|
|
4491
4491
|
nsp: e.nsp,
|
|
4492
4492
|
data: e.data,
|
|
@@ -4807,8 +4807,8 @@ class cr extends F {
|
|
|
4807
4807
|
data: s
|
|
4808
4808
|
};
|
|
4809
4809
|
if (a.options = {}, a.options.compress = this.flags.compress !== !1, typeof s[s.length - 1] == "function") {
|
|
4810
|
-
const
|
|
4811
|
-
this._registerAckCallback(
|
|
4810
|
+
const u = this.ids++, l = s.pop();
|
|
4811
|
+
this._registerAckCallback(u, l), a.id = u;
|
|
4812
4812
|
}
|
|
4813
4813
|
const o = (i = (n = this.io.engine) === null || n === void 0 ? void 0 : n.transport) === null || i === void 0 ? void 0 : i.writable, c = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
|
|
4814
4814
|
return this.flags.volatile && !o || (c ? (this.notifyOutgoingListeners(a), this.packet(a)) : this.sendBuffer.push(a)), this.flags = {}, this;
|
|
@@ -5300,7 +5300,7 @@ Fe.prototype.setJitter = function(t) {
|
|
|
5300
5300
|
class en extends F {
|
|
5301
5301
|
constructor(e, s) {
|
|
5302
5302
|
var n;
|
|
5303
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (s = e, e = void 0), s = s || {}, s.path = s.path || "/socket.io", this.opts = s,
|
|
5303
|
+
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (s = e, e = void 0), s = s || {}, s.path = s.path || "/socket.io", this.opts = s, Ht(this, s), this.reconnection(s.reconnection !== !1), this.reconnectionAttempts(s.reconnectionAttempts || 1 / 0), this.reconnectionDelay(s.reconnectionDelay || 1e3), this.reconnectionDelayMax(s.reconnectionDelayMax || 5e3), this.randomizationFactor((n = s.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new Fe({
|
|
5304
5304
|
min: this.reconnectionDelay(),
|
|
5305
5305
|
max: this.reconnectionDelayMax(),
|
|
5306
5306
|
jitter: this.randomizationFactor()
|
|
@@ -5418,7 +5418,7 @@ class en extends F {
|
|
|
5418
5418
|
* @private
|
|
5419
5419
|
*/
|
|
5420
5420
|
ondecoded(e) {
|
|
5421
|
-
|
|
5421
|
+
zt(() => {
|
|
5422
5422
|
this.emitReserved("packet", e);
|
|
5423
5423
|
}, this.setTimeoutFn);
|
|
5424
5424
|
}
|
|
@@ -5536,17 +5536,17 @@ class en extends F {
|
|
|
5536
5536
|
}
|
|
5537
5537
|
}
|
|
5538
5538
|
const We = {};
|
|
5539
|
-
function
|
|
5539
|
+
function qt(t, e) {
|
|
5540
5540
|
typeof t == "object" && (e = t, t = void 0), e = e || {};
|
|
5541
5541
|
const s = Ia(t, e.path || "/socket.io"), n = s.source, i = s.id, r = s.path, a = We[i] && r in We[i].nsps, o = e.forceNew || e["force new connection"] || e.multiplex === !1 || a;
|
|
5542
5542
|
let c;
|
|
5543
5543
|
return o ? c = new en(n, e) : (We[i] || (We[i] = new en(n, e)), c = We[i]), s.query && !e.query && (e.query = s.queryKey), c.socket(s.path, e);
|
|
5544
5544
|
}
|
|
5545
|
-
Object.assign(
|
|
5545
|
+
Object.assign(qt, {
|
|
5546
5546
|
Manager: en,
|
|
5547
5547
|
Socket: cr,
|
|
5548
|
-
io:
|
|
5549
|
-
connect:
|
|
5548
|
+
io: qt,
|
|
5549
|
+
connect: qt
|
|
5550
5550
|
});
|
|
5551
5551
|
const xa = 9e4, Pa = /* @__PURE__ */ new Set([
|
|
5552
5552
|
"chat.user_message",
|
|
@@ -5575,7 +5575,7 @@ function Yn(t, e) {
|
|
|
5575
5575
|
}
|
|
5576
5576
|
class Da {
|
|
5577
5577
|
constructor(e) {
|
|
5578
|
-
this.options = e, this.socket =
|
|
5578
|
+
this.options = e, this.socket = qt(`${e.backendUrl.replace(/\/$/, "")}/product-agent`, {
|
|
5579
5579
|
path: "/api/product-agent/socket.io",
|
|
5580
5580
|
transports: ["websocket"],
|
|
5581
5581
|
autoConnect: !1,
|
|
@@ -5847,14 +5847,14 @@ class Da {
|
|
|
5847
5847
|
this.pending.add(a);
|
|
5848
5848
|
const o = Math.min(40 * 6e4, 6e4 + Math.ceil(n / (128 * 1024)) * 1e3), c = setTimeout(() => r.abort(), o);
|
|
5849
5849
|
try {
|
|
5850
|
-
const { token: d, ...
|
|
5850
|
+
const { token: d, ...u } = this.options.auth, l = await fetch(new URL("/api/product-agent/socket-results", this.options.backendUrl), {
|
|
5851
5851
|
method: "POST",
|
|
5852
5852
|
signal: r.signal,
|
|
5853
5853
|
headers: {
|
|
5854
5854
|
"content-type": "application/json",
|
|
5855
5855
|
authorization: `Bearer ${d}`,
|
|
5856
5856
|
"x-product-agent-result-context": JSON.stringify({
|
|
5857
|
-
auth:
|
|
5857
|
+
auth: u,
|
|
5858
5858
|
connection_id: `pa-sio:${this.socket.id}`,
|
|
5859
5859
|
request_id: i,
|
|
5860
5860
|
session_id: e.sessionId ?? e.session_id
|
|
@@ -5862,10 +5862,10 @@ class Da {
|
|
|
5862
5862
|
},
|
|
5863
5863
|
body: JSON.stringify({ request_id: i, type: "tool.result", payload: e })
|
|
5864
5864
|
});
|
|
5865
|
-
if (
|
|
5865
|
+
if (l.status >= 500)
|
|
5866
5866
|
throw new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
5867
|
-
if (!
|
|
5868
|
-
const h = await
|
|
5867
|
+
if (!l.ok) throw new q(`Result upload rejected (${l.status})`, String(l.status), !1, void 0, !0);
|
|
5868
|
+
const h = await l.json();
|
|
5869
5869
|
if (s !== this.generation || r.signal.aborted)
|
|
5870
5870
|
throw new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
5871
5871
|
if (h?.request_id !== i || typeof h.ok != "boolean")
|
|
@@ -5873,8 +5873,8 @@ class Da {
|
|
|
5873
5873
|
if (!h.ok) throw Yn(h, "Product Agent result rejected");
|
|
5874
5874
|
return h.result;
|
|
5875
5875
|
} catch (d) {
|
|
5876
|
-
const
|
|
5877
|
-
throw this.recoverUncertainDelivery(
|
|
5876
|
+
const u = d instanceof q ? d : new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
5877
|
+
throw this.recoverUncertainDelivery(u, s), u;
|
|
5878
5878
|
} finally {
|
|
5879
5879
|
clearTimeout(c), this.uploadingResult = !1, this.pending.delete(a);
|
|
5880
5880
|
}
|
|
@@ -5920,7 +5920,7 @@ function ee(t, e) {
|
|
|
5920
5920
|
throw Object.assign(new Error("Conversation authority was retired."), { code: "authority_retired", retryable: !0 });
|
|
5921
5921
|
}
|
|
5922
5922
|
function ke(t, e) {
|
|
5923
|
-
const s = Y(t, "connection_interrupted", "web_transport"), { code: n, message: i } = s, r = t instanceof Error && "detail" in t ? t.detail : t instanceof Error && "details" in t ? t.details : void 0, a = r && typeof r == "object" && "httpRequest" in r ? r.httpRequest : r, o = a && typeof a == "object" ? a : {}, c = o.category ?? o.transportCode, d = o.elapsedMs ?? o.durationMs,
|
|
5923
|
+
const s = Y(t, "connection_interrupted", "web_transport"), { code: n, message: i } = s, r = t instanceof Error && "detail" in t ? t.detail : t instanceof Error && "details" in t ? t.details : void 0, a = r && typeof r == "object" && "httpRequest" in r ? r.httpRequest : r, o = a && typeof a == "object" ? a : {}, c = o.category ?? o.transportCode, d = o.elapsedMs ?? o.durationMs, u = r && typeof r == "object" && "successfulRequests" in r && typeof r.successfulRequests == "number" ? r.successfulRequests : 0, l = r && typeof r == "object" && "securitySettingsUrl" in r && typeof r.securitySettingsUrl == "string" ? r.securitySettingsUrl : void 0, h = r && typeof r == "object" && "httpRequest" in r && he(r.httpRequest) ? r.httpRequest : void 0;
|
|
5924
5924
|
return Object.assign(new Error(i), {
|
|
5925
5925
|
code: n,
|
|
5926
5926
|
// Keep the actionable public URL without copying arbitrary transport internals into durable errors.
|
|
@@ -5928,11 +5928,11 @@ function ke(t, e) {
|
|
|
5928
5928
|
...s.details,
|
|
5929
5929
|
...e?.requestId ? { requestId: e.requestId } : {},
|
|
5930
5930
|
...h ? { httpRequest: h } : {},
|
|
5931
|
-
...
|
|
5931
|
+
...l ? { securitySettingsUrl: l } : {},
|
|
5932
5932
|
...typeof c == "string" && /^[a-z0-9_]{1,80}$/.test(c) ? { transportCode: c } : {},
|
|
5933
5933
|
...typeof o.requestId == "string" && /^[a-zA-Z0-9_-]{1,160}$/.test(o.requestId) ? { requestId: o.requestId } : {},
|
|
5934
5934
|
...typeof d == "number" && Number.isFinite(d) && d >= 0 ? { durationMs: d } : {},
|
|
5935
|
-
successfulRequests:
|
|
5935
|
+
successfulRequests: u
|
|
5936
5936
|
},
|
|
5937
5937
|
retryable: t !== null && typeof t == "object" && "retryable" in t && typeof t.retryable == "boolean" ? t.retryable : ["authority_retired", "executor_not_ready", "connection_interrupted", "request_timed_out", "408", "425", "429"].includes(n) || /^5\d\d$/.test(n)
|
|
5938
5938
|
});
|
|
@@ -5940,14 +5940,14 @@ function ke(t, e) {
|
|
|
5940
5940
|
function Ua(t) {
|
|
5941
5941
|
let e = Promise.resolve();
|
|
5942
5942
|
const s = (o = un(t.runtime().engine.getState().slices.conversation, t.runtime().engine.getState().slices.directory), c = Promise.resolve()) => {
|
|
5943
|
-
const d = c.then(() => ({ ok: !0 }), (m) => ({ ok: !1, error: m })),
|
|
5943
|
+
const d = c.then(() => ({ ok: !0 }), (m) => ({ ok: !1, error: m })), u = o ? Object.values(o.submissions).filter((m) => m.delivery !== "accepted").slice(-8).map((m) => ({ submission: m, timer: Q(t.onTiming, {
|
|
5944
5944
|
operation: "send",
|
|
5945
5945
|
layer: "http",
|
|
5946
5946
|
requestId: m.requestId,
|
|
5947
5947
|
clientMessageId: m.userMessageId,
|
|
5948
5948
|
sessionId: m.sessionId,
|
|
5949
5949
|
entrySurface: m.entrySurface
|
|
5950
|
-
}) })) : [],
|
|
5950
|
+
}) })) : [], l = e, h = Promise.all(u.map(({ timer: m }) => m.measure("checkpoint_queue", () => l.then(() => {
|
|
5951
5951
|
}, () => {
|
|
5952
5952
|
})))), f = async () => {
|
|
5953
5953
|
await h;
|
|
@@ -5955,8 +5955,8 @@ function Ua(t) {
|
|
|
5955
5955
|
const p = await d;
|
|
5956
5956
|
if (!p.ok) throw p.error;
|
|
5957
5957
|
};
|
|
5958
|
-
await Promise.all(
|
|
5959
|
-
for (const { submission: p, timer: y } of
|
|
5958
|
+
await Promise.all(u.length ? u.map(({ timer: p }) => p.measure("checkpoint_prerequisite", m)) : [m()]), ee(t, t.authority), await t.saveDelivery(o, u[u.length - 1]?.timer);
|
|
5959
|
+
for (const { submission: p, timer: y } of u) y.mark(p.contextPreparation === null ? "checkpoint" : "checkpoint_prepared");
|
|
5960
5960
|
};
|
|
5961
5961
|
return e = e.then(f, f), e;
|
|
5962
5962
|
}, n = (o, c) => {
|
|
@@ -5971,7 +5971,7 @@ function Ua(t) {
|
|
|
5971
5971
|
if (!t.onTiming || o.submission.sessionId !== null) return;
|
|
5972
5972
|
const c = t.runtime(), d = Object.values(c.engine.getState().slices.conversation.operations).find((f) => f.command.type === "runtime.warmup" && f.conversationScopeId === o.submission.conversationScopeId && ["waiting", "running", "uncertain"].includes(f.phase));
|
|
5973
5973
|
if (!d) return;
|
|
5974
|
-
const
|
|
5974
|
+
const u = Q(t.onTiming, {
|
|
5975
5975
|
operation: "send",
|
|
5976
5976
|
layer: "http",
|
|
5977
5977
|
requestId: d.command.request_id,
|
|
@@ -5979,18 +5979,18 @@ function Ua(t) {
|
|
|
5979
5979
|
sessionId: typeof d.command.payload.warmupId == "string" ? d.command.payload.warmupId : null,
|
|
5980
5980
|
entrySurface: o.submission.entrySurface
|
|
5981
5981
|
});
|
|
5982
|
-
let
|
|
5982
|
+
let l = () => {
|
|
5983
5983
|
}, h = () => {
|
|
5984
5984
|
};
|
|
5985
|
-
|
|
5985
|
+
u.measure("warmup_wait", () => new Promise((f, m) => {
|
|
5986
5986
|
const p = () => {
|
|
5987
5987
|
const y = c.engine.getState().slices, b = y.conversation.submissions[o.submission.userMessageId], k = y.conversation.operations[d.command.request_id];
|
|
5988
5988
|
!J(t) || !b || b.cancelled || y.directory.clients[b.clientScopeId] !== b.conversationScopeId ? m(new Error("Warmup wait was retired.")) : (b.sessionId !== null || !k || !["waiting", "running", "uncertain"].includes(k.phase)) && f();
|
|
5989
5989
|
};
|
|
5990
|
-
|
|
5990
|
+
l = c.engine.subscribe(p), h = c.onDispose(() => m(new Error("Warmup wait was retired."))), p();
|
|
5991
5991
|
})).catch(() => {
|
|
5992
5992
|
}).finally(() => {
|
|
5993
|
-
|
|
5993
|
+
l(), h();
|
|
5994
5994
|
});
|
|
5995
5995
|
};
|
|
5996
5996
|
return {
|
|
@@ -6003,21 +6003,21 @@ function Ua(t) {
|
|
|
6003
6003
|
clientMessageId: o.submission.userMessageId,
|
|
6004
6004
|
sessionId: o.submission.sessionId,
|
|
6005
6005
|
entrySurface: o.submission.entrySurface
|
|
6006
|
-
}),
|
|
6006
|
+
}), u = (y) => {
|
|
6007
6007
|
c.signal.aborted || (d.mark("preparation_retired"), c.abort(y));
|
|
6008
|
-
},
|
|
6009
|
-
d.mark("preparation_deadline"),
|
|
6008
|
+
}, l = setTimeout(() => {
|
|
6009
|
+
d.mark("preparation_deadline"), u(Object.assign(
|
|
6010
6010
|
new Error("Message preparation timed out. Retry this message."),
|
|
6011
6011
|
{ code: "submission_preparation_timeout", retryable: !0 }
|
|
6012
6012
|
));
|
|
6013
6013
|
}, 18e4), h = t.runtime(), f = () => {
|
|
6014
6014
|
const y = h.engine.getState().slices, b = y.conversation.submissions[o.submission.userMessageId];
|
|
6015
|
-
(!J(t) || !b || b.cancelled || b.requestId !== o.submission.requestId || y.directory.clients[b.clientScopeId] !== b.conversationScopeId) &&
|
|
6016
|
-
}, m = h.engine.subscribe(f), p = h.onDispose(() =>
|
|
6017
|
-
return f(),
|
|
6015
|
+
(!J(t) || !b || b.cancelled || b.requestId !== o.submission.requestId || y.directory.clients[b.clientScopeId] !== b.conversationScopeId) && u(Object.assign(new Error("Submission preparation was retired."), { code: "aborted", retryable: !1 }));
|
|
6016
|
+
}, m = h.engine.subscribe(f), p = h.onDispose(() => u(Object.assign(new Error("Submission runtime was disposed."), { code: "aborted" })));
|
|
6017
|
+
return f(), It(c.signal, () => t.prepareSubmission(o, c.signal).then((y) => (c.signal.aborted && d.mark("context_discarded"), y), (y) => {
|
|
6018
6018
|
throw c.signal.aborted && d.mark("context_discarded"), y;
|
|
6019
|
-
})).then((y) => (f(), c.signal.throwIfAborted(), a(o), y)).catch((y) => (
|
|
6020
|
-
clearTimeout(
|
|
6019
|
+
})).then((y) => (f(), c.signal.throwIfAborted(), a(o), y)).catch((y) => (u(y), n(y, { operation: "conversation.prepare", requestId: o.submission.userMessageId }))).finally(() => {
|
|
6020
|
+
clearTimeout(l), m(), p();
|
|
6021
6021
|
});
|
|
6022
6022
|
},
|
|
6023
6023
|
"conversation.checkpoint": async (o) => (ee(t, o), await s(o.checkpoint, t.saveCancellation(o.checkpoint)).catch((c) => n(c, { operation: "conversation.checkpoint" })), ee(t, o), { ...t.authority, submissionIds: Object.keys(o.checkpoint.submissions) }),
|
|
@@ -6047,21 +6047,21 @@ function Ua(t) {
|
|
|
6047
6047
|
let c = !1;
|
|
6048
6048
|
return Promise.resolve().then(async () => {
|
|
6049
6049
|
ee(t, o), (o.command.type === "chat.user_message" || o.command.type === "attachment.upload_completed") && r(String(o.command.payload.clientMessageId));
|
|
6050
|
-
const d = o.command.payload,
|
|
6050
|
+
const d = o.command.payload, u = o.command.type === "runtime.warmup", l = Q(["runtime.warmup", "chat.user_message", "chat.retry_last_user_message", "run.stop", "attachment.upload_completed"].includes(o.command.type) ? t.onTiming : void 0, {
|
|
6051
6051
|
operation: o.command.type === "run.stop" ? "stop" : "send",
|
|
6052
6052
|
layer: "http",
|
|
6053
6053
|
requestId: o.command.request_id,
|
|
6054
|
-
clientMessageId:
|
|
6055
|
-
sessionId: typeof d.sessionId == "string" ? d.sessionId :
|
|
6054
|
+
clientMessageId: u ? null : String(d.clientMessageId ?? d.expectedUserMessageId ?? o.command.request_id),
|
|
6055
|
+
sessionId: typeof d.sessionId == "string" ? d.sessionId : u && typeof d.warmupId == "string" ? d.warmupId : null
|
|
6056
6056
|
});
|
|
6057
|
-
return await
|
|
6057
|
+
return await l.measure(u ? "warmup_checkpoint" : "checkpoint", () => o.command.type === "run.stop" ? t.saveCancellation(t.runtime().engine.getState().slices.conversation) : s()), ee(t, o), (o.command.type === "chat.user_message" || o.command.type === "attachment.upload_completed") && r(String(o.command.payload.clientMessageId)), t.onCommand?.(o.command), c = !0, await l.measure(u ? "warmup_http" : "command_http", async () => {
|
|
6058
6058
|
const h = await t.http.request(
|
|
6059
6059
|
"/commands",
|
|
6060
6060
|
{},
|
|
6061
6061
|
{ context: i(), command: o.command },
|
|
6062
6062
|
"POST",
|
|
6063
6063
|
"conversations",
|
|
6064
|
-
{ timing:
|
|
6064
|
+
{ timing: l }
|
|
6065
6065
|
);
|
|
6066
6066
|
if (ee(t, o), h.request_id !== o.command.request_id || !je(h.result)) throw Object.assign(new Error("Conversation response identity mismatch."), { code: "acceptance_identity_mismatch" });
|
|
6067
6067
|
if (o.command.type.startsWith("chat.")) {
|
|
@@ -6080,12 +6080,12 @@ function Ua(t) {
|
|
|
6080
6080
|
}).catch((d) => {
|
|
6081
6081
|
if (o.previousAcceptance === "unissued" && d instanceof Error && "backendRefusal" in d && d.backendRefusal === !0) {
|
|
6082
6082
|
J(t) && t.onError?.(d, { operation: o.command.type, requestId: o.command.request_id });
|
|
6083
|
-
const
|
|
6084
|
-
throw Object.assign(
|
|
6083
|
+
const u = ke(d);
|
|
6084
|
+
throw Object.assign(u, { details: { ...u.details, acceptance: "rejected" } });
|
|
6085
6085
|
}
|
|
6086
6086
|
if (!c && o.previousAcceptance === "unissued") {
|
|
6087
|
-
const
|
|
6088
|
-
throw Object.assign(
|
|
6087
|
+
const u = ke(d);
|
|
6088
|
+
throw Object.assign(u, { details: { ...u.details, acceptance: "unissued" } });
|
|
6089
6089
|
}
|
|
6090
6090
|
if (d instanceof Error && "code" in d && d.code === "403") throw ke(d);
|
|
6091
6091
|
return n(d, { operation: o.command.type, requestId: o.command.request_id });
|
|
@@ -6107,9 +6107,9 @@ function Ua(t) {
|
|
|
6107
6107
|
throw Object.assign(new Error("Attachment preparation was cancelled."), { code: "submission_cancelled", retryable: !1 });
|
|
6108
6108
|
};
|
|
6109
6109
|
d(), await s(), d();
|
|
6110
|
-
const
|
|
6111
|
-
if (d(),
|
|
6112
|
-
const
|
|
6110
|
+
const u = await t.readAttachment(o.source.sourceId);
|
|
6111
|
+
if (d(), u.size !== o.source.sizeBytes) throw Object.assign(new Error("Attachment source changed."), { code: "attachment_changed" });
|
|
6112
|
+
const l = {
|
|
6113
6113
|
sessionId: o.submission.sessionId ?? void 0,
|
|
6114
6114
|
attachmentId: o.source.sourceId,
|
|
6115
6115
|
clientId: t.http.auth.client_id,
|
|
@@ -6124,11 +6124,11 @@ function Ua(t) {
|
|
|
6124
6124
|
entrySurface: o.submission.entrySurface
|
|
6125
6125
|
};
|
|
6126
6126
|
c = !0;
|
|
6127
|
-
const h = t.persistUpload ? await t.persistUpload(
|
|
6127
|
+
const h = t.persistUpload ? await t.persistUpload(l, new File([u], o.source.name, { type: o.source.mimeType })) : t.prepareUpload ? await t.prepareUpload(l) : await t.http.request("/attachments/upload", {}, l);
|
|
6128
6128
|
if (d(), !h.sessionId || o.submission.sessionId && h.sessionId !== o.submission.sessionId || h.attachment.id !== o.source.sourceId || h.attachment.mimeType !== o.source.mimeType || h.attachment.sizeBytes !== o.source.sizeBytes)
|
|
6129
6129
|
throw Object.assign(new Error("Attachment preparation identity mismatch."), { code: "attachment_identity_mismatch", retryable: !1 });
|
|
6130
6130
|
if ("uploadUrl" in h) {
|
|
6131
|
-
const p = await fetch(t.http.resolveUrl(h.uploadUrl), { method: h.uploadMethod, headers: h.uploadHeaders, body:
|
|
6131
|
+
const p = await fetch(t.http.resolveUrl(h.uploadUrl), { method: h.uploadMethod, headers: h.uploadHeaders, body: u });
|
|
6132
6132
|
if (!p.ok) throw Object.assign(new Error("Attachment transfer failed."), { code: String(p.status) });
|
|
6133
6133
|
}
|
|
6134
6134
|
d();
|
|
@@ -6144,19 +6144,19 @@ function Ua(t) {
|
|
|
6144
6144
|
return await t.onUploaded?.(o.source.sourceId, h.sessionId, m), d(), { sessionId: h.sessionId, attachment: m };
|
|
6145
6145
|
}).catch((d) => {
|
|
6146
6146
|
if (!c && o.previousAllocation === "unissued") {
|
|
6147
|
-
const
|
|
6148
|
-
throw Object.assign(
|
|
6147
|
+
const u = ke(d);
|
|
6148
|
+
throw Object.assign(u, { details: { ...u.details, allocation: "unissued" } });
|
|
6149
6149
|
}
|
|
6150
6150
|
return n(d, { operation: "conversation.upload", requestId: o.submission.userMessageId, ...o.submission.sessionId ? { sessionId: o.submission.sessionId } : {} });
|
|
6151
6151
|
}));
|
|
6152
6152
|
},
|
|
6153
6153
|
"conversation.snapshot": (o) => Promise.resolve().then(async () => {
|
|
6154
6154
|
ee(t, o);
|
|
6155
|
-
const c = t.runtime(), d = new AbortController(),
|
|
6155
|
+
const c = t.runtime(), d = new AbortController(), u = () => {
|
|
6156
6156
|
const f = c.engine.getState().slices;
|
|
6157
6157
|
J(t) ? f.directory.memberships[o.sessionId]?.members.length ? f.conversation.sessions[o.sessionId]?.queries[o.lane].requestId !== o.requestId && d.abort("request_replaced") : d.abort("observation_released") : d.abort("authority_retired");
|
|
6158
|
-
},
|
|
6159
|
-
|
|
6158
|
+
}, l = c.engine.subscribe(u), h = c.onDispose(() => d.abort("owner_disposed"));
|
|
6159
|
+
u();
|
|
6160
6160
|
try {
|
|
6161
6161
|
const f = [];
|
|
6162
6162
|
for (let b = 0; b < Math.max(1, o.refreshItemIds.length); b += 200) {
|
|
@@ -6197,7 +6197,7 @@ function Ua(t) {
|
|
|
6197
6197
|
projection_ready: f.every((b) => b.projection_ready)
|
|
6198
6198
|
}, updatedAt: t.now() };
|
|
6199
6199
|
} finally {
|
|
6200
|
-
|
|
6200
|
+
l(), h();
|
|
6201
6201
|
}
|
|
6202
6202
|
}).catch((c) => {
|
|
6203
6203
|
const d = ke(c, { requestId: o.requestId, sessionId: o.sessionId });
|
|
@@ -6241,13 +6241,13 @@ class Na {
|
|
|
6241
6241
|
maxFailureIntervalMs: 3e4,
|
|
6242
6242
|
isActiveTurn: () => !0,
|
|
6243
6243
|
poll: async () => {
|
|
6244
|
-
await this.options.socket.retain(r, o).catch((
|
|
6245
|
-
const h =
|
|
6246
|
-
if (
|
|
6244
|
+
await this.options.socket.retain(r, o).catch((l) => {
|
|
6245
|
+
const h = l instanceof q && l.code === "409" && l.message === "This conversation is temporarily unavailable. Please try again later.";
|
|
6246
|
+
if (l instanceof q && l.backendRefusal && !l.outcomeUnknown && !h && l.detail?.retryable !== !0) {
|
|
6247
6247
|
const f = this.observations.get(r);
|
|
6248
|
-
f?.subscription === c && (f.subscriptionDenied = !0), c.stop(), this.report(
|
|
6248
|
+
f?.subscription === c && (f.subscriptionDenied = !0), c.stop(), this.report(l);
|
|
6249
6249
|
}
|
|
6250
|
-
throw
|
|
6250
|
+
throw l;
|
|
6251
6251
|
}), c.stop(), this.observations.get(r)?.subscription !== c && await this.options.socket.release(r, o);
|
|
6252
6252
|
}
|
|
6253
6253
|
}), d = new Ye({
|
|
@@ -6257,31 +6257,31 @@ class Na {
|
|
|
6257
6257
|
isActiveTurn: () => !1,
|
|
6258
6258
|
poll: async () => {
|
|
6259
6259
|
for (; !this.disposed && J(this.options) && this.observations.get(r)?.history === d; ) {
|
|
6260
|
-
const
|
|
6261
|
-
if (!
|
|
6262
|
-
const h =
|
|
6260
|
+
const l = e.engine.getState().slices.conversation.sessions[r]?.queries.history;
|
|
6261
|
+
if (!l || l.cursor === null || l.error && !l.error.retryable) return;
|
|
6262
|
+
const h = l.cursor;
|
|
6263
6263
|
if (await this.refresh(r, "history"), this.observations.get(r)?.history !== d) return;
|
|
6264
6264
|
if (e.engine.getState().slices.conversation.sessions[r]?.queries.history.cursor === h)
|
|
6265
6265
|
throw new Error("Conversation history cursor did not advance.");
|
|
6266
6266
|
}
|
|
6267
6267
|
}
|
|
6268
|
-
}),
|
|
6268
|
+
}), u = new Ye({
|
|
6269
6269
|
activeIntervalMs: 15e3,
|
|
6270
6270
|
idleIntervalMs: 6e4,
|
|
6271
6271
|
maxFailureIntervalMs: 6e4,
|
|
6272
6272
|
isActiveTurn: () => {
|
|
6273
|
-
const
|
|
6274
|
-
return !!
|
|
6273
|
+
const l = e.engine.getState().slices.conversation;
|
|
6274
|
+
return !!l.sessions[r]?.preparation || ["thinking", "steering", "queued", "stopping"].includes(l.sessions[r]?.execution?.phase ?? "idle") || Object.values(l.submissions).some((h) => h.sessionId === r && !h.cancelled && !["accepted", "failed"].includes(h.delivery));
|
|
6275
6275
|
},
|
|
6276
6276
|
poll: async () => {
|
|
6277
|
-
const
|
|
6278
|
-
if (
|
|
6277
|
+
const l = e.engine.getState().slices.conversation.sessions[r]?.queries.current;
|
|
6278
|
+
if (l?.error && !l.error.retryable) return;
|
|
6279
6279
|
await this.refresh(r);
|
|
6280
6280
|
const h = e.engine.getState().slices.conversation.sessions[r]?.queries.history;
|
|
6281
6281
|
h?.status === "ready" && h.cursor !== null && d.refresh();
|
|
6282
6282
|
}
|
|
6283
6283
|
});
|
|
6284
|
-
this.observations.set(r, { current:
|
|
6284
|
+
this.observations.set(r, { current: u, history: d, subscription: c, subscriptionOwner: o, subscriptionDenied: !1 }), c.start(r, o), u.start(r, this.owner), d.start(r, this.owner);
|
|
6285
6285
|
}
|
|
6286
6286
|
const i = s && this.hasUncertainDelivery();
|
|
6287
6287
|
i ? this.deliveryRecovery.start("pending-delivery", this.owner) : (!s || !this.hasRunningDelivery()) && this.deliveryRecovery.stop(), this.observations.size || i ? this.options.wakeup.start() : this.options.wakeup.stop();
|
|
@@ -6292,11 +6292,11 @@ class Na {
|
|
|
6292
6292
|
const r = i ?? this.options.nextRequestId();
|
|
6293
6293
|
return n.engine.dispatch({ ...this.options.authority, type: "conversation.snapshot", sessionId: e, requestId: r, lane: s }).then(() => new Promise((o, c) => {
|
|
6294
6294
|
let d = null;
|
|
6295
|
-
const
|
|
6296
|
-
const
|
|
6297
|
-
return h &&
|
|
6295
|
+
const u = () => {
|
|
6296
|
+
const l = n.engine.getState().slices.conversation.sessions[e]?.queries[s], h = !this.disposed && J(this.options) && this.observations.has(e);
|
|
6297
|
+
return h && l?.requestId === r ? !1 : (d?.(), this.waiters.delete(u), h && l?.status === "error" ? c(l.error) : o(), !0);
|
|
6298
6298
|
};
|
|
6299
|
-
|
|
6299
|
+
u() || (this.waiters.add(u), d = n.engine.subscribe(u));
|
|
6300
6300
|
}));
|
|
6301
6301
|
}
|
|
6302
6302
|
receive(e) {
|
|
@@ -6417,7 +6417,7 @@ function Ba(t, e, s, n) {
|
|
|
6417
6417
|
return { ...r, role: "system", dataType: "run_status", content: t.data.message, loading: !1 };
|
|
6418
6418
|
}
|
|
6419
6419
|
}
|
|
6420
|
-
function
|
|
6420
|
+
function fs(t, e, s, n) {
|
|
6421
6421
|
const i = /* @__PURE__ */ new Map();
|
|
6422
6422
|
for (const _ of t.segments)
|
|
6423
6423
|
for (const T of [..._.activityIds, ..._.outcomeIds]) i.set(T, _.userMessageId);
|
|
@@ -6455,7 +6455,7 @@ function ps(t, e, s, n) {
|
|
|
6455
6455
|
createdAt: "",
|
|
6456
6456
|
loading: !1
|
|
6457
6457
|
});
|
|
6458
|
-
const c = t.activity.phase, d = t.submissions.filter((_) => !_.cancelled && !["accepted", "failed"].includes(_.delivery)),
|
|
6458
|
+
const c = t.activity.phase, d = t.submissions.filter((_) => !_.cancelled && !["accepted", "failed"].includes(_.delivery)), u = t.submissions[t.submissions.length - 1], l = [...t.items].reverse().find((_) => _.type === "user_message"), h = ["queued", "thinking", "steering", "awaiting_execution"].includes(c), f = u?.delivery === "failed" && (h && t.activity.userMessageId != null && t.activity.userMessageId !== u.userMessageId || l !== void 0 && l.id !== u.userMessageId && Date.parse(l.created_at) > u.submittedAt), m = new Map(t.submissions.filter((_) => (_ !== u || f) && !_.cancelled && _.delivery === "failed" && _.error).map((_) => [_.userMessageId, _])), p = a.flatMap((_) => {
|
|
6459
6459
|
const T = _.role === "user" ? m.get(_.id) : void 0;
|
|
6460
6460
|
return T?.error ? [_, {
|
|
6461
6461
|
id: `submission-error:${T.userMessageId}`,
|
|
@@ -6471,13 +6471,13 @@ function ps(t, e, s, n) {
|
|
|
6471
6471
|
code: "submission_checkpoint_pending",
|
|
6472
6472
|
message: Kr,
|
|
6473
6473
|
details: { requestId: k.requestId }
|
|
6474
|
-
} : null, g =
|
|
6474
|
+
} : null, g = u?.delivery === "failed" && !u.cancelled && !f ? u.error : b ?? R;
|
|
6475
6475
|
let I = {
|
|
6476
6476
|
isRetrying: t.isRetrying ?? !1,
|
|
6477
6477
|
historyRefreshFailure: g === e?.error ? t.historyRefreshFailure ?? null : null,
|
|
6478
6478
|
conversationDiagnostics: {
|
|
6479
6479
|
...g ? { errorMessageFingerprint: Gi(Me(g.message)) } : {},
|
|
6480
|
-
...
|
|
6480
|
+
...u && g && g === u.error && !f ? { failedClientMessageId: u.userMessageId } : {},
|
|
6481
6481
|
...typeof g?.details?.requestId == "string" ? { errorRequestId: g.details.requestId } : {},
|
|
6482
6482
|
...it(g?.details?.errorNormalization) ? { errorNormalization: g.details.errorNormalization } : {},
|
|
6483
6483
|
...n ? { owner: n } : {},
|
|
@@ -6493,7 +6493,7 @@ function ps(t, e, s, n) {
|
|
|
6493
6493
|
sessionId: t.sessionId,
|
|
6494
6494
|
messages: p,
|
|
6495
6495
|
removedItems: o,
|
|
6496
|
-
activeResponseUserMessageId: t.activity.userMessageId ?? t.segments[t.segments.length - 1]?.userMessageId ??
|
|
6496
|
+
activeResponseUserMessageId: t.activity.userMessageId ?? t.segments[t.segments.length - 1]?.userMessageId ?? u?.userMessageId ?? null,
|
|
6497
6497
|
segments: t.segments,
|
|
6498
6498
|
activity: t.activity,
|
|
6499
6499
|
receipts: t.receipts,
|
|
@@ -6570,7 +6570,7 @@ function La(t) {
|
|
|
6570
6570
|
}))
|
|
6571
6571
|
};
|
|
6572
6572
|
}
|
|
6573
|
-
function
|
|
6573
|
+
function Tt(t) {
|
|
6574
6574
|
return {
|
|
6575
6575
|
key: t,
|
|
6576
6576
|
status: "not_requested",
|
|
@@ -6582,7 +6582,7 @@ function qt(t) {
|
|
|
6582
6582
|
}
|
|
6583
6583
|
class ti {
|
|
6584
6584
|
constructor(e, s, n = (i, r) => r) {
|
|
6585
|
-
this.loader = s, this.merge = n, this.state =
|
|
6585
|
+
this.loader = s, this.merge = n, this.state = Tt(e);
|
|
6586
6586
|
}
|
|
6587
6587
|
loader;
|
|
6588
6588
|
merge;
|
|
@@ -6597,10 +6597,10 @@ class ti {
|
|
|
6597
6597
|
return this.listeners.add(e), e(this.state), () => this.listeners.delete(e);
|
|
6598
6598
|
}
|
|
6599
6599
|
setKey(e) {
|
|
6600
|
-
e !== this.state.key && (this.state =
|
|
6600
|
+
e !== this.state.key && (this.state = Tt(e), this.trailingLoad = null, this.publish());
|
|
6601
6601
|
}
|
|
6602
6602
|
reset() {
|
|
6603
|
-
this.state =
|
|
6603
|
+
this.state = Tt(this.state.key), this.trailingLoad = null, this.publish();
|
|
6604
6604
|
}
|
|
6605
6605
|
invalidate() {
|
|
6606
6606
|
this.state = {
|
|
@@ -6655,7 +6655,7 @@ class ti {
|
|
|
6655
6655
|
for (const e of this.listeners) e(this.state);
|
|
6656
6656
|
}
|
|
6657
6657
|
}
|
|
6658
|
-
function
|
|
6658
|
+
function Ct(t) {
|
|
6659
6659
|
const e = {}, s = [];
|
|
6660
6660
|
for (const n of t.entities)
|
|
6661
6661
|
e[n.id] || s.push(n.id), e[n.id] = n;
|
|
@@ -6722,12 +6722,12 @@ class dr {
|
|
|
6722
6722
|
}
|
|
6723
6723
|
async request(e, s = {}, n, i, r, a = {}) {
|
|
6724
6724
|
if (a.skipAuthentication) return this.requestOnce(e, s, n, i, r, a.signal, a.diagnostic);
|
|
6725
|
-
const o = this.options.authority?.(), c = (
|
|
6725
|
+
const o = this.options.authority?.(), c = (l = !0) => {
|
|
6726
6726
|
if (o !== this.options.authority?.()) throw new q("Conversation authority was retired.", "authority_retired", !0);
|
|
6727
|
-
|
|
6727
|
+
l && (this.requests.signal.throwIfAborted(), a.signal?.throwIfAborted());
|
|
6728
6728
|
}, d = a.readOnly ?? (i ?? (n === void 0 ? "GET" : "POST")) === "GET";
|
|
6729
|
-
let
|
|
6730
|
-
for (let
|
|
6729
|
+
let u = 0;
|
|
6730
|
+
for (let l = 0; ; ) {
|
|
6731
6731
|
await (a.timing ? a.timing.measure("http_authentication", async () => {
|
|
6732
6732
|
await this.options.pendingAuthentication?.();
|
|
6733
6733
|
}) : this.options.pendingAuthentication?.()), c();
|
|
@@ -6742,23 +6742,23 @@ class dr {
|
|
|
6742
6742
|
const k = n;
|
|
6743
6743
|
p = { ...k, context: { ...k.context, connection_id: m } };
|
|
6744
6744
|
}
|
|
6745
|
-
const y = () => this.requestOnce(e, s, p, i, r, a.signal, a.diagnostic, ++
|
|
6745
|
+
const y = () => this.requestOnce(e, s, p, i, r, a.signal, a.diagnostic, ++u), b = await (a.timing ? a.timing.measure("http_request", y) : y());
|
|
6746
6746
|
return c(), b;
|
|
6747
6747
|
} catch (p) {
|
|
6748
6748
|
if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw p;
|
|
6749
|
-
if (p instanceof q && p.code === "executor_not_ready" && m &&
|
|
6750
|
-
await this.options.restoreExecutor(m),
|
|
6749
|
+
if (p instanceof q && p.code === "executor_not_ready" && m && l === 0 && this.options.restoreExecutor) {
|
|
6750
|
+
await this.options.restoreExecutor(m), l++, c();
|
|
6751
6751
|
continue;
|
|
6752
6752
|
}
|
|
6753
|
-
if (!(p instanceof q) || !["unauthorized", "403"].includes(p.code) || !this.options.recoverAuthentication || !d || (await this.options.recoverAuthentication(f, p, d &&
|
|
6754
|
-
|
|
6753
|
+
if (!(p instanceof q) || !["unauthorized", "403"].includes(p.code) || !this.options.recoverAuthentication || !d || (await this.options.recoverAuthentication(f, p, d && l === 0), c(), !d || l !== 0)) throw p;
|
|
6754
|
+
l++;
|
|
6755
6755
|
}
|
|
6756
6756
|
}
|
|
6757
6757
|
}
|
|
6758
6758
|
async requestOnce(e, s, n, i, r, a, o, c = 1) {
|
|
6759
|
-
const d = this.auth.client_kind === "embed",
|
|
6760
|
-
for (const [E, C] of Object.entries({ ...
|
|
6761
|
-
C != null &&
|
|
6759
|
+
const d = this.auth.client_kind === "embed", u = new URL(`/api/product-agent/${r ?? (d ? "embed" : "runtime")}${e}`, this.options.backendUrl), l = r === "conversations" ? {} : d ? { client_id: this.auth.client_id, transport_id: this.auth.transport_id } : { community_id: this.auth.community_id, automation_run_id: this.auth.automation_run_id };
|
|
6760
|
+
for (const [E, C] of Object.entries({ ...l, ...s }))
|
|
6761
|
+
C != null && u.searchParams.set(E, String(C));
|
|
6762
6762
|
this.requests.signal.throwIfAborted(), a?.throwIfAborted();
|
|
6763
6763
|
const h = new AbortController(), f = { trigger: null }, m = (E) => {
|
|
6764
6764
|
h.signal.aborted || (f.trigger = E, h.abort());
|
|
@@ -6767,7 +6767,7 @@ class dr {
|
|
|
6767
6767
|
const b = r === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && i === "POST", k = /^\/conversations(?:\/[^/]+)?$/.test(e) && (i ?? (n === void 0 ? "GET" : "POST")) === "GET", R = setTimeout(() => m("deadline"), k ? 6e4 : b ? 3e4 : 15e3), g = Va(), v = Date.now();
|
|
6768
6768
|
let I = null, w = !1, A = null, _ = null, T = null;
|
|
6769
6769
|
try {
|
|
6770
|
-
const E = await Promise.resolve(fetch(
|
|
6770
|
+
const E = await Promise.resolve(fetch(u, {
|
|
6771
6771
|
method: i ?? (n === void 0 ? "GET" : "POST"),
|
|
6772
6772
|
cache: "no-store",
|
|
6773
6773
|
signal: h.signal,
|
|
@@ -6786,7 +6786,7 @@ class dr {
|
|
|
6786
6786
|
throw new q(M === "embedded_submission_conflict" ? "This message conflicts with an earlier submission. Review the conversation before retrying." : "This earlier submission cannot be verified. Review the conversation before retrying.", M, !1, void 0, !0);
|
|
6787
6787
|
if (r === "conversations" && e === "/commands" && (E.status === 409 && M?.code === "executor_not_ready" && M.retryable === !0 || E.status === 403 && M === "Register the executor before commands"))
|
|
6788
6788
|
throw new q("Reconnecting the browser before continuing.", "executor_not_ready");
|
|
6789
|
-
if (E.status !== 401 && M && typeof M == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(M.code) || !
|
|
6789
|
+
if (E.status !== 401 && M && typeof M == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(M.code) || !xt(void 0, M.code).allowed) && typeof M.message == "string")
|
|
6790
6790
|
throw new q(M.message, M.code, !1, {
|
|
6791
6791
|
...typeof M.blockedOrigin == "string" ? { blockedOrigin: M.blockedOrigin } : {},
|
|
6792
6792
|
...typeof M.securitySettingsUrl == "string" ? { securitySettingsUrl: M.securitySettingsUrl } : {}
|
|
@@ -6812,7 +6812,7 @@ class dr {
|
|
|
6812
6812
|
ownerId: j(o?.ownerId),
|
|
6813
6813
|
authorityGeneration: o?.authorityGeneration ?? null,
|
|
6814
6814
|
sessionId: j(o?.sessionId),
|
|
6815
|
-
release: this.auth.extension_version ? `extension-${this.auth.extension_version}` : `sdk-${
|
|
6815
|
+
release: this.auth.extension_version ? `extension-${this.auth.extension_version}` : `sdk-${Ft.version}`,
|
|
6816
6816
|
upstreamRequestId: _,
|
|
6817
6817
|
upstreamTraceId: T
|
|
6818
6818
|
};
|
|
@@ -6882,7 +6882,7 @@ function et(t) {
|
|
|
6882
6882
|
const e = t.error;
|
|
6883
6883
|
return t.status === "error" && t.consecutiveFailures < 10 && e !== null && !["unauthorized", "401", "403", "authority_retired"].includes(e.code) && (e.retryable || /^5\d\d$/.test(e.code) || ["runtime_error", "connection_interrupted", "request_timed_out", "408", "429"].includes(e.code));
|
|
6884
6884
|
}
|
|
6885
|
-
const
|
|
6885
|
+
const gs = { activeIntervalMs: 3e3, idleIntervalMs: 15e3, maxFailureIntervalMs: 3e4 };
|
|
6886
6886
|
function te(t) {
|
|
6887
6887
|
const e = t.currentAuthority();
|
|
6888
6888
|
return e.authorityId === t.authority.authorityId && e.generation === t.authority.generation;
|
|
@@ -6911,8 +6911,8 @@ function ii(t) {
|
|
|
6911
6911
|
const d = t.runtime.engine.getState().slices.directory;
|
|
6912
6912
|
if (t.isDisposed() || d.authorityId !== t.authority.authorityId || d.generation !== t.authority.generation)
|
|
6913
6913
|
return o(), !0;
|
|
6914
|
-
const
|
|
6915
|
-
return
|
|
6914
|
+
const u = d.mutations[t.sessionId]?.[t.field];
|
|
6915
|
+
return u && u.requestId !== t.requestId ? (r = !0, a(), s(new Error("Conversation update was superseded.")), !0) : u?.status === "pending" ? !1 : (r = !0, a(), u?.status === "failed" ? s(new Error(u.error?.message ?? t.failureMessage)) : e(), !0);
|
|
6916
6916
|
};
|
|
6917
6917
|
c() || (n = t.runtime.engine.subscribe(c), i = t.runtime.onDispose(o));
|
|
6918
6918
|
});
|
|
@@ -6978,7 +6978,7 @@ class Ja {
|
|
|
6978
6978
|
if (s) for (const [i, r] of Object.entries(e)) {
|
|
6979
6979
|
if (!r.observe || this.observations.has(i)) continue;
|
|
6980
6980
|
const a = this.options.recovery?.(i), o = new Ye({
|
|
6981
|
-
...
|
|
6981
|
+
...gs,
|
|
6982
6982
|
isActiveTurn: () => this.options.isActiveTurn(i),
|
|
6983
6983
|
poll: async () => {
|
|
6984
6984
|
try {
|
|
@@ -7014,8 +7014,8 @@ class Ja {
|
|
|
7014
7014
|
const a = this.queryRetries.get(r) ?? { timer: null };
|
|
7015
7015
|
if (a.timer !== null) continue;
|
|
7016
7016
|
const o = Math.min(
|
|
7017
|
-
|
|
7018
|
-
|
|
7017
|
+
gs.activeIntervalMs * 2 ** Math.min(i.consecutiveFailures - 1, 4),
|
|
7018
|
+
gs.maxFailureIntervalMs
|
|
7019
7019
|
);
|
|
7020
7020
|
a.timer = setTimeout(() => {
|
|
7021
7021
|
a.timer = null, !this.queryRequests.has(r) && this.refreshObservedQuery(i.query).catch((c) => this.report(c));
|
|
@@ -7228,8 +7228,8 @@ class Xa {
|
|
|
7228
7228
|
if (e !== void 0 && r.some((c) => c.sessionId !== e)) return !1;
|
|
7229
7229
|
const a = [], o = new Set(r.map((c) => c.sessionId));
|
|
7230
7230
|
for (const c of o) {
|
|
7231
|
-
const d = r.filter((f) => f.sessionId === c),
|
|
7232
|
-
for (const f of
|
|
7231
|
+
const d = r.filter((f) => f.sessionId === c), u = c === null ? d[0] : d.find((f) => f.clientScopeId === n.mains[c]) ?? this.choose(d), l = [u, ...d.filter((f) => f !== u)], h = /* @__PURE__ */ new Set();
|
|
7232
|
+
for (const f of l) {
|
|
7233
7233
|
const m = { ...this.options.authority, clientScopeId: f.clientScopeId, conversationScopeId: f.conversationScopeId, replacement: null };
|
|
7234
7234
|
f.provisionalId !== null && !h.has(f.conversationScopeId) && !s.selections[f.conversationScopeId]?.sessionId ? (a.push({ ...m, type: "directory.provisional", provisionalId: f.provisionalId }), c !== null && (a.push({
|
|
7235
7235
|
...this.options.authority,
|
|
@@ -7375,7 +7375,7 @@ class L extends EventTarget {
|
|
|
7375
7375
|
const n = this.connectionAttempt, i = (/* @__PURE__ */ new Date()).toISOString(), r = this.diagnostics.findIndex((c) => c.phase === e && c.connectionAttemptId === n?.connectionAttemptId), a = this.diagnostics[r], o = {
|
|
7376
7376
|
id: a?.id ?? crypto.randomUUID(),
|
|
7377
7377
|
phase: e,
|
|
7378
|
-
sdkVersion:
|
|
7378
|
+
sdkVersion: Ft.version,
|
|
7379
7379
|
stage: s.stage ?? (s.readinessPhase === "bootstrap" ? "bootstrap" : s.readinessPhase === "activation" ? "executor_registration" : "socket_admission"),
|
|
7380
7380
|
...s.httpStatus ? { httpStatus: s.httpStatus } : {},
|
|
7381
7381
|
...s.failureKind ? { failureKind: s.failureKind } : {},
|
|
@@ -7577,14 +7577,14 @@ class L extends EventTarget {
|
|
|
7577
7577
|
if (n === "session.reset" && !e.sessionId && !e.warmupId) return;
|
|
7578
7578
|
const c = n === "chat.user_message" || n === "chat.retry_last_user_message";
|
|
7579
7579
|
c && e.sessionId && await this.retain(e.sessionId);
|
|
7580
|
-
const
|
|
7581
|
-
if (!
|
|
7582
|
-
const
|
|
7580
|
+
const u = await this.transport.rpc(n, i);
|
|
7581
|
+
if (!u?.sessionId || !c && n !== "runtime.warmup") return;
|
|
7582
|
+
const l = u.sessionId;
|
|
7583
7583
|
if (n === "runtime.warmup") {
|
|
7584
7584
|
if (!this.isCurrent(s)) return;
|
|
7585
|
-
e.warmupId && this.receive({ type: "runtime.warmup_ack", sessionId:
|
|
7585
|
+
e.warmupId && this.receive({ type: "runtime.warmup_ack", sessionId: l, warmupId: e.warmupId, reason: e.reason });
|
|
7586
7586
|
}
|
|
7587
|
-
(n === "chat.user_message" || n === "chat.retry_last_user_message") && (s.submissionAccepted = !0, this.receive({ type: "submission.accepted", sessionId:
|
|
7587
|
+
(n === "chat.user_message" || n === "chat.retry_last_user_message") && (s.submissionAccepted = !0, this.receive({ type: "submission.accepted", sessionId: l, clientMessageId: u.clientMessageId ?? e.clientMessageId })), await this.retain(l), this.isCurrent(s) && (n === "chat.user_message" || n === "runtime.warmup") && !e.sessionId && await this.hydrate(l, { sessionId: l, page: e.page }, s, e.warmupId);
|
|
7588
7588
|
}
|
|
7589
7589
|
isCurrent(e) {
|
|
7590
7590
|
return this.readyState === 1 && this.contextRevisions.get(e.key) === e.revision;
|
|
@@ -7666,15 +7666,15 @@ function tc(t, e, s) {
|
|
|
7666
7666
|
return n?.sessionId === s ? n : null;
|
|
7667
7667
|
}
|
|
7668
7668
|
function sc(t, e, s, n, i, r, a, o, c = null, d = !1) {
|
|
7669
|
-
const
|
|
7669
|
+
const u = n ? o.find((h) => h.role === "user" && (h.id === n || h.clientMessageId === n)) : void 0, l = u ? [...o].reverse().find((h) => (h.role === "assistant" || h.dataType === "commentary_history" || h.dataType === "tool_summary") && h.respondsToUserMessageId === u.id) : void 0;
|
|
7670
7670
|
return {
|
|
7671
7671
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7672
7672
|
authenticated: i,
|
|
7673
7673
|
activeClientMessageId: qe(r) ? r : null,
|
|
7674
7674
|
pendingClientMessageId: qe(a) ? a : null,
|
|
7675
|
-
clientUserMessageItemId:
|
|
7676
|
-
clientResponseItemId:
|
|
7677
|
-
clientDraftObserved: !!(
|
|
7675
|
+
clientUserMessageItemId: u && qe(u.id) ? u.id : null,
|
|
7676
|
+
clientResponseItemId: l && qe(l.id) ? l.id : null,
|
|
7677
|
+
clientDraftObserved: !!(u && d && c === u.id),
|
|
7678
7678
|
renderer: tc(t, e, s)
|
|
7679
7679
|
};
|
|
7680
7680
|
}
|
|
@@ -7801,7 +7801,7 @@ function li(t, e, s) {
|
|
|
7801
7801
|
delete r[e];
|
|
7802
7802
|
let a = t.memberships;
|
|
7803
7803
|
if (i !== null) {
|
|
7804
|
-
const o = a[i], c = o.members.filter((
|
|
7804
|
+
const o = a[i], c = o.members.filter((u) => u !== e);
|
|
7805
7805
|
let d = o.mainClientScopeId;
|
|
7806
7806
|
if (d === e && (d = null, c.length > 0)) {
|
|
7807
7807
|
if (!s || s.sessionId !== i || s.membershipRevision !== t.membershipRevision || !c.includes(s.clientScopeId))
|
|
@@ -7887,7 +7887,7 @@ function nn(t) {
|
|
|
7887
7887
|
queries: Object.fromEntries(Object.entries(t.queries).map(([e, s]) => [e, { ...s, invalidated: !0 }]))
|
|
7888
7888
|
};
|
|
7889
7889
|
}
|
|
7890
|
-
function
|
|
7890
|
+
function ms(t, e, s) {
|
|
7891
7891
|
if (e.conversation_id !== e.conversation.id || !Number.isSafeInteger(e.version) || e.version < 0)
|
|
7892
7892
|
throw new Error("Invalid conversation metadata envelope identity or version.");
|
|
7893
7893
|
const n = t.entities[e.conversation_id];
|
|
@@ -7918,15 +7918,15 @@ function Te(t, e, s) {
|
|
|
7918
7918
|
if (e.type === "effect.failed")
|
|
7919
7919
|
n = { ...n, queries: { ...n.queries, [o]: { ...c, status: "error", error: { ...e.error }, requestId: null, consecutiveFailures: c.consecutiveFailures + 1 } } };
|
|
7920
7920
|
else if (e.effectKind === "directory.query") {
|
|
7921
|
-
for (const p of e.output.entries) n =
|
|
7922
|
-
const d = e.output.entries.map((p) => p.conversation_id),
|
|
7921
|
+
for (const p of e.output.entries) n = ms(n, p, !0);
|
|
7922
|
+
const d = e.output.entries.map((p) => p.conversation_id), u = { ...n.durableActivityBySessionId }, l = { ...n.activityBySessionId }, h = { ...n.activityRevisionBySessionId };
|
|
7923
7923
|
for (const p of e.output.entries) {
|
|
7924
7924
|
if (typeof p.is_active != "boolean") continue;
|
|
7925
|
-
|
|
7925
|
+
u[p.conversation_id] = p.is_active;
|
|
7926
7926
|
const y = c.startedAtActivityRevisionBySessionId[p.conversation_id];
|
|
7927
|
-
y !== void 0 && h[p.conversation_id] === y && (delete
|
|
7927
|
+
y !== void 0 && h[p.conversation_id] === y && (delete l[p.conversation_id], delete h[p.conversation_id]);
|
|
7928
7928
|
}
|
|
7929
|
-
n = { ...n, durableActivityBySessionId:
|
|
7929
|
+
n = { ...n, durableActivityBySessionId: u, activityBySessionId: l, activityRevisionBySessionId: h };
|
|
7930
7930
|
const f = Object.fromEntries(Object.entries(n.optimisticEntries).filter(([, p]) => p.sessionId === null || !d.includes(p.sessionId)));
|
|
7931
7931
|
n = { ...n, optimisticEntries: f };
|
|
7932
7932
|
const m = [.../* @__PURE__ */ new Set([...c.mode === "append" ? c.data ?? [] : [], ...d])];
|
|
@@ -7946,7 +7946,7 @@ function Te(t, e, s) {
|
|
|
7946
7946
|
} else {
|
|
7947
7947
|
if (e.type === "effect.completed" && e.effectKind === "directory.mutate") {
|
|
7948
7948
|
if (e.output.conversation_id !== r.input.sessionId) throw new Error("Mutation response has the wrong conversation identity.");
|
|
7949
|
-
n =
|
|
7949
|
+
n = ms(n, e.output, !0);
|
|
7950
7950
|
}
|
|
7951
7951
|
const o = { ...n.mutations[r.input.sessionId] };
|
|
7952
7952
|
for (const c of ["title", "pinned"]) {
|
|
@@ -7959,7 +7959,7 @@ function Te(t, e, s) {
|
|
|
7959
7959
|
if (e.authorityId !== (t.authorityId ?? "") || e.generation !== t.generation)
|
|
7960
7960
|
return { state: t, effects: i };
|
|
7961
7961
|
if (e.type === "directory.metadata_received")
|
|
7962
|
-
n =
|
|
7962
|
+
n = ms(t, e.metadata, !0);
|
|
7963
7963
|
else if (e.type === "directory.invalidate")
|
|
7964
7964
|
n = nn(t);
|
|
7965
7965
|
else if (e.type === "directory.optimistic_upsert")
|
|
@@ -8003,14 +8003,14 @@ function Te(t, e, s) {
|
|
|
8003
8003
|
const c = B(e.query), d = t.queries[c];
|
|
8004
8004
|
if (d?.requestId !== null && d?.requestId !== void 0) return { state: t, effects: i };
|
|
8005
8005
|
if (e.mode === "append" && e.cursor === void 0 && (!d?.data || d.cursor === null)) return { state: t, effects: i };
|
|
8006
|
-
const
|
|
8006
|
+
const u = { ...e.query };
|
|
8007
8007
|
o = { kind: "directory.query", input: {
|
|
8008
8008
|
...a,
|
|
8009
|
-
query:
|
|
8009
|
+
query: u,
|
|
8010
8010
|
cursor: e.cursor !== void 0 ? e.cursor : e.mode === "append" ? d?.cursor ?? null : null
|
|
8011
8011
|
} }, n = { ...t, queries: { ...t.queries, [c]: {
|
|
8012
8012
|
...Ue(d ?? ye(c), { key: c, requestId: e.requestId, mode: e.mode }),
|
|
8013
|
-
query:
|
|
8013
|
+
query: u,
|
|
8014
8014
|
requestSequence: t.requestSequence + 1,
|
|
8015
8015
|
mode: e.mode,
|
|
8016
8016
|
invalidated: d?.invalidated ?? !1,
|
|
@@ -8024,9 +8024,9 @@ function Te(t, e, s) {
|
|
|
8024
8024
|
if (c.title === void 0 && c.pinned === void 0 || c.title !== void 0 && (!c.title.trim() || c.title.trim().length > 120)) throw new Error("Invalid directory mutation.");
|
|
8025
8025
|
c.title !== void 0 && (c.title = c.title.trim()), o = { kind: "directory.mutate", input: { ...a, sessionId: e.sessionId, patch: c } };
|
|
8026
8026
|
const d = { ...t.mutations[e.sessionId] };
|
|
8027
|
-
for (const
|
|
8028
|
-
const
|
|
8029
|
-
|
|
8027
|
+
for (const u of ["title", "pinned"]) {
|
|
8028
|
+
const l = c[u];
|
|
8029
|
+
l !== void 0 && (d[u] = { requestId: e.requestId, value: l, status: "pending", error: null });
|
|
8030
8030
|
}
|
|
8031
8031
|
n = nn({ ...t, mutations: { ...t.mutations, [e.sessionId]: d } });
|
|
8032
8032
|
}
|
|
@@ -8326,10 +8326,10 @@ function pi(t, e, s) {
|
|
|
8326
8326
|
for (const [a, o] of Object.entries(s.memberships)) {
|
|
8327
8327
|
const c = s.clients[o.members[0]];
|
|
8328
8328
|
if (!c) continue;
|
|
8329
|
-
const d = Ie(e, s, c),
|
|
8330
|
-
if (d.activity.phase ===
|
|
8331
|
-
const
|
|
8332
|
-
n = Te(n, { ...i, type: "directory.activity_set", sessionId: a, active:
|
|
8329
|
+
const d = Ie(e, s, c), u = Ie(t, s, c);
|
|
8330
|
+
if (d.activity.phase === u.activity.phase) continue;
|
|
8331
|
+
const l = ["submitting", "awaiting_execution", "thinking", "steering", "queued", "stopping"].includes(d.activity.phase);
|
|
8332
|
+
n = Te(n, { ...i, type: "directory.activity_set", sessionId: a, active: l }).state;
|
|
8333
8333
|
}
|
|
8334
8334
|
return n;
|
|
8335
8335
|
}
|
|
@@ -8354,27 +8354,27 @@ class vc {
|
|
|
8354
8354
|
if (o.type.startsWith("stage7.") || (o.type === "effect.completed" || o.type === "effect.failed") && o.effectKind.startsWith("stage7.")) {
|
|
8355
8355
|
const d = Fs(r.slices, o, r.slices);
|
|
8356
8356
|
if (d.state === r.slices) return { state: r, effects: d.effects };
|
|
8357
|
-
const
|
|
8358
|
-
return { state: Object.freeze({ revision: r.revision + 1, slices: Object.freeze({ ...r.slices, ...
|
|
8357
|
+
const u = G(Z({ account: d.state.account, features: d.state.features, interactions: d.state.interactions }));
|
|
8358
|
+
return { state: Object.freeze({ revision: r.revision + 1, slices: Object.freeze({ ...r.slices, ...u }) }), effects: d.effects };
|
|
8359
8359
|
}
|
|
8360
8360
|
if (o.type.startsWith("activeUsers.") || (o.type === "effect.completed" || o.type === "effect.failed") && o.effectKind.startsWith("activeUsers.")) {
|
|
8361
8361
|
const d = rc(r.slices.activeUsers, o);
|
|
8362
8362
|
return { state: d.state === r.slices.activeUsers ? r : Object.freeze({ revision: r.revision + 1, slices: Object.freeze({ ...r.slices, activeUsers: d.state }) }), effects: d.effects };
|
|
8363
8363
|
}
|
|
8364
8364
|
if (fc(o)) {
|
|
8365
|
-
const d = Te(r.slices.directory, o, r.slices.conversation),
|
|
8365
|
+
const d = Te(r.slices.directory, o, r.slices.conversation), u = Js(Ks(r.slices.conversation, d.state, o.type === "directory.authority_replace" && o.adoptLocalSubmissions === !0)), l = Ws(r.slices.conversation, u.state, d.state, d.state.clients !== r.slices.directory.clients), h = l.state, f = pi(r.slices.conversation, h, d.state);
|
|
8366
8366
|
return { state: f === r.slices.directory && h === r.slices.conversation ? r : Object.freeze({
|
|
8367
8367
|
revision: r.revision + 1,
|
|
8368
8368
|
slices: Object.freeze({ ...r.slices, directory: f, conversation: h })
|
|
8369
|
-
}), effects: [...
|
|
8369
|
+
}), effects: [...l.effects, ...d.effects, ...u.effects] };
|
|
8370
8370
|
}
|
|
8371
8371
|
if (gc(o)) {
|
|
8372
8372
|
const d = wo(r.slices.conversation, o, r.slices.directory, r.slices.modelSelection);
|
|
8373
|
-
let
|
|
8373
|
+
let u = r.slices.directory;
|
|
8374
8374
|
for (const [k, R] of Object.entries(d.state.operations)) {
|
|
8375
8375
|
if (!["runtime.warmup", "attachment.prepare"].includes(R.command.type) || !R.conversationScopeId || R.phase !== "done" || r.slices.conversation.operations[k]?.phase === "done") continue;
|
|
8376
|
-
const g = R.result, v =
|
|
8377
|
-
g?.sessionId && v?.provisionalId && v.sessionId === null && Object.values(
|
|
8376
|
+
const g = R.result, v = u.selections[R.conversationScopeId];
|
|
8377
|
+
g?.sessionId && v?.provisionalId && v.sessionId === null && Object.values(u.clients).includes(R.conversationScopeId) && (u = Te(u, {
|
|
8378
8378
|
authorityId: d.state.authorityId,
|
|
8379
8379
|
generation: d.state.generation,
|
|
8380
8380
|
type: "directory.accepted",
|
|
@@ -8383,29 +8383,29 @@ class vc {
|
|
|
8383
8383
|
sessionId: g.sessionId
|
|
8384
8384
|
}).state);
|
|
8385
8385
|
}
|
|
8386
|
-
const
|
|
8387
|
-
if (
|
|
8388
|
-
const k =
|
|
8389
|
-
!
|
|
8386
|
+
const l = Object.values(d.state.submissions).find((k) => k.delivery === "accepted" && r.slices.conversation.submissions[k.userMessageId]?.delivery !== "accepted");
|
|
8387
|
+
if (l) {
|
|
8388
|
+
const k = u.selections[l.conversationScopeId];
|
|
8389
|
+
!l.cancelled && k?.provisionalId && (u = Te(u, {
|
|
8390
8390
|
type: "directory.accepted",
|
|
8391
8391
|
authorityId: d.state.authorityId,
|
|
8392
8392
|
generation: d.state.generation,
|
|
8393
|
-
conversationScopeId:
|
|
8393
|
+
conversationScopeId: l.conversationScopeId,
|
|
8394
8394
|
provisionalId: k.provisionalId,
|
|
8395
|
-
sessionId:
|
|
8395
|
+
sessionId: l.sessionId
|
|
8396
8396
|
}).state);
|
|
8397
8397
|
}
|
|
8398
|
-
|
|
8399
|
-
const h = Js(Ks(d.state,
|
|
8398
|
+
u = pi(r.slices.conversation, d.state, u);
|
|
8399
|
+
const h = Js(Ks(d.state, u)), f = Ws(d.state, h.state, u);
|
|
8400
8400
|
let m = r.slices;
|
|
8401
8401
|
const p = [], y = d.interactionSources, b = m.account.authority;
|
|
8402
8402
|
if (y && b && b.authorityId === y.authorityId && b.generation === y.generation) {
|
|
8403
|
-
const k = Fs(m, { type: "stage7.sources", authority: b, now: m.features.now, sources: y.sources }, { conversation: f.state, directory:
|
|
8403
|
+
const k = Fs(m, { type: "stage7.sources", authority: b, now: m.features.now, sources: y.sources }, { conversation: f.state, directory: u });
|
|
8404
8404
|
m = G(Z({ account: k.state.account, features: k.state.features, interactions: k.state.interactions })), p.push(...k.effects);
|
|
8405
8405
|
}
|
|
8406
|
-
return { state: f.state === r.slices.conversation &&
|
|
8406
|
+
return { state: f.state === r.slices.conversation && u === r.slices.directory && m === r.slices ? r : Object.freeze({
|
|
8407
8407
|
revision: r.revision + 1,
|
|
8408
|
-
slices: Object.freeze({ ...r.slices, account: m.account, features: m.features, interactions: m.interactions, directory:
|
|
8408
|
+
slices: Object.freeze({ ...r.slices, account: m.account, features: m.features, interactions: m.interactions, directory: u, conversation: f.state })
|
|
8409
8409
|
}), effects: [...d.effects, ...p, ...f.effects, ...h.effects] };
|
|
8410
8410
|
}
|
|
8411
8411
|
const c = ac(r.slices.modelSelection, o);
|
|
@@ -8498,11 +8498,11 @@ class vc {
|
|
|
8498
8498
|
}
|
|
8499
8499
|
const bc = "pluno-product-agent-attachments", Ic = 1, rn = "files", wc = 1440 * 60 * 1e3;
|
|
8500
8500
|
async function _c(t) {
|
|
8501
|
-
const e = await
|
|
8501
|
+
const e = await Vt();
|
|
8502
8502
|
await gr(e, "readwrite", (s) => s.put(t));
|
|
8503
8503
|
}
|
|
8504
8504
|
async function fi(t) {
|
|
8505
|
-
const e = await
|
|
8505
|
+
const e = await Vt(), s = await gr(
|
|
8506
8506
|
e,
|
|
8507
8507
|
"readonly",
|
|
8508
8508
|
(i) => i.get(t)
|
|
@@ -8513,7 +8513,7 @@ async function fi(t) {
|
|
|
8513
8513
|
return await fr(t, { lastUsedAt: n }), { ...s, lastUsedAt: n };
|
|
8514
8514
|
}
|
|
8515
8515
|
async function fr(t, e) {
|
|
8516
|
-
const s = await
|
|
8516
|
+
const s = await Vt();
|
|
8517
8517
|
await wn(s, "readwrite", async (n) => {
|
|
8518
8518
|
const i = await _n(
|
|
8519
8519
|
n.get(t)
|
|
@@ -8525,13 +8525,13 @@ async function fr(t, e) {
|
|
|
8525
8525
|
});
|
|
8526
8526
|
}
|
|
8527
8527
|
async function Sc(t = wc) {
|
|
8528
|
-
const e = await
|
|
8528
|
+
const e = await Vt(), s = Date.now() - t;
|
|
8529
8529
|
await wn(e, "readwrite", async (n) => {
|
|
8530
8530
|
const i = n.index("lastUsedAt");
|
|
8531
8531
|
(await _n(i.getAllKeys(IDBKeyRange.upperBound(s)))).forEach((a) => n.delete(a));
|
|
8532
8532
|
});
|
|
8533
8533
|
}
|
|
8534
|
-
function
|
|
8534
|
+
function Vt() {
|
|
8535
8535
|
return typeof indexedDB > "u" ? Promise.reject(new Error("Product Agent attachment storage is unavailable")) : new Promise((t, e) => {
|
|
8536
8536
|
const s = indexedDB.open(bc, Ic);
|
|
8537
8537
|
s.onupgradeneeded = () => {
|
|
@@ -8607,11 +8607,11 @@ const Ec = "save_runtime_captured_skill";
|
|
|
8607
8607
|
function qc(t) {
|
|
8608
8608
|
return (t.type === "function_call" || t.type === "tool_call") && t.name === Ec;
|
|
8609
8609
|
}
|
|
8610
|
-
const
|
|
8610
|
+
const ys = "pluno.productAgent.transportId", Tc = "pluno.productAgent.transportIdentity", vs = "pluno.productAgent.transportIdentity.event", Cc = 50, Mc = globalThis.setTimeout.bind(globalThis);
|
|
8611
8611
|
let Je = null;
|
|
8612
|
-
const
|
|
8612
|
+
const Mt = /* @__PURE__ */ new Set(), bs = /* @__PURE__ */ new Map();
|
|
8613
8613
|
async function Oc(t = vr()) {
|
|
8614
|
-
const e = t.randomUUID(), s = t.storage.getItem(
|
|
8614
|
+
const e = t.randomUUID(), s = t.storage.getItem(ys);
|
|
8615
8615
|
let n = s ?? t.randomUUID(), i = !1, r = !1;
|
|
8616
8616
|
const a = t.channel.subscribe((c) => {
|
|
8617
8617
|
if (!(c.senderId === e || c.transportId !== n)) {
|
|
@@ -8629,7 +8629,7 @@ async function Oc(t = vr()) {
|
|
|
8629
8629
|
}
|
|
8630
8630
|
});
|
|
8631
8631
|
if (!s)
|
|
8632
|
-
t.storage.setItem(
|
|
8632
|
+
t.storage.setItem(ys, n), i = !0;
|
|
8633
8633
|
else if (t.skipStoredIdentityCollisionCheck)
|
|
8634
8634
|
i = !0;
|
|
8635
8635
|
else
|
|
@@ -8638,7 +8638,7 @@ async function Oc(t = vr()) {
|
|
|
8638
8638
|
i = !0;
|
|
8639
8639
|
break;
|
|
8640
8640
|
}
|
|
8641
|
-
n = t.randomUUID(), t.storage.setItem(
|
|
8641
|
+
n = t.randomUUID(), t.storage.setItem(ys, n);
|
|
8642
8642
|
}
|
|
8643
8643
|
let o = !1;
|
|
8644
8644
|
return {
|
|
@@ -8654,24 +8654,24 @@ async function xc(t = !1) {
|
|
|
8654
8654
|
skipStoredIdentityCollisionCheck: t
|
|
8655
8655
|
}), Je.then((i) => {
|
|
8656
8656
|
const r = (a) => {
|
|
8657
|
-
a.persisted || (i.release(), Je = null,
|
|
8657
|
+
a.persisted || (i.release(), Je = null, Mt.clear(), window.removeEventListener("pagehide", r));
|
|
8658
8658
|
};
|
|
8659
8659
|
window.addEventListener("pagehide", r);
|
|
8660
8660
|
}));
|
|
8661
8661
|
const e = await Je, s = Pc();
|
|
8662
|
-
|
|
8662
|
+
Mt.add(s);
|
|
8663
8663
|
let n = !1;
|
|
8664
8664
|
return {
|
|
8665
8665
|
// A stable per-tab base keeps reload routing intact, while slots isolate multiple live SDK instances in one tab.
|
|
8666
8666
|
transportId: s === 0 ? e.transportId : `${e.transportId}.${s}`,
|
|
8667
8667
|
release: () => {
|
|
8668
|
-
n || (n = !0,
|
|
8668
|
+
n || (n = !0, Mt.delete(s));
|
|
8669
8669
|
}
|
|
8670
8670
|
};
|
|
8671
8671
|
}
|
|
8672
8672
|
function Pc() {
|
|
8673
8673
|
let t = 0;
|
|
8674
|
-
for (;
|
|
8674
|
+
for (; Mt.has(t); )
|
|
8675
8675
|
t += 1;
|
|
8676
8676
|
return t;
|
|
8677
8677
|
}
|
|
@@ -8687,13 +8687,13 @@ function Dc() {
|
|
|
8687
8687
|
return {
|
|
8688
8688
|
getItem: (t) => {
|
|
8689
8689
|
try {
|
|
8690
|
-
return window.sessionStorage?.getItem(t) ??
|
|
8690
|
+
return window.sessionStorage?.getItem(t) ?? bs.get(t) ?? null;
|
|
8691
8691
|
} catch {
|
|
8692
|
-
return
|
|
8692
|
+
return bs.get(t) ?? null;
|
|
8693
8693
|
}
|
|
8694
8694
|
},
|
|
8695
8695
|
setItem: (t, e) => {
|
|
8696
|
-
|
|
8696
|
+
bs.set(t, e);
|
|
8697
8697
|
try {
|
|
8698
8698
|
window.sessionStorage?.setItem(t, e);
|
|
8699
8699
|
} catch {
|
|
@@ -8717,7 +8717,7 @@ function Uc() {
|
|
|
8717
8717
|
}
|
|
8718
8718
|
function Nc() {
|
|
8719
8719
|
const t = /* @__PURE__ */ new Set(), e = (s) => {
|
|
8720
|
-
if (s.key !==
|
|
8720
|
+
if (s.key !== vs || !s.newValue)
|
|
8721
8721
|
return;
|
|
8722
8722
|
const n = JSON.parse(s.newValue);
|
|
8723
8723
|
for (const i of t)
|
|
@@ -8726,9 +8726,9 @@ function Nc() {
|
|
|
8726
8726
|
return window.addEventListener("storage", e), {
|
|
8727
8727
|
postMessage: (s) => {
|
|
8728
8728
|
window.localStorage.setItem(
|
|
8729
|
-
|
|
8729
|
+
vs,
|
|
8730
8730
|
JSON.stringify({ ...s, eventId: crypto.randomUUID() })
|
|
8731
|
-
), window.localStorage.removeItem(
|
|
8731
|
+
), window.localStorage.removeItem(vs);
|
|
8732
8732
|
},
|
|
8733
8733
|
subscribe: (s) => (t.add(s), () => t.delete(s)),
|
|
8734
8734
|
close: () => {
|
|
@@ -8764,7 +8764,7 @@ const Bc = [
|
|
|
8764
8764
|
"gpt-5.6-luna",
|
|
8765
8765
|
"gpt-5.6-terra",
|
|
8766
8766
|
"gpt-5.6-sol"
|
|
8767
|
-
], on = (t) => typeof t == "string" && Bc.includes(t),
|
|
8767
|
+
], on = (t) => typeof t == "string" && Bc.includes(t), Is = /* @__PURE__ */ new Map();
|
|
8768
8768
|
function Lc(t, e, s) {
|
|
8769
8769
|
const n = `pluno.productAgent.modelClientScope:${e}`, i = t.getItem(n);
|
|
8770
8770
|
if (i) return i;
|
|
@@ -8774,11 +8774,11 @@ function Lc(t, e, s) {
|
|
|
8774
8774
|
function Fc(t, e) {
|
|
8775
8775
|
try {
|
|
8776
8776
|
const s = Lc(window.sessionStorage, t, e);
|
|
8777
|
-
return
|
|
8777
|
+
return Is.set(t, s), s;
|
|
8778
8778
|
} catch (s) {
|
|
8779
8779
|
if (!(s instanceof DOMException) || s.name !== "SecurityError" && s.name !== "QuotaExceededError") throw s;
|
|
8780
|
-
const n =
|
|
8781
|
-
return
|
|
8780
|
+
const n = Is.get(t) ?? e();
|
|
8781
|
+
return Is.set(t, n), n;
|
|
8782
8782
|
}
|
|
8783
8783
|
}
|
|
8784
8784
|
function $c(t) {
|
|
@@ -8791,7 +8791,7 @@ const Ir = (t, e) => yo(
|
|
|
8791
8791
|
t.engine.getState().slices.modelSelection,
|
|
8792
8792
|
e
|
|
8793
8793
|
);
|
|
8794
|
-
function
|
|
8794
|
+
function ws(t, e, s, n) {
|
|
8795
8795
|
return t.engine.dispatch({
|
|
8796
8796
|
type: "model.submission_capture",
|
|
8797
8797
|
clientScopeId: e,
|
|
@@ -8810,7 +8810,7 @@ function zc(t, e, s, n, i, r) {
|
|
|
8810
8810
|
updatedAt: r ? Date.parse(r) : void 0
|
|
8811
8811
|
});
|
|
8812
8812
|
}
|
|
8813
|
-
function
|
|
8813
|
+
function _s(t, e, s, n) {
|
|
8814
8814
|
if (Array.isArray(n))
|
|
8815
8815
|
for (const i of n) {
|
|
8816
8816
|
if (!i || typeof i != "object") continue;
|
|
@@ -8829,7 +8829,7 @@ class nu {
|
|
|
8829
8829
|
constructor(e, s, n = 20) {
|
|
8830
8830
|
this.loadPage = s, this.limit = n, this.recentQuery = new ti(
|
|
8831
8831
|
`${e}:recent`,
|
|
8832
|
-
async ({ cursor: i }) =>
|
|
8832
|
+
async ({ cursor: i }) => Ct(
|
|
8833
8833
|
await this.loadPage({ cursor: i, limit: this.limit, pinned: !1 }).then((r) => ({
|
|
8834
8834
|
entities: r.sessions,
|
|
8835
8835
|
nextCursor: r.nextCursor
|
|
@@ -8838,7 +8838,7 @@ class nu {
|
|
|
8838
8838
|
Fa
|
|
8839
8839
|
), this.pinnedQuery = new ti(
|
|
8840
8840
|
`${e}:pinned`,
|
|
8841
|
-
async () =>
|
|
8841
|
+
async () => Ct({
|
|
8842
8842
|
entities: await this.loadAllPinned(),
|
|
8843
8843
|
nextCursor: null
|
|
8844
8844
|
})
|
|
@@ -8862,7 +8862,7 @@ class nu {
|
|
|
8862
8862
|
...gt(e.data)
|
|
8863
8863
|
], i = new Map(n.map((c) => [c.id, c])), r = Array.from(i.values()).map(
|
|
8864
8864
|
(c) => this.applyOverrides(c, this.completedRefreshSequence)
|
|
8865
|
-
), a = Array.from(this.optimisticEntities.values()).filter((c) => !i.has(c.id)).reverse(), o = e.data || s.data || a.length > 0 ?
|
|
8865
|
+
), a = Array.from(this.optimisticEntities.values()).filter((c) => !i.has(c.id)).reverse(), o = e.data || s.data || a.length > 0 ? Ct({
|
|
8866
8866
|
entities: [...a, ...r],
|
|
8867
8867
|
nextCursor: e.data?.nextCursor ?? null
|
|
8868
8868
|
}) : null;
|
|
@@ -9123,14 +9123,14 @@ class iu {
|
|
|
9123
9123
|
return null;
|
|
9124
9124
|
}
|
|
9125
9125
|
getDecisionKey(e) {
|
|
9126
|
-
const s =
|
|
9126
|
+
const s = Ss(e.scope);
|
|
9127
9127
|
return e.action === "dont_show_again" ? `${s}:category:${e.category}` : `${s}:interaction:${e.promptKey}`;
|
|
9128
9128
|
}
|
|
9129
9129
|
getExactKey(e) {
|
|
9130
|
-
return `${
|
|
9130
|
+
return `${Ss(e.scope)}:interaction:${e.key}`;
|
|
9131
9131
|
}
|
|
9132
9132
|
getCategoryKey(e) {
|
|
9133
|
-
return `${
|
|
9133
|
+
return `${Ss(e.scope)}:category:${e.category}`;
|
|
9134
9134
|
}
|
|
9135
9135
|
}
|
|
9136
9136
|
function ru(t, e) {
|
|
@@ -9145,7 +9145,7 @@ function Vc(t, e) {
|
|
|
9145
9145
|
const n = JSON.parse(s);
|
|
9146
9146
|
return Array.isArray(n) ? n.filter(an) : [];
|
|
9147
9147
|
}
|
|
9148
|
-
function
|
|
9148
|
+
function Ss(t) {
|
|
9149
9149
|
return `${t.level}:${t.key}`;
|
|
9150
9150
|
}
|
|
9151
9151
|
function wr(t) {
|
|
@@ -9163,8 +9163,8 @@ const Kc = {
|
|
|
9163
9163
|
stopped: "⏹️"
|
|
9164
9164
|
}, Wc = /^(?:⌛|⏳|✅|❗|⏹️) Pluno(?:: )?/;
|
|
9165
9165
|
function Gc(t, e) {
|
|
9166
|
-
if (!e) return
|
|
9167
|
-
const s =
|
|
9166
|
+
if (!e) return jt(t);
|
|
9167
|
+
const s = jt(t), n = `${Kc[e]} Pluno`;
|
|
9168
9168
|
return s ? `${n}: ${s}` : n;
|
|
9169
9169
|
}
|
|
9170
9170
|
class ou {
|
|
@@ -9189,10 +9189,10 @@ class ou {
|
|
|
9189
9189
|
}
|
|
9190
9190
|
applyStatus(e) {
|
|
9191
9191
|
const s = this.titleDocument.getTitle();
|
|
9192
|
-
s !== this.lastAppliedTitle && (this.baseTitle =
|
|
9192
|
+
s !== this.lastAppliedTitle && (this.baseTitle = jt(s)), this.status = e, this.stopObserving || (this.stopObserving = this.titleDocument.observeTitle(() => this.handleTitleChanged())), this.applyTitle();
|
|
9193
9193
|
}
|
|
9194
9194
|
applyClear() {
|
|
9195
|
-
const e = this.titleDocument.getTitle(), s = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ?
|
|
9195
|
+
const e = this.titleDocument.getTitle(), s = this.lastAppliedTitle !== null && e === this.lastAppliedTitle, n = this.lastAppliedTitle === null ? jt(e) : e;
|
|
9196
9196
|
this.status = null, this.lastAppliedTitle = null, this.stopObserving?.(), this.stopObserving = null, s ? this.titleDocument.setTitle(this.baseTitle) : n !== e && this.titleDocument.setTitle(n);
|
|
9197
9197
|
}
|
|
9198
9198
|
handleTitleChanged() {
|
|
@@ -9221,7 +9221,7 @@ function au(t) {
|
|
|
9221
9221
|
}
|
|
9222
9222
|
};
|
|
9223
9223
|
}
|
|
9224
|
-
function
|
|
9224
|
+
function jt(t) {
|
|
9225
9225
|
return t.replace(Wc, "");
|
|
9226
9226
|
}
|
|
9227
9227
|
const Jc = {
|
|
@@ -9306,7 +9306,7 @@ function cu(t) {
|
|
|
9306
9306
|
}
|
|
9307
9307
|
class du {
|
|
9308
9308
|
constructor(e, s, n) {
|
|
9309
|
-
this.adapter = s, this.state =
|
|
9309
|
+
this.adapter = s, this.state = mt(e), this.hasBeenReady = e.status === "connected" && e.submissionReady !== !1, this.initialModel = n ?? "gpt-5.6-terra", this.model = this.initialModel;
|
|
9310
9310
|
}
|
|
9311
9311
|
adapter;
|
|
9312
9312
|
listeners = {};
|
|
@@ -9315,7 +9315,7 @@ class du {
|
|
|
9315
9315
|
interactionListeners = /* @__PURE__ */ new Set();
|
|
9316
9316
|
accountListeners = /* @__PURE__ */ new Set();
|
|
9317
9317
|
state;
|
|
9318
|
-
sessionHistoryState =
|
|
9318
|
+
sessionHistoryState = Tt("unavailable");
|
|
9319
9319
|
model;
|
|
9320
9320
|
initialModel;
|
|
9321
9321
|
interactions = [];
|
|
@@ -9327,6 +9327,8 @@ class du {
|
|
|
9327
9327
|
submissionPreviews = /* @__PURE__ */ new Map();
|
|
9328
9328
|
// Durable metadata can retire the preview before receipt reconciliation permits byte transfer.
|
|
9329
9329
|
submissionRetries = /* @__PURE__ */ new Map();
|
|
9330
|
+
// Items painted before an owner restart, kept until the restarted owner has reread the same conversation's history.
|
|
9331
|
+
retainedTranscript = null;
|
|
9330
9332
|
submissionGeneration = 0;
|
|
9331
9333
|
pendingStop = null;
|
|
9332
9334
|
stopError = null;
|
|
@@ -9341,8 +9343,14 @@ class du {
|
|
|
9341
9343
|
return n.add(s), this.listeners[e] = n, () => n.delete(s);
|
|
9342
9344
|
}
|
|
9343
9345
|
getState() {
|
|
9344
|
-
const e =
|
|
9345
|
-
this.pendingNavigation && (e.isLoadingSession = !0)
|
|
9346
|
+
const e = mt(this.state);
|
|
9347
|
+
if (this.pendingNavigation && (e.isLoadingSession = !0), this.retainedTranscript) {
|
|
9348
|
+
const i = mt({ ...e, ...this.retainedTranscript }), r = new Set(i.messages.map((o) => o.id)), a = new Set(i.segments?.map((o) => o.id));
|
|
9349
|
+
e.messages = [...i.messages, ...e.messages.filter((o) => !r.has(o.id))], (i.segments || e.segments) && (e.segments = [
|
|
9350
|
+
...(i.segments ?? []).map((o) => ({ ...o })),
|
|
9351
|
+
...(e.segments ?? []).filter((o) => !a.has(o.id))
|
|
9352
|
+
]), e.removedItems = { ...i.removedItems, ...e.removedItems };
|
|
9353
|
+
}
|
|
9346
9354
|
for (const [i, r] of this.submissionPreviews)
|
|
9347
9355
|
e.messages.some((a) => a.id === i) || (e.messages.push({ ...r.message, attachments: r.message.attachments?.map((a) => ({ ...a })) }), e.segments && (e.segments = [...e.segments, { id: i, userMessageId: i, activityIds: [], outcomeIds: [], collapsed: !1 }]), e.isLoadingSession = !1, r.pending && (e.activeResponseUserMessageId = i, e.pendingMessageStatus = "sending", e.turnPhase = "sending", e.activity = { phase: "submitting", activeItemId: null }), r.error && (e.lastError = r.error.message, e.lastErrorCode = ["unauthorized", "401", "auth_reconnecting", "submission_not_available", "submission_checkpoint_pending"].includes(r.error.code) ? r.error.code : "message_delivery_failed"));
|
|
9348
9356
|
this.stopError && (e.lastError = this.stopError, e.lastErrorCode = "stop_failed");
|
|
@@ -9356,17 +9364,18 @@ class du {
|
|
|
9356
9364
|
const a = this.getState(), o = !this.hasBeenReady && (!a.user || a.user.id === e.user?.id), c = a.stableSelectionKey !== void 0 && a.stableSelectionKey === e.stableSelectionKey && a.user?.id === e.user?.id && a.sessionId === e.sessionId, d = c && this.pendingTransfers.size > 0 && this.submissionRetries.size === 0 && [...this.pendingTransfers.keys()].every((l) => this.readinessPendingSubmissions.has(l));
|
|
9357
9365
|
!o && !d && (a.user?.id !== e.user?.id || a.selectionKey !== void 0 && a.selectionKey !== e.selectionKey || a.selectionKey === void 0 && a.sessionId !== null && a.sessionId !== e.sessionId) && (c || (this.model = this.initialModel), this.cancelPendingSubmissions(), this.submissionPreviews.clear());
|
|
9358
9366
|
for (const l of e.messages)
|
|
9359
|
-
l.role === "user" && e.receipts?.find((
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9367
|
+
l.role === "user" && e.receipts?.find((h) => h.userMessageId === l.id)?.durable !== !1 && this.submissionPreviews.delete(l.id);
|
|
9368
|
+
const u = c && e.sessionId !== null && e.isLoadingSession && !e.isDraftSession;
|
|
9369
|
+
this.retainedTranscript = u ? this.retainedTranscript ?? (this.state.isLoadingSession || this.state.messages.length === 0 ? null : { messages: this.state.messages, segments: this.state.segments, removedItems: this.state.removedItems }) : null, this.state = mt(e), e.status === "connected" && e.submissionReady !== !1 && (this.hasBeenReady = !0);
|
|
9370
|
+
for (const [l, h] of this.stopPreviews) {
|
|
9371
|
+
const f = e.activity?.executionKey;
|
|
9372
|
+
(h !== void 0 && h !== "[]" && f !== void 0 && f !== "[]" && (f !== h || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (h === void 0 || h === "[]") && e.messages.some((p) => p.respondsToUserMessageId === l && !p.provisional && p.loading !== !0 && (p.dataType === "run_status" || p.dataType === "run_error" || p.role === "assistant" && p.phase !== "commentary" && (p.streamState === void 0 || ["finished", "stopped", "failed"].includes(p.streamState))))) && this.stopPreviews.delete(l);
|
|
9364
9373
|
}
|
|
9365
9374
|
if (this.pendingStop?.userMessageIds.every((l) => !this.stopPreviews.has(l)) && (this.pendingStop = null), a.user?.id === e.user?.id)
|
|
9366
9375
|
for (const l of this.state.messages) {
|
|
9367
9376
|
if (l.role !== "user" || !l.attachments?.length) continue;
|
|
9368
|
-
const
|
|
9369
|
-
a.sessionId !== e.sessionId && !(a.sessionId === null &&
|
|
9377
|
+
const h = a.messages.find((f) => f.role === "user" && f.id === l.id);
|
|
9378
|
+
a.sessionId !== e.sessionId && !(a.sessionId === null && h) || (l.attachments = Xc(h?.attachments, l.attachments));
|
|
9370
9379
|
}
|
|
9371
9380
|
if (n && JSON.stringify(n) !== JSON.stringify(this.sessionHistoryState)) {
|
|
9372
9381
|
this.sessionHistoryState = mi(n);
|
|
@@ -9390,7 +9399,7 @@ class du {
|
|
|
9390
9399
|
if (!this.destroyed) {
|
|
9391
9400
|
this.destroyed = !0;
|
|
9392
9401
|
for (const e of this.durabilityWaiters) e();
|
|
9393
|
-
this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionRetries.clear(), this.submissionPreviews.clear(), this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
9402
|
+
this.pendingStop = null, this.stopPreviews.clear(), this.pendingTransfers.clear(), this.submissionRetries.clear(), this.submissionPreviews.clear(), this.retainedTranscript = null, this.attachmentFiles.clear(), this.sessionHistoryListeners.clear(), this.interactionListeners.clear(), this.accountListeners.clear();
|
|
9394
9403
|
for (const e of Object.values(this.listeners)) e?.clear();
|
|
9395
9404
|
this.adapter.onDisconnect?.();
|
|
9396
9405
|
}
|
|
@@ -9464,8 +9473,8 @@ class du {
|
|
|
9464
9473
|
});
|
|
9465
9474
|
}
|
|
9466
9475
|
async sendMessageNow(e, s, n) {
|
|
9467
|
-
const i = e, r = s.clientMessageId, a = Q((
|
|
9468
|
-
n === this.submissionGeneration && this.reportOperationTiming(
|
|
9476
|
+
const i = e, r = s.clientMessageId, a = Q((u) => {
|
|
9477
|
+
n === this.submissionGeneration && this.reportOperationTiming(u);
|
|
9469
9478
|
}, {
|
|
9470
9479
|
operation: "send",
|
|
9471
9480
|
layer: "renderer",
|
|
@@ -9478,7 +9487,7 @@ class du {
|
|
|
9478
9487
|
if (n !== this.submissionGeneration) return null;
|
|
9479
9488
|
d && this.readinessPendingSubmissions.add(r);
|
|
9480
9489
|
try {
|
|
9481
|
-
const
|
|
9490
|
+
const u = await a.measure("staging_ipc", async () => {
|
|
9482
9491
|
if (d) {
|
|
9483
9492
|
if (!await a.measure("authentication", () => this.waitForSubmissionReadiness(n))) return null;
|
|
9484
9493
|
this.readinessPendingSubmissions.delete(r), d = !1, s = { ...s, selectionKey: this.state.selectionKey };
|
|
@@ -9504,27 +9513,27 @@ class du {
|
|
|
9504
9513
|
return m && (m.error = f), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, n) ? { result: void 0 } : null;
|
|
9505
9514
|
});
|
|
9506
9515
|
});
|
|
9507
|
-
if (!
|
|
9508
|
-
if (c = !0, this.submissionRetries.delete(r),
|
|
9516
|
+
if (!u || n !== this.submissionGeneration) return null;
|
|
9517
|
+
if (c = !0, this.submissionRetries.delete(r), u.result?.submissionAccepted) {
|
|
9509
9518
|
r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null);
|
|
9510
|
-
for (const
|
|
9511
|
-
|
|
9519
|
+
for (const l of s.attachments ?? [])
|
|
9520
|
+
l.id && this.attachmentFiles.delete(l.id);
|
|
9512
9521
|
return r;
|
|
9513
9522
|
}
|
|
9514
9523
|
if (o.length > 0) {
|
|
9515
9524
|
if (!this.adapter.uploadAttachment)
|
|
9516
9525
|
throw new Error("The runtime does not support attachments.");
|
|
9517
|
-
const
|
|
9526
|
+
const l = [];
|
|
9518
9527
|
for (const h of o) {
|
|
9519
9528
|
if (h.sandboxPath || h.storageKey) {
|
|
9520
|
-
|
|
9529
|
+
l.push(h);
|
|
9521
9530
|
continue;
|
|
9522
9531
|
}
|
|
9523
9532
|
const f = h.id ? this.attachmentFiles.get(h.id) : void 0;
|
|
9524
9533
|
if (!f) throw new Error(`Attachment bytes are unavailable for ${h.name}`);
|
|
9525
|
-
if (
|
|
9534
|
+
if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(f, h, { clientMessageId: r }))), n !== this.submissionGeneration) return null;
|
|
9526
9535
|
}
|
|
9527
|
-
o =
|
|
9536
|
+
o = l;
|
|
9528
9537
|
}
|
|
9529
9538
|
if (n !== this.submissionGeneration || (await this.adapter.dispatch({
|
|
9530
9539
|
type: "conversation.send",
|
|
@@ -9538,25 +9547,25 @@ class du {
|
|
|
9538
9547
|
proactiveSuggestionQuestion: s.proactiveSuggestionQuestion,
|
|
9539
9548
|
attachments: o.length > 0 ? o.map(gi) : void 0
|
|
9540
9549
|
}), n !== this.submissionGeneration)) return null;
|
|
9541
|
-
for (const
|
|
9542
|
-
|
|
9550
|
+
for (const l of s.attachments ?? [])
|
|
9551
|
+
l.id && this.attachmentFiles.delete(l.id);
|
|
9543
9552
|
return r === this.stagedProactiveSuggestionClientMessageId && (this.stagedProactiveSuggestionClientMessageId = null), r;
|
|
9544
|
-
} catch (
|
|
9553
|
+
} catch (u) {
|
|
9545
9554
|
if (n !== this.submissionGeneration) return null;
|
|
9546
|
-
if (si(
|
|
9555
|
+
if (si(u))
|
|
9547
9556
|
for (const m of s.attachments ?? [])
|
|
9548
9557
|
m.id && this.attachmentFiles.delete(m.id);
|
|
9549
|
-
const h = Y(
|
|
9550
|
-
!c && !si(
|
|
9558
|
+
const h = Y(u).code === "command_not_received";
|
|
9559
|
+
!c && !si(u) && (d || h || s.selectionKey !== void 0) && this.submissionRetries.set(r, {
|
|
9551
9560
|
retry: async () => (d && await this.connect(), this.sendMessageNow(e, { ...s, reconcileAcceptance: !d && !h }, n)),
|
|
9552
9561
|
attachmentIds: (s.attachments ?? []).flatMap((m) => m.id ? [m.id] : [])
|
|
9553
9562
|
});
|
|
9554
9563
|
const f = this.submissionPreviews.get(r);
|
|
9555
|
-
throw f && (f.pending = !1, f.error = Y(
|
|
9564
|
+
throw f && (f.pending = !1, f.error = Y(u), this.emit("state", this.getState())), c && await this.adapter.dispatch({
|
|
9556
9565
|
type: "conversation.fail_staged",
|
|
9557
9566
|
clientMessageId: r,
|
|
9558
|
-
message: Y(
|
|
9559
|
-
}),
|
|
9567
|
+
message: Y(u).message
|
|
9568
|
+
}), u;
|
|
9560
9569
|
} finally {
|
|
9561
9570
|
this.readinessPendingSubmissions.delete(r);
|
|
9562
9571
|
}
|
|
@@ -9616,8 +9625,8 @@ class du {
|
|
|
9616
9625
|
const o = this.submissionGeneration;
|
|
9617
9626
|
return r.promise = i.measure("stop_ipc", () => this.adapter.dispatch({ type: "run.stop", ...s.length ? { clientMessageIds: s } : {} })).then(() => {
|
|
9618
9627
|
}, (d) => {
|
|
9619
|
-
if (!(o !== this.submissionGeneration || n.every((
|
|
9620
|
-
for (const
|
|
9628
|
+
if (!(o !== this.submissionGeneration || n.every((u) => !this.stopPreviews.has(u)))) {
|
|
9629
|
+
for (const u of n) this.stopPreviews.delete(u);
|
|
9621
9630
|
this.stopError = Y(d).message;
|
|
9622
9631
|
}
|
|
9623
9632
|
}).finally(() => {
|
|
@@ -9694,7 +9703,7 @@ class du {
|
|
|
9694
9703
|
return s;
|
|
9695
9704
|
}
|
|
9696
9705
|
startNewSession(e = {}) {
|
|
9697
|
-
return this.cancelPendingSubmissions(), this.submissionPreviews.clear(), this.model = this.initialModel, this.emit("state", this.getState()), e.notifyTransport === !1 ? Promise.resolve() : this.navigate({ type: "session.new" });
|
|
9706
|
+
return this.cancelPendingSubmissions(), this.submissionPreviews.clear(), this.retainedTranscript = null, this.model = this.initialModel, this.emit("state", this.getState()), e.notifyTransport === !1 ? Promise.resolve() : this.navigate({ type: "session.new" });
|
|
9698
9707
|
}
|
|
9699
9708
|
async listSessions(e = {}) {
|
|
9700
9709
|
const s = await this.dispatch({ type: "session.list", ...e });
|
|
@@ -9758,7 +9767,7 @@ class du {
|
|
|
9758
9767
|
}
|
|
9759
9768
|
loadSession(e) {
|
|
9760
9769
|
return e === this.getState().sessionId ? this.adapter.dispatch({ type: "session.load", sessionId: e }).then(() => {
|
|
9761
|
-
}) : (this.cancelPendingSubmissions(), this.submissionPreviews.clear(), this.emit("state", this.getState()), this.navigate({ type: "session.load", sessionId: e }));
|
|
9770
|
+
}) : (this.cancelPendingSubmissions(), this.submissionPreviews.clear(), this.retainedTranscript = null, this.emit("state", this.getState()), this.navigate({ type: "session.load", sessionId: e }));
|
|
9762
9771
|
}
|
|
9763
9772
|
stageProactiveSuggestionQuestion(e) {
|
|
9764
9773
|
const s = e.trim();
|
|
@@ -9800,7 +9809,7 @@ function Xc(t, e) {
|
|
|
9800
9809
|
return i ? { ...n, previewUrl: i } : n;
|
|
9801
9810
|
});
|
|
9802
9811
|
}
|
|
9803
|
-
function
|
|
9812
|
+
function mt(t) {
|
|
9804
9813
|
return {
|
|
9805
9814
|
...t,
|
|
9806
9815
|
starterPrompts: [...t.starterPrompts],
|
|
@@ -9827,7 +9836,7 @@ function Ss(t) {
|
|
|
9827
9836
|
function mi(t) {
|
|
9828
9837
|
return {
|
|
9829
9838
|
...t,
|
|
9830
|
-
data: t.data ?
|
|
9839
|
+
data: t.data ? Ct({
|
|
9831
9840
|
entities: $a(t.data).map((e) => ({ ...e })),
|
|
9832
9841
|
nextCursor: t.data.nextCursor
|
|
9833
9842
|
}) : null
|
|
@@ -9874,20 +9883,20 @@ function ks(t) {
|
|
|
9874
9883
|
const r = (c) => {
|
|
9875
9884
|
if (!c || typeof c != "object")
|
|
9876
9885
|
return null;
|
|
9877
|
-
const d = c,
|
|
9886
|
+
const d = c, u = d.data, l = u && typeof u == "object" ? u : {}, h = Er(c);
|
|
9878
9887
|
return {
|
|
9879
9888
|
id: typeof d.id == "string" ? d.id : null,
|
|
9880
|
-
streamId:
|
|
9881
|
-
type: typeof
|
|
9882
|
-
role: typeof
|
|
9889
|
+
streamId: l.type === "message" && l.role === "assistant" && typeof l.id == "string" ? l.id : null,
|
|
9890
|
+
type: typeof l.type == "string" ? l.type : null,
|
|
9891
|
+
role: typeof l.role == "string" ? l.role : null,
|
|
9883
9892
|
sessionId: typeof d.sessionId == "string" ? d.sessionId : null,
|
|
9884
|
-
runId: typeof
|
|
9885
|
-
respondsToUserMessageId: typeof
|
|
9886
|
-
status: typeof
|
|
9887
|
-
stage: typeof
|
|
9888
|
-
retryable:
|
|
9893
|
+
runId: typeof l.runId == "string" ? l.runId : null,
|
|
9894
|
+
respondsToUserMessageId: typeof l.respondsToUserMessageId == "string" ? l.respondsToUserMessageId : null,
|
|
9895
|
+
status: typeof l.status == "string" ? l.status : null,
|
|
9896
|
+
stage: typeof l.stage == "string" ? l.stage : null,
|
|
9897
|
+
retryable: l.retryable === !0,
|
|
9889
9898
|
visible: !!(h && // Recovery-only failures are intentionally hidden, not missing transcript items.
|
|
9890
|
-
!(
|
|
9899
|
+
!(l.type === "run_error" && l.retryable === !0) && !h.scheduledCheckInAt && h.toolName !== yr && (l.type !== "run_status" || ["failed", "interrupted", "stopped"].includes(String(l.status))))
|
|
9891
9900
|
};
|
|
9892
9901
|
}, a = r(t.item);
|
|
9893
9902
|
if (a?.id && (e.itemId = a.id, a.type && (e.itemType = a.type), a.role && (e.itemRole = a.role), a.sessionId && typeof e.sessionId != "string" && (e.sessionId = a.sessionId), a.runId && typeof e.runId != "string" && (e.runId = a.runId), a.respondsToUserMessageId && typeof e.respondsToUserMessageId != "string" && (e.respondsToUserMessageId = a.respondsToUserMessageId), a.status && (e.itemStatus = a.status), a.stage && (e.itemStage = a.stage), a.retryable && (e.itemRetryable = !0), a.visible && (e.visibleItemId = a.id, a.streamId && (e.visibleItemAliases = JSON.stringify([[a.streamId, a.id]])))), Array.isArray(t.items)) {
|
|
@@ -9901,10 +9910,10 @@ function ks(t) {
|
|
|
9901
9910
|
typeof c.id == "string" && (e.sessionId = c.id);
|
|
9902
9911
|
const d = c.metadata;
|
|
9903
9912
|
if (d && typeof d == "object") {
|
|
9904
|
-
const
|
|
9905
|
-
if (
|
|
9906
|
-
const
|
|
9907
|
-
e.composerPreloaded = !0, typeof
|
|
9913
|
+
const u = d.composerPreload;
|
|
9914
|
+
if (u && typeof u == "object") {
|
|
9915
|
+
const l = u.runId;
|
|
9916
|
+
e.composerPreloaded = !0, typeof l == "string" && (e.preloadRunId = l);
|
|
9908
9917
|
}
|
|
9909
9918
|
}
|
|
9910
9919
|
}
|
|
@@ -9935,8 +9944,8 @@ const id = "https://app.pluno.ai", rd = 2e4, od = 1e4, ad = 6e4, cd = 6e4, dd =
|
|
|
9935
9944
|
".pdf:application/pdf",
|
|
9936
9945
|
".png:image/png",
|
|
9937
9946
|
".webp:image/webp"
|
|
9938
|
-
]), lu = ".pdf,.png,.jpg,.jpeg,.webp", Sn = 64e3, Es = 4e3, kn = 30, md = 2e3, yd = 1e3, Sr = "Image is too large for model vision input.", vd = "pluno.productAgent.state.", dn = "pluno.productAgent.pendingEvents.",
|
|
9939
|
-
let
|
|
9947
|
+
]), lu = ".pdf,.png,.jpg,.jpeg,.webp", Sn = 64e3, Es = 4e3, kn = 30, md = 2e3, yd = 1e3, Sr = "Image is too large for model vision input.", vd = "pluno.productAgent.state.", dn = "pluno.productAgent.pendingEvents.", Kt = "pluno.productAgent.activeToolCalls.", bd = 100, Ot = /* @__PURE__ */ new Set();
|
|
9948
|
+
let yt = null;
|
|
9940
9949
|
function Id(t, e = Math.random) {
|
|
9941
9950
|
const s = Math.min(cn, ud * 2 ** t), n = 1 - vi + e() * vi * 2;
|
|
9942
9951
|
return Math.min(cn, Math.round(s * n));
|
|
@@ -9975,10 +9984,10 @@ function Qe(t) {
|
|
|
9975
9984
|
function Ts(t) {
|
|
9976
9985
|
return t === "main_web_chat" ? ["pinned", "recent"] : ["all"];
|
|
9977
9986
|
}
|
|
9978
|
-
class
|
|
9987
|
+
class Wt {
|
|
9979
9988
|
constructor(e, s) {
|
|
9980
9989
|
this.options = e, this.transportIdentity = s, this.directoryAuthority = {
|
|
9981
|
-
authorityId:
|
|
9990
|
+
authorityId: ls(`pa.authority:${e.clientId}`) ?? `${e.clientId}:${e.runtimeCommunityId ?? e.productVariant}`,
|
|
9982
9991
|
generation: 1
|
|
9983
9992
|
}, this.directoryHttp = new dr({
|
|
9984
9993
|
backendUrl: e.backendUrl,
|
|
@@ -10014,7 +10023,7 @@ class Kt {
|
|
|
10014
10023
|
}), void 0, Do(async () => {
|
|
10015
10024
|
if (!this.token || !this.state.user || this.state.status === "closed") throw new Error("Product Agent is not authenticated");
|
|
10016
10025
|
return this.options.activeUsersLoader ? (await this.options.activeUsersLoader()).count : Uo(this.options.backendUrl);
|
|
10017
|
-
})), this.draftModel = e.model ?? (e.productVariant === "personal" ?
|
|
10026
|
+
})), this.draftModel = e.model ?? (e.productVariant === "personal" ? ts[0].value : "gpt-5.6-terra"), this.modelClientScopeId = Fc(e.clientId, () => crypto.randomUUID()), this.directoryConversationScopeId = `conversation:${this.modelClientScopeId}`, this.createDirectoryAdapters(), this.clientRuntime.engine.dispatch({
|
|
10018
10027
|
type: "model.scope_open",
|
|
10019
10028
|
clientScopeId: this.modelClientScopeId,
|
|
10020
10029
|
sessionId: null,
|
|
@@ -10140,7 +10149,7 @@ class Kt {
|
|
|
10140
10149
|
static async init(e) {
|
|
10141
10150
|
const s = e, n = await xc(
|
|
10142
10151
|
s.skipStoredTransportIdentityCollisionCheck === !0
|
|
10143
|
-
), i = new
|
|
10152
|
+
), i = new Wt({
|
|
10144
10153
|
...e,
|
|
10145
10154
|
backendUrl: jd(e.backendUrl ?? id),
|
|
10146
10155
|
clientId: e.clientId ?? sl(),
|
|
@@ -10201,7 +10210,7 @@ class Kt {
|
|
|
10201
10210
|
});
|
|
10202
10211
|
const i = `pa.conversation.delivery:${this.modelClientScopeId}:${s.authorityId}`, r = `${i}:cancellations`;
|
|
10203
10212
|
this.authenticatedUserId && this.options.restorePersistedState === !1 && sessionStorage.removeItem(r);
|
|
10204
|
-
const a = this.authenticatedUserId ?
|
|
10213
|
+
const a = this.authenticatedUserId ? ls(r) : null, o = Ao({
|
|
10205
10214
|
authorityId: s.authorityId,
|
|
10206
10215
|
isCurrent: n,
|
|
10207
10216
|
read: async () => a ? JSON.parse(a) : null,
|
|
@@ -10224,7 +10233,7 @@ class Kt {
|
|
|
10224
10233
|
requestId: p.requestId,
|
|
10225
10234
|
clientMessageId: p.userMessageId,
|
|
10226
10235
|
sessionId: p.sessionId
|
|
10227
|
-
}), R = (v, I) => k.measure(v, () =>
|
|
10236
|
+
}), R = (v, I) => k.measure(v, () => It(b, I));
|
|
10228
10237
|
let g = p.contextPreparation ?? { pageContent: "", sessionTabs: [] };
|
|
10229
10238
|
if (p.contextPreparation === null) {
|
|
10230
10239
|
await R("first_frame", () => new Promise((I) => {
|
|
@@ -10245,9 +10254,9 @@ class Kt {
|
|
|
10245
10254
|
}
|
|
10246
10255
|
if (await R("authentication", () => this.waitForAuthentication()), !n() || s !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
|
|
10247
10256
|
for (const v of y)
|
|
10248
|
-
if (!v.uploaded && (await
|
|
10257
|
+
if (!v.uploaded && (await It(b, () => (this.attachmentPersistence.get(v.sourceId) ?? Promise.resolve()).catch(() => {
|
|
10249
10258
|
throw Object.assign(new Error("Attachment files could not be stored. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
|
|
10250
|
-
})), !await
|
|
10259
|
+
})), !await It(b, () => fi(v.sourceId))))
|
|
10251
10260
|
throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
|
|
10252
10261
|
return b.throwIfAborted(), k.mark("context_ready"), { ...g, now: Date.now() };
|
|
10253
10262
|
},
|
|
@@ -10289,7 +10298,7 @@ class Kt {
|
|
|
10289
10298
|
}
|
|
10290
10299
|
})
|
|
10291
10300
|
});
|
|
10292
|
-
const c = this.clientRuntime.engine.getState().slices.conversation, d = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null :
|
|
10301
|
+
const c = this.clientRuntime.engine.getState().slices.conversation, d = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : ls(i);
|
|
10293
10302
|
if (this.authenticatedUserId && !c.submissionOrder.length && !Object.keys(c.operations).length) {
|
|
10294
10303
|
const p = this.queuedClientEvents.filter((k) => k.type === "chat.user_message"), y = d ? JSON.parse(d) : p.length ? jo(c, p.map((k) => {
|
|
10295
10304
|
const { type: R, ...g } = k, v = this.clientRuntime.engine.getState().slices.directory, I = v.clients[this.modelClientScopeId];
|
|
@@ -10336,7 +10345,7 @@ class Kt {
|
|
|
10336
10345
|
} },
|
|
10337
10346
|
onError: (p) => this.handleDirectoryTransportError(p)
|
|
10338
10347
|
});
|
|
10339
|
-
const
|
|
10348
|
+
const u = (p, y) => {
|
|
10340
10349
|
if (this.firstResponseTimersByClientMessageId.size) {
|
|
10341
10350
|
for (const b of p)
|
|
10342
10351
|
(b.dataType === "run_status" || b.dataType === "run_error") && this.clearFirstResponseTimer(b.respondsToUserMessageId ?? null);
|
|
@@ -10348,7 +10357,7 @@ class Kt {
|
|
|
10348
10357
|
}
|
|
10349
10358
|
}
|
|
10350
10359
|
};
|
|
10351
|
-
let
|
|
10360
|
+
let l = new Map(this.getState().messages.map((p) => [p.id, p])), h = this.clientRuntime.engine.getState().slices.conversation, f = this.clientRuntime.engine.getState().slices.directory.selections, m = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
|
|
10352
10361
|
this.conversationUnsubscribe = this.clientRuntime.engine.subscribe(() => {
|
|
10353
10362
|
const p = this.clientRuntime.engine.getState().slices, y = h;
|
|
10354
10363
|
h = p.conversation, Eo(y, p.conversation, this.operationTimingReporter, "sdk");
|
|
@@ -10360,7 +10369,7 @@ class Kt {
|
|
|
10360
10369
|
g && (g.sessionId = R.sessionId), this.emit("ack", { clientMessageId: R.userMessageId, sessionId: R.sessionId });
|
|
10361
10370
|
const v = R.sessionId;
|
|
10362
10371
|
v && this.getState().sessionId === v && this.directoryHttp.request(`/sessions/${encodeURIComponent(v)}/history`, { limit: 200 }).then((I) => {
|
|
10363
|
-
n() && this.getState().sessionId === v && this.state.status !== "closed" &&
|
|
10372
|
+
n() && this.getState().sessionId === v && this.state.status !== "closed" && _s(this.clientRuntime, this.modelClientScopeId, v, I.turns);
|
|
10364
10373
|
}).catch((I) => {
|
|
10365
10374
|
n() && this.getState().sessionId === v && this.handleDirectoryTransportError(I);
|
|
10366
10375
|
});
|
|
@@ -10370,18 +10379,18 @@ class Kt {
|
|
|
10370
10379
|
for (const [R, g] of Object.entries(p.directory.clients)) {
|
|
10371
10380
|
if (!R.startsWith(`background:${this.modelClientScopeId}:`)) continue;
|
|
10372
10381
|
const v = Ie(p.conversation, p.directory, g), I = v.sessionId ? p.conversation.sessions[v.sessionId] : void 0;
|
|
10373
|
-
if (this.firstResponseTimersByClientMessageId.size && (
|
|
10382
|
+
if (this.firstResponseTimersByClientMessageId.size && (u(fs(v, I?.queries.current, this.options.backendUrl).messages, v.sessionId), ["failed", "stopped"].includes(v.activity.phase)))
|
|
10374
10383
|
for (const A of le(I?.execution)) this.clearFirstResponseTimer(A);
|
|
10375
10384
|
const w = v.activity.phase === "completed" && le(I?.execution).some((A) => this.firstResponseTimersByClientMessageId.has(A));
|
|
10376
10385
|
(b && v.sessionId === this.getState().sessionId || !w && ["completed", "failed", "stopped"].includes(v.activity.phase)) && this.directoryScope.detach(R);
|
|
10377
10386
|
}
|
|
10378
10387
|
const k = this.getState();
|
|
10379
|
-
|
|
10388
|
+
u(k.messages, k.sessionId);
|
|
10380
10389
|
for (const R of k.messages) {
|
|
10381
|
-
const g =
|
|
10390
|
+
const g = l.get(R.id);
|
|
10382
10391
|
(!g || g.content !== R.content || g.loading !== R.loading) && this.emit("message", R), R.content.trim() && R.content !== g?.content && (R.role === "assistant" || R.dataType === "commentary_history") && R.content.startsWith(g?.content ?? "") && this.emit("delta", R.content.slice(g?.content.length ?? 0));
|
|
10383
10392
|
}
|
|
10384
|
-
|
|
10393
|
+
l = new Map(k.messages.map((R) => [R.id, R])), this.rebuildRuntimeInteractions(), this.emit("state", k);
|
|
10385
10394
|
}), this.conversationObservation.wake();
|
|
10386
10395
|
}
|
|
10387
10396
|
async initializeDirectory() {
|
|
@@ -10403,7 +10412,7 @@ class Kt {
|
|
|
10403
10412
|
}
|
|
10404
10413
|
}
|
|
10405
10414
|
handleDirectoryTransportError(e) {
|
|
10406
|
-
if (!(e instanceof q) || this.authenticationFailure || !["unauthorized", "update_required", "service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(e.code) &&
|
|
10415
|
+
if (!(e instanceof q) || this.authenticationFailure || !["unauthorized", "update_required", "service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(e.code) && xt(void 0, e.code).allowed) return;
|
|
10407
10416
|
const s = e.detail && typeof e.detail == "object" ? e.detail : {};
|
|
10408
10417
|
this.handleServerEvent({
|
|
10409
10418
|
...s,
|
|
@@ -10436,12 +10445,12 @@ class Kt {
|
|
|
10436
10445
|
return n.add(s), this.listeners[e] = n, () => n.delete(s);
|
|
10437
10446
|
}
|
|
10438
10447
|
getState() {
|
|
10439
|
-
const e = this.clientRuntime.engine.getState().slices, s = e.directory.clients[this.modelClientScopeId] ?? this.directoryConversationScopeId, n = Ie(e.conversation, e.directory, s), i =
|
|
10448
|
+
const e = this.clientRuntime.engine.getState().slices, s = e.directory.clients[this.modelClientScopeId] ?? this.directoryConversationScopeId, n = Ie(e.conversation, e.directory, s), i = fs(
|
|
10440
10449
|
n,
|
|
10441
10450
|
n.sessionId ? e.conversation.sessions[n.sessionId]?.queries.current : void 0,
|
|
10442
10451
|
this.options.backendUrl,
|
|
10443
10452
|
this.clientRuntime.engine.getDiagnostics({ clientScopeId: this.modelClientScopeId, scopeId: s, sessionId: n.sessionId })
|
|
10444
|
-
), r = { clientScopeId: this.modelClientScopeId, origin: location.origin, pageUrl: location.href }, a = this.options.productVariant === "personal" ? { kind: "userSuggestedTasks" } : { kind: "starterPrompts", ...r, includeUserSuggestions: !1 }, o =
|
|
10453
|
+
), r = { clientScopeId: this.modelClientScopeId, origin: location.origin, pageUrl: location.href }, a = this.options.productVariant === "personal" ? { kind: "userSuggestedTasks" } : { kind: "starterPrompts", ...r, includeUserSuggestions: !1 }, o = Dt(e, a), c = Dt(e, { kind: "appearance", ...r }), d = c?.data?.kind === "appearance" ? c.data.value : null;
|
|
10445
10454
|
return {
|
|
10446
10455
|
...this.platformState,
|
|
10447
10456
|
...i,
|
|
@@ -10485,9 +10494,9 @@ class Kt {
|
|
|
10485
10494
|
this.tokenAbortController = r;
|
|
10486
10495
|
const a = (async () => {
|
|
10487
10496
|
let o = null;
|
|
10488
|
-
const c = new Promise((d,
|
|
10497
|
+
const c = new Promise((d, u) => {
|
|
10489
10498
|
o = window.setTimeout(() => {
|
|
10490
|
-
r.abort(),
|
|
10499
|
+
r.abort(), u(new ue("Pluno token provider timed out", !0));
|
|
10491
10500
|
}, ad);
|
|
10492
10501
|
});
|
|
10493
10502
|
try {
|
|
@@ -10604,8 +10613,8 @@ class Kt {
|
|
|
10604
10613
|
this.socket === a && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.setReconnectingState(), this.scheduleReconnect(), a.readyState !== WebSocket.CLOSED && a.readyState !== WebSocket.CLOSING && a.close());
|
|
10605
10614
|
}), a.addEventListener("diagnosticpending", (o) => {
|
|
10606
10615
|
if (this.clientRuntime.isDisposed || this.state.status === "closed") return;
|
|
10607
|
-
const c = o.detail, d = new Set(c.map((
|
|
10608
|
-
this.pendingTransportDiagnostics = [...this.pendingTransportDiagnostics.filter((
|
|
10616
|
+
const c = o.detail, d = new Set(c.map((u) => u.id));
|
|
10617
|
+
this.pendingTransportDiagnostics = [...this.pendingTransportDiagnostics.filter((u) => !d.has(u.id)), ...c].slice(-20), this.flushClientDiagnostics();
|
|
10609
10618
|
}), a.addEventListener("close", (o) => {
|
|
10610
10619
|
this.socket === a && (this.clearSocketPhaseTimers(), this.stopHeartbeat(), this.socket = null, this.state.status !== "closed" && (V("web-sdk.agent", "Pluno socket closed; scheduling reconnect", {
|
|
10611
10620
|
code: typeof o?.code == "number" ? o.code : null,
|
|
@@ -10751,19 +10760,19 @@ class Kt {
|
|
|
10751
10760
|
sessionId: this.getState().sessionId
|
|
10752
10761
|
});
|
|
10753
10762
|
a.mark("submit");
|
|
10754
|
-
const o =
|
|
10763
|
+
const o = ws(
|
|
10755
10764
|
this.clientRuntime,
|
|
10756
10765
|
this.modelClientScopeId,
|
|
10757
10766
|
r,
|
|
10758
10767
|
s.requestedModel ?? this.getModel()
|
|
10759
10768
|
), c = this.submissionIntentRevision, d = this.authenticatedUserId;
|
|
10760
10769
|
if (s.initiatedBy || this.startFirstResponseTimer(r, s.submittedAt), d || await a.measure("authentication", () => this.waitForAuthentication()), this.clientRuntime.isDisposed || c !== this.submissionIntentRevision || d && d !== this.authenticatedUserId) return null;
|
|
10761
|
-
|
|
10762
|
-
const
|
|
10763
|
-
if (
|
|
10764
|
-
const
|
|
10770
|
+
ws(this.clientRuntime, this.modelClientScopeId, r, o ?? null);
|
|
10771
|
+
const u = this.clientRuntime.engine.getState().slices.conversation.submissions[r];
|
|
10772
|
+
if (u && (u.content !== n || JSON.stringify(u.attachments.map((y) => y.sourceId)) !== JSON.stringify(i.map((y) => y.id ?? y.storageKey ?? y.sandboxPath)))) throw new Error("User-message identity cannot be reused with different input.");
|
|
10773
|
+
const l = ae(), h = !u && !s.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== l.url, m = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
|
|
10765
10774
|
if (!m) throw new Error("Conversation selection is not initialized.");
|
|
10766
|
-
|
|
10775
|
+
u || await this.clientRuntime.engine.dispatch({
|
|
10767
10776
|
...this.directoryAuthority,
|
|
10768
10777
|
type: "conversation.submission_stage",
|
|
10769
10778
|
prepareContext: h,
|
|
@@ -10790,7 +10799,7 @@ class Kt {
|
|
|
10790
10799
|
} } : {}
|
|
10791
10800
|
})),
|
|
10792
10801
|
context: JSON.parse(JSON.stringify({
|
|
10793
|
-
page:
|
|
10802
|
+
page: l,
|
|
10794
10803
|
...s.proactiveSuggestionQuestion ? { proactiveSuggestionQuestion: s.proactiveSuggestionQuestion } : {},
|
|
10795
10804
|
metadata: { ...wi(this.options.metadata), ...s.automationOnboarding ? { automationOnboarding: !0 } : {} }
|
|
10796
10805
|
})),
|
|
@@ -10851,7 +10860,7 @@ class Kt {
|
|
|
10851
10860
|
if (!r) return !1;
|
|
10852
10861
|
if (r.type === "preparation") {
|
|
10853
10862
|
const a = z(), o = La(r.submission);
|
|
10854
|
-
return
|
|
10863
|
+
return ws(this.clientRuntime, this.modelClientScopeId, a, r.submission.requestedModel), this.sendMessage(o.content, { clientMessageId: a, attachments: o.attachments, proactiveSuggestionQuestion: o.proactiveSuggestionQuestion }).catch((c) => this.emit("error", Qe(c))), !0;
|
|
10855
10864
|
}
|
|
10856
10865
|
return r.type === "delivery" ? (this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "conversation.submit", userMessageId: r.userMessageId, now: Date.now(), manualRetry: !0 }), !0) : (this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "conversation.operation", command: {
|
|
10857
10866
|
request_id: z(),
|
|
@@ -10904,13 +10913,13 @@ class Kt {
|
|
|
10904
10913
|
entrySurface: this.options.entrySurface,
|
|
10905
10914
|
sessionId: this.getState().sessionId
|
|
10906
10915
|
} }
|
|
10907
|
-
}), new Promise((d,
|
|
10908
|
-
let
|
|
10916
|
+
}), new Promise((d, u) => {
|
|
10917
|
+
let l, h;
|
|
10909
10918
|
const f = () => {
|
|
10910
10919
|
const m = this.clientRuntime.engine.getState().slices, p = m.conversation.operations[c], y = m.directory.authorityId !== a.authorityId || m.directory.clients[this.modelClientScopeId] !== o;
|
|
10911
10920
|
if (!y && p && !["done", "failed"].includes(p.phase)) return;
|
|
10912
|
-
if (
|
|
10913
|
-
|
|
10921
|
+
if (l?.(), h?.(), y || !p || p.phase === "failed") {
|
|
10922
|
+
u(new Error(p?.error?.message ?? "Attachment preparation was cancelled."));
|
|
10914
10923
|
return;
|
|
10915
10924
|
}
|
|
10916
10925
|
const k = p.result.attachment;
|
|
@@ -10924,8 +10933,8 @@ class Kt {
|
|
|
10924
10933
|
fileUrl: k.file_url
|
|
10925
10934
|
}, this.options.backendUrl));
|
|
10926
10935
|
};
|
|
10927
|
-
|
|
10928
|
-
|
|
10936
|
+
l = this.clientRuntime.engine.subscribe(f), h = this.clientRuntime.onDispose(() => {
|
|
10937
|
+
l?.(), u(new Error("Product Agent was disposed."));
|
|
10929
10938
|
}), f();
|
|
10930
10939
|
});
|
|
10931
10940
|
}
|
|
@@ -10989,7 +10998,7 @@ class Kt {
|
|
|
10989
10998
|
warmupId: this.activeComposerWarmupId,
|
|
10990
10999
|
page: ae()
|
|
10991
11000
|
}
|
|
10992
|
-
} }), this.activeComposerWarmupId = null, this.lastUserMessagePageUrl = null, this.draftModel = this.options.model ?? (this.options.productVariant === "personal" ?
|
|
11001
|
+
} }), this.activeComposerWarmupId = null, this.lastUserMessagePageUrl = null, this.draftModel = this.options.model ?? (this.options.productVariant === "personal" ? ts[0].value : "gpt-5.6-terra"), this.clientRuntime.engine.dispatch({ type: "model.scope_navigate", clientScopeId: this.modelClientScopeId, sessionId: null }), this.beginDirectoryProvisional();
|
|
10993
11002
|
}
|
|
10994
11003
|
listSessions(e = {}) {
|
|
10995
11004
|
return this.clientRuntime.route("directory", { core: async () => {
|
|
@@ -11007,20 +11016,20 @@ class Kt {
|
|
|
11007
11016
|
}
|
|
11008
11017
|
getSessionHistoryState() {
|
|
11009
11018
|
return this.clientRuntime.project("directory", { core: () => {
|
|
11010
|
-
const e = this.clientRuntime.engine.getProjection().directory, s = e.queries[B(this.getDirectoryQuery())], n = Ts(this.options.entrySurface).map((
|
|
11011
|
-
...i.map((
|
|
11012
|
-
id:
|
|
11019
|
+
const e = this.clientRuntime.engine.getProjection().directory, s = e.queries[B(this.getDirectoryQuery())], n = Ts(this.options.entrySurface).map((u) => this.getDirectoryQuery(u)).map((u) => e.queries[B(u)]).filter((u) => u !== void 0), i = Object.values(e.optimisticEntries).reverse(), r = Wa(n), a = new Set(i.flatMap((u) => u.sessionId ? [u.sessionId] : [])), o = [...i.map((u) => u.id), ...r.filter((u) => !a.has(u))], c = Object.fromEntries([
|
|
11020
|
+
...i.map((u) => [u.id, {
|
|
11021
|
+
id: u.id,
|
|
11013
11022
|
title: null,
|
|
11014
11023
|
customTitle: null,
|
|
11015
|
-
firstUserMessage:
|
|
11016
|
-
currentPage:
|
|
11017
|
-
createdAt:
|
|
11018
|
-
updatedAt:
|
|
11019
|
-
lastActiveAt:
|
|
11020
|
-
isActive:
|
|
11024
|
+
firstUserMessage: u.firstUserMessage,
|
|
11025
|
+
currentPage: u.currentPage,
|
|
11026
|
+
createdAt: u.createdAt,
|
|
11027
|
+
updatedAt: u.createdAt,
|
|
11028
|
+
lastActiveAt: u.createdAt,
|
|
11029
|
+
isActive: u.sessionId ? e.activityBySessionId[u.sessionId] === !0 : u.isActive,
|
|
11021
11030
|
isPinned: !1
|
|
11022
11031
|
}]),
|
|
11023
|
-
...r.filter((
|
|
11032
|
+
...r.filter((u) => !a.has(u)).map((u) => [u, this.toSessionHistoryEntry(e.entities[u])])
|
|
11024
11033
|
]), d = Ka(n);
|
|
11025
11034
|
return {
|
|
11026
11035
|
key: `${this.options.clientId}:recent`,
|
|
@@ -11028,7 +11037,7 @@ class Kt {
|
|
|
11028
11037
|
data: n.length || i.length ? { entitiesById: c, ids: o, nextCursor: s?.cursor ?? null } : null,
|
|
11029
11038
|
error: d?.error?.message ?? null,
|
|
11030
11039
|
requestId: e.requestSequence,
|
|
11031
|
-
updatedAt: Math.max(...n.map((
|
|
11040
|
+
updatedAt: Math.max(...n.map((u) => u.updatedAt ?? 0), 0) || null
|
|
11032
11041
|
};
|
|
11033
11042
|
} });
|
|
11034
11043
|
}
|
|
@@ -11174,45 +11183,45 @@ class Kt {
|
|
|
11174
11183
|
if (!n() || !i) return;
|
|
11175
11184
|
this.clientRuntime.engine.getState().slices.account.authority || this.applyAuthenticatedDirectoryIdentity(i.user);
|
|
11176
11185
|
}
|
|
11177
|
-
await
|
|
11186
|
+
await cs(this.clientRuntime, { kind: "account" });
|
|
11178
11187
|
}
|
|
11179
11188
|
}
|
|
11180
11189
|
installFeaturePorts() {
|
|
11181
11190
|
const e = ao(() => Date.now());
|
|
11182
11191
|
let s = !1, n = !1;
|
|
11183
11192
|
const i = () => {
|
|
11184
|
-
const
|
|
11185
|
-
if (!
|
|
11193
|
+
const u = this.options.runtimeAdapters?.featurePermissions, l = this.clientRuntime.engine.getState().slices.account.authority;
|
|
11194
|
+
if (!u || l?.profile !== "main_web_chat" || this.clientRuntime.isDisposed) return;
|
|
11186
11195
|
if (s) {
|
|
11187
11196
|
n = !0;
|
|
11188
11197
|
return;
|
|
11189
11198
|
}
|
|
11190
11199
|
s = !0;
|
|
11191
|
-
const h = this.getState().sessionId, f = () => !this.clientRuntime.isDisposed && JSON.stringify(this.clientRuntime.engine.getState().slices.account.authority) === JSON.stringify(
|
|
11200
|
+
const h = this.getState().sessionId, f = () => !this.clientRuntime.isDisposed && JSON.stringify(this.clientRuntime.engine.getState().slices.account.authority) === JSON.stringify(l) && this.getState().sessionId === h;
|
|
11192
11201
|
Promise.all(["notifications", "tab_grouping"].map(async (m) => {
|
|
11193
|
-
const p = await
|
|
11202
|
+
const p = await u.getState(m, h);
|
|
11194
11203
|
if (f()) {
|
|
11195
11204
|
if (!p.bridgeReady) return p;
|
|
11196
11205
|
if (await this.clientRuntime.engine.dispatch({
|
|
11197
11206
|
type: "stage7.device_fact",
|
|
11198
|
-
authority:
|
|
11207
|
+
authority: l,
|
|
11199
11208
|
now: Date.now(),
|
|
11200
11209
|
feature: m,
|
|
11201
11210
|
fact: { permission: p.permissionGranted ? "granted" : p.permissionNeeded ? "missing" : "unknown", revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[m].revision + 1), snoozedUntil: p.snoozedUntil ?? null, pending: p.permissionPending === !0 }
|
|
11202
11211
|
}), m === "tab_grouping" && p.sessionId === h && h) for (const y of p.crossTabUserMessageIds ?? [])
|
|
11203
|
-
await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority:
|
|
11212
|
+
await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority: l, now: Date.now(), sessionId: h, userMessageId: y });
|
|
11204
11213
|
return p;
|
|
11205
11214
|
}
|
|
11206
11215
|
})).then(async (m) => {
|
|
11207
11216
|
f() && await this.clientRuntime.engine.dispatch({
|
|
11208
11217
|
type: "stage7.bridge_ready",
|
|
11209
|
-
authority:
|
|
11218
|
+
authority: l,
|
|
11210
11219
|
now: Date.now(),
|
|
11211
11220
|
ready: m.every((p) => p?.bridgeReady),
|
|
11212
11221
|
error: m.find((p) => p?.error)?.error ?? null
|
|
11213
11222
|
});
|
|
11214
11223
|
}).catch(async () => {
|
|
11215
|
-
f() && await this.clientRuntime.engine.dispatch({ type: "stage7.bridge_ready", authority:
|
|
11224
|
+
f() && await this.clientRuntime.engine.dispatch({ type: "stage7.bridge_ready", authority: l, now: Date.now(), ready: !1, error: "The Pluno extension could not reconnect. Try again." });
|
|
11216
11225
|
}).finally(() => {
|
|
11217
11226
|
s = !1, n && (n = !1, i());
|
|
11218
11227
|
});
|
|
@@ -11221,53 +11230,53 @@ class Kt {
|
|
|
11221
11230
|
now: () => Date.now(),
|
|
11222
11231
|
preferenceStorage: {
|
|
11223
11232
|
// Separate locks serialize shared storage and backups across dashboard tabs without blocking local edits on HTTP.
|
|
11224
|
-
exclusive: async (
|
|
11225
|
-
load: async (
|
|
11226
|
-
save: async (
|
|
11227
|
-
localStorage.setItem(`pa.preferences:${this.options.backendUrl}:${
|
|
11233
|
+
exclusive: async (u, l) => await navigator.locks.request(`pa.preferences:${this.options.backendUrl}:${u}`, l),
|
|
11234
|
+
load: async (u) => JSON.parse(localStorage.getItem(`pa.preferences:${this.options.backendUrl}:${u}`) ?? "null"),
|
|
11235
|
+
save: async (u, l) => {
|
|
11236
|
+
localStorage.setItem(`pa.preferences:${this.options.backendUrl}:${u}`, JSON.stringify(l));
|
|
11228
11237
|
}
|
|
11229
11238
|
},
|
|
11230
11239
|
authority: () => this.clientRuntime.engine.getState().slices.account.authority,
|
|
11231
|
-
readAccount: async (
|
|
11232
|
-
const
|
|
11240
|
+
readAccount: async (u) => {
|
|
11241
|
+
const l = this.clientRuntime.engine.getState().slices.account, h = this.options.accountLoader ? await this.options.accountLoader() : l.refusal ? null : this.options.initialAccount;
|
|
11233
11242
|
if (!h) throw new Error("Account information is unavailable.");
|
|
11234
11243
|
return i(), fo(h, {
|
|
11235
|
-
id:
|
|
11244
|
+
id: u.userId,
|
|
11236
11245
|
email: this.state.user?.email ?? null,
|
|
11237
11246
|
name: this.state.user?.name ?? null,
|
|
11238
11247
|
isSuperuser: !1
|
|
11239
|
-
},
|
|
11248
|
+
}, u.communityId);
|
|
11240
11249
|
},
|
|
11241
11250
|
embedded: {
|
|
11242
|
-
appearance: async (
|
|
11243
|
-
const
|
|
11244
|
-
return { kind: "appearance", origin:
|
|
11251
|
+
appearance: async (u) => {
|
|
11252
|
+
const l = await this.directoryHttp.request("/bootstrap", { page_url: u.pageUrl }, void 0, "GET", "embed"), h = Yd(l);
|
|
11253
|
+
return { kind: "appearance", origin: u.origin, value: h ? { accent: h.accentColor ?? "#7c3aed", colorScheme: h.colorScheme ?? "light", fontFamily: h.fontFamily ?? "inherit", scribbleStyle: h.scribbleStyle ?? !1 } : null };
|
|
11245
11254
|
},
|
|
11246
|
-
feedback: async (
|
|
11255
|
+
feedback: async (u) => (await this.directoryHttp.request("/feedback", {}, { message: u }, "POST", "embed")).success
|
|
11247
11256
|
}
|
|
11248
11257
|
});
|
|
11249
11258
|
this.clientRuntime.installFeaturePorts({
|
|
11250
11259
|
...r,
|
|
11251
11260
|
"stage7.wait": e.wait,
|
|
11252
|
-
"stage7.device": async ({ feature:
|
|
11261
|
+
"stage7.device": async ({ feature: u, action: l, requestId: h }) => {
|
|
11253
11262
|
const f = this.options.runtimeAdapters?.featurePermissions;
|
|
11254
11263
|
if (!f) return { fact: { permission: "unsupported", revision: Date.now(), snoozedUntil: null }, completedAt: Date.now() };
|
|
11255
|
-
const m = this.clientRuntime.engine.getState().slices.interactions, p = m.promptActions[h], y = p?.expectedRevision ?? m.preferencePrompts[
|
|
11256
|
-
|
|
11257
|
-
const b = await f.getState(
|
|
11264
|
+
const m = this.clientRuntime.engine.getState().slices.interactions, p = m.promptActions[h], y = p?.expectedRevision ?? m.preferencePrompts[u].revision;
|
|
11265
|
+
l === "allow" && await f.enable(u, { requestId: h, expectedRevision: y, action: p?.action === "enable" ? "enable" : "allow" }), l === "not_now" && await f.dismiss(u, { requestId: h, expectedRevision: y, action: "not_now" });
|
|
11266
|
+
const b = await f.getState(u, this.getState().sessionId);
|
|
11258
11267
|
if (!b.bridgeReady) throw new Error("The Pluno extension is reconnecting. Try again.");
|
|
11259
11268
|
return { fact: {
|
|
11260
11269
|
permission: b.permissionGranted === !0 ? "granted" : b.permissionNeeded ? "missing" : "unknown",
|
|
11261
|
-
revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[
|
|
11270
|
+
revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[u].revision + 1),
|
|
11262
11271
|
snoozedUntil: b.snoozedUntil ?? null,
|
|
11263
11272
|
pending: b.permissionPending === !0
|
|
11264
11273
|
}, completedAt: Date.now() };
|
|
11265
11274
|
},
|
|
11266
|
-
"stage7.platform": async (
|
|
11267
|
-
const
|
|
11268
|
-
if (
|
|
11269
|
-
zr(localStorage,
|
|
11270
|
-
else if (
|
|
11275
|
+
"stage7.platform": async (u) => {
|
|
11276
|
+
const l = u.operation, h = l.kind === "connect" ? l.source : null;
|
|
11277
|
+
if (l.kind === "saveHint")
|
|
11278
|
+
zr(localStorage, l.interactionId);
|
|
11279
|
+
else if (l.kind === "connect" && h?.payload.kind === "integration_auth") {
|
|
11271
11280
|
const f = h.payload;
|
|
11272
11281
|
if (!this.options.runtimeAdapters?.integrationAuthHandler) throw new Error("Connection handler unavailable.");
|
|
11273
11282
|
await this.options.runtimeAdapters.integrationAuthHandler({
|
|
@@ -11278,15 +11287,15 @@ class Kt {
|
|
|
11278
11287
|
appLogo: f.app_logo,
|
|
11279
11288
|
expiresAt: f.expires_at
|
|
11280
11289
|
});
|
|
11281
|
-
} else if (
|
|
11290
|
+
} else if (l.kind === "pair") {
|
|
11282
11291
|
if (!this.options.runtimeAdapters?.personalChannelConnectionHandler) throw new Error("Pairing handler unavailable.");
|
|
11283
11292
|
await this.options.runtimeAdapters.personalChannelConnectionHandler({
|
|
11284
11293
|
type: "personal_channel_connection_required",
|
|
11285
|
-
requestId:
|
|
11294
|
+
requestId: l.requestId,
|
|
11286
11295
|
channel: "whatsapp",
|
|
11287
|
-
managementUrl:
|
|
11296
|
+
managementUrl: l.managementUrl
|
|
11288
11297
|
});
|
|
11289
|
-
} else if (this.options.runtimeAdapters?.interactionEffect) await this.options.runtimeAdapters.interactionEffect(
|
|
11298
|
+
} else if (this.options.runtimeAdapters?.interactionEffect) await this.options.runtimeAdapters.interactionEffect(u);
|
|
11290
11299
|
else throw new Error("Interaction effect is unavailable.");
|
|
11291
11300
|
return { revision: 0, completedAt: Date.now() };
|
|
11292
11301
|
}
|
|
@@ -11294,13 +11303,13 @@ class Kt {
|
|
|
11294
11303
|
let a = "";
|
|
11295
11304
|
const o = this.clientRuntime.engine.subscribe(() => {
|
|
11296
11305
|
this.rebuildRuntimeInteractions();
|
|
11297
|
-
const
|
|
11306
|
+
const u = this.clientRuntime.engine.getState().slices, h = u.directory.selections[u.directory.clients[this.modelClientScopeId]]?.sessionId, f = JSON.stringify([h, h ? u.conversation.sessions[h]?.execution : null]);
|
|
11298
11307
|
f !== a && (a = f, i());
|
|
11299
11308
|
}), c = this.options.runtimeAdapters?.featurePermissions?.subscribe?.(i);
|
|
11300
11309
|
this.clientRuntime.onDispose(() => c?.()), co(this.clientRuntime, () => Date.now());
|
|
11301
11310
|
const d = () => {
|
|
11302
|
-
const
|
|
11303
|
-
|
|
11311
|
+
const u = this.clientRuntime.engine.getState().slices.account.authority;
|
|
11312
|
+
u?.profile === "main_web_chat" && this.options.entrySurface === "main_web_chat" && this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: u, now: Date.now(), hints: Ds(localStorage) });
|
|
11304
11313
|
};
|
|
11305
11314
|
window.addEventListener("storage", d), this.clientRuntime.onDispose(() => window.removeEventListener("storage", d)), this.clientRuntime.onDispose(() => {
|
|
11306
11315
|
e.dispose(), o(), this.options.runtimeAdapters?.featurePermissions?.dispose?.();
|
|
@@ -11316,7 +11325,7 @@ class Kt {
|
|
|
11316
11325
|
if (Object.values(s.optimisticEntries).some((i) => i.id === e && i.sessionId === null)) return;
|
|
11317
11326
|
!this.options.keepRunsActiveOnSessionNavigation && this.state.sessionId !== e && this.stopConversation("session_switch"), this.retainNavigatedConversation();
|
|
11318
11327
|
const n = "conversation:" + this.modelClientScopeId + ":" + z();
|
|
11319
|
-
this.directoryConversationScopeId = n, this.lastUserMessagePageUrl = null, this.draftModel = this.options.model ?? (this.options.productVariant === "personal" ?
|
|
11328
|
+
this.directoryConversationScopeId = n, this.lastUserMessagePageUrl = null, this.draftModel = this.options.model ?? (this.options.productVariant === "personal" ? ts[0].value : "gpt-5.6-terra"), this.clientRuntime.engine.dispatch({ type: "model.scope_navigate", clientScopeId: this.modelClientScopeId, sessionId: e }), this.directoryScope.bind(this.modelClientScopeId, this.directoryConversationScopeId, e).then(async () => {
|
|
11320
11329
|
await this.directoryScope.persist(), this.state.sessionId === e && (s.intents[e]?.observe && this.conversationObservation?.refresh(e).catch((i) => this.handleDirectoryTransportError(i)), this.send({ type: "page.upsert", sessionId: e, page: ae(), model: this.getModel() }));
|
|
11321
11330
|
});
|
|
11322
11331
|
}
|
|
@@ -11348,7 +11357,7 @@ class Kt {
|
|
|
11348
11357
|
let n = this.getState();
|
|
11349
11358
|
if (e === "first_response_slow" && s.sessionId && s.sessionId !== n.sessionId) {
|
|
11350
11359
|
const { conversation: m, directory: p } = this.clientRuntime.engine.getState().slices, y = Object.values(p.clients).find((b) => p.selections[b]?.sessionId === s.sessionId);
|
|
11351
|
-
y && (n = { ...n, ...
|
|
11360
|
+
y && (n = { ...n, ...fs(
|
|
11352
11361
|
Ie(m, p, y),
|
|
11353
11362
|
m.sessions[s.sessionId]?.queries.current,
|
|
11354
11363
|
this.options.backendUrl
|
|
@@ -11383,8 +11392,8 @@ class Kt {
|
|
|
11383
11392
|
...n.sessionId ? { sessionId: n.sessionId } : {},
|
|
11384
11393
|
...s,
|
|
11385
11394
|
...s.renderedError?.runId ? { runId: s.renderedError.runId } : {}
|
|
11386
|
-
}, { errorDiagnostic: a, responseDiagnostics: o, renderedError: c, uiInvariant: d, timings:
|
|
11387
|
-
for (const m of
|
|
11395
|
+
}, { errorDiagnostic: a, responseDiagnostics: o, renderedError: c, uiInvariant: d, timings: u, httpRequest: l, historyRefreshFailure: h, ...f } = r;
|
|
11396
|
+
for (const m of u ?? []) xe("client_event", "operation_timing", { ...m });
|
|
11388
11397
|
if (xe("client_event", "runtime.health", {
|
|
11389
11398
|
...f,
|
|
11390
11399
|
signalName: e,
|
|
@@ -11475,7 +11484,7 @@ class Kt {
|
|
|
11475
11484
|
occurrenceCount: (o?.occurrenceCount ?? 0) + 1,
|
|
11476
11485
|
maxReconnectAttempt: Math.max(o?.maxReconnectAttempt ?? 0, this.reconnectAttempts),
|
|
11477
11486
|
connectivity: n,
|
|
11478
|
-
sdkVersion:
|
|
11487
|
+
sdkVersion: Ft.version,
|
|
11479
11488
|
stage: "socket_admission",
|
|
11480
11489
|
...s,
|
|
11481
11490
|
connectionAttemptId: i
|
|
@@ -11542,12 +11551,12 @@ class Kt {
|
|
|
11542
11551
|
if (!o.ok)
|
|
11543
11552
|
throw new Error(`Client diagnostic upload failed (${o.status})`);
|
|
11544
11553
|
const c = new Map(
|
|
11545
|
-
s.map((
|
|
11546
|
-
), d = new Set(n.map((
|
|
11554
|
+
s.map((u) => [u.id, u.occurrenceCount])
|
|
11555
|
+
), d = new Set(n.map((u) => u.id));
|
|
11547
11556
|
this.pendingTransportDiagnostics = this.pendingTransportDiagnostics.filter(
|
|
11548
|
-
(
|
|
11557
|
+
(u) => !c.has(u.id) || u.occurrenceCount > (c.get(u.id) ?? 0)
|
|
11549
11558
|
), this.pendingHealthDiagnostics = this.pendingHealthDiagnostics.filter(
|
|
11550
|
-
(
|
|
11559
|
+
(u) => !d.has(u.id)
|
|
11551
11560
|
);
|
|
11552
11561
|
} catch {
|
|
11553
11562
|
this.scheduleClientDiagnosticsRetry();
|
|
@@ -11583,8 +11592,8 @@ class Kt {
|
|
|
11583
11592
|
if (!this.clientRuntime.engine.getState().slices.account.authority || this.state.status === "closed") return Promise.resolve();
|
|
11584
11593
|
const e = { clientScopeId: this.modelClientScopeId, origin: location.origin, pageUrl: location.href };
|
|
11585
11594
|
return Promise.all([
|
|
11586
|
-
|
|
11587
|
-
|
|
11595
|
+
cs(this.clientRuntime, { kind: "appearance", ...e }),
|
|
11596
|
+
cs(this.clientRuntime, this.options.productVariant === "personal" ? { kind: "userSuggestedTasks" } : { kind: "starterPrompts", ...e, includeUserSuggestions: !1 }).then(async (s) => {
|
|
11588
11597
|
s.kind === "starterPrompts" && s.prompts.length === 0 && location.href === e.pageUrl && await this.requestTransientStarterPrompts();
|
|
11589
11598
|
})
|
|
11590
11599
|
]).then(() => {
|
|
@@ -11609,12 +11618,12 @@ class Kt {
|
|
|
11609
11618
|
applyAuthenticatedDirectoryIdentity(e) {
|
|
11610
11619
|
const s = Ri(e);
|
|
11611
11620
|
if (!s) return !1;
|
|
11612
|
-
const n =
|
|
11621
|
+
const n = bt(e, "runtimeCommunityId") ?? this.directoryHttp.auth.community_id, i = `${this.options.clientId}:${s.id}:${n ?? this.options.productVariant}`, r = this.directoryAuthority.authorityId !== i, a = this.authenticatedUserId === null, o = a ? Object.values(this.clientRuntime.engine.getState().slices.conversation.operations).filter((u) => ["waiting", "running", "uncertain"].includes(u.phase) && (u.command.type === "run.stop" || u.command.type === "session.reset")).map((u) => u.command) : [], c = a && this.directoryAuthority.authorityId === `${this.options.clientId}:${this.options.runtimeCommunityId ?? this.options.productVariant}` ? this.state.sessionId : null;
|
|
11613
11622
|
if (this.authenticatedUserId = s.id, this.directoryHttp.auth.community_id = n, Bo(this.options.clientId, i), r) {
|
|
11614
|
-
const
|
|
11615
|
-
this.directoryObservation.dispose(), this.conversationAdapterGeneration++, this.conversationObservation?.dispose(), this.directoryAuthority = { authorityId: i, generation:
|
|
11616
|
-
const
|
|
11617
|
-
a || (this.pendingWidgetLifecycleEvents = []), this.resetForAuthenticationScopeChange(), c && (this.directoryConversationScopeId = `conversation:${this.modelClientScopeId}:${z()}`, this.clientRuntime.engine.dispatch({ type: "model.scope_navigate", clientScopeId: this.modelClientScopeId, sessionId: c }), this.directoryScope.bind(this.modelClientScopeId, this.directoryConversationScopeId, c).then(() => this.directoryScope.persist())),
|
|
11623
|
+
const u = this.directoryAuthority;
|
|
11624
|
+
this.directoryObservation.dispose(), this.conversationAdapterGeneration++, this.conversationObservation?.dispose(), this.directoryAuthority = { authorityId: i, generation: u.generation + 1 }, this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "directory.authority_replace", expectedGeneration: u.generation }), this.createDirectoryAdapters();
|
|
11625
|
+
const l = a ? this.draftModel : void 0;
|
|
11626
|
+
a || (this.pendingWidgetLifecycleEvents = []), this.resetForAuthenticationScopeChange(), c && (this.directoryConversationScopeId = `conversation:${this.modelClientScopeId}:${z()}`, this.clientRuntime.engine.dispatch({ type: "model.scope_navigate", clientScopeId: this.modelClientScopeId, sessionId: c }), this.directoryScope.bind(this.modelClientScopeId, this.directoryConversationScopeId, c).then(() => this.directoryScope.persist())), l && this.setModel(l);
|
|
11618
11627
|
}
|
|
11619
11628
|
const d = {
|
|
11620
11629
|
...this.directoryAuthority,
|
|
@@ -11631,18 +11640,18 @@ class Kt {
|
|
|
11631
11640
|
this.options.entrySurface === "main_web_chat" && d.profile === "main_web_chat" && await this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: d, now: Date.now(), hints: Ds(localStorage) }), await this.refreshStarterPromptsForCurrentUrl();
|
|
11632
11641
|
}).catch(() => {
|
|
11633
11642
|
}), r || a) {
|
|
11634
|
-
const
|
|
11643
|
+
const u = this.directoryAuthority;
|
|
11635
11644
|
this.initializeConversation().then(async () => {
|
|
11636
|
-
if (this.clientRuntime.isDisposed || this.directoryAuthority !==
|
|
11637
|
-
let
|
|
11645
|
+
if (this.clientRuntime.isDisposed || this.directoryAuthority !== u) return;
|
|
11646
|
+
let l = !1;
|
|
11638
11647
|
for (const h of o) {
|
|
11639
11648
|
const f = this.clientRuntime.engine.getState().slices.directory, m = f.clients[this.modelClientScopeId];
|
|
11640
11649
|
if (h.type === "run.stop" && f.selections[m]?.sessionId === h.payload.sessionId) {
|
|
11641
|
-
if (
|
|
11642
|
-
|
|
11650
|
+
if (l) continue;
|
|
11651
|
+
l = !0;
|
|
11643
11652
|
const p = o.filter((y) => y.type === "run.stop" && y.payload.sessionId === h.payload.sessionId).map((y) => String(y.payload.expectedUserMessageId));
|
|
11644
11653
|
await this.clientRuntime.engine.dispatch({
|
|
11645
|
-
...
|
|
11654
|
+
...u,
|
|
11646
11655
|
type: "conversation.stop",
|
|
11647
11656
|
clientScopeId: this.modelClientScopeId,
|
|
11648
11657
|
conversationScopeId: m,
|
|
@@ -11650,7 +11659,7 @@ class Kt {
|
|
|
11650
11659
|
reason: h.payload.reason,
|
|
11651
11660
|
userMessageIds: p
|
|
11652
11661
|
});
|
|
11653
|
-
} else (h.type === "run.stop" || h.type === "session.reset") && await this.clientRuntime.engine.dispatch({ ...
|
|
11662
|
+
} else (h.type === "run.stop" || h.type === "session.reset") && await this.clientRuntime.engine.dispatch({ ...u, type: "conversation.operation", command: h });
|
|
11654
11663
|
}
|
|
11655
11664
|
});
|
|
11656
11665
|
}
|
|
@@ -11716,11 +11725,11 @@ class Kt {
|
|
|
11716
11725
|
return;
|
|
11717
11726
|
}
|
|
11718
11727
|
if (e.type === "conversation.routing") {
|
|
11719
|
-
e.sessionId === this.state.sessionId &&
|
|
11728
|
+
e.sessionId === this.state.sessionId && _s(this.clientRuntime, this.modelClientScopeId, String(e.sessionId), e.turns);
|
|
11720
11729
|
return;
|
|
11721
11730
|
}
|
|
11722
11731
|
if (e.type === "session.updated" || e.type === "conversation.state") {
|
|
11723
|
-
|
|
11732
|
+
bt(e.session, "id") === this.state.sessionId && (this.updatePersonalModelFromSession(e.session), this.updateAccountFallbackFromSession(e.session), _s(this.clientRuntime, this.modelClientScopeId, this.state.sessionId, e.turns));
|
|
11724
11733
|
return;
|
|
11725
11734
|
}
|
|
11726
11735
|
if (e.type === "tool.call")
|
|
@@ -11730,7 +11739,7 @@ class Kt {
|
|
|
11730
11739
|
this.setState({ status: "reconnecting", lastError: String(e.message), lastErrorCode: e.code });
|
|
11731
11740
|
return;
|
|
11732
11741
|
}
|
|
11733
|
-
if (e.code === "service_origin_not_allowed" || e.code === "security_control_enforcement_unavailable" || !
|
|
11742
|
+
if (e.code === "service_origin_not_allowed" || e.code === "security_control_enforcement_unavailable" || !xt(void 0, String(e.code)).allowed) {
|
|
11734
11743
|
this.applyAccountSubmissionError(String(e.code)), this.setState({
|
|
11735
11744
|
status: "error",
|
|
11736
11745
|
lastError: String(e.message),
|
|
@@ -11787,7 +11796,7 @@ class Kt {
|
|
|
11787
11796
|
}
|
|
11788
11797
|
updatePersonalModelFromSession(e) {
|
|
11789
11798
|
if (!e || typeof e != "object") return;
|
|
11790
|
-
const s =
|
|
11799
|
+
const s = bt(e, "id");
|
|
11791
11800
|
if (!s) return;
|
|
11792
11801
|
const n = e.metadata, i = n && typeof n == "object" ? n.model : void 0;
|
|
11793
11802
|
this.clientRuntime.engine.accept({
|
|
@@ -11799,7 +11808,7 @@ class Kt {
|
|
|
11799
11808
|
}
|
|
11800
11809
|
updateAccountFallbackFromSession(e) {
|
|
11801
11810
|
if (!e || typeof e != "object") return;
|
|
11802
|
-
const s =
|
|
11811
|
+
const s = bt(e, "id"), n = this.clientRuntime.engine.getState().slices.account.authority;
|
|
11803
11812
|
s && n && this.clientRuntime.engine.dispatch({
|
|
11804
11813
|
type: "stage7.account_fallback",
|
|
11805
11814
|
authority: n,
|
|
@@ -11867,8 +11876,8 @@ class Kt {
|
|
|
11867
11876
|
startedAtUrl: location.href,
|
|
11868
11877
|
startedAtOrigin: location.origin
|
|
11869
11878
|
}), this.installSessionBrowserApis();
|
|
11870
|
-
let
|
|
11871
|
-
|
|
11879
|
+
let u = null, l;
|
|
11880
|
+
u = await this.executeRuntimeHelper(), l = await _i(
|
|
11872
11881
|
a,
|
|
11873
11882
|
Ud(e.runtimeContext, this.options.backendUrl)
|
|
11874
11883
|
).catch((h) => ({
|
|
@@ -11883,7 +11892,7 @@ class Kt {
|
|
|
11883
11892
|
toolName: i,
|
|
11884
11893
|
summary: a.summary,
|
|
11885
11894
|
rawInput: ne(a),
|
|
11886
|
-
rawOutput: ne(el(
|
|
11895
|
+
rawOutput: ne(el(l, u))
|
|
11887
11896
|
}), Ei(this.options.clientId, this.activeBrowserToolCalls.values()));
|
|
11888
11897
|
}
|
|
11889
11898
|
startPageLifecycleRecovery() {
|
|
@@ -12239,9 +12248,9 @@ function Sd() {
|
|
|
12239
12248
|
XMLHttpRequest.prototype.send = d;
|
|
12240
12249
|
} catch {
|
|
12241
12250
|
}
|
|
12242
|
-
let
|
|
12251
|
+
let u = null;
|
|
12243
12252
|
if (typeof PerformanceObserver < "u") {
|
|
12244
|
-
|
|
12253
|
+
u = new PerformanceObserver((h) => {
|
|
12245
12254
|
for (const f of h.getEntries()) {
|
|
12246
12255
|
const m = f;
|
|
12247
12256
|
if (m.initiatorType === "fetch" || m.initiatorType === "xmlhttprequest" || Pe(m.name))
|
|
@@ -12259,15 +12268,15 @@ function Sd() {
|
|
|
12259
12268
|
}
|
|
12260
12269
|
});
|
|
12261
12270
|
try {
|
|
12262
|
-
|
|
12271
|
+
u.observe({ type: "resource", buffered: !0 });
|
|
12263
12272
|
} catch {
|
|
12264
|
-
|
|
12273
|
+
u.disconnect(), u = null;
|
|
12265
12274
|
}
|
|
12266
12275
|
}
|
|
12267
|
-
const
|
|
12276
|
+
const l = {
|
|
12268
12277
|
subscribers: t,
|
|
12269
12278
|
destroy: () => {
|
|
12270
|
-
|
|
12279
|
+
u?.disconnect();
|
|
12271
12280
|
try {
|
|
12272
12281
|
window.fetch === a && (window.fetch = s);
|
|
12273
12282
|
} catch {
|
|
@@ -12286,7 +12295,7 @@ function Sd() {
|
|
|
12286
12295
|
}
|
|
12287
12296
|
}
|
|
12288
12297
|
};
|
|
12289
|
-
return window.__plunoProductAgentNetworkCapture =
|
|
12298
|
+
return window.__plunoProductAgentNetworkCapture = l, l;
|
|
12290
12299
|
}
|
|
12291
12300
|
function V(t, e, s) {
|
|
12292
12301
|
if (typeof window > "u")
|
|
@@ -12404,20 +12413,20 @@ async function _i(t, e) {
|
|
|
12404
12413
|
info: console.info,
|
|
12405
12414
|
warn: console.warn,
|
|
12406
12415
|
error: console.error
|
|
12407
|
-
}, c = (d) => (...
|
|
12408
|
-
r.push({ level: d, args:
|
|
12416
|
+
}, c = (d) => (...u) => {
|
|
12417
|
+
r.push({ level: d, args: u }), o[d](...u);
|
|
12409
12418
|
};
|
|
12410
12419
|
console.log = c("log"), console.info = c("info"), console.warn = c("warn"), console.error = c("error");
|
|
12411
12420
|
try {
|
|
12412
|
-
const d = /* @__PURE__ */ Symbol("execute_code_timeout"),
|
|
12421
|
+
const d = /* @__PURE__ */ Symbol("execute_code_timeout"), u = await Promise.race([
|
|
12413
12422
|
new s("sandboxFiles", t.javascript)(e?.value),
|
|
12414
|
-
new Promise((
|
|
12415
|
-
a = window.setTimeout(() =>
|
|
12423
|
+
new Promise((l) => {
|
|
12424
|
+
a = window.setTimeout(() => l(d), n);
|
|
12416
12425
|
})
|
|
12417
12426
|
]);
|
|
12418
|
-
return
|
|
12427
|
+
return u === d ? Nd(n) : {
|
|
12419
12428
|
ok: !0,
|
|
12420
|
-
result:
|
|
12429
|
+
result: u,
|
|
12421
12430
|
console: r,
|
|
12422
12431
|
metadata: {
|
|
12423
12432
|
durationMs: Date.now() - i,
|
|
@@ -12460,14 +12469,14 @@ function Ud(t, e) {
|
|
|
12460
12469
|
upload: async (o) => {
|
|
12461
12470
|
if (i(), !(o instanceof Blob))
|
|
12462
12471
|
throw new TypeError("sandboxFiles.upload expects a File or Blob");
|
|
12463
|
-
const c = o instanceof File && o.name ? o.name : "file", d = `?name=${encodeURIComponent(c)}&size_bytes=${o.size}`,
|
|
12472
|
+
const c = o instanceof File && o.name ? o.name : "file", d = `?name=${encodeURIComponent(c)}&size_bytes=${o.size}`, u = await r(`/api/product-agent/attachments/sandbox-files${d}`, {
|
|
12464
12473
|
method: "PUT",
|
|
12465
12474
|
headers: { Authorization: `Bearer ${s}` },
|
|
12466
12475
|
body: o
|
|
12467
12476
|
});
|
|
12468
|
-
if (!
|
|
12469
|
-
throw new Error(`sandboxFiles.upload failed (${
|
|
12470
|
-
return String((await
|
|
12477
|
+
if (!u.ok)
|
|
12478
|
+
throw new Error(`sandboxFiles.upload failed (${u.status})`);
|
|
12479
|
+
return String((await u.json()).path);
|
|
12471
12480
|
},
|
|
12472
12481
|
download: async (o) => {
|
|
12473
12482
|
i();
|
|
@@ -12477,8 +12486,8 @@ function Ud(t, e) {
|
|
|
12477
12486
|
);
|
|
12478
12487
|
if (!c.ok)
|
|
12479
12488
|
throw new Error(`sandboxFiles.download failed (${c.status})`);
|
|
12480
|
-
const d = await c.blob(),
|
|
12481
|
-
return new File([d],
|
|
12489
|
+
const d = await c.blob(), l = (c.headers.get("content-disposition") ?? "").match(/filename="([^"]+)"/i)?.[1];
|
|
12490
|
+
return new File([d], l || o.split("/").pop() || "file", {
|
|
12482
12491
|
type: d.type
|
|
12483
12492
|
});
|
|
12484
12493
|
}
|
|
@@ -12532,13 +12541,13 @@ function Fd() {
|
|
|
12532
12541
|
};
|
|
12533
12542
|
}
|
|
12534
12543
|
function $d(t) {
|
|
12535
|
-
return
|
|
12536
|
-
|
|
12544
|
+
return Ot.add(t), yt || (yt = zd()), () => {
|
|
12545
|
+
Ot.delete(t), Ot.size === 0 && (yt?.(), yt = null);
|
|
12537
12546
|
};
|
|
12538
12547
|
}
|
|
12539
12548
|
function zd() {
|
|
12540
12549
|
const t = () => {
|
|
12541
|
-
for (const r of Array.from(
|
|
12550
|
+
for (const r of Array.from(Ot))
|
|
12542
12551
|
r();
|
|
12543
12552
|
}, e = window.history.pushState.bind(window.history), s = window.history.replaceState.bind(window.history), n = ((...r) => {
|
|
12544
12553
|
const a = e(...r);
|
|
@@ -12570,11 +12579,11 @@ function Rn() {
|
|
|
12570
12579
|
${y}`).join(`
|
|
12571
12580
|
|
|
12572
12581
|
`).trim().slice(0, 12e3), c = Vd(i, r).trim(), d = `Simplified DOM outline:
|
|
12573
|
-
`,
|
|
12582
|
+
`, u = `
|
|
12574
12583
|
|
|
12575
12584
|
Visible page text:
|
|
12576
|
-
`,
|
|
12577
|
-
return `${d}${f}${
|
|
12585
|
+
`, l = 12e3 - d.length - u.length, h = Math.min(o.length, 7900), f = c.slice(0, l - h), m = o.slice(0, l - f.length);
|
|
12586
|
+
return `${d}${f}${u}${m}`;
|
|
12578
12587
|
}
|
|
12579
12588
|
function st(t) {
|
|
12580
12589
|
return t.innerText ?? t.textContent ?? "";
|
|
@@ -12680,7 +12689,7 @@ function Vd(t, e) {
|
|
|
12680
12689
|
"data-test",
|
|
12681
12690
|
"data-qa",
|
|
12682
12691
|
"data-cy"
|
|
12683
|
-
], d = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements:
|
|
12692
|
+
], d = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: l } = Kd(), h = new Set(t);
|
|
12684
12693
|
e && h.add(e);
|
|
12685
12694
|
let f = 0;
|
|
12686
12695
|
const m = (R) => {
|
|
@@ -12691,7 +12700,7 @@ function Vd(t, e) {
|
|
|
12691
12700
|
return `${R.tagName.toLowerCase()}|${m(R)}|${g}`;
|
|
12692
12701
|
}, y = (R, g, v) => {
|
|
12693
12702
|
const I = (w, A) => {
|
|
12694
|
-
const _ = w.tagName.toLowerCase(), T = window.getComputedStyle(w), E =
|
|
12703
|
+
const _ = w.tagName.toLowerCase(), T = window.getComputedStyle(w), E = u.has(w);
|
|
12695
12704
|
if (f >= 1e3 && !E || v.has(w) || r.has(_) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || T.display === "none" || T.visibility === "hidden")
|
|
12696
12705
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
12697
12706
|
f += 1;
|
|
@@ -12703,45 +12712,45 @@ function Vd(t, e) {
|
|
|
12703
12712
|
const H = /* @__PURE__ */ new Map(), $e = /* @__PURE__ */ new Map();
|
|
12704
12713
|
for (const D of O) {
|
|
12705
12714
|
const $ = p(D), ve = $e.get($) ?? 0;
|
|
12706
|
-
$e.set($, ve + 1), (U.get($) ?? 0) > 8 && ve >= 6 && !
|
|
12715
|
+
$e.set($, ve + 1), (U.get($) ?? 0) > 8 && ve >= 6 && !u.has(D) && H.set($, (H.get($) ?? 0) + 1);
|
|
12707
12716
|
}
|
|
12708
|
-
const at = /* @__PURE__ */ new Map(), Tn = /* @__PURE__ */ new Set(),
|
|
12717
|
+
const at = /* @__PURE__ */ new Map(), Tn = /* @__PURE__ */ new Set(), Jt = [], Cn = [];
|
|
12709
12718
|
for (const D of O) {
|
|
12710
12719
|
const $ = p(D), ve = U.get($) ?? 0, xn = at.get($) ?? 0;
|
|
12711
|
-
if (at.set($, xn + 1), ve > 8 && xn >= 6 && !
|
|
12712
|
-
Tn.has($) || (
|
|
12720
|
+
if (at.set($, xn + 1), ve > 8 && xn >= 6 && !u.has(D)) {
|
|
12721
|
+
Tn.has($) || (Jt.push([`… ${H.get($) ?? 0} similar siblings omitted`]), Tn.add($));
|
|
12713
12722
|
continue;
|
|
12714
12723
|
}
|
|
12715
12724
|
const Pn = I(D, A);
|
|
12716
|
-
Cn.push(Pn),
|
|
12725
|
+
Cn.push(Pn), Jt.push(Pn.lines);
|
|
12717
12726
|
}
|
|
12718
|
-
const
|
|
12727
|
+
const Qt = [];
|
|
12719
12728
|
if (w.shadowRoot)
|
|
12720
12729
|
for (const D of Array.from(w.shadowRoot.children))
|
|
12721
|
-
D instanceof HTMLElement &&
|
|
12722
|
-
const ct = [...Cn, ...
|
|
12730
|
+
D instanceof HTMLElement && Qt.push(I(D, A + 1));
|
|
12731
|
+
const ct = [...Cn, ...Qt], Xt = M.length > 0 || S || ct.some((D) => D.hasUsefulContent), Mn = Le(
|
|
12723
12732
|
[M, ...ct.map((D) => D.textPreview)].filter(Boolean).join(" ")
|
|
12724
|
-
).slice(0, 180), $r = w.hasAttribute("contenteditable") && (M.length > 0 || !w.querySelector("[contenteditable]")), On = d.some((D) => w.hasAttribute(D)) || !!C || $r,
|
|
12725
|
-
if (
|
|
12733
|
+
).slice(0, 180), $r = w.hasAttribute("contenteditable") && (M.length > 0 || !w.querySelector("[contenteditable]")), On = d.some((D) => w.hasAttribute(D)) || !!C || $r, Yt = (w.getClientRects().length > 0 || T.display === "contents") && (s.has(_) || On || E) && (Xt || E) && (!i.has(_) || Xt || On || E), Zt = Yt ? 1 : 0, ze = [];
|
|
12734
|
+
if (Yt) {
|
|
12726
12735
|
const D = ct.some((ve) => ve.containsTextElement), $ = n.has(_) && !D ? Mn : M;
|
|
12727
12736
|
ze.push(Rr(w, c, a, $.slice(0, 180)));
|
|
12728
12737
|
}
|
|
12729
|
-
for (const D of
|
|
12730
|
-
ze.push(...
|
|
12731
|
-
const
|
|
12732
|
-
if (
|
|
12733
|
-
const D =
|
|
12734
|
-
|
|
12738
|
+
for (const D of Jt)
|
|
12739
|
+
ze.push(...vt(D, Zt));
|
|
12740
|
+
const es = Qt.flatMap((D) => D.lines);
|
|
12741
|
+
if (es.length > 0) {
|
|
12742
|
+
const D = es.slice(0, 20);
|
|
12743
|
+
es.length > D.length && D.push("… shadow DOM omitted");
|
|
12735
12744
|
const $ = _.includes("tooltip") || _.includes("popper") || _.includes("loader");
|
|
12736
12745
|
if (A < 2 && !$) {
|
|
12737
|
-
const ve =
|
|
12738
|
-
ze.push(...
|
|
12746
|
+
const ve = Yt ? "#shadow-root" : `${_} #shadow-root`;
|
|
12747
|
+
ze.push(...vt([ve, ...vt(D, 1)], Zt));
|
|
12739
12748
|
} else
|
|
12740
|
-
ze.push(...
|
|
12749
|
+
ze.push(...vt(D, Zt));
|
|
12741
12750
|
}
|
|
12742
12751
|
return {
|
|
12743
12752
|
lines: ze,
|
|
12744
|
-
hasUsefulContent:
|
|
12753
|
+
hasUsefulContent: Xt,
|
|
12745
12754
|
textPreview: Mn,
|
|
12746
12755
|
containsTextElement: n.has(_) || ct.some((D) => D.containsTextElement)
|
|
12747
12756
|
};
|
|
@@ -12750,7 +12759,7 @@ function Vd(t, e) {
|
|
|
12750
12759
|
`);
|
|
12751
12760
|
}, b = [], k = Le(window.getSelection()?.toString() ?? "");
|
|
12752
12761
|
k && b.push(`--- selected text ---
|
|
12753
|
-
${JSON.stringify(k)}`),
|
|
12762
|
+
${JSON.stringify(k)}`), l.length > 0 && b.push(Wd(l, s, c, a));
|
|
12754
12763
|
for (const R of t.slice(0, 3))
|
|
12755
12764
|
b.push(y(R, "active overlay DOM", /* @__PURE__ */ new Set()));
|
|
12756
12765
|
if (e && b.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
|
|
@@ -12785,13 +12794,13 @@ function Kd() {
|
|
|
12785
12794
|
const d = window.getComputedStyle(o);
|
|
12786
12795
|
if (d.display === "none" || d.visibility === "hidden")
|
|
12787
12796
|
return;
|
|
12788
|
-
const
|
|
12789
|
-
|
|
12790
|
-
let
|
|
12791
|
-
for (;
|
|
12792
|
-
t.add(
|
|
12793
|
-
const h =
|
|
12794
|
-
|
|
12797
|
+
const u = e.get(o) ?? /* @__PURE__ */ new Set();
|
|
12798
|
+
u.add(c), e.set(o, u);
|
|
12799
|
+
let l = o;
|
|
12800
|
+
for (; l; ) {
|
|
12801
|
+
t.add(l);
|
|
12802
|
+
const h = l.getRootNode();
|
|
12803
|
+
l = l.parentElement ?? (h instanceof ShadowRoot && h.host instanceof HTMLElement ? h.host : null);
|
|
12795
12804
|
}
|
|
12796
12805
|
};
|
|
12797
12806
|
let n = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -12810,9 +12819,9 @@ function Kd() {
|
|
|
12810
12819
|
], a = [document];
|
|
12811
12820
|
for (let o = 0; o < a.length; o += 1) {
|
|
12812
12821
|
const c = a[o];
|
|
12813
|
-
for (const [d,
|
|
12814
|
-
for (const
|
|
12815
|
-
s(
|
|
12822
|
+
for (const [d, u] of r)
|
|
12823
|
+
for (const l of Array.from(c.querySelectorAll(d)))
|
|
12824
|
+
s(l, u);
|
|
12816
12825
|
for (const d of Array.from(c.querySelectorAll("*")))
|
|
12817
12826
|
d.shadowRoot && a.push(d.shadowRoot);
|
|
12818
12827
|
}
|
|
@@ -12827,16 +12836,16 @@ function Wd(t, e, s, n) {
|
|
|
12827
12836
|
const a = [];
|
|
12828
12837
|
let o = r.element;
|
|
12829
12838
|
for (; o; ) {
|
|
12830
|
-
const
|
|
12831
|
-
(o === r.element || e.has(
|
|
12832
|
-
const
|
|
12833
|
-
o = o.parentElement ?? (
|
|
12839
|
+
const u = o.tagName.toLowerCase();
|
|
12840
|
+
(o === r.element || e.has(u) || o.hasAttribute("id") || o.hasAttribute("role") || o.hasAttribute("aria-label")) && a.unshift(o);
|
|
12841
|
+
const l = o.getRootNode();
|
|
12842
|
+
o = o.parentElement ?? (l instanceof ShadowRoot && l.host instanceof HTMLElement ? l.host : null);
|
|
12834
12843
|
}
|
|
12835
|
-
const c = a.length > 6 ? [a[0], ...a.slice(-5)] : a, d = c.map((
|
|
12836
|
-
|
|
12844
|
+
const c = a.length > 6 ? [a[0], ...a.slice(-5)] : a, d = c.map((u, l) => Rr(
|
|
12845
|
+
u,
|
|
12837
12846
|
s,
|
|
12838
12847
|
n,
|
|
12839
|
-
|
|
12848
|
+
l === c.length - 1 ? Ar(u).slice(0, 180) : ""
|
|
12840
12849
|
));
|
|
12841
12850
|
a.length > c.length && d.splice(1, 0, "…"), i.push(`${r.labels.join(", ")}: ${d.join(" > ")}`);
|
|
12842
12851
|
}
|
|
@@ -12846,7 +12855,7 @@ function Wd(t, e, s, n) {
|
|
|
12846
12855
|
function Si(t) {
|
|
12847
12856
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
12848
12857
|
}
|
|
12849
|
-
function
|
|
12858
|
+
function vt(t, e) {
|
|
12850
12859
|
if (e === 0)
|
|
12851
12860
|
return t;
|
|
12852
12861
|
const s = " ".repeat(e);
|
|
@@ -13284,7 +13293,7 @@ function yl(t, e) {
|
|
|
13284
13293
|
function ot(t, e) {
|
|
13285
13294
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
13286
13295
|
}
|
|
13287
|
-
function
|
|
13296
|
+
function bt(t, e) {
|
|
13288
13297
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
13289
13298
|
}
|
|
13290
13299
|
function vl(t, e) {
|
|
@@ -13332,7 +13341,7 @@ function Re(t, e) {
|
|
|
13332
13341
|
}
|
|
13333
13342
|
function qr(t, e) {
|
|
13334
13343
|
try {
|
|
13335
|
-
const s = `${
|
|
13344
|
+
const s = `${Kt}${t}`, n = location.href, i = location.origin, r = Array.from(e, (a) => ({
|
|
13336
13345
|
...a,
|
|
13337
13346
|
storedAt: Date.now(),
|
|
13338
13347
|
unloadUrl: n,
|
|
@@ -13348,7 +13357,7 @@ function qr(t, e) {
|
|
|
13348
13357
|
}
|
|
13349
13358
|
function Ei(t, e) {
|
|
13350
13359
|
try {
|
|
13351
|
-
if (window.sessionStorage.getItem(`${
|
|
13360
|
+
if (window.sessionStorage.getItem(`${Kt}${t}`) === null)
|
|
13352
13361
|
return;
|
|
13353
13362
|
} catch {
|
|
13354
13363
|
return;
|
|
@@ -13357,7 +13366,7 @@ function Ei(t, e) {
|
|
|
13357
13366
|
}
|
|
13358
13367
|
function Il(t) {
|
|
13359
13368
|
try {
|
|
13360
|
-
const e = `${
|
|
13369
|
+
const e = `${Kt}${t}`, s = window.sessionStorage.getItem(e);
|
|
13361
13370
|
if (window.sessionStorage.removeItem(e), !s)
|
|
13362
13371
|
return [];
|
|
13363
13372
|
const n = JSON.parse(s);
|
|
@@ -13405,7 +13414,7 @@ function Sl(t, e) {
|
|
|
13405
13414
|
}
|
|
13406
13415
|
function kl(t) {
|
|
13407
13416
|
try {
|
|
13408
|
-
window.sessionStorage.removeItem(`${
|
|
13417
|
+
window.sessionStorage.removeItem(`${Kt}${t}`);
|
|
13409
13418
|
} catch {
|
|
13410
13419
|
return;
|
|
13411
13420
|
}
|
|
@@ -13520,7 +13529,7 @@ function xr(t) {
|
|
|
13520
13529
|
return e;
|
|
13521
13530
|
}
|
|
13522
13531
|
function qn(t, e) {
|
|
13523
|
-
return Lr(t) ?
|
|
13532
|
+
return Lr(t) ? Gt : ge(Lt(e), md);
|
|
13524
13533
|
}
|
|
13525
13534
|
function Ml(t, e) {
|
|
13526
13535
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
@@ -13555,9 +13564,9 @@ async function xl(t) {
|
|
|
13555
13564
|
const { done: c, value: d } = o;
|
|
13556
13565
|
if (c)
|
|
13557
13566
|
return ge(r + i.decode());
|
|
13558
|
-
const
|
|
13559
|
-
if (d.byteLength >
|
|
13560
|
-
return r += i.decode(d.subarray(0, Math.max(
|
|
13567
|
+
const u = Sn - a;
|
|
13568
|
+
if (d.byteLength > u)
|
|
13569
|
+
return r += i.decode(d.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${ge(r)}... [truncated]`;
|
|
13561
13570
|
a += d.byteLength, r += i.decode(d, { stream: !0 });
|
|
13562
13571
|
}
|
|
13563
13572
|
} catch {
|
|
@@ -13591,11 +13600,11 @@ function Ci(t) {
|
|
|
13591
13600
|
return t;
|
|
13592
13601
|
const e = t.trim();
|
|
13593
13602
|
if (!e.startsWith("{") && !e.startsWith("["))
|
|
13594
|
-
return
|
|
13603
|
+
return Lt(t);
|
|
13595
13604
|
try {
|
|
13596
13605
|
return JSON.stringify(ne(JSON.parse(t)));
|
|
13597
13606
|
} catch {
|
|
13598
|
-
return
|
|
13607
|
+
return Lt(t);
|
|
13599
13608
|
}
|
|
13600
13609
|
}
|
|
13601
13610
|
function Pr(t) {
|
|
@@ -13685,13 +13694,13 @@ function $l(t) {
|
|
|
13685
13694
|
function zl(t) {
|
|
13686
13695
|
return t === 401 || t === 403;
|
|
13687
13696
|
}
|
|
13688
|
-
const
|
|
13697
|
+
const Gt = "[REDACTED_SECRET]", me = "[REDACTED_TOKEN]", Hl = "[REDACTED_SIGNED_URL]", Vl = 20, Kl = /^(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, Ur = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Nr = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, jr = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Br = /\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, Wl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Gl = /\bhttps?:\/\/[^\s"'<>]+/gi, Jl = /[),.;\]]+$/;
|
|
13689
13698
|
function ne(t) {
|
|
13690
|
-
return
|
|
13699
|
+
return Bt(t, 0, /* @__PURE__ */ new WeakSet());
|
|
13691
13700
|
}
|
|
13692
|
-
function
|
|
13701
|
+
function Bt(t, e, s) {
|
|
13693
13702
|
if (typeof t == "string")
|
|
13694
|
-
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t :
|
|
13703
|
+
return t.startsWith("data:image/") || t.startsWith("data:application/pdf;") ? t : Lt(t);
|
|
13695
13704
|
if (t === null || typeof t != "object")
|
|
13696
13705
|
return t;
|
|
13697
13706
|
if (e >= Vl)
|
|
@@ -13699,10 +13708,10 @@ function jt(t, e, s) {
|
|
|
13699
13708
|
if (s.has(t))
|
|
13700
13709
|
return "[REDACTED_CIRCULAR]";
|
|
13701
13710
|
if (s.add(t), Array.isArray(t))
|
|
13702
|
-
return t.map((i) =>
|
|
13711
|
+
return t.map((i) => Bt(i, e + 1, s));
|
|
13703
13712
|
const n = {};
|
|
13704
13713
|
for (const [i, r] of Object.entries(t))
|
|
13705
|
-
i === "pageContent" ? n[i] = r : Lr(i) ? n[i] =
|
|
13714
|
+
i === "pageContent" ? n[i] = r : Lr(i) ? n[i] = Gt : n[i] = i.toLowerCase() === "url" ? Ql(r) : Bt(r, e + 1, s);
|
|
13706
13715
|
return n;
|
|
13707
13716
|
}
|
|
13708
13717
|
function Lr(t) {
|
|
@@ -13710,7 +13719,7 @@ function Lr(t) {
|
|
|
13710
13719
|
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");
|
|
13711
13720
|
}
|
|
13712
13721
|
function Ql(t) {
|
|
13713
|
-
return typeof t == "string" ? Fr(t) :
|
|
13722
|
+
return typeof t == "string" ? Fr(t) : Bt(t, 0, /* @__PURE__ */ new WeakSet());
|
|
13714
13723
|
}
|
|
13715
13724
|
function Fr(t) {
|
|
13716
13725
|
try {
|
|
@@ -13722,21 +13731,21 @@ function Fr(t) {
|
|
|
13722
13731
|
return Xl(t);
|
|
13723
13732
|
}
|
|
13724
13733
|
}
|
|
13725
|
-
function
|
|
13726
|
-
return t.replace(Wl, Hl).replace(Gl, Yl).replace(Ur, `Bearer ${me}`).replace(Nr, `Basic ${me}`).replace(jr, me).replace(Br, (e, s) => `${s}: ${
|
|
13734
|
+
function Lt(t) {
|
|
13735
|
+
return t.replace(Wl, Hl).replace(Gl, Yl).replace(Ur, `Bearer ${me}`).replace(Nr, `Basic ${me}`).replace(jr, me).replace(Br, (e, s) => `${s}: ${Gt}`);
|
|
13727
13736
|
}
|
|
13728
13737
|
function Xl(t) {
|
|
13729
|
-
return t.replace(Ur, `Bearer ${me}`).replace(Nr, `Basic ${me}`).replace(jr, me).replace(Br, (e, s) => `${s}: ${
|
|
13738
|
+
return t.replace(Ur, `Bearer ${me}`).replace(Nr, `Basic ${me}`).replace(jr, me).replace(Br, (e, s) => `${s}: ${Gt}`);
|
|
13730
13739
|
}
|
|
13731
13740
|
function Yl(t) {
|
|
13732
13741
|
const e = t.match(Jl)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|
|
13733
13742
|
return `${Fr(s)}${e}`;
|
|
13734
13743
|
}
|
|
13735
13744
|
const pu = Object.freeze({
|
|
13736
|
-
init: (t) =>
|
|
13745
|
+
init: (t) => Wt.init(t)
|
|
13737
13746
|
});
|
|
13738
13747
|
function fu(t) {
|
|
13739
|
-
return
|
|
13748
|
+
return Wt.init(t);
|
|
13740
13749
|
}
|
|
13741
13750
|
export {
|
|
13742
13751
|
yi as PLUNO_PRODUCT_AGENT_WIDGET_HOST_SELECTOR,
|
|
@@ -13749,14 +13758,14 @@ export {
|
|
|
13749
13758
|
iu as ProductAgentInteractionManager,
|
|
13750
13759
|
ti as ProductAgentQueryController,
|
|
13751
13760
|
du as ProductAgentRemoteRuntimeClient,
|
|
13752
|
-
|
|
13761
|
+
Wt as ProductAgentSessionEngine,
|
|
13753
13762
|
nu as ProductAgentSessionHistoryManager,
|
|
13754
13763
|
ou as ProductAgentTaskPageTitleController,
|
|
13755
13764
|
ue as ProductAgentTokenProviderError,
|
|
13756
13765
|
Id as calculateReconnectDelay,
|
|
13757
13766
|
tu as canSubmitPersonalProductAgentMessage,
|
|
13758
13767
|
ru as createLocalStorageInteractionDecisionStorage,
|
|
13759
|
-
|
|
13768
|
+
Tt as createProductAgentQueryState,
|
|
13760
13769
|
fu as createProductAgentRuntime,
|
|
13761
13770
|
au as createProductAgentTaskPageTitleDocument,
|
|
13762
13771
|
pu as default,
|
|
@@ -13765,7 +13774,7 @@ export {
|
|
|
13765
13774
|
si as isProductAgentAuthReconnectError,
|
|
13766
13775
|
cu as isProductAgentRuntimeCommand,
|
|
13767
13776
|
Fa as mergeProductAgentEntityPages,
|
|
13768
|
-
|
|
13777
|
+
Ct as normalizeProductAgentEntityPage,
|
|
13769
13778
|
hu as normalizeProductAgentSessionItems,
|
|
13770
13779
|
Vc as readLocalStorageInteractionDecisions,
|
|
13771
13780
|
su as resolveProductAgentComposerAction,
|