Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

1.1 KB
Raw Blame
import { GetFunctionCommand, LambdaClient } from '@aws-sdk/client-lambda';

function getLambdaFunctionName(agentId: string, componentId: string) {
  return `${agentId}-${componentId}`;
}

async function getDeployedFunction(componentId: string, agentId: string, awsConfigs: {
  region: string,
  accessKeyId: string,
  secretAccessKey: string
}) {
  try {
    const client = new LambdaClient({
      region: awsConfigs.region,
      credentials: {
        accessKeyId: awsConfigs.accessKeyId,
        secretAccessKey: awsConfigs.secretAccessKey
    }
  });
    const getFunctionCommand = new GetFunctionCommand({ FunctionName: getLambdaFunctionName(agentId, componentId) })
    const lambdaResponse = await client.send(getFunctionCommand);
    return {
      status: lambdaResponse.Configuration.LastUpdateStatus,
      functionName: lambdaResponse.Configuration.FunctionName,
      functionVersion: lambdaResponse.Configuration.Version,
      updatedAt: lambdaResponse.Configuration.LastModified,
      role: lambdaResponse.Configuration.Role,
    };
  } catch (error) {
    return null;
  }
}

export const serverlessCodeHelper = {
  getDeployedFunction
};