@epam/ai-dial-chat-hooks 1.2.0-dev.6 → 1.2.0-dev.61

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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Annotation } from '@epam/ai-dial-chat-shared';
2
2
  import { AnnotationGroup } from '@epam/ai-dial-quotations';
3
+ import { ApplicationVisualizer } from '@epam/ai-dial-chat-shared';
3
4
  import { ArchiveItemDto } from '@epam/ai-dial-chat-api-client';
4
5
  import { Attachment } from '@epam/ai-dial-chat-shared';
5
6
  import { AttachmentDisplayResolvers } from '@epam/ai-dial-chat-shared';
@@ -69,6 +70,7 @@ import { FileUploadStatus } from '@epam/ai-dial-chat-shared';
69
70
  import { FileUploadValidationResult } from '@epam/ai-dial-chat-shared';
70
71
  import { FilterTab } from '@epam/ai-dial-chat-shared';
71
72
  import { getParentFolderPath } from '@epam/ai-dial-chat-shared';
73
+ import type { GroupedAttachmentItem } from '@epam/ai-dial-chat-shared';
72
74
  import type { InputHighlightData } from '@epam/pdf-highlighter-kit';
73
75
  import { ListFilesItemDto } from '@epam/ai-dial-chat-api-client';
74
76
  import { ListFilesResponseDto } from '@epam/ai-dial-chat-api-client';
@@ -127,6 +129,7 @@ import { SkillFileUploadCandidate } from '@epam/ai-dial-skill-editor';
127
129
  import { SkillFileValidationResult } from '@epam/ai-dial-skill-editor';
128
130
  import { SkillMetadataItemDto } from '@epam/ai-dial-chat-api-client';
129
131
  import { SkillUploadResponseDto } from '@epam/ai-dial-chat-api-client';
132
+ import { Stage } from '@epam/ai-dial-chat-shared';
130
133
  import { StarterOption } from '@epam/ai-dial-chat-shared';
131
134
  import { StatusMessage } from '@epam/ai-dial-chat-shared';
132
135
  import { StreamChunk } from '@epam/ai-dial-chat-shared';
