@epam/ai-dial-chat-hooks 1.1.0-dev.447 → 1.1.0-dev.456

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.
@@ -1,12 +1,12 @@
1
1
  import { MessageRole as e } from "@epam/ai-dial-chat-shared";
2
2
  //#region src/conversation/useConversationHandlers/message-utils.ts
3
- var t = (e) => e != null && Object.keys(e).length > 0, n = (e, t, n, r) => {
4
- if (t !== e.content || r.length > 0) return !0;
5
- let i = e.custom_content?.attachments?.length ?? 0;
6
- return n.length !== i;
7
- }, r = (t) => t == null || t.role !== e.Assistant || !!t.wasStoppedByUser || t.streamErrorMessage != null, i = (e, t, i, a, o) => {
8
- let s = e[t];
9
- return s ? n(s, i, a, o) || r(e[t + 1]) : !1;
3
+ var t = (e) => e != null && Object.keys(e).length > 0, n = (e, t) => (e?.length ?? 0) === (t?.length ?? 0) ? (e ?? []).some((e, n) => e.url !== t?.[n]?.url) : !0, r = (e, t, r, i, a) => {
4
+ if (t !== e.content || i.length > 0) return !0;
5
+ let o = e.custom_content?.attachments?.length ?? 0;
6
+ return r.length === o ? a != null && n(e.custom_content?.skills, a) : !0;
7
+ }, i = (t) => t == null || t.role !== e.Assistant || !!t.wasStoppedByUser || t.streamErrorMessage != null, a = (e, t, n, a, o, s) => {
8
+ let c = e[t];
9
+ return c ? r(c, n, a, o, s) || i(e[t + 1]) : !1;
10
10
  };
11
11
  //#endregion
12
- export { t as hasActiveToolConfig, r as isAnswerIncomplete, n as isMessageChanged, i as shouldRerunGenerationOnEdit };
12
+ export { t as hasActiveToolConfig, i as isAnswerIncomplete, r as isMessageChanged, a as shouldRerunGenerationOnEdit };
@@ -13,24 +13,25 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
13
13
  filesApi: b,
14
14
  bucket: h,
15
15
  onNetworkError: T
16
- }), P = u(async (e, i) => {
16
+ }), P = u(async (e, i, a) => {
17
17
  if (!m || !p) return;
18
- let a = t(i), o = r(E), s = a?.length || o ? {
19
- ...a?.length ? { attachments: a } : {},
20
- ...o ? { configuration_value: E } : {}
21
- } : void 0, c = C(), { userMessage: u, assistantMessage: d } = n(e, s, c);
18
+ let o = t(i), s = r(E), c = o?.length || s || a?.length ? {
19
+ ...o?.length ? { attachments: o } : {},
20
+ ...s ? { configuration_value: E } : {},
21
+ ...a?.length ? { skills: a } : {}
22
+ } : void 0, u = C(), { userMessage: d, assistantMessage: h } = n(e, c, u);
22
23
  v((e) => {
23
24
  if (!e) return e;
24
25
  let t = {
25
26
  ...e,
26
27
  messages: [
27
28
  ...e.messages,
28
- u,
29
- d
29
+ d,
30
+ h
30
31
  ]
31
32
  };
32
33
  return y.current = t, t;
33
- }), _(m, e, p.messages.length + 1, c, s, l(), f.Append);
34
+ }), _(m, e, p.messages.length + 1, u, c, l(), f.Append);
34
35
  }, [
35
36
  p,
36
37
  m,
@@ -206,43 +207,46 @@ var p = ({ conversation: p, conversationId: m, bucket: h, isStreaming: g, startS
206
207
  return n.delete(e), n;
207
208
  });
208
209
  }, []),
