@pluno/product-agent-web 0.1.302 → 0.1.304
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 +1 -1
- package/dist/product-agent-sdk.js +528 -527
- package/dist/product-agent-widget.js +175 -174
- package/package.json +1 -1
|
@@ -42,20 +42,20 @@ function is(t, e, s, n) {
|
|
|
42
42
|
if (!o) continue;
|
|
43
43
|
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: {} };
|
|
44
44
|
if (h.awaitingBaseline && c?.execution) {
|
|
45
|
-
const m = d.filter((
|
|
46
|
-
const y = e.submissions[
|
|
45
|
+
const m = d.filter((f) => {
|
|
46
|
+
const y = e.submissions[f];
|
|
47
47
|
return y?.conversationScopeId === a && y.submittedAt >= h.openedAt;
|
|
48
48
|
});
|
|
49
|
-
h.awaitingBaseline = !1, h.ignoredTurns = d.filter((
|
|
49
|
+
h.awaitingBaseline = !1, h.ignoredTurns = d.filter((f) => !m.includes(f));
|
|
50
50
|
}
|
|
51
|
-
const
|
|
52
|
-
for (const [m,
|
|
53
|
-
const y = u && d.includes(m), b = y && !
|
|
54
|
-
|
|
51
|
+
const p = {};
|
|
52
|
+
for (const [m, f] of Object.entries(h.turns)) {
|
|
53
|
+
const y = u && d.includes(m), b = y && !f.active ? n : f.startedAt;
|
|
54
|
+
p[m] = { ...f, startedAt: b, active: y, notifications: !f.notificationsSuppressed && (f.notifications || y && n - b >= 1e4) };
|
|
55
55
|
}
|
|
56
56
|
if (u)
|
|
57
|
-
for (const m of d) !h.ignoredTurns.includes(m) && !
|
|
58
|
-
i[a] = { ...h, turns:
|
|
57
|
+
for (const m of d) !h.ignoredTurns.includes(m) && !p[m] && (p[m] = { startedAt: n, active: !0, notifications: !1, tab_grouping: (t.interactions.crossTabTurns[o.sessionId] ?? []).includes(m) });
|
|
58
|
+
i[a] = { ...h, turns: p };
|
|
59
59
|
}
|
|
60
60
|
return { ...t, interactions: { ...t.interactions, openings: i, openingGeneration: r } };
|
|
61
61
|
}
|
|
@@ -249,7 +249,7 @@ function fe(t) {
|
|
|
249
249
|
function Dt(t) {
|
|
250
250
|
return "revision" in t.data ? t.data.revision : null;
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function ve(t) {
|
|
253
253
|
return {
|
|
254
254
|
key: t,
|
|
255
255
|
status: "not_requested",
|
|
@@ -315,7 +315,7 @@ function Bs(t) {
|
|
|
315
315
|
executionByUserMessage: {},
|
|
316
316
|
followUps: [],
|
|
317
317
|
followUpsVersion: -1,
|
|
318
|
-
queries: { current:
|
|
318
|
+
queries: { current: ve(`${t}:current`), history: ve(`${t}:history`) }
|
|
319
319
|
};
|
|
320
320
|
}
|
|
321
321
|
function ji(t) {
|
|
@@ -326,7 +326,7 @@ function Yr(t, e) {
|
|
|
326
326
|
const s = t?.executionByUserMessage[e]?.responseMessageIds, n = s?.indexOf(e) ?? -1;
|
|
327
327
|
return s && n >= 0 ? s.slice(0, n + 1) : [e];
|
|
328
328
|
}
|
|
329
|
-
function
|
|
329
|
+
function ge(t, e, s) {
|
|
330
330
|
const n = t.submissionOrder.map((S) => t.submissions[S]).filter((S) => S.conversationScopeId === s), i = e.selections[s]?.sessionId ?? n.find((S) => !S.cancelled && S.sessionId !== null)?.sessionId ?? null, r = i ? t.sessions[i] : void 0, a = t.submissionOrder.map((S) => t.submissions[S]).filter((S) => i ? S.sessionId === i || S.sessionId === null && S.conversationScopeId === s : S.conversationScopeId === s), o = Object.values(r?.items ?? {}).sort((S, O) => {
|
|
331
331
|
const U = fe(S.created_at), H = fe(O.created_at);
|
|
332
332
|
return U < H ? -1 : U > H ? 1 : S.id < O.id ? -1 : S.id > O.id ? 1 : 0;
|
|
@@ -359,14 +359,14 @@ function Ie(t, e, s) {
|
|
|
359
359
|
collapsed: !1
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
|
-
const l = r?.execution, h = a.filter((S) => !S.cancelled && S.delivery !== "failed"),
|
|
362
|
+
const l = r?.execution, h = a.filter((S) => !S.cancelled && S.delivery !== "failed"), p = h.filter((S) => S.delivery !== "accepted" && S.executionVersion === null), m = h.filter((S) => S.delivery === "accepted" && S.executionVersion === null), f = h[h.length - 1], y = p.length > 0, b = f !== void 0 && m.includes(f);
|
|
363
363
|
let k = y ? "submitting" : b ? "awaiting_execution" : l?.phase ?? "idle";
|
|
364
364
|
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));
|
|
365
365
|
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");
|
|
366
366
|
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) => {
|
|
367
367
|
const O = a.find((H) => H.userMessageId === S);
|
|
368
368
|
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)));
|
|
369
|
-
}), _ = l?.user_message_ids ?? [], q = y || b ?
|
|
369
|
+
}), _ = l?.user_message_ids ?? [], q = y || b ? f?.userMessageId ?? null : _[_.length - 1] ?? null, E = u.find((S) => S.userMessageId === q), 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.
|
|
370
370
|
(!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);
|
|
371
371
|
return G({
|
|
372
372
|
historyRefreshFailure: r?.historyRefreshFailure ?? null,
|
|
@@ -407,7 +407,7 @@ function Bi(t, e) {
|
|
|
407
407
|
return t.sessionId && a ? { type: "execution", userMessageId: a, sessionId: t.sessionId } : null;
|
|
408
408
|
}
|
|
409
409
|
function Zr(t, e) {
|
|
410
|
-
return G({ scopes: Object.fromEntries([...new Set(Object.values(e.clients))].map((s) => [s,
|
|
410
|
+
return G({ scopes: Object.fromEntries([...new Set(Object.values(e.clients))].map((s) => [s, ge(t, e, s)])) });
|
|
411
411
|
}
|
|
412
412
|
function Li(t, e) {
|
|
413
413
|
if (!e) return !1;
|
|
@@ -453,7 +453,7 @@ function eo(t, e, s) {
|
|
|
453
453
|
const n = t.account.authority;
|
|
454
454
|
if (!n) return [];
|
|
455
455
|
const i = X(n.profile, "canShowPersonalFeatures"), r = [], a = t.features.now, o = (c) => {
|
|
456
|
-
const d = Object.values(t.features.pending).filter((
|
|
456
|
+
const d = Object.values(t.features.pending).filter((p) => p.mode === "mutation" && c.includes(p.key)), u = d.some((p) => p.status === "pending"), l = d[d.length - 1], h = l?.status === "error" ? l.error : null;
|
|
457
457
|
return { status: u ? "pending" : h ? "error" : "presentable", error: h };
|
|
458
458
|
};
|
|
459
459
|
if (n.profile === "main_web_chat") for (const [c, d] of Object.entries(t.interactions.deviceHints)) {
|
|
@@ -481,9 +481,9 @@ function eo(t, e, s) {
|
|
|
481
481
|
if (!X(n.profile, d)) continue;
|
|
482
482
|
const u = s.conversationScopeId ? t.interactions.openings[s.conversationScopeId] : void 0;
|
|
483
483
|
if (!s.sessionId || !u || u.sessionId !== s.sessionId || !Pi(t, s.conversationScopeId, c) || t.features.refreshRequired && !u.shown[c] || n.profile === "main_web_chat" && !t.interactions.bridgeReady && !u.shown[c]) continue;
|
|
484
|
-
const l = _t(t, c), h = t.interactions.preferencePrompts[c],
|
|
485
|
-
if (l === !1 || t.features.desiredPreferences[c] === !1 || l === !0 && ["granted", "unknown"].includes(
|
|
486
|
-
const
|
|
484
|
+
const l = _t(t, c), h = t.interactions.preferencePrompts[c], p = t.interactions.deviceFacts[c], m = `preference:${c}`;
|
|
485
|
+
if (l === !1 || t.features.desiredPreferences[c] === !1 || l === !0 && ["granted", "unknown"].includes(p.permission) || p.permission === "unsupported" || h.snoozedUntil && Date.parse(h.snoozedUntil) > a || p.snoozedUntil && Date.parse(p.snoozedUntil) > a) continue;
|
|
486
|
+
const f = p.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);
|
|
487
487
|
r.push({
|
|
488
488
|
id: m,
|
|
489
489
|
category: "preference",
|
|
@@ -494,10 +494,10 @@ function eo(t, e, s) {
|
|
|
494
494
|
sourceVersion: u.generation,
|
|
495
495
|
decisionRevision: h.revision,
|
|
496
496
|
actions: ["enable", "not_now", "dont_enable"],
|
|
497
|
-
status:
|
|
497
|
+
status: f ? "pending" : b ? "error" : y.status,
|
|
498
498
|
error: b,
|
|
499
499
|
payload: { feature: c, openingGeneration: u.generation },
|
|
500
|
-
nextEligibleAt: h.snoozedUntil ??
|
|
500
|
+
nextEligibleAt: h.snoozedUntil ?? p.snoozedUntil
|
|
501
501
|
});
|
|
502
502
|
}
|
|
503
503
|
for (const c of Object.values(t.interactions.sources)) {
|
|
@@ -510,7 +510,7 @@ function eo(t, e, s) {
|
|
|
510
510
|
if (d.wait_for_terminal && (!m || !Li(m, c.user_message_id)) || (n.profile.startsWith("extension_") ? t.interactions.localSharing[c.id]?.resolved : Ln(t.interactions.decisions[`prompt:social_share:${c.id}`], a))) continue;
|
|
511
511
|
}
|
|
512
512
|
if (d.kind === "integration_auth" && !X(n.profile, "canManageIntegrationAuth") || d.kind === "personal_channel" && !i) continue;
|
|
513
|
-
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],
|
|
513
|
+
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], p = 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];
|
|
514
514
|
r.push({
|
|
515
515
|
id: c.id,
|
|
516
516
|
category: d.kind,
|
|
@@ -521,9 +521,9 @@ function eo(t, e, s) {
|
|
|
521
521
|
sourceVersion: c.version,
|
|
522
522
|
decisionRevision: n.profile.startsWith("extension_") ? h?.revision ?? 0 : l?.revision ?? 0,
|
|
523
523
|
actions: d.kind === "sharing" ? ["copy", "share", "dismiss"] : d.kind === "integration_auth" ? ["connect"] : ["pair"],
|
|
524
|
-
...d.kind === "integration_auth" ? { actionLabels: { connect:
|
|
524
|
+
...d.kind === "integration_auth" ? { actionLabels: { connect: p?.status === "error" ? "Try again" : u === "pending" ? "Connect" : "Reconnect" } } : {},
|
|
525
525
|
...o([`prompt:social_share:${c.id}`]),
|
|
526
|
-
...
|
|
526
|
+
...p?.status === "pending" || p?.status === "error" ? { status: p.status, error: p.error } : {},
|
|
527
527
|
payload: d.kind === "integration_auth" ? { ...d, lifecycle: u } : d,
|
|
528
528
|
nextEligibleAt: null
|
|
529
529
|
});
|
|
@@ -532,7 +532,7 @@ function eo(t, e, s) {
|
|
|
532
532
|
for (const c of Object.values(t.interactions.welcome)) {
|
|
533
533
|
const d = c.category === "morning_report" ? "canManageMorningReport" : "canManageProactiveSuggestions", u = c.category === "morning_report" ? "category:morning_report" : `prompt:proactive_suggestion:${c.sourceSuggestionId ?? c.id}`;
|
|
534
534
|
if (c.clientScopeId && c.clientScopeId !== s.clientScopeId || !c.eligible || c.expiresAt !== void 0 && c.expiresAt <= a || !X(n.profile, d) || Ln(t.interactions.decisions[u], a)) continue;
|
|
535
|
-
const l = o([u]), h = $i(t, c.id, s),
|
|
535
|
+
const l = o([u]), h = $i(t, c.id, s), p = l.status === "pending" || h?.status === "pending" ? "pending" : l.error || h?.status === "error" ? "error" : "presentable";
|
|
536
536
|
r.push({
|
|
537
537
|
id: c.id,
|
|
538
538
|
category: c.category,
|
|
@@ -543,7 +543,7 @@ function eo(t, e, s) {
|
|
|
543
543
|
sourceVersion: null,
|
|
544
544
|
decisionRevision: t.interactions.decisions[u]?.revision ?? 0,
|
|
545
545
|
actions: c.category === "morning_report" ? ["run", "snooze"] : ["run", "edit", "not_now", "never", "feedback"],
|
|
546
|
-
status:
|
|
546
|
+
status: p,
|
|
547
547
|
error: l.error ?? (h?.status === "error" ? h.error : null),
|
|
548
548
|
payload: { text: c.text, tasks: c.tasks, sourceSuggestionId: c.sourceSuggestionId ?? c.id },
|
|
549
549
|
nextEligibleAt: t.interactions.decisions[u]?.nextEligibleAt ?? null
|
|
@@ -567,13 +567,13 @@ function to(t, e, s, n) {
|
|
|
567
567
|
if (e.type === "stage7.act") {
|
|
568
568
|
const u = i.interactions.actions[e.requestId];
|
|
569
569
|
if (u) {
|
|
570
|
-
const
|
|
570
|
+
const f = i.interactions.welcome[e.interactionId], y = f?.category === "morning_report" ? f.tasks[e.taskIndex ?? 0] : f?.text;
|
|
571
571
|
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.");
|
|
572
572
|
return { state: i, effects: r, command: null };
|
|
573
573
|
}
|
|
574
574
|
if (e.action === "feedback") {
|
|
575
|
-
const
|
|
576
|
-
if (!
|
|
575
|
+
const f = i.interactions.welcome[e.interactionId];
|
|
576
|
+
if (!f || f.category !== "proactive_suggestion" || !e.feedback || f.clientScopeId && f.clientScopeId !== e.clientScopeId) throw new Error("Missing proactive feedback.");
|
|
577
577
|
return { state: i, effects: r, command: {
|
|
578
578
|
type: "stage7.mutate",
|
|
579
579
|
authority: a,
|
|
@@ -581,30 +581,30 @@ function to(t, e, s, n) {
|
|
|
581
581
|
requestId: e.requestId,
|
|
582
582
|
mutation: {
|
|
583
583
|
kind: "proactiveFeedback",
|
|
584
|
-
suggestionId:
|
|
585
|
-
suggestedQuery:
|
|
584
|
+
suggestionId: f.sourceSuggestionId ?? f.id,
|
|
585
|
+
suggestedQuery: f.text,
|
|
586
586
|
message: e.feedback.message,
|
|
587
587
|
context: e.feedback.context
|
|
588
588
|
}
|
|
589
589
|
} };
|
|
590
590
|
}
|
|
591
|
-
const l = zi(i, s, n, e.clientScopeId).find((
|
|
591
|
+
const l = zi(i, s, n, e.clientScopeId).find((f) => f.id === e.interactionId);
|
|
592
592
|
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.");
|
|
593
593
|
if (l.category === "preference" || l.category === "permission") {
|
|
594
|
-
const
|
|
595
|
-
if (
|
|
596
|
-
if (i = { ...i, interactions: { ...i.interactions, promptActions: { ...i.interactions.promptActions, [e.requestId]: { scope: n.clients[e.clientScopeId], openingGeneration: l.sourceVersion, expectedRevision: e.expectedRevision, feature:
|
|
597
|
-
const y = e.action === "not_now" ? { kind: "preferenceSnooze", feature:
|
|
594
|
+
const f = l.payload.feature;
|
|
595
|
+
if (f !== "notifications" && f !== "tab_grouping") throw new Error("Missing preference feature.");
|
|
596
|
+
if (i = { ...i, interactions: { ...i.interactions, promptActions: { ...i.interactions.promptActions, [e.requestId]: { scope: n.clients[e.clientScopeId], openingGeneration: l.sourceVersion, expectedRevision: e.expectedRevision, feature: f, 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: f, action: e.action === "enable" ? "allow" : e.action, settings: !1 } };
|
|
597
|
+
const y = e.action === "not_now" ? { kind: "preferenceSnooze", feature: f, expectedRevision: e.expectedRevision } : { kind: "preference", feature: f, enabled: !1 };
|
|
598
598
|
return { state: i, effects: r, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: y } };
|
|
599
599
|
}
|
|
600
600
|
if (["not_now", "never", "snooze"].includes(e.action)) {
|
|
601
|
-
const
|
|
602
|
-
return { state: i, effects: r, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation:
|
|
601
|
+
const f = 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 };
|
|
602
|
+
return { state: i, effects: r, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: f } };
|
|
603
603
|
}
|
|
604
|
-
const h = Object.values(i.interactions.sources).find((
|
|
605
|
-
let
|
|
604
|
+
const h = Object.values(i.interactions.sources).find((f) => f.id === l.sourceId && f.conversation_id === l.conversationId);
|
|
605
|
+
let p;
|
|
606
606
|
if (l.category === "device_hint")
|
|
607
|
-
|
|
607
|
+
p = { kind: "saveHint", interactionId: l.id };
|
|
608
608
|
else if (e.action === "dismiss") {
|
|
609
609
|
if (!a.profile.startsWith("extension_")) return { state: i, effects: r, command: {
|
|
610
610
|
type: "stage7.mutate",
|
|
@@ -613,21 +613,21 @@ function to(t, e, s, n) {
|
|
|
613
613
|
requestId: e.requestId,
|
|
614
614
|
mutation: { kind: "decision", category: "social_share", promptKey: l.id, action: "dismiss", expectedRevision: e.expectedRevision }
|
|
615
615
|
} };
|
|
616
|
-
|
|
616
|
+
p = { kind: "saveSharing", interactionId: l.id, expectedRevision: e.expectedRevision };
|
|
617
617
|
} else if (e.action === "copy" || e.action === "share") {
|
|
618
618
|
if (h?.payload.kind !== "sharing") throw new Error("Missing sharing source.");
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
|
|
619
|
+
const f = 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"));
|
|
620
|
+
if (f && f.error?.code !== "interaction_not_started") throw new Error("The previous sharing action has an uncertain outcome.");
|
|
621
|
+
p = { kind: e.action, interactionId: l.id, variant: h.payload.variant, ...e.sharePlatform ? { platform: e.sharePlatform } : {} };
|
|
622
622
|
} else if (e.action === "connect") {
|
|
623
623
|
if (h?.payload.kind !== "integration_auth") throw new Error("Missing integration request.");
|
|
624
|
-
|
|
624
|
+
p = { kind: "connect", interactionId: l.id, authRequestId: h.payload.request_id, source: h };
|
|
625
625
|
} else if (e.action === "pair") {
|
|
626
626
|
if (h?.payload.kind !== "personal_channel") throw new Error("Missing channel request.");
|
|
627
|
-
|
|
627
|
+
p = { kind: "pair", interactionId: l.id, requestId: h.payload.request_id, managementUrl: h.payload.management_url };
|
|
628
628
|
} else {
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
629
|
+
const f = $i(i, l.id, { clientScopeId: e.clientScopeId, conversationScopeId: n.clients[e.clientScopeId] });
|
|
630
|
+
if (f?.status === "error" && f.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
|
|
631
631
|
if (e.action !== "edit") {
|
|
632
632
|
if (a.profile.startsWith("extension_") && !e.origin) throw new Error("Task submission requires the current page origin.");
|
|
633
633
|
const k = Ui(i.account, "send_message", e.origin ?? null);
|
|
@@ -635,7 +635,7 @@ function to(t, e, s, n) {
|
|
|
635
635
|
}
|
|
636
636
|
const y = i.interactions.welcome[l.id], b = y.category === "morning_report" ? y.tasks[e.taskIndex ?? 0] : y.text;
|
|
637
637
|
if (!b) throw new Error("Missing selected task.");
|
|
638
|
-
|
|
638
|
+
p = {
|
|
639
639
|
kind: e.action === "edit" ? "edit" : "run",
|
|
640
640
|
interactionId: l.id,
|
|
641
641
|
text: b,
|
|
@@ -645,7 +645,7 @@ function to(t, e, s, n) {
|
|
|
645
645
|
...e.requestedModel !== void 0 ? { requestedModel: e.requestedModel } : {}
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
|
-
const m =
|
|
648
|
+
const m = p.kind === "saveSharing" || p.kind === "saveHint" ? "persist" : "perform";
|
|
649
649
|
c(e.requestId, {
|
|
650
650
|
interactionId: l.id,
|
|
651
651
|
clientScopeId: e.clientScopeId,
|
|
@@ -654,11 +654,11 @@ function to(t, e, s, n) {
|
|
|
654
654
|
action: e.action,
|
|
655
655
|
expectedRevision: e.expectedRevision,
|
|
656
656
|
sourceVersion: e.sourceVersion ?? null,
|
|
657
|
-
operation:
|
|
657
|
+
operation: p,
|
|
658
658
|
step: m,
|
|
659
659
|
status: "pending",
|
|
660
660
|
error: null
|
|
661
|
-
}), d(e.requestId,
|
|
661
|
+
}), d(e.requestId, p, m);
|
|
662
662
|
} else if (e.type === "stage7.retry_action") {
|
|
663
663
|
const u = i.interactions.actions[e.requestId];
|
|
664
664
|
if (!u || u.step !== "persist" || u.status !== "error") throw new Error("An uncertain browser action cannot be replayed.");
|
|
@@ -666,7 +666,7 @@ function to(t, e, s, n) {
|
|
|
666
666
|
return { state: i, effects: r, command: { type: "stage7.retry", authority: a, now: e.now, requestId: `sharing:${e.requestId}` } };
|
|
667
667
|
d(e.requestId, u.operation, "persist");
|
|
668
668
|
} else {
|
|
669
|
-
const u = Object.entries(i.interactions.actions).find(([
|
|
669
|
+
const u = Object.entries(i.interactions.actions).find(([p, m]) => o(p, m.step) === e.effectId && m.status === "pending");
|
|
670
670
|
if (!u) return { state: i, effects: r, command: null };
|
|
671
671
|
const [l, h] = u;
|
|
672
672
|
if (e.type === "effect.failed") c(l, { ...h, status: "error", error: e.error });
|
|
@@ -679,8 +679,8 @@ function to(t, e, s, n) {
|
|
|
679
679
|
requestId: `sharing:${l}`,
|
|
680
680
|
mutation: { kind: "decision", category: "social_share", promptKey: h.interactionId, action: "shared", expectedRevision: h.expectedRevision }
|
|
681
681
|
} };
|
|
682
|
-
const
|
|
683
|
-
c(l, { ...h, operation:
|
|
682
|
+
const p = { kind: "saveSharing", interactionId: h.interactionId, expectedRevision: h.expectedRevision };
|
|
683
|
+
c(l, { ...h, operation: p, step: "persist" }), d(l, p, "persist");
|
|
684
684
|
} else
|
|
685
685
|
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: {
|
|
686
686
|
...i.interactions.localSharing,
|
|
@@ -697,21 +697,21 @@ function so(t, e, s, n) {
|
|
|
697
697
|
let i = t;
|
|
698
698
|
const r = [], a = (l) => {
|
|
699
699
|
i = { ...i, ...l };
|
|
700
|
-
}, o = (l, h,
|
|
700
|
+
}, o = (l, h, p) => JSON.stringify(["stage7", e.authorityId, e.generation, l, h, ...p === void 0 ? [] : [p]]), c = (l, h) => Hi(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) => {
|
|
701
701
|
const h = i.pending[l];
|
|
702
702
|
a({ pending: { ...i.pending, [l]: { ...h, status: "pending" } } }), r.push({ kind: "stage7.query", id: l, input: { authority: e, requestId: h.requestId, query: h.operation } });
|
|
703
703
|
};
|
|
704
704
|
if (s.type === "stage7.query" && s.query.kind === "appearance") {
|
|
705
705
|
const l = { ...s.query, kind: "appearance" }, h = n(l);
|
|
706
|
-
if (Object.values(i.pending).some((
|
|
707
|
-
const
|
|
706
|
+
if (Object.values(i.pending).some((f) => f.mode === "query" && f.key === h)) return { state: i, effects: r };
|
|
707
|
+
const p = o("query", s.requestId, i.appearanceEpochs[l.origin] ?? 0), m = i.pending[p];
|
|
708
708
|
if (m && m.fingerprint !== JSON.stringify(l)) throw new Error("Query request ID changed payload.");
|
|
709
709
|
a({
|
|
710
710
|
appearanceQueries: { ...i.appearanceQueries, [h]: l },
|
|
711
|
-
queries: { ...i.queries, [h]: Ne(i.queries[h] ??
|
|
712
|
-
pending: { ...i.pending, [
|
|
711
|
+
queries: { ...i.queries, [h]: Ne(i.queries[h] ?? ve(h), { key: h, requestId: oe(s.requestId), mode: "replace" }) },
|
|
712
|
+
pending: { ...i.pending, [p]: {
|
|
713
713
|
requestId: s.requestId,
|
|
714
|
-
effectId:
|
|
714
|
+
effectId: p,
|
|
715
715
|
fingerprint: JSON.stringify(l),
|
|
716
716
|
key: h,
|
|
717
717
|
generation: e.generation,
|
|
@@ -721,11 +721,11 @@ function so(t, e, s, n) {
|
|
|
721
721
|
error: null,
|
|
722
722
|
result: null
|
|
723
723
|
} }
|
|
724
|
-
}), d(l.origin) || u(
|
|
724
|
+
}), d(l.origin) || u(p);
|
|
725
725
|
} else if (s.type === "stage7.mutate" && (s.mutation.kind === "sampleStyle" || s.mutation.kind === "saveStyle" || s.mutation.kind === "scribble" || s.mutation.kind === "deleteStyle")) {
|
|
726
|
-
const l = s.mutation, h = l.origin,
|
|
726
|
+
const l = s.mutation, h = l.origin, p = o("mutate", s.requestId), m = i.pending[p], f = JSON.stringify(l);
|
|
727
727
|
if (m) {
|
|
728
|
-
if (m.fingerprint !==
|
|
728
|
+
if (m.fingerprint !== f) throw new Error("Request ID was reused with a different payload.");
|
|
729
729
|
return { state: i, effects: r };
|
|
730
730
|
}
|
|
731
731
|
const y = d(h), b = (i.appearanceEpochs[h] ?? 0) + 1, k = { ...i.pending };
|
|
@@ -735,10 +735,10 @@ function so(t, e, s, n) {
|
|
|
735
735
|
const v = o("query", g.requestId, b);
|
|
736
736
|
k[v] = { ...g, effectId: v, status: "queued" };
|
|
737
737
|
}
|
|
738
|
-
k[
|
|
738
|
+
k[p] = {
|
|
739
739
|
requestId: s.requestId,
|
|
740
|
-
effectId:
|
|
741
|
-
fingerprint:
|
|
740
|
+
effectId: p,
|
|
741
|
+
fingerprint: f,
|
|
742
742
|
key: `appearance:${h}`,
|
|
743
743
|
generation: e.generation,
|
|
744
744
|
operation: l,
|
|
@@ -747,26 +747,26 @@ function so(t, e, s, n) {
|
|
|
747
747
|
status: y ? "queued" : "pending",
|
|
748
748
|
error: null,
|
|
749
749
|
result: null
|
|
750
|
-
}, a({ pending: k, appearanceEpochs: { ...i.appearanceEpochs, [h]: b } }), y || r.push({ kind: "stage7.mutate", id:
|
|
750
|
+
}, a({ pending: k, appearanceEpochs: { ...i.appearanceEpochs, [h]: b } }), y || r.push({ kind: "stage7.mutate", id: p, input: { authority: e, requestId: s.requestId, mutation: l } });
|
|
751
751
|
} else if (s.type === "effect.completed" || s.type === "effect.failed") {
|
|
752
752
|
const l = i.pending[s.effectId];
|
|
753
753
|
if (!l || l.status !== "pending" || !("origin" in l.operation)) return { state: i, effects: r };
|
|
754
754
|
const h = l.operation.origin;
|
|
755
755
|
if (s.effectKind !== "stage7.query" && s.effectKind !== "stage7.mutate") return { state: i, effects: r };
|
|
756
|
-
const
|
|
757
|
-
if (
|
|
758
|
-
const m = { ...i.pending },
|
|
756
|
+
const p = s.type === "effect.completed" ? s.output.data : null;
|
|
757
|
+
if (p && (p.kind !== "appearance" || p.origin !== h)) throw new Error("Appearance response does not match its origin.");
|
|
758
|
+
const m = { ...i.pending }, f = { ...i.queries };
|
|
759
759
|
if (l.mode === "query") {
|
|
760
760
|
delete m[s.effectId];
|
|
761
|
-
const y =
|
|
762
|
-
y?.requestId === l.requestId && (
|
|
763
|
-
} else if (m[s.effectId] = { ...l, status:
|
|
761
|
+
const y = f[l.key];
|
|
762
|
+
y?.requestId === l.requestId && (f[l.key] = s.type === "effect.failed" ? { ...y, status: "error", error: s.error, requestId: null } : { ...y, status: "ready", data: p, error: null, requestId: null, updatedAt: s.output.completedAt });
|
|
763
|
+
} else if (m[s.effectId] = { ...l, status: p ? "done" : "error", result: p, error: s.type === "effect.failed" ? s.error : null }, p && s.type === "effect.completed") {
|
|
764
764
|
for (const [y, b] of Object.entries(i.appearanceQueries))
|
|
765
|
-
b.origin === h && (
|
|
765
|
+
b.origin === h && (f[y] = { ...f[y], status: "ready", data: p, requestId: null, error: null, updatedAt: s.output.completedAt });
|
|
766
766
|
for (const [y, b] of Object.entries(m)) b.mode === "query" && c(b.operation, h) && delete m[y];
|
|
767
767
|
} else if (s.type === "effect.failed")
|
|
768
768
|
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 } });
|
|
769
|
-
if (a({ pending: m, queries:
|
|
769
|
+
if (a({ pending: m, queries: f }), l.mode === "mutation") {
|
|
770
770
|
const y = Object.values(i.pending).find((b) => b.mode === "mutation" && b.status === "queued" && c(b.operation, h));
|
|
771
771
|
if (y && (y.operation.kind === "sampleStyle" || y.operation.kind === "saveStyle" || y.operation.kind === "scribble" || y.operation.kind === "deleteStyle"))
|
|
772
772
|
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 } });
|
|
@@ -776,7 +776,7 @@ function so(t, e, s, n) {
|
|
|
776
776
|
return { state: i, effects: r };
|
|
777
777
|
}
|
|
778
778
|
function Ls(t = null) {
|
|
779
|
-
return { authority: t, refusal: null, paidFallbackBySession: {}, query:
|
|
779
|
+
return { authority: t, refusal: null, paidFallbackBySession: {}, query: ve("account"), preferences: null };
|
|
780
780
|
}
|
|
781
781
|
function no(t, e) {
|
|
782
782
|
return t.preferences && e.preferencesVersion <= t.preferences.preferencesVersion ? t : { ...t, preferences: e };
|
|
@@ -946,12 +946,12 @@ function zs(t, e, s) {
|
|
|
946
946
|
w && w.revision > n.interactions.preferencePrompts[I].revision && l(I, w.requestId);
|
|
947
947
|
}
|
|
948
948
|
g.kind === "preferences" && (n = { ...n, account: no(n.account, g.value) }), g.kind === "preferencePrompts" && (n = { ...n, interactions: Bn(n.interactions, g.value) }), g.kind === "preferencePrompt" && (n = { ...n, interactions: Bn(n.interactions, { ...n.interactions.preferencePrompts, [g.feature]: g.value }) }), g.kind === "decisions" && (n = { ...n, interactions: os(n.interactions, g.decisions) }), g.kind === "decision" && (n = { ...n, interactions: os(n.interactions, [g.value]) });
|
|
949
|
-
},
|
|
949
|
+
}, p = (g, v) => {
|
|
950
950
|
const I = n.interactions.deviceFacts[g];
|
|
951
951
|
if (!(v.revision <= I.revision) && ((_t(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 && _t(n, g) !== !0)) {
|
|
952
952
|
const w = Object.values(n.features.pending).filter((A) => A.mode === "mutation" && A.key === `preference:${g}`);
|
|
953
953
|
if (v.permission === "granted" && !w.some((A) => A.status === "pending" || A.status === "error"))
|
|
954
|
-
|
|
954
|
+
f({ kind: "preference", feature: g, enabled: !0 }, `permission:${g}:${v.revision}`);
|
|
955
955
|
else if (!v.pending && v.permission === "missing" && v.snoozedUntil) {
|
|
956
956
|
const A = { ...n.features.desiredPreferences };
|
|
957
957
|
delete A[g], r({ desiredPreferences: A });
|
|
@@ -967,7 +967,7 @@ function zs(t, e, s) {
|
|
|
967
967
|
const _ = n.features.pending[A];
|
|
968
968
|
if (_ && _.fingerprint !== JSON.stringify(g)) throw new Error("Query request ID changed payload.");
|
|
969
969
|
if (_?.status === "pending" || Object.values(n.features.pending).some((C) => C.mode === "query" && C.key === w && C.status === "pending")) return;
|
|
970
|
-
const q = n.features.queries[w] ??
|
|
970
|
+
const q = n.features.queries[w] ?? ve(w), E = Ne(q, { key: w, requestId: oe(v), mode: "replace" });
|
|
971
971
|
r({ queries: { ...n.features.queries, [w]: E }, pending: { ...n.features.pending, [A]: {
|
|
972
972
|
requestId: v,
|
|
973
973
|
effectId: A,
|
|
@@ -980,7 +980,7 @@ function zs(t, e, s) {
|
|
|
980
980
|
error: null,
|
|
981
981
|
result: null
|
|
982
982
|
} } }), g.kind === "account" && (n = { ...n, account: { ...n.account, query: Ne(n.account.query, { key: w, requestId: oe(v), mode: "replace" }) } }), i.push({ kind: "stage7.query", id: A, input: { authority: o, requestId: v, query: g } });
|
|
983
|
-
},
|
|
983
|
+
}, f = (g, v, I = !1) => {
|
|
984
984
|
if (Ce(o, g), g.kind === "report" && !n.account.query.data?.user?.isSuperuser) throw new Error("Chat reporting requires superuser access.");
|
|
985
985
|
const w = Se(o, "mutate", v), A = JSON.stringify(g), _ = n.features.pending[w];
|
|
986
986
|
if (_) {
|
|
@@ -1010,14 +1010,14 @@ function zs(t, e, s) {
|
|
|
1010
1010
|
return;
|
|
1011
1011
|
}
|
|
1012
1012
|
if (g.kind === "generatePrompts") {
|
|
1013
|
-
const q = { kind: "starterPrompts", ...g.page, includeUserSuggestions: g.includeUserSuggestions ?? !1 }, E = ie(o, q), C = n.features.queries[E] ??
|
|
1013
|
+
const q = { kind: "starterPrompts", ...g.page, includeUserSuggestions: g.includeUserSuggestions ?? !1 }, E = ie(o, q), C = n.features.queries[E] ?? ve(E);
|
|
1014
1014
|
r({ queries: { ...n.features.queries, [E]: Ne(C, { key: E, requestId: oe(v), mode: "replace" }) } });
|
|
1015
1015
|
}
|
|
1016
1016
|
r({ pending: { ...n.features.pending, [w]: { requestId: v, effectId: w, fingerprint: A, key: Fn(g), generation: o.generation, operation: g, mode: "mutation", status: "pending", error: null, result: null } } }), i.push({ kind: "stage7.mutate", id: w, input: { authority: o, requestId: v, mutation: g } });
|
|
1017
1017
|
}, y = (g) => {
|
|
1018
1018
|
if (!(!X(o.profile, "canManagePreferences") || n.features.refreshBatch)) {
|
|
1019
1019
|
for (const v of Object.values(n.features.pending))
|
|
1020
|
-
v.mode === "mutation" && v.operation.kind === "preferenceAcknowledge" && v.status === "error" && !["conflict", "409"].includes(v.error?.code ?? "") &&
|
|
1020
|
+
v.mode === "mutation" && v.operation.kind === "preferenceAcknowledge" && v.status === "error" && !["conflict", "409"].includes(v.error?.code ?? "") && f(v.operation, v.requestId, !0);
|
|
1021
1021
|
for (const v of ["account", "preferences", "preferencePrompts", "decisions"])
|
|
1022
1022
|
Object.values(n.features.pending).some((I) => I.mode === "query" && I.status === "pending" && I.operation.kind === v) || m({ kind: v }, `${g}:${v}`);
|
|
1023
1023
|
r({ refreshAt: null, refreshBatch: { pending: Object.values(n.features.pending).filter((v) => v.mode === "query" && v.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(v.operation.kind)).map((v) => v.effectId), failed: !1 } });
|
|
@@ -1071,12 +1071,12 @@ function zs(t, e, s) {
|
|
|
1071
1071
|
m(e.query, e.requestId, e.force);
|
|
1072
1072
|
break;
|
|
1073
1073
|
case "stage7.mutate":
|
|
1074
|
-
|
|
1074
|
+
f(e.mutation, e.requestId);
|
|
1075
1075
|
break;
|
|
1076
1076
|
case "stage7.retry": {
|
|
1077
1077
|
const g = n.features.pending[Se(o, "mutate", e.requestId)];
|
|
1078
1078
|
if (!g || g.mode !== "mutation") throw new Error("Unknown mutation request.");
|
|
1079
|
-
|
|
1079
|
+
f(g.operation, e.requestId, !0);
|
|
1080
1080
|
break;
|
|
1081
1081
|
}
|
|
1082
1082
|
case "stage7.reconcile":
|
|
@@ -1135,7 +1135,7 @@ function zs(t, e, s) {
|
|
|
1135
1135
|
break;
|
|
1136
1136
|
}
|
|
1137
1137
|
case "stage7.device_fact":
|
|
1138
|
-
|
|
1138
|
+
p(e.feature, e.fact);
|
|
1139
1139
|
break;
|
|
1140
1140
|
case "stage7.import_legacy_decisions":
|
|
1141
1141
|
if (!o.profile.startsWith("extension_") || e.decisions.some((g) => g.revision !== 0)) throw new Error("Invalid legacy decision import.");
|
|
@@ -1220,14 +1220,14 @@ function zs(t, e, s) {
|
|
|
1220
1220
|
if (delete w[e.effectId], a({ devicePending: w }), e.type === "effect.completed") {
|
|
1221
1221
|
if (I.action !== "check" && n.interactions.promptActions[I.requestId] && !n.features.pending[Se(o, "mutate", `${I.requestId}:ack`)]) {
|
|
1222
1222
|
const A = n.interactions.promptActions[I.requestId];
|
|
1223
|
-
l(A.feature, I.requestId),
|
|
1223
|
+
l(A.feature, I.requestId), f({
|
|
1224
1224
|
kind: "preferenceAcknowledge",
|
|
1225
1225
|
feature: A.feature,
|
|
1226
1226
|
action: A.action,
|
|
1227
1227
|
expectedRevision: A.expectedRevision
|
|
1228
1228
|
}, `${I.requestId}:ack`);
|
|
1229
1229
|
}
|
|
1230
|
-
|
|
1230
|
+
p(I.feature, e.output.fact);
|
|
1231
1231
|
} else n.features.desiredPreferences[I.feature] !== !1 && a({ deviceErrors: { ...n.interactions.deviceErrors, [I.feature]: e.error } });
|
|
1232
1232
|
break;
|
|
1233
1233
|
}
|
|
@@ -1266,7 +1266,7 @@ function zs(t, e, s) {
|
|
|
1266
1266
|
}
|
|
1267
1267
|
if (!v && g.mode === "mutation" && g.operation.kind === "preference" && n.interactions.promptActions[g.requestId]) {
|
|
1268
1268
|
const I = n.interactions.promptActions[g.requestId];
|
|
1269
|
-
l(I.feature, g.requestId),
|
|
1269
|
+
l(I.feature, g.requestId), f({
|
|
1270
1270
|
kind: "preferenceAcknowledge",
|
|
1271
1271
|
feature: I.feature,
|
|
1272
1272
|
action: I.action,
|
|
@@ -1345,7 +1345,7 @@ function zs(t, e, s) {
|
|
|
1345
1345
|
const I = g.operation.feature, w = n.features.queuedPreferences[I];
|
|
1346
1346
|
if (w) {
|
|
1347
1347
|
const A = { ...n.features.queuedPreferences };
|
|
1348
|
-
delete A[I], r({ queuedPreferences: A }),
|
|
1348
|
+
delete A[I], r({ queuedPreferences: A }), f({ kind: "preference", feature: I, enabled: w.enabled }, w.requestId);
|
|
1349
1349
|
} else {
|
|
1350
1350
|
const A = { ...n.features.desiredPreferences };
|
|
1351
1351
|
delete A[I], r({ desiredPreferences: A });
|
|
@@ -1406,8 +1406,8 @@ function ao(t, e, s, n) {
|
|
|
1406
1406
|
if (!h) return;
|
|
1407
1407
|
await t["stage7.mutate"]({ authority: d, requestId: `local-preferences:${n()}`, mutation: h }), await o(async () => {
|
|
1408
1408
|
a(d);
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1409
|
+
const p = await e.load(d.userId);
|
|
1410
|
+
p && await e.save(d.userId, { ...p, pending: p.pending.slice(1) });
|
|
1411
1411
|
});
|
|
1412
1412
|
}
|
|
1413
1413
|
};
|
|
@@ -1426,22 +1426,22 @@ function ao(t, e, s, n) {
|
|
|
1426
1426
|
if (!l || u) {
|
|
1427
1427
|
const h = await t["stage7.query"](d);
|
|
1428
1428
|
if (h.data.kind !== "preferences") throw new Error("Invalid preference result.");
|
|
1429
|
-
const
|
|
1429
|
+
const p = h.data.value;
|
|
1430
1430
|
l = await o(async () => {
|
|
1431
1431
|
a(d.authority);
|
|
1432
1432
|
const m = await e.load(d.authority.userId);
|
|
1433
1433
|
if (m) {
|
|
1434
|
-
if (!u || (
|
|
1434
|
+
if (!u || (p.securityPolicyVersion ?? 1) < (m.value.securityPolicyVersion ?? 1)) return m;
|
|
1435
1435
|
const y = { ...m, value: {
|
|
1436
1436
|
...m.value,
|
|
1437
|
-
blockedOrigins:
|
|
1438
|
-
securityPolicyVersion:
|
|
1439
|
-
preferencesVersion: Math.max(m.value.preferencesVersion,
|
|
1437
|
+
blockedOrigins: p.blockedOrigins,
|
|
1438
|
+
securityPolicyVersion: p.securityPolicyVersion,
|
|
1439
|
+
preferencesVersion: Math.max(m.value.preferencesVersion, p.preferencesVersion) + 1
|
|
1440
1440
|
} };
|
|
1441
1441
|
return await e.save(d.authority.userId, y), y;
|
|
1442
1442
|
}
|
|
1443
|
-
const
|
|
1444
|
-
return await e.save(d.authority.userId,
|
|
1443
|
+
const f = { value: p, pending: [] };
|
|
1444
|
+
return await e.save(d.authority.userId, f), f;
|
|
1445
1445
|
});
|
|
1446
1446
|
}
|
|
1447
1447
|
return a(d.authority), c(d.authority), { data: { kind: "preferences", value: l.value }, completedAt: n() };
|
|
@@ -1450,9 +1450,9 @@ function ao(t, e, s, n) {
|
|
|
1450
1450
|
a(d.authority), Ce(d.authority, d.mutation);
|
|
1451
1451
|
const u = d.mutation;
|
|
1452
1452
|
if (u.kind === "blockedOrigins" || u.kind === "personalInstructions") {
|
|
1453
|
-
const h = async (
|
|
1454
|
-
if (
|
|
1455
|
-
const m =
|
|
1453
|
+
const h = async (p) => {
|
|
1454
|
+
if (p.data.kind !== "preferences") throw new Error("Invalid preference result.");
|
|
1455
|
+
const m = p.data.value;
|
|
1456
1456
|
return { data: { kind: "preferences", value: await o(async () => {
|
|
1457
1457
|
a(d.authority);
|
|
1458
1458
|
const y = await e.load(d.authority.userId), b = {
|
|
@@ -1463,15 +1463,15 @@ function ao(t, e, s, n) {
|
|
|
1463
1463
|
return await e.save(d.authority.userId, { value: b, pending: y?.pending ?? [] }), b;
|
|
1464
1464
|
}) }, completedAt: n() };
|
|
1465
1465
|
};
|
|
1466
|
-
return t["stage7.mutate"](d).then(h, async (
|
|
1467
|
-
throw u.kind === "personalInstructions" || await h(await t["stage7.query"]({ authority: d.authority, requestId: d.requestId, query: { kind: "preferences" } })),
|
|
1466
|
+
return t["stage7.mutate"](d).then(h, async (p) => {
|
|
1467
|
+
throw u.kind === "personalInstructions" || await h(await t["stage7.query"]({ authority: d.authority, requestId: d.requestId, query: { kind: "preferences" } })), p;
|
|
1468
1468
|
});
|
|
1469
1469
|
}
|
|
1470
1470
|
if (u.kind !== "preference" && u.kind !== "scribblePreference") return t["stage7.mutate"](d);
|
|
1471
1471
|
const l = await o(async () => {
|
|
1472
1472
|
a(d.authority);
|
|
1473
|
-
const h = await e.load(d.authority.userId),
|
|
1474
|
-
return await e.save(d.authority.userId, { value:
|
|
1473
|
+
const h = await e.load(d.authority.userId), p = h?.value ?? oo, m = u.kind === "preference" ? { [u.feature === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"]: u.enabled } : { scribbleStyleEnabled: u.enabled }, f = { ...p, ...m, preferencesVersion: p.preferencesVersion + 1 };
|
|
1474
|
+
return await e.save(d.authority.userId, { value: f, pending: [...h?.pending ?? [], u] }), f;
|
|
1475
1475
|
});
|
|
1476
1476
|
return a(d.authority), c(d.authority), { data: { kind: "preferences", value: l }, completedAt: n() };
|
|
1477
1477
|
}
|
|
@@ -1863,9 +1863,9 @@ function Vi(t, e, s) {
|
|
|
1863
1863
|
let c = !1, d = !1, u = () => {
|
|
1864
1864
|
}, l = () => {
|
|
1865
1865
|
};
|
|
1866
|
-
const h = (m,
|
|
1867
|
-
d || (d = !0, u(), l(), m ? o(m) : a(
|
|
1868
|
-
},
|
|
1866
|
+
const h = (m, f) => {
|
|
1867
|
+
d || (d = !0, u(), l(), m ? o(m) : a(f));
|
|
1868
|
+
}, p = () => {
|
|
1869
1869
|
if (!c) return;
|
|
1870
1870
|
const m = t.engine.getState().slices;
|
|
1871
1871
|
if (JSON.stringify(m.account.authority) !== JSON.stringify(n)) {
|
|
@@ -1876,15 +1876,15 @@ function Vi(t, e, s) {
|
|
|
1876
1876
|
h(Object.assign(new Error("Context observation retired."), { code: "observation_released", retryable: !1 }));
|
|
1877
1877
|
return;
|
|
1878
1878
|
}
|
|
1879
|
-
const
|
|
1880
|
-
if (!
|
|
1879
|
+
const f = Object.values(m.features.pending).find((y) => y.requestId === r);
|
|
1880
|
+
if (!f && e.type === "stage7.query") {
|
|
1881
1881
|
const y = Ut(m, e.query);
|
|
1882
1882
|
y?.status === "error" ? h(y.error) : y?.status === "ready" && y.data && h(null, y.data);
|
|
1883
1883
|
}
|
|
1884
|
-
|
|
1884
|
+
f?.status === "error" ? h(f.error) : f?.status === "done" && h(null, f.result);
|
|
1885
1885
|
};
|
|
1886
|
-
u = t.engine.subscribe(
|
|
1887
|
-
c = !0,
|
|
1886
|
+
u = t.engine.subscribe(p), l = t.onDispose(() => h(new Error("Feature runtime disposed."))), t.engine.dispatch({ ...e, authority: n, requestId: r, now: Date.now() }).then(() => {
|
|
1887
|
+
c = !0, p();
|
|
1888
1888
|
}, (m) => h(m));
|
|
1889
1889
|
});
|
|
1890
1890
|
}
|
|
@@ -1896,36 +1896,36 @@ async function yo(t, e, s = crypto.randomUUID()) {
|
|
|
1896
1896
|
let c = !1, d = !1, u = () => {
|
|
1897
1897
|
}, l = () => {
|
|
1898
1898
|
};
|
|
1899
|
-
const h = (
|
|
1900
|
-
d || (d = !0, u(), l(),
|
|
1901
|
-
},
|
|
1899
|
+
const h = (f) => {
|
|
1900
|
+
d || (d = !0, u(), l(), f ? o(f) : a());
|
|
1901
|
+
}, p = () => {
|
|
1902
1902
|
if (!c) return;
|
|
1903
|
-
const
|
|
1904
|
-
if (JSON.stringify(
|
|
1905
|
-
const y =
|
|
1903
|
+
const f = t.engine.getState().slices;
|
|
1904
|
+
if (JSON.stringify(f.account.authority) !== JSON.stringify(n)) return h(new Error("Feature authority retired."));
|
|
1905
|
+
const y = f.interactions.actions[r];
|
|
1906
1906
|
if (y) {
|
|
1907
1907
|
y.status === "error" ? h(y.error) : y.status === "done" && h();
|
|
1908
1908
|
return;
|
|
1909
1909
|
}
|
|
1910
|
-
const b = Object.values(
|
|
1910
|
+
const b = Object.values(f.features.pending).find((R) => R.requestId === r);
|
|
1911
1911
|
if (b) {
|
|
1912
1912
|
b.status === "error" ? h(b.error) : b.status === "done" && h();
|
|
1913
1913
|
return;
|
|
1914
1914
|
}
|
|
1915
|
-
if (Object.values(
|
|
1915
|
+
if (Object.values(f.interactions.devicePending).some((R) => R.requestId === r)) return;
|
|
1916
1916
|
const k = e.interactionId === "preference:notifications" ? "notifications" : e.interactionId === "preference:tab_grouping" ? "tab_grouping" : null;
|
|
1917
|
-
h(k ?
|
|
1917
|
+
h(k ? f.interactions.deviceErrors[k] : void 0);
|
|
1918
1918
|
};
|
|
1919
|
-
u = t.engine.subscribe(
|
|
1919
|
+
u = t.engine.subscribe(p), l = t.onDispose(() => h(new Error("Feature runtime disposed.")));
|
|
1920
1920
|
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 };
|
|
1921
1921
|
t.engine.dispatch(m).then(() => {
|
|
1922
|
-
c = !0,
|
|
1922
|
+
c = !0, p();
|
|
1923
1923
|
}, h);
|
|
1924
1924
|
});
|
|
1925
1925
|
}
|
|
1926
1926
|
function vo(t, e, s, n) {
|
|
1927
1927
|
return zi(t, e, s, n).map((i) => {
|
|
1928
|
-
const r = i.sourceId ? Object.values(t.interactions.sources).find((
|
|
1928
|
+
const r = i.sourceId ? Object.values(t.interactions.sources).find((p) => p.id === i.sourceId && p.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" ? "Enable tab groups to keep Pluno’s tabs organized?" : i.category === "sharing" ? "Share what Pluno helped you accomplish." : String(i.payload.text ?? d ?? ""), l = Object.fromEntries(i.actions.map((p) => [p, i.actionLabels?.[p] ?? { 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" }[p] ?? p])), 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;
|
|
1929
1929
|
return {
|
|
1930
1930
|
id: i.id,
|
|
1931
1931
|
kind: c,
|
|
@@ -1987,7 +1987,7 @@ function Io(t, e = null) {
|
|
|
1987
1987
|
} : void 0);
|
|
1988
1988
|
return { ...n, ...o ? { auth: o } : {}, submissionGate: a, usingPaidCreditFallback: e ? t.paidFallbackBySession[e] ?? !1 : !1 };
|
|
1989
1989
|
}
|
|
1990
|
-
const wo = "0.1.
|
|
1990
|
+
const wo = "0.1.304", zt = {
|
|
1991
1991
|
version: wo
|
|
1992
1992
|
}, Ki = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, _o = (t, e) => t.scopes[e];
|
|
1993
1993
|
function Ht(t) {
|
|
@@ -2131,7 +2131,7 @@ function ko(t, e, s, n) {
|
|
|
2131
2131
|
} : null });
|
|
2132
2132
|
const h = { ...t.requests };
|
|
2133
2133
|
delete h[e.effectId];
|
|
2134
|
-
let
|
|
2134
|
+
let p = t.submissions;
|
|
2135
2135
|
if (e.type === "effect.completed" && e.output.snapshot.conversation_id !== o.sessionId) throw new Error("Snapshot belongs to another conversation.");
|
|
2136
2136
|
if (e.type === "effect.completed" && !e.output.snapshot.projection_ready && (e.output.snapshot.preparation === "pending" || e.output.snapshot.preparation === "busy")) {
|
|
2137
2137
|
for (const m of e.output.snapshot.items) m.type === "user_message" && (c = Hs(c, m));
|
|
@@ -2150,7 +2150,7 @@ function ko(t, e, s, n) {
|
|
|
2150
2150
|
else {
|
|
2151
2151
|
const m = Z(e.output.snapshot);
|
|
2152
2152
|
o.lane === "current" && (c = { ...c, preparation: null });
|
|
2153
|
-
const
|
|
2153
|
+
const f = c.queries.history, y = o.lane === "current" && (f.status === "not_requested" || m.next_cursor !== null && !c.items[m.next_cursor]);
|
|
2154
2154
|
if (m.conversation_id !== o.sessionId) throw new Error("Snapshot belongs to another conversation.");
|
|
2155
2155
|
for (const b of m.removed_items) c = us(c, b);
|
|
2156
2156
|
for (const b of m.items) c = Hs(c, b);
|
|
@@ -2163,9 +2163,9 @@ function ko(t, e, s, n) {
|
|
|
2163
2163
|
}), m.interactions.some((b) => b.conversation_id !== m.conversation_id)) throw new Error("Interaction belongs to another conversation.");
|
|
2164
2164
|
if (a = { authorityId: t.authorityId, generation: t.generation, sessionId: o.sessionId, sources: m.interactions }, m.execution.version === c.execution?.version)
|
|
2165
2165
|
for (const b of o.acceptedUserMessageIds) {
|
|
2166
|
-
const k =
|
|
2167
|
-
k.executionVersion === null && (
|
|
2168
|
-
...
|
|
2166
|
+
const k = p[b];
|
|
2167
|
+
k.executionVersion === null && (p = {
|
|
2168
|
+
...p,
|
|
2169
2169
|
[b]: { ...k, executionVersion: m.execution.version }
|
|
2170
2170
|
});
|
|
2171
2171
|
}
|
|
@@ -2180,10 +2180,10 @@ function ko(t, e, s, n) {
|
|
|
2180
2180
|
} } }, y) {
|
|
2181
2181
|
for (const [b, k] of Object.entries(h))
|
|
2182
2182
|
k.sessionId === o.sessionId && k.lane === "history" && delete h[b];
|
|
2183
|
-
c = { ...c, queries: { ...c.queries, history: { ...c.queries.current, key:
|
|
2183
|
+
c = { ...c, queries: { ...c.queries, history: { ...c.queries.current, key: f.key } } };
|
|
2184
2184
|
}
|
|
2185
2185
|
}
|
|
2186
|
-
i = { ...t, requests: h, submissions:
|
|
2186
|
+
i = { ...t, requests: h, submissions: p, sessions: { ...t.sessions, [c.sessionId]: c } };
|
|
2187
2187
|
} else {
|
|
2188
2188
|
if (e.authorityId !== t.authorityId || e.generation !== t.generation || !s.authorityId && !["conversation.submission_stage", "conversation.submission_delivery", "conversation.stop"].includes(e.type)) return { state: t, effects: r };
|
|
2189
2189
|
switch (e.type) {
|
|
@@ -2214,18 +2214,18 @@ function ko(t, e, s, n) {
|
|
|
2214
2214
|
}
|
|
2215
2215
|
case "conversation.submission_stage": {
|
|
2216
2216
|
if (s.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
|
|
2217
|
-
const { type: o, authorityId: c, generation: d, prepareContext: u, reconcileAcceptance: l, waitForAuthentication: h, ...
|
|
2217
|
+
const { type: o, authorityId: c, generation: d, prepareContext: u, reconcileAcceptance: l, waitForAuthentication: h, ...p } = e, m = t.submissions[e.userMessageId];
|
|
2218
2218
|
if (m) {
|
|
2219
2219
|
const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled: A, cancellationReason: _, error: q, executionVersion: E, ...C } = m;
|
|
2220
|
-
if (pt(C) !== pt(
|
|
2220
|
+
if (pt(C) !== pt(p)) throw new Error("User-message identity cannot be reused with different input.");
|
|
2221
2221
|
return { state: t, effects: r };
|
|
2222
2222
|
}
|
|
2223
|
-
const
|
|
2224
|
-
...Z(
|
|
2223
|
+
const f = 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 = {
|
|
2224
|
+
...Z(p),
|
|
2225
2225
|
...u ? { contextPreparation: null } : {},
|
|
2226
2226
|
// Extension staging can await page context after the picker has already changed.
|
|
2227
2227
|
requestedModel: b?.submissions[e.userMessageId] ? b.submissions[e.userMessageId].requestedModel ?? null : b ? Ki(b) ?? null : null,
|
|
2228
|
-
sessionId:
|
|
2228
|
+
sessionId: f.sessionId ?? y?.sessionId ?? null,
|
|
2229
2229
|
delivery: h ? "failed" : "staged",
|
|
2230
2230
|
cancelled: !1,
|
|
2231
2231
|
error: h ? { code: h, message: h === "unauthorized" ? "Open the Pluno login link, then return to Pluno." : "Pluno is reconnecting. Try again in a moment.", retryable: !1 } : null,
|
|
@@ -2248,14 +2248,14 @@ function ko(t, e, s, n) {
|
|
|
2248
2248
|
}
|
|
2249
2249
|
case "conversation.stop": {
|
|
2250
2250
|
if (s.clients[e.clientScopeId] !== e.conversationScopeId) return { state: t, effects: r };
|
|
2251
|
-
const o = s.selections[e.conversationScopeId].sessionId, c = o ? t.sessions[o]?.execution : null, d = Object.values(t.submissions).filter((
|
|
2251
|
+
const o = s.selections[e.conversationScopeId].sessionId, c = o ? t.sessions[o]?.execution : null, d = Object.values(t.submissions).filter((f) => (o ? f.sessionId === o : f.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(f.userMessageId))), u = d.filter((f) => !f.cancelled && (f.delivery !== "failed" || t.deliveries[f.userMessageId]?.phase === "paused" || e.userMessageIds?.includes(f.userMessageId) && t.deliveries[f.userMessageId]?.acceptance === "unissued") && (f.delivery !== "accepted" || f.executionVersion === null)), l = u.length > 0, h = c && ["queued", "thinking", "steering", "stopping"].includes(c.phase) && (!e.userMessageIds || le(c).some((f) => e.userMessageIds.includes(f)));
|
|
2252
2252
|
if (!l && !h && (c || !e.userMessageIds?.length)) return { state: t, effects: r };
|
|
2253
|
-
const
|
|
2254
|
-
for (const
|
|
2255
|
-
|
|
2253
|
+
const p = Array.from(new Set(e.userMessageIds ?? [...u.map((f) => f.userMessageId), ...h ? le(c) : []])), m = { ...t.submissions };
|
|
2254
|
+
for (const f of d)
|
|
2255
|
+
p.includes(f.userMessageId) && f.delivery !== "accepted" && (m[f.userMessageId] = { ...f, cancelled: !0, cancellationReason: e.reason ?? "user_requested" });
|
|
2256
2256
|
i = { ...t, submissions: m, stops: { ...t.stops, [e.conversationScopeId]: {
|
|
2257
2257
|
requestId: e.requestId,
|
|
2258
|
-
userMessageIds:
|
|
2258
|
+
userMessageIds: p,
|
|
2259
2259
|
executionVersion: c?.version ?? -1,
|
|
2260
2260
|
reason: e.reason ?? "user_requested"
|
|
2261
2261
|
} } };
|
|
@@ -2284,7 +2284,7 @@ function ko(t, e, s, n) {
|
|
|
2284
2284
|
const h = d[l.lane];
|
|
2285
2285
|
d[l.lane] = { ...h, requestId: null, status: h.data === null ? "not_requested" : "ready" };
|
|
2286
2286
|
}
|
|
2287
|
-
d.history =
|
|
2287
|
+
d.history = ve(d.history.key), i = { ...t, requests: c, sessions: { ...t.sessions, [e.sessionId]: { ...o, queries: d } } };
|
|
2288
2288
|
break;
|
|
2289
2289
|
}
|
|
2290
2290
|
case "conversation.snapshot": {
|
|
@@ -2300,7 +2300,7 @@ function ko(t, e, s, n) {
|
|
|
2300
2300
|
before: e.lane === "history" ? c.cursor : null,
|
|
2301
2301
|
refreshItemIds: So(o),
|
|
2302
2302
|
retryPreparation: c.error?.code === "history_preparation_failed"
|
|
2303
|
-
}, u = Object.values(t.submissions).filter((
|
|
2303
|
+
}, u = Object.values(t.submissions).filter((p) => p.sessionId === e.sessionId && p.delivery === "accepted" && p.executionVersion === null).map((p) => p.userMessageId), l = t.requestSequence + 1, h = `conversation:${t.generation}:${l}`;
|
|
2304
2304
|
i = {
|
|
2305
2305
|
...t,
|
|
2306
2306
|
requestSequence: l,
|
|
@@ -2334,37 +2334,38 @@ const zn = (t, e) => ({
|
|
|
2334
2334
|
command: null
|
|
2335
2335
|
});
|
|
2336
2336
|
function hn(t, e) {
|
|
2337
|
-
const s = new Set(Object.values(e.clients)), n = Object.values(t.operations).filter((
|
|
2338
|
-
const
|
|
2339
|
-
if (
|
|
2340
|
-
if (
|
|
2341
|
-
if (
|
|
2342
|
-
const
|
|
2343
|
-
return
|
|
2344
|
-
}
|
|
2345
|
-
return !
|
|
2346
|
-
}).map(([
|
|
2347
|
-
if (
|
|
2348
|
-
if (!
|
|
2349
|
-
const
|
|
2350
|
-
return s.has(
|
|
2351
|
-
}))),
|
|
2352
|
-
if (!["done", "failed"].includes(
|
|
2353
|
-
if (
|
|
2354
|
-
if (
|
|
2355
|
-
if (
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2337
|
+
const s = new Set(Object.values(e.clients)), n = new Set(Object.values(t.pendingRestoration)), i = Object.values(t.operations).filter((l) => l.command.type === "run.stop"), r = (l) => i.some((h) => h.command.payload.expectedUserMessageId === l && h.phase === "done"), a = Object.fromEntries(Object.entries(t.submissions).filter(([l, h]) => {
|
|
2338
|
+
const p = h.sessionId ? t.sessions[h.sessionId] : void 0;
|
|
2339
|
+
if (h.cancelled && s.has(h.conversationScopeId) && t.stops[h.conversationScopeId]?.userMessageIds.includes(l) && !p?.items[l] && !p?.removedItems[l]) return !0;
|
|
2340
|
+
if (h.delivery === "accepted") {
|
|
2341
|
+
if (h.cancelled) return !r(l);
|
|
2342
|
+
const m = h.sessionId ? t.sessions[h.sessionId] : void 0;
|
|
2343
|
+
return h.executionVersion === null || !(m?.items[l] || m?.removedItems[l]);
|
|
2344
|
+
}
|
|
2345
|
+
return !h.cancelled || we(t, l) || t.deliveries[l]?.phase === "running";
|
|
2346
|
+
}).map(([l, h]) => [l, h.delivery === "accepted" || h.cancelled ? { ...h, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } } : h])), o = Object.fromEntries(Object.entries(t.deliveries).filter(([l]) => l in a).map(([l, h]) => [l, a[l].delivery === "accepted" ? { ...h, phase: "done", effectId: null, command: null, uploads: [], completedUploads: 0 } : a[l].cancelled ? { ...h, command: null } : h])), c = Object.fromEntries(Object.entries(t.stops).filter(([l, h]) => h.userMessageIds.some((p) => {
|
|
2347
|
+
if (a[p]) return !0;
|
|
2348
|
+
if (!r(p)) return i.some((f) => f.command.payload.expectedUserMessageId === p && f.phase !== "done");
|
|
2349
|
+
const m = Object.values(t.sessions).find((f) => f.executionByUserMessage[p])?.executionByUserMessage[p];
|
|
2350
|
+
return s.has(l) && (!m || m.version <= h.executionVersion || !["completed", "failed", "stopped"].includes(m.phase));
|
|
2351
|
+
}))), d = new Set(Object.values(c).flatMap((l) => l.userMessageIds)), u = Object.fromEntries(Object.entries(t.operations).filter(([, l]) => {
|
|
2352
|
+
if (!["done", "failed"].includes(l.phase)) return !0;
|
|
2353
|
+
if (l.command.type === "run.stop") return d.has(String(l.command.payload.expectedUserMessageId)) || Object.values(a).some((p) => p.cancelled && p.userMessageId === l.command.payload.expectedUserMessageId);
|
|
2354
|
+
if (l.phase !== "done" || !l.conversationScopeId || !s.has(l.conversationScopeId) && !(l.command.type === "runtime.warmup" && n.has(l.conversationScopeId))) return !1;
|
|
2355
|
+
if (l.command.type === "runtime.warmup")
|
|
2356
|
+
return e.selections[l.conversationScopeId]?.sessionId !== l.result?.sessionId || ge(t, e, l.conversationScopeId).isDraftSession;
|
|
2357
|
+
if (l.command.type !== "attachment.prepare") return !1;
|
|
2358
|
+
const h = l.command.payload.source;
|
|
2359
|
+
return !Object.values(t.submissions).some((p) => p.conversationScopeId === l.conversationScopeId && p.delivery === "accepted" && p.attachments.some((m) => m.sourceId === h.sourceId));
|
|
2359
2360
|
}));
|
|
2360
2361
|
return G({
|
|
2361
2362
|
schema: 1,
|
|
2362
2363
|
authorityId: t.authorityId,
|
|
2363
|
-
submissions:
|
|
2364
|
-
submissionOrder: t.submissionOrder.filter((
|
|
2365
|
-
deliveries:
|
|
2366
|
-
operations:
|
|
2367
|
-
stops:
|
|
2364
|
+
submissions: a,
|
|
2365
|
+
submissionOrder: t.submissionOrder.filter((l) => l in a),
|
|
2366
|
+
deliveries: o,
|
|
2367
|
+
operations: u,
|
|
2368
|
+
stops: c,
|
|
2368
2369
|
requestSequence: t.requestSequence
|
|
2369
2370
|
});
|
|
2370
2371
|
}
|
|
@@ -2406,31 +2407,31 @@ function Xs(t) {
|
|
|
2406
2407
|
let d = e.deliveries[o];
|
|
2407
2408
|
if (t.pendingRestoration[c.clientScopeId] === c.conversationScopeId || !d || d.phase !== "waiting" || !we(e, o) || c.delivery === "accepted") continue;
|
|
2408
2409
|
if (d.handoffRecovery && d.step === "receipt") {
|
|
2409
|
-
const
|
|
2410
|
-
e = { ...e, deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId:
|
|
2410
|
+
const p = i();
|
|
2411
|
+
e = { ...e, deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId: p, prepared: c.cancelled } } }, s.push({ id: p, kind: "conversation.receipt", input: { ...n, userMessageId: o, sessionId: c.sessionId } });
|
|
2411
2412
|
continue;
|
|
2412
2413
|
}
|
|
2413
2414
|
if (!d.prepared && !c.cancelled) {
|
|
2414
|
-
const
|
|
2415
|
-
e = { ...e, deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId:
|
|
2415
|
+
const p = i();
|
|
2416
|
+
e = { ...e, deliveries: { ...e.deliveries, [o]: { ...d, phase: "running", effectId: p } } }, s.push({ id: p, kind: "conversation.prepare", input: { ...n, submission: c, sources: c.attachments.slice(d.uploads.length) } });
|
|
2416
2417
|
continue;
|
|
2417
2418
|
}
|
|
2418
|
-
if (c.contextPreparation === null && !c.cancelled || c.sessionId === null && Object.values(e.operations).some((
|
|
2419
|
+
if (c.contextPreparation === null && !c.cancelled || c.sessionId === null && Object.values(e.operations).some((p) => ["runtime.warmup", "attachment.prepare"].includes(p.command.type) && p.conversationScopeId === c.conversationScopeId && (["waiting", "running", "uncertain"].includes(p.phase) || p.phase === "done" && !!p.result?.sessionId)) || c.sessionId === null && r.some((p) => p !== o && r.indexOf(p) < r.indexOf(o) && e.submissions[p].conversationScopeId === c.conversationScopeId && e.deliveries[p] && !e.submissions[p].cancelled && (e.submissions[p].delivery !== "failed" || e.deliveries[p].acceptance === "uncertain" || e.deliveries[p].allocation === "uncertain"))) continue;
|
|
2419
2420
|
for (; d.uploads.length < c.attachments.length; ) {
|
|
2420
|
-
const
|
|
2421
|
-
if (
|
|
2422
|
-
d = { ...d, uploads: [...d.uploads,
|
|
2421
|
+
const p = c.attachments[d.uploads.length];
|
|
2422
|
+
if (p.uploaded) {
|
|
2423
|
+
d = { ...d, uploads: [...d.uploads, p.uploaded] };
|
|
2423
2424
|
continue;
|
|
2424
2425
|
}
|
|
2425
|
-
const m = Object.values(e.operations).find((
|
|
2426
|
+
const m = Object.values(e.operations).find((f) => f.command.type === "attachment.prepare" && f.conversationScopeId === c.conversationScopeId && f.phase === "done" && f.command.payload.source.sourceId === p.sourceId && f.result?.sessionId === c.sessionId);
|
|
2426
2427
|
if (!m) break;
|
|
2427
2428
|
d = { ...d, uploads: [...d.uploads, m.result.attachment] };
|
|
2428
2429
|
}
|
|
2429
2430
|
for (; d.completedUploads < d.uploads.length && c.attachments[d.completedUploads].uploaded; )
|
|
2430
2431
|
d = { ...d, completedUploads: d.completedUploads + 1 };
|
|
2431
|
-
if (!c.cancelled && d.uploads.length === c.attachments.length && d.completedUploads === d.uploads.length && r.slice(0, r.indexOf(o)).some((
|
|
2432
|
-
const m = e.submissions[
|
|
2433
|
-
return (m.conversationScopeId === c.conversationScopeId || c.sessionId !== null && m.sessionId === c.sessionId) && m.delivery !== "accepted" && (m.delivery !== "failed" || e.deliveries[
|
|
2432
|
+
if (!c.cancelled && d.uploads.length === c.attachments.length && d.completedUploads === d.uploads.length && r.slice(0, r.indexOf(o)).some((p) => {
|
|
2433
|
+
const m = e.submissions[p];
|
|
2434
|
+
return (m.conversationScopeId === c.conversationScopeId || c.sessionId !== null && m.sessionId === c.sessionId) && m.delivery !== "accepted" && (m.delivery !== "failed" || e.deliveries[p]?.acceptance === "uncertain") && (!m.cancelled || we(e, p));
|
|
2434
2435
|
})) continue;
|
|
2435
2436
|
const u = i();
|
|
2436
2437
|
let l, h = d.command;
|
|
@@ -2468,7 +2469,7 @@ function Xs(t) {
|
|
|
2468
2469
|
};
|
|
2469
2470
|
for (const [o, c] of Object.entries(e.stops))
|
|
2470
2471
|
for (const d of c.userMessageIds) {
|
|
2471
|
-
const u = e.submissions[d], l = u?.sessionId ?? Object.values(e.sessions).find((
|
|
2472
|
+
const u = e.submissions[d], l = u?.sessionId ?? Object.values(e.sessions).find((p) => le(p.execution).includes(d))?.sessionId, h = u?.delivery === "accepted" || l && le(e.sessions[l]?.execution).includes(d);
|
|
2472
2473
|
l && h && a(`stop:${o}:${c.requestId}:${d}`, l, d, c.reason);
|
|
2473
2474
|
}
|
|
2474
2475
|
for (const o of Object.values(e.submissions))
|
|
@@ -2480,14 +2481,14 @@ function Xs(t) {
|
|
|
2480
2481
|
));
|
|
2481
2482
|
for (const [o, c] of Object.entries(e.operations)) {
|
|
2482
2483
|
if (c.phase !== "waiting" || c.conversationScopeId && Object.values(e.pendingRestoration).includes(c.conversationScopeId)) continue;
|
|
2483
|
-
const d = Object.values(e.operations).filter((
|
|
2484
|
-
if (c.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(c.command.type) && !h && (d.some((
|
|
2484
|
+
const d = Object.values(e.operations).filter((f) => f !== c && f.conversationScopeId === c.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(f.command.type)), u = d.find((f) => f.phase === "done" && f.result?.sessionId), l = u?.result, h = c.command.payload.sessionId ?? l?.sessionId ?? Object.values(e.submissions).find((f) => f.conversationScopeId === c.conversationScopeId && !f.cancelled && f.sessionId)?.sessionId ?? null;
|
|
2485
|
+
if (c.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(c.command.type) && !h && (d.some((f) => f.phase === "running" || f.phase === "uncertain") || Object.values(e.submissions).some((f) => f.conversationScopeId === c.conversationScopeId && e.deliveries[f.userMessageId]?.phase === "running"))) continue;
|
|
2485
2486
|
if (c.command.type === "runtime.warmup" && l && !c.command.payload.sessionId && u?.command.type === "runtime.warmup" && u.command.payload.model === c.command.payload.model) {
|
|
2486
2487
|
e = { ...e, operations: { ...e.operations, [o]: { ...c, phase: "done", result: l } } };
|
|
2487
2488
|
continue;
|
|
2488
2489
|
}
|
|
2489
|
-
const
|
|
2490
|
-
e = { ...e, operations: { ...e.operations, [o]: { ...c, command:
|
|
2490
|
+
const p = c.command.type === "runtime.warmup" && l && !c.command.payload.sessionId ? { ...c.command, payload: { ...c.command.payload, sessionId: l.sessionId } } : c.command, m = i();
|
|
2491
|
+
e = { ...e, operations: { ...e.operations, [o]: { ...c, command: p, phase: "running", effectId: m } } }, p.type === "attachment.prepare" ? s.push({ id: m, kind: "conversation.upload", input: {
|
|
2491
2492
|
...n,
|
|
2492
2493
|
preparationId: o,
|
|
2493
2494
|
source: c.command.payload.source,
|
|
@@ -2499,61 +2500,61 @@ function Xs(t) {
|
|
|
2499
2500
|
requestedModel: c.command.payload.requestedModel,
|
|
2500
2501
|
entrySurface: c.command.payload.entrySurface
|
|
2501
2502
|
}
|
|
2502
|
-
} }) : s.push({ id: m, kind: "conversation.command", input: { ...n, command:
|
|
2503
|
+
} }) : s.push({ id: m, kind: "conversation.command", input: { ...n, command: p } });
|
|
2503
2504
|
}
|
|
2504
2505
|
return { state: G(e), effects: s };
|
|
2505
2506
|
}
|
|
2506
2507
|
function Ao(t, e, s, n) {
|
|
2507
2508
|
let i = t, r = e;
|
|
2508
2509
|
if (e.type === "effect.completed" || e.type === "effect.failed") {
|
|
2509
|
-
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((
|
|
2510
|
-
const l = Object.keys(t.deliveries).find((
|
|
2510
|
+
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((p) => !!t.submissions[p]) });
|
|
2511
|
+
const l = Object.keys(t.deliveries).find((p) => t.deliveries[p].effectId === e.effectId), h = Object.keys(t.operations).find((p) => t.operations[p].effectId === e.effectId);
|
|
2511
2512
|
if (l) {
|
|
2512
|
-
const
|
|
2513
|
-
let
|
|
2513
|
+
const p = t.deliveries[l], m = t.submissions[l];
|
|
2514
|
+
let f = { ...p, phase: "waiting", effectId: null };
|
|
2514
2515
|
if (e.type === "effect.failed") {
|
|
2515
|
-
const y = e.error.details?.acceptance === "unissued" &&
|
|
2516
|
-
|
|
2517
|
-
...
|
|
2516
|
+
const y = e.error.details?.acceptance === "unissued" && p.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : p.acceptance, b = e.error.details?.allocation === "unissued" ? "unissued" : p.allocation, k = e.effectKind === "conversation.command" && p.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";
|
|
2517
|
+
f = {
|
|
2518
|
+
...f,
|
|
2518
2519
|
phase: R,
|
|
2519
2520
|
acceptance: y,
|
|
2520
2521
|
allocation: b,
|
|
2521
|
-
...
|
|
2522
|
+
...p.handoffRecovery && p.step === "send" ? { step: "receipt" } : {}
|
|
2522
2523
|
}, !m.cancelled && m.delivery !== "accepted" && (i = { ...i, submissions: {
|
|
2523
2524
|
...i.submissions,
|
|
2524
2525
|
[l]: { ...m, delivery: R, error: e.error }
|
|
2525
2526
|
} });
|
|
2526
2527
|
} else if (e.effectKind === "conversation.prepare")
|
|
2527
|
-
m.cancelled ?
|
|
2528
|
+
m.cancelled ? f = { ...f, phase: "failed" } : (f = { ...f, prepared: !0 }, i = { ...i, submissions: { ...i.submissions, [l]: {
|
|
2528
2529
|
...m,
|
|
2529
2530
|
...m.contextPreparation === null ? { contextPreparation: { pageContent: e.output.pageContent, sessionTabs: e.output.sessionTabs } } : {}
|
|
2530
|
-
} } },
|
|
2531
|
+
} } }, p.recoveryDeadline !== null && e.output.now >= p.recoveryDeadline && (f = { ...f, phase: "paused" }, i = { ...i, submissions: { ...i.submissions, [l]: {
|
|
2531
2532
|
...i.submissions[l],
|
|
2532
2533
|
delivery: "failed",
|
|
2533
2534
|
error: { code: "message_delivery_failed", message: "Pluno could not send this message. Try it again.", retryable: !0 }
|
|
2534
2535
|
} } }));
|
|
2535
2536
|
else if (e.effectKind === "conversation.upload") {
|
|
2536
|
-
const y = Z(e.output), b = m.attachments[
|
|
2537
|
+
const y = Z(e.output), b = m.attachments[p.uploads.length];
|
|
2537
2538
|
if (y.attachment.id !== b.sourceId || y.attachment.size_bytes !== b.sizeBytes || m.sessionId !== null && m.sessionId !== y.sessionId)
|
|
2538
2539
|
throw new Error("Upload does not match the captured attachment or conversation.");
|
|
2539
|
-
|
|
2540
|
+
f = { ...f, allocation: "resolved", uploads: [...p.uploads, y.attachment] };
|
|
2540
2541
|
const k = Object.fromEntries(Object.entries(i.submissions).map(([R, g]) => [
|
|
2541
2542
|
R,
|
|
2542
2543
|
g.conversationScopeId === m.conversationScopeId && (R === l || !g.cancelled && !m.cancelled) ? { ...g, sessionId: y.sessionId } : g
|
|
2543
2544
|
]));
|
|
2544
2545
|
i = { ...i, submissions: k };
|
|
2545
2546
|
} else if (e.effectKind === "conversation.receipt")
|
|
2546
|
-
if (e.output === null &&
|
|
2547
|
-
|
|
2547
|
+
if (e.output === null && p.handoffRecovery && !m.cancelled)
|
|
2548
|
+
f = { ...f, phase: "waiting", step: null };
|
|
2548
2549
|
else if (e.output === null)
|
|
2549
|
-
|
|
2550
|
+
f = { ...f, phase: m.cancelled ? "uncertain" : "paused" }, m.cancelled || (i = { ...i, submissions: { ...i.submissions, [l]: {
|
|
2550
2551
|
...m,
|
|
2551
2552
|
delivery: "failed",
|
|
2552
2553
|
error: { code: "message_acceptance_unconfirmed", message: "Pluno could not confirm whether this message was accepted. Try again.", retryable: !0 }
|
|
2553
2554
|
} } });
|
|
2554
2555
|
else {
|
|
2555
2556
|
const y = Hn(e.output, l);
|
|
2556
|
-
|
|
2557
|
+
f = { ...f, phase: "done", acceptance: "accepted" }, r = {
|
|
2557
2558
|
type: "conversation.submission_accepted",
|
|
2558
2559
|
authorityId: t.authorityId,
|
|
2559
2560
|
generation: t.generation,
|
|
@@ -2561,11 +2562,11 @@ function Ao(t, e, s, n) {
|
|
|
2561
2562
|
sessionId: y.sessionId
|
|
2562
2563
|
};
|
|
2563
2564
|
}
|
|
2564
|
-
else if (e.effectKind === "conversation.command" &&
|
|
2565
|
-
|
|
2566
|
-
else if (e.effectKind === "conversation.command" &&
|
|
2565
|
+
else if (e.effectKind === "conversation.command" && p.step === "complete")
|
|
2566
|
+
f = { ...f, completedUploads: p.completedUploads + 1, command: null };
|
|
2567
|
+
else if (e.effectKind === "conversation.command" && p.step === "send") {
|
|
2567
2568
|
const y = Hn(e.output, l);
|
|
2568
|
-
|
|
2569
|
+
f = { ...f, phase: "done", acceptance: "accepted" }, r = {
|
|
2569
2570
|
type: "conversation.submission_accepted",
|
|
2570
2571
|
authorityId: t.authorityId,
|
|
2571
2572
|
generation: t.generation,
|
|
@@ -2573,26 +2574,26 @@ function Ao(t, e, s, n) {
|
|
|
2573
2574
|
sessionId: y.sessionId
|
|
2574
2575
|
};
|
|
2575
2576
|
}
|
|
2576
|
-
i = { ...i, deliveries: { ...i.deliveries, [l]:
|
|
2577
|
+
i = { ...i, deliveries: { ...i.deliveries, [l]: f } };
|
|
2577
2578
|
} else if (h) {
|
|
2578
|
-
const
|
|
2579
|
+
const p = t.operations[h];
|
|
2579
2580
|
if (i = { ...i, operations: { ...i.operations, [h]: {
|
|
2580
|
-
...
|
|
2581
|
+
...p,
|
|
2581
2582
|
effectId: null,
|
|
2582
2583
|
phase: e.type === "effect.failed" ? e.error.retryable ? "uncertain" : "failed" : "done",
|
|
2583
2584
|
error: e.type === "effect.failed" ? e.error : null,
|
|
2584
2585
|
result: e.type === "effect.completed" ? Z(e.output) : null
|
|
2585
|
-
} } }, e.type === "effect.completed" && ["runtime.warmup", "attachment.prepare"].includes(
|
|
2586
|
+
} } }, e.type === "effect.completed" && ["runtime.warmup", "attachment.prepare"].includes(p.command.type) && !p.command.payload.sessionId && p.conversationScopeId && !Object.values(s.clients).includes(p.conversationScopeId)) {
|
|
2586
2587
|
const m = e.output;
|
|
2587
2588
|
m?.sessionId && (i = { ...i, operations: {
|
|
2588
2589
|
...i.operations,
|
|
2589
2590
|
[`cleanup:${h}`]: Qs({
|
|
2590
|
-
request_id: `cleanup:${
|
|
2591
|
+
request_id: `cleanup:${p.command.request_id}`,
|
|
2591
2592
|
type: "session.reset",
|
|
2592
2593
|
payload: {
|
|
2593
2594
|
sessionId: m.sessionId,
|
|
2594
|
-
...
|
|
2595
|
-
...
|
|
2595
|
+
...p.command.payload.warmupId ? { warmupId: p.command.payload.warmupId } : {},
|
|
2596
|
+
...p.command.payload.page ? { page: p.command.payload.page } : {}
|
|
2596
2597
|
}
|
|
2597
2598
|
})
|
|
2598
2599
|
} });
|
|
@@ -2606,16 +2607,16 @@ function Ao(t, e, s, n) {
|
|
|
2606
2607
|
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 ?? ""));
|
|
2607
2608
|
if (l.schema !== 1 || l.authorityId !== t.authorityId || !h || Object.keys(t.operations).length)
|
|
2608
2609
|
throw new Error("Delivery restoration requires an empty engine with the same authenticated authority.");
|
|
2609
|
-
const
|
|
2610
|
+
const p = { ...t.submissions, ...l.submissions };
|
|
2610
2611
|
for (const [g, v] of Object.entries(t.submissions))
|
|
2611
|
-
v.cancelled && (
|
|
2612
|
+
v.cancelled && (p[g] = { ...p[g], cancelled: !0, cancellationReason: v.cancellationReason });
|
|
2612
2613
|
const m = {
|
|
2613
2614
|
...l,
|
|
2614
|
-
submissions:
|
|
2615
|
+
submissions: p,
|
|
2615
2616
|
stops: { ...l.stops, ...t.stops },
|
|
2616
2617
|
deliveries: { ...t.deliveries, ...l.deliveries },
|
|
2617
2618
|
submissionOrder: [.../* @__PURE__ */ new Set([...l.submissionOrder, ...t.submissionOrder])]
|
|
2618
|
-
}, { schema:
|
|
2619
|
+
}, { schema: f, authorityId: y, ...b } = m, k = Z(e.pendingRestoration ?? {}), R = (g) => !s.clients[g.clientScopeId] && k[g.clientScopeId] === g.conversationScopeId;
|
|
2619
2620
|
i = {
|
|
2620
2621
|
...t,
|
|
2621
2622
|
...b,
|
|
@@ -2672,7 +2673,7 @@ function Ao(t, e, s, n) {
|
|
|
2672
2673
|
if (!l) throw new Error("Stage the immutable submission before sending.");
|
|
2673
2674
|
const h = t.deliveries[e.userMessageId];
|
|
2674
2675
|
if (h && !l.cancelled && l.delivery !== "accepted" && (h.phase === "uncertain" || e.manualRetry && ["paused", "failed"].includes(h.phase))) {
|
|
2675
|
-
const m = (h.acceptance === "unissued" || h.acceptance === "rejected") && h.allocation !== "uncertain" ? Math.max(t.requestSequence, ...Object.values(t.deliveries).map((
|
|
2676
|
+
const m = (h.acceptance === "unissued" || h.acceptance === "rejected") && h.allocation !== "uncertain" ? Math.max(t.requestSequence, ...Object.values(t.deliveries).map((f) => f.queuePosition)) + 1 : h.queuePosition;
|
|
2676
2677
|
i = {
|
|
2677
2678
|
...t,
|
|
2678
2679
|
effectsEnabled: !0,
|
|
@@ -2693,11 +2694,11 @@ function Ao(t, e, s, n) {
|
|
|
2693
2694
|
}
|
|
2694
2695
|
if (e.type === "conversation.recover" || e.type === "conversation.submit")
|
|
2695
2696
|
for (const [l, h] of Object.entries(i.deliveries)) {
|
|
2696
|
-
const
|
|
2697
|
-
h.phase !== "waiting" ||
|
|
2697
|
+
const p = i.submissions[l];
|
|
2698
|
+
h.phase !== "waiting" || p.cancelled || h.recoveryDeadline === null || e.now < h.recoveryDeadline || (i = {
|
|
2698
2699
|
...i,
|
|
2699
2700
|
deliveries: { ...i.deliveries, [l]: { ...h, phase: "paused" } },
|
|
2700
|
-
submissions: { ...i.submissions, [l]: { ...
|
|
2701
|
+
submissions: { ...i.submissions, [l]: { ...p, delivery: "failed", error: {
|
|
2701
2702
|
code: "message_delivery_failed",
|
|
2702
2703
|
message: "Pluno could not send this message. Try it again.",
|
|
2703
2704
|
retryable: !0
|
|
@@ -2712,12 +2713,12 @@ function Ao(t, e, s, n) {
|
|
|
2712
2713
|
const h = t.operations[l.request_id];
|
|
2713
2714
|
if (h && (JSON.stringify(h.command) !== JSON.stringify(l) || h.conversationScopeId !== (e.conversationScopeId ?? null))) throw new Error("Command identity changed.");
|
|
2714
2715
|
if (!h) {
|
|
2715
|
-
const
|
|
2716
|
-
if (s.selections[m]?.sessionId !== l.payload.sessionId) return [[m,
|
|
2717
|
-
const y =
|
|
2718
|
-
return y.length ? [[m, { ...
|
|
2716
|
+
const p = l.type === "chat.retry_last_user_message" ? Object.fromEntries(Object.entries(t.stops).flatMap(([m, f]) => {
|
|
2717
|
+
if (s.selections[m]?.sessionId !== l.payload.sessionId) return [[m, f]];
|
|
2718
|
+
const y = f.userMessageIds.filter((b) => b !== l.payload.clientMessageId);
|
|
2719
|
+
return y.length ? [[m, { ...f, userMessageIds: y }]] : [];
|
|
2719
2720
|
})) : t.stops;
|
|
2720
|
-
i = { ...t, stops:
|
|
2721
|
+
i = { ...t, stops: p, effectsEnabled: !0, operations: {
|
|
2721
2722
|
...t.operations,
|
|
2722
2723
|
[l.request_id]: Qs(l, e.conversationScopeId ?? null)
|
|
2723
2724
|
} };
|
|
@@ -2742,21 +2743,21 @@ function Ao(t, e, s, n) {
|
|
|
2742
2743
|
} }
|
|
2743
2744
|
};
|
|
2744
2745
|
const l = o.submissions[e.userMessageId], h = o.deliveries[e.userMessageId];
|
|
2745
|
-
h.phase === "waiting" && (o = { ...o, deliveries: Object.fromEntries(Object.entries(o.deliveries).map(([
|
|
2746
|
-
const
|
|
2747
|
-
return m.queuePosition < h.queuePosition && (
|
|
2746
|
+
h.phase === "waiting" && (o = { ...o, deliveries: Object.fromEntries(Object.entries(o.deliveries).map(([p, m]) => {
|
|
2747
|
+
const f = o.submissions[p];
|
|
2748
|
+
return m.queuePosition < h.queuePosition && (f.conversationScopeId === l.conversationScopeId || l.sessionId !== null && f.sessionId === l.sessionId) && m.acceptance === "uncertain" && ["uncertain", "paused"].includes(m.phase) && f.error?.code !== "message_acceptance_unconfirmed" ? [p, { ...m, phase: "waiting", effectId: null, prepared: !0, step: "receipt" }] : [p, m];
|
|
2748
2749
|
})) });
|
|
2749
2750
|
}
|
|
2750
2751
|
for (const [l, h] of Object.entries(o.submissions)) {
|
|
2751
|
-
const
|
|
2752
|
-
|
|
2752
|
+
const p = o.deliveries[l];
|
|
2753
|
+
p && (h.delivery === "accepted" && p.acceptance !== "accepted" ? o = {
|
|
2753
2754
|
...o,
|
|
2754
|
-
deliveries: { ...o.deliveries, [l]: { ...
|
|
2755
|
-
} : (h.cancelled || h.delivery === "failed") &&
|
|
2755
|
+
deliveries: { ...o.deliveries, [l]: { ...p, acceptance: "accepted", phase: "done", effectId: null } }
|
|
2756
|
+
} : (h.cancelled || h.delivery === "failed") && p.phase === "running" && !p.prepared && (o = {
|
|
2756
2757
|
...o,
|
|
2757
2758
|
// Stop retires readiness work, but a previously issued message still needs receipt reconciliation.
|
|
2758
2759
|
deliveries: { ...o.deliveries, [l]: {
|
|
2759
|
-
...
|
|
2760
|
+
...p,
|
|
2760
2761
|
phase: h.cancelled && we(o, l) ? "waiting" : "failed",
|
|
2761
2762
|
prepared: h.cancelled,
|
|
2762
2763
|
effectId: null
|
|
@@ -2923,31 +2924,31 @@ function Mo(t) {
|
|
|
2923
2924
|
requestId: u?.request_id ?? "cancellation",
|
|
2924
2925
|
clientMessageId: u ? String(u.payload.expectedUserMessageId) : null,
|
|
2925
2926
|
sessionId: u ? String(u.payload.sessionId) : null
|
|
2926
|
-
}), h = e,
|
|
2927
|
+
}), h = e, p = async () => {
|
|
2927
2928
|
if (!t.isCurrent() || a.authorityId !== t.authorityId) throw new Error("Cancellation authority was retired.");
|
|
2928
2929
|
if (!o && s && a.requestSequence <= s.requestSequence) return;
|
|
2929
2930
|
const m = await i();
|
|
2930
2931
|
if (m && m.authorityId !== t.authorityId) throw new Error("Cancellation checkpoint authority mismatch.");
|
|
2931
|
-
const
|
|
2932
|
+
const f = { authorityId: t.authorityId, requestSequence: Math.max(a.requestSequence, m?.requestSequence ?? 0), cancelled: { ...m?.cancelled }, operations: { ...m?.operations }, stops: { ...m?.stops } };
|
|
2932
2933
|
if (o) {
|
|
2933
|
-
s = a, a.requestSequence >= (m?.requestSequence ?? 0) && (
|
|
2934
|
-
for (const [y] of d) delete
|
|
2935
|
-
for (const [y, b] of Object.entries(a.stops))
|
|
2934
|
+
s = a, a.requestSequence >= (m?.requestSequence ?? 0) && (f.cancelled = {}, f.operations = {}, f.stops = {});
|
|
2935
|
+
for (const [y] of d) delete f.cancelled[y];
|
|
2936
|
+
for (const [y, b] of Object.entries(a.stops)) f.stops[y]?.requestId === b.requestId && delete f.stops[y];
|
|
2936
2937
|
for (const [y, b] of c)
|
|
2937
|
-
JSON.stringify(
|
|
2938
|
+
JSON.stringify(f.operations[y]?.command) === JSON.stringify(b.command) && delete f.operations[y];
|
|
2938
2939
|
} else {
|
|
2939
|
-
for (const [y, b] of d) s?.submissions[y]?.cancelled || (
|
|
2940
|
-
for (const [y, b] of Object.entries(a.stops)) s?.stops[y]?.requestId !== b.requestId && (
|
|
2941
|
-
for (const [y, b] of c) b.phase !== "done" && b.phase !== "failed" && JSON.stringify(s?.operations[y]?.command) !== JSON.stringify(b.command) && (
|
|
2940
|
+
for (const [y, b] of d) s?.submissions[y]?.cancelled || (f.cancelled[y] = { ...b, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } });
|
|
2941
|
+
for (const [y, b] of Object.entries(a.stops)) s?.stops[y]?.requestId !== b.requestId && (f.stops[y] = b);
|
|
2942
|
+
for (const [y, b] of c) b.phase !== "done" && b.phase !== "failed" && JSON.stringify(s?.operations[y]?.command) !== JSON.stringify(b.command) && (f.operations[y] = { ...b, effectId: null, phase: "uncertain", result: null, error: null });
|
|
2942
2943
|
}
|
|
2943
|
-
if (!(!m && !Object.keys(
|
|
2944
|
+
if (!(!m && !Object.keys(f.cancelled).length && !Object.keys(f.operations).length && !Object.keys(f.stops).length) && !(JSON.stringify(m?.cancelled ?? {}) === JSON.stringify(f.cancelled) && JSON.stringify(m?.operations ?? {}) === JSON.stringify(f.operations) && JSON.stringify(m?.stops ?? {}) === JSON.stringify(f.stops))) {
|
|
2944
2945
|
if (!t.isCurrent()) throw new Error("Cancellation authority was retired.");
|
|
2945
|
-
await l.measure("cancellation_write", () => t.write(
|
|
2946
|
+
await l.measure("cancellation_write", () => t.write(f)), n = Promise.resolve(f);
|
|
2946
2947
|
}
|
|
2947
2948
|
};
|
|
2948
2949
|
return e = l.measure("cancellation_queue", () => h.then(() => {
|
|
2949
2950
|
}, () => {
|
|
2950
|
-
})).then(
|
|
2951
|
+
})).then(p), e;
|
|
2951
2952
|
};
|
|
2952
2953
|
return {
|
|
2953
2954
|
save: (a) => r(a, !1),
|
|
@@ -5865,7 +5866,7 @@ class La {
|
|
|
5865
5866
|
connection_id: `pa-sio:${this.socket.id}`,
|
|
5866
5867
|
request_id: i,
|
|
5867
5868
|
session_id: e.sessionId ?? e.session_id
|
|
5868
|
-
}).replace(/[\u007f-\uffff]/g, (
|
|
5869
|
+
}).replace(/[\u007f-\uffff]/g, (p) => `\\u${p.charCodeAt(0).toString(16).padStart(4, "0")}`)
|
|
5869
5870
|
},
|
|
5870
5871
|
body: JSON.stringify({ request_id: i, type: "tool.result", payload: e })
|
|
5871
5872
|
});
|
|
@@ -5956,16 +5957,16 @@ function Fa(t) {
|
|
|
5956
5957
|
entrySurface: m.entrySurface
|
|
5957
5958
|
}) })) : [], l = e, h = Promise.all(u.map(({ timer: m }) => m.measure("checkpoint_queue", () => l.then(() => {
|
|
5958
5959
|
}, () => {
|
|
5959
|
-
})))),
|
|
5960
|
+
})))), p = async () => {
|
|
5960
5961
|
await h;
|
|
5961
5962
|
const m = async () => {
|
|
5962
|
-
const
|
|
5963
|
-
if (!
|
|
5963
|
+
const f = await d;
|
|
5964
|
+
if (!f.ok) throw f.error;
|
|
5964
5965
|
};
|
|
5965
|
-
await Promise.all(u.length ? u.map(({ timer:
|
|
5966
|
-
for (const { submission:
|
|
5966
|
+
await Promise.all(u.length ? u.map(({ timer: f }) => f.measure("checkpoint_prerequisite", m)) : [m()]), ee(t, t.authority), await t.saveDelivery(o, u[u.length - 1]?.timer);
|
|
5967
|
+
for (const { submission: f, timer: y } of u) y.mark(f.contextPreparation === null ? "checkpoint" : "checkpoint_prepared");
|
|
5967
5968
|
};
|
|
5968
|
-
return e = e.then(
|
|
5969
|
+
return e = e.then(p, p), e;
|
|
5969
5970
|
}, n = (o, c) => {
|
|
5970
5971
|
throw J(t) && !(o instanceof Error && "code" in o && ["executor_not_ready", "request_timed_out"].includes(String(o.code))) && t.onError?.(o, c), ke(o, c);
|
|
5971
5972
|
}, i = () => {
|
|
@@ -5976,7 +5977,7 @@ function Fa(t) {
|
|
|
5976
5977
|
throw Object.assign(new Error("Submission was cancelled."), { code: "submission_cancelled", retryable: !1 });
|
|
5977
5978
|
}, a = (o) => {
|
|
5978
5979
|
if (!t.onTiming || o.submission.sessionId !== null) return;
|
|
5979
|
-
const c = t.runtime(), d = Object.values(c.engine.getState().slices.conversation.operations).find((
|
|
5980
|
+
const c = t.runtime(), d = Object.values(c.engine.getState().slices.conversation.operations).find((p) => p.command.type === "runtime.warmup" && p.conversationScopeId === o.submission.conversationScopeId && ["waiting", "running", "uncertain"].includes(p.phase));
|
|
5980
5981
|
if (!d) return;
|
|
5981
5982
|
const u = Q(t.onTiming, {
|
|
5982
5983
|
operation: "send",
|
|
@@ -5989,12 +5990,12 @@ function Fa(t) {
|
|
|
5989
5990
|
let l = () => {
|
|
5990
5991
|
}, h = () => {
|
|
5991
5992
|
};
|
|
5992
|
-
u.measure("warmup_wait", () => new Promise((
|
|
5993
|
-
const
|
|
5993
|
+
u.measure("warmup_wait", () => new Promise((p, m) => {
|
|
5994
|
+
const f = () => {
|
|
5994
5995
|
const y = c.engine.getState().slices, b = y.conversation.submissions[o.submission.userMessageId], k = y.conversation.operations[d.command.request_id];
|
|
5995
|
-
!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)) &&
|
|
5996
|
+
!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)) && p();
|
|
5996
5997
|
};
|
|
5997
|
-
l = c.engine.subscribe(
|
|
5998
|
+
l = c.engine.subscribe(f), h = c.onDispose(() => m(new Error("Warmup wait was retired."))), f();
|
|
5998
5999
|
})).catch(() => {
|
|
5999
6000
|
}).finally(() => {
|
|
6000
6001
|
l(), h();
|
|
@@ -6017,14 +6018,14 @@ function Fa(t) {
|
|
|
6017
6018
|
new Error("Message preparation timed out. Retry this message."),
|
|
6018
6019
|
{ code: "submission_preparation_timeout", retryable: !0 }
|
|
6019
6020
|
));
|
|
6020
|
-
}, 18e4), h = t.runtime(),
|
|
6021
|
+
}, 18e4), h = t.runtime(), p = () => {
|
|
6021
6022
|
const y = h.engine.getState().slices, b = y.conversation.submissions[o.submission.userMessageId];
|
|
6022
6023
|
(!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 }));
|
|
6023
|
-
}, m = h.engine.subscribe(
|
|
6024
|
-
return
|
|
6024
|
+
}, m = h.engine.subscribe(p), f = h.onDispose(() => u(Object.assign(new Error("Submission runtime was disposed."), { code: "aborted" })));
|
|
6025
|
+
return p(), wt(c.signal, () => t.prepareSubmission(o, c.signal).then((y) => (c.signal.aborted && d.mark("context_discarded"), y), (y) => {
|
|
6025
6026
|
throw c.signal.aborted && d.mark("context_discarded"), y;
|
|
6026
|
-
})).then((y) => (
|
|
6027
|
-
clearTimeout(l), m(),
|
|
6027
|
+
})).then((y) => (p(), c.signal.throwIfAborted(), a(o), y)).catch((y) => (u(y), n(y, { operation: "conversation.prepare", requestId: o.submission.userMessageId }))).finally(() => {
|
|
6028
|
+
clearTimeout(l), m(), f();
|
|
6028
6029
|
});
|
|
6029
6030
|
},
|
|
6030
6031
|
"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) }),
|
|
@@ -6072,14 +6073,14 @@ function Fa(t) {
|
|
|
6072
6073
|
);
|
|
6073
6074
|
if (ee(t, o), h.request_id !== o.command.request_id || !Be(h.result)) throw Object.assign(new Error("Conversation response identity mismatch."), { code: "acceptance_identity_mismatch" });
|
|
6074
6075
|
if (o.command.type.startsWith("chat.")) {
|
|
6075
|
-
const
|
|
6076
|
-
if (typeof
|
|
6076
|
+
const p = h.result;
|
|
6077
|
+
if (typeof p?.sessionId != "string" || !p.sessionId || p.clientMessageId !== o.command.payload.clientMessageId || o.command.payload.sessionId && p.sessionId !== o.command.payload.sessionId) throw Object.assign(new Error("Conversation acceptance identity mismatch."), { code: "acceptance_identity_mismatch" });
|
|
6077
6078
|
Q(t.onTiming, {
|
|
6078
6079
|
operation: "send",
|
|
6079
6080
|
layer: "http",
|
|
6080
6081
|
requestId: o.command.request_id,
|
|
6081
6082
|
clientMessageId: String(d.clientMessageId),
|
|
6082
|
-
sessionId:
|
|
6083
|
+
sessionId: p.sessionId
|
|
6083
6084
|
}).mark("acceptance_received");
|
|
6084
6085
|
}
|
|
6085
6086
|
return h.result;
|
|
@@ -6109,8 +6110,8 @@ function Fa(t) {
|
|
|
6109
6110
|
}).measure("attachment_upload", () => Promise.resolve().then(async () => {
|
|
6110
6111
|
const d = () => {
|
|
6111
6112
|
if (ee(t, o), !o.preparationId) return r(o.submission.userMessageId);
|
|
6112
|
-
const
|
|
6113
|
-
if (!Object.values(
|
|
6113
|
+
const f = t.runtime().engine.getState().slices.directory;
|
|
6114
|
+
if (!Object.values(f.clients).includes(o.submission.conversationScopeId))
|
|
6114
6115
|
throw Object.assign(new Error("Attachment preparation was cancelled."), { code: "submission_cancelled", retryable: !1 });
|
|
6115
6116
|
};
|
|
6116
6117
|
d(), await s(), d();
|
|
@@ -6135,18 +6136,18 @@ function Fa(t) {
|
|
|
6135
6136
|
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)
|
|
6136
6137
|
throw Object.assign(new Error("Attachment preparation identity mismatch."), { code: "attachment_identity_mismatch", retryable: !1 });
|
|
6137
6138
|
if ("uploadUrl" in h) {
|
|
6138
|
-
const
|
|
6139
|
-
if (!
|
|
6139
|
+
const f = await fetch(t.http.resolveUrl(h.uploadUrl), { method: h.uploadMethod, headers: h.uploadHeaders, body: u });
|
|
6140
|
+
if (!f.ok) throw Object.assign(new Error("Attachment transfer failed."), { code: String(f.status) });
|
|
6140
6141
|
}
|
|
6141
6142
|
d();
|
|
6142
|
-
const
|
|
6143
|
-
id:
|
|
6144
|
-
name:
|
|
6145
|
-
mime_type:
|
|
6146
|
-
size_bytes:
|
|
6147
|
-
storage_key:
|
|
6148
|
-
sandbox_path:
|
|
6149
|
-
file_url:
|
|
6143
|
+
const p = h.attachment, m = {
|
|
6144
|
+
id: p.id ?? null,
|
|
6145
|
+
name: p.name,
|
|
6146
|
+
mime_type: p.mimeType,
|
|
6147
|
+
size_bytes: p.sizeBytes,
|
|
6148
|
+
storage_key: p.storageKey ?? null,
|
|
6149
|
+
sandbox_path: p.sandboxPath ?? null,
|
|
6150
|
+
file_url: p.fileUrl ?? null
|
|
6150
6151
|
};
|
|
6151
6152
|
return await t.onUploaded?.(o.source.sourceId, h.sessionId, m), d(), { sessionId: h.sessionId, attachment: m };
|
|
6152
6153
|
}).catch((d) => {
|
|
@@ -6160,12 +6161,12 @@ function Fa(t) {
|
|
|
6160
6161
|
"conversation.snapshot": (o) => Promise.resolve().then(async () => {
|
|
6161
6162
|
ee(t, o);
|
|
6162
6163
|
const c = t.runtime(), d = new AbortController(), u = () => {
|
|
6163
|
-
const
|
|
6164
|
-
J(t) ?
|
|
6164
|
+
const p = c.engine.getState().slices;
|
|
6165
|
+
J(t) ? p.directory.memberships[o.sessionId]?.members.length ? p.conversation.sessions[o.sessionId]?.queries[o.lane].requestId !== o.requestId && d.abort("request_replaced") : d.abort("observation_released") : d.abort("authority_retired");
|
|
6165
6166
|
}, l = c.engine.subscribe(u), h = c.onDispose(() => d.abort("owner_disposed"));
|
|
6166
6167
|
u();
|
|
6167
6168
|
try {
|
|
6168
|
-
const
|
|
6169
|
+
const p = [];
|
|
6169
6170
|
for (let b = 0; b < Math.max(1, o.refreshItemIds.length); b += 200) {
|
|
6170
6171
|
if (ee(t, o), !t.runtime().engine.getState().slices.directory.memberships[o.sessionId]?.members.length) throw new Error("Conversation observation was retired.");
|
|
6171
6172
|
const k = await t.http.request(
|
|
@@ -6181,27 +6182,27 @@ function Fa(t) {
|
|
|
6181
6182
|
authorityGeneration: o.generation
|
|
6182
6183
|
} }
|
|
6183
6184
|
).catch((R) => {
|
|
6184
|
-
if (
|
|
6185
|
+
if (p.length === 0) throw R;
|
|
6185
6186
|
const g = ke(R);
|
|
6186
|
-
throw Object.assign(g, { details: { ...g.details, successfulRequests:
|
|
6187
|
+
throw Object.assign(g, { details: { ...g.details, successfulRequests: p.length } });
|
|
6187
6188
|
});
|
|
6188
6189
|
if (ee(t, o), k.conversation_id !== o.sessionId) throw new Error("Snapshot conversation identity mismatch.");
|
|
6189
|
-
if (
|
|
6190
|
+
if (p.push(k), !k.projection_ready) break;
|
|
6190
6191
|
}
|
|
6191
|
-
const m =
|
|
6192
|
+
const m = p[0];
|
|
6192
6193
|
if (o.before !== null && m.next_cursor === o.before)
|
|
6193
6194
|
throw Object.assign(new Error("Conversation history cursor did not advance."), { code: "invalid_history_cursor" });
|
|
6194
|
-
const
|
|
6195
|
+
const f = p.reduce((b, k) => k.execution.version > b.version ? k.execution : b, m.execution), y = p.reduce((b, k) => k.follow_ups_version > b.follow_ups_version ? k : b, m);
|
|
6195
6196
|
return { snapshot: {
|
|
6196
6197
|
...m,
|
|
6197
|
-
execution:
|
|
6198
|
-
items:
|
|
6199
|
-
streams:
|
|
6200
|
-
removed_items:
|
|
6201
|
-
interactions:
|
|
6198
|
+
execution: f,
|
|
6199
|
+
items: p.flatMap((b) => b.items),
|
|
6200
|
+
streams: p.flatMap((b) => b.streams),
|
|
6201
|
+
removed_items: p.flatMap((b) => b.removed_items),
|
|
6202
|
+
interactions: p.flatMap((b) => b.interactions),
|
|
6202
6203
|
follow_ups: y.follow_ups,
|
|
6203
6204
|
follow_ups_version: y.follow_ups_version,
|
|
6204
|
-
projection_ready:
|
|
6205
|
+
projection_ready: p.every((b) => b.projection_ready)
|
|
6205
6206
|
}, updatedAt: t.now() };
|
|
6206
6207
|
} finally {
|
|
6207
6208
|
l(), h();
|
|
@@ -6259,13 +6260,13 @@ class $a {
|
|
|
6259
6260
|
poll: async () => {
|
|
6260
6261
|
const l = this.subscriptionIdentity();
|
|
6261
6262
|
if (!l) return;
|
|
6262
|
-
await this.options.socket.retain(r, o).catch((
|
|
6263
|
-
const m =
|
|
6264
|
-
if (
|
|
6265
|
-
const
|
|
6266
|
-
|
|
6263
|
+
await this.options.socket.retain(r, o).catch((p) => {
|
|
6264
|
+
const m = p instanceof T && p.code === "409" && p.message === "This conversation is temporarily unavailable. Please try again later.";
|
|
6265
|
+
if (p instanceof T && p.backendRefusal && !p.outcomeUnknown && !m && p.detail?.retryable !== !0) {
|
|
6266
|
+
const f = this.observations.get(r);
|
|
6267
|
+
f?.subscription === c && (f.subscriptionDenied = !0), c.stop(), this.report(p);
|
|
6267
6268
|
}
|
|
6268
|
-
throw
|
|
6269
|
+
throw p;
|
|
6269
6270
|
});
|
|
6270
6271
|
const h = this.observations.get(r);
|
|
6271
6272
|
h?.subscription === c && h.subscriptionIdentity === l && this.subscriptionIdentity() === l && (h.subscribed = !0, c.stop()), this.observations.get(r)?.subscription !== c && await this.options.socket.release(r, o);
|
|
@@ -6475,7 +6476,7 @@ function ms(t, e, s, n) {
|
|
|
6475
6476
|
createdAt: "",
|
|
6476
6477
|
loading: !1
|
|
6477
6478
|
});
|
|
6478
|
-
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),
|
|
6479
|
+
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), p = 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 || p) && !_.cancelled && _.delivery === "failed" && _.error).map((_) => [_.userMessageId, _])), f = a.flatMap((_) => {
|
|
6479
6480
|
const q = _.role === "user" ? m.get(_.id) : void 0;
|
|
6480
6481
|
return q?.error ? [_, {
|
|
6481
6482
|
id: `submission-error:${q.userMessageId}`,
|
|
@@ -6491,13 +6492,13 @@ function ms(t, e, s, n) {
|
|
|
6491
6492
|
code: "submission_checkpoint_pending",
|
|
6492
6493
|
message: Xr,
|
|
6493
6494
|
details: { requestId: k.requestId }
|
|
6494
|
-
} : null, g = u?.delivery === "failed" && !u.cancelled && !
|
|
6495
|
+
} : null, g = u?.delivery === "failed" && !u.cancelled && !p ? u.error : b ?? R;
|
|
6495
6496
|
let I = {
|
|
6496
6497
|
isRetrying: t.isRetrying ?? !1,
|
|
6497
6498
|
historyRefreshFailure: g === e?.error ? t.historyRefreshFailure ?? null : null,
|
|
6498
6499
|
conversationDiagnostics: {
|
|
6499
6500
|
...g ? { errorMessageFingerprint: Xi(Me(g.message)) } : {},
|
|
6500
|
-
...u && g && g === u.error && !
|
|
6501
|
+
...u && g && g === u.error && !p ? { failedClientMessageId: u.userMessageId } : {},
|
|
6501
6502
|
...typeof g?.details?.requestId == "string" ? { errorRequestId: g.details.requestId } : {},
|
|
6502
6503
|
...rt(g?.details?.errorNormalization) ? { errorNormalization: g.details.errorNormalization } : {},
|
|
6503
6504
|
...n ? { owner: n } : {},
|
|
@@ -6511,7 +6512,7 @@ function ms(t, e, s, n) {
|
|
|
6511
6512
|
stableSelectionKey: t.stableSelectionKey,
|
|
6512
6513
|
isDraftSession: t.isDraftSession,
|
|
6513
6514
|
sessionId: t.sessionId,
|
|
6514
|
-
messages:
|
|
6515
|
+
messages: f,
|
|
6515
6516
|
removedItems: o,
|
|
6516
6517
|
activeResponseUserMessageId: t.activity.userMessageId ?? t.segments[t.segments.length - 1]?.userMessageId ?? u?.userMessageId ?? null,
|
|
6517
6518
|
segments: t.segments,
|
|
@@ -6753,24 +6754,24 @@ class hr {
|
|
|
6753
6754
|
}) : this.options.pendingAuthentication?.()), c();
|
|
6754
6755
|
const h = this.options.authenticationFailure?.();
|
|
6755
6756
|
if (h) throw h;
|
|
6756
|
-
const
|
|
6757
|
+
const p = this.auth.token;
|
|
6757
6758
|
let m = null;
|
|
6758
6759
|
try {
|
|
6759
|
-
let
|
|
6760
|
+
let f = n;
|
|
6760
6761
|
if (r === "conversations" && e === "/commands" && this.auth.role !== "session_surface" && this.options.executorConnection) {
|
|
6761
6762
|
if (m = this.options.executorConnection(), !m) throw new T("Reconnecting the browser before continuing.", "executor_not_ready");
|
|
6762
6763
|
const k = n;
|
|
6763
|
-
|
|
6764
|
+
f = { ...k, context: { ...k.context, connection_id: m } };
|
|
6764
6765
|
}
|
|
6765
|
-
const y = () => this.requestOnce(e, s,
|
|
6766
|
+
const y = () => this.requestOnce(e, s, f, i, r, a.signal, a.diagnostic, ++u), b = await (a.timing ? a.timing.measure("http_request", y) : y());
|
|
6766
6767
|
return c(), b;
|
|
6767
|
-
} catch (
|
|
6768
|
-
if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw
|
|
6769
|
-
if (
|
|
6768
|
+
} catch (f) {
|
|
6769
|
+
if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw f;
|
|
6770
|
+
if (f instanceof T && f.code === "executor_not_ready" && m && l === 0 && this.options.restoreExecutor) {
|
|
6770
6771
|
await this.options.restoreExecutor(m), l++, c();
|
|
6771
6772
|
continue;
|
|
6772
6773
|
}
|
|
6773
|
-
if (!(
|
|
6774
|
+
if (!(f instanceof T) || !["unauthorized", "403"].includes(f.code) || !this.options.recoverAuthentication || !d || (await this.options.recoverAuthentication(p, f, d && l === 0), c(), !d || l !== 0)) throw f;
|
|
6774
6775
|
l++;
|
|
6775
6776
|
}
|
|
6776
6777
|
}
|
|
@@ -6780,10 +6781,10 @@ class hr {
|
|
|
6780
6781
|
for (const [E, C] of Object.entries({ ...l, ...s }))
|
|
6781
6782
|
C != null && u.searchParams.set(E, String(C));
|
|
6782
6783
|
this.requests.signal.throwIfAborted(), a?.throwIfAborted();
|
|
6783
|
-
const h = new AbortController(),
|
|
6784
|
-
h.signal.aborted || (
|
|
6785
|
-
},
|
|
6786
|
-
this.requests.signal.addEventListener("abort",
|
|
6784
|
+
const h = new AbortController(), p = { trigger: null }, m = (E) => {
|
|
6785
|
+
h.signal.aborted || (p.trigger = E, h.abort());
|
|
6786
|
+
}, f = () => m("transport_disposed"), y = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
|
|
6787
|
+
this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", y, { once: !0 });
|
|
6787
6788
|
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 = Qa(), v = Date.now();
|
|
6788
6789
|
let I = null, w = !1, A = null, _ = null, q = null;
|
|
6789
6790
|
try {
|
|
@@ -6816,7 +6817,7 @@ class hr {
|
|
|
6816
6817
|
}
|
|
6817
6818
|
return await E.json();
|
|
6818
6819
|
} catch (E) {
|
|
6819
|
-
const C =
|
|
6820
|
+
const C = p.trigger ?? ((E instanceof Error || E instanceof DOMException) && E.name === "AbortError" ? "unexpected_abort" : null), M = {
|
|
6820
6821
|
requestId: g,
|
|
6821
6822
|
method: i ?? (n === void 0 ? "GET" : "POST"),
|
|
6822
6823
|
route: b ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
|
|
@@ -6855,7 +6856,7 @@ class hr {
|
|
|
6855
6856
|
S
|
|
6856
6857
|
) : E;
|
|
6857
6858
|
} finally {
|
|
6858
|
-
clearTimeout(R), this.requests.signal.removeEventListener("abort",
|
|
6859
|
+
clearTimeout(R), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", y);
|
|
6859
6860
|
}
|
|
6860
6861
|
}
|
|
6861
6862
|
}
|
|
@@ -7248,16 +7249,16 @@ class sc {
|
|
|
7248
7249
|
if (e !== void 0 && r.some((c) => c.sessionId !== e)) return !1;
|
|
7249
7250
|
const a = [], o = new Set(r.map((c) => c.sessionId));
|
|
7250
7251
|
for (const c of o) {
|
|
7251
|
-
const d = r.filter((
|
|
7252
|
-
for (const
|
|
7253
|
-
const m = { ...this.options.authority, clientScopeId:
|
|
7254
|
-
|
|
7252
|
+
const d = r.filter((p) => p.sessionId === c), u = c === null ? d[0] : d.find((p) => p.clientScopeId === n.mains[c]) ?? this.choose(d), l = [u, ...d.filter((p) => p !== u)], h = /* @__PURE__ */ new Set();
|
|
7253
|
+
for (const p of l) {
|
|
7254
|
+
const m = { ...this.options.authority, clientScopeId: p.clientScopeId, conversationScopeId: p.conversationScopeId, replacement: null };
|
|
7255
|
+
p.provisionalId !== null && !h.has(p.conversationScopeId) && !s.selections[p.conversationScopeId]?.sessionId ? (a.push({ ...m, type: "directory.provisional", provisionalId: p.provisionalId }), c !== null && (a.push({
|
|
7255
7256
|
...this.options.authority,
|
|
7256
7257
|
type: "directory.accepted",
|
|
7257
|
-
conversationScopeId:
|
|
7258
|
-
provisionalId:
|
|
7258
|
+
conversationScopeId: p.conversationScopeId,
|
|
7259
|
+
provisionalId: p.provisionalId,
|
|
7259
7260
|
sessionId: c
|
|
7260
|
-
}), h.add(
|
|
7261
|
+
}), h.add(p.conversationScopeId))) : a.push({ ...m, type: "directory.bind", sessionId: c, reason: "user" });
|
|
7261
7262
|
}
|
|
7262
7263
|
}
|
|
7263
7264
|
return await Promise.all(a.map((c) => this.options.runtime.engine.dispatch(c))), !0;
|
|
@@ -7551,7 +7552,7 @@ class L extends EventTarget {
|
|
|
7551
7552
|
if (n === "auth.session") {
|
|
7552
7553
|
if (this.initialized) return;
|
|
7553
7554
|
this.initialized = !0;
|
|
7554
|
-
const h = this.bootstrapRequests.signal,
|
|
7555
|
+
const h = this.bootstrapRequests.signal, p = this.credentialBootstrap ?? await this.httpTransport.request(
|
|
7555
7556
|
r ? "/bootstrap" : "/me",
|
|
7556
7557
|
r ? o : {},
|
|
7557
7558
|
void 0,
|
|
@@ -7559,8 +7560,8 @@ class L extends EventTarget {
|
|
|
7559
7560
|
void 0,
|
|
7560
7561
|
{ signal: h }
|
|
7561
7562
|
);
|
|
7562
|
-
if (h.aborted || !this.isCurrent(s) || (this.credentialBootstrap = null, !this.options.auth.community_id &&
|
|
7563
|
-
this.options.auth.client_kind === "extension" && this.receive({ type: "executor.registered", userId:
|
|
7563
|
+
if (h.aborted || !this.isCurrent(s) || (this.credentialBootstrap = null, !this.options.auth.community_id && p.user?.runtimeCommunityId && (this.options.auth.community_id = p.user.runtimeCommunityId), this.receive({ type: "auth.ok", ...p }), h.aborted)) return;
|
|
7564
|
+
this.options.auth.client_kind === "extension" && this.receive({ type: "executor.registered", userId: p.user.id }), this.bootstrapped = !0;
|
|
7564
7565
|
for (const m of this.beforeBootstrap.splice(0)) this.receive(m);
|
|
7565
7566
|
this.synchronizeReferences();
|
|
7566
7567
|
return;
|
|
@@ -7570,8 +7571,8 @@ class L extends EventTarget {
|
|
|
7570
7571
|
return;
|
|
7571
7572
|
}
|
|
7572
7573
|
if (n === "starter_prompts.page_url" || n === "starter_prompts.page_context") {
|
|
7573
|
-
const h = ++this.promptRevision,
|
|
7574
|
-
this.isCurrent(s) && h === this.promptRevision && a === this.options.pageUrl() && this.receive({ type: "starterPrompts.updated", ...
|
|
7574
|
+
const h = ++this.promptRevision, p = await this.http("/starter-prompts", o, n === "starter_prompts.page_context" ? { page_url: a, page_title: e.pageTitle ?? "", html_content: e.htmlContent ?? "" } : void 0);
|
|
7575
|
+
this.isCurrent(s) && h === this.promptRevision && a === this.options.pageUrl() && this.receive({ type: "starterPrompts.updated", ...p });
|
|
7575
7576
|
return;
|
|
7576
7577
|
}
|
|
7577
7578
|
if (n === "session.load") {
|
|
@@ -7700,7 +7701,7 @@ function ac(t, e, s, n, i, r, a, o, c = null, d = !1) {
|
|
|
7700
7701
|
}
|
|
7701
7702
|
const cc = 1e4, dc = 3e3;
|
|
7702
7703
|
function mr() {
|
|
7703
|
-
return { authenticated: !1, generation: 0, sequence: 0, displaySequence: 0, backendCount: null, query:
|
|
7704
|
+
return { authenticated: !1, generation: 0, sequence: 0, displaySequence: 0, backendCount: null, query: ve("activeUsers") };
|
|
7704
7705
|
}
|
|
7705
7706
|
function lc(t, e) {
|
|
7706
7707
|
if (e.type === "activeUsers.authenticate") {
|
|
@@ -7901,7 +7902,7 @@ function pc(t, e, s) {
|
|
|
7901
7902
|
}
|
|
7902
7903
|
function fc(t, e, s, n) {
|
|
7903
7904
|
const i = t.clients[e];
|
|
7904
|
-
return i === void 0 || t.selections[i].sessionId === s ? !0 : !n || Object.values(n.pendingRestoration).includes(i) || Object.values(n.submissions).some((r) => r.conversationScopeId === i && !r.cancelled) ? !1 : t.selections[i].sessionId === null ||
|
|
7905
|
+
return i === void 0 || t.selections[i].sessionId === s ? !0 : !n || Object.values(n.pendingRestoration).includes(i) || Object.values(n.submissions).some((r) => r.conversationScopeId === i && !r.cancelled) ? !1 : t.selections[i].sessionId === null || ge(n, t, i).isDraftSession;
|
|
7905
7906
|
}
|
|
7906
7907
|
function on(t) {
|
|
7907
7908
|
return {
|
|
@@ -7941,17 +7942,17 @@ function qe(t, e, s) {
|
|
|
7941
7942
|
if (e.type === "effect.failed")
|
|
7942
7943
|
n = { ...n, queries: { ...n.queries, [o]: { ...c, status: "error", error: { ...e.error }, requestId: null, consecutiveFailures: c.consecutiveFailures + 1 } } };
|
|
7943
7944
|
else if (e.effectKind === "directory.query") {
|
|
7944
|
-
for (const
|
|
7945
|
-
const d = e.output.entries.map((
|
|
7946
|
-
for (const
|
|
7947
|
-
if (typeof
|
|
7948
|
-
u[
|
|
7949
|
-
const y = c.startedAtActivityRevisionBySessionId[
|
|
7950
|
-
y !== void 0 && h[
|
|
7945
|
+
for (const f of e.output.entries) n = vs(n, f, !0);
|
|
7946
|
+
const d = e.output.entries.map((f) => f.conversation_id), u = { ...n.durableActivityBySessionId }, l = { ...n.activityBySessionId }, h = { ...n.activityRevisionBySessionId };
|
|
7947
|
+
for (const f of e.output.entries) {
|
|
7948
|
+
if (typeof f.is_active != "boolean") continue;
|
|
7949
|
+
u[f.conversation_id] = f.is_active;
|
|
7950
|
+
const y = c.startedAtActivityRevisionBySessionId[f.conversation_id];
|
|
7951
|
+
y !== void 0 && h[f.conversation_id] === y && (delete l[f.conversation_id], delete h[f.conversation_id]);
|
|
7951
7952
|
}
|
|
7952
7953
|
n = { ...n, durableActivityBySessionId: u, activityBySessionId: l, activityRevisionBySessionId: h };
|
|
7953
|
-
const
|
|
7954
|
-
n = { ...n, optimisticEntries:
|
|
7954
|
+
const p = Object.fromEntries(Object.entries(n.optimisticEntries).filter(([, f]) => f.sessionId === null || !d.includes(f.sessionId)));
|
|
7955
|
+
n = { ...n, optimisticEntries: p };
|
|
7955
7956
|
const m = [.../* @__PURE__ */ new Set([...c.mode === "append" ? c.data ?? [] : [], ...d])];
|
|
7956
7957
|
n = { ...n, queries: { ...n.queries, [o]: {
|
|
7957
7958
|
...c,
|
|
@@ -8032,7 +8033,7 @@ function qe(t, e, s) {
|
|
|
8032
8033
|
query: u,
|
|
8033
8034
|
cursor: e.cursor !== void 0 ? e.cursor : e.mode === "append" ? d?.cursor ?? null : null
|
|
8034
8035
|
} }, n = { ...t, queries: { ...t.queries, [c]: {
|
|
8035
|
-
...Ne(d ??
|
|
8036
|
+
...Ne(d ?? ve(c), { key: c, requestId: e.requestId, mode: e.mode }),
|
|
8036
8037
|
query: u,
|
|
8037
8038
|
requestSequence: t.requestSequence + 1,
|
|
8038
8039
|
mode: e.mode,
|
|
@@ -8349,7 +8350,7 @@ function fi(t, e, s) {
|
|
|
8349
8350
|
for (const [a, o] of Object.entries(s.memberships)) {
|
|
8350
8351
|
const c = s.clients[o.members[0]];
|
|
8351
8352
|
if (!c) continue;
|
|
8352
|
-
const d =
|
|
8353
|
+
const d = ge(e, s, c), u = ge(t, s, c);
|
|
8353
8354
|
if (d.activity.phase === u.activity.phase) continue;
|
|
8354
8355
|
const l = ["submitting", "awaiting_execution", "thinking", "steering", "queued", "stopping"].includes(d.activity.phase);
|
|
8355
8356
|
n = qe(n, { ...i, type: "directory.activity_set", sessionId: a, active: l }).state;
|
|
@@ -8385,10 +8386,10 @@ class Sc {
|
|
|
8385
8386
|
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 };
|
|
8386
8387
|
}
|
|
8387
8388
|
if (bc(o)) {
|
|
8388
|
-
const d = qe(r.slices.directory, o, r.slices.conversation), u = Xs(Gs(r.slices.conversation, d.state, o.type === "directory.authority_replace" && o.adoptLocalSubmissions === !0)), l = Js(r.slices.conversation, u.state, d.state, d.state.clients !== r.slices.directory.clients), h = l.state,
|
|
8389
|
-
return { state:
|
|
8389
|
+
const d = qe(r.slices.directory, o, r.slices.conversation), u = Xs(Gs(r.slices.conversation, d.state, o.type === "directory.authority_replace" && o.adoptLocalSubmissions === !0)), l = Js(r.slices.conversation, u.state, d.state, d.state.clients !== r.slices.directory.clients), h = l.state, p = fi(r.slices.conversation, h, d.state);
|
|
8390
|
+
return { state: p === r.slices.directory && h === r.slices.conversation ? r : Object.freeze({
|
|
8390
8391
|
revision: r.revision + 1,
|
|
8391
|
-
slices: Object.freeze({ ...r.slices, directory:
|
|
8392
|
+
slices: Object.freeze({ ...r.slices, directory: p, conversation: h })
|
|
8392
8393
|
}), effects: [...l.effects, ...d.effects, ...u.effects] };
|
|
8393
8394
|
}
|
|
8394
8395
|
if (Ic(o)) {
|
|
@@ -8419,17 +8420,17 @@ class Sc {
|
|
|
8419
8420
|
}).state);
|
|
8420
8421
|
}
|
|
8421
8422
|
u = fi(r.slices.conversation, d.state, u);
|
|
8422
|
-
const h = Xs(Gs(d.state, u)),
|
|
8423
|
+
const h = Xs(Gs(d.state, u)), p = Js(d.state, h.state, u);
|
|
8423
8424
|
let m = r.slices;
|
|
8424
|
-
const
|
|
8425
|
+
const f = [], y = d.interactionSources, b = m.account.authority;
|
|
8425
8426
|
if (y && b && b.authorityId === y.authorityId && b.generation === y.generation) {
|
|
8426
|
-
const k = zs(m, { type: "stage7.sources", authority: b, now: m.features.now, sources: y.sources }, { conversation:
|
|
8427
|
-
m = G(Z({ account: k.state.account, features: k.state.features, interactions: k.state.interactions })),
|
|
8427
|
+
const k = zs(m, { type: "stage7.sources", authority: b, now: m.features.now, sources: y.sources }, { conversation: p.state, directory: u });
|
|
8428
|
+
m = G(Z({ account: k.state.account, features: k.state.features, interactions: k.state.interactions })), f.push(...k.effects);
|
|
8428
8429
|
}
|
|
8429
|
-
return { state:
|
|
8430
|
+
return { state: p.state === r.slices.conversation && u === r.slices.directory && m === r.slices ? r : Object.freeze({
|
|
8430
8431
|
revision: r.revision + 1,
|
|
8431
|
-
slices: Object.freeze({ ...r.slices, account: m.account, features: m.features, interactions: m.interactions, directory: u, conversation:
|
|
8432
|
-
}), effects: [...d.effects, ...
|
|
8432
|
+
slices: Object.freeze({ ...r.slices, account: m.account, features: m.features, interactions: m.interactions, directory: u, conversation: p.state })
|
|
8433
|
+
}), effects: [...d.effects, ...f, ...p.effects, ...h.effects] };
|
|
8433
8434
|
}
|
|
8434
8435
|
const c = hc(r.slices.modelSelection, o);
|
|
8435
8436
|
return { state: c === r.slices.modelSelection ? r : Object.freeze({
|
|
@@ -9395,13 +9396,13 @@ class fu {
|
|
|
9395
9396
|
const u = c && e.sessionId !== null && e.isLoadingSession && !e.isDraftSession;
|
|
9396
9397
|
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 = yt(e), s !== void 0 && !this.modelExplicit && (this.model = s), e.status === "connected" && e.submissionReady !== !1 && (this.hasBeenReady = !0);
|
|
9397
9398
|
for (const [l, h] of this.stopPreviews) {
|
|
9398
|
-
const
|
|
9399
|
-
(h !== void 0 && h !== "[]" &&
|
|
9399
|
+
const p = e.activity?.executionKey;
|
|
9400
|
+
(h !== void 0 && h !== "[]" && p !== void 0 && p !== "[]" && (p !== h || ["completed", "failed", "stopped"].includes(e.activity.phase)) || (h === void 0 || h === "[]") && e.messages.some((f) => f.respondsToUserMessageId === l && !f.provisional && f.loading !== !0 && (f.dataType === "run_status" || f.dataType === "run_error" || f.role === "assistant" && f.phase !== "commentary" && (f.streamState === void 0 || ["finished", "stopped", "failed"].includes(f.streamState))))) && this.stopPreviews.delete(l);
|
|
9400
9401
|
}
|
|
9401
9402
|
if (this.pendingStop?.userMessageIds.every((l) => !this.stopPreviews.has(l)) && (this.pendingStop = null), a.user?.id === e.user?.id)
|
|
9402
9403
|
for (const l of this.state.messages) {
|
|
9403
9404
|
if (l.role !== "user" || !l.attachments?.length) continue;
|
|
9404
|
-
const h = a.messages.find((
|
|
9405
|
+
const h = a.messages.find((p) => p.role === "user" && p.id === l.id);
|
|
9405
9406
|
a.sessionId !== e.sessionId && !(a.sessionId === null && h) || (l.attachments = sd(h?.attachments, l.attachments));
|
|
9406
9407
|
}
|
|
9407
9408
|
if (n && JSON.stringify(n) !== JSON.stringify(this.sessionHistoryState)) {
|
|
@@ -9534,10 +9535,10 @@ class fu {
|
|
|
9534
9535
|
attachments: o.length > 0 ? o.map(mi) : void 0,
|
|
9535
9536
|
submittedAt: s.submittedAt
|
|
9536
9537
|
}).then((h) => ({ result: h }), async (h) => {
|
|
9537
|
-
const
|
|
9538
|
-
if (
|
|
9538
|
+
const p = Y(h);
|
|
9539
|
+
if (p.code !== "submission_checkpoint_pending") throw h;
|
|
9539
9540
|
const m = this.submissionPreviews.get(r);
|
|
9540
|
-
return m && (m.error =
|
|
9541
|
+
return m && (m.error = p), this.emit("state", this.getState()), await this.waitForSubmissionDurability(r, n) ? { result: void 0 } : null;
|
|
9541
9542
|
});
|
|
9542
9543
|
});
|
|
9543
9544
|
if (!u || n !== this.submissionGeneration) return null;
|
|
@@ -9556,9 +9557,9 @@ class fu {
|
|
|
9556
9557
|
l.push(h);
|
|
9557
9558
|
continue;
|
|
9558
9559
|
}
|
|
9559
|
-
const
|
|
9560
|
-
if (!
|
|
9561
|
-
if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(
|
|
9560
|
+
const p = h.id ? this.attachmentFiles.get(h.id) : void 0;
|
|
9561
|
+
if (!p) throw new Error(`Attachment bytes are unavailable for ${h.name}`);
|
|
9562
|
+
if (l.push(await a.measure("attachment_transfer", () => this.adapter.uploadAttachment(p, h, { clientMessageId: r }))), n !== this.submissionGeneration) return null;
|
|
9562
9563
|
}
|
|
9563
9564
|
o = l;
|
|
9564
9565
|
}
|
|
@@ -9587,8 +9588,8 @@ class fu {
|
|
|
9587
9588
|
retry: async () => (d && await this.connect(), this.sendMessageNow(e, { ...s, reconcileAcceptance: !d && !h }, n)),
|
|
9588
9589
|
attachmentIds: (s.attachments ?? []).flatMap((m) => m.id ? [m.id] : [])
|
|
9589
9590
|
});
|
|
9590
|
-
const
|
|
9591
|
-
throw
|
|
9591
|
+
const p = this.submissionPreviews.get(r);
|
|
9592
|
+
throw p && (p.pending = !1, p.error = Y(u), this.emit("state", this.getState())), c && await this.adapter.dispatch({
|
|
9592
9593
|
type: "conversation.fail_staged",
|
|
9593
9594
|
clientMessageId: r,
|
|
9594
9595
|
message: Y(u).message
|
|
@@ -10237,8 +10238,8 @@ class Jt {
|
|
|
10237
10238
|
const e = ++this.conversationAdapterGeneration;
|
|
10238
10239
|
this.conversationObservation?.dispose(), this.conversationUnsubscribe?.();
|
|
10239
10240
|
const s = this.directoryAuthority, n = () => e === this.conversationAdapterGeneration;
|
|
10240
|
-
this.operationTimingReporter = Co((
|
|
10241
|
-
n() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings:
|
|
10241
|
+
this.operationTimingReporter = Co((f) => {
|
|
10242
|
+
n() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings: f.map((y) => ({ ...y, entrySurface: this.options.entrySurface })) });
|
|
10242
10243
|
});
|
|
10243
10244
|
const i = `pa.conversation.delivery:${this.modelClientScopeId}:${s.authorityId}`, r = `${i}:cancellations`;
|
|
10244
10245
|
this.authenticatedUserId && this.options.restorePersistedState === !1 && sessionStorage.removeItem(r);
|
|
@@ -10246,10 +10247,10 @@ class Jt {
|
|
|
10246
10247
|
authorityId: s.authorityId,
|
|
10247
10248
|
isCurrent: n,
|
|
10248
10249
|
read: async () => a ? JSON.parse(a) : null,
|
|
10249
|
-
write: async (
|
|
10250
|
-
this.authenticatedUserId && sessionStorage.setItem(r, JSON.stringify(
|
|
10250
|
+
write: async (f) => {
|
|
10251
|
+
this.authenticatedUserId && sessionStorage.setItem(r, JSON.stringify(f));
|
|
10251
10252
|
},
|
|
10252
|
-
onTiming: (
|
|
10253
|
+
onTiming: (f) => this.reportOperationTiming(f)
|
|
10253
10254
|
});
|
|
10254
10255
|
this.clientRuntime.installConversationPorts({
|
|
10255
10256
|
...Fa({
|
|
@@ -10258,16 +10259,16 @@ class Jt {
|
|
|
10258
10259
|
isCurrent: n,
|
|
10259
10260
|
http: this.directoryHttp,
|
|
10260
10261
|
now: () => Date.now(),
|
|
10261
|
-
prepareSubmission: async ({ submission:
|
|
10262
|
+
prepareSubmission: async ({ submission: f, sources: y }, b) => {
|
|
10262
10263
|
const k = Q(this.operationTimingReporter, {
|
|
10263
10264
|
operation: "send",
|
|
10264
10265
|
layer: "sdk",
|
|
10265
|
-
requestId:
|
|
10266
|
-
clientMessageId:
|
|
10267
|
-
sessionId:
|
|
10266
|
+
requestId: f.requestId,
|
|
10267
|
+
clientMessageId: f.userMessageId,
|
|
10268
|
+
sessionId: f.sessionId
|
|
10268
10269
|
}), R = (v, I) => k.measure(v, () => wt(b, I));
|
|
10269
|
-
let g =
|
|
10270
|
-
if (
|
|
10270
|
+
let g = f.contextPreparation ?? { pageContent: "", sessionTabs: [] };
|
|
10271
|
+
if (f.contextPreparation === null) {
|
|
10271
10272
|
await R("first_frame", () => new Promise((I) => {
|
|
10272
10273
|
if (document.visibilityState !== "visible") {
|
|
10273
10274
|
setTimeout(I, 0);
|
|
@@ -10280,7 +10281,7 @@ class Jt {
|
|
|
10280
10281
|
}, _ = requestAnimationFrame(w);
|
|
10281
10282
|
document.addEventListener("visibilitychange", A);
|
|
10282
10283
|
}));
|
|
10283
|
-
const v =
|
|
10284
|
+
const v = f.context.page;
|
|
10284
10285
|
if (ae().url !== v.url) throw Object.assign(new Error("The page changed before preparation completed. Send this message again."), { code: "context_preparation_interrupted", retryable: !1 });
|
|
10285
10286
|
g = { pageContent: await R("page_capture", async () => An()), sessionTabs: [] };
|
|
10286
10287
|
}
|
|
@@ -10293,46 +10294,46 @@ class Jt {
|
|
|
10293
10294
|
return b.throwIfAborted(), k.mark("context_ready"), { ...g, now: Date.now() };
|
|
10294
10295
|
},
|
|
10295
10296
|
connectionId: () => this.socket instanceof L ? this.socket.connectionId : null,
|
|
10296
|
-
prepareUpload: this.options.prepareAttachmentUpload ?? (this.options.productVariant === "customer_embedded" ? (
|
|
10297
|
-
onUploaded: async (
|
|
10298
|
-
await yr(
|
|
10297
|
+
prepareUpload: this.options.prepareAttachmentUpload ?? (this.options.productVariant === "customer_embedded" ? (f) => this.prepareEmbedAttachmentUpload(f, n) : void 0),
|
|
10298
|
+
onUploaded: async (f, y, b) => {
|
|
10299
|
+
await yr(f, {
|
|
10299
10300
|
sessionId: y,
|
|
10300
10301
|
sandboxPath: b.sandbox_path ?? void 0,
|
|
10301
10302
|
storageKey: b.storage_key ?? void 0,
|
|
10302
10303
|
fileUrl: b.file_url ? new URL(b.file_url, this.options.backendUrl).toString() : void 0,
|
|
10303
10304
|
lastUsedAt: Date.now()
|
|
10304
10305
|
}).catch((k) => V("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
|
|
10305
|
-
attachmentId:
|
|
10306
|
+
attachmentId: f,
|
|
10306
10307
|
message: k instanceof Error ? k.message : String(k)
|
|
10307
10308
|
}));
|
|
10308
10309
|
},
|
|
10309
10310
|
persistUpload: this.options.persistAttachmentUpload,
|
|
10310
|
-
readAttachment: async (
|
|
10311
|
-
const y = (await gi(
|
|
10311
|
+
readAttachment: async (f) => {
|
|
10312
|
+
const y = (await gi(f))?.blob;
|
|
10312
10313
|
if (!y) throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
|
|
10313
10314
|
return y;
|
|
10314
10315
|
},
|
|
10315
|
-
saveCancellation: (
|
|
10316
|
-
saveDelivery: async (
|
|
10317
|
-
this.authenticatedUserId && (sessionStorage.setItem(i, JSON.stringify(
|
|
10316
|
+
saveCancellation: (f) => o.save(f),
|
|
10317
|
+
saveDelivery: async (f) => {
|
|
10318
|
+
this.authenticatedUserId && (sessionStorage.setItem(i, JSON.stringify(f)), await o.committed(f));
|
|
10318
10319
|
},
|
|
10319
10320
|
// HTTP now owns command delivery; keep opt-in operational traces at that actual handoff.
|
|
10320
|
-
onTiming: (
|
|
10321
|
-
n() && this.reportOperationTiming(
|
|
10321
|
+
onTiming: (f) => {
|
|
10322
|
+
n() && this.reportOperationTiming(f);
|
|
10322
10323
|
},
|
|
10323
|
-
onCommand: (
|
|
10324
|
-
onError: (
|
|
10325
|
-
if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" &&
|
|
10324
|
+
onCommand: (f) => Pe("client_event", f.type, As({ ...f.payload, type: f.type })),
|
|
10325
|
+
onError: (f, y) => {
|
|
10326
|
+
if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" && f instanceof T && f.code === "conversation_access_denied") {
|
|
10326
10327
|
y.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
|
|
10327
10328
|
return;
|
|
10328
10329
|
}
|
|
10329
|
-
V("web-sdk.conversation", "Conversation operation failed", { ...y, ...jo(
|
|
10330
|
+
V("web-sdk.conversation", "Conversation operation failed", { ...y, ...jo(f) }), f instanceof T && f.backendRefusal && y.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
|
|
10330
10331
|
}
|
|
10331
10332
|
})
|
|
10332
10333
|
});
|
|
10333
10334
|
const c = this.clientRuntime.engine.getState().slices.conversation, d = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : hs(i);
|
|
10334
10335
|
if (this.authenticatedUserId && !c.submissionOrder.length && !Object.keys(c.operations).length) {
|
|
10335
|
-
const
|
|
10336
|
+
const f = this.queuedClientEvents.filter((k) => k.type === "chat.user_message"), y = d ? JSON.parse(d) : f.length ? zo(c, f.map((k) => {
|
|
10336
10337
|
const { type: R, ...g } = k, v = this.clientRuntime.engine.getState().slices.directory, I = v.clients[this.modelClientScopeId];
|
|
10337
10338
|
return {
|
|
10338
10339
|
command: { type: R, request_id: k.clientMessageId, payload: JSON.parse(JSON.stringify(g)) },
|
|
@@ -10350,7 +10351,7 @@ class Jt {
|
|
|
10350
10351
|
if (!n()) return;
|
|
10351
10352
|
b && (y || Object.keys(b.operations).length || Object.keys(b.stops).length) && await this.clientRuntime.engine.dispatch({ ...s, type: "conversation.restore_delivery", checkpoint: b });
|
|
10352
10353
|
}
|
|
10353
|
-
if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((
|
|
10354
|
+
if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((f) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(f.type))), Re(this.options.clientId, this.queuedClientEvents), !n()) return;
|
|
10354
10355
|
this.conversationObservation = new $a({
|
|
10355
10356
|
authority: s,
|
|
10356
10357
|
now: () => Date.now(),
|
|
@@ -10358,15 +10359,15 @@ class Jt {
|
|
|
10358
10359
|
isCurrent: n,
|
|
10359
10360
|
enabled: () => !!this.token && !this.authenticationFailure && !this.refreshingDefaultCredentials && this.state.status !== "closed",
|
|
10360
10361
|
socket: {
|
|
10361
|
-
retain: async (
|
|
10362
|
+
retain: async (f, y) => {
|
|
10362
10363
|
const b = this.socket;
|
|
10363
|
-
b instanceof L && await b.directoryRooms.retain(
|
|
10364
|
+
b instanceof L && await b.directoryRooms.retain(f, y).catch((k) => {
|
|
10364
10365
|
if (this.socket === b) throw k;
|
|
10365
10366
|
});
|
|
10366
10367
|
},
|
|
10367
|
-
release: async (
|
|
10368
|
+
release: async (f, y) => {
|
|
10368
10369
|
const b = this.socket;
|
|
10369
|
-
b instanceof L && await b.directoryRooms.release(
|
|
10370
|
+
b instanceof L && await b.directoryRooms.release(f, y).catch((k) => {
|
|
10370
10371
|
if (this.socket === b) throw k;
|
|
10371
10372
|
});
|
|
10372
10373
|
}
|
|
@@ -10376,13 +10377,13 @@ class Jt {
|
|
|
10376
10377
|
wakeup: { start: () => {
|
|
10377
10378
|
}, stop: () => {
|
|
10378
10379
|
} },
|
|
10379
|
-
onError: (
|
|
10380
|
+
onError: (f) => this.handleDirectoryTransportError(f)
|
|
10380
10381
|
});
|
|
10381
|
-
const u = (
|
|
10382
|
+
const u = (f, y) => {
|
|
10382
10383
|
if (this.firstResponseTimersByClientMessageId.size) {
|
|
10383
|
-
for (const b of
|
|
10384
|
+
for (const b of f)
|
|
10384
10385
|
(b.dataType === "run_status" || b.dataType === "run_error") && this.clearFirstResponseTimer(b.respondsToUserMessageId ?? null);
|
|
10385
|
-
for (const b of
|
|
10386
|
+
for (const b of f)
|
|
10386
10387
|
if (b.content.trim() && (b.role === "assistant" || b.dataType === "commentary_history" || b.dataType === "tool_summary")) {
|
|
10387
10388
|
const k = y ? this.clientRuntime.engine.getState().slices.conversation.sessions[y] : void 0;
|
|
10388
10389
|
for (const R of b.respondsToUserMessageId ? Yr(k, b.respondsToUserMessageId) : [])
|
|
@@ -10390,13 +10391,13 @@ class Jt {
|
|
|
10390
10391
|
}
|
|
10391
10392
|
}
|
|
10392
10393
|
};
|
|
10393
|
-
let l = new Map(this.getState().messages.map((
|
|
10394
|
+
let l = new Map(this.getState().messages.map((f) => [f.id, f])), h = this.clientRuntime.engine.getState().slices.conversation, p = this.clientRuntime.engine.getState().slices.directory.selections, m = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
|
|
10394
10395
|
this.conversationUnsubscribe = this.clientRuntime.engine.subscribe(() => {
|
|
10395
|
-
const
|
|
10396
|
-
h =
|
|
10397
|
-
const b = m !==
|
|
10398
|
-
m =
|
|
10399
|
-
for (const R of Object.values(
|
|
10396
|
+
const f = this.clientRuntime.engine.getState().slices, y = h;
|
|
10397
|
+
h = f.conversation, Oo(y, f.conversation, this.operationTimingReporter, "sdk");
|
|
10398
|
+
const b = m !== f.directory.clients[this.modelClientScopeId];
|
|
10399
|
+
m = f.directory.clients[this.modelClientScopeId], p !== f.directory.selections && (p = f.directory.selections, this.directoryScope.persist());
|
|
10400
|
+
for (const R of Object.values(f.conversation.submissions)) {
|
|
10400
10401
|
if (R.delivery === "accepted" && y.submissions[R.userMessageId]?.delivery !== "accepted") {
|
|
10401
10402
|
const g = this.firstResponseTimersByClientMessageId.get(R.userMessageId);
|
|
10402
10403
|
g && (g.sessionId = R.sessionId), this.emit("ack", { clientMessageId: R.userMessageId, sessionId: R.sessionId });
|
|
@@ -10409,9 +10410,9 @@ class Jt {
|
|
|
10409
10410
|
}
|
|
10410
10411
|
(R.cancelled || R.delivery === "failed") && this.clearFirstResponseTimer(R.userMessageId);
|
|
10411
10412
|
}
|
|
10412
|
-
for (const [R, g] of Object.entries(
|
|
10413
|
+
for (const [R, g] of Object.entries(f.directory.clients)) {
|
|
10413
10414
|
if (!R.startsWith(`background:${this.modelClientScopeId}:`)) continue;
|
|
10414
|
-
const v =
|
|
10415
|
+
const v = ge(f.conversation, f.directory, g), I = v.sessionId ? f.conversation.sessions[v.sessionId] : void 0;
|
|
10415
10416
|
if (this.firstResponseTimersByClientMessageId.size && (u(ms(v, I?.queries.current, this.options.backendUrl).messages, v.sessionId), ["failed", "stopped"].includes(v.activity.phase)))
|
|
10416
10417
|
for (const A of le(I?.execution)) this.clearFirstResponseTimer(A);
|
|
10417
10418
|
const w = v.activity.phase === "completed" && le(I?.execution).some((A) => this.firstResponseTimersByClientMessageId.has(A));
|
|
@@ -10478,7 +10479,7 @@ class Jt {
|
|
|
10478
10479
|
return n.add(s), this.listeners[e] = n, () => n.delete(s);
|
|
10479
10480
|
}
|
|
10480
10481
|
getState() {
|
|
10481
|
-
const e = this.clientRuntime.engine.getState().slices, s = e.directory.clients[this.modelClientScopeId] ?? this.directoryConversationScopeId, n =
|
|
10482
|
+
const e = this.clientRuntime.engine.getState().slices, s = e.directory.clients[this.modelClientScopeId] ?? this.directoryConversationScopeId, n = ge(e.conversation, e.directory, s), i = ms(
|
|
10482
10483
|
n,
|
|
10483
10484
|
n.sessionId ? e.conversation.sessions[n.sessionId]?.queries.current : void 0,
|
|
10484
10485
|
this.options.backendUrl,
|
|
@@ -10840,7 +10841,7 @@ class Jt {
|
|
|
10840
10841
|
entrySurface: this.options.entrySurface,
|
|
10841
10842
|
submittedAt: s.submittedAt ?? Date.now()
|
|
10842
10843
|
});
|
|
10843
|
-
const
|
|
10844
|
+
const f = this.directoryAuthority;
|
|
10844
10845
|
return this.clientRuntime.isDisposed ? null : new Promise((y, b) => {
|
|
10845
10846
|
let k = null, R = null;
|
|
10846
10847
|
const g = () => {
|
|
@@ -10849,7 +10850,7 @@ class Jt {
|
|
|
10849
10850
|
if (k?.(), R?.(), v?.delivery === "failed" && !v.cancelled) b(new Error(v.error?.message ?? "Message delivery failed."));
|
|
10850
10851
|
else {
|
|
10851
10852
|
const I = v?.invocation === "user" && v.contextPreparation?.pageContent ? v.context.page?.url : null;
|
|
10852
|
-
v?.delivery === "accepted" && !v.cancelled && typeof I == "string" && c === this.submissionIntentRevision &&
|
|
10853
|
+
v?.delivery === "accepted" && !v.cancelled && typeof I == "string" && c === this.submissionIntentRevision && f === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === m && (this.lastUserMessagePageUrl = I), y(v?.delivery === "accepted" && !v.cancelled ? r : null);
|
|
10853
10854
|
}
|
|
10854
10855
|
};
|
|
10855
10856
|
k = this.clientRuntime.engine.subscribe(g), R = this.clientRuntime.onDispose(() => {
|
|
@@ -10890,7 +10891,7 @@ class Jt {
|
|
|
10890
10891
|
this.draftModelExplicit = !0, this.draftModel !== s && (this.draftModel = s, this.emit("state", this.getState()));
|
|
10891
10892
|
}
|
|
10892
10893
|
retryLastMessage(e) {
|
|
10893
|
-
const s = this.clientRuntime.engine.getState().slices, n = s.directory.clients[this.modelClientScopeId], i =
|
|
10894
|
+
const s = this.clientRuntime.engine.getState().slices, n = s.directory.clients[this.modelClientScopeId], i = ge(s.conversation, s.directory, n), r = Bi(i, e);
|
|
10894
10895
|
if (!r) return !1;
|
|
10895
10896
|
if (r.type === "preparation") {
|
|
10896
10897
|
const a = z(), o = Va(r.submission);
|
|
@@ -10949,14 +10950,14 @@ class Jt {
|
|
|
10949
10950
|
} }
|
|
10950
10951
|
}), new Promise((d, u) => {
|
|
10951
10952
|
let l, h;
|
|
10952
|
-
const
|
|
10953
|
-
const m = this.clientRuntime.engine.getState().slices,
|
|
10954
|
-
if (!y &&
|
|
10955
|
-
if (l?.(), h?.(), y || !
|
|
10956
|
-
u(new Error(
|
|
10953
|
+
const p = () => {
|
|
10954
|
+
const m = this.clientRuntime.engine.getState().slices, f = m.conversation.operations[c], y = m.directory.authorityId !== a.authorityId || m.directory.clients[this.modelClientScopeId] !== o;
|
|
10955
|
+
if (!y && f && !["done", "failed"].includes(f.phase)) return;
|
|
10956
|
+
if (l?.(), h?.(), y || !f || f.phase === "failed") {
|
|
10957
|
+
u(new Error(f?.error?.message ?? "Attachment preparation was cancelled."));
|
|
10957
10958
|
return;
|
|
10958
10959
|
}
|
|
10959
|
-
const k =
|
|
10960
|
+
const k = f.result.attachment;
|
|
10960
10961
|
d(xr({
|
|
10961
10962
|
id: k.id,
|
|
10962
10963
|
name: k.name,
|
|
@@ -10967,9 +10968,9 @@ class Jt {
|
|
|
10967
10968
|
fileUrl: k.file_url
|
|
10968
10969
|
}, this.options.backendUrl));
|
|
10969
10970
|
};
|
|
10970
|
-
l = this.clientRuntime.engine.subscribe(
|
|
10971
|
+
l = this.clientRuntime.engine.subscribe(p), h = this.clientRuntime.onDispose(() => {
|
|
10971
10972
|
l?.(), u(new Error("Product Agent was disposed."));
|
|
10972
|
-
}),
|
|
10973
|
+
}), p();
|
|
10973
10974
|
});
|
|
10974
10975
|
}
|
|
10975
10976
|
async prepareEmbedAttachmentUpload(e, s) {
|
|
@@ -11231,31 +11232,31 @@ class Jt {
|
|
|
11231
11232
|
return;
|
|
11232
11233
|
}
|
|
11233
11234
|
s = !0;
|
|
11234
|
-
const h = this.getState().sessionId,
|
|
11235
|
+
const h = this.getState().sessionId, p = () => !this.clientRuntime.isDisposed && JSON.stringify(this.clientRuntime.engine.getState().slices.account.authority) === JSON.stringify(l) && this.getState().sessionId === h;
|
|
11235
11236
|
Promise.all(["notifications", "tab_grouping"].map(async (m) => {
|
|
11236
|
-
const
|
|
11237
|
-
if (
|
|
11238
|
-
if (!
|
|
11237
|
+
const f = await u.getState(m, h);
|
|
11238
|
+
if (p()) {
|
|
11239
|
+
if (!f.bridgeReady) return f;
|
|
11239
11240
|
if (await this.clientRuntime.engine.dispatch({
|
|
11240
11241
|
type: "stage7.device_fact",
|
|
11241
11242
|
authority: l,
|
|
11242
11243
|
now: Date.now(),
|
|
11243
11244
|
feature: m,
|
|
11244
|
-
fact: { permission:
|
|
11245
|
-
}), m === "tab_grouping" &&
|
|
11245
|
+
fact: { permission: f.permissionGranted ? "granted" : f.permissionNeeded ? "missing" : "unknown", revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[m].revision + 1), snoozedUntil: f.snoozedUntil ?? null, pending: f.permissionPending === !0 }
|
|
11246
|
+
}), m === "tab_grouping" && f.sessionId === h && h) for (const y of f.crossTabUserMessageIds ?? [])
|
|
11246
11247
|
await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority: l, now: Date.now(), sessionId: h, userMessageId: y });
|
|
11247
|
-
return
|
|
11248
|
+
return f;
|
|
11248
11249
|
}
|
|
11249
11250
|
})).then(async (m) => {
|
|
11250
|
-
|
|
11251
|
+
p() && await this.clientRuntime.engine.dispatch({
|
|
11251
11252
|
type: "stage7.bridge_ready",
|
|
11252
11253
|
authority: l,
|
|
11253
11254
|
now: Date.now(),
|
|
11254
|
-
ready: m.every((
|
|
11255
|
-
error: m.find((
|
|
11255
|
+
ready: m.every((f) => f?.bridgeReady),
|
|
11256
|
+
error: m.find((f) => f?.error)?.error ?? null
|
|
11256
11257
|
});
|
|
11257
11258
|
}).catch(async () => {
|
|
11258
|
-
|
|
11259
|
+
p() && 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." });
|
|
11259
11260
|
}).finally(() => {
|
|
11260
11261
|
s = !1, n && (n = !1, i());
|
|
11261
11262
|
});
|
|
@@ -11293,11 +11294,11 @@ class Jt {
|
|
|
11293
11294
|
...r,
|
|
11294
11295
|
"stage7.wait": e.wait,
|
|
11295
11296
|
"stage7.device": async ({ feature: u, action: l, requestId: h }) => {
|
|
11296
|
-
const
|
|
11297
|
-
if (!
|
|
11298
|
-
const m = this.clientRuntime.engine.getState().slices.interactions,
|
|
11299
|
-
l === "allow" && await
|
|
11300
|
-
const b = await
|
|
11297
|
+
const p = this.options.runtimeAdapters?.featurePermissions;
|
|
11298
|
+
if (!p) return { fact: { permission: "unsupported", revision: Date.now(), snoozedUntil: null }, completedAt: Date.now() };
|
|
11299
|
+
const m = this.clientRuntime.engine.getState().slices.interactions, f = m.promptActions[h], y = f?.expectedRevision ?? m.preferencePrompts[u].revision;
|
|
11300
|
+
l === "allow" && await p.enable(u, { requestId: h, expectedRevision: y, action: f?.action === "enable" ? "enable" : "allow" }), l === "not_now" && await p.dismiss(u, { requestId: h, expectedRevision: y, action: "not_now" });
|
|
11301
|
+
const b = await p.getState(u, this.getState().sessionId);
|
|
11301
11302
|
if (!b.bridgeReady) throw new Error("The Pluno extension is reconnecting. Try again.");
|
|
11302
11303
|
return { fact: {
|
|
11303
11304
|
permission: b.permissionGranted === !0 ? "granted" : b.permissionNeeded ? "missing" : "unknown",
|
|
@@ -11311,15 +11312,15 @@ class Jt {
|
|
|
11311
11312
|
if (l.kind === "saveHint")
|
|
11312
11313
|
Gr(localStorage, l.interactionId);
|
|
11313
11314
|
else if (l.kind === "connect" && h?.payload.kind === "integration_auth") {
|
|
11314
|
-
const
|
|
11315
|
+
const p = h.payload;
|
|
11315
11316
|
if (!this.options.runtimeAdapters?.integrationAuthHandler) throw new Error("Connection handler unavailable.");
|
|
11316
11317
|
await this.options.runtimeAdapters.integrationAuthHandler({
|
|
11317
11318
|
type: "pipedream_auth_required",
|
|
11318
|
-
authRequestId:
|
|
11319
|
-
appSlug:
|
|
11320
|
-
appName:
|
|
11321
|
-
appLogo:
|
|
11322
|
-
expiresAt:
|
|
11319
|
+
authRequestId: p.request_id,
|
|
11320
|
+
appSlug: p.app_slug,
|
|
11321
|
+
appName: p.app_name,
|
|
11322
|
+
appLogo: p.app_logo,
|
|
11323
|
+
expiresAt: p.expires_at
|
|
11323
11324
|
});
|
|
11324
11325
|
} else if (l.kind === "pair") {
|
|
11325
11326
|
if (!this.options.runtimeAdapters?.personalChannelConnectionHandler) throw new Error("Pairing handler unavailable.");
|
|
@@ -11337,8 +11338,8 @@ class Jt {
|
|
|
11337
11338
|
let a = "";
|
|
11338
11339
|
const o = this.clientRuntime.engine.subscribe(() => {
|
|
11339
11340
|
this.rebuildRuntimeInteractions();
|
|
11340
|
-
const u = this.clientRuntime.engine.getState().slices, h = u.directory.selections[u.directory.clients[this.modelClientScopeId]]?.sessionId,
|
|
11341
|
-
|
|
11341
|
+
const u = this.clientRuntime.engine.getState().slices, h = u.directory.selections[u.directory.clients[this.modelClientScopeId]]?.sessionId, p = JSON.stringify([h, h ? u.conversation.sessions[h]?.execution : null]);
|
|
11342
|
+
p !== a && (a = p, i());
|
|
11342
11343
|
}), c = this.options.runtimeAdapters?.featurePermissions?.subscribe?.(i);
|
|
11343
11344
|
this.clientRuntime.onDispose(() => c?.()), fo(this.clientRuntime, () => Date.now());
|
|
11344
11345
|
const d = () => {
|
|
@@ -11390,9 +11391,9 @@ class Jt {
|
|
|
11390
11391
|
reportHealthSignal(e, s = {}) {
|
|
11391
11392
|
let n = this.getState();
|
|
11392
11393
|
if (e === "first_response_slow" && s.sessionId && s.sessionId !== n.sessionId) {
|
|
11393
|
-
const { conversation: m, directory:
|
|
11394
|
+
const { conversation: m, directory: f } = this.clientRuntime.engine.getState().slices, y = Object.values(f.clients).find((b) => f.selections[b]?.sessionId === s.sessionId);
|
|
11394
11395
|
y && (n = { ...n, ...ms(
|
|
11395
|
-
|
|
11396
|
+
ge(m, f, y),
|
|
11396
11397
|
m.sessions[s.sessionId]?.queries.current,
|
|
11397
11398
|
this.options.backendUrl
|
|
11398
11399
|
) });
|
|
@@ -11426,10 +11427,10 @@ class Jt {
|
|
|
11426
11427
|
...n.sessionId ? { sessionId: n.sessionId } : {},
|
|
11427
11428
|
...s,
|
|
11428
11429
|
...s.renderedError?.runId ? { runId: s.renderedError.runId } : {}
|
|
11429
|
-
}, { errorDiagnostic: a, responseDiagnostics: o, renderedError: c, uiInvariant: d, timings: u, httpRequest: l, historyRefreshFailure: h, ...
|
|
11430
|
+
}, { errorDiagnostic: a, responseDiagnostics: o, renderedError: c, uiInvariant: d, timings: u, httpRequest: l, historyRefreshFailure: h, ...p } = r;
|
|
11430
11431
|
for (const m of u ?? []) Pe("client_event", "operation_timing", { ...m });
|
|
11431
11432
|
if (Pe("client_event", "runtime.health", {
|
|
11432
|
-
...
|
|
11433
|
+
...p,
|
|
11433
11434
|
signalName: e,
|
|
11434
11435
|
...h ? { historyRefreshConsecutiveFailures: h.consecutiveFailures, historyRefreshEpisodeId: h.episodeId } : {}
|
|
11435
11436
|
}), this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN || this.authenticatedSocket !== this.socket) {
|
|
@@ -11679,11 +11680,11 @@ class Jt {
|
|
|
11679
11680
|
if (this.clientRuntime.isDisposed || this.directoryAuthority !== u) return;
|
|
11680
11681
|
let l = !1;
|
|
11681
11682
|
for (const h of o) {
|
|
11682
|
-
const
|
|
11683
|
-
if (h.type === "run.stop" &&
|
|
11683
|
+
const p = this.clientRuntime.engine.getState().slices.directory, m = p.clients[this.modelClientScopeId];
|
|
11684
|
+
if (h.type === "run.stop" && p.selections[m]?.sessionId === h.payload.sessionId) {
|
|
11684
11685
|
if (l) continue;
|
|
11685
11686
|
l = !0;
|
|
11686
|
-
const
|
|
11687
|
+
const f = o.filter((y) => y.type === "run.stop" && y.payload.sessionId === h.payload.sessionId).map((y) => String(y.payload.expectedUserMessageId));
|
|
11687
11688
|
await this.clientRuntime.engine.dispatch({
|
|
11688
11689
|
...u,
|
|
11689
11690
|
type: "conversation.stop",
|
|
@@ -11691,7 +11692,7 @@ class Jt {
|
|
|
11691
11692
|
conversationScopeId: m,
|
|
11692
11693
|
requestId: h.request_id,
|
|
11693
11694
|
reason: h.payload.reason,
|
|
11694
|
-
userMessageIds:
|
|
11695
|
+
userMessageIds: f
|
|
11695
11696
|
});
|
|
11696
11697
|
} else (h.type === "run.stop" || h.type === "session.reset") && await this.clientRuntime.engine.dispatch({ ...u, type: "conversation.operation", command: h });
|
|
11697
11698
|
}
|
|
@@ -12170,47 +12171,47 @@ function Ed(t) {
|
|
|
12170
12171
|
}
|
|
12171
12172
|
function Td() {
|
|
12172
12173
|
const t = /* @__PURE__ */ new Set(), e = (h) => {
|
|
12173
|
-
t.forEach((
|
|
12174
|
+
t.forEach((p) => {
|
|
12174
12175
|
try {
|
|
12175
|
-
|
|
12176
|
+
p(h);
|
|
12176
12177
|
} catch {
|
|
12177
12178
|
}
|
|
12178
12179
|
});
|
|
12179
|
-
}, s = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, a = function(
|
|
12180
|
-
const
|
|
12180
|
+
}, s = window.fetch, n = XMLHttpRequest.prototype.open, i = XMLHttpRequest.prototype.setRequestHeader, r = XMLHttpRequest.prototype.send, a = function(p, m) {
|
|
12181
|
+
const f = Date.now();
|
|
12181
12182
|
let y;
|
|
12182
12183
|
try {
|
|
12183
|
-
y = s.call(this,
|
|
12184
|
+
y = s.call(this, p, m);
|
|
12184
12185
|
} catch (b) {
|
|
12185
12186
|
throw b;
|
|
12186
12187
|
}
|
|
12187
12188
|
try {
|
|
12188
|
-
const b =
|
|
12189
|
+
const b = p instanceof Request ? p : null, k = Ul(p, b), R = Ur(m?.headers ?? b?.headers);
|
|
12189
12190
|
if (!De(k, R, m?.body)) {
|
|
12190
12191
|
const v = {
|
|
12191
12192
|
requestId: Ps("fetch"),
|
|
12192
|
-
url:
|
|
12193
|
+
url: me(k, qs),
|
|
12193
12194
|
method: (m?.method ?? b?.method ?? "GET").toUpperCase(),
|
|
12194
12195
|
requestHeaders: R,
|
|
12195
12196
|
requestBody: Ci(m?.body),
|
|
12196
12197
|
resourceType: "fetch",
|
|
12197
|
-
startedAt: new Date(
|
|
12198
|
+
startedAt: new Date(f).toISOString()
|
|
12198
12199
|
};
|
|
12199
12200
|
y.then(
|
|
12200
12201
|
(I) => {
|
|
12201
|
-
Nl(I, v,
|
|
12202
|
+
Nl(I, v, f, e).catch(() => {
|
|
12202
12203
|
e({
|
|
12203
12204
|
...v,
|
|
12204
12205
|
responseStatus: I.status,
|
|
12205
|
-
durationMs: Date.now() -
|
|
12206
|
+
durationMs: Date.now() - f
|
|
12206
12207
|
});
|
|
12207
12208
|
});
|
|
12208
12209
|
},
|
|
12209
12210
|
(I) => {
|
|
12210
12211
|
e({
|
|
12211
12212
|
...v,
|
|
12212
|
-
errorText:
|
|
12213
|
-
durationMs: Date.now() -
|
|
12213
|
+
errorText: me(I instanceof Error ? I.message : String(I)),
|
|
12214
|
+
durationMs: Date.now() - f
|
|
12214
12215
|
});
|
|
12215
12216
|
}
|
|
12216
12217
|
);
|
|
@@ -12218,29 +12219,29 @@ function Td() {
|
|
|
12218
12219
|
} catch {
|
|
12219
12220
|
}
|
|
12220
12221
|
return y;
|
|
12221
|
-
}, o = function(
|
|
12222
|
-
const k = n.call(this,
|
|
12222
|
+
}, o = function(p, m, f, y, b) {
|
|
12223
|
+
const k = n.call(this, p, m, f ?? !0, y ?? void 0, b ?? void 0), R = typeof m == "string" ? m : m.toString();
|
|
12223
12224
|
return Os.set(this, {
|
|
12224
12225
|
requestId: Ps("xhr"),
|
|
12225
|
-
method: String(
|
|
12226
|
-
url:
|
|
12226
|
+
method: String(p ?? "GET").toUpperCase(),
|
|
12227
|
+
url: me(R, qs),
|
|
12227
12228
|
requestHeaders: {},
|
|
12228
12229
|
startedAtMs: Date.now(),
|
|
12229
12230
|
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12230
12231
|
excluded: De(R)
|
|
12231
12232
|
}), k;
|
|
12232
|
-
}, c = function(
|
|
12233
|
-
const
|
|
12234
|
-
return y && Object.keys(y.requestHeaders).length < Rn && (y.requestHeaders[
|
|
12235
|
-
}, d = function(
|
|
12233
|
+
}, c = function(p, m) {
|
|
12234
|
+
const f = i.call(this, p, m), y = Os.get(this);
|
|
12235
|
+
return y && Object.keys(y.requestHeaders).length < Rn && (y.requestHeaders[p] = qn(p, m), y.excluded = y.excluded || De(y.url, y.requestHeaders)), f;
|
|
12236
|
+
}, d = function(p) {
|
|
12236
12237
|
try {
|
|
12237
12238
|
const m = Os.get(this);
|
|
12238
|
-
m && (m.excluded = m.excluded || De(m.url, m.requestHeaders,
|
|
12239
|
+
m && (m.excluded = m.excluded || De(m.url, m.requestHeaders, p), m.requestBody = Ci(p), m.excluded || this.addEventListener(
|
|
12239
12240
|
"loadend",
|
|
12240
12241
|
() => {
|
|
12241
12242
|
queueMicrotask(() => {
|
|
12242
12243
|
try {
|
|
12243
|
-
const
|
|
12244
|
+
const f = zl(this.getAllResponseHeaders());
|
|
12244
12245
|
e({
|
|
12245
12246
|
requestId: m.requestId,
|
|
12246
12247
|
url: m.url,
|
|
@@ -12249,8 +12250,8 @@ function Td() {
|
|
|
12249
12250
|
requestBody: m.requestBody,
|
|
12250
12251
|
resourceType: "xhr",
|
|
12251
12252
|
responseStatus: this.status,
|
|
12252
|
-
responseHeaders:
|
|
12253
|
-
responseBody: Bl(this,
|
|
12253
|
+
responseHeaders: f,
|
|
12254
|
+
responseBody: Bl(this, f),
|
|
12254
12255
|
errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
|
|
12255
12256
|
startedAt: m.startedAt,
|
|
12256
12257
|
durationMs: Date.now() - m.startedAtMs
|
|
@@ -12264,7 +12265,7 @@ function Td() {
|
|
|
12264
12265
|
));
|
|
12265
12266
|
} catch {
|
|
12266
12267
|
}
|
|
12267
|
-
return r.call(this,
|
|
12268
|
+
return r.call(this, p ?? null);
|
|
12268
12269
|
};
|
|
12269
12270
|
try {
|
|
12270
12271
|
window.fetch = a;
|
|
@@ -12285,18 +12286,18 @@ function Td() {
|
|
|
12285
12286
|
let u = null;
|
|
12286
12287
|
if (typeof PerformanceObserver < "u") {
|
|
12287
12288
|
u = new PerformanceObserver((h) => {
|
|
12288
|
-
for (const
|
|
12289
|
-
const m =
|
|
12289
|
+
for (const p of h.getEntries()) {
|
|
12290
|
+
const m = p;
|
|
12290
12291
|
if (m.initiatorType === "fetch" || m.initiatorType === "xmlhttprequest" || De(m.name))
|
|
12291
12292
|
continue;
|
|
12292
|
-
const
|
|
12293
|
+
const f = performance.timeOrigin + m.startTime;
|
|
12293
12294
|
e({
|
|
12294
12295
|
requestId: Ps("resource"),
|
|
12295
|
-
url:
|
|
12296
|
+
url: me(m.name, qs),
|
|
12296
12297
|
method: "GET",
|
|
12297
12298
|
resourceType: "resource",
|
|
12298
12299
|
responseStatus: m.responseStatus,
|
|
12299
|
-
startedAt: new Date(
|
|
12300
|
+
startedAt: new Date(f).toISOString(),
|
|
12300
12301
|
durationMs: m.duration
|
|
12301
12302
|
});
|
|
12302
12303
|
}
|
|
@@ -12597,27 +12598,27 @@ function Gd() {
|
|
|
12597
12598
|
function An() {
|
|
12598
12599
|
if (!document.body)
|
|
12599
12600
|
return "";
|
|
12600
|
-
const t = [], e = [], s = (
|
|
12601
|
+
const t = [], e = [], s = (f, y) => {
|
|
12601
12602
|
const b = Fe(y);
|
|
12602
|
-
!b || e.includes(b) || (t.push([
|
|
12603
|
+
!b || e.includes(b) || (t.push([f, b]), e.push(b));
|
|
12603
12604
|
};
|
|
12604
12605
|
s("Selected text", window.getSelection()?.toString() ?? "");
|
|
12605
12606
|
const n = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", i = Array.from(document.querySelectorAll(n)).filter(
|
|
12606
|
-
(
|
|
12607
|
+
(f) => Er(f) && !f.parentElement?.closest(n)
|
|
12607
12608
|
);
|
|
12608
|
-
for (const
|
|
12609
|
-
s("Active overlay", xs(nt(
|
|
12609
|
+
for (const f of i.slice(0, 3))
|
|
12610
|
+
s("Active overlay", xs(nt(f), e));
|
|
12610
12611
|
const r = Jd(), a = r ? xs(nt(r), e) : "";
|
|
12611
12612
|
s("Main page content", a), s("Additional visible page text", xs(nt(document.body), e));
|
|
12612
|
-
const o = t.map(([
|
|
12613
|
+
const o = t.map(([f, y]) => `${f}:
|
|
12613
12614
|
${y}`).join(`
|
|
12614
12615
|
|
|
12615
12616
|
`).trim().slice(0, 12e3), c = Qd(i, r).trim(), d = `Simplified DOM outline:
|
|
12616
12617
|
`, u = `
|
|
12617
12618
|
|
|
12618
12619
|
Visible page text:
|
|
12619
|
-
`, l = 12e3 - d.length - u.length, h = Math.min(o.length, 7900),
|
|
12620
|
-
return `${d}${
|
|
12620
|
+
`, l = 12e3 - d.length - u.length, h = Math.min(o.length, 7900), p = c.slice(0, l - h), m = o.slice(0, l - p.length);
|
|
12621
|
+
return `${d}${p}${u}${m}`;
|
|
12621
12622
|
}
|
|
12622
12623
|
function nt(t) {
|
|
12623
12624
|
return t.innerText ?? t.textContent ?? "";
|
|
@@ -12725,33 +12726,33 @@ function Qd(t, e) {
|
|
|
12725
12726
|
"data-cy"
|
|
12726
12727
|
], d = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: l } = Xd(), h = new Set(t);
|
|
12727
12728
|
e && h.add(e);
|
|
12728
|
-
let
|
|
12729
|
+
let p = 0;
|
|
12729
12730
|
const m = (R) => {
|
|
12730
12731
|
const g = R.getAttribute("role");
|
|
12731
12732
|
return g && !a.has(g) ? g : "";
|
|
12732
|
-
},
|
|
12733
|
+
}, f = (R) => {
|
|
12733
12734
|
const g = R.getAttribute("data-testid") || R.getAttribute("data-test") || R.getAttribute("data-qa") || R.getAttribute("data-cy") || "";
|
|
12734
12735
|
return `${R.tagName.toLowerCase()}|${m(R)}|${g}`;
|
|
12735
12736
|
}, y = (R, g, v) => {
|
|
12736
12737
|
const I = (w, A) => {
|
|
12737
12738
|
const _ = w.tagName.toLowerCase(), q = window.getComputedStyle(w), E = u.has(w);
|
|
12738
|
-
if (
|
|
12739
|
+
if (p >= 1e3 && !E || v.has(w) || r.has(_) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || q.display === "none" || q.visibility === "hidden")
|
|
12739
12740
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
12740
|
-
|
|
12741
|
+
p += 1;
|
|
12741
12742
|
const C = m(w), M = qr(w), S = o.has(C) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(_) || _ === "a" && w.hasAttribute("href"), O = Array.from(w.children).filter((D) => D instanceof HTMLElement), U = /* @__PURE__ */ new Map();
|
|
12742
12743
|
for (const D of O) {
|
|
12743
|
-
const $ =
|
|
12744
|
+
const $ = f(D);
|
|
12744
12745
|
U.set($, (U.get($) ?? 0) + 1);
|
|
12745
12746
|
}
|
|
12746
12747
|
const H = /* @__PURE__ */ new Map(), ze = /* @__PURE__ */ new Map();
|
|
12747
12748
|
for (const D of O) {
|
|
12748
|
-
const $ =
|
|
12749
|
-
ze.set($,
|
|
12749
|
+
const $ = f(D), be = ze.get($) ?? 0;
|
|
12750
|
+
ze.set($, be + 1), (U.get($) ?? 0) > 8 && be >= 6 && !u.has(D) && H.set($, (H.get($) ?? 0) + 1);
|
|
12750
12751
|
}
|
|
12751
12752
|
const ct = /* @__PURE__ */ new Map(), Cn = /* @__PURE__ */ new Set(), Xt = [], Mn = [];
|
|
12752
12753
|
for (const D of O) {
|
|
12753
|
-
const $ =
|
|
12754
|
-
if (ct.set($, Pn + 1),
|
|
12754
|
+
const $ = f(D), be = U.get($) ?? 0, Pn = ct.get($) ?? 0;
|
|
12755
|
+
if (ct.set($, Pn + 1), be > 8 && Pn >= 6 && !u.has(D)) {
|
|
12755
12756
|
Cn.has($) || (Xt.push([`… ${H.get($) ?? 0} similar siblings omitted`]), Cn.add($));
|
|
12756
12757
|
continue;
|
|
12757
12758
|
}
|
|
@@ -12766,7 +12767,7 @@ function Qd(t, e) {
|
|
|
12766
12767
|
[M, ...dt.map((D) => D.textPreview)].filter(Boolean).join(" ")
|
|
12767
12768
|
).slice(0, 180), Vr = w.hasAttribute("contenteditable") && (M.length > 0 || !w.querySelector("[contenteditable]")), xn = d.some((D) => w.hasAttribute(D)) || !!C || Vr, es = (w.getClientRects().length > 0 || q.display === "contents") && (s.has(_) || xn || E) && (Zt || E) && (!i.has(_) || Zt || xn || E), ts = es ? 1 : 0, He = [];
|
|
12768
12769
|
if (es) {
|
|
12769
|
-
const D = dt.some((
|
|
12770
|
+
const D = dt.some((be) => be.containsTextElement), $ = n.has(_) && !D ? On : M;
|
|
12770
12771
|
He.push(Tr(w, c, a, $.slice(0, 180)));
|
|
12771
12772
|
}
|
|
12772
12773
|
for (const D of Xt)
|
|
@@ -12777,8 +12778,8 @@ function Qd(t, e) {
|
|
|
12777
12778
|
ss.length > D.length && D.push("… shadow DOM omitted");
|
|
12778
12779
|
const $ = _.includes("tooltip") || _.includes("popper") || _.includes("loader");
|
|
12779
12780
|
if (A < 2 && !$) {
|
|
12780
|
-
const
|
|
12781
|
-
He.push(...bt([
|
|
12781
|
+
const be = es ? "#shadow-root" : `${_} #shadow-root`;
|
|
12782
|
+
He.push(...bt([be, ...bt(D, 1)], ts));
|
|
12782
12783
|
} else
|
|
12783
12784
|
He.push(...bt(D, ts));
|
|
12784
12785
|
}
|
|
@@ -13042,7 +13043,7 @@ function Cr(t, e) {
|
|
|
13042
13043
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13043
13044
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13044
13045
|
...se(i) !== null ? { causalSequence: se(i) } : {},
|
|
13045
|
-
respondsToUserMessageId:
|
|
13046
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13046
13047
|
...W(i) ? { runId: W(i) } : {},
|
|
13047
13048
|
dataType: "assistant_draft",
|
|
13048
13049
|
...i.steered === !0 ? { steered: !0 } : {}
|
|
@@ -13059,7 +13060,7 @@ function Cr(t, e) {
|
|
|
13059
13060
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13060
13061
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13061
13062
|
...se(i) !== null ? { causalSequence: se(i) } : {},
|
|
13062
|
-
respondsToUserMessageId:
|
|
13063
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13063
13064
|
...W(i) ? { runId: W(i) } : {},
|
|
13064
13065
|
attachments: Or(i.attachments, e),
|
|
13065
13066
|
...i.steered === !0 ? { steered: !0 } : {}
|
|
@@ -13084,7 +13085,7 @@ function Cr(t, e) {
|
|
|
13084
13085
|
content: "",
|
|
13085
13086
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13086
13087
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13087
|
-
respondsToUserMessageId:
|
|
13088
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13088
13089
|
...W(i) ? { runId: W(i) } : {},
|
|
13089
13090
|
dataType: "function_call_output",
|
|
13090
13091
|
toolName: Ir,
|
|
@@ -13099,7 +13100,7 @@ function Cr(t, e) {
|
|
|
13099
13100
|
content: "",
|
|
13100
13101
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13101
13102
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13102
|
-
respondsToUserMessageId:
|
|
13103
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13103
13104
|
...W(i) ? { runId: W(i) } : {},
|
|
13104
13105
|
dataType: "scheduled_check_in",
|
|
13105
13106
|
toolName: _r,
|
|
@@ -13115,7 +13116,7 @@ function Cr(t, e) {
|
|
|
13115
13116
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13116
13117
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13117
13118
|
...se(i) !== null ? { causalSequence: se(i) } : {},
|
|
13118
|
-
respondsToUserMessageId:
|
|
13119
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13119
13120
|
...W(i) ? { runId: W(i) } : {},
|
|
13120
13121
|
dataType: "function_call_output",
|
|
13121
13122
|
toolName: "authenticate_pipedream_app",
|
|
@@ -13128,7 +13129,7 @@ function Cr(t, e) {
|
|
|
13128
13129
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13129
13130
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13130
13131
|
...se(i) !== null ? { causalSequence: se(i) } : {},
|
|
13131
|
-
respondsToUserMessageId:
|
|
13132
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13132
13133
|
...W(i) ? { runId: W(i) } : {},
|
|
13133
13134
|
dataType: "function_call_output",
|
|
13134
13135
|
toolName: "request_personal_channel_connection",
|
|
@@ -13143,7 +13144,7 @@ function Cr(t, e) {
|
|
|
13143
13144
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13144
13145
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13145
13146
|
...se(i) !== null ? { causalSequence: se(i) } : {},
|
|
13146
|
-
respondsToUserMessageId:
|
|
13147
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13147
13148
|
...W(i) ? { runId: W(i) } : {},
|
|
13148
13149
|
dataType: String(i.type),
|
|
13149
13150
|
toolName: i.type === "tab_lifecycle_decision" ? "tab_lifecycle_decision" : typeof i.name == "string" ? i.name : void 0,
|
|
@@ -13157,7 +13158,7 @@ function Cr(t, e) {
|
|
|
13157
13158
|
createdAt: typeof s.createdAt == "string" ? s.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
13158
13159
|
...K(i) !== null ? { displaySequence: K(i) } : {},
|
|
13159
13160
|
...se(i) !== null ? { causalSequence: se(i) } : {},
|
|
13160
|
-
respondsToUserMessageId:
|
|
13161
|
+
respondsToUserMessageId: Ie(i) ?? void 0,
|
|
13161
13162
|
...W(i) ? { runId: W(i) } : {},
|
|
13162
13163
|
dataType: String(i.type),
|
|
13163
13164
|
loading: i.steered !== !0 && i.type === "run_status" && (i.status === "running" || i.status === "retrying"),
|
|
@@ -13539,7 +13540,7 @@ function Pl(t) {
|
|
|
13539
13540
|
} = t;
|
|
13540
13541
|
return r;
|
|
13541
13542
|
}
|
|
13542
|
-
function
|
|
13543
|
+
function Ie(t) {
|
|
13543
13544
|
const e = t.respondsToUserMessageId;
|
|
13544
13545
|
return typeof e == "string" && e ? e : null;
|
|
13545
13546
|
}
|
|
@@ -13563,7 +13564,7 @@ function Ur(t) {
|
|
|
13563
13564
|
return e;
|
|
13564
13565
|
}
|
|
13565
13566
|
function qn(t, e) {
|
|
13566
|
-
return zr(t) ? Qt :
|
|
13567
|
+
return zr(t) ? Qt : me($t(e), wd);
|
|
13567
13568
|
}
|
|
13568
13569
|
function Ul(t, e) {
|
|
13569
13570
|
return typeof t == "string" ? t : t instanceof URL ? t.toString() : e?.url ?? "";
|
|
@@ -13597,10 +13598,10 @@ async function jl(t) {
|
|
|
13597
13598
|
return;
|
|
13598
13599
|
const { done: c, value: d } = o;
|
|
13599
13600
|
if (c)
|
|
13600
|
-
return
|
|
13601
|
+
return me(r + i.decode());
|
|
13601
13602
|
const u = kn - a;
|
|
13602
13603
|
if (d.byteLength > u)
|
|
13603
|
-
return r += i.decode(d.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${
|
|
13604
|
+
return r += i.decode(d.subarray(0, Math.max(u, 0)), { stream: !0 }), e.cancel(), `${me(r)}... [truncated]`;
|
|
13604
13605
|
a += d.byteLength, r += i.decode(d, { stream: !0 });
|
|
13605
13606
|
}
|
|
13606
13607
|
} catch {
|
|
@@ -13613,14 +13614,14 @@ async function jl(t) {
|
|
|
13613
13614
|
function Bl(t, e) {
|
|
13614
13615
|
if (Nr(new Headers(e)))
|
|
13615
13616
|
try {
|
|
13616
|
-
return t.responseType === "" || t.responseType === "text" ?
|
|
13617
|
+
return t.responseType === "" || t.responseType === "text" ? me(t.responseText ?? "") : void 0;
|
|
13617
13618
|
} catch {
|
|
13618
13619
|
return;
|
|
13619
13620
|
}
|
|
13620
13621
|
}
|
|
13621
13622
|
function Ci(t) {
|
|
13622
13623
|
if (typeof t == "string")
|
|
13623
|
-
return
|
|
13624
|
+
return me(t);
|
|
13624
13625
|
}
|
|
13625
13626
|
function Ll(t) {
|
|
13626
13627
|
return ne({
|
|
@@ -13689,7 +13690,7 @@ function zl(t) {
|
|
|
13689
13690
|
}
|
|
13690
13691
|
return e;
|
|
13691
13692
|
}
|
|
13692
|
-
function
|
|
13693
|
+
function me(t, e = kn) {
|
|
13693
13694
|
return t.length <= e ? t : `${t.slice(0, e)}... [truncated ${t.length - e} chars]`;
|
|
13694
13695
|
}
|
|
13695
13696
|
function Ps(t) {
|
|
@@ -13728,7 +13729,7 @@ function Wl(t) {
|
|
|
13728
13729
|
function Gl(t) {
|
|
13729
13730
|
return t === 401 || t === 403;
|
|
13730
13731
|
}
|
|
13731
|
-
const Qt = "[REDACTED_SECRET]",
|
|
13732
|
+
const Qt = "[REDACTED_SECRET]", ye = "[REDACTED_TOKEN]", Jl = "[REDACTED_SIGNED_URL]", Ql = 20, Xl = /^(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, Br = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Lr = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Fr = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, $r = /\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, Yl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Zl = /\bhttps?:\/\/[^\s"'<>]+/gi, eu = /[),.;\]]+$/;
|
|
13732
13733
|
function ne(t) {
|
|
13733
13734
|
return Ft(t, 0, /* @__PURE__ */ new WeakSet());
|
|
13734
13735
|
}
|
|
@@ -13759,17 +13760,17 @@ function Hr(t) {
|
|
|
13759
13760
|
try {
|
|
13760
13761
|
const e = new URL(t, location.href);
|
|
13761
13762
|
for (const s of Array.from(e.searchParams.keys()))
|
|
13762
|
-
Xl.test(s) && e.searchParams.set(s,
|
|
13763
|
-
return e.username && (e.username =
|
|
13763
|
+
Xl.test(s) && e.searchParams.set(s, ye);
|
|
13764
|
+
return e.username && (e.username = ye), e.password && (e.password = ye), e.toString();
|
|
13764
13765
|
} catch {
|
|
13765
13766
|
return su(t);
|
|
13766
13767
|
}
|
|
13767
13768
|
}
|
|
13768
13769
|
function $t(t) {
|
|
13769
|
-
return t.replace(Yl, Jl).replace(Zl, nu).replace(Br, `Bearer ${
|
|
13770
|
+
return t.replace(Yl, Jl).replace(Zl, nu).replace(Br, `Bearer ${ye}`).replace(Lr, `Basic ${ye}`).replace(Fr, ye).replace($r, (e, s) => `${s}: ${Qt}`);
|
|
13770
13771
|
}
|
|
13771
13772
|
function su(t) {
|
|
13772
|
-
return t.replace(Br, `Bearer ${
|
|
13773
|
+
return t.replace(Br, `Bearer ${ye}`).replace(Lr, `Basic ${ye}`).replace(Fr, ye).replace($r, (e, s) => `${s}: ${Qt}`);
|
|
13773
13774
|
}
|
|
13774
13775
|
function nu(t) {
|
|
13775
13776
|
const e = t.match(eu)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;
|