export interface IMessage { role: string; content: string; timestamp?: Date | string; tool_calls?: any[]; name?: string; tool_call_id?: string; function_call?: any; message_id?: string; } export interface IMessageSummary { fromIndex: number; toIndex: number; summary: string; } export interface IThread { _id?: string; integration: string; title?: string; messages: IMessage[]; messageSummaries: IMessageSummary[]; created?: Date; updated?: Date; user?: string; workspace?: string; } export interface IClientTool { name: string; description: string; schema?: any; } export interface IChatCompletionOptions { messages: IMessage[]; model?: string; temperature?: number; top_p?: number; frequency_penalty?: number; presence_penalty?: number; stop?: string | string[]; max_tokens?: number; response_format?: any; context?: Record; stream?: boolean; queryParams?: Record; clientTools?: IClientTool[]; rules?: string[]; } export interface ISSEStreamProcessor extends AsyncIterable { processManually(onData: (data: any) => void | boolean): Promise; } export interface IChatCompletionResponse { id: string; object: string; created: number; model: string; choices: Array<{ index: number; message: IMessage; finish_reason: string; }>; usage?: { prompt_tokens: number; completion_tokens: number; total_tokens: number; }; } export interface ICreateThreadRequest { integration: string; title?: string; } export interface ICreateVectorStorageRequest { integrationId: string; scope: 'thread' | 'user' | 'workspace' | 'tenant'; subjectId?: string; expirationAfterDays?: number; } export interface IUploadContentRequest { integrationId?: string; vectorStoreId?: string; content: string | object; fileName?: string; metadata?: Record; } export interface IClearStorageRequest { integrationId?: string; vectorStoreId?: string; fileIds?: string[]; } export interface IVectorStore { _id: string; scope: string; subjectId?: string; tenant: string; agent: string; externalId: string; expirationAfterDays?: number; created: Date; } export interface IAgentTool { name: string; description: string; schema?: object; } export interface IAgent { _id: string; name: string; description?: string; model?: string; kind?: string[]; active?: boolean; tenant?: string; user?: string; workspace?: string; systemPrompt?: string; tools?: IAgentTool[]; temperature?: number; maxTokens?: number; triggerSource?: string; targetSource?: string; created?: Date; updated?: Date; } /** Payload for `sdk.ai.agents.create()` — maps to a chat-completion integration */ export interface ICreateAgentRequest { name: string; model: string; triggerSource: string; targetSource: string; systemPrompt?: string; tools?: IAgentTool[]; temperature?: number; maxTokens?: number; workspace?: string; active?: boolean; } /** Partial update for `sdk.ai.agents.update()` */ export interface IUpdateAgentRequest { name?: string; model?: string; triggerSource?: string; targetSource?: string; systemPrompt?: string; tools?: IAgentTool[]; temperature?: number; maxTokens?: number; workspace?: string; active?: boolean; } export interface IAgentChatOptions extends Partial> { /** * Additional messages to prepend before the user message * (e.g. system prompt overrides, prior context) */ history?: IMessage[]; /** * When set, reuses an existing thread created by a prior agent chat call. */ threadId?: string; }