UNPKG

@openai/agents-core

Version:

The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.

20 lines • 960 B
import { UserError } from "../errors.mjs"; export function normalizeToolAllowedCallers(allowedCallers, toolName) { if (typeof allowedCallers === 'undefined') { return undefined; } const callers = allowedCallers; if (!Array.isArray(callers) || callers.length === 0) { throw new 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 UserError(`Tool '${toolName}' allowedCallers contains unsupported caller '${String(invalidCaller)}'.`); } if (new Set(callers).size !== callers.length) { throw new UserError(`Tool '${toolName}' allowedCallers must not contain duplicate callers.`); } return [...callers]; } //# sourceMappingURL=toolCallers.mjs.map