-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopilot.interface.ts
More file actions
92 lines (77 loc) · 2.41 KB
/
copilot.interface.ts
File metadata and controls
92 lines (77 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT
// SSE event types from our Express server to the client
export type CopilotSSEEventType = 'status' | 'block' | 'content' | 'session_id' | 'done' | 'error';
// Frontend loading stages derived from upstream stream events
export type CopilotStreamStage = 'starting' | 'analyzing' | 'querying' | 'preparing' | 'complete';
// Block types from LFX Copilot API response
export type CopilotBlockType = 'message' | 'sql' | 'suggestions';
export interface CopilotMessageBlock {
type: 'message';
content: string;
}
export interface CopilotSqlBlock {
type: 'sql';
sql: string;
result: {
data: Record<string, unknown>[];
columns: string[];
rowCount: number;
} | null;
}
export interface CopilotSuggestionsBlock {
type: 'suggestions';
items: string[];
}
export type CopilotBlock = CopilotMessageBlock | CopilotSqlBlock | CopilotSuggestionsBlock;
// What the frontend stores per conversation turn
export interface CopilotMessage {
role: 'user' | 'assistant';
content: string;
blocks: CopilotBlock[];
loading: boolean;
}
// Context passed from dashboards (maps to API's additional_data)
export interface CopilotContext {
foundation: { slug: string; name: string };
company?: { id: string; name?: string };
}
// Request body from Angular to Express
export interface CopilotChatRequest {
message: string;
sessionId?: string;
context?: CopilotContext;
}
// The full LFX Copilot API response (sync mode)
export interface LfxCopilotApiResponse {
content: { blocks: CopilotBlock[] };
session_id: string;
status: 'COMPLETED' | 'ERROR';
run_id: string;
metrics?: {
duration: number;
steps: Record<string, { metrics: { input_tokens: number; output_tokens: number; duration: number } }>;
};
}
// Server-side query parameters for the Copilot service
export interface CopilotQueryParams {
message: string;
userId: string;
sessionId?: string;
context?: CopilotContext;
}
// Server-side SSE event emitted by the Copilot service
export interface CopilotSSEEvent {
type: CopilotSSEEventType;
data: unknown;
}
// Visual config for a loading stage
export interface CopilotStageConfig {
stage: CopilotStreamStage;
label: string;
dotColor: string;
}
// Stage config extended with runtime status
export interface CopilotStageStatus extends CopilotStageConfig {
status: 'pending' | 'active' | 'completed';
}