(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "@langchain/core/tools", "./fromai-helpers", "./fromai-helpers"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.createZodSchemaFromArgs = exports.extractFromAIParameters = void 0;
    exports.createToolFromNode = createToolFromNode;
    const tools_1 = require("@langchain/core/tools");
    const fromai_helpers_1 = require("./fromai-helpers");
    var fromai_helpers_2 = require("./fromai-helpers");
    Object.defineProperty(exports, "extractFromAIParameters", { enumerable: true, get: function () { return fromai_helpers_2.extractFromAIParameters; } });
    Object.defineProperty(exports, "createZodSchemaFromArgs", { enumerable: true, get: function () { return fromai_helpers_2.createZodSchemaFromArgs; } });
    function createToolFromNode(node, options) {
        const { name, description, func, extraArgs = [] } = options;
        const collectedArguments = (0, fromai_helpers_1.extractFromAIParameters)(node.parameters);
        if (collectedArguments.length === 0 && extraArgs.length === 0) {
            return new tools_1.DynamicTool({ name, description, func });
        }
        const allArguments = [...collectedArguments, ...extraArgs];
        const schema = (0, fromai_helpers_1.createZodSchemaFromArgs)(allArguments);
        return new tools_1.DynamicStructuredTool({ schema, name, description, func });
    }
});
//# sourceMappingURL=fromai-tool-factory.js.map