UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

86 lines (85 loc) 2.44 kB
import 'reflect-metadata'; import { Event, SessionInterface as Session, SessionsList } from './types'; import { BaseSessionService, ListEventsResponse } from './BaseSessionService'; /** * A session service that uses a database for persistent storage. * This implementation uses TypeORM with SQLite by default. */ export declare class DatabaseSessionService extends BaseSessionService { private dbUrl; private connection; private sessionRepo; private eventRepo; private appStateRepo; private userStateRepo; /** * Creates a new DatabaseSessionService. * @param dbUrl The database URL (e.g., 'sqlite:///:memory:' for in-memory SQLite) */ constructor(dbUrl: string); /** * Closes the database connection for this instance. * This is useful for testing to properly clean up resources. */ closeConnection(): Promise<void>; /** * Closes all database connections. * This static method is useful for testing to properly clean up resources. */ static closeAllConnections(): Promise<void>; /** * Ensures the database connection is established */ private ensureConnection; /** * Creates a new session. */ createSession(options: { appName: string; userId: string; sessionId?: string; state?: Record<string, any>; }): Promise<Session>; /** * Gets a session by its ID. */ getSession(options: { appName: string; userId: string; sessionId: string; }): Promise<Session | null>; /** * Lists all sessions for a user in an app. */ listSessions(options: { appName: string; userId: string; }): Promise<SessionsList>; /** * Deletes a session. */ deleteSession(options: { appName: string; userId: string; sessionId: string; }): Promise<void>; /** * Appends an event to a session. */ appendEvent(options: { session: Session; event: Event; }): Promise<void>; /** * Lists events in a session. */ listEvents(options: { appName: string; userId: string; sessionId: string; }): Promise<ListEventsResponse>; /** * Updates the state of a session. */ updateSessionState(appName: string, userId: string, sessionId: string, stateDelta: Record<string, any>): Promise<Session>; }