src/kit.js
/**
 * Create a craft ai agent
 *
 * @param {String} log
 * @param {Object} client craft ai client
 * @param {String} agentId id to give to the agent
 * @param {Object} agentConfiguration craft ai agent configuration
 *
 * @returns {Object} craft ai agent configuration
 */
Create a craft ai agent
@param {String} log
@param {Object} client craft ai client
@param {String} agentId id to give to the agent
@param {Object} agentConfiguration craft ai agent configuration

@returns {Object} craft ai agent configuration
Create a craft ai agent @param { String } log @param { Object } client craft ai client @param { String } agentId id to give to the agent @param { Object } agentConfiguration craft ai agent configuration @returns { Object } craft ai agent configuration
async function createAgent(log, client, agentId, agentConfiguration) {
  log('creating the agent');
  return client
    .createAgent(agentConfiguration, agentId)
    .then(() => {
      log('the agent has been created');
      return client.getAgent(agentId);
    })
    .catch((error) => {
      if (error.message.includes('because one already exists.')) {
        return client.getAgent(agentId);
      }
      throw error;
    });
}
async function createAgent ( log , client , agentId , agentConfiguration ) { log ( 'creating the agent' ) ; return client . createAgent ( agentConfiguration , agentId ) . then ( ( ) => { log ( 'the agent has been created' ) ; return client . getAgent ( agentId ) ; } ) . catch ( ( error ) => { if ( error . message . includes ( 'because one already exists.' ) ) { return client . getAgent ( agentId ) ; } throw error ; } ) ; }
Create a craft ai agent
 @param {String} log
 @param {Object} client craft ai client
 @param {String} agentId id to give to the agent
 @param {Object} agentConfiguration craft ai agent configuration
Create a craft ai agent @param { String } log @param { Object } client craft ai client @param { String } agentId id to give to the agent @param { Object } agentConfiguration craft ai agent configuration
/* istanbul ignore next */ // Agent has been already created during our creation so we just get the info from it