@epam/ai-dial-chat-hooks 1.2.0-dev.1 → 1.2.0-dev.102

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.
Files changed (56) hide show
  1. package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
  2. package/attachments.d.ts +10 -4
  3. package/catalog/map-deployment-to-catalog-item.js +2 -2
  4. package/catalog/map-skill-to-catalog-item.js +48 -48
  5. package/catalog/publish.js +2 -1
  6. package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
  7. package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
  8. package/catalog/useSkillItemDetails.js +19 -17
  9. package/catalog.d.ts +60 -5
  10. package/catalog.js +15 -14
  11. package/conversation/announcement-message.js +16 -5
  12. package/conversation/conversation-transfer/queue.js +8 -5
  13. package/conversation/stage.js +23 -0
  14. package/conversation/useAttachmentUpload/useAttachmentUpload.js +12 -5
  15. package/conversation/useConversationHandlers/useConversationHandlers.js +13 -17
  16. package/conversation/useConversationImport/useConversationImport.js +1 -1
  17. package/conversation/useConversationScroll/useConversationScroll.js +68 -64
  18. package/conversation/useConversationStream/apply-chunk.js +1 -1
  19. package/conversation/useConversationStream/useConversationStream.js +5 -1
  20. package/conversation/useTranscribeAudio/transcription-retry.js +5 -4
  21. package/conversation-overlay.d.ts +7 -0
  22. package/conversation-overlay.js +2 -0
  23. package/conversation.d.ts +139 -7
  24. package/conversation.js +24 -23
  25. package/file-manager-canvas.d.ts +398 -0
  26. package/file-manager-canvas.js +2 -0
  27. package/file-manager.d.ts +71 -330
  28. package/file-manager.js +15 -15
  29. package/files/attachment-canvas.js +51 -13
  30. package/files/attachment-types.js +14 -13
  31. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +1 -5
  32. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +43 -0
  33. package/index.d.ts +761 -29
  34. package/index.js +123 -111
  35. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
  36. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
  37. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
  38. package/mcp-apps.d.ts +8 -6
  39. package/package.json +37 -18
  40. package/scheduled-task/scheduled-task-description.js +77 -0
  41. package/scheduled-task/scheduled-task-preparation.js +24 -0
  42. package/scheduled-task/scheduled-tasks-api-client.js +19 -0
  43. package/scheduled-task/use-scheduled-task-runs.js +82 -0
  44. package/scheduled-task/use-scheduled-tasks.js +93 -0
  45. package/scheduled-tasks.d.ts +178 -0
  46. package/scheduled-tasks.js +7 -2
  47. package/skill/skill.js +10 -7
  48. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +75 -0
  49. package/skill/useSkillEditorLoad.js +29 -28
  50. package/skill/useSkillEditorSubmit.js +92 -75
  51. package/skill-editor.d.ts +107 -0
  52. package/skill-editor.js +9 -8
  53. package/usage/map-usage-data-to-dashboard.js +66 -0
  54. package/usage/map-user-usage-to-model-limits.js +160 -0
  55. package/usage.d.ts +120 -0
  56. package/usage.js +3 -0
