@smart-cloud/ai-kit-ui 1.5.30 → 1.5.32

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.
Files changed (53) hide show
  1. package/dist/LocaleDirectionProvider.d.ts +5 -0
  2. package/dist/ShadowBoundary.d.ts +31 -0
  3. package/dist/ai-chatbot/AiChatbot.d.ts +18 -0
  4. package/dist/ai-chatbot/AnswerPresentation.d.ts +5 -0
  5. package/dist/ai-chatbot/activityPresentation.d.ts +4 -0
  6. package/dist/ai-chatbot/answer-presentation-state.d.ts +10 -0
  7. package/dist/ai-chatbot/attachmentStorage.d.ts +19 -0
  8. package/dist/ai-chatbot/chatStream.d.ts +95 -0
  9. package/dist/ai-chatbot/citations.d.ts +15 -0
  10. package/dist/ai-chatbot/index.d.ts +2 -0
  11. package/dist/ai-chatbot/welcome.d.ts +4 -0
  12. package/dist/ai-feature/AiFeature.d.ts +29 -0
  13. package/dist/ai-feature/AiFeatureBorder.d.ts +5 -0
  14. package/dist/ai-feature/ProofreadDiff.d.ts +13 -0
  15. package/dist/ai-feature/index.d.ts +2 -0
  16. package/dist/ai-feature/utils.d.ts +1 -0
  17. package/dist/doc-search/DocSearch.d.ts +22 -0
  18. package/dist/doc-search/index.d.ts +1 -0
  19. package/dist/doc-search/initialFilters.d.ts +1 -0
  20. package/dist/doc-search/localizedOptions.d.ts +6 -0
  21. package/dist/errorHandling.d.ts +24 -0
  22. package/dist/i18n/ar.d.ts +1 -0
  23. package/dist/i18n/de.d.ts +1 -0
  24. package/dist/i18n/en.d.ts +1 -0
  25. package/dist/i18n/es.d.ts +1 -0
  26. package/dist/i18n/fr.d.ts +1 -0
  27. package/dist/i18n/he.d.ts +1 -0
  28. package/dist/i18n/hi.d.ts +1 -0
  29. package/dist/i18n/hu.d.ts +1 -0
  30. package/dist/i18n/id.d.ts +1 -0
  31. package/dist/i18n/index.d.ts +1 -0
  32. package/dist/i18n/it.d.ts +1 -0
  33. package/dist/i18n/ja.d.ts +1 -0
  34. package/dist/i18n/ko.d.ts +1 -0
  35. package/dist/i18n/nb.d.ts +1 -0
  36. package/dist/i18n/nl.d.ts +1 -0
  37. package/dist/i18n/pl.d.ts +1 -0
  38. package/dist/i18n/pt.d.ts +1 -0
  39. package/dist/i18n/ru.d.ts +1 -0
  40. package/dist/i18n/sv.d.ts +1 -0
  41. package/dist/i18n/th.d.ts +1 -0
  42. package/dist/i18n/tr.d.ts +1 -0
  43. package/dist/i18n/ua.d.ts +1 -0
  44. package/dist/i18n/zh.d.ts +1 -0
  45. package/dist/index.cjs +11 -11
  46. package/dist/index.d.ts +7 -0
  47. package/dist/index.js +11 -11
  48. package/dist/locale.d.ts +13 -0
  49. package/dist/poweredBy.d.ts +4 -0
  50. package/dist/shared/citation-display.d.ts +4 -0
  51. package/dist/useAiRun.d.ts +40 -0
  52. package/dist/withAiKitShell.d.ts +14 -0
  53. package/package.json +6 -6
