@epam/ai-dial-chat-hooks 1.1.0-dev.422 → 1.1.0-dev.426
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-DuLNy43N.js → api-error/api-error.js} +1 -1
- package/api-transport/create-csrf-middleware.js +21 -0
- package/api-transport/create-unauthorized-middleware.js +41 -0
- package/attachment/useAttachmentAction/useAttachmentAction.js +74 -0
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +35 -0
- package/attachments.js +3 -2
- package/catalog/catalog-derivations.js +10 -0
- package/catalog/catalog-primary-action.js +21 -0
- package/catalog/create-publish-api.js +27 -0
- package/catalog/deployment-endpoint-url.js +34 -0
- package/{deployment-id-CxWgJTs9.js → catalog/deployment-id.js} +1 -1
- package/catalog/entity-details.js +6 -0
- package/catalog/map-deployment-limits-to-catalog.js +73 -0
- package/catalog/map-deployment-limits-to-input.js +14 -0
- package/catalog/map-deployment-to-catalog-item.js +92 -0
- package/catalog/map-entity-details-to-catalog.js +350 -0
- package/catalog/map-prompt-to-catalog-item.js +49 -0
- package/catalog/map-skill-to-catalog-item.js +123 -0
- package/catalog/mcp-endpoint-url.js +26 -0
- package/catalog/publish.js +18 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +109 -0
- package/catalog/useCatalogItemDetails.js +101 -0
- package/catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js +146 -0
- package/catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js +50 -0
- package/catalog/usePublishFolders/usePublishFolders.js +72 -0
- package/catalog.js +22 -3
- package/conversation/announcement-message.js +42 -0
- package/conversation/conversation-transfer/async.js +18 -0
- package/conversation/conversation-transfer/attachment-refs.js +11 -0
- package/conversation/conversation-transfer/build-upload-path.js +27 -0
- package/{date-BeuD8G79.js → conversation/conversation-transfer/date.js} +1 -1
- package/conversation/conversation-transfer/dial-file-resolve.js +18 -0
- package/conversation/conversation-transfer/export-conversation.js +32 -0
- package/conversation/conversation-transfer/import-conversation.js +93 -0
- package/conversation/conversation-transfer/progress.js +39 -0
- package/conversation/conversation-transfer/queue.js +84 -0
- package/conversation/conversation-transfer/types.js +9 -0
- package/conversation/conversation-transfer/zip-export.js +19 -0
- package/conversation/conversation-transfer/zip-import.js +29 -0
- package/conversation/create-chat-stream-api.js +96 -0
- package/conversation/deriveConversationRowActionState/deriveConversationRowActionState.js +14 -0
- package/conversation/display-name-watch.js +5 -0
- package/conversation/footer-message.js +23 -0
- package/conversation/get-model-id-from-conversation-id.js +14 -0
- package/conversation/greeting.js +7 -0
- package/conversation/message-factory.js +19 -0
- package/conversation/message-utils.js +13 -0
- package/conversation/overlay-messages.js +8 -0
- package/conversation/quick-app-conversation-starters.js +29 -0
- package/conversation/starter-option.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +19 -0
- package/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js +39 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +33 -0
- package/conversation/useConversationExport/useConversationExport.js +285 -0
- package/conversation/useConversationHandlers/attachment-to-dto.js +13 -0
- package/conversation/useConversationHandlers/message-factory.js +21 -0
- package/conversation/useConversationHandlers/message-utils.js +8 -0
- package/conversation/useConversationHandlers/starter-option.js +11 -0
- package/conversation/useConversationHandlers/useConversationHandlers.js +263 -0
- package/conversation/useConversationImport/useConversationImport.js +239 -0
- package/conversation/useConversationLookupMaps/useConversationLookupMaps.js +11 -0
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +35 -0
- package/{useConversationScroll-CliIMnjP.js → conversation/useConversationScroll/useConversationScroll.js} +1 -1
- package/conversation/useConversationStream/apply-chunk.js +78 -0
- package/conversation/useConversationStream/buffered-generation.js +18 -0
- package/conversation/useConversationStream/conversation-path.js +8 -0
- package/conversation/useConversationStream/generation-resume.js +126 -0
- package/conversation/useConversationStream/useConversationStream.js +148 -0
- package/conversation/useImportFilePicker/useImportFilePicker.js +20 -0
- package/conversation/useTranscribeAudio/audio-transcription-error.js +12 -0
- package/conversation/useTranscribeAudio/transcription-retry.js +38 -0
- package/conversation/useTranscribeAudio/useTranscribeAudio.js +41 -0
- package/{useConversationSources-DKaKvjXZ.js → conversation-sources/useConversationSources/useConversationSources.js} +1 -1
- package/conversation-sources.js +1 -1
- package/conversation-transfer.js +7 -3
- package/conversation.d.ts +66 -0
- package/conversation.js +31 -2
- package/file-manager.d.ts +3 -4
- package/file-manager.js +28 -3
- package/files/annotation.js +15 -0
- package/files/attachment-canvas.js +218 -0
- package/files/attachment-dto-to-display.js +15 -0
- package/files/attachment-types.js +16 -0
- package/files/create-files-api.js +40 -0
- package/files/create-upload-file-with-progress.js +42 -0
- package/files/dial-file-manager-copy-move.util.js +55 -0
- package/files/dial-file-manager-mapping.util.js +140 -0
- package/files/dial-file-manager-path.util.js +72 -0
- package/files/dial-file-manager.model.js +25 -0
- package/files/dial-file-manager.types.js +10 -0
- package/files/dial-file-to-attachment.js +37 -0
- package/files/dial-file.js +30 -0
- package/files/dial-files-api.js +6 -0
- package/files/download-destination.js +6 -0
- package/files/file-manager-variant.js +11 -0
- package/files/file-name.js +19 -0
- package/files/prepare-download-destination.js +24 -0
- package/files/resolve-dial-file-api-path.js +33 -0
- package/files/source-content.js +37 -0
- package/files/useDialFileListing/useDialFileListing.js +295 -0
- package/files/useDialFileManager/useDialFileManager.js +146 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +23 -0
- package/files/useDialFileMetadata/useDialFileMetadata.js +42 -0
- package/files/useDialFileMutations/useDialFileMutations.js +359 -0
- package/files/useDialFileSharing/useDialFileSharing.js +70 -0
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +156 -0
- package/index.d.ts +69 -4
- package/index.js +134 -28
- package/mcp-apps/mcp-apps-api-client.js +48 -0
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +26 -0
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +26 -0
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +71 -0
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +58 -0
- package/mcp-apps.js +6 -2
- package/oauth/authorize-url.js +12 -0
- package/oauth/handshake.js +65 -0
- package/oauth/popup.js +29 -0
- package/oauth/toolset-id.js +10 -0
- package/oauth/types.js +24 -0
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +94 -0
- package/oauth/useToolsetLogin/useToolsetLogin.js +73 -0
- package/oauth.js +9 -3
- package/package.json +35 -23
- package/prompt/export-prompt.js +28 -0
- package/prompt/prompt-resource.js +15 -0
- package/prompt/prompt.js +12 -0
- package/prompt/usePromptsState/usePromptsState.js +42 -0
- package/scheduled-task/scheduled-task-mapping.js +6 -0
- package/{scheduled-task-trigger-D9RZCk52.js → scheduled-task/scheduled-task-trigger.js} +39 -40
- package/scheduled-tasks.js +3 -2
- package/scroll-anchoring.js +1 -1
- package/shared/application-schema.js +4 -0
- package/shared/browser-timezone.js +10 -0
- package/{cron-weekday-B4w29eAC.js → shared/cron-weekday.js} +1 -1
- package/shared/custom-apps.js +30 -0
- package/shared/external-services.js +18 -0
- package/{formatting-CZyyxBG3.js → shared/formatting.js} +1 -1
- package/{prompt-resource-Bt1I-8ri.js → shared/locale.js} +2 -13
- package/{string-utils-iBi2Y55C.js → shared/string-utils.js} +1 -1
- package/shared/toolset-login-events.js +13 -0
- package/sharing.js +3 -3
- package/skill/skill-file-batch-validation.js +48 -0
- package/skill/skill-file-preview.js +15 -0
- package/skill/skill-manifest.js +70 -0
- package/skill/skill-types.js +15 -0
- package/skill/skill.js +48 -0
- package/skill/useSkillEditorLoad.js +103 -0
- package/skill/useSkillEditorSubmit.js +135 -0
- package/skill/useSkillFileActions.js +99 -0
- package/skill/useSkillFilePreview.js +29 -0
- package/{useSkillsState-BoLlwmzb.js → skill/useSkillsState/useSkillsState.js} +1 -1
- package/skill-editor.js +8 -3
- package/skills-state.js +1 -1
- package/source-content.d.ts +29 -0
- package/source-content.js +2 -0
- package/usage/useUsageData/useUsageData.js +32 -0
- package/useChatSettingsFormConfig/useChatSettingsFormConfig.js +74 -0
- package/{usePanelMaxWidth-BEZYuqF9.js → usePageFileDrag/usePageFileDrag.js} +1 -11
- package/usePanelMaxWidth/usePanelMaxWidth.js +8 -0
- package/{useShareLink-xkiaxATt.js → useShareLink/useShareLink.js} +1 -1
- package/{useShareRecipientsCount-BgwCLKY0.js → useShareRecipientsCount/useShareRecipientsCount.js} +1 -1
- package/useToolsMenu/useToolsMenu.js +50 -0
- package/useViewportWidth/useViewportWidth.js +12 -0
- package/utils.js +17 -7
- package/viewport-layout.js +4 -2
- package/attachment-types-AAoN9E95.js +0 -7760
- package/browser-Btsa0Lmr.js +0 -607
- package/skill-manifest-CeG6-WSK.js +0 -4056
- package/useAttachmentValidation-CkMTd5lA.js +0 -102
- package/useConversationImport-CDRs7JF1.js +0 -826
- package/useDialFileManagerTabConfig-CjI46lMo.js +0 -2291
- package/useOAuthCallbackCompletion-CvyTKLER.js +0 -93
- package/useOpenMcpAppCanvas-C7-AMseH.js +0 -207
- package/useSkillFileActions-B-VaGD20.js +0 -373
- package/useSkillFilePreview-B5o1n_0F.js +0 -1244
- package/useToolsMenu-zURpMEn1.js +0 -1882
- package/useToolsetLogin-B05m134e.js +0 -195
- package/useUsageData-D7BxloKZ.js +0 -201
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/conversation/conversation-transfer/progress.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.Prepare = "prepare", e.Transfer = "transfer", e.Finalize = "finalize", e;
|
|
4
|
+
}({}), t = /* @__PURE__ */ function(e) {
|
|
5
|
+
return e.ExportSingle = "exportSingle", e.ExportSingleWithAttachments = "exportSingleWithAttachments", e.ExportAll = "exportAll", e.Import = "import", e;
|
|
6
|
+
}({}), n = {
|
|
7
|
+
exportSingle: {
|
|
8
|
+
prepare: 20,
|
|
9
|
+
transfer: 0,
|
|
10
|
+
finalize: 80
|
|
11
|
+
},
|
|
12
|
+
exportSingleWithAttachments: {
|
|
13
|
+
prepare: 15,
|
|
14
|
+
transfer: 70,
|
|
15
|
+
finalize: 15
|
|
16
|
+
},
|
|
17
|
+
exportAll: {
|
|
18
|
+
prepare: 20,
|
|
19
|
+
transfer: 70,
|
|
20
|
+
finalize: 10
|
|
21
|
+
},
|
|
22
|
+
import: {
|
|
23
|
+
prepare: 10,
|
|
24
|
+
transfer: 70,
|
|
25
|
+
finalize: 20
|
|
26
|
+
}
|
|
27
|
+
}, r = [
|
|
28
|
+
"prepare",
|
|
29
|
+
"transfer",
|
|
30
|
+
"finalize"
|
|
31
|
+
], i = (e, t) => r.slice(0, r.indexOf(t)).reduce((t, n) => t + e[n], 0), a = ({ kind: e, phase: t, completed: r = 0, total: a = 0 }) => {
|
|
32
|
+
let o = n[e], s = a > 0 ? Math.min(r / a, 1) : 1, c = i(o, t) + o[t] * s;
|
|
33
|
+
return Math.round(Math.min(Math.max(c, 0), 100));
|
|
34
|
+
}, o = (e, t) => ({
|
|
35
|
+
percent: a(e),
|
|
36
|
+
units: t
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
39
|
+
export { t as ConversationTransferKind, e as ConversationTransferPhase, o as buildTransferProgress };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ConversationTransferJobStatus as e, generateUUID as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
|
|
3
|
+
//#region src/conversation/conversation-transfer/queue.ts
|
|
4
|
+
var o = () => {
|
|
5
|
+
let [o, s] = a([]), c = i(/* @__PURE__ */ new Map()), l = i(/* @__PURE__ */ new Map()), u = n((e, t) => {
|
|
6
|
+
s((n) => n.map((n) => n.id === e ? {
|
|
7
|
+
...n,
|
|
8
|
+
...t
|
|
9
|
+
} : n));
|
|
10
|
+
}, []), d = n((t, n) => {
|
|
11
|
+
s((r) => r.map((r) => r.id !== t || r.status !== e.InProgress || n.percent < r.progress.percent ? r : {
|
|
12
|
+
...r,
|
|
13
|
+
progress: n
|
|
14
|
+
}));
|
|
15
|
+
}, []), f = n((n, r) => {
|
|
16
|
+
let i = t();
|
|
17
|
+
return s((t) => [...t, {
|
|
18
|
+
id: i,
|
|
19
|
+
subject: n,
|
|
20
|
+
status: e.InProgress,
|
|
21
|
+
fileName: r,
|
|
22
|
+
progress: { percent: 0 }
|
|
23
|
+
}]), i;
|
|
24
|
+
}, []), p = n((t) => {
|
|
25
|
+
u(t, {
|
|
26
|
+
status: e.Success,
|
|
27
|
+
progress: { percent: 100 },
|
|
28
|
+
errorCode: void 0
|
|
29
|
+
});
|
|
30
|
+
}, [u]), m = n((t, n) => {
|
|
31
|
+
s((r) => r.map((r) => r.id !== t || r.status !== e.InProgress ? r : {
|
|
32
|
+
...r,
|
|
33
|
+
status: e.Warning,
|
|
34
|
+
progress: { percent: 100 },
|
|
35
|
+
errorCode: void 0,
|
|
36
|
+
warningCode: n
|
|
37
|
+
}));
|
|
38
|
+
}, []), h = n((t, n) => {
|
|
39
|
+
u(t, {
|
|
40
|
+
status: e.Failed,
|
|
41
|
+
errorCode: n
|
|
42
|
+
});
|
|
43
|
+
}, [u]), g = n((t) => {
|
|
44
|
+
c.current.get(t)?.abort(), c.current.delete(t), u(t, { status: e.Canceled });
|
|
45
|
+
}, [u]), _ = n((e) => {
|
|
46
|
+
c.current.get(e)?.abort(), c.current.delete(e), l.current.delete(e), s((t) => t.filter((t) => t.id !== e));
|
|
47
|
+
}, []), v = n((e) => {
|
|
48
|
+
l.current.get(e)?.();
|
|
49
|
+
}, []), y = n(() => {
|
|
50
|
+
for (let e of c.current.values()) e.abort();
|
|
51
|
+
c.current.clear(), l.current.clear(), s([]);
|
|
52
|
+
}, []), b = n((t, n) => {
|
|
53
|
+
let r = () => {
|
|
54
|
+
let e = new AbortController();
|
|
55
|
+
return c.current.set(t, e), n(e.signal);
|
|
56
|
+
};
|
|
57
|
+
return l.current.set(t, () => (u(t, {
|
|
58
|
+
status: e.InProgress,
|
|
59
|
+
progress: { percent: 0 },
|
|
60
|
+
errorCode: void 0
|
|
61
|
+
}), r())), r();
|
|
62
|
+
}, [u]);
|
|
63
|
+
return r(() => {
|
|
64
|
+
let e = c.current;
|
|
65
|
+
return () => {
|
|
66
|
+
for (let t of e.values()) t.abort();
|
|
67
|
+
};
|
|
68
|
+
}, []), {
|
|
69
|
+
jobs: o,
|
|
70
|
+
addJob: f,
|
|
71
|
+
updateJob: u,
|
|
72
|
+
setJobProgress: d,
|
|
73
|
+
succeedJob: p,
|
|
74
|
+
warnJob: m,
|
|
75
|
+
failJob: h,
|
|
76
|
+
cancelJob: g,
|
|
77
|
+
dismissJob: _,
|
|
78
|
+
retryJob: v,
|
|
79
|
+
dismissAll: y,
|
|
80
|
+
startJob: b
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { o as useConversationTransferQueue };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConversationTransferErrorCode as e, ConversationTransferWarningCode as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
//#region src/conversation/conversation-transfer/types.ts
|
|
3
|
+
var n = /* @__PURE__ */ function(e) {
|
|
4
|
+
return e.WithAttachments = "withAttachments", e.WithoutAttachments = "withoutAttachments", e;
|
|
5
|
+
}({}), r = /* @__PURE__ */ function(e) {
|
|
6
|
+
return e.SingleConversation = "chat_conversation", e.SingleConversationWithAttachments = "chat_with_attachments", e.AllConversationsHistory = "chat_conversations_history", e;
|
|
7
|
+
}({});
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as ConversationExportMode, e as ConversationTransferErrorCode, t as ConversationTransferWarningCode, r as ExportFileNameKind };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { strToU8 as e, zipSync as t } from "fflate";
|
|
2
|
+
//#region src/conversation/conversation-transfer/zip-export.ts
|
|
3
|
+
var n = e("", !0).constructor, r = (e) => e instanceof n ? e : new n(e), i = (e) => e.length > 0 && e.split("/").every((e) => e !== "" && e !== "." && e !== ".."), a = (n, a) => {
|
|
4
|
+
let o = [], s = { "conversation.json": r(e(JSON.stringify(n, null, 2))) };
|
|
5
|
+
for (let e of a) {
|
|
6
|
+
if (!i(e.path)) {
|
|
7
|
+
o.push(e.path);
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
s[`res/${e.path}`] = r(e.data);
|
|
11
|
+
}
|
|
12
|
+
let c = t(s);
|
|
13
|
+
return {
|
|
14
|
+
blob: new Blob([new Uint8Array(c)], { type: "application/zip" }),
|
|
15
|
+
skippedPaths: o
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { a as buildDialArchive, i as isValidArchivePath };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { UnsupportedImportFormatError as e, parseImportEnvelope as t } from "./import-conversation.js";
|
|
2
|
+
import { isValidArchivePath as n } from "./zip-export.js";
|
|
3
|
+
import { strFromU8 as r, unzipSync as i } from "fflate";
|
|
4
|
+
//#region src/conversation/conversation-transfer/zip-import.ts
|
|
5
|
+
var a = "conversation.json", o = /^conversations\/.*\.json$/, s = "res/", c = (e) => e.find((e) => e === a) ?? e.find((e) => o.test(e)) ?? e.find((e) => !e.includes("/") && e.toLowerCase().endsWith(".json")), l = (e) => new Promise((t, n) => {
|
|
6
|
+
let r = new FileReader();
|
|
7
|
+
r.onload = () => t(new Uint8Array(r.result)), r.onerror = () => n(r.error), r.readAsArrayBuffer(e);
|
|
8
|
+
}), u = async (a) => {
|
|
9
|
+
let o = await l(a), u;
|
|
10
|
+
try {
|
|
11
|
+
u = i(o);
|
|
12
|
+
} catch {
|
|
13
|
+
throw new e("Import file is not a valid archive");
|
|
14
|
+
}
|
|
15
|
+
let d = Object.keys(u), f = c(d);
|
|
16
|
+
if (!f) throw new e("Archive does not contain a readable conversation-JSON entry");
|
|
17
|
+
let p = t(r(u[f])), m = /* @__PURE__ */ new Map();
|
|
18
|
+
for (let e of d) {
|
|
19
|
+
if (e.endsWith("/") || !e.startsWith(s)) continue;
|
|
20
|
+
let t = e.slice(4);
|
|
21
|
+
!t || !n(t) || m.set(t, u[e]);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
envelope: p,
|
|
25
|
+
attachments: m
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { u as parseDialArchive };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//#region src/conversation/create-chat-stream-api.ts
|
|
2
|
+
var e = { "Content-Type": "application/json" }, t = (e, t, n) => {
|
|
3
|
+
let r = e.trim();
|
|
4
|
+
if (!r || r.startsWith(":") || !r.startsWith("data: ")) return;
|
|
5
|
+
let i = r.slice(6);
|
|
6
|
+
if (i !== "[DONE]") try {
|
|
7
|
+
let e = JSON.parse(i);
|
|
8
|
+
if (e.error) {
|
|
9
|
+
n(Error(e.error.message));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
t(e);
|
|
13
|
+
} catch {}
|
|
14
|
+
}, n = (n) => {
|
|
15
|
+
let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
|
|
16
|
+
return {
|
|
17
|
+
streamCompletion: (a, o, s, c, l, u, d, f, p) => {
|
|
18
|
+
let { onChunk: m, onComplete: h, onError: g, signal: _ } = c;
|
|
19
|
+
(async () => {
|
|
20
|
+
let c;
|
|
21
|
+
try {
|
|
22
|
+
let t = n.getTimezone?.();
|
|
23
|
+
c = await i(`${r}/completions`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
credentials: "include",
|
|
26
|
+
signal: _,
|
|
27
|
+
headers: {
|
|
28
|
+
...e,
|
|
29
|
+
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() },
|
|
30
|
+
...t ? { "X-Timezone": t } : {}
|
|
31
|
+
},
|
|
32
|
+
body: JSON.stringify({
|
|
33
|
+
path: a,
|
|
34
|
+
message: o ?? "",
|
|
35
|
+
model: s,
|
|
36
|
+
custom_content: l || {},
|
|
37
|
+
...u != null && { generationId: u },
|
|
38
|
+
...d != null && { mode: d },
|
|
39
|
+
...f != null && { messageIndex: f },
|
|
40
|
+
...p != null && { clientChannelId: p }
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (e instanceof Error && e.name === "AbortError") return;
|
|
45
|
+
g(e instanceof Error ? e : Error(String(e)));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let v = c.headers.get("x-csrf-token");
|
|
49
|
+
if (v && n.setCsrfToken(v), !c.ok) {
|
|
50
|
+
g(/* @__PURE__ */ Error(`Stream request failed with status ${c.status}`));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!c.body) {
|
|
54
|
+
g(/* @__PURE__ */ Error("No response body"));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
let y = c.body.getReader(), b = new TextDecoder(), x = "", S = !1, C = (e) => {
|
|
58
|
+
S = !0, g(e);
|
|
59
|
+
};
|
|
60
|
+
try {
|
|
61
|
+
for (;;) {
|
|
62
|
+
let { done: e, value: n } = await y.read();
|
|
63
|
+
if (e) {
|
|
64
|
+
x.trim() && t(x, m, C);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
x += b.decode(n, { stream: !0 });
|
|
68
|
+
let r = x.split("\n");
|
|
69
|
+
x = r.pop() ?? "";
|
|
70
|
+
for (let e of r) t(e, m, C);
|
|
71
|
+
}
|
|
72
|
+
S || h();
|
|
73
|
+
} catch (e) {
|
|
74
|
+
if (e instanceof Error && e.name === "AbortError") return;
|
|
75
|
+
g(e instanceof Error ? e : Error(String(e)));
|
|
76
|
+
} finally {
|
|
77
|
+
y.releaseLock();
|
|
78
|
+
}
|
|
79
|
+
})();
|
|
80
|
+
},
|
|
81
|
+
stopCompletion: async (t) => {
|
|
82
|
+
let a = await i(`${r}/completions/stop`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
credentials: "include",
|
|
85
|
+
headers: {
|
|
86
|
+
...e,
|
|
87
|
+
...n.getCsrfToken() == null ? {} : { "X-CSRF-Token": n.getCsrfToken() }
|
|
88
|
+
},
|
|
89
|
+
body: JSON.stringify(t)
|
|
90
|
+
}), o = a.headers.get("x-csrf-token");
|
|
91
|
+
if (o && n.setCsrfToken(o), !a.ok) throw Error(`stopCompletion failed: ${a.status}`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { n as createChatStreamApi };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RecipientsCountStatus as e } from "../../useShareRecipientsCount/useShareRecipientsCount.js";
|
|
2
|
+
//#region src/conversation/deriveConversationRowActionState/deriveConversationRowActionState.ts
|
|
3
|
+
var t = (t, n, r) => {
|
|
4
|
+
let i = !!(t.isReadonly || t.sharedWithMe || t.publishedWithMe), a = !i && n != null ? [...new Set(n.map((e) => e.folderPath.join("/")))] : [];
|
|
5
|
+
return {
|
|
6
|
+
isReadonly: i,
|
|
7
|
+
publishedFolders: a,
|
|
8
|
+
isRevokeVisible: r.status === e.Unknown || r.status === e.Resolved && (r.count ?? 0) > 0,
|
|
9
|
+
isPublishApplicable: a.length === 0,
|
|
10
|
+
isUnpublishApplicable: a.length > 0
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as deriveConversationRowActionState };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MessageRole as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
//#region src/conversation/display-name-watch.ts
|
|
3
|
+
var t = (t) => t.messages.filter((t) => t.role !== e.Status).length < 2 ? !1 : t.llmNamingDone !== !0;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { t as shouldWatchForDisplayNameUpdate };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import e from "dompurify";
|
|
2
|
+
//#region src/conversation/footer-message.ts
|
|
3
|
+
var t = {
|
|
4
|
+
ALLOWED_TAGS: [
|
|
5
|
+
"a",
|
|
6
|
+
"span",
|
|
7
|
+
"strong",
|
|
8
|
+
"u",
|
|
9
|
+
"em",
|
|
10
|
+
"br",
|
|
11
|
+
"p"
|
|
12
|
+
],
|
|
13
|
+
ALLOWED_ATTR: [
|
|
14
|
+
"href",
|
|
15
|
+
"target",
|
|
16
|
+
"rel"
|
|
17
|
+
]
|
|
18
|
+
}, n = (n) => e.sanitize(n, t), r = (e) => {
|
|
19
|
+
let t = e.trim();
|
|
20
|
+
return /^v/i.test(t) ? t : `v${t}`;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { r as formatAppVersion, n as sanitizeFooterHtml };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/conversation/get-model-id-from-conversation-id.ts
|
|
2
|
+
var e = "__", t = /[-+]/, n = /^\d+$/, r = ".scheduler", i = "applications", a = (e) => e ? e.split(t)[0].split(".").every((e) => n.test(e)) : !1, o = (t, n) => {
|
|
3
|
+
let [r, i] = t.split(e);
|
|
4
|
+
return n && a(i) ? [r, i].join(e) : r;
|
|
5
|
+
}, s = (t) => {
|
|
6
|
+
let n = t.split("/");
|
|
7
|
+
if (n.length < 3) return;
|
|
8
|
+
let a = n.slice(2), s = a[0] === r ? a.slice(2) : a, c = s.findIndex((t) => t.includes(e));
|
|
9
|
+
if (c === -1) return;
|
|
10
|
+
let l = s[c], u = s.slice(0, c).filter(Boolean), d = o(l, u[0] === i), f = [...u, d].filter(Boolean);
|
|
11
|
+
return f.length > 0 ? f.join("/") : void 0;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { s as getModelIdFromConversationId };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/conversation/greeting.ts
|
|
2
|
+
var e = (e, t, n) => {
|
|
3
|
+
let r = n != null && n.length > 0;
|
|
4
|
+
return e >= 5 && e <= 11 ? r ? t.morningWithName : t.morningNoName : e >= 12 && e <= 16 ? r ? t.afternoonWithName : t.afternoonNoName : e >= 17 && e <= 20 ? r ? t.eveningWithName : t.eveningNoName : r ? t.nightWithName : t.nightNoName;
|
|
5
|
+
};
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as getTimeOfDayGreeting };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MessageRole as e, StatusEvent as t, generateUUID as n } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
//#region src/conversation/message-factory.ts
|
|
3
|
+
var r = (r, i) => {
|
|
4
|
+
let a = {
|
|
5
|
+
event_type: t.ModelChanged,
|
|
6
|
+
previous_deployment_id: r,
|
|
7
|
+
new_deployment_id: i
|
|
8
|
+
};
|
|
9
|
+
return {
|
|
10
|
+
id: n(),
|
|
11
|
+
role: e.Status,
|
|
12
|
+
content: "",
|
|
13
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14
|
+
deploymentId: i,
|
|
15
|
+
custom_content: a
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { r as createDeploymentChangedMessage };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MessageRole as e, ResponseFormat as t, StatusEvent as n, isStatusMessage as r } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
//#region src/conversation/message-utils.ts
|
|
3
|
+
var i = (t, n, r, i) => i && n === r - 1 && t.role === e.Assistant, a = (e) => {
|
|
4
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
5
|
+
let i = e[t];
|
|
6
|
+
if (r(i) && i.custom_content?.event_type === n.ModelChanged) return i.custom_content.new_deployment_id;
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
}, o = (t) => t.role === e.Assistant && (t.custom_content?.stages?.length ?? 0) > 0, s = (t) => {
|
|
10
|
+
for (let n = t.length - 1; n >= 0; n--) if (t[n].role === e.User) return t[n].custom_content?.configuration_value;
|
|
11
|
+
}, c = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? t.PlainText : t.Markdown;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { a as getLastDeploymentId, s as getLastUserMessageToolConfiguration, i as isMessageStreaming, o as messageHasStages, c as normalizeResponseFormat };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region src/conversation/quick-app-conversation-starters.ts
|
|
2
|
+
var e = (e) => typeof e == "object" && !!e && !Array.isArray(e), t = (e) => {
|
|
3
|
+
if (typeof e == "string") return e.trim() || void 0;
|
|
4
|
+
}, n = (n) => {
|
|
5
|
+
if (!e(n) || !Array.isArray(n.starters)) return {
|
|
6
|
+
starters: [],
|
|
7
|
+
introText: void 0,
|
|
8
|
+
isChatMessageInputDisabled: !1
|
|
9
|
+
};
|
|
10
|
+
let r = n.autoSubmit !== !1;
|
|
11
|
+
return {
|
|
12
|
+
starters: n.starters.filter(e).map((e) => ({
|
|
13
|
+
title: t(e.title),
|
|
14
|
+
text: t(e.text)
|
|
15
|
+
})).filter((e) => e.title != null && e.text != null).map((e, t) => ({
|
|
16
|
+
const: t,
|
|
17
|
+
title: e.title,
|
|
18
|
+
"dial:widgetOptions": {
|
|
19
|
+
populateText: e.text,
|
|
20
|
+
submit: r,
|
|
21
|
+
confirmationMessage: null
|
|
22
|
+
}
|
|
23
|
+
})),
|
|
24
|
+
introText: t(n.introText),
|
|
25
|
+
isChatMessageInputDisabled: n.chatMessageInputDisabled === !0
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { n as getQuickAppConversationStarters };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/conversation/starter-option.ts
|
|
2
|
+
var e = (e) => e["dial:widgetOptions"].populateText || e.title, t = (e) => {
|
|
3
|
+
let t = e?.properties;
|
|
4
|
+
if (!t) return {
|
|
5
|
+
starters: [],
|
|
6
|
+
propertyKey: void 0,
|
|
7
|
+
description: void 0
|
|
8
|
+
};
|
|
9
|
+
let n;
|
|
10
|
+
if ("starter" in t ? n = "starter" : "button" in t && (n = "button"), !n) return {
|
|
11
|
+
starters: [],
|
|
12
|
+
propertyKey: void 0,
|
|
13
|
+
description: void 0
|
|
14
|
+
};
|
|
15
|
+
let r = t[n], i = r?.oneOf, a = typeof r?.description == "string" ? r.description : void 0;
|
|
16
|
+
return Array.isArray(i) ? {
|
|
17
|
+
starters: i,
|
|
18
|
+
propertyKey: n,
|
|
19
|
+
description: a
|
|
20
|
+
} : {
|
|
21
|
+
starters: [],
|
|
22
|
+
propertyKey: n,
|
|
23
|
+
description: a
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { e as getStarterPopulateText, t as getStartersFromSchema };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect as e, useMemo as t } from "react";
|
|
2
|
+
//#region src/conversation/useActiveConversationSync/useActiveConversationSync.ts
|
|
3
|
+
var n = ({ activeConversationId: n, items: r, refreshConversations: i, markConversationViewed: a, conversationIdsMatch: o, toPanelConversationId: s }) => {
|
|
4
|
+
let c = t(() => n ? s(n) : void 0, [n, s]);
|
|
5
|
+
return e(() => {
|
|
6
|
+
c && (r.some((e) => o(e.id, c)) || i());
|
|
7
|
+
}, [c, o]), e(() => {
|
|
8
|
+
if (!c) return;
|
|
9
|
+
let e = r.find((e) => o(e.id, c));
|
|
10
|
+
e && a(e.id);
|
|
11
|
+
}, [
|
|
12
|
+
c,
|
|
13
|
+
r,
|
|
14
|
+
a,
|
|
15
|
+
o
|
|
16
|
+
]), c;
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { n as useActiveConversationSync };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
//#region src/conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.ts
|
|
3
|
+
var i = () => {
|
|
4
|
+
let [i, a] = r(null), [o, s] = r(!1), [c, l] = r(null), u = n(null), d = n(!1), f = n(0), p = n(null), m = e((e, t) => {
|
|
5
|
+
let { activeElement: n } = document;
|
|
6
|
+
p.current = t ?? (n instanceof HTMLElement ? n : null), f.current += 1, u.current = e, d.current = !1, a(e), s(!1), l(null);
|
|
7
|
+
}, []);
|
|
8
|
+
t(() => {
|
|
9
|
+
if (i != null) return;
|
|
10
|
+
let e = p.current;
|
|
11
|
+
p.current = null, e?.isConnected && e.focus({ preventScroll: !0 });
|
|
12
|
+
}, [i]);
|
|
13
|
+
let h = e(() => {
|
|
14
|
+
f.current += 1, u.current = null, d.current = !1, a(null), l(null), s(!1);
|
|
15
|
+
}, []), g = e(async (e, t) => {
|
|
16
|
+
let n = u.current;
|
|
17
|
+
if (d.current || n == null) return;
|
|
18
|
+
let r = ++f.current;
|
|
19
|
+
d.current = !0, s(!0), l(null);
|
|
20
|
+
try {
|
|
21
|
+
if (await e(n), r !== f.current) return;
|
|
22
|
+
u.current = null, a(null), l(null), d.current = !1, s(!1);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
if (r !== f.current) return;
|
|
25
|
+
l(t(e)), d.current = !1, s(!1);
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
return {
|
|
29
|
+
pending: i,
|
|
30
|
+
isPending: i != null,
|
|
31
|
+
isRunning: o,
|
|
32
|
+
error: c,
|
|
33
|
+
open: m,
|
|
34
|
+
close: h,
|
|
35
|
+
confirm: g
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { i as useAsyncConfirmDialog };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AttachmentErrorReason as e } from "@epam/ai-dial-chat-shared";
|
|
2
|
+
import { useCallback as t, useRef as n } from "react";
|
|
3
|
+
//#region src/conversation/useAttachmentUpload/useAttachmentUpload.ts
|
|
4
|
+
var r = 700, i = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", a = (e, t = /* @__PURE__ */ new Date()) => `uploads/${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}/${encodeURIComponent(i(e))}`, o = ({ filesApi: i, bucket: o, onNetworkError: s, debounceMs: c = r }) => {
|
|
5
|
+
let l = n([]), u = n(null);
|
|
6
|
+
return { handleUploadAttachment: t(async (t) => {
|
|
7
|
+
if (!o) throw Error("User bucket is not available");
|
|
8
|
+
try {
|
|
9
|
+
return (await i.uploadFile({
|
|
10
|
+
bucket: o,
|
|
11
|
+
path: a(t.name),
|
|
12
|
+
file: t.file
|
|
13
|
+
})).url;
|
|
14
|
+
} catch (n) {
|
|
15
|
+
if (!navigator.onLine) {
|
|
16
|
+
l.current.push(t.name), u.current != null && clearTimeout(u.current), u.current = setTimeout(() => {
|
|
17
|
+
let e = l.current.splice(0);
|
|
18
|
+
s?.(e), u.current = null;
|
|
19
|
+
}, c);
|
|
20
|
+
let r = n instanceof Error ? n : /* @__PURE__ */ Error("Network upload failed");
|
|
21
|
+
throw r.errorReason = e.Network, r;
|
|
22
|
+
}
|
|
23
|
+
throw n;
|
|
24
|
+
}
|
|
25
|
+
}, [
|
|
26
|
+
o,
|
|
27
|
+
c,
|
|
28
|
+
i,
|
|
29
|
+
s
|
|
30
|
+
]) };
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { o as useAttachmentUpload };
|