@mastra/core
Version:
84 lines (83 loc) • 2.06 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const require_tool = require("../tool-d85xHVkl.cjs");
let zod_v4 = require("zod/v4");
//#region src/integration/integration.ts
var Integration = class {
name = "Integration";
workflows;
constructor() {
this.workflows = {};
}
/**
* Workflows
*/
registerWorkflow(name, fn) {
if (this.workflows[name]) throw new Error(`Sync function "${name}" already registered`);
this.workflows[name] = fn;
}
listWorkflows({ serialized }) {
if (serialized) return Object.entries(this.workflows).reduce((acc, [k, v]) => {
return {
...acc,
[k]: { name: v.name }
};
}, {});
return this.workflows;
}
/**
* TOOLS
*/
listStaticTools(_params) {
throw new Error("Method not implemented.");
}
async listTools(_params) {
throw new Error("Method not implemented.");
}
async getApiClient() {
throw new Error("Method not implemented");
}
};
//#endregion
//#region src/integration/openapi-toolset.ts
var OpenAPIToolset = class {
authType = "API_KEY";
constructor() {}
get toolSchemas() {
return {};
}
get toolDocumentations() {
return {};
}
get baseClient() {
return {};
}
async getApiClient() {
throw new Error("API not implemented");
}
_generateIntegrationTools() {
const { client: _client, ...clientMethods } = this.baseClient;
const schemas = this.toolSchemas;
const documentations = this.toolDocumentations;
return Object.keys(clientMethods).reduce((acc, key) => {
const comment = documentations[key]?.comment;
const fallbackComment = `Execute ${key}`;
const tool = require_tool.createTool({
id: key,
inputSchema: schemas[key] || zod_v4.z.object({}),
description: comment || fallbackComment,
execute: async (input) => {
const value = (await this.getApiClient())[key];
return value({ ...input });
}
});
return {
...acc,
[key]: tool
};
}, {});
}
};
//#endregion
exports.Integration = Integration;
exports.OpenAPIToolset = OpenAPIToolset;
//# sourceMappingURL=index.cjs.map