package/catalog.js CHANGED
@@ -8,17 +8,18 @@ import { mapDeploymentDetailsDtoToEntityDetails as u, mapEntityDetailsToCatalogD
8
8
  import { mapDeploymentToCatalogItem as p, mapDeploymentToolsetCredentials as m, mapToolsetToCatalogItem as h, resolveDeploymentFolder as g } from "./catalog/map-deployment-to-catalog-item.js";
9
9
  import { buildPromptOverview as _, isOrganisationPromptItem as v, mapPromptToCatalogItem as y } from "./catalog/map-prompt-to-catalog-item.js";
10
10
  import { PUBLIC_SKILL_BUCKET as b, SKILL_LISTING_MAX_PAGES as x, SKILL_LISTING_PAGE_SIZE as S, SKILL_MANIFEST_MAX_BYTES as C, SkillSource as w, parseSkillResourceUrl as T } from "./skill/skill-types.js";
11
- import { buildSkillContentTree as E, buildSkillOverview as D, mapSkillToCatalogItem as O, readSkillFileBytes as k, readSkillManifest as A, resolveSkillFileDownloadPath as j, resolveSkillManifestFileId as M } from "./catalog/map-skill-to-catalog-item.js";
12
- import { McpResourceKind as N, buildApplicationMcpUrl as P, buildConnectApi as F, buildToolsetMcpUrl as I, resolveMcpResourceKind as L } from "./catalog/mcp-endpoint-url.js";
13
- import { getPublicCatalogEntityFolderPath as R, isPublicCatalogEntityId as z, mapPublishConversationResultDto as B, mapPublishHistoryEntryDto as V, toPublishEntityType as H } from "./catalog/publish.js";
14
- import { deriveAvailableTabIds as U, deriveFavoriteItems as W, filterCatalogItemsBySelector as G, filterHiddenOwnedItems as K, reconcileFilterTopics as q } from "./catalog/catalog-derivations.js";
15
- import { CatalogPrimaryActionType as J, resolveCatalogPrimaryAction as Y } from "./catalog/catalog-primary-action.js";
16
- import { useCatalogEditNavigation as X } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
17
- import { useSkillItemDetails as Z } from "./catalog/useSkillItemDetails.js";
18
- import { useCatalogItemDetails as Q } from "./catalog/useCatalogItemDetails.js";
19
- import { useCatalogToolsetCredentials as $ } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
20
- import { useSkillDetailsPanelData as ee } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
21
- import { FavoriteEntityType as te, useFavoriteEntitiesState as ne } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
22
- import { usePublishFolders as re } from "./catalog/usePublishFolders/usePublishFolders.js";
23
- import { SkillPreviewErrorKind as ie, useSkillFilePreview as ae } from "./skill/useSkillFilePreview.js";
24
- export { s as AuthenticationType, J as CatalogPrimaryActionType, te as FavoriteEntityType, N as McpResourceKind, b as PUBLIC_SKILL_BUCKET, x as SKILL_LISTING_MAX_PAGES, S as SKILL_LISTING_PAGE_SIZE, C as SKILL_MANIFEST_MAX_BYTES, ie as SkillPreviewErrorKind, w as SkillSource, P as buildApplicationMcpUrl, n as buildChatCompletionsUrl, F as buildConnectApi, r as buildDeploymentConnectApi, _ as buildPromptOverview, i as buildResponsesUrl, E as buildSkillContentTree, D as buildSkillOverview, I as buildToolsetMcpUrl, e as createPublishApiClient, U as deriveAvailableTabIds, W as deriveFavoriteItems, a as encodeDeploymentId, G as filterCatalogItemsBySelector, K as filterHiddenOwnedItems, o as findDeploymentByIdOrReference, R as getPublicCatalogEntityFolderPath, v as isOrganisationPromptItem, z as isPublicCatalogEntityId, u as mapDeploymentDetailsDtoToEntityDetails, c as mapDeploymentLimitsDtoToCatalogLimits, l as mapDeploymentLimitsToInput, p as mapDeploymentToCatalogItem, m as mapDeploymentToolsetCredentials, d as mapEntityDetailsToCatalogDetails, y as mapPromptToCatalogItem, B as mapPublishConversationResultDto, V as mapPublishHistoryEntryDto, O as mapSkillToCatalogItem, f as mapToolsetCredentials, h as mapToolsetToCatalogItem, T as parseSkillResourceUrl, k as readSkillFileBytes, A as readSkillManifest, q as reconcileFilterTopics, Y as resolveCatalogPrimaryAction, g as resolveDeploymentFolder, L as resolveMcpResourceKind, j as resolveSkillFileDownloadPath, M as resolveSkillManifestFileId, H as toPublishEntityType, t as toPublishRuleDto, X as useCatalogEditNavigation, Q as useCatalogItemDetails, $ as useCatalogToolsetCredentials, ne as useFavoriteEntitiesState, re as usePublishFolders, ee as useSkillDetailsPanelData, ae as useSkillFilePreview, Z as useSkillItemDetails };
11
+ import { buildSkillContentTree as E, buildSkillOverview as D, mapSkillToCatalogItem as O, readSkillFileBytes as k, readSkillFilePreviewBytes as A, readSkillManifest as j, resolveSkillFileDownloadPath as M, resolveSkillManifestFileId as N } from "./catalog/map-skill-to-catalog-item.js";
12
+ import { McpResourceKind as P, buildApplicationMcpUrl as F, buildConnectApi as I, buildToolsetMcpUrl as L, resolveMcpResourceKind as R } from "./catalog/mcp-endpoint-url.js";
13
+ import { getPublicCatalogEntityFolderPath as z, isPublicCatalogEntityId as B, mapPublishConversationResultDto as V, mapPublishHistoryEntryDto as H, toPublishEntityType as U } from "./catalog/publish.js";
14
+ import { deriveAvailableTabIds as W, deriveFavoriteItems as G, filterCatalogItemsBySelector as K, filterHiddenOwnedItems as q, reconcileFilterTopics as J } from "./catalog/catalog-derivations.js";
15
+ import { CatalogPrimaryActionType as Y, resolveCatalogPrimaryAction as X } from "./catalog/catalog-primary-action.js";
16
+ import { useCatalogEditNavigation as Z } from "./catalog/useCatalogEditNavigation/useCatalogEditNavigation.js";
17
+ import { useSkillItemDetails as Q } from "./catalog/useSkillItemDetails.js";
18
+ import { useCatalogItemDetails as $ } from "./catalog/useCatalogItemDetails.js";
19
+ import { useCatalogToolsetCredentials as ee } from "./catalog/useCatalogToolsetCredentials/useCatalogToolsetCredentials.js";
20
+ import { useApplicationCredentials as te } from "./catalog/useApplicationCredentials/useApplicationCredentials.js";
21
+ import { useSkillDetailsPanelData as ne } from "./catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js";
22
+ import { FavoriteEntityType as re, useFavoriteEntitiesState as ie } from "./catalog/useFavoriteEntitiesState/useFavoriteEntitiesState.js";
23
+ import { usePublishFolders as ae } from "./catalog/usePublishFolders/usePublishFolders.js";
24
+ import { SkillPreviewErrorKind as oe, useSkillFilePreview as se } from "./skill/useSkillFilePreview.js";
25
+ export { s as AuthenticationType, Y as CatalogPrimaryActionType, re as FavoriteEntityType, P as McpResourceKind, b as PUBLIC_SKILL_BUCKET, x as SKILL_LISTING_MAX_PAGES, S as SKILL_LISTING_PAGE_SIZE, C as SKILL_MANIFEST_MAX_BYTES, oe as SkillPreviewErrorKind, w as SkillSource, F as buildApplicationMcpUrl, n as buildChatCompletionsUrl, I as buildConnectApi, r as buildDeploymentConnectApi, _ as buildPromptOverview, i as buildResponsesUrl, E as buildSkillContentTree, D as buildSkillOverview, L as buildToolsetMcpUrl, e as createPublishApiClient, W as deriveAvailableTabIds, G as deriveFavoriteItems, a as encodeDeploymentId, K as filterCatalogItemsBySelector, q as filterHiddenOwnedItems, o as findDeploymentByIdOrReference, z as getPublicCatalogEntityFolderPath, v as isOrganisationPromptItem, B as isPublicCatalogEntityId, u as mapDeploymentDetailsDtoToEntityDetails, c as mapDeploymentLimitsDtoToCatalogLimits, l as mapDeploymentLimitsToInput, p as mapDeploymentToCatalogItem, m as mapDeploymentToolsetCredentials, d as mapEntityDetailsToCatalogDetails, y as mapPromptToCatalogItem, V as mapPublishConversationResultDto, H as mapPublishHistoryEntryDto, O as mapSkillToCatalogItem, f as mapToolsetCredentials, h as mapToolsetToCatalogItem, T as parseSkillResourceUrl, k as readSkillFileBytes, A as readSkillFilePreviewBytes, j as readSkillManifest, J as reconcileFilterTopics, X as resolveCatalogPrimaryAction, g as resolveDeploymentFolder, R as resolveMcpResourceKind, M as resolveSkillFileDownloadPath, N as resolveSkillManifestFileId, U as toPublishEntityType, t as toPublishRuleDto, te as useApplicationCredentials, Z as useCatalogEditNavigation, $ as useCatalogItemDetails, ee as useCatalogToolsetCredentials, ie as useFavoriteEntitiesState, ae as usePublishFolders, ne as useSkillDetailsPanelData, se as useSkillFilePreview, Q as useSkillItemDetails };
@@ -34,9 +34,20 @@ var t = {
34
34
  e.addHook("afterSanitizeAttributes", (e) => {
35
35
  e.tagName === "A" && e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer");
36
36
  });
37
- var r = (n) => e.sanitize(n, t), i = (t) => e.sanitize(t, n), a = (e) => typeof e == "string" && e.length > 0, o = ({ title: e, description: t }) => a(e) || a(t), s = (e) => o(e) || a(e.html), c = (e) => o(e) ? JSON.stringify({
38
- title: e.title ?? "",
39
- description: e.description ?? ""
40
- }) : e.html ?? "";
37
+ var r = (n) => e.sanitize(n, t), i = (t) => e.sanitize(t, n), a = (e) => typeof e == "string" && e.length > 0, o = ({ title: e, description: t }) => a(e) || a(t), s = (e) => o(e) || a(e.html), c = (e) => e.map((e) => ({
38
+ title: e.title,
39
+ description: e.description ?? "",
40
+ link: e.link ? {
41
+ label: e.link.label,
42
+ href: e.link.href
43
+ } : null
44
+ })), l = (e) => {
45
+ if (!o(e)) return e.html ?? "";
46
+ let t = {
47
+ title: e.title ?? "",
48
+ description: e.description ?? ""
49
+ }, n = e.items ?? [];
50
+ return n.length > 0 && (t.items = c(n)), JSON.stringify(t);
51
+ };
41
52
  //#endregion
42
- export { c as buildAnnouncementSignature, s as hasAnnouncementContent, o as hasStructuredAnnouncement, r as sanitizeAnnouncementHtml, i as sanitizeAnnouncementMessageHtml };
53
+ export { l as buildAnnouncementSignature, s as hasAnnouncementContent, o as hasStructuredAnnouncement, r as sanitizeAnnouncementHtml, i as sanitizeAnnouncementMessageHtml };
@@ -27,13 +27,14 @@ var o = () => {
27
27
  progress: { percent: 100 },
28
28
  errorCode: void 0
29
29
  });
30
- }, [u]), m = n((t, n) => {
31
- s((r) => r.map((r) => r.id !== t || r.status !== e.InProgress ? r : {
32
- ...r,
30
+ }, [u]), m = n((t, n, r) => {
31
+ s((i) => i.map((i) => i.id !== t || i.status !== e.InProgress ? i : {
32
+ ...i,
33
33
  status: e.Warning,
34
34
  progress: { percent: 100 },
35
35
  errorCode: void 0,
36
- warningCode: n
36
+ warningCode: n,
37
+ warningNames: r
37
38
  }));
38
39
  }, []), h = n((t, n) => {
39
40
  u(t, {
@@ -57,7 +58,9 @@ var o = () => {
57
58
  return l.current.set(t, () => (u(t, {
58
59
  status: e.InProgress,
59
60
  progress: { percent: 0 },
60
- errorCode: void 0
61
+ errorCode: void 0,
62
+ warningCode: void 0,
63
+ warningNames: void 0
61
64
  }), r())), r();
62
65
  }, [u]);
63
66
  return r(() => {
@@ -0,0 +1,23 @@
1
+ import { StageStatus as e } from "@epam/ai-dial-chat-shared";
2
+ //#region src/conversation/stage.ts
3
+ var t = (t) => t === e.Completed ? e.Completed : t === e.Failed ? e.Failed : null, n = (e) => ({
4
+ title: e.title ?? "",
5
+ ...e.index != null && { index: e.index },
6
+ ...e.type != null && { type: e.type },
7
+ ...e.data != null && { data: e.data },
8
+ ...e.url != null && { url: e.url },
9
+ ...e.reference_type != null && { reference_type: e.reference_type },
10
+ ...e.reference_url != null && { reference_url: e.reference_url }
11
+ }), r = (e) => ({
12
+ index: e.index ?? 0,
13
+ name: e.name ?? "",
14
+ status: t(e.status),
15
+ ...e.content != null && { content: e.content },
16
+ ...e.tag != null && { tag: e.tag },
17
+ ...e.attachments?.length && { attachments: e.attachments.map(n) }
18
+ }), i = (e) => {
19
+ let t = Array.isArray(e) ? e : e?.custom_content?.stages ?? e?.customContent?.stages;
20
+ if (t?.length) return t.map(r);
21
+ };
22
+ //#endregion
23
+ export { i as mapStages, r as toStage };
@@ -26,9 +26,16 @@ var o = 700, s = 5, c = (e) => t(e.split("/").filter(Boolean).pop() ?? "file").r
26
26
  })).url,
27
27
  name: a.fileName
28
28
  };
29
- } catch (t) {
30
- if (l(t)) {
29
+ } catch (c) {
30
+ if (l(c)) {
31
31
  if (i.markTaken(a.fileName), o < s) {
32
+ if (t.listFiles) try {
33
+ let e = await t.listFiles({
34
+ bucket: u,
35
+ path: a.path.slice(0, a.path.lastIndexOf("/"))
36
+ });
37
+ for (let t of e.items) i.markTaken(t.name);
38
+ } catch {}
32
39
  a = i.allocate(n);
33
40
  continue;
34
41
  }
@@ -38,10 +45,10 @@ var o = 700, s = 5, c = (e) => t(e.split("/").filter(Boolean).pop() ?? "file").r
38
45
  let e = p.current.splice(0);
39
46
  d?.(e), m.current = null;
40
47
  }, f);
41
- let n = t instanceof Error ? t : /* @__PURE__ */ Error("Network upload failed");
42
- throw n.errorReason = r.Network, n;
48
+ let t = c instanceof Error ? c : /* @__PURE__ */ Error("Network upload failed");
49
+ throw t.errorReason = r.Network, t;
43
50
  }
44
- throw t;
51
+ throw c;
45
52
  }
46
53
  }, [
47
54
  u,
@@ -44,23 +44,19 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
44
44
  if (g || !m || !p || e === -1 || p.messages[e]?.role !== c.Assistant) return;
45
45
  let t = p.messages[e - 1];
46
46
  if (!t || t.role !== c.User) return;
47
- let n = C();
48
- v((t) => {
49
- if (!t) return t;
50
- let r = {
51
- ...t.messages[e],
52
- content: "",
53
- custom_content: void 0,
54
- wasStoppedByUser: void 0,
55
- stoppedWithoutContent: void 0,
56
- streamErrorMessage: void 0,
57
- deploymentId: n
58
- }, i = {
59
- ...t,
60
- messages: [...t.messages.slice(0, e), r]
61
- };
62
- return y.current = i, i;
63
- }), A((t) => new Set([...t].filter((t) => t < e))), _(m, t.content, e, n, t.custom_content, l(), f.Regenerate);
47
+ let n = C(), r = {
48
+ ...p.messages[e],
49
+ content: "",
50
+ custom_content: void 0,
51
+ wasStoppedByUser: void 0,
52
+ stoppedWithoutContent: void 0,
53
+ streamErrorMessage: void 0,
54
+ deploymentId: n
55
+ }, i = {
56
+ ...p,
57
+ messages: [...p.messages.slice(0, e), r]
58
+ };
59
+ y.current = i, v(i), A((t) => new Set([...t].filter((t) => t < e))), _(m, t.content, e, n, t.custom_content, l(), f.Regenerate);
64
60
  }, [
65
61
  p,
66
62
  m,
@@ -191,7 +191,7 @@ var b = 5, x = 5, S = (e) => /\.(dial|zip)$/i.test(e.name), C = (e) => new Promi
191
191
  jobId: n,
192
192
  code: t.AttachmentSkipped,
193
193
  names: [...j]
194
- }), A.length > 0 ? D.failJob(n, h.Unknown) : j.size > 0 ? D.warnJob(n, t.AttachmentSkipped) : D.succeedJob(n);
194
+ }), A.length > 0 ? D.failJob(n, h.Unknown) : j.size > 0 ? D.warnJob(n, t.AttachmentSkipped, [...j]) : D.succeedJob(n);
195
195
  }