@@ -0,0 +1,5 @@
1
+ import { type PropsWithChildren } from "react";
2
+ /** Controlled per-root direction: never reads or changes documentElement.dir. */
3
+ export declare function LocaleDirectionProvider({ initialDirection, children }: PropsWithChildren<{
4
+ initialDirection?: "ltr" | "rtl";
5
+ }>): import("react").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { SetStateAction } from "react";
2
+ export type ShadowBoundaryMode = "local" | "overlay";
3
+ export type ShadowBoundaryProps = {
4
+ /** Stylesheets to inject into the shadow root (as <link rel="stylesheet">). */
5
+ stylesheets: string[];
6
+ /** ID of the element inside the shadow root used as the portal target. */
7
+ rootElementId: string;
8
+ /** Variation of the shadow boundary behavior. */
9
+ variation?: "default" | "modal";
10
+ /**
11
+ * Where to create the shadow root:
12
+ * - "local": attach shadow to this component's host element (keeps layout positioning).
13
+ * - "overlay": attach shadow to a singleton element in top (or self) document (always on top).
14
+ */
15
+ mode?: ShadowBoundaryMode;
16
+ /**
17
+ * For mode="overlay": host id in the top (or self) document.
18
+ * Same id everywhere => singleton overlay host.
19
+ */
20
+ overlayRootId?: string;
21
+ setHost: React.Dispatch<SetStateAction<HTMLElement | null>>;
22
+ /** Optional notification for consumers that need a distinct modal portal. */
23
+ setRootElement?: React.Dispatch<SetStateAction<HTMLDivElement | null>>;
24
+ children: (api: {
25
+ /** Portal target element inside the shadow root. */
26
+ rootElement: HTMLDivElement;
27
+ /** Shadow root instance. */
28
+ shadowRoot: ShadowRoot;
29
+ }) => React.ReactNode;
30
+ };
31
+ export declare function ShadowBoundary({ stylesheets, children, rootElementId, mode, overlayRootId, setHost, setRootElement, }: ShadowBoundaryProps): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { type AiChatbotLabels, type HistoryStorageMode } from "@smart-cloud/ai-kit-core";
2
+ import React from "react";
3
+ export declare const DEFAULT_CHATBOT_LABELS: Required<AiChatbotLabels>;
4
+ export declare const AiChatbot: React.FC<import("@smart-cloud/ai-kit-core").AiWorkerProps & {
5
+ context?: import("@smart-cloud/ai-kit-core").ContextKind;
6
+ placeholder?: string;
7
+ greeting?: string;
8
+ starterQuestions?: string[];
9
+ maxImages?: number;
10
+ maxImageBytes?: number;
11
+ maxTokens?: number;
12
+ previewMode?: boolean;
13
+ historyStorage?: HistoryStorageMode;
14
+ emptyHistoryAfterDays?: number;
15
+ labels?: AiChatbotLabels;
16
+ openButtonIconLayout?: import("@smart-cloud/ai-kit-core").OpenButtonIconLayout;
17
+ openButtonPosition?: import("@smart-cloud/ai-kit-core").OpenButtonPosition;
18
+ } & Partial<import("@smart-cloud/ai-kit-core").AiWorkerProps>>;
@@ -0,0 +1,5 @@
1
+ import type { AnswerPresentation } from "@smart-cloud/ai-kit-core";
2
+ /** The same source-independent layouts render approved REST, MCP and CPT data. */
3
+ export declare function AnswerPresentationView({ presentation }: {
4
+ presentation?: AnswerPresentation;
5
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,4 @@
1
+ import type { ChatActivity } from "./chatStream";
2
+ export declare function safePublicActivityParams(value: unknown): Record<string, string> | undefined;
3
+ export declare function publicToolActivityLabel(activity: ChatActivity, translate: (key: string) => string, settled?: boolean): string | null;
4
+ export declare function publicToolActivityDetails(activity: ChatActivity): string | null;
@@ -0,0 +1,10 @@
1
+ import { type AnswerEntity, type AnswerPresentation } from "@smart-cloud/ai-kit-core";
2
+ /** Browser storage and transport values are untrusted, including old history. */
3
+ export declare function normalizeAnswerPresentation(value: unknown): AnswerPresentation | undefined;
4
+ export declare function answerAttributeText(attribute: AnswerEntity["attributes"][number]): string;
5
+ /** Retain only a validated envelope when crossing a history boundary. */
6
+ export declare function withSafeAnswerPresentation<T extends {
7
+ presentation?: unknown;
8
+ }>(value: T): Omit<T, "presentation"> & {
9
+ presentation?: AnswerPresentation;
10
+ };
@@ -0,0 +1,19 @@
1
+ export type StoredAttachment = {
2
+ id: string;
3
+ name: string;
4
+ type: string;
5
+ size: number;
6
+ blob: Blob;
7
+ createdAt: number;
8
+ };
9
+ export declare function persistAttachmentBlob(id: string, blob: Blob, meta: {
10
+ name: string;
11
+ type: string;
12
+ size: number;
13
+ }): Promise<string | null>;
14
+ export declare function loadAttachmentBlob(id: string): Promise<StoredAttachment | null>;
15
+ export declare function deleteAttachmentBlob(id: string): Promise<void>;
16
+ export declare function clearAllAttachments(): Promise<void>;
17
+ export declare function cleanupDanglingAttachments(validIds: Set<string>): Promise<void>;
18
+ export declare function getAllAttachments(): Promise<StoredAttachment[]>;
19
+ export declare function enforceStorageQuota(): Promise<void>;
@@ -0,0 +1,95 @@
1
+ import { type ProcessedCitations, type PromptResult, type AnswerPresentation } from "@smart-cloud/ai-kit-core";
2
+ export type ChatActivity = {
3
+ activityId: string;
4
+ kind: "knowledge_search" | "web_search" | "web_read" | "calculation" | "script" | "validation" | "thinking" | "generating_response" | "checking_sources" | "other";
5
+ labelKey: string;
6
+ labelParams?: Record<string, string | number>;
7
+ safeDomain?: string;
8
+ safeDomains?: string[];
9
+ query?: string;
10
+ categoryCount?: number;
11
+ subcategoryCount?: number;
12
+ tagCount?: number;
13
+ resultCount?: number;
14
+ urls?: string[];
15
+ status: "running" | "completed" | "failed";
16
+ };
17
+ export type ChatStreamCheckpoint = {
18
+ requestId: string;
19
+ conversationId: string;
20
+ turnId: string;
21
+ lastSeq: number;
22
+ assistantMessageId?: string;
23
+ };
24
+ export type ChatStreamView = {
25
+ text: string;
26
+ presentation?: AnswerPresentation;
27
+ activities: ChatActivity[];
28
+ citations: StreamCitation[];
29
+ checkpoint?: ChatStreamCheckpoint;
30
+ };
31
+ export type StreamCitation = {
32
+ citationId: string;
33
+ docId?: string;
34
+ chunkId?: string;
35
+ title?: string;
36
+ sourceUrl?: string;
37
+ snippet?: string;
38
+ };
39
+ export type ChatStreamResult = {
40
+ result: string;
41
+ presentation?: AnswerPresentation;
42
+ sessionId: string;
43
+ messageId?: string;
44
+ citations?: ProcessedCitations | StreamCitation[];
45
+ metadata?: PromptResult["metadata"];
46
+ completion: "complete" | "partial" | "truncated";
47
+ };
48
+ type StreamTicket = {
49
+ ticket: string;
50
+ expiresAt: string;
51
+ sessionId: string;
52
+ };
53
+ export type ChatStreamOptions = {
54
+ url: string;
55
+ text: string;
56
+ locale: string;
57
+ sessionId?: string;
58
+ requestId: string;
59
+ resume?: ChatStreamCheckpoint;
60
+ initialView?: ChatStreamView;
61
+ signal: AbortSignal;
62
+ onView: (view: ChatStreamView) => void;
63
+ onAccepted?: (checkpoint: ChatStreamCheckpoint, sessionId: string) => void;
64
+ onSession?: (sessionId: string) => void;
65
+ onSocket?: (socket: WebSocket | null) => void;
66
+ onTransportState?: (state: "sending" | "waiting" | "receiving" | "reconnecting") => void;
67
+ /** Transport seams used by deterministic replay tests. */
68
+ ticketProvider?: (sessionId: string | undefined, signal: AbortSignal) => Promise<StreamTicket>;
69
+ socketFactory?: (url: string) => WebSocket;
70
+ retryDelayMs?: number;
71
+ };
72
+ export declare class ChatStreamError extends Error {
73
+ readonly code: string;
74
+ readonly retryable: boolean;
75
+ readonly status?: number;
76
+ readonly requestId?: string;
77
+ constructor(message: string, code: string, retryable?: boolean, status?: number, requestId?: string);
78
+ }
79
+ export declare function isToolActivity(activity: ChatActivity): boolean;
80
+ /** An unnamed successful internal operation is not useful visitor-facing history. */
81
+ export declare function isSummaryActivity(activity: ChatActivity): boolean;
82
+ export declare function summarizeChatActivities(activities: ChatActivity[]): {
83
+ knowledgeSearches: number;
84
+ websites: number;
85
+ otherTools: number;
86
+ };
87
+ /** The backend advertises streaming only when its WebSocket route is ready. */
88
+ export declare function discoverChatStreamUrl(): Promise<string | undefined>;
89
+ export declare function sendChatStreamCancel(socket: WebSocket | null, checkpoint: ChatStreamCheckpoint | undefined): void;
90
+ /**
91
+ * The ticket is single use and short lived. Reconnect requests a fresh ticket
92
+ * and replays from the last acknowledged sequence, never starting a new turn.
93
+ */
94
+ export declare function runChatStreamTurn(options: ChatStreamOptions): Promise<ChatStreamResult>;
95
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ProcessedCitations } from "@smart-cloud/ai-kit-core";
2
+ export type CitationLike = {
3
+ url?: string;
4
+ sourceUrl?: string;
5
+ title?: string;
6
+ description?: string;
7
+ snippet?: string;
8
+ };
9
+ type CitationPayload = ProcessedCitations | CitationLike[] | undefined;
10
+ /**
11
+ * Normalize both the current structured citation response and the legacy flat
12
+ * response used by older backends during rolling upgrades.
13
+ */
14
+ export declare function normalizeChatCitations(citations: CitationPayload): CitationLike[] | undefined;
15
+ export {};
@@ -0,0 +1,2 @@
1
+ export { AiChatbot, DEFAULT_CHATBOT_LABELS } from "./AiChatbot";
2
+ export { AnswerPresentationView } from "./AnswerPresentation";
@@ -0,0 +1,4 @@
1
+ export declare function resolveChatWelcome(greeting: string | undefined, starterQuestions: string[] | undefined, translate: (text: string) => string): {
2
+ greeting: string;
3
+ questions: string[];
4
+ };
@@ -0,0 +1,29 @@
1
+ import { type AiModePreference } from "@smart-cloud/ai-kit-core";
2
+ import { FC } from "react";
3
+ export declare const AiFeature: FC<import("@smart-cloud/ai-kit-core").AiWorkerProps & {
4
+ mode: import("@smart-cloud/ai-kit-core").AiFeatureMode;
5
+ context?: import("@smart-cloud/ai-kit-core").ContextKind;
6
+ modeOverride?: AiModePreference;
7
+ autoRun?: boolean;
8
+ showLanguageSwitcher?: boolean;
9
+ onDeviceTimeout?: number;
10
+ editable?: boolean;
11
+ acceptButtonTitle?: string;
12
+ showRegenerateOnBackendButton?: boolean;
13
+ optionsDisplay?: "collapse" | "horizontal" | "vertical";
14
+ default?: import("@smart-cloud/ai-kit-core").AiFeatureOptions & {
15
+ getText?: Promise<string> | (() => Promise<string>);
16
+ image?: Blob;
17
+ };
18
+ allowOverride?: {
19
+ text?: boolean;
20
+ instructions?: boolean;
21
+ tone?: boolean;
22
+ length?: boolean;
23
+ type?: boolean;
24
+ outputLanguage?: boolean;
25
+ outputFormat?: boolean;
26
+ };
27
+ onAccept?: (result: unknown) => void;
28
+ onOptionsChanged?: (options: import("@smart-cloud/ai-kit-core").AiFeatureOptions) => void;
29
+ } & Partial<import("@smart-cloud/ai-kit-core").AiWorkerProps>>;
@@ -0,0 +1,5 @@
1
+ export declare function AiFeatureBorder({ enabled, working, variation, children, }: React.PropsWithChildren<{
2
+ enabled?: boolean;
3
+ working?: boolean;
4
+ variation?: string;
5
+ }>): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ export type Correction = {
2
+ startIndex: number;
3
+ endIndex: number;
4
+ correction?: string;
5
+ replacement?: string;
6
+ explanation?: string;
7
+ type?: string;
8
+ };
9
+ export type ProofreadDiffProps = {
10
+ original: string;
11
+ corrections: Correction[];
12
+ };
13
+ export declare function ProofreadDiff({ original, corrections }: ProofreadDiffProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { AiFeature } from "./AiFeature";
2
+ export { markdownToHtml } from "./utils";
@@ -0,0 +1 @@
1
+ export declare const markdownToHtml: (markdown: string) => Promise<string>;
@@ -0,0 +1,22 @@
1
+ import { type ContextKind } from "@smart-cloud/ai-kit-core";
2
+ import { FC } from "react";
3
+ export declare const DocSearch: FC<import("@smart-cloud/ai-kit-core").AiWorkerProps & {
4
+ context?: ContextKind;
5
+ autoRun?: boolean;
6
+ aiDisclosure?: string;
7
+ title?: string;
8
+ getSearchText?: () => string;
9
+ searchButtonIcon?: string;
10
+ showSearchButtonTitle?: boolean;
11
+ showSearchButtonIcon?: boolean;
12
+ showSources?: boolean;
13
+ topK?: number;
14
+ snippetMaxChars?: number;
15
+ onClickDoc?: (doc: import("@smart-cloud/ai-kit-core").RetrievedDoc) => void;
16
+ enableUserFilters?: boolean;
17
+ availableCategories?: Record<string, string[]>;
18
+ availableTags?: string[];
19
+ initialSelectedCategories?: string[];
20
+ initialSelectedSubcategories?: string[];
21
+ initialSelectedTags?: string[];
22
+ } & Partial<import("@smart-cloud/ai-kit-core").AiWorkerProps>>;
@@ -0,0 +1 @@
1
+ export { DocSearch } from "./DocSearch";
@@ -0,0 +1 @@
1
+ export declare const normalizeInitialFilterValues: (values: readonly string[] | undefined) => string[];
@@ -0,0 +1,6 @@
1
+ export interface LocalizedOption {
2
+ value: string;
3
+ label: string;
4
+ }
5
+ /** Keep canonical filter values while ordering options by their visible labels. */
6
+ export declare function buildLocalizedOptions(values: string[], translate: (value: string) => string, locale: string): LocalizedOption[];
@@ -0,0 +1,24 @@
1
+ export type AiRunErrorKind = "cancelled" | "human-verification" | "authorization" | "throttled" | "grounding" | "timeout" | "validation" | "network" | "server" | "general";
2
+ export type HumanVerificationClassification = "TOKEN_REJECTED" | "ACTION_REJECTED" | "RISK_REJECTED" | "PROVIDER_UNAVAILABLE";
3
+ export type AiRunErrorDetails = {
4
+ kind: AiRunErrorKind;
5
+ status?: number;
6
+ code?: string;
7
+ safeMessage?: string;
8
+ requestId?: string;
9
+ classification?: HumanVerificationClassification;
10
+ retryable?: boolean;
11
+ };
12
+ export type AiRunErrorFeedback = {
13
+ message: string | null;
14
+ details: AiRunErrorDetails | null;
15
+ };
16
+ export declare function isAiRunAbort(error: unknown): boolean;
17
+ export declare function normalizeAiRunError(error: unknown): AiRunErrorDetails;
18
+ export declare function getAiRunErrorMessage(details: AiRunErrorDetails, translate?: (message: string) => string): string;
19
+ export declare function clearAiRunErrorFeedback(): AiRunErrorFeedback;
20
+ export declare function createAiRunErrorFeedback(error: unknown, translate?: (message: string) => string): AiRunErrorFeedback;
21
+ export declare class AiRunError extends Error {
22
+ readonly details: AiRunErrorDetails;
23
+ constructor(details: AiRunErrorDetails, message?: string, options?: ErrorOptions);
24
+ }
@@ -0,0 +1 @@
1
+ export declare const arDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const deDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const enDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const esDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const frDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const heDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const hiDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const huDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const idDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const translations: Record<string, Record<string, string>>;
@@ -0,0 +1 @@
1
+ export declare const itDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const jaDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const koDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const nbDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const nlDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const plDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const ptDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const ruDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const svDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const thDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const trDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const uaDict: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const zhDict: Record<string, string>;