@epam/ai-dial-chat-hooks 1.4.0-dev.154 → 1.4.0-dev.161

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.
@@ -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, files: h, setFiles: g, filesContentRef: _, frontmatterRef: v, loadedValues: y, setLoadedValues: b, isEditMode: x, isDirty: S, setSelectedPath: C, messages: w, pickFromFileSystem: T }) => {
9
- let [E, D] = d(!1), [O, k] = d({}), A = u(null), j = c(() => {
10
- let e = h.filter((e) => e.kind === f.File).map((e) => e.path), r = 0, i = /* @__PURE__ */ new Map();
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 = _.current.get(t)?.bytes.length ?? 0;
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: y?.name ?? "",
17
- description: y?.description ?? "",
18
- instructions: y?.instructions ?? ""
19
- }, o = x ? n(v.current, a.name, a.description, a.instructions) : t(a);
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: h.filter((e) => e.kind === f.Folder).map((e) => e.path),
27
+ existingFolderPaths: _.filter((e) => e.kind === f.Folder).map((e) => e.path),
26
28
  manifestByteLength: s(o),
27
- messages: w
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
- w
37
- ]), M = c(() => new Promise((e) => {
38
- A.current = e, D(!0);
39
- }), []), N = c((e) => {
40
- D(!1), A.current?.(e), A.current = null;
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, j());
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, j());
53
- if (t.some((e) => e.error !== void 0) || n.length > 0) return { error: n[0]?.message ?? w.saveError };
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 (x && r.name !== (y?.name ?? "")) return { error: w.manifestNameMismatch };
56
- if ((x || S) && !await M()) return { error: w.manifestImportDeclined };
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(h.filter((e) => e.kind === f.File).map((e) => e.path)), a = await Promise.all(t.map(async (e) => ({
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) _.current.set(e.path, {
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 && g((e) => [...e, ...o.map((e) => ({
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 && k((e) => {
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 && (v.current = x ? {
81
- ...v.current,
84
+ }), r && (b.current = C ? {
85
+ ...b.current,
82
86
  ...r.frontmatter
83
- } : r.frontmatter, b({
84
- name: x ? y?.name ?? r.name : r.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
- g((e) => e.filter((e) => e.path !== t && !e.path.startsWith(`${t}/`)));
94
- for (let e of [..._.current.keys()]) (e === t || e.startsWith(`${t}/`)) && _.current.delete(e);
95
- C((n) => n === t || n.startsWith(`${t}/`) ? e : n);
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
- g((t) => t.some((t) => t.path === e) ? t : [...t, {
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 : w.pathInvalid,
108
+ validateFolderPath: (e) => r(`${e}/${p}`) ? void 0 : E.pathInvalid,
105
109
  extractArchive: o,
106
- pickFromFileSystem: T
110
+ pickFromFileSystem: D
107
111
  }), [
108
- j,
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
- T
116
+ x,
117
+ P,
118
+ y,
119
+ b,
120
+ v,
121
+ S,
122
+ T,
123
+ E,
124
+ D
121
125
  ]),
122
- pendingManifestImport: E,
123
- resolveManifestImport: N,
124
- contentRevisions: O
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 { useSkillEditorSubmit as T } from "./skill/useSkillEditorSubmit.js";
7
- import { useSkillFileActions as E } from "./skill/useSkillFileActions.js";
8
- import { SkillArchiveImportErrorKind as D, SkillArchiveImportStatus as O, SkillArchiveSelectionRejectionReason as k, classifySkillArchiveImportError as A, useSkillArchiveImport as j } from "./skill/useSkillArchiveImport/useSkillArchiveImport.js";
9
- import { useSkillFileSystemPicker as M } from "./skill-editor/useSkillFileSystemPicker/useSkillFileSystemPicker.js";
10
- import { SkillFilePreviewState as N, useSkillFilePreviewSyncController as P } from "./skill-editor/useSkillFilePreviewSyncController.js";
11
- 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, D as SkillArchiveImportErrorKind, O as SkillArchiveImportStatus, k as SkillArchiveSelectionRejectionReason, C as SkillEditorLoadState, N as SkillFilePreviewState, a as SkillTextField, o as buildSkillFilesPayload, s as buildSkillManifest, c as buildSkillManifestForSubmit, l as buildSkillManifestFromFrontmatter, A 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, j as useSkillArchiveImport, w as useSkillEditorLoad, T as useSkillEditorSubmit, E as useSkillFileActions, P as useSkillFilePreviewSyncController, M as useSkillFileSystemPicker, x as validateSkillFileBatch };
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 };