@waldzellai/adk-typescript
Version:
TypeScript SDK for Google Agent Development Kit (ADK) - A comprehensive framework for building AI agents
106 lines (105 loc) • 2.85 kB
TypeScript
import { Content } from '../models/base_llm';
import { Event } from '../events/event';
/**
* Represents a series of interactions between a user and agents.
*/
export declare class Session {
/**
* The unique identifier of the session.
*/
id: string;
/**
* The name of the app.
*/
appName: string;
/**
* The id of the user.
*/
userId: string;
/**
* The state of the session.
*/
state: Record<string, unknown>;
/**
* The events of the session, e.g., user input, model response, function call/response, etc.
*/
events: Event[];
/**
* The last update time of the session (Unix timestamp in milliseconds).
*/
lastUpdateTime: number;
/**
* Creates a new Session.
*
* @param data The session data
*/
constructor(data: {
id: string;
appName: string;
userId: string;
state?: Record<string, unknown>;
events?: Event[];
lastUpdateTime?: number;
});
/**
* Adds an event to the session.
*
* @param event The event to add
* @returns The added event
*/
addEvent(event: Event): Event;
/**
* Gets all the content from events in the session.
*
* @returns The content from events in the session
*/
getContents(): Content[];
/**
* Gets the state value for the given key.
*
* @param key The state key
* @param defaultValue The default value to return if the key is not found
* @returns The state value or the default value if not found
*/
getStateValue(key: string, defaultValue?: unknown): unknown;
/**
* Sets the state value for the given key.
*
* @param key The state key
* @param value The state value
*/
setStateValue(key: string, value: unknown): void;
/**
* Deletes the state value for the given key.
*
* @param key The state key
* @returns True if the key was found and deleted, false otherwise
*/
deleteStateValue(key: string): boolean;
/**
* Checks if the state has a value for the given key.
*
* @param key The state key
* @returns True if the key exists in the state, false otherwise
*/
hasStateValue(key: string): boolean;
/**
* Updates the session state with the given values.
*
* @param values The values to update the state with
*/
updateState(values: Record<string, unknown>): void;
/**
* Gets the session as a JSON object.
*
* @returns The session as a JSON object
*/
toJSON(): Record<string, unknown>;
/**
* Creates a session from a JSON object.
*
* @param json The JSON object
* @returns A new session instance
*/
static fromJSON(json: Record<string, unknown>): Session;
}