import * as _langchain_core_messages from '@langchain/core/messages'; import * as _langchain_langgraph from '@langchain/langgraph'; import { AnnotationRoot, StateDefinition, StateGraph, BaseCheckpointSaver, CheckpointTuple, Checkpoint, CheckpointMetadata, BaseStore, Item, Operation, OperationResults } from '@langchain/langgraph'; import { AbstractAgent, AgentConfig, RunAgentInput, EventType, BaseEvent } from '@ag-ui/client'; import { Observable, Subscriber } from 'rxjs'; import { InteropZodObject } from '@langchain/core/utils/types'; import { Logger } from '@cloudbase/agent-shared'; export { Logger, createConsoleLogger, noopLogger } from '@cloudbase/agent-shared'; import { RunnableConfig } from '@langchain/core/runnables'; import { IMemoryClientOptions, MemoryClient } from '@cloudbase/agent-agents'; import { CheckpointListOptions as CheckpointListOptions$1, PendingWrite as PendingWrite$1 } from '@langchain/langgraph-checkpoint'; import { CloudBase } from '@cloudbase/node-sdk'; type SDZod = StateDefinition | InteropZodObject; type CompiledStateGraph = ReturnType["compile"]>; type AnnotationInside = T extends AnnotationRoot ? U : never; type ClientStateDefinition = AnnotationInside; declare const ClientPropertiesAnnotation: AnnotationRoot<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }>; declare const ClientStateAnnotation: AnnotationRoot<{ messages: _langchain_langgraph.BaseChannel<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure<_langchain_core_messages.MessageToolSet>, _langchain_core_messages.MessageType>[], _langchain_langgraph.OverwriteValue<_langchain_core_messages.BaseMessage<_langchain_core_messages.MessageStructure<_langchain_core_messages.MessageToolSet>, _langchain_core_messages.MessageType>[]> | _langchain_langgraph.Messages, unknown>; client: { (annotation: _langchain_langgraph.SingleReducer<_langchain_langgraph.StateType<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }>, _langchain_langgraph.StateType<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }>>): _langchain_langgraph.BaseChannel<_langchain_langgraph.StateType<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }>, _langchain_langgraph.StateType<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }> | _langchain_langgraph.OverwriteValue<_langchain_langgraph.StateType<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }>>, unknown>; (): _langchain_langgraph.LastValue<_langchain_langgraph.StateType<{ tools: { (annotation: _langchain_langgraph.SingleReducer): _langchain_langgraph.BaseChannel, unknown>; (): _langchain_langgraph.LastValue; Root: (sd: S) => AnnotationRoot; }; }>>; Root: (sd: S) => AnnotationRoot; }; }>; type ClientState = typeof ClientStateAnnotation.State; declare class LanggraphAgent extends AbstractAgent { compiledWorkflow?: CompiledStateGraph; private observabilityCallback?; private adapterName; private logger; constructor(agentConfig: AgentConfig & { compiledWorkflow: any; adapterName?: string; /** * Logger instance for structured logging. * @default noopLogger (silent) */ logger?: Logger; }); run(input: RunAgentInput): Observable<{ type: EventType; timestamp?: number | undefined; rawEvent?: any; }>; _run(subscriber: Subscriber, input: RunAgentInput): Promise; clone(): LanggraphAgent; /** * Setup observability for agent execution. * Lazy loads observability callback, restores server context from forwardedProps, * and configures the callback for graph execution. */ private setupObservability; } type PendingWrite = [string, any]; interface CheckpointListOptions { limit?: number; before?: RunnableConfig; filter?: Record; } interface TDAISaverConfig extends IMemoryClientOptions { checkpointType?: string; checkpointWritesType?: string; } /** * TDAISaver - LangGraph checkpoint saver implementation using TDAI Memory * * Storage Strategy: * - Events (NoSQL): Store checkpoint data and pending writes in separate collections * - Supports namespaces and parent checkpoint relationships */ declare class TDAISaver extends BaseCheckpointSaver { private memoryClient; private checkpointType; private checkpointWritesType; constructor(config: TDAISaverConfig); /** * Retrieves a checkpoint from TDAI Memory based on the provided config. * If the config contains a "checkpoint_id" key, the checkpoint with the matching * thread ID and checkpoint ID is retrieved. Otherwise, the latest checkpoint * for the given thread ID is retrieved. */ getTuple(config: RunnableConfig): Promise; /** * Retrieve a list of checkpoint tuples from TDAI Memory based on the provided config. * The checkpoints are ordered by checkpoint ID in descending order (newest first). */ list(config: RunnableConfig, options?: CheckpointListOptions): AsyncGenerator; /** * Saves a checkpoint to TDAI Memory. The checkpoint is associated with the * provided config and its parent config (if any). */ put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise; /** * Saves intermediate writes associated with a checkpoint to TDAI Memory. */ putWrites(config: RunnableConfig, writes: PendingWrite[], taskId: string): Promise; /** * Delete all checkpoints and writes for a thread from TDAI Memory. */ deleteThread(threadId: string): Promise; /** * Close the memory client connection */ close(): void; } /** CloudBase database instance type (from app.database()) */ type CloudBaseDb = ReturnType; interface CloudBaseSaverConfig { /** CloudBase database instance from app.database() */ db: CloudBaseDb; /** User ID for multi-tenant isolation */ userId: string; /** Agent ID to distinguish different agents/graphs (default: "default") */ agentId?: string; /** Collection name for checkpoints (default: "checkpoints") */ checkpointsCollection?: string; /** Collection name for writes (default: "checkpoint_writes") */ writesCollection?: string; } /** * CloudBaseSaver - LangGraph checkpoint saver implementation using Tencent CloudBase * * Storage Strategy: * - Uses 2 collections: checkpoints and checkpoint_writes * - Data is serialized using BaseCheckpointSaver's serde (base64 encoded) * - Multi-tenant isolation via userId field */ declare class CloudBaseSaver extends BaseCheckpointSaver { private db; private userId; private agentId; private checkpointsCollection; private writesCollection; constructor(config: CloudBaseSaverConfig); /** * Setup the required collections in CloudBase. * Call this once before using the saver. Safe to call multiple times. */ setup(): Promise; /** * Serialize data to JSON object using serde. * CloudBase is a document database, so we store JSON directly instead of Base64. * Binary data (Uint8Array) is not supported - fail early if encountered. */ private serialize; /** * Deserialize JSON object back to data using serde. */ private deserialize; /** * Retrieves a checkpoint from CloudBase based on the provided config. */ getTuple(config: RunnableConfig): Promise; /** * List checkpoints from CloudBase, ordered by checkpoint_id descending. */ list(config: RunnableConfig, options?: CheckpointListOptions$1): AsyncGenerator; /** * Save a checkpoint to CloudBase. */ put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise; /** * Save intermediate writes to CloudBase. */ putWrites(config: RunnableConfig, writes: PendingWrite$1[], taskId: string): Promise; /** * Delete all checkpoints and writes for a thread. */ deleteThread(threadId: string): Promise; } /** * TDAI Store configuration */ interface TDAIStoreConfig { /** * TDAI Memory Client instance for long-term storage */ memoryClient: MemoryClient; /** * Session ID for storing records */ sessionId: string; /** * Optional namespace prefix for all operations */ namespacePrefix?: string[]; /** * TTL configuration for records */ ttl?: { defaultTtlSeconds?: number; sweepIntervalMinutes?: number; }; /** * Whether to ensure tables/collections exist on startup */ ensureTables?: boolean; /** * Default strategy for storing records */ defaultStrategy?: string; } /** * Filter operators for advanced filtering */ interface FilterOperators { $eq?: unknown; $ne?: unknown; $gt?: number | Date; $gte?: number | Date; $lt?: number | Date; $lte?: number | Date; $in?: unknown[]; $nin?: unknown[]; $exists?: boolean; $regex?: string; } /** * TDAI implementation of the BaseStore interface. * Uses TDAI Memory Client for long-term record storage. */ declare class TDAIStore extends BaseStore { private client; private namespacePrefix; private ttlConfig?; private ensureTables; private isSetup; private isClosed; private sweepInterval?; private sessionId; private defaultStrategy; constructor(config: TDAIStoreConfig); /** * Create a storage key from namespace and key */ private createStorageKey; /** * Parse a storage key back to namespace and key */ private parseStorageKey; /** * Put an item with optional TTL. */ put(namespace: string[], key: string, value: Record, index?: false | string[], options?: { ttl?: number; }): Promise; /** * Get an item by namespace and key. */ get(namespace: string[], key: string): Promise; /** * Delete an item by namespace and key. */ delete(namespace: string[], key: string): Promise; /** * List namespaces with optional filtering. */ listNamespaces(options?: { prefix?: string[]; suffix?: string[]; maxDepth?: number; limit?: number; offset?: number; }): Promise; /** * Execute multiple operations in a single batch. */ batch(operations: Op): Promise>; /** * Execute search operation */ private executeSearch; /** * Execute list namespaces operation */ private executeListNamespaces; /** * Initialize the store. */ setup(): Promise; /** * Start the store. */ start(): Promise; /** * Stop the store and close all connections. */ stop(): Promise; /** * Manually sweep expired items from the store. */ sweepExpiredItems(): Promise; /** * Get statistics about the store. */ getStats(): Promise<{ totalItems: number; expiredItems: number; namespaceCount: number; oldestItem: Date | null; newestItem: Date | null; }>; /** * Search for items in the store with support for text search and filtering. */ search(namespacePrefix: string[], options?: { /** * Filter conditions with support for advanced operators. */ filter?: Record; /** * Natural language search query. */ query?: string; /** * Maximum number of results to return. * @default 10 */ limit?: number; /** * Number of results to skip for pagination. * @default 0 */ offset?: number; /** * Whether to refresh TTL for returned items. */ refreshTtl?: boolean; }): Promise; } export { ClientPropertiesAnnotation, type ClientState, ClientStateAnnotation, CloudBaseSaver, type CloudBaseSaverConfig, LanggraphAgent, TDAISaver, type TDAISaverConfig, TDAIStore, type TDAIStoreConfig };