@agents24/chat-react 0.1.2 → 0.1.4
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/README.md +12 -3
- package/dist/index.cjs +388 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -22
- package/dist/index.d.ts +124 -22
- package/dist/index.js +370 -137
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactNode, RefObject, UIEvent } from 'react';
|
|
3
3
|
|
|
4
4
|
type ChatRunStatus = "queued" | "running" | "completed" | "cancelled" | "failed" | string;
|
|
5
5
|
type ChatContextWindow = {
|
|
@@ -35,30 +35,89 @@ type ChatReasoningStep = {
|
|
|
35
35
|
query?: string;
|
|
36
36
|
sources?: Array<Record<string, unknown>>;
|
|
37
37
|
};
|
|
38
|
-
type
|
|
39
|
-
type
|
|
40
|
-
|
|
38
|
+
type ChatToolState = "input-streaming" | "input-available" | "output-available" | "output-error" | "cancelled";
|
|
39
|
+
type ToolPresentation = {
|
|
40
|
+
title?: string | null;
|
|
41
|
+
activity?: string | null;
|
|
42
|
+
detail?: string | null;
|
|
43
|
+
category?: string | null;
|
|
44
|
+
groupKey?: string | null;
|
|
45
|
+
groupLabel?: string | null;
|
|
46
|
+
showOutput?: boolean;
|
|
47
|
+
outputView?: Record<string, unknown> | null;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
type ChatTextPart = {
|
|
41
51
|
id: string;
|
|
52
|
+
type: "text";
|
|
42
53
|
kind: "text";
|
|
43
|
-
|
|
54
|
+
text: string;
|
|
55
|
+
raw?: Record<string, unknown>;
|
|
44
56
|
};
|
|
45
|
-
type
|
|
57
|
+
type ChatToolPart = {
|
|
46
58
|
id: string;
|
|
59
|
+
type: `tool-${string}`;
|
|
47
60
|
kind: "tool";
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
toolName: string;
|
|
62
|
+
toolCallId?: string | null;
|
|
63
|
+
state: ChatToolState;
|
|
64
|
+
input?: unknown;
|
|
65
|
+
output?: unknown;
|
|
66
|
+
errorText?: string | null;
|
|
67
|
+
presentation?: ToolPresentation | null;
|
|
68
|
+
raw: Record<string, unknown>;
|
|
53
69
|
};
|
|
54
|
-
type
|
|
70
|
+
type ChatReasoningPart = {
|
|
55
71
|
id: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
type: "reasoning";
|
|
73
|
+
kind: "reasoning";
|
|
74
|
+
label?: string | null;
|
|
75
|
+
text?: string | null;
|
|
76
|
+
status?: string | null;
|
|
77
|
+
raw: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
type ChatUiBlocksPart = {
|
|
80
|
+
id: string;
|
|
81
|
+
type: "ui-blocks";
|
|
82
|
+
kind: "ui-blocks";
|
|
83
|
+
state: ChatToolState;
|
|
84
|
+
toolCallId?: string | null;
|
|
85
|
+
contractVersion?: string | null;
|
|
86
|
+
bundle?: Record<string, unknown> | null;
|
|
87
|
+
errorText?: string | null;
|
|
88
|
+
raw: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
type ChatApprovalPart = {
|
|
91
|
+
id: string;
|
|
92
|
+
type: "approval";
|
|
93
|
+
kind: "approval";
|
|
94
|
+
raw: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
type ChatErrorPart = {
|
|
97
|
+
id: string;
|
|
98
|
+
type: "error";
|
|
99
|
+
kind: "error";
|
|
100
|
+
errorText: string;
|
|
101
|
+
raw: Record<string, unknown>;
|
|
102
|
+
};
|
|
103
|
+
type ChatDataPart = {
|
|
104
|
+
id: string;
|
|
105
|
+
type: "data";
|
|
106
|
+
kind: "data";
|
|
107
|
+
name: string;
|
|
108
|
+
data: Record<string, unknown>;
|
|
109
|
+
raw: Record<string, unknown>;
|
|
110
|
+
};
|
|
111
|
+
type ChatPart = ChatTextPart | ChatToolPart | ChatReasoningPart | ChatUiBlocksPart | ChatApprovalPart | ChatErrorPart | ChatDataPart;
|
|
112
|
+
type ToolRenderer = (props: {
|
|
113
|
+
part: ChatToolPart;
|
|
114
|
+
message: ChatMessage;
|
|
115
|
+
}) => ReactNode;
|
|
116
|
+
type Agents24ChatRenderOptions = {
|
|
117
|
+
renderPart?: (part: ChatPart, message: ChatMessage) => ReactNode;
|
|
118
|
+
toolRenderers?: Partial<Record<`tool-${string}`, ToolRenderer>>;
|
|
119
|
+
fallbackToolRenderer?: ToolRenderer;
|
|
60
120
|
};
|
|
61
|
-
type ChatMessageBlock = ChatTextBlock | ChatToolBlock | ChatToolGroupBlock;
|
|
62
121
|
type ChatMessage = {
|
|
63
122
|
id: string;
|
|
64
123
|
role: "user" | "assistant";
|
|
@@ -66,7 +125,7 @@ type ChatMessage = {
|
|
|
66
125
|
content: string;
|
|
67
126
|
createdAt: Date;
|
|
68
127
|
isFinal?: boolean;
|
|
69
|
-
|
|
128
|
+
parts: ChatPart[];
|
|
70
129
|
attachments?: ChatAttachment[];
|
|
71
130
|
citations?: ChatCitation[];
|
|
72
131
|
reasoningSteps?: ChatReasoningStep[];
|
|
@@ -149,6 +208,7 @@ type ChatTransport = {
|
|
|
149
208
|
threadId: string;
|
|
150
209
|
limit?: number;
|
|
151
210
|
beforeTurnIndex?: number | null;
|
|
211
|
+
includeRunEvents?: boolean;
|
|
152
212
|
signal?: AbortSignal;
|
|
153
213
|
}) => Promise<ChatThreadDetail>;
|
|
154
214
|
streamMessage: (input: {
|
|
@@ -254,13 +314,15 @@ declare const titleFromMessage: (text: string, files?: Array<{
|
|
|
254
314
|
filename?: string;
|
|
255
315
|
}>) => string;
|
|
256
316
|
declare const threadActivityDate: (thread: ChatThreadSummary) => string;
|
|
257
|
-
declare const
|
|
317
|
+
declare const assistantTextFromResponseBlocks: (blocks?: Array<Record<string, unknown>>) => string;
|
|
318
|
+
declare const assistantTextFromParts: (parts?: ChatPart[]) => string;
|
|
258
319
|
declare const textFromFinalOutput: (value: unknown) => string;
|
|
259
|
-
declare const
|
|
320
|
+
declare const toolStateFromStatus: (status?: unknown) => ChatToolState;
|
|
321
|
+
declare const partsFromResponseBlocks: (blocks?: Array<Record<string, unknown>>, fallbackText?: string) => ChatPart[];
|
|
260
322
|
declare const mergeReasoningSteps: (steps?: ChatReasoningStep[], options?: {
|
|
261
323
|
finalize?: boolean;
|
|
262
324
|
}) => ChatReasoningStep[];
|
|
263
|
-
declare const
|
|
325
|
+
declare const reasoningStepsFromParts: (parts?: ChatPart[]) => ChatReasoningStep[];
|
|
264
326
|
declare const threadDetailToMessages: (thread: ChatThreadDetail) => ChatMessage[];
|
|
265
327
|
declare const threadPaging: (thread: ChatThreadDetail) => {
|
|
266
328
|
hasOlderTurns: boolean;
|
|
@@ -274,9 +336,43 @@ declare const hasStaleUnfinishedAssistantCache: (thread?: (Partial<ChatThreadSum
|
|
|
274
336
|
}) | null) => boolean;
|
|
275
337
|
declare const activeRunIdFromThreadDetail: (thread?: ChatThreadDetail | null) => string | null;
|
|
276
338
|
|
|
339
|
+
declare const DefaultToolPart: ({ part }: {
|
|
340
|
+
part: ChatToolPart;
|
|
341
|
+
}) => react.JSX.Element;
|
|
342
|
+
declare const DefaultChatPart: ({ part, message, renderOptions, }: {
|
|
343
|
+
part: ChatPart;
|
|
344
|
+
message: ChatMessage;
|
|
345
|
+
renderOptions?: Agents24ChatRenderOptions;
|
|
346
|
+
}) => react.JSX.Element;
|
|
347
|
+
declare const renderChatPart: (part: ChatPart, message: ChatMessage, renderOptions?: Agents24ChatRenderOptions) => react.JSX.Element;
|
|
348
|
+
|
|
277
349
|
declare const parseSseBlock: (block: string) => ChatRuntimeEvent | null;
|
|
278
350
|
declare const consumeSseResponse: (response: Response, onEvent: (event: ChatRuntimeEvent) => void | Promise<void>) => Promise<ChatStreamResult>;
|
|
279
351
|
|
|
352
|
+
type StreamingTextMode = "streaming" | "static";
|
|
353
|
+
type StreamingTextCache = {
|
|
354
|
+
get: (id: string) => string | undefined;
|
|
355
|
+
set: (id: string, text: string) => void;
|
|
356
|
+
};
|
|
357
|
+
type UseStreamingTextOptions = {
|
|
358
|
+
id: string;
|
|
359
|
+
isStreaming: boolean;
|
|
360
|
+
text: string;
|
|
361
|
+
cache?: StreamingTextCache | false;
|
|
362
|
+
charsPerSecond?: number;
|
|
363
|
+
catchupThreshold?: number;
|
|
364
|
+
maxCatchupChars?: number;
|
|
365
|
+
};
|
|
366
|
+
type UseStreamingTextResult = {
|
|
367
|
+
displayedText: string;
|
|
368
|
+
isAnimating: boolean;
|
|
369
|
+
mode: StreamingTextMode;
|
|
370
|
+
parseIncompleteMarkdown: boolean;
|
|
371
|
+
};
|
|
372
|
+
declare const getActiveStreamingTextPartId: (message: ChatMessage, streamingMessageId: string | null) => string | null;
|
|
373
|
+
declare const isActiveStreamingTextPart: (message: ChatMessage, part: ChatPart, streamingMessageId: string | null) => boolean;
|
|
374
|
+
declare function useStreamingText({ id, isStreaming, text, cache, charsPerSecond, catchupThreshold, maxCatchupChars, }: UseStreamingTextOptions): UseStreamingTextResult;
|
|
375
|
+
|
|
280
376
|
type MaybePromise<T> = T | Promise<T>;
|
|
281
377
|
type FetchChatTransportRoutes = {
|
|
282
378
|
listThreads: () => string;
|
|
@@ -284,6 +380,7 @@ type FetchChatTransportRoutes = {
|
|
|
284
380
|
threadId: string;
|
|
285
381
|
limit?: number;
|
|
286
382
|
beforeTurnIndex?: number | null;
|
|
383
|
+
includeRunEvents?: boolean;
|
|
287
384
|
}) => string;
|
|
288
385
|
streamMessage: () => string;
|
|
289
386
|
attachRun: (input: {
|
|
@@ -312,6 +409,11 @@ declare const isScrollable: (element: Pick<HTMLDivElement, "scrollHeight" | "cli
|
|
|
312
409
|
declare const isAtTimelineLatestEdge: (element: Pick<HTMLDivElement, "scrollHeight" | "clientHeight" | "scrollTop">, isTopOrigin: boolean) => boolean;
|
|
313
410
|
declare const shouldPrefetchOlder: (element: Pick<HTMLDivElement, "scrollHeight" | "clientHeight" | "scrollTop">) => boolean;
|
|
314
411
|
declare const getLatestScrollTop: (element: Pick<HTMLDivElement, "scrollHeight" | "clientHeight">, isTopOrigin: boolean) => number;
|
|
412
|
+
declare const shouldUseTopOriginTimeline: ({ hasOlder, itemCount, topOriginMaxItems, }: {
|
|
413
|
+
hasOlder: boolean;
|
|
414
|
+
itemCount: number;
|
|
415
|
+
topOriginMaxItems?: number;
|
|
416
|
+
}) => boolean;
|
|
315
417
|
type UseLatestThreadViewportOptions = {
|
|
316
418
|
itemCount: number;
|
|
317
419
|
hasOlder: boolean;
|
|
@@ -348,4 +450,4 @@ type LatestThreadViewportProps<T> = {
|
|
|
348
450
|
};
|
|
349
451
|
declare function LatestThreadViewport<T>({ items, hasOlder, isLoadingOlder, onLoadOlder, activeStreamKey, className, latestSpacer, trailingSpacer, renderItem, }: LatestThreadViewportProps<T>): react.JSX.Element;
|
|
350
452
|
|
|
351
|
-
export { type ChatActiveRun, type ChatAttachment, type ChatCitation, type ChatContextWindow, type ChatController, type ChatMessage, type
|
|
453
|
+
export { type Agents24ChatRenderOptions, type ChatActiveRun, type ChatApprovalPart, type ChatAttachment, type ChatCitation, type ChatContextWindow, type ChatController, type ChatDataPart, type ChatErrorPart, type ChatMessage, type ChatPart, type ChatReasoningPart, type ChatReasoningStep, type ChatRunStatus, type ChatRuntimeEvent, type ChatStorageAdapter, type ChatStreamResult, type ChatTextPart, type ChatThreadDetail, type ChatThreadSummary, type ChatThreadTurn, type ChatToolPart, type ChatToolState, type ChatTransport, type ChatUiBlocksPart, DEFAULT_THREAD_PAGE_SIZE, DefaultChatPart, DefaultToolPart, type FetchChatTransportOptions, type FetchChatTransportRoutes, LatestThreadViewport, type LatestThreadViewportProps, type LatestThreadViewportRenderContext, type LatestThreadViewportState, type StoredChatThread, type StreamingTextCache, type StreamingTextMode, type ToolPresentation, type ToolRenderer, type UseAgents24ChatControllerOptions, type UseLatestThreadViewportOptions, type UseStreamingTextOptions, type UseStreamingTextResult, activeRunIdFromThread, activeRunIdFromThreadDetail, assistantTextFromParts, assistantTextFromResponseBlocks, consumeSseResponse, createChatId, createFetchChatTransport, getActiveStreamingTextPartId, getLatestScrollTop, hasStaleUnfinishedAssistantCache, hasUnfinishedAssistantMessage, isActiveStreamingTextPart, isAtTimelineLatestEdge, isRunningThreadStatus, isScrollable, latestContextWindowFromThread, mergeReasoningSteps, parseSseBlock, partsFromResponseBlocks, reasoningStepsFromParts, renderChatPart, shouldPrefetchOlder, shouldUseTopOriginTimeline, textFromFinalOutput, threadActivityDate, threadDetailToMessages, threadPaging, titleFromMessage, toolStateFromStatus, useAgents24ChatController, useLatestThreadViewport, useStreamingText };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactNode, RefObject, UIEvent } from 'react';
|
|
3
3
|
|
|
4
4
|
type ChatRunStatus = "queued" | "running" | "completed" | "cancelled" | "failed" | string;
|
|
5
5
|
type ChatContextWindow = {
|
|
@@ -35,30 +35,89 @@ type ChatReasoningStep = {
|
|
|
35
35
|
query?: string;
|
|
36
36
|
sources?: Array<Record<string, unknown>>;
|
|
37
37
|
};
|
|
38
|
-
type
|
|
39
|
-
type
|
|
40
|
-
|
|
38
|
+
type ChatToolState = "input-streaming" | "input-available" | "output-available" | "output-error" | "cancelled";
|
|
39
|
+
type ToolPresentation = {
|
|
40
|
+
title?: string | null;
|
|
41
|
+
activity?: string | null;
|
|
42
|
+
detail?: string | null;
|
|
43
|
+
category?: string | null;
|
|
44
|
+
groupKey?: string | null;
|
|
45
|
+
groupLabel?: string | null;
|
|
46
|
+
showOutput?: boolean;
|
|
47
|
+
outputView?: Record<string, unknown> | null;
|
|
48
|
+
[key: string]: unknown;
|
|
49
|
+
};
|
|
50
|
+
type ChatTextPart = {
|
|
41
51
|
id: string;
|
|
52
|
+
type: "text";
|
|
42
53
|
kind: "text";
|
|
43
|
-
|
|
54
|
+
text: string;
|
|
55
|
+
raw?: Record<string, unknown>;
|
|
44
56
|
};
|
|
45
|
-
type
|
|
57
|
+
type ChatToolPart = {
|
|
46
58
|
id: string;
|
|
59
|
+
type: `tool-${string}`;
|
|
47
60
|
kind: "tool";
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
toolName: string;
|
|
62
|
+
toolCallId?: string | null;
|
|
63
|
+
state: ChatToolState;
|
|
64
|
+
input?: unknown;
|
|
65
|
+
output?: unknown;
|
|
66
|
+
errorText?: string | null;
|
|
67
|
+
presentation?: ToolPresentation | null;
|
|
68
|
+
raw: Record<string, unknown>;
|
|
53
69
|
};
|
|
54
|
-
type
|
|
70
|
+
type ChatReasoningPart = {
|
|
55
71
|
id: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
type: "reasoning";
|
|
73
|
+
kind: "reasoning";
|
|
74
|
+
label?: string | null;
|
|
75
|
+
text?: string | null;
|
|
76
|
+
status?: string | null;
|
|
77
|
+
raw: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
type ChatUiBlocksPart = {
|
|
80
|
+
id: string;
|
|
81
|
+
type: "ui-blocks";
|
|
82
|
+
kind: "ui-blocks";
|
|
83
|
+
state: ChatToolState;
|
|
84
|
+
toolCallId?: string | null;
|
|
85
|
+
contractVersion?: string | null;
|
|
86
|
+
bundle?: Record<string, unknown> | null;
|
|
87
|
+
errorText?: string | null;
|
|
88
|
+
raw: Record<string, unknown>;
|
|
89
|
+
};
|
|
90
|
+
type ChatApprovalPart = {
|
|
91
|
+
id: string;
|
|
92
|
+
type: "approval";
|
|
93
|
+
kind: "approval";
|
|
94
|
+
raw: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
type ChatErrorPart = {
|
|
97
|
+
id: string;
|
|
98
|
+
type: "error";
|
|
99
|
+
kind: "error";
|
|
100
|
+
errorText: string;
|
|
101
|
+
raw: Record<string, unknown>;
|
|
102
|
+
};
|
|
103
|
+
type ChatDataPart = {
|
|
104
|
+
id: string;
|
|
105
|
+
type: "data";
|
|
106
|
+
kind: "data";
|
|
107
|
+
name: string;
|
|
108
|
+
data: Record<string, unknown>;
|
|
109
|
+
raw: Record<string, unknown>;
|
|
110
|
+
};
|
|
111
|
+
type ChatPart = ChatTextPart | ChatToolPart | ChatReasoningPart | ChatUiBlocksPart | ChatApprovalPart | ChatErrorPart | ChatDataPart;
|
|
112
|
+
type ToolRenderer = (props: {
|
|
113
|
+
part: ChatToolPart;
|
|
114
|
+
message: ChatMessage;
|
|
115
|
+
}) => ReactNode;
|
|
116
|
+
type Agents24ChatRenderOptions = {
|
|
117
|
+
renderPart?: (part: ChatPart, message: ChatMessage) => ReactNode;
|
|
118
|
+
toolRenderers?: Partial<Record<`tool-${string}`, ToolRenderer>>;
|
|
119
|
+
fallbackToolRenderer?: ToolRenderer;
|
|
60
120
|
};
|
|
61
|
-
type ChatMessageBlock = ChatTextBlock | ChatToolBlock | ChatToolGroupBlock;
|
|
62
121
|
type ChatMessage = {
|
|
63
122
|
id: string;
|
|
64
123
|
role: "user" | "assistant";
|
|
@@ -66,7 +125,7 @@ type ChatMessage = {
|
|
|
66
125
|
content: string;
|
|
67
126
|
createdAt: Date;
|
|
68
127
|
isFinal?: boolean;
|
|
69
|
-
|
|
128
|
+
parts: ChatPart[];
|
|
70
129
|
attachments?: ChatAttachment[];
|
|
71
130
|
citations?: ChatCitation[];
|
|
72
131
|
reasoningSteps?: ChatReasoningStep[];
|
|
@@ -149,6 +208,7 @@ type ChatTransport = {
|
|
|
149
208
|
threadId: string;
|
|
150
209
|
limit?: number;
|
|
151
210
|
beforeTurnIndex?: number | null;
|
|
211
|
+
includeRunEvents?: boolean;
|
|
152
212
|
signal?: AbortSignal;
|
|
153
213
|
}) => Promise<ChatThreadDetail>;
|
|
154
214
|
streamMessage: (input: {
|
|
@@ -254,13 +314,15 @@ declare const titleFromMessage: (text: string, files?: Array<{
|
|
|
254
314
|
filename?: string;
|
|
255
315
|
}>) => string;
|
|
256
316
|
declare const threadActivityDate: (thread: ChatThreadSummary) => string;
|
|
257
|
-
declare const
|
|
317
|
+
declare const assistantTextFromResponseBlocks: (blocks?: Array<Record<string, unknown>>) => string;
|
|
318
|
+
declare const assistantTextFromParts: (parts?: ChatPart[]) => string;
|
|
258
319
|
declare const textFromFinalOutput: (value: unknown) => string;
|
|
259
|
-
declare const
|
|
320
|
+
declare const toolStateFromStatus: (status?: unknown) => ChatToolState;
|
|
321
|
+
declare const partsFromResponseBlocks: (blocks?: Array<Record<string, unknown>>, fallbackText?: string) => ChatPart[];
|
|
260
322
|
declare const mergeReasoningSteps: (steps?: ChatReasoningStep[], options?: {
|
|
261
323
|
finalize?: boolean;
|
|
262
324
|
}) => ChatReasoningStep[];
|
|
263
|
-
declare const
|
|
325
|
+
declare const reasoningStepsFromParts: (parts?: ChatPart[]) => ChatReasoningStep[];
|
|
264
326
|
declare const threadDetailToMessages: (thread: ChatThreadDetail) => ChatMessage[];
|
|
265
327
|
declare const threadPaging: (thread: ChatThreadDetail) => {
|
|
266
328
|
hasOlderTurns: boolean;
|
|
@@ -274,9 +336,43 @@ declare const hasStaleUnfinishedAssistantCache: (thread?: (Partial<ChatThreadSum
|
|
|
274
336
|
}) | null) => boolean;
|
|
275
337
|
declare const activeRunIdFromThreadDetail: (thread?: ChatThreadDetail | null) => string | null;
|
|
276
338
|
|
|
339
|
+
declare const DefaultToolPart: ({ part }: {
|
|
340
|
+
part: ChatToolPart;
|
|
341
|
+
}) => react.JSX.Element;
|
|
342
|
+
declare const DefaultChatPart: ({ part, message, renderOptions, }: {
|
|
343
|
+
part: ChatPart;
|
|
344
|
+
message: ChatMessage;
|
|
345
|
+
renderOptions?: Agents24ChatRenderOptions;
|
|
346
|
+
}) => react.JSX.Element;
|
|
347
|
+
declare const renderChatPart: (part: ChatPart, message: ChatMessage, renderOptions?: Agents24ChatRenderOptions) => react.JSX.Element;
|
|
348
|
+
|
|
277
349
|
declare const parseSseBlock: (block: string) => ChatRuntimeEvent | null;
|
|
278
350
|
declare const consumeSseResponse: (response: Response, onEvent: (event: ChatRuntimeEvent) => void | Promise<void>) => Promise<ChatStreamResult>;
|
|
279
351
|
|
|
352
|
+
type StreamingTextMode = "streaming" | "static";
|
|
353
|
+
type StreamingTextCache = {
|
|
354
|
+
get: (id: string) => string | undefined;
|
|
355
|
+
set: (id: string, text: string) => void;
|
|
356
|
+
};
|
|
357
|
+
type UseStreamingTextOptions = {
|
|
358
|
+
id: string;
|
|
359
|
+
isStreaming: boolean;
|
|
360
|
+
text: string;
|
|
361
|
+
cache?: StreamingTextCache | false;
|
|
362
|
+
charsPerSecond?: number;
|
|
363
|
+
catchupThreshold?: number;
|
|
364
|
+
maxCatchupChars?: number;
|
|
365
|
+
};
|
|
366
|
+
type UseStreamingTextResult = {
|
|
367
|
+
displayedText: string;
|
|
368
|
+
isAnimating: boolean;
|
|
369
|
+
mode: StreamingTextMode;
|
|
370
|
+
parseIncompleteMarkdown: boolean;
|
|
371
|
+
};
|
|
372
|
+
declare const getActiveStreamingTextPartId: (message: ChatMessage, streamingMessageId: string | null) => string | null;
|
|
373
|
+
declare const isActiveStreamingTextPart: (message: ChatMessage, part: ChatPart, streamingMessageId: string | null) => boolean;
|
|
374
|
+
declare function useStreamingText({ id, isStreaming, text, cache, charsPerSecond, catchupThreshold, maxCatchupChars, }: UseStreamingTextOptions): UseStreamingTextResult;
|
|
375
|
+
|
|
280
376
|
type MaybePromise<T> = T | Promise<T>;
|
|
281
377
|
type FetchChatTransportRoutes = {
|
|
282
378
|
listThreads: () => string;
|
|
@@ -284,6 +380,7 @@ type FetchChatTransportRoutes = {
|
|
|
284
380
|
threadId: string;
|
|
285
381
|
limit?: number;
|
|
286
382
|
beforeTurnIndex?: number | null;
|
|
383
|
+
includeRunEvents?: boolean;
|
|
287
384
|
}) => string;
|
|
288
385
|
streamMessage: () => string;
|
|
289
386
|
attachRun: (input: {
|
|
@@ -312,6 +409,11 @@ declare const isScrollable: (element: Pick<HTMLDivElement, "scrollHeight" | "cli
|
|
|
312
409
|
declare const isAtTimelineLatestEdge: (element: Pick<HTMLDivElement, "scrollHeight" | "clientHeight" | "scrollTop">, isTopOrigin: boolean) => boolean;
|
|
313
410
|
declare const shouldPrefetchOlder: (element: Pick<HTMLDivElement, "scrollHeight" | "clientHeight" | "scrollTop">) => boolean;
|
|
314
411
|
declare const getLatestScrollTop: (element: Pick<HTMLDivElement, "scrollHeight" | "clientHeight">, isTopOrigin: boolean) => number;
|
|
412
|
+
declare const shouldUseTopOriginTimeline: ({ hasOlder, itemCount, topOriginMaxItems, }: {
|
|
413
|
+
hasOlder: boolean;
|
|
414
|
+
itemCount: number;
|
|
415
|
+
topOriginMaxItems?: number;
|
|
416
|
+
}) => boolean;
|
|
315
417
|
type UseLatestThreadViewportOptions = {
|
|
316
418
|
itemCount: number;
|
|
317
419
|
hasOlder: boolean;
|
|
@@ -348,4 +450,4 @@ type LatestThreadViewportProps<T> = {
|
|
|
348
450
|
};
|
|
349
451
|
declare function LatestThreadViewport<T>({ items, hasOlder, isLoadingOlder, onLoadOlder, activeStreamKey, className, latestSpacer, trailingSpacer, renderItem, }: LatestThreadViewportProps<T>): react.JSX.Element;
|
|
350
452
|
|
|
351
|
-
export { type ChatActiveRun, type ChatAttachment, type ChatCitation, type ChatContextWindow, type ChatController, type ChatMessage, type
|
|
453
|
+
export { type Agents24ChatRenderOptions, type ChatActiveRun, type ChatApprovalPart, type ChatAttachment, type ChatCitation, type ChatContextWindow, type ChatController, type ChatDataPart, type ChatErrorPart, type ChatMessage, type ChatPart, type ChatReasoningPart, type ChatReasoningStep, type ChatRunStatus, type ChatRuntimeEvent, type ChatStorageAdapter, type ChatStreamResult, type ChatTextPart, type ChatThreadDetail, type ChatThreadSummary, type ChatThreadTurn, type ChatToolPart, type ChatToolState, type ChatTransport, type ChatUiBlocksPart, DEFAULT_THREAD_PAGE_SIZE, DefaultChatPart, DefaultToolPart, type FetchChatTransportOptions, type FetchChatTransportRoutes, LatestThreadViewport, type LatestThreadViewportProps, type LatestThreadViewportRenderContext, type LatestThreadViewportState, type StoredChatThread, type StreamingTextCache, type StreamingTextMode, type ToolPresentation, type ToolRenderer, type UseAgents24ChatControllerOptions, type UseLatestThreadViewportOptions, type UseStreamingTextOptions, type UseStreamingTextResult, activeRunIdFromThread, activeRunIdFromThreadDetail, assistantTextFromParts, assistantTextFromResponseBlocks, consumeSseResponse, createChatId, createFetchChatTransport, getActiveStreamingTextPartId, getLatestScrollTop, hasStaleUnfinishedAssistantCache, hasUnfinishedAssistantMessage, isActiveStreamingTextPart, isAtTimelineLatestEdge, isRunningThreadStatus, isScrollable, latestContextWindowFromThread, mergeReasoningSteps, parseSseBlock, partsFromResponseBlocks, reasoningStepsFromParts, renderChatPart, shouldPrefetchOlder, shouldUseTopOriginTimeline, textFromFinalOutput, threadActivityDate, threadDetailToMessages, threadPaging, titleFromMessage, toolStateFromStatus, useAgents24ChatController, useLatestThreadViewport, useStreamingText };
|