121 lines
2.9 KiB
TypeScript
121 lines
2.9 KiB
TypeScript
/**
|
|
* Data Transfer Objects for the REST API.
|
|
* Wire format for request/response bodies — independent of domain entities.
|
|
* Mirrors `apps/interfaces/api/src/dto/*.rs`.
|
|
*/
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* Auth DTOs */
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
export interface LoginRequest {
|
|
username: string;
|
|
password: string;
|
|
}
|
|
|
|
export interface RegisterRequest {
|
|
username: string;
|
|
password: string;
|
|
/** Optional display name. */
|
|
display_name?: string;
|
|
}
|
|
|
|
export interface RefreshRequest {
|
|
refresh_token: string;
|
|
}
|
|
|
|
export interface AuthResponse {
|
|
access_token: string;
|
|
refresh_token: string;
|
|
token_type: string;
|
|
expires_in: number;
|
|
}
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* Session DTOs */
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
export interface CreateSessionRequest {
|
|
title: string;
|
|
}
|
|
|
|
export interface SessionResponse {
|
|
id: string;
|
|
created_at: number;
|
|
updated_at: number;
|
|
title: string;
|
|
model: string;
|
|
message_count: number;
|
|
archived: boolean;
|
|
summary?: string;
|
|
}
|
|
|
|
export interface SessionListResponse {
|
|
sessions: SessionResponse[];
|
|
total: number;
|
|
}
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* Conversation DTOs */
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
export interface AddMessageRequest {
|
|
role: string;
|
|
content: string;
|
|
}
|
|
|
|
export interface ToolFunctionResponse {
|
|
name: string;
|
|
arguments: string;
|
|
}
|
|
|
|
export interface ToolCallResponse {
|
|
id: string;
|
|
function: ToolFunctionResponse;
|
|
}
|
|
|
|
export interface MessageResponse {
|
|
role: string;
|
|
content?: string;
|
|
tool_calls?: ToolCallResponse[];
|
|
tool_call_id?: string;
|
|
}
|
|
|
|
export interface ConversationResponse {
|
|
session_id: string;
|
|
messages: MessageResponse[];
|
|
message_count: number;
|
|
model: string;
|
|
system_prompt: string;
|
|
max_tokens?: number;
|
|
temperature?: number;
|
|
}
|
|
|
|
export interface ChatCompletionRequest {
|
|
session_id: string;
|
|
message: string;
|
|
model?: string;
|
|
max_tokens?: number;
|
|
temperature?: number;
|
|
}
|
|
|
|
export interface ChatCompletionResponse {
|
|
reply: string;
|
|
prompt_tokens: number;
|
|
completion_tokens: number;
|
|
}
|
|
|
|
/* -------------------------------------------------------------------------- */
|
|
/* Error DTO */
|
|
/* -------------------------------------------------------------------------- */
|
|
|
|
export interface ErrorResponse {
|
|
message: string;
|
|
code: number;
|
|
}
|
|
|
|
/** Build a standardised error response body. */
|
|
export function errorBody(message: string, code: number): ErrorResponse {
|
|
return { message, code };
|
|
}
|