UNPKG

adk-typescript

Version:

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

85 lines (84 loc) 2.96 kB
import { CallbackContext } from '../agents/CallbackContext'; import { InvocationContext } from '../agents/InvocationContext'; import { EventActions } from '../events/EventActions'; import { AuthConfig } from '../auth/AuthConfig'; import { AuthCredential } from '../auth/AuthCredential'; import { SearchMemoryResponse } from '../memory/BaseMemoryService'; /** * The context for a tool execution. * * This class provides the context for a tool invocation, including access to * the invocation context, function call ID, event actions, and authentication * response. It also provides methods for requesting credentials, retrieving * authentication responses, listing artifacts, and searching memory. */ export declare class ToolContext extends CallbackContext { /** * The function call id of the current tool call. This id was * returned in the function call event from LLM to identify a function call. * If LLM didn't return this id, ADK will assign one to it. This id is used * to map function call response to the original function call. */ functionCallId?: string; /** * The event actions for this tool call */ private toolEventActions; /** * Additional properties for dynamic access */ [key: string]: any; /** * Create a new tool context * * @param invocationContext The invocation context * @param functionCallId The function call ID * @param eventActions The event actions */ constructor(invocationContext: InvocationContext, functionCallId?: string, eventActions?: EventActions); /** * Get the event actions for this tool call */ get actions(): EventActions; /** * Request credential using the given auth config * * @param authConfig The auth config to use * @throws Error if function call ID is not set */ requestCredential(authConfig: AuthConfig): void; /** * Get the auth response for the given auth config * * @param authConfig The auth config to use * @returns The auth credential */ getAuthResponse(authConfig: AuthConfig): AuthCredential; /** * List artifacts attached to the current session * * @returns List of artifact filenames * @throws Error if artifact service is not initialized */ listArtifacts(): string[] | Promise<string[]>; /** * Search the memory for the given query * * @param query The search query * @returns The search results * @throws Error if memory service is not available */ searchMemory(query: string): SearchMemoryResponse | Promise<SearchMemoryResponse>; /** * Check if the context has a specific property */ has(key: string): boolean; /** * Get a value from the context */ get<T>(key: string, defaultValue?: T): T | undefined; /** * Set a value in the context */ set<T>(key: string, value: T): void; }