@epam/ai-dial-chat-hooks 1.2.5 → 1.3.0-dev.102
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/catalog-derivations.d.ts +1 -1
- package/catalog/catalog-derivations.d.ts.map +1 -1
- package/catalog/catalog-derivations.js +1 -1
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.d.ts +8 -1
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.d.ts.map +1 -1
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +57 -38
- package/conversation/conversation-draft/conversation-draft-store.d.ts +21 -0
- package/conversation/conversation-draft/conversation-draft-store.d.ts.map +1 -0
- package/conversation/conversation-draft/conversation-draft-store.js +84 -0
- package/conversation/conversation-draft/conversation-draft.d.ts +48 -0
- package/conversation/conversation-draft/conversation-draft.d.ts.map +1 -0
- package/conversation/create-chat-stream-api.d.ts +6 -0
- package/conversation/create-chat-stream-api.d.ts.map +1 -1
- package/conversation/create-chat-stream-api.js +28 -23
- package/conversation/useConversationComposerDraft/useConversationComposerDraft.d.ts +39 -0
- package/conversation/useConversationComposerDraft/useConversationComposerDraft.d.ts.map +1 -0
- package/conversation/useConversationComposerDraft/useConversationComposerDraft.js +132 -0
- package/conversation/useConversationStream/useConversationStream.d.ts.map +1 -1
- package/conversation/useConversationStream/useConversationStream.js +233 -219
- package/conversation.js +34 -32
- package/entry-points/conversation.d.ts +3 -0
- package/entry-points/conversation.d.ts.map +1 -1
- package/entry-points/offline-credentials.d.ts +5 -0
- package/entry-points/offline-credentials.d.ts.map +1 -0
- package/entry-points/scheduled-tasks.d.ts +1 -0
- package/entry-points/scheduled-tasks.d.ts.map +1 -1
- package/file-manager.js +21 -21
- package/files/dial-file-manager-mapping.util.d.ts +17 -1
- package/files/dial-file-manager-mapping.util.d.ts.map +1 -1
- package/files/dial-file-manager-mapping.util.js +77 -62
- package/files/useDialFileListing/useDialFileListing.d.ts.map +1 -1
- package/files/useDialFileListing/useDialFileListing.js +56 -53
- package/files/useDialFileMutations/useDialFileMutations.d.ts.map +1 -1
- package/files/useDialFileMutations/useDialFileMutations.js +206 -204
- package/index.d.ts +8 -0
- package/index.d.ts.map +1 -1
- package/index.js +131 -124
- package/mcp-apps/mcp-apps-api-client.d.ts.map +1 -1
- package/mcp-apps/mcp-apps-api-client.js +18 -17
- package/mcp-apps/useMcpAppTools/useMcpAppTools.d.ts.map +1 -1
- package/mcp-apps/useMcpAppTools/useMcpAppTools.js +29 -29
- package/oauth/popup.d.ts.map +1 -1
- package/oauth/popup.js +19 -17
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.d.ts.map +1 -1
- package/oauth/useOAuthCallbackCompletion/useOAuthCallbackCompletion.js +40 -38
- package/offline-credentials/map-offline-credentials-response.d.ts +17 -0
- package/offline-credentials/map-offline-credentials-response.d.ts.map +1 -0
- package/offline-credentials/map-offline-credentials-response.js +15 -0
- package/offline-credentials/useOfflineCredentialsAuth/useOfflineCredentialsAuth.d.ts +58 -0
- package/offline-credentials/useOfflineCredentialsAuth/useOfflineCredentialsAuth.d.ts.map +1 -0
- package/offline-credentials/useOfflineCredentialsAuth/useOfflineCredentialsAuth.js +37 -0
- package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.d.ts +57 -0
- package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.d.ts.map +1 -0
- package/offline-credentials/useOfflineCredentialsGate/useOfflineCredentialsGate.js +34 -0
- package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.d.ts +28 -0
- package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.d.ts.map +1 -0
- package/offline-credentials/useOfflineCredentialsLogin/useOfflineCredentialsLogin.js +29 -0
- package/offline-credentials.d.ts +2 -0
- package/offline-credentials.js +5 -0
- package/package.json +23 -18
- package/scheduled-task/check-scheduled-task-auth-session-error.d.ts +27 -0
- package/scheduled-task/check-scheduled-task-auth-session-error.d.ts.map +1 -0
- package/scheduled-task/check-scheduled-task-auth-session-error.js +17 -0
- package/scheduled-tasks.js +2 -1
- package/shared/application-schema.d.ts +0 -2
- package/shared/application-schema.d.ts.map +1 -1
- package/shared/application-schema.js +2 -2
- package/useShareLink/useShareLink.d.ts.map +1 -1
- package/useShareLink/useShareLink.js +1 -0
- package/utils.js +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CatalogItem } from '@epam/ai-dial-catalog';
|
|
2
2
|
import { CatalogEntityType } from '@epam/ai-dial-chat-shared';
|
|
3
3
|
/**
|
|
4
|
-
* Filters catalog items to those whose type is in `visibleTypes`.
|
|
4
|
+
* Filters catalog items to those whose type is in `visibleTypes` and whose `supportsChat` is not `false`.
|
|
5
5
|
* Call only when selector mode is active; otherwise pass through the original array.
|
|
6
6
|
*/
|
|
7
7
|
export declare const filterCatalogItemsBySelector: (items: readonly CatalogItem[], visibleTypes: ReadonlySet<CatalogEntityType>) => CatalogItem[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-derivations.d.ts","sourceRoot":"","sources":["../../src/catalog/catalog-derivations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,SAAS,WAAW,EAAE,EAC7B,cAAc,WAAW,CAAC,iBAAiB,CAAC,KAC3C,WAAW,
|
|
1
|
+
{"version":3,"file":"catalog-derivations.d.ts","sourceRoot":"","sources":["../../src/catalog/catalog-derivations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,OAAO,SAAS,WAAW,EAAE,EAC7B,cAAc,WAAW,CAAC,iBAAiB,CAAC,KAC3C,WAAW,EAGX,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,SAAS,WAAW,EAAE,EAC7B,WAAW,OAAO,KACjB,WAAW,EACkD,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,SAAS,WAAW,EAAE,KAC5B,WAAW,EACiD,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,iBAAiB,EAC/D,OAAO,SAAS,WAAW,EAAE,EAC7B,UAAU,SAAS,CAAC,EAAE,KACrB,CAAC,EAGH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,iBAAiB,WAAW,CAAC,MAAM,CAAC,EACpC,OAAO,SAAS,WAAW,EAAE,KAC5B,GAAG,CAAC,MAAM,CAKZ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/catalog/catalog-derivations.ts
|
|
2
|
-
var e = (e, t) => e.filter((e) => t.has(e.type)), t = (e, t) => t ? e.filter((e) => !e.isMyApp) : [...e], n = (e) => e.filter((e) => e.isUserFavorite && !e.isHidden), r = (e, t) => {
|
|
2
|
+
var e = (e, t) => e.filter((e) => t.has(e.type) && e.supportsChat !== !1), t = (e, t) => t ? e.filter((e) => !e.isMyApp) : [...e], n = (e) => e.filter((e) => e.isUserFavorite && !e.isHidden), r = (e, t) => {
|
|
3
3
|
let n = new Set(e.map((e) => e.type));
|
|
4
4
|
return t.filter((e) => n.has(e));
|
|
5
5
|
}, i = (e, t) => {
|
|
@@ -15,6 +15,8 @@ export interface CatalogEditNavigationLabels {
|
|
|
15
15
|
createSkillWriteInstructions: string;
|
|
16
16
|
createSkillUpload: string;
|
|
17
17
|
createPrompt: string;
|
|
18
|
+
/** Header of the Create menu's runner section (Custom App and the runner schemas). */
|
|
19
|
+
createRunners: string;
|
|
18
20
|
deleteError: string;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
@@ -83,7 +85,12 @@ export interface UseCatalogEditNavigationParams {
|
|
|
83
85
|
export interface UseCatalogEditNavigationResult {
|
|
84
86
|
handleEdit: (item: CatalogItem) => void;
|
|
85
87
|
handleDelete: (item: CatalogItem) => Promise<void>;
|
|
86
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The Create dropdown's items, all filtered by `createSearch.value`: Toolset,
|
|
90
|
+
* Skill and Prompt sorted by label, then a divider and a runner-section header,
|
|
91
|
+
* then Custom App and the runners sorted by label. The divider and header are
|
|
92
|
+
* present only while both sections hold an option.
|
|
93
|
+
*/
|
|
87
94
|
createOptions: DropdownItem[];
|
|
88
95
|
/** The Create menu's search field state, or `undefined` when no runner option is offered. */
|
|
89
96
|
createSearch: CatalogCreateSearch | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCatalogEditNavigation.d.ts","sourceRoot":"","sources":["../../../src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"useCatalogEditNavigation.d.ts","sourceRoot":"","sources":["../../../src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO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AED,wDAAwD;AACxD,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD;;;;;OAKG;IACH,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,6FAA6F;IAC7F,YAAY,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAC9C,uGAAuG;IACvG,gBAAgB,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAC,CAAC;CAC5E;AAED;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,oVAsBtC,8BAA8B,KAAG,8BAmQnC,CAAC"}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { getApiErrorDetails as e } from "../../api-error/api-error.js";
|
|
2
2
|
import { findDeploymentByIdOrReference as t } from "../deployment-id.js";
|
|
3
3
|
import { parseSkillResourceUrl as n } from "../../skill/skill-types.js";
|
|
4
|
-
import { getRunnerSchemas as r,
|
|
5
|
-
import { CatalogEntityType as
|
|
6
|
-
import { useCallback as
|
|
4
|
+
import { getRunnerSchemas as r, isQuickAppSchema as i } from "../../shared/application-schema.js";
|
|
5
|
+
import { CatalogEntityType as a } from "@epam/ai-dial-chat-shared";
|
|
6
|
+
import { useCallback as o, useMemo as s, useState as c } from "react";
|
|
7
|
+
import { DropdownItemType as l } from "@epam/ai-dial-ui-kit";
|
|
7
8
|
//#region src/catalog/useCatalogEditNavigation/useCatalogEditNavigation.ts
|
|
8
9
|
var u = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(t.label ?? ""), void 0, { sensitivity: "base" })), d = ({ deployments: d, isCustomAppsEnabled: f, isSchemaAppsEnabled: p, isHideCustomAppCreationEnabled: m, isToolsetsEnabled: h, isPromptsEnabled: g, schemas: _, urls: v, onNavigate: y, deletePrompt: b, deleteToolset: x, deleteSkill: S, deleteApplication: C, refetchPrompts: w, refetchToolsets: T, refetchSkills: E, refetchDeployments: D, onDeleteSuccess: O, labels: k, onNotify: A, onSkillUploadClick: j }) => {
|
|
9
|
-
let M =
|
|
10
|
-
if (e.type ===
|
|
10
|
+
let M = s(() => r(_), [_]), [N, P] = c(""), F = p && !m, I = o((e) => {
|
|
11
|
+
if (e.type === a.Prompt) {
|
|
11
12
|
y(v.buildPromptEditUrl(e.id));
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
|
-
if (e.type ===
|
|
15
|
+
if (e.type === a.Skill) {
|
|
15
16
|
y(v.buildSkillEditUrl(e.id));
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
|
-
if (e.type ===
|
|
19
|
+
if (e.type === a.Toolset) {
|
|
19
20
|
y(v.buildToolsetEditUrl(e.id));
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
@@ -24,7 +25,7 @@ var u = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(
|
|
|
24
25
|
y(v.buildCustomAppEditUrl(e.id));
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
let r = M.find((e) => e.id === n?.applicationTypeSchemaId)?.id ?? M.find((e) =>
|
|
28
|
+
let r = M.find((e) => e.id === n?.applicationTypeSchemaId)?.id ?? M.find((e) => i(e))?.id;
|
|
28
29
|
r && y(v.buildQuickAppEditUrl(r, e.id));
|
|
29
30
|
}, [
|
|
30
31
|
d,
|
|
@@ -32,11 +33,11 @@ var u = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(
|
|
|
32
33
|
M,
|
|
33
34
|
y,
|
|
34
35
|
v
|
|
35
|
-
]),
|
|
36
|
+
]), L = o(async (t) => {
|
|
36
37
|
try {
|
|
37
|
-
if (t.type ===
|
|
38
|
-
else if (t.type ===
|
|
39
|
-
else if (t.type ===
|
|
38
|
+
if (t.type === a.Prompt) await b(t.id), await w();
|
|
39
|
+
else if (t.type === a.Toolset) await x(t.id), await T();
|
|
40
|
+
else if (t.type === a.Skill) {
|
|
40
41
|
let e = n(t.id);
|
|
41
42
|
if (e == null) throw Error(`Invalid skill resource url: ${t.id}`);
|
|
42
43
|
await S(e.bucket, e.path), await E();
|
|
@@ -61,8 +62,8 @@ var u = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(
|
|
|
61
62
|
O,
|
|
62
63
|
k,
|
|
63
64
|
A
|
|
64
|
-
]),
|
|
65
|
-
let e =
|
|
65
|
+
]), R = s(() => {
|
|
66
|
+
let e = N.trim().toLocaleLowerCase(), t = (t) => !e || t.toLocaleLowerCase().includes(e), n = F ? M.map((e) => ({
|
|
66
67
|
id: e.id,
|
|
67
68
|
label: e.displayName || e.id
|
|
68
69
|
})).filter((e) => t(e.label)).map((e) => ({
|
|
@@ -98,9 +99,9 @@ var u = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(
|
|
|
98
99
|
} : void 0
|
|
99
100
|
};
|
|
100
101
|
}, [
|
|
101
|
-
P,
|
|
102
|
-
I,
|
|
103
102
|
N,
|
|
103
|
+
F,
|
|
104
|
+
M,
|
|
104
105
|
y,
|
|
105
106
|
v,
|
|
106
107
|
g,
|
|
@@ -109,38 +110,56 @@ var u = (e) => [...e].sort((e, t) => String(e.label ?? "").localeCompare(String(
|
|
|
109
110
|
h,
|
|
110
111
|
f,
|
|
111
112
|
j
|
|
112
|
-
]),
|
|
113
|
-
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } =
|
|
114
|
-
|
|
113
|
+
]), z = s(() => {
|
|
114
|
+
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } = R, a = [];
|
|
115
|
+
t && a.push(t), r.length > 0 && a.push({
|
|
115
116
|
key: "skill",
|
|
116
117
|
label: k.createSkill,
|
|
117
118
|
children: r
|
|
118
|
-
}), i && a.push(i)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
}), i && a.push(i);
|
|
120
|
+
let o = u(n ? [n, ...e] : e), s = u(a);
|
|
121
|
+
return s.length === 0 || o.length === 0 ? [...s, ...o] : [
|
|
122
|
+
...s,
|
|
123
|
+
{
|
|
124
|
+
key: "create-sections-divider",
|
|
125
|
+
type: l.Divider
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: "runners-header",
|
|
129
|
+
type: l.PlainText,
|
|
130
|
+
label: k.createRunners
|
|
131
|
+
},
|
|
132
|
+
...o
|
|
133
|
+
];
|
|
134
|
+
}, [
|
|
135
|
+
R,
|
|
136
|
+
k.createSkill,
|
|
137
|
+
k.createRunners
|
|
138
|
+
]), B = s(() => F && M.length > 0 ? {
|
|
139
|
+
value: N,
|
|
140
|
+
onChange: P
|
|
122
141
|
} : void 0, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
F,
|
|
143
|
+
M.length,
|
|
144
|
+
N
|
|
126
145
|
]);
|
|
127
146
|
return {
|
|
128
|
-
handleEdit:
|
|
129
|
-
handleDelete:
|
|
130
|
-
createOptions:
|
|
131
|
-
createSearch:
|
|
132
|
-
createMenuByType:
|
|
133
|
-
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } =
|
|
147
|
+
handleEdit: I,
|
|
148
|
+
handleDelete: L,
|
|
149
|
+
createOptions: z,
|
|
150
|
+
createSearch: B,
|
|
151
|
+
createMenuByType: s(() => {
|
|
152
|
+
let { runnerOptions: e, toolsetOption: t, customAppOption: n, visibleSkillChildren: r, promptOption: i } = R;
|
|
134
153
|
return {
|
|
135
|
-
[
|
|
154
|
+
[a.Agent]: {
|
|
136
155
|
options: u(n ? [...e, n] : e),
|
|
137
|
-
search:
|
|
156
|
+
search: B
|
|
138
157
|
},
|
|
139
|
-
[
|
|
140
|
-
[
|
|
141
|
-
[
|
|
158
|
+
[a.Toolset]: { options: t ? [t] : [] },
|
|
159
|
+
[a.Skill]: { options: r },
|
|
160
|
+
[a.Prompt]: { options: i ? [i] : [] }
|
|
142
161
|
};
|
|
143
|
-
}, [
|
|
162
|
+
}, [R, B])
|
|
144
163
|
};
|
|
145
164
|
};
|
|
146
165
|
//#endregion
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConversationDraftStore, MemoryConversationDraftStoreOptions, WebStorageConversationDraftStoreOptions } from './conversation-draft';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a `ConversationDraftStore` over a host-chosen Web `Storage`.
|
|
4
|
+
*
|
|
5
|
+
* Every host-specific fact — which storage, which key (including any user
|
|
6
|
+
* scope), how ids are canonicalised — arrives through `options`. The store owns
|
|
7
|
+
* only the versioned JSON format of its own data
|
|
8
|
+
* (`{ version: 1, drafts: { [id]: ConversationDraft } }`), the `maxEntries`
|
|
9
|
+
* cap with oldest-first eviction, a half-eviction retry when the quota is
|
|
10
|
+
* exceeded, and silent failure: an absent or throwing storage behaves as an
|
|
11
|
+
* empty store that ignores writes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const createWebStorageConversationDraftStore: ({ getStorage, storageKey, maxEntries, normalizeId, }: WebStorageConversationDraftStoreOptions) => ConversationDraftStore;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a `ConversationDraftStore` that keeps drafts in memory for the
|
|
16
|
+
* lifetime of the returned instance. Same semantics as the Web Storage store
|
|
17
|
+
* (`maxEntries`, `normalizeId`, empty-draft removal); suited to hosts that want
|
|
18
|
+
* drafts only for the page lifetime, and to tests.
|
|
19
|
+
*/
|
|
20
|
+
export declare const createMemoryConversationDraftStore: ({ maxEntries, normalizeId, }?: MemoryConversationDraftStoreOptions) => ConversationDraftStore;
|
|
21
|
+
//# sourceMappingURL=conversation-draft-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-draft-store.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-draft/conversation-draft-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACtB,mCAAmC,EACnC,uCAAuC,EACxC,MAAM,sBAAsB,CAAC;AAqE9B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sCAAsC,GAAI,sDAKpD,uCAAuC,KAAG,sBA0E5C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kCAAkC,GAAI,+BAGhD,mCAAwC,KAAG,sBAwB7C,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/conversation/conversation-draft/conversation-draft-store.ts
|
|
2
|
+
var e = 50, t = 1, n = (e) => e, r = (e) => e.text.trim() === "" && e.skills.length === 0, i = (e) => {
|
|
3
|
+
if (typeof e != "object" || !e) return !1;
|
|
4
|
+
let t = e;
|
|
5
|
+
return typeof t.text == "string" && Array.isArray(t.skills) && typeof t.updatedAt == "number";
|
|
6
|
+
}, a = (e, t) => Object.hasOwn(e, t) ? e[t] : void 0, o = (e) => Object.keys(e).sort((t, n) => e[t].updatedAt - e[n].updatedAt), s = (e, t) => {
|
|
7
|
+
let n = o(e), r = n.length - Math.max(t, 0);
|
|
8
|
+
if (r <= 0) return e;
|
|
9
|
+
let i = { ...e };
|
|
10
|
+
return n.slice(0, r).forEach((e) => delete i[e]), i;
|
|
11
|
+
}, c = (e, t, n, i) => {
|
|
12
|
+
let a = { ...e };
|
|
13
|
+
return r(n) ? (delete a[t], a) : (a[t] = n, s(a, i));
|
|
14
|
+
}, l = (e) => e instanceof DOMException && (e.name === "QuotaExceededError" || e.name === "NS_ERROR_DOM_QUOTA_REACHED"), u = ({ getStorage: r, storageKey: u, maxEntries: d = e, normalizeId: f = n }) => {
|
|
15
|
+
let p = () => {
|
|
16
|
+
try {
|
|
17
|
+
return r();
|
|
18
|
+
} catch {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}, m = () => {
|
|
22
|
+
try {
|
|
23
|
+
let e = p()?.getItem(u);
|
|
24
|
+
if (!e) return {};
|
|
25
|
+
let n = JSON.parse(e);
|
|
26
|
+
return n == null || n.version !== t || n.drafts == null || typeof n.drafts != "object" ? {} : Object.fromEntries(Object.entries(n.drafts).filter(([, e]) => i(e)));
|
|
27
|
+
} catch {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
}, h = (e, n) => {
|
|
31
|
+
if (Object.keys(n).length === 0) {
|
|
32
|
+
e.removeItem(u);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let r = {
|
|
36
|
+
version: t,
|
|
37
|
+
drafts: n
|
|
38
|
+
};
|
|
39
|
+
e.setItem(u, JSON.stringify(r));
|
|
40
|
+
}, g = (e) => {
|
|
41
|
+
let t = p();
|
|
42
|
+
if (t) try {
|
|
43
|
+
h(t, e);
|
|
44
|
+
} catch (n) {
|
|
45
|
+
if (!l(n)) return;
|
|
46
|
+
try {
|
|
47
|
+
let n = o(e);
|
|
48
|
+
h(t, s(e, Math.floor(n.length / 2)));
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return {
|
|
53
|
+
read: (e) => a(m(), f(e)),
|
|
54
|
+
write: (e, t) => g(c(m(), f(e), t, d)),
|
|
55
|
+
remove: (e) => {
|
|
56
|
+
let t = m(), n = f(e);
|
|
57
|
+
Object.hasOwn(t, n) && (delete t[n], g(t));
|
|
58
|
+
},
|
|
59
|
+
clear: () => {
|
|
60
|
+
try {
|
|
61
|
+
p()?.removeItem(u);
|
|
62
|
+
} catch {}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}, d = ({ maxEntries: t = e, normalizeId: r = n } = {}) => {
|
|
66
|
+
let i = {};
|
|
67
|
+
return {
|
|
68
|
+
read: (e) => a(i, r(e)),
|
|
69
|
+
write: (e, n) => {
|
|
70
|
+
i = c(i, r(e), n, t);
|
|
71
|
+
},
|
|
72
|
+
remove: (e) => {
|
|
73
|
+
let t = r(e);
|
|
74
|
+
if (!Object.hasOwn(i, t)) return;
|
|
75
|
+
let n = { ...i };
|
|
76
|
+
delete n[t], i = n;
|
|
77
|
+
},
|
|
78
|
+
clear: () => {
|
|
79
|
+
i = {};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
export { d as createMemoryConversationDraftStore, u as createWebStorageConversationDraftStore };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
/** An unsent composer draft kept for one conversation. */
|
|
3
|
+
export interface ConversationDraft {
|
|
4
|
+
/** The composer text as the user left it. */
|
|
5
|
+
text: string;
|
|
6
|
+
/** Skills mentioned in the draft, in the same shape a sent message carries. */
|
|
7
|
+
skills: RequestSkill[];
|
|
8
|
+
/** Epoch milliseconds of the last change; the oldest entry is evicted first. */
|
|
9
|
+
updatedAt: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Synchronous, never-throwing persistence contract for conversation drafts.
|
|
13
|
+
*
|
|
14
|
+
* The host creates and owns the instance: it decides the storage medium, the
|
|
15
|
+
* key, the user scope and how conversation ids are canonicalised. A host with
|
|
16
|
+
* async persistence wraps it behind a synchronous in-memory cache, because the
|
|
17
|
+
* restore runs before the user can type and the flush on unmount must finish
|
|
18
|
+
* synchronously.
|
|
19
|
+
*/
|
|
20
|
+
export interface ConversationDraftStore {
|
|
21
|
+
/** Returns the stored draft for `conversationId`, or `undefined` when there is none. */
|
|
22
|
+
read: (conversationId: string) => ConversationDraft | undefined;
|
|
23
|
+
/** Stores `draft` for `conversationId`; an empty draft removes the entry instead. */
|
|
24
|
+
write: (conversationId: string, draft: ConversationDraft) => void;
|
|
25
|
+
/** Removes the draft for `conversationId`. */
|
|
26
|
+
remove: (conversationId: string) => void;
|
|
27
|
+
/** Removes every draft the store holds. */
|
|
28
|
+
clear: () => void;
|
|
29
|
+
}
|
|
30
|
+
/** Options shared by both store factories. */
|
|
31
|
+
export interface MemoryConversationDraftStoreOptions {
|
|
32
|
+
/** Maximum number of drafts kept; the oldest-`updatedAt` entry is evicted beyond it. Defaults to `50`. */
|
|
33
|
+
maxEntries?: number;
|
|
34
|
+
/** Canonicalises a conversation id before it is used as an entry key. Defaults to identity. */
|
|
35
|
+
normalizeId?: (conversationId: string) => string;
|
|
36
|
+
}
|
|
37
|
+
/** Options for `createWebStorageConversationDraftStore`. */
|
|
38
|
+
export interface WebStorageConversationDraftStoreOptions extends MemoryConversationDraftStoreOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Returns the `Storage` to use, or `undefined` when none is available. It is
|
|
41
|
+
* a getter so an absent or throwing storage accessor (SSR, tests, blocked
|
|
42
|
+
* site data) is handled inside the store's guard.
|
|
43
|
+
*/
|
|
44
|
+
getStorage: () => Storage | undefined;
|
|
45
|
+
/** The single key all drafts are written under, including any user scope the host needs. */
|
|
46
|
+
storageKey: string;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=conversation-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-draft.d.ts","sourceRoot":"","sources":["../../../src/conversation/conversation-draft/conversation-draft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,0DAA0D;AAC1D,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC,wFAAwF;IACxF,IAAI,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IAChE,qFAAqF;IACrF,KAAK,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAClE,8CAA8C;IAC9C,MAAM,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,2CAA2C;IAC3C,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,8CAA8C;AAC9C,MAAM,WAAW,mCAAmC;IAClD,0GAA0G;IAC1G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+FAA+F;IAC/F,WAAW,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD;AAED,4DAA4D;AAC5D,MAAM,WAAW,uCAAwC,SAAQ,mCAAmC;IAClG;;;;OAIG;IACH,UAAU,EAAE,MAAM,OAAO,GAAG,SAAS,CAAC;IACtC,4FAA4F;IAC5F,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -46,6 +46,12 @@ export declare class StreamUpstreamError extends Error {
|
|
|
46
46
|
export declare class StreamInterruptedError extends Error {
|
|
47
47
|
constructor(cause?: unknown);
|
|
48
48
|
}
|
|
49
|
+
/** Thrown when the Stop endpoint answers with a non-OK status. */
|
|
50
|
+
export declare class StopCompletionError extends Error {
|
|
51
|
+
/** HTTP status of the rejected Stop request. */
|
|
52
|
+
readonly status: number;
|
|
53
|
+
constructor(status: number);
|
|
54
|
+
}
|
|
49
55
|
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45000;
|
|
50
56
|
/** Callbacks {@link streamCompletion} reports streamed completion events through. */
|
|
51
57
|
export interface ChatStreamCompletionOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-chat-stream-api.d.ts","sourceRoot":"","sources":["../../src/conversation/create-chat-stream-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAOnC,mFAAmF;AACnF,eAAO,MAAM,4CAA4C,0IACgF,CAAC;AAE1I,yFAAyF;AACzF,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,QAAQ,CAAC,IAAI,8BA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,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,2BAA2B,EACpC,aAAa,CAAC,EAAE,oBAAoB,EACpC,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,yBAAyB,EAChC,YAAY,CAAC,EAAE,MAAM,EACrB,eAAe,CAAC,EAAE,MAAM,KACrB,IAAI,CAAC;IACV,cAAc,EAAE,CAAC,GAAG,EAAE;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,uBAAuB,KAC5B,aAoKF,CAAC"}
|
|
1
|
+
{"version":3,"file":"create-chat-stream-api.d.ts","sourceRoot":"","sources":["../../src/conversation/create-chat-stream-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAOnC,mFAAmF;AACnF,eAAO,MAAM,4CAA4C,0IACgF,CAAC;AAE1I,yFAAyF;AACzF,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,QAAQ,CAAC,IAAI,8BAA8B;IAElD,iFAAiF;IACjF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;gBACS,MAAM,CAAC,EAAE,MAAM;CAK5B;AAED,sFAAsF;AACtF,eAAO,MAAM,mCAAmC,iIACgF,CAAC;AAEjI;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,GAAE,MAA4C;CAIlE;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM;CAI5B;A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B,eAAe,CAAC,EAAE,MAAM,KACrB,IAAI,CAAC;IACV,cAAc,EAAE,CAAC,GAAG,EAAE;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,uBAAuB,KAC5B,aAoKF,CAAC"}
|
|
@@ -17,7 +17,12 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
17
17
|
constructor(e) {
|
|
18
18
|
super("The completion stream was interrupted", { cause: e }), this.name = "StreamInterruptedError";
|
|
19
19
|
}
|
|
20
|
-
}, c =
|
|
20
|
+
}, c = class extends Error {
|
|
21
|
+
status;
|
|
22
|
+
constructor(e) {
|
|
23
|
+
super(`stopCompletion failed: ${e}`), this.name = "StopCompletionError", this.status = e;
|
|
24
|
+
}
|
|
25
|
+
}, l = 45e3, u = (e, t) => {
|
|
21
26
|
let n = Date.now(), r, i = !1, a = () => {
|
|
22
27
|
if (i) return;
|
|
23
28
|
let o = Date.now() - n;
|
|
@@ -37,31 +42,31 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
37
42
|
i || (i = !0, clearTimeout(r), s && (document.removeEventListener("visibilitychange", o), window.removeEventListener("online", a), window.removeEventListener("pageshow", a)));
|
|
38
43
|
}
|
|
39
44
|
};
|
|
40
|
-
},
|
|
45
|
+
}, d = (e) => typeof e == "object" && !!e && e.name === "AbortError", f = (e) => {
|
|
41
46
|
let { status: t } = e;
|
|
42
47
|
return typeof t == "number" ? t : void 0;
|
|
43
|
-
},
|
|
48
|
+
}, p = (e, t, n) => {
|
|
44
49
|
let i = e.trim();
|
|
45
50
|
if (!i || i.startsWith(":") || !i.startsWith("data: ")) return;
|
|
46
51
|
let a = i.slice(6);
|
|
47
52
|
if (a !== "[DONE]") try {
|
|
48
53
|
let e = JSON.parse(a);
|
|
49
54
|
if (e.error) {
|
|
50
|
-
n(e.error.type === r.type ? new r(
|
|
55
|
+
n(e.error.type === r.type ? new r(f(e.error)) : new o(e.error.message));
|
|
51
56
|
return;
|
|
52
57
|
}
|
|
53
58
|
t(e);
|
|
54
59
|
} catch {}
|
|
55
|
-
},
|
|
60
|
+
}, m = (n) => {
|
|
56
61
|
let { completionsBasePath: r } = n, i = (...e) => (n.fetchImpl ?? fetch)(...e);
|
|
57
62
|
return {
|
|
58
|
-
streamCompletion: (o, c,
|
|
59
|
-
let { onChunk: y, onComplete: b, onError: x, signal: S } =
|
|
63
|
+
streamCompletion: (o, c, l, f, m, h, g, _, v) => {
|
|
64
|
+
let { onChunk: y, onComplete: b, onError: x, signal: S } = f;
|
|
60
65
|
(async () => {
|
|
61
|
-
let
|
|
66
|
+
let f;
|
|
62
67
|
try {
|
|
63
68
|
let t = n.getTimezone?.();
|
|
64
|
-
|
|
69
|
+
f = await i(`${r}/completions`, {
|
|
65
70
|
method: "POST",
|
|
66
71
|
credentials: "include",
|
|
67
72
|
signal: S,
|
|
@@ -73,7 +78,7 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
73
78
|
body: JSON.stringify({
|
|
74
79
|
path: o,
|
|
75
80
|
message: c ?? "",
|
|
76
|
-
model:
|
|
81
|
+
model: l,
|
|
77
82
|
custom_content: m || {},
|
|
78
83
|
...h != null && { generationId: h },
|
|
79
84
|
...g != null && { mode: g },
|
|
@@ -82,26 +87,26 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
82
87
|
})
|
|
83
88
|
});
|
|
84
89
|
} catch (e) {
|
|
85
|
-
if (
|
|
90
|
+
if (d(e)) return;
|
|
86
91
|
x(new s(e));
|
|
87
92
|
return;
|
|
88
93
|
}
|
|
89
|
-
let C =
|
|
90
|
-
if (C && n.setCsrfToken(C), !
|
|
91
|
-
if (
|
|
94
|
+
let C = f.headers.get("x-csrf-token");
|
|
95
|
+
if (C && n.setCsrfToken(C), !f.ok) {
|
|
96
|
+
if (f.status === t) {
|
|
92
97
|
x(new a());
|
|
93
98
|
return;
|
|
94
99
|
}
|
|
95
|
-
x(/* @__PURE__ */ Error(`Stream request failed with status ${
|
|
100
|
+
x(/* @__PURE__ */ Error(`Stream request failed with status ${f.status}`));
|
|
96
101
|
return;
|
|
97
102
|
}
|
|
98
|
-
if (!
|
|
103
|
+
if (!f.body) {
|
|
99
104
|
x(/* @__PURE__ */ Error("No response body"));
|
|
100
105
|
return;
|
|
101
106
|
}
|
|
102
|
-
let w =
|
|
107
|
+
let w = f.body.getReader(), T = new TextDecoder(), E = "", D = !1, O = !1, k = (e) => {
|
|
103
108
|
D || (D = !0, A.stop(), x(e));
|
|
104
|
-
}, A =
|
|
109
|
+
}, A = u(n.idleTimeoutMs ?? 45e3, () => {
|
|
105
110
|
O = !0, k(new s()), w.cancel().catch(() => void 0);
|
|
106
111
|
});
|
|
107
112
|
try {
|
|
@@ -109,17 +114,17 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
109
114
|
let { done: e, value: t } = await w.read();
|
|
110
115
|
if (O) break;
|
|
111
116
|
if (e) {
|
|
112
|
-
E.trim() &&
|
|
117
|
+
E.trim() && p(E, y, k);
|
|
113
118
|
break;
|
|
114
119
|
}
|
|
115
120
|
A.touch(), E += T.decode(t, { stream: !0 });
|
|
116
121
|
let n = E.split("\n");
|
|
117
122
|
E = n.pop() ?? "";
|
|
118
|
-
for (let e of n)
|
|
123
|
+
for (let e of n) p(e, y, k);
|
|
119
124
|
}
|
|
120
125
|
D || (D = !0, b());
|
|
121
126
|
} catch (e) {
|
|
122
|
-
if (
|
|
127
|
+
if (d(e)) return;
|
|
123
128
|
k(new s(e));
|
|
124
129
|
} finally {
|
|
125
130
|
A.stop(), w.releaseLock();
|
|
@@ -136,9 +141,9 @@ var e = { "Content-Type": "application/json" }, t = 409, n = "The response could
|
|
|
136
141
|
},
|
|
137
142
|
body: JSON.stringify(t)
|
|
138
143
|
}), o = a.headers.get("x-csrf-token");
|
|
139
|
-
if (o && n.setCsrfToken(o), !a.ok) throw
|
|
144
|
+
if (o && n.setCsrfToken(o), !a.ok) throw new c(a.status);
|
|
140
145
|
}
|
|
141
146
|
};
|
|
142
147
|
};
|
|
143
148
|
//#endregion
|
|
144
|
-
export { i as DEFAULT_GENERATION_CONFLICT_MESSAGE, n as DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE,
|
|
149
|
+
export { i as DEFAULT_GENERATION_CONFLICT_MESSAGE, n as DEFAULT_GENERATION_PERSISTENCE_ERROR_MESSAGE, l as DEFAULT_STREAM_IDLE_TIMEOUT_MS, a as GenerationConflictError, r as GenerationPersistenceError, c as StopCompletionError, s as StreamInterruptedError, o as StreamUpstreamError, m as createChatStreamApi };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { ConversationDraft, ConversationDraftStore } from '../conversation-draft/conversation-draft';
|
|
3
|
+
/** Parameters of `useConversationComposerDraft`. */
|
|
4
|
+
export interface UseConversationComposerDraftParams {
|
|
5
|
+
/** Host-owned draft store; `undefined` (e.g. no signed-in user yet) makes every handler a no-op. */
|
|
6
|
+
store: ConversationDraftStore | undefined;
|
|
7
|
+
/** The conversation whose draft is managed. */
|
|
8
|
+
conversationId: string;
|
|
9
|
+
/** Seeds the host's own composer and mention state from a restored draft. */
|
|
10
|
+
restoreDraft: (draft: ConversationDraft) => void;
|
|
11
|
+
/** While `false` the restore is deferred. Defaults to `true`. */
|
|
12
|
+
isRestoreReady?: boolean;
|
|
13
|
+
/** Skips the restore for this conversation, e.g. when external content is pending. Defaults to `false`. */
|
|
14
|
+
shouldSkipRestore?: boolean;
|
|
15
|
+
/** Delay before a change is written to the store, in milliseconds. Defaults to `300`. */
|
|
16
|
+
debounceMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Stable handlers returned by `useConversationComposerDraft`. */
|
|
19
|
+
export interface UseConversationComposerDraftResult {
|
|
20
|
+
/** Records a user-driven text change and schedules a save. */
|
|
21
|
+
handleTextChange: (text: string) => void;
|
|
22
|
+
/** Records the current skill mentions and schedules a save when they changed. */
|
|
23
|
+
handleSkillsChange: (skills: RequestSkill[]) => void;
|
|
24
|
+
/** Replaces the draft with host-provided content and no skills, and schedules a save. */
|
|
25
|
+
handleExternalContent: (text: string) => void;
|
|
26
|
+
/** Runs `send`, removing the draft when it resolves unless the user edited meanwhile, and storing `text` again when it rejects (the rejection is rethrown). */
|
|
27
|
+
sendWithDraft: (text: string, send: () => Promise<unknown> | unknown) => Promise<void>;
|
|
28
|
+
/** Discards the draft for the current conversation. */
|
|
29
|
+
clearDraft: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Headless per-conversation composer draft: saves the text and skill mentions
|
|
33
|
+
* the user leaves behind, restores them once when the conversation is shown
|
|
34
|
+
* again, and discards them on a successful send or an emptied input.
|
|
35
|
+
*
|
|
36
|
+
* All state lives in refs, so the hook never re-renders the host.
|
|
37
|
+
*/
|
|
38
|
+
export declare const useConversationComposerDraft: ({ store, conversationId, restoreDraft, isRestoreReady, shouldSkipRestore, debounceMs, }: UseConversationComposerDraftParams) => UseConversationComposerDraftResult;
|
|
39
|
+
//# sourceMappingURL=useConversationComposerDraft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConversationComposerDraft.d.ts","sourceRoot":"","sources":["../../../src/conversation/useConversationComposerDraft/useConversationComposerDraft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,0CAA0C,CAAC;AAMlD,oDAAoD;AACpD,MAAM,WAAW,kCAAkC;IACjD,oGAAoG;IACpG,KAAK,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC1C,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,6EAA6E;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2GAA2G;IAC3G,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,kEAAkE;AAClE,MAAM,WAAW,kCAAkC;IACjD,8DAA8D;IAC9D,gBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,iFAAiF;IACjF,kBAAkB,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IACrD,yFAAyF;IACzF,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,+JAA+J;IAC/J,aAAa,EAAE,CACb,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,KACnC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,uDAAuD;IACvD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAgCD;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GAAI,yFAO1C,kCAAkC,KAAG,kCA4KvC,CAAC"}
|