196
196
  }, [
197
197
  l,
@@ -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()), y = e((e, t) => {
5
- t ? v.current.set(e, t) : v.current.delete(e);
6
- }, []), b = r(null), x = e((e) => {
7
- b.current = e;
8
- }, []), S = e((e, t) => {
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
- }, []), T = e((e = !1) => {
22
- let t = w();
23
- t != null && S(Math.max(t, 0), e);
24
- }, [S, w]), E = e(() => {
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
- }, []), D = e(() => {
29
+ }, []), O = e(() => {
30
30
  if (!g.current) return;
31
- let e = E();
32
- e == null || e < -1 || C();
33
- }, [C, E]), O = e((e) => {
34
- let t = f.current, n = v.current.get(e);
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
- }, []), k = e((e, t = !1) => {
39
- let n = O(e);
40
- n != null && S(n, t);
41
- }, [O, S]), A = e(() => {
42
- let e = w();
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
- }, [w]), j = e(() => {
44
+ }, [T]), M = e(() => {
45
45
  if (!h.current) return null;
46
- let e = _.current, t = A();
46
+ let e = _.current, t = j();
47
47
  return e == null || t == null ? null : Math.max(e, t);
48
- }, [A]), M = e(() => {
49
- let e = f.current, t = j();
48
+ }, [j]), N = e(() => {
49
+ let e = f.current, t = M();
50
50
  !e || t == null || e.scrollTop > t + o && (e.scrollTop = t);
51
- }, [j]), N = e((e) => {
52
- let t = m.current, n = A();
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
- }, [A]), P = e((e) => {
57
- let t = O(e);
58
- t != null && (N(t), k(e, !1));
56
+ }, [j]), F = e((e) => {
57
+ let t = k(e);
58
+ t != null && (P(t), A(e, !1));
59
59
  }, [
60
- N,
61
- O,
62
- k
63
- ]), F = e(() => {
64
- let e = E();
65
- e != null && d(e >= a);
66
- }, [E]), I = r(s.length), L = r(null);
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 !== I.current, t = l !== L.current, n = () => {
69
- I.current = s.length, L.current = l;
70
+ let e = s.length !== L.current, t = l !== R.current, n = () => {
71
+ L.current = s.length, R.current = l;
70
72
  };
71
- t && C();
72
- let r = b.current;
73
- if (r != null && v.current.has(r)) {
74
- b.current = null, P(r), n();
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) && T(!1), n());
79
+ c || ((e || t) && E(!1), n());
78
80
  }, [
79
81
  s,
80
82
  c,
81
83
  l,
82
- T,
83
- P,
84
- C
84
+ E,
85
+ F,
86
+ w
85
87
  ]), n(() => {
86
- !c && h.current && (g.current = !0, D());
87
- }, [c, D]);
88
- let R = e(() => {
89
- M(), D(), F();
88
+ !c && h.current && (g.current = !0, O());
89
+ }, [c, O]);
90
+ let z = e(() => {
91
+ N(), O(), I();
90
92
  }, [
91
- M,
92
- D,
93
- F
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", R, { passive: !0 }), () => e.removeEventListener("scroll", R);
98
- }, [R]), t(() => {
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
- M(), D(), F();
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
- M,
107
- D,
108
- F
109
+ N,
110
+ O,
111
+ I,
112
+ E
109
113
  ]), {
110
114
  containerRef: f,
111
115
  contentRef: p,
112
116
  spacerRef: m,
113
- setMessageRef: y,
117
+ setMessageRef: b,
114
118
  isScrollButtonVisible: u,
115
119
  scrollToBottom: e(() => {
116
- T(!1);
117
- }, [T]),
118
- armAnchor: x
120
+ E(!1);
121
+ }, [E]),
122
+ armAnchor: S
119
123
  };
