2025-12-24 17:17:35 +00:00
|
|
|
export type Role = "system" | "user" | "assistant" | "tool";
|
|
|
|
|
|
|
|
|
|
export interface ToolCall {
|
2025-12-27 16:50:18 +00:00
|
|
|
id?: string;
|
|
|
|
|
type: string;
|
|
|
|
|
function: {
|
|
|
|
|
name: string;
|
|
|
|
|
arguments: string;
|
|
|
|
|
};
|
2025-12-24 17:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Message {
|
2025-12-27 16:50:18 +00:00
|
|
|
role: Role;
|
|
|
|
|
content: string;
|
|
|
|
|
tool_calls?: ToolCall[];
|
|
|
|
|
tool_call_id?: string;
|
2025-12-24 17:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ProviderConfig {
|
2025-12-27 16:50:18 +00:00
|
|
|
provider: string;
|
|
|
|
|
model: string;
|
|
|
|
|
base_url?: string;
|
|
|
|
|
enable_tools?: boolean;
|
2026-02-20 11:51:19 +00:00
|
|
|
session_id?: string;
|
2025-12-24 17:17:35 +00:00
|
|
|
}
|
2026-02-13 12:31:36 +00:00
|
|
|
|
|
|
|
|
export interface FileEntry {
|
|
|
|
|
name: string;
|
|
|
|
|
kind: "file" | "dir";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface SearchResult {
|
|
|
|
|
path: string;
|
|
|
|
|
matches: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface CommandOutput {
|
|
|
|
|
stdout: string;
|
|
|
|
|
stderr: string;
|
|
|
|
|
exit_code: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type WsRequest =
|
|
|
|
|
| {
|
|
|
|
|
type: "chat";
|
|
|
|
|
messages: Message[];
|
|
|
|
|
config: ProviderConfig;
|
|
|
|
|
}
|
|
|
|
|
| {
|
|
|
|
|
type: "cancel";
|
2026-02-23 16:01:22 +00:00
|
|
|
}
|
|
|
|
|
| {
|
|
|
|
|
type: "permission_response";
|
|
|
|
|
request_id: string;
|
|
|
|
|
approved: boolean;
|
2026-02-27 10:00:33 +00:00
|
|
|
always_allow: boolean;
|
2026-02-13 12:31:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type WsResponse =
|
|
|
|
|
| { type: "token"; content: string }
|
|
|
|
|
| { type: "update"; messages: Message[] }
|
2026-02-20 11:51:19 +00:00
|
|
|
| { type: "session_id"; session_id: string }
|
2026-02-23 16:01:22 +00:00
|
|
|
| { type: "error"; message: string }
|
|
|
|
|
| {
|
|
|
|
|
type: "permission_request";
|
|
|
|
|
request_id: string;
|
|
|
|
|
tool_name: string;
|
|
|
|
|
tool_input: Record<string, unknown>;
|
|
|
|
|
};
|
2026-02-13 12:31:36 +00:00
|
|
|
|
|
|
|
|
// Re-export API client types for convenience
|
|
|
|
|
export type {
|
|
|
|
|
Message as ApiMessage,
|
|
|
|
|
ProviderConfig as ApiProviderConfig,
|
|
|
|
|
FileEntry as ApiFileEntry,
|
|
|
|
|
SearchResult as ApiSearchResult,
|
|
|
|
|
CommandOutput as ApiCommandOutput,
|
|
|
|
|
WsRequest as ApiWsRequest,
|
|
|
|
|
WsResponse as ApiWsResponse,
|
|
|
|
|
};
|