@smart-cloud/ai-kit-ui 1.5.21 → 1.5.23

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.
@@ -0,0 +1,93 @@
1
+ import { type ProcessedCitations, type PromptResult } 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
+ activities: ChatActivity[];
27
+ citations: StreamCitation[];
28
+ checkpoint?: ChatStreamCheckpoint;
29
+ };
30
+ export type StreamCitation = {
31
+ citationId: string;
32
+ docId?: string;
33
+ chunkId?: string;
34
+ title?: string;
35
+ sourceUrl?: string;
36
+ snippet?: string;
37
+ };
38
+ export type ChatStreamResult = {
39
+ result: string;
40
+ sessionId: string;
41
+ messageId?: string;
42
+ citations?: ProcessedCitations | StreamCitation[];
43
+ metadata?: PromptResult["metadata"];
44
+ completion: "complete" | "partial" | "truncated";
45
+ };
46
+ type StreamTicket = {
47
+ ticket: string;
48
+ expiresAt: string;
49
+ sessionId: string;
50
+ };
51
+ export type ChatStreamOptions = {
52
+ url: string;
53
+ text: string;
54
+ locale: string;
55
+ sessionId?: string;
56
+ requestId: string;
57
+ resume?: ChatStreamCheckpoint;
58
+ initialView?: ChatStreamView;
59
+ signal: AbortSignal;
60
+ onView: (view: ChatStreamView) => void;
61
+ onAccepted?: (checkpoint: ChatStreamCheckpoint, sessionId: string) => void;
62
+ onSession?: (sessionId: string) => void;
63
+ onSocket?: (socket: WebSocket | null) => void;
64
+ onTransportState?: (state: "sending" | "waiting" | "receiving" | "reconnecting") => void;
65
+ /** Transport seams used by deterministic replay tests. */
66
+ ticketProvider?: (sessionId: string | undefined, signal: AbortSignal) => Promise<StreamTicket>;
67
+ socketFactory?: (url: string) => WebSocket;
68
+ retryDelayMs?: number;
69
+ };
70
+ export declare class ChatStreamError extends Error {
71
+ readonly code: string;
72
+ readonly retryable: boolean;
73
+ readonly status?: number;
74
+ readonly requestId?: string;
75
+ constructor(message: string, code: string, retryable?: boolean, status?: number, requestId?: string);
76
+ }
77
+ export declare function isToolActivity(activity: ChatActivity): boolean;
78
+ /** An unnamed successful internal operation is not useful visitor-facing history. */
79
+ export declare function isSummaryActivity(activity: ChatActivity): boolean;
80
+ export declare function summarizeChatActivities(activities: ChatActivity[]): {
81
+ knowledgeSearches: number;
82
+ websites: number;
83
+ otherTools: number;
84
+ };
85
+ /** The backend advertises streaming only when its WebSocket route is ready. */
86
+ export declare function discoverChatStreamUrl(): Promise<string | undefined>;
87
+ export declare function sendChatStreamCancel(socket: WebSocket | null, checkpoint: ChatStreamCheckpoint | undefined): void;
88
+ /**
89
+ * The ticket is single use and short lived. Reconnect requests a fresh ticket
90
+ * and replays from the last acknowledged sequence, never starting a new turn.
91
+ */
92
+ export declare function runChatStreamTurn(options: ChatStreamOptions): Promise<ChatStreamResult>;
93
+ export {};
@@ -3,6 +3,7 @@ export type CitationLike = {
3
3
  url?: string;
4
4
  sourceUrl?: string;
5
5
  title?: string;
6
+ description?: string;
6
7
  snippet?: string;
7
8
  };
8
9
  type CitationPayload = ProcessedCitations | CitationLike[] | undefined;
@@ -187,6 +187,15 @@
187
187
  font-family: var(--ai-kit-font-family);
188
188
  }
189
189
 
