@epam/ai-dial-chat-hooks 1.2.0-dev.14 → 1.2.0-dev.142
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/api-error/api-error.js +5 -4
- 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 +30 -27
- package/catalog/publish.js +2 -1
- package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
- package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
- package/catalog/useSkillItemDetails.js +17 -13
- package/catalog.d.ts +42 -5
- package/catalog.js +6 -5
- package/conversation/conversation-transfer/queue.js +8 -5
- package/conversation/create-chat-stream-api.js +30 -21
- package/conversation/stage.js +23 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +12 -5
- 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/generation-resume.js +75 -63
- package/conversation/useConversationStream/useConversationStream.js +145 -102
- package/conversation-overlay.d.ts +7 -0
- package/conversation-overlay.js +2 -0
- package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
- package/conversation-sources.d.ts +1 -1
- package/conversation.d.ts +140 -8
- package/conversation.js +31 -30
- 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 +750 -35
- package/index.js +123 -111
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
- package/mcp-apps/useMcpAppTools/useMcpAppTools.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-task-trigger.js +7 -2
- 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 +180 -3
- 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
- package/utils.d.ts +3 -1
|
@@ -1,152 +1,195 @@
|
|
|
1
1
|
import { safeDecodeURI as e } from "../../shared/string-utils.js";
|
|
2
|
-
import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t,
|
|
3
|
-
import { getConversationPath as
|
|
4
|
-
import { applyChunkToMessages as
|
|
5
|
-
import { restoreBufferedMessage as
|
|
6
|
-
import { createResumeIfAwaitingGeneration as
|
|
7
|
-
import { generateUUID as
|
|
8
|
-
import { useCallback as
|
|
9
|
-
import { SendCompletionDtoModeEnum as
|
|
2
|
+
import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as n, GenerationConflictError as r, GenerationPersistenceError as i, StreamUpstreamError as a } from "../create-chat-stream-api.js";
|
|
3
|
+
import { getConversationPath as o } from "./conversation-path.js";
|
|
4
|
+
import { applyChunkToMessages as s } from "./apply-chunk.js";
|
|
5
|
+
import { restoreBufferedMessage as c } from "./buffered-generation.js";
|
|
6
|
+
import { createResumeIfAwaitingGeneration as l, hasGeneratedPayload as u, isAwaitingGenerationResume as d } from "./generation-resume.js";
|
|
7
|
+
import { generateUUID as f } from "@epam/ai-dial-chat-shared";
|
|
8
|
+
import { useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
|
|
9
|
+
import { SendCompletionDtoModeEnum as v } from "@epam/ai-dial-chat-api-client";
|
|
10
10
|
//#region src/conversation/useConversationStream/useConversationStream.ts
|
|
11
|
-
var
|
|
12
|
-
let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, [
|
|
16
|
-
let
|
|
17
|
-
|
|
11
|
+
var y = 2e4, b = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof a ? e.message : "", x = ({ conversationId: r, state: { setConversation: a, conversationRef: x }, transport: S, generation: { startGeneration: C, completeGeneration: w }, channel: T, overlay: E, onStopError: D, generationConflictMessage: O = t, generationPersistenceErrorMessage: k = n, onStreamError: A }) => {
|
|
12
|
+
let j = g(A);
|
|
13
|
+
m(() => {
|
|
14
|
+
j.current = A;
|
|
15
|
+
}, [A]);
|
|
16
|
+
let [M, N] = _(() => /* @__PURE__ */ new Set()), [P, F] = _(null), I = g(null), L = g(null), R = g(/* @__PURE__ */ new Set()), z = g(/* @__PURE__ */ new Map()), B = g(/* @__PURE__ */ new Set()), V = g(/* @__PURE__ */ new Map()), H = g(r);
|
|
17
|
+
m(() => {
|
|
18
|
+
H.current = r;
|
|
19
|
+
}, [r]);
|
|
20
|
+
let U = p((e) => o(H.current ?? "") === e, []), W = p((e) => {
|
|
21
|
+
N((t) => {
|
|
18
22
|
if (t.has(e)) return t;
|
|
19
23
|
let n = new Set(t);
|
|
20
24
|
return n.add(e), n;
|
|
21
25
|
});
|
|
22
|
-
}, []),
|
|
23
|
-
|
|
26
|
+
}, []), G = p((e) => {
|
|
27
|
+
N((t) => {
|
|
24
28
|
if (!t.has(e)) return t;
|
|
25
29
|
let n = new Set(t);
|
|
26
30
|
return n.delete(e), n;
|
|
27
31
|
});
|
|
28
|
-
}, []),
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
generationId:
|
|
36
|
-
messageIndex:
|
|
37
|
-
message:
|
|
38
|
-
}) :
|
|
39
|
-
let
|
|
40
|
-
|
|
32
|
+
}, []), K = p((t, n, r, l, p, m, h = v.Append) => {
|
|
33
|
+
let g = m ?? f(), _ = o(t);
|
|
34
|
+
R.current.delete(_), I.current = g, L.current = _, V.current.set(_, g), F(_);
|
|
35
|
+
let D;
|
|
36
|
+
h === v.Regenerate ? D = r : h === v.Edit && (D = r - 1);
|
|
37
|
+
let A = () => V.current.get(_) !== g, M = C(_, g), N = x.current?.messages[r];
|
|
38
|
+
N ? z.current.set(_, {
|
|
39
|
+
generationId: g,
|
|
40
|
+
messageIndex: r,
|
|
41
|
+
message: N
|
|
42
|
+
}) : z.current.delete(_), W(_), E?.notifyGenerationStart?.(), T?.ensureConnected();
|
|
43
|
+
let P = () => {
|
|
44
|
+
if (A()) return;
|
|
45
|
+
let e = z.current.get(_);
|
|
46
|
+
!e || e.generationId !== g || (e.message = {
|
|
47
|
+
...e.message,
|
|
48
|
+
streamErrorMessage: k
|
|
49
|
+
}, j.current?.(new i()), U(_) && a((t) => {
|
|
50
|
+
if (!t || A() || !U(_)) return t;
|
|
51
|
+
let n = c(t, e);
|
|
52
|
+
return x.current = n, n;
|
|
53
|
+
}));
|
|
54
|
+
}, H = {
|
|
55
|
+
signal: M.signal,
|
|
41
56
|
onChunk: (e) => {
|
|
42
|
-
if (
|
|
43
|
-
let t =
|
|
44
|
-
if (t?.generationId ===
|
|
45
|
-
let n =
|
|
57
|
+
if (I.current !== g) return;
|
|
58
|
+
let t = z.current.get(_);
|
|
59
|
+
if (t?.generationId === g) {
|
|
60
|
+
let n = s([t.message], 0, e);
|
|
46
61
|
n && (t.message = n[0]);
|
|
47
62
|
}
|
|
48
|
-
|
|
63
|
+
U(_) && a((t) => {
|
|
49
64
|
if (!t) return t;
|
|
50
|
-
let n =
|
|
51
|
-
if (n?.generationId ===
|
|
65
|
+
let n = z.current.get(_), i;
|
|
66
|
+
if (n?.generationId === g) i = c(t, n);
|
|
52
67
|
else {
|
|
53
|
-
let n =
|
|
68
|
+
let n = s(t.messages, r, e);
|
|
54
69
|
if (!n) return t;
|
|
55
|
-
|
|
70
|
+
i = {
|
|
56
71
|
...t,
|
|
57
72
|
messages: n
|
|
58
73
|
};
|
|
59
74
|
}
|
|
60
|
-
return
|
|
75
|
+
return x.current = i, i;
|
|
61
76
|
});
|
|
62
77
|
},
|
|
63
78
|
onComplete: async () => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
let n = z.current.get(_), r = n?.generationId === g ? n : void 0;
|
|
80
|
+
if (A() || G(_), I.current === g && (I.current = null, L.current = null, F(null)), w(_, g), T?.notifyGenerationSettled?.(), B.current.has(g) ? B.current.delete(g) : A() || E?.notifyGenerationEnd?.(), !A()) {
|
|
81
|
+
if (!U(_)) {
|
|
82
|
+
r && z.current.delete(_);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
let n = await S.getConversation(e(t));
|
|
87
|
+
if (A()) return;
|
|
88
|
+
if (!U(_)) {
|
|
89
|
+
r && z.current.delete(_);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (r && r.messageIndex === n.messages.length - 1 && d(n) && u(r.message)) {
|
|
93
|
+
P();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
r && z.current.delete(_), a(n), x.current = n;
|
|
97
|
+
} catch {
|
|
98
|
+
A() || P();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
69
101
|
},
|
|
70
102
|
onError: (e) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
103
|
+
j.current?.(e);
|
|
104
|
+
let t = z.current.get(_), n = t?.generationId === g ? t : void 0;
|
|
105
|
+
if (n && (e instanceof i ? n.message = {
|
|
106
|
+
...n.message,
|
|
107
|
+
streamErrorMessage: k
|
|
108
|
+
} : z.current.delete(_)), A() || G(_), I.current === g && (I.current = null, L.current = null, F(null)), w(_, g), T?.notifyGenerationSettled?.(), A() || !U(_)) return;
|
|
109
|
+
let o = b(e, O, k);
|
|
110
|
+
a((e) => {
|
|
111
|
+
if (!e || A() || !U(_)) return e;
|
|
112
|
+
let t = n?.generationId === g ? c(e, n) : e, i = {
|
|
77
113
|
...t,
|
|
78
|
-
messages: t.messages.map((e, t) => t ===
|
|
114
|
+
messages: t.messages.map((e, t) => t === r ? {
|
|
79
115
|
...e,
|
|
80
|
-
streamErrorMessage:
|
|
116
|
+
streamErrorMessage: o
|
|
81
117
|
} : e)
|
|
82
118
|
};
|
|
83
|
-
return
|
|
119
|
+
return x.current = i, i;
|
|
84
120
|
});
|
|
85
121
|
}
|
|
86
122
|
};
|
|
87
123
|
(async () => {
|
|
88
124
|
try {
|
|
89
|
-
let e =
|
|
90
|
-
|
|
125
|
+
let e = T?.channelId ?? await T?.waitForChannel(y) ?? void 0, t = B.current.has(g);
|
|
126
|
+
if (M.signal.aborted || A() || t) {
|
|
127
|
+
z.current.get(_)?.generationId === g && z.current.delete(_), A() || G(_), I.current === g && (I.current = null, L.current = null, F(null)), w(_, g), T?.notifyGenerationSettled?.(), t ? B.current.delete(g) : A() || E?.notifyGenerationEnd?.();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
S.streamCompletion(_, n, l, H, p, g, h, D, e);
|
|
91
131
|
} catch (e) {
|
|
92
|
-
|
|
132
|
+
H.onError(e instanceof Error ? e : Error(String(e)));
|
|
93
133
|
}
|
|
94
134
|
})();
|
|
95
135
|
}, [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
136
|
+
C,
|
|
137
|
+
w,
|
|
138
|
+
W,
|
|
139
|
+
G,
|
|
140
|
+
U,
|
|
141
|
+
T?.channelId,
|
|
142
|
+
T?.ensureConnected,
|
|
143
|
+
T?.waitForChannel,
|
|
144
|
+
T?.notifyGenerationSettled,
|
|
145
|
+
E,
|
|
105
146
|
S,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
]),
|
|
109
|
-
let n =
|
|
110
|
-
return
|
|
111
|
-
}, []),
|
|
112
|
-
let e =
|
|
113
|
-
if (!e || !
|
|
114
|
-
let t = r
|
|
115
|
-
|
|
147
|
+
O,
|
|
148
|
+
k
|
|
149
|
+
]), q = p((e, t) => {
|
|
150
|
+
let n = o(e), r = z.current.get(n);
|
|
151
|
+
return r ? c(t, r) : t;
|
|
152
|
+
}, []), J = p(() => {
|
|
153
|
+
let e = I.current;
|
|
154
|
+
if (!e || !r) return;
|
|
155
|
+
let t = o(r);
|
|
156
|
+
L.current === t && (B.current.add(e), E?.notifyStopGenerating?.(), S.stopCompletion({
|
|
116
157
|
generationId: e,
|
|
117
158
|
path: t
|
|
118
159
|
}).catch((e) => {
|
|
119
160
|
let t = e instanceof Error ? e : Error(String(e));
|
|
120
|
-
|
|
161
|
+
D?.(t);
|
|
121
162
|
}));
|
|
122
163
|
}, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
]),
|
|
128
|
-
transport:
|
|
129
|
-
setConversation:
|
|
130
|
-
conversationRef:
|
|
131
|
-
resumingPathsRef:
|
|
132
|
-
bufferedGenerationsRef:
|
|
133
|
-
addStreamingPath:
|
|
134
|
-
removeStreamingPath:
|
|
135
|
-
isPathDisplayed:
|
|
164
|
+
r,
|
|
165
|
+
D,
|
|
166
|
+
E,
|
|
167
|
+
S
|
|
168
|
+
]), Y = h(() => l({
|
|
169
|
+
transport: S,
|
|
170
|
+
setConversation: a,
|
|
171
|
+
conversationRef: x,
|
|
172
|
+
resumingPathsRef: R,
|
|
173
|
+
bufferedGenerationsRef: z,
|
|
174
|
+
addStreamingPath: W,
|
|
175
|
+
removeStreamingPath: G,
|
|
176
|
+
isPathDisplayed: U,
|
|
177
|
+
generationPersistenceErrorMessage: k
|
|
136
178
|
}), [
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
179
|
+
W,
|
|
180
|
+
G,
|
|
181
|
+
U,
|
|
182
|
+
S,
|
|
183
|
+
k
|
|
184
|
+
]), X = r != null && M.has(o(r)), Z = r == null ? null : o(r);
|
|
142
185
|
return {
|
|
143
|
-
startStream:
|
|
144
|
-
handleStop:
|
|
145
|
-
resumeIfAwaitingGeneration:
|
|
146
|
-
restoreBufferedGeneration:
|
|
147
|
-
isStreaming:
|
|
148
|
-
canStopStreaming:
|
|
186
|
+
startStream: K,
|
|
187
|
+
handleStop: J,
|
|
188
|
+
resumeIfAwaitingGeneration: Y,
|
|
189
|
+
restoreBufferedGeneration: q,
|
|
190
|
+
isStreaming: X,
|
|
191
|
+
canStopStreaming: Z != null && P === Z
|
|
149
192
|
};
|
|
150
193
|
};
|
|
151
194
|
//#endregion
|
|
152
|
-
export {
|
|
195
|
+
export { x as useConversationStream };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Message } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { OverlayChatMessage } from '@epam/ai-dial-chat-overlay';
|
|
3
|
+
|
|
4
|
+
/** Maps chat messages to the DIAL Chat Overlay protocol's message shape. */
|
|
5
|
+
export declare const toOverlayMessages: (messages: Message[]) => OverlayChatMessage[];
|
|
6
|
+
|
|
7
|
+
export { }
|
|
@@ -1,35 +1,42 @@
|
|
|
1
1
|
import { MessageRole as e, messageAttachmentToDisplayAttachment as t } from "@epam/ai-dial-chat-shared";
|
|
2
|
-
import {
|
|
3
|
-
import { useMemo as
|
|
2
|
+
import { getAnnotationPdfPage as n, isReferenceOnlyAttachment as r, parsePdfPageReference as i, resolveMessageAnnotations as a } from "@epam/ai-dial-quotations";
|
|
3
|
+
import { useMemo as o } from "react";
|
|
4
4
|
//#region src/conversation-sources/useConversationSources/useConversationSources.ts
|
|
5
|
-
var
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
var s = {}, c = (e, t) => {
|
|
6
|
+
let r = n(e);
|
|
7
|
+
if (r == null) return t;
|
|
8
|
+
let a = i(t);
|
|
9
|
+
return a == null || a.page != null ? t : `${t}#page=${r}`;
|
|
10
|
+
}, l = (n, i = s) => o(() => {
|
|
11
|
+
let o = [], s = [], l = [], u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
|
|
12
|
+
for (let p of n) {
|
|
13
|
+
let n = p.custom_content?.attachments;
|
|
14
|
+
if (p.role === e.User) for (let e of n ?? []) {
|
|
15
|
+
let n = t(e, i);
|
|
16
|
+
d.has(n.id) || (d.add(n.id), o.push(n));
|
|
12
17
|
}
|
|
13
|
-
else if (
|
|
14
|
-
let e =
|
|
18
|
+
else if (p.role === e.Assistant) {
|
|
19
|
+
let e = n?.filter((e) => !r(e));
|
|
15
20
|
for (let n of e ?? []) {
|
|
16
|
-
let e = t(n,
|
|
17
|
-
|
|
21
|
+
let e = t(n, i);
|
|
22
|
+
f.has(e.id) || (f.add(e.id), s.push(e));
|
|
18
23
|
}
|
|
19
|
-
for (let e of
|
|
20
|
-
if (!
|
|
24
|
+
for (let e of n ?? []) {
|
|
25
|
+
if (!r(e)) continue;
|
|
21
26
|
let t = e.reference_url;
|
|
22
|
-
|
|
27
|
+
u.has(t) || (u.add(t), l.push({
|
|
23
28
|
url: t,
|
|
24
29
|
title: e.title ?? t,
|
|
25
30
|
contentType: e.reference_type ?? e.type ?? "",
|
|
26
31
|
quote: e.data
|
|
27
32
|
}));
|
|
28
33
|
}
|
|
29
|
-
for (let e of
|
|
34
|
+
for (let e of a(p)) {
|
|
30
35
|
let t = e?.body?.source?.attachment, n = t?.url;
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
if (!n) continue;
|
|
37
|
+
let r = c(e, n);
|
|
38
|
+
u.has(r) || (u.add(r), l.push({
|
|
39
|
+
url: r,
|
|
33
40
|
title: t?.title ?? n.split("/").pop() ?? n,
|
|
34
41
|
contentType: t?.type ?? "",
|
|
35
42
|
quote: e.body?.quote
|
|
@@ -38,10 +45,10 @@ var a = {}, o = (o, s = a) => i(() => {
|
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
47
|
return {
|
|
41
|
-
uploaded:
|
|
42
|
-
generated:
|
|
43
|
-
sources:
|
|
48
|
+
uploaded: o,
|
|
49
|
+
generated: s,
|
|
50
|
+
sources: l
|
|
44
51
|
};
|
|
45
|
-
}, [
|
|
52
|
+
}, [n, i]);
|
|
46
53
|
//#endregion
|
|
47
|
-
export {
|
|
54
|
+
export { l as useConversationSources };
|
|
@@ -18,7 +18,7 @@ export declare interface UseConversationSourcesResult {
|
|
|
18
18
|
uploaded: DisplayAttachment[];
|
|
19
19
|
/** Deduplicated attachments the assistant generated across the conversation. */
|
|
20
20
|
generated: DisplayAttachment[];
|
|
21
|
-
/** Quotation sources referenced by assistant messages, deduplicated by URL
|
|
21
|
+
/** Quotation sources referenced by assistant messages, deduplicated by URL; PDF sources are qualified with `#page=N`. */
|
|
22
22
|
sources: QuotationSource[];
|
|
23
23
|
}
|
|
24
24
|
|
package/conversation.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { Message } from '@epam/ai-dial-chat-shared';
|
|
|
15
15
|
import { MessageCustomContent } from '@epam/ai-dial-chat-shared';
|
|
16
16
|
import { MessageRating } from '@epam/ai-dial-chat-shared';
|
|
17
17
|
import { MutableRefObject } from 'react';
|
|
18
|
-
import { OverlayChatMessage } from '@epam/ai-dial-chat-overlay';
|
|
19
18
|
import { PublishHistoryEntry } from '@epam/ai-dial-publish-panel';
|
|
20
19
|
import { RateApi } from '@epam/ai-dial-chat-api-client';
|
|
21
20
|
import { ReactNode } from 'react';
|
|
@@ -24,6 +23,7 @@ import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
|
24
23
|
import { ResponseFormat } from '@epam/ai-dial-chat-shared';
|
|
25
24
|
import { SendCompletionDtoModeEnum } from '@epam/ai-dial-chat-api-client';
|
|
26
25
|
import { SetStateAction } from 'react';
|
|
26
|
+
import { Stage } from '@epam/ai-dial-chat-shared';
|
|
27
27
|
import { StarterOption } from '@epam/ai-dial-chat-shared';
|
|
28
28
|
import { StatusMessage } from '@epam/ai-dial-chat-shared';
|
|
29
29
|
import { StreamChunk } from '@epam/ai-dial-chat-shared';
|
|
@@ -58,6 +58,25 @@ export declare interface AnnouncementListItemLink {
|
|
|
58
58
|
href: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Applies a single SSE stream chunk to the message list.
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* Attachments are accumulated: each chunk's attachments are appended to the
|
|
66
|
+
* existing array rather than replacing it.
|
|
67
|
+
*
|
|
68
|
+
* Annotations are merged by `index`: partial `body.title` and `body.quote`
|
|
69
|
+
* strings are concatenated across chunks, matching the same delta-merge
|
|
70
|
+
* semantics used for stages.
|
|
71
|
+
*
|
|
72
|
+
* `state` is overwritten (not merged) by each chunk that carries one,
|
|
73
|
+
* matching the DIAL stateful-app contract.
|
|
74
|
+
*
|
|
75
|
+
* @returns Updated message array, or `null` when the chunk carries no
|
|
76
|
+
* actionable data (empty content, no form_schema, and no attachments).
|
|
77
|
+
*/
|
|
78
|
+
export declare const applyChunkToMessages: (messages: Message[], messageIndex: number, chunk: StreamChunk) => Message[] | null;
|
|
79
|
+
|
|
61
80
|
/** State and controls returned by `useAsyncConfirmDialog`. */
|
|
62
81
|
export declare interface AsyncConfirmDialogControls<T> {
|
|
63
82
|
/**
|
|
@@ -342,6 +361,9 @@ export declare const createMessagePair: (content: string, customContent?: Messag
|
|
|
342
361
|
/** Fallback text of a {@link GenerationConflictError} when no message is supplied. */
|
|
343
362
|
export declare const DEFAULT_GENERATION_CONFLICT_MESSAGE = "A response is already being generated in this conversation. Wait for it to finish or stop it before sending another message.";
|
|
344
363
|
|
|
364
|
+
/** Safe fallback for hosts that do not supply a translated persistence warning. */
|
|
365
|
+
export declare const DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE = "The response could not be saved. It is still shown here, but may be lost if you reload or leave this page. Copy it before continuing.";
|
|
366
|
+
|
|
345
367
|
/**
|
|
346
368
|
* Derives the row-action visibility state for a single conversation item.
|
|
347
369
|
*
|
|
@@ -376,6 +398,12 @@ export declare class GenerationConflictError extends Error {
|
|
|
376
398
|
constructor(message?: string);
|
|
377
399
|
}
|
|
378
400
|
|
|
401
|
+
/** Identifies a failed terminal save independently of the model's generation outcome. */
|
|
402
|
+
export declare class GenerationPersistenceError extends Error {
|
|
403
|
+
static readonly type = "conversation_save_failed";
|
|
404
|
+
constructor();
|
|
405
|
+
}
|
|
406
|
+
|
|
379
407
|
/**
|
|
380
408
|
* Strips the leading bucket segment from a conversation id and decodes any
|
|
381
409
|
* already-percent-encoded remainder back to raw, so callers that re-encode
|
|
@@ -530,8 +558,8 @@ export declare const isAnswerIncomplete: (answer: Message | undefined) => boolea
|
|
|
530
558
|
* True when the conversation's last message is an unresolved assistant
|
|
531
559
|
* placeholder: the backend only persists a conversation at generation start
|
|
532
560
|
* (empty placeholder) and at generation end (final content, or a partial
|
|
533
|
-
* flagged `streamErrorMessage`/`wasStoppedByUser`)
|
|
534
|
-
*
|
|
561
|
+
* flagged `streamErrorMessage`/`wasStoppedByUser`). This can mean generation
|
|
562
|
+
* is still active elsewhere, or that its terminal save failed.
|
|
535
563
|
*/
|
|
536
564
|
export declare const isAwaitingGenerationResume: (conversation: Conversation) => boolean;
|
|
537
565
|
|
|
@@ -573,6 +601,29 @@ declare interface LocalModeValues {
|
|
|
573
601
|
temperature: number;
|
|
574
602
|
}
|
|
575
603
|
|
|
604
|
+
/**
|
|
605
|
+
* Returns the normalized stages of a raw stage array or a message-like
|
|
606
|
+
* payload (reading `custom_content.stages`, falling back to
|
|
607
|
+
* `customContent.stages`), or `undefined` when there are none.
|
|
608
|
+
*/
|
|
609
|
+
export declare const mapStages: (source: RawStage[] | RawStageSource | null | undefined) => Stage[] | undefined;
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Merges incoming stage deltas into an existing stage list, keyed by `index`.
|
|
613
|
+
*
|
|
614
|
+
* Partial `name` and `content` strings are concatenated across chunks;
|
|
615
|
+
* attachments are merged by their own `index` (concatenating partial `title`
|
|
616
|
+
* and `data`); every other field on the incoming delta overwrites the
|
|
617
|
+
* accumulated one. A brand-new stage whose first chunk carries `name: null`
|
|
618
|
+
* is normalized to `''`.
|
|
619
|
+
*
|
|
620
|
+
* Exported for hosts that keep a flattened `Stage[]` on the message instead
|
|
621
|
+
* of `Message.custom_content.stages` and therefore cannot reuse
|
|
622
|
+
* {@link applyChunkToMessages}. Prefer `useConversationStream` when the host
|
|
623
|
+
* can delegate the whole stream loop.
|
|
624
|
+
*/
|
|
625
|
+
export declare const mergeStages: (existing: Stage[], incoming: Stage[]) => Stage[];
|
|
626
|
+
|
|
576
627
|
/** True when `message` is an assistant message carrying at least one stage. */
|
|
577
628
|
export declare const messageHasStages: (message: Message) => boolean;
|
|
578
629
|
|
|
@@ -606,6 +657,63 @@ export declare interface QuickAppConversationStartersSettings {
|
|
|
606
657
|
isChatMessageInputDisabled: boolean;
|
|
607
658
|
}
|
|
608
659
|
|
|
660
|
+
/**
|
|
661
|
+
* One stage as it arrives from the REST API or the SSE stream, before
|
|
662
|
+
* normalization. Structurally satisfied by the generated `StageDto` and by a
|
|
663
|
+
* raw stream delta, both of which omit `index`/`name`/`status` on the chunk
|
|
664
|
+
* that opens a stage.
|
|
665
|
+
*/
|
|
666
|
+
export declare interface RawStage {
|
|
667
|
+
/** Ordering key. Defaults to `0` when absent. */
|
|
668
|
+
index?: number | null;
|
|
669
|
+
/** Stage title. `null` on the chunk that opens the stage. */
|
|
670
|
+
name?: string | null;
|
|
671
|
+
/** Terminal state as a raw wire string; anything other than `'completed'`/`'failed'` means still running. */
|
|
672
|
+
status?: string | null;
|
|
673
|
+
/** Additional stage text. */
|
|
674
|
+
content?: string | null;
|
|
675
|
+
/** Short source/category label shown beside the stage name. */
|
|
676
|
+
tag?: string | null;
|
|
677
|
+
/** Files produced or referenced by this stage. */
|
|
678
|
+
attachments?: RawStageAttachment[] | null;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* One stage attachment as it arrives from the REST API or the SSE stream,
|
|
683
|
+
* before normalization: every field is optional and may be `null`.
|
|
684
|
+
*/
|
|
685
|
+
export declare interface RawStageAttachment {
|
|
686
|
+
/** Zero-based position in the attachment list. */
|
|
687
|
+
index?: number | null;
|
|
688
|
+
/** MIME type of the attachment content. */
|
|
689
|
+
type?: string | null;
|
|
690
|
+
/** Display name shown in the UI. */
|
|
691
|
+
title?: string | null;
|
|
692
|
+
/** Inline base-64 encoded content. */
|
|
693
|
+
data?: string | null;
|
|
694
|
+
/** Remote URL pointing to the attachment content. */
|
|
695
|
+
url?: string | null;
|
|
696
|
+
/** MIME type of the referenced resource. */
|
|
697
|
+
reference_type?: string | null;
|
|
698
|
+
/** URL of an alternate reference resource. */
|
|
699
|
+
reference_url?: string | null;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* Message-like payload carrying stages under either the wire's snake_case
|
|
704
|
+
* `custom_content` or a host's camelCased `customContent`.
|
|
705
|
+
*/
|
|
706
|
+
export declare interface RawStageSource {
|
|
707
|
+
/** Custom content as the DIAL wire format spells it. */
|
|
708
|
+
custom_content?: {
|
|
709
|
+
stages?: RawStage[] | null;
|
|
710
|
+
} | null;
|
|
711
|
+
/** Custom content as a camelCasing host spells it. */
|
|
712
|
+
customContent?: {
|
|
713
|
+
stages?: RawStage[] | null;
|
|
714
|
+
} | null;
|
|
715
|
+
}
|
|
716
|
+
|
|
609
717
|
/** State of one resource's recipient-count lookup. */
|
|
610
718
|
declare interface RecipientsCountEntry {
|
|
611
719
|
/** Where the lookup for this resource currently stands. */
|
|
@@ -662,8 +770,23 @@ export declare interface StreamCompletionOptions {
|
|
|
662
770
|
signal: AbortSignal;
|
|
663
771
|
}
|
|
664
772
|
|
|
665
|
-
/**
|
|
666
|
-
|
|
773
|
+
/**
|
|
774
|
+
* Reported through `onError` when DIAL Core itself signals a failure with an
|
|
775
|
+
* in-band `{ error: { message } }` SSE chunk. Its `message` is upstream text
|
|
776
|
+
* intended for the user, unlike a transport failure (failed `fetch`, non-OK
|
|
777
|
+
* status, broken stream), whose message is technical detail. A custom
|
|
778
|
+
* transport raises this for any user-facing upstream error text.
|
|
779
|
+
*/
|
|
780
|
+
export declare class StreamUpstreamError extends Error {
|
|
781
|
+
constructor(message: string);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* Returns a renderable `Stage` for one raw payload: `index` defaults to `0`,
|
|
786
|
+
* `name` to `''`, an unrecognized `status` to `null` (still running), and
|
|
787
|
+
* `content`/`tag`/`attachments` are passed through when present.
|
|
788
|
+
*/
|
|
789
|
+
export declare const toStage: (stage: RawStage) => Stage;
|
|
667
790
|
|
|
668
791
|
/** Request shape the host's selected-deployment recognition call accepts. */
|
|
669
792
|
export declare interface TranscribeWithDeploymentParams {
|
|
@@ -728,8 +851,8 @@ export declare const useAttachmentUpload: ({ filesApi, bucket, onNetworkError, d
|
|
|
728
851
|
|
|
729
852
|
/** Parameters for {@link useAttachmentUpload}. */
|
|
730
853
|
export declare interface UseAttachmentUploadParams {
|
|
731
|
-
/** Already-configured
|
|
732
|
-
filesApi: Pick<FilesApi, 'uploadFile'
|
|
854
|
+
/** Already-configured client; optional listing skips stored names after a conflict. */
|
|
855
|
+
filesApi: Pick<FilesApi, 'uploadFile'> & Partial<Pick<FilesApi, 'listFiles'>>;
|
|
733
856
|
/** DIAL Core bucket the file is uploaded into. */
|
|
734
857
|
bucket: string | undefined;
|
|
735
858
|
/** Called with batched filenames after a burst of network-error upload failures. */
|
|
@@ -938,7 +1061,7 @@ export declare interface UseConversationPanelItemsResolvers {
|
|
|
938
1061
|
* `transport`/`generation`/`channel`/`overlay` capabilities rather than any
|
|
939
1062
|
* app context or `server-api` import.
|
|
940
1063
|
*/
|
|
941
|
-
export declare const useConversationStream: ({ conversationId, state: { setConversation, conversationRef }, transport, generation: { startGeneration, completeGeneration }, channel, overlay, onStopError, generationConflictMessage, }: UseConversationStreamParams) => UseConversationStreamResult;
|
|
1064
|
+
export declare const useConversationStream: ({ conversationId, state: { setConversation, conversationRef }, transport, generation: { startGeneration, completeGeneration }, channel, overlay, onStopError, generationConflictMessage, generationPersistenceErrorMessage, onStreamError, }: UseConversationStreamParams) => UseConversationStreamResult;
|
|
942
1065
|
|
|
943
1066
|
/** Parameters for {@link useConversationStream}. */
|
|
944
1067
|
export declare interface UseConversationStreamParams {
|
|
@@ -956,6 +1079,15 @@ export declare interface UseConversationStreamParams {
|
|
|
956
1079
|
* {@link DEFAULT_GENERATION_CONFLICT_MESSAGE}.
|
|
957
1080
|
*/
|
|
958
1081
|
generationConflictMessage?: string;
|
|
1082
|
+
/** Host-translated warning shown when the received answer could not be saved. */
|
|
1083
|
+
generationPersistenceErrorMessage?: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* Receives the original error of every failed stream. The hook shows only
|
|
1086
|
+
* host-supplied or upstream-supplied text on the message bubble and hides
|
|
1087
|
+
* transport detail (e.g. `Failed to fetch`), so this is where the host can
|
|
1088
|
+
* still log or report the raw error.
|
|
1089
|
+
*/
|
|
1090
|
+
onStreamError?: (error: Error) => void;
|
|
959
1091
|
}
|
|
960
1092
|
|
|
961
1093
|
/** Return value of {@link useConversationStream}. */
|