209
- handleEditMessage: u(async (e, n, r, a) => {
210
+ handleEditMessage: u(async (e, n, r, a, o) => {
210
211
  if (g || !m || !p) return;
211
- let o = e;
212
- if (o === -1 || p.messages[o].role !== c.User) return;
213
- let s = p.messages[o];
214
- if (!i(p.messages, o, n, r, a)) {
212
+ let s = e;
213
+ if (s === -1 || p.messages[s].role !== c.User) return;
214
+ let u = p.messages[s];
215
+ if (!i(p.messages, s, n, r, a, o)) {
215
216
  A((e) => {
216
217
  let t = new Set(e);
217
- return t.delete(o), t;
218
+ return t.delete(s), t;
218
219
  });
219
220
  return;
220
221
  }
221
- let u = t(a), d = new Set(r.map((e) => e.id)), h = [...(s.custom_content?.attachments ?? []).filter((e) => {
222
+ let d = t(a), h = new Set(r.map((e) => e.id)), b = [...(u.custom_content?.attachments ?? []).filter((e) => {
222
223
  let t = e.url ?? e.data ?? e.title;
223
- return d.has(t);
224
- }), ...u ?? []], { attachments: b, ...x } = s.custom_content ?? {}, S = h.length > 0 ? {
225
- ...x,
226
- attachments: h
227
- } : Object.keys(x).length > 0 ? x : void 0, w = {
228
- ...s,
224
+ return h.has(t);
225
+ }), ...d ?? []], { attachments: x, skills: S, ...w } = u.custom_content ?? {}, T = o ?? S, E;
226
+ E = b.length > 0 || T?.length ? {
227
+ ...w,
228
+ ...b.length > 0 ? { attachments: b } : {},
229
+ ...T?.length ? { skills: T } : {}
230
+ } : Object.keys(w).length > 0 ? w : void 0;
231
+ let D = {
232
+ ...u,
229
233
  content: n,
230
- custom_content: S
231
- }, T = Date.now(), E = {
234
+ custom_content: E
235
+ }, O = Date.now(), k = {
232
236
  role: c.Assistant,
233
237
  content: "",
234
- timestamp: new Date(T).toISOString()
235
- }, D = [
236
- ...p.messages.slice(0, o),
237
- w,
238
- E
239
- ], O = {
238
+ timestamp: new Date(O).toISOString()
239
+ }, j = [
240
+ ...p.messages.slice(0, s),
241
+ D,
242
+ k
243
+ ], M = {
240
244
  ...p,
241
- messages: D
245
+ messages: j
242
246
  };
243
- y.current = O, v(O);
244
- let k = C();
245
- _(m, n, D.length - 1, k, S, l(), f.Edit), A(/* @__PURE__ */ new Set());
247
+ y.current = M, v(M);
248
+ let N = C();
249
+ _(m, n, j.length - 1, N, E, l(), f.Edit), A(/* @__PURE__ */ new Set());
246
250
  }, [
247
251
  p,
248
252
  m,
package/conversation.d.ts CHANGED
@@ -20,6 +20,7 @@ import { PublishHistoryEntry } from '@epam/ai-dial-publish-panel';
20
20
  import { RateApi } from '@epam/ai-dial-chat-api-client';
21
21
  import { ReactNode } from 'react';
22
22
  import { RefObject } from 'react';
23
+ import { RequestSkill } from '@epam/ai-dial-chat-shared';
23
24
  import { ResponseFormat } from '@epam/ai-dial-chat-shared';
24
25
  import { SendCompletionDtoModeEnum } from '@epam/ai-dial-chat-api-client';
25
26
  import { SetStateAction } from 'react';
@@ -506,15 +507,20 @@ export declare const isAnswerIncomplete: (answer: Message | undefined) => boolea
506
507
  export declare const isAwaitingGenerationResume: (conversation: Conversation) => boolean;
507
508
 
508
509
  /**
509
- * Returns `true` when the edited text or attachment list differs from the
510
- * original message, meaning a regeneration is needed.
510
+ * Returns `true` when the edited text, attachment list, or skills list differs
511
+ * from the original message, meaning a regeneration is needed.
512
+ *
513
+ * `skills` is the skills state the edit will write: `undefined` leaves the
514
+ * original skills out of the comparison (nothing about them changes), while an
515
+ * array — including an empty one — is compared against the original.
511
516
  *
512
517
  * @param originalMessage - The unmodified message stored in the conversation.
513
518
  * @param newText - The text the user submitted from the edit area.
514
519
  * @param keptDisplayAttachments - Attachments the user kept (not removed).
515
520
  * @param newAttachments - Brand-new attachments the user added during editing.
521
+ * @param skills - The skills the edited message will carry, or `undefined` to leave them unchanged.
516
522
  */
517
- export declare const isMessageChanged: (originalMessage: Message, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => boolean;
523
+ export declare const isMessageChanged: (originalMessage: Message, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[], skills?: RequestSkill[]) => boolean;
518
524
 
519
525
  /**
520
526
  * Returns `true` when `message` is the actively-streaming assistant response.
@@ -611,8 +617,10 @@ export declare const sanitizeFooterHtml: (html: string) => string;
611
617
  * its answer never completed — after stopping a generation the user submits
612
618
  * the same message precisely to get a full answer, so treating that as "no
613
619
  * change" would leave the conversation stuck with the partial one.
620
+ *
621
+ * @param skills - The skills the edited message will carry, or `undefined` to leave them unchanged — see {@link isMessageChanged}.
614
622
  */
615
- export declare const shouldRerunGenerationOnEdit: (messages: Message[], messageIndex: number, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => boolean;
623
+ export declare const shouldRerunGenerationOnEdit: (messages: Message[], messageIndex: number, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[], skills?: RequestSkill[]) => boolean;
616
624
 
617
625
  /** True when the first user/assistant exchange is complete and LLM naming may still run. */
618
626
  export declare const shouldWatchForDisplayNameUpdate: (conversation: Conversation) => boolean;
@@ -795,7 +803,7 @@ export declare interface UseConversationHandlersParams {
795
803
 
796
804
  /** Return value of {@link useConversationHandlers}. */
797
805
  export declare interface UseConversationHandlersResult {
798
- handleSend: (message: string, attachments: Attachment[]) => Promise<void>;
806
+ handleSend: (message: string, attachments: Attachment[], skills?: RequestSkill[]) => Promise<void>;
799
807
  handleUploadAttachment: (attachment: Attachment) => Promise<UploadedAttachmentResult>;
800
808
  handleRegenerateMessage: (messageIndex: number) => void;
801
809
  handleDeleteMessage: (messageIndex: number) => void;
@@ -805,7 +813,7 @@ export declare interface UseConversationHandlersResult {
805
813
  handleConfirmStarter: () => void;
806
814
  handleStartEdit: (messageIndex: number) => void;
807
815
  handleCancelEdit: (messageIndex: number) => void;
808
- handleEditMessage: (messageIndex: number, text: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => Promise<void>;
816
+ handleEditMessage: (messageIndex: number, text: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[], skills?: RequestSkill[]) => Promise<void>;
809
817
  editingMessageIndexes: Set<number>;
810
818
  pendingDeleteIndex: number | null;
811
819
  setPendingDeleteIndex: (index: number | null) => void;
package/index.d.ts CHANGED
@@ -105,6 +105,7 @@ import { ReactNode } from 'react';
105
105
  import { RefObject } from 'react';
106
106
  import { RenameFilesResponseDto } from '@epam/ai-dial-chat-api-client';
107
107
  import { RenameItemDto } from '@epam/ai-dial-chat-api-client';
108
+ import { RequestSkill } from '@epam/ai-dial-chat-shared';
108
109
  import { ResponseFormat } from '@epam/ai-dial-chat-shared';
109
110
  import { RevokeAccessItemDto } from '@epam/ai-dial-chat-api-client';
110
111
  import { RevokeAccessResponseDto } from '@epam/ai-dial-chat-api-client';
@@ -1911,15 +1912,20 @@ export declare const isDownloadableAttachment: (attachment: DisplayAttachment) =
1911
1912
  export declare const isExternalSourcePreviewable: (contentType: string, url: string) => boolean;
1912
1913
 
1913
1914
  /**
1914
- * Returns `true` when the edited text or attachment list differs from the
1915
- * original message, meaning a regeneration is needed.
1915
+ * Returns `true` when the edited text, attachment list, or skills list differs
1916
+ * from the original message, meaning a regeneration is needed.
1917
+ *
1918
+ * `skills` is the skills state the edit will write: `undefined` leaves the
1919
+ * original skills out of the comparison (nothing about them changes), while an
1920
+ * array — including an empty one — is compared against the original.
1916
1921
  *
1917
1922
  * @param originalMessage - The unmodified message stored in the conversation.
1918
1923
  * @param newText - The text the user submitted from the edit area.
1919
1924
  * @param keptDisplayAttachments - Attachments the user kept (not removed).
1920
1925
  * @param newAttachments - Brand-new attachments the user added during editing.
1926
+ * @param skills - The skills the edited message will carry, or `undefined` to leave them unchanged.
1921
1927
  */
1922
- export declare const isMessageChanged: (originalMessage: Message, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => boolean;
1928
+ export declare const isMessageChanged: (originalMessage: Message, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[], skills?: RequestSkill[]) => boolean;
1923
1929
 
1924
1930
  /**
1925
1931
  * Returns `true` when `message` is the actively-streaming assistant response.
@@ -3067,8 +3073,10 @@ export declare interface SharedRootMeta {
3067
3073
  * its answer never completed — after stopping a generation the user submits
3068
3074
  * the same message precisely to get a full answer, so treating that as "no
3069
3075
  * change" would leave the conversation stuck with the partial one.
3076
+ *
3077
+ * @param skills - The skills the edited message will carry, or `undefined` to leave them unchanged — see {@link isMessageChanged}.
3070
3078
  */
3071
- export declare const shouldRerunGenerationOnEdit: (messages: Message[], messageIndex: number, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => boolean;
3079
+ export declare const shouldRerunGenerationOnEdit: (messages: Message[], messageIndex: number, newText: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[], skills?: RequestSkill[]) => boolean;
3072
3080
 
3073
3081
  /** True when the first user/assistant exchange is complete and LLM naming may still run. */
3074
3082
  export declare const shouldWatchForDisplayNameUpdate: (conversation: Conversation) => boolean;
@@ -4176,7 +4184,7 @@ export declare interface UseConversationHandlersParams {
4176
4184
 
4177
4185
  /** Return value of {@link useConversationHandlers}. */
4178
4186
  export declare interface UseConversationHandlersResult {
4179
- handleSend: (message: string, attachments: Attachment[]) => Promise<void>;
4187
+ handleSend: (message: string, attachments: Attachment[], skills?: RequestSkill[]) => Promise<void>;
4180
4188
  handleUploadAttachment: (attachment: Attachment) => Promise<UploadedAttachmentResult>;
4181
4189
  handleRegenerateMessage: (messageIndex: number) => void;
4182
4190
  handleDeleteMessage: (messageIndex: number) => void;
@@ -4186,7 +4194,7 @@ export declare interface UseConversationHandlersResult {
4186
4194
  handleConfirmStarter: () => void;
4187
4195
  handleStartEdit: (messageIndex: number) => void;
4188
4196
  handleCancelEdit: (messageIndex: number) => void;
4189
- handleEditMessage: (messageIndex: number, text: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[]) => Promise<void>;
4197
+ handleEditMessage: (messageIndex: number, text: string, keptDisplayAttachments: DisplayAttachment[], newAttachments: Attachment[], skills?: RequestSkill[]) => Promise<void>;
4190
4198
  editingMessageIndexes: Set<number>;
4191
4199
  pendingDeleteIndex: number | null;
4192
4200
  setPendingDeleteIndex: (index: number | null) => void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.1.0-dev.447",
4
+ "version": "1.1.0-dev.456",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -104,21 +104,21 @@
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^19.2.6",
107
- "@epam/ai-dial-attachment-canvas": "1.1.0-dev.447",
108
- "@epam/ai-dial-attachment-input": "1.1.0-dev.447",
109
- "@epam/ai-dial-catalog": "1.1.0-dev.447",
110
- "@epam/ai-dial-chat-api-client": "1.1.0-dev.447",
111
- "@epam/ai-dial-chat-overlay": "1.1.0-dev.447",
112
- "@epam/ai-dial-chat-shared": "1.1.0-dev.447",
113
- "@epam/ai-dial-deployment-creation-form": "1.1.0-dev.447",
114
- "@epam/ai-dial-mcp-apps": "1.1.0-dev.447",
115
- "@epam/ai-dial-publish-panel": "1.1.0-dev.447",
116
- "@epam/ai-dial-quotations": "1.1.0-dev.447",
107
+ "@epam/ai-dial-attachment-canvas": "1.1.0-dev.456",
108
+ "@epam/ai-dial-attachment-input": "1.1.0-dev.456",
109
+ "@epam/ai-dial-catalog": "1.1.0-dev.456",
110
+ "@epam/ai-dial-chat-api-client": "1.1.0-dev.456",
111
+ "@epam/ai-dial-chat-overlay": "1.1.0-dev.456",
112
+ "@epam/ai-dial-chat-shared": "1.1.0-dev.456",
113
+ "@epam/ai-dial-deployment-creation-form": "1.1.0-dev.456",
114
+ "@epam/ai-dial-mcp-apps": "1.1.0-dev.456",
115
+ "@epam/ai-dial-publish-panel": "1.1.0-dev.456",
116
+ "@epam/ai-dial-quotations": "1.1.0-dev.456",
117
117
  "@epam/ai-dial-react-file-manager": "*",
118
- "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.447",
119
- "@epam/ai-dial-share": "1.1.0-dev.447",
120
- "@epam/ai-dial-skill-editor": "1.1.0-dev.447",
121
- "@epam/ai-dial-source-panel": "1.1.0-dev.447",
118
+ "@epam/ai-dial-scheduled-tasks": "1.1.0-dev.456",
119
+ "@epam/ai-dial-share": "1.1.0-dev.456",
120
+ "@epam/ai-dial-skill-editor": "1.1.0-dev.456",
121
+ "@epam/ai-dial-source-panel": "1.1.0-dev.456",
122
122
  "@epam/ai-dial-ui-kit": "*",
123
123
  "@modelcontextprotocol/sdk": "^1.27.1",
124
124
  "@epam/pdf-highlighter-kit": ">=0.0.14",