// Don't import from the generated folder, as it is removed when we build and publish the package. import type { AppendMessageInput, AppendMessageToConversationMutation, ConversationInput, CreateConversationInput, DeleteConversationInput, UpdateConversationTitleInput, GetAConversationQuery, GetAllConversationsQuery, DeleteAiDocumentMutation, UpdateAiDocumentMutation, UploadAiDocumentMutation, UpdateAiSettingsMutation, GetAiSettingsQuery, } from "./generated/apiHooks"; /** * Context passed to callbacks containing both request and response data */ export interface CallbackContext { /** * The original request details */ request: { /** * The full path of the request (e.g., "/ai-assistant?targetPath=/api") */ path: string; /** * The HTTP method (POST, GET, etc.) */ method: string; /** * The parsed request body */ body: TRequest; }; /** * The parsed response body from the proxied request */ response: TResponse; } /** * REST endpoint request/response types */ export interface ChatRequest { model?: "large" | "medium" | "small"; temperature?: number; stream?: boolean; maxTokens?: number; /** * Optional Vertex region override. When set, the server uses this region * for the LLM call instead of the `GCP_LLM_LOCATION` env-var default. * Leave unset (or empty string) to use the default. */ region?: string; messages: Array<{ role: "user" | "model" | "tool"; parts: Array< | { type: "text"; text: string; } | { type: "toolCall"; toolName: string; args: Record; } | { type: "toolResult"; toolName: string; result: unknown; } >; name?: string; }>; } export interface ChatResponse { role: "user" | "model" | "tool"; parts: Array< | { type: "text"; text: string; } | { type: "toolCall"; toolName: string; args: Record; } | { type: "toolResult"; toolName: string; result: unknown; } >; } export interface StructuredResponseRequest { model?: "large" | "medium" | "small"; prompt: string; schema: unknown; temperature?: number; maxTokens?: number; /** * Optional Vertex region override. When set, the server uses this region * for the LLM call instead of the `GCP_LLM_LOCATION` env-var default. * Leave unset (or empty string) to use the default. */ region?: string; } export type StructuredResponseResponse = unknown; export interface TTSRequest { text: string; voice?: string; } export interface TTSResponse { synthesis: string; } export interface STTRequest { audio: string; } export interface STTResponse { transcription: Array<{ transcript: string; confidence: number; }>; } /** * GraphQL request wrapper */ export interface GraphQLRequest { operationName?: string; query: string; variables?: TVariables; } /** * GraphQL response wrapper with potential errors */ export interface GraphQLResponse { data?: TData; errors?: Array<{ message: string; extensions?: Record; }>; } /** * Callbacks for REST endpoints * Note: Keys are URL paths, not following camelCase convention intentionally */ export interface RestEndpointCallbacks { // eslint-disable-next-line @typescript-eslint/naming-convention "/api/api-ai-assistant/v1/chat"?: ( context: CallbackContext ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention "/api/api-ai-assistant/v1/structured-response"?: ( context: CallbackContext< StructuredResponseRequest, StructuredResponseResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention "/api/api-ai-assistant/v1/tts"?: ( context: CallbackContext ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention "/api/api-ai-assistant/v1/stt"?: ( context: CallbackContext ) => void | Promise; } /** * Callbacks for GraphQL operations * Note: Keys match the GraphQL operation names (PascalCase), not the field names */ export interface GraphQLOperationCallbacks { // eslint-disable-next-line @typescript-eslint/naming-convention AppendMessageToConversation?: ( context: CallbackContext< GraphQLRequest<{ input: AppendMessageInput }>, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention GetAConversation?: ( context: CallbackContext< GraphQLRequest<{ input: ConversationInput }>, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention GetAllConversations?: ( context: CallbackContext< GraphQLRequest>, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention CreateConversation?: ( context: CallbackContext< GraphQLRequest<{ input: CreateConversationInput }>, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention DeleteConversation?: ( context: CallbackContext< GraphQLRequest<{ input: DeleteConversationInput }>, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention UpdateConversationTitle?: ( context: CallbackContext< GraphQLRequest<{ input: UpdateConversationTitleInput }>, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention DeleteAiDocument?: ( context: CallbackContext< GraphQLRequest, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention UpdateAiDocument?: ( context: CallbackContext< GraphQLRequest, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention UploadAiDocument?: ( context: CallbackContext< GraphQLRequest, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention UpdateAiSettings?: ( context: CallbackContext< GraphQLRequest, GraphQLResponse > ) => void | Promise; // eslint-disable-next-line @typescript-eslint/naming-convention GetAiSettings?: ( context: CallbackContext< GraphQLRequest>, GraphQLResponse > ) => void | Promise; }