adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
96 lines (95 loc) • 2.65 kB
TypeScript
import { BaseTool, BaseToolOptions } from '../tools/BaseTool';
import { ToolContext } from '../tools/ToolContext';
import { AuthScheme } from './AuthScheme';
import { AuthCredential } from './AuthCredential';
/**
* Configuration for authentication
*/
export interface AuthConfig {
/**
* The authentication scheme used to collect credentials
*/
authScheme: AuthScheme;
/**
* The raw auth credential used to collect credentials
* Used in some auth schemes that need to exchange auth credentials
* For other auth schemes, it could be null
*/
rawAuthCredential?: AuthCredential;
/**
* The exchanged auth credential
* For auth schemes that don't need to exchange credentials (e.g., API key),
* it's filled by client directly
* For auth schemes that need to exchange credentials (e.g., OAuth2),
* it's first filled by ADK
*/
exchangedAuthCredential?: AuthCredential;
}
/**
* Arguments for the auth tool
*/
export interface AuthToolArguments {
/**
* The function call ID
*/
functionCallId: string;
/**
* The auth configuration
*/
authConfig: AuthConfig;
}
/**
* Options for creating an authentication tool
*/
export interface AuthToolOptions extends BaseToolOptions {
/**
* Handler for authentication completion
*/
onAuthComplete?: (args: AuthToolArguments) => Promise<void>;
}
/**
* Tool for handling authentication flows
*/
export declare class AuthTool extends BaseTool {
/**
* Handler for authentication completion
*/
private onAuthComplete?;
/**
* Creates a new authentication tool
*
* @param options The options for the tool
*/
constructor(options: AuthToolOptions);
/**
* Get the function declaration for this tool
*
* @returns The function declaration
*/
protected _getDeclaration(): {
name: string;
description: string;
parameters: {
type: string;
properties: {
authScheme: {
type: string;
description: string;
};
credentials: {
type: string;
description: string;
};
};
required: string[];
};
};
/**
* Execute the authentication tool
*
* @param params The parameters for tool execution
* @param context The context for tool execution
* @returns The result of the tool execution
*/
execute(params: Record<string, any>, context: ToolContext): Promise<any>;
}