@epam/ai-dial-chat-hooks 1.2.0-dev.21 → 1.2.0-dev.217

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 (89) hide show
  1. package/api-error/api-error.js +7 -4
  2. package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
  3. package/attachments.d.ts +10 -4
  4. package/catalog/catalog-derivations.js +1 -1
  5. package/catalog/deployment-id.js +8 -2
  6. package/catalog/map-deployment-limits-to-input.js +81 -9
  7. package/catalog/map-deployment-to-catalog-item.js +34 -34
  8. package/catalog/map-entity-details-to-catalog.js +7 -0
  9. package/catalog/map-skill-to-catalog-item.js +30 -27
  10. package/catalog/publish.js +6 -5
  11. package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
  12. package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
  13. package/catalog/useSkillItemDetails.js +17 -13
  14. package/catalog.d.ts +116 -20
  15. package/catalog.js +23 -22
  16. package/conversation/conversation-transfer/export-conversation.js +24 -16
  17. package/conversation/conversation-transfer/import-conversation.js +80 -31
  18. package/conversation/conversation-transfer/queue.js +8 -5
  19. package/conversation/create-chat-stream-api.js +85 -49
  20. package/conversation/message-utils.js +44 -2
  21. package/conversation/stage.js +23 -0
  22. package/conversation/useConversationExport/useConversationExport.js +9 -9
  23. package/conversation/useConversationHandlers/useConversationHandlers.js +16 -5
  24. package/conversation/useConversationImport/useConversationImport.js +123 -121
  25. package/conversation/useConversationPanelItems/useConversationPanelItems.js +2 -3
  26. package/conversation/useConversationScroll/useConversationScroll.js +68 -64
  27. package/conversation/useConversationStream/apply-chunk.js +1 -1
  28. package/conversation/useConversationStream/generation-resume.js +104 -63
  29. package/conversation/useConversationStream/useConversationStream.js +181 -110
  30. package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
  31. package/conversation-overlay.d.ts +7 -0
  32. package/conversation-overlay.js +2 -0
  33. package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
  34. package/conversation-sources.d.ts +1 -1
  35. package/conversation-transfer.d.ts +2 -1
  36. package/conversation.d.ts +241 -13
  37. package/conversation.js +32 -30
  38. package/file-manager-canvas.d.ts +409 -0
  39. package/file-manager-canvas.js +2 -0
  40. package/file-manager.d.ts +153 -350
  41. package/file-manager.js +25 -24
  42. package/files/attachment-canvas.js +73 -22
  43. package/files/attachment-types.js +14 -13
  44. package/files/dial-file-manager-mapping.util.js +2 -1
  45. package/files/dial-file-manager-path.util.js +23 -1
  46. package/files/dial-file-manager.model.js +23 -19
  47. package/files/dial-file-manager.types.js +3 -3
  48. package/files/useDialFileListing/useDialFileListing.js +139 -127
  49. package/files/useDialFileManager/useDialFileManager.js +132 -128
  50. package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
  51. package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -19
  52. package/files/useDialFileMutations/useDialFileMutations.js +33 -32
  53. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
  54. package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +43 -0
  55. package/index.d.ts +1094 -86
  56. package/index.js +136 -122
  57. package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
  58. package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
  59. package/mcp-apps/useMcpAppTools/useMcpAppTools.js +1 -1
  60. package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
  61. package/mcp-apps.d.ts +8 -6
  62. package/oauth/toolset-id.js +5 -3
  63. package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
  64. package/oauth.d.ts +32 -0
  65. package/oauth.js +9 -9
  66. package/package.json +36 -21
  67. package/scheduled-task/scheduled-task-description.js +77 -0
  68. package/scheduled-task/scheduled-task-preparation.js +24 -0
  69. package/scheduled-task/scheduled-task-trigger.js +7 -2
  70. package/scheduled-task/scheduled-tasks-api-client.js +19 -0
  71. package/scheduled-task/use-scheduled-task-runs.js +194 -0
  72. package/scheduled-task/use-scheduled-tasks.js +93 -0
  73. package/scheduled-tasks.d.ts +195 -3
  74. package/scheduled-tasks.js +7 -2
  75. package/skill/skill-archive.js +19 -0
  76. package/skill/skill-types.js +8 -7
  77. package/skill/skill.js +42 -27
  78. package/skill/useSkillArchiveImport/useSkillArchiveImport.js +79 -0
  79. package/skill/useSkillEditorLoad.js +29 -28
  80. package/skill/useSkillEditorSubmit.js +108 -84
  81. package/skill/useSkillFileActions.js +70 -58
  82. package/skill-editor.d.ts +133 -3
  83. package/skill-editor.js +9 -8
  84. package/usage/map-usage-data-to-dashboard.js +66 -0
  85. package/usage/map-user-usage-to-model-limits.js +202 -0
  86. package/usage.d.ts +125 -0
  87. package/usage.js +3 -0
  88. package/usePageFileDrag/usePageFileDrag.js +3 -3
  89. package/utils.d.ts +18 -6