190
+ /* Keep muted copy legible on dark surfaces, including the expanded chat trace.
191
+ The light-theme value above remains the default. */
192
+ :host([data-mantine-color-scheme="dark"]),
193
+ #ai-kit-inline-root[data-mantine-color-scheme="dark"],
194
+ #ai-kit-portal-root[data-mantine-color-scheme="dark"],
195
+ [data-ai-kit-theme="dark"] {
196
+ --ai-kit-color-text-muted: rgba(235, 240, 248, 0.72);
197
+ }
198
+
190
199
  /* Variation defaults */
191
200
  :host[data-ai-kit-variation="default"] {
192
201
  --ai-kit-background-color: transparent;
@@ -760,6 +769,20 @@
760
769
  margin: 0;
761
770
  }
762
771
 
772
+ .ai-chat-bubble.typing.waiting {
773
+ min-width: min(260px, 80vw);
774
+ }
775
+
776
+ .ai-chat-waiting-label {
777
+ font-size: inherit;
778
+ line-height: inherit;
779
+ color: inherit;
780
+ max-width: 100%;
781
+ white-space: nowrap;
782
+ overflow: hidden;
783
+ text-overflow: ellipsis;
784
+ }
785
+
763
786
  .ai-chat-row.user .ai-chat-bubble {
764
787
  background: var(--ai-kit-user-bubble-bg);
765
788
  color: var(--ai-kit-user-bubble-color);
@@ -859,6 +882,81 @@
859
882
  margin: 4px 0 0;
860
883
  }
861
884
 
885
+ .ai-chat-activity-trace {
886
+ max-width: min(600px, 100%);
887
+ margin-top: var(--ai-kit-space-2);
888
+ padding: 6px 10px;
889
+ border: 1px solid var(--ai-kit-color-border, #d7dce3);
890
+ border-radius: 10px;
891
+ color: var(--ai-kit-color-text-muted, var(--ai-kit-color-text));
892
+ font-size: 0.8rem;
893
+ }
894
+
895
+ .ai-chat-activity-trace summary {
896
+ cursor: pointer;
897
+ overflow-wrap: anywhere;
898
+ }
899
+
900
+ .ai-status-text svg,
901
+ .ai-chat-activity-trace summary svg {
902
+ margin-right: 6px;
903
+ vertical-align: text-bottom;
904
+ }
905
+
906
+ .ai-chat-activity-detail,
907
+ .ai-chat-activity-urls {
908
+ margin-top: 4px;
909
+ overflow-wrap: anywhere;
910
+ }
911
+
912
+ .ai-chat-activity-detail:empty {
913
+ display: none;
914
+ }
915
+
916
+ .ai-chat-activity-urls {
917
+ padding-left: 18px;
918
+ }
919
+
920
+ .ai-chat-activity-trace ol {
921
+ display: grid;
922
+ gap: 5px;
923
+ padding-left: 18px;
924
+ margin: 6px 0 0;
925
+ }
926
+
927
+ .ai-chat-activity-trace li {
928
+ padding-left: 2px;
929
+ }
930
+
931
+ .ai-chat-activity-trace li svg {
932
+ margin-right: 6px;
933
+ vertical-align: text-bottom;
934
+ }
935
+
936
+ .ai-chat-activity-trace li[data-status="failed"] {
937
+ color: var(--ai-kit-color-danger);
938
+ }
939
+
940
+ .ai-chat-site-icons {
941
+ display: inline-flex;
942
+ gap: 3px;
943
+ margin-left: 8px;
944
+ vertical-align: middle;
945
+ }
946
+
947
+ .ai-chat-site-icon {
948
+ position: relative;
949
+ display: inline-grid;
950
+ width: 18px;
951
+ height: 18px;
952
+ place-items: center;
953
+ overflow: hidden;
954
+ border-radius: 50%;
955
+ background: var(--ai-kit-color-surface, #e8edf3);
956
+ font-size: 10px;
957
+ font-weight: 600;
958
+ }
959
+
862
960
  .ai-status-text {
863
961
  font-size: 0.85rem;
864
962
  color: var(--ai-kit-color-text);