@epam/ai-dial-chat-hooks 1.2.0-dev.6 → 1.2.0-dev.69
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/attachment/useAttachmentValidation/useAttachmentValidation.js +26 -19
- package/attachments.d.ts +10 -4
- package/catalog/map-deployment-to-catalog-item.js +2 -2
- package/catalog/map-skill-to-catalog-item.js +2 -2
- package/catalog/publish.js +2 -1
- package/catalog/useSkillDetailsPanelData/useSkillDetailsPanelData.js +39 -39
- package/catalog/useSkillItemDetails.js +19 -17
- package/catalog.d.ts +38 -5
- package/catalog.js +14 -14
- package/conversation/conversation-transfer/queue.js +8 -5
- package/conversation/stage.js +23 -0
- package/conversation/useAttachmentUpload/useAttachmentUpload.js +12 -5
- package/conversation/useConversationHandlers/useConversationHandlers.js +13 -17
- package/conversation/useConversationImport/useConversationImport.js +1 -1
- package/conversation/useConversationStream/apply-chunk.js +1 -1
- package/conversation/useConversationStream/useConversationStream.js +5 -1
- package/conversation-overlay.d.ts +7 -0
- package/conversation-overlay.js +2 -0
- package/conversation.d.ts +108 -5
- package/conversation.js +24 -23
- package/file-manager-canvas.d.ts +398 -0
- package/file-manager-canvas.js +2 -0
- package/file-manager.d.ts +0 -325
- package/file-manager.js +14 -15
- package/files/attachment-canvas.js +51 -13
- package/index.d.ts +238 -22
- package/index.js +111 -109
- package/mcp-apps/useMcpAppHostAdapter/useMcpAppHostAdapter.js +7 -5
- package/mcp-apps/useMcpAppHostContext/useMcpAppHostContext.js +1 -1
- package/mcp-apps/useOpenMcpAppCanvas/useOpenMcpAppCanvas.js +25 -23
- package/mcp-apps.d.ts +8 -6
- package/package.json +28 -18
package/conversation.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { Message } from '@epam/ai-dial-chat-shared';
|
|
|
15
15
|
import { MessageCustomContent } from '@epam/ai-dial-chat-shared';
|
|
16
16
|
import { MessageRating } from '@epam/ai-dial-chat-shared';
|
|
17
17
|
import { MutableRefObject } from 'react';
|
|
18
|
-
import { OverlayChatMessage } from '@epam/ai-dial-chat-overlay';
|
|
19
18
|
import { PublishHistoryEntry } from '@epam/ai-dial-publish-panel';
|
|
20
19
|
import { RateApi } from '@epam/ai-dial-chat-api-client';
|
|
21
20
|
import { ReactNode } from 'react';
|
|
@@ -24,6 +23,7 @@ import { RequestSkill } from '@epam/ai-dial-chat-shared';
|
|
|
24
23
|
import { ResponseFormat } from '@epam/ai-dial-chat-shared';
|
|
25
24
|
import { SendCompletionDtoModeEnum } from '@epam/ai-dial-chat-api-client';
|
|
26
25
|
import { SetStateAction } from 'react';
|
|
26
|
+
import { Stage } from '@epam/ai-dial-chat-shared';
|
|
27
27
|
import { StarterOption } from '@epam/ai-dial-chat-shared';
|
|
28
28
|
import { StatusMessage } from '@epam/ai-dial-chat-shared';
|
|
29
29
|
import { StreamChunk } from '@epam/ai-dial-chat-shared';
|
|
@@ -58,6 +58,25 @@ export declare interface AnnouncementListItemLink {
|
|
|
58
58
|
href: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Applies a single SSE stream chunk to the message list.
|
|
63
|
+
*
|
|
64
|
+
*
|
|
65
|
+
* Attachments are accumulated: each chunk's attachments are appended to the
|
|
66
|
+
* existing array rather than replacing it.
|
|
67
|
+
*
|
|
68
|
+
* Annotations are merged by `index`: partial `body.title` and `body.quote`
|
|
69
|
+
* strings are concatenated across chunks, matching the same delta-merge
|
|
70
|
+
* semantics used for stages.
|
|
71
|
+
*
|
|
72
|
+
* `state` is overwritten (not merged) by each chunk that carries one,
|
|
73
|
+
* matching the DIAL stateful-app contract.
|
|
74
|
+
*
|
|
75
|
+
* @returns Updated message array, or `null` when the chunk carries no
|
|
76
|
+
* actionable data (empty content, no form_schema, and no attachments).
|
|
77
|
+
*/
|
|
78
|
+
export declare const applyChunkToMessages: (messages: Message[], messageIndex: number, chunk: StreamChunk) => Message[] | null;
|
|
79
|
+
|
|
61
80
|
/** State and controls returned by `useAsyncConfirmDialog`. */
|
|
62
81
|
export declare interface AsyncConfirmDialogControls<T> {
|
|
63
82
|
/**
|
|
@@ -573,6 +592,29 @@ declare interface LocalModeValues {
|
|
|
573
592
|
temperature: number;
|
|
574
593
|
}
|
|
575
594
|
|
|
595
|
+
/**
|
|
596
|
+
* Returns the normalized stages of a raw stage array or a message-like
|
|
597
|
+
* payload (reading `custom_content.stages`, falling back to
|
|
598
|
+
* `customContent.stages`), or `undefined` when there are none.
|
|
599
|
+
*/
|
|
600
|
+
export declare const mapStages: (source: RawStage[] | RawStageSource | null | undefined) => Stage[] | undefined;
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Merges incoming stage deltas into an existing stage list, keyed by `index`.
|
|
604
|
+
*
|
|
605
|
+
* Partial `name` and `content` strings are concatenated across chunks;
|
|
606
|
+
* attachments are merged by their own `index` (concatenating partial `title`
|
|
607
|
+
* and `data`); every other field on the incoming delta overwrites the
|
|
608
|
+
* accumulated one. A brand-new stage whose first chunk carries `name: null`
|
|
609
|
+
* is normalized to `''`.
|
|
610
|
+
*
|
|
611
|
+
* Exported for hosts that keep a flattened `Stage[]` on the message instead
|
|
612
|
+
* of `Message.custom_content.stages` and therefore cannot reuse
|
|
613
|
+
* {@link applyChunkToMessages}. Prefer `useConversationStream` when the host
|
|
614
|
+
* can delegate the whole stream loop.
|
|
615
|
+
*/
|
|
616
|
+
export declare const mergeStages: (existing: Stage[], incoming: Stage[]) => Stage[];
|
|
617
|
+
|
|
576
618
|
/** True when `message` is an assistant message carrying at least one stage. */
|
|
577
619
|
export declare const messageHasStages: (message: Message) => boolean;
|
|
578
620
|
|
|
@@ -606,6 +648,63 @@ export declare interface QuickAppConversationStartersSettings {
|
|
|
606
648
|
isChatMessageInputDisabled: boolean;
|
|
607
649
|
}
|
|
608
650
|
|
|
651
|
+
/**
|
|
652
|
+
* One stage as it arrives from the REST API or the SSE stream, before
|
|
653
|
+
* normalization. Structurally satisfied by the generated `StageDto` and by a
|
|
654
|
+
* raw stream delta, both of which omit `index`/`name`/`status` on the chunk
|
|
655
|
+
* that opens a stage.
|
|
656
|
+
*/
|
|
657
|
+
export declare interface RawStage {
|
|
658
|
+
/** Ordering key. Defaults to `0` when absent. */
|
|
659
|
+
index?: number | null;
|
|
660
|
+
/** Stage title. `null` on the chunk that opens the stage. */
|
|
661
|
+
name?: string | null;
|
|
662
|
+
/** Terminal state as a raw wire string; anything other than `'completed'`/`'failed'` means still running. */
|
|
663
|
+
status?: string | null;
|
|
664
|
+
/** Additional stage text. */
|
|
665
|
+
content?: string | null;
|
|
666
|
+
/** Short source/category label shown beside the stage name. */
|
|
667
|
+
tag?: string | null;
|
|
668
|
+
/** Files produced or referenced by this stage. */
|
|
669
|
+
attachments?: RawStageAttachment[] | null;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* One stage attachment as it arrives from the REST API or the SSE stream,
|
|
674
|
+
* before normalization: every field is optional and may be `null`.
|
|
675
|
+
*/
|
|
676
|
+
export declare interface RawStageAttachment {
|
|
677
|
+
/** Zero-based position in the attachment list. */
|
|
678
|
+
index?: number | null;
|
|
679
|
+
/** MIME type of the attachment content. */
|
|
680
|
+
type?: string | null;
|
|
681
|
+
/** Display name shown in the UI. */
|
|
682
|
+
title?: string | null;
|
|
683
|
+
/** Inline base-64 encoded content. */
|
|
684
|
+
data?: string | null;
|
|
685
|
+
/** Remote URL pointing to the attachment content. */
|
|
686
|
+
url?: string | null;
|
|
687
|
+
/** MIME type of the referenced resource. */
|
|
688
|
+
reference_type?: string | null;
|
|
689
|
+
/** URL of an alternate reference resource. */
|
|
690
|
+
reference_url?: string | null;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Message-like payload carrying stages under either the wire's snake_case
|
|
695
|
+
* `custom_content` or a host's camelCased `customContent`.
|
|
696
|
+
*/
|
|
697
|
+
export declare interface RawStageSource {
|
|
698
|
+
/** Custom content as the DIAL wire format spells it. */
|
|
699
|
+
custom_content?: {
|
|
700
|
+
stages?: RawStage[] | null;
|
|
701
|
+
} | null;
|
|
702
|
+
/** Custom content as a camelCasing host spells it. */
|
|
703
|
+
customContent?: {
|
|
704
|
+
stages?: RawStage[] | null;
|
|
705
|
+
} | null;
|
|
706
|
+
}
|
|
707
|
+
|
|
609
708
|
/** State of one resource's recipient-count lookup. */
|
|
610
709
|
declare interface RecipientsCountEntry {
|
|
611
710
|
/** Where the lookup for this resource currently stands. */
|
|
@@ -662,8 +761,12 @@ export declare interface StreamCompletionOptions {
|
|
|
662
761
|
signal: AbortSignal;
|
|
663
762
|
}
|
|
664
763
|
|
|
665
|
-
/**
|
|
666
|
-
|
|
764
|
+
/**
|
|
765
|
+
* Returns a renderable `Stage` for one raw payload: `index` defaults to `0`,
|
|
766
|
+
* `name` to `''`, an unrecognized `status` to `null` (still running), and
|
|
767
|
+
* `content`/`tag`/`attachments` are passed through when present.
|
|
768
|
+
*/
|
|
769
|
+
export declare const toStage: (stage: RawStage) => Stage;
|
|
667
770
|
|
|
668
771
|
/** Request shape the host's selected-deployment recognition call accepts. */
|
|
669
772
|
export declare interface TranscribeWithDeploymentParams {
|
|
@@ -728,8 +831,8 @@ export declare const useAttachmentUpload: ({ filesApi, bucket, onNetworkError, d
|
|
|
728
831
|
|
|
729
832
|
/** Parameters for {@link useAttachmentUpload}. */
|
|
730
833
|
export declare interface UseAttachmentUploadParams {
|
|
731
|
-
/** Already-configured
|
|
732
|
-
filesApi: Pick<FilesApi, 'uploadFile'
|
|
834
|
+
/** Already-configured client; optional listing skips stored names after a conflict. */
|
|
835
|
+
filesApi: Pick<FilesApi, 'uploadFile'> & Partial<Pick<FilesApi, 'listFiles'>>;
|
|
733
836
|
/** DIAL Core bucket the file is uploaded into. */
|
|
734
837
|
bucket: string | undefined;
|
|
735
838
|
/** Called with batched filenames after a burst of network-error upload failures. */
|
package/conversation.js
CHANGED
|
@@ -6,26 +6,27 @@ import { getModelIdFromConversationId as d } from "./conversation/get-model-id-f
|
|
|
6
6
|
import { getTimeOfDayGreeting as f } from "./conversation/greeting.js";
|
|
7
7
|
import { createDeploymentChangedMessage as p } from "./conversation/message-factory.js";
|
|
8
8
|
import { getLastDeploymentId as m, getLastUserMessageToolConfiguration as h, isMessageStreaming as g, messageHasStages as _, normalizeResponseFormat as v } from "./conversation/message-utils.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { getStarterPopulateText as
|
|
12
|
-
import { deriveConversationRowActionState as
|
|
13
|
-
import { useActiveConversationSync as
|
|
14
|
-
import { useAsyncConfirmDialog as
|
|
15
|
-
import { useConversationLookupMaps as
|
|
16
|
-
import { getConversationSource as
|
|
17
|
-
import { useImportFilePicker as
|
|
18
|
-
import { useAttachmentUpload as
|
|
19
|
-
import { AudioTranscriptionError as
|
|
20
|
-
import { useTranscribeAudio as
|
|
21
|
-
import { attachmentToDto as
|
|
22
|
-
import { createMessagePair as
|
|
23
|
-
import { hasActiveToolConfig as
|
|
24
|
-
import { getStarterConversationText as
|
|
25
|
-
import { getConversationPath as
|
|
26
|
-
import { useConversationHandlers as
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
|
|
9
|
+
import { getQuickAppConversationStarters as y } from "./conversation/quick-app-conversation-starters.js";
|
|
10
|
+
import { mapStages as b, toStage as x } from "./conversation/stage.js";
|
|
11
|
+
import { getStarterPopulateText as S, getStartersFromSchema as C } from "./conversation/starter-option.js";
|
|
12
|
+
import { deriveConversationRowActionState as w } from "./conversation/deriveConversationRowActionState/deriveConversationRowActionState.js";
|
|
13
|
+
import { useActiveConversationSync as T } from "./conversation/useActiveConversationSync/useActiveConversationSync.js";
|
|
14
|
+
import { useAsyncConfirmDialog as E } from "./conversation/useAsyncConfirmDialog/useAsyncConfirmDialog.js";
|
|
15
|
+
import { useConversationLookupMaps as D } from "./conversation/useConversationLookupMaps/useConversationLookupMaps.js";
|
|
16
|
+
import { getConversationSource as O, useConversationPanelItems as k } from "./conversation/useConversationPanelItems/useConversationPanelItems.js";
|
|
17
|
+
import { useImportFilePicker as A } from "./conversation/useImportFilePicker/useImportFilePicker.js";
|
|
18
|
+
import { useAttachmentUpload as j } from "./conversation/useAttachmentUpload/useAttachmentUpload.js";
|
|
19
|
+
import { AudioTranscriptionError as M, AudioTranscriptionErrorReason as N } from "./conversation/useTranscribeAudio/audio-transcription-error.js";
|
|
20
|
+
import { useTranscribeAudio as P } from "./conversation/useTranscribeAudio/useTranscribeAudio.js";
|
|
21
|
+
import { attachmentToDto as F, attachmentsToDtos as I } from "./conversation/useConversationHandlers/attachment-to-dto.js";
|
|
22
|
+
import { createMessagePair as L } from "./conversation/useConversationHandlers/message-factory.js";
|
|
23
|
+
import { hasActiveToolConfig as R, isAnswerIncomplete as z, isMessageChanged as B, shouldRerunGenerationOnEdit as V } from "./conversation/useConversationHandlers/message-utils.js";
|
|
24
|
+
import { getStarterConversationText as H, getStarterDisplayText as U, getStarterSubmitText as W } from "./conversation/useConversationHandlers/starter-option.js";
|
|
25
|
+
import { getConversationPath as G } from "./conversation/useConversationStream/conversation-path.js";
|
|
26
|
+
import { useConversationHandlers as K } from "./conversation/useConversationHandlers/useConversationHandlers.js";
|
|
27
|
+
import { applyChunkToMessages as q, mergeStages as J } from "./conversation/useConversationStream/apply-chunk.js";
|
|
28
|
+
import { isAwaitingGenerationResume as Y } from "./conversation/useConversationStream/generation-resume.js";
|
|
29
|
+
import { useConversationStream as X } from "./conversation/useConversationStream/useConversationStream.js";
|
|
30
|
+
import { useChatSettingsFormConfig as Z } from "./useChatSettingsFormConfig/useChatSettingsFormConfig.js";
|
|
31
|
+
import { useToolsMenu as Q } from "./useToolsMenu/useToolsMenu.js";
|
|
32
|
+
export { M as AudioTranscriptionError, N as AudioTranscriptionErrorReason, a as DEFAULT_GENERATION_CONFLICT_MESSAGE, o as GenerationConflictError, q as applyChunkToMessages, F as attachmentToDto, I as attachmentsToDtos, e as buildAnnouncementSignature, s as createChatStreamApi, p as createDeploymentChangedMessage, L as createMessagePair, w as deriveConversationRowActionState, l as formatAppVersion, G as getConversationPath, O as getConversationSource, m as getLastDeploymentId, h as getLastUserMessageToolConfiguration, d as getModelIdFromConversationId, y as getQuickAppConversationStarters, H as getStarterConversationText, U as getStarterDisplayText, S as getStarterPopulateText, W as getStarterSubmitText, C as getStartersFromSchema, f as getTimeOfDayGreeting, R as hasActiveToolConfig, t as hasAnnouncementContent, n as hasStructuredAnnouncement, z as isAnswerIncomplete, Y as isAwaitingGenerationResume, B as isMessageChanged, g as isMessageStreaming, b as mapStages, J as mergeStages, _ as messageHasStages, v as normalizeResponseFormat, r as sanitizeAnnouncementHtml, i as sanitizeAnnouncementMessageHtml, u as sanitizeFooterHtml, V as shouldRerunGenerationOnEdit, c as shouldWatchForDisplayNameUpdate, x as toStage, T as useActiveConversationSync, E as useAsyncConfirmDialog, j as useAttachmentUpload, Z as useChatSettingsFormConfig, K as useConversationHandlers, D as useConversationLookupMaps, k as useConversationPanelItems, X as useConversationStream, A as useImportFilePicker, Q as useToolsMenu, P as useTranscribeAudio };
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { Annotation } from '@epam/ai-dial-chat-shared';
|
|
2
|
+
import { AnnotationGroup } from '@epam/ai-dial-quotations';
|
|
3
|
+
import { ApplicationVisualizer } from '@epam/ai-dial-chat-shared';
|
|
4
|
+
import { AttachmentResource } from '@epam/ai-dial-chat-shared';
|
|
5
|
+
import { CustomVisualizer } from '@epam/ai-dial-chat-shared';
|
|
6
|
+
import type { CustomVisualizerDataLayout } from '@epam/ai-dial-chat-shared';
|
|
7
|
+
import { DisplayAttachment } from '@epam/ai-dial-chat-shared';
|
|
8
|
+
import type { GroupedAttachmentItem } from '@epam/ai-dial-chat-shared';
|
|
9
|
+
import type { InputHighlightData } from '@epam/pdf-highlighter-kit';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Builds an `OoxmlCanvasContent` for a DOCX/PPTX/XLSX citation annotation,
|
|
13
|
+
* including highlights for every annotation sharing the clicked one's source
|
|
14
|
+
* document. Returns `null` when the annotation has no source attachment,
|
|
15
|
+
* the source is not a format `@silurus/ooxml` renders as DOCX/XLSX/PPTX (a
|
|
16
|
+
* CSV source returns `null` — citation highlighting targets Office documents
|
|
17
|
+
* only), or no URL resolves.
|
|
18
|
+
*/
|
|
19
|
+
export declare const annotationToOoxmlCanvasContent: (annotation: Annotation, annotations: Annotation[], resolvers: AttachmentCanvasUrlResolvers) => OoxmlCanvasContent | null;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builds a `PdfCanvasContent` for a PDF citation annotation, including highlights
|
|
23
|
+
* for the clicked annotation's document within its citation group.
|
|
24
|
+
* Returns `null` if the annotation has no PDF source attachment.
|
|
25
|
+
*/
|
|
26
|
+
export declare const annotationToPdfCanvasContent: (annotation: Annotation, groups: AnnotationGroup[], resolvers: AttachmentCanvasUrlResolvers) => PdfCanvasContent | null;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* DIAL-file URL resolution injected by the host into every attachment-canvas
|
|
30
|
+
* content resolver below. Host-owned — encodes the app's own
|
|
31
|
+
* file-download endpoint.
|
|
32
|
+
*/
|
|
33
|
+
export declare interface AttachmentCanvasUrlResolvers {
|
|
34
|
+
/** Resolves a DIAL Core file id to a downloadable URL. */
|
|
35
|
+
resolveDialFileDownloadUrl: (fileId: string) => string | undefined;
|
|
36
|
+
/** Resolves the best downloadable DIAL-file URL from an attachment's `url` or `referenceUrl`. */
|
|
37
|
+
resolveDialUrl: (attachment: DisplayAttachment) => string | undefined;
|
|
38
|
+
/** Resolves a DIAL Core file id to a fetchable metadata URL (used for cache-freshness validation). */
|
|
39
|
+
resolveDialFileMetadataUrl: (fileId: string) => string | undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The type of content the canvas can display. */
|
|
43
|
+
declare enum AttachmentContentType {
|
|
44
|
+
PlainText = 'plain_text',
|
|
45
|
+
Image = 'image',
|
|
46
|
+
Audio = 'audio',
|
|
47
|
+
Markdown = 'markdown',
|
|
48
|
+
MarkdownTable = 'markdown_table',
|
|
49
|
+
Json = 'json',
|
|
50
|
+
Pdf = 'pdf',
|
|
51
|
+
Ooxml = 'ooxml',
|
|
52
|
+
Code = 'code',
|
|
53
|
+
Html = 'html',
|
|
54
|
+
Visualizer = 'visualizer',
|
|
55
|
+
GroupedVisualizer = 'grouped_visualizer',
|
|
56
|
+
McpApp = 'mcp_app',
|
|
57
|
+
Unsupported = 'unsupported',
|
|
58
|
+
Error = 'error',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The kind of failure that produced an `ErrorCanvasContent`. */
|
|
62
|
+
declare enum AttachmentErrorType {
|
|
63
|
+
/** The file failed to load (network error or a non-`403` non-OK response). */
|
|
64
|
+
LoadFailed = 'load_failed',
|
|
65
|
+
/** The file request failed with HTTP `403` — the user lacks permission to access it. */
|
|
66
|
+
Forbidden = 'forbidden',
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Clears all cached fetch results. Call this when leaving a conversation. */
|
|
70
|
+
export declare const clearAttachmentCache: () => void;
|
|
71
|
+
|
|
72
|
+
/** Content payload for syntax-highlighted source-code or text file attachments. */
|
|
73
|
+
declare interface CodeCanvasContent {
|
|
74
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
75
|
+
type: AttachmentContentType.Code;
|
|
76
|
+
/** The raw source text to display. */
|
|
77
|
+
text: string;
|
|
78
|
+
/** `react-syntax-highlighter` language identifier (e.g. `'typescript'`). `undefined` renders plain monospace. */
|
|
79
|
+
language?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Content payload for attachments whose file failed to load or that the user cannot access. */
|
|
83
|
+
declare interface ErrorCanvasContent {
|
|
84
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
85
|
+
type: AttachmentContentType.Error;
|
|
86
|
+
/** The kind of failure that occurred. */
|
|
87
|
+
errorType: AttachmentErrorType;
|
|
88
|
+
/** Remote URL of the file, if known. Ignored for download purposes when `errorType` is `Forbidden`. */
|
|
89
|
+
url?: string;
|
|
90
|
+
/** Overrides the default `loadErrorLabel`/`forbiddenErrorLabel` message, for callers whose failed content isn't a generic "file" (e.g. an MCP App). */
|
|
91
|
+
label?: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Content payload for an application-scoped grouped visualizer: every attachment a message's visualizer claims, rendered together inside one sandboxed iframe. */
|
|
95
|
+
declare interface GroupedVisualizerCanvasContent {
|
|
96
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
97
|
+
type: AttachmentContentType.GroupedVisualizer;
|
|
98
|
+
/** Iframe `src`, resolved from the matching registry entry's `url`. */
|
|
99
|
+
url: string;
|
|
100
|
+
/** One item per claimed attachment, in the message's attachment order. Each `url` is absolute, resolved by the host. */
|
|
101
|
+
attachments: GroupedAttachmentItem[];
|
|
102
|
+
/** Presentation layout hints (`themeId`, `width`, `height`, `mobileHeight`) shared by every item. */
|
|
103
|
+
layout: CustomVisualizerDataLayout;
|
|
104
|
+
/** postMessage protocol namespace — MUST equal the registry entry's `title`, or the iframe never receives data. */
|
|
105
|
+
visualizerName: string;
|
|
106
|
+
/** Milliseconds to wait for a `send()` request's response before rejecting. From the registry entry; does NOT bound the handshake. */
|
|
107
|
+
requestTimeout?: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Outcome of building a grouped visualizer payload. */
|
|
111
|
+
export declare interface GroupedVisualizerResolution {
|
|
112
|
+
/** The grouped payload, or `null` when no claimed attachment resolved to a URL. */
|
|
113
|
+
content: GroupedVisualizerCanvasContent | null;
|
|
114
|
+
/** The claimed attachments that reached `content.attachments`, in the input's order. The caller returns the rest to the ordinary attachment tray. */
|
|
115
|
+
resolved: DisplayAttachment[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Whether the attachment carries text `resolveAttachmentText` can resolve —
|
|
120
|
+
* inline data, a DIAL download URL, or a locally-picked file. Mirrors that
|
|
121
|
+
* function's source list, so a `null` resolver result can be read as "the text
|
|
122
|
+
* was fetched and rejected" rather than "there was no text to fetch".
|
|
123
|
+
*/
|
|
124
|
+
export declare const hasAttachmentTextSource: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => boolean;
|
|
125
|
+
|
|
126
|
+
/** Content payload for HTML file attachments or external HTML URL sources. */
|
|
127
|
+
declare interface HtmlCanvasContent {
|
|
128
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
129
|
+
type: AttachmentContentType.Html;
|
|
130
|
+
/** Full HTML text rendered via `srcdoc` in a sandboxed iframe. Used for file attachments. */
|
|
131
|
+
srcdoc?: string;
|
|
132
|
+
/** External URL rendered via `src` in a sandboxed iframe. Used for external link sources. */
|
|
133
|
+
url?: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Content payload for image attachments. */
|
|
137
|
+
declare interface ImageCanvasContent {
|
|
138
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
139
|
+
type: AttachmentContentType.Image;
|
|
140
|
+
/** URL of the image to display (object URL or resolved download URL). */
|
|
141
|
+
url: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Content payload for JSON file attachments. */
|
|
145
|
+
declare interface JsonCanvasContent {
|
|
146
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
147
|
+
type: AttachmentContentType.Json;
|
|
148
|
+
/** Already-parsed JSON value. The lib never calls JSON.parse. */
|
|
149
|
+
value: unknown;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Content payload for Markdown file attachments. */
|
|
153
|
+
declare interface MarkdownCanvasContent {
|
|
154
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
155
|
+
type: AttachmentContentType.Markdown;
|
|
156
|
+
/** Raw Markdown string to render. */
|
|
157
|
+
text: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Content payload for OOXML document and CSV spreadsheet attachments. */
|
|
161
|
+
declare interface OoxmlCanvasContent {
|
|
162
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
163
|
+
type: AttachmentContentType.Ooxml;
|
|
164
|
+
/** Resolved download URL or object URL for the source file. */
|
|
165
|
+
url: string;
|
|
166
|
+
/** The document format used to select and configure the format-specific renderer. */
|
|
167
|
+
format: OoxmlFileType;
|
|
168
|
+
/** Cited locations to draw over the document. Omitted, never `[]`, when there is nothing to highlight. */
|
|
169
|
+
highlights?: OoxmlHighlight[];
|
|
170
|
+
/** Id of the highlight to navigate to and emphasise. Omitted when the clicked citation resolved to no location. */
|
|
171
|
+
selectedHighlightId?: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** A 1-based cell address, matching `@silurus/ooxml`'s own `CellAddress`. */
|
|
175
|
+
declare interface OoxmlCellAddress {
|
|
176
|
+
/** 1-based row number. */
|
|
177
|
+
row: number;
|
|
178
|
+
/** 1-based column number. */
|
|
179
|
+
col: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** A cited character range inside a DOCX story, addressed by story name and source-tree path. */
|
|
183
|
+
declare interface OoxmlDocxHighlightLocation {
|
|
184
|
+
/** Discriminates this location within `OoxmlHighlightLocation`. */
|
|
185
|
+
kind: OoxmlHighlightKind.DocxTextRange;
|
|
186
|
+
/** Name of the DOCX story the range lives in, as an opaque string (only `'body'` is confirmed upstream). */
|
|
187
|
+
story: string;
|
|
188
|
+
/** Source-tree element indices identifying the paragraph, matched element-wise. */
|
|
189
|
+
path: number[];
|
|
190
|
+
/** Inclusive start character offset within the story's matched text. */
|
|
191
|
+
start: number;
|
|
192
|
+
/** Exclusive end character offset, already converted from the wire's inclusive `end`. */
|
|
193
|
+
endExclusive: number;
|
|
194
|
+
/** The cited text, compared against the text resolved over `[start, endExclusive)`. */
|
|
195
|
+
text: string;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** A complete table row in the DOCX body, matched by cell text. */
|
|
199
|
+
declare interface OoxmlDocxTableRowLocation {
|
|
200
|
+
/** Location kind. */
|
|
201
|
+
kind: OoxmlHighlightKind.DocxTableRow;
|
|
202
|
+
/** Plain text of each cell, in column order. */
|
|
203
|
+
cells: string[];
|
|
204
|
+
/** 1-based matching row in document order. */
|
|
205
|
+
occurrence: number;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** Supported document formats rendered by the installed `@silurus/ooxml` runtime. */
|
|
209
|
+
declare enum OoxmlFileType {
|
|
210
|
+
Docx = 'docx',
|
|
211
|
+
Xlsx = 'xlsx',
|
|
212
|
+
Pptx = 'pptx',
|
|
213
|
+
Csv = 'csv',
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** One citation's highlight: the locations it resolved to, under a stable id. */
|
|
217
|
+
declare interface OoxmlHighlight {
|
|
218
|
+
/** Stable id, used to mark exactly one highlight selected. */
|
|
219
|
+
id: string;
|
|
220
|
+
/** One or more locations — a single citation may carry several selectors. */
|
|
221
|
+
locations: OoxmlHighlightLocation[];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Discriminates the Office highlight location descriptors an `OoxmlCanvasContent` can carry. */
|
|
225
|
+
declare enum OoxmlHighlightKind {
|
|
226
|
+
/** A character range inside a DOCX story, addressed by story name and source-tree path. */
|
|
227
|
+
DocxTextRange = 'docxTextRange',
|
|
228
|
+
/** A character range inside a single PPTX shape on one slide. */
|
|
229
|
+
PptxTextRange = 'pptxTextRange',
|
|
230
|
+
/** A complete DOCX table row identified by its cell text. */
|
|
231
|
+
DocxTableRow = 'docxTableRow',
|
|
232
|
+
/** A complete PPTX table row identified by its cell text on one slide. */
|
|
233
|
+
PptxTableRow = 'pptxTableRow',
|
|
234
|
+
/** One cell, or a contiguous same-row cell range, on a named XLSX sheet. */
|
|
235
|
+
XlsxCellRange = 'xlsxCellRange',
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** A cited location inside an Office document, in document coordinates. */
|
|
239
|
+
declare type OoxmlHighlightLocation =
|
|
240
|
+
| OoxmlDocxHighlightLocation
|
|
241
|
+
| OoxmlPptxHighlightLocation
|
|
242
|
+
| OoxmlDocxTableRowLocation
|
|
243
|
+
| OoxmlPptxTableRowLocation
|
|
244
|
+
| OoxmlXlsxHighlightLocation;
|
|
245
|
+
|
|
246
|
+
/** A cited character range inside a single shape on one PPTX slide. */
|
|
247
|
+
declare interface OoxmlPptxHighlightLocation {
|
|
248
|
+
/** Discriminates this location within `OoxmlHighlightLocation`. */
|
|
249
|
+
kind: OoxmlHighlightKind.PptxTextRange;
|
|
250
|
+
/** 1-based slide number. */
|
|
251
|
+
slide: number;
|
|
252
|
+
/** Shape identifier, compared as a string against the run's own `shapeId`. */
|
|
253
|
+
shapeId: string;
|
|
254
|
+
/** Inclusive start character offset within the shape's matched text. */
|
|
255
|
+
start: number;
|
|
256
|
+
/** Exclusive end character offset, already converted from the wire's inclusive `end`. */
|
|
257
|
+
endExclusive: number;
|
|
258
|
+
/** The cited text, compared against the text resolved over `[start, endExclusive)`. */
|
|
259
|
+
text: string;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** A complete table row on one PPTX slide, matched by cell text. */
|
|
263
|
+
declare interface OoxmlPptxTableRowLocation {
|
|
264
|
+
/** Location kind. */
|
|
265
|
+
kind: OoxmlHighlightKind.PptxTableRow;
|
|
266
|
+
/** Plain text of each cell, in column order. */
|
|
267
|
+
cells: string[];
|
|
268
|
+
/** 1-based matching row on the specified slide. */
|
|
269
|
+
occurrence: number;
|
|
270
|
+
/** 1-based slide number. */
|
|
271
|
+
slide: number;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** A cited cell, or contiguous same-row cell range, on a named XLSX sheet. */
|
|
275
|
+
declare interface OoxmlXlsxHighlightLocation {
|
|
276
|
+
/** Discriminates this location within `OoxmlHighlightLocation`. */
|
|
277
|
+
kind: OoxmlHighlightKind.XlsxCellRange;
|
|
278
|
+
/** Sheet name, matched exactly against the workbook's own sheet names. */
|
|
279
|
+
sheet: string;
|
|
280
|
+
/** First cell of the range. 1-based, passed to the viewer unconverted. */
|
|
281
|
+
start: OoxmlCellAddress;
|
|
282
|
+
/** Last cell of the range, on the same row as `start`. Omitted for a single cell. */
|
|
283
|
+
end?: OoxmlCellAddress;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/** Content payload for PDF file attachments. */
|
|
287
|
+
declare interface PdfCanvasContent {
|
|
288
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
289
|
+
type: AttachmentContentType.Pdf;
|
|
290
|
+
/** Resolved download URL or object URL for the PDF file. */
|
|
291
|
+
url: string;
|
|
292
|
+
/** Highlight regions to render over the PDF pages. */
|
|
293
|
+
highlights?: InputHighlightData[];
|
|
294
|
+
/** ID of the highlight to scroll to and select on initial load. */
|
|
295
|
+
selectedHighlightId?: string;
|
|
296
|
+
/** 1-based page to navigate to on initial load, independent of highlight geometry. */
|
|
297
|
+
page?: number;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** Content payload for plain-text attachments. */
|
|
301
|
+
declare interface PlainTextCanvasContent {
|
|
302
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
303
|
+
type: AttachmentContentType.PlainText;
|
|
304
|
+
/** The raw text to display. */
|
|
305
|
+
text: string;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Builds a `PdfCanvasContent` for a reference-only attachment whose
|
|
310
|
+
* `reference_url` points at a PDF file (optionally with a `#page=N`
|
|
311
|
+
* fragment), so it can be opened in the canvas and scrolled to the
|
|
312
|
+
* referenced page the same way a regular PDF citation is. Returns `null`
|
|
313
|
+
* when the attachment's `url` does not target a PDF.
|
|
314
|
+
*/
|
|
315
|
+
export declare const referenceAttachmentToPdfCanvasContent: (attachment: AttachmentResource, resolvers: AttachmentCanvasUrlResolvers) => PdfCanvasContent | null;
|
|
316
|
+
|
|
317
|
+
/** Resolves a syntax-highlighted code canvas content payload from a DisplayAttachment, or `null` if unavailable. */
|
|
318
|
+
export declare const resolveCodeCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers, language?: string) => Promise<CodeCanvasContent | ErrorCanvasContent | null>;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Builds the grouped payload for an application-scoped visualizer from the
|
|
322
|
+
* attachments its entry claims, reporting which of them `resolveAbsoluteUrl`
|
|
323
|
+
* could produce a URL for. Unlike the single-attachment resolver this fetches
|
|
324
|
+
* nothing: the grouped protocol hands the visualizer URLs and lets it read
|
|
325
|
+
* them itself, so the URLs must be absolute — a host-relative path would
|
|
326
|
+
* resolve against the iframe's own origin. Producing one is host knowledge,
|
|
327
|
+
* which is why it arrives as a callback rather than being built here.
|
|
328
|
+
*/
|
|
329
|
+
export declare const resolveGroupedVisualizerCanvasContent: (attachments: DisplayAttachment[], resolveAbsoluteUrl: (attachment: DisplayAttachment) => string | undefined, entry: ApplicationVisualizer, themeId: string) => GroupedVisualizerResolution;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Resolves an HTML canvas content payload from a DisplayAttachment.
|
|
333
|
+
* Fetches and inlines the HTML as `srcdoc` when the attachment has a download URL or inline data.
|
|
334
|
+
* Returns `null` if no source is available, or an `ErrorCanvasContent` on fetch failure.
|
|
335
|
+
* Rejects `srcdoc` payloads larger than 1 MiB to prevent browser truncation.
|
|
336
|
+
*/
|
|
337
|
+
export declare const resolveHtmlCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<HtmlCanvasContent | ErrorCanvasContent | null>;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Resolves an image canvas content payload from a DisplayAttachment without
|
|
341
|
+
* fetching — returns a local blob URL or the BFF download URL directly so the
|
|
342
|
+
* browser cache can be shared with the conversation view's `<img>` element.
|
|
343
|
+
* A local `File` with bytes takes precedence over the DIAL download URL; a
|
|
344
|
+
* 0-byte `File` (the file-manager placeholder) does not. Error detection is
|
|
345
|
+
* delegated to `<img onError>` in the canvas renderer. Returns `null` if no
|
|
346
|
+
* URL source is available.
|
|
347
|
+
*/
|
|
348
|
+
export declare const resolveImageCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => ImageCanvasContent | null;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Resolves a JSON canvas content payload from a DisplayAttachment, or `null` if unavailable.
|
|
352
|
+
* Falls back to `PlainTextCanvasContent` when the fetched text is not valid JSON.
|
|
353
|
+
*/
|
|
354
|
+
export declare const resolveJsonCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<JsonCanvasContent | PlainTextCanvasContent | ErrorCanvasContent | null>;
|
|
355
|
+
|
|
356
|
+
/** Resolves a Markdown canvas content payload from a DisplayAttachment, or `null` if unavailable. */
|
|
357
|
+
export declare const resolveMarkdownCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<MarkdownCanvasContent | ErrorCanvasContent | null>;
|
|
358
|
+
|
|
359
|
+
/** Resolves an OOXML or CSV renderer payload from a DisplayAttachment, or `null` if unavailable. */
|
|
360
|
+
export declare const resolveOoxmlCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers, format: OoxmlFileType) => Promise<OoxmlCanvasContent | ErrorCanvasContent | null>;
|
|
361
|
+
|
|
362
|
+
/** Resolves a PDF canvas content payload from a DisplayAttachment, or `null` if unavailable. */
|
|
363
|
+
export declare const resolvePdfCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<PdfCanvasContent | ErrorCanvasContent | null>;
|
|
364
|
+
|
|
365
|
+
/** Resolves a plain-text canvas content payload from a DisplayAttachment, or `null` if unavailable. */
|
|
366
|
+
export declare const resolveTextCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => Promise<PlainTextCanvasContent | ErrorCanvasContent | null>;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Fetches the attachment payload and builds a `VisualizerCanvasContent` for the
|
|
370
|
+
* given registry entry and theme. Returns `null` when the payload cannot be
|
|
371
|
+
* fetched (caller should fall through to default content-type handling).
|
|
372
|
+
*
|
|
373
|
+
* Only JSON payloads are parsed into `data`. Non-JSON payloads (plain text,
|
|
374
|
+
* CSV, binary, …) resolve with `data: {}` — the visualizer still receives
|
|
375
|
+
* `mimeType` and `layout`, just no payload body. This is intentional: only
|
|
376
|
+
* JSON attachment content is forwarded to visualizers in this version.
|
|
377
|
+
*/
|
|
378
|
+
export declare const resolveVisualizerCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers, entry: CustomVisualizer, themeId: string) => Promise<VisualizerCanvasContent | null>;
|
|
379
|
+
|
|
380
|
+
/** Content payload for a custom-visualizer attachment rendered inside a sandboxed iframe. */
|
|
381
|
+
declare interface VisualizerCanvasContent {
|
|
382
|
+
/** Discriminates the content type to select the correct renderer. */
|
|
383
|
+
type: AttachmentContentType.Visualizer;
|
|
384
|
+
/** Iframe `src`, resolved from the matching registry entry's `url`. */
|
|
385
|
+
url: string;
|
|
386
|
+
/** The attachment's own MIME type (not the registry entry's raw, possibly comma-separated, `contentType`). */
|
|
387
|
+
mimeType: string;
|
|
388
|
+
/** Opaque attachment payload consumed by the visualizer. */
|
|
389
|
+
data: unknown;
|
|
390
|
+
/** Presentation layout hints (`themeId`, `width`, `height`, `mobileHeight`). */
|
|
391
|
+
layout: CustomVisualizerDataLayout;
|
|
392
|
+
/** postMessage protocol namespace — MUST equal the registry entry's `title`, or the iframe never receives data. */
|
|
393
|
+
visualizerName: string;
|
|
394
|
+
/** Milliseconds to wait for a `send()` request's response before rejecting. From the registry entry; does NOT bound the handshake. */
|
|
395
|
+
requestTimeout?: number;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export { }
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { annotationToOoxmlCanvasContent as e, annotationToPdfCanvasContent as t, clearAttachmentCache as n, hasAttachmentTextSource as r, referenceAttachmentToPdfCanvasContent as i, resolveCodeCanvasContent as a, resolveGroupedVisualizerCanvasContent as o, resolveHtmlCanvasContent as s, resolveImageCanvasContent as c, resolveJsonCanvasContent as l, resolveMarkdownCanvasContent as u, resolveOoxmlCanvasContent as d, resolvePdfCanvasContent as f, resolveTextCanvasContent as p, resolveVisualizerCanvasContent as m } from "./files/attachment-canvas.js";
|
|
2
|
+
export { e as annotationToOoxmlCanvasContent, t as annotationToPdfCanvasContent, n as clearAttachmentCache, r as hasAttachmentTextSource, i as referenceAttachmentToPdfCanvasContent, a as resolveCodeCanvasContent, o as resolveGroupedVisualizerCanvasContent, s as resolveHtmlCanvasContent, c as resolveImageCanvasContent, l as resolveJsonCanvasContent, u as resolveMarkdownCanvasContent, d as resolveOoxmlCanvasContent, f as resolvePdfCanvasContent, p as resolveTextCanvasContent, m as resolveVisualizerCanvasContent };
|