/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { FunctionCall } from '@google/genai'; import { InvocationContext } from '../agents/invocation_context.js'; import { Event } from '../events/event.js'; import { BaseTool } from '../tools/base_tool.js'; import { ToolConfirmation } from '../tools/tool_confirmation.js'; import { SingleAfterToolCallback, SingleBeforeToolCallback } from './llm_agent.js'; export { AF_FUNCTION_CALL_ID_PREFIX, generateClientFunctionCallId, populateClientFunctionCallId, } from '../events/event.js'; export { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, REQUEST_CREDENTIAL_FUNCTION_CALL_NAME, REQUEST_INPUT_FUNCTION_CALL_NAME, reservedFunctionCallName, } from './framework_function_calls.js'; export declare const functionsExportedForTestingOnly: { handleFunctionCallList: typeof handleFunctionCallList; generateAuthEvent: typeof generateAuthEvent; generateRequestConfirmationEvent: typeof generateRequestConfirmationEvent; }; /** * Returns a set of function call ids of the long running tools. */ export declare function getLongRunningFunctionCalls(functionCalls: FunctionCall[], toolsDict: Record): Set; /** * Generates an authentication event. * * It iterates through requested auth configurations in a function response * event and creates a new function call for each. */ export declare function generateAuthEvent(invocationContext: InvocationContext, functionResponseEvent: Event): Event | undefined; /** * Generates a request confirmation event from a function response event. */ export declare function generateRequestConfirmationEvent({ invocationContext, functionCallEvent, functionResponseEvent, }: { invocationContext: InvocationContext; functionCallEvent: Event; functionResponseEvent: Event; }): Event | undefined; /** * Handles function calls. * Runtime behavior to pay attention to: * - Iterate through each function call in the `functionCallEvent`: * - Execute before tool callbacks !!if a callback provides a response, short * circuit the rest. * - Execute the tool. * - Execute after tool callbacks !!if a callback provides a response, short * circuit the rest. * - If the tool is long-running and the response is null, continue. !!state * - Merge all function response events into a single event. */ export declare function handleFunctionCallsAsync({ invocationContext, functionCallEvent, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, }: { invocationContext: InvocationContext; functionCallEvent: Event; toolsDict: Record; beforeToolCallbacks: SingleBeforeToolCallback[]; afterToolCallbacks: SingleAfterToolCallback[]; filters?: Set; toolConfirmationDict?: Record; }): Promise; /** * The underlying implementation of handleFunctionCalls, but takes a list of * function calls instead of an event. * This is also used by llm_agent execution flow in preprocessing. */ export declare function handleFunctionCallList({ invocationContext, functionCalls, toolsDict, beforeToolCallbacks, afterToolCallbacks, filters, toolConfirmationDict, }: { invocationContext: InvocationContext; functionCalls: FunctionCall[]; toolsDict: Record; beforeToolCallbacks: SingleBeforeToolCallback[]; afterToolCallbacks: SingleAfterToolCallback[]; filters?: Set; toolConfirmationDict?: Record; }): Promise; /** * Merges a list of function response events into a single event. */ export declare function mergeParallelFunctionResponseEvents(functionResponseEvents: Event[]): Event; /** * Finds the function call event that matches the function call ID. * Mirrors Python ADK's `find_event_by_function_call_id`. */ export declare function findEventByFunctionCallId(events: Event[], functionCallId: string, endIndex?: number): Event | undefined; /** * Finds the function call event that matches the function response ID of the last event. * Mirrors Python ADK's `find_matching_function_call`. */ export declare function findMatchingFunctionCall(events: Event[]): Event | undefined;