@salesforce/agents
Version:
Client side APIs for working with Salesforce agents
49 lines • 2.19 kB
JavaScript
;
/*
* Copyright 2026, Salesforce, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAgentTester = createAgentTester;
const core_1 = require("@salesforce/core");
const agentTester_1 = require("./agentTester");
const agentforceStudioTester_1 = require("./agentforceStudioTester");
const utils_1 = require("./utils");
/**
* Creates the appropriate tester based on detection priority:
* 1. `explicitType` — always wins, no detection performed
* 2. `runId` prefix — instant detection from the Salesforce ID prefix, no network call
* 3. `testDefinitionName` — org metadata query, used as last resort
*/
async function createAgentTester(connection, options) {
const makeTester = (type) => ({
runner: type === 'agentforce-studio' ? new agentforceStudioTester_1.AgentforceStudioTester(connection) : new agentTester_1.AgentTester(connection),
type,
});
if (options.explicitType) {
return makeTester(options.explicitType);
}
if (options.runId) {
const runnerType = (0, utils_1.detectTestRunnerFromId)(options.runId);
if (!runnerType) {
throw core_1.SfError.create({
name: 'UnrecognizedRunId',
message: `Cannot determine test runner from run ID '${options.runId}'. Expected a Salesforce ID starting with '3A2' (Agentforce Studio) or '4KB' (Testing Center).`,
});
}
return makeTester(runnerType);
}
return makeTester(await (0, utils_1.determineTestRunner)(connection, options.testDefinitionName));
}
//# sourceMappingURL=agentTesterFactory.js.map