@salesforce/agents
    Preparing search index...

    Class AgentTest

    A client side representation of an agent test (AiEvaluationDefinition) within an org. Also provides utilities such as creating and listing agent tests, and converting between agent test spec and AiEvaluationDefinition.

    Examples

    Create a new instance from an agent test spec:

    const agentTest = new AgentTest({ specPath: path/to/specfile });

    Get the metadata content of an agent test:

    const metadataContent = await agentTest.getMetadata();

    Write the metadata content to a file:

    await agentTest.writeMetadata('path/to/metadataFile');

    Index

    Constructors

    • Create an AgentTest based on one of:

      1. AiEvaluationDefinition API name.
      2. Path to a local AiEvaluationDefinition metadata file.
      3. Path to a local agent test spec file.
      4. Agent test spec data.

      Parameters

      Returns AgentTest

    Methods

    • Get the metadata content for this agent test.

      Returns the AiEvaluationDefinition metadata if already generated. Otherwise it will get it by:

      1. Read from an existing local AiEvaluationDefinition metadata file.
      2. Read from an existing local spec file and convert it.
      3. Use the provided org connection to read the remote AiEvaluationDefinition metadata.

      Parameters

      • Optionalconnection: Connection<Schema>

        Org connection to use if this AgentTest only has an AiEvaluationDefinition API name.

      Returns Promise<AiEvaluationDefinition>

      Promise

    • Get the specification for this agent test.

      Returns the test spec data if already generated. Otherwise it will generate the spec by:

      1. Read from an existing local spec file.
      2. Read from an existing local AiEvaluationDefinition metadata file and convert it.
      3. Use the provided org connection to read the remote AiEvaluationDefinition metadata.

      Parameters

      • Optionalconnection: Connection<Schema>

        Org connection to use if this AgentTest only has an AiEvaluationDefinition API name.

      Returns Promise<TestSpec>

      Promise

    • Write AiEvaluationDefinition metadata file.

      Parameters

      • outputFile: string

        The file path where the metadata file should be written.

      Returns Promise<void>

    • Write a test specification file in YAML format.

      Parameters

      • outputFile: string

        The file path where the YAML test spec should be written.

      Returns Promise<void>

    • Creates and deploys an AiEvaluationDefinition from a specification file.

      Parameters

      • connection: Connection

        Connection to the org where the agent test will be created.

      • apiName: string

        The API name of the AiEvaluationDefinition to create

      • specFilePath: string

        The path to the specification file to create the definition from

      • options: { outputDir: string; preview?: boolean }

        Configuration options for creating the definition

        • outputDir: string

          The directory where the AiEvaluationDefinition file will be written

        • Optionalpreview?: boolean

          If true, writes the AiEvaluationDefinition file to -preview-.xml in the current working directory and does not deploy it

      Returns Promise<{ contents: string; deployResult?: DeployResult; path: string }>

      Promise containing:

      • path: The filesystem path to the created AiEvaluationDefinition file
      • contents: The AiEvaluationDefinition contents as a string
      • deployResult: The deployment result (if not in preview mode)

      When deployment fails