@pluno/product-agent-web 0.1.279 → 0.1.281
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product-agent-runtime.cjs +1 -1
- package/dist/product-agent-runtime.js +1 -1
- package/dist/product-agent-sdk.js +260 -257
- package/dist/product-agent-widget.js +699 -696
- package/package.json +1 -1
|
@@ -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" }))
|
|
@@ -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) || Ye(n, g) !== !0 || n.features.desiredPreferences[g] === !1 || Object.values(n.interactions.devicePending).some((
|
|
909
|
-
const
|
|
910
|
-
delete
|
|
908
|
+
if (!X(o.profile, w) || Ye(n, g) !== !0 || n.features.desiredPreferences[g] === !1 || 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 });
|
|
@@ -937,18 +937,18 @@ function Ls(t, e, s) {
|
|
|
937
937
|
v.revision <= I.revision || (Ye(n, g) === !0 && (v.permission === "granted" && I.permission !== "granted" || v.snoozedUntil && v.snoozedUntil !== I.snoozedUntil) && u(g, null), a({ deviceFacts: { ...n.interactions.deviceFacts, [g]: v } }));
|
|
938
938
|
}, m = (g, v, I = !1) => {
|
|
939
939
|
Ce(o, g);
|
|
940
|
-
const w = ie(o, g),
|
|
940
|
+
const w = ie(o, g), A = Se(o, "query", v);
|
|
941
941
|
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]:
|
|
942
|
+
const C = n.features.queries[w], O = n.features.contextReads[w];
|
|
943
|
+
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;
|
|
944
|
+
}
|
|
945
|
+
const _ = n.features.pending[A];
|
|
946
|
+
if (_ && _.fingerprint !== JSON.stringify(g)) throw new Error("Query request ID changed payload.");
|
|
947
|
+
if (_?.status === "pending" || Object.values(n.features.pending).some((C) => C.mode === "query" && C.key === w && C.status === "pending")) return;
|
|
948
|
+
const T = n.features.queries[w] ?? ye(w), E = Ue(T, { key: w, requestId: oe(v), mode: "replace" });
|
|
949
|
+
r({ queries: { ...n.features.queries, [w]: E }, pending: { ...n.features.pending, [A]: {
|
|
950
950
|
requestId: v,
|
|
951
|
-
effectId:
|
|
951
|
+
effectId: A,
|
|
952
952
|
fingerprint: JSON.stringify(g),
|
|
953
953
|
key: w,
|
|
954
954
|
generation: o.generation,
|
|
@@ -957,27 +957,27 @@ function Ls(t, e, s) {
|
|
|
957
957
|
status: "pending",
|
|
958
958
|
error: null,
|
|
959
959
|
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:
|
|
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: A, input: { authority: o, requestId: v, query: g } });
|
|
961
961
|
}, f = (g, v, I = !1) => {
|
|
962
962
|
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 ||
|
|
963
|
+
const w = Se(o, "mutate", v), A = JSON.stringify(g), _ = n.features.pending[w];
|
|
964
|
+
if (_) {
|
|
965
|
+
if (_.fingerprint !== A) throw new Error("Request ID was reused with a different payload.");
|
|
966
|
+
if (!I || _.status !== "error") return;
|
|
967
967
|
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(
|
|
968
|
+
if (["conflict", "409"].includes(_.error?.code ?? "")) throw new Error("Refresh the conflicting decision before making another choice.");
|
|
969
|
+
}
|
|
970
|
+
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))) {
|
|
971
|
+
const T = n.features.queuedPreferences[g.feature];
|
|
972
|
+
if (T && T.requestId !== v) {
|
|
973
|
+
const E = Se(o, "mutate", T.requestId), C = { kind: "preference", feature: g.feature, enabled: T.enabled };
|
|
974
|
+
r({ pending: { ...n.features.pending, [E]: {
|
|
975
|
+
requestId: T.requestId,
|
|
976
|
+
effectId: E,
|
|
977
|
+
fingerprint: JSON.stringify(C),
|
|
978
|
+
key: Fn(C),
|
|
979
979
|
generation: o.generation,
|
|
980
|
-
operation:
|
|
980
|
+
operation: C,
|
|
981
981
|
mode: "mutation",
|
|
982
982
|
status: "error",
|
|
983
983
|
result: null,
|
|
@@ -988,10 +988,10 @@ function Ls(t, e, s) {
|
|
|
988
988
|
return;
|
|
989
989
|
}
|
|
990
990
|
if (g.kind === "generatePrompts") {
|
|
991
|
-
const
|
|
992
|
-
r({ queries: { ...n.features.queries, [
|
|
991
|
+
const T = { kind: "starterPrompts", ...g.page, includeUserSuggestions: g.includeUserSuggestions ?? !1 }, E = ie(o, T), C = n.features.queries[E] ?? ye(E);
|
|
992
|
+
r({ queries: { ...n.features.queries, [E]: Ue(C, { key: E, requestId: oe(v), mode: "replace" }) } });
|
|
993
993
|
}
|
|
994
|
-
r({ pending: { ...n.features.pending, [w]: { requestId: v, effectId: w, fingerprint:
|
|
994
|
+
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
995
|
}, y = (g) => {
|
|
996
996
|
if (!(!X(o.profile, "canManagePreferences") || n.features.refreshBatch)) {
|
|
997
997
|
for (const v of Object.values(n.features.pending))
|
|
@@ -1003,13 +1003,13 @@ function Ls(t, e, s) {
|
|
|
1003
1003
|
}, b = (g, v) => {
|
|
1004
1004
|
const I = n.features.refreshBatch;
|
|
1005
1005
|
if (I?.pending.includes(g)) {
|
|
1006
|
-
const w = I.pending.filter((
|
|
1007
|
-
if (w.length) r({ refreshBatch: { pending: w, failed:
|
|
1006
|
+
const w = I.pending.filter((_) => _ !== g), A = I.failed || v;
|
|
1007
|
+
if (w.length) r({ refreshBatch: { pending: w, failed: A } });
|
|
1008
1008
|
else {
|
|
1009
|
-
const
|
|
1010
|
-
r({ refreshBatch: null, failures:
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1009
|
+
const _ = A ? n.features.failures + 1 : 0;
|
|
1010
|
+
r({ refreshBatch: null, failures: _, refreshAt: n.features.now + Math.min(6e4 * 2 ** _, 9e5) });
|
|
1011
|
+
const T = n.features.refreshQueuedRequestId;
|
|
1012
|
+
T && (r({ refreshQueuedRequestId: null }), y(T));
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
1015
|
};
|
|
@@ -1018,19 +1018,19 @@ function Ls(t, e, s) {
|
|
|
1018
1018
|
const g = xt(void 0, e.code);
|
|
1019
1019
|
if (g.allowed) return { state: n, effects: i };
|
|
1020
1020
|
const v = { ...n.features.queries }, I = { ...n.features.pending }, w = [];
|
|
1021
|
-
for (const [
|
|
1022
|
-
if (
|
|
1023
|
-
const
|
|
1024
|
-
I[
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1021
|
+
for (const [A, _] of Object.entries(I)) {
|
|
1022
|
+
if (_.operation.kind !== "account" || _.status === "done" || _.status === "error") continue;
|
|
1023
|
+
const T = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
|
|
1024
|
+
I[A] = { ..._, status: "error", error: T }, w.push(A);
|
|
1025
|
+
const E = v[_.key];
|
|
1026
|
+
E && (v[_.key] = dt(E, { key: _.key, requestId: oe(_.requestId), error: T }));
|
|
1027
1027
|
}
|
|
1028
1028
|
n = { ...n, features: { ...n.features, pending: I, queries: v }, account: {
|
|
1029
1029
|
...n.account,
|
|
1030
1030
|
refusal: g,
|
|
1031
1031
|
query: { ...n.account.query, requestId: null, status: n.account.query.data ? "ready" : "not_requested" }
|
|
1032
1032
|
} };
|
|
1033
|
-
for (const
|
|
1033
|
+
for (const A of w) b(A, !0);
|
|
1034
1034
|
break;
|
|
1035
1035
|
}
|
|
1036
1036
|
case "stage7.context_observe":
|
|
@@ -1180,9 +1180,9 @@ function Ls(t, e, s) {
|
|
|
1180
1180
|
r({ now: e.output.now }), n = es(n, s.conversation, s.directory, e.output.now);
|
|
1181
1181
|
for (const [I, w] of Object.entries(n.features.polls)) {
|
|
1182
1182
|
if (w.deadline > e.output.now) continue;
|
|
1183
|
-
Object.values(n.features.pending).some((
|
|
1184
|
-
const
|
|
1185
|
-
delete
|
|
1183
|
+
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);
|
|
1184
|
+
const A = { ...n.features.polls };
|
|
1185
|
+
delete A[I], r({ polls: A });
|
|
1186
1186
|
}
|
|
1187
1187
|
n.features.refreshAt !== null && e.output.now >= n.features.refreshAt && y(`timer:${e.output.now}`);
|
|
1188
1188
|
}
|
|
@@ -1194,12 +1194,12 @@ function Ls(t, e, s) {
|
|
|
1194
1194
|
const w = { ...n.interactions.devicePending };
|
|
1195
1195
|
if (delete w[e.effectId], a({ devicePending: w }), e.type === "effect.completed") {
|
|
1196
1196
|
if (I.action !== "check" && n.interactions.promptActions[I.requestId] && !n.features.pending[Se(o, "mutate", `${I.requestId}:ack`)]) {
|
|
1197
|
-
const
|
|
1198
|
-
u(
|
|
1197
|
+
const A = n.interactions.promptActions[I.requestId];
|
|
1198
|
+
u(A.feature, I.requestId), f({
|
|
1199
1199
|
kind: "preferenceAcknowledge",
|
|
1200
|
-
feature:
|
|
1201
|
-
action:
|
|
1202
|
-
expectedRevision:
|
|
1200
|
+
feature: A.feature,
|
|
1201
|
+
action: A.action,
|
|
1202
|
+
expectedRevision: A.expectedRevision
|
|
1203
1203
|
}, `${I.requestId}:ack`);
|
|
1204
1204
|
}
|
|
1205
1205
|
p(I.feature, e.output.fact);
|
|
@@ -1215,8 +1215,8 @@ function Ls(t, e, s) {
|
|
|
1215
1215
|
const w = n.features.queries[g.key];
|
|
1216
1216
|
if (!w || w.requestId !== g.requestId) break;
|
|
1217
1217
|
if (["originContext", "userContext", "contextRun"].includes(g.operation.kind)) {
|
|
1218
|
-
const
|
|
1219
|
-
delete
|
|
1218
|
+
const A = { ...n.features.polls };
|
|
1219
|
+
delete A[g.key], r({ polls: A, contextReads: { ...n.features.contextReads, [g.key]: {
|
|
1220
1220
|
settledAt: v ? n.features.now : e.output.completedAt,
|
|
1221
1221
|
failures: v ? (n.features.contextReads[g.key]?.failures ?? 0) + 1 : 0
|
|
1222
1222
|
} } });
|
|
@@ -1235,8 +1235,8 @@ function Ls(t, e, s) {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
if (g.mode === "mutation" && g.operation.kind === "decision") {
|
|
1237
1237
|
const I = { ...n.interactions.actions };
|
|
1238
|
-
for (const [w,
|
|
1239
|
-
|
|
1238
|
+
for (const [w, A] of Object.entries(I))
|
|
1239
|
+
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
1240
|
a({ actions: I });
|
|
1241
1241
|
}
|
|
1242
1242
|
if (!v && g.mode === "mutation" && g.operation.kind === "preference" && n.interactions.promptActions[g.requestId]) {
|
|
@@ -1249,8 +1249,8 @@ function Ls(t, e, s) {
|
|
|
1249
1249
|
}, `${g.requestId}:ack`);
|
|
1250
1250
|
}
|
|
1251
1251
|
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
|
-
|
|
1252
|
+
const I = { kind: "starterPrompts", ...g.operation.page, includeUserSuggestions: g.operation.includeUserSuggestions ?? !1 }, w = ie(o, I), A = n.features.queries[w];
|
|
1253
|
+
A?.requestId === g.requestId && r({ queries: { ...n.features.queries, [w]: v ? dt(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
1254
|
}
|
|
1255
1255
|
if (!v && e.output.data.kind === "originContext") {
|
|
1256
1256
|
const I = e.output.data, w = g.operation.kind === "originContext" || g.operation.kind === "refreshContext" ? g.operation.origin : null;
|
|
@@ -1258,32 +1258,32 @@ function Ls(t, e, s) {
|
|
|
1258
1258
|
if (I.value.runId && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status))
|
|
1259
1259
|
r({ contextRunOrigins: { ...n.features.contextRunOrigins, [I.value.runId]: w } });
|
|
1260
1260
|
else {
|
|
1261
|
-
const
|
|
1262
|
-
for (const [
|
|
1263
|
-
r({ contextRunOrigins:
|
|
1261
|
+
const A = { ...n.features.contextRunOrigins };
|
|
1262
|
+
for (const [_, T] of Object.entries(A)) T === w && delete A[_];
|
|
1263
|
+
r({ contextRunOrigins: A });
|
|
1264
1264
|
}
|
|
1265
1265
|
if (g.mode === "mutation") {
|
|
1266
|
-
const
|
|
1267
|
-
for (const [
|
|
1266
|
+
const A = { ...n.features.queries }, _ = { ...n.features.pending }, T = { ...n.features.contextReads }, E = { ...n.features.polls };
|
|
1267
|
+
for (const [C, O] of Object.entries(n.features.originContextQueries))
|
|
1268
1268
|
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) && (
|
|
1269
|
+
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];
|
|
1270
|
+
for (const [S, x] of Object.entries(_)) x.mode === "query" && x.key === C && delete _[S];
|
|
1271
|
+
["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
1272
|
}
|
|
1273
|
-
r({ queries:
|
|
1273
|
+
r({ queries: A, pending: _, contextReads: T, polls: E });
|
|
1274
1274
|
}
|
|
1275
1275
|
}
|
|
1276
1276
|
}
|
|
1277
1277
|
if (!v && e.output.data.kind === "contextRun" && !["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(e.output.data.value.status)) {
|
|
1278
1278
|
const I = e.output.data.value.runId, w = I ? n.features.contextRunOrigins[I] : null;
|
|
1279
1279
|
if (w && I) {
|
|
1280
|
-
const
|
|
1281
|
-
delete
|
|
1282
|
-
for (const [
|
|
1283
|
-
if (
|
|
1284
|
-
const
|
|
1285
|
-
for (const [
|
|
1286
|
-
r({ pending:
|
|
1280
|
+
const A = { ...n.features.contextRunOrigins };
|
|
1281
|
+
delete A[I], r({ contextRunOrigins: A });
|
|
1282
|
+
for (const [_, T] of Object.entries(n.features.originContextQueries)) {
|
|
1283
|
+
if (T.origin !== w) continue;
|
|
1284
|
+
const E = { ...n.features.pending };
|
|
1285
|
+
for (const [C, O] of Object.entries(E)) O.mode === "query" && O.key === _ && delete E[C];
|
|
1286
|
+
r({ pending: E }), m({ ...T, kind: "originContext" }, `context-final:${g.requestId}:${_}`, !0);
|
|
1287
1287
|
}
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
@@ -1292,18 +1292,18 @@ function Ls(t, e, s) {
|
|
|
1292
1292
|
if (I.kind === "originContext" || I.kind === "userContext" || I.kind === "contextRun") {
|
|
1293
1293
|
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
1294
|
if (w && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status)) {
|
|
1295
|
-
const
|
|
1296
|
-
r({ polls: { ...n.features.polls, [
|
|
1295
|
+
const A = ie(o, w);
|
|
1296
|
+
r({ polls: { ...n.features.polls, [A]: { query: w, deadline: n.features.now + 5e3 } } });
|
|
1297
1297
|
}
|
|
1298
1298
|
}
|
|
1299
1299
|
}
|
|
1300
1300
|
if (!v && g.operation.kind === "stopContext")
|
|
1301
1301
|
for (const [I, w] of Object.entries(n.features.originContextQueries)) {
|
|
1302
|
-
const
|
|
1303
|
-
if (
|
|
1304
|
-
const
|
|
1305
|
-
for (const [
|
|
1306
|
-
r({ pending:
|
|
1302
|
+
const A = n.features.queries[I]?.data;
|
|
1303
|
+
if (A?.kind === "originContext" && A.value.runId === g.operation.runId) {
|
|
1304
|
+
const _ = { ...n.features.pending };
|
|
1305
|
+
for (const [T, E] of Object.entries(_)) E.mode === "query" && E.key === I && delete _[T];
|
|
1306
|
+
r({ pending: _ }), m({ ...w, kind: "originContext" }, `context-stop:${g.requestId}:${I}`, !0);
|
|
1307
1307
|
}
|
|
1308
1308
|
}
|
|
1309
1309
|
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 +1313,17 @@ function Ls(t, e, s) {
|
|
|
1313
1313
|
if (g.mode === "query" && g.operation.kind === "userSuggestedTasks") {
|
|
1314
1314
|
const I = v ? n.features.suggestionReadFailures + 1 : 0, w = { ...n.features.polls };
|
|
1315
1315
|
delete w[g.key];
|
|
1316
|
-
const
|
|
1317
|
-
|
|
1316
|
+
const A = v && (e.error.retryable || ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.error.code));
|
|
1317
|
+
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
1318
|
}
|
|
1319
1319
|
if (g.operation.kind === "preference") {
|
|
1320
1320
|
const I = g.operation.feature, w = n.features.queuedPreferences[I];
|
|
1321
1321
|
if (w) {
|
|
1322
|
-
const
|
|
1323
|
-
delete
|
|
1322
|
+
const A = { ...n.features.queuedPreferences };
|
|
1323
|
+
delete A[I], r({ queuedPreferences: A }), f({ kind: "preference", feature: I, enabled: w.enabled }, w.requestId);
|
|
1324
1324
|
} else {
|
|
1325
|
-
const
|
|
1326
|
-
delete
|
|
1325
|
+
const A = { ...n.features.desiredPreferences };
|
|
1326
|
+
delete A[I], r({ desiredPreferences: A });
|
|
1327
1327
|
}
|
|
1328
1328
|
}
|
|
1329
1329
|
if (!v && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) l(I, "check", `preference:${g.requestId}:${I}`);
|
|
@@ -1962,7 +1962,7 @@ function fo(t, e = null) {
|
|
|
1962
1962
|
} : void 0);
|
|
1963
1963
|
return { ...n, ...o ? { auth: o } : {}, submissionGate: a, usingPaidCreditFallback: e ? t.paidFallbackBySession[e] ?? !1 : !1 };
|
|
1964
1964
|
}
|
|
1965
|
-
const go = "0.1.
|
|
1965
|
+
const go = "0.1.281", Lt = {
|
|
1966
1966
|
version: go
|
|
1967
1967
|
}, ln = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, mo = (t, e) => t.scopes[e];
|
|
1968
1968
|
function Ft(t) {
|
|
@@ -2191,8 +2191,8 @@ function vo(t, e, s, n) {
|
|
|
2191
2191
|
if (s.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
|
|
2192
2192
|
const { type: o, authorityId: c, generation: d, prepareContext: l, reconcileAcceptance: u, waitForAuthentication: h, ...p } = e, m = t.submissions[e.userMessageId];
|
|
2193
2193
|
if (m) {
|
|
2194
|
-
const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled:
|
|
2195
|
-
if (ht(
|
|
2194
|
+
const { contextPreparation: g, requestedModel: v, sessionId: I, delivery: w, cancelled: A, cancellationReason: _, error: T, executionVersion: E, ...C } = m;
|
|
2195
|
+
if (ht(C) !== ht(p)) throw new Error("User-message identity cannot be reused with different input.");
|
|
2196
2196
|
return { state: t, effects: r };
|
|
2197
2197
|
}
|
|
2198
2198
|
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 +2607,18 @@ function Io(t, e, s, n) {
|
|
|
2607
2607
|
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
2608
|
}])),
|
|
2609
2609
|
deliveries: Object.fromEntries(Object.entries(m.submissions).map(([g, v], I) => {
|
|
2610
|
-
const w = m.deliveries[g],
|
|
2610
|
+
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
2611
|
return [g, {
|
|
2612
2612
|
...zn(v, I),
|
|
2613
2613
|
...w,
|
|
2614
|
-
acceptance:
|
|
2614
|
+
acceptance: _,
|
|
2615
2615
|
allocation: v.sessionId !== null ? "resolved" : w?.allocation ?? (w?.step === "upload" ? "uncertain" : "unissued"),
|
|
2616
2616
|
effectId: null,
|
|
2617
2617
|
// Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
|
|
2618
|
-
step:
|
|
2619
|
-
prepared:
|
|
2618
|
+
step: _ === "uncertain" && (w?.step === "send" || w?.handoffRecovery) && w.phase !== "done" ? "receipt" : w?.step ?? null,
|
|
2619
|
+
prepared: _ === "accepted",
|
|
2620
2620
|
queuePosition: w?.queuePosition ?? I,
|
|
2621
|
-
phase:
|
|
2621
|
+
phase: _ === "accepted" ? "done" : A || !w ? "failed" : ["running", "waiting"].includes(w.phase) ? "uncertain" : w.phase
|
|
2622
2622
|
}];
|
|
2623
2623
|
})),
|
|
2624
2624
|
operations: Object.fromEntries(Object.entries(m.operations).map(([g, v]) => [g, {
|
|
@@ -3723,7 +3723,7 @@ function $o(t, e, s, n) {
|
|
|
3723
3723
|
function ds(t, e, s, n) {
|
|
3724
3724
|
const i = /* @__PURE__ */ new Map();
|
|
3725
3725
|
for (const _ of t.segments)
|
|
3726
|
-
for (const
|
|
3726
|
+
for (const T of [..._.activityIds, ..._.outcomeIds]) i.set(T, _.userMessageId);
|
|
3727
3727
|
const r = t.items.map((_) => $o(
|
|
3728
3728
|
_,
|
|
3729
3729
|
i.get(_.id) ?? null,
|
|
@@ -3737,18 +3737,18 @@ function ds(t, e, s, n) {
|
|
|
3737
3737
|
// There is no canonical timestamp before acceptance. Keep identity stable without fabricating one.
|
|
3738
3738
|
createdAt: "",
|
|
3739
3739
|
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:
|
|
3740
|
+
attachments: _.attachments.map((T) => ({
|
|
3741
|
+
id: T.sourceId,
|
|
3742
|
+
name: T.name,
|
|
3743
|
+
mimeType: T.mimeType,
|
|
3744
|
+
sizeBytes: T.sizeBytes
|
|
3745
3745
|
}))
|
|
3746
3746
|
});
|
|
3747
|
-
const a =
|
|
3747
|
+
const a = r, o = { ...t.removedItems };
|
|
3748
3748
|
for (const _ of t.segments) {
|
|
3749
3749
|
if (!_.userMessageId) continue;
|
|
3750
|
-
const
|
|
3751
|
-
|
|
3750
|
+
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"));
|
|
3751
|
+
T && (o[`local-interrupted:${_.userMessageId}`] = T.id);
|
|
3752
3752
|
}
|
|
3753
3753
|
t.proactiveQuestion && a.push({
|
|
3754
3754
|
id: t.proactiveQuestion.id,
|
|
@@ -3759,22 +3759,23 @@ function ds(t, e, s, n) {
|
|
|
3759
3759
|
loading: !1
|
|
3760
3760
|
});
|
|
3761
3761
|
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:${
|
|
3762
|
+
const T = _.role === "user" ? m.get(_.id) : void 0;
|
|
3763
|
+
return T?.error ? [_, {
|
|
3764
|
+
id: `submission-error:${T.userMessageId}`,
|
|
3765
3765
|
role: "system",
|
|
3766
3766
|
dataType: "run_error",
|
|
3767
|
-
respondsToUserMessageId:
|
|
3768
|
-
content:
|
|
3767
|
+
respondsToUserMessageId: T.userMessageId,
|
|
3768
|
+
content: T.error.message,
|
|
3769
3769
|
createdAt: "",
|
|
3770
3770
|
loading: !1,
|
|
3771
|
-
...typeof
|
|
3771
|
+
...typeof T.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: T.error.details.securitySettingsUrl } : {}
|
|
3772
3772
|
}] : [_];
|
|
3773
3773
|
}), 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
3774
|
code: "submission_checkpoint_pending",
|
|
3775
3775
|
message: Vr,
|
|
3776
3776
|
details: { requestId: k.requestId }
|
|
3777
|
-
} : null, g = l?.delivery === "failed" && !l.cancelled && !p ? l.error : b ?? R
|
|
3777
|
+
} : null, g = l?.delivery === "failed" && !l.cancelled && !p ? l.error : b ?? R;
|
|
3778
|
+
let I = {
|
|
3778
3779
|
isRetrying: t.isRetrying ?? !1,
|
|
3779
3780
|
historyRefreshFailure: g === e?.error ? t.historyRefreshFailure ?? null : null,
|
|
3780
3781
|
conversationDiagnostics: {
|
|
@@ -3815,20 +3816,22 @@ function ds(t, e, s, n) {
|
|
|
3815
3816
|
lastErrorCode: g?.code ?? null,
|
|
3816
3817
|
lastErrorSecuritySettingsUrl: typeof g?.details?.securitySettingsUrl == "string" ? g.details.securitySettingsUrl : null
|
|
3817
3818
|
};
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3819
|
+
for (const _ of t.optimistic.filter((T) => T.cancelled && !t.stop?.userMessageIds.includes(T.userMessageId))) {
|
|
3820
|
+
const T = Js(I, "", "stopped", [_.userMessageId], Jn(_.cancellationReason));
|
|
3821
|
+
I = { ...I, messages: T.messages, segments: T.segments };
|
|
3822
|
+
}
|
|
3823
|
+
if (t.stop) {
|
|
3824
|
+
const _ = Js(
|
|
3825
|
+
I,
|
|
3826
|
+
"",
|
|
3827
|
+
t.stop.pending ? "stopping" : "stopped",
|
|
3828
|
+
t.stop.userMessageIds,
|
|
3829
|
+
Jn(t.stop.reason ?? "user_requested")
|
|
3830
|
+
);
|
|
3831
|
+
I = { ...I, messages: _.messages, segments: _.segments };
|
|
3832
|
+
}
|
|
3833
|
+
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;
|
|
3834
|
+
return { ...I, messages: [...I.messages].sort((_, T) => A(_) - A(T)) };
|
|
3832
3835
|
}
|
|
3833
3836
|
function Jn(t) {
|
|
3834
3837
|
switch (t) {
|
|
@@ -6309,7 +6312,7 @@ const Fa = 9e4, $a = /* @__PURE__ */ new Set([
|
|
|
6309
6312
|
"tool.started",
|
|
6310
6313
|
"tool.result"
|
|
6311
6314
|
]);
|
|
6312
|
-
class
|
|
6315
|
+
class q extends Error {
|
|
6313
6316
|
constructor(e, s, n = !1, i, r = !1) {
|
|
6314
6317
|
super(e), this.code = s, this.outcomeUnknown = n, this.detail = i, this.backendRefusal = r, this.code = s === "401" ? "unauthorized" : s;
|
|
6315
6318
|
}
|
|
@@ -6320,7 +6323,7 @@ class E extends Error {
|
|
|
6320
6323
|
}
|
|
6321
6324
|
function ni(t, e) {
|
|
6322
6325
|
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
|
|
6326
|
+
return new q(n, t.code ?? "request_rejected", !1, t.result, !0);
|
|
6324
6327
|
}
|
|
6325
6328
|
class za {
|
|
6326
6329
|
constructor(e) {
|
|
@@ -6349,7 +6352,7 @@ class za {
|
|
|
6349
6352
|
}) : this.invalidate(!1, s), this.restoreBackoff();
|
|
6350
6353
|
}), this.socket.io.on("reconnect", () => this.restoreBackoff()), this.socket.on("connection.ready", (s) => {
|
|
6351
6354
|
if (s.protocol !== 1 || s.role !== this.options.auth.role || s.display_projection_ready !== !1) {
|
|
6352
|
-
this.options.onError(new
|
|
6355
|
+
this.options.onError(new q("Unsupported Product Agent transport negotiation", "protocol_error")), this.disconnect();
|
|
6353
6356
|
return;
|
|
6354
6357
|
}
|
|
6355
6358
|
this.admitted = s, this.activate();
|
|
@@ -6360,14 +6363,14 @@ class za {
|
|
|
6360
6363
|
}), this.socket.on("connect_error", (s) => {
|
|
6361
6364
|
const n = s.data?.code;
|
|
6362
6365
|
if (n === "unauthorized" && s.data?.reason === "token_expired" && s.data.retryable === !0) {
|
|
6363
|
-
this.options.onError(new
|
|
6366
|
+
this.options.onError(new q(s.message, n, !1, s.data)), this.disconnect();
|
|
6364
6367
|
return;
|
|
6365
6368
|
}
|
|
6366
6369
|
if (!n || s.data?.retryable === !0) {
|
|
6367
6370
|
this.invalidate(!1, "connect_error"), this.options.reconnect === !1 ? this.socket.disconnect() : this.scheduleNamespaceReconnect();
|
|
6368
6371
|
return;
|
|
6369
6372
|
}
|
|
6370
|
-
(n === "unauthorized" || n === "update_required") && (this.rejectedToken = this.options.auth.token), this.options.onError(new
|
|
6373
|
+
(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
6374
|
}), this.socket.on("conversation.event", (s) => {
|
|
6372
6375
|
this.ready && s.protocol === 1 && s.session_id && this.bindings.get(s.session_id)?.owners.size && this.options.onEvent("conversation.event", s.event);
|
|
6373
6376
|
}), this.socket.on("conversation.metadata.updated", (s) => {
|
|
@@ -6394,7 +6397,7 @@ class za {
|
|
|
6394
6397
|
const i = this.generation, r = await this.options.onToolCall(s);
|
|
6395
6398
|
n({ received: r && !!this.ready && i === this.generation });
|
|
6396
6399
|
}), this.socket.on("executor.replaced", () => {
|
|
6397
|
-
this.retired = !0, this.options.onError(new
|
|
6400
|
+
this.retired = !0, this.options.onError(new q("Browser executor was replaced", "executor_replaced")), this.disconnect();
|
|
6398
6401
|
});
|
|
6399
6402
|
}
|
|
6400
6403
|
options;
|
|
@@ -6438,11 +6441,11 @@ class za {
|
|
|
6438
6441
|
return this.ready && this.socket.id ? `pa-sio:${this.socket.id}` : null;
|
|
6439
6442
|
}
|
|
6440
6443
|
async restoreExecutor(e) {
|
|
6441
|
-
if (this.connectionId !== e) throw new
|
|
6444
|
+
if (this.connectionId !== e) throw new q("Browser connection changed.", "executor_not_ready");
|
|
6442
6445
|
if (this.executorRecovery) return this.executorRecovery;
|
|
6443
6446
|
const s = this.request("executor.register", {}, this.generation).then(() => {
|
|
6444
6447
|
}, (n) => {
|
|
6445
|
-
throw n instanceof
|
|
6448
|
+
throw n instanceof q && (n.outcomeUnknown || n.code === "disconnected") ? new q("Reconnecting the browser before continuing.", "executor_not_ready") : n;
|
|
6446
6449
|
});
|
|
6447
6450
|
this.executorRecovery = s;
|
|
6448
6451
|
try {
|
|
@@ -6484,7 +6487,7 @@ class za {
|
|
|
6484
6487
|
beginAttempt() {
|
|
6485
6488
|
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
6489
|
const e = this.generation, s = (n) => {
|
|
6487
|
-
e !== this.generation || !this.active || (this.options.onError(new
|
|
6490
|
+
e !== this.generation || !this.active || (this.options.onError(new q("Product Agent readiness timed out", n, !1, {
|
|
6488
6491
|
retryable: !0,
|
|
6489
6492
|
...this.attempt,
|
|
6490
6493
|
readinessPhase: this.ready ? "bootstrap" : this.admitted ? "activation" : "namespace_ready"
|
|
@@ -6498,20 +6501,20 @@ class za {
|
|
|
6498
6501
|
async retain(e, s) {
|
|
6499
6502
|
let n = this.bindings.get(e);
|
|
6500
6503
|
if (!n) {
|
|
6501
|
-
if (this.bindings.size >= 64) throw new
|
|
6504
|
+
if (this.bindings.size >= 64) throw new q("Too many conversation subscriptions", "subscription_limit");
|
|
6502
6505
|
n = { id: crypto.randomUUID(), owners: /* @__PURE__ */ new Set(), joinedGeneration: -1 }, this.bindings.set(e, n);
|
|
6503
6506
|
}
|
|
6504
6507
|
if (n.owners.add(s), !this.ready) return;
|
|
6505
6508
|
const i = this.generation;
|
|
6506
6509
|
await this.synchronize().catch((r) => {
|
|
6507
|
-
throw i !== this.generation || (n.owners.delete(s), r instanceof
|
|
6510
|
+
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
6511
|
});
|
|
6509
6512
|
}
|
|
6510
6513
|
async release(e, s) {
|
|
6511
6514
|
this.bindings.get(e)?.owners.delete(s), this.ready && await this.synchronize();
|
|
6512
6515
|
}
|
|
6513
6516
|
async rpc(e, s) {
|
|
6514
|
-
if (!$a.has(e)) throw new
|
|
6517
|
+
if (!$a.has(e)) throw new q("Operation requires its HTTP adapter", "unsupported_rpc");
|
|
6515
6518
|
const n = this.generation, i = JSON.stringify(s);
|
|
6516
6519
|
return e === "run.stop" && this.uploadingResult ? (this.assertReady(n), this.request("runtime.rpc", { type: e, payload: JSON.parse(i) }, n)) : this.enqueue(async () => {
|
|
6517
6520
|
if (this.assertReady(n), e === "tool.result") {
|
|
@@ -6531,13 +6534,13 @@ class za {
|
|
|
6531
6534
|
this.ready = s, await this.synchronize(!0), e === this.generation && this.ready && (this.options.bootstrapRequired || this.markReady(), this.options.onReady(s));
|
|
6532
6535
|
} catch (i) {
|
|
6533
6536
|
if (e === this.generation) {
|
|
6534
|
-
const r = Y(i, "activation_error", "web_transport"), a = i instanceof
|
|
6537
|
+
const r = Y(i, "activation_error", "web_transport"), a = i instanceof q ? i : new q(
|
|
6535
6538
|
r.message,
|
|
6536
6539
|
r.code,
|
|
6537
6540
|
!1,
|
|
6538
6541
|
{ ...r.details, retryable: r.retryable }
|
|
6539
6542
|
);
|
|
6540
|
-
this.activationFailed(new
|
|
6543
|
+
this.activationFailed(new q(
|
|
6541
6544
|
a.message,
|
|
6542
6545
|
a.code,
|
|
6543
6546
|
a.outcomeUnknown,
|
|
@@ -6564,7 +6567,7 @@ class za {
|
|
|
6564
6567
|
subscription_id: i.id,
|
|
6565
6568
|
...this.options.displaySchema === "canonical" ? { display_schema: "canonical" } : {}
|
|
6566
6569
|
}, s).then(() => !0).catch((a) => {
|
|
6567
|
-
if (a instanceof
|
|
6570
|
+
if (a instanceof q && !a.outcomeUnknown && a.detail?.retryable !== !0 && this.bindings.get(n) === i && (this.bindings.delete(n), e))
|
|
6568
6571
|
return this.options.onError(a), !1;
|
|
6569
6572
|
throw a;
|
|
6570
6573
|
})) continue;
|
|
@@ -6576,7 +6579,7 @@ class za {
|
|
|
6576
6579
|
}
|
|
6577
6580
|
enqueue(e) {
|
|
6578
6581
|
if (this.queuedOperations >= 128) {
|
|
6579
|
-
const n = new
|
|
6582
|
+
const n = new q("Product Agent transport queue is full", "backpressure");
|
|
6580
6583
|
return this.recoverUncertainDelivery(n, this.generation), Promise.reject(n);
|
|
6581
6584
|
}
|
|
6582
6585
|
this.queuedOperations++;
|
|
@@ -6587,7 +6590,7 @@ class za {
|
|
|
6587
6590
|
}), s;
|
|
6588
6591
|
}
|
|
6589
6592
|
assertReady(e) {
|
|
6590
|
-
if (!this.ready || !this.socket.connected || e !== this.generation) throw new
|
|
6593
|
+
if (!this.ready || !this.socket.connected || e !== this.generation) throw new q("Transport is not ready", "disconnected");
|
|
6591
6594
|
}
|
|
6592
6595
|
async uploadResult(e, s, n) {
|
|
6593
6596
|
const i = crypto.randomUUID();
|
|
@@ -6612,38 +6615,38 @@ class za {
|
|
|
6612
6615
|
body: JSON.stringify({ request_id: i, type: "tool.result", payload: e })
|
|
6613
6616
|
});
|
|
6614
6617
|
if (u.status >= 500)
|
|
6615
|
-
throw new
|
|
6616
|
-
if (!u.ok) throw new
|
|
6618
|
+
throw new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
6619
|
+
if (!u.ok) throw new q(`Result upload rejected (${u.status})`, String(u.status), !1, void 0, !0);
|
|
6617
6620
|
const h = await u.json();
|
|
6618
6621
|
if (s !== this.generation || r.signal.aborted)
|
|
6619
|
-
throw new
|
|
6622
|
+
throw new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
6620
6623
|
if (h?.request_id !== i || typeof h.ok != "boolean")
|
|
6621
|
-
throw new
|
|
6624
|
+
throw new q("Invalid result acknowledgement identity", "invalid_ack", !0);
|
|
6622
6625
|
if (!h.ok) throw ni(h, "Product Agent result rejected");
|
|
6623
6626
|
return h.result;
|
|
6624
6627
|
} catch (d) {
|
|
6625
|
-
const l = d instanceof
|
|
6628
|
+
const l = d instanceof q ? d : new q("Result upload outcome is unknown", "delivery_unknown", !0);
|
|
6626
6629
|
throw this.recoverUncertainDelivery(l, s), l;
|
|
6627
6630
|
} finally {
|
|
6628
6631
|
clearTimeout(c), this.uploadingResult = !1, this.pending.delete(a);
|
|
6629
6632
|
}
|
|
6630
6633
|
}
|
|
6631
6634
|
request(e, s, n) {
|
|
6632
|
-
if (!this.socket.connected || n !== this.generation) return Promise.reject(new
|
|
6635
|
+
if (!this.socket.connected || n !== this.generation) return Promise.reject(new q("Transport disconnected", "disconnected"));
|
|
6633
6636
|
const i = crypto.randomUUID();
|
|
6634
6637
|
return new Promise((r, a) => {
|
|
6635
6638
|
const o = (c) => {
|
|
6636
6639
|
this.pending.delete(o), a(c);
|
|
6637
6640
|
};
|
|
6638
6641
|
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
|
|
6642
|
+
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
6643
|
});
|
|
6641
6644
|
}).catch((r) => {
|
|
6642
6645
|
throw this.recoverUncertainDelivery(r, n), r;
|
|
6643
6646
|
});
|
|
6644
6647
|
}
|
|
6645
6648
|
recoverUncertainDelivery(e, s) {
|
|
6646
|
-
e instanceof
|
|
6649
|
+
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
6650
|
}
|
|
6648
6651
|
invalidate(e = !1, s = "local_invalidation") {
|
|
6649
6652
|
if (this.clearReadinessTimers(), !!this.active) {
|
|
@@ -6655,7 +6658,7 @@ class za {
|
|
|
6655
6658
|
lastHeartbeatReceivedAt: this.activity.lastHeartbeatReceivedAt,
|
|
6656
6659
|
lastHeartbeatQueuedAt: this.activity.lastHeartbeatQueuedAt
|
|
6657
6660
|
}, this.active = !1, this.generation++, this.ready = null, this.admitted = null, this.activating = !1;
|
|
6658
|
-
for (const n of [...this.pending]) n(new
|
|
6661
|
+
for (const n of [...this.pending]) n(new q("Connection lost before acknowledgement", "delivery_unknown", !0));
|
|
6659
6662
|
this.options.onDisconnect(e, s);
|
|
6660
6663
|
}
|
|
6661
6664
|
}
|
|
@@ -6683,7 +6686,7 @@ class dr {
|
|
|
6683
6686
|
async request(e, s = {}, n, i, r, a = {}) {
|
|
6684
6687
|
if (a.skipAuthentication) return this.requestOnce(e, s, n, i, r, a.signal, a.diagnostic);
|
|
6685
6688
|
const o = this.options.authority?.(), c = (u = !0) => {
|
|
6686
|
-
if (o !== this.options.authority?.()) throw new
|
|
6689
|
+
if (o !== this.options.authority?.()) throw new q("Conversation authority was retired.", "authority_retired", !0);
|
|
6687
6690
|
u && (this.requests.signal.throwIfAborted(), a.signal?.throwIfAborted());
|
|
6688
6691
|
}, d = a.readOnly ?? (i ?? (n === void 0 ? "GET" : "POST")) === "GET";
|
|
6689
6692
|
let l = 0;
|
|
@@ -6698,7 +6701,7 @@ class dr {
|
|
|
6698
6701
|
try {
|
|
6699
6702
|
let f = n;
|
|
6700
6703
|
if (r === "conversations" && e === "/commands" && this.auth.role !== "session_surface" && this.options.executorConnection) {
|
|
6701
|
-
if (m = this.options.executorConnection(), !m) throw new
|
|
6704
|
+
if (m = this.options.executorConnection(), !m) throw new q("Reconnecting the browser before continuing.", "executor_not_ready");
|
|
6702
6705
|
const k = n;
|
|
6703
6706
|
f = { ...k, context: { ...k.context, connection_id: m } };
|
|
6704
6707
|
}
|
|
@@ -6706,66 +6709,66 @@ class dr {
|
|
|
6706
6709
|
return c(), b;
|
|
6707
6710
|
} catch (f) {
|
|
6708
6711
|
if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw f;
|
|
6709
|
-
if (f instanceof
|
|
6712
|
+
if (f instanceof q && f.code === "executor_not_ready" && m && u === 0 && this.options.restoreExecutor) {
|
|
6710
6713
|
await this.options.restoreExecutor(m), u++, c();
|
|
6711
6714
|
continue;
|
|
6712
6715
|
}
|
|
6713
|
-
if (!(f instanceof
|
|
6716
|
+
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
6717
|
u++;
|
|
6715
6718
|
}
|
|
6716
6719
|
}
|
|
6717
6720
|
}
|
|
6718
6721
|
async requestOnce(e, s, n, i, r, a, o, c = 1) {
|
|
6719
6722
|
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
|
-
|
|
6723
|
+
for (const [E, C] of Object.entries({ ...u, ...s }))
|
|
6724
|
+
C != null && l.searchParams.set(E, String(C));
|
|
6722
6725
|
this.requests.signal.throwIfAborted(), a?.throwIfAborted();
|
|
6723
|
-
const h = new AbortController(), p = { trigger: null }, m = (
|
|
6724
|
-
h.signal.aborted || (p.trigger =
|
|
6726
|
+
const h = new AbortController(), p = { trigger: null }, m = (E) => {
|
|
6727
|
+
h.signal.aborted || (p.trigger = E, h.abort());
|
|
6725
6728
|
}, f = () => m("transport_disposed"), y = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
|
|
6726
6729
|
this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", y, { once: !0 });
|
|
6727
6730
|
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,
|
|
6731
|
+
let I = null, w = !1, A = null, _ = null, T = null;
|
|
6729
6732
|
try {
|
|
6730
|
-
const
|
|
6733
|
+
const E = await Promise.resolve(fetch(l, {
|
|
6731
6734
|
method: i ?? (n === void 0 ? "GET" : "POST"),
|
|
6732
6735
|
cache: "no-store",
|
|
6733
6736
|
signal: h.signal,
|
|
6734
6737
|
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
6738
|
...n === void 0 ? {} : { body: JSON.stringify(n) }
|
|
6736
|
-
})).catch((
|
|
6737
|
-
throw w = !0,
|
|
6739
|
+
})).catch((C) => {
|
|
6740
|
+
throw w = !0, C;
|
|
6738
6741
|
});
|
|
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
|
|
6742
|
+
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) {
|
|
6743
|
+
const C = E.status === 401 ? "unauthorized" : E.status === 426 ? "update_required" : String(E.status), O = (await E.json().catch(() => null))?.detail;
|
|
6744
|
+
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))
|
|
6745
|
+
throw new q("Conversation unavailable", "conversation_access_denied");
|
|
6746
|
+
if (r === "conversations" && e.endsWith("/snapshot") && E.status === 409 && O === "Display projection is not enabled")
|
|
6747
|
+
throw new q("Conversation history is unavailable. Try loading this chat again after the service is ready.", "display_projection_disabled");
|
|
6748
|
+
if (r === "conversations" && e === "/commands" && E.status === 409 && (O === "embedded_submission_conflict" || O === "embedded_submission_snapshot_unavailable"))
|
|
6749
|
+
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);
|
|
6750
|
+
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"))
|
|
6751
|
+
throw new q("Reconnecting the browser before continuing.", "executor_not_ready");
|
|
6752
|
+
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")
|
|
6753
|
+
throw new q(O.message, O.code, !1, {
|
|
6751
6754
|
...typeof O.blockedOrigin == "string" ? { blockedOrigin: O.blockedOrigin } : {},
|
|
6752
6755
|
...typeof O.securitySettingsUrl == "string" ? { securitySettingsUrl: O.securitySettingsUrl } : {}
|
|
6753
6756
|
}, r === "conversations" && e === "/commands");
|
|
6754
|
-
const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, x =
|
|
6755
|
-
throw new E
|
|
6757
|
+
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;
|
|
6758
|
+
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
6759
|
}
|
|
6757
|
-
return await
|
|
6758
|
-
} catch (
|
|
6759
|
-
const
|
|
6760
|
+
return await E.json();
|
|
6761
|
+
} catch (E) {
|
|
6762
|
+
const C = p.trigger ?? ((E instanceof Error || E instanceof DOMException) && E.name === "AbortError" ? "unexpected_abort" : null), O = {
|
|
6760
6763
|
requestId: g,
|
|
6761
6764
|
method: i ?? (n === void 0 ? "GET" : "POST"),
|
|
6762
6765
|
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:
|
|
6766
|
+
status: A,
|
|
6767
|
+
abortTrigger: C,
|
|
6768
|
+
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
6769
|
responseHeadersMs: I === null ? null : Math.max(0, I - v),
|
|
6767
6770
|
responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
|
|
6768
|
-
owner:
|
|
6771
|
+
owner: C === "deadline" ? "http_deadline" : C === "transport_disposed" ? "http_transport" : C && C !== "unexpected_abort" ? "conversation_query" : A === null ? "browser" : "http_response",
|
|
6769
6772
|
elapsedMs: Math.max(0, Date.now() - v),
|
|
6770
6773
|
attempt: c,
|
|
6771
6774
|
queryRequestId: j(o?.queryRequestId),
|
|
@@ -6773,27 +6776,27 @@ class dr {
|
|
|
6773
6776
|
authorityGeneration: o?.authorityGeneration ?? null,
|
|
6774
6777
|
sessionId: j(o?.sessionId),
|
|
6775
6778
|
release: this.auth.extension_version ? `extension-${this.auth.extension_version}` : `sdk-${Lt.version}`,
|
|
6776
|
-
upstreamRequestId:
|
|
6777
|
-
upstreamTraceId:
|
|
6779
|
+
upstreamRequestId: _,
|
|
6780
|
+
upstreamTraceId: T
|
|
6778
6781
|
};
|
|
6779
6782
|
he(O) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(O) : console.warn("Product Agent HTTP request failed", O)).catch(() => {
|
|
6780
6783
|
});
|
|
6781
6784
|
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" :
|
|
6785
|
+
if (C !== null) {
|
|
6786
|
+
const x = C !== "deadline" && C !== "unexpected_abort";
|
|
6787
|
+
throw new q(
|
|
6788
|
+
x ? "The request was cancelled." : C === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
|
|
6789
|
+
x ? "request_cancelled" : C === "deadline" ? "request_timed_out" : "connection_interrupted",
|
|
6787
6790
|
!0,
|
|
6788
6791
|
S
|
|
6789
6792
|
);
|
|
6790
6793
|
}
|
|
6791
|
-
throw
|
|
6794
|
+
throw E instanceof q && S ? new q(E.message, E.code, E.outcomeUnknown, { ...E.detail, ...S }, E.backendRefusal) : S ? new q(
|
|
6792
6795
|
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
6796
|
"connection_interrupted",
|
|
6794
6797
|
!0,
|
|
6795
6798
|
S
|
|
6796
|
-
) :
|
|
6799
|
+
) : E;
|
|
6797
6800
|
} finally {
|
|
6798
6801
|
clearTimeout(R), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", y);
|
|
6799
6802
|
}
|
|
@@ -7273,7 +7276,7 @@ class L extends EventTarget {
|
|
|
7273
7276
|
stage: i,
|
|
7274
7277
|
httpStatus: /^[45][0-9]{2}$/.test(s.code) ? Number(s.code) : void 0,
|
|
7275
7278
|
failureKind: s.outcomeUnknown || n.retryable === !0 ? "temporary" : "permanent"
|
|
7276
|
-
}), this.fail(new
|
|
7279
|
+
}), this.fail(new q(s.message, s.code, s.outcomeUnknown, { ...n, stage: i }, s.backendRefusal));
|
|
7277
7280
|
}
|
|
7278
7281
|
}
|
|
7279
7282
|
}), queueMicrotask(() => {
|
|
@@ -7403,17 +7406,17 @@ class L extends EventTarget {
|
|
|
7403
7406
|
this.queueDiagnostic("auth_timeout", {
|
|
7404
7407
|
readinessPhase: "bootstrap",
|
|
7405
7408
|
failureKind: "temporary",
|
|
7406
|
-
httpStatus: a instanceof
|
|
7409
|
+
httpStatus: a instanceof q && /^[45][0-9]{2}$/.test(a.code) ? Number(a.code) : void 0
|
|
7407
7410
|
}), this.transport.recover();
|
|
7408
7411
|
return;
|
|
7409
7412
|
}
|
|
7410
7413
|
if (s.type === "auth.session") {
|
|
7411
|
-
const o = a instanceof
|
|
7414
|
+
const o = a instanceof q ? a : new q("Chat setup failed", "request_failed"), c = this.isInvalidResponse(o);
|
|
7412
7415
|
this.queueDiagnostic("auth_rejected", {
|
|
7413
7416
|
stage: "bootstrap",
|
|
7414
7417
|
failureKind: "permanent",
|
|
7415
7418
|
httpStatus: /^[45][0-9]{2}$/.test(o.code) ? Number(o.code) : void 0
|
|
7416
|
-
}), this.fail(new
|
|
7419
|
+
}), this.fail(new q(
|
|
7417
7420
|
o.message,
|
|
7418
7421
|
c ? "invalid_response" : o.code,
|
|
7419
7422
|
c ? !1 : o.outcomeUnknown,
|
|
@@ -7430,7 +7433,7 @@ class L extends EventTarget {
|
|
|
7430
7433
|
try {
|
|
7431
7434
|
return await this.transport.rpc(e.type, Object.fromEntries(Object.entries(e).filter(([s]) => s !== "type"))), !0;
|
|
7432
7435
|
} catch (s) {
|
|
7433
|
-
return s instanceof
|
|
7436
|
+
return s instanceof q && s.code === "backpressure" && !s.backendRefusal || this.fail(s, e), s instanceof q && s.backendRefusal;
|
|
7434
7437
|
}
|
|
7435
7438
|
}
|
|
7436
7439
|
receive(e) {
|
|
@@ -7449,13 +7452,13 @@ class L extends EventTarget {
|
|
|
7449
7452
|
}
|
|
7450
7453
|
buffer(e, s) {
|
|
7451
7454
|
if (e.length >= 128) {
|
|
7452
|
-
this.fail(new
|
|
7455
|
+
this.fail(new q("Product Agent delivery buffer is full", "backpressure")), this.close();
|
|
7453
7456
|
return;
|
|
7454
7457
|
}
|
|
7455
7458
|
e.push(s);
|
|
7456
7459
|
}
|
|
7457
7460
|
fail(e, s, n = !1) {
|
|
7458
|
-
const i = Y(e, "request_failed", "web_transport"), r = e instanceof
|
|
7461
|
+
const i = Y(e, "request_failed", "web_transport"), r = e instanceof q ? e : new q(
|
|
7459
7462
|
i.message,
|
|
7460
7463
|
i.code,
|
|
7461
7464
|
!1,
|
|
@@ -7480,11 +7483,11 @@ class L extends EventTarget {
|
|
|
7480
7483
|
return this.httpTransport.request(e, s, n, i);
|
|
7481
7484
|
}
|
|
7482
7485
|
isInvalidResponse(e) {
|
|
7483
|
-
const s = e instanceof
|
|
7486
|
+
const s = e instanceof q ? e.detail : void 0;
|
|
7484
7487
|
return !!(s && typeof s == "object" && "httpRequest" in s && he(s.httpRequest) && s.httpRequest.category === "invalid_response");
|
|
7485
7488
|
}
|
|
7486
7489
|
isRetryableRead(e) {
|
|
7487
|
-
return this.isInvalidResponse(e) ? !1 : e instanceof TypeError || e instanceof DOMException && e.name === "AbortError" || e instanceof
|
|
7490
|
+
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
7491
|
}
|
|
7489
7492
|
async dispatch(e, s) {
|
|
7490
7493
|
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 };
|
|
@@ -9879,7 +9882,7 @@ function Es(t) {
|
|
|
9879
9882
|
if (t instanceof ue)
|
|
9880
9883
|
return t.retryable;
|
|
9881
9884
|
if (t && typeof t == "object") {
|
|
9882
|
-
const e = t instanceof
|
|
9885
|
+
const e = t instanceof q ? t.code : "", s = /^[45][0-9]{2}$/.test(e) ? Number(e) : t.status;
|
|
9883
9886
|
if (typeof s == "number")
|
|
9884
9887
|
return s === 408 || s === 425 || s === 429 || s >= 500;
|
|
9885
9888
|
}
|
|
@@ -9911,7 +9914,7 @@ class Kt {
|
|
|
9911
9914
|
recoverAuthentication: (i, r, a) => this.recoverHttpAuthentication(i, r, a),
|
|
9912
9915
|
// Public custom transports own their admission contract and do not expose the default Socket.IO lease.
|
|
9913
9916
|
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
|
|
9917
|
+
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
9918
|
auth: {
|
|
9916
9919
|
protocol: 1,
|
|
9917
9920
|
token: e.token ?? "",
|
|
@@ -10156,11 +10159,11 @@ class Kt {
|
|
|
10156
10159
|
return;
|
|
10157
10160
|
}
|
|
10158
10161
|
const w = () => {
|
|
10159
|
-
cancelAnimationFrame(
|
|
10160
|
-
},
|
|
10162
|
+
cancelAnimationFrame(_), document.removeEventListener("visibilitychange", A), setTimeout(I, 0);
|
|
10163
|
+
}, A = () => {
|
|
10161
10164
|
document.visibilityState !== "visible" && w();
|
|
10162
|
-
},
|
|
10163
|
-
document.addEventListener("visibilitychange",
|
|
10165
|
+
}, _ = requestAnimationFrame(w);
|
|
10166
|
+
document.addEventListener("visibilitychange", A);
|
|
10164
10167
|
}));
|
|
10165
10168
|
const v = f.context.page;
|
|
10166
10169
|
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 });
|
|
@@ -10204,11 +10207,11 @@ class Kt {
|
|
|
10204
10207
|
},
|
|
10205
10208
|
onCommand: (f) => Me("client_event", f.type, Ss({ ...f.payload, type: f.type })),
|
|
10206
10209
|
onError: (f, y) => {
|
|
10207
|
-
if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" && f instanceof
|
|
10210
|
+
if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" && f instanceof q && f.code === "conversation_access_denied") {
|
|
10208
10211
|
y.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
|
|
10209
10212
|
return;
|
|
10210
10213
|
}
|
|
10211
|
-
V("web-sdk.conversation", "Conversation operation failed", { ...y, ...xo(f) }), f instanceof
|
|
10214
|
+
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
10215
|
}
|
|
10213
10216
|
})
|
|
10214
10217
|
});
|
|
@@ -10294,8 +10297,8 @@ class Kt {
|
|
|
10294
10297
|
if (!R.startsWith(`background:${this.modelClientScopeId}:`)) continue;
|
|
10295
10298
|
const v = Ie(f.conversation, f.directory, g), I = v.sessionId ? f.conversation.sessions[v.sessionId] : void 0;
|
|
10296
10299
|
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((
|
|
10300
|
+
for (const A of le(I?.execution)) this.clearFirstResponseTimer(A);
|
|
10301
|
+
const w = v.activity.phase === "completed" && le(I?.execution).some((A) => this.firstResponseTimersByClientMessageId.has(A));
|
|
10299
10302
|
(b && v.sessionId === this.getState().sessionId || !w && ["completed", "failed", "stopped"].includes(v.activity.phase)) && this.directoryScope.detach(R);
|
|
10300
10303
|
}
|
|
10301
10304
|
const k = this.getState();
|
|
@@ -10326,7 +10329,7 @@ class Kt {
|
|
|
10326
10329
|
}
|
|
10327
10330
|
}
|
|
10328
10331
|
handleDirectoryTransportError(e) {
|
|
10329
|
-
if (!(e instanceof
|
|
10332
|
+
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
10333
|
const s = e.detail && typeof e.detail == "object" ? e.detail : {};
|
|
10331
10334
|
this.handleServerEvent({
|
|
10332
10335
|
...s,
|
|
@@ -10549,7 +10552,7 @@ class Kt {
|
|
|
10549
10552
|
} catch (r) {
|
|
10550
10553
|
if (n !== this.connectionAttemptId || this.state.status === "closed")
|
|
10551
10554
|
return;
|
|
10552
|
-
if (r instanceof
|
|
10555
|
+
if (r instanceof q && (r.code === "unauthorized" || r.code === "update_required")) {
|
|
10553
10556
|
this.handleDirectoryTransportError(r);
|
|
10554
10557
|
return;
|
|
10555
10558
|
}
|
|
@@ -10567,7 +10570,7 @@ class Kt {
|
|
|
10567
10570
|
);
|
|
10568
10571
|
return;
|
|
10569
10572
|
}
|
|
10570
|
-
throw this.options.productVariant === "customer_embedded" ? (this.reportTransportDiagnostic("auth_rejected", this.connectionFailureDiagnostic(r, "token_provider")), this.stopAuthentication(new
|
|
10573
|
+
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
10574
|
status: "error",
|
|
10572
10575
|
lastError: a.message,
|
|
10573
10576
|
lastErrorCode: "connection_failed"
|
|
@@ -11668,7 +11671,7 @@ class Kt {
|
|
|
11668
11671
|
return;
|
|
11669
11672
|
}
|
|
11670
11673
|
if (e.code === "invalid_response" && e.stage === "bootstrap") {
|
|
11671
|
-
this.stopAuthentication(new
|
|
11674
|
+
this.stopAuthentication(new q(String(e.message), "connection_failed", !1, { stage: "bootstrap" }));
|
|
11672
11675
|
return;
|
|
11673
11676
|
}
|
|
11674
11677
|
if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "401") && e.reason === "invalid_token" && (this.canRefreshInvalidCredential() || this.credentialRecovery !== null)) {
|
|
@@ -11677,7 +11680,7 @@ class Kt {
|
|
|
11677
11680
|
this.credentialRecovery || this.refreshCredentials(
|
|
11678
11681
|
s,
|
|
11679
11682
|
!0,
|
|
11680
|
-
new
|
|
11683
|
+
new q("", "unauthorized", !1, {
|
|
11681
11684
|
reason: e.reason,
|
|
11682
11685
|
authTransport: e.authTransport,
|
|
11683
11686
|
requestId: e.requestId,
|
|
@@ -11694,7 +11697,7 @@ class Kt {
|
|
|
11694
11697
|
return;
|
|
11695
11698
|
}
|
|
11696
11699
|
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
|
|
11700
|
+
this.stopAuthentication(new q(
|
|
11698
11701
|
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
11702
|
"connection_failed",
|
|
11700
11703
|
!1,
|
|
@@ -11703,7 +11706,7 @@ class Kt {
|
|
|
11703
11706
|
return;
|
|
11704
11707
|
}
|
|
11705
11708
|
if (!this.options.webSocketFactory && (e.code === "unauthorized" || e.code === "update_required" || e.code === "executor_replaced")) {
|
|
11706
|
-
this.stopAuthentication(new
|
|
11709
|
+
this.stopAuthentication(new q(String(e.message), String(e.code), !1, { reason: e.reason, authTransport: "socket" }));
|
|
11707
11710
|
return;
|
|
11708
11711
|
}
|
|
11709
11712
|
["unauthorized", "update_required", "executor_replaced", "connection_failed"].includes(String(e.code)) && this.setState({ status: "error", lastError: String(e.message), lastErrorCode: String(e.code) });
|
|
@@ -11864,7 +11867,7 @@ class Kt {
|
|
|
11864
11867
|
stage: this.lastRecoveryStage,
|
|
11865
11868
|
recoveryOutcome: "exhausted",
|
|
11866
11869
|
failureKind: "temporary"
|
|
11867
|
-
}), this.stopAuthentication(new
|
|
11870
|
+
}), this.stopAuthentication(new q(
|
|
11868
11871
|
"Chat could not reconnect. Your conversation and draft are saved here. Try again.",
|
|
11869
11872
|
"connection_failed",
|
|
11870
11873
|
!1
|
|
@@ -11875,7 +11878,7 @@ class Kt {
|
|
|
11875
11878
|
this.embeddedRecoveryTimer !== null && window.clearTimeout(this.embeddedRecoveryTimer), this.embeddedRecoveryTimer = null;
|
|
11876
11879
|
}
|
|
11877
11880
|
connectionFailureDiagnostic(e, s) {
|
|
11878
|
-
const n = e instanceof ue ? e.status : e instanceof
|
|
11881
|
+
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
11882
|
return {
|
|
11880
11883
|
stage: s,
|
|
11881
11884
|
...i !== void 0 ? { httpStatus: i } : {},
|
|
@@ -11944,7 +11947,7 @@ class Kt {
|
|
|
11944
11947
|
...this.authenticationDiagnostic(e),
|
|
11945
11948
|
failureKind: "permanent",
|
|
11946
11949
|
recoveryOutcome: "refused"
|
|
11947
|
-
}), e.code === "unauthorized" && (e = new
|
|
11950
|
+
}), 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
11951
|
const n = this.clientRuntime.engine.getState().slices.account.authority;
|
|
11949
11952
|
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
11953
|
const i = this.socket;
|
|
@@ -11970,7 +11973,7 @@ class Kt {
|
|
|
11970
11973
|
refreshCredentials(e, s = !1, n) {
|
|
11971
11974
|
if (this.credentialRecovery) return this.credentialRecovery;
|
|
11972
11975
|
this.credentialRecoveryFailure = null;
|
|
11973
|
-
const i = this.token, r = this.authenticationDiagnostic(n ?? new
|
|
11976
|
+
const i = this.token, r = this.authenticationDiagnostic(n ?? new q(
|
|
11974
11977
|
"",
|
|
11975
11978
|
"unauthorized",
|
|
11976
11979
|
!1,
|
|
@@ -11982,14 +11985,14 @@ class Kt {
|
|
|
11982
11985
|
const o = (async () => {
|
|
11983
11986
|
const c = await this.acquireToken("connect", { forceRefresh: !0 });
|
|
11984
11987
|
if (this.socket !== e || this.state.status === "closed" || this.clientRuntime.isDisposed)
|
|
11985
|
-
throw new
|
|
11988
|
+
throw new q("Conversation authority was retired.", "authority_retired", !0);
|
|
11986
11989
|
if (!c) throw new ue("Pluno token provider did not return a token", !1);
|
|
11987
|
-
if (s && c === i) throw new
|
|
11990
|
+
if (s && c === i) throw new q("Credential did not change.", "unauthorized", !1);
|
|
11988
11991
|
this.directoryHttp.auth.token = c, a = "bootstrap", this.lastRecoveryStage = a, await this.replaceDefaultTransportCredentials(e), this.reportTransportDiagnostic("auth_refresh_validated", r);
|
|
11989
11992
|
})().catch((c) => {
|
|
11990
11993
|
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
|
|
11994
|
+
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)) {
|
|
11995
|
+
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
11996
|
throw this.stopAuthentication(d), d;
|
|
11994
11997
|
}
|
|
11995
11998
|
throw this.options.productVariant === "customer_embedded" && this.setState({ status: "reconnecting", lastError: Ii, lastErrorCode: "connection_failed" }), this.scheduleReconnect(), c;
|
|
@@ -12618,12 +12621,12 @@ function Vd(t, e) {
|
|
|
12618
12621
|
const g = R.getAttribute("data-testid") || R.getAttribute("data-test") || R.getAttribute("data-qa") || R.getAttribute("data-cy") || "";
|
|
12619
12622
|
return `${R.tagName.toLowerCase()}|${m(R)}|${g}`;
|
|
12620
12623
|
}, y = (R, g, v) => {
|
|
12621
|
-
const I = (w,
|
|
12622
|
-
const
|
|
12623
|
-
if (p >= 1e3 && !
|
|
12624
|
+
const I = (w, A) => {
|
|
12625
|
+
const _ = w.tagName.toLowerCase(), T = window.getComputedStyle(w), E = l.has(w);
|
|
12626
|
+
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
12627
|
return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
|
|
12625
12628
|
p += 1;
|
|
12626
|
-
const
|
|
12629
|
+
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
12630
|
for (const D of x) {
|
|
12628
12631
|
const $ = f(D);
|
|
12629
12632
|
U.set($, (U.get($) ?? 0) + 1);
|
|
@@ -12640,18 +12643,18 @@ function Vd(t, e) {
|
|
|
12640
12643
|
Cn.has($) || (Gt.push([`… ${H.get($) ?? 0} similar siblings omitted`]), Cn.add($));
|
|
12641
12644
|
continue;
|
|
12642
12645
|
}
|
|
12643
|
-
const Dn = I(D,
|
|
12646
|
+
const Dn = I(D, A);
|
|
12644
12647
|
On.push(Dn), Gt.push(Dn.lines);
|
|
12645
12648
|
}
|
|
12646
12649
|
const Jt = [];
|
|
12647
12650
|
if (w.shadowRoot)
|
|
12648
12651
|
for (const D of Array.from(w.shadowRoot.children))
|
|
12649
|
-
D instanceof HTMLElement && Jt.push(I(D,
|
|
12652
|
+
D instanceof HTMLElement && Jt.push(I(D, A + 1));
|
|
12650
12653
|
const ct = [...On, ...Jt], Qt = O.length > 0 || S || ct.some((D) => D.hasUsefulContent), xn = Le(
|
|
12651
12654
|
[O, ...ct.map((D) => D.textPreview)].filter(Boolean).join(" ")
|
|
12652
|
-
).slice(0, 180), Fr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Mn = d.some((D) => w.hasAttribute(D)) || !!
|
|
12655
|
+
).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
12656
|
if (Xt) {
|
|
12654
|
-
const D = ct.some((ve) => ve.containsTextElement), $ = n.has(
|
|
12657
|
+
const D = ct.some((ve) => ve.containsTextElement), $ = n.has(_) && !D ? xn : O;
|
|
12655
12658
|
ze.push(kr(w, c, a, $.slice(0, 180)));
|
|
12656
12659
|
}
|
|
12657
12660
|
for (const D of Gt)
|
|
@@ -12660,9 +12663,9 @@ function Vd(t, e) {
|
|
|
12660
12663
|
if (Zt.length > 0) {
|
|
12661
12664
|
const D = Zt.slice(0, 20);
|
|
12662
12665
|
Zt.length > D.length && D.push("… shadow DOM omitted");
|
|
12663
|
-
const $ =
|
|
12664
|
-
if (
|
|
12665
|
-
const ve = Xt ? "#shadow-root" : `${
|
|
12666
|
+
const $ = _.includes("tooltip") || _.includes("popper") || _.includes("loader");
|
|
12667
|
+
if (A < 2 && !$) {
|
|
12668
|
+
const ve = Xt ? "#shadow-root" : `${_} #shadow-root`;
|
|
12666
12669
|
ze.push(...yt([ve, ...yt(D, 1)], Yt));
|
|
12667
12670
|
} else
|
|
12668
12671
|
ze.push(...yt(D, Yt));
|
|
@@ -12671,7 +12674,7 @@ function Vd(t, e) {
|
|
|
12671
12674
|
lines: ze,
|
|
12672
12675
|
hasUsefulContent: Qt,
|
|
12673
12676
|
textPreview: xn,
|
|
12674
|
-
containsTextElement: n.has(
|
|
12677
|
+
containsTextElement: n.has(_) || ct.some((D) => D.containsTextElement)
|
|
12675
12678
|
};
|
|
12676
12679
|
};
|
|
12677
12680
|
return [`--- ${g} ---`, ...I(R, 0).lines].join(`
|