@epam/ai-dial-chat-hooks 1.2.0-dev.252 → 1.2.0-dev.256
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/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +63 -63
- package/catalog/usePublishFolders/usePublishFolders.js +1 -1
- package/catalog.d.ts +4 -5
- package/conversation/useConversationStream/generation-resume.js +71 -70
- package/conversation/useConversationStream/useConversationStream.js +113 -100
- package/conversation.d.ts +12 -6
- package/file-manager-canvas.d.ts +8 -2
- package/files/attachment-canvas.js +2 -1
- package/index.d.ts +24 -13
- package/package.json +17 -17
|
@@ -5,126 +5,126 @@ import { getRunnerSchemas as r, isQuickAppSchema as i } from "../../shared/appli
|
|
|
5
5
|
import { CatalogEntityType as a } from "@epam/ai-dial-chat-shared";
|
|
6
6
|
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
7
7
|
//#region src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts
|
|
8
|
-
var l =
|
|
9
|
-
let
|
|
8
|
+
var l = ({ deployments: l, isCustomAppsEnabled: u, isSchemaAppsEnabled: d, isHideCustomAppCreationEnabled: f, isToolsetsEnabled: p, isPromptsEnabled: m, schemas: h, urls: g, onNavigate: _, deletePrompt: v, deleteToolset: y, deleteSkill: b, deleteApplication: x, refetchPrompts: S, refetchToolsets: C, refetchSkills: w, refetchDeployments: T, onDeleteSuccess: E, labels: D, onNotify: O, onSkillUploadClick: k }) => {
|
|
9
|
+
let A = s(() => r(h), [h]), [j, M] = c(""), N = d && !f;
|
|
10
10
|
return {
|
|
11
11
|
handleEdit: o((e) => {
|
|
12
12
|
if (e.type === a.Prompt) {
|
|
13
|
-
|
|
13
|
+
_(g.buildPromptEditUrl(e.id));
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
if (e.type === a.Skill) {
|
|
17
|
-
|
|
17
|
+
_(g.buildSkillEditUrl(e.id));
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
if (e.type === a.Toolset) {
|
|
21
|
-
|
|
21
|
+
_(g.buildToolsetEditUrl(e.id));
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
let n = t(
|
|
25
|
-
if (
|
|
26
|
-
|
|
24
|
+
let n = t(l, e.id);
|
|
25
|
+
if (u && n != null && !n.applicationTypeSchemaId) {
|
|
26
|
+
_(g.buildCustomAppEditUrl(e.id));
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
let r =
|
|
30
|
-
r &&
|
|
29
|
+
let r = A.find((e) => e.id === n?.applicationTypeSchemaId)?.id ?? A.find((e) => i(e))?.id;
|
|
30
|
+
r && _(g.buildQuickAppEditUrl(r, e.id));
|
|
31
31
|
}, [
|
|
32
|
+
l,
|
|
32
33
|
u,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
_
|
|
34
|
+
A,
|
|
35
|
+
_,
|
|
36
|
+
g
|
|
37
37
|
]),
|
|
38
38
|
handleDelete: o(async (t) => {
|
|
39
39
|
try {
|
|
40
|
-
if (t.type === a.Prompt) await
|
|
41
|
-
else if (t.type === a.Toolset) await
|
|
40
|
+
if (t.type === a.Prompt) await v(t.id), await S();
|
|
41
|
+
else if (t.type === a.Toolset) await y(t.id), await C();
|
|
42
42
|
else if (t.type === a.Skill) {
|
|
43
43
|
let e = n(t.id);
|
|
44
44
|
if (e == null) throw Error(`Invalid skill resource url: ${t.id}`);
|
|
45
|
-
await
|
|
46
|
-
} else await
|
|
47
|
-
|
|
45
|
+
await b(e.bucket, e.path), await w();
|
|
46
|
+
} else await x(t.id), await T();
|
|
47
|
+
E(t);
|
|
48
48
|
} catch (t) {
|
|
49
49
|
let { traceId: n } = await e(t);
|
|
50
|
-
throw
|
|
51
|
-
message:
|
|
50
|
+
throw O({
|
|
51
|
+
message: D.deleteError,
|
|
52
52
|
requestId: n
|
|
53
53
|
}), t;
|
|
54
54
|
}
|
|
55
55
|
}, [
|
|
56
|
+
v,
|
|
56
57
|
y,
|
|
57
58
|
b,
|
|
58
59
|
x,
|
|
60
|
+
C,
|
|
61
|
+
T,
|
|
59
62
|
S,
|
|
60
63
|
w,
|
|
61
64
|
E,
|
|
62
|
-
C,
|
|
63
|
-
T,
|
|
64
65
|
D,
|
|
65
|
-
O
|
|
66
|
-
k
|
|
66
|
+
O
|
|
67
67
|
]),
|
|
68
68
|
createOptions: s(() => {
|
|
69
|
-
let e =
|
|
70
|
-
|
|
69
|
+
let e = j.trim().toLocaleLowerCase(), t = (t) => !e || t.toLocaleLowerCase().includes(e), n = [];
|
|
70
|
+
N && A.map((e) => ({
|
|
71
71
|
id: e.id,
|
|
72
|
-
label:
|
|
73
|
-
})).
|
|
72
|
+
label: e.displayName || e.id
|
|
73
|
+
})).filter((e) => t(e.label)).forEach((e) => {
|
|
74
74
|
n.push({
|
|
75
75
|
key: `runner:${e.id}`,
|
|
76
76
|
label: e.label,
|
|
77
|
-
onClick: () =>
|
|
77
|
+
onClick: () => _(g.buildQuickAppCreateUrl(e.id))
|
|
78
78
|
});
|
|
79
|
-
}),
|
|
79
|
+
}), p && t(D.createToolset) && n.push({
|
|
80
80
|
key: "toolset",
|
|
81
|
-
label:
|
|
82
|
-
onClick: () =>
|
|
83
|
-
}),
|
|
81
|
+
label: D.createToolset,
|
|
82
|
+
onClick: () => _(g.buildToolsetCreateUrl())
|
|
83
|
+
}), u && !f && t(D.createCustomApp) && n.push({
|
|
84
84
|
key: "custom-app",
|
|
85
|
-
label:
|
|
86
|
-
onClick: () =>
|
|
85
|
+
label: D.createCustomApp,
|
|
86
|
+
onClick: () => _(g.buildCustomAppCreateUrl())
|
|
87
87
|
});
|
|
88
88
|
let r = [{
|
|
89
89
|
key: "skill-write-instructions",
|
|
90
|
-
label:
|
|
91
|
-
onClick: () =>
|
|
90
|
+
label: D.createSkillWriteInstructions,
|
|
91
|
+
onClick: () => _(g.buildSkillCreateUrl())
|
|
92
92
|
}, {
|
|
93
93
|
key: "skill-upload",
|
|
94
|
-
label:
|
|
95
|
-
onClick:
|
|
96
|
-
}],
|
|
97
|
-
return
|
|
94
|
+
label: D.createSkillUpload,
|
|
95
|
+
onClick: k
|
|
96
|
+
}], i = t(D.createSkill) ? r : r.filter((e) => t(String(e.label)));
|
|
97
|
+
return i.length > 0 && n.push({
|
|
98
98
|
key: "skill",
|
|
99
|
-
label:
|
|
100
|
-
children:
|
|
101
|
-
}),
|
|
99
|
+
label: D.createSkill,
|
|
100
|
+
children: i
|
|
101
|
+
}), m && t(D.createPrompt) && n.push({
|
|
102
102
|
key: "prompt",
|
|
103
|
-
label:
|
|
104
|
-
onClick: () =>
|
|
105
|
-
}), n;
|
|
103
|
+
label: D.createPrompt,
|
|
104
|
+
onClick: () => _(g.buildPromptCreateUrl())
|
|
105
|
+
}), n.sort((e, t) => String(e.label ?? "").localeCompare(String(t.label ?? ""), void 0, { sensitivity: "base" }));
|
|
106
106
|
}, [
|
|
107
|
-
M,
|
|
108
|
-
P,
|
|
109
107
|
j,
|
|
110
|
-
|
|
108
|
+
N,
|
|
109
|
+
A,
|
|
111
110
|
_,
|
|
112
|
-
|
|
113
|
-
O,
|
|
114
|
-
p,
|
|
111
|
+
g,
|
|
115
112
|
m,
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
D,
|
|
114
|
+
f,
|
|
115
|
+
p,
|
|
116
|
+
u,
|
|
117
|
+
k
|
|
118
118
|
]),
|
|
119
|
-
createSearch: s(() =>
|
|
120
|
-
value:
|
|
121
|
-
onChange:
|
|
119
|
+
createSearch: s(() => N && A.length > 0 ? {
|
|
120
|
+
value: j,
|
|
121
|
+
onChange: M
|
|
122
122
|
} : void 0, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
N,
|
|
124
|
+
A.length,
|
|
125
|
+
j
|
|
126
126
|
])
|
|
127
127
|
};
|
|
128
128
|
};
|
|
129
129
|
//#endregion
|
|
130
|
-
export {
|
|
130
|
+
export { l as useCatalogEditNavigation };
|
|
@@ -48,7 +48,7 @@ var c = "Production", l = 50, u = (e, t, n) => {
|
|
|
48
48
|
return b((e) => e.includes(n) ? e : [...e, n]), Promise.resolve();
|
|
49
49
|
}, []), T = e((e) => {
|
|
50
50
|
let t = s(e), n = Array.isArray(d) ? d : [];
|
|
51
|
-
!t || n
|
|
51
|
+
!t || n[0] === t || f?.([t, ...n.filter((e) => e !== t)].slice(0, l));
|
|
52
52
|
}, [d, f]), E = e((e) => !e.includes(c), []);
|
|
53
53
|
return {
|
|
54
54
|
folderItems: n(() => {
|
package/catalog.d.ts
CHANGED
|
@@ -169,7 +169,6 @@ export declare interface CatalogDetailsApi extends SkillDetailsApi {
|
|
|
169
169
|
|
|
170
170
|
/** Localized copy `useCatalogEditNavigation` needs for the Create menu and delete errors. */
|
|
171
171
|
export declare interface CatalogEditNavigationLabels {
|
|
172
|
-
createQuickApp: string;
|
|
173
172
|
createToolset: string;
|
|
174
173
|
createCustomApp: string;
|
|
175
174
|
createSkill: string;
|
|
@@ -1047,7 +1046,7 @@ export declare interface UseCatalogEditNavigationParams {
|
|
|
1047
1046
|
export declare interface UseCatalogEditNavigationResult {
|
|
1048
1047
|
handleEdit: (item: CatalogItem) => void;
|
|
1049
1048
|
handleDelete: (item: CatalogItem) => Promise<void>;
|
|
1050
|
-
/** The Create dropdown's items: runners
|
|
1049
|
+
/** The Create dropdown's items: runners and static options sorted together by label, all filtered by `createSearch.value`. */
|
|
1051
1050
|
createOptions: DropdownItem[];
|
|
1052
1051
|
/** The Create menu's search field state, or `undefined` when no runner option is offered. */
|
|
1053
1052
|
createSearch: CatalogCreateSearch | undefined;
|
|
@@ -1228,9 +1227,9 @@ export declare interface UsePublishFoldersResult {
|
|
|
1228
1227
|
*/
|
|
1229
1228
|
onCreatePublishFolder: (parentPath: string[], name: string) => Promise<void>;
|
|
1230
1229
|
/**
|
|
1231
|
-
* Records `folderPath` as
|
|
1232
|
-
* so it keeps appearing in the tree on
|
|
1233
|
-
* successful publish.
|
|
1230
|
+
* Records `folderPath` as the most recent publish destination (moving it to
|
|
1231
|
+
* the front if already remembered), so it keeps appearing in the tree on
|
|
1232
|
+
* later publishes. Call it after a successful publish.
|
|
1234
1233
|
*/
|
|
1235
1234
|
rememberPublishFolder: (folderPath: string[]) => void;
|
|
1236
1235
|
/** Heuristic write-access check for a folder path (see the TODO above). */
|
|
@@ -3,37 +3,38 @@ import { DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE as t, GenerationPersistenc
|
|
|
3
3
|
import { getConversationPath as r } from "./conversation-path.js";
|
|
4
4
|
import { applyChunkToMessages as i } from "./apply-chunk.js";
|
|
5
5
|
import { restoreBufferedMessage as a } from "./buffered-generation.js";
|
|
6
|
-
import {
|
|
6
|
+
import { BackgroundGenerationStatus as o, MessageRole as s } from "@epam/ai-dial-chat-shared";
|
|
7
7
|
//#region src/conversation/useConversationStream/generation-resume.ts
|
|
8
|
-
var
|
|
8
|
+
var c = (e) => {
|
|
9
9
|
let t = e.custom_content;
|
|
10
10
|
return !!e.content || e.responseId != null || !!t?.attachments?.length || !!t?.stages?.length || !!t?.annotations?.length || !!t?.form_schema || t?.state != null;
|
|
11
|
-
},
|
|
11
|
+
}, l = (e) => e.messages.findIndex((e) => e.backgroundGeneration?.status === o.Pending), u = (e) => {
|
|
12
|
+
if (l(e) !== -1) return !0;
|
|
12
13
|
let t = e.messages[e.messages.length - 1];
|
|
13
|
-
return !!t && t.role ===
|
|
14
|
-
},
|
|
14
|
+
return !!t && t.role === s.Assistant && !c(t) && t.streamErrorMessage == null && !t.wasStoppedByUser;
|
|
15
|
+
}, d = 300 * 1e3, f = "awaiting-resume", p = [
|
|
15
16
|
1e3,
|
|
16
17
|
2e3,
|
|
17
18
|
4e3,
|
|
18
19
|
8e3,
|
|
19
20
|
16e3
|
|
20
|
-
],
|
|
21
|
+
], m = (e) => new Promise((t) => {
|
|
21
22
|
let n = typeof window < "u", r = () => {
|
|
22
23
|
clearTimeout(i), n && window.removeEventListener("online", r), t();
|
|
23
24
|
}, i = setTimeout(r, e);
|
|
24
25
|
n && window.addEventListener("online", r);
|
|
25
|
-
}),
|
|
26
|
-
for (let n = 0; n <=
|
|
26
|
+
}), h = async (e, t) => {
|
|
27
|
+
for (let n = 0; n <= p.length; n++) {
|
|
27
28
|
if (t()) return null;
|
|
28
29
|
try {
|
|
29
30
|
return await e();
|
|
30
31
|
} catch {
|
|
31
|
-
if (n ===
|
|
32
|
-
await
|
|
32
|
+
if (n === p.length) return null;
|
|
33
|
+
await m(p[n]);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
return null;
|
|
36
|
-
},
|
|
37
|
+
}, g = async (e, t) => {
|
|
37
38
|
let n = e.getReader(), r = new TextDecoder(), i = "";
|
|
38
39
|
try {
|
|
39
40
|
for (;;) {
|
|
@@ -62,112 +63,112 @@ var s = (e) => {
|
|
|
62
63
|
} catch {} finally {
|
|
63
64
|
n.releaseLock();
|
|
64
65
|
}
|
|
65
|
-
},
|
|
66
|
-
if (!
|
|
67
|
-
|
|
66
|
+
}, _ = ({ transport: o, setConversation: s, conversationRef: p, resumingPathsRef: m, bufferedGenerationsRef: h, addStreamingPath: _, removeStreamingPath: v, isPathDisplayed: y, generationPersistenceErrorMessage: b = t, frameScheduler: x, stoppedGenerationIdsRef: S }) => (t, C, w = {}) => {
|
|
67
|
+
if (!u(C)) {
|
|
68
|
+
w.onSettled?.();
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
let
|
|
71
|
-
if (!
|
|
72
|
-
|
|
73
|
-
let
|
|
74
|
-
generationId:
|
|
75
|
-
messageIndex:
|
|
76
|
-
message:
|
|
71
|
+
let T = r(t);
|
|
72
|
+
if (!w.skipDedupe && m.current.has(T)) return;
|
|
73
|
+
m.current.add(T), _(T);
|
|
74
|
+
let E = l(C), D = E !== -1, O = D ? E : C.messages.length - 1, k = {
|
|
75
|
+
generationId: f,
|
|
76
|
+
messageIndex: O,
|
|
77
|
+
message: w.seedMessage ?? C.messages[O]
|
|
77
78
|
};
|
|
78
|
-
h.current.set(
|
|
79
|
-
let
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
let n = e && e.messages.length - 1 ===
|
|
79
|
+
h.current.set(T, k);
|
|
80
|
+
let A = () => h.current.get(T) === k, j = D ? C.messages[O].backgroundGeneration?.generationId : void 0, M = () => j != null && (S?.current.has(j) ?? !1), N = (e, t = !1) => {
|
|
81
|
+
if (x?.flush(T), j != null && S?.current.delete(j), !A()) return;
|
|
82
|
+
m.current.delete(T), v(T);
|
|
83
|
+
let n = !D && e && e.messages.length - 1 === O && u(e) && c(k.message);
|
|
83
84
|
if (t || n) {
|
|
84
|
-
|
|
85
|
-
...
|
|
86
|
-
streamErrorMessage:
|
|
87
|
-
},
|
|
88
|
-
if (!e || !
|
|
89
|
-
let t = a(e,
|
|
90
|
-
return
|
|
85
|
+
k.message = {
|
|
86
|
+
...k.message,
|
|
87
|
+
streamErrorMessage: b
|
|
88
|
+
}, y(T) && s((e) => {
|
|
89
|
+
if (!e || !A() || !y(T)) return e;
|
|
90
|
+
let t = a(e, k);
|
|
91
|
+
return p.current = t, t;
|
|
91
92
|
});
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
|
-
h.current.delete(
|
|
95
|
-
},
|
|
95
|
+
h.current.delete(T), e && y(T) && (s(e), p.current = e);
|
|
96
|
+
}, P = async () => {
|
|
96
97
|
try {
|
|
97
|
-
|
|
98
|
+
N(await o.getConversation(e(t)));
|
|
98
99
|
} catch {
|
|
99
|
-
|
|
100
|
+
N(void 0, c(k.message));
|
|
100
101
|
}
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
if (!e || !
|
|
104
|
-
let t = a(e,
|
|
105
|
-
return
|
|
102
|
+
}, F = (e) => {
|
|
103
|
+
x?.cancel(T), A() && (k.message = e, y(T) && s((e) => {
|
|
104
|
+
if (!e || !A() || !y(T)) return e;
|
|
105
|
+
let t = a(e, k);
|
|
106
|
+
return p.current = t, t;
|
|
106
107
|
}));
|
|
107
|
-
},
|
|
108
|
-
if (!e || !
|
|
109
|
-
let t = a(e,
|
|
110
|
-
return
|
|
111
|
-
}),
|
|
112
|
-
if (!
|
|
113
|
-
let t = i([
|
|
114
|
-
if (t && (
|
|
115
|
-
if (
|
|
116
|
-
|
|
108
|
+
}, I = () => s((e) => {
|
|
109
|
+
if (!e || !A() || !y(T)) return e;
|
|
110
|
+
let t = a(e, k);
|
|
111
|
+
return p.current = t, t;
|
|
112
|
+
}), L = (e) => {
|
|
113
|
+
if (!A() || M()) return;
|
|
114
|
+
let t = i([k.message], 0, e);
|
|
115
|
+
if (t && (k.message = t[0]), y(T)) {
|
|
116
|
+
if (x) {
|
|
117
|
+
x.schedule(T, I);
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
I();
|
|
120
121
|
}
|
|
121
|
-
},
|
|
122
|
+
}, R = async () => {
|
|
122
123
|
let n = new AbortController(), r;
|
|
123
124
|
try {
|
|
124
|
-
r = await o.watchConversation(
|
|
125
|
+
r = await o.watchConversation(T, n.signal);
|
|
125
126
|
} catch {
|
|
126
|
-
await
|
|
127
|
+
await P();
|
|
127
128
|
return;
|
|
128
129
|
}
|
|
129
130
|
let i = !1, a = window.setTimeout(() => {
|
|
130
131
|
n.abort();
|
|
131
|
-
},
|
|
132
|
+
}, d);
|
|
132
133
|
try {
|
|
133
|
-
await
|
|
134
|
+
await g(r, async (n) => {
|
|
134
135
|
if (n?.action !== "UPDATE") return !1;
|
|
135
136
|
try {
|
|
136
137
|
let n = await o.getConversation(e(t));
|
|
137
|
-
if (!
|
|
138
|
+
if (!u(n)) return N(n), i = !0, !0;
|
|
138
139
|
} catch {}
|
|
139
140
|
return !1;
|
|
140
141
|
});
|
|
141
142
|
} finally {
|
|
142
143
|
clearTimeout(a);
|
|
143
144
|
}
|
|
144
|
-
i || await
|
|
145
|
-
},
|
|
145
|
+
i || await P();
|
|
146
|
+
}, z = async () => {
|
|
146
147
|
let e = new AbortController(), t;
|
|
147
148
|
try {
|
|
148
|
-
t = await o.attachToGeneration(
|
|
149
|
+
t = await o.attachToGeneration(T, e.signal);
|
|
149
150
|
} catch {
|
|
150
151
|
return !1;
|
|
151
152
|
}
|
|
152
153
|
let r = !1, i = !1;
|
|
153
|
-
return await
|
|
154
|
-
if (!
|
|
154
|
+
return await g(t, (e) => {
|
|
155
|
+
if (!A()) return !0;
|
|
155
156
|
switch (e.type) {
|
|
156
|
-
case "snapshot": return
|
|
157
|
-
case "chunk": return
|
|
157
|
+
case "snapshot": return F(e.message), !1;
|
|
158
|
+
case "chunk": return L(e.chunk), !1;
|
|
158
159
|
case "done":
|
|
159
160
|
case "error":
|
|
160
161
|
case "stopped": return i = e.type === "error" && e.errorType === n.type, r = !0, !0;
|
|
161
162
|
}
|
|
162
|
-
}), r ? (i ?
|
|
163
|
+
}), r ? (i ? N(void 0, !0) : await P(), !0) : !A();
|
|
163
164
|
};
|
|
164
165
|
(async () => {
|
|
165
166
|
try {
|
|
166
|
-
await
|
|
167
|
+
await z() || await R();
|
|
167
168
|
} finally {
|
|
168
|
-
|
|
169
|
+
w.onSettled?.();
|
|
169
170
|
}
|
|
170
171
|
})();
|
|
171
172
|
};
|
|
172
173
|
//#endregion
|
|
173
|
-
export {
|
|
174
|
+
export { _ as createResumeIfAwaitingGeneration, h as fetchConversationForRecovery, l as findPendingBackgroundMessageIndex, c as hasGeneratedPayload, u as isAwaitingGenerationResume };
|
|
@@ -3,36 +3,40 @@ import { DEFAULT_GENERATION_CONFLICT_MESSAGE as t, DEFAULT_GENERATION_PERSISTENC
|
|
|
3
3
|
import { getConversationPath as s } from "./conversation-path.js";
|
|
4
4
|
import { applyChunkToMessages as c } from "./apply-chunk.js";
|
|
5
5
|
import { restoreBufferedMessage as l } from "./buffered-generation.js";
|
|
6
|
-
import { createResumeIfAwaitingGeneration as u, fetchConversationForRecovery as d, hasGeneratedPayload as
|
|
7
|
-
import { createFrameScheduler as
|
|
8
|
-
import { MessageRole as
|
|
9
|
-
import { useCallback as
|
|
10
|
-
import { SendCompletionDtoModeEnum as
|
|
6
|
+
import { createResumeIfAwaitingGeneration as u, fetchConversationForRecovery as ee, findPendingBackgroundMessageIndex as d, hasGeneratedPayload as te, isAwaitingGenerationResume as f } from "./generation-resume.js";
|
|
7
|
+
import { createFrameScheduler as p } from "./frame-scheduler.js";
|
|
8
|
+
import { MessageRole as m, generateUUID as ne } from "@epam/ai-dial-chat-shared";
|
|
9
|
+
import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
10
|
+
import { SendCompletionDtoModeEnum as b } from "@epam/ai-dial-chat-api-client";
|
|
11
11
|
//#region src/conversation/useConversationStream/useConversationStream.ts
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var re = 2e4, ie = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e instanceof o ? e.message : "", x = (e) => {
|
|
13
|
+
if (!e) return;
|
|
14
|
+
let t = d(e);
|
|
15
|
+
return t === -1 ? void 0 : e.messages[t].backgroundGeneration?.generationId;
|
|
16
|
+
}, S = ({ conversationId: r, state: { setConversation: o, conversationRef: S }, transport: C, generation: { startGeneration: w, completeGeneration: T }, channel: E, overlay: D, onStopError: O, generationConflictMessage: k = t, generationPersistenceErrorMessage: A = n, onStreamError: j, batchChunksPerFrame: M = !1 }) => {
|
|
17
|
+
let N = v(j);
|
|
18
|
+
g(() => {
|
|
15
19
|
N.current = j;
|
|
16
20
|
}, [j]);
|
|
17
|
-
let P =
|
|
18
|
-
|
|
21
|
+
let P = v(M);
|
|
22
|
+
g(() => {
|
|
19
23
|
P.current = M;
|
|
20
24
|
}, [M]);
|
|
21
|
-
let [F] =
|
|
22
|
-
|
|
23
|
-
let q =
|
|
25
|
+
let [F] = y(p), [I, L] = y(() => /* @__PURE__ */ new Set()), [R, z] = y(null), B = v(null), V = v(null), H = v(/* @__PURE__ */ new Set()), U = v(/* @__PURE__ */ new Map()), W = v(/* @__PURE__ */ new Set()), G = v(/* @__PURE__ */ new Map()), K = v(r);
|
|
26
|
+
g(() => (K.current = r, () => F.cancelAll()), [r, F]);
|
|
27
|
+
let q = h((e) => s(K.current ?? "") === e, []), J = h((e) => {
|
|
24
28
|
L((t) => {
|
|
25
29
|
if (t.has(e)) return t;
|
|
26
30
|
let n = new Set(t);
|
|
27
31
|
return n.add(e), n;
|
|
28
32
|
});
|
|
29
|
-
}, []), Y =
|
|
33
|
+
}, []), Y = h((e) => {
|
|
30
34
|
L((t) => {
|
|
31
35
|
if (!t.has(e)) return t;
|
|
32
36
|
let n = new Set(t);
|
|
33
37
|
return n.delete(e), n;
|
|
34
38
|
});
|
|
35
|
-
}, []), X =
|
|
39
|
+
}, []), X = _(() => u({
|
|
36
40
|
transport: C,
|
|
37
41
|
setConversation: o,
|
|
38
42
|
conversationRef: S,
|
|
@@ -42,7 +46,8 @@ var te = 2e4, ne = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
42
46
|
removeStreamingPath: Y,
|
|
43
47
|
isPathDisplayed: q,
|
|
44
48
|
generationPersistenceErrorMessage: A,
|
|
45
|
-
frameScheduler: M ? F : void 0
|
|
49
|
+
frameScheduler: M ? F : void 0,
|
|
50
|
+
stoppedGenerationIdsRef: W
|
|
46
51
|
}), [
|
|
47
52
|
J,
|
|
48
53
|
Y,
|
|
@@ -51,44 +56,44 @@ var te = 2e4, ne = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
51
56
|
A,
|
|
52
57
|
M,
|
|
53
58
|
F
|
|
54
|
-
]), Z =
|
|
55
|
-
let
|
|
56
|
-
F.flush(
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
generationId:
|
|
59
|
+
]), Z = h((t, n, r, u, p, h, g = b.Append) => {
|
|
60
|
+
let _ = h ?? ne(), v = s(t);
|
|
61
|
+
F.flush(v), H.current.delete(v), B.current = _, V.current = v, G.current.set(v, _), z(v);
|
|
62
|
+
let y;
|
|
63
|
+
g === b.Regenerate ? y = r : g === b.Edit && (y = r - 1);
|
|
64
|
+
let x = () => G.current.get(v) !== _, O = w(v, _), j = S.current?.messages[r];
|
|
65
|
+
j ? U.current.set(v, {
|
|
66
|
+
generationId: _,
|
|
62
67
|
messageIndex: r,
|
|
63
|
-
message:
|
|
64
|
-
}) : U.current.delete(
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
if (
|
|
69
|
-
let e = U.current.get(
|
|
70
|
-
!e || e.generationId !==
|
|
68
|
+
message: j
|
|
69
|
+
}) : U.current.delete(v), J(v), D?.notifyGenerationStart?.(), E?.ensureConnected();
|
|
70
|
+
let M = () => {
|
|
71
|
+
x() || Y(v), B.current === _ && (B.current = null, V.current = null, z(null)), T(v, _), E?.notifyGenerationSettled?.();
|
|
72
|
+
}, I = () => {
|
|
73
|
+
if (x()) return;
|
|
74
|
+
let e = U.current.get(v);
|
|
75
|
+
!e || e.generationId !== _ || (e.message = {
|
|
71
76
|
...e.message,
|
|
72
77
|
streamErrorMessage: A
|
|
73
|
-
}, N.current?.(new i()), q(
|
|
74
|
-
if (!t ||
|
|
78
|
+
}, N.current?.(new i()), q(v) && o((t) => {
|
|
79
|
+
if (!t || x() || !q(v)) return t;
|
|
75
80
|
let n = l(t, e);
|
|
76
81
|
return S.current = n, n;
|
|
77
82
|
}));
|
|
78
|
-
},
|
|
79
|
-
signal:
|
|
83
|
+
}, L = {
|
|
84
|
+
signal: O.signal,
|
|
80
85
|
onChunk: (e) => {
|
|
81
|
-
if (B.current !==
|
|
82
|
-
let t = U.current.get(
|
|
83
|
-
if (t?.generationId ===
|
|
86
|
+
if (B.current !== _) return;
|
|
87
|
+
let t = U.current.get(v);
|
|
88
|
+
if (t?.generationId === _) {
|
|
84
89
|
let n = c([t.message], 0, e);
|
|
85
90
|
n && (t.message = n[0]);
|
|
86
91
|
}
|
|
87
|
-
if (q(
|
|
88
|
-
if (P.current && t?.generationId ===
|
|
89
|
-
F.schedule(
|
|
90
|
-
let e = U.current.get(
|
|
91
|
-
if (B.current !==
|
|
92
|
+
if (q(v)) {
|
|
93
|
+
if (P.current && t?.generationId === _) {
|
|
94
|
+
F.schedule(v, () => {
|
|
95
|
+
let e = U.current.get(v);
|
|
96
|
+
if (B.current !== _ || !q(v) || e?.generationId !== _) return;
|
|
92
97
|
let t = { ...e };
|
|
93
98
|
o((e) => {
|
|
94
99
|
if (!e) return e;
|
|
@@ -100,8 +105,8 @@ var te = 2e4, ne = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
100
105
|
}
|
|
101
106
|
o((t) => {
|
|
102
107
|
if (!t) return t;
|
|
103
|
-
let n = U.current.get(
|
|
104
|
-
if (n?.generationId ===
|
|
108
|
+
let n = U.current.get(v), i;
|
|
109
|
+
if (n?.generationId === _) i = l(t, n);
|
|
105
110
|
else {
|
|
106
111
|
let n = c(t.messages, r, e);
|
|
107
112
|
if (!n) return t;
|
|
@@ -115,47 +120,51 @@ var te = 2e4, ne = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
115
120
|
}
|
|
116
121
|
},
|
|
117
122
|
onComplete: async () => {
|
|
118
|
-
F.flush(
|
|
119
|
-
let n = U.current.get(
|
|
120
|
-
if (
|
|
121
|
-
if (!q(
|
|
122
|
-
r && U.current.delete(
|
|
123
|
+
F.flush(v);
|
|
124
|
+
let n = U.current.get(v), r = n?.generationId === _ ? n : void 0;
|
|
125
|
+
if (M(), W.current.has(_) ? W.current.delete(_) : x() || D?.notifyGenerationEnd?.(), !x()) {
|
|
126
|
+
if (!q(v)) {
|
|
127
|
+
r && U.current.delete(v);
|
|
123
128
|
return;
|
|
124
129
|
}
|
|
125
130
|
try {
|
|
126
131
|
let n = await C.getConversation(e(t));
|
|
127
|
-
if (
|
|
128
|
-
if (!q(
|
|
129
|
-
r && U.current.delete(
|
|
132
|
+
if (x()) return;
|
|
133
|
+
if (!q(v)) {
|
|
134
|
+
r && U.current.delete(v);
|
|
130
135
|
return;
|
|
131
136
|
}
|
|
132
|
-
if (
|
|
133
|
-
|
|
137
|
+
if (d(n) !== -1) {
|
|
138
|
+
X(t, n, { seedMessage: r?.message });
|
|
134
139
|
return;
|
|
135
140
|
}
|
|
136
|
-
r &&
|
|
141
|
+
if (r && r.messageIndex === n.messages.length - 1 && f(n) && te(r.message)) {
|
|
142
|
+
I();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
r && U.current.delete(v), o(n), S.current = n;
|
|
137
146
|
} catch {
|
|
138
|
-
|
|
147
|
+
x() || I();
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
},
|
|
142
151
|
onError: (e) => {
|
|
143
|
-
if (F.flush(
|
|
144
|
-
|
|
152
|
+
if (F.flush(v), N.current?.(e), e instanceof a && !x()) {
|
|
153
|
+
Z(e);
|
|
145
154
|
return;
|
|
146
155
|
}
|
|
147
|
-
|
|
156
|
+
R(e);
|
|
148
157
|
}
|
|
149
|
-
},
|
|
150
|
-
let t = U.current.get(
|
|
158
|
+
}, R = (e) => {
|
|
159
|
+
let t = U.current.get(v), n = t?.generationId === _ ? t : void 0;
|
|
151
160
|
if (n && (e instanceof i ? n.message = {
|
|
152
161
|
...n.message,
|
|
153
162
|
streamErrorMessage: A
|
|
154
|
-
} : U.current.delete(
|
|
155
|
-
let a =
|
|
163
|
+
} : U.current.delete(v)), M(), x() || !q(v)) return;
|
|
164
|
+
let a = ie(e, k, A);
|
|
156
165
|
o((e) => {
|
|
157
|
-
if (!e ||
|
|
158
|
-
let t = n?.generationId ===
|
|
166
|
+
if (!e || x() || !q(v)) return e;
|
|
167
|
+
let t = n?.generationId === _ ? l(e, n) : e, i = {
|
|
159
168
|
...t,
|
|
160
169
|
messages: t.messages.map((e, t) => t === r ? {
|
|
161
170
|
...e,
|
|
@@ -164,41 +173,41 @@ var te = 2e4, ne = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
164
173
|
};
|
|
165
174
|
return S.current = i, i;
|
|
166
175
|
});
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
},
|
|
170
|
-
H.current.add(
|
|
171
|
-
let i = await
|
|
172
|
-
if (
|
|
173
|
-
|
|
176
|
+
}, K = () => {
|
|
177
|
+
M(), W.current.has(_) ? W.current.delete(_) : x() || D?.notifyGenerationEnd?.();
|
|
178
|
+
}, Z = async (n) => {
|
|
179
|
+
H.current.add(v);
|
|
180
|
+
let i = await ee(() => C.getConversation(e(t)), x);
|
|
181
|
+
if (x()) {
|
|
182
|
+
M();
|
|
174
183
|
return;
|
|
175
184
|
}
|
|
176
|
-
let a = i?.messages[i.messages.length - 1], s = i != null && i.messages.length - 1 === r && a?.role ===
|
|
185
|
+
let a = i?.messages[i.messages.length - 1], s = i != null && i.messages.length - 1 === r && a?.role === m.Assistant;
|
|
177
186
|
if (!i || !s) {
|
|
178
|
-
H.current.delete(
|
|
187
|
+
H.current.delete(v), R(n);
|
|
179
188
|
return;
|
|
180
189
|
}
|
|
181
|
-
let c = U.current.get(
|
|
182
|
-
if (
|
|
190
|
+
let c = U.current.get(v), l = c?.generationId === _ ? c : void 0;
|
|
191
|
+
if (f(i)) {
|
|
183
192
|
X(t, i, {
|
|
184
193
|
seedMessage: l?.message,
|
|
185
194
|
skipDedupe: !0,
|
|
186
|
-
onSettled:
|
|
195
|
+
onSettled: K
|
|
187
196
|
});
|
|
188
197
|
return;
|
|
189
198
|
}
|
|
190
|
-
H.current.delete(
|
|
199
|
+
H.current.delete(v), l && U.current.delete(v), q(v) && (o(i), S.current = i), K();
|
|
191
200
|
};
|
|
192
201
|
(async () => {
|
|
193
202
|
try {
|
|
194
|
-
let e = E?.channelId ?? await E?.waitForChannel(
|
|
195
|
-
if (
|
|
196
|
-
U.current.get(
|
|
203
|
+
let e = E?.channelId ?? await E?.waitForChannel(re) ?? void 0, t = W.current.has(_);
|
|
204
|
+
if (O.signal.aborted || x() || t) {
|
|
205
|
+
U.current.get(v)?.generationId === _ && U.current.delete(v), x() || Y(v), B.current === _ && (B.current = null, V.current = null, z(null)), T(v, _), E?.notifyGenerationSettled?.(), t ? W.current.delete(_) : x() || D?.notifyGenerationEnd?.();
|
|
197
206
|
return;
|
|
198
207
|
}
|
|
199
|
-
C.streamCompletion(
|
|
208
|
+
C.streamCompletion(v, n, u, L, p, _, g, y, e);
|
|
200
209
|
} catch (e) {
|
|
201
|
-
|
|
210
|
+
L.onError(e instanceof Error ? e : Error(String(e)));
|
|
202
211
|
}
|
|
203
212
|
})();
|
|
204
213
|
}, [
|
|
@@ -217,34 +226,38 @@ var te = 2e4, ne = (e, t, n) => e instanceof i ? n : e instanceof r ? t : e inst
|
|
|
217
226
|
k,
|
|
218
227
|
A,
|
|
219
228
|
F
|
|
220
|
-
]),
|
|
229
|
+
]), ae = h((e, t) => {
|
|
221
230
|
let n = s(e), r = U.current.get(n);
|
|
222
231
|
return r ? l(t, r) : t;
|
|
223
|
-
}, []),
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
232
|
+
}, []), oe = h(() => {
|
|
233
|
+
if (!r) return;
|
|
234
|
+
let e = s(r), t = (V.current === e ? B.current : null) ?? x(S.current);
|
|
235
|
+
if (!t) return;
|
|
236
|
+
W.current.add(t), F.flush(e), D?.notifyStopGenerating?.();
|
|
237
|
+
let n = U.current.get(e)?.message.content;
|
|
238
|
+
C.stopCompletion({
|
|
239
|
+
generationId: t,
|
|
240
|
+
path: e,
|
|
241
|
+
content: n
|
|
230
242
|
}).catch((e) => {
|
|
231
243
|
let t = e instanceof Error ? e : Error(String(e));
|
|
232
244
|
O?.(t);
|
|
233
|
-
})
|
|
245
|
+
});
|
|
234
246
|
}, [
|
|
235
247
|
r,
|
|
248
|
+
S,
|
|
236
249
|
F,
|
|
237
250
|
O,
|
|
238
251
|
D,
|
|
239
252
|
C
|
|
240
|
-
]),
|
|
253
|
+
]), se = h((e, t) => X(e, t), [X]), Q = r != null && I.has(s(r)), $ = r == null ? null : s(r);
|
|
241
254
|
return {
|
|
242
255
|
startStream: Z,
|
|
243
|
-
handleStop:
|
|
244
|
-
resumeIfAwaitingGeneration:
|
|
245
|
-
restoreBufferedGeneration:
|
|
246
|
-
isStreaming:
|
|
247
|
-
canStopStreaming: $ != null && R === $
|
|
256
|
+
handleStop: oe,
|
|
257
|
+
resumeIfAwaitingGeneration: se,
|
|
258
|
+
restoreBufferedGeneration: ae,
|
|
259
|
+
isStreaming: Q,
|
|
260
|
+
canStopStreaming: $ != null && (R === $ || Q && x(S.current) != null)
|
|
248
261
|
};
|
|
249
262
|
};
|
|
250
263
|
//#endregion
|
package/conversation.d.ts
CHANGED
|
@@ -215,6 +215,7 @@ export declare interface ChatStreamApi {
|
|
|
215
215
|
stopCompletion: (dto: {
|
|
216
216
|
generationId: string;
|
|
217
217
|
path: string;
|
|
218
|
+
content?: string;
|
|
218
219
|
}) => Promise<void>;
|
|
219
220
|
}
|
|
220
221
|
|
|
@@ -307,10 +308,14 @@ export declare type ConversationStreamStarter = (conversationPath: string, userC
|
|
|
307
308
|
export declare interface ConversationStreamTransport {
|
|
308
309
|
/** Starts a completion; delivers chunks/completion/error through `options`, aborted via `options.signal`. */
|
|
309
310
|
streamCompletion(path: string, message: string | undefined, model: string, options: StreamCompletionOptions, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, messageIndex?: number, clientChannelId?: string): void;
|
|
310
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Requests the backend stop an active generation. `content` is the answer text shown
|
|
313
|
+
* so far; the backend saves it for a generation whose text it does not hold.
|
|
314
|
+
*/
|
|
311
315
|
stopCompletion(params: {
|
|
312
316
|
generationId: string;
|
|
313
317
|
path: string;
|
|
318
|
+
content?: string;
|
|
314
319
|
}): Promise<void>;
|
|
315
320
|
/** Opens a stream of resource-update events for `path`, until aborted via `signal`. */
|
|
316
321
|
watchConversation(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -596,11 +601,12 @@ export declare const hasStructuredAnnouncement: ({ title, description, }: Announ
|
|
|
596
601
|
export declare const isAnswerIncomplete: (answer: Message | undefined) => boolean;
|
|
597
602
|
|
|
598
603
|
/**
|
|
599
|
-
* True when the conversation
|
|
600
|
-
* placeholder: the backend only persists a
|
|
601
|
-
* (empty placeholder) and at generation end
|
|
602
|
-
* flagged `streamErrorMessage`/`wasStoppedByUser`).
|
|
603
|
-
* is still active elsewhere, or that its terminal save
|
|
604
|
+
* True when the conversation has a pending background message, or its last
|
|
605
|
+
* message is an unresolved assistant placeholder: the backend only persists a
|
|
606
|
+
* conversation at generation start (empty placeholder) and at generation end
|
|
607
|
+
* (final content, or a partial flagged `streamErrorMessage`/`wasStoppedByUser`).
|
|
608
|
+
* This can mean generation is still active elsewhere, or that its terminal save
|
|
609
|
+
* failed.
|
|
604
610
|
*/
|
|
605
611
|
export declare const isAwaitingGenerationResume: (conversation: Conversation) => boolean;
|
|
606
612
|
|
package/file-manager-canvas.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare interface AttachmentCanvasUrlResolvers {
|
|
|
40
40
|
resolveDialUrl: (attachment: DisplayAttachment) => string | undefined;
|
|
41
41
|
/** Resolves a DIAL Core file id to a fetchable metadata URL (used for cache-freshness validation). */
|
|
42
42
|
resolveDialFileMetadataUrl: (fileId: string) => string | undefined;
|
|
43
|
+
/** URL of a host-served bootstrap document that renders HTML with no download URL (inline `data`) under its own response CSP instead of the embedding page's — forwarded as `HtmlCanvasContent.srcdocHostUrl`. When omitted, that HTML renders via plain `srcdoc`. */
|
|
44
|
+
htmlSrcdocHostUrl?: string;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/** The type of content the canvas can display. */
|
|
@@ -138,6 +140,8 @@ declare interface HtmlCanvasContent {
|
|
|
138
140
|
isSameOriginUrl?: boolean;
|
|
139
141
|
/** Lazily fetches the full HTML source text for the "View source" toggle. Used instead of an eagerly-populated `srcdoc` when `url` is set; absent when `srcdoc` is already populated. */
|
|
140
142
|
resolveSourceText?: () => Promise<string>;
|
|
143
|
+
/** Host-served bootstrap document used to render `srcdoc` without inheriting the embedding page's CSP. When set alongside `srcdoc`, the iframe loads this URL via `src` (still `sandbox="allow-scripts"`) and posts `{ type: HTML_PREVIEW_FRAME_RENDER_MESSAGE, html: srcdoc }` to it once loaded, so the HTML renders under that response's own policy. Ignored when `srcdoc` is absent or `isSameOriginUrl` selects `url`. */
|
|
144
|
+
srcdocHostUrl?: string;
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
/** Content payload for image attachments. */
|
|
@@ -343,8 +347,10 @@ export declare const resolveGroupedVisualizerCanvasContent: (attachments: Displa
|
|
|
343
347
|
* front; `resolveSourceText` fetches it lazily, only when the "View source"
|
|
344
348
|
* toggle is used, and rejects if that fetch fails. `isSameOriginUrl` reflects
|
|
345
349
|
* a real comparison against the embedding document's own origin.
|
|
346
|
-
* With no download URL (local file or inline data), falls back to `srcdoc
|
|
347
|
-
*
|
|
350
|
+
* With no download URL (local file or inline data), falls back to `srcdoc`,
|
|
351
|
+
* rejecting payloads larger than 1 MiB to prevent browser truncation, and
|
|
352
|
+
* forwards `resolvers.htmlSrcdocHostUrl` so that HTML can still render under
|
|
353
|
+
* its own response-level CSP.
|
|
348
354
|
* Returns `null` if no source is available, or an `ErrorCanvasContent` when
|
|
349
355
|
* that fallback fetch fails.
|
|
350
356
|
*/
|
|
@@ -145,7 +145,8 @@ var g = (e, t) => URL.createObjectURL(s(e, t)), _ = (e) => {
|
|
|
145
145
|
let i = await k(e, n);
|
|
146
146
|
return i == null ? null : typeof i == "string" ? i.length > P ? null : {
|
|
147
147
|
type: t.Html,
|
|
148
|
-
srcdoc: i
|
|
148
|
+
srcdoc: i,
|
|
149
|
+
srcdocHostUrl: n.htmlSrcdocHostUrl
|
|
149
150
|
} : i;
|
|
150
151
|
}, R = (e, t) => ({
|
|
151
152
|
id: e,
|
package/index.d.ts
CHANGED
|
@@ -359,6 +359,8 @@ export declare interface AttachmentCanvasUrlResolvers {
|
|
|
359
359
|
resolveDialUrl: (attachment: DisplayAttachment) => string | undefined;
|
|
360
360
|
/** Resolves a DIAL Core file id to a fetchable metadata URL (used for cache-freshness validation). */
|
|
361
361
|
resolveDialFileMetadataUrl: (fileId: string) => string | undefined;
|
|
362
|
+
/** URL of a host-served bootstrap document that renders HTML with no download URL (inline `data`) under its own response CSP instead of the embedding page's — forwarded as `HtmlCanvasContent.srcdocHostUrl`. When omitted, that HTML renders via plain `srcdoc`. */
|
|
363
|
+
htmlSrcdocHostUrl?: string;
|
|
362
364
|
}
|
|
363
365
|
|
|
364
366
|
/** The type of content the canvas can display. */
|
|
@@ -641,7 +643,6 @@ export declare interface CatalogDetailsApi extends SkillDetailsApi {
|
|
|
641
643
|
|
|
642
644
|
/** Localized copy `useCatalogEditNavigation` needs for the Create menu and delete errors. */
|
|
643
645
|
export declare interface CatalogEditNavigationLabels {
|
|
644
|
-
createQuickApp: string;
|
|
645
646
|
createToolset: string;
|
|
646
647
|
createCustomApp: string;
|
|
647
648
|
createSkill: string;
|
|
@@ -780,6 +781,7 @@ export declare interface ChatStreamApi {
|
|
|
780
781
|
stopCompletion: (dto: {
|
|
781
782
|
generationId: string;
|
|
782
783
|
path: string;
|
|
784
|
+
content?: string;
|
|
783
785
|
}) => Promise<void>;
|
|
784
786
|
}
|
|
785
787
|
|
|
@@ -935,10 +937,14 @@ export declare type ConversationStreamStarter = (conversationPath: string, userC
|
|
|
935
937
|
export declare interface ConversationStreamTransport {
|
|
936
938
|
/** Starts a completion; delivers chunks/completion/error through `options`, aborted via `options.signal`. */
|
|
937
939
|
streamCompletion(path: string, message: string | undefined, model: string, options: StreamCompletionOptions, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, messageIndex?: number, clientChannelId?: string): void;
|
|
938
|
-
/**
|
|
940
|
+
/**
|
|
941
|
+
* Requests the backend stop an active generation. `content` is the answer text shown
|
|
942
|
+
* so far; the backend saves it for a generation whose text it does not hold.
|
|
943
|
+
*/
|
|
939
944
|
stopCompletion(params: {
|
|
940
945
|
generationId: string;
|
|
941
946
|
path: string;
|
|
947
|
+
content?: string;
|
|
942
948
|
}): Promise<void>;
|
|
943
949
|
/** Opens a stream of resource-update events for `path`, until aborted via `signal`. */
|
|
944
950
|
watchConversation(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -2102,6 +2108,8 @@ declare interface HtmlCanvasContent {
|
|
|
2102
2108
|
isSameOriginUrl?: boolean;
|
|
2103
2109
|
/** Lazily fetches the full HTML source text for the "View source" toggle. Used instead of an eagerly-populated `srcdoc` when `url` is set; absent when `srcdoc` is already populated. */
|
|
2104
2110
|
resolveSourceText?: () => Promise<string>;
|
|
2111
|
+
/** Host-served bootstrap document used to render `srcdoc` without inheriting the embedding page's CSP. When set alongside `srcdoc`, the iframe loads this URL via `src` (still `sandbox="allow-scripts"`) and posts `{ type: HTML_PREVIEW_FRAME_RENDER_MESSAGE, html: srcdoc }` to it once loaded, so the HTML renders under that response's own policy. Ignored when `srcdoc` is absent or `isSameOriginUrl` selects `url`. */
|
|
2112
|
+
srcdocHostUrl?: string;
|
|
2105
2113
|
}
|
|
2106
2114
|
|
|
2107
2115
|
/** Content payload for image attachments. */
|
|
@@ -2135,11 +2143,12 @@ export declare const initiateOAuthLogin: (auth: ToolsetOAuthSettings, toolsetId:
|
|
|
2135
2143
|
export declare const isAnswerIncomplete: (answer: Message | undefined) => boolean;
|
|
2136
2144
|
|
|
2137
2145
|
/**
|
|
2138
|
-
* True when the conversation
|
|
2139
|
-
* placeholder: the backend only persists a
|
|
2140
|
-
* (empty placeholder) and at generation end
|
|
2141
|
-
* flagged `streamErrorMessage`/`wasStoppedByUser`).
|
|
2142
|
-
* is still active elsewhere, or that its terminal save
|
|
2146
|
+
* True when the conversation has a pending background message, or its last
|
|
2147
|
+
* message is an unresolved assistant placeholder: the backend only persists a
|
|
2148
|
+
* conversation at generation start (empty placeholder) and at generation end
|
|
2149
|
+
* (final content, or a partial flagged `streamErrorMessage`/`wasStoppedByUser`).
|
|
2150
|
+
* This can mean generation is still active elsewhere, or that its terminal save
|
|
2151
|
+
* failed.
|
|
2143
2152
|
*/
|
|
2144
2153
|
export declare const isAwaitingGenerationResume: (conversation: Conversation) => boolean;
|
|
2145
2154
|
|
|
@@ -3447,8 +3456,10 @@ export declare const resolveGroupedVisualizerCanvasContent: (attachments: Displa
|
|
|
3447
3456
|
* front; `resolveSourceText` fetches it lazily, only when the "View source"
|
|
3448
3457
|
* toggle is used, and rejects if that fetch fails. `isSameOriginUrl` reflects
|
|
3449
3458
|
* a real comparison against the embedding document's own origin.
|
|
3450
|
-
* With no download URL (local file or inline data), falls back to `srcdoc
|
|
3451
|
-
*
|
|
3459
|
+
* With no download URL (local file or inline data), falls back to `srcdoc`,
|
|
3460
|
+
* rejecting payloads larger than 1 MiB to prevent browser truncation, and
|
|
3461
|
+
* forwards `resolvers.htmlSrcdocHostUrl` so that HTML can still render under
|
|
3462
|
+
* its own response-level CSP.
|
|
3452
3463
|
* Returns `null` if no source is available, or an `ErrorCanvasContent` when
|
|
3453
3464
|
* that fallback fetch fails.
|
|
3454
3465
|
*/
|
|
@@ -4790,7 +4801,7 @@ export declare interface UseCatalogEditNavigationParams {
|
|
|
4790
4801
|
export declare interface UseCatalogEditNavigationResult {
|
|
4791
4802
|
handleEdit: (item: CatalogItem) => void;
|
|
4792
4803
|
handleDelete: (item: CatalogItem) => Promise<void>;
|
|
4793
|
-
/** The Create dropdown's items: runners
|
|
4804
|
+
/** The Create dropdown's items: runners and static options sorted together by label, all filtered by `createSearch.value`. */
|
|
4794
4805
|
createOptions: DropdownItem[];
|
|
4795
4806
|
/** The Create menu's search field state, or `undefined` when no runner option is offered. */
|
|
4796
4807
|
createSearch: CatalogCreateSearch | undefined;
|
|
@@ -6151,9 +6162,9 @@ export declare interface UsePublishFoldersResult {
|
|
|
6151
6162
|
*/
|
|
6152
6163
|
onCreatePublishFolder: (parentPath: string[], name: string) => Promise<void>;
|
|
6153
6164
|
/**
|
|
6154
|
-
* Records `folderPath` as
|
|
6155
|
-
* so it keeps appearing in the tree on
|
|
6156
|
-
* successful publish.
|
|
6165
|
+
* Records `folderPath` as the most recent publish destination (moving it to
|
|
6166
|
+
* the front if already remembered), so it keeps appearing in the tree on
|
|
6167
|
+
* later publishes. Call it after a successful publish.
|
|
6157
6168
|
*/
|
|
6158
6169
|
rememberPublishFolder: (folderPath: string[]) => void;
|
|
6159
6170
|
/** Heuristic write-access check for a folder path (see the TODO above). */
|
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.2.0-dev.
|
|
4
|
+
"version": "1.2.0-dev.256",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.js",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@epam/ai-dial-chat-api-client": "1.2.0-dev.
|
|
114
|
+
"@epam/ai-dial-chat-api-client": "1.2.0-dev.256",
|
|
115
115
|
"dompurify": "3.4.16",
|
|
116
116
|
"fflate": "^0.8.3",
|
|
117
117
|
"lru-cache": "^10.4.3",
|
|
@@ -120,21 +120,21 @@
|
|
|
120
120
|
},
|
|
121
121
|
"peerDependencies": {
|
|
122
122
|
"react": "^19.2.8",
|
|
123
|
-
"@epam/ai-dial-attachment-canvas": "1.2.0-dev.
|
|
124
|
-
"@epam/ai-dial-attachment-input": "1.2.0-dev.
|
|
125
|
-
"@epam/ai-dial-catalog": "1.2.0-dev.
|
|
126
|
-
"@epam/ai-dial-chat-overlay": "1.2.0-dev.
|
|
127
|
-
"@epam/ai-dial-chat-shared": "1.2.0-dev.
|
|
128
|
-
"@epam/ai-dial-mcp-apps": "1.2.0-dev.
|
|
129
|
-
"@epam/ai-dial-publish-panel": "1.2.0-dev.
|
|
130
|
-
"@epam/ai-dial-quotations": "1.2.0-dev.
|
|
131
|
-
"@epam/ai-dial-react-file-manager": "^0.3.0-dev.
|
|
132
|
-
"@epam/ai-dial-scheduled-tasks": "1.2.0-dev.
|
|
133
|
-
"@epam/ai-dial-share": "1.2.0-dev.
|
|
134
|
-
"@epam/ai-dial-skill-editor": "1.2.0-dev.
|
|
135
|
-
"@epam/ai-dial-source-panel": "1.2.0-dev.
|
|
136
|
-
"@epam/ai-dial-ui-kit": "^0.15.0-dev.
|
|
137
|
-
"@epam/ai-dial-usage-dashboard": "1.2.0-dev.
|
|
123
|
+
"@epam/ai-dial-attachment-canvas": "1.2.0-dev.256",
|
|
124
|
+
"@epam/ai-dial-attachment-input": "1.2.0-dev.256",
|
|
125
|
+
"@epam/ai-dial-catalog": "1.2.0-dev.256",
|
|
126
|
+
"@epam/ai-dial-chat-overlay": "1.2.0-dev.256",
|
|
127
|
+
"@epam/ai-dial-chat-shared": "1.2.0-dev.256",
|
|
128
|
+
"@epam/ai-dial-mcp-apps": "1.2.0-dev.256",
|
|
129
|
+
"@epam/ai-dial-publish-panel": "1.2.0-dev.256",
|
|
130
|
+
"@epam/ai-dial-quotations": "1.2.0-dev.256",
|
|
131
|
+
"@epam/ai-dial-react-file-manager": "^0.3.0-dev.22",
|
|
132
|
+
"@epam/ai-dial-scheduled-tasks": "1.2.0-dev.256",
|
|
133
|
+
"@epam/ai-dial-share": "1.2.0-dev.256",
|
|
134
|
+
"@epam/ai-dial-skill-editor": "1.2.0-dev.256",
|
|
135
|
+
"@epam/ai-dial-source-panel": "1.2.0-dev.256",
|
|
136
|
+
"@epam/ai-dial-ui-kit": "^0.15.0-dev.36",
|
|
137
|
+
"@epam/ai-dial-usage-dashboard": "1.2.0-dev.256",
|
|
138
138
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
139
139
|
"@epam/pdf-highlighter-kit": "^0.0.19",
|
|
140
140
|
"@mcp-ui/client": "^7.1.1"
|