UNPKG

adk-typescript

Version:

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

105 lines (104 loc) 3.75 kB
import { Content } from '../models/types'; import type { BaseAgent, RunConfig } from './index'; import { LiveRequestQueue } from './LiveRequestQueue'; import { ActiveStreamingTool } from './ActiveStreamingTool'; import { TranscriptionEntry } from './TranscriptionEntry'; import { Session } from '../sessions/Session'; import { BaseArtifactService } from '../artifacts/BaseArtifactService'; import { BaseMemoryService } from '../memory/BaseMemoryService'; import { BaseSessionService } from '../sessions/BaseSessionService'; import { BaseLlm } from '../models/BaseLlm'; import { ToolContext } from '../tools/ToolContext'; /** * Error thrown when the number of LLM calls exceed the limit. */ export declare class LlmCallsLimitExceededError extends Error { constructor(message: string); } /** * Options for creating an invocation context. */ export interface InvocationContextOptions { /** The invocation ID */ invocationId?: string; /** The session */ session?: Session; /** The agent being invoked */ agent?: BaseAgent; /** The user content */ userContent?: Content; /** Whether this is a live invocation */ live?: boolean; /** The LLM model to use */ llm?: BaseLlm; /** The live request queue for real-time interactions */ liveRequestQueue?: LiveRequestQueue; /** Additional context-specific options */ [key: string]: any; } /** * An invocation context represents the data of a single invocation of an agent. */ export declare class InvocationContext { /** The artifact service */ artifactService?: BaseArtifactService; /** The session service */ sessionService: BaseSessionService; /** The memory service */ memoryService?: BaseMemoryService; /** The id of this invocation context. Readonly. */ invocationId: string; /** * The branch of the invocation context. * * The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of * agent_2, and agent_2 is the parent of agent_3. * * Branch is used when multiple sub-agents shouldn't see their peer agents' * conversation history. */ branch?: string; /** The current agent of this invocation context. Readonly. */ agent: BaseAgent; /** The user content that started this invocation. Readonly. */ userContent?: Content; /** The current session of this invocation context. Readonly. */ session: Session; /** * Whether to end this invocation. * * Set to True in callbacks or tools to terminate this invocation. */ endInvocation: boolean; /** The queue to receive live requests. */ liveRequestQueue?: LiveRequestQueue; /** The running streaming tools of this invocation. */ activeStreamingTools?: Map<string, ActiveStreamingTool>; /** Caches necessary data, audio or contents, that are needed by transcription. */ transcriptionCache?: TranscriptionEntry[]; /** Configurations for live agents under this invocation. */ runConfig?: RunConfig; /** The LLM model to use */ llm?: BaseLlm; /** Tools available in this context */ tools?: ToolContext; /** Whether this is a live invocation */ live: boolean; private invocationCostManager; /** * Creates a new invocation context. * * @param options Options for the context */ constructor(options?: InvocationContextOptions); /** * Tracks number of llm calls made. * * @throws LlmCallsLimitExceededError If number of llm calls made exceed the set threshold. */ incrementLlmCallCount(): void; /** The app name from the session */ get appName(): string; /** The user ID from the session */ get userId(): string; }