@epam/ai-dial-chat-hooks 1.4.0-dev.154 → 1.4.0-dev.159
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/entry-points/skill-editor.d.ts +1 -0
- package/entry-points/skill-editor.d.ts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +122 -121
- package/package.json +17 -17
- package/skill/skill-file-batch-validation.d.ts +4 -0
- package/skill/skill-file-batch-validation.d.ts.map +1 -1
- package/skill/skill-file-batch-validation.js +39 -39
- package/skill/types/skill-editor-submit.d.ts +8 -0
- package/skill/types/skill-editor-submit.d.ts.map +1 -0
- package/skill/types/skill-editor-submit.js +6 -0
- package/skill/useSkillEditorSubmit.d.ts +2 -3
- package/skill/useSkillEditorSubmit.d.ts.map +1 -1
- package/skill/useSkillEditorSubmit.js +103 -102
- package/skill/useSkillFileActions.d.ts +5 -1
- package/skill/useSkillFileActions.d.ts.map +1 -1
- package/skill/useSkillFileActions.js +53 -49
- package/skill-editor.js +7 -6
|
@@ -5,83 +5,87 @@ import { getUtf8ByteLength as s } from "@epam/ai-dial-chat-shared";
|
|
|
5
5
|
import { useCallback as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
6
6
|
import { SkillFileNodeKind as f } from "@epam/ai-dial-skill-editor";
|
|
7
7
|
//#region src/skill/useSkillFileActions.ts
|
|
8
|
-
var p = "probe", m = ({ maxFiles: m,
|
|
9
|
-
let [
|
|
10
|
-
let e =
|
|
8
|
+
var p = "probe", m = ({ maxFiles: m, maxFileBytes: h, maxTotalBytes: g, files: _, setFiles: v, filesContentRef: y, frontmatterRef: b, loadedValues: x, setLoadedValues: S, isEditMode: C, isDirty: w, setSelectedPath: T, messages: E, pickFromFileSystem: D }) => {
|
|
9
|
+
let [O, k] = d(!1), [A, j] = d({}), M = u(null), N = c(() => {
|
|
10
|
+
let e = _.filter((e) => e.kind === f.File).map((e) => e.path), r = 0, i = /* @__PURE__ */ new Map();
|
|
11
11
|
for (let t of e) {
|
|
12
|
-
let e =
|
|
12
|
+
let e = y.current.get(t)?.bytes.length ?? 0;
|
|
13
13
|
i.set(t, e), r += e;
|
|
14
14
|
}
|
|
15
15
|
let a = {
|
|
16
|
-
name:
|
|
17
|
-
description:
|
|
18
|
-
instructions:
|
|
19
|
-
}, o =
|
|
16
|
+
name: x?.name ?? "",
|
|
17
|
+
description: x?.description ?? "",
|
|
18
|
+
instructions: x?.instructions ?? ""
|
|
19
|
+
}, o = C ? n(b.current, a.name, a.description, a.instructions) : t(a);
|
|
20
20
|
return {
|
|
21
21
|
maxFiles: m,
|
|
22
|
+
maxFileBytes: h,
|
|
23
|
+
maxTotalBytes: g,
|
|
22
24
|
existingPaths: e,
|
|
23
25
|
existingTotalBytes: r,
|
|
24
26
|
existingFileBytes: i,
|
|
25
|
-
existingFolderPaths:
|
|
27
|
+
existingFolderPaths: _.filter((e) => e.kind === f.Folder).map((e) => e.path),
|
|
26
28
|
manifestByteLength: s(o),
|
|
27
|
-
messages:
|
|
29
|
+
messages: E
|
|
28
30
|
};
|
|
29
31
|
}, [
|
|
30
32
|
m,
|
|
31
33
|
h,
|
|
34
|
+
g,
|
|
32
35
|
_,
|
|
33
|
-
x,
|
|
34
|
-
v,
|
|
35
36
|
y,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
C,
|
|
38
|
+
b,
|
|
39
|
+
x,
|
|
40
|
+
E
|
|
41
|
+
]), P = c(() => new Promise((e) => {
|
|
42
|
+
M.current = e, k(!0);
|
|
43
|
+
}), []), F = c((e) => {
|
|
44
|
+
k(!1), M.current?.(e), M.current = null;
|
|
41
45
|
}, []);
|
|
42
46
|
return {
|
|
43
47
|
fileActions: l(() => ({
|
|
44
48
|
validateBatch: async (e) => {
|
|
45
|
-
let { results: t, batchErrors: n } = await a(e,
|
|
49
|
+
let { results: t, batchErrors: n } = await a(e, N());
|
|
46
50
|
return {
|
|
47
51
|
results: t,
|
|
48
52
|
batchErrors: n
|
|
49
53
|
};
|
|
50
54
|
},
|
|
51
55
|
commitBatch: async (e) => {
|
|
52
|
-
let { results: t, batchErrors: n, manifestCandidate: r } = await a(e,
|
|
53
|
-
if (t.some((e) => e.error !== void 0) || n.length > 0) return { error: n[0]?.message ??
|
|
56
|
+
let { results: t, batchErrors: n, manifestCandidate: r } = await a(e, N());
|
|
57
|
+
if (t.some((e) => e.error !== void 0) || n.length > 0) return { error: n[0]?.message ?? E.saveError };
|
|
54
58
|
if (r) {
|
|
55
|
-
if (
|
|
56
|
-
if ((
|
|
59
|
+
if (C && r.name !== (x?.name ?? "")) return { error: E.manifestNameMismatch };
|
|
60
|
+
if ((C || w) && !await P()) return { error: E.manifestImportDeclined };
|
|
57
61
|
}
|
|
58
62
|
try {
|
|
59
|
-
let t = e.filter((e) => e.id !== r?.candidateId), n = new Set(
|
|
63
|
+
let t = e.filter((e) => e.id !== r?.candidateId), n = new Set(_.filter((e) => e.kind === f.File).map((e) => e.path)), a = await Promise.all(t.map(async (e) => ({
|
|
60
64
|
path: e.path,
|
|
61
65
|
bytes: new Uint8Array(await e.file.arrayBuffer()),
|
|
62
66
|
mimeType: e.file.type || void 0,
|
|
63
67
|
isReplacement: n.has(e.path)
|
|
64
68
|
})));
|
|
65
|
-
for (let e of a)
|
|
69
|
+
for (let e of a) y.current.set(e.path, {
|
|
66
70
|
bytes: e.bytes,
|
|
67
71
|
mimeType: e.mimeType
|
|
68
72
|
});
|
|
69
73
|
let o = a.filter((e) => !e.isReplacement);
|
|
70
|
-
o.length > 0 &&
|
|
74
|
+
o.length > 0 && v((e) => [...e, ...o.map((e) => ({
|
|
71
75
|
path: e.path,
|
|
72
76
|
name: i(e.path),
|
|
73
77
|
kind: f.File
|
|
74
78
|
}))]);
|
|
75
79
|
let s = a.filter((e) => e.isReplacement).map((e) => e.path);
|
|
76
|
-
return s.length > 0 &&
|
|
80
|
+
return s.length > 0 && j((e) => {
|
|
77
81
|
let t = { ...e };
|
|
78
82
|
for (let e of s) t[e] = (t[e] ?? 0) + 1;
|
|
79
83
|
return t;
|
|
80
|
-
}), r && (
|
|
81
|
-
...
|
|
84
|
+
}), r && (b.current = C ? {
|
|
85
|
+
...b.current,
|
|
82
86
|
...r.frontmatter
|
|
83
|
-
} : r.frontmatter,
|
|
84
|
-
name:
|
|
87
|
+
} : r.frontmatter, S({
|
|
88
|
+
name: C ? x?.name ?? r.name : r.name,
|
|
85
89
|
description: r.description,
|
|
86
90
|
instructions: r.instructions
|
|
87
91
|
})), {};
|
|
@@ -90,38 +94,38 @@ var p = "probe", m = ({ maxFiles: m, files: h, setFiles: g, filesContentRef: _,
|
|
|
90
94
|
}
|
|
91
95
|
},
|
|
92
96
|
onRemoveNode: (t) => {
|
|
93
|
-
|
|
94
|
-
for (let e of [...
|
|
95
|
-
|
|
97
|
+
v((e) => e.filter((e) => e.path !== t && !e.path.startsWith(`${t}/`)));
|
|
98
|
+
for (let e of [...y.current.keys()]) (e === t || e.startsWith(`${t}/`)) && y.current.delete(e);
|
|
99
|
+
T((n) => n === t || n.startsWith(`${t}/`) ? e : n);
|
|
96
100
|
},
|
|
97
101
|
onCreateFolder: (e) => {
|
|
98
|
-
|
|
102
|
+
v((t) => t.some((t) => t.path === e) ? t : [...t, {
|
|
99
103
|
path: e,
|
|
100
104
|
name: i(e),
|
|
101
105
|
kind: f.Folder
|
|
102
106
|
}]);
|
|
103
107
|
},
|
|
104
|
-
validateFolderPath: (e) => r(`${e}/${p}`) ? void 0 :
|
|
108
|
+
validateFolderPath: (e) => r(`${e}/${p}`) ? void 0 : E.pathInvalid,
|
|
105
109
|
extractArchive: o,
|
|
106
|
-
pickFromFileSystem:
|
|
110
|
+
pickFromFileSystem: D
|
|
107
111
|
}), [
|
|
108
|
-
|
|
109
|
-
h,
|
|
110
|
-
x,
|
|
111
|
-
S,
|
|
112
|
-
y,
|
|
113
|
-
M,
|
|
112
|
+
N,
|
|
114
113
|
_,
|
|
115
|
-
v,
|
|
116
|
-
g,
|
|
117
|
-
b,
|
|
118
114
|
C,
|
|
119
115
|
w,
|
|
120
|
-
|
|
116
|
+
x,
|
|
117
|
+
P,
|
|
118
|
+
y,
|
|
119
|
+
b,
|
|
120
|
+
v,
|
|
121
|
+
S,
|
|
122
|
+
T,
|
|
123
|
+
E,
|
|
124
|
+
D
|
|
121
125
|
]),
|
|
122
|
-
pendingManifestImport:
|
|
123
|
-
resolveManifestImport:
|
|
124
|
-
contentRevisions:
|
|
126
|
+
pendingManifestImport: O,
|
|
127
|
+
resolveManifestImport: F,
|
|
128
|
+
contentRevisions: A
|
|
125
129
|
};
|
|
126
130
|
};
|
|
127
131
|
//#endregion
|
package/skill-editor.js
CHANGED
|
@@ -3,9 +3,10 @@ import { parseSkillManifestDocument as b } from "./skill/skill-manifest.js";
|
|
|
3
3
|
import { validateSkillFileBatch as x } from "./skill/skill-file-batch-validation.js";
|
|
4
4
|
import { skillFileToAttachment as S } from "./skill/skill-file-preview.js";
|
|
5
5
|
import { SkillEditorLoadState as C, useSkillEditorLoad as w } from "./skill/useSkillEditorLoad.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
6
|
+
import { SkillEditorSubmitPhase as T } from "./skill/types/skill-editor-submit.js";
|
|
7
|
+
import { useSkillEditorSubmit as E } from "./skill/useSkillEditorSubmit.js";
|
|
8
|
+
import { useSkillFileActions as D } from "./skill/useSkillFileActions.js";
|
|
9
|
+
import { SkillArchiveImportErrorKind as O, SkillArchiveImportStatus as k, SkillArchiveSelectionRejectionReason as A, classifySkillArchiveImportError as j, useSkillArchiveImport as M } from "./skill/useSkillArchiveImport/useSkillArchiveImport.js";
|
|
10
|
+
import { useSkillFileSystemPicker as N } from "./skill-editor/useSkillFileSystemPicker/useSkillFileSystemPicker.js";
|
|
11
|
+
import { SkillFilePreviewState as P, useSkillFilePreviewSyncController as F } from "./skill-editor/useSkillFilePreviewSyncController.js";
|
|
12
|
+
export { e as SKILL_FILE_UPLOAD_MAX_BYTES, t as SKILL_FOLDER_MARKER, n as SKILL_MANIFEST_FILE, r as SKILL_TEXT_FIELD_MAX_LENGTHS, i as SKILL_UPLOAD_MAX_TOTAL_BYTES, O as SkillArchiveImportErrorKind, k as SkillArchiveImportStatus, A as SkillArchiveSelectionRejectionReason, C as SkillEditorLoadState, T as SkillEditorSubmitPhase, P as SkillFilePreviewState, a as SkillTextField, o as buildSkillFilesPayload, s as buildSkillManifest, c as buildSkillManifestForSubmit, l as buildSkillManifestFromFrontmatter, j as classifySkillArchiveImportError, u as getSkillFieldLengthViolations, d as isSkillFolderMarkerPath, f as isValidSkillRelativePath, p as nameFromPath, m as normalizeSkillName, h as parseSkillManifest, b as parseSkillManifestDocument, g as skillFileBytesToBlob, S as skillFileToAttachment, _ as skillFolderMarkerParent, v as startsWithFrontmatterBlock, y as unpackSkillArchive, M as useSkillArchiveImport, w as useSkillEditorLoad, E as useSkillEditorSubmit, D as useSkillFileActions, F as useSkillFilePreviewSyncController, N as useSkillFileSystemPicker, x as validateSkillFileBatch };
|