@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
23 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizeToolAllowedCallers = normalizeToolAllowedCallers;
const errors_1 = require("../errors.js");
function normalizeToolAllowedCallers(allowedCallers, toolName) {
if (typeof allowedCallers === 'undefined') {
return undefined;
}
const callers = allowedCallers;
if (!Array.isArray(callers) || callers.length === 0) {
throw new errors_1.UserError(`Tool '${toolName}' allowedCallers must contain at least one caller.`);
}
const invalidCallerIndex = callers.findIndex((caller) => caller !== 'direct' && caller !== 'programmatic');
if (invalidCallerIndex !== -1) {
const invalidCaller = callers[invalidCallerIndex];
throw new errors_1.UserError(`Tool '${toolName}' allowedCallers contains unsupported caller '${String(invalidCaller)}'.`);
}
if (new Set(callers).size !== callers.length) {
throw new errors_1.UserError(`Tool '${toolName}' allowedCallers must not contain duplicate callers.`);
}
return [...callers];
}
//# sourceMappingURL=toolCallers.js.map