@@ -247,6 +250,25 @@ export declare interface ApiErrorDetails {
247
250
  /** Appends a locale's uppercased code to a field label, e.g. `'Name [EN]'`. */
248
251
  export declare const appendLocaleCode: (label: string, locale: string) => string;
249
252
 
253
+ /**
254
+ * Applies a single SSE stream chunk to the message list.
255
+ *
256
+ *
257
+ * Attachments are accumulated: each chunk's attachments are appended to the
258
+ * existing array rather than replacing it.
259
+ *
260
+ * Annotations are merged by `index`: partial `body.title` and `body.quote`
261
+ * strings are concatenated across chunks, matching the same delta-merge
262
+ * semantics used for stages.
263
+ *
264
+ * `state` is overwritten (not merged) by each chunk that carries one,
265
+ * matching the DIAL stateful-app contract.
266
+ *
267
+ * @returns Updated message array, or `null` when the chunk carries no
268
+ * actionable data (empty content, no form_schema, and no attachments).
269
+ */
270
+ export declare const applyChunkToMessages: (messages: Message[], messageIndex: number, chunk: StreamChunk) => Message[] | null;
271
+
250
272
  /** Converts an APScheduler weekday (Monday=0..Sunday=6) to a JS `Date` weekday (Sunday=0..Saturday=6). */
251
273
  export declare const apSchedulerDayToJsDay: (apSchedulerDay: number) => number;
252
274
 
@@ -314,6 +336,7 @@ declare enum AttachmentContentType {
314
336
  Code = 'code',
315
337
  Html = 'html',
316
338
  Visualizer = 'visualizer',
339
+ GroupedVisualizer = 'grouped_visualizer',
317
340
  McpApp = 'mcp_app',
318
341
  Unsupported = 'unsupported',
319
342
  Error = 'error',
@@ -522,6 +545,13 @@ export declare const buildSkillManifestFromFrontmatter: (baseFrontmatter: Record
522
545
  * authored it, when it last changed, and its file inventory. Grouping folders
523
546
  * in the file listing are excluded from both the count and the rows. Sizes are
524
547
  * not shown — the skill metadata carries no content-length field.
548
+ *
549
+ * `skill` is the authoritative `getSkillMetadata` response when that request
550
+ * fulfilled; the caller falls back to the catalog listing entry only when it
551
+ * rejected (`useSkillItemDetails`'s `onFetchSkillDetails`). Either way, this
552
+ * function never fills a gap in one source from the other — an absent
553
+ * `author` omits the row and an absent `updatedAt` leaves the updated row's
554
+ * value empty, exactly as `skill` carries it.
525
555
  */
526
556
  export declare const buildSkillOverview: (skill: SkillMetadataItemDto | undefined, files: SkillMetadataItemDto[], about: SkillAboutDetails | undefined, labels: SkillOverviewLabels) => CatalogItemOverview;
527
557
 
@@ -1838,6 +1868,30 @@ export declare interface GreetingTranslations {
1838
1868
  nightNoName: string;
1839
1869
  }
1840
1870
 
1871
+ /** Content payload for an application-scoped grouped visualizer: every attachment a message's visualizer claims, rendered together inside one sandboxed iframe. */
1872
+ declare interface GroupedVisualizerCanvasContent {
1873
+ /** Discriminates the content type to select the correct renderer. */
1874
+ type: AttachmentContentType.GroupedVisualizer;
1875
+ /** Iframe `src`, resolved from the matching registry entry's `url`. */
1876
+ url: string;
1877
+ /** One item per claimed attachment, in the message's attachment order. Each `url` is absolute, resolved by the host. */
1878
+ attachments: GroupedAttachmentItem[];
1879
+ /** Presentation layout hints (`themeId`, `width`, `height`, `mobileHeight`) shared by every item. */
1880
+ layout: CustomVisualizerDataLayout;
1881
+ /** postMessage protocol namespace — MUST equal the registry entry's `title`, or the iframe never receives data. */
1882
+ visualizerName: string;
1883
+ /** Milliseconds to wait for a `send()` request's response before rejecting. From the registry entry; does NOT bound the handshake. */
1884
+ requestTimeout?: number;
1885
+ }
1886
+
1887
+ /** Outcome of building a grouped visualizer payload. */
1888
+ export declare interface GroupedVisualizerResolution {
1889
+ /** The grouped payload, or `null` when no claimed attachment resolved to a URL. */
1890
+ content: GroupedVisualizerCanvasContent | null;
1891
+ /** The claimed attachments that reached `content.attachments`, in the input's order. The caller returns the rest to the ordinary attachment tray. */
1892
+ resolved: DisplayAttachment[];
1893
+ }
1894
+
1841
1895
  /** Whether at least one tool toggle in `value` is active. */
1842
1896
  export declare const hasActiveToolConfig: (value: Record<string, boolean> | undefined) => boolean;
1843
1897
 
@@ -2174,6 +2228,13 @@ export declare interface MapSkillToCatalogItemOptions {
2174
2228
  favoriteIds: ReadonlySet<string>;
2175
2229
  }
2176
2230
 
2231
+ /**
2232
+ * Returns the normalized stages of a raw stage array or a message-like
2233
+ * payload (reading `custom_content.stages`, falling back to
2234
+ * `customContent.stages`), or `undefined` when there are none.
2235
+ */
2236
+ export declare const mapStages: (source: RawStage[] | RawStageSource | null | undefined) => Stage[] | undefined;
2237
+
2177
2238
  /**
2178
2239
  * Maps a toolset's specification into the lib's credential-status shape,
2179
2240
  * for refreshing the details panel after login/logout. Includes both
@@ -2356,6 +2417,22 @@ export declare enum McpResourceKind {
2356
2417
 
2357
2418
  export declare const mergeCreatedFolderIntoCache: (cache: Map<string, ListFilesItemDto[]>, parentApiPath: string, created: CreateFolderResponseDto, inheritedPermissions?: string[]) => Map<string, ListFilesItemDto[]>;
2358
2419
 
2420
+ /**
2421
+ * Merges incoming stage deltas into an existing stage list, keyed by `index`.
2422
+ *
2423
+ * Partial `name` and `content` strings are concatenated across chunks;
2424
+ * attachments are merged by their own `index` (concatenating partial `title`
2425
+ * and `data`); every other field on the incoming delta overwrites the
2426
+ * accumulated one. A brand-new stage whose first chunk carries `name: null`
2427
+ * is normalized to `''`.
2428
+ *
2429
+ * Exported for hosts that keep a flattened `Stage[]` on the message instead
2430
+ * of `Message.custom_content.stages` and therefore cannot reuse
2431
+ * {@link applyChunkToMessages}. Prefer `useConversationStream` when the host
2432
+ * can delegate the whole stream loop.
2433
+ */
2434
+ export declare const mergeStages: (existing: Stage[], incoming: Stage[]) => Stage[];
2435
+
2359
2436
  /** True when `message` is an assistant message carrying at least one stage. */
2360
2437
  export declare const messageHasStages: (message: Message) => boolean;
2361
2438
 
@@ -2544,7 +2621,17 @@ declare interface OoxmlDocxHighlightLocation {
2544
2621
  text: string;
2545
2622
  }
2546
2623
 
2547
- /** Supported document formats rendered by the bundled `@silurus/ooxml` runtime. */
2624
+ /** A complete table row in the DOCX body, matched by cell text. */
2625
+ declare interface OoxmlDocxTableRowLocation {
2626
+ /** Location kind. */
2627
+ kind: OoxmlHighlightKind.DocxTableRow;
2628
+ /** Plain text of each cell, in column order. */
2629
+ cells: string[];
2630
+ /** 1-based matching row in document order. */
2631
+ occurrence: number;
2632
+ }
2633
+
2634
+ /** Supported document formats rendered by the installed `@silurus/ooxml` runtime. */
2548
2635
  declare enum OoxmlFileType {
2549
2636
  Docx = 'docx',
2550
2637
  Xlsx = 'xlsx',
@@ -2566,6 +2653,10 @@ declare enum OoxmlHighlightKind {
2566
2653
  DocxTextRange = 'docxTextRange',
2567
2654
  /** A character range inside a single PPTX shape on one slide. */
2568
2655
  PptxTextRange = 'pptxTextRange',
2656
+ /** A complete DOCX table row identified by its cell text. */
2657
+ DocxTableRow = 'docxTableRow',
2658
+ /** A complete PPTX table row identified by its cell text on one slide. */
2659
+ PptxTableRow = 'pptxTableRow',
2569
2660
  /** One cell, or a contiguous same-row cell range, on a named XLSX sheet. */
2570
2661
  XlsxCellRange = 'xlsxCellRange',
2571
2662
  }
@@ -2574,6 +2665,8 @@ declare enum OoxmlHighlightKind {
2574
2665
  declare type OoxmlHighlightLocation =
2575
2666
  | OoxmlDocxHighlightLocation
2576
2667
  | OoxmlPptxHighlightLocation
2668
+ | OoxmlDocxTableRowLocation
2669
+ | OoxmlPptxTableRowLocation
2577
2670
  | OoxmlXlsxHighlightLocation;
2578
2671
 
2579
2672
  /** A cited character range inside a single shape on one PPTX slide. */
@@ -2592,6 +2685,18 @@ declare interface OoxmlPptxHighlightLocation {
2592
2685
  text: string;
2593
2686
  }
2594
2687
 
2688
+ /** A complete table row on one PPTX slide, matched by cell text. */
2689
+ declare interface OoxmlPptxTableRowLocation {
2690
+ /** Location kind. */
2691
+ kind: OoxmlHighlightKind.PptxTableRow;
2692
+ /** Plain text of each cell, in column order. */
2693
+ cells: string[];
2694
+ /** 1-based matching row on the specified slide. */
2695
+ occurrence: number;
2696
+ /** 1-based slide number. */
2697
+ slide: number;
2698
+ }
2699
+
2595
2700
  /** A cited cell, or contiguous same-row cell range, on a named XLSX sheet. */
2596
2701
  declare interface OoxmlXlsxHighlightLocation {
2597
2702
  /** Discriminates this location within `OoxmlHighlightLocation`. */
@@ -2846,6 +2951,63 @@ export declare interface QuickAppSchemaLike {
2846
2951
  displayName?: string;
2847
2952
  }
2848
2953
 
2954
+ /**
2955
+ * One stage as it arrives from the REST API or the SSE stream, before
2956
+ * normalization. Structurally satisfied by the generated `StageDto` and by a
2957
+ * raw stream delta, both of which omit `index`/`name`/`status` on the chunk
2958
+ * that opens a stage.
2959
+ */
2960
+ export declare interface RawStage {
2961
+ /** Ordering key. Defaults to `0` when absent. */
2962
+ index?: number | null;
2963
+ /** Stage title. `null` on the chunk that opens the stage. */
2964
+ name?: string | null;
2965
+ /** Terminal state as a raw wire string; anything other than `'completed'`/`'failed'` means still running. */
2966
+ status?: string | null;
2967
+ /** Additional stage text. */
2968
+ content?: string | null;
2969
+ /** Short source/category label shown beside the stage name. */
2970
+ tag?: string | null;
2971
+ /** Files produced or referenced by this stage. */
2972
+ attachments?: RawStageAttachment[] | null;
2973
+ }
2974
+
2975
+ /**
2976
+ * One stage attachment as it arrives from the REST API or the SSE stream,
2977
+ * before normalization: every field is optional and may be `null`.
2978
+ */
2979
+ export declare interface RawStageAttachment {
2980
+ /** Zero-based position in the attachment list. */
2981
+ index?: number | null;
2982
+ /** MIME type of the attachment content. */
2983
+ type?: string | null;
2984
+ /** Display name shown in the UI. */
2985
+ title?: string | null;
2986
+ /** Inline base-64 encoded content. */
2987
+ data?: string | null;
2988
+ /** Remote URL pointing to the attachment content. */
2989
+ url?: string | null;
2990
+ /** MIME type of the referenced resource. */
2991
+ reference_type?: string | null;
2992
+ /** URL of an alternate reference resource. */
2993
+ reference_url?: string | null;
2994
+ }
2995
+
2996
+ /**
2997
+ * Message-like payload carrying stages under either the wire's snake_case
2998
+ * `custom_content` or a host's camelCased `customContent`.
2999
+ */
3000
+ export declare interface RawStageSource {
3001
+ /** Custom content as the DIAL wire format spells it. */
3002
+ custom_content?: {
3003
+ stages?: RawStage[] | null;
3004
+ } | null;
3005
+ /** Custom content as a camelCasing host spells it. */
3006
+ customContent?: {
3007
+ stages?: RawStage[] | null;
3008
+ } | null;
3009
+ }
3010
+
2849
3011
  /**
2850
3012
  * Reads a skill file response as raw bytes, or `null` when the body is
2851
3013
  * larger than `SKILL_MANIFEST_MAX_BYTES`. The declared `content-length` is
@@ -2856,6 +3018,24 @@ export declare interface QuickAppSchemaLike {
2856
3018
  */
2857
3019
  export declare const readSkillFileBytes: (response: Response) => Promise<Uint8Array | null>;
2858
3020
 
3021
+ /**
3022
+ * Reads a skill file response as raw bytes with no size ceiling, for the
3023
+ * supporting-file **preview** path.
3024
+ *
3025
+ * Previews are user-initiated, one file at a time, and a realistic binary
3026
+ * (a PDF, an image) routinely exceeds `SKILL_MANIFEST_MAX_BYTES` — a cap
3027
+ * sized for `SKILL.md` frontmatter, not for binaries — so applying that cap
3028
+ * here rejected virtually every real PDF before it was ever decoded. This
3029
+ * reader therefore never returns `null`: file size is not a failure class on
3030
+ * the preview path.
3031
+ *
3032
+ * `readSkillFileBytes` and `readSkillManifest` keep their
3033
+ * `SKILL_MANIFEST_MAX_BYTES` ceiling, because they feed the manifest parse
3034
+ * and the textual Content-tab read, where an oversized body must never be
3035
+ * decoded into a string.
3036
+ */
3037
+ export declare const readSkillFilePreviewBytes: (response: Response) => Promise<Uint8Array>;
3038
+
2859
3039
  /**
2860
3040
  * Reads a skill manifest response as text, or `null` when the body is larger
2861
3041
  * than `SKILL_MANIFEST_MAX_BYTES`. The size is checked before decoding, so an
@@ -2920,7 +3100,8 @@ export declare const resolveCatalogPrimaryAction: (item: CatalogItem, fetchPromp
2920
3100
  /** Resolves a syntax-highlighted code canvas content payload from a DisplayAttachment, or `null` if unavailable. */
2921
3101
  export declare const resolveCodeCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers, language?: string) => Promise<CodeCanvasContent | ErrorCanvasContent | null>;
2922
3102
 
2923
- export declare const resolveDeploymentFolder: (deployment: Pick<DeploymentItemDto, "isMy" | "sharedWithMe" | "applicationFolder">, labels: DeploymentFolderLabels) => string[];
3103
+ /** Resolves a deployment's display folder, including organization applications without a folder path. */
3104
+ export declare const resolveDeploymentFolder: (deployment: Pick<DeploymentItemDto, "isMy" | "sharedWithMe" | "applicationFolder"> & Partial<Pick<DeploymentItemDto, "type">>, labels: DeploymentFolderLabels) => string[];
2924
3105
 
2925
3106
  /**
2926
3107
  * Resolves a DialFile to the bucket-relative API path used by files BFF endpoints.
@@ -2956,6 +3137,17 @@ export declare type ResolveDownloadUrl = (fileId: string) => string | undefined;
2956
3137
  */
2957
3138
  export declare const resolveExternalSourceContentType: (contentType: string, url: string) => string;
2958
3139
 
3140
+ /**
3141
+ * Builds the grouped payload for an application-scoped visualizer from the
3142
+ * attachments its entry claims, reporting which of them `resolveAbsoluteUrl`
3143
+ * could produce a URL for. Unlike the single-attachment resolver this fetches
3144
+ * nothing: the grouped protocol hands the visualizer URLs and lets it read
3145
+ * them itself, so the URLs must be absolute — a host-relative path would
3146
+ * resolve against the iframe's own origin. Producing one is host knowledge,
3147
+ * which is why it arrives as a callback rather than being built here.
3148
+ */
3149
+ export declare const resolveGroupedVisualizerCanvasContent: (attachments: DisplayAttachment[], resolveAbsoluteUrl: (attachment: DisplayAttachment) => string | undefined, entry: ApplicationVisualizer, themeId: string) => GroupedVisualizerResolution;
3150
+
2959
3151
  /**
2960
3152
  * Resolves an HTML canvas content payload from a DisplayAttachment.
2961
3153
  * Fetches and inlines the HTML as `srcdoc` when the attachment has a download URL or inline data.
@@ -2966,10 +3158,12 @@ export declare const resolveHtmlCanvasContent: (attachment: DisplayAttachment, r
2966
3158
 
2967
3159
  /**
2968
3160
  * Resolves an image canvas content payload from a DisplayAttachment without
2969
- * fetching — returns the BFF download URL (or a local/inline blob URL)
2970
- * directly so the browser cache can be shared with the conversation view's
2971
- * `<img>` element. Error detection is delegated to `<img onError>` in the
2972
- * canvas renderer. Returns `null` if no URL source is available.
3161
+ * fetching — returns a local blob URL or the BFF download URL directly so the
3162
+ * browser cache can be shared with the conversation view's `<img>` element.
3163
+ * A local `File` with bytes takes precedence over the DIAL download URL; a
3164
+ * 0-byte `File` (the file-manager placeholder) does not. Error detection is
3165
+ * delegated to `<img onError>` in the canvas renderer. Returns `null` if no
3166
+ * URL source is available.
2973
3167
  */
2974
3168
  export declare const resolveImageCanvasContent: (attachment: DisplayAttachment, resolvers: AttachmentCanvasUrlResolvers) => ImageCanvasContent | null;
2975
3169
 
@@ -3175,6 +3369,12 @@ export declare interface SkillDetailsApi {
3175
3369
  limit?: number;
3176
3370
  recursive?: boolean;
3177
3371
  }, signal?: AbortSignal): Promise<SkillFileListResponseDto>;
3372
+ /**
3373
+ * Fetches a single skill's own authoritative metadata (`author`,
3374
+ * `updatedAt`, and the rest of `SkillMetadataItemDto`) — not the catalog
3375
+ * listing entry, which may be sparse for a shared skill.
3376
+ */
3377
+ getSkillMetadata(bucket: string, path: string, signal?: AbortSignal): Promise<SkillMetadataItemDto>;
3178
3378
  }
3179
3379
 
3180
3380
  /** Already-configured DIAL Core download operations `useSkillEditorLoad` needs. */
@@ -3749,6 +3949,13 @@ export declare const toPublishEntityType: (type: CatalogEntityType) => CatalogPu
3749
3949
  */
3750
3950
  export declare const toPublishRuleDto: (rule: PublicationRule) => PublishRuleDto;
3751
3951
 
3952
+ /**
3953
+ * Returns a renderable `Stage` for one raw payload: `index` defaults to `0`,
3954
+ * `name` to `''`, an unrecognized `status` to `null` (still running), and
3955
+ * `content`/`tag`/`attachments` are passed through when present.
3956
+ */
3957
+ export declare const toStage: (stage: RawStage) => Stage;
3958
+
3752
3959
  /** Request shape the host's selected-deployment recognition call accepts. */
3753
3960
  export declare interface TranscribeWithDeploymentParams {
3754
3961
  audioUrl: string;
@@ -3891,8 +4098,8 @@ export declare const useAttachmentUpload: ({ filesApi, bucket, onNetworkError, d
3891
4098
 
3892
4099
  /** Parameters for {@link useAttachmentUpload}. */
3893
4100
  export declare interface UseAttachmentUploadParams {
3894
- /** Already-configured generated-client instance used to upload the file. */
3895
- filesApi: Pick<FilesApi, 'uploadFile'>;
4101
+ /** Already-configured client; optional listing skips stored names after a conflict. */
4102
+ filesApi: Pick<FilesApi, 'uploadFile'> & Partial<Pick<FilesApi, 'listFiles'>>;
3896
4103
  /** DIAL Core bucket the file is uploaded into. */
3897
4104
  bucket: string | undefined;
3898
4105
  /** Called with batched filenames after a burst of network-error upload failures. */
@@ -5473,10 +5680,11 @@ export declare interface UseSkillFilePreviewResult {
5473
5680
 
5474
5681
  /**
5475
5682
  * Headless hook that encapsulates skill detail fetching: manifest download and
5476
- * parse, package file listing, overview construction, and in-package file
5477
- * loads. `useCatalogItemDetails` delegates its skill branch here; hosts that
5478
- * only surface skill details consume this hook directly, without the
5479
- * deployment and prompt ports the full catalog pipeline requires.
5683
+ * parse, package file listing, authoritative metadata fetching, overview
5684
+ * construction, and in-package file loads. `useCatalogItemDetails` delegates
5685
+ * its skill branch here; hosts that only surface skill details consume this
5686
+ * hook directly, without the deployment and prompt ports the full catalog
5687
+ * pipeline requires.
5480
5688
  */
5481
5689
  export declare const useSkillItemDetails: ({ api, skills, skillOverviewLabels, }: UseSkillItemDetailsOptions) => UseSkillItemDetailsResult;
5482
5690