@pluno/product-agent-web 0.1.280 → 0.1.282
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/core/interactions/contracts.d.ts +1 -0
- package/dist/featureActionFeedback.d.ts +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +1 -1
- package/dist/product-agent-sdk.js +406 -392
- package/dist/product-agent-widget.js +4162 -4104
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function vt(t, e, s) {
|
|
2
2
|
t.throwIfAborted();
|
|
3
3
|
let n, i = () => {
|
|
4
4
|
};
|
|
@@ -272,7 +272,7 @@ function ts(t, e) {
|
|
|
272
272
|
updatedAt: e.updatedAt
|
|
273
273
|
};
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function ct(t, e) {
|
|
276
276
|
return t.key !== e.key || t.requestId !== e.requestId ? t : { ...t, status: "error", error: e.error };
|
|
277
277
|
}
|
|
278
278
|
function je(t) {
|
|
@@ -336,7 +336,7 @@ function Ie(t, e, s) {
|
|
|
336
336
|
}
|
|
337
337
|
for (const S of c) {
|
|
338
338
|
const x = l.findIndex((U) => {
|
|
339
|
-
const H = a.find((
|
|
339
|
+
const H = a.find((ot) => ot.userMessageId === U.userMessageId), $e = r?.items[U.userMessageId ?? U.activityIds[0] ?? U.outcomeIds[0]];
|
|
340
340
|
return (H?.submittedAt ?? ($e ? Date.parse($e.created_at) : 1 / 0)) > S.submittedAt;
|
|
341
341
|
});
|
|
342
342
|
l.splice(x < 0 ? l.length : x, 0, {
|
|
@@ -351,10 +351,10 @@ function Ie(t, e, s) {
|
|
|
351
351
|
let k = y ? "submitting" : b ? "awaiting_execution" : u?.phase ?? "idle";
|
|
352
352
|
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(u).some((x) => S.userMessageIds.includes(x))) && (!u || u.version <= S.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(u.phase) || a.some((x) => x.cancelled && x.executionVersion === null && S.userMessageIds.includes(x.userMessageId)))), g = u && ["thinking", "steering", "queued", "stopping"].includes(u.phase) || a.some((S) => S.delivery === "accepted" && S.executionVersion === null && R?.userMessageIds.includes(S.userMessageId));
|
|
353
353
|
R && g && !y && (!u || !["thinking", "steering", "queued", "stopping"].includes(u.phase) || le(u).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");
|
|
354
|
-
const v = ["thinking", "steering", "queued"].includes(k), I = t.stops[s] ?? R, w = I?.userMessageIds.filter((S) => !["completed", "failed"].includes(r?.executionByUserMessage[S]?.phase ?? "")) ?? [],
|
|
354
|
+
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) => {
|
|
355
355
|
const x = a.find((H) => H.userMessageId === S);
|
|
356
356
|
return !Object.values(t.operations).some((H) => H.command.type === "run.stop" && H.command.payload.expectedUserMessageId === S && H.phase === "done") && (x?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(x.delivery) || !!(u && le(u).includes(S) && ["thinking", "steering", "queued", "stopping"].includes(u.phase)));
|
|
357
|
-
}),
|
|
357
|
+
}), _ = u?.user_message_ids ?? [], T = y || b ? f?.userMessageId ?? null : _[_.length - 1] ?? null, E = l.find((S) => S.userMessageId === T), C = v ? [...E?.activityIds ?? []].reverse().find((S) => d[S] === "open") ?? null : null, O = i !== null && !!e.selections[s]?.provisionalId && o.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
|
|
358
358
|
(!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);
|
|
359
359
|
return G({
|
|
360
360
|
historyRefreshFailure: r?.historyRefreshFailure ?? null,
|
|
@@ -372,9 +372,9 @@ function Ie(t, e, s) {
|
|
|
372
372
|
removedItems: r?.removedItems ?? {},
|
|
373
373
|
streamStates: d,
|
|
374
374
|
preparation: r?.preparation ?? null,
|
|
375
|
-
stop: I ? { ...I, userMessageIds: w, pending:
|
|
376
|
-
segments: l.map((S, x) => ({ ...S, collapsed: v ? S.userMessageId !==
|
|
377
|
-
activity: { phase: k, activeItemId:
|
|
375
|
+
stop: I ? { ...I, userMessageIds: w, pending: A } : null,
|
|
376
|
+
segments: l.map((S, x) => ({ ...S, collapsed: v ? S.userMessageId !== T : x < l.length - 1 || S.activityIds.length > 0 })),
|
|
377
|
+
activity: { phase: k, activeItemId: C, userMessageId: T, executionKey: JSON.stringify([...le(u)].sort()) },
|
|
378
378
|
// Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
|
|
379
379
|
// the same submitted text in the optimistic transcript and composer during delivery.
|
|
380
380
|
receipts: n.filter((S) => !S.cancelled && e.clients[S.clientScopeId] === s).map((S) => ({ viewId: S.viewId, userMessageId: S.userMessageId, acceptedRendererRevision: S.rendererRevision, durable: t.durableSubmissionIds.includes(S.userMessageId) || S.delivery === "accepted" }))
|
|
@@ -468,23 +468,23 @@ function Gr(t, e, s) {
|
|
|
468
468
|
if (!X(n.profile, d)) continue;
|
|
469
469
|
const l = s.conversationScopeId ? t.interactions.openings[s.conversationScopeId] : void 0;
|
|
470
470
|
if (!s.sessionId || !l || l.sessionId !== s.sessionId || !xi(t, s.conversationScopeId, c) || t.features.refreshRequired && !l.shown[c] || n.profile === "main_web_chat" && !t.interactions.bridgeReady && !l.shown[c]) continue;
|
|
471
|
-
const u =
|
|
472
|
-
if (u === !1 || t.features.desiredPreferences[c] === !1 ||
|
|
473
|
-
const
|
|
471
|
+
const u = bt(t, c), h = t.interactions.preferencePrompts[c], p = t.interactions.deviceFacts[c], m = `preference:${c}`;
|
|
472
|
+
if (u === !1 || t.features.desiredPreferences[c] === !1 || u === !0 && ["granted", "unknown"].includes(p.permission) || p.permission === "unsupported" || h.snoozedUntil && Date.parse(h.snoozedUntil) > a || p.snoozedUntil && Date.parse(p.snoozedUntil) > a) continue;
|
|
473
|
+
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] ?? (l.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
|
|
474
474
|
r.push({
|
|
475
475
|
id: m,
|
|
476
|
-
category:
|
|
476
|
+
category: "preference",
|
|
477
477
|
placement: "bottom_overlay",
|
|
478
478
|
sourceId: null,
|
|
479
479
|
conversationId: null,
|
|
480
480
|
userMessageId: null,
|
|
481
481
|
sourceVersion: l.generation,
|
|
482
482
|
decisionRevision: h.revision,
|
|
483
|
-
actions:
|
|
484
|
-
status:
|
|
485
|
-
error:
|
|
483
|
+
actions: ["enable", "not_now", "dont_enable"],
|
|
484
|
+
status: f ? "pending" : b ? "error" : y.status,
|
|
485
|
+
error: b,
|
|
486
486
|
payload: { feature: c, openingGeneration: l.generation },
|
|
487
|
-
nextEligibleAt:
|
|
487
|
+
nextEligibleAt: h.snoozedUntil ?? p.snoozedUntil
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
490
|
for (const c of Object.values(t.interactions.sources)) {
|
|
@@ -580,8 +580,8 @@ function Jr(t, e, s, n) {
|
|
|
580
580
|
if (u.category === "preference" || u.category === "permission") {
|
|
581
581
|
const f = u.payload.feature;
|
|
582
582
|
if (f !== "notifications" && f !== "tab_grouping") throw new Error("Missing preference feature.");
|
|
583
|
-
if (i = { ...i, interactions: { ...i.interactions, promptActions: { ...i.interactions.promptActions, [e.requestId]: { scope: n.clients[e.clientScopeId], openingGeneration: u.sourceVersion, expectedRevision: e.expectedRevision, feature: f, action: e.action } } } }, u.category === "permission") return { state: i, effects: r, command: { type: "stage7.permission", authority: a, now: e.now, requestId: e.requestId, feature: f, action: e.action, settings: !1 } };
|
|
584
|
-
const y = e.action === "not_now" ? { kind: "preferenceSnooze", feature: f, expectedRevision: e.expectedRevision } : { kind: "preference", feature: f, enabled:
|
|
583
|
+
if (i = { ...i, interactions: { ...i.interactions, promptActions: { ...i.interactions.promptActions, [e.requestId]: { scope: n.clients[e.clientScopeId], openingGeneration: u.sourceVersion, expectedRevision: e.expectedRevision, feature: f, action: e.action } } } }, e.action === "enable" || u.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 } };
|
|
584
|
+
const y = e.action === "not_now" ? { kind: "preferenceSnooze", feature: f, expectedRevision: e.expectedRevision } : { kind: "preference", feature: f, enabled: !1 };
|
|
585
585
|
return { state: i, effects: r, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: y } };
|
|
586
586
|
}
|
|
587
587
|
if (["not_now", "never", "snooze"].includes(e.action)) {
|
|
@@ -810,7 +810,7 @@ function ie(t, e) {
|
|
|
810
810
|
"runId" in e ? e.runId : null
|
|
811
811
|
]);
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function bt(t, e) {
|
|
814
814
|
return t.account.preferences?.[e === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"] ?? null;
|
|
815
815
|
}
|
|
816
816
|
const Yr = {
|
|
@@ -881,11 +881,11 @@ function Ls(t, e, s) {
|
|
|
881
881
|
const c = (g, v) => {
|
|
882
882
|
const I = { ...n.features.contextObservers }, w = I[g];
|
|
883
883
|
if (v === null ? delete I[g] : I[g] = ie(o, { kind: "originContext", clientScopeId: g, origin: v, pageUrl: "" }), r({ contextObservers: I }), !w || Object.values(I).includes(w)) return;
|
|
884
|
-
const
|
|
884
|
+
const A = { ...n.features.queries }, _ = { ...n.features.polls }, T = { ...n.features.contextReads }, E = { ...n.features.originContextQueries }, C = { ...n.features.pending }, O = E[w]?.origin, S = { ...n.features.contextRunOrigins };
|
|
885
885
|
for (const [x, U] of Object.entries(S)) U === O && delete S[x];
|
|
886
|
-
delete
|
|
887
|
-
for (const [x, U] of Object.entries(
|
|
888
|
-
r({ queries:
|
|
886
|
+
delete A[w], delete _[w], delete T[w], delete E[w];
|
|
887
|
+
for (const [x, U] of Object.entries(C)) U.mode === "query" && U.key === w && delete C[x];
|
|
888
|
+
r({ queries: A, polls: _, contextReads: T, originContextQueries: E, contextRunOrigins: S, pending: C });
|
|
889
889
|
};
|
|
890
890
|
if (e.type === "stage7.account_fallback") return { state: { ...n, account: {
|
|
891
891
|
...n.account,
|
|
@@ -905,18 +905,18 @@ function Ls(t, e, s) {
|
|
|
905
905
|
}
|
|
906
906
|
const l = (g, v, I) => {
|
|
907
907
|
const w = g === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
|
|
908
|
-
if (!X(o.profile, w) ||
|
|
909
|
-
const
|
|
910
|
-
delete
|
|
908
|
+
if (!X(o.profile, w) || n.features.desiredPreferences[g] === !1 || v === "check" && bt(n, g) !== !0 || Object.values(n.interactions.devicePending).some((T) => T.feature === g && (v === "check" || T.action !== "check"))) return;
|
|
909
|
+
const A = Se(o, "device", I), _ = { ...n.interactions.deviceErrors };
|
|
910
|
+
delete _[g], a({ deviceErrors: _, devicePending: { ...n.interactions.devicePending, [A]: { feature: g, requestId: I, generation: o.generation, desired: !0, action: v } } }), i.push({ kind: "stage7.device", id: A, input: { authority: o, requestId: I, feature: g, action: v, now: n.features.now } });
|
|
911
911
|
}, u = (g, v) => {
|
|
912
912
|
const I = v ? n.interactions.promptActions[v.replace(/:ack$/, "")] : void 0, w = { ...n.interactions.openings };
|
|
913
|
-
for (const [
|
|
914
|
-
if (I?.scope ===
|
|
915
|
-
const
|
|
916
|
-
delete
|
|
917
|
-
...
|
|
918
|
-
shown:
|
|
919
|
-
turns: Object.fromEntries(Object.entries(
|
|
913
|
+
for (const [A, _] of Object.entries(w)) {
|
|
914
|
+
if (I?.scope === A && I.openingGeneration === _.generation && ["enable", "allow"].includes(I.action)) continue;
|
|
915
|
+
const T = { ..._.shown };
|
|
916
|
+
delete T[g], w[A] = {
|
|
917
|
+
..._,
|
|
918
|
+
shown: T,
|
|
919
|
+
turns: Object.fromEntries(Object.entries(_.turns).map(([E, C]) => [E, { ...C, [g]: !1, [`${g}Suppressed`]: !0 }]))
|
|
920
920
|
};
|
|
921
921
|
}
|
|
922
922
|
a({ openings: w });
|
|
@@ -934,21 +934,29 @@ function Ls(t, e, s) {
|
|
|
934
934
|
g.kind === "preferences" && (n = { ...n, account: Xr(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: ss(n.interactions, g.decisions) }), g.kind === "decision" && (n = { ...n, interactions: ss(n.interactions, [g.value]) });
|
|
935
935
|
}, p = (g, v) => {
|
|
936
936
|
const I = n.interactions.deviceFacts[g];
|
|
937
|
-
v.revision <= I.revision
|
|
937
|
+
if (!(v.revision <= I.revision) && ((bt(n, g) === !0 || n.features.desiredPreferences[g] === !0) && (v.permission === "granted" && I.permission !== "granted" || v.snoozedUntil && v.snoozedUntil !== I.snoozedUntil) && u(g, null), a({ deviceFacts: { ...n.interactions.deviceFacts, [g]: v } }), n.features.desiredPreferences[g] === !0 && bt(n, g) !== !0)) {
|
|
938
|
+
const w = Object.values(n.features.pending).filter((A) => A.mode === "mutation" && A.key === `preference:${g}`);
|
|
939
|
+
if (v.permission === "granted" && !w.some((A) => A.status === "pending" || A.status === "error"))
|
|
940
|
+
f({ kind: "preference", feature: g, enabled: !0 }, `permission:${g}:${v.revision}`);
|
|
941
|
+
else if (!v.pending && v.permission === "missing" && v.snoozedUntil) {
|
|
942
|
+
const A = { ...n.features.desiredPreferences };
|
|
943
|
+
delete A[g], r({ desiredPreferences: A });
|
|
944
|
+
}
|
|
945
|
+
}
|
|
938
946
|
}, m = (g, v, I = !1) => {
|
|
939
947
|
Ce(o, g);
|
|
940
|
-
const w = ie(o, g),
|
|
948
|
+
const w = ie(o, g), A = Se(o, "query", v);
|
|
941
949
|
if (g.kind === "originContext") {
|
|
942
|
-
const
|
|
943
|
-
if (r({ originContextQueries: { ...n.features.originContextQueries, [w]: g } }), !I && (
|
|
944
|
-
}
|
|
945
|
-
const
|
|
946
|
-
if (
|
|
947
|
-
if (
|
|
948
|
-
const
|
|
949
|
-
r({ queries: { ...n.features.queries, [w]:
|
|
950
|
+
const C = n.features.queries[w], O = n.features.contextReads[w];
|
|
951
|
+
if (r({ originContextQueries: { ...n.features.originContextQueries, [w]: g } }), !I && (C?.status === "ready" || C?.status === "error") && O && (n.features.now - O.settledAt < 3e4 || C.error && !C.error.retryable && C.error.code !== "runtime_error")) return;
|
|
952
|
+
}
|
|
953
|
+
const _ = n.features.pending[A];
|
|
954
|
+
if (_ && _.fingerprint !== JSON.stringify(g)) throw new Error("Query request ID changed payload.");
|
|
955
|
+
if (_?.status === "pending" || Object.values(n.features.pending).some((C) => C.mode === "query" && C.key === w && C.status === "pending")) return;
|
|
956
|
+
const T = n.features.queries[w] ?? ye(w), E = Ue(T, { key: w, requestId: oe(v), mode: "replace" });
|
|
957
|
+
r({ queries: { ...n.features.queries, [w]: E }, pending: { ...n.features.pending, [A]: {
|
|
950
958
|
requestId: v,
|
|
951
|
-
effectId:
|
|
959
|
+
effectId: A,
|
|
952
960
|
fingerprint: JSON.stringify(g),
|
|
953
961
|
key: w,
|
|
954
962
|
generation: o.generation,
|
|
@@ -957,27 +965,27 @@ function Ls(t, e, s) {
|
|
|
957
965
|
status: "pending",
|
|
958
966
|
error: null,
|
|
959
967
|
result: null
|
|
960
|
-
} } }), g.kind === "account" && (n = { ...n, account: { ...n.account, query: Ue(n.account.query, { key: w, requestId: oe(v), mode: "replace" }) } }), i.push({ kind: "stage7.query", id:
|
|
968
|
+
} } }), g.kind === "account" && (n = { ...n, account: { ...n.account, query: Ue(n.account.query, { key: w, requestId: oe(v), mode: "replace" }) } }), i.push({ kind: "stage7.query", id: A, input: { authority: o, requestId: v, query: g } });
|
|
961
969
|
}, f = (g, v, I = !1) => {
|
|
962
970
|
if (Ce(o, g), g.kind === "report" && !n.account.query.data?.user?.isSuperuser) throw new Error("Chat reporting requires superuser access.");
|
|
963
|
-
const w = Se(o, "mutate", v),
|
|
964
|
-
if (
|
|
965
|
-
if (
|
|
966
|
-
if (!I ||
|
|
971
|
+
const w = Se(o, "mutate", v), A = JSON.stringify(g), _ = n.features.pending[w];
|
|
972
|
+
if (_) {
|
|
973
|
+
if (_.fingerprint !== A) throw new Error("Request ID was reused with a different payload.");
|
|
974
|
+
if (!I || _.status !== "error") return;
|
|
967
975
|
if (!["decision", "preferenceSnooze", "preferenceAcknowledge"].includes(g.kind)) throw new Error("This operation cannot be replayed automatically.");
|
|
968
|
-
if (["conflict", "409"].includes(
|
|
969
|
-
}
|
|
970
|
-
if (g.kind === "preference" && (r({ desiredPreferences: { ...n.features.desiredPreferences, [g.feature]: g.enabled } }), Object.values(n.features.pending).some((
|
|
971
|
-
const
|
|
972
|
-
if (
|
|
973
|
-
const
|
|
974
|
-
r({ pending: { ...n.features.pending, [
|
|
975
|
-
requestId:
|
|
976
|
-
effectId:
|
|
977
|
-
fingerprint: JSON.stringify(
|
|
978
|
-
key: Fn(
|
|
976
|
+
if (["conflict", "409"].includes(_.error?.code ?? "")) throw new Error("Refresh the conflicting decision before making another choice.");
|
|
977
|
+
}
|
|
978
|
+
if (g.kind === "preference" && (r({ desiredPreferences: { ...n.features.desiredPreferences, [g.feature]: g.enabled } }), Object.values(n.features.pending).some((T) => T.status === "pending" && T.operation.kind === "preference" && T.operation.feature === g.feature))) {
|
|
979
|
+
const T = n.features.queuedPreferences[g.feature];
|
|
980
|
+
if (T && T.requestId !== v) {
|
|
981
|
+
const E = Se(o, "mutate", T.requestId), C = { kind: "preference", feature: g.feature, enabled: T.enabled };
|
|
982
|
+
r({ pending: { ...n.features.pending, [E]: {
|
|
983
|
+
requestId: T.requestId,
|
|
984
|
+
effectId: E,
|
|
985
|
+
fingerprint: JSON.stringify(C),
|
|
986
|
+
key: Fn(C),
|
|
979
987
|
generation: o.generation,
|
|
980
|
-
operation:
|
|
988
|
+
operation: C,
|
|
981
989
|
mode: "mutation",
|
|
982
990
|
status: "error",
|
|
983
991
|
result: null,
|
|
@@ -988,10 +996,10 @@ function Ls(t, e, s) {
|
|
|
988
996
|
return;
|
|
989
997
|
}
|
|
990
998
|
if (g.kind === "generatePrompts") {
|
|
991
|
-
const
|
|
992
|
-
r({ queries: { ...n.features.queries, [
|
|
999
|
+
const T = { kind: "starterPrompts", ...g.page, includeUserSuggestions: g.includeUserSuggestions ?? !1 }, E = ie(o, T), C = n.features.queries[E] ?? ye(E);
|
|
1000
|
+
r({ queries: { ...n.features.queries, [E]: Ue(C, { key: E, requestId: oe(v), mode: "replace" }) } });
|
|
993
1001
|
}
|
|
994
|
-
r({ pending: { ...n.features.pending, [w]: { requestId: v, effectId: w, fingerprint:
|
|
1002
|
+
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 } });
|
|
995
1003
|
}, y = (g) => {
|
|
996
1004
|
if (!(!X(o.profile, "canManagePreferences") || n.features.refreshBatch)) {
|
|
997
1005
|
for (const v of Object.values(n.features.pending))
|
|
@@ -1003,13 +1011,13 @@ function Ls(t, e, s) {
|
|
|
1003
1011
|
}, b = (g, v) => {
|
|
1004
1012
|
const I = n.features.refreshBatch;
|
|
1005
1013
|
if (I?.pending.includes(g)) {
|
|
1006
|
-
const w = I.pending.filter((
|
|
1007
|
-
if (w.length) r({ refreshBatch: { pending: w, failed:
|
|
1014
|
+
const w = I.pending.filter((_) => _ !== g), A = I.failed || v;
|
|
1015
|
+
if (w.length) r({ refreshBatch: { pending: w, failed: A } });
|
|
1008
1016
|
else {
|
|
1009
|
-
const
|
|
1010
|
-
r({ refreshBatch: null, failures:
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1017
|
+
const _ = A ? n.features.failures + 1 : 0;
|
|
1018
|
+
r({ refreshBatch: null, failures: _, refreshAt: n.features.now + Math.min(6e4 * 2 ** _, 9e5) });
|
|
1019
|
+
const T = n.features.refreshQueuedRequestId;
|
|
1020
|
+
T && (r({ refreshQueuedRequestId: null }), y(T));
|
|
1013
1021
|
}
|
|
1014
1022
|
}
|
|
1015
1023
|
};
|
|
@@ -1018,19 +1026,19 @@ function Ls(t, e, s) {
|
|
|
1018
1026
|
const g = xt(void 0, e.code);
|
|
1019
1027
|
if (g.allowed) return { state: n, effects: i };
|
|
1020
1028
|
const v = { ...n.features.queries }, I = { ...n.features.pending }, w = [];
|
|
1021
|
-
for (const [
|
|
1022
|
-
if (
|
|
1023
|
-
const
|
|
1024
|
-
I[
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1029
|
+
for (const [A, _] of Object.entries(I)) {
|
|
1030
|
+
if (_.operation.kind !== "account" || _.status === "done" || _.status === "error") continue;
|
|
1031
|
+
const T = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
|
|
1032
|
+
I[A] = { ..._, status: "error", error: T }, w.push(A);
|
|
1033
|
+
const E = v[_.key];
|
|
1034
|
+
E && (v[_.key] = ct(E, { key: _.key, requestId: oe(_.requestId), error: T }));
|
|
1027
1035
|
}
|
|
1028
1036
|
n = { ...n, features: { ...n.features, pending: I, queries: v }, account: {
|
|
1029
1037
|
...n.account,
|
|
1030
1038
|
refusal: g,
|
|
1031
1039
|
query: { ...n.account.query, requestId: null, status: n.account.query.data ? "ready" : "not_requested" }
|
|
1032
1040
|
} };
|
|
1033
|
-
for (const
|
|
1041
|
+
for (const A of w) b(A, !0);
|
|
1034
1042
|
break;
|
|
1035
1043
|
}
|
|
1036
1044
|
case "stage7.context_observe":
|
|
@@ -1103,7 +1111,10 @@ function Ls(t, e, s) {
|
|
|
1103
1111
|
break;
|
|
1104
1112
|
}
|
|
1105
1113
|
case "stage7.permission": {
|
|
1106
|
-
if (
|
|
1114
|
+
if (e.action === "allow") {
|
|
1115
|
+
const v = Object.fromEntries(Object.entries(n.features.pending).filter(([, I]) => !(I.key === `preference:${e.feature}` && I.status === "error")));
|
|
1116
|
+
r({ pending: v, desiredPreferences: { ...n.features.desiredPreferences, [e.feature]: !0 } });
|
|
1117
|
+
}
|
|
1107
1118
|
const g = n.interactions.deviceFacts[e.feature].snoozedUntil;
|
|
1108
1119
|
if (!e.settings && g && Date.parse(g) > e.now) break;
|
|
1109
1120
|
l(e.feature, e.action, e.requestId);
|
|
@@ -1180,9 +1191,9 @@ function Ls(t, e, s) {
|
|
|
1180
1191
|
r({ now: e.output.now }), n = es(n, s.conversation, s.directory, e.output.now);
|
|
1181
1192
|
for (const [I, w] of Object.entries(n.features.polls)) {
|
|
1182
1193
|
if (w.deadline > e.output.now) continue;
|
|
1183
|
-
Object.values(n.features.pending).some((
|
|
1184
|
-
const
|
|
1185
|
-
delete
|
|
1194
|
+
Object.values(n.features.pending).some((_) => _.mode === "query" && _.key === I && _.status === "pending") || m(w.query.kind === "originContext" ? { ...w.query, trigger: "poll" } : w.query, `poll:${I}:${e.output.now}`, !0);
|
|
1195
|
+
const A = { ...n.features.polls };
|
|
1196
|
+
delete A[I], r({ polls: A });
|
|
1186
1197
|
}
|
|
1187
1198
|
n.features.refreshAt !== null && e.output.now >= n.features.refreshAt && y(`timer:${e.output.now}`);
|
|
1188
1199
|
}
|
|
@@ -1194,16 +1205,16 @@ function Ls(t, e, s) {
|
|
|
1194
1205
|
const w = { ...n.interactions.devicePending };
|
|
1195
1206
|
if (delete w[e.effectId], a({ devicePending: w }), e.type === "effect.completed") {
|
|
1196
1207
|
if (I.action !== "check" && n.interactions.promptActions[I.requestId] && !n.features.pending[Se(o, "mutate", `${I.requestId}:ack`)]) {
|
|
1197
|
-
const
|
|
1198
|
-
u(
|
|
1208
|
+
const A = n.interactions.promptActions[I.requestId];
|
|
1209
|
+
u(A.feature, I.requestId), f({
|
|
1199
1210
|
kind: "preferenceAcknowledge",
|
|
1200
|
-
feature:
|
|
1201
|
-
action:
|
|
1202
|
-
expectedRevision:
|
|
1211
|
+
feature: A.feature,
|
|
1212
|
+
action: A.action,
|
|
1213
|
+
expectedRevision: A.expectedRevision
|
|
1203
1214
|
}, `${I.requestId}:ack`);
|
|
1204
1215
|
}
|
|
1205
1216
|
p(I.feature, e.output.fact);
|
|
1206
|
-
} else
|
|
1217
|
+
} else n.features.desiredPreferences[I.feature] !== !1 && a({ deviceErrors: { ...n.interactions.deviceErrors, [I.feature]: e.error } });
|
|
1207
1218
|
break;
|
|
1208
1219
|
}
|
|
1209
1220
|
const g = n.features.pending[e.effectId];
|
|
@@ -1215,14 +1226,14 @@ function Ls(t, e, s) {
|
|
|
1215
1226
|
const w = n.features.queries[g.key];
|
|
1216
1227
|
if (!w || w.requestId !== g.requestId) break;
|
|
1217
1228
|
if (["originContext", "userContext", "contextRun"].includes(g.operation.kind)) {
|
|
1218
|
-
const
|
|
1219
|
-
delete
|
|
1229
|
+
const A = { ...n.features.polls };
|
|
1230
|
+
delete A[g.key], r({ polls: A, contextReads: { ...n.features.contextReads, [g.key]: {
|
|
1220
1231
|
settledAt: v ? n.features.now : e.output.completedAt,
|
|
1221
1232
|
failures: v ? (n.features.contextReads[g.key]?.failures ?? 0) + 1 : 0
|
|
1222
1233
|
} } });
|
|
1223
1234
|
}
|
|
1224
1235
|
if (v)
|
|
1225
|
-
r({ queries: { ...n.features.queries, [g.key]:
|
|
1236
|
+
r({ queries: { ...n.features.queries, [g.key]: ct(w, { key: g.key, requestId: oe(g.requestId), error: e.error }) } }), g.operation.kind === "account" && (n = { ...n, account: { ...n.account, query: ct(n.account.query, { key: g.key, requestId: oe(g.requestId), error: e.error }) } });
|
|
1226
1237
|
else {
|
|
1227
1238
|
if (e.output.data.kind !== g.operation.kind) throw new Error("Feature response kind does not match the query.");
|
|
1228
1239
|
r({ now: e.output.completedAt, queries: { ...n.features.queries, [g.key]: ts(w, { key: g.key, requestId: oe(g.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } }), h(e.output.data, g.requestId), e.output.data.kind === "account" && (n = { ...n, account: { ...n.account, refusal: null, query: ts(n.account.query, { key: g.key, requestId: oe(g.requestId), data: e.output.data.value, cursor: null, updatedAt: e.output.completedAt }) } });
|
|
@@ -1235,8 +1246,8 @@ function Ls(t, e, s) {
|
|
|
1235
1246
|
}
|
|
1236
1247
|
if (g.mode === "mutation" && g.operation.kind === "decision") {
|
|
1237
1248
|
const I = { ...n.interactions.actions };
|
|
1238
|
-
for (const [w,
|
|
1239
|
-
|
|
1249
|
+
for (const [w, A] of Object.entries(I))
|
|
1250
|
+
A.step === "persist" && g.requestId === `sharing:${w}` && (A.operation.kind === "copy" || A.operation.kind === "share") && (I[w] = { ...A, status: v ? "error" : "done", error: v ? e.error : null });
|
|
1240
1251
|
a({ actions: I });
|
|
1241
1252
|
}
|
|
1242
1253
|
if (!v && g.mode === "mutation" && g.operation.kind === "preference" && n.interactions.promptActions[g.requestId]) {
|
|
@@ -1249,8 +1260,8 @@ function Ls(t, e, s) {
|
|
|
1249
1260
|
}, `${g.requestId}:ack`);
|
|
1250
1261
|
}
|
|
1251
1262
|
if (b(e.effectId, v), g.operation.kind === "generatePrompts") {
|
|
1252
|
-
const I = { kind: "starterPrompts", ...g.operation.page, includeUserSuggestions: g.operation.includeUserSuggestions ?? !1 }, w = ie(o, I),
|
|
1253
|
-
|
|
1263
|
+
const I = { kind: "starterPrompts", ...g.operation.page, includeUserSuggestions: g.operation.includeUserSuggestions ?? !1 }, w = ie(o, I), A = n.features.queries[w];
|
|
1264
|
+
A?.requestId === g.requestId && r({ queries: { ...n.features.queries, [w]: v ? ct(A, { key: w, requestId: oe(g.requestId), error: e.error }) : ts(A, { key: w, requestId: oe(g.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } });
|
|
1254
1265
|
}
|
|
1255
1266
|
if (!v && e.output.data.kind === "originContext") {
|
|
1256
1267
|
const I = e.output.data, w = g.operation.kind === "originContext" || g.operation.kind === "refreshContext" ? g.operation.origin : null;
|
|
@@ -1258,32 +1269,32 @@ function Ls(t, e, s) {
|
|
|
1258
1269
|
if (I.value.runId && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status))
|
|
1259
1270
|
r({ contextRunOrigins: { ...n.features.contextRunOrigins, [I.value.runId]: w } });
|
|
1260
1271
|
else {
|
|
1261
|
-
const
|
|
1262
|
-
for (const [
|
|
1263
|
-
r({ contextRunOrigins:
|
|
1272
|
+
const A = { ...n.features.contextRunOrigins };
|
|
1273
|
+
for (const [_, T] of Object.entries(A)) T === w && delete A[_];
|
|
1274
|
+
r({ contextRunOrigins: A });
|
|
1264
1275
|
}
|
|
1265
1276
|
if (g.mode === "mutation") {
|
|
1266
|
-
const
|
|
1267
|
-
for (const [
|
|
1277
|
+
const A = { ...n.features.queries }, _ = { ...n.features.pending }, T = { ...n.features.contextReads }, E = { ...n.features.polls };
|
|
1278
|
+
for (const [C, O] of Object.entries(n.features.originContextQueries))
|
|
1268
1279
|
if (O.origin === w) {
|
|
1269
|
-
|
|
1270
|
-
for (const [S, x] of Object.entries(
|
|
1271
|
-
["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (
|
|
1280
|
+
A[C] = { ...A[C], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, T[C] = { settledAt: e.output.completedAt, failures: 0 }, delete E[C];
|
|
1281
|
+
for (const [S, x] of Object.entries(_)) x.mode === "query" && x.key === C && delete _[S];
|
|
1282
|
+
["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (E[C] = { query: { ...O, kind: "originContext", trigger: "poll" }, deadline: n.features.now + 5e3 });
|
|
1272
1283
|
}
|
|
1273
|
-
r({ queries:
|
|
1284
|
+
r({ queries: A, pending: _, contextReads: T, polls: E });
|
|
1274
1285
|
}
|
|
1275
1286
|
}
|
|
1276
1287
|
}
|
|
1277
1288
|
if (!v && e.output.data.kind === "contextRun" && !["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(e.output.data.value.status)) {
|
|
1278
1289
|
const I = e.output.data.value.runId, w = I ? n.features.contextRunOrigins[I] : null;
|
|
1279
1290
|
if (w && I) {
|
|
1280
|
-
const
|
|
1281
|
-
delete
|
|
1282
|
-
for (const [
|
|
1283
|
-
if (
|
|
1284
|
-
const
|
|
1285
|
-
for (const [
|
|
1286
|
-
r({ pending:
|
|
1291
|
+
const A = { ...n.features.contextRunOrigins };
|
|
1292
|
+
delete A[I], r({ contextRunOrigins: A });
|
|
1293
|
+
for (const [_, T] of Object.entries(n.features.originContextQueries)) {
|
|
1294
|
+
if (T.origin !== w) continue;
|
|
1295
|
+
const E = { ...n.features.pending };
|
|
1296
|
+
for (const [C, O] of Object.entries(E)) O.mode === "query" && O.key === _ && delete E[C];
|
|
1297
|
+
r({ pending: E }), m({ ...T, kind: "originContext" }, `context-final:${g.requestId}:${_}`, !0);
|
|
1287
1298
|
}
|
|
1288
1299
|
}
|
|
1289
1300
|
}
|
|
@@ -1292,18 +1303,18 @@ function Ls(t, e, s) {
|
|
|
1292
1303
|
if (I.kind === "originContext" || I.kind === "userContext" || I.kind === "contextRun") {
|
|
1293
1304
|
const w = I.kind === "originContext" ? g.mode === "query" && g.operation.kind === "originContext" && Object.values(n.features.contextObservers).includes(g.key) ? g.operation : null : I.kind === "userContext" ? { kind: "userContext" } : I.value.runId ? { kind: "contextRun", runId: I.value.runId } : null;
|
|
1294
1305
|
if (w && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status)) {
|
|
1295
|
-
const
|
|
1296
|
-
r({ polls: { ...n.features.polls, [
|
|
1306
|
+
const A = ie(o, w);
|
|
1307
|
+
r({ polls: { ...n.features.polls, [A]: { query: w, deadline: n.features.now + 5e3 } } });
|
|
1297
1308
|
}
|
|
1298
1309
|
}
|
|
1299
1310
|
}
|
|
1300
1311
|
if (!v && g.operation.kind === "stopContext")
|
|
1301
1312
|
for (const [I, w] of Object.entries(n.features.originContextQueries)) {
|
|
1302
|
-
const
|
|
1303
|
-
if (
|
|
1304
|
-
const
|
|
1305
|
-
for (const [
|
|
1306
|
-
r({ pending:
|
|
1313
|
+
const A = n.features.queries[I]?.data;
|
|
1314
|
+
if (A?.kind === "originContext" && A.value.runId === g.operation.runId) {
|
|
1315
|
+
const _ = { ...n.features.pending };
|
|
1316
|
+
for (const [T, E] of Object.entries(_)) E.mode === "query" && E.key === I && delete _[T];
|
|
1317
|
+
r({ pending: _ }), m({ ...w, kind: "originContext" }, `context-stop:${g.requestId}:${I}`, !0);
|
|
1307
1318
|
}
|
|
1308
1319
|
}
|
|
1309
1320
|
if (v && g.mode === "query" && ["originContext", "userContext", "contextRun"].includes(g.operation.kind) && e.error.retryable && (n.features.contextReads[g.key]?.failures ?? 0) <= 3) {
|
|
@@ -1313,17 +1324,17 @@ function Ls(t, e, s) {
|
|
|
1313
1324
|
if (g.mode === "query" && g.operation.kind === "userSuggestedTasks") {
|
|
1314
1325
|
const I = v ? n.features.suggestionReadFailures + 1 : 0, w = { ...n.features.polls };
|
|
1315
1326
|
delete w[g.key];
|
|
1316
|
-
const
|
|
1317
|
-
|
|
1327
|
+
const A = v && (e.error.retryable || ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.error.code));
|
|
1328
|
+
A && I <= 3 && (w[g.key] = { query: g.operation, deadline: n.features.now + 1e3 * 2 ** (I - 1) }), r({ suggestionReadFailures: I, suggestionRetryAfter: A && I > 3 ? n.features.now + 3e4 : null, polls: w });
|
|
1318
1329
|
}
|
|
1319
1330
|
if (g.operation.kind === "preference") {
|
|
1320
1331
|
const I = g.operation.feature, w = n.features.queuedPreferences[I];
|
|
1321
1332
|
if (w) {
|
|
1322
|
-
const
|
|
1323
|
-
delete
|
|
1333
|
+
const A = { ...n.features.queuedPreferences };
|
|
1334
|
+
delete A[I], r({ queuedPreferences: A }), f({ kind: "preference", feature: I, enabled: w.enabled }, w.requestId);
|
|
1324
1335
|
} else {
|
|
1325
|
-
const
|
|
1326
|
-
delete
|
|
1336
|
+
const A = { ...n.features.desiredPreferences };
|
|
1337
|
+
delete A[I], r({ desiredPreferences: A });
|
|
1327
1338
|
}
|
|
1328
1339
|
}
|
|
1329
1340
|
if (!v && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) l(I, "check", `preference:${g.requestId}:${I}`);
|
|
@@ -1452,7 +1463,7 @@ function to(t, e, s, n) {
|
|
|
1452
1463
|
}
|
|
1453
1464
|
};
|
|
1454
1465
|
}
|
|
1455
|
-
function
|
|
1466
|
+
function nt(t) {
|
|
1456
1467
|
if (!t || typeof t != "object") return !1;
|
|
1457
1468
|
const e = t;
|
|
1458
1469
|
return Object.keys(t).every((s) => ["boundary", "category", "messageKind"].includes(s)) && ["runtime", "web_transport", "extension_ipc"].includes(e.boundary) && ["error", "object", "null", "array", "string", "undefined", "number", "boolean", "bigint", "symbol", "function"].includes(e.category) && ["object_coercion", "text", "blank", "non_text"].includes(e.messageKind);
|
|
@@ -1471,7 +1482,7 @@ function Y(t, e = "runtime_error", s = "runtime") {
|
|
|
1471
1482
|
const n = t !== null && typeof t == "object" ? t : null, i = typeof t == "string" ? t : n && "message" in n && typeof n.message == "string" ? n.message : "", r = n && "code" in n && typeof n.code == "string" && n.code.trim() ? n.code : e, a = n && "details" in n ? n.details : null, o = a && typeof a == "object" ? a : {}, c = {
|
|
1472
1483
|
...typeof o.httpStatus == "number" && Number.isInteger(o.httpStatus) && o.httpStatus >= 100 && o.httpStatus <= 599 ? { httpStatus: o.httpStatus } : {},
|
|
1473
1484
|
// Preserve the first boundary's shape after normalization replaces the original message/prototype.
|
|
1474
|
-
errorNormalization:
|
|
1485
|
+
errorNormalization: nt(o.errorNormalization) ? o.errorNormalization : {
|
|
1475
1486
|
boundary: s,
|
|
1476
1487
|
category: t instanceof Error ? "error" : t === null ? "null" : Array.isArray(t) ? "array" : typeof t,
|
|
1477
1488
|
messageKind: i.trim() === "[object Object]" ? "object_coercion" : i.trim() ? "text" : typeof t == "string" || n && "message" in n && typeof n.message == "string" ? "blank" : "non_text"
|
|
@@ -1602,7 +1613,7 @@ function Ve(t, e) {
|
|
|
1602
1613
|
hasContext: Be(s.hasContext)
|
|
1603
1614
|
} };
|
|
1604
1615
|
}
|
|
1605
|
-
function
|
|
1616
|
+
function dt(t, e) {
|
|
1606
1617
|
const s = N(t), n = s.style === null ? null : N(s.style), i = n && N(n.style ?? n);
|
|
1607
1618
|
if (!i) return { kind: "appearance", origin: e, value: null };
|
|
1608
1619
|
const r = P(i.colorScheme);
|
|
@@ -1611,7 +1622,7 @@ function lt(t, e) {
|
|
|
1611
1622
|
if (!je(a)) throw new Error("Invalid appearance metadata.");
|
|
1612
1623
|
return { kind: "appearance", origin: e, ...n?.createdAt === void 0 ? {} : { stored: { createdAt: P(n.createdAt), updatedAt: P(n.updatedAt), metadata: a } }, value: { accent: P(i.accent), colorScheme: r, fontFamily: P(i.fontFamily), scribbleStyle: Be(i.scribbleStyle) } };
|
|
1613
1624
|
}
|
|
1614
|
-
function
|
|
1625
|
+
function lt(t) {
|
|
1615
1626
|
const e = N(t);
|
|
1616
1627
|
if (!Be(e.success)) throw new Error(de(e.message) ?? "Failed to submit feedback");
|
|
1617
1628
|
return { kind: "ack", success: !0 };
|
|
@@ -1696,7 +1707,7 @@ function ro(t) {
|
|
|
1696
1707
|
c = Ve("contextRun", await o(`/context-refresh-runs/${encodeURIComponent(i.runId)}`));
|
|
1697
1708
|
break;
|
|
1698
1709
|
case "appearance":
|
|
1699
|
-
c = a ? await t.embedded.appearance(i) :
|
|
1710
|
+
c = a ? await t.embedded.appearance(i) : dt(await o("/style", { origin: i.origin }), i.origin);
|
|
1700
1711
|
break;
|
|
1701
1712
|
case "hostedEligibility":
|
|
1702
1713
|
c = { kind: "hostedEligibility", eligible: Be(N(await o("/remote-browser/eligibility", { community_id: n.communityId })).usableBrowserStorage) };
|
|
@@ -1731,10 +1742,10 @@ function ro(t) {
|
|
|
1731
1742
|
c = { kind: "decision", value: $n(await o("/interaction-decisions", { category: i.category, prompt_key: i.promptKey, action: i.action, request_id: r, expected_revision: i.expectedRevision })) };
|
|
1732
1743
|
break;
|
|
1733
1744
|
case "feedback":
|
|
1734
|
-
c =
|
|
1745
|
+
c = lt(a ? { success: await t.embedded.feedback(i.message) } : await o("/feedback", { ...rs(i.context), feedback_type: "general", message: i.message }));
|
|
1735
1746
|
break;
|
|
1736
1747
|
case "proactiveFeedback":
|
|
1737
|
-
c =
|
|
1748
|
+
c = lt(await o("/feedback", {
|
|
1738
1749
|
...rs(i.context),
|
|
1739
1750
|
feedback_type: "proactive_suggestion",
|
|
1740
1751
|
proactive_suggestion_action: "feedback",
|
|
@@ -1745,10 +1756,10 @@ function ro(t) {
|
|
|
1745
1756
|
break;
|
|
1746
1757
|
case "targetFeedback":
|
|
1747
1758
|
if (a) throw new Error("Embedded target feedback has no HTTP contract.");
|
|
1748
|
-
c =
|
|
1759
|
+
c = lt(await o("/feedback/target", { feedback_type: "target_rating", target_id: i.targetId, rating: i.rating, ...i.comment === void 0 ? {} : { comment: i.comment } }));
|
|
1749
1760
|
break;
|
|
1750
1761
|
case "report":
|
|
1751
|
-
c =
|
|
1762
|
+
c = lt(await o("/feedback", { ...rs(i.context), feedback_type: "chat_report", session_id: i.sessionId, message: i.message, ui_evidence: i.uiEvidence, widget_evidence_available: i.widgetEvidenceAvailable }));
|
|
1752
1763
|
break;
|
|
1753
1764
|
case "generatePrompts": {
|
|
1754
1765
|
const d = N(await o("/starter-prompts", { page_url: i.page.pageUrl, html_content: i.htmlContent, page_title: i.pageTitle }, "POST", a ? {} : { origin: i.page.origin, include_user_suggestions: i.includeUserSuggestions ?? !1 }));
|
|
@@ -1770,17 +1781,17 @@ function ro(t) {
|
|
|
1770
1781
|
case "sampleStyle": {
|
|
1771
1782
|
if (!t.sampleStyle) throw new Error("Style sampling unavailable.");
|
|
1772
1783
|
const d = await t.sampleStyle(i.page);
|
|
1773
|
-
e(n), c =
|
|
1784
|
+
e(n), c = dt(await o("/style/refresh", { origin: i.origin, style: { accent: d.accent, color_scheme: d.colorScheme, font_family: d.fontFamily, scribble_style: d.scribbleStyle } }), i.origin);
|
|
1774
1785
|
break;
|
|
1775
1786
|
}
|
|
1776
1787
|
case "saveStyle":
|
|
1777
|
-
c =
|
|
1788
|
+
c = dt(await o("/style/refresh", { origin: i.origin, style: { accent: i.value.accent, color_scheme: i.value.colorScheme, font_family: i.value.fontFamily, scribble_style: i.value.scribbleStyle } }), i.origin);
|
|
1778
1789
|
break;
|
|
1779
1790
|
case "deleteStyle":
|
|
1780
1791
|
await o("/style", {}, "DELETE", { origin: i.origin }), c = { kind: "appearance", origin: i.origin, value: null };
|
|
1781
1792
|
break;
|
|
1782
1793
|
case "scribble":
|
|
1783
|
-
c =
|
|
1794
|
+
c = dt(await o("/style/scribble", { origin: i.origin, enabled: i.enabled }), i.origin);
|
|
1784
1795
|
break;
|
|
1785
1796
|
}
|
|
1786
1797
|
return e(n), { data: c, completedAt: t.now() };
|
|
@@ -1900,16 +1911,16 @@ async function uo(t, e, s = crypto.randomUUID()) {
|
|
|
1900
1911
|
}
|
|
1901
1912
|
function ho(t, e, s, n) {
|
|
1902
1913
|
return Fi(t, e, s, n).map((i) => {
|
|
1903
|
-
const r = i.sourceId ? Object.values(t.interactions.sources).find((
|
|
1914
|
+
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, l = o === "notifications" ? "Get notified when Pluno finishes a task?" : o === "tab_grouping" ? "Group tabs used by Pluno?" : i.category === "sharing" ? "Share what Pluno helped you accomplish." : String(i.payload.text ?? d ?? ""), u = 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;
|
|
1904
1915
|
return {
|
|
1905
1916
|
id: i.id,
|
|
1906
|
-
kind:
|
|
1917
|
+
kind: c,
|
|
1907
1918
|
category: i.category,
|
|
1908
1919
|
scope: { level: i.conversationId ? "session" : "user", key: i.conversationId ?? t.account.authority.userId },
|
|
1909
1920
|
payload: {
|
|
1910
1921
|
...i.payload,
|
|
1911
1922
|
error: i.error?.message ?? null,
|
|
1912
|
-
...
|
|
1923
|
+
...h ? { request: h, status: i.payload.lifecycle ?? r?.lifecycle, error: i.error?.message ?? null } : {},
|
|
1913
1924
|
...i.category === "sharing" ? { candidate: { id: i.id, variant: a?.kind === "sharing" ? a.variant : "social" } } : {},
|
|
1914
1925
|
...i.category === "proactive_suggestion" ? { suggestion: { id: String(i.payload.sourceSuggestionId ?? i.id), interactionId: i.id, genericQuestion: String(i.payload.text ?? ""), question: String(i.payload.text ?? "") } } : {},
|
|
1915
1926
|
...i.category === "morning_report" ? { opening: i.payload.text, prompts: i.payload.tasks } : {}
|
|
@@ -1917,7 +1928,7 @@ function ho(t, e, s, n) {
|
|
|
1917
1928
|
placement: i.placement,
|
|
1918
1929
|
userMessageId: i.userMessageId,
|
|
1919
1930
|
sourceVersion: i.sourceVersion,
|
|
1920
|
-
presentation: { title:
|
|
1931
|
+
presentation: { title: d, body: l, actionLabels: u },
|
|
1921
1932
|
eligible: !0,
|
|
1922
1933
|
status: i.status,
|
|
1923
1934
|
allowedActions: i.actions,
|
|
@@ -1962,7 +1973,7 @@ function fo(t, e = null) {
|
|
|
1962
1973
|
} : void 0);
|
|
1963
1974
|
return { ...n, ...o ? { auth: o } : {}, submissionGate: a, usingPaidCreditFallback: e ? t.paidFallbackBySession[e] ?? !1 : !1 };
|
|
1964
1975
|
}
|
|
1965
|
-
const go = "0.1.
|
|
1976
|
+
const go = "0.1.282", Lt = {
|
|
1966
1977
|
version: go
|
|
1967
1978
|
}, ln = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, mo = (t, e) => t.scopes[e];
|
|
1968
1979
|
function Ft(t) {
|
|
@@ -2082,7 +2093,7 @@ function Vs(t, e, s = !1) {
|
|
|
2082
2093
|
}
|
|
2083
2094
|
return G(i);
|
|
2084
2095
|
}
|
|
2085
|
-
function
|
|
2096
|
+
function ut(t) {
|
|
2086
2097
|
return JSON.stringify(t, (e, s) => s && typeof s == "object" && !Array.isArray(s) ? Object.fromEntries(Object.entries(s).sort(([n], [i]) => n.localeCompare(i))) : s);
|
|
2087
2098
|
}
|
|
2088
2099
|
function vo(t, e, s, n) {
|
|
@@ -2181,7 +2192,7 @@ function vo(t, e, s, n) {
|
|
|
2181
2192
|
if (!o || o.cancelled || o.delivery === "failed") return { state: t, effects: r };
|
|
2182
2193
|
const c = Z({ pageContent: e.pageContent, sessionTabs: e.sessionTabs });
|
|
2183
2194
|
if (o.contextPreparation !== null) {
|
|
2184
|
-
if (
|
|
2195
|
+
if (ut(o.contextPreparation) !== ut(c)) throw new Error("Prepared submission context cannot change.");
|
|
2185
2196
|
return { state: t, effects: r };
|
|
2186
2197
|
}
|
|
2187
2198
|
i = { ...t, submissions: { ...t.submissions, [e.userMessageId]: { ...o, contextPreparation: c } } };
|
|
@@ -2191,8 +2202,8 @@ function vo(t, e, s, n) {
|
|
|
2191
2202
|
if (s.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
|
|
2192
2203
|
const { type: o, authorityId: c, generation: d, prepareContext: l, reconcileAcceptance: u, waitForAuthentication: h, ...p } = e, m = t.submissions[e.userMessageId];
|
|
2193
2204
|
if (m) {
|
|
2194
|
-
const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled:
|
|
2195
|
-
if (
|
|
2205
|
+
const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled: A, cancellationReason: _, error: T, executionVersion: E, ...C } = m;
|
|
2206
|
+
if (ut(C) !== ut(p)) throw new Error("User-message identity cannot be reused with different input.");
|
|
2196
2207
|
return { state: t, effects: r };
|
|
2197
2208
|
}
|
|
2198
2209
|
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 = {
|
|
@@ -2607,18 +2618,18 @@ function Io(t, e, s, n) {
|
|
|
2607
2618
|
error: v.contextPreparation === null && !m.deliveries[g]?.handoffRecovery && !v.cancelled && !["unauthorized", "auth_reconnecting"].includes(v.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !m.deliveries[g] && v.delivery !== "accepted" && !v.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : v.error
|
|
2608
2619
|
}])),
|
|
2609
2620
|
deliveries: Object.fromEntries(Object.entries(m.submissions).map(([g, v], I) => {
|
|
2610
|
-
const w = m.deliveries[g],
|
|
2621
|
+
const w = m.deliveries[g], A = v.contextPreparation === null && !w?.handoffRecovery, _ = v.delivery === "accepted" ? "accepted" : w?.acceptance ?? (w && (w.step === "send" || w.step === "receipt") ? "uncertain" : "unissued");
|
|
2611
2622
|
return [g, {
|
|
2612
2623
|
...zn(v, I),
|
|
2613
2624
|
...w,
|
|
2614
|
-
acceptance:
|
|
2625
|
+
acceptance: _,
|
|
2615
2626
|
allocation: v.sessionId !== null ? "resolved" : w?.allocation ?? (w?.step === "upload" ? "uncertain" : "unissued"),
|
|
2616
2627
|
effectId: null,
|
|
2617
2628
|
// Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
|
|
2618
|
-
step:
|
|
2619
|
-
prepared:
|
|
2629
|
+
step: _ === "uncertain" && (w?.step === "send" || w?.handoffRecovery) && w.phase !== "done" ? "receipt" : w?.step ?? null,
|
|
2630
|
+
prepared: _ === "accepted",
|
|
2620
2631
|
queuePosition: w?.queuePosition ?? I,
|
|
2621
|
-
phase:
|
|
2632
|
+
phase: _ === "accepted" ? "done" : A || !w ? "failed" : ["running", "waiting"].includes(w.phase) ? "uncertain" : w.phase
|
|
2622
2633
|
}];
|
|
2623
2634
|
})),
|
|
2624
2635
|
operations: Object.fromEntries(Object.entries(m.operations).map(([g, v]) => [g, {
|
|
@@ -2705,16 +2716,23 @@ function Io(t, e, s, n) {
|
|
|
2705
2716
|
}
|
|
2706
2717
|
const a = vo(i, r, s, n);
|
|
2707
2718
|
let o = a.state;
|
|
2708
|
-
e.type === "conversation.submission_stage" && o !== i && !o.deliveries[e.userMessageId]
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
...
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2719
|
+
if (e.type === "conversation.submission_stage" && o !== i && !o.deliveries[e.userMessageId]) {
|
|
2720
|
+
o = {
|
|
2721
|
+
...o,
|
|
2722
|
+
effectsEnabled: !0,
|
|
2723
|
+
requestSequence: o.requestSequence + 1,
|
|
2724
|
+
deliveries: { ...o.deliveries, [e.userMessageId]: {
|
|
2725
|
+
...zn(o.submissions[e.userMessageId], o.requestSequence + 1),
|
|
2726
|
+
...e.reconcileAcceptance !== void 0 ? { handoffRecovery: !0, recoveryDeadline: e.reconcileAcceptance + 18e4, acceptance: "uncertain", step: "receipt" } : {},
|
|
2727
|
+
...e.waitForAuthentication ? { phase: "failed" } : {}
|
|
2728
|
+
} }
|
|
2729
|
+
};
|
|
2730
|
+
const u = o.submissions[e.userMessageId], h = o.deliveries[e.userMessageId];
|
|
2731
|
+
h.phase === "waiting" && (o = { ...o, deliveries: Object.fromEntries(Object.entries(o.deliveries).map(([p, m]) => {
|
|
2732
|
+
const f = o.submissions[p];
|
|
2733
|
+
return m.queuePosition < h.queuePosition && (f.conversationScopeId === u.conversationScopeId || u.sessionId !== null && f.sessionId === u.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];
|
|
2734
|
+
})) });
|
|
2735
|
+
}
|
|
2718
2736
|
for (const [u, h] of Object.entries(o.submissions)) {
|
|
2719
2737
|
const p = o.deliveries[u];
|
|
2720
2738
|
p && (h.delivery === "accepted" && p.acceptance !== "accepted" ? o = {
|
|
@@ -2827,7 +2845,7 @@ function _o(t) {
|
|
|
2827
2845
|
const Wi = Math.random().toString(36).slice(2);
|
|
2828
2846
|
let So = 0;
|
|
2829
2847
|
const Vn = () => `timing:${Wi}:${++So}`, Ke = (t) => typeof t == "string" && /^[a-zA-Z0-9:_-]{1,160}$/.test(t);
|
|
2830
|
-
function
|
|
2848
|
+
function it(t) {
|
|
2831
2849
|
if (!t || typeof t != "object") return !1;
|
|
2832
2850
|
const e = t;
|
|
2833
2851
|
return Object.keys(e).every((s) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory", "tabId", "queueDepth", "workerId"].includes(s)) && (e.tabId === void 0 || Number.isSafeInteger(e.tabId) && e.tabId >= 0) && (e.queueDepth === void 0 || Number.isSafeInteger(e.queueDepth) && e.queueDepth >= 0) && (e.workerId === void 0 || Ke(e.workerId)) && (e.failureCategory === void 0 || e.status === "failed" && Ki.includes(e.failureCategory)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && wo.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && Ke(e.spanId) && Ke(e.requestId) && (e.clientMessageId === null || Ke(e.clientMessageId)) && (e.sessionId === null || Ke(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
|
|
@@ -2849,7 +2867,7 @@ function Q(t, e) {
|
|
|
2849
2867
|
durationMs: Math.max(0, Math.round(performance.now() - a)),
|
|
2850
2868
|
...r === "failed" ? { failureCategory: _o(c) } : {}
|
|
2851
2869
|
};
|
|
2852
|
-
t &&
|
|
2870
|
+
t && it(d) && Promise.resolve().then(() => t(d)).catch(() => {
|
|
2853
2871
|
});
|
|
2854
2872
|
};
|
|
2855
2873
|
return {
|
|
@@ -2875,7 +2893,7 @@ function ko(t) {
|
|
|
2875
2893
|
});
|
|
2876
2894
|
};
|
|
2877
2895
|
return (i) => {
|
|
2878
|
-
|
|
2896
|
+
it(i) && (JSON.stringify([...e, i]).length > 2800 && n(), e.push(i), e.length === 8 ? n() : s ??= setTimeout(n, 250));
|
|
2879
2897
|
};
|
|
2880
2898
|
}
|
|
2881
2899
|
function Ro(t) {
|
|
@@ -3023,7 +3041,7 @@ function Gi(t) {
|
|
|
3023
3041
|
function Oo(t) {
|
|
3024
3042
|
if (!t || typeof t != "object") return !1;
|
|
3025
3043
|
const e = t;
|
|
3026
|
-
return Object.keys(e).every((s) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(s)) && (e.clientMessageId === void 0 || j(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((s) => s === null || j(s) !== null) && (e.normalization === void 0 ||
|
|
3044
|
+
return Object.keys(e).every((s) => ["sessionId", "requestId", "code", "normalization", "builds", "clientMessageId"].includes(s)) && (e.clientMessageId === void 0 || j(e.clientMessageId) !== null) && [e.sessionId, e.requestId, e.code].every((s) => s === null || j(s) !== null) && (e.normalization === void 0 || nt(e.normalization)) && !!e.builds && typeof e.builds == "object" && typeof e.builds.sdk == "string" && Object.entries(e.builds).every(([s, n]) => ["sdk", "rendererExtension", "contentExtension", "backgroundExtension"].includes(s) && typeof n == "string" && /^\d{1,5}\.\d{1,5}\.\d{1,5}$/.test(n));
|
|
3027
3045
|
}
|
|
3028
3046
|
function Ji(t, e, s, n, i = {}) {
|
|
3029
3047
|
const r = !n && e === "conversation_error" && s !== void 0 && t.conversationDiagnostics?.errorMessageFingerprint === Gi(Oe(s)) ? t.conversationDiagnostics : void 0;
|
|
@@ -3032,7 +3050,7 @@ function Ji(t, e, s, n, i = {}) {
|
|
|
3032
3050
|
requestId: j(r?.httpRequest?.requestId ?? r?.errorRequestId ?? r?.queryRequestId),
|
|
3033
3051
|
...j(r?.failedClientMessageId) ? { clientMessageId: r.failedClientMessageId } : {},
|
|
3034
3052
|
code: r ? j(t.lastErrorCode) : null,
|
|
3035
|
-
...
|
|
3053
|
+
...nt(r?.errorNormalization) ? { normalization: r.errorNormalization } : {},
|
|
3036
3054
|
builds: { sdk: Lt.version, ...i }
|
|
3037
3055
|
};
|
|
3038
3056
|
}
|
|
@@ -3042,7 +3060,7 @@ function xo(t, e = "runtime") {
|
|
|
3042
3060
|
`).replace(/\n\s*at\s/g, `
|
|
3043
3061
|
frame `)) : void 0;
|
|
3044
3062
|
return {
|
|
3045
|
-
...
|
|
3063
|
+
...nt(s.details?.errorNormalization) ? { normalization: s.details.errorNormalization } : {},
|
|
3046
3064
|
category: t instanceof Error ? "error" : t === null ? "null" : Array.isArray(t) ? "array" : typeof t,
|
|
3047
3065
|
code: Oe(s.code),
|
|
3048
3066
|
message: Oe(s.message),
|
|
@@ -3328,7 +3346,7 @@ function Bo(t) {
|
|
|
3328
3346
|
const y = h.engine.getState().slices, b = y.conversation.submissions[o.submission.userMessageId];
|
|
3329
3347
|
(!J(t) || !b || b.cancelled || b.requestId !== o.submission.requestId || y.directory.clients[b.clientScopeId] !== b.conversationScopeId) && l(Object.assign(new Error("Submission preparation was retired."), { code: "aborted", retryable: !1 }));
|
|
3330
3348
|
}, m = h.engine.subscribe(p), f = h.onDispose(() => l(Object.assign(new Error("Submission runtime was disposed."), { code: "aborted" })));
|
|
3331
|
-
return p(),
|
|
3349
|
+
return p(), vt(c.signal, () => t.prepareSubmission(o, c.signal).then((y) => (c.signal.aborted && d.mark("context_discarded"), y), (y) => {
|
|
3332
3350
|
throw c.signal.aborted && d.mark("context_discarded"), y;
|
|
3333
3351
|
})).then((y) => (p(), c.signal.throwIfAborted(), a(o), y)).catch((y) => (l(y), n(y, { operation: "conversation.prepare", requestId: o.submission.userMessageId }))).finally(() => {
|
|
3334
3352
|
clearTimeout(u), m(), f();
|
|
@@ -3723,7 +3741,7 @@ function $o(t, e, s, n) {
|
|
|
3723
3741
|
function ds(t, e, s, n) {
|
|
3724
3742
|
const i = /* @__PURE__ */ new Map();
|
|
3725
3743
|
for (const _ of t.segments)
|
|
3726
|
-
for (const
|
|
3744
|
+
for (const T of [..._.activityIds, ..._.outcomeIds]) i.set(T, _.userMessageId);
|
|
3727
3745
|
const r = t.items.map((_) => $o(
|
|
3728
3746
|
_,
|
|
3729
3747
|
i.get(_.id) ?? null,
|
|
@@ -3737,18 +3755,18 @@ function ds(t, e, s, n) {
|
|
|
3737
3755
|
// There is no canonical timestamp before acceptance. Keep identity stable without fabricating one.
|
|
3738
3756
|
createdAt: "",
|
|
3739
3757
|
retryable: _.delivery === "failed" && !["unauthorized", "401", "auth_reconnecting"].includes(_.error?.code ?? "") && ["delivery", "preparation"].includes(Ni(t, _.userMessageId)?.type ?? ""),
|
|
3740
|
-
attachments: _.attachments.map((
|
|
3741
|
-
id:
|
|
3742
|
-
name:
|
|
3743
|
-
mimeType:
|
|
3744
|
-
sizeBytes:
|
|
3758
|
+
attachments: _.attachments.map((T) => ({
|
|
3759
|
+
id: T.sourceId,
|
|
3760
|
+
name: T.name,
|
|
3761
|
+
mimeType: T.mimeType,
|
|
3762
|
+
sizeBytes: T.sizeBytes
|
|
3745
3763
|
}))
|
|
3746
3764
|
});
|
|
3747
|
-
const a =
|
|
3765
|
+
const a = r, o = { ...t.removedItems };
|
|
3748
3766
|
for (const _ of t.segments) {
|
|
3749
3767
|
if (!_.userMessageId) continue;
|
|
3750
|
-
const
|
|
3751
|
-
|
|
3768
|
+
const T = r.find((E) => _.outcomeIds.includes(E.id) && !E.loading && (E.dataType === "run_status" || E.dataType === "run_error" || E.role === "assistant" && E.phase === "final_answer" && E.streamState === "finished"));
|
|
3769
|
+
T && (o[`local-interrupted:${_.userMessageId}`] = T.id);
|
|
3752
3770
|
}
|
|
3753
3771
|
t.proactiveQuestion && a.push({
|
|
3754
3772
|
id: t.proactiveQuestion.id,
|
|
@@ -3759,29 +3777,30 @@ function ds(t, e, s, n) {
|
|
|
3759
3777
|
loading: !1
|
|
3760
3778
|
});
|
|
3761
3779
|
const c = t.activity.phase, d = t.submissions.filter((_) => !_.cancelled && !["accepted", "failed"].includes(_.delivery)), l = t.submissions[t.submissions.length - 1], u = [...t.items].reverse().find((_) => _.type === "user_message"), h = ["queued", "thinking", "steering", "awaiting_execution"].includes(c), p = l?.delivery === "failed" && (h && t.activity.userMessageId != null && t.activity.userMessageId !== l.userMessageId || u !== void 0 && u.id !== l.userMessageId && Date.parse(u.created_at) > l.submittedAt), m = new Map(t.submissions.filter((_) => (_ !== l || p) && !_.cancelled && _.delivery === "failed" && _.error).map((_) => [_.userMessageId, _])), f = a.flatMap((_) => {
|
|
3762
|
-
const
|
|
3763
|
-
return
|
|
3764
|
-
id: `submission-error:${
|
|
3780
|
+
const T = _.role === "user" ? m.get(_.id) : void 0;
|
|
3781
|
+
return T?.error ? [_, {
|
|
3782
|
+
id: `submission-error:${T.userMessageId}`,
|
|
3765
3783
|
role: "system",
|
|
3766
3784
|
dataType: "run_error",
|
|
3767
|
-
respondsToUserMessageId:
|
|
3768
|
-
content:
|
|
3785
|
+
respondsToUserMessageId: T.userMessageId,
|
|
3786
|
+
content: T.error.message,
|
|
3769
3787
|
createdAt: "",
|
|
3770
3788
|
loading: !1,
|
|
3771
|
-
...typeof
|
|
3789
|
+
...typeof T.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: T.error.details.securitySettingsUrl } : {}
|
|
3772
3790
|
}] : [_];
|
|
3773
3791
|
}), y = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, b = y ? null : e?.error ?? null, k = [...t.submissions].reverse().find((_) => t.pendingDurabilityIds?.includes(_.userMessageId)), R = k ? {
|
|
3774
3792
|
code: "submission_checkpoint_pending",
|
|
3775
3793
|
message: Vr,
|
|
3776
3794
|
details: { requestId: k.requestId }
|
|
3777
|
-
} : null, g = l?.delivery === "failed" && !l.cancelled && !p ? l.error : b ?? R
|
|
3795
|
+
} : null, g = l?.delivery === "failed" && !l.cancelled && !p ? l.error : b ?? R;
|
|
3796
|
+
let I = {
|
|
3778
3797
|
isRetrying: t.isRetrying ?? !1,
|
|
3779
3798
|
historyRefreshFailure: g === e?.error ? t.historyRefreshFailure ?? null : null,
|
|
3780
3799
|
conversationDiagnostics: {
|
|
3781
3800
|
...g ? { errorMessageFingerprint: Gi(Oe(g.message)) } : {},
|
|
3782
3801
|
...l && g && g === l.error && !p ? { failedClientMessageId: l.userMessageId } : {},
|
|
3783
3802
|
...typeof g?.details?.requestId == "string" ? { errorRequestId: g.details.requestId } : {},
|
|
3784
|
-
...
|
|
3803
|
+
...nt(g?.details?.errorNormalization) ? { errorNormalization: g.details.errorNormalization } : {},
|
|
3785
3804
|
...n ? { owner: n } : {},
|
|
3786
3805
|
...he(g?.details?.httpRequest) ? { httpRequest: g.details.httpRequest } : {},
|
|
3787
3806
|
queryStatus: e?.status ?? null,
|
|
@@ -3815,20 +3834,22 @@ function ds(t, e, s, n) {
|
|
|
3815
3834
|
lastErrorCode: g?.code ?? null,
|
|
3816
3835
|
lastErrorSecuritySettingsUrl: typeof g?.details?.securitySettingsUrl == "string" ? g.details.securitySettingsUrl : null
|
|
3817
3836
|
};
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3837
|
+
for (const _ of t.optimistic.filter((T) => T.cancelled && !t.stop?.userMessageIds.includes(T.userMessageId))) {
|
|
3838
|
+
const T = Js(I, "", "stopped", [_.userMessageId], Jn(_.cancellationReason));
|
|
3839
|
+
I = { ...I, messages: T.messages, segments: T.segments };
|
|
3840
|
+
}
|
|
3841
|
+
if (t.stop) {
|
|
3842
|
+
const _ = Js(
|
|
3843
|
+
I,
|
|
3844
|
+
"",
|
|
3845
|
+
t.stop.pending ? "stopping" : "stopped",
|
|
3846
|
+
t.stop.userMessageIds,
|
|
3847
|
+
Jn(t.stop.reason ?? "user_requested")
|
|
3848
|
+
);
|
|
3849
|
+
I = { ...I, messages: _.messages, segments: _.segments };
|
|
3850
|
+
}
|
|
3851
|
+
const w = new Map(I.segments.flatMap((_, T) => [_.userMessageId, ..._.activityIds, ..._.outcomeIds].filter((E) => E !== null).map((E) => [E, T]))), A = (_) => w.get(_.id) ?? w.get(_.respondsToUserMessageId ?? "") ?? 1 / 0;
|
|
3852
|
+
return { ...I, messages: [...I.messages].sort((_, T) => A(_) - A(T)) };
|
|
3832
3853
|
}
|
|
3833
3854
|
function Jn(t) {
|
|
3834
3855
|
switch (t) {
|
|
@@ -4031,15 +4052,15 @@ function Go(t, e) {
|
|
|
4031
4052
|
ls || (ls = new TextEncoder()), e(ls.encode(s));
|
|
4032
4053
|
});
|
|
4033
4054
|
}
|
|
4034
|
-
const ei = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
4055
|
+
const ei = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Ye = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
4035
4056
|
for (let t = 0; t < ei.length; t++)
|
|
4036
|
-
|
|
4057
|
+
Ye[ei.charCodeAt(t)] = t;
|
|
4037
4058
|
const Jo = (t) => {
|
|
4038
4059
|
let e = t.length * 0.75, s = t.length, n, i = 0, r, a, o, c;
|
|
4039
4060
|
t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
|
|
4040
4061
|
const d = new ArrayBuffer(e), l = new Uint8Array(d);
|
|
4041
4062
|
for (n = 0; n < s; n += 4)
|
|
4042
|
-
r =
|
|
4063
|
+
r = Ye[t.charCodeAt(n)], a = Ye[t.charCodeAt(n + 1)], o = Ye[t.charCodeAt(n + 2)], c = Ye[t.charCodeAt(n + 3)], l[i++] = r << 2 | a >> 4, l[i++] = (a & 15) << 4 | o >> 2, l[i++] = (o & 3) << 6 | c & 63;
|
|
4043
4064
|
return d;
|
|
4044
4065
|
}, Qo = typeof ArrayBuffer == "function", yn = (t, e) => {
|
|
4045
4066
|
if (typeof t != "string")
|
|
@@ -4103,10 +4124,10 @@ function ea() {
|
|
|
4103
4124
|
});
|
|
4104
4125
|
}
|
|
4105
4126
|
let us;
|
|
4106
|
-
function
|
|
4127
|
+
function ht(t) {
|
|
4107
4128
|
return t.reduce((e, s) => e + s.length, 0);
|
|
4108
4129
|
}
|
|
4109
|
-
function
|
|
4130
|
+
function pt(t, e) {
|
|
4110
4131
|
if (t[0].length === e)
|
|
4111
4132
|
return t.shift();
|
|
4112
4133
|
const s = new Uint8Array(e);
|
|
@@ -4123,28 +4144,28 @@ function ta(t, e) {
|
|
|
4123
4144
|
transform(a, o) {
|
|
4124
4145
|
for (s.push(a); ; ) {
|
|
4125
4146
|
if (n === 0) {
|
|
4126
|
-
if (
|
|
4147
|
+
if (ht(s) < 1)
|
|
4127
4148
|
break;
|
|
4128
|
-
const c =
|
|
4149
|
+
const c = pt(s, 1);
|
|
4129
4150
|
r = (c[0] & 128) === 128, i = c[0] & 127, i < 126 ? n = 3 : i === 126 ? n = 1 : n = 2;
|
|
4130
4151
|
} else if (n === 1) {
|
|
4131
|
-
if (
|
|
4152
|
+
if (ht(s) < 2)
|
|
4132
4153
|
break;
|
|
4133
|
-
const c =
|
|
4154
|
+
const c = pt(s, 2);
|
|
4134
4155
|
i = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), n = 3;
|
|
4135
4156
|
} else if (n === 2) {
|
|
4136
|
-
if (
|
|
4157
|
+
if (ht(s) < 8)
|
|
4137
4158
|
break;
|
|
4138
|
-
const c =
|
|
4159
|
+
const c = pt(s, 8), d = new DataView(c.buffer, c.byteOffset, c.length), l = d.getUint32(0);
|
|
4139
4160
|
if (l > Math.pow(2, 21) - 1) {
|
|
4140
4161
|
o.enqueue(Qs);
|
|
4141
4162
|
break;
|
|
4142
4163
|
}
|
|
4143
4164
|
i = l * Math.pow(2, 32) + d.getUint32(4), n = 3;
|
|
4144
4165
|
} else {
|
|
4145
|
-
if (
|
|
4166
|
+
if (ht(s) < i)
|
|
4146
4167
|
break;
|
|
4147
|
-
const c =
|
|
4168
|
+
const c = pt(s, i);
|
|
4148
4169
|
o.enqueue(yn(r ? c : us.decode(c), e)), n = 0;
|
|
4149
4170
|
}
|
|
4150
4171
|
if (i === 0 || i > t) {
|
|
@@ -6309,7 +6330,7 @@ const Fa = 9e4, $a = /* @__PURE__ */ new Set([
|
|
|
6309
6330
|
"tool.started",
|
|
6310
6331
|
"tool.result"
|
|
6311
6332
|
]);
|
|
6312
|
-
class
|
|
6333
|
+
class q extends Error {
|
|
6313
6334
|
constructor(e, s, n = !1, i, r = !1) {
|
|
6314
6335
|
super(e), this.code = s, this.outcomeUnknown = n, this.detail = i, this.backendRefusal = r, this.code = s === "401" ? "unauthorized" : s;
|
|
6315
6336
|
}
|
|
@@ -6320,7 +6341,7 @@ class E extends Error {
|
|
|
6320
6341
|
}
|
|
6321
6342
|
function ni(t, e) {
|
|
6322
6343
|
const s = t.result && typeof t.result == "object" ? t.result : void 0, n = typeof s?.message == "string" && s.message.trim() ? s.message : `${e} (${t.code ?? "request_rejected"})`;
|
|
6323
|
-
return new
|
|
6344
|
+
return new q(n, t.code ?? "request_rejected", !1, t.result, !0);
|
|
6324
6345
|
}
|
|
6325
6346
|
class za {
|
|
6326
6347
|
constructor(e) {
|
|
@@ -6349,7 +6370,7 @@ class za {
|
|
|
6349
6370
|
}) : this.invalidate(!1, s), this.restoreBackoff();
|
|
6350
6371
|
}), this.socket.io.on("reconnect", () => this.restoreBackoff()), this.socket.on("connection.ready", (s) => {
|
|
6351
6372
|
if (s.protocol !== 1 || s.role !== this.options.auth.role || s.display_projection_ready !== !1) {
|
|
6352
|
-
this.options.onError(new
|
|
6373
|
+
this.options.onError(new q("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
|
|
6353
6374
|
return;
|
|
6354
6375
|
}
|
|
6355
6376
|
this.admitted = s, this.activate();
|
|
@@ -6360,14 +6381,14 @@ class za {
|
|
|
6360
6381
|
}), this.socket.on("connect_error", (s) => {
|
|
6361
6382
|
const n = s.data?.code;
|
|
6362
6383
|
if (n === "unauthorized" && s.data?.reason === "token_expired" && s.data.retryable === !0) {
|
|
6363
|
-
this.options.onError(new
|
|
6384
|
+
this.options.onError(new q(s.message, n, !1, s.data)), this.disconnect();
|
|
6364
6385
|
return;
|
|
6365
6386
|
}
|
|
6366
6387
|
if (!n || s.data?.retryable === !0) {
|
|
6367
6388
|
this.invalidate(!1, "connect_error"), this.options.reconnect === !1 ? this.socket.disconnect() : this.scheduleNamespaceReconnect();
|
|
6368
6389
|
return;
|
|
6369
6390
|
}
|
|
6370
|
-
(n === "unauthorized" || n === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new
|
|
6391
|
+
(n === "unauthorized" || n === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new q(s.message, n ?? "connection_error", !1, s.data)), this.rejectedToken === this.options.auth.token && this.disconnect();
|
|
6371
6392
|
}), this.socket.on("conversation.event", (s) => {
|
|
6372
6393
|
this.ready && s.protocol === 1 && s.session_id && this.bindings.get(s.session_id)?.owners.size && this.options.onEvent("conversation.event", s.event);
|
|
6373
6394
|
}), this.socket.on("conversation.metadata.updated", (s) => {
|
|
@@ -6394,7 +6415,7 @@ class za {
|
|
|
6394
6415
|
const i = this.generation, r = await this.options.onToolCall(s);
|
|
6395
6416
|
n({ received: r && !!this.ready && i === this.generation });
|
|
6396
6417
|
}), this.socket.on("executor.replaced", () => {
|
|
6397
|
-
this.retired = !0, this.options.onError(new
|
|
6418
|
+
this.retired = !0, this.options.onError(new q("Browser executor was replaced", "executor_replaced")), this.disconnect();
|
|
6398
6419
|
});
|
|
6399
6420
|
}
|
|
6400
6421
|
options;
|
|
@@ -6438,11 +6459,11 @@ class za {
|
|
|
6438
6459
|
return this.ready && this.socket.id ? `pa-sio:${this.socket.id}` : null;
|
|
6439
6460
|
}
|
|
6440
6461
|
async restoreExecutor(e) {
|
|
6441
|
-
if (this.connectionId !== e) throw new
|
|
6462
|
+
if (this.connectionId !== e) throw new q("Browser connection changed.", "executor_not_ready");
|
|
6442
6463
|
if (this.executorRecovery) return this.executorRecovery;
|
|
6443
6464
|
const s = this.request("executor.register", {}, this.generation).then(() => {
|
|
6444
6465
|
}, (n) => {
|
|
6445
|
-
throw n instanceof
|
|
6466
|
+
throw n instanceof q && (n.outcomeUnknown || n.code === "disconnected") ? new q("Reconnecting the browser before continuing.", "executor_not_ready") : n;
|
|
6446
6467
|
});
|
|
6447
6468
|
this.executorRecovery = s;
|
|
6448
6469
|
try {
|
|
@@ -6484,7 +6505,7 @@ class za {
|
|
|
6484
6505
|
beginAttempt() {
|
|
6485
6506
|
this.clearReadinessTimers(), this.activity = { ...this.activity, lastPacketReceivedAt: null, lastHeartbeatReceivedAt: null, lastHeartbeatQueuedAt: null }, this.active = !0, this.attempt = { connectionAttemptId: crypto.randomUUID(), reconnectAttempt: this.attemptCount++, startedAt: Date.now() }, this.socket.auth = { ...this.options.auth, connection_attempt_id: this.attempt.connectionAttemptId }, this.options.onAttempt?.(this.attempt);
|
|
6486
6507
|
const e = this.generation, s = (n) => {
|
|
6487
|
-
e !== this.generation || !this.active || (this.options.onError(new
|
|
6508
|
+
e !== this.generation || !this.active || (this.options.onError(new q("Product Agent readiness timed out", n, !1, {
|
|
6488
6509
|
retryable: !0,
|
|
6489
6510
|
...this.attempt,
|
|
6490
6511
|
readinessPhase: this.ready ? "bootstrap" : this.admitted ? "activation" : "namespace_ready"
|
|
@@ -6498,20 +6519,20 @@ class za {
|
|
|
6498
6519
|
async retain(e, s) {
|
|
6499
6520
|
let n = this.bindings.get(e);
|
|
6500
6521
|
if (!n) {
|
|
6501
|
-
if (this.bindings.size >= 64) throw new
|
|
6522
|
+
if (this.bindings.size >= 64) throw new q("Too many conversation subscriptions", "subscription_limit");
|
|
6502
6523
|
n = { id: crypto.randomUUID(), owners: /* @__PURE__ */ new Set(), joinedGeneration: -1 }, this.bindings.set(e, n);
|
|
6503
6524
|
}
|
|
6504
6525
|
if (n.owners.add(s), !this.ready) return;
|
|
6505
6526
|
const i = this.generation;
|
|
6506
6527
|
await this.synchronize().catch((r) => {
|
|
6507
|
-
throw i !== this.generation || (n.owners.delete(s), r instanceof
|
|
6528
|
+
throw i !== this.generation || (n.owners.delete(s), r instanceof q && r.outcomeUnknown && this.ready && (n.joinedGeneration = this.generation), this.synchronize().catch((a) => this.options.onError(a))), r;
|
|
6508
6529
|
});
|
|
6509
6530
|
}
|
|
6510
6531
|
async release(e, s) {
|
|
6511
6532
|
this.bindings.get(e)?.owners.delete(s), this.ready && await this.synchronize();
|
|
6512
6533
|
}
|
|
6513
6534
|
async rpc(e, s) {
|
|
6514
|
-
if (!$a.has(e)) throw new
|
|
6535
|
+
if (!$a.has(e)) throw new q("Operation requires its HTTP adapter", "unsupported_rpc");
|
|
6515
6536
|
const n = this.generation, i = JSON.stringify(s);
|
|
6516
6537
|
return e === "run.stop" && this.uploadingResult ? (this.assertReady(n), this.request("runtime.rpc", { type: e, payload: JSON.parse(i) }, n)) : this.enqueue(async () => {
|
|
6517
6538
|
if (this.assertReady(n), e === "tool.result") {
|
|
@@ -6531,13 +6552,13 @@ class za {
|
|
|
6531
6552
|
this.ready = s, await this.synchronize(!0), e === this.generation && this.ready && (this.options.bootstrapRequired || this.markReady(), this.options.onReady(s));
|
|
6532
6553
|
} catch (i) {
|
|
6533
6554
|
if (e === this.generation) {
|
|
6534
|
-
const r = Y(i, "activation_error", "web_transport"), a = i instanceof
|
|
6555
|
+
const r = Y(i, "activation_error", "web_transport"), a = i instanceof q ? i : new q(
|
|
6535
6556
|
r.message,
|
|
6536
6557
|
r.code,
|
|
6537
6558
|
!1,
|
|
6538
6559
|
{ ...r.details, retryable: r.retryable }
|
|
6539
6560
|
);
|
|
6540
|
-
this.activationFailed(new
|
|
6561
|
+
this.activationFailed(new q(
|
|
6541
6562
|
a.message,
|
|
6542
6563
|
a.code,
|
|
6543
6564
|
a.outcomeUnknown,
|
|
@@ -6564,7 +6585,7 @@ class za {
|
|
|
6564
6585
|
subscription_id: i.id,
|
|
6565
6586
|
...this.options.displaySchema === "canonical" ? { display_schema: "canonical" } : {}
|
|
6566
6587
|
}, s).then(() => !0).catch((a) => {
|
|
6567
|
-
if (a instanceof
|
|
6588
|
+
if (a instanceof q && !a.outcomeUnknown && a.detail?.retryable !== !0 && this.bindings.get(n) === i && (this.bindings.delete(n), e))
|
|
6568
6589
|
return this.options.onError(a), !1;
|
|
6569
6590
|
throw a;
|
|
6570
6591
|
})) continue;
|
|
@@ -6576,7 +6597,7 @@ class za {
|
|
|
6576
6597
|
}
|
|
6577
6598
|
enqueue(e) {
|
|
6578
6599
|
if (this.queuedOperations >= 128) {
|
|
6579
|
-
const n = new
|
|
6600
|
+
const n = new q("Product Agent transport queue is full", "backpressure");
|
|
6580
6601
|
return this.recoverUncertainDelivery(n, this.generation), Promise.reject(n);
|
|
6581
6602
|
}
|
|
6582
6603
|
this.queuedOperations++;
|
|
@@ -6587,7 +6608,7 @@ class za {
|
|
|
6587
6608
|
}), s;
|
|
6588
6609
|
}
|
|
6589
6610
|
assertReady(e) {
|
|
6590
|
-
if (!this.ready || !this.socket.connected || e !== this.generation) throw new
|
|
6611
|
+
if (!this.ready || !this.socket.connected || e !== this.generation) throw new q("Transport is not ready", "disconnected");
|
|
6591
6612
|
}
|
|
6592
6613
|
async uploadResult(e, s, n) {
|
|
6593
6614
|
const i = crypto.randomUUID();
|
|
@@ -6612,38 +6633,38 @@ class za {
|
|
|
6612
6633
|
body: JSON.stringify({ request_id: i, type: "tool.result", payload: e })
|
|
6613
6634
|
});
|
|
6614
6635
|
if (u.status >= 500)
|
|
6615
|
-
throw new
|
|
6616
|
-
if (!u.ok) throw new
|
|
6636
|
+
throw new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
6637
|
+
if (!u.ok) throw new q(`Result upload rejected (${u.status})`, String(u.status), !1, void 0, !0);
|
|
6617
6638
|
const h = await u.json();
|
|
6618
6639
|
if (s !== this.generation || r.signal.aborted)
|
|
6619
|
-
throw new
|
|
6640
|
+
throw new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
6620
6641
|
if (h?.request_id !== i || typeof h.ok != "boolean")
|
|
6621
|
-
throw new
|
|
6642
|
+
throw new q("Invalid result acknowledgement identity", "invalid_ack", !0);
|
|
6622
6643
|
if (!h.ok) throw ni(h, "Product Agent result rejected");
|
|
6623
6644
|
return h.result;
|
|
6624
6645
|
} catch (d) {
|
|
6625
|
-
const l = d instanceof
|
|
6646
|
+
const l = d instanceof q ? d : new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
6626
6647
|
throw this.recoverUncertainDelivery(l, s), l;
|
|
6627
6648
|
} finally {
|
|
6628
6649
|
clearTimeout(c), this.uploadingResult = !1, this.pending.delete(a);
|
|
6629
6650
|
}
|
|
6630
6651
|
}
|
|
6631
6652
|
request(e, s, n) {
|
|
6632
|
-
if (!this.socket.connected || n !== this.generation) return Promise.reject(new
|
|
6653
|
+
if (!this.socket.connected || n !== this.generation) return Promise.reject(new q("Transport disconnected", "disconnected"));
|
|
6633
6654
|
const i = crypto.randomUUID();
|
|
6634
6655
|
return new Promise((r, a) => {
|
|
6635
6656
|
const o = (c) => {
|
|
6636
6657
|
this.pending.delete(o), a(c);
|
|
6637
6658
|
};
|
|
6638
6659
|
this.pending.add(o), this.socket.timeout(this.options.requestTimeoutMs ?? 15e3).emit(e, { ...s, request_id: i }, (c, d) => {
|
|
6639
|
-
this.pending.delete(o) && (c || n !== this.generation ? a(new
|
|
6660
|
+
this.pending.delete(o) && (c || n !== this.generation ? a(new q("Delivery outcome is unknown; reconcile without repeating execution", "delivery_unknown", !0)) : d?.request_id !== i || typeof d.ok != "boolean" ? a(new q("Invalid acknowledgement identity", "invalid_ack", !0)) : d.ok ? r(d.result) : a(ni(d, "Product Agent request rejected")));
|
|
6640
6661
|
});
|
|
6641
6662
|
}).catch((r) => {
|
|
6642
6663
|
throw this.recoverUncertainDelivery(r, n), r;
|
|
6643
6664
|
});
|
|
6644
6665
|
}
|
|
6645
6666
|
recoverUncertainDelivery(e, s) {
|
|
6646
|
-
e instanceof
|
|
6667
|
+
e instanceof q && (e.outcomeUnknown || e.code === "backpressure" && !e.backendRefusal) && s === this.generation && this.active && this.recover(e.code === "backpressure" ? "local_backpressure" : "local_delivery_uncertain");
|
|
6647
6668
|
}
|
|
6648
6669
|
invalidate(e = !1, s = "local_invalidation") {
|
|
6649
6670
|
if (this.clearReadinessTimers(), !!this.active) {
|
|
@@ -6655,7 +6676,7 @@ class za {
|
|
|
6655
6676
|
lastHeartbeatReceivedAt: this.activity.lastHeartbeatReceivedAt,
|
|
6656
6677
|
lastHeartbeatQueuedAt: this.activity.lastHeartbeatQueuedAt
|
|
6657
6678
|
}, this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
|
|
6658
|
-
for (const n of [...this.pending]) n(new
|
|
6679
|
+
for (const n of [...this.pending]) n(new q("Connection lost before acknowledgement", "delivery_unknown", !0));
|
|
6659
6680
|
this.options.onDisconnect(e, s);
|
|
6660
6681
|
}
|
|
6661
6682
|
}
|
|
@@ -6683,7 +6704,7 @@ class dr {
|
|
|
6683
6704
|
async request(e, s = {}, n, i, r, a = {}) {
|
|
6684
6705
|
if (a.skipAuthentication) return this.requestOnce(e, s, n, i, r, a.signal, a.diagnostic);
|
|
6685
6706
|
const o = this.options.authority?.(), c = (u = !0) => {
|
|
6686
|
-
if (o !== this.options.authority?.()) throw new
|
|
6707
|
+
if (o !== this.options.authority?.()) throw new q("Conversation authority was retired.", "authority_retired", !0);
|
|
6687
6708
|
u && (this.requests.signal.throwIfAborted(), a.signal?.throwIfAborted());
|
|
6688
6709
|
}, d = a.readOnly ?? (i ?? (n === void 0 ? "GET" : "POST")) === "GET";
|
|
6689
6710
|
let l = 0;
|
|
@@ -6698,7 +6719,7 @@ class dr {
|
|
|
6698
6719
|
try {
|
|
6699
6720
|
let f = n;
|
|
6700
6721
|
if (r === "conversations" && e === "/commands" && this.auth.role !== "session_surface" && this.options.executorConnection) {
|
|
6701
|
-
if (m = this.options.executorConnection(), !m) throw new
|
|
6722
|
+
if (m = this.options.executorConnection(), !m) throw new q("Reconnecting the browser before continuing.", "executor_not_ready");
|
|
6702
6723
|
const k = n;
|
|
6703
6724
|
f = { ...k, context: { ...k.context, connection_id: m } };
|
|
6704
6725
|
}
|
|
@@ -6706,66 +6727,66 @@ class dr {
|
|
|
6706
6727
|
return c(), b;
|
|
6707
6728
|
} catch (f) {
|
|
6708
6729
|
if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw f;
|
|
6709
|
-
if (f instanceof
|
|
6730
|
+
if (f instanceof q && f.code === "executor_not_ready" && m && u === 0 && this.options.restoreExecutor) {
|
|
6710
6731
|
await this.options.restoreExecutor(m), u++, c();
|
|
6711
6732
|
continue;
|
|
6712
6733
|
}
|
|
6713
|
-
if (!(f instanceof
|
|
6734
|
+
if (!(f instanceof q) || !["unauthorized", "403"].includes(f.code) || !this.options.recoverAuthentication || !d || (await this.options.recoverAuthentication(p, f, d && u === 0), c(), !d || u !== 0)) throw f;
|
|
6714
6735
|
u++;
|
|
6715
6736
|
}
|
|
6716
6737
|
}
|
|
6717
6738
|
}
|
|
6718
6739
|
async requestOnce(e, s, n, i, r, a, o, c = 1) {
|
|
6719
6740
|
const d = this.auth.client_kind === "embed", l = new URL(`/api/product-agent/${r ?? (d ? "embed" : "runtime")}${e}`, this.options.backendUrl), u = r === "conversations" ? {} : d ? { client_id: this.auth.client_id, transport_id: this.auth.transport_id } : { community_id: this.auth.community_id, automation_run_id: this.auth.automation_run_id };
|
|
6720
|
-
for (const [
|
|
6721
|
-
|
|
6741
|
+
for (const [E, C] of Object.entries({ ...u, ...s }))
|
|
6742
|
+
C != null && l.searchParams.set(E, String(C));
|
|
6722
6743
|
this.requests.signal.throwIfAborted(), a?.throwIfAborted();
|
|
6723
|
-
const h = new AbortController(), p = { trigger: null }, m = (
|
|
6724
|
-
h.signal.aborted || (p.trigger =
|
|
6744
|
+
const h = new AbortController(), p = { trigger: null }, m = (E) => {
|
|
6745
|
+
h.signal.aborted || (p.trigger = E, h.abort());
|
|
6725
6746
|
}, f = () => m("transport_disposed"), y = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
|
|
6726
6747
|
this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", y, { once: !0 });
|
|
6727
6748
|
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 = Ha(), v = Date.now();
|
|
6728
|
-
let I = null, w = !1,
|
|
6749
|
+
let I = null, w = !1, A = null, _ = null, T = null;
|
|
6729
6750
|
try {
|
|
6730
|
-
const
|
|
6751
|
+
const E = await Promise.resolve(fetch(l, {
|
|
6731
6752
|
method: i ?? (n === void 0 ? "GET" : "POST"),
|
|
6732
6753
|
cache: "no-store",
|
|
6733
6754
|
signal: h.signal,
|
|
6734
6755
|
headers: { "x-product-agent-auth-request-id": g, authorization: d || r === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...b ? { "x-request-id": g } : {} },
|
|
6735
6756
|
...n === void 0 ? {} : { body: JSON.stringify(n) }
|
|
6736
|
-
})).catch((
|
|
6737
|
-
throw w = !0,
|
|
6757
|
+
})).catch((C) => {
|
|
6758
|
+
throw w = !0, C;
|
|
6738
6759
|
});
|
|
6739
|
-
if (I = Date.now(),
|
|
6740
|
-
const
|
|
6741
|
-
if (d &&
|
|
6742
|
-
throw new
|
|
6743
|
-
if (r === "conversations" && e.endsWith("/snapshot") &&
|
|
6744
|
-
throw new
|
|
6745
|
-
if (r === "conversations" && e === "/commands" &&
|
|
6746
|
-
throw new
|
|
6747
|
-
if (r === "conversations" && e === "/commands" && (
|
|
6748
|
-
throw new
|
|
6749
|
-
if (
|
|
6750
|
-
throw new
|
|
6760
|
+
if (I = Date.now(), A = E.status, _ = ii(E.headers.get("x-request-id")), T = ii(E.headers.get("x-cloud-trace-context")), !E.ok) {
|
|
6761
|
+
const C = E.status === 401 ? "unauthorized" : E.status === 426 ? "update_required" : String(E.status), O = (await E.json().catch(() => null))?.detail;
|
|
6762
|
+
if (d && E.status === 403 && (r === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!r || r === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(O))
|
|
6763
|
+
throw new q("Conversation unavailable", "conversation_access_denied");
|
|
6764
|
+
if (r === "conversations" && e.endsWith("/snapshot") && E.status === 409 && O === "Display projection is not enabled")
|
|
6765
|
+
throw new q("Conversation history is unavailable. Try loading this chat again after the service is ready.", "display_projection_disabled");
|
|
6766
|
+
if (r === "conversations" && e === "/commands" && E.status === 409 && (O === "embedded_submission_conflict" || O === "embedded_submission_snapshot_unavailable"))
|
|
6767
|
+
throw new q(O === "embedded_submission_conflict" ? "This message conflicts with an earlier submission. Review the conversation before retrying." : "This earlier submission cannot be verified. Review the conversation before retrying.", O, !1, void 0, !0);
|
|
6768
|
+
if (r === "conversations" && e === "/commands" && (E.status === 409 && O?.code === "executor_not_ready" && O.retryable === !0 || E.status === 403 && O === "Register the executor before commands"))
|
|
6769
|
+
throw new q("Reconnecting the browser before continuing.", "executor_not_ready");
|
|
6770
|
+
if (E.status !== 401 && O && typeof O == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(O.code) || !xt(void 0, O.code).allowed) && typeof O.message == "string")
|
|
6771
|
+
throw new q(O.message, O.code, !1, {
|
|
6751
6772
|
...typeof O.blockedOrigin == "string" ? { blockedOrigin: O.blockedOrigin } : {},
|
|
6752
6773
|
...typeof O.securitySettingsUrl == "string" ? { securitySettingsUrl: O.securitySettingsUrl } : {}
|
|
6753
6774
|
}, r === "conversations" && e === "/commands");
|
|
6754
|
-
const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, x =
|
|
6755
|
-
throw new E
|
|
6775
|
+
const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, x = E.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(S) ? { requestId: g, authTransport: "http", authEndpoint: `${r ?? (d ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: S, retryable: S === "token_expired" && (O === "Token expired" || O.retryable === !0) } : void 0;
|
|
6776
|
+
throw new q(E.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : E.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${E.status})`, C, !1, x);
|
|
6756
6777
|
}
|
|
6757
|
-
return await
|
|
6758
|
-
} catch (
|
|
6759
|
-
const
|
|
6778
|
+
return await E.json();
|
|
6779
|
+
} catch (E) {
|
|
6780
|
+
const C = p.trigger ?? ((E instanceof Error || E instanceof DOMException) && E.name === "AbortError" ? "unexpected_abort" : null), O = {
|
|
6760
6781
|
requestId: g,
|
|
6761
6782
|
method: i ?? (n === void 0 ? "GET" : "POST"),
|
|
6762
6783
|
route: b ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
|
|
6763
|
-
status:
|
|
6764
|
-
abortTrigger:
|
|
6765
|
-
category:
|
|
6784
|
+
status: A,
|
|
6785
|
+
abortTrigger: C,
|
|
6786
|
+
category: C === "deadline" ? "request_timed_out" : C === "unexpected_abort" ? "connection_interrupted" : C ? "request_cancelled" : E instanceof q ? E.code : w ? "connection_interrupted" : "invalid_response",
|
|
6766
6787
|
responseHeadersMs: I === null ? null : Math.max(0, I - v),
|
|
6767
6788
|
responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
|
|
6768
|
-
owner:
|
|
6789
|
+
owner: C === "deadline" ? "http_deadline" : C === "transport_disposed" ? "http_transport" : C && C !== "unexpected_abort" ? "conversation_query" : A === null ? "browser" : "http_response",
|
|
6769
6790
|
elapsedMs: Math.max(0, Date.now() - v),
|
|
6770
6791
|
attempt: c,
|
|
6771
6792
|
queryRequestId: j(o?.queryRequestId),
|
|
@@ -6773,41 +6794,41 @@ class dr {
|
|
|
6773
6794
|
authorityGeneration: o?.authorityGeneration ?? null,
|
|
6774
6795
|
sessionId: j(o?.sessionId),
|
|
6775
6796
|
release: this.auth.extension_version ? `extension-${this.auth.extension_version}` : `sdk-${Lt.version}`,
|
|
6776
|
-
upstreamRequestId:
|
|
6777
|
-
upstreamTraceId:
|
|
6797
|
+
upstreamRequestId: _,
|
|
6798
|
+
upstreamTraceId: T
|
|
6778
6799
|
};
|
|
6779
6800
|
he(O) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(O) : console.warn("Product Agent HTTP request failed", O)).catch(() => {
|
|
6780
6801
|
});
|
|
6781
6802
|
const S = he(O) ? { httpRequest: O } : void 0;
|
|
6782
|
-
if (
|
|
6783
|
-
const x =
|
|
6784
|
-
throw new
|
|
6785
|
-
x ? "The request was cancelled." :
|
|
6786
|
-
x ? "request_cancelled" :
|
|
6803
|
+
if (C !== null) {
|
|
6804
|
+
const x = C !== "deadline" && C !== "unexpected_abort";
|
|
6805
|
+
throw new q(
|
|
6806
|
+
x ? "The request was cancelled." : C === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
|
|
6807
|
+
x ? "request_cancelled" : C === "deadline" ? "request_timed_out" : "connection_interrupted",
|
|
6787
6808
|
!0,
|
|
6788
6809
|
S
|
|
6789
6810
|
);
|
|
6790
6811
|
}
|
|
6791
|
-
throw
|
|
6812
|
+
throw E instanceof q && S ? new q(E.message, E.code, E.outcomeUnknown, { ...E.detail, ...S }, E.backendRefusal) : S ? new q(
|
|
6792
6813
|
w ? "The connection was interrupted. Please try again." : b ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
|
|
6793
6814
|
"connection_interrupted",
|
|
6794
6815
|
!0,
|
|
6795
6816
|
S
|
|
6796
|
-
) :
|
|
6817
|
+
) : E;
|
|
6797
6818
|
} finally {
|
|
6798
6819
|
clearTimeout(R), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", y);
|
|
6799
6820
|
}
|
|
6800
6821
|
}
|
|
6801
6822
|
}
|
|
6802
|
-
function
|
|
6823
|
+
function st(t) {
|
|
6803
6824
|
if (t !== null && typeof t == "object" && !Object.isFrozen(t)) {
|
|
6804
|
-
for (const e of Object.values(t))
|
|
6825
|
+
for (const e of Object.values(t)) st(e);
|
|
6805
6826
|
Object.freeze(t);
|
|
6806
6827
|
}
|
|
6807
6828
|
return t;
|
|
6808
6829
|
}
|
|
6809
6830
|
function lr() {
|
|
6810
|
-
return
|
|
6831
|
+
return st({
|
|
6811
6832
|
authorityId: null,
|
|
6812
6833
|
generation: 0,
|
|
6813
6834
|
entities: {},
|
|
@@ -6832,13 +6853,13 @@ function B(t) {
|
|
|
6832
6853
|
return JSON.stringify([t.kind, t.origin, t.limit]);
|
|
6833
6854
|
}
|
|
6834
6855
|
function Va(t) {
|
|
6835
|
-
const e = t.map((s) =>
|
|
6856
|
+
const e = t.map((s) => Ze(s) || s.requestId !== null && s.status !== "error" ? { ...s, status: s.status === "error" ? s.data?.length ? "refreshing" : "loading" : s.status, error: null } : s);
|
|
6836
6857
|
return e.find((s) => s.status === "loading_more" || s.status === "loading" || s.status === "refreshing") ?? e.find((s) => s.status === "error") ?? e.find((s) => s.query.kind === "recent") ?? e[0];
|
|
6837
6858
|
}
|
|
6838
6859
|
function Ka(t) {
|
|
6839
6860
|
return [...new Set(t.flatMap((e) => e.data ?? []))];
|
|
6840
6861
|
}
|
|
6841
|
-
function
|
|
6862
|
+
function Ze(t) {
|
|
6842
6863
|
const e = t.error;
|
|
6843
6864
|
return t.status === "error" && t.consecutiveFailures < 10 && e !== null && !["unauthorized", "401", "403", "authority_retired"].includes(e.code) && (e.retryable || /^5\d\d$/.test(e.code) || ["runtime_error", "connection_interrupted", "request_timed_out", "408", "429"].includes(e.code));
|
|
6844
6865
|
}
|
|
@@ -6966,7 +6987,7 @@ class Ga {
|
|
|
6966
6987
|
if (s) for (const i of Object.values(n)) {
|
|
6967
6988
|
const r = B(i.query);
|
|
6968
6989
|
if (i.status !== "error" || i.requestId !== null || this.queryRequests.has(r) || !this.isObserved(i.query)) continue;
|
|
6969
|
-
if (!
|
|
6990
|
+
if (!Ze(i)) {
|
|
6970
6991
|
const c = this.queryRetries.get(r);
|
|
6971
6992
|
c?.timer !== null && c?.timer !== void 0 && clearTimeout(c.timer), this.queryRetries.delete(r);
|
|
6972
6993
|
continue;
|
|
@@ -7030,16 +7051,16 @@ class Ga {
|
|
|
7030
7051
|
}
|
|
7031
7052
|
refreshObservedQuery(e) {
|
|
7032
7053
|
const s = this.options.runtime.engine.getState().slices.directory.queries[B(Ae(e))];
|
|
7033
|
-
return s?.status === "error" && !
|
|
7054
|
+
return s?.status === "error" && !Ze(s) ? Promise.resolve() : e.kind !== "pinned" && s?.status === "error" && s.mode === "append" ? this.enqueueQuery(e, async () => {
|
|
7034
7055
|
const n = this.options.runtime.engine.getState().slices.directory.queries[B(Ae(e))];
|
|
7035
|
-
!this.isObserved(e) || n?.status !== "error" || n.mode !== "append" || !
|
|
7056
|
+
!this.isObserved(e) || n?.status !== "error" || n.mode !== "append" || !Ze(n) || await this.readPage(e, "append", n.cursor);
|
|
7036
7057
|
}) : this.refreshPages(e, e.kind === "pinned", () => this.isObserved(e));
|
|
7037
7058
|
}
|
|
7038
7059
|
refreshPages(e, s, n, i = !1) {
|
|
7039
7060
|
return e = Ae(e), this.enqueueQuery(e, async () => {
|
|
7040
7061
|
if (!n()) return;
|
|
7041
7062
|
const r = this.options.runtime.engine.getState().slices.directory.queries[B(e)];
|
|
7042
|
-
if (!i && r?.status === "error" && !
|
|
7063
|
+
if (!i && r?.status === "error" && !Ze(r) || (await this.readPage(e, "replace", void 0, i), !s)) return;
|
|
7043
7064
|
let a = this.options.runtime.engine.getState().slices.directory.queries[B(e)]?.cursor ?? null;
|
|
7044
7065
|
for (; a !== null && n(); ) {
|
|
7045
7066
|
const o = a;
|
|
@@ -7273,7 +7294,7 @@ class L extends EventTarget {
|
|
|
7273
7294
|
stage: i,
|
|
7274
7295
|
httpStatus: /^[45][0-9]{2}$/.test(s.code) ? Number(s.code) : void 0,
|
|
7275
7296
|
failureKind: s.outcomeUnknown || n.retryable === !0 ? "temporary" : "permanent"
|
|
7276
|
-
}), this.fail(new
|
|
7297
|
+
}), this.fail(new q(s.message, s.code, s.outcomeUnknown, { ...n, stage: i }, s.backendRefusal));
|
|
7277
7298
|
}
|
|
7278
7299
|
}
|
|
7279
7300
|
}), queueMicrotask(() => {
|
|
@@ -7403,17 +7424,17 @@ class L extends EventTarget {
|
|
|
7403
7424
|
this.queueDiagnostic("auth_timeout", {
|
|
7404
7425
|
readinessPhase: "bootstrap",
|
|
7405
7426
|
failureKind: "temporary",
|
|
7406
|
-
httpStatus: a instanceof
|
|
7427
|
+
httpStatus: a instanceof q && /^[45][0-9]{2}$/.test(a.code) ? Number(a.code) : void 0
|
|
7407
7428
|
}), this.transport.recover();
|
|
7408
7429
|
return;
|
|
7409
7430
|
}
|
|
7410
7431
|
if (s.type === "auth.session") {
|
|
7411
|
-
const o = a instanceof
|
|
7432
|
+
const o = a instanceof q ? a : new q("Chat setup failed", "request_failed"), c = this.isInvalidResponse(o);
|
|
7412
7433
|
this.queueDiagnostic("auth_rejected", {
|
|
7413
7434
|
stage: "bootstrap",
|
|
7414
7435
|
failureKind: "permanent",
|
|
7415
7436
|
httpStatus: /^[45][0-9]{2}$/.test(o.code) ? Number(o.code) : void 0
|
|
7416
|
-
}), this.fail(new
|
|
7437
|
+
}), this.fail(new q(
|
|
7417
7438
|
o.message,
|
|
7418
7439
|
c ? "invalid_response" : o.code,
|
|
7419
7440
|
c ? !1 : o.outcomeUnknown,
|
|
@@ -7430,7 +7451,7 @@ class L extends EventTarget {
|
|
|
7430
7451
|
try {
|
|
7431
7452
|
return await this.transport.rpc(e.type, Object.fromEntries(Object.entries(e).filter(([s]) => s !== "type"))), !0;
|
|
7432
7453
|
} catch (s) {
|
|
7433
|
-
return s instanceof
|
|
7454
|
+
return s instanceof q && s.code === "backpressure" && !s.backendRefusal || this.fail(s, e), s instanceof q && s.backendRefusal;
|
|
7434
7455
|
}
|
|
7435
7456
|
}
|
|
7436
7457
|
receive(e) {
|
|
@@ -7449,13 +7470,13 @@ class L extends EventTarget {
|
|
|
7449
7470
|
}
|
|
7450
7471
|
buffer(e, s) {
|
|
7451
7472
|
if (e.length >= 128) {
|
|
7452
|
-
this.fail(new
|
|
7473
|
+
this.fail(new q("Product Agent delivery buffer is full", "backpressure")), this.close();
|
|
7453
7474
|
return;
|
|
7454
7475
|
}
|
|
7455
7476
|
e.push(s);
|
|
7456
7477
|
}
|
|
7457
7478
|
fail(e, s, n = !1) {
|
|
7458
|
-
const i = Y(e, "request_failed", "web_transport"), r = e instanceof
|
|
7479
|
+
const i = Y(e, "request_failed", "web_transport"), r = e instanceof q ? e : new q(
|
|
7459
7480
|
i.message,
|
|
7460
7481
|
i.code,
|
|
7461
7482
|
!1,
|
|
@@ -7480,11 +7501,11 @@ class L extends EventTarget {
|
|
|
7480
7501
|
return this.httpTransport.request(e, s, n, i);
|
|
7481
7502
|
}
|
|
7482
7503
|
isInvalidResponse(e) {
|
|
7483
|
-
const s = e instanceof
|
|
7504
|
+
const s = e instanceof q ? e.detail : void 0;
|
|
7484
7505
|
return !!(s && typeof s == "object" && "httpRequest" in s && he(s.httpRequest) && s.httpRequest.category === "invalid_response");
|
|
7485
7506
|
}
|
|
7486
7507
|
isRetryableRead(e) {
|
|
7487
|
-
return this.isInvalidResponse(e) ? !1 : e instanceof TypeError || e instanceof DOMException && e.name === "AbortError" || e instanceof
|
|
7508
|
+
return this.isInvalidResponse(e) ? !1 : e instanceof TypeError || e instanceof DOMException && e.name === "AbortError" || e instanceof q && ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.code);
|
|
7488
7509
|
}
|
|
7489
7510
|
async dispatch(e, s) {
|
|
7490
7511
|
const { type: n, ...i } = e, r = this.options.auth.client_kind === "embed", a = e.pageUrl ?? e.page?.url ?? this.options.pageUrl(), o = { page_url: a, origin: new URL(a).origin };
|
|
@@ -7874,7 +7895,7 @@ function Te(t, e, s) {
|
|
|
7874
7895
|
const a = { ...t.requests };
|
|
7875
7896
|
if (delete a[e.effectId], n = { ...t, requests: a }, r.kind === "directory.query") {
|
|
7876
7897
|
const o = B(r.input.query), c = t.queries[o];
|
|
7877
|
-
if (c.requestId !== r.input.requestId) return { state:
|
|
7898
|
+
if (c.requestId !== r.input.requestId) return { state: st(n), effects: i };
|
|
7878
7899
|
if (e.type === "effect.failed")
|
|
7879
7900
|
n = { ...n, queries: { ...n.queries, [o]: { ...c, status: "error", error: { ...e.error }, requestId: null, consecutiveFailures: c.consecutiveFailures + 1 } } };
|
|
7880
7901
|
else if (e.effectKind === "directory.query") {
|
|
@@ -7994,7 +8015,7 @@ function Te(t, e, s) {
|
|
|
7994
8015
|
} else
|
|
7995
8016
|
n = ac(t, e, s);
|
|
7996
8017
|
}
|
|
7997
|
-
return { state:
|
|
8018
|
+
return { state: st(n), effects: i };
|
|
7998
8019
|
}
|
|
7999
8020
|
function dc(t) {
|
|
8000
8021
|
const e = { ...t.entities };
|
|
@@ -8009,7 +8030,7 @@ function dc(t) {
|
|
|
8009
8030
|
activityRevision: i,
|
|
8010
8031
|
...r
|
|
8011
8032
|
} = t;
|
|
8012
|
-
return
|
|
8033
|
+
return st({
|
|
8013
8034
|
...r,
|
|
8014
8035
|
entities: e,
|
|
8015
8036
|
activityBySessionId: { ...s, ...t.activityBySessionId },
|
|
@@ -8818,8 +8839,8 @@ class nu {
|
|
|
8818
8839
|
activityReconciliationScheduled = !1;
|
|
8819
8840
|
getState() {
|
|
8820
8841
|
const e = this.recentQuery.getState(), s = this.pinnedQuery.getState(), n = [
|
|
8821
|
-
...
|
|
8822
|
-
...
|
|
8842
|
+
...ft(s.data),
|
|
8843
|
+
...ft(e.data)
|
|
8823
8844
|
], i = new Map(n.map((c) => [c.id, c])), r = Array.from(i.values()).map(
|
|
8824
8845
|
(c) => this.applyOverrides(c, this.completedRefreshSequence)
|
|
8825
8846
|
), a = Array.from(this.optimisticEntities.values()).filter((c) => !i.has(c.id)).reverse(), o = e.data || s.data || a.length > 0 ? St({
|
|
@@ -8894,8 +8915,8 @@ class nu {
|
|
|
8894
8915
|
}
|
|
8895
8916
|
reconcileDurableEntities() {
|
|
8896
8917
|
const e = [
|
|
8897
|
-
...
|
|
8898
|
-
...
|
|
8918
|
+
...ft(this.pinnedQuery.getState().data),
|
|
8919
|
+
...ft(this.recentQuery.getState().data)
|
|
8899
8920
|
], s = new Set(e.map((n) => n.id));
|
|
8900
8921
|
for (const n of this.optimisticEntities.keys())
|
|
8901
8922
|
s.has(n) && this.optimisticEntities.delete(n);
|
|
@@ -8934,7 +8955,7 @@ class nu {
|
|
|
8934
8955
|
for (const e of this.listeners) e(this.getState());
|
|
8935
8956
|
}
|
|
8936
8957
|
}
|
|
8937
|
-
function
|
|
8958
|
+
function ft(t) {
|
|
8938
8959
|
return t ? t.ids.map((e) => t.entitiesById[e]).filter((e) => !!e) : [];
|
|
8939
8960
|
}
|
|
8940
8961
|
function Hc(t, e) {
|
|
@@ -9230,7 +9251,7 @@ function cu(t) {
|
|
|
9230
9251
|
case "runtime.warmup":
|
|
9231
9252
|
return e.reason === "panel_open" || e.reason === "extension_install" || e.reason === "composer_input";
|
|
9232
9253
|
case "runtime.report_operation_timing":
|
|
9233
|
-
return
|
|
9254
|
+
return it(e.timing);
|
|
9234
9255
|
case "runtime.report_displayed_error":
|
|
9235
9256
|
return (e.errorDiagnostic === void 0 || Oo(e.errorDiagnostic)) && (e.httpRequest === void 0 || he(e.httpRequest)) && (e.historyRefreshFailure === void 0 || hn(e.historyRefreshFailure)) && (e.renderedError === void 0 || fn(e.renderedError)) && (e.reason === "conversation_error" || e.reason === "attachment_error" || e.reason === "history_error" || e.reason === "action_error") && typeof e.errorFingerprint == "string" && /^fnv1a-[0-9a-f]{8}$/.test(e.errorFingerprint) && (e.displayedMessage === void 0 || typeof e.displayedMessage == "string" && e.displayedMessage.length <= 500);
|
|
9236
9257
|
case "runtime.report_invalid_state_transition":
|
|
@@ -9361,7 +9382,7 @@ class du {
|
|
|
9361
9382
|
this.dispatch({ type: "runtime.widget_lifecycle", action: e, trigger: s });
|
|
9362
9383
|
}
|
|
9363
9384
|
reportOperationTiming(e) {
|
|
9364
|
-
!this.destroyed &&
|
|
9385
|
+
!this.destroyed && it(e) && this.adapter.dispatch({ type: "runtime.report_operation_timing", timing: e }).catch(() => {
|
|
9365
9386
|
});
|
|
9366
9387
|
}
|
|
9367
9388
|
reportResponseVisibility(e) {
|
|
@@ -9859,7 +9880,7 @@ const id = "https://app.pluno.ai", rd = 2e4, od = 1e4, ad = 6e4, cd = 6e4, dd =
|
|
|
9859
9880
|
".png:image/png",
|
|
9860
9881
|
".webp:image/webp"
|
|
9861
9882
|
]), lu = ".pdf,.png,.jpg,.jpeg,.webp", kn = 64e3, As = 4e3, Rn = 30, md = 2e3, yd = 1e3, _r = "Image is too large for model vision input.", vd = "pluno.productAgent.state.", cn = "pluno.productAgent.pendingEvents.", Vt = "pluno.productAgent.activeToolCalls.", bd = 100, Ot = /* @__PURE__ */ new Set();
|
|
9862
|
-
let
|
|
9883
|
+
let gt = null;
|
|
9863
9884
|
function Id(t, e = Math.random) {
|
|
9864
9885
|
const s = Math.min(an, ud * 2 ** t), n = 1 - bi + e() * bi * 2;
|
|
9865
9886
|
return Math.min(an, Math.round(s * n));
|
|
@@ -9879,7 +9900,7 @@ function Es(t) {
|
|
|
9879
9900
|
if (t instanceof ue)
|
|
9880
9901
|
return t.retryable;
|
|
9881
9902
|
if (t && typeof t == "object") {
|
|
9882
|
-
const e = t instanceof
|
|
9903
|
+
const e = t instanceof q ? t.code : "", s = /^[45][0-9]{2}$/.test(e) ? Number(e) : t.status;
|
|
9883
9904
|
if (typeof s == "number")
|
|
9884
9905
|
return s === 408 || s === 425 || s === 429 || s >= 500;
|
|
9885
9906
|
}
|
|
@@ -9911,7 +9932,7 @@ class Kt {
|
|
|
9911
9932
|
recoverAuthentication: (i, r, a) => this.recoverHttpAuthentication(i, r, a),
|
|
9912
9933
|
// Public custom transports own their admission contract and do not expose the default Socket.IO lease.
|
|
9913
9934
|
executorConnection: e.webSocketFactory ? void 0 : () => this.socket instanceof L ? this.socket.connectionId : null,
|
|
9914
|
-
restoreExecutor: e.webSocketFactory ? void 0 : (i) => this.socket instanceof L ? this.socket.restoreExecutor(i) : Promise.reject(new
|
|
9935
|
+
restoreExecutor: e.webSocketFactory ? void 0 : (i) => this.socket instanceof L ? this.socket.restoreExecutor(i) : Promise.reject(new q("Browser is reconnecting.", "executor_not_ready")),
|
|
9915
9936
|
auth: {
|
|
9916
9937
|
protocol: 1,
|
|
9917
9938
|
token: e.token ?? "",
|
|
@@ -10113,7 +10134,7 @@ class Kt {
|
|
|
10113
10134
|
operationTimingReporter = () => {
|
|
10114
10135
|
};
|
|
10115
10136
|
reportOperationTiming(e) {
|
|
10116
|
-
|
|
10137
|
+
it(e) && this.operationTimingReporter(e);
|
|
10117
10138
|
}
|
|
10118
10139
|
async initializeConversation() {
|
|
10119
10140
|
const e = ++this.conversationAdapterGeneration;
|
|
@@ -10147,7 +10168,7 @@ class Kt {
|
|
|
10147
10168
|
requestId: f.requestId,
|
|
10148
10169
|
clientMessageId: f.userMessageId,
|
|
10149
10170
|
sessionId: f.sessionId
|
|
10150
|
-
}), R = (v, I) => k.measure(v, () =>
|
|
10171
|
+
}), R = (v, I) => k.measure(v, () => vt(b, I));
|
|
10151
10172
|
let g = f.contextPreparation ?? { pageContent: "", sessionTabs: [] };
|
|
10152
10173
|
if (f.contextPreparation === null) {
|
|
10153
10174
|
await R("first_frame", () => new Promise((I) => {
|
|
@@ -10156,11 +10177,11 @@ class Kt {
|
|
|
10156
10177
|
return;
|
|
10157
10178
|
}
|
|
10158
10179
|
const w = () => {
|
|
10159
|
-
cancelAnimationFrame(
|
|
10160
|
-
},
|
|
10180
|
+
cancelAnimationFrame(_), document.removeEventListener("visibilitychange", A), setTimeout(I, 0);
|
|
10181
|
+
}, A = () => {
|
|
10161
10182
|
document.visibilityState !== "visible" && w();
|
|
10162
|
-
},
|
|
10163
|
-
document.addEventListener("visibilitychange",
|
|
10183
|
+
}, _ = requestAnimationFrame(w);
|
|
10184
|
+
document.addEventListener("visibilitychange", A);
|
|
10164
10185
|
}));
|
|
10165
10186
|
const v = f.context.page;
|
|
10166
10187
|
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 });
|
|
@@ -10168,9 +10189,9 @@ class Kt {
|
|
|
10168
10189
|
}
|
|
10169
10190
|
if (await R("authentication", () => this.waitForAuthentication()), !n() || s !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
|
|
10170
10191
|
for (const v of y)
|
|
10171
|
-
if (!v.uploaded && (await
|
|
10192
|
+
if (!v.uploaded && (await vt(b, () => (this.attachmentPersistence.get(v.sourceId) ?? Promise.resolve()).catch(() => {
|
|
10172
10193
|
throw Object.assign(new Error("Attachment files could not be stored. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
|
|
10173
|
-
})), !await
|
|
10194
|
+
})), !await vt(b, () => gi(v.sourceId))))
|
|
10174
10195
|
throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
|
|
10175
10196
|
return b.throwIfAborted(), k.mark("context_ready"), { ...g, now: Date.now() };
|
|
10176
10197
|
},
|
|
@@ -10204,11 +10225,11 @@ class Kt {
|
|
|
10204
10225
|
},
|
|
10205
10226
|
onCommand: (f) => Me("client_event", f.type, Ss({ ...f.payload, type: f.type })),
|
|
10206
10227
|
onError: (f, y) => {
|
|
10207
|
-
if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" && f instanceof
|
|
10228
|
+
if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" && f instanceof q && f.code === "conversation_access_denied") {
|
|
10208
10229
|
y.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
|
|
10209
10230
|
return;
|
|
10210
10231
|
}
|
|
10211
|
-
V("web-sdk.conversation", "Conversation operation failed", { ...y, ...xo(f) }), f instanceof
|
|
10232
|
+
V("web-sdk.conversation", "Conversation operation failed", { ...y, ...xo(f) }), f instanceof q && f.backendRefusal && y.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
|
|
10212
10233
|
}
|
|
10213
10234
|
})
|
|
10214
10235
|
});
|
|
@@ -10294,8 +10315,8 @@ class Kt {
|
|
|
10294
10315
|
if (!R.startsWith(`background:${this.modelClientScopeId}:`)) continue;
|
|
10295
10316
|
const v = Ie(f.conversation, f.directory, g), I = v.sessionId ? f.conversation.sessions[v.sessionId] : void 0;
|
|
10296
10317
|
if (this.firstResponseTimersByClientMessageId.size && (l(ds(v, I?.queries.current, this.options.backendUrl).messages, v.sessionId), ["failed", "stopped"].includes(v.activity.phase)))
|
|
10297
|
-
for (const
|
|
10298
|
-
const w = v.activity.phase === "completed" && le(I?.execution).some((
|
|
10318
|
+
for (const A of le(I?.execution)) this.clearFirstResponseTimer(A);
|
|
10319
|
+
const w = v.activity.phase === "completed" && le(I?.execution).some((A) => this.firstResponseTimersByClientMessageId.has(A));
|
|
10299
10320
|
(b && v.sessionId === this.getState().sessionId || !w && ["completed", "failed", "stopped"].includes(v.activity.phase)) && this.directoryScope.detach(R);
|
|
10300
10321
|
}
|
|
10301
10322
|
const k = this.getState();
|
|
@@ -10326,7 +10347,7 @@ class Kt {
|
|
|
10326
10347
|
}
|
|
10327
10348
|
}
|
|
10328
10349
|
handleDirectoryTransportError(e) {
|
|
10329
|
-
if (!(e instanceof
|
|
10350
|
+
if (!(e instanceof q) || this.authenticationFailure || !["unauthorized", "update_required", "service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(e.code) && xt(void 0, e.code).allowed) return;
|
|
10330
10351
|
const s = e.detail && typeof e.detail == "object" ? e.detail : {};
|
|
10331
10352
|
this.handleServerEvent({
|
|
10332
10353
|
...s,
|
|
@@ -10549,7 +10570,7 @@ class Kt {
|
|
|
10549
10570
|
} catch (r) {
|
|
10550
10571
|
if (n !== this.connectionAttemptId || this.state.status === "closed")
|
|
10551
10572
|
return;
|
|
10552
|
-
if (r instanceof
|
|
10573
|
+
if (r instanceof q && (r.code === "unauthorized" || r.code === "update_required")) {
|
|
10553
10574
|
this.handleDirectoryTransportError(r);
|
|
10554
10575
|
return;
|
|
10555
10576
|
}
|
|
@@ -10567,7 +10588,7 @@ class Kt {
|
|
|
10567
10588
|
);
|
|
10568
10589
|
return;
|
|
10569
10590
|
}
|
|
10570
|
-
throw this.options.productVariant === "customer_embedded" ? (this.reportTransportDiagnostic("auth_rejected", this.connectionFailureDiagnostic(r, "token_provider")), this.stopAuthentication(new
|
|
10591
|
+
throw this.options.productVariant === "customer_embedded" ? (this.reportTransportDiagnostic("auth_rejected", this.connectionFailureDiagnostic(r, "token_provider")), this.stopAuthentication(new q(a.message, "connection_failed", !1), !0), this.emit("error", a), a) : (this.setState({
|
|
10571
10592
|
status: "error",
|
|
10572
10593
|
lastError: a.message,
|
|
10573
10594
|
lastErrorCode: "connection_failed"
|
|
@@ -11062,15 +11083,7 @@ class Kt {
|
|
|
11062
11083
|
bridgeStatus: null,
|
|
11063
11084
|
sdkPreviewOpen: null
|
|
11064
11085
|
} } } : {}
|
|
11065
|
-
}, c)
|
|
11066
|
-
type: "stage7.permission",
|
|
11067
|
-
authority: r,
|
|
11068
|
-
feature: a.kind === "task_notifications" ? "notifications" : "tab_grouping",
|
|
11069
|
-
action: "allow",
|
|
11070
|
-
settings: !0,
|
|
11071
|
-
requestId: c,
|
|
11072
|
-
now: Date.now()
|
|
11073
|
-
});
|
|
11086
|
+
}, c);
|
|
11074
11087
|
}
|
|
11075
11088
|
rebuildRuntimeInteractions() {
|
|
11076
11089
|
for (const e of this.interactionListeners) e(this.getInteractions());
|
|
@@ -11127,7 +11140,7 @@ class Kt {
|
|
|
11127
11140
|
authority: u,
|
|
11128
11141
|
now: Date.now(),
|
|
11129
11142
|
feature: m,
|
|
11130
|
-
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 }
|
|
11143
|
+
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 }
|
|
11131
11144
|
}), m === "tab_grouping" && f.sessionId === h && h) for (const y of f.crossTabUserMessageIds ?? [])
|
|
11132
11145
|
await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority: u, now: Date.now(), sessionId: h, userMessageId: y });
|
|
11133
11146
|
return f;
|
|
@@ -11188,7 +11201,8 @@ class Kt {
|
|
|
11188
11201
|
return { fact: {
|
|
11189
11202
|
permission: b.permissionGranted === !0 ? "granted" : b.permissionNeeded ? "missing" : "unknown",
|
|
11190
11203
|
revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[l].revision + 1),
|
|
11191
|
-
snoozedUntil: b.snoozedUntil ?? null
|
|
11204
|
+
snoozedUntil: b.snoozedUntil ?? null,
|
|
11205
|
+
pending: b.permissionPending === !0
|
|
11192
11206
|
}, completedAt: Date.now() };
|
|
11193
11207
|
},
|
|
11194
11208
|
"stage7.platform": async (l) => {
|
|
@@ -11537,7 +11551,7 @@ class Kt {
|
|
|
11537
11551
|
applyAuthenticatedDirectoryIdentity(e) {
|
|
11538
11552
|
const s = Ai(e);
|
|
11539
11553
|
if (!s) return !1;
|
|
11540
|
-
const n =
|
|
11554
|
+
const n = yt(e, "runtimeCommunityId") ?? this.directoryHttp.auth.community_id, i = `${this.options.clientId}:${s.id}:${n ?? this.options.productVariant}`, r = this.directoryAuthority.authorityId !== i, a = this.authenticatedUserId === null, o = a ? Object.values(this.clientRuntime.engine.getState().slices.conversation.operations).filter((l) => ["waiting", "running", "uncertain"].includes(l.phase) && (l.command.type === "run.stop" || l.command.type === "session.reset")).map((l) => l.command) : [], c = a && this.directoryAuthority.authorityId === `${this.options.clientId}:${this.options.runtimeCommunityId ?? this.options.productVariant}` ? this.state.sessionId : null;
|
|
11541
11555
|
if (this.authenticatedUserId = s.id, this.directoryHttp.auth.community_id = n, jo(this.options.clientId, i), r) {
|
|
11542
11556
|
const l = this.directoryAuthority;
|
|
11543
11557
|
this.directoryObservation.dispose(), this.conversationAdapterGeneration++, this.conversationObservation?.dispose(), this.directoryAuthority = { authorityId: i, generation: l.generation + 1 }, this.clientRuntime.engine.dispatch({ ...this.directoryAuthority, type: "directory.authority_replace", expectedGeneration: l.generation }), this.createDirectoryAdapters();
|
|
@@ -11648,7 +11662,7 @@ class Kt {
|
|
|
11648
11662
|
return;
|
|
11649
11663
|
}
|
|
11650
11664
|
if (e.type === "session.updated" || e.type === "conversation.state") {
|
|
11651
|
-
|
|
11665
|
+
yt(e.session, "id") === this.state.sessionId && (this.updatePersonalModelFromSession(e.session), this.updateAccountFallbackFromSession(e.session), Is(this.clientRuntime, this.modelClientScopeId, this.state.sessionId, e.turns));
|
|
11652
11666
|
return;
|
|
11653
11667
|
}
|
|
11654
11668
|
if (e.type === "tool.call")
|
|
@@ -11668,7 +11682,7 @@ class Kt {
|
|
|
11668
11682
|
return;
|
|
11669
11683
|
}
|
|
11670
11684
|
if (e.code === "invalid_response" && e.stage === "bootstrap") {
|
|
11671
|
-
this.stopAuthentication(new
|
|
11685
|
+
this.stopAuthentication(new q(String(e.message), "connection_failed", !1, { stage: "bootstrap" }));
|
|
11672
11686
|
return;
|
|
11673
11687
|
}
|
|
11674
11688
|
if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "401") && e.reason === "invalid_token" && (this.canRefreshInvalidCredential() || this.credentialRecovery !== null)) {
|
|
@@ -11677,7 +11691,7 @@ class Kt {
|
|
|
11677
11691
|
this.credentialRecovery || this.refreshCredentials(
|
|
11678
11692
|
s,
|
|
11679
11693
|
!0,
|
|
11680
|
-
new
|
|
11694
|
+
new q("", "unauthorized", !1, {
|
|
11681
11695
|
reason: e.reason,
|
|
11682
11696
|
authTransport: e.authTransport,
|
|
11683
11697
|
requestId: e.requestId,
|
|
@@ -11694,7 +11708,7 @@ class Kt {
|
|
|
11694
11708
|
return;
|
|
11695
11709
|
}
|
|
11696
11710
|
if (this.options.productVariant === "customer_embedded" && /^4[0-9]{2}$/.test(String(e.code)) && !["401", "408", "425", "429"].includes(String(e.code)) && e.retryable !== !0 && (e.stage === "executor_registration" || e.stage === "socket_admission" || e.stage === "bootstrap")) {
|
|
11697
|
-
this.stopAuthentication(new
|
|
11711
|
+
this.stopAuthentication(new q(
|
|
11698
11712
|
e.code === "403" ? "Chat access is not configured for this page. Contact your app administrator, then try again." : "Chat setup could not be completed. Contact your app administrator, then try again.",
|
|
11699
11713
|
"connection_failed",
|
|
11700
11714
|
!1,
|
|
@@ -11703,7 +11717,7 @@ class Kt {
|
|
|
11703
11717
|
return;
|
|
11704
11718
|
}
|
|
11705
11719
|
if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "update_required" || e.code === "executor_replaced")) {
|
|
11706
|
-
this.stopAuthentication(new
|
|
11720
|
+
this.stopAuthentication(new q(String(e.message), String(e.code), !1, { reason: e.reason, authTransport: "socket" }));
|
|
11707
11721
|
return;
|
|
11708
11722
|
}
|
|
11709
11723
|
["unauthorized", "update_required", "executor_replaced", "connection_failed"].includes(String(e.code)) && this.setState({ status: "error", lastError: String(e.message), lastErrorCode: String(e.code) });
|
|
@@ -11715,7 +11729,7 @@ class Kt {
|
|
|
11715
11729
|
}
|
|
11716
11730
|
updatePersonalModelFromSession(e) {
|
|
11717
11731
|
if (!e || typeof e != "object") return;
|
|
11718
|
-
const s =
|
|
11732
|
+
const s = yt(e, "id");
|
|
11719
11733
|
if (!s) return;
|
|
11720
11734
|
const n = e.metadata, i = n && typeof n == "object" ? n.model : void 0;
|
|
11721
11735
|
this.clientRuntime.engine.accept({
|
|
@@ -11727,7 +11741,7 @@ class Kt {
|
|
|
11727
11741
|
}
|
|
11728
11742
|
updateAccountFallbackFromSession(e) {
|
|
11729
11743
|
if (!e || typeof e != "object") return;
|
|
11730
|
-
const s =
|
|
11744
|
+
const s = yt(e, "id"), n = this.clientRuntime.engine.getState().slices.account.authority;
|
|
11731
11745
|
s && n && this.clientRuntime.engine.dispatch({
|
|
11732
11746
|
type: "stage7.account_fallback",
|
|
11733
11747
|
authority: n,
|
|
@@ -11737,7 +11751,7 @@ class Kt {
|
|
|
11737
11751
|
});
|
|
11738
11752
|
}
|
|
11739
11753
|
async executeToolCall(e) {
|
|
11740
|
-
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, i = typeof e.toolName == "string" ? e.toolName : null, r =
|
|
11754
|
+
const s = typeof e.sessionId == "string" ? e.sessionId : null, n = typeof e.callId == "string" ? e.callId : null, i = typeof e.toolName == "string" ? e.toolName : null, r = et(
|
|
11741
11755
|
typeof e.summary == "string" ? e.summary : "Running browser tool"
|
|
11742
11756
|
), a = e.rawInput;
|
|
11743
11757
|
if (!s || !n || !i)
|
|
@@ -11864,7 +11878,7 @@ class Kt {
|
|
|
11864
11878
|
stage: this.lastRecoveryStage,
|
|
11865
11879
|
recoveryOutcome: "exhausted",
|
|
11866
11880
|
failureKind: "temporary"
|
|
11867
|
-
}), this.stopAuthentication(new
|
|
11881
|
+
}), this.stopAuthentication(new q(
|
|
11868
11882
|
"Chat could not reconnect. Your conversation and draft are saved here. Try again.",
|
|
11869
11883
|
"connection_failed",
|
|
11870
11884
|
!1
|
|
@@ -11875,7 +11889,7 @@ class Kt {
|
|
|
11875
11889
|
this.embeddedRecoveryTimer !== null && window.clearTimeout(this.embeddedRecoveryTimer), this.embeddedRecoveryTimer = null;
|
|
11876
11890
|
}
|
|
11877
11891
|
connectionFailureDiagnostic(e, s) {
|
|
11878
|
-
const n = e instanceof ue ? e.status : e instanceof
|
|
11892
|
+
const n = e instanceof ue ? e.status : e instanceof q && e.code === "unauthorized" ? 401 : e instanceof q && /^[45][0-9]{2}$/.test(e.code) ? Number(e.code) : void 0, i = n !== void 0 && Number.isInteger(n) && n >= 400 && n <= 599 ? n : void 0, a = !(e instanceof q && ["unauthorized", "403", "update_required", "executor_replaced"].includes(e.code)) && Es(e) && i !== 401 && i !== 403;
|
|
11879
11893
|
return {
|
|
11880
11894
|
stage: s,
|
|
11881
11895
|
...i !== void 0 ? { httpStatus: i } : {},
|
|
@@ -11944,7 +11958,7 @@ class Kt {
|
|
|
11944
11958
|
...this.authenticationDiagnostic(e),
|
|
11945
11959
|
failureKind: "permanent",
|
|
11946
11960
|
recoveryOutcome: "refused"
|
|
11947
|
-
}), e.code === "unauthorized" && (e = new
|
|
11961
|
+
}), e.code === "unauthorized" && (e = new q("Your chat session could not be refreshed. Reload the page to reconnect.", e.code, !1, e.detail)), this.authenticationFailure = e;
|
|
11948
11962
|
const n = this.clientRuntime.engine.getState().slices.account.authority;
|
|
11949
11963
|
n && e.code !== "403" && this.clientRuntime.engine.dispatch({ type: "stage7.retire", authority: n, now: Date.now() }), this.credentialRecovery = null, this.clearEmbeddedRecoveryBudget(), this.rejectedTransportToken = ["unauthorized", "update_required"].includes(e.code) ? this.token : null, this.refreshingDefaultCredentials = !1, this.reconnectTimer !== null && window.clearTimeout(this.reconnectTimer), this.reconnectTimer = null, this.clearSocketPhaseTimers(), this.stopHeartbeat();
|
|
11950
11964
|
const i = this.socket;
|
|
@@ -11970,7 +11984,7 @@ class Kt {
|
|
|
11970
11984
|
refreshCredentials(e, s = !1, n) {
|
|
11971
11985
|
if (this.credentialRecovery) return this.credentialRecovery;
|
|
11972
11986
|
this.credentialRecoveryFailure = null;
|
|
11973
|
-
const i = this.token, r = this.authenticationDiagnostic(n ?? new
|
|
11987
|
+
const i = this.token, r = this.authenticationDiagnostic(n ?? new q(
|
|
11974
11988
|
"",
|
|
11975
11989
|
"unauthorized",
|
|
11976
11990
|
!1,
|
|
@@ -11982,14 +11996,14 @@ class Kt {
|
|
|
11982
11996
|
const o = (async () => {
|
|
11983
11997
|
const c = await this.acquireToken("connect", { forceRefresh: !0 });
|
|
11984
11998
|
if (this.socket !== e || this.state.status === "closed" || this.clientRuntime.isDisposed)
|
|
11985
|
-
throw new
|
|
11999
|
+
throw new q("Conversation authority was retired.", "authority_retired", !0);
|
|
11986
12000
|
if (!c) throw new ue("Pluno token provider did not return a token", !1);
|
|
11987
|
-
if (s && c === i) throw new
|
|
12001
|
+
if (s && c === i) throw new q("Credential did not change.", "unauthorized", !1);
|
|
11988
12002
|
this.directoryHttp.auth.token = c, a = "bootstrap", this.lastRecoveryStage = a, await this.replaceDefaultTransportCredentials(e), this.reportTransportDiagnostic("auth_refresh_validated", r);
|
|
11989
12003
|
})().catch((c) => {
|
|
11990
12004
|
if (this.socket !== e || this.state.status === "closed") throw c;
|
|
11991
|
-
if (this.reportTransportDiagnostic("auth_refresh_failed", { ...r, ...this.connectionFailureDiagnostic(c, a) }), this.credentialRecoveryFailure = Qe(c), c instanceof
|
|
11992
|
-
const d = c instanceof
|
|
12005
|
+
if (this.reportTransportDiagnostic("auth_refresh_failed", { ...r, ...this.connectionFailureDiagnostic(c, a) }), this.credentialRecoveryFailure = Qe(c), c instanceof q && ["unauthorized", "403", "update_required"].includes(c.code) || !Es(c)) {
|
|
12006
|
+
const d = c instanceof q ? c : new q(c instanceof ue ? c.message : "Your session could not be refreshed. Try again.", this.options.productVariant === "customer_embedded" ? "connection_failed" : "unauthorized", !1);
|
|
11993
12007
|
throw this.stopAuthentication(d), d;
|
|
11994
12008
|
}
|
|
11995
12009
|
throw this.options.productVariant === "customer_embedded" && this.setState({ status: "reconnecting", lastError: Ii, lastErrorCode: "connection_failed" }), this.scheduleReconnect(), c;
|
|
@@ -12460,8 +12474,8 @@ function Fd() {
|
|
|
12460
12474
|
};
|
|
12461
12475
|
}
|
|
12462
12476
|
function $d(t) {
|
|
12463
|
-
return Ot.add(t),
|
|
12464
|
-
Ot.delete(t), Ot.size === 0 && (
|
|
12477
|
+
return Ot.add(t), gt || (gt = zd()), () => {
|
|
12478
|
+
Ot.delete(t), Ot.size === 0 && (gt?.(), gt = null);
|
|
12465
12479
|
};
|
|
12466
12480
|
}
|
|
12467
12481
|
function zd() {
|
|
@@ -12491,9 +12505,9 @@ function An() {
|
|
|
12491
12505
|
(f) => Sr(f) && !f.parentElement?.closest(n)
|
|
12492
12506
|
);
|
|
12493
12507
|
for (const f of i.slice(0, 3))
|
|
12494
|
-
s("Active overlay", Cs(
|
|
12495
|
-
const r = Hd(), a = r ? Cs(
|
|
12496
|
-
s("Main page content", a), s("Additional visible page text", Cs(
|
|
12508
|
+
s("Active overlay", Cs(tt(f), e));
|
|
12509
|
+
const r = Hd(), a = r ? Cs(tt(r), e) : "";
|
|
12510
|
+
s("Main page content", a), s("Additional visible page text", Cs(tt(document.body), e));
|
|
12497
12511
|
const o = t.map(([f, y]) => `${f}:
|
|
12498
12512
|
${y}`).join(`
|
|
12499
12513
|
|
|
@@ -12504,7 +12518,7 @@ Visible page text:
|
|
|
12504
12518
|
`, u = 12e3 - d.length - l.length, h = Math.min(o.length, 7900), p = c.slice(0, u - h), m = o.slice(0, u - p.length);
|
|
12505
12519
|
return `${d}${p}${l}${m}`;
|
|
12506
12520
|
}
|
|
12507
|
-
function
|
|
12521
|
+
function tt(t) {
|
|
12508
12522
|
return t.innerText ?? t.textContent ?? "";
|
|
12509
12523
|
}
|
|
12510
12524
|
function Le(t) {
|
|
@@ -12526,7 +12540,7 @@ function Sr(t) {
|
|
|
12526
12540
|
return e.display !== "none" && e.visibility !== "hidden" && t.getClientRects().length > 0;
|
|
12527
12541
|
}
|
|
12528
12542
|
function Hd() {
|
|
12529
|
-
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Sr).sort((t, e) =>
|
|
12543
|
+
return Array.from(document.querySelectorAll("main, [role='main'], article")).filter(Sr).sort((t, e) => tt(e).length - tt(t).length)[0] ?? null;
|
|
12530
12544
|
}
|
|
12531
12545
|
function Vd(t, e) {
|
|
12532
12546
|
const s = /* @__PURE__ */ new Set([
|
|
@@ -12618,12 +12632,12 @@ function Vd(t, e) {
|
|
|
12618
12632
|
const g = R.getAttribute("data-testid") || R.getAttribute("data-test") || R.getAttribute("data-qa") || R.getAttribute("data-cy") || "";
|
|
12619
12633
|
return `${R.tagName.toLowerCase()}|${m(R)}|${g}`;
|
|
12620
12634
|
}, y = (R, g, v) => {
|
|
12621
|
-
const I = (w,
|
|
12622
|
-
const
|
|
12623
|
-
if (p >= 1e3 && !
|
|
12635
|
+
const I = (w, A) => {
|
|
12636
|
+
const _ = w.tagName.toLowerCase(), T = window.getComputedStyle(w), E = l.has(w);
|
|
12637
|
+
if (p >= 1e3 && !E || v.has(w) || r.has(_) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || T.display === "none" || T.visibility === "hidden")
|
|
12624
12638
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
12625
12639
|
p += 1;
|
|
12626
|
-
const
|
|
12640
|
+
const C = m(w), O = Rr(w), S = o.has(C) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(_) || _ === "a" && w.hasAttribute("href"), x = Array.from(w.children).filter((D) => D instanceof HTMLElement), U = /* @__PURE__ */ new Map();
|
|
12627
12641
|
for (const D of x) {
|
|
12628
12642
|
const $ = f(D);
|
|
12629
12643
|
U.set($, (U.get($) ?? 0) + 1);
|
|
@@ -12633,45 +12647,45 @@ function Vd(t, e) {
|
|
|
12633
12647
|
const $ = f(D), ve = $e.get($) ?? 0;
|
|
12634
12648
|
$e.set($, ve + 1), (U.get($) ?? 0) > 8 && ve >= 6 && !l.has(D) && H.set($, (H.get($) ?? 0) + 1);
|
|
12635
12649
|
}
|
|
12636
|
-
const
|
|
12650
|
+
const ot = /* @__PURE__ */ new Map(), Cn = /* @__PURE__ */ new Set(), Gt = [], On = [];
|
|
12637
12651
|
for (const D of x) {
|
|
12638
|
-
const $ = f(D), ve = U.get($) ?? 0, Pn =
|
|
12639
|
-
if (
|
|
12652
|
+
const $ = f(D), ve = U.get($) ?? 0, Pn = ot.get($) ?? 0;
|
|
12653
|
+
if (ot.set($, Pn + 1), ve > 8 && Pn >= 6 && !l.has(D)) {
|
|
12640
12654
|
Cn.has($) || (Gt.push([`… ${H.get($) ?? 0} similar siblings omitted`]), Cn.add($));
|
|
12641
12655
|
continue;
|
|
12642
12656
|
}
|
|
12643
|
-
const Dn = I(D,
|
|
12657
|
+
const Dn = I(D, A);
|
|
12644
12658
|
On.push(Dn), Gt.push(Dn.lines);
|
|
12645
12659
|
}
|
|
12646
12660
|
const Jt = [];
|
|
12647
12661
|
if (w.shadowRoot)
|
|
12648
12662
|
for (const D of Array.from(w.shadowRoot.children))
|
|
12649
|
-
D instanceof HTMLElement && Jt.push(I(D,
|
|
12650
|
-
const
|
|
12651
|
-
[O, ...
|
|
12652
|
-
).slice(0, 180), Fr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Mn = d.some((D) => w.hasAttribute(D)) || !!
|
|
12663
|
+
D instanceof HTMLElement && Jt.push(I(D, A + 1));
|
|
12664
|
+
const at = [...On, ...Jt], Qt = O.length > 0 || S || at.some((D) => D.hasUsefulContent), xn = Le(
|
|
12665
|
+
[O, ...at.map((D) => D.textPreview)].filter(Boolean).join(" ")
|
|
12666
|
+
).slice(0, 180), Fr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Mn = d.some((D) => w.hasAttribute(D)) || !!C || Fr, Xt = (w.getClientRects().length > 0 || T.display === "contents") && (s.has(_) || Mn || E) && (Qt || E) && (!i.has(_) || Qt || Mn || E), Yt = Xt ? 1 : 0, ze = [];
|
|
12653
12667
|
if (Xt) {
|
|
12654
|
-
const D =
|
|
12668
|
+
const D = at.some((ve) => ve.containsTextElement), $ = n.has(_) && !D ? xn : O;
|
|
12655
12669
|
ze.push(kr(w, c, a, $.slice(0, 180)));
|
|
12656
12670
|
}
|
|
12657
12671
|
for (const D of Gt)
|
|
12658
|
-
ze.push(...
|
|
12672
|
+
ze.push(...mt(D, Yt));
|
|
12659
12673
|
const Zt = Jt.flatMap((D) => D.lines);
|
|
12660
12674
|
if (Zt.length > 0) {
|
|
12661
12675
|
const D = Zt.slice(0, 20);
|
|
12662
12676
|
Zt.length > D.length && D.push("… shadow DOM omitted");
|
|
12663
|
-
const $ =
|
|
12664
|
-
if (
|
|
12665
|
-
const ve = Xt ? "#shadow-root" : `${
|
|
12666
|
-
ze.push(...
|
|
12677
|
+
const $ = _.includes("tooltip") || _.includes("popper") || _.includes("loader");
|
|
12678
|
+
if (A < 2 && !$) {
|
|
12679
|
+
const ve = Xt ? "#shadow-root" : `${_} #shadow-root`;
|
|
12680
|
+
ze.push(...mt([ve, ...mt(D, 1)], Yt));
|
|
12667
12681
|
} else
|
|
12668
|
-
ze.push(...
|
|
12682
|
+
ze.push(...mt(D, Yt));
|
|
12669
12683
|
}
|
|
12670
12684
|
return {
|
|
12671
12685
|
lines: ze,
|
|
12672
12686
|
hasUsefulContent: Qt,
|
|
12673
12687
|
textPreview: xn,
|
|
12674
|
-
containsTextElement: n.has(
|
|
12688
|
+
containsTextElement: n.has(_) || at.some((D) => D.containsTextElement)
|
|
12675
12689
|
};
|
|
12676
12690
|
};
|
|
12677
12691
|
return [`--- ${g} ---`, ...I(R, 0).lines].join(`
|
|
@@ -12774,7 +12788,7 @@ function Wd(t, e, s, n) {
|
|
|
12774
12788
|
function ki(t) {
|
|
12775
12789
|
return t instanceof HTMLElement ? t : t?.parentElement instanceof HTMLElement ? t.parentElement : null;
|
|
12776
12790
|
}
|
|
12777
|
-
function
|
|
12791
|
+
function mt(t, e) {
|
|
12778
12792
|
if (e === 0)
|
|
12779
12793
|
return t;
|
|
12780
12794
|
const s = " ".repeat(e);
|
|
@@ -13106,18 +13120,18 @@ function al(t) {
|
|
|
13106
13120
|
}
|
|
13107
13121
|
function cl(t) {
|
|
13108
13122
|
if (typeof t.summary == "string" && t.summary.trim().length > 0)
|
|
13109
|
-
return
|
|
13123
|
+
return et(t.summary);
|
|
13110
13124
|
if (typeof t.arguments == "string")
|
|
13111
13125
|
try {
|
|
13112
13126
|
const e = JSON.parse(t.arguments);
|
|
13113
13127
|
if (typeof e.summary == "string" && e.summary.trim().length > 0)
|
|
13114
|
-
return
|
|
13128
|
+
return et(e.summary);
|
|
13115
13129
|
} catch {
|
|
13116
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
13130
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? et(t.name) : "🛠️ Run tool";
|
|
13117
13131
|
}
|
|
13118
|
-
return typeof t.name == "string" && t.name.trim().length > 0 ?
|
|
13132
|
+
return typeof t.name == "string" && t.name.trim().length > 0 ? et(t.name) : "🛠️ Run tool";
|
|
13119
13133
|
}
|
|
13120
|
-
function
|
|
13134
|
+
function et(t) {
|
|
13121
13135
|
const e = t.trim() || "Run tool", s = e.codePointAt(0) ?? 0;
|
|
13122
13136
|
return s >= 126976 && s <= 129791 || s >= 9728 && s <= 10175 || s >= 127462 && s <= 127487 ? e : `🛠️ ${e}`;
|
|
13123
13137
|
}
|
|
@@ -13159,7 +13173,7 @@ function ul(t, e) {
|
|
|
13159
13173
|
}
|
|
13160
13174
|
function hl(t, e, s) {
|
|
13161
13175
|
const n = t[e], i = t[s];
|
|
13162
|
-
if (
|
|
13176
|
+
if (rt(n, i))
|
|
13163
13177
|
return !0;
|
|
13164
13178
|
if (!n.respondsToUserMessageId || i.respondsToUserMessageId || !n.runId || n.runId !== i.runId)
|
|
13165
13179
|
return !1;
|
|
@@ -13172,7 +13186,7 @@ function pl(t, e) {
|
|
|
13172
13186
|
const s = t[e];
|
|
13173
13187
|
for (let n = e + 1; n < t.length; n += 1) {
|
|
13174
13188
|
const i = t[n];
|
|
13175
|
-
if (i.role === "assistant" &&
|
|
13189
|
+
if (i.role === "assistant" && rt(s, i))
|
|
13176
13190
|
return !0;
|
|
13177
13191
|
}
|
|
13178
13192
|
return !1;
|
|
@@ -13193,26 +13207,26 @@ function fl(t, e) {
|
|
|
13193
13207
|
function gl(t, e) {
|
|
13194
13208
|
const s = t[e];
|
|
13195
13209
|
return t.some(
|
|
13196
|
-
(n, i) => i !== e && n.role === "assistant" &&
|
|
13210
|
+
(n, i) => i !== e && n.role === "assistant" && rt(s, n)
|
|
13197
13211
|
);
|
|
13198
13212
|
}
|
|
13199
13213
|
function ml(t, e) {
|
|
13200
13214
|
const s = t[e];
|
|
13201
13215
|
return t.some(
|
|
13202
|
-
(n, i) => i !== e && n.role === "tool" &&
|
|
13216
|
+
(n, i) => i !== e && n.role === "tool" && rt(s, n)
|
|
13203
13217
|
);
|
|
13204
13218
|
}
|
|
13205
13219
|
function yl(t, e) {
|
|
13206
13220
|
const s = t[e];
|
|
13207
13221
|
for (let n = e + 1; n < t.length; n += 1)
|
|
13208
|
-
if (En(t[n]) &&
|
|
13222
|
+
if (En(t[n]) && rt(s, t[n]))
|
|
13209
13223
|
return !0;
|
|
13210
13224
|
return !1;
|
|
13211
13225
|
}
|
|
13212
|
-
function
|
|
13226
|
+
function rt(t, e) {
|
|
13213
13227
|
return !!(t.respondsToUserMessageId && t.respondsToUserMessageId === e.respondsToUserMessageId);
|
|
13214
13228
|
}
|
|
13215
|
-
function
|
|
13229
|
+
function yt(t, e) {
|
|
13216
13230
|
return t && typeof t == "object" && typeof t[e] == "string" ? t[e] : null;
|
|
13217
13231
|
}
|
|
13218
13232
|
function vl(t, e) {
|