@epam/ai-dial-chat-hooks 1.2.0-dev.28 → 1.2.0-dev.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/api-error/api-error.js +7 -4
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
- package/attachments.d.ts +10 -4
- package/catalog/catalog-derivations.js +1 -1
- package/catalog/deployment-id.js +8 -2
- package/catalog/map-deployment-limits-to-catalog.js +16 -24
- package/catalog/map-deployment-limits-to-input.js +81 -9
- package/catalog/map-deployment-to-catalog-item.js +34 -34
- package/catalog/map-entity-details-to-catalog.js +7 -0
- package/catalog/map-skill-to-catalog-item.js +55 -48
- package/catalog/publish.js +6 -5
- package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +122 -101
- package/catalog/usePublishFolders/usePublishFolders.js +1 -1
- package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
- package/catalog/useSkillItemDetails.js +17 -13
- package/catalog.d.ts +139 -34
- package/catalog.js +23 -22
- package/conversation/conversation-transfer/export-conversation.js +24 -16
- package/conversation/conversation-transfer/import-conversation.js +80 -31
- package/conversation/conversation-transfer/queue.js +8 -5
- package/conversation/create-chat-stream-api.js +85 -49
- package/conversation/message-utils.js +44 -2
- package/conversation/stage.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +7 -8
- package/conversation/useConversationExport/useConversationExport.js +9 -9
- package/conversation/useConversationHandlers/useConversationHandlers.js +73 -57
- package/conversation/useConversationImport/useConversationImport.js +123 -121
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +50 -32
- package/conversation/useConversationScroll/useConversationScroll.js +68 -64
- package/conversation/useConversationStream/apply-chunk.js +1 -1
- package/conversation/useConversationStream/frame-scheduler.js +39 -0
- package/conversation/useConversationStream/generation-resume.js +122 -64
- package/conversation/useConversationStream/useConversationStream.js +265 -116
- package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
- package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
- package/conversation-sources.d.ts +1 -1
- package/conversation-transfer.d.ts +2 -1
- package/conversation.d.ts +295 -17
- package/conversation.js +32 -29
- package/file-manager-canvas.d.ts +53 -5
- package/file-manager.d.ts +156 -26
- package/file-manager.js +25 -23
- package/files/attachment-canvas.js +74 -40
- package/files/attachment-types.js +14 -13
- package/files/dial-file-manager-mapping.util.js +2 -1
- package/files/dial-file-manager-path.util.js +23 -1
- package/files/dial-file-manager.model.js +23 -19
- package/files/dial-file-manager.types.js +3 -3
- package/files/useDialFileListing/useDialFileListing.js +139 -127
- package/files/useDialFileManager/useDialFileManager.js +132 -128
- package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -19
- package/files/useDialFileMutations/useDialFileMutations.js +33 -32
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
- package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +49 -0
- package/index.d.ts +1178 -112
- package/index.js +136 -122
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
- package/mcp-apps.d.ts +8 -6
- package/oauth/toolset-id.js +5 -3
- package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
- package/oauth.d.ts +32 -0
- package/oauth.js +9 -9
- package/package.json +26 -21
- package/scheduled-task/scheduled-task-description.js +81 -0
- package/scheduled-task/scheduled-task-preparation.js +24 -0
- package/scheduled-task/scheduled-task-trigger.js +74 -71
- package/scheduled-task/scheduled-tasks-api-client.js +19 -0
- package/scheduled-task/use-scheduled-task-runs.js +194 -0
- package/scheduled-task/use-scheduled-tasks.js +93 -0
- package/scheduled-tasks.d.ts +197 -3
- package/scheduled-tasks.js +7 -2
- package/shared/application-schema.js +5 -2
- package/shared/cron-day-of-month.js +13 -0
- package/skill/skill-archive.js +19 -0
- package/skill/skill-types.js +8 -7
- package/skill/skill.js +53 -27
- package/skill/useSkillArchiveImport/useSkillArchiveImport.js +79 -0
- package/skill/useSkillEditorLoad.js +65 -59
- package/skill/useSkillEditorSubmit.js +108 -84
- package/skill/useSkillFileActions.js +70 -58
- package/skill-editor.d.ts +160 -8
- package/skill-editor.js +9 -8
- package/usage/map-usage-data-to-dashboard.js +66 -0
- package/usage/map-user-usage-to-model-limits.js +202 -0
- package/usage.d.ts +125 -0
- package/usage.js +3 -0
- package/usePageFileDrag/usePageFileDrag.js +3 -3
- package/utils.d.ts +26 -6
- package/utils.js +10 -10
|
@@ -1,121 +1,125 @@
|
|
|
1
1
|
import { useCallback as e, useEffect as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
2
|
//#region src/conversation/useConversationScroll/useConversationScroll.ts
|
|
3
3
|
var a = 80, o = 1, s = ({ messages: s, isAssistantTyping: c, conversationId: l }) => {
|
|
4
|
-
let [u, d] = i(!1), f = r(null), p = r(null), m = r(null), h = r(!1), g = r(!1), _ = r(null), v = r(/* @__PURE__ */ new Map()),
|
|
5
|
-
t ?
|
|
6
|
-
}, []),
|
|
7
|
-
|
|
8
|
-
}, []),
|
|
4
|
+
let [u, d] = i(!1), f = r(null), p = r(null), m = r(null), h = r(!1), g = r(!1), _ = r(null), v = r(!0), y = r(/* @__PURE__ */ new Map()), b = e((e, t) => {
|
|
5
|
+
t ? y.current.set(e, t) : y.current.delete(e);
|
|
6
|
+
}, []), x = r(null), S = e((e) => {
|
|
7
|
+
x.current = e;
|
|
8
|
+
}, []), C = e((e, t) => {
|
|
9
9
|
let n = f.current;
|
|
10
10
|
n && n.scrollTo({
|
|
11
11
|
top: e,
|
|
12
12
|
behavior: t ? "instant" : "smooth"
|
|
13
13
|
});
|
|
14
|
-
}, []), C = e(() => {
|
|
15
|
-
m.current && (m.current.style.height = "0px"), h.current = !1, g.current = !1, _.current = null;
|
|
16
14
|
}, []), w = e(() => {
|
|
15
|
+
m.current && (m.current.style.height = "0px"), h.current = !1, g.current = !1, _.current = null;
|
|
16
|
+
}, []), T = e(() => {
|
|
17
17
|
let e = f.current, t = p.current;
|
|
18
18
|
if (!e || !t) return null;
|
|
19
19
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
20
20
|
return e.scrollTop + (r.bottom - n.top) - e.clientHeight;
|
|
21
|
-
}, []),
|
|
22
|
-
let t =
|
|
23
|
-
t != null &&
|
|
24
|
-
}, [
|
|
21
|
+
}, []), E = e((e = !1) => {
|
|
22
|
+
let t = T();
|
|
23
|
+
t != null && C(Math.max(t, 0), e);
|
|
24
|
+
}, [C, T]), D = e(() => {
|
|
25
25
|
let e = f.current, t = p.current;
|
|
26
26
|
if (!e || !t) return null;
|
|
27
27
|
let n = e.getBoundingClientRect();
|
|
28
28
|
return t.getBoundingClientRect().bottom - n.top - e.clientHeight;
|
|
29
|
-
}, []),
|
|
29
|
+
}, []), O = e(() => {
|
|
30
30
|
if (!g.current) return;
|
|
31
|
-
let e =
|
|
32
|
-
e == null || e < -1 ||
|
|
33
|
-
}, [
|
|
34
|
-
let t = f.current, n =
|
|
31
|
+
let e = D();
|
|
32
|
+
e == null || e < -1 || w();
|
|
33
|
+
}, [w, D]), k = e((e) => {
|
|
34
|
+
let t = f.current, n = y.current.get(e);
|
|
35
35
|
if (!t || !n) return null;
|
|
36
36
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = t.scrollTop + (i.top - r.top);
|
|
37
37
|
return Math.max(a, 0);
|
|
38
|
-
}, []),
|
|
39
|
-
let n =
|
|
40
|
-
n != null &&
|
|
41
|
-
}, [
|
|
42
|
-
let e =
|
|
38
|
+
}, []), A = e((e, t = !1) => {
|
|
39
|
+
let n = k(e);
|
|
40
|
+
n != null && C(n, t);
|
|
41
|
+
}, [k, C]), j = e(() => {
|
|
42
|
+
let e = T();
|
|
43
43
|
return e == null ? null : Math.max(e, 0);
|
|
44
|
-
}, [
|
|
44
|
+
}, [T]), M = e(() => {
|
|
45
45
|
if (!h.current) return null;
|
|
46
|
-
let e = _.current, t =
|
|
46
|
+
let e = _.current, t = j();
|
|
47
47
|
return e == null || t == null ? null : Math.max(e, t);
|
|
48
|
-
}, [
|
|
49
|
-
let e = f.current, t =
|
|
48
|
+
}, [j]), N = e(() => {
|
|
49
|
+
let e = f.current, t = M();
|
|
50
50
|
!e || t == null || e.scrollTop > t + o && (e.scrollTop = t);
|
|
51
|
-
}, [
|
|
52
|
-
let t = m.current, n =
|
|
51
|
+
}, [M]), P = e((e) => {
|
|
52
|
+
let t = m.current, n = j();
|
|
53
53
|
if (!t || n == null) return;
|
|
54
54
|
let r = Math.max(e - n, 0);
|
|
55
55
|
t.style.height = `${r}px`, h.current = r > 0, g.current = !1, _.current = r > 0 ? e : null;
|
|
56
|
-
}, [
|
|
57
|
-
let t =
|
|
58
|
-
t != null && (
|
|
56
|
+
}, [j]), F = e((e) => {
|
|
57
|
+
let t = k(e);
|
|
58
|
+
t != null && (P(t), A(e, !1));
|
|
59
59
|
}, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
]),
|
|
64
|
-
let e =
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
P,
|
|
61
|
+
k,
|
|
62
|
+
A
|
|
63
|
+
]), I = e(() => {
|
|
64
|
+
let e = D();
|
|
65
|
+
if (e == null) return;
|
|
66
|
+
let t = e < a;
|
|
67
|
+
v.current = t, d(!t);
|
|
68
|
+
}, [D]), L = r(s.length), R = r(null);
|
|
67
69
|
n(() => {
|
|
68
|
-
let e = s.length !==
|
|
69
|
-
|
|
70
|
+
let e = s.length !== L.current, t = l !== R.current, n = () => {
|
|
71
|
+
L.current = s.length, R.current = l;
|
|
70
72
|
};
|
|
71
|
-
t &&
|
|
72
|
-
let r =
|
|
73
|
-
if (r != null &&
|
|
74
|
-
|
|
73
|
+
t && w();
|
|
74
|
+
let r = x.current;
|
|
75
|
+
if (r != null && y.current.has(r)) {
|
|
76
|
+
x.current = null, F(r), n();
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
|
-
c || ((e || t) &&
|
|
79
|
+
c || ((e || t) && E(!1), n());
|
|
78
80
|
}, [
|
|
79
81
|
s,
|
|
80
82
|
c,
|
|
81
83
|
l,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
E,
|
|
85
|
+
F,
|
|
86
|
+
w
|
|
85
87
|
]), n(() => {
|
|
86
|
-
!c && h.current && (g.current = !0,
|
|
87
|
-
}, [c,
|
|
88
|
-
let
|
|
89
|
-
|
|
88
|
+
!c && h.current && (g.current = !0, O());
|
|
89
|
+
}, [c, O]);
|
|
90
|
+
let z = e(() => {
|
|
91
|
+
N(), O(), I();
|
|
90
92
|
}, [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
N,
|
|
94
|
+
O,
|
|
95
|
+
I
|
|
94
96
|
]);
|
|
95
97
|
return t(() => {
|
|
96
98
|
let e = f.current;
|
|
97
|
-
if (e) return e.addEventListener("scroll",
|
|
98
|
-
}, [
|
|
99
|
+
if (e) return e.addEventListener("scroll", z, { passive: !0 }), () => e.removeEventListener("scroll", z);
|
|
100
|
+
}, [z]), t(() => {
|
|
99
101
|
let e = p.current;
|
|
100
102
|
if (!e) return;
|
|
101
103
|
let t = new ResizeObserver(() => {
|
|
102
|
-
|
|
104
|
+
let e = v.current && !h.current;
|
|
105
|
+
N(), e && E(!0), O(), I();
|
|
103
106
|
});
|
|
104
107
|
return t.observe(e), () => t.disconnect();
|
|
105
108
|
}, [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
N,
|
|
110
|
+
O,
|
|
111
|
+
I,
|
|
112
|
+
E
|
|
109
113
|
]), {
|
|
110
114
|
containerRef: f,
|
|
111
115
|
contentRef: p,
|
|
112
116
|
spacerRef: m,
|
|
113
|
-
setMessageRef:
|
|
117
|
+
setMessageRef: b,
|
|
114
118
|
isScrollButtonVisible: u,
|
|
115
119
|
scrollToBottom: e(() => {
|
|
116
|
-
|
|
117
|
-
}, [
|
|
118
|
-
armAnchor:
|
|
120
|
+
E(!1);
|
|
121
|
+
}, [E]),
|
|
122
|
+
armAnchor: S
|
|
119
123
|
};
|
|
120
124
|
};
|
|
121
125
|
//#endregion
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/conversation/useConversationStream/frame-scheduler.ts
|
|
2
|
+
var e = 16, t = (t) => {
|
|
3
|
+
if (typeof requestAnimationFrame == "function") {
|
|
4
|
+
let e = requestAnimationFrame(t);
|
|
5
|
+
return () => cancelAnimationFrame(e);
|
|
6
|
+
}
|
|
7
|
+
let n = setTimeout(t, e);
|
|
8
|
+
return () => clearTimeout(n);
|
|
9
|
+
}, n = () => {
|
|
10
|
+
let e = /* @__PURE__ */ new Map(), n = (t) => {
|
|
11
|
+
let n = e.get(t);
|
|
12
|
+
n && (e.delete(t), n.task());
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
schedule: (r, i) => {
|
|
16
|
+
let a = e.get(r);
|
|
17
|
+
if (a) {
|
|
18
|
+
a.task = i;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let o = {
|
|
22
|
+
task: i,
|
|
23
|
+
cancelFrame: () => void 0
|
|
24
|
+
};
|
|
25
|
+
e.set(r, o), o.cancelFrame = t(() => n(r));
|
|
26
|
+
},
|
|
27
|
+
flush: (t) => {
|
|
28
|
+
e.get(t)?.cancelFrame(), n(t);
|
|
29
|
+
},
|
|
30
|
+
cancel: (t) => {
|
|
31
|
+
e.get(t)?.cancelFrame(), e.delete(t);
|
|
32
|
+
},
|
|
33
|
+
cancelAll: () => {
|
|
34
|
+
e.forEach((e) => e.cancelFrame()), e.clear();
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { n as createFrameScheduler };
|
|
@@ -1,16 +1,40 @@
|
|
|
1
1
|
import { safeDecodeURI as e } from "../../shared/string-utils.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as t, GenerationPersistenceError as n } from "../create-chat-stream-api.js";
|
|
3
|
+
import { getConversationPath as r } from "./conversation-path.js";
|
|
4
|
+
import { applyChunkToMessages as i } from "./apply-chunk.js";
|
|
5
|
+
import { restoreBufferedMessage as a } from "./buffered-generation.js";
|
|
6
|
+
import { BackgroundGenerationStatus as o, MessageRole as s } from "@epam/ai-dial-chat-shared";
|
|
6
7
|
//#region src/conversation/useConversationStream/generation-resume.ts
|
|
7
|
-
var
|
|
8
|
+
var c = (e) => {
|
|
8
9
|
let t = e.custom_content;
|
|
9
10
|
return !!e.content || e.responseId != null || !!t?.attachments?.length || !!t?.stages?.length || !!t?.annotations?.length || !!t?.form_schema || t?.state != null;
|
|
10
|
-
}, o = (e) => {
|
|
11
|
+
}, l = (e) => e.messages.findIndex((e) => e.backgroundGeneration?.status === o.Pending), u = (e) => {
|
|
12
|
+
if (l(e) !== -1) return !0;
|
|
11
13
|
let t = e.messages[e.messages.length - 1];
|
|
12
|
-
return !!t && t.role ===
|
|
13
|
-
},
|
|
14
|
+
return !!t && t.role === s.Assistant && !c(t) && t.streamErrorMessage == null && !t.wasStoppedByUser;
|
|
15
|
+
}, d = 300 * 1e3, f = "awaiting-resume", p = [
|
|
16
|
+
1e3,
|
|
17
|
+
2e3,
|
|
18
|
+
4e3,
|
|
19
|
+
8e3,
|
|
20
|
+
16e3
|
|
21
|
+
], m = (e) => new Promise((t) => {
|
|
22
|
+
let n = typeof window < "u", r = () => {
|
|
23
|
+
clearTimeout(i), n && window.removeEventListener("online", r), t();
|
|
24
|
+
}, i = setTimeout(r, e);
|
|
25
|
+
n && window.addEventListener("online", r);
|
|
26
|
+
}), h = async (e, t, n) => {
|
|
27
|
+
for (let r = 0; r <= p.length; r++) {
|
|
28
|
+
if (t()) return null;
|
|
29
|
+
try {
|
|
30
|
+
let t = await e();
|
|
31
|
+
if (!n?.(t)) return t;
|
|
32
|
+
} catch {}
|
|
33
|
+
if (r === p.length) return null;
|
|
34
|
+
await m(p[r]);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}, g = async (e, t) => {
|
|
14
38
|
let n = e.getReader(), r = new TextDecoder(), i = "";
|
|
15
39
|
try {
|
|
16
40
|
for (;;) {
|
|
@@ -39,88 +63,122 @@ var a = (e) => {
|
|
|
39
63
|
} catch {} finally {
|
|
40
64
|
n.releaseLock();
|
|
41
65
|
}
|
|
42
|
-
},
|
|
43
|
-
if (!
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
}, _ = ({ transport: o, setConversation: s, conversationRef: p, resumingPathsRef: m, bufferedGenerationsRef: h, addStreamingPath: _, removeStreamingPath: v, isPathDisplayed: y, generationPersistenceErrorMessage: b = t, frameScheduler: x, stoppedGenerationIdsRef: S, onReloadError: C, onReloadSuccess: w }) => (t, T, E = {}) => {
|
|
67
|
+
if (!u(T)) {
|
|
68
|
+
E.onSettled?.();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
let D = r(t);
|
|
72
|
+
if (!E.skipDedupe && m.current.has(D)) return;
|
|
73
|
+
m.current.add(D), _(D);
|
|
74
|
+
let O = l(T), k = O !== -1, A = k ? O : T.messages.length - 1, j = {
|
|
75
|
+
generationId: f,
|
|
76
|
+
messageIndex: A,
|
|
77
|
+
message: E.seedMessage ?? T.messages[A]
|
|
78
|
+
};
|
|
79
|
+
h.current.set(D, j);
|
|
80
|
+
let M = () => h.current.get(D) === j, N = k ? T.messages[A].backgroundGeneration?.generationId : void 0, P = () => N != null && (S?.current.has(N) ?? !1), F = (e, t = !1) => {
|
|
81
|
+
if (x?.flush(D), N != null && S?.current.delete(N), !M()) return;
|
|
82
|
+
m.current.delete(D), v(D);
|
|
83
|
+
let n = !k && e && e.messages.length - 1 === A && u(e) && c(j.message);
|
|
84
|
+
if (t || n) {
|
|
85
|
+
j.message = {
|
|
86
|
+
...j.message,
|
|
87
|
+
streamErrorMessage: b
|
|
88
|
+
}, y(D) && s((e) => {
|
|
89
|
+
if (!e || !M() || !y(D)) return e;
|
|
90
|
+
let t = a(e, j);
|
|
91
|
+
return p.current = t, t;
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
h.current.delete(D), e && y(D) && (s(e), p.current = e);
|
|
96
|
+
}, I = async () => {
|
|
97
|
+
if (M()) try {
|
|
98
|
+
let n = await o.getConversation(e(t));
|
|
99
|
+
if (!M()) return;
|
|
100
|
+
w?.(D), F(n);
|
|
52
101
|
} catch {
|
|
53
|
-
|
|
102
|
+
if (!M()) return;
|
|
103
|
+
x?.flush(D), m.current.delete(D), v(D), N != null && S?.current.delete(N), C?.(D, I, M);
|
|
54
104
|
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let t =
|
|
68
|
-
if (t
|
|
69
|
-
|
|
70
|
-
|
|
105
|
+
}, L = (e) => {
|
|
106
|
+
x?.cancel(D), M() && (j.message = e, y(D) && s((e) => {
|
|
107
|
+
if (!e || !M() || !y(D)) return e;
|
|
108
|
+
let t = a(e, j);
|
|
109
|
+
return p.current = t, t;
|
|
110
|
+
}));
|
|
111
|
+
}, R = () => s((e) => {
|
|
112
|
+
if (!e || !M() || !y(D)) return e;
|
|
113
|
+
let t = a(e, j);
|
|
114
|
+
return p.current = t, t;
|
|
115
|
+
}), z = (e) => {
|
|
116
|
+
if (!M() || P()) return;
|
|
117
|
+
let t = i([j.message], 0, e);
|
|
118
|
+
if (t && (j.message = t[0]), y(D)) {
|
|
119
|
+
if (x) {
|
|
120
|
+
x.schedule(D, R);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
R();
|
|
71
124
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let t = f.current.get(v);
|
|
75
|
-
if (t?.generationId !== c) return e;
|
|
76
|
-
let n = r(e, t);
|
|
77
|
-
return u.current = n, n;
|
|
78
|
-
});
|
|
79
|
-
}, w = async () => {
|
|
80
|
-
let t = new AbortController(), n;
|
|
125
|
+
}, B = async () => {
|
|
126
|
+
let n = new AbortController(), r;
|
|
81
127
|
try {
|
|
82
|
-
|
|
128
|
+
r = await o.watchConversation(D, n.signal);
|
|
83
129
|
} catch {
|
|
84
|
-
await
|
|
130
|
+
await I();
|
|
85
131
|
return;
|
|
86
132
|
}
|
|
87
|
-
let r = !1, a = window.setTimeout(() => {
|
|
88
|
-
t.abort();
|
|
89
|
-
}, s);
|
|
90
133
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
134
|
+
let i = await o.getConversation(e(t));
|
|
135
|
+
if (!u(i)) {
|
|
136
|
+
n.abort(), r.cancel().catch(() => void 0), F(i);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
} catch {}
|
|
140
|
+
let i = !1, a = window.setTimeout(() => {
|
|
141
|
+
n.abort();
|
|
142
|
+
}, d);
|
|
143
|
+
try {
|
|
144
|
+
await g(r, async (n) => {
|
|
145
|
+
if (n?.action !== "UPDATE") return !1;
|
|
93
146
|
try {
|
|
94
|
-
let
|
|
95
|
-
if (!
|
|
147
|
+
let n = await o.getConversation(e(t));
|
|
148
|
+
if (!u(n)) return F(n), i = !0, !0;
|
|
96
149
|
} catch {}
|
|
97
150
|
return !1;
|
|
98
151
|
});
|
|
99
152
|
} finally {
|
|
100
153
|
clearTimeout(a);
|
|
101
154
|
}
|
|
102
|
-
|
|
103
|
-
},
|
|
155
|
+
i || await I();
|
|
156
|
+
}, V = async () => {
|
|
104
157
|
let e = new AbortController(), t;
|
|
105
158
|
try {
|
|
106
|
-
t = await
|
|
159
|
+
t = await o.attachToGeneration(D, e.signal);
|
|
107
160
|
} catch {
|
|
108
161
|
return !1;
|
|
109
162
|
}
|
|
110
|
-
let
|
|
111
|
-
return await
|
|
163
|
+
let r = !1, i = !1;
|
|
164
|
+
return await g(t, (e) => {
|
|
165
|
+
if (!M()) return !0;
|
|
112
166
|
switch (e.type) {
|
|
113
|
-
case "snapshot": return
|
|
114
|
-
case "chunk": return
|
|
167
|
+
case "snapshot": return L(e.message), !1;
|
|
168
|
+
case "chunk": return z(e.chunk), !1;
|
|
115
169
|
case "done":
|
|
116
170
|
case "error":
|
|
117
|
-
case "stopped": return n = !0, !0;
|
|
171
|
+
case "stopped": return i = e.type === "error" && e.errorType === n.type, r = !0, !0;
|
|
118
172
|
}
|
|
119
|
-
}),
|
|
173
|
+
}), r ? (i ? F(void 0, !0) : await I(), !0) : !M();
|
|
120
174
|
};
|
|
121
175
|
(async () => {
|
|
122
|
-
|
|
176
|
+
try {
|
|
177
|
+
await V() || await B();
|
|
178
|
+
} finally {
|
|
179
|
+
E.onSettled?.();
|
|
180
|
+
}
|
|
123
181
|
})();
|
|
124
182
|
};
|
|
125
183
|
//#endregion
|
|
126
|
-
export {
|
|
184
|
+
export { _ as createResumeIfAwaitingGeneration, h as fetchConversationForRecovery, l as findPendingBackgroundMessageIndex, c as hasGeneratedPayload, u as isAwaitingGenerationResume };
|