UNPKG

adk-typescript

Version:

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

57 lines (56 loc) 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TransferToAgentTool = void 0; exports.transferToAgent = transferToAgent; const FunctionTool_1 = require("./FunctionTool"); /** * Function to transfer control to another agent * * @param params Parameters for the function * @param params.agentName The name of the agent to transfer to * @param context The tool context * @returns A message about the transfer */ function transferToAgent(params, context) { const agentName = params.agentName; // Set the transfer_to_agent action on the context if (context.get) { const actions = (context.get('actions') || {}); actions.transferToAgent = agentName; context.set('actions', actions); } else if (context.actions) { context.actions.transferToAgent = agentName; } return Promise.resolve(`Transferring to agent: ${agentName}`); } /** * Tool for transferring control to another agent */ class TransferToAgentTool extends FunctionTool_1.FunctionTool { /** * Creates a new transfer to agent tool */ constructor() { super({ name: 'transfer_to_agent', description: 'Transfers the question to another agent', fn: transferToAgent, functionDeclaration: { name: 'transfer_to_agent', description: 'Transfers the question to another agent', parameters: { type: 'object', properties: { agentName: { type: 'string', description: 'The name of the agent to transfer to' } }, required: ['agentName'] } } }); } } exports.TransferToAgentTool = TransferToAgentTool;