teodor-new-chat-ui 4.3.257 → 4.3.258
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/dist/types/api.d.ts +6 -443
- package/dist/types/context.d.ts +153 -0
- package/dist/types/events.d.ts +99 -0
- package/dist/types/models.d.ts +171 -0
- package/dist/types/requests.d.ts +14 -0
- package/package.json +15 -17
package/dist/types/api.d.ts
CHANGED
|
@@ -1,443 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
type: "image_url";
|
|
8
|
-
url: string;
|
|
9
|
-
mimeType?: string;
|
|
10
|
-
alt?: string;
|
|
11
|
-
};
|
|
12
|
-
export type FilePart = {
|
|
13
|
-
type: "file";
|
|
14
|
-
url: string;
|
|
15
|
-
mimeType?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
size?: number;
|
|
18
|
-
sourceType?: string;
|
|
19
|
-
};
|
|
20
|
-
export type ToolCallPart = {
|
|
21
|
-
type: "tool_call";
|
|
22
|
-
id: string;
|
|
23
|
-
name: string;
|
|
24
|
-
args: Record<string, unknown>;
|
|
25
|
-
};
|
|
26
|
-
export type InterruptPart = {
|
|
27
|
-
type: "interrupt";
|
|
28
|
-
value?: any;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
};
|
|
31
|
-
export type MessagePart = TextPart | ImagePart | FilePart | ToolCallPart | InterruptPart;
|
|
32
|
-
export interface ChatMessage {
|
|
33
|
-
id: string;
|
|
34
|
-
role: Role;
|
|
35
|
-
content: MessagePart[];
|
|
36
|
-
name?: string;
|
|
37
|
-
model?: string;
|
|
38
|
-
createdAt?: string;
|
|
39
|
-
checkpointId?: string;
|
|
40
|
-
checkpointNs?: string;
|
|
41
|
-
additionalKwargs?: Record<string, unknown>;
|
|
42
|
-
responseMetadata?: Record<string, unknown>;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Default/welcome message type for rendering initial instructions
|
|
46
|
-
* Markdown content is automatically rendered with proper theme support
|
|
47
|
-
*/
|
|
48
|
-
export interface DefaultMessage {
|
|
49
|
-
id: "default-message";
|
|
50
|
-
role: "assistant";
|
|
51
|
-
type: "default_message";
|
|
52
|
-
content: string;
|
|
53
|
-
createdAt?: string;
|
|
54
|
-
}
|
|
55
|
-
export interface PregelTask {
|
|
56
|
-
id: string;
|
|
57
|
-
name: string;
|
|
58
|
-
path?: string[];
|
|
59
|
-
error?: string | null;
|
|
60
|
-
interrupts?: unknown[];
|
|
61
|
-
state?: unknown;
|
|
62
|
-
[key: string]: unknown;
|
|
63
|
-
}
|
|
64
|
-
export interface CheckpointSnapshot {
|
|
65
|
-
createdAt?: string | null;
|
|
66
|
-
config?: Record<string, unknown> | null;
|
|
67
|
-
metadata?: Record<string, unknown> | null;
|
|
68
|
-
values: {
|
|
69
|
-
messages: ChatMessage[];
|
|
70
|
-
results?: unknown[];
|
|
71
|
-
active_agent?: string | null;
|
|
72
|
-
research_summary?: string | null;
|
|
73
|
-
[key: string]: unknown;
|
|
74
|
-
};
|
|
75
|
-
next: unknown[];
|
|
76
|
-
parentConfig?: Record<string, unknown> | null;
|
|
77
|
-
tasks?: PregelTask[] | null;
|
|
78
|
-
}
|
|
79
|
-
export type PendingInterrupt = {
|
|
80
|
-
id: string;
|
|
81
|
-
value: unknown;
|
|
82
|
-
} | null;
|
|
83
|
-
export interface HydratedCheckpointSnapshot {
|
|
84
|
-
checkpointId: string | null;
|
|
85
|
-
checkpointNs: string | null;
|
|
86
|
-
createdAt: string | null;
|
|
87
|
-
parentId: string | null;
|
|
88
|
-
branchLabel: string | null;
|
|
89
|
-
lastMessageId: string | null;
|
|
90
|
-
messagesLen: number;
|
|
91
|
-
hasMessages: boolean;
|
|
92
|
-
messages: ChatMessage[];
|
|
93
|
-
nextCursor: string | null;
|
|
94
|
-
nextCursorNs: string | null;
|
|
95
|
-
interrupt: PendingInterrupt;
|
|
96
|
-
metadata?: Record<string, unknown> | null;
|
|
97
|
-
config?: Record<string, unknown> | null;
|
|
98
|
-
parentConfig?: Record<string, unknown> | null;
|
|
99
|
-
next?: unknown[] | null;
|
|
100
|
-
tasks?: PregelTask[] | null;
|
|
101
|
-
values?: Omit<CheckpointSnapshot["values"], "messages"> | null;
|
|
102
|
-
}
|
|
103
|
-
export interface TimelineCheckpoint {
|
|
104
|
-
id: string;
|
|
105
|
-
label: string;
|
|
106
|
-
messageId: string | null;
|
|
107
|
-
step: number | null;
|
|
108
|
-
source: string | null;
|
|
109
|
-
createdAt: string | null;
|
|
110
|
-
next?: string | null;
|
|
111
|
-
}
|
|
112
|
-
export interface HistoryPayload {
|
|
113
|
-
version: "chat-history@1";
|
|
114
|
-
threadId: string;
|
|
115
|
-
checkpoints: CheckpointSnapshot[];
|
|
116
|
-
timeline?: TimelineCheckpoint[];
|
|
117
|
-
}
|
|
118
|
-
export interface CheckpointList {
|
|
119
|
-
thread_id: string;
|
|
120
|
-
items: HydratedCheckpointSnapshot[];
|
|
121
|
-
}
|
|
122
|
-
export interface StatePayload {
|
|
123
|
-
threadId: string;
|
|
124
|
-
checkpointId?: string;
|
|
125
|
-
state: unknown;
|
|
126
|
-
}
|
|
127
|
-
export type StreamCommand = {
|
|
128
|
-
kind: "resume";
|
|
129
|
-
value: unknown;
|
|
130
|
-
} | {
|
|
131
|
-
kind: "goto";
|
|
132
|
-
node: string;
|
|
133
|
-
value?: unknown;
|
|
134
|
-
};
|
|
135
|
-
export interface ChatRequest {
|
|
136
|
-
threadId?: string | null;
|
|
137
|
-
payload?: Record<string, unknown>;
|
|
138
|
-
checkpointId?: string | null;
|
|
139
|
-
checkpointNs?: string | null;
|
|
140
|
-
nodeFilter?: string | string[] | null;
|
|
141
|
-
config?: Record<string, unknown>;
|
|
142
|
-
edit?: boolean;
|
|
143
|
-
originalMessageId?: string;
|
|
144
|
-
branchLabel?: string;
|
|
145
|
-
active_agent?: string;
|
|
146
|
-
command?: StreamCommand | null;
|
|
147
|
-
}
|
|
148
|
-
type ToolEventIdentity = {
|
|
149
|
-
id: string;
|
|
150
|
-
call_id?: string;
|
|
151
|
-
} | {
|
|
152
|
-
call_id: string;
|
|
153
|
-
id?: string;
|
|
154
|
-
};
|
|
155
|
-
export type ToolStartEvent = {
|
|
156
|
-
type: "tool_start";
|
|
157
|
-
args: Record<string, unknown>;
|
|
158
|
-
name?: string;
|
|
159
|
-
tool?: string;
|
|
160
|
-
seq?: number;
|
|
161
|
-
} & ToolEventIdentity;
|
|
162
|
-
export type ToolEndEvent = {
|
|
163
|
-
type: "tool_end";
|
|
164
|
-
output: unknown;
|
|
165
|
-
error?: string;
|
|
166
|
-
name?: string;
|
|
167
|
-
tool?: string;
|
|
168
|
-
seq?: number;
|
|
169
|
-
} & ToolEventIdentity;
|
|
170
|
-
export type MessageStreamEvent = {
|
|
171
|
-
type: "token";
|
|
172
|
-
content: string;
|
|
173
|
-
} | {
|
|
174
|
-
type: "message_start";
|
|
175
|
-
role: "assistant";
|
|
176
|
-
id: string;
|
|
177
|
-
model?: string;
|
|
178
|
-
} | {
|
|
179
|
-
type: "message_delta";
|
|
180
|
-
delta: MessagePart[];
|
|
181
|
-
} | {
|
|
182
|
-
type: "message_end";
|
|
183
|
-
};
|
|
184
|
-
export type ToolStreamEvent = ToolStartEvent | ToolEndEvent;
|
|
185
|
-
export type ThreadStreamEvent = {
|
|
186
|
-
type: "thread_info";
|
|
187
|
-
threadId: string;
|
|
188
|
-
title: string;
|
|
189
|
-
createdAt: string;
|
|
190
|
-
updatedAt: string;
|
|
191
|
-
messageCount: number;
|
|
192
|
-
lastMessage?: string | null;
|
|
193
|
-
created?: boolean | null;
|
|
194
|
-
ready?: boolean | null;
|
|
195
|
-
seq?: number | null;
|
|
196
|
-
} | {
|
|
197
|
-
type: "checkpoint";
|
|
198
|
-
checkpointId: string;
|
|
199
|
-
checkpointNs?: string | null;
|
|
200
|
-
} | {
|
|
201
|
-
type: "branch";
|
|
202
|
-
threadId: string;
|
|
203
|
-
parentThreadId?: string | null;
|
|
204
|
-
parentCheckpointId?: string | null;
|
|
205
|
-
checkpointId?: string | null;
|
|
206
|
-
checkpointNs?: string | null;
|
|
207
|
-
editedMessageId?: string | null;
|
|
208
|
-
branchLabel?: string | null;
|
|
209
|
-
};
|
|
210
|
-
export type SystemStreamEvent = {
|
|
211
|
-
type: "error";
|
|
212
|
-
message: string;
|
|
213
|
-
error_type?: string;
|
|
214
|
-
code?: string;
|
|
215
|
-
} | {
|
|
216
|
-
type: "interrupt";
|
|
217
|
-
id: string;
|
|
218
|
-
value: any;
|
|
219
|
-
seq: number;
|
|
220
|
-
} | {
|
|
221
|
-
type: "heartbeat";
|
|
222
|
-
timestamp: number;
|
|
223
|
-
seq: number;
|
|
224
|
-
} | {
|
|
225
|
-
type: "cancelled";
|
|
226
|
-
reason?: string;
|
|
227
|
-
seq?: number;
|
|
228
|
-
} | ({
|
|
229
|
-
type: "state_history";
|
|
230
|
-
seq?: number;
|
|
231
|
-
} & HistoryPayload);
|
|
232
|
-
export type StreamEvent = MessageStreamEvent | ToolStreamEvent | ThreadStreamEvent | SystemStreamEvent;
|
|
233
|
-
export declare function isMessageEvent(ev: StreamEvent): ev is MessageStreamEvent;
|
|
234
|
-
export declare function isToolEvent(ev: StreamEvent): ev is ToolStreamEvent;
|
|
235
|
-
export declare function isThreadEvent(ev: StreamEvent): ev is ThreadStreamEvent;
|
|
236
|
-
export declare function isSystemEvent(ev: StreamEvent): ev is SystemStreamEvent;
|
|
237
|
-
export interface Envelope<T = unknown> {
|
|
238
|
-
protocolVersion: "v1";
|
|
239
|
-
data: T;
|
|
240
|
-
}
|
|
241
|
-
export interface ThreadSummary {
|
|
242
|
-
threadId: string;
|
|
243
|
-
title: string;
|
|
244
|
-
createdAt: string;
|
|
245
|
-
updatedAt: string;
|
|
246
|
-
messageCount: number;
|
|
247
|
-
}
|
|
248
|
-
export interface ThreadInfo extends ThreadSummary {
|
|
249
|
-
lastMessage?: string | null;
|
|
250
|
-
}
|
|
251
|
-
export interface AgentSummary {
|
|
252
|
-
agentId: string;
|
|
253
|
-
name: string;
|
|
254
|
-
stateValue?: string | null;
|
|
255
|
-
description?: string | null;
|
|
256
|
-
}
|
|
257
|
-
export interface AgentList {
|
|
258
|
-
items: AgentSummary[];
|
|
259
|
-
}
|
|
260
|
-
export interface AgentDetail extends AgentSummary {
|
|
261
|
-
transferBackTo: string[];
|
|
262
|
-
transferForwardTo: string[];
|
|
263
|
-
transferReasons: Record<string, string>;
|
|
264
|
-
handoffQuestions: Record<string, string>;
|
|
265
|
-
saveBeforeTransfer: Record<string, boolean>;
|
|
266
|
-
outputStyle?: string | null;
|
|
267
|
-
systemPrompt?: string | null;
|
|
268
|
-
uiDefaultMessage?: string | null;
|
|
269
|
-
}
|
|
270
|
-
export interface AgentSchemaInfo {
|
|
271
|
-
agentId: string;
|
|
272
|
-
schema: Record<string, unknown>;
|
|
273
|
-
}
|
|
274
|
-
export interface ExcelColumnSchema {
|
|
275
|
-
name: string;
|
|
276
|
-
sqlType: string;
|
|
277
|
-
nullable: boolean;
|
|
278
|
-
example?: string | null;
|
|
279
|
-
}
|
|
280
|
-
export interface ExcelSheetSchema {
|
|
281
|
-
sheetName: string;
|
|
282
|
-
tableName: string;
|
|
283
|
-
columns: ExcelColumnSchema[];
|
|
284
|
-
rowCount: number;
|
|
285
|
-
}
|
|
286
|
-
export interface ExcelUploadResponse {
|
|
287
|
-
status: 'ok';
|
|
288
|
-
sheets: ExcelSheetSchema[];
|
|
289
|
-
}
|
|
290
|
-
export interface ApiConfig {
|
|
291
|
-
baseUrl?: string;
|
|
292
|
-
apiKey?: string;
|
|
293
|
-
headers?: Record<string, string>;
|
|
294
|
-
getToken?: () => string | null;
|
|
295
|
-
uploadPath?: string;
|
|
296
|
-
}
|
|
297
|
-
export interface SendOptions {
|
|
298
|
-
checkpointId?: string;
|
|
299
|
-
checkpointNs?: string;
|
|
300
|
-
nodeFilter?: string | string[] | null;
|
|
301
|
-
config?: Record<string, unknown>;
|
|
302
|
-
payloadExtras?: Record<string, unknown>;
|
|
303
|
-
attachments?: File[];
|
|
304
|
-
command?: StreamCommand | null;
|
|
305
|
-
}
|
|
306
|
-
export interface ApiContextValue {
|
|
307
|
-
token: string | null;
|
|
308
|
-
setToken: (token: string | null) => void;
|
|
309
|
-
baseUrl: string;
|
|
310
|
-
api: import("@/lib/chat-api").ChatApi;
|
|
311
|
-
}
|
|
312
|
-
export interface ThreadsContextValue {
|
|
313
|
-
threads: ThreadSummary[];
|
|
314
|
-
currentThreadId: string | null;
|
|
315
|
-
setCurrentThreadId: (id: string | null) => void;
|
|
316
|
-
isLoading: boolean;
|
|
317
|
-
error: string | null;
|
|
318
|
-
actions: {
|
|
319
|
-
createThread: (title?: string) => Promise<string>;
|
|
320
|
-
deleteThread: (id: string) => Promise<void>;
|
|
321
|
-
renameThread: (id: string, title: string) => Promise<void>;
|
|
322
|
-
refreshThreads: () => Promise<void>;
|
|
323
|
-
};
|
|
324
|
-
persistThreadsCache: () => void;
|
|
325
|
-
hydrateFromCache: () => void;
|
|
326
|
-
}
|
|
327
|
-
export interface ThreadStateMetadata {
|
|
328
|
-
branchLabel?: string | null;
|
|
329
|
-
lastBranch?: Extract<StreamEvent, {
|
|
330
|
-
type: "branch";
|
|
331
|
-
}> | null;
|
|
332
|
-
assemblingMessageId?: string | null;
|
|
333
|
-
}
|
|
334
|
-
export interface ThreadStateContextValue {
|
|
335
|
-
threadId: string | null;
|
|
336
|
-
messages: ChatMessage[];
|
|
337
|
-
interrupt: PendingInterrupt;
|
|
338
|
-
checkpoint: {
|
|
339
|
-
id: string | null;
|
|
340
|
-
namespace: string | null;
|
|
341
|
-
};
|
|
342
|
-
checkpoints: HydratedCheckpointSnapshot[];
|
|
343
|
-
metadata: ThreadStateMetadata | null;
|
|
344
|
-
isLoading: boolean;
|
|
345
|
-
isHistoryLoading: boolean;
|
|
346
|
-
error: string | null;
|
|
347
|
-
hasMore: boolean;
|
|
348
|
-
loadOlder: (opts?: {
|
|
349
|
-
limit?: number;
|
|
350
|
-
}) => Promise<void>;
|
|
351
|
-
seedFromSnapshot: (snapshot: HydratedCheckpointSnapshot & {
|
|
352
|
-
threadId: string;
|
|
353
|
-
}) => void;
|
|
354
|
-
clearState: () => void;
|
|
355
|
-
navigateToCheckpoint: (checkpointId: string, checkpointNs?: string | null) => Promise<void>;
|
|
356
|
-
returnToLatest: () => Promise<void>;
|
|
357
|
-
loadThread: (threadId: string, checkpointId?: string, checkpointNs?: string, force?: boolean) => Promise<void>;
|
|
358
|
-
clearThread: () => Promise<void>;
|
|
359
|
-
respondToInterrupt: (interruptId: string, approved: boolean, value?: unknown) => Promise<void>;
|
|
360
|
-
}
|
|
361
|
-
export interface StreamSubmitPayload {
|
|
362
|
-
text?: string;
|
|
363
|
-
attachments?: File[];
|
|
364
|
-
payload?: Record<string, unknown>;
|
|
365
|
-
messageAdditionalKwargs?: Record<string, unknown>;
|
|
366
|
-
}
|
|
367
|
-
export interface StreamContextValue {
|
|
368
|
-
isStreaming: boolean;
|
|
369
|
-
error: string | null;
|
|
370
|
-
connectionState: 'idle' | 'connecting' | 'connected' | 'reconnecting' | 'error';
|
|
371
|
-
submit: (payload: StreamSubmitPayload, options?: SendOptions) => Promise<void>;
|
|
372
|
-
/**
|
|
373
|
-
* @deprecated Prefer `submit`; retained for backwards compatibility while
|
|
374
|
-
* hosts migrate to the unified helper.
|
|
375
|
-
*/
|
|
376
|
-
send?: (payload: StreamSubmitPayload, options?: SendOptions) => Promise<void>;
|
|
377
|
-
stop: () => void;
|
|
378
|
-
setAuthToken: (token: string | null) => void;
|
|
379
|
-
}
|
|
380
|
-
export type StreamAction = {
|
|
381
|
-
type: 'STREAM_START';
|
|
382
|
-
assistantId?: string;
|
|
383
|
-
} | {
|
|
384
|
-
type: 'STREAM_END';
|
|
385
|
-
} | {
|
|
386
|
-
type: 'STREAM_ERROR';
|
|
387
|
-
error: string;
|
|
388
|
-
} | {
|
|
389
|
-
type: 'UPDATE_CHECKPOINT';
|
|
390
|
-
event: ThreadStreamEvent;
|
|
391
|
-
};
|
|
392
|
-
export type MessageAction = {
|
|
393
|
-
type: 'STREAM_EVENT';
|
|
394
|
-
event: MessageStreamEvent | ToolStreamEvent | SystemStreamEvent;
|
|
395
|
-
} | {
|
|
396
|
-
type: 'USER_MESSAGE';
|
|
397
|
-
message: ChatMessage;
|
|
398
|
-
} | {
|
|
399
|
-
type: 'LOAD_HISTORY';
|
|
400
|
-
messages: ChatMessage[];
|
|
401
|
-
hasMore: boolean;
|
|
402
|
-
} | {
|
|
403
|
-
type: 'CLEAR_MESSAGES';
|
|
404
|
-
} | {
|
|
405
|
-
type: 'STREAM_ERROR';
|
|
406
|
-
error: string;
|
|
407
|
-
};
|
|
408
|
-
export type ThreadAction = {
|
|
409
|
-
type: 'LOAD_THREADS';
|
|
410
|
-
threads: ThreadSummary[];
|
|
411
|
-
} | {
|
|
412
|
-
type: 'SET_CURRENT_THREAD';
|
|
413
|
-
threadId: string | null;
|
|
414
|
-
} | {
|
|
415
|
-
type: 'ADD_THREAD';
|
|
416
|
-
thread: ThreadSummary;
|
|
417
|
-
} | {
|
|
418
|
-
type: 'REMOVE_THREAD';
|
|
419
|
-
threadId: string;
|
|
420
|
-
} | {
|
|
421
|
-
type: 'UPDATE_THREAD';
|
|
422
|
-
threadId: string;
|
|
423
|
-
updates: Partial<ThreadSummary>;
|
|
424
|
-
} | {
|
|
425
|
-
type: 'STREAM_EVENT';
|
|
426
|
-
event: ThreadStreamEvent;
|
|
427
|
-
} | {
|
|
428
|
-
type: 'LOADING_THREADS';
|
|
429
|
-
loading: boolean;
|
|
430
|
-
} | {
|
|
431
|
-
type: 'LOADING_THREAD';
|
|
432
|
-
loading: boolean;
|
|
433
|
-
};
|
|
434
|
-
export interface CoordinatorOptions {
|
|
435
|
-
onThreadInfo?: (ev: ThreadStreamEvent) => void;
|
|
436
|
-
onMessageEvent: (ev: MessageStreamEvent | ToolStreamEvent | SystemStreamEvent) => void;
|
|
437
|
-
onUnhandledEvent?: (ev: StreamEvent) => void;
|
|
438
|
-
onSequenceGap?: (info: {
|
|
439
|
-
expected: number;
|
|
440
|
-
got: number;
|
|
441
|
-
}) => void;
|
|
442
|
-
}
|
|
443
|
-
export {};
|
|
1
|
+
export * from "./models";
|
|
2
|
+
export * from "./events";
|
|
3
|
+
export * from "./context";
|
|
4
|
+
export * from "./timeline";
|
|
5
|
+
export * from "./json-structures";
|
|
6
|
+
export * from "./requests";
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { StreamCommand, ThreadStreamEvent, MessageStreamEvent, ToolStreamEvent, SystemStreamEvent, StreamEvent } from "./events";
|
|
2
|
+
import type { ChatMessage, HydratedCheckpointSnapshot, PendingInterrupt, ThreadSummary } from "./models";
|
|
3
|
+
export interface ApiConfig {
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
getToken?: () => string | null;
|
|
8
|
+
uploadPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface SendOptions {
|
|
11
|
+
checkpointId?: string;
|
|
12
|
+
checkpointNs?: string;
|
|
13
|
+
nodeFilter?: string | string[] | null;
|
|
14
|
+
config?: Record<string, unknown>;
|
|
15
|
+
payloadExtras?: Record<string, unknown>;
|
|
16
|
+
attachments?: File[];
|
|
17
|
+
command?: StreamCommand | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ApiContextValue {
|
|
20
|
+
token: string | null;
|
|
21
|
+
setToken: (token: string | null) => void;
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
api: import("@/lib/chat-api").ChatApi;
|
|
24
|
+
}
|
|
25
|
+
export interface ThreadsContextValue {
|
|
26
|
+
threads: ThreadSummary[];
|
|
27
|
+
currentThreadId: string | null;
|
|
28
|
+
setCurrentThreadId: (id: string | null) => void;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
error: string | null;
|
|
31
|
+
actions: {
|
|
32
|
+
createThread: (title?: string) => Promise<string>;
|
|
33
|
+
deleteThread: (id: string) => Promise<void>;
|
|
34
|
+
renameThread: (id: string, title: string) => Promise<void>;
|
|
35
|
+
refreshThreads: () => Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
persistThreadsCache: () => void;
|
|
38
|
+
hydrateFromCache: () => void;
|
|
39
|
+
}
|
|
40
|
+
export interface ThreadStateMetadata {
|
|
41
|
+
branchLabel?: string | null;
|
|
42
|
+
lastBranch?: ThreadStreamEvent | null;
|
|
43
|
+
assemblingMessageId?: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface ThreadStateContextValue {
|
|
46
|
+
threadId: string | null;
|
|
47
|
+
messages: ChatMessage[];
|
|
48
|
+
interrupt: PendingInterrupt;
|
|
49
|
+
checkpoint: {
|
|
50
|
+
id: string | null;
|
|
51
|
+
namespace: string | null;
|
|
52
|
+
};
|
|
53
|
+
checkpoints: HydratedCheckpointSnapshot[];
|
|
54
|
+
metadata: ThreadStateMetadata | null;
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
isHistoryLoading: boolean;
|
|
57
|
+
error: string | null;
|
|
58
|
+
hasMore: boolean;
|
|
59
|
+
loadOlder: (opts?: {
|
|
60
|
+
limit?: number;
|
|
61
|
+
}) => Promise<void>;
|
|
62
|
+
seedFromSnapshot: (snapshot: HydratedCheckpointSnapshot & {
|
|
63
|
+
threadId: string;
|
|
64
|
+
}) => void;
|
|
65
|
+
clearState: () => void;
|
|
66
|
+
navigateToCheckpoint: (checkpointId: string, checkpointNs?: string | null) => Promise<void>;
|
|
67
|
+
returnToLatest: () => Promise<void>;
|
|
68
|
+
loadThread: (threadId: string, checkpointId?: string, checkpointNs?: string, force?: boolean) => Promise<void>;
|
|
69
|
+
clearThread: () => Promise<void>;
|
|
70
|
+
respondToInterrupt: (interruptId: string, approved: boolean, value?: unknown) => Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
export interface StreamSubmitPayload {
|
|
73
|
+
text?: string;
|
|
74
|
+
attachments?: File[];
|
|
75
|
+
payload?: Record<string, unknown>;
|
|
76
|
+
messageAdditionalKwargs?: Record<string, unknown>;
|
|
77
|
+
}
|
|
78
|
+
export interface StreamContextValue {
|
|
79
|
+
isStreaming: boolean;
|
|
80
|
+
error: string | null;
|
|
81
|
+
connectionState: "idle" | "connecting" | "connected" | "reconnecting" | "error";
|
|
82
|
+
submit: (payload: StreamSubmitPayload, options?: SendOptions) => Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Prefer `submit`; retained for backwards compatibility while
|
|
85
|
+
* hosts migrate to the unified helper.
|
|
86
|
+
*/
|
|
87
|
+
send?: (payload: StreamSubmitPayload, options?: SendOptions) => Promise<void>;
|
|
88
|
+
stop: () => void;
|
|
89
|
+
setAuthToken: (token: string | null) => void;
|
|
90
|
+
}
|
|
91
|
+
export type StreamAction = {
|
|
92
|
+
type: "STREAM_START";
|
|
93
|
+
assistantId?: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: "STREAM_END";
|
|
96
|
+
} | {
|
|
97
|
+
type: "STREAM_ERROR";
|
|
98
|
+
error: string;
|
|
99
|
+
} | {
|
|
100
|
+
type: "UPDATE_CHECKPOINT";
|
|
101
|
+
event: ThreadStreamEvent;
|
|
102
|
+
};
|
|
103
|
+
export type MessageAction = {
|
|
104
|
+
type: "STREAM_EVENT";
|
|
105
|
+
event: MessageStreamEvent | ToolStreamEvent | SystemStreamEvent;
|
|
106
|
+
} | {
|
|
107
|
+
type: "USER_MESSAGE";
|
|
108
|
+
message: ChatMessage;
|
|
109
|
+
} | {
|
|
110
|
+
type: "LOAD_HISTORY";
|
|
111
|
+
messages: ChatMessage[];
|
|
112
|
+
hasMore: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
type: "CLEAR_MESSAGES";
|
|
115
|
+
} | {
|
|
116
|
+
type: "STREAM_ERROR";
|
|
117
|
+
error: string;
|
|
118
|
+
};
|
|
119
|
+
export type ThreadAction = {
|
|
120
|
+
type: "LOAD_THREADS";
|
|
121
|
+
threads: ThreadSummary[];
|
|
122
|
+
} | {
|
|
123
|
+
type: "SET_CURRENT_THREAD";
|
|
124
|
+
threadId: string | null;
|
|
125
|
+
} | {
|
|
126
|
+
type: "ADD_THREAD";
|
|
127
|
+
thread: ThreadSummary;
|
|
128
|
+
} | {
|
|
129
|
+
type: "REMOVE_THREAD";
|
|
130
|
+
threadId: string;
|
|
131
|
+
} | {
|
|
132
|
+
type: "UPDATE_THREAD";
|
|
133
|
+
threadId: string;
|
|
134
|
+
updates: Partial<ThreadSummary>;
|
|
135
|
+
} | {
|
|
136
|
+
type: "STREAM_EVENT";
|
|
137
|
+
event: ThreadStreamEvent;
|
|
138
|
+
} | {
|
|
139
|
+
type: "LOADING_THREADS";
|
|
140
|
+
loading: boolean;
|
|
141
|
+
} | {
|
|
142
|
+
type: "LOADING_THREAD";
|
|
143
|
+
loading: boolean;
|
|
144
|
+
};
|
|
145
|
+
export interface CoordinatorOptions {
|
|
146
|
+
onThreadInfo?: (ev: ThreadStreamEvent) => void;
|
|
147
|
+
onMessageEvent: (ev: MessageStreamEvent | ToolStreamEvent | SystemStreamEvent) => void;
|
|
148
|
+
onUnhandledEvent?: (ev: StreamEvent) => void;
|
|
149
|
+
onSequenceGap?: (info: {
|
|
150
|
+
expected: number;
|
|
151
|
+
got: number;
|
|
152
|
+
}) => void;
|
|
153
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { HistoryPayload, MessagePart } from "./models";
|
|
2
|
+
export type StreamCommand = {
|
|
3
|
+
kind: "resume";
|
|
4
|
+
value: unknown;
|
|
5
|
+
} | {
|
|
6
|
+
kind: "goto";
|
|
7
|
+
node: string;
|
|
8
|
+
value?: unknown;
|
|
9
|
+
};
|
|
10
|
+
type ToolEventIdentity = {
|
|
11
|
+
id: string;
|
|
12
|
+
call_id?: string;
|
|
13
|
+
} | {
|
|
14
|
+
call_id: string;
|
|
15
|
+
id?: string;
|
|
16
|
+
};
|
|
17
|
+
export type ToolStartEvent = {
|
|
18
|
+
type: "tool_start";
|
|
19
|
+
args: Record<string, unknown>;
|
|
20
|
+
name?: string;
|
|
21
|
+
tool?: string;
|
|
22
|
+
seq?: number;
|
|
23
|
+
} & ToolEventIdentity;
|
|
24
|
+
export type ToolEndEvent = {
|
|
25
|
+
type: "tool_end";
|
|
26
|
+
output: unknown;
|
|
27
|
+
error?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
tool?: string;
|
|
30
|
+
seq?: number;
|
|
31
|
+
} & ToolEventIdentity;
|
|
32
|
+
export type MessageStreamEvent = {
|
|
33
|
+
type: "token";
|
|
34
|
+
content: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: "message_start";
|
|
37
|
+
role: "assistant";
|
|
38
|
+
id: string;
|
|
39
|
+
model?: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "message_delta";
|
|
42
|
+
delta: MessagePart[];
|
|
43
|
+
} | {
|
|
44
|
+
type: "message_end";
|
|
45
|
+
};
|
|
46
|
+
export type ToolStreamEvent = ToolStartEvent | ToolEndEvent;
|
|
47
|
+
export type ThreadStreamEvent = {
|
|
48
|
+
type: "thread_info";
|
|
49
|
+
threadId: string;
|
|
50
|
+
title: string;
|
|
51
|
+
createdAt: string;
|
|
52
|
+
updatedAt: string;
|
|
53
|
+
messageCount: number;
|
|
54
|
+
lastMessage?: string | null;
|
|
55
|
+
created?: boolean | null;
|
|
56
|
+
ready?: boolean | null;
|
|
57
|
+
seq?: number | null;
|
|
58
|
+
} | {
|
|
59
|
+
type: "checkpoint";
|
|
60
|
+
checkpointId: string;
|
|
61
|
+
checkpointNs?: string | null;
|
|
62
|
+
} | {
|
|
63
|
+
type: "branch";
|
|
64
|
+
threadId: string;
|
|
65
|
+
parentThreadId?: string | null;
|
|
66
|
+
parentCheckpointId?: string | null;
|
|
67
|
+
checkpointId?: string | null;
|
|
68
|
+
checkpointNs?: string | null;
|
|
69
|
+
editedMessageId?: string | null;
|
|
70
|
+
branchLabel?: string | null;
|
|
71
|
+
};
|
|
72
|
+
export type SystemStreamEvent = {
|
|
73
|
+
type: "error";
|
|
74
|
+
message: string;
|
|
75
|
+
error_type?: string;
|
|
76
|
+
code?: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: "interrupt";
|
|
79
|
+
id: string;
|
|
80
|
+
value: any;
|
|
81
|
+
seq: number;
|
|
82
|
+
} | {
|
|
83
|
+
type: "heartbeat";
|
|
84
|
+
timestamp: number;
|
|
85
|
+
seq: number;
|
|
86
|
+
} | {
|
|
87
|
+
type: "cancelled";
|
|
88
|
+
reason?: string;
|
|
89
|
+
seq?: number;
|
|
90
|
+
} | ({
|
|
91
|
+
type: "state_history";
|
|
92
|
+
seq?: number;
|
|
93
|
+
} & HistoryPayload);
|
|
94
|
+
export type StreamEvent = MessageStreamEvent | ToolStreamEvent | ThreadStreamEvent | SystemStreamEvent;
|
|
95
|
+
export declare function isMessageEvent(ev: StreamEvent): ev is MessageStreamEvent;
|
|
96
|
+
export declare function isToolEvent(ev: StreamEvent): ev is ToolStreamEvent;
|
|
97
|
+
export declare function isThreadEvent(ev: StreamEvent): ev is ThreadStreamEvent;
|
|
98
|
+
export declare function isSystemEvent(ev: StreamEvent): ev is SystemStreamEvent;
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { TimelineCheckpoint } from "./timeline";
|
|
2
|
+
export type Role = "system" | "user" | "assistant" | "tool";
|
|
3
|
+
export type TextPart = {
|
|
4
|
+
type: "text";
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
export type ImagePart = {
|
|
8
|
+
type: "image_url";
|
|
9
|
+
url: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
alt?: string;
|
|
12
|
+
};
|
|
13
|
+
export type FilePart = {
|
|
14
|
+
type: "file";
|
|
15
|
+
url: string;
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
size?: number;
|
|
19
|
+
sourceType?: string;
|
|
20
|
+
};
|
|
21
|
+
export type ToolCallPart = {
|
|
22
|
+
type: "tool_call";
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
args: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
export type InterruptPart = {
|
|
28
|
+
type: "interrupt";
|
|
29
|
+
value?: any;
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
export type MessagePart = TextPart | ImagePart | FilePart | ToolCallPart | InterruptPart;
|
|
33
|
+
export interface ChatMessage {
|
|
34
|
+
id: string;
|
|
35
|
+
role: Role;
|
|
36
|
+
content: MessagePart[];
|
|
37
|
+
name?: string;
|
|
38
|
+
model?: string;
|
|
39
|
+
createdAt?: string;
|
|
40
|
+
checkpointId?: string;
|
|
41
|
+
checkpointNs?: string;
|
|
42
|
+
additionalKwargs?: Record<string, unknown>;
|
|
43
|
+
responseMetadata?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Default/welcome message type for rendering initial instructions
|
|
47
|
+
* Markdown content is automatically rendered with proper theme support
|
|
48
|
+
*/
|
|
49
|
+
export interface DefaultMessage {
|
|
50
|
+
id: "default-message";
|
|
51
|
+
role: "assistant";
|
|
52
|
+
type: "default_message";
|
|
53
|
+
content: string;
|
|
54
|
+
createdAt?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface PregelTask {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
path?: string[];
|
|
60
|
+
error?: string | null;
|
|
61
|
+
interrupts?: unknown[];
|
|
62
|
+
state?: unknown;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
export interface CheckpointSnapshot {
|
|
66
|
+
createdAt?: string | null;
|
|
67
|
+
config?: Record<string, unknown> | null;
|
|
68
|
+
metadata?: Record<string, unknown> | null;
|
|
69
|
+
values: {
|
|
70
|
+
messages: ChatMessage[];
|
|
71
|
+
results?: unknown[];
|
|
72
|
+
active_agent?: string | null;
|
|
73
|
+
research_summary?: string | null;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
next: unknown[];
|
|
77
|
+
parentConfig?: Record<string, unknown> | null;
|
|
78
|
+
tasks?: PregelTask[] | null;
|
|
79
|
+
}
|
|
80
|
+
export type PendingInterrupt = {
|
|
81
|
+
id: string;
|
|
82
|
+
value: unknown;
|
|
83
|
+
} | null;
|
|
84
|
+
export interface HydratedCheckpointSnapshot {
|
|
85
|
+
checkpointId: string | null;
|
|
86
|
+
checkpointNs: string | null;
|
|
87
|
+
createdAt: string | null;
|
|
88
|
+
parentId: string | null;
|
|
89
|
+
branchLabel: string | null;
|
|
90
|
+
lastMessageId: string | null;
|
|
91
|
+
messagesLen: number;
|
|
92
|
+
hasMessages: boolean;
|
|
93
|
+
messages: ChatMessage[];
|
|
94
|
+
nextCursor: string | null;
|
|
95
|
+
nextCursorNs: string | null;
|
|
96
|
+
interrupt: PendingInterrupt;
|
|
97
|
+
metadata?: Record<string, unknown> | null;
|
|
98
|
+
config?: Record<string, unknown> | null;
|
|
99
|
+
parentConfig?: Record<string, unknown> | null;
|
|
100
|
+
next?: unknown[] | null;
|
|
101
|
+
tasks?: PregelTask[] | null;
|
|
102
|
+
values?: Omit<CheckpointSnapshot["values"], "messages"> | null;
|
|
103
|
+
}
|
|
104
|
+
export interface HistoryPayload {
|
|
105
|
+
version: "chat-history@1";
|
|
106
|
+
threadId: string;
|
|
107
|
+
checkpoints: CheckpointSnapshot[];
|
|
108
|
+
timeline?: TimelineCheckpoint[];
|
|
109
|
+
}
|
|
110
|
+
export interface CheckpointList {
|
|
111
|
+
thread_id: string;
|
|
112
|
+
items: HydratedCheckpointSnapshot[];
|
|
113
|
+
}
|
|
114
|
+
export interface StatePayload {
|
|
115
|
+
threadId: string;
|
|
116
|
+
checkpointId?: string;
|
|
117
|
+
state: unknown;
|
|
118
|
+
}
|
|
119
|
+
export interface Envelope<T = unknown> {
|
|
120
|
+
protocolVersion: "v1";
|
|
121
|
+
data: T;
|
|
122
|
+
}
|
|
123
|
+
export interface ThreadSummary {
|
|
124
|
+
threadId: string;
|
|
125
|
+
title: string;
|
|
126
|
+
createdAt: string;
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
messageCount: number;
|
|
129
|
+
}
|
|
130
|
+
export interface ThreadInfo extends ThreadSummary {
|
|
131
|
+
lastMessage?: string | null;
|
|
132
|
+
}
|
|
133
|
+
export interface AgentSummary {
|
|
134
|
+
agentId: string;
|
|
135
|
+
name: string;
|
|
136
|
+
stateValue?: string | null;
|
|
137
|
+
description?: string | null;
|
|
138
|
+
}
|
|
139
|
+
export interface AgentList {
|
|
140
|
+
items: AgentSummary[];
|
|
141
|
+
}
|
|
142
|
+
export interface AgentDetail extends AgentSummary {
|
|
143
|
+
transferBackTo: string[];
|
|
144
|
+
transferForwardTo: string[];
|
|
145
|
+
transferReasons: Record<string, string>;
|
|
146
|
+
handoffQuestions: Record<string, string>;
|
|
147
|
+
saveBeforeTransfer: Record<string, boolean>;
|
|
148
|
+
outputStyle?: string | null;
|
|
149
|
+
systemPrompt?: string | null;
|
|
150
|
+
uiDefaultMessage?: string | null;
|
|
151
|
+
}
|
|
152
|
+
export interface AgentSchemaInfo {
|
|
153
|
+
agentId: string;
|
|
154
|
+
schema: Record<string, unknown>;
|
|
155
|
+
}
|
|
156
|
+
export interface ExcelColumnSchema {
|
|
157
|
+
name: string;
|
|
158
|
+
sqlType: string;
|
|
159
|
+
nullable: boolean;
|
|
160
|
+
example?: string | null;
|
|
161
|
+
}
|
|
162
|
+
export interface ExcelSheetSchema {
|
|
163
|
+
sheetName: string;
|
|
164
|
+
tableName: string;
|
|
165
|
+
columns: ExcelColumnSchema[];
|
|
166
|
+
rowCount: number;
|
|
167
|
+
}
|
|
168
|
+
export interface ExcelUploadResponse {
|
|
169
|
+
status: "ok";
|
|
170
|
+
sheets: ExcelSheetSchema[];
|
|
171
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StreamCommand } from "./events";
|
|
2
|
+
export interface ChatRequest {
|
|
3
|
+
threadId?: string | null;
|
|
4
|
+
payload?: Record<string, unknown>;
|
|
5
|
+
checkpointId?: string | null;
|
|
6
|
+
checkpointNs?: string | null;
|
|
7
|
+
nodeFilter?: string | string[] | null;
|
|
8
|
+
config?: Record<string, unknown>;
|
|
9
|
+
edit?: boolean;
|
|
10
|
+
originalMessageId?: string;
|
|
11
|
+
branchLabel?: string;
|
|
12
|
+
active_agent?: string;
|
|
13
|
+
command?: StreamCommand | null;
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teodor-new-chat-ui",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.258",
|
|
4
4
|
"description": "React chat UI components with streaming support, tool calls, and modern design",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -35,21 +35,6 @@
|
|
|
35
35
|
},
|
|
36
36
|
"private": false,
|
|
37
37
|
"type": "module",
|
|
38
|
-
"scripts": {
|
|
39
|
-
"dev": "vite",
|
|
40
|
-
"build": "npm run build:lib && npm run build:types",
|
|
41
|
-
"build:lib": "vite build --mode library",
|
|
42
|
-
"build:types": "tsc --project tsconfig.build.json",
|
|
43
|
-
"bump": "node scripts/bump-version.mjs",
|
|
44
|
-
"bump:minor": "node scripts/bump-version.mjs minor",
|
|
45
|
-
"bump:major": "node scripts/bump-version.mjs major",
|
|
46
|
-
"build:dev": "vite build --mode development",
|
|
47
|
-
"lint": "eslint .",
|
|
48
|
-
"preview": "vite preview",
|
|
49
|
-
"prepare": "npm run build",
|
|
50
|
-
"prepublishOnly": "npm run build",
|
|
51
|
-
"test": "vitest"
|
|
52
|
-
},
|
|
53
38
|
"peerDependencies": {
|
|
54
39
|
"react": ">=18.0.0",
|
|
55
40
|
"react-dom": ">=18.0.0",
|
|
@@ -144,5 +129,18 @@
|
|
|
144
129
|
"typescript-eslint": "^8.40.0",
|
|
145
130
|
"vite": "^5.4.19",
|
|
146
131
|
"vitest": "^2.1.4"
|
|
132
|
+
},
|
|
133
|
+
"scripts": {
|
|
134
|
+
"dev": "vite",
|
|
135
|
+
"build": "npm run build:lib && npm run build:types",
|
|
136
|
+
"build:lib": "vite build --mode library",
|
|
137
|
+
"build:types": "tsc --project tsconfig.build.json",
|
|
138
|
+
"bump": "node scripts/bump-version.mjs",
|
|
139
|
+
"bump:minor": "node scripts/bump-version.mjs minor",
|
|
140
|
+
"bump:major": "node scripts/bump-version.mjs major",
|
|
141
|
+
"build:dev": "vite build --mode development",
|
|
142
|
+
"lint": "eslint .",
|
|
143
|
+
"preview": "vite preview",
|
|
144
|
+
"test": "vitest"
|
|
147
145
|
}
|
|
148
|
-
}
|
|
146
|
+
}
|