import { z } from 'zod'; /** * Cognis memory models */ interface CognisMessage { role: string; content: string; } interface CognisMemoryRecord { id: string; memory_id: string; content: string; owner_id?: string; agent_id?: string; session_id?: string; status?: string; is_current?: boolean; version?: number; salience_score?: number; decay_score?: number; metadata?: Record; created_at?: string; updated_at?: string; } interface CognisSearchResult { id: string; memory_id: string; content: string; score?: number; owner_id?: string; agent_id?: string; session_id?: string; metadata?: Record; created_at?: string; } interface CognisMemoryList { memories: CognisMemoryRecord[]; total: number; } /** * CognisModule — direct memory CRUD operations via the Lyzr memory API * * Distinct from MemoryModule which manages memory credentials/providers. * Creates its own HTTP client pointed at the memory service (different base URL). * * Example (standalone): * const cognis = new CognisModule('sk-xxx', 'https://memory.studio.lyzr.ai'); * await cognis.add({ messages: [...], ownerId: 'user_1' }); * * Example (through Studio): * const studio = new Studio({ apiKey: 'sk-xxx' }); * await studio.cognis.add({ messages: [...], ownerId: 'user_1' }); */ interface AddMemoryArgs { messages: (CognisMessage | { role: string; content: string; })[]; ownerId?: string; agentId?: string; sessionId?: string; } interface SearchMemoriesArgs { query: string; ownerId?: string; agentId?: string; sessionId?: string; limit?: number; crossSession?: boolean; } interface GetMemoriesArgs { ownerId?: string; agentId?: string; sessionId?: string; limit?: number; offset?: number; includeHistorical?: boolean; crossSession?: boolean; } interface UpdateMemoryArgs { content?: string; metadata?: Record; ownerId?: string; } interface GetContextArgs { currentMessages: (CognisMessage | { role: string; content: string; })[]; ownerId: string; sessionId?: string; agentId?: string; maxShortTermMessages?: number; enableLongTermMemory?: boolean; crossSession?: boolean; } interface GetMessagesArgs { ownerId?: string; sessionId?: string; agentId?: string; limit?: number; latest?: boolean; crossSession?: boolean; } interface StoreSummaryArgs { ownerId: string; sessionId: string; content: string; messagesCoveredCount: number; agentId?: string; } interface SearchSummariesArgs { ownerId: string; query: string; sessionId?: string; limit?: number; } declare class CognisModule { private _http; constructor(apiKey: string, memoryApiUrl: string); private static _validateIds; private static _buildIdBody; private static _parseMemoryList; private static _parseSearchResults; /** * Add messages to memory * * At least one of ownerId, agentId, sessionId must be provided. */ add(args: AddMemoryArgs): Promise>; /** * Search memories by semantic query */ search(args: SearchMemoriesArgs): Promise; /** * List memories for an owner/agent/session */ get(args: GetMemoriesArgs): Promise; /** * Get a specific memory by ID */ getMemory(memoryId: string, ownerId?: string): Promise; /** * Update a memory record (PATCH, then re-fetch to return updated state) */ update(memoryId: string, args: UpdateMemoryArgs): Promise; /** * Delete a memory record */ delete(memoryId: string, ownerId?: string): Promise; /** * Get conversation context (short-term + long-term memory assembly) * * Requires ownerId (server requirement). */ context(args: GetContextArgs): Promise>; /** * Get raw conversation messages */ getMessages(args: GetMessagesArgs): Promise>; /** * Store a conversation summary (auto-archives previous summary) * * ownerId is required by the memory service. */ storeSummary(args: StoreSummaryArgs): Promise>; /** * Get current active summary for a session * * ownerId is required by the memory service. */ getCurrentSummary(ownerId: string, sessionId: string): Promise>; /** * Search archived summaries * * ownerId is required by the memory service. */ searchSummaries(args: SearchSummariesArgs): Promise>; /** * Clear all messages and memories from a session */ deleteSession(ownerId: string, sessionId: string, agentId?: string): Promise; } /** * Cognis configuration for agent memory feature */ interface CognisConfig { /** Maximum messages to keep in conversation context (1-200, default: 20) */ maxMessagesContextCount: number; /** Whether to search memories across all sessions (default: false) */ crossSession: boolean; } declare function cognisConfigDefaults(): CognisConfig; /** * Convert CognisConfig to the agent features array format expected by the API */ declare function toFeatureFormat(config: CognisConfig): Record; /** * HTTP Client for Lyzr SDK * * Handles all HTTP communication with Lyzr APIs including: * - Request/response handling * - Error handling with custom exceptions * - Retry logic with exponential backoff * - Authentication via x-api-key header */ interface HTTPClientConfig { apiKey: string; baseUrl?: string; timeout?: number; retries?: number; retryDelay?: number; } declare class HTTPClient { private client; private config; readonly apiKey: string; readonly baseUrl: string; constructor(config: HTTPClientConfig); private setupInterceptors; get(path: string, params?: Record): Promise; post(path: string, data?: any, config?: any): Promise; put(path: string, data?: any): Promise; patch(path: string, data?: any): Promise; delete(path: string, options?: { params?: Record; data?: any; }): Promise; postFile(path: string, file: File | Buffer, params?: Record): Promise; private retry; private shouldRetry; private handleError; private sleep; } /** * Environment and URL configuration for Lyzr SDK */ type Environment = 'prod' | 'dev' | 'local'; interface EnvironmentConfig { agentApi: string; ragApi: string; raiApi: string; pagosApi: string; memoryApi: string; schedulerApi: string; } declare const ENV_CONFIGS: Record; declare function getEnvironmentConfig(env?: Environment): EnvironmentConfig; /** * Memory configuration schemas */ declare const MemoryConfigSchema: z.ZodObject<{ maxMessages: z.ZodDefault; }, "strip", z.ZodTypeAny, { maxMessages: number; }, { maxMessages?: number | undefined; }>; type MemoryConfig = z.infer; /** * Convert MemoryConfig to the agent features array format expected by the API */ declare function lyzrMemoryToFeatureFormat(config: MemoryConfig): Record; declare enum MemoryProvider { LYZR = "lyzr", AWS_AGENTCORE = "aws-agentcore", MEM0 = "mem0", SUPERMEMORY = "supermemory" } declare enum MemoryStatus { PENDING = "pending", VALIDATING = "validating", VALIDATED = "validated", ACTIVE = "active", FAILED = "failed", CREATING = "creating" } interface MemoryResource { id: string; name: string; status: string; createdAt: string; } /** * Memory entity - Provider connection */ declare class Memory { credentialId: string; provider: MemoryProvider; name: string; status?: MemoryStatus; memoryId?: string; memoryArn?: string; private _http; private _envConfig; constructor(data: any, http: HTTPClient, envConfig: EnvironmentConfig); validate(): Promise>; getStatus(): Promise; listResources(): Promise; useExisting(memoryId: string): Promise; deleteResource(): Promise; delete(): Promise; } /** * Response types for Lyzr SDK */ interface ArtifactData { name: string; file_url: string; format_type: string; artifact_id?: string; } declare class Artifact { name: string; url: string; formatType: string; artifactId?: string; constructor(data: ArtifactData); download(savePath: string): Promise; hasUrl(): boolean; } interface AgentResponse { response: string; sessionId: string; messageId?: string; metadata?: Record; toolCalls?: any[]; artifactFiles?: Artifact[]; rawResponse?: any; } interface AgentStream { content: string; delta?: string; done: boolean; sessionId: string; metadata?: Record; chunkIndex?: number; artifactFiles?: Artifact[]; } interface TaskResponse { taskId: string; status: string; sessionId: string; createdAt?: string; } interface TaskStatus { taskId: string; status: 'pending' | 'processing' | 'completed' | 'failed'; result?: AgentResponse; error?: string; progress?: number; metadata?: Record; isComplete(): boolean; isFailed(): boolean; } interface AgentList { items: any[]; total: number; skip: number; limit: number; } interface KnowledgeBaseList { items: any[]; total: number; skip: number; limit: number; } interface ContextList { items: any[]; total: number; skip: number; limit: number; } interface RAIPolicyList { items: any[]; total: number; skip: number; limit: number; } interface MemoryList { items: any[]; total: number; skip: number; limit: number; } /** * Agent configuration and schemas */ declare const AgentConfigSchema: z.ZodObject<{ name: z.ZodString; role: z.ZodString; goal: z.ZodString; instructions: z.ZodString; provider: z.ZodString; description: z.ZodOptional; temperature: z.ZodOptional; topP: z.ZodOptional; responseModel: z.ZodOptional; storeMessages: z.ZodOptional; fileOutput: z.ZodOptional; imageOutputConfig: z.ZodOptional>; memory: z.ZodOptional; crossSession: z.ZodOptional; }, "strip", z.ZodTypeAny, { maxMessagesContextCount?: number | undefined; crossSession?: boolean | undefined; }, { maxMessagesContextCount?: number | undefined; crossSession?: boolean | undefined; }>, z.ZodObject<{ maxMessages: z.ZodOptional; }, "strip", z.ZodTypeAny, { maxMessages?: number | undefined; }, { maxMessages?: number | undefined; }>]>>; features: z.ZodOptional>; contexts: z.ZodOptional>; reflection: z.ZodOptional; biasCheck: z.ZodOptional; llmJudge: z.ZodOptional; groundednessFacts: z.ZodOptional>; raiPolicy: z.ZodOptional; imageModel: z.ZodOptional; localTools: z.ZodOptional, z.ZodUnknown>, "many">>; tools: z.ZodOptional>; toolConfigs: z.ZodOptional, "many">>; examples: z.ZodOptional; managedAgents: z.ZodOptional>; }, "strip", z.ZodTypeAny, { name: string; role: string; goal: string; instructions: string; provider: string; description?: string | undefined; temperature?: number | undefined; topP?: number | undefined; responseModel?: any; storeMessages?: boolean | undefined; fileOutput?: boolean | undefined; imageOutputConfig?: Record | undefined; memory?: number | boolean | { maxMessagesContextCount?: number | undefined; crossSession?: boolean | undefined; } | { maxMessages?: number | undefined; } | undefined; features?: any[] | undefined; contexts?: any[] | undefined; reflection?: boolean | undefined; biasCheck?: boolean | undefined; llmJudge?: boolean | undefined; groundednessFacts?: string[] | undefined; raiPolicy?: any; imageModel?: any; localTools?: ((...args: unknown[]) => unknown)[] | undefined; tools?: string[] | undefined; toolConfigs?: Record[] | undefined; examples?: string | undefined; managedAgents?: any[] | undefined; }, { name: string; role: string; goal: string; instructions: string; provider: string; description?: string | undefined; temperature?: number | undefined; topP?: number | undefined; responseModel?: any; storeMessages?: boolean | undefined; fileOutput?: boolean | undefined; imageOutputConfig?: Record | undefined; memory?: number | boolean | { maxMessagesContextCount?: number | undefined; crossSession?: boolean | undefined; } | { maxMessages?: number | undefined; } | undefined; features?: any[] | undefined; contexts?: any[] | undefined; reflection?: boolean | undefined; biasCheck?: boolean | undefined; llmJudge?: boolean | undefined; groundednessFacts?: string[] | undefined; raiPolicy?: any; imageModel?: any; localTools?: ((...args: unknown[]) => unknown)[] | undefined; tools?: string[] | undefined; toolConfigs?: Record[] | undefined; examples?: string | undefined; managedAgents?: any[] | undefined; }>; type AgentConfig = z.infer; /** * Runtime options for running an agent */ interface RunOptions { sessionId?: string; userId?: string; stream?: boolean; knowledgeBases?: any[]; systemPromptVariables?: Record; features?: any[]; } /** * Inference Module - Agent execution and streaming * * Uses: * POST /v3/inference/chat/ (agent_id in body, not URL) * POST /v3/inference/stream/ (SSE format, agent_id in body) */ declare class InferenceModule { private http; constructor(http: HTTPClient); /** Build the common chat/stream payload. */ private buildPayload; /** * Synchronous chat - single message execution */ chat(agentId: string, message: string, sessionId: string, userId?: string, options?: RunOptions): Promise; /** * Streaming chat - returns async iterable of SSE chunks */ stream(agentId: string, message: string, sessionId: string, userId?: string, options?: RunOptions): AsyncIterable; /** * Task-based execution - returns immediately with task ID */ task(agentId: string, message: string, sessionId: string, userId?: string, options?: RunOptions): Promise; /** * Get task status */ getTaskStatus(taskId: string): Promise; /** * Cancel a running task */ cancelTask(taskId: string): Promise; /** * Wait for task to complete with polling */ waitForTask(taskId: string, pollInterval?: number, timeout?: number): Promise; } /** * Local Tools module for Lyzr SDK * * Enables local tool execution with agents using simple function registration. * No decorators needed - just pass your functions directly! */ interface ToolParameter { name: string; type: string; description?: string; required: boolean; } /** * Tool - Represents a local function that can be executed */ declare class Tool { name: string; description: string; parameters: ToolParameter[]; func: Function; constructor(func: Function, name?: string, description?: string); toApiFormat(): Record; execute(args: Record): Promise; } /** * ToolRegistry - Manages tools for an agent */ declare class ToolRegistry { private tools; add(tool: Tool): void; register(tool: Tool): void; remove(toolName: string): boolean; get(name: string): Tool | undefined; list(): Tool[]; clear(): void; toApiFormat(): Record[]; has(name: string): boolean; size(): number; } /** * LocalToolExecutor - Executes local tools during agent runs */ declare class LocalToolExecutor { private tools; constructor(tools: ToolRegistry); execute(toolName: string, arguments_: Record): Promise; } /** * Image Generation Models - Typed image model configurations * * Mirrors Python SDK's image_models.py. * Use these with agent.setImageModel() or AgentConfig.imageModel. * * Example: * const agent = await studio.createAgent({ ... }); * await agent.setImageModel(DallE.DALL_E_3); */ declare enum ImageProvider { GOOGLE = "Google", OPENAI = "OpenAI" } interface ImageModelConfig { model: string; credential_id: string; provider: ImageProvider; } /** * Google Gemini image generation models */ declare const Gemini: { PRO: ImageModelConfig; FLASH: ImageModelConfig; }; /** * OpenAI DALL-E and GPT image generation models */ declare const DallE: { DALL_E_3: ImageModelConfig; DALL_E_2: ImageModelConfig; GPT_IMAGE_1: ImageModelConfig; GPT_IMAGE_1_5: ImageModelConfig; }; /** * Skills Module for Lyzr ADK * * Skills are instruction sets that agents can load on-demand. * They provide a progressive disclosure pattern where agents see metadata * upfront and can load full content via the use_skill tool when needed. * * Mirrors Python SDK's skills/ package. * * Example: * import { Skill, loadSkills } from '@lyzr-sdk/adk'; * * const skills = [ * new Skill({ * name: 'research', * description: 'Research assistant for finding information', * content: 'Full research instructions...' * }) * ]; * * const agent = await studio.createAgent({ ... }); * agent.addSkills(skills); */ interface SkillMetadata { name: string; description: string; usage?: string; tags?: string[]; version?: string; } declare class Skill { name: string; description: string; /** Full skill content (instructions, examples, etc.) */ content: string; metadata?: SkillMetadata; constructor(data: { name: string; description: string; content?: string; metadata?: SkillMetadata; }); } /** * Generate a markdown metadata prompt describing all available skills. * This is injected into the agent's context so it knows what skills exist. */ declare function generateSkillsMetadataPrompt(skills: Skill[]): string; /** * Create a `use_skill` tool that returns the full content of a skill by name. * This tool is auto-registered when agent.addSkills() is called. */ declare function createUseSkillTool(skills: Skill[]): Tool; /** * Load skills from an array or filter by names. * Equivalent to Python SDK's load_skills(). * * @param options.skills - Array of Skill objects to use * @param options.names - Filter to only load skills with these names */ declare function loadSkills(options?: { skills?: Skill[]; names?: string[]; }): Skill[]; /** * Agent entity — smart agent object with methods for common operations. * * Memory state is tracked via the `features` array (type: "MEMORY" entries), * mirroring the Python SDK architecture. The `memory` config field is only * used at creation time; after that, `features` is the source of truth. * * Feature types managed here: * MEMORY, CONTEXT, RAI, SRS (reflection/bias), UQLM_LLM_JUDGE, GROUNDEDNESS */ interface AddMemoryOptions { /** Max messages to keep in context (default: 10) */ maxMessages?: number; /** Use Cognis provider instead of Lyzr default */ cognis?: boolean; /** Search memories across all sessions (Cognis only, default: false) */ crossSession?: boolean; } declare class Agent { id: string; name: string; role: string; goal: string; instructions: string; provider: string; providerId: string; model: string; credentialId: string; description?: string; temperature?: number; topP?: number; responseModel?: any; storeMessages?: boolean; fileOutput?: boolean; imageOutputConfig?: Record; imageModel?: any; managedAgents?: any[]; examples?: string; features: Record[]; private _http; private _agentModule; private _inference; private _tools; private _skills; private _skillsMetadataPrompt?; constructor(data: any, http: HTTPClient, agentModule: AgentModule, inference: InferenceModule); /** * Run the agent with a message */ run(message: string, options?: RunOptions): Promise>; /** * Update agent configuration */ update(config: Partial): Promise; /** * Delete the agent */ delete(): Promise; /** * Clone the agent with an optional new name */ clone(newName?: string): Promise; addTool(tool: Function | Tool): Agent; removeTool(toolName: string): Agent; getTools(): Tool[]; /** * Add skills to the agent (local-only, no API call). * Auto-registers a use_skill tool so the agent can load full skill content. */ addSkills(skills: Skill[]): Agent; hasSkills(): boolean; listSkills(): string[]; getSkillsMetadataPrompt(): string | undefined; hasMemory(): boolean; getMemoryConfig(): Record | undefined; addMemory(options?: AddMemoryOptions): Promise; removeMemory(): Promise; /** * Add a context to the agent. * Accepts a Context entity (with toFeatureFormat()) or a raw feature dict. */ addContext(context: { toFeatureFormat(): Record; } | Record): Promise; /** * Remove a context by Context entity or context ID string. */ removeContext(context: { id: string; } | string): Promise; /** * List all CONTEXT feature entries. */ listContexts(): Record[]; hasRaiPolicy(): boolean; /** * Add a RAI policy to the agent. * @param policy RAI policy entity with toFeatureFormat(endpoint) * @param raiEndpoint Optional RAI inference endpoint URL (auto-derived if omitted) */ addRaiPolicy(policy: { id: string; name: string; toFeatureFormat(endpoint: string): Record; }, raiEndpoint?: string): Promise; removeRaiPolicy(): Promise; enableFileOutput(): Promise; disableFileOutput(): Promise; hasFileOutput(): boolean; /** * Set the image generation model for this agent. */ setImageModel(imageModel: ImageModelConfig): Promise; disableImageOutput(): Promise; hasImageOutput(): boolean; private _getSrsModules; private _updateSrsModules; enableReflection(): Promise; disableReflection(): Promise; hasReflection(): boolean; enableBiasCheck(): Promise; disableBiasCheck(): Promise; hasBiasCheck(): boolean; enableLlmJudge(): Promise; disableLlmJudge(): Promise; hasLlmJudge(): boolean; addGroundednessFacts(facts: string[]): Promise; removeGroundedness(): Promise; hasGroundedness(): boolean; toDict(): Record; } /** * Agent Module - CRUD operations for agents * * Handles serialization of AgentConfig (camelCase, user-facing) to the * Lyzr API format (snake_case, agent_role/agent_goal/agent_instructions, * provider_id+model+llm_credential_id). * * update() mirrors the Python SDK: fetches current agent first, builds a * full merged payload (all required fields), PUTs it, then GETs the result. */ declare class AgentModule { private http; private envConfig; private inference; constructor(http: HTTPClient, envConfig: EnvironmentConfig); create(config: AgentConfig): Promise; get(agentId: string): Promise; list(userId?: string): Promise; /** * Update an agent, mirroring the Python SDK pattern: * 1. Fetch current agent to use as base values * 2. Build a FULL merged payload (API requires all required fields) * 3. PUT the full payload * 4. Fetch and return the updated agent */ update(agentId: string, config: Partial): Promise; delete(agentId: string): Promise; clone(agentId: string, newName?: string): Promise; bulkDelete(agentIds: string[]): Promise; removeRaiPolicy(agentId: string): Promise; private makeSmartAgent; } /** * Knowledge Base configuration schemas */ declare const KnowledgeBaseConfigSchema: z.ZodObject<{ name: z.ZodString; vectorStore: z.ZodDefault>; embeddingModel: z.ZodDefault; llmModel: z.ZodDefault; description: z.ZodOptional; semanticDataModel: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; vectorStore: "qdrant" | "weaviate" | "pg_vector" | "milvus" | "neptune"; embeddingModel: string; llmModel: string; description?: string | undefined; semanticDataModel?: boolean | undefined; }, { name: string; description?: string | undefined; vectorStore?: "qdrant" | "weaviate" | "pg_vector" | "milvus" | "neptune" | undefined; embeddingModel?: string | undefined; llmModel?: string | undefined; semanticDataModel?: boolean | undefined; }>; type KnowledgeBaseConfig = z.infer; interface TrainingOptions { dataParser?: string; chunkSize?: number; chunkOverlap?: number; extraInfo?: string; } interface WebsiteOptions extends TrainingOptions { source?: string; maxCrawlPages?: number; maxCrawlDepth?: number; dynamicContentWaitSecs?: number; actor?: string; crawlerType?: string; } interface QueryOptions { topK?: number; retrievalType?: 'basic' | 'mmr' | 'hyde' | 'time_aware'; scoreThreshold?: number; lambdaParam?: number; timeDecayFactor?: number; } interface QueryResult { text: string; score: number; source?: string; metadata?: Record; } interface Document { id: string; name: string; type: string; size: number; uploadedAt: string; metadata?: Record; } /** * Knowledge Base entity * * Mirrors the Python SDK: ID comes from `_id` field in API response. * Training endpoints use the RAG API: /v3/train/text/, /v3/train/website/. * toAgenticConfig() returns { rag_id, ... } as expected by inference API. */ declare class KnowledgeBase { id: string; name: string; collectionName: string; description?: string; vectorStore: string; embeddingModel: string; llmModel: string; private _http; private _envConfig; private _module?; constructor(data: any, http: HTTPClient, envConfig: EnvironmentConfig, module?: KnowledgeBaseModule); /** * Add text to knowledge base * API: POST /v3/train/text/?rag_id={id} body: { data: [{text, source}] } */ addText(text: string, source: string, options?: TrainingOptions): Promise; /** * Add website content to knowledge base */ addWebsite(url: string | string[], options?: WebsiteOptions): Promise; query(queryText: string, options?: QueryOptions): Promise; listDocuments(): Promise; deleteDocuments(docIds: string[]): Promise; reset(): Promise; update(config: Partial): Promise; delete(): Promise; /** * Convert to agentic_rag config format expected by the inference API. * Pass the result to `agent.run(message, { knowledgeBases: [kb.toAgenticConfig()] })`. */ toAgenticConfig(options?: { topK?: number; retrievalType?: string; scoreThreshold?: number; timeDecayFactor?: number; }): Record; } /** * Knowledge Base Module - CRUD operations and training * * Uses the RAG API (separate base URL from the agent API). * All endpoints are under /v3/rag/ and /v3/train/. */ declare class KnowledgeBaseModule { private http; private envConfig; constructor(http: HTTPClient, envConfig: EnvironmentConfig); create(config: KnowledgeBaseConfig): Promise; get(kbId: string): Promise; list(userId?: string): Promise; private _parseListResponse; update(kbId: string, config: Partial): Promise; delete(kbId: string): Promise; bulkDelete(kbIds: string[]): Promise; _trainText(ragId: string, data: Array<{ text: string; source: string; }>, options?: TrainingOptions): Promise; _trainWebsite(ragId: string, urls: string[], options?: any): Promise; _query(ragId: string, query: string, topK?: number, retrievalType?: string, scoreThreshold?: number): Promise; } /** * Context module - Simple key-value context management * * API endpoints: /v3/contexts/ * The create/update calls return a message/context_id; then a GET is needed * for the full Context object (same pattern as agents). * * Context ID comes from `_id` field in the API response (Python Pydantic alias). * * toFeatureFormat() returns the CONTEXT feature format expected by the agent API. */ declare class Context { id: string; name: string; value: string; apiKey: string; createdAt: string; updatedAt: string; private _http; private _envConfig; constructor(data: any, http: HTTPClient, envConfig: EnvironmentConfig); update(value: string): Promise; delete(): Promise; /** * Convert to CONTEXT feature format for agent.update({ contexts: [ctx.toFeatureFormat()] }) * Matches Python SDK's to_feature_format(). */ toFeatureFormat(): Record; } declare class ContextModule { private http; private envConfig; constructor(http: HTTPClient, envConfig: EnvironmentConfig); create(name: string, value: string): Promise; get(contextId: string): Promise; list(skip?: number, limit?: number): Promise; update(contextId: string, value: string): Promise; delete(contextId: string): Promise; } /** * RAI (Responsible AI) Module - Guardrails and safety policies * * Uses the RAI API (separate base URL: raiApi). * All endpoints are under /v1/rai/. */ declare enum PIIType { CREDIT_CARD = "CREDIT_CARD", EMAIL = "EMAIL_ADDRESS", PHONE = "PHONE_NUMBER", SSN = "US_SSN", PERSON = "PERSON", LOCATION = "LOCATION", IP_ADDRESS = "IP_ADDRESS", URL = "URL", DATE_TIME = "DATE_TIME" } declare enum PIIAction { BLOCK = "block", REDACT = "redact", DISABLED = "disabled" } declare enum SecretsAction { MASK = "mask", BLOCK = "block", DISABLED = "disabled" } declare enum ValidationMethod { FULL = "full", PARTIAL = "partial" } declare class RAIPolicy { id: string; name: string; description: string; toxicityCheck?: Record; promptInjection?: Record; secretsDetection?: Record; piiDetection?: Record; nsfwCheck?: Record; allowedTopics?: Record; bannedTopics?: Record; keywords?: Record; fairnessAndBias?: Record; private _raiModule?; constructor(data: any, raiModule?: RAIModule); update(config: Partial): Promise; delete(): Promise; /** * Convert to RAI feature format for agent. * Matches Python SDK's to_feature_format(rai_endpoint). */ toFeatureFormat(raiEndpoint: string): Record; } interface RAIPolicyConfig { name: string; description?: string; toxicityThreshold?: number; promptInjection?: boolean; secretsDetection?: SecretsAction; piiDetection?: Partial>; bannedTopics?: string[]; nsfwCheck?: boolean; nsfwThreshold?: number; allowedTopics?: Record; keywords?: Record; fairnessAndBias?: Record; toxicityCheck?: Record; promptInjectionConfig?: Record; secretsDetectionConfig?: Record; piiDetectionConfig?: Record; nsfwCheckConfig?: Record; allowedTopicsConfig?: Record; bannedTopicsConfig?: Record; keywordsConfig?: Record; } declare class RAIModule { private http; private envConfig; constructor(mainHttp: HTTPClient, envConfig: EnvironmentConfig); private makeSmartPolicy; private buildPiiConfig; createPolicy(config: RAIPolicyConfig): Promise; getPolicy(policyId: string): Promise; listPolicies(): Promise; updatePolicy(policyId: string, config: Partial): Promise; deletePolicy(policyId: string): Promise; /** Get the RAI inference endpoint URL for adding policies to agents */ getRaiInferenceEndpoint(): string; } /** * Memory Module - Provider management */ declare class MemoryModule { private http; private envConfig; constructor(http: HTTPClient, envConfig: EnvironmentConfig); listProviders(): Promise; getProvider(providerId: string): Promise; createCredential(provider: string, name: string, credentials: Record): Promise; getMemory(credentialId: string, provider: string): Promise; listMemories(): Promise; deleteCredential(credentialId: string): Promise; } /** * Scheduler Module for Lyzr ADK * * Agent scheduling support via the Lyzr scheduler service. * Uses schedulerApi as base URL; all endpoints are under /schedules/. * * Example: * const studio = new Studio({ apiKey: 'sk-xxx' }); * * // Through Studio * const schedule = await studio.createSchedule({ * userId: 'user_123', * agentId: 'agent_abc', * cronExpression: '0 9 * * *', * message: 'Generate daily report', * timezone: 'America/New_York' * }); * * // Through module directly * const schedule = await studio.scheduler.create({ ... }); */ interface ScheduleCreate { /** User ID for agent execution */ userId: string; /** Agent ID to execute on schedule */ agentId: string; /** * 5-field cron expression: minute hour day month weekday * e.g. "0 9 * * *" = 9 AM daily, "*\/15 * * * *" = every 15 minutes. * Supports standard cron syntax: *, *\/n, n-m, n,m,k. */ cronExpression: string; /** Message to send to the agent on each run (default: '') */ message?: string; /** * IANA timezone for the cron expression (default: 'UTC'). * e.g. 'America/New_York', 'Europe/London', 'Asia/Kolkata'. */ timezone?: string; /** Retries on failure, 0–5 (default: 3) */ maxRetries?: number; /** Seconds between retries, 10–3600 (default: 60) */ retryDelay?: number; } interface Schedule { id: string; userId: string; agentId: string; message: string; cronExpression: string; timezone: string; maxRetries: number; retryDelay: number; isActive: boolean; createdAt?: string; updatedAt?: string; nextRunTime?: string; lastRunAt?: string; lastRunSuccess?: boolean; } interface ScheduleList { schedules: Schedule[]; total: number; } interface ListSchedulesOptions { userId?: string; agentId?: string; isActive?: boolean; skip?: number; limit?: number; } declare class SchedulerModule { private http; constructor(apiKey: string, envConfig: EnvironmentConfig); /** * Create a new agent schedule. * * @example * const schedule = await scheduler.create({ * userId: 'user_123', * agentId: 'agent_abc', * cronExpression: '0 9 * * *', * message: 'Generate daily report', * timezone: 'America/New_York' * }); */ create(config: ScheduleCreate): Promise; /** * Get a schedule by ID. */ get(scheduleId: string): Promise; /** * List schedules with optional filters. */ list(options?: ListSchedulesOptions): Promise; /** * Delete a schedule. */ delete(scheduleId: string): Promise; /** * Pause an active schedule (sets is_active = false). */ pause(scheduleId: string): Promise; /** * Resume a paused schedule (sets is_active = true). */ resume(scheduleId: string): Promise; /** * Trigger a schedule to run immediately (one-off execution). */ trigger(scheduleId: string): Promise; } interface StudioConfig { apiKey?: string; env?: Environment; logLevel?: 'debug' | 'info' | 'warning' | 'error' | 'none'; timeout?: number; retries?: number; } declare class Studio { private http; readonly envConfig: EnvironmentConfig; agents: AgentModule; knowledgeBases: KnowledgeBaseModule; contexts: ContextModule; rai: RAIModule; memory: MemoryModule; cognis: CognisModule; scheduler: SchedulerModule; private inference; constructor(config?: StudioConfig); createAgent(config: AgentConfig): Promise; getAgent(agentId: string): Promise; listAgents(userId?: string): Promise; updateAgent(agentId: string, config: Partial): Promise; deleteAgent(agentId: string): Promise; cloneAgent(agentId: string, newName?: string): Promise; bulkDeleteAgents(agentIds: string[]): Promise; createKnowledgeBase(config: KnowledgeBaseConfig): Promise; getKnowledgeBase(kbId: string): Promise; listKnowledgeBases(userId?: string): Promise; updateKnowledgeBase(kbId: string, config: Partial): Promise; deleteKnowledgeBase(kbId: string): Promise; createContext(name: string, value: string): Promise; getContext(contextId: string): Promise; listContexts(skip?: number, limit?: number): Promise; updateContext(contextId: string, value: string): Promise; deleteContext(contextId: string): Promise; createRAIPolicy(config: RAIPolicyConfig): Promise; getRAIPolicy(policyId: string): Promise; listRAIPolicies(): Promise; updateRAIPolicy(policyId: string, config: Partial): Promise; deleteRAIPolicy(policyId: string): Promise; createMemoryCredential(provider: string, name: string, credentials: Record): Promise; listMemoryProviders(): Promise; getMemoryProvider(providerId: string): Promise; /** Add messages to memory */ addMemory(args: AddMemoryArgs): Promise>; /** Search memories by semantic query */ searchMemories(args: SearchMemoriesArgs): Promise; /** List memories for an owner/agent/session */ getMemories(args: GetMemoriesArgs): Promise; /** Update a memory record */ updateMemory(memoryId: string, args: UpdateMemoryArgs): Promise; /** Delete a memory record */ deleteMemory(memoryId: string, ownerId?: string): Promise; /** Get conversation context (short + long term memory assembly) */ getMemoryContext(args: GetContextArgs): Promise>; /** Get raw conversation messages */ getMemoryMessages(args: GetMessagesArgs): Promise>; /** Store a conversation summary */ storeMemorySummary(args: StoreSummaryArgs): Promise>; /** Get current active summary for a session */ getCurrentMemorySummary(ownerId: string, sessionId: string): Promise>; /** Search archived summaries */ searchMemorySummaries(args: SearchSummariesArgs): Promise>; /** Clear all messages and memories from a session */ deleteMemorySession(ownerId: string, sessionId: string, agentId?: string): Promise; /** Create a new agent cron schedule */ createSchedule(config: ScheduleCreate): Promise; /** Get a schedule by ID */ getSchedule(scheduleId: string): Promise; /** List schedules with optional filters */ listSchedules(options?: ListSchedulesOptions): Promise<{ schedules: Schedule[]; total: number; }>; /** Delete a schedule */ deleteSchedule(scheduleId: string): Promise; /** Pause an active schedule */ pauseSchedule(scheduleId: string): Promise; /** Resume a paused schedule */ resumeSchedule(scheduleId: string): Promise; /** Trigger a schedule to run immediately */ triggerSchedule(scheduleId: string): Promise; } /** * Structured Outputs with Zod Validation * * Comprehensive Zod schema parsing and validation for LLM responses. * Handles JSON extraction, repair, validation, and type-safe returns. */ interface ParseOptions { maxRetries?: number; repairJson?: boolean; throwOnError?: boolean; defaultValue?: any; } /** * ResponseParser - Parse and validate LLM responses against Zod schemas */ declare class ResponseParser { /** * Parse and validate LLM response text against Zod schema * * @param responseText - Raw text response from LLM * @param schema - Zod schema to validate against * @param options - Parsing options * @returns Parsed and validated object */ static parse(responseText: string, schema: z.ZodSchema, options?: ParseOptions): T; /** * Parse with automatic retries on validation failure */ static parseWithRetry(responseText: string, schema: z.ZodSchema, maxRetries?: number): T; /** * Validate data against schema without parsing JSON */ static validate(data: unknown, schema: z.ZodSchema): T; /** * Safe parse - returns result object instead of throwing. * Uses schema.safeParse() directly to avoid wrapping ZodError. */ static safeParse(responseText: string, schema: z.ZodSchema): { success: true; data: T; } | { success: false; error: z.ZodError; }; /** * Extract JSON from response text using brace-counting for correct nesting. */ private static extractJson; /** * Find the first balanced JSON object or array in text using brace-counting. * Correctly handles nested structures unlike non-greedy regex. */ private static findBalancedJson; /** * Repair malformed JSON */ private static repairJson; /** * Aggressive JSON extraction for retry attempts */ private static aggressiveJsonExtraction; } /** * Streaming utilities for Lyzr SDK * * Provides utilities for handling streaming responses from agents. * Supports multiple streaming backends (fetch EventSource, Node.js streams). */ /** * Stream handler for processing chunks from EventSource */ interface StreamHandler { onChunk?(chunk: AgentStream): void; onError?(error: Error): void; onComplete?(): void; } /** * Stream processor for various streaming backends */ declare class StreamProcessor { /** * Process EventSource stream (browser-compatible) */ static fromEventSource(url: string, headers: Record): AsyncIterable; /** * Process fetch ReadableStream (Node.js 18+, browsers) */ static fromFetchStream(response: Response): AsyncIterable; /** * Process Node.js stream */ static fromNodeStream(stream: NodeJS.ReadableStream): AsyncIterable; /** * Collect all chunks from a stream */ static collectStream(stream: AsyncIterable): Promise; /** * Process stream with handler callbacks */ static processStream(stream: AsyncIterable, handler: StreamHandler): Promise; /** * Convert stream to promise that resolves with complete response */ static toPromise(stream: AsyncIterable): Promise; } /** * Exception hierarchy for Lyzr SDK */ declare class LyzrError extends Error { context?: Record | undefined; constructor(message: string, context?: Record | undefined); } declare class APIError extends LyzrError { statusCode?: number | undefined; constructor(message: string, statusCode?: number | undefined, context?: Record); } declare class ValidationError extends LyzrError { constructor(message: string, context?: Record); } declare class NotFoundError extends LyzrError { constructor(message: string, context?: Record); } declare class AuthenticationError extends LyzrError { constructor(message: string, context?: Record); } declare class RateLimitError extends LyzrError { retryAfter?: number | undefined; constructor(message: string, retryAfter?: number | undefined, context?: Record); } declare class TimeoutError extends LyzrError { constructor(message: string, context?: Record); } declare class InvalidResponseError extends LyzrError { constructor(message: string, context?: Record); } /** * Provider and model definitions for Lyzr SDK */ interface Model { id: string; name: string; provider: string; contextWindow: number; maxOutputTokens?: number; supportsFunctionCalling?: boolean; supportsStreaming?: boolean; } declare enum OpenAIModels { GPT_4O = "gpt-4o", GPT_4O_MINI = "gpt-4o-mini", GPT_4 = "gpt-4", GPT_3_5_TURBO = "gpt-3.5-turbo", O3 = "o3", O4_MINI = "o4-mini" } declare enum AnthropicModels { CLAUDE_SONNET_4_5 = "claude-sonnet-4-5", CLAUDE_OPUS_4_5 = "claude-opus-4-5", CLAUDE_OPUS = "claude-opus-4-1", CLAUDE_SONNET = "claude-3-5-sonnet", CLAUDE_HAIKU = "claude-3-5-haiku" } declare enum GoogleModels { GEMINI_2_0_FLASH = "gemini-2.0-flash", GEMINI_2_0_PRO = "gemini-2.0-pro", GEMINI_2_5_FLASH = "gemini-2.5-flash", GEMINI_2_5_PRO = "gemini-2.5-pro", GEMINI_3_0_FLASH = "gemini-3.0-flash", GEMINI_3_0_PRO = "gemini-3.0-pro" } declare class ModelResolver { /** * Resolve provider and model from a provider string (legacy, kept for compatibility). * Use resolveProvider() for the full ProviderInfo including credentialId. */ static resolve(providerString: string): { providerId: string; model: string; }; /** * Get model metadata by ID */ static getModel(modelId: string): Model | undefined; /** * Check if a model supports function calling */ static supportsFunctionCalling(modelId: string): boolean; /** * Check if a model supports streaming */ static supportsStreaming(modelId: string): boolean; /** * Get context window for a model */ static getContextWindow(modelId: string): number; } /** * Lyzr ADK - Main entry point */ declare const VERSION = "0.1.8"; export { APIError, type AddMemoryArgs, Agent, type AgentConfig, AgentModule, type AgentResponse, type AgentStream, AnthropicModels, Artifact, type ArtifactData, AuthenticationError, type CognisConfig, type CognisMemoryList, type CognisMemoryRecord, type CognisMessage, CognisModule, type CognisSearchResult, Context, ContextModule, DallE, type Document, ENV_CONFIGS, type Environment, type EnvironmentConfig, Gemini, type GetContextArgs, type GetMemoriesArgs, type GetMessagesArgs, GoogleModels, HTTPClient, type ImageModelConfig, ImageProvider, InferenceModule, InvalidResponseError, KnowledgeBase, type KnowledgeBaseConfig, KnowledgeBaseModule, type ListSchedulesOptions, LocalToolExecutor, LyzrError, Memory, type MemoryConfig, MemoryModule, MemoryProvider, MemoryStatus, type Model, ModelResolver, NotFoundError, OpenAIModels, PIIAction, PIIType, type QueryOptions, type QueryResult, RAIModule, RAIPolicy, type RAIPolicyConfig, RateLimitError, ResponseParser, type RunOptions, type Schedule, type ScheduleCreate, type ScheduleList, SchedulerModule, type SearchMemoriesArgs, type SearchSummariesArgs, SecretsAction, Skill, type SkillMetadata, type StoreSummaryArgs, type StreamHandler, StreamProcessor, Studio, type TaskResponse, type TaskStatus, TimeoutError, Tool, ToolRegistry, type TrainingOptions, type UpdateMemoryArgs, VERSION, ValidationError, ValidationMethod, type WebsiteOptions, cognisConfigDefaults, toFeatureFormat as cognisToFeatureFormat, createUseSkillTool, generateSkillsMetadataPrompt, getEnvironmentConfig, loadSkills, lyzrMemoryToFeatureFormat };