@waldzellai/adk-typescript
Version:
TypeScript SDK for Google Agent Development Kit (ADK) - A comprehensive framework for building AI agents
151 lines (150 loc) • 4.09 kB
TypeScript
/**
* A state object that maintains the current value and the pending-commit delta.
*
* This class provides app-level, user-level, and session-level state management
* with prefixes to distinguish between them.
*/
export declare class State {
/**
* Prefix for app-level state keys.
*/
static readonly APP_PREFIX = "app:";
/**
* Prefix for user-level state keys.
*/
static readonly USER_PREFIX = "user:";
/**
* Prefix for temporary state keys.
*/
static readonly TEMP_PREFIX = "temp:";
/**
* The current value of the state.
*/
private _value;
/**
* The delta change to the current value that hasn't been committed.
*/
private _delta;
/**
* Creates a new State instance.
*
* @param value The current value of the state
* @param delta The delta change to the current value that hasn't been committed
*/
constructor(value?: Record<string, unknown>, delta?: Record<string, unknown>);
/**
* Creates a new state from a plain object.
*
* @param obj The object to create the state from
* @returns A new state instance
*/
static fromObject(obj?: Record<string, unknown>): State;
/**
* Sets a value in the state.
*
* @param key The key to set
* @param value The value to set
*/
set(key: string, value: unknown): void;
/**
* Gets a value from the state.
*
* @param key The key to get
* @returns The value for the key or undefined if not found
*/
get(key: string): unknown;
/**
* Checks if the state has a value for the given key.
*
* @param key The key to check
* @returns Whether the state has a value for the key
*/
hasValue(key: string): boolean;
/**
* Checks if the state has any values.
*
* @returns Whether the state has any values
*/
hasAny(): boolean;
/**
* Checks if the state has any pending changes.
*
* @returns Whether the state has any pending changes
*/
hasDelta(): boolean;
/**
* Gets the state delta.
*
* @returns The state delta
*/
getDelta(): Record<string, unknown>;
/**
* Commits the delta to the value and clears the delta.
*/
commitDelta(): void;
/**
* Clears the delta without committing.
*/
clearDelta(): void;
/**
* Updates the state with the given values.
*
* @param values The values to update the state with
*/
update(values: Record<string, unknown>): void;
/**
* Sets an app-level state value.
*
* @param key The key to set
* @param value The value to set
*/
setAppValue(key: string, value: unknown): void;
/**
* Gets an app-level state value.
*
* @param key The key to get
* @returns The app-level state value
*/
getAppValue(key: string): unknown;
/**
* Sets a user-level state value.
*
* @param key The key to set
* @param value The value to set
*/
setUserValue(key: string, value: unknown): void;
/**
* Gets a user-level state value.
*
* @param key The key to get
* @returns The user-level state value
*/
getUserValue(key: string): unknown;
/**
* Sets a temporary state value.
*
* @param key The key to set
* @param value The value to set
*/
setTempValue(key: string, value: unknown): void;
/**
* Gets a temporary state value.
*
* @param key The key to get
* @returns The temporary state value
*/
getTempValue(key: string): unknown;
/**
* Returns the state as a plain object.
*
* @returns The state as a plain object
*/
toObject(): Record<string, unknown>;
/**
* Returns the metadata associated with the state.
* TODO(b/314118552): Implement proper metadata handling if needed for Python ADK compatibility.
*
* @returns The state metadata as a plain object.
*/
getMetadata(): Record<string, unknown>;
}