adk-typescript
Version:
TypeScript port of Google's Agent Development Kit (ADK)
61 lines (60 loc) • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoogleApiTool = exports.AuthCredentialTypes = void 0;
const BaseTool_1 = require("../BaseTool");
/**
* Auth credential types enum
*/
var AuthCredentialTypes;
(function (AuthCredentialTypes) {
AuthCredentialTypes["OPEN_ID_CONNECT"] = "open_id_connect";
})(AuthCredentialTypes || (exports.AuthCredentialTypes = AuthCredentialTypes = {}));
/**
* GoogleApiTool class
* A wrapper around RestApiTool that adds Google API specific functionality
*/
class GoogleApiTool extends BaseTool_1.BaseTool {
/**
* Create a new GoogleApiTool
* @param restApiTool The underlying RestApiTool to wrap
*/
constructor(restApiTool) {
super({
name: restApiTool.name,
description: restApiTool.description,
isLongRunning: restApiTool.isLongRunning
});
this.restApiTool = restApiTool;
}
/**
* Get the function declaration
* @returns The function declaration from the underlying RestApiTool
*/
_getDeclaration() {
return this.restApiTool.getDeclaration();
}
/**
* Execute the tool
* @param params The parameters for the tool execution
* @param context The context for the tool execution
* @returns The result of executing the underlying RestApiTool
*/
async execute(params, context) {
return await this.restApiTool.execute(params, context);
}
/**
* Configure authentication for the tool
* @param clientId The OAuth2 client ID
* @param clientSecret The OAuth2 client secret
*/
configureAuth(clientId, clientSecret) {
this.restApiTool.authCredential = {
authType: AuthCredentialTypes.OPEN_ID_CONNECT,
oauth2: {
clientId,
clientSecret
}
};
}
}
exports.GoogleApiTool = GoogleApiTool;