@epam/ai-dial-chat-hooks 1.2.0-dev.28 → 1.2.0-dev.284
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 +7 -4
- package/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
- package/attachments.d.ts +10 -4
- package/catalog/catalog-derivations.js +1 -1
- package/catalog/deployment-id.js +8 -2
- package/catalog/map-deployment-limits-to-catalog.js +16 -24
- package/catalog/map-deployment-limits-to-input.js +81 -9
- package/catalog/map-deployment-to-catalog-item.js +34 -34
- package/catalog/map-entity-details-to-catalog.js +7 -0
- package/catalog/map-skill-to-catalog-item.js +55 -48
- package/catalog/publish.js +6 -5
- package/catalog/useApplicationCredentials/useApplicationCredentials.js +39 -0
- package/catalog/useCatalogEditNavigation/useCatalogEditNavigation.js +122 -101
- package/catalog/usePublishFolders/usePublishFolders.js +1 -1
- package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
- package/catalog/useSkillItemDetails.js +17 -13
- package/catalog.d.ts +139 -34
- package/catalog.js +23 -22
- package/conversation/conversation-transfer/export-conversation.js +24 -16
- package/conversation/conversation-transfer/import-conversation.js +80 -31
- package/conversation/conversation-transfer/queue.js +8 -5
- package/conversation/create-chat-stream-api.js +85 -49
- package/conversation/message-utils.js +44 -2
- package/conversation/stage.js +27 -0
- package/conversation/useActiveConversationSync/useActiveConversationSync.js +7 -8
- package/conversation/useConversationExport/useConversationExport.js +9 -9
- package/conversation/useConversationHandlers/useConversationHandlers.js +73 -57
- package/conversation/useConversationImport/useConversationImport.js +123 -121
- package/conversation/useConversationPanelItems/useConversationPanelItems.js +50 -32
- package/conversation/useConversationScroll/useConversationScroll.js +68 -64
- package/conversation/useConversationStream/apply-chunk.js +1 -1
- package/conversation/useConversationStream/frame-scheduler.js +39 -0
- package/conversation/useConversationStream/generation-resume.js +122 -64
- package/conversation/useConversationStream/useConversationStream.js +265 -116
- package/conversation/useMessageSelectionReply/useMessageSelectionReply.js +189 -0
- package/conversation-sources/useConversationSources/useConversationSources.js +31 -24
- package/conversation-sources.d.ts +1 -1
- package/conversation-transfer.d.ts +2 -1
- package/conversation.d.ts +295 -17
- package/conversation.js +32 -29
- package/file-manager-canvas.d.ts +53 -5
- package/file-manager.d.ts +156 -26
- package/file-manager.js +25 -23
- package/files/attachment-canvas.js +74 -40
- package/files/attachment-types.js +14 -13
- package/files/dial-file-manager-mapping.util.js +2 -1
- package/files/dial-file-manager-path.util.js +23 -1
- package/files/dial-file-manager.model.js +23 -19
- package/files/dial-file-manager.types.js +3 -3
- package/files/useDialFileListing/useDialFileListing.js +139 -127
- package/files/useDialFileManager/useDialFileManager.js +132 -128
- package/files/useDialFileManagerSections/useDialFileManagerSections.js +155 -0
- package/files/useDialFileManagerTabConfig/useDialFileManagerTabConfig.js +20 -19
- package/files/useDialFileMutations/useDialFileMutations.js +33 -32
- package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +117 -110
- package/files/useFileAttachmentPicker/useFileAttachmentPicker.js +49 -0
- package/index.d.ts +1178 -112
- package/index.js +136 -122
- 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/oauth/toolset-id.js +5 -3
- package/oauth/useToolsetLogin/useToolsetLogin.js +8 -8
- package/oauth.d.ts +32 -0
- package/oauth.js +9 -9
- package/package.json +26 -21
- package/scheduled-task/scheduled-task-description.js +81 -0
- package/scheduled-task/scheduled-task-preparation.js +24 -0
- package/scheduled-task/scheduled-task-trigger.js +74 -71
- package/scheduled-task/scheduled-tasks-api-client.js +19 -0
- package/scheduled-task/use-scheduled-task-runs.js +194 -0
- package/scheduled-task/use-scheduled-tasks.js +93 -0
- package/scheduled-tasks.d.ts +197 -3
- package/scheduled-tasks.js +7 -2
- package/shared/application-schema.js +5 -2
- package/shared/cron-day-of-month.js +13 -0
- package/skill/skill-archive.js +19 -0
- package/skill/skill-types.js +8 -7
- package/skill/skill.js +53 -27
- package/skill/useSkillArchiveImport/useSkillArchiveImport.js +79 -0
- package/skill/useSkillEditorLoad.js +65 -59
- package/skill/useSkillEditorSubmit.js +108 -84
- package/skill/useSkillFileActions.js +70 -58
- package/skill-editor.d.ts +160 -8
- 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 +202 -0
- package/usage.d.ts +125 -0
- package/usage.js +3 -0
- package/usePageFileDrag/usePageFileDrag.js +3 -3
- package/utils.d.ts +26 -6
- package/utils.js +10 -10
|
@@ -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
|
|
|
@@ -139,7 +139,8 @@ export declare interface UseConversationExportResult {
|
|
|
139
139
|
* `.dial`/`.zip`, v5 envelope, old- or new-chat origin) once per file, then
|
|
140
140
|
* re-uploads any archive attachments to `uploads/<YYYY-MM>/` —
|
|
141
141
|
* disambiguating a name collision with a ` (n)` suffix instead of rejecting
|
|
142
|
-
* it — rewrites attachment references (and renamed titles),
|
|
142
|
+
* it — rewrites attachment references (and renamed titles), drops any
|
|
143
|
+
* reference still pointing into another user's bucket, regenerates each
|
|
143
144
|
* conversation's id/path with a fresh UUID (collision-free save, no replace
|
|
144
145
|
* dialog), and persists every conversation through the injected
|
|
145
146
|
* `conversationsApi`. One job per imported file, not per conversation.
|
package/conversation.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
|
23
23
|
import { ResponseFormat } from '@epam/ai-dial-chat-shared';
|
|
24
24
|
import { SendCompletionDtoModeEnum } from '@epam/ai-dial-chat-api-client';
|
|
25
25
|
import { SetStateAction } from 'react';
|
|
26
|
+
import { Stage } from '@epam/ai-dial-chat-shared';
|
|
26
27
|
import { StarterOption } from '@epam/ai-dial-chat-shared';
|
|
27
28
|
import { StatusMessage } from '@epam/ai-dial-chat-shared';
|
|
28
29
|
import { StreamChunk } from '@epam/ai-dial-chat-shared';
|
|
@@ -57,6 +58,25 @@ export declare interface AnnouncementListItemLink {
|
|
|
57
58
|
href: string;
|
|
58
59
|
}
|
|
59
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
|
+
|
|
60
80
|
/** State and controls returned by `useAsyncConfirmDialog`. */
|
|
61
81
|
export declare interface AsyncConfirmDialogControls<T> {
|
|
62
82
|
/**
|
|
@@ -195,6 +215,7 @@ export declare interface ChatStreamApi {
|
|
|
195
215
|
stopCompletion: (dto: {
|
|
196
216
|
generationId: string;
|
|
197
217
|
path: string;
|
|
218
|
+
content?: string;
|
|
198
219
|
}) => Promise<void>;
|
|
199
220
|
}
|
|
200
221
|
|
|
@@ -277,7 +298,7 @@ export declare interface ConversationStreamOverlayNotifier {
|
|
|
277
298
|
}
|
|
278
299
|
|
|
279
300
|
/** The exact `startStream` shape `useConversationStream` returns. */
|
|
280
|
-
export declare type ConversationStreamStarter = (conversationPath: string, userContent: string, messageIndex: number, model: string, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum) => void;
|
|
301
|
+
export declare type ConversationStreamStarter = (conversationPath: string, userContent: string, messageIndex: number, model: string, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, options?: StartStreamOptions) => void;
|
|
281
302
|
|
|
282
303
|
/**
|
|
283
304
|
* Host-owned transport for the DIAL Core completion protocol. Implemented at
|
|
@@ -287,10 +308,14 @@ export declare type ConversationStreamStarter = (conversationPath: string, userC
|
|
|
287
308
|
export declare interface ConversationStreamTransport {
|
|
288
309
|
/** Starts a completion; delivers chunks/completion/error through `options`, aborted via `options.signal`. */
|
|
289
310
|
streamCompletion(path: string, message: string | undefined, model: string, options: StreamCompletionOptions, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, messageIndex?: number, clientChannelId?: string): void;
|
|
290
|
-
/**
|
|
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
|
+
*/
|
|
291
315
|
stopCompletion(params: {
|
|
292
316
|
generationId: string;
|
|
293
317
|
path: string;
|
|
318
|
+
content?: string;
|
|
294
319
|
}): Promise<void>;
|
|
295
320
|
/** Opens a stream of resource-update events for `path`, until aborted via `signal`. */
|
|
296
321
|
watchConversation(path: string, signal: AbortSignal): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -327,6 +352,12 @@ export declare interface CreateChatStreamApiDeps {
|
|
|
327
352
|
getTimezone?: () => string | undefined;
|
|
328
353
|
/** `fetch` implementation to issue requests through. Defaults to the global `fetch`. */
|
|
329
354
|
fetchImpl?: typeof fetch;
|
|
355
|
+
/**
|
|
356
|
+
* How long an open completion stream may go without receiving a byte
|
|
357
|
+
* (keepalive comments included) before it is reported as a
|
|
358
|
+
* {@link StreamInterruptedError}. Defaults to {@link DEFAULT_STREAM_IDLE_TIMEOUT_MS}.
|
|
359
|
+
*/
|
|
360
|
+
idleTimeoutMs?: number;
|
|
330
361
|
}
|
|
331
362
|
|
|
332
363
|
/**
|
|
@@ -341,6 +372,11 @@ export declare const createMessagePair: (content: string, customContent?: Messag
|
|
|
341
372
|
/** Fallback text of a {@link GenerationConflictError} when no message is supplied. */
|
|
342
373
|
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.";
|
|
343
374
|
|
|
375
|
+
/** Safe fallback for hosts that do not supply a translated persistence warning. */
|
|
376
|
+
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.";
|
|
377
|
+
|
|
378
|
+
export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 45000;
|
|
379
|
+
|
|
344
380
|
/**
|
|
345
381
|
* Derives the row-action visibility state for a single conversation item.
|
|
346
382
|
*
|
|
@@ -375,6 +411,12 @@ export declare class GenerationConflictError extends Error {
|
|
|
375
411
|
constructor(message?: string);
|
|
376
412
|
}
|
|
377
413
|
|
|
414
|
+
/** Identifies a failed terminal save independently of the model's generation outcome. */
|
|
415
|
+
export declare class GenerationPersistenceError extends Error {
|
|
416
|
+
static readonly type = "conversation_save_failed";
|
|
417
|
+
constructor();
|
|
418
|
+
}
|
|
419
|
+
|
|
378
420
|
/**
|
|
379
421
|
* Strips the leading bucket segment from a conversation id and decodes any
|
|
380
422
|
* already-percent-encoded remainder back to raw, so callers that re-encode
|
|
@@ -387,6 +429,21 @@ export declare const getConversationPath: (conversationId: string) => string;
|
|
|
387
429
|
*/
|
|
388
430
|
export declare const getConversationSource: (item: Pick<ConversationListItemDto, "sharedWithMe" | "publishedWithMe">) => FilterTab;
|
|
389
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Returns the tool values the conversation's last message sets through its
|
|
434
|
+
* `form_schema`, restricted to `toolIds`, plus a key identifying that exact
|
|
435
|
+
* application. `undefined` when the last message is not an assistant message
|
|
436
|
+
* or sets no known tool.
|
|
437
|
+
*
|
|
438
|
+
* Streamed chunks and reloads re-create an identical `form_schema`; comparing
|
|
439
|
+
* keys rather than object identity applies an app's value once and leaves a
|
|
440
|
+
* later user toggle alone until the app sends a different value.
|
|
441
|
+
*/
|
|
442
|
+
export declare const getFormSchemaToolSyncKey: (conversationId: string, messages: Message[], toolIds: readonly string[]) => {
|
|
443
|
+
key: string;
|
|
444
|
+
values: Record<string, boolean>;
|
|
445
|
+
} | undefined;
|
|
446
|
+
|
|
390
447
|
/**
|
|
391
448
|
* Returns the deployment the conversation was last running on: scanning
|
|
392
449
|
* backwards, the `new_deployment_id` of a `model_changed` status message or
|
|
@@ -410,6 +467,15 @@ export declare const getLastDeploymentId: (messages: Message[]) => string | null
|
|
|
410
467
|
*/
|
|
411
468
|
export declare const getLastUserMessageToolConfiguration: (messages: Message[]) => Record<string, unknown> | undefined;
|
|
412
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Returns the tool configuration a (re-)loaded conversation should show: the
|
|
472
|
+
* last user message's `configuration_value`, overlaid in order by the
|
|
473
|
+
* `form_schema` values of the assistant messages after it. An app that turned
|
|
474
|
+
* a toggle off in its final response must not see it re-armed on reload just
|
|
475
|
+
* because the user message that started the run had it on.
|
|
476
|
+
*/
|
|
477
|
+
export declare const getLatestToolConfiguration: (messages: Message[]) => Record<string, unknown> | undefined;
|
|
478
|
+
|
|
413
479
|
/**
|
|
414
480
|
* Extracts the deployment/model ID from a DIAL Core conversation ID.
|
|
415
481
|
*
|
|
@@ -493,6 +559,15 @@ export declare const getStarterSubmitText: (starter: StarterOption, description?
|
|
|
493
559
|
*/
|
|
494
560
|
export declare const getTimeOfDayGreeting: (hour: number, translations: GreetingTranslations, firstName?: string) => string;
|
|
495
561
|
|
|
562
|
+
/**
|
|
563
|
+
* Returns the boolean values an assistant message's `form_schema` sets, keyed
|
|
564
|
+
* by property name, or `undefined` when no property resolves to a boolean.
|
|
565
|
+
* Lets a DIAL app switch a tools-menu toggle (e.g. `deep_research`) per
|
|
566
|
+
* message — on while a run is in progress, off once its result is delivered.
|
|
567
|
+
* Not filtered by tool id: `restoreToolConfiguration` ignores unknown ids.
|
|
568
|
+
*/
|
|
569
|
+
export declare const getToolConfigurationFromFormSchema: (formSchema: DeploymentConfigurationSchema | undefined) => Record<string, boolean> | undefined;
|
|
570
|
+
|
|
496
571
|
/** Pre-translated greeting phrase strings for each time-of-day period. */
|
|
497
572
|
export declare interface GreetingTranslations {
|
|
498
573
|
morningWithName: string;
|
|
@@ -526,11 +601,12 @@ export declare const hasStructuredAnnouncement: ({ title, description, }: Announ
|
|
|
526
601
|
export declare const isAnswerIncomplete: (answer: Message | undefined) => boolean;
|
|
527
602
|
|
|
528
603
|
/**
|
|
529
|
-
* True when the conversation
|
|
530
|
-
* placeholder: the backend only persists a
|
|
531
|
-
* (empty placeholder) and at generation end
|
|
532
|
-
* flagged `streamErrorMessage`/`wasStoppedByUser`)
|
|
533
|
-
* generation
|
|
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.
|
|
534
610
|
*/
|
|
535
611
|
export declare const isAwaitingGenerationResume: (conversation: Conversation) => boolean;
|
|
536
612
|
|
|
@@ -572,6 +648,32 @@ declare interface LocalModeValues {
|
|
|
572
648
|
temperature: number;
|
|
573
649
|
}
|
|
574
650
|
|
|
651
|
+
/**
|
|
652
|
+
* Returns the normalized stages of a complete raw stage array or a
|
|
653
|
+
* message-like payload (reading `custom_content.stages`, falling back to
|
|
654
|
+
* `customContent.stages`), or `undefined` when there are none. An entry
|
|
655
|
+
* without an `index` takes its array position — the identity a complete
|
|
656
|
+
* non-streaming array's `parent_stage_index` refers to — while explicit
|
|
657
|
+
* (possibly sparse) indexes are kept. Not for partial stream deltas.
|
|
658
|
+
*/
|
|
659
|
+
export declare const mapStages: (source: RawStage[] | RawStageSource | null | undefined) => Stage[] | undefined;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Merges incoming stage deltas into an existing stage list, keyed by `index`.
|
|
663
|
+
*
|
|
664
|
+
* Partial `name` and `content` strings are concatenated across chunks;
|
|
665
|
+
* attachments are merged by their own `index` (concatenating partial `title`
|
|
666
|
+
* and `data`); every other field on the incoming delta overwrites the
|
|
667
|
+
* accumulated one. A brand-new stage whose first chunk carries `name: null`
|
|
668
|
+
* is normalized to `''`.
|
|
669
|
+
*
|
|
670
|
+
* Exported for hosts that keep a flattened `Stage[]` on the message instead
|
|
671
|
+
* of `Message.custom_content.stages` and therefore cannot reuse
|
|
672
|
+
* {@link applyChunkToMessages}. Prefer `useConversationStream` when the host
|
|
673
|
+
* can delegate the whole stream loop.
|
|
674
|
+
*/
|
|
675
|
+
export declare const mergeStages: (existing: Stage[], incoming: Stage[]) => Stage[];
|
|
676
|
+
|
|
575
677
|
/** True when `message` is an assistant message carrying at least one stage. */
|
|
576
678
|
export declare const messageHasStages: (message: Message) => boolean;
|
|
577
679
|
|
|
@@ -581,6 +683,20 @@ export declare interface MessagePair {
|
|
|
581
683
|
assistantMessage: Message;
|
|
582
684
|
}
|
|
583
685
|
|
|
686
|
+
/** A stable snapshot of one eligible native text selection. */
|
|
687
|
+
export declare interface MessageSelectionReplySnapshot {
|
|
688
|
+
/** Scope that owned the selection when it was captured. */
|
|
689
|
+
conversationId: string;
|
|
690
|
+
/** Message text root containing the captured range. */
|
|
691
|
+
body: HTMLDivElement;
|
|
692
|
+
/** Captured native range. */
|
|
693
|
+
range: Range;
|
|
694
|
+
/** Native selected text preserved for the generated file. */
|
|
695
|
+
text: string;
|
|
696
|
+
/** Visible fragment of the selected range. */
|
|
697
|
+
rect: DOMRect;
|
|
698
|
+
}
|
|
699
|
+
|
|
584
700
|
/**
|
|
585
701
|
* Normalises a stored response-format string to the current enum. Legacy data
|
|
586
702
|
* may contain `'Markdown'` or `'PlainText'` (capital-first) instead of the
|
|
@@ -605,6 +721,68 @@ export declare interface QuickAppConversationStartersSettings {
|
|
|
605
721
|
isChatMessageInputDisabled: boolean;
|
|
606
722
|
}
|
|
607
723
|
|
|
724
|
+
/**
|
|
725
|
+
* One stage as it arrives from the REST API or the SSE stream, before
|
|
726
|
+
* normalization. Structurally satisfied by the generated `StageDto` and by a
|
|
727
|
+
* raw stream delta, both of which omit `index`/`name`/`status` on the chunk
|
|
728
|
+
* that opens a stage.
|
|
729
|
+
*/
|
|
730
|
+
export declare interface RawStage {
|
|
731
|
+
/** Ordering key. Defaults to `0` when absent. */
|
|
732
|
+
index?: number | null;
|
|
733
|
+
/** Stage title. `null` on the chunk that opens the stage. */
|
|
734
|
+
name?: string | null;
|
|
735
|
+
/** Terminal state as a raw wire string; anything other than `'completed'`/`'failed'` means still running. */
|
|
736
|
+
status?: string | null;
|
|
737
|
+
/** Additional stage text. */
|
|
738
|
+
content?: string | null;
|
|
739
|
+
/** Short source/category label shown beside the stage name. */
|
|
740
|
+
tag?: string | null;
|
|
741
|
+
/** Files produced or referenced by this stage. */
|
|
742
|
+
attachments?: RawStageAttachment[] | null;
|
|
743
|
+
/**
|
|
744
|
+
* `index` of the parent stage (its array position in a complete unindexed
|
|
745
|
+
* array). Nullish means top level; `0` is a valid parent.
|
|
746
|
+
*/
|
|
747
|
+
parent_stage_index?: number | null;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* One stage attachment as it arrives from the REST API or the SSE stream,
|
|
752
|
+
* before normalization: every field is optional and may be `null`.
|
|
753
|
+
*/
|
|
754
|
+
export declare interface RawStageAttachment {
|
|
755
|
+
/** Zero-based position in the attachment list. */
|
|
756
|
+
index?: number | null;
|
|
757
|
+
/** MIME type of the attachment content. */
|
|
758
|
+
type?: string | null;
|
|
759
|
+
/** Display name shown in the UI. */
|
|
760
|
+
title?: string | null;
|
|
761
|
+
/** Inline base-64 encoded content. */
|
|
762
|
+
data?: string | null;
|
|
763
|
+
/** Remote URL pointing to the attachment content. */
|
|
764
|
+
url?: string | null;
|
|
765
|
+
/** MIME type of the referenced resource. */
|
|
766
|
+
reference_type?: string | null;
|
|
767
|
+
/** URL of an alternate reference resource. */
|
|
768
|
+
reference_url?: string | null;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* Message-like payload carrying stages under either the wire's snake_case
|
|
773
|
+
* `custom_content` or a host's camelCased `customContent`.
|
|
774
|
+
*/
|
|
775
|
+
export declare interface RawStageSource {
|
|
776
|
+
/** Custom content as the DIAL wire format spells it. */
|
|
777
|
+
custom_content?: {
|
|
778
|
+
stages?: RawStage[] | null;
|
|
779
|
+
} | null;
|
|
780
|
+
/** Custom content as a camelCasing host spells it. */
|
|
781
|
+
customContent?: {
|
|
782
|
+
stages?: RawStage[] | null;
|
|
783
|
+
} | null;
|
|
784
|
+
}
|
|
785
|
+
|
|
608
786
|
/** State of one resource's recipient-count lookup. */
|
|
609
787
|
declare interface RecipientsCountEntry {
|
|
610
788
|
/** Where the lookup for this resource currently stands. */
|
|
@@ -653,6 +831,18 @@ export declare const shouldRerunGenerationOnEdit: (messages: Message[], messageI
|
|
|
653
831
|
/** True when the first user/assistant exchange is complete and LLM naming may still run. */
|
|
654
832
|
export declare const shouldWatchForDisplayNameUpdate: (conversation: Conversation) => boolean;
|
|
655
833
|
|
|
834
|
+
/** Per-start options of {@link UseConversationStreamResult.startStream}. */
|
|
835
|
+
export declare interface StartStreamOptions {
|
|
836
|
+
/**
|
|
837
|
+
* Treats a `GenerationConflictError` as "this turn is already being
|
|
838
|
+
* generated" — e.g. a page reloaded before that generation saved its start
|
|
839
|
+
* state — and joins the running generation instead of showing the conflict
|
|
840
|
+
* message, which remains the fallback. Only for a start that sends no new
|
|
841
|
+
* user text; a send the user typed must keep reporting the conflict.
|
|
842
|
+
*/
|
|
843
|
+
resumeOnConflict?: boolean;
|
|
844
|
+
}
|
|
845
|
+
|
|
656
846
|
/** Options accepted by {@link ConversationStreamTransport.streamCompletion}. */
|
|
657
847
|
export declare interface StreamCompletionOptions {
|
|
658
848
|
onChunk: (chunk: StreamChunk) => void;
|
|
@@ -661,6 +851,37 @@ export declare interface StreamCompletionOptions {
|
|
|
661
851
|
signal: AbortSignal;
|
|
662
852
|
}
|
|
663
853
|
|
|
854
|
+
/**
|
|
855
|
+
* Reported through `onError` when the network connection carrying a
|
|
856
|
+
* completion stream is lost (a rejected `fetch`, or a read that fails after a
|
|
857
|
+
* 2xx response) or goes silent past the idle timeout — what a laptop sleep or
|
|
858
|
+
* a phone lock mid-generation produces. The backend-owned generation may
|
|
859
|
+
* still be running, so the caller can recover it rather than treat the
|
|
860
|
+
* response as failed. `cause` holds the original error, when there is one.
|
|
861
|
+
*/
|
|
862
|
+
export declare class StreamInterruptedError extends Error {
|
|
863
|
+
constructor(cause?: unknown);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Reported through `onError` when DIAL Core itself signals a failure with an
|
|
868
|
+
* in-band `{ error: { message } }` SSE chunk. Its `message` is upstream text
|
|
869
|
+
* intended for the user, unlike a transport failure (failed `fetch`, non-OK
|
|
870
|
+
* status, broken stream), whose message is technical detail. A custom
|
|
871
|
+
* transport raises this for any user-facing upstream error text.
|
|
872
|
+
*/
|
|
873
|
+
export declare class StreamUpstreamError extends Error {
|
|
874
|
+
constructor(message: string);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/**
|
|
878
|
+
* Returns a renderable `Stage` for one raw payload: `index` defaults to `0`,
|
|
879
|
+
* `name` to `''`, an unrecognized `status` to `null` (still running), and
|
|
880
|
+
* `content`/`tag`/`attachments`/`parent_stage_index` are passed through when
|
|
881
|
+
* present (a parent of `0` included).
|
|
882
|
+
*/
|
|
883
|
+
export declare const toStage: (stage: RawStage) => Stage;
|
|
884
|
+
|
|
664
885
|
/** Request shape the host's selected-deployment recognition call accepts. */
|
|
665
886
|
export declare interface TranscribeWithDeploymentParams {
|
|
666
887
|
audioUrl: string;
|
|
@@ -677,7 +898,8 @@ export declare interface TranscribeWithDeploymentParams {
|
|
|
677
898
|
* 1. If the active conversation is not present in the list, requests a
|
|
678
899
|
* refresh. The list and refresh callback are intentionally excluded from
|
|
679
900
|
* the dependency array to avoid a refresh-loop on every list update.
|
|
680
|
-
* 2. Marks the active conversation as viewed
|
|
901
|
+
* 2. Marks the active conversation as viewed when its matching identity becomes
|
|
902
|
+
* available. List refreshes and persistence rollback do not retry the write.
|
|
681
903
|
*/
|
|
682
904
|
export declare const useActiveConversationSync: ({ activeConversationId, items, refreshConversations, markConversationViewed, conversationIdsMatch, toPanelConversationId, }: UseActiveConversationSyncParams) => string | undefined;
|
|
683
905
|
|
|
@@ -878,10 +1100,14 @@ export declare interface UseConversationLookupMapsParams {
|
|
|
878
1100
|
* Returns a memoised array whose shape is compatible with the conversation
|
|
879
1101
|
* panel's item contract. All app-specific concerns (icon URL resolution,
|
|
880
1102
|
* route generation, id normalisation) are injected via resolver callbacks.
|
|
1103
|
+
*
|
|
1104
|
+
* While every input except `items` is unchanged, a DTO that is referentially
|
|
1105
|
+
* the same as in the previous render maps to the same item object, so a list
|
|
1106
|
+
* change (or a navigation that re-derives the list) re-renders only the rows
|
|
1107
|
+
* whose DTO actually changed.
|
|
881
1108
|
*/
|
|
882
|
-
export declare const useConversationPanelItems: ({ items, deployments, isDeploymentsLoading, toPanelConversationId, resolveIconUrl, resolveIconTooltip, resolveHref,
|
|
883
|
-
|
|
884
|
-
taskBadgeLabel?: string | undefined;
|
|
1109
|
+
export declare const useConversationPanelItems: ({ items, deployments, isDeploymentsLoading, toPanelConversationId, resolveIconUrl, resolveIconTooltip, resolveHref, resolveTaskPresentation, }: UseConversationPanelItemsParams) => {
|
|
1110
|
+
leadingIcon?: ReactNode;
|
|
885
1111
|
isUnread?: boolean | undefined;
|
|
886
1112
|
id: string;
|
|
887
1113
|
title: string;
|
|
@@ -917,11 +1143,12 @@ export declare interface UseConversationPanelItemsResolvers {
|
|
|
917
1143
|
/** Resolves the href to navigate to when the conversation row is clicked. */
|
|
918
1144
|
resolveHref: (panelConversationId: string) => string;
|
|
919
1145
|
/**
|
|
920
|
-
* Returns
|
|
921
|
-
*
|
|
1146
|
+
* Returns the row presentation for a scheduled-task conversation — a
|
|
1147
|
+
* host-rendered leading icon that replaces the deployment avatar, and the
|
|
1148
|
+
* unread flag — or `undefined` for an ordinary conversation.
|
|
922
1149
|
*/
|
|
923
|
-
|
|
924
|
-
|
|
1150
|
+
resolveTaskPresentation?: (item: ConversationListItemDto) => {
|
|
1151
|
+
leadingIcon?: ReactNode;
|
|
925
1152
|
isUnread: boolean;
|
|
926
1153
|
} | undefined;
|
|
927
1154
|
}
|
|
@@ -934,7 +1161,7 @@ export declare interface UseConversationPanelItemsResolvers {
|
|
|
934
1161
|
* `transport`/`generation`/`channel`/`overlay` capabilities rather than any
|
|
935
1162
|
* app context or `server-api` import.
|
|
936
1163
|
*/
|
|
937
|
-
export declare const useConversationStream: ({ conversationId, state: { setConversation, conversationRef }, transport, generation: { startGeneration, completeGeneration }, channel, overlay, onStopError, generationConflictMessage, }: UseConversationStreamParams) => UseConversationStreamResult;
|
|
1164
|
+
export declare const useConversationStream: ({ conversationId, state: { setConversation, conversationRef }, transport, generation: { startGeneration, completeGeneration }, channel, overlay, onStopError, generationConflictMessage, generationPersistenceErrorMessage, onStreamError, batchChunksPerFrame, }: UseConversationStreamParams) => UseConversationStreamResult;
|
|
938
1165
|
|
|
939
1166
|
/** Parameters for {@link useConversationStream}. */
|
|
940
1167
|
export declare interface UseConversationStreamParams {
|
|
@@ -952,17 +1179,39 @@ export declare interface UseConversationStreamParams {
|
|
|
952
1179
|
* {@link DEFAULT_GENERATION_CONFLICT_MESSAGE}.
|
|
953
1180
|
*/
|
|
954
1181
|
generationConflictMessage?: string;
|
|
1182
|
+
/** Host-translated warning shown when the received answer could not be saved. */
|
|
1183
|
+
generationPersistenceErrorMessage?: string;
|
|
1184
|
+
/**
|
|
1185
|
+
* Receives the original error of every failed stream. The hook shows only
|
|
1186
|
+
* host-supplied or upstream-supplied text on the message bubble and hides
|
|
1187
|
+
* transport detail (e.g. `Failed to fetch`), so this is where the host can
|
|
1188
|
+
* still log or report the raw error.
|
|
1189
|
+
*/
|
|
1190
|
+
onStreamError?: (error: Error) => void;
|
|
1191
|
+
/**
|
|
1192
|
+
* Coalesces the displayed chunk updates into one `setConversation` per
|
|
1193
|
+
* animation frame. Chunks still reach the per-path buffer immediately, and
|
|
1194
|
+
* any pending update is flushed before completion, error, stop, or a
|
|
1195
|
+
* superseding generation. Defaults to `false` (one update per chunk).
|
|
1196
|
+
*/
|
|
1197
|
+
batchChunksPerFrame?: boolean;
|
|
955
1198
|
}
|
|
956
1199
|
|
|
957
1200
|
/** Return value of {@link useConversationStream}. */
|
|
958
1201
|
export declare interface UseConversationStreamResult {
|
|
959
|
-
startStream: (conversationId: string, userContent: string, messageIndex: number, model: string, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum) => void;
|
|
1202
|
+
startStream: (conversationId: string, userContent: string, messageIndex: number, model: string, customContent?: MessageCustomContent, generationId?: string, mode?: SendCompletionDtoModeEnum, options?: StartStreamOptions) => void;
|
|
960
1203
|
handleStop: () => void;
|
|
961
1204
|
resumeIfAwaitingGeneration: (currentConversationId: string, conversation: Conversation) => void;
|
|
962
1205
|
/** Restores the accumulated live assistant message when its conversation is loaded again before completion. */
|
|
963
1206
|
restoreBufferedGeneration: (currentConversationId: string, conversation: Conversation) => Conversation;
|
|
964
1207
|
isStreaming: boolean;
|
|
965
1208
|
canStopStreaming: boolean;
|
|
1209
|
+
/** Whether the displayed conversation's terminal read failed. */
|
|
1210
|
+
hasConversationReloadError: boolean;
|
|
1211
|
+
/** Whether a retry of that read is in flight. */
|
|
1212
|
+
isReloadingConversation: boolean;
|
|
1213
|
+
/** Retries the failed read without saving or regenerating the answer. */
|
|
1214
|
+
retryConversationReload: () => Promise<void>;
|
|
966
1215
|
}
|
|
967
1216
|
|
|
968
1217
|
/**
|
|
@@ -998,6 +1247,35 @@ export declare interface UseImportFilePickerResult {
|
|
|
998
1247
|
handleFileChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
999
1248
|
}
|
|
1000
1249
|
|
|
1250
|
+
/**
|
|
1251
|
+
* Captures eligible message text and creates Reply files for an existing composer
|
|
1252
|
+
* attachment flow without acquiring host deployment, upload or localization knowledge.
|
|
1253
|
+
*/
|
|
1254
|
+
export declare const useMessageSelectionReply: ({ conversationId, enabled, droppedFiles, onDroppedFilesConsumed, }: UseMessageSelectionReplyParams) => {
|
|
1255
|
+
contentRef: (node: HTMLDivElement | null) => (() => void) | undefined;
|
|
1256
|
+
actionRef: RefObject<HTMLDivElement | null>;
|
|
1257
|
+
selection: MessageSelectionReplySnapshot | null;
|
|
1258
|
+
onReply: () => void;
|
|
1259
|
+
dismiss: () => void;
|
|
1260
|
+
pendingFiles: File[];
|
|
1261
|
+
onFilesConsumed: () => void;
|
|
1262
|
+
focusRequestId: number | undefined;
|
|
1263
|
+
onAttachmentsChange: (attachments: Attachment[]) => void;
|
|
1264
|
+
addedRevision: number;
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
/** Parameters accepted by {@link useMessageSelectionReply}. */
|
|
1268
|
+
export declare interface UseMessageSelectionReplyParams {
|
|
1269
|
+
/** Identifier used to discard selection and queued files after a scope change. */
|
|
1270
|
+
conversationId: string;
|
|
1271
|
+
/** Whether the host currently permits a Reply attachment. */
|
|
1272
|
+
enabled: boolean;
|
|
1273
|
+
/** Files from the host's ordinary page-drop queue. */
|
|
1274
|
+
droppedFiles: File[];
|
|
1275
|
+
/** Acknowledges the captured page-drop batch after the composer accepts it. */
|
|
1276
|
+
onDroppedFilesConsumed: () => void;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1001
1279
|
/**
|
|
1002
1280
|
* Derives the tools submenu from the active deployment's configuration schema:
|
|
1003
1281
|
* every boolean property becomes a toggle. Manages toggle state locally, resets
|