@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.
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
- package/attachments.d.ts +10 -4
- package/catalog/map-deployment-to-catalog-item.js +2 -2
- package/catalog/map-skill-to-catalog-item.js +48 -48
- package/catalog/publish.js +2 -1
- package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
- package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
- package/catalog/useSkillItemDetails.js +19 -17
- package/catalog.d.ts +60 -5
- package/catalog.js +15 -14
- package/conversation/announcement-message.js +16 -5
- package/conversation/conversation-transfer/queue.js +8 -5
- package/conversation/stage.js +23 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +12 -5
- package/conversation/useConversationHandlers/useConversationHandlers.js +13 -17
- package/conversation/useConversationImport/useConversationImport.js +1 -1
- package/conversation/useConversationScroll/useConversationScroll.js +68 -64
- package/conversation/useConversationStream/apply-chunk.js +1 -1
- package/conversation/useConversationStream/useConversationStream.js +5 -1
- package/conversation/useTranscribeAudio/transcription-retry.js +5 -4
- package/conversation-overlay.d.ts +7 -0
- package/conversation-overlay.js +2 -0
- package/conversation.d.ts +139 -7
- package/conversation.js +24 -23
- package/file-manager-canvas.d.ts +398 -0
- package/file-manager-canvas.js +2 -0
- package/file-manager.d.ts +71 -330
- package/file-manager.js +15 -15
- package/files/attachment-canvas.js +51 -13
- package/files/attachment-types.js +14 -13
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +1 -5
- package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +43 -0
- package/index.d.ts +761 -29
- package/index.js +123 -111
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
- package/mcp-apps.d.ts +8 -6
- package/package.json +37 -18
- package/scheduled-task/scheduled-task-description.js +77 -0
- package/scheduled-task/scheduled-task-preparation.js +24 -0
- package/scheduled-task/scheduled-tasks-api-client.js +19 -0
- package/scheduled-task/use-scheduled-task-runs.js +82 -0
- package/scheduled-task/use-scheduled-tasks.js +93 -0
- package/scheduled-tasks.d.ts +178 -0
- package/scheduled-tasks.js +7 -2
- package/skill/skill.js +10 -7
- package/skill/useSkillArchiveImport/useSkillArchiveImport.js +75 -0
- package/skill/useSkillEditorLoad.js +29 -28
- package/skill/useSkillEditorSubmit.js +92 -75
- package/skill-editor.d.ts +107 -0
- 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 +160 -0
- package/usage.d.ts +120 -0
- package/usage.js +3 -0
|
@@ -4,31 +4,38 @@ import { useCallback as n, useEffect as r, useMemo as i, useRef as a } from "rea
|
|
|
4
4
|
import { isMimeTypeAllowed as o, mimeTypesToExtensionLabels as s } from "@epam/ai-dial-attachment-input";
|
|
5
5
|
//#region src/attachment/useAttachmentValidation/useAttachmentValidation.ts
|
|
6
6
|
var c = 100, l = /* @__PURE__ */ function(e) {
|
|
7
|
-
return e.NoTypesAllowed = "noTypesAllowed", e.UnsupportedType = "unsupportedType", e;
|
|
8
|
-
}({}), u = ({ allowedMimeTypes: l,
|
|
9
|
-
let
|
|
10
|
-
(
|
|
11
|
-
let
|
|
7
|
+
return e.NoTypesAllowed = "noTypesAllowed", e.UnsupportedType = "unsupportedType", e.FileTooLarge = "fileTooLarge", e;
|
|
8
|
+
}({}), u = ({ allowedMimeTypes: l, maxFileSizeBytes: u, onValidationError: d, debounceMs: f = c }) => {
|
|
9
|
+
let p = a(l);
|
|
10
|
+
(p.current.length !== l.length || p.current.some((e, t) => e !== l[t])) && (p.current = l);
|
|
11
|
+
let m = p.current, h = m.length > 0, g = i(() => e(m), [m]), _ = a(null), v = a(null);
|
|
12
12
|
return r(() => () => {
|
|
13
|
-
|
|
13
|
+
_.current != null && clearTimeout(_.current), v.current != null && clearTimeout(v.current);
|
|
14
14
|
}, []), {
|
|
15
|
-
inputAttachmentTypes:
|
|
16
|
-
isAttachmentsAllowed:
|
|
15
|
+
inputAttachmentTypes: m,
|
|
16
|
+
isAttachmentsAllowed: h,
|
|
17
17
|
validateAttachment: n((e) => {
|
|
18
|
-
if (!o(e.contentType,
|
|
19
|
-
let e =
|
|
20
|
-
|
|
18
|
+
if (!o(e.contentType, m)) return _.current != null && clearTimeout(_.current), _.current = setTimeout(() => {
|
|
19
|
+
let e = m.length === 0;
|
|
20
|
+
d?.({
|
|
21
21
|
reason: e ? "noTypesAllowed" : "unsupportedType",
|
|
22
|
-
allowedMimeTypes:
|
|
23
|
-
...e ? {} : { formats: s(
|
|
24
|
-
}),
|
|
25
|
-
},
|
|
22
|
+
allowedMimeTypes: m,
|
|
23
|
+
...e ? {} : { formats: s(m) }
|
|
24
|
+
}), _.current = null;
|
|
25
|
+
}, f), t.UnsupportedType;
|
|
26
|
+
if (u != null && e.file.size > u) return v.current != null && clearTimeout(v.current), v.current = setTimeout(() => {
|
|
27
|
+
d?.({
|
|
28
|
+
reason: "fileTooLarge",
|
|
29
|
+
maxFileSizeBytes: u
|
|
30
|
+
}), v.current = null;
|
|
31
|
+
}, f), t.FileTooLarge;
|
|
26
32
|
}, [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
m,
|
|
34
|
+
u,
|
|
35
|
+
f,
|
|
36
|
+
d
|
|
30
37
|
]),
|
|
31
|
-
fileAccept:
|
|
38
|
+
fileAccept: g
|
|
32
39
|
};
|
|
33
40
|
};
|
|
34
41
|
//#endregion
|
package/attachments.d.ts
CHANGED
|
@@ -6,10 +6,12 @@ import { DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
|
6
6
|
export declare interface AttachmentValidationErrorEvent {
|
|
7
7
|
/** Why the attachment(s) were rejected. */
|
|
8
8
|
reason: AttachmentValidationErrorReason;
|
|
9
|
-
/** The resolved MIME types the caller currently allows (possibly empty). */
|
|
10
|
-
allowedMimeTypes
|
|
9
|
+
/** The resolved MIME types the caller currently allows (possibly empty). Present only when `reason` is `NoTypesAllowed` or `UnsupportedType`. */
|
|
10
|
+
allowedMimeTypes?: string[];
|
|
11
11
|
/** Already-formatted, non-translated extension list (e.g. ".png, .jpg"), present only when `reason` is `UnsupportedType`. */
|
|
12
12
|
formats?: string;
|
|
13
|
+
/** The size limit, in bytes, that was exceeded. Present only when `reason` is `FileTooLarge`. */
|
|
14
|
+
maxFileSizeBytes?: number;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
/** Reason a rejected attachment failed validation. */
|
|
@@ -17,7 +19,9 @@ export declare enum AttachmentValidationErrorReason {
|
|
|
17
19
|
/** No MIME types are allowed at all — attachments are disabled entirely. */
|
|
18
20
|
NoTypesAllowed = "noTypesAllowed",
|
|
19
21
|
/** The attachment's content type is not among the allowed MIME types. */
|
|
20
|
-
UnsupportedType = "unsupportedType"
|
|
22
|
+
UnsupportedType = "unsupportedType",
|
|
23
|
+
/** The attachment's file size exceeds `maxFileSizeBytes`. */
|
|
24
|
+
FileTooLarge = "fileTooLarge"
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
/**
|
|
@@ -61,12 +65,14 @@ export declare interface UseAttachmentActionResult {
|
|
|
61
65
|
* MIME types, debouncing a burst of rejected files into a single
|
|
62
66
|
* `onValidationError` call rather than firing one per file.
|
|
63
67
|
*/
|
|
64
|
-
export declare const useAttachmentValidation: ({ allowedMimeTypes, onValidationError, debounceMs, }: UseAttachmentValidationParams) => UseAttachmentValidationResult;
|
|
68
|
+
export declare const useAttachmentValidation: ({ allowedMimeTypes, maxFileSizeBytes, onValidationError, debounceMs, }: UseAttachmentValidationParams) => UseAttachmentValidationResult;
|
|
65
69
|
|
|
66
70
|
/** Parameters for {@link useAttachmentValidation}. */
|
|
67
71
|
export declare interface UseAttachmentValidationParams {
|
|
68
72
|
/** Resolved MIME types currently allowed for attachments. */
|
|
69
73
|
allowedMimeTypes: string[];
|
|
74
|
+
/** Maximum attachment file size, in bytes. When omitted, no file is rejected for size. */
|
|
75
|
+
maxFileSizeBytes?: number;
|
|
70
76
|
/** Called with a structured event when a rejected attachment is reported, at most once per debounce window. */
|
|
71
77
|
onValidationError?: (event: AttachmentValidationErrorEvent) => void;
|
|
72
78
|
/** Debounce window, in ms, before firing `onValidationError` for a rejected file. Defaults to `100`. */
|
|
@@ -31,11 +31,11 @@ var c = {
|
|
|
31
31
|
}, f = "applications/", p = "toolsets/", m = "public", h = (t, n) => (t.startsWith(n) ? t.slice(n.length) : t).split("/").filter(Boolean).map(e), g = (e, t) => {
|
|
32
32
|
if (e.isMy) return [t.personal];
|
|
33
33
|
let n = h(e.applicationFolder ?? "", f);
|
|
34
|
-
return e.sharedWithMe ? [t.shared, ...n.slice(1)] : n[0]?.toLowerCase() === m ? [t.public, ...n.slice(1)] : n;
|
|
34
|
+
return e.sharedWithMe ? [t.shared, ...n.slice(1)] : n.length === 0 && e.type?.toLowerCase() === "application" ? [t.public] : n[0]?.toLowerCase() === m ? [t.public, ...n.slice(1)] : n;
|
|
35
35
|
}, _ = (e, t) => {
|
|
36
36
|
if (e.isMy && t != null) return [t.personal];
|
|
37
37
|
let n = e.toolset || e.id;
|
|
38
|
-
if (!n.startsWith(p)) return [];
|
|
38
|
+
if (!n.startsWith(p)) return t == null ? [] : e.sharedWithMe ? [t.shared] : n.length > 0 && !n.includes("/") ? [t.public] : [];
|
|
39
39
|
let r = h(n, p).slice(0, -1);
|
|
40
40
|
return e.sharedWithMe && t != null ? [t.shared, ...r.slice(1)] : r[0]?.toLowerCase() === m && t != null ? [t.public, ...r.slice(1)] : r.slice(1);
|
|
41
41
|
}, v = (e, { favoriteIds: t = /* @__PURE__ */ new Set(), entityDetails: o, folderLabels: s, editableSchemaIds: c = [], isCustomAppsEditable: l = !1, activeLocale: u, primaryLocale: f, resolveIconUrl: p }) => {
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { formatCalendarDate as
|
|
1
|
+
import { stripSurroundingSlashes as e } from "../shared/string-utils.js";
|
|
2
|
+
import { formatCalendarDate as t } from "../shared/formatting.js";
|
|
3
3
|
import "../skill/skill.js";
|
|
4
|
-
import { SkillSource as
|
|
5
|
-
import { CatalogEntityType as
|
|
6
|
-
import { CatalogContentNodeType as
|
|
7
|
-
import { SkillMetadataItemDtoNodeTypeEnum as
|
|
4
|
+
import { SkillSource as n } from "../skill/skill-types.js";
|
|
5
|
+
import { CatalogEntityType as r, formatLastUsed as i } from "@epam/ai-dial-chat-shared";
|
|
6
|
+
import { CatalogContentNodeType as a } from "@epam/ai-dial-catalog";
|
|
7
|
+
import { SkillMetadataItemDtoNodeTypeEnum as o } from "@epam/ai-dial-chat-api-client";
|
|
8
8
|
//#region src/catalog/map-skill-to-catalog-item.ts
|
|
9
|
-
var
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
},
|
|
14
|
-
let s = o.has(e.url),
|
|
9
|
+
var s = {
|
|
10
|
+
[n.Personal]: "personal",
|
|
11
|
+
[n.SharedWithMe]: "shared",
|
|
12
|
+
[n.Public]: "public"
|
|
13
|
+
}, c = (e, t, n) => [n[s[t]], ...(e ?? "").split("/").filter(Boolean)], l = (e, { folderLabels: t, source: a, favoriteIds: o }) => {
|
|
14
|
+
let s = o.has(e.url), l = a === n.Public, u = a === n.Personal;
|
|
15
15
|
return {
|
|
16
16
|
id: e.url,
|
|
17
|
-
type:
|
|
17
|
+
type: r.Skill,
|
|
18
18
|
name: e.name,
|
|
19
19
|
description: e.description ?? "",
|
|
20
20
|
version: "",
|
|
21
|
-
lastUsed:
|
|
21
|
+
lastUsed: i(e.updatedAt),
|
|
22
22
|
createdAt: e.createdAt,
|
|
23
23
|
updatedAt: e.updatedAt,
|
|
24
24
|
isFeatured: !1,
|
|
@@ -27,11 +27,11 @@ var c = {
|
|
|
27
27
|
isUserFavorite: s,
|
|
28
28
|
isStarred: s,
|
|
29
29
|
isMyApp: u && (e.isMy ?? !0),
|
|
30
|
-
sharedWithMe: e.sharedWithMe ??
|
|
31
|
-
isEditable: !
|
|
32
|
-
folder:
|
|
30
|
+
sharedWithMe: e.sharedWithMe ?? a === n.SharedWithMe,
|
|
31
|
+
isEditable: !l && (e.canEdit ?? u),
|
|
32
|
+
folder: c(e.parentPath, a, t)
|
|
33
33
|
};
|
|
34
|
-
},
|
|
34
|
+
}, u = (e) => e.join(" · "), d = (e, t) => {
|
|
35
35
|
if (e == null) return null;
|
|
36
36
|
let n = [];
|
|
37
37
|
return e.whenToUse != null && n.push({
|
|
@@ -39,25 +39,25 @@ var c = {
|
|
|
39
39
|
value: e.whenToUse
|
|
40
40
|
}), e.allowedTools?.length && n.push({
|
|
41
41
|
label: t.allowedToolsLabel,
|
|
42
|
-
value:
|
|
42
|
+
value: u(e.allowedTools)
|
|
43
43
|
}), e.bundledResources?.length && n.push({
|
|
44
44
|
label: t.bundledResourcesLabel,
|
|
45
|
-
value:
|
|
45
|
+
value: u(e.bundledResources)
|
|
46
46
|
}), n.length === 0 ? null : {
|
|
47
47
|
title: t.specificationSectionTitle,
|
|
48
48
|
specs: n
|
|
49
49
|
};
|
|
50
|
-
},
|
|
51
|
-
let r =
|
|
52
|
-
return
|
|
53
|
-
let n = t
|
|
50
|
+
}, f = (e) => e.filter((e) => e.nodeType === o.Item), p = (t, n) => {
|
|
51
|
+
let r = e(n), i = r ? `${r}/files` : "files";
|
|
52
|
+
return f(t).find((t) => {
|
|
53
|
+
let n = e(t.path);
|
|
54
54
|
return n === "SKILL.md" || n === "files/SKILL.md" || n === `${i}/SKILL.md`;
|
|
55
55
|
})?.path ?? "SKILL.md";
|
|
56
|
-
},
|
|
57
|
-
let r = t
|
|
56
|
+
}, m = (t, n) => {
|
|
57
|
+
let r = e(t), i = e(n), a = i ? `${i}/files` : "files";
|
|
58
58
|
return r === "" || r === "files" || r === a ? null : r.startsWith(`${a}/`) ? r.slice(a.length + 1) : r.startsWith("files/") ? r.slice(6) : r;
|
|
59
|
-
},
|
|
60
|
-
let a = [], o =
|
|
59
|
+
}, h = (e, t) => m(e, t), g = (e, n, r, i) => {
|
|
60
|
+
let a = [], o = d(r, i);
|
|
61
61
|
o != null && a.push(o);
|
|
62
62
|
let s = [];
|
|
63
63
|
return e?.author && s.push({
|
|
@@ -65,26 +65,26 @@ var c = {
|
|
|
65
65
|
value: e.author
|
|
66
66
|
}), s.push({
|
|
67
67
|
label: i.updatedLabel,
|
|
68
|
-
value: e?.updatedAt ?
|
|
68
|
+
value: e?.updatedAt ? t(e.updatedAt) : ""
|
|
69
69
|
}), s.push({
|
|
70
70
|
label: i.fileCountLabel,
|
|
71
|
-
value: String(
|
|
71
|
+
value: String(f(n).length)
|
|
72
72
|
}), a.push({
|
|
73
73
|
title: i.detailsSectionTitle,
|
|
74
74
|
specs: s
|
|
75
75
|
}), { sections: a };
|
|
76
|
-
},
|
|
76
|
+
}, _ = (e, t, n) => {
|
|
77
77
|
if (e === "") return n;
|
|
78
78
|
let r = t.get(e);
|
|
79
79
|
if (r != null) return r.items;
|
|
80
|
-
let i = e.split("/"),
|
|
81
|
-
type:
|
|
80
|
+
let i = e.split("/"), o = _(i.slice(0, -1).join("/"), t, n), s = {
|
|
81
|
+
type: a.Folder,
|
|
82
82
|
id: e,
|
|
83
83
|
name: i[i.length - 1],
|
|
84
84
|
items: []
|
|
85
85
|
};
|
|
86
|
-
return t.set(e, s),
|
|
87
|
-
},
|
|
86
|
+
return t.set(e, s), o.push(s), s.items;
|
|
87
|
+
}, v = (e, t) => {
|
|
88
88
|
e.sort((e, n) => {
|
|
89
89
|
if (t) {
|
|
90
90
|
if (e.name === "SKILL.md") return -1;
|
|
@@ -92,32 +92,32 @@ var c = {
|
|
|
92
92
|
}
|
|
93
93
|
return e.name.localeCompare(n.name);
|
|
94
94
|
});
|
|
95
|
-
for (let t of e) t.type ===
|
|
96
|
-
},
|
|
95
|
+
for (let t of e) t.type === a.Folder && v(t.items, !1);
|
|
96
|
+
}, y = (e, t) => {
|
|
97
97
|
let n = /* @__PURE__ */ new Map(), r = [];
|
|
98
98
|
for (let i of e) {
|
|
99
|
-
let e =
|
|
99
|
+
let e = m(i.path, t);
|
|
100
100
|
if (e == null) continue;
|
|
101
|
-
if (i.nodeType ===
|
|
102
|
-
|
|
101
|
+
if (i.nodeType === o.Folder) {
|
|
102
|
+
_(e, n, r);
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
|
-
let
|
|
106
|
-
|
|
107
|
-
type:
|
|
105
|
+
let s = e.lastIndexOf("/");
|
|
106
|
+
_(s === -1 ? "" : e.slice(0, s), n, r).push({
|
|
107
|
+
type: a.File,
|
|
108
108
|
id: i.path,
|
|
109
109
|
name: i.name
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
return
|
|
113
|
-
},
|
|
112
|
+
return v(r, !0), r;
|
|
113
|
+
}, b = async (e) => {
|
|
114
114
|
let t = Number(e.headers.get("content-length"));
|
|
115
115
|
if (Number.isFinite(t) && t > 262144) return null;
|
|
116
116
|
let n = await e.arrayBuffer();
|
|
117
117
|
return n.byteLength > 262144 ? null : new Uint8Array(n);
|
|
118
|
-
}, S = async (e) => {
|
|
119
|
-
let t = await
|
|
118
|
+
}, x = async (e) => new Uint8Array(await e.arrayBuffer()), S = async (e) => {
|
|
119
|
+
let t = await b(e);
|
|
120
120
|
return t == null ? null : new TextDecoder().decode(t);
|
|
121
121
|
};
|
|
122
122
|
//#endregion
|
|
123
|
-
export {
|
|
123
|
+
export { y as buildSkillContentTree, g as buildSkillOverview, l as mapSkillToCatalogItem, b as readSkillFileBytes, x as readSkillFilePreviewBytes, S as readSkillManifest, h as resolveSkillFileDownloadPath, p as resolveSkillManifestFileId };
|
package/catalog/publish.js
CHANGED
|
@@ -10,7 +10,8 @@ var n = {
|
|
|
10
10
|
}, r = (e) => n[e], i = "public", a = (e) => e.split("/")[1] === i, o = (t) => a(t) ? t.split("/").slice(2, -1).map(e) : [], s = (e) => ({
|
|
11
11
|
version: e.version,
|
|
12
12
|
publishedAt: Date.parse(e.publishedAt),
|
|
13
|
-
folderPath: e.folderPath.split("/").filter(Boolean)
|
|
13
|
+
folderPath: e.folderPath.split("/").filter(Boolean),
|
|
14
|
+
publishCredentials: e.publishCredentials
|
|
14
15
|
}), c = (e) => ({
|
|
15
16
|
publishedAt: Date.parse(e.publishedAt),
|
|
16
17
|
folderPath: e.folderPath.split("/").filter(Boolean)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
//#region src/catalog/useApplicationCredentials/useApplicationCredentials.ts
|
|
3
|
+
var i = ({ appId: i, externalServicesClient: a, offlineCredentialsClient: o }) => {
|
|
4
|
+
let [s, c] = r([]), [l, u] = r(!1), [d, f] = r(!0), [p, m] = r(!1), h = n(0), g = n(null), _ = e(async () => {
|
|
5
|
+
if (g.current !== i) return;
|
|
6
|
+
let e = ++h.current;
|
|
7
|
+
f(!0), m(!1);
|
|
8
|
+
try {
|
|
9
|
+
let t = await a.listExternalServices({ appId: i });
|
|
10
|
+
if (h.current !== e) return;
|
|
11
|
+
let n = t.some((e) => e.authenticationType === "DIAL_NATIVE") ? await o.getOfflineCredentials() : void 0;
|
|
12
|
+
if (h.current !== e) return;
|
|
13
|
+
c(t.filter((e) => e.authenticationType !== "NONE")), u(n?.connected ?? !1);
|
|
14
|
+
} catch {
|
|
15
|
+
h.current === e && m(!0);
|
|
16
|
+
} finally {
|
|
17
|
+
h.current === e && f(!1);
|
|
18
|
+
}
|
|
19
|
+
}, [
|
|
20
|
+
i,
|
|
21
|
+
a,
|
|
22
|
+
o
|
|
23
|
+
]), v = e(() => {
|
|
24
|
+
g.current = null, h.current++;
|
|
25
|
+
}, []);
|
|
26
|
+
return t(() => (g.current = i, c([]), f(!0), u(!1), _(), v), [
|
|
27
|
+
i,
|
|
28
|
+
_,
|
|
29
|
+
v
|
|
30
|
+
]), {
|
|
31
|
+
services: s,
|
|
32
|
+
isOfflineConnected: l,
|
|
33
|
+
isLoading: d,
|
|
34
|
+
hasError: p,
|
|
35
|
+
refresh: _
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { i as useApplicationCredentials };
|
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import { SkillSource as e } from "../../skill/skill-types.js";
|
|
2
2
|
import { mapSkillToCatalogItem as t } from "../map-skill-to-catalog-item.js";
|
|
3
3
|
import { useSkillItemDetails as n } from "../useSkillItemDetails.js";
|
|
4
|
-
import { useEffect as r, useMemo as i,
|
|
4
|
+
import { useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
5
5
|
//#region src/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.ts
|
|
6
|
-
var
|
|
7
|
-
let
|
|
8
|
-
...
|
|
9
|
-
...
|
|
10
|
-
...
|
|
6
|
+
var s = ({ api: s, skills: c, sharedWithMe: l, publicSkills: u, skillId: d, folderLabels: f, skillOverviewLabels: p, favoriteIds: m }) => {
|
|
7
|
+
let h = i(() => [
|
|
8
|
+
...c,
|
|
9
|
+
...l ?? [],
|
|
10
|
+
...u ?? []
|
|
11
11
|
], [
|
|
12
|
-
s,
|
|
13
|
-
c,
|
|
14
|
-
l
|
|
15
|
-
]), { onFetchSkillDetails: h, onLoadSkillDetailsFile: g } = n({
|
|
16
|
-
api: o,
|
|
17
|
-
skills: m,
|
|
18
|
-
skillOverviewLabels: f
|
|
19
|
-
}), _ = i(() => m.find((e) => e.url === u) ?? null, [m, u]), v = i(() => s.some((e) => e.url === u) ? e.Personal : c?.some((e) => e.url === u) ? e.SharedWithMe : e.Public, [
|
|
20
|
-
s,
|
|
21
12
|
c,
|
|
13
|
+
l,
|
|
22
14
|
u
|
|
23
|
-
]),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
]), { onFetchSkillDetails: g, onLoadSkillDetailsFile: _ } = n({
|
|
16
|
+
api: s,
|
|
17
|
+
skills: h,
|
|
18
|
+
skillOverviewLabels: p
|
|
19
|
+
}), v = i(() => h.find((e) => e.url === d) ?? null, [h, d]), y = i(() => c.some((e) => e.url === d) ? e.Personal : l?.some((e) => e.url === d) ? e.SharedWithMe : e.Public, [
|
|
20
|
+
c,
|
|
21
|
+
l,
|
|
22
|
+
d
|
|
23
|
+
]), b = i(() => v == null ? null : t(v, {
|
|
24
|
+
folderLabels: f,
|
|
25
|
+
source: y,
|
|
26
|
+
favoriteIds: m
|
|
27
27
|
}), [
|
|
28
|
-
_,
|
|
29
28
|
v,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
y,
|
|
30
|
+
f,
|
|
31
|
+
m
|
|
32
|
+
]), [x, S] = o(null), [C, w] = o(!1), T = a(0);
|
|
33
33
|
return r(() => {
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
let e = !1;
|
|
37
|
-
return
|
|
38
|
-
e || (
|
|
34
|
+
if (b == null) return;
|
|
35
|
+
w(!0), S(null);
|
|
36
|
+
let e = !1, t = ++T.current;
|
|
37
|
+
return g(b).then((n) => {
|
|
38
|
+
e || T.current !== t || (S(n ?? null), w(!1));
|
|
39
39
|
}), () => {
|
|
40
40
|
e = !0;
|
|
41
41
|
};
|
|
42
|
-
}, [
|
|
42
|
+
}, [b?.id]), {
|
|
43
43
|
detailsPanelItem: i(() => {
|
|
44
|
-
if (
|
|
45
|
-
if (
|
|
46
|
-
let { credentials: e, ...t } =
|
|
44
|
+
if (b == null) return null;
|
|
45
|
+
if (x == null) return b;
|
|
46
|
+
let { credentials: e, ...t } = x;
|
|
47
47
|
return {
|
|
48
|
-
...
|
|
48
|
+
...b,
|
|
49
49
|
details: t,
|
|
50
|
-
credentials: e ??
|
|
50
|
+
credentials: e ?? b.credentials
|
|
51
51
|
};
|
|
52
|
-
}, [
|
|
53
|
-
isDetailsLoading:
|
|
54
|
-
isStarred:
|
|
55
|
-
onLoadSkillDetailsFile:
|
|
52
|
+
}, [b, x]),
|
|
53
|
+
isDetailsLoading: C,
|
|
54
|
+
isStarred: b != null && m.has(b.id),
|
|
55
|
+
onLoadSkillDetailsFile: _
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
//#endregion
|
|
59
|
-
export {
|
|
59
|
+
export { s as useSkillDetailsPanelData };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SKILL_MANIFEST_FILE as e } from "../skill/skill.js";
|
|
2
2
|
import { parseSkillResourceUrl as t } from "../skill/skill-types.js";
|
|
3
|
-
import { buildSkillContentTree as n, buildSkillOverview as r,
|
|
3
|
+
import { buildSkillContentTree as n, buildSkillOverview as r, readSkillFilePreviewBytes as i, readSkillManifest as a, resolveSkillFileDownloadPath as o, resolveSkillManifestFileId as s } from "./map-skill-to-catalog-item.js";
|
|
4
4
|
import { parseSkillManifestDocument as c } from "../skill/skill-manifest.js";
|
|
5
5
|
import { useCallback as l, useRef as u } from "react";
|
|
6
6
|
//#region src/catalog/useSkillItemDetails.ts
|
|
@@ -12,20 +12,24 @@ var d = ({ api: d, skills: f, skillOverviewLabels: p }) => {
|
|
|
12
12
|
if (o == null) return;
|
|
13
13
|
let { bucket: l, path: u } = o;
|
|
14
14
|
m.current = o;
|
|
15
|
-
let [h, g] = await Promise.allSettled([
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
let [h, g, _] = await Promise.allSettled([
|
|
16
|
+
d.downloadSkillFile(l, u, e).then(a),
|
|
17
|
+
d.listSkillFiles({
|
|
18
|
+
bucket: l,
|
|
19
|
+
path: u,
|
|
20
|
+
filePath: "",
|
|
21
|
+
recursive: !0
|
|
22
|
+
}),
|
|
23
|
+
d.getSkillMetadata(l, u)
|
|
24
|
+
]), v = h.status === "fulfilled" && h.value != null ? c(h.value) : void 0, y = _.status === "fulfilled" ? _.value : f.find((e) => e.url === i.id), b = g.status === "fulfilled" ? r(y, g.value.items, v?.about, p) : void 0, x = g.status === "fulfilled" ? n(g.value.items, u) : [], S = g.status === "fulfilled" ? s(g.value.items, u) : e;
|
|
25
|
+
if (!(v == null && b == null)) return {
|
|
26
|
+
...v == null ? {} : { promptContent: {
|
|
27
|
+
content: v.body,
|
|
28
|
+
...v.description == null ? {} : { description: v.description },
|
|
29
|
+
files: x,
|
|
30
|
+
selectedFileId: S
|
|
27
31
|
} },
|
|
28
|
-
...
|
|
32
|
+
...b == null ? {} : { overview: b }
|
|
29
33
|
};
|
|
30
34
|
}, [
|
|
31
35
|
d,
|
|
@@ -47,9 +51,7 @@ var d = ({ api: d, skills: f, skillOverviewLabels: p }) => {
|
|
|
47
51
|
if (n == null) throw Error("A folder cannot be previewed");
|
|
48
52
|
let r = await d.downloadSkillFile(t.bucket, t.path, n);
|
|
49
53
|
if (!r.ok) throw Object.assign(/* @__PURE__ */ Error(`File preview failed with status ${r.status}`), { status: r.status });
|
|
50
|
-
let a = await i(r);
|
|
51
|
-
if (a == null) throw Error("File exceeds the preview size limit");
|
|
52
|
-
let s = r.headers.get("content-type")?.split(";")[0].trim() || void 0;
|
|
54
|
+
let a = await i(r), s = r.headers.get("content-type")?.split(";")[0].trim() || void 0;
|
|
53
55
|
return {
|
|
54
56
|
bytes: a,
|
|
55
57
|
mimeType: s === "application/octet-stream" ? void 0 : s
|
package/catalog.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ApplicationExternalServiceDto } from '@epam/ai-dial-chat-api-client';
|
|
1
2
|
import { CatalogContentTreeNode } from '@epam/ai-dial-catalog';
|
|
2
3
|
import { CatalogEntityType } from '@epam/ai-dial-chat-shared';
|
|
3
4
|
import { CatalogItem } from '@epam/ai-dial-catalog';
|
|
@@ -14,8 +15,10 @@ import { DeploymentLimitsResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
|
14
15
|
import { DialToolsetAuthSettingsDto } from '@epam/ai-dial-chat-api-client';
|
|
15
16
|
import { DialToolsetDto } from '@epam/ai-dial-chat-api-client';
|
|
16
17
|
import { DropdownItem } from '@epam/ai-dial-ui-kit';
|
|
18
|
+
import { ExternalServicesApi } from '@epam/ai-dial-chat-api-client';
|
|
17
19
|
import { ListFilesResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
18
20
|
import { NotificationVariant } from '@epam/ai-dial-ui-kit';
|
|
21
|
+
import { OfflineCredentialsApi } from '@epam/ai-dial-chat-api-client';
|
|
19
22
|
import { PromptResponseDto } from '@epam/ai-dial-chat-api-client';
|
|
20
23
|
import { PublicationRule } from '@epam/ai-dial-publish-panel';
|
|
21
24
|
import { PublishApi } from '@epam/ai-dial-chat-api-client';
|
|
@@ -132,6 +135,13 @@ export declare const buildSkillContentTree: (files: SkillMetadataItemDto[], skil
|
|
|
132
135
|
* authored it, when it last changed, and its file inventory. Grouping folders
|
|
133
136
|
* in the file listing are excluded from both the count and the rows. Sizes are
|
|
134
137
|
* not shown — the skill metadata carries no content-length field.
|
|
138
|
+
*
|
|
139
|
+
* `skill` is the authoritative `getSkillMetadata` response when that request
|
|
140
|
+
* fulfilled; the caller falls back to the catalog listing entry only when it
|
|
141
|
+
* rejected (`useSkillItemDetails`'s `onFetchSkillDetails`). Either way, this
|
|
142
|
+
* function never fills a gap in one source from the other — an absent
|
|
143
|
+
* `author` omits the row and an absent `updatedAt` leaves the updated row's
|
|
144
|
+
* value empty, exactly as `skill` carries it.
|
|
135
145
|
*/
|
|
136
146
|
export declare const buildSkillOverview: (skill: SkillMetadataItemDto | undefined, files: SkillMetadataItemDto[], about: SkillAboutDetails | undefined, labels: SkillOverviewLabels) => CatalogItemOverview;
|
|
137
147
|
|
|
@@ -652,6 +662,24 @@ export declare interface PublishApiClient {
|
|
|
652
662
|
*/
|
|
653
663
|
export declare const readSkillFileBytes: (response: Response) => Promise<Uint8Array | null>;
|
|
654
664
|
|
|
665
|
+
/**
|
|
666
|
+
* Reads a skill file response as raw bytes with no size ceiling, for the
|
|
667
|
+
* supporting-file **preview** path.
|
|
668
|
+
*
|
|
669
|
+
* Previews are user-initiated, one file at a time, and a realistic binary
|
|
670
|
+
* (a PDF, an image) routinely exceeds `SKILL_MANIFEST_MAX_BYTES` — a cap
|
|
671
|
+
* sized for `SKILL.md` frontmatter, not for binaries — so applying that cap
|
|
672
|
+
* here rejected virtually every real PDF before it was ever decoded. This
|
|
673
|
+
* reader therefore never returns `null`: file size is not a failure class on
|
|
674
|
+
* the preview path.
|
|
675
|
+
*
|
|
676
|
+
* `readSkillFileBytes` and `readSkillManifest` keep their
|
|
677
|
+
* `SKILL_MANIFEST_MAX_BYTES` ceiling, because they feed the manifest parse
|
|
678
|
+
* and the textual Content-tab read, where an oversized body must never be
|
|
679
|
+
* decoded into a string.
|
|
680
|
+
*/
|
|
681
|
+
export declare const readSkillFilePreviewBytes: (response: Response) => Promise<Uint8Array>;
|
|
682
|
+
|
|
655
683
|
/**
|
|
656
684
|
* Reads a skill manifest response as text, or `null` when the body is larger
|
|
657
685
|
* than `SKILL_MANIFEST_MAX_BYTES`. The size is checked before decoding, so an
|
|
@@ -681,7 +709,8 @@ export declare const reconcileFilterTopics: (persistedTopics: ReadonlySet<string
|
|
|
681
709
|
*/
|
|
682
710
|
export declare const resolveCatalogPrimaryAction: (item: CatalogItem, fetchPrompt: (item: CatalogItem) => Promise<PromptResponseDto>) => Promise<CatalogPrimaryActionResult>;
|
|
683
711
|
|
|
684
|
-
|
|
712
|
+
/** Resolves a deployment's display folder, including organization applications without a folder path. */
|
|
713
|
+
export declare const resolveDeploymentFolder: (deployment: Pick<DeploymentItemDto, "isMy" | "sharedWithMe" | "applicationFolder"> & Partial<Pick<DeploymentItemDto, "type">>, labels: DeploymentFolderLabels) => string[];
|
|
685
714
|
|
|
686
715
|
/** Returns the MCP resource kind a catalog item's Connect endpoint belongs to, or `null` when the item exposes no MCP endpoint. */
|
|
687
716
|
export declare const resolveMcpResourceKind: (type: CatalogEntityType, supportsMcp?: boolean) => McpResourceKind | null;
|
|
@@ -738,6 +767,12 @@ export declare interface SkillDetailsApi {
|
|
|
738
767
|
limit?: number;
|
|
739
768
|
recursive?: boolean;
|
|
740
769
|
}, signal?: AbortSignal): Promise<SkillFileListResponseDto>;
|
|
770
|
+
/**
|
|
771
|
+
* Fetches a single skill's own authoritative metadata (`author`,
|
|
772
|
+
* `updatedAt`, and the rest of `SkillMetadataItemDto`) — not the catalog
|
|
773
|
+
* listing entry, which may be sparse for a shared skill.
|
|
774
|
+
*/
|
|
775
|
+
getSkillMetadata(bucket: string, path: string, signal?: AbortSignal): Promise<SkillMetadataItemDto>;
|
|
741
776
|
}
|
|
742
777
|
|
|
743
778
|
/** A skill's parsed manifest details. */
|
|
@@ -880,6 +915,25 @@ export declare const toPublishEntityType: (type: CatalogEntityType) => CatalogPu
|
|
|
880
915
|
*/
|
|
881
916
|
export declare const toPublishRuleDto: (rule: PublicationRule) => PublishRuleDto;
|
|
882
917
|
|
|
918
|
+
/** Loads fresh service statuses without coupling proactive credentials to a live completion. */
|
|
919
|
+
export declare const useApplicationCredentials: ({ appId, externalServicesClient, offlineCredentialsClient, }: UseApplicationCredentialsParams) => {
|
|
920
|
+
services: ApplicationExternalServiceDto[];
|
|
921
|
+
isOfflineConnected: boolean;
|
|
922
|
+
isLoading: boolean;
|
|
923
|
+
hasError: boolean;
|
|
924
|
+
refresh: () => Promise<void>;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
/** Configured operations for loading application credential metadata. */
|
|
928
|
+
export declare interface UseApplicationCredentialsParams {
|
|
929
|
+
/** Application identifier passed through to the configured client. */
|
|
930
|
+
appId: string;
|
|
931
|
+
/** Host-configured external-services API. */
|
|
932
|
+
externalServicesClient: Pick<ExternalServicesApi, 'listExternalServices'>;
|
|
933
|
+
/** Host-configured offline-credentials API. */
|
|
934
|
+
offlineCredentialsClient: Pick<OfflineCredentialsApi, 'getOfflineCredentials'>;
|
|
935
|
+
}
|
|
936
|
+
|
|
883
937
|
/**
|
|
884
938
|
* Owns the catalog's edit/delete/create-menu navigation: routing the details
|
|
885
939
|
* panel's Edit action to the right editor URL for each item type, deleting an
|
|
@@ -1199,10 +1253,11 @@ export declare interface UseSkillFilePreviewResult {
|
|
|
1199
1253
|
|
|
1200
1254
|
/**
|
|
1201
1255
|
* Headless hook that encapsulates skill detail fetching: manifest download and
|
|
1202
|
-
* parse, package file listing,
|
|
1203
|
-
* loads. `useCatalogItemDetails` delegates
|
|
1204
|
-
* only surface skill details consume this
|
|
1205
|
-
* deployment and prompt ports the full catalog
|
|
1256
|
+
* parse, package file listing, authoritative metadata fetching, overview
|
|
1257
|
+
* construction, and in-package file loads. `useCatalogItemDetails` delegates
|
|
1258
|
+
* its skill branch here; hosts that only surface skill details consume this
|
|
1259
|
+
* hook directly, without the deployment and prompt ports the full catalog
|
|
1260
|
+
* pipeline requires.
|
|
1206
1261
|
*/
|
|
1207
1262
|
export declare const useSkillItemDetails: ({ api, skills, skillOverviewLabels, }: UseSkillItemDetailsOptions) => UseSkillItemDetailsResult;
|
|
1208
1263
|
|