@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
|
@@ -41,30 +41,41 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
|
|
|
41
41
|
_,
|
|
42
42
|
E
|
|
43
43
|
]), F = u((e) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
let t = y.current;
|
|
45
|
+
if (g || !m || !t || e === -1 || t.messages[e]?.role !== c.Assistant) return;
|
|
46
|
+
let n = t.messages[e - 1];
|
|
47
|
+
if (!n || n.role !== c.User) return;
|
|
48
|
+
let i = C(), a = r(E) ? {
|
|
49
|
+
...n.custom_content,
|
|
50
|
+
configuration_value: E
|
|
51
|
+
} : n.custom_content, o = {
|
|
52
|
+
...t.messages[e],
|
|
49
53
|
content: "",
|
|
50
54
|
custom_content: void 0,
|
|
51
55
|
wasStoppedByUser: void 0,
|
|
52
56
|
stoppedWithoutContent: void 0,
|
|
53
57
|
streamErrorMessage: void 0,
|
|
54
|
-
deploymentId:
|
|
55
|
-
},
|
|
56
|
-
...
|
|
57
|
-
messages: [
|
|
58
|
+
deploymentId: i
|
|
59
|
+
}, s = {
|
|
60
|
+
...t,
|
|
61
|
+
messages: [
|
|
62
|
+
...t.messages.slice(0, e - 1),
|
|
63
|
+
{
|
|
64
|
+
...n,
|
|
65
|
+
custom_content: a
|
|
66
|
+
},
|
|
67
|
+
o
|
|
68
|
+
]
|
|
58
69
|
};
|
|
59
|
-
y.current =
|
|
70
|
+
y.current = s, v(s), A((t) => new Set([...t].filter((t) => t < e))), _(m, n.content, e, i, a, l(), f.Regenerate);
|
|
60
71
|
}, [
|
|
61
|
-
p,
|
|
62
72
|
m,
|
|
63
73
|
y,
|
|
64
74
|
g,
|
|
65
75
|
C,
|
|
66
76
|
v,
|
|
67
|
-
_
|
|
77
|
+
_,
|
|
78
|
+
E
|
|
68
79
|
]), I = u((e) => {
|
|
69
80
|
g || O(e);
|
|
70
81
|
}, [g]), L = u(() => {
|
|
@@ -94,54 +105,59 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
|
|
|
94
105
|
D,
|
|
95
106
|
v
|
|
96
107
|
]), R = u(async (e, t, n) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
let r = y.current;
|
|
109
|
+
if (!m || !r) return !1;
|
|
110
|
+
let i = r.messages[e];
|
|
111
|
+
if (!i) return !1;
|
|
112
|
+
let a = i.rating, o = {
|
|
113
|
+
...r,
|
|
114
|
+
messages: r.messages.map((n, r) => r === e ? {
|
|
103
115
|
...n,
|
|
104
116
|
rating: t ?? void 0
|
|
105
117
|
} : n)
|
|
106
118
|
};
|
|
107
|
-
v(() => (y.current =
|
|
108
|
-
let
|
|
109
|
-
v((t) =>
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
v(() => (y.current = o, o));
|
|
120
|
+
let c = s(m), l = () => {
|
|
121
|
+
v((t) => {
|
|
122
|
+
if (!t) return t;
|
|
123
|
+
let n = {
|
|
112
124
|
...t,
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
messages: t.messages.map((t, n) => n === e ? {
|
|
126
|
+
...t,
|
|
127
|
+
rating: a
|
|
128
|
+
} : t)
|
|
129
|
+
};
|
|
130
|
+
return y.current = n, n;
|
|
115
131
|
});
|
|
116
|
-
},
|
|
117
|
-
path:
|
|
118
|
-
saveConversationBodyDto: { conversation:
|
|
119
|
-
}),
|
|
120
|
-
if (!
|
|
132
|
+
}, u = () => x.saveConversation({
|
|
133
|
+
path: c,
|
|
134
|
+
saveConversationBodyDto: { conversation: o }
|
|
135
|
+
}), d = i.responseId;
|
|
136
|
+
if (!d) return l(), !1;
|
|
121
137
|
try {
|
|
122
138
|
return await S.rateMessage({ rateMessageDto: {
|
|
123
|
-
conversationId:
|
|
124
|
-
responseId:
|
|
125
|
-
modelId:
|
|
139
|
+
conversationId: r.id,
|
|
140
|
+
responseId: d,
|
|
141
|
+
modelId: r.model.id,
|
|
126
142
|
rate: t,
|
|
127
143
|
...n ? { comment: n } : {}
|
|
128
|
-
} }), await
|
|
144
|
+
} }), await u(), !0;
|
|
129
145
|
} catch {
|
|
130
|
-
return
|
|
146
|
+
return l(), !1;
|
|
131
147
|
}
|
|
132
148
|
}, [
|
|
133
|
-
p,
|
|
134
149
|
m,
|
|
135
150
|
y,
|
|
136
151
|
x,
|
|
137
152
|
S,
|
|
138
153
|
v
|
|
139
154
|
]), z = u((e, t, i) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
...d ? {
|
|
144
|
-
|
|
155
|
+
let s = y.current;
|
|
156
|
+
if (!m || !s) return;
|
|
157
|
+
let c = a(e, i), u = o(e, i), d = t ? { [t]: e.const } : void 0, p = r(E), h = d || p ? {
|
|
158
|
+
...d ? { form_value: d } : {},
|
|
159
|
+
...p ? { configuration_value: E } : {}
|
|
160
|
+
} : void 0, g = C(), { userMessage: b, assistantMessage: x } = n(c, h, g);
|
|
145
161
|
v((e) => {
|
|
146
162
|
if (!e) return e;
|
|
147
163
|
let t = {
|
|
@@ -153,9 +169,8 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
|
|
|
153
169
|
]
|
|
154
170
|
};
|
|
155
171
|
return y.current = t, t;
|
|
156
|
-
}), _(m,
|
|
172
|
+
}), _(m, u, s.messages.length + 1, g, h, l(), f.Append);
|
|
157
173
|
}, [
|
|
158
|
-
p,
|
|
159
174
|
m,
|
|
160
175
|
y,
|
|
161
176
|
C,
|
|
@@ -171,14 +186,15 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
|
|
|
171
186
|
handleConfirmDelete: L,
|
|
172
187
|
handleRateMessage: R,
|
|
173
188
|
handleButtonSelect: u((e, t, n) => {
|
|
174
|
-
|
|
189
|
+
let r = y.current;
|
|
190
|
+
!m || !r || g || (e["dial:widgetOptions"].confirmationMessage ? M({
|
|
175
191
|
starter: e,
|
|
176
192
|
propertyKey: t,
|
|
177
193
|
description: n
|
|
178
194
|
}) : z(e, t, n));
|
|
179
195
|
}, [
|
|
180
|
-
p,
|
|
181
196
|
m,
|
|
197
|
+
y,
|
|
182
198
|
g,
|
|
183
199
|
z
|
|
184
200
|
]),
|
|
@@ -197,28 +213,29 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
|
|
|
197
213
|
});
|
|
198
214
|
}, []),
|
|
199
215
|
handleEditMessage: u(async (e, n, r, a, o) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
216
|
+
let s = y.current;
|
|
217
|
+
if (g || !m || !s) return;
|
|
218
|
+
let u = e;
|
|
219
|
+
if (u === -1 || s.messages[u].role !== c.User) return;
|
|
220
|
+
let d = s.messages[u];
|
|
221
|
+
if (!i(s.messages, u, n, r, a, o)) {
|
|
205
222
|
A((e) => {
|
|
206
223
|
let t = new Set(e);
|
|
207
|
-
return t.delete(
|
|
224
|
+
return t.delete(u), t;
|
|
208
225
|
});
|
|
209
226
|
return;
|
|
210
227
|
}
|
|
211
|
-
let
|
|
228
|
+
let p = t(a), h = new Set(r.map((e) => e.id)), b = [...(d.custom_content?.attachments ?? []).filter((e) => {
|
|
212
229
|
let t = e.url ?? e.data ?? e.title;
|
|
213
230
|
return h.has(t);
|
|
214
|
-
}), ...
|
|
231
|
+
}), ...p ?? []], { attachments: x, skills: S, ...w } = d.custom_content ?? {}, T = o ?? S, E;
|
|
215
232
|
E = b.length > 0 || T?.length ? {
|
|
216
233
|
...w,
|
|
217
234
|
...b.length > 0 ? { attachments: b } : {},
|
|
218
235
|
...T?.length ? { skills: T } : {}
|
|
219
236
|
} : Object.keys(w).length > 0 ? w : void 0;
|
|
220
237
|
let D = {
|
|
221
|
-
...
|
|
238
|
+
...d,
|
|
222
239
|
content: n,
|
|
223
240
|
custom_content: E
|
|
224
241
|
}, O = Date.now(), k = {
|
|
@@ -226,18 +243,17 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
|
|
|
226
243
|
content: "",
|
|
227
244
|
timestamp: new Date(O).toISOString()
|
|
228
245
|
}, j = [
|
|
229
|
-
...
|
|
246
|
+
...s.messages.slice(0, u),
|
|
230
247
|
D,
|
|
231
248
|
k
|
|
232
249
|
], M = {
|
|
233
|
-
...
|
|
250
|
+
...s,
|
|
234
251
|
messages: j
|
|
235
252
|
};
|
|
236
253
|
y.current = M, v(M);
|
|
237
254
|
let N = C();
|
|
238
255
|
_(m, n, j.length - 1, N, E, l(), f.Edit), A(/* @__PURE__ */ new Set());
|
|
239
256
|
}, [
|
|
240
|
-
p,
|
|
241
257
|
m,
|
|
242
258
|
y,
|
|
243
259
|
g,
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { formatDateYM as e } from "../conversation-transfer/date.js";
|
|
2
2
|
import { ConversationTransferWarningCode as t } from "../conversation-transfer/types.js";
|
|
3
|
-
import { UnsupportedImportFormatError as n,
|
|
4
|
-
import { createUploadPathAllocator as
|
|
5
|
-
import { runWithConcurrency as
|
|
6
|
-
import { ConversationTransferKind as
|
|
7
|
-
import { useConversationTransferQueue as
|
|
8
|
-
import { parseDialArchive as
|
|
9
|
-
import { ConversationTransferErrorCode as
|
|
10
|
-
import { useCallback as
|
|
3
|
+
import { UnsupportedImportFormatError as n, dropForeignAttachmentRefs as r, getFolderBreadcrumb as i, parseImportEnvelope as a, planAttachmentUploads as o, rebaseConversationId as s, rewriteAttachmentUrls as c } from "../conversation-transfer/import-conversation.js";
|
|
4
|
+
import { createUploadPathAllocator as l } from "../conversation-transfer/build-upload-path.js";
|
|
5
|
+
import { runWithConcurrency as u } from "../conversation-transfer/async.js";
|
|
6
|
+
import { ConversationTransferKind as d, ConversationTransferPhase as f, buildTransferProgress as p } from "../conversation-transfer/progress.js";
|
|
7
|
+
import { useConversationTransferQueue as m } from "../conversation-transfer/queue.js";
|
|
8
|
+
import { parseDialArchive as h } from "../conversation-transfer/zip-import.js";
|
|
9
|
+
import { ConversationTransferErrorCode as g, ConversationTransferSubjectKind as _, ConversationTransferUnitKind as v, generateUUID as y } from "@epam/ai-dial-chat-shared";
|
|
10
|
+
import { useCallback as b } from "react";
|
|
11
11
|
//#region src/conversation/useConversationImport/useConversationImport.ts
|
|
12
|
-
var
|
|
12
|
+
var x = 5, S = 5, C = (e) => /\.(dial|zip)$/i.test(e.name), w = (e) => new Promise((t, n) => {
|
|
13
13
|
let r = new FileReader();
|
|
14
14
|
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsText(e);
|
|
15
|
-
}),
|
|
16
|
-
if (
|
|
17
|
-
let { envelope: t, attachments: n } = await
|
|
15
|
+
}), T = async (e) => {
|
|
16
|
+
if (C(e)) {
|
|
17
|
+
let { envelope: t, attachments: n } = await h(e);
|
|
18
18
|
return {
|
|
19
19
|
history: t.history,
|
|
20
20
|
attachments: n,
|
|
@@ -22,15 +22,15 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
return {
|
|
25
|
-
history:
|
|
25
|
+
history: a(await w(e)).history,
|
|
26
26
|
attachments: /* @__PURE__ */ new Map(),
|
|
27
27
|
isArchive: !1
|
|
28
28
|
};
|
|
29
|
-
},
|
|
30
|
-
let { plan:
|
|
29
|
+
}, E = async (e, t, n, r, i, a, s, c) => {
|
|
30
|
+
let { plan: l, skippedNames: d } = o(e, t, r), f = !1, p = await u(l, x, async (e) => {
|
|
31
31
|
if (c.aborted || f) return;
|
|
32
32
|
let t = e.allocated;
|
|
33
|
-
for (let
|
|
33
|
+
for (let o = 0; o <= S; o += 1) try {
|
|
34
34
|
let r = new File([new Uint8Array(e.bytes)], t.fileName), a = await i.uploadFile({
|
|
35
35
|
bucket: n,
|
|
36
36
|
path: t.path,
|
|
@@ -45,11 +45,11 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
|
|
|
45
45
|
};
|
|
46
46
|
} catch (n) {
|
|
47
47
|
if (c.aborted) return;
|
|
48
|
-
if (
|
|
48
|
+
if (a(n)) {
|
|
49
49
|
f = !0;
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) ||
|
|
52
|
+
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || o === S) return s(), {
|
|
53
53
|
kind: "skipped",
|
|
54
54
|
name: e.originalFileName
|
|
55
55
|
};
|
|
@@ -69,171 +69,173 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
|
|
|
69
69
|
skippedNames: c.aborted || f ? [] : h,
|
|
70
70
|
isUnauthorized: !c.aborted && f
|
|
71
71
|
};
|
|
72
|
-
},
|
|
73
|
-
let
|
|
74
|
-
if (!
|
|
75
|
-
|
|
72
|
+
}, D = ({ conversationsApi: a, filesApi: o, bucket: u, onImported: h, classifyTransferError: x = () => ({}), resolveErrorTraceId: S = async () => void 0, onSuccess: C, onWarning: w, onError: D }) => {
|
|
73
|
+
let O = m(), k = b(async (n, i, m) => {
|
|
74
|
+
if (!u) {
|
|
75
|
+
D?.({
|
|
76
76
|
jobId: n,
|
|
77
|
-
code:
|
|
78
|
-
}),
|
|
77
|
+
code: g.MissingBucket
|
|
78
|
+
}), O.failJob(n, g.MissingBucket);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
kind:
|
|
84
|
-
phase:
|
|
85
|
-
completed:
|
|
86
|
-
total:
|
|
81
|
+
let _ = d.Import, y = i.attachments.size, b = 0, T = () => {
|
|
82
|
+
b += 1, O.setJobProgress(n, p({
|
|
83
|
+
kind: _,
|
|
84
|
+
phase: f.Transfer,
|
|
85
|
+
completed: b,
|
|
86
|
+
total: y
|
|
87
87
|
}, {
|
|
88
|
-
completed: Math.min(
|
|
89
|
-
total:
|
|
90
|
-
kind:
|
|
88
|
+
completed: Math.min(b, y),
|
|
89
|
+
total: y,
|
|
90
|
+
kind: v.Attachment
|
|
91
91
|
}));
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
kind:
|
|
95
|
-
phase:
|
|
92
|
+
}, k = (e) => {
|
|
93
|
+
O.setJobProgress(n, p({
|
|
94
|
+
kind: _,
|
|
95
|
+
phase: f.Finalize,
|
|
96
96
|
completed: e,
|
|
97
|
-
total:
|
|
97
|
+
total: i.history.length
|
|
98
98
|
}, {
|
|
99
99
|
completed: e,
|
|
100
|
-
total:
|
|
101
|
-
kind:
|
|
100
|
+
total: i.history.length,
|
|
101
|
+
kind: v.Conversation
|
|
102
102
|
}));
|
|
103
|
-
},
|
|
104
|
-
if (
|
|
105
|
-
let t = `uploads/${e(
|
|
103
|
+
}, A = [], j = [], M = /* @__PURE__ */ new Set(), N = !1, P, F = /* @__PURE__ */ new Date(), I = (e) => !!x(e).isUnauthorized, L;
|
|
104
|
+
if (i.isArchive) {
|
|
105
|
+
let t = `uploads/${e(F)}`, r = [];
|
|
106
106
|
try {
|
|
107
|
-
r = (await
|
|
108
|
-
bucket:
|
|
107
|
+
r = (await o.listFiles({
|
|
108
|
+
bucket: u,
|
|
109
109
|
path: t
|
|
110
|
-
}, { signal:
|
|
110
|
+
}, { signal: m })).items.map((e) => e.name);
|
|
111
111
|
} catch (e) {
|
|
112
|
-
if (
|
|
113
|
-
if (
|
|
114
|
-
|
|
112
|
+
if (m.aborted) return;
|
|
113
|
+
if (I(e)) {
|
|
114
|
+
D?.({
|
|
115
115
|
jobId: n,
|
|
116
|
-
code:
|
|
117
|
-
}),
|
|
116
|
+
code: g.Unauthorized
|
|
117
|
+
}), O.failJob(n, g.Unauthorized);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
console.error("Failed to list the upload folder for attachment name disambiguation", e);
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
date:
|
|
122
|
+
L = l({
|
|
123
|
+
date: F,
|
|
124
124
|
existingNames: r
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
kind:
|
|
129
|
-
phase:
|
|
130
|
-
})),
|
|
131
|
-
kind:
|
|
132
|
-
phase:
|
|
127
|
+
O.setJobProgress(n, p({
|
|
128
|
+
kind: _,
|
|
129
|
+
phase: f.Prepare
|
|
130
|
+
})), y === 0 && O.setJobProgress(n, p({
|
|
131
|
+
kind: _,
|
|
132
|
+
phase: f.Transfer
|
|
133
133
|
}));
|
|
134
|
-
for (let e of
|
|
135
|
-
if (
|
|
136
|
-
if (
|
|
134
|
+
for (let e of i.history) {
|
|
135
|
+
if (m.aborted) return;
|
|
136
|
+
if (N) break;
|
|
137
137
|
try {
|
|
138
138
|
let t = /* @__PURE__ */ new Map();
|
|
139
|
-
if (
|
|
140
|
-
let n = await
|
|
141
|
-
if (
|
|
139
|
+
if (i.isArchive && L) {
|
|
140
|
+
let n = await E(e, i.attachments, u, L, o, I, T, m);
|
|
141
|
+
if (m.aborted) return;
|
|
142
142
|
if (n.isUnauthorized) {
|
|
143
|
-
|
|
143
|
+
N = !0;
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
|
-
for (let e of n.skippedNames)
|
|
146
|
+
for (let e of n.skippedNames) M.add(e);
|
|
147
147
|
t = n.targetMap;
|
|
148
148
|
}
|
|
149
|
-
let { conversation: n,
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
let { conversation: n, droppedNames: l } = r(c(e, t), u);
|
|
150
|
+
for (let e of l) M.add(e);
|
|
151
|
+
let { conversation: d, subPath: f } = s(n, u);
|
|
152
|
+
if (await a.saveConversation({
|
|
153
|
+
path: f,
|
|
152
154
|
saveConversationBodyDto: { conversation: {
|
|
153
|
-
...
|
|
155
|
+
...d,
|
|
154
156
|
llmNamingDone: !0
|
|
155
157
|
} }
|
|
156
|
-
}, { signal:
|
|
157
|
-
|
|
158
|
+
}, { signal: m }), m.aborted) return;
|
|
159
|
+
A.push(d.name);
|
|
158
160
|
} catch (t) {
|
|
159
|
-
if (
|
|
160
|
-
if (
|
|
161
|
-
|
|
161
|
+
if (m.aborted) return;
|
|
162
|
+
if (I(t)) {
|
|
163
|
+
N = !0;
|
|
162
164
|
break;
|
|
163
165
|
}
|
|
164
|
-
|
|
166
|
+
j.push(e.name), P === void 0 && (P = await S(t)), console.error("Failed to import a conversation", t);
|
|
165
167
|
}
|
|
166
|
-
|
|
168
|
+
k(A.length + j.length);
|
|
167
169
|
}
|
|
168
|
-
if (!
|
|
169
|
-
if (
|
|
170
|
-
|
|
170
|
+
if (!m.aborted) {
|
|
171
|
+
if (N) {
|
|
172
|
+
D?.({
|
|
171
173
|
jobId: n,
|
|
172
|
-
code:
|
|
173
|
-
}),
|
|
174
|
+
code: g.Unauthorized
|
|
175
|
+
}), O.failJob(n, g.Unauthorized);
|
|
174
176
|
return;
|
|
175
177
|
}
|
|
176
|
-
if (
|
|
178
|
+
if (A.length > 0) {
|
|
177
179
|
try {
|
|
178
|
-
await
|
|
180
|
+
await h?.();
|
|
179
181
|
} catch {}
|
|
180
|
-
|
|
182
|
+
C?.({
|
|
181
183
|
jobId: n,
|
|
182
|
-
titles:
|
|
184
|
+
titles: A
|
|
183
185
|
});
|
|
184
186
|
}
|
|
185
|
-
|
|
187
|
+
j.length > 0 && D?.({
|
|
186
188
|
jobId: n,
|
|
187
|
-
code:
|
|
188
|
-
titles:
|
|
189
|
-
traceId:
|
|
190
|
-
}),
|
|
189
|
+
code: g.Unknown,
|
|
190
|
+
titles: j,
|
|
191
|
+
traceId: P
|
|
192
|
+
}), M.size > 0 && w?.({
|
|
191
193
|
jobId: n,
|
|
192
194
|
code: t.AttachmentSkipped,
|
|
193
|
-
names: [...
|
|
194
|
-
}),
|
|
195
|
+
names: [...M]
|
|
196
|
+
}), j.length > 0 ? O.failJob(n, g.Unknown) : M.size > 0 ? O.warnJob(n, t.AttachmentSkipped, [...M]) : O.succeedJob(n);
|
|
195
197
|
}
|
|
196
198
|
}, [
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
i,
|
|
199
|
+
u,
|
|
200
|
+
x,
|
|
200
201
|
a,
|
|
201
|
-
|
|
202
|
-
m,
|
|
203
|
-
S,
|
|
204
|
-
C,
|
|
202
|
+
o,
|
|
205
203
|
D,
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
h,
|
|
205
|
+
C,
|
|
206
|
+
w,
|
|
207
|
+
O,
|
|
208
|
+
S
|
|
209
|
+
]), A = b(async (e) => {
|
|
208
210
|
let t;
|
|
209
211
|
try {
|
|
210
|
-
t = await
|
|
212
|
+
t = await T(e);
|
|
211
213
|
} catch (e) {
|
|
212
|
-
|
|
213
|
-
jobId:
|
|
214
|
-
code:
|
|
214
|
+
D?.({
|
|
215
|
+
jobId: y(),
|
|
216
|
+
code: g.UnsupportedFormat
|
|
215
217
|
}), e instanceof n || console.error("Failed to parse import file", e);
|
|
216
218
|
return;
|
|
217
219
|
}
|
|
218
|
-
let
|
|
219
|
-
kind:
|
|
220
|
+
let r = t.history.length > 1, a = t.history[0], o = r ? { kind: _.All } : {
|
|
221
|
+
kind: _.Single,
|
|
220
222
|
title: a?.name ?? e.name,
|
|
221
|
-
sourceBreadcrumb: a ?
|
|
222
|
-
}, s =
|
|
223
|
-
return
|
|
223
|
+
sourceBreadcrumb: a ? i(a) : void 0
|
|
224
|
+
}, s = O.addJob(o, e.name);
|
|
225
|
+
return O.startJob(s, (e) => k(s, t, e));
|
|
224
226
|
}, [
|
|
225
|
-
E,
|
|
226
227
|
D,
|
|
227
|
-
O
|
|
228
|
+
O,
|
|
229
|
+
k
|
|
228
230
|
]);
|
|
229
231
|
return {
|
|
230
|
-
jobs:
|
|
231
|
-
importConversations:
|
|
232
|
-
cancelJob:
|
|
233
|
-
dismissJob:
|
|
234
|
-
retryJob:
|
|
235
|
-
dismissAll:
|
|
232
|
+
jobs: O.jobs,
|
|
233
|
+
importConversations: A,
|
|
234
|
+
cancelJob: O.cancelJob,
|
|
235
|
+
dismissJob: O.dismissJob,
|
|
236
|
+
retryJob: O.retryJob,
|
|
237
|
+
dismissAll: O.dismissAll
|
|
236
238
|
};
|
|
237
239
|
};
|
|
238
240
|
//#endregion
|
|
239
|
-
export {
|
|
241
|
+
export { D as useConversationImport };
|
|
@@ -1,35 +1,53 @@
|
|
|
1
1
|
import { safeDecodeURIComponent as e } from "../../shared/string-utils.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useMemo as i } from "react";
|
|
2
|
+
import { getModelIdFromConversationId as t } from "../get-model-id-from-conversation-id.js";
|
|
3
|
+
import { FilterTab as n } from "@epam/ai-dial-chat-shared";
|
|
4
|
+
import { useEffect as r, useMemo as i, useRef as a } from "react";
|
|
6
5
|
//#region src/conversation/useConversationPanelItems/useConversationPanelItems.ts
|
|
7
|
-
var
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
6
|
+
var o = (e) => e.sharedWithMe ? n.Shared : e.publishedWithMe ? n.Organization : n.MyChats, s = (e) => {
|
|
7
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
8
|
+
for (let r of e) t.has(r.id) || t.set(r.id, r), r.reference && !n.has(r.reference) && n.set(r.reference, r);
|
|
9
|
+
return (e) => t.get(e) ?? n.get(e);
|
|
10
|
+
}, c = ({ items: n, deployments: c, isDeploymentsLoading: l, toPanelConversationId: u, resolveIconUrl: d, resolveIconTooltip: f, resolveHref: p, resolveTaskPresentation: m }) => {
|
|
11
|
+
let h = i(() => s(c), [c]), g = i(() => (n) => {
|
|
12
|
+
let r = u(n.id), i = t(n.id), a = i ? h(i) : void 0, s = i ? e(i.split("/").pop() ?? i) : "", c = m?.(n);
|
|
13
|
+
return {
|
|
14
|
+
id: r,
|
|
15
|
+
title: n.title,
|
|
16
|
+
isPinned: n.isPinned ?? !1,
|
|
17
|
+
iconUrl: d(a),
|
|
18
|
+
iconTooltip: f(a, s),
|
|
19
|
+
isIconLoading: l,
|
|
20
|
+
source: o(n),
|
|
21
|
+
href: p(r),
|
|
22
|
+
...c == null ? {} : {
|
|
23
|
+
leadingIcon: c.leadingIcon,
|
|
24
|
+
isUnread: c.isUnread
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, [
|
|
28
|
+
h,
|
|
29
|
+
l,
|
|
30
|
+
u,
|
|
31
|
+
d,
|
|
32
|
+
f,
|
|
33
|
+
p,
|
|
34
|
+
m
|
|
35
|
+
]), _ = a(null), v = i(() => {
|
|
36
|
+
let e = _.current, t = e?.mapItem === g ? e.byDto : void 0, r = /* @__PURE__ */ new Map();
|
|
37
|
+
return {
|
|
38
|
+
mapped: n.map((e) => {
|
|
39
|
+
let n = t?.get(e) ?? g(e);
|
|
40
|
+
return r.set(e, n), n;
|
|
41
|
+
}),
|
|
42
|
+
cache: {
|
|
43
|
+
mapItem: g,
|
|
44
|
+
byDto: r
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}, [n, g]);
|
|
48
|
+
return r(() => {
|
|
49
|
+
_.current = v.cache;
|
|
50
|
+
}, [v]), v.mapped;
|
|
51
|
+
};
|
|
34
52
|
//#endregion
|
|
35
|
-
export {
|
|
53
|
+
export { o as getConversationSource, c as useConversationPanelItems };
|