@smart-cloud/ai-kit-ui 1.5.20 → 1.5.22

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;
@@ -760,6 +760,20 @@
760
760
  margin: 0;
761
761
  }
762
762
 
763
+ .ai-chat-bubble.typing.waiting {
764
+ min-width: min(260px, 80vw);
765
+ }
766
+
767
+ .ai-chat-waiting-label {
768
+ font-size: inherit;
769
+ line-height: inherit;
770
+ color: inherit;
771
+ max-width: 100%;
772
+ white-space: nowrap;
773
+ overflow: hidden;
774
+ text-overflow: ellipsis;
775
+ }
776
+
763
777
  .ai-chat-row.user .ai-chat-bubble {
764
778
  background: var(--ai-kit-user-bubble-bg);
765
779
  color: var(--ai-kit-user-bubble-color);
@@ -859,6 +873,81 @@
859
873
  margin: 4px 0 0;
860
874
  }
861
875
 
876
+ .ai-chat-activity-trace {
877
+ max-width: min(600px, 100%);
878
+ margin-top: var(--ai-kit-space-2);
879
+ padding: 6px 10px;
880
+ border: 1px solid var(--ai-kit-color-border, #d7dce3);
881
+ border-radius: 10px;
882
+ color: var(--ai-kit-color-text-muted, var(--ai-kit-color-text));
883
+ font-size: 0.8rem;
884
+ }
885
+
886
+ .ai-chat-activity-trace summary {
887
+ cursor: pointer;
888
+ overflow-wrap: anywhere;
889
+ }
890
+
891
+ .ai-status-text svg,
892
+ .ai-chat-activity-trace summary svg {
893
+ margin-right: 6px;
894
+ vertical-align: text-bottom;
895
+ }
896
+
897
+ .ai-chat-activity-detail,
898
+ .ai-chat-activity-urls {
899
+ margin-top: 4px;
900
+ overflow-wrap: anywhere;
901
+ }
902
+
903
+ .ai-chat-activity-detail:empty {
904
+ display: none;
905
+ }
906
+
907
+ .ai-chat-activity-urls {
908
+ padding-left: 18px;
909
+ }
910
+
911
+ .ai-chat-activity-trace ol {
912
+ display: grid;
913
+ gap: 5px;
914
+ padding-left: 18px;
915
+ margin: 6px 0 0;
916
+ }
917
+
918
+ .ai-chat-activity-trace li {
919
+ padding-left: 2px;
920
+ }
921
+
922
+ .ai-chat-activity-trace li svg {
923
+ margin-right: 6px;
924
+ vertical-align: text-bottom;
925
+ }
926
+
927
+ .ai-chat-activity-trace li[data-status="failed"] {
928
+ color: var(--ai-kit-color-danger);
929
+ }
930
+
931
+ .ai-chat-site-icons {
932
+ display: inline-flex;
933
+ gap: 3px;
934
+ margin-left: 8px;
935
+ vertical-align: middle;
936
+ }
937
+
938
+ .ai-chat-site-icon {
939
+ position: relative;
940
+ display: inline-grid;
941
+ width: 18px;
942
+ height: 18px;
943
+ place-items: center;
944
+ overflow: hidden;
945
+ border-radius: 50%;
946
+ background: var(--ai-kit-color-surface, #e8edf3);
947
+ font-size: 10px;
948
+ font-weight: 600;
949
+ }
950
+
862
951
  .ai-status-text {
863
952
  font-size: 0.85rem;
864
953
  color: var(--ai-kit-color-text);