/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { Part } from '@google/genai'; import { AuthCredential } from '../auth/auth_credential.js'; import { AuthConfig } from '../auth/auth_tool.js'; import { EventActions } from '../events/event_actions.js'; import { SearchMemoryResponse } from '../memory/base_memory_service.js'; import { State } from '../sessions/state.js'; import { ToolConfirmation } from '../tools/tool_confirmation.js'; import { InvocationContext } from './invocation_context.js'; import { ReadonlyContext } from './readonly_context.js'; /** * The context of various callbacks within an agent run. * * This class provides the context for callbacks and tool invocations, including * access to the invocation context, function call ID, event actions, and * authentication response. It also provides methods for requesting credentials, * retrieving authentication responses, loading and saving artifacts, and * searching memory. */ export declare class Context extends ReadonlyContext { private readonly _state; readonly eventActions: EventActions; readonly functionCallId?: string; toolConfirmation?: ToolConfirmation; readonly abortSignal?: AbortSignal; /** * @param options The configuration options for the Context. * @param options.invocationContext The invocation context. * @param options.eventActions The event actions of the current call. * @param options.functionCallId 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. * @param options.toolConfirmation The tool confirmation of the current tool * call. */ constructor(options: { invocationContext: InvocationContext; eventActions?: EventActions; functionCallId?: string; toolConfirmation?: ToolConfirmation; }); /** * The delta-aware state of the current session. */ get state(): State; get actions(): EventActions; /** * Loads an artifact attached to the current session. * * @param filename The filename of the artifact. * @param version The version of the artifact. If not provided, the latest * version will be used. * @return A promise that resolves to the loaded artifact. */ loadArtifact(filename: string, version?: number): Promise; /** * Saves an artifact attached to the current session. * * @param filename The filename of the artifact. * @param artifact The artifact to save. * @return A promise that resolves to the version of the saved artifact. */ saveArtifact(filename: string, artifact: Part): Promise; requestCredential(authConfig: AuthConfig): void; /** * Gets the auth credential for the given auth config. * * @param authConfig The auth config to get the auth credential for. * @return The auth credential for the given auth config. */ getAuthResponse(authConfig: AuthConfig): AuthCredential | undefined; /** * Lists the filenames of the artifacts attached to the current session. * * @return A promise that resolves to a list of artifact filenames. */ listArtifacts(): Promise; /** * Searches the memory of the current user. * * @param query The query to search memory for. * @return A promise that resolves to SearchMemoryResponse containing the * matching memories. */ searchMemory(query: string): Promise; /** * Requests confirmation for the current tool call. */ requestConfirmation({ hint, payload }: { hint?: string; payload?: unknown; }): void; }