120
124
  };
121
125
  //#endregion
@@ -75,4 +75,4 @@ var t = (e) => {
75
75
  });
76
76
  };
77
77
  //#endregion
78
- export { o as applyChunkToMessages };
78
+ export { o as applyChunkToMessages, a as mergeStages };
@@ -86,7 +86,11 @@ var m = 2e4, h = ({ conversationId: h, state: { setConversation: g, conversation
86
86
  };
87
87
  (async () => {
88
88
  try {
89
- let e = x?.channelId ?? await x?.waitForChannel(m) ?? void 0;
89
+ let e = x?.channelId ?? await x?.waitForChannel(m) ?? void 0, t = N.current.has(h);
90
+ if (D.signal.aborted || E() || t) {
91
+ M.current.get(C)?.generationId === h && M.current.delete(C), E() || R(C), k.current === h && (k.current = null, A.current = null, O(null)), b(C, h), x?.notifyGenerationSettled?.(), t ? N.current.delete(h) : E() || S?.notifyGenerationEnd?.();
92
+ return;
93
+ }
90
94
  v.streamCompletion(C, o, l, F, u, h, f, T, e);
91
95
  } catch (e) {
92
96
  F.onError(e instanceof Error ? e : Error(String(e)));
@@ -1,6 +1,6 @@
1
1
  import { AudioTranscriptionError as e, AudioTranscriptionErrorReason as t } from "./audio-transcription-error.js";
2
2
  //#region src/conversation/useTranscribeAudio/transcription-retry.ts
3
- var n = 2, r = 9e4, i = (e, t) => (t.throwIfAborted(), new Promise((n, r) => {
3
+ var n = 2, r = 6e3, i = (e, t) => (t.throwIfAborted(), new Promise((n, r) => {
4
4
  let i = () => {
5
5
  clearTimeout(a), r(t.reason);
6
6
  }, a = setTimeout(() => {
@@ -28,9 +28,10 @@ var n = 2, r = 9e4, i = (e, t) => (t.throwIfAborted(), new Promise((n, r) => {
28
28
  503,
29
29
  504
30
30
  ].includes(u.status)) throw o;
31
- let d = [429, 503].includes(u.status) ? 3e4 : 2e3, f = Math.max(1e3, a(u.headers.get("retry-after")) ?? d * 2 ** l);
32
- if (l >= n || c + f > r) throw new e(t.Busy);
33
- c += f, await i(f, s);
31
+ if ([429, 503].includes(u.status)) throw new e(t.Busy);
32
+ let d = Math.max(1e3, a(u.headers.get("retry-after")) ?? 2e3 * 2 ** l);
33
+ if (l >= n || c + d > r) throw new e(t.Busy);
34
+ c += d, await i(d, s);
34
35
  }
35
36
  }
36
37
  };
@@ -0,0 +1,7 @@
1
+ import { Message } from '@epam/ai-dial-chat-shared';
2
+ import { OverlayChatMessage } from '@epam/ai-dial-chat-overlay';
3
+
4
+ /** Maps chat messages to the DIAL Chat Overlay protocol's message shape. */
5
+ export declare const toOverlayMessages: (messages: Message[]) => OverlayChatMessage[];
6
+
7
+ export { }
@@ -0,0 +1,2 @@
1
+ import { toOverlayMessages as e } from "./conversation/overlay-messages.js";
2
+ export { e as toOverlayMessages };