UNPKG

adk-typescript

Version:

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

81 lines (80 loc) 2.21 kB
/** * Represents a session for managing agents and their state. */ import { BaseAgent } from '../agents/BaseAgent'; import { Content } from '../models/types'; import { State } from './State'; import { Event } from '../events/Event'; /** * Options for creating a session. */ export interface SessionOptions { /** The ID of the session */ id?: string; /** The app name that owns the session */ appName?: string; /** The user ID that owns the session */ userId?: string; /** The initial state of the session */ state?: Record<string, any>; /** Initial events for the session */ events?: Event[]; } /** * Represents a session for managing agents and their state. */ export declare class Session { /** The ID of the session */ id: string; /** The app name that owns the session */ appName: string; /** The user ID that owns the session */ userId: string; /** The agents in the session - directly accessible as public property */ agents: Map<string, BaseAgent>; /** The events of the session */ events: Event[]; /** The conversation history */ private conversationHistory; /** The state of the session */ state: State; /** The last update time of the session */ lastUpdateTime: number; /** * Creates a new session. * * @param options Options for the session */ constructor(options?: SessionOptions); /** * Adds an agent to the session. * * @param agent The agent to add */ addAgent(agent: BaseAgent): void; /** * Gets an agent from the session. * * @param name The name of the agent * @returns The agent, or undefined if not found */ getAgent(name: string): BaseAgent | undefined; /** * Adds content to the conversation history. * * @param content The content to add */ addConversationHistory(content: Content): void; /** * Gets the conversation history. * * @returns The conversation history */ getConversationHistory(): Content[]; /** * Adds an event to the session. * * @param event The event to add */ addEvent(event: Event): void; }