@@ -19,138 +19,145 @@ var f = 5, p = (e) => e.error ? `${e.path} (${e.error})` : e.path, m = (e) => {
19
19
  }, h = (e, t) => `${e}${t}/`, g = (e) => /\.zip$/i.test(e), _ = (e) => {
20
20
  let [t] = e;
21
21
  if (!(e.length !== 1 || t == null)) return g(t.fileContent.name) && !g(t.name) ? t : void 0;
22
- }, v = ({ filesApi: f, bucket: p, rootLabel: g, activeTab: v, cache: y, sharedRootMetaRef: b, invalidateFolders: x, bumpRetry: S, onNotification: C }) => {
23
- let [w, T] = l(null), E = c(null), D = s((e, t, r) => {
24
- let a = i(r, g);
25
- T({
26
- files: [{
27
- id: `${Date.now()}-archive`,
28
- name: t,
29
- status: o.Uploading
30
- }],
31
- isOpen: !0
32
- }), (async () => {
22
+ }, v = 0, y = () => (v += 1, `${Date.now()}-${v}`), b = (e, t) => ({
23
+ files: [...e?.files ?? [], ...t],
24
+ isOpen: !0
25
+ }), x = ({ filesApi: f, bucket: p, rootLabel: g, activeTab: v, cache: x, sharedRootMetaRef: S, invalidateFolders: C, bumpRetry: w, onNotification: T }) => {
26
+ let [E, D] = l(null), O = c(/* @__PURE__ */ new Map()), k = s((e, t, r) => {
27
+ let s = i(r, g), c = y();
28
+ D((e) => b(e, [{
29
+ id: c,
30
+ name: t,
31
+ status: o.Uploading
32
+ }])), (async () => {
33
+ let r = o.Failed;
33
34
  try {
34
- let { results: r } = await f.uploadArchive(e, p, h(a, t)), i = r.filter((e) => e.success).length, o = r.filter((e) => !e.success), s = o.length, { names: c, restCount: l } = m(o);
35
- r.length > 0 && i === 0 ? C?.({
35
+ let { results: i } = await f.uploadArchive(e, p, h(s, t)), a = i.filter((e) => e.success).length, c = i.filter((e) => !e.success), l = c.length, { names: d, restCount: g } = m(c);
36
+ i.length > 0 && a === 0 ? T?.({
36
37
  variant: u.Error,
37
38
  reason: n.UploadArchiveFailed,
38
- names: c,
39
- restCount: l
40
- }) : s > 0 && C?.({
39
+ names: d,
40
+ restCount: g
41
+ }) : (r = o.Completed, l > 0 && T?.({
41
42
  variant: u.Error,
42
43
  reason: n.UploadArchivePartiallyFailed,
43
- count: s,
44
- names: c,
45
- restCount: l
46
- });
44
+ count: l,
45
+ names: d,
46
+ restCount: g
47
+ }));
47
48
  } catch {
48
- C?.({
49
+ T?.({
49
50
  variant: u.Error,
50
51
  reason: n.UploadArchiveRequestFailed
51
52
  });
52
53
  } finally {
53
- x([a]), S(), T(null);
54
+ C([s]), w(), D((e) => a(e, c, {
55
+ status: r,
56
+ percent: 100
57
+ }));
54
58
  }
55
59
  })();
56
60
  }, [
57
61
  p,
58
62
  g,
59
- C,
63
+ T,
60
64
  f,
65
+ C,
66
+ w
67
+ ]), A = s((e, s) => {
68
+ if (e.length === 0) return;
69
+ let c = _(e);
70
+ if (c != null) {
71
+ k(c.fileContent, c.name, s);
72
+ return;
73
+ }
74
+ let l = e.map((e) => ({
75
+ id: y(),
76
+ name: e.name,
77
+ status: o.Queued
78
+ })), m = O.current;
79
+ for (let e of l) m.set(e.id, new AbortController());
80
+ D((e) => b(e, l));
81
+ let h = i(s, g), { bucket: E, path: A } = v === d.Shared ? r(h, S.current, p) : {
82
+ bucket: p,
83
+ path: h
84
+ }, j = new Set((x.get(h) ?? []).map((e) => e.name.toLowerCase()));
85
+ (async () => {
86
+ let r = 0, i = 0, s = 0, c = 0, d = async () => {
87
+ for (; r < e.length;) {
88
+ let n = r++, u = e[n], { id: d } = l[n], p = m.get(d);
89
+ if (p == null || p.signal.aborted) {
90
+ c += 1, m.delete(d), D((e) => a(e, d, o.Cancelled));
91
+ continue;
92
+ }
93
+ D((e) => a(e, d, {
94
+ status: o.Uploading,
95
+ percent: 0
96
+ }));
97
+ let h = j.has(u.name.toLowerCase()) ? t.Overwrite : t.CreateOnly;
98
+ try {
99
+ await f.uploadFile(E, `${A}${u.name}`, u.fileContent, {
100
+ signal: p.signal,
101
+ uploadMode: h,
102
+ onProgress: (e) => {
103
+ D((t) => a(t, d, {
104
+ status: o.Uploading,
105
+ percent: e
106
+ }));
107
+ }
108
+ }), D((e) => a(e, d, {
109
+ status: o.Completed,
110
+ percent: 100
111
+ })), i += 1;
112
+ } catch {
113
+ let e = o.Failed;
114
+ p.signal.aborted ? (e = o.Cancelled, c += 1) : s += 1, D((t) => a(t, d, e));
115
+ } finally {
116
+ m.delete(d);
117
+ }
118
+ }
119
+ };
120
+ await Promise.all(Array.from({ length: 3 }, () => d())), c < e.length && (i === 0 && s > 0 ? T?.({
121
+ variant: u.Error,
122
+ reason: n.UploadFailed
123
+ }) : i > 0 && T?.({
124
+ variant: u.Success,
125
+ reason: n.UploadCompleted,
126
+ folder: A || g
127
+ })), C([h]), w();
128
+ })();
129
+ }, [
130
+ v,
131
+ p,
61
132
  x,
62
- S
63
- ]);
133
+ g,
134
+ T,
135
+ f,
136
+ S,
137
+ C,
138
+ w,
139
+ k
140
+ ]), j = s((e, t, n) => {
141
+ k(e, t, n);
142
+ }, [k]), M = s(async (t, n, r) => {
143
+ for (let n of t) n.name = e(n.name);
144
+ return { valid: !0 };
145
+ }, []), N = s((e) => {
146
+ O.current.get(e)?.abort();
147
+ }, []);
64
148
  return {
65
- onUploadFiles: s((e, s) => {
66
- if (e.length === 0) return;
67
- let c = _(e);
68
- if (c != null) {
69
- D(c.fileContent, c.name, s);
70
- return;
71
- }
72
- let l = new AbortController();
73
- E.current = l, T({
74
- files: e.map((e, t) => ({
75
- id: `${Date.now()}-${t}`,
76
- name: e.name,
77
- status: o.Queued
78
- })),
79
- isOpen: !0
80
- });
81
- let m = i(s, g), { bucket: h, path: w } = v === d.Shared ? r(m, b.current, p) : {
82
- bucket: p,
83
- path: m
84
- }, O = new Set((y.get(m) ?? []).map((e) => e.name.toLowerCase()));
85
- (async () => {
86
- let r = 0, i = 0, s = 0, c = async () => {
87
- for (; r < e.length;) {
88
- let n = r++, c = e[n];
89
- if (l.signal.aborted) {
90
- T((e) => a(e, n, o.Cancelled));
91
- continue;
92
- }
93
- T((e) => a(e, n, {
94
- status: o.Uploading,
95
- percent: 0
96
- }));
97
- let u = O.has(c.name.toLowerCase()) ? t.Overwrite : t.CreateOnly;
98
- try {
99
- await f.uploadFile(h, `${w}${c.name}`, c.fileContent, {
100
- signal: l.signal,
101
- uploadMode: u,
102
- onProgress: (e) => {
103
- T((t) => a(t, n, {
104
- status: o.Uploading,
105
- percent: e
106
- }));
107
- }
108
- }), T((e) => a(e, n, {
109
- status: o.Completed,
110
- percent: 100
111
- })), i += 1;
112
- } catch {
113
- let e = l.signal.aborted ? o.Cancelled : o.Failed;
114
- e === o.Failed && (s += 1), T((t) => a(t, n, e));
115
- }
116
- }
117
- };
118
- await Promise.all(Array.from({ length: 3 }, () => c())), l.signal.aborted || (i === 0 && s > 0 ? C?.({
119
- variant: u.Error,
120
- reason: n.UploadFailed
121
- }) : C?.({
122
- variant: u.Success,
123
- reason: n.UploadCompleted,
124
- folder: w || g
125
- })), x([m]), S(), E.current = null, T(null);
126
- })();
127
- }, [
128
- v,
129
- p,
130
- y,
131
- g,
132
- C,
133
- f,
134
- b,
135
- x,
136
- S,
137
- D
138
- ]),
139
- onUploadArchive: s((e, t, n) => {
140
- D(e, t, n);
141
- }, [D]),
142
- onValidateUpload: s(async (t, n, r) => {
143
- for (let n of t) n.name = e(n.name);
144
- return { valid: !0 };
145
- }, []),
146
- uploadBatchState: w,
149
+ onUploadFiles: A,
150
+ onUploadArchive: j,
151
+ onValidateUpload: M,
152
+ uploadBatchState: E,
147
153
  cancelUpload: s(() => {
148
- E.current?.abort();
154
+ for (let e of O.current.values()) e.abort();
149
155
  }, []),
156
+ cancelUploadFile: N,
150
157
  clearUploadBatch: s(() => {
151
- T(null);
158
+ D(null);
152
159
  }, [])
153
160
  };
154
161
  };
155
162
  //#endregion
156
- export { v as useDialFileUploadBatch };
163
+ export { x as useDialFileUploadBatch };
@@ -0,0 +1,43 @@
1
+ import { mimeTypesToDialFileAcceptTypes as e } from "../attachment-types.js";
2
+ import { DialFileManagerVariant as t } from "../file-manager-variant.js";
3
+ import { useDialFileManager as n } from "../useDialFileManager/useDialFileManager.js";
4
+ import { useDialFileManagerTabConfig as r } from "../useDialFileManagerTabConfig/useDialFileManagerTabConfig.js";
5
+ import { isHiddenPath as i } from "@epam/ai-dial-chat-shared";
6
+ import { useCallback as a, useMemo as o, useState as s } from "react";
7
+ import { isMimeTypeAllowed as c } from "@epam/ai-dial-attachment-input";
8
+ import { DialFileManagerTabs as l, DialFileNodeType as u, useDialFileManagerTabs as d } from "@epam/ai-dial-react-file-manager";
9
+ //#region src/files/useFileAttachmentPicker/useFileAttachmentPicker.ts
10
+ var f = ({ fileManagerOptions: f, bucket: p, forbiddenSymbolsRegExp: m, tabLabels: h, allowedTabs: g, initialTab: _, allowedTypes: v, maxSelectableFileSize: y, canAttachFolders: b = !1 }) => {
11
+ let { activeTab: x, handleTabChange: S, tabs: C } = d(h, _ === l.All ? void 0 : _), w = o(() => (g ?? Object.values(l)).filter((e) => e !== l.All), [g]), [T, E] = s(() => /* @__PURE__ */ new Set()), D = a((e) => {
12
+ E(new Set(e));
13
+ }, []), O = a((e) => {
14
+ E(/* @__PURE__ */ new Set()), S(e);
15
+ }, [S]), { tabs: k } = r(x, O, C, w), A = h[x] || h[l.MyFiles], j = n({
16
+ ...f,
17
+ bucket: p,
18
+ activeTab: x,
19
+ rootLabel: A,
20
+ variant: t.Attach,
21
+ forbiddenSymbolsRegExp: m
22
+ }), M = a((e) => v == null || v.length === 0 ? !0 : c(e, v), [v]);
23
+ return {
24
+ controller: j,
25
+ activeTab: x,
26
+ tabs: k,
27
+ onTabChange: O,
28
+ selectedPaths: T,
29
+ onSelectedPathsChange: D,
30
+ isRowSelectable: a((e) => {
31
+ let t = e.data;
32
+ return t == null || i(t.path) ? !1 : t.nodeType === u.FOLDER ? b : t.nodeType === u.ITEM ? !(t.contentType != null && !M(t.contentType) || y != null && t.contentLength != null && t.contentLength > y) : !1;
33
+ }, [
34
+ b,
35
+ M,
36
+ y
37
+ ]),
38
+ isFileTypeAllowed: M,
39
+ allowedFileTypes: o(() => e(v), [v])
40
+ };
41
+ };
42
+ //#endregion
43
+ export { f as useFileAttachmentPicker };