@openai/agents-core
Version:
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.
47 lines • 1.98 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.REDACTED_FINAL_OUTPUT_ERROR_MESSAGE = void 0;
exports.createRedactedFinalOutputError = createRedactedFinalOutputError;
exports.processFinalOutputWithRedaction = processFinalOutputWithRedaction;
exports.createRedactedErrorDetailsError = createRedactedErrorDetailsError;
exports.isDataRedactedError = isDataRedactedError;
const errors_1 = require("../errors.js");
const logger_1 = __importDefault(require("../logger.js"));
const standardSchema_1 = require("./standardSchema.js");
const dataRedactedErrors = new WeakSet();
exports.REDACTED_FINAL_OUTPUT_ERROR_MESSAGE = 'Invalid output type: final assistant output did not match the expected schema.';
const REDACTED_ERROR_DETAILS_MESSAGE = 'Error details are redacted.';
function markDataRedacted(error) {
dataRedactedErrors.add(error);
return error;
}
function createRedactedFinalOutputError() {
return markDataRedacted(new errors_1.ModelBehaviorError(exports.REDACTED_FINAL_OUTPUT_ERROR_MESSAGE));
}
function processFinalOutputWithRedaction(callback) {
const redactFromStart = logger_1.default.dontLogModelData;
try {
return callback();
}
catch (error) {
if ((0, standardSchema_1.isAsyncStandardSchemaValidationError)(error)) {
throw error;
}
if (!redactFromStart && !logger_1.default.dontLogModelData) {
throw error;
}
throw createRedactedFinalOutputError();
}
}
function createRedactedErrorDetailsError() {
return new errors_1.UserError(REDACTED_ERROR_DETAILS_MESSAGE);
}
function isDataRedactedError(error) {
return ((typeof error === 'object' || typeof error === 'function') &&
error !== null &&
dataRedactedErrors.has(error));
}
//# sourceMappingURL=finalOutputError.js.map