diff --git a/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs b/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs new file mode 100644 index 0000000000000..6f0805e8eeebc --- /dev/null +++ b/components/tess_ai_by_pareto/actions/execute-agent/execute-agent.mjs @@ -0,0 +1,45 @@ +import { getQuestionProps } from "../../common/utils.mjs"; +import app from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-execute-agent", + name: "Execute AI Agent", + description: + "Executes an AI Agent (template) with the given input. [See the documentation](https://tess.pareto.io/api/swagger#/default/f13b3be7386ce63d99fa4bdee0cf6c95)", + version: "0.0.1", + type: "action", + props: { + app, + templateId: { + propDefinition: [ + app, + "templateId", + ], + reloadProps: true, + }, + }, + methods: { + getQuestionProps, + }, + async additionalProps() { + const { questions } = await this.app.getTemplate(this.templateId); + return this.getQuestionProps(questions); + + }, + async run({ $ }) { + /* eslint-disable no-unused-vars */ + const { + app, templateId, getQuestionProps, ...data + } = this; + const response = await this.app.executeTemplate({ + $, + templateId, + data, + }); + $.export( + "$summary", + `Executed AI agent ${response.id}`, + ); + return response; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs b/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs new file mode 100644 index 0000000000000..79546f275d361 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/get-execution-response/get-execution-response.mjs @@ -0,0 +1,30 @@ +import app from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-get-execution-response", + name: "Get Agent Execution Response", + description: + "Retrieves the result of a previously executed AI Agent (template). [See the documentation](https://tess.pareto.io/api/swagger#/default/370b6709c5d9e8c17a76e1abb288e7ad)", + version: "0.0.1", + type: "action", + props: { + app, + executionId: { + type: "string", + label: "Agent Execution ID", + description: + "The ID of the AI Agent (template) execution to retrieve the result for.", + }, + }, + async run({ $ }) { + const result = await this.app.getTemplateResponse({ + $, + executionId: this.executionId, + }); + $.export( + "$summary", + `Retrieved response for execution ID ${this.executionId}`, + ); + return result; + }, +}; diff --git a/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs new file mode 100644 index 0000000000000..0d418cd82bee0 --- /dev/null +++ b/components/tess_ai_by_pareto/actions/search-ai-agents/search-ai-agents.mjs @@ -0,0 +1,47 @@ +import app from "../../tess_ai_by_pareto.app.mjs"; + +export default { + key: "tess_ai_by_pareto-search-ai-agents", + name: "Search AI Agents", + description: + "Retrieve AI Agents (templates) that match the specified criteria. [See the documentation](https://tess.pareto.io/api/swagger#/default/201046139d07458d530ad3526e0b3c2f)", + version: "0.0.1", + type: "action", + props: { + app, + query: { + type: "string", + label: "Search Query", + description: + "Search agents (templates) by title, description and long description.", + optional: true, + }, + type: { + type: "string", + label: "Type Filter", + description: "Filter by template type", + optional: true, + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of results to return", + optional: true, + default: 15, + min: 1, + max: 1000, + }, + }, + async run({ $ }) { + const response = await this.app.searchTemplates({ + $, + params: { + q: this.query, + type: this.type, + per_page: this.maxResults, + }, + }); + $.export("$summary", `Retrieved ${response.data?.length} templates`); + return response; + }, +}; diff --git a/components/tess_ai_by_pareto/common/utils.mjs b/components/tess_ai_by_pareto/common/utils.mjs new file mode 100644 index 0000000000000..b21ac571c51cd --- /dev/null +++ b/components/tess_ai_by_pareto/common/utils.mjs @@ -0,0 +1,21 @@ +export function getQuestionProps(questions) { + function getQuestionPropType(type) { + switch (type) { + case "number": + return "integer"; + default: + return "string"; + } + } + + return (questions ?? []).reduce((obj, question) => { + obj[question.name] = { + type: getQuestionPropType(question.type), + label: `Field: "${question.name}"`, + description: `Type: \`${question.type}\`. Description: "${question.description}"`, + options: question.options, + optional: !question.required, + }; + return obj; + }, {}); +} diff --git a/components/tess_ai_by_pareto/package.json b/components/tess_ai_by_pareto/package.json index 16ca35b5f25dc..8060e0938e483 100644 --- a/components/tess_ai_by_pareto/package.json +++ b/components/tess_ai_by_pareto/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/tess_ai_by_pareto", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Tess AI by Pareto Components", "main": "tess_ai_by_pareto.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs index a07f40f61533f..3769360ea2446 100644 --- a/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs +++ b/components/tess_ai_by_pareto/tess_ai_by_pareto.app.mjs @@ -1,11 +1,73 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "tess_ai_by_pareto", - propDefinitions: {}, + propDefinitions: { + templateId: { + type: "string", + label: "AI Agent ID", + description: "The ID of the AI Agent (template) to execute.", + useQuery: true, + async options({ + page = 0, query, + }) { + const response = await this.searchTemplates({ + params: { + page: page + 1, + q: query || undefined, + }, + }); + return response?.data?.map((template) => ({ + label: template.title, + value: template.id, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://tess.pareto.io/api"; + }, + async _makeRequest({ + $ = this, path = "/", headers, ...otherOpts + } = {}) { + return axios($, { + url: this._baseUrl() + path, + headers: { + ...headers, + "Authorization": `Bearer ${this.$auth.api_token}`, + }, + ...otherOpts, + }); + }, + async executeTemplate({ + templateId, ...args + }) { + return this._makeRequest({ + method: "POST", + path: `/templates/${templateId}/execute`, + ...args, + }); + }, + async getTemplate(templateId) { + return this._makeRequest({ + path: `/templates/${templateId}`, + }); + }, + async searchTemplates(args) { + return this._makeRequest({ + path: "/templates", + ...args, + }); + }, + async getTemplateResponse({ + executionId, ...args + }) { + return this._makeRequest({ + path: `/template-responses/${executionId}`, + ...args, + }); }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e4c6e295e7fcc..63541669d2bbe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10092,7 +10092,10 @@ importers: '@pipedream/platform': 1.5.1 components/tess_ai_by_pareto: - specifiers: {} + specifiers: + '@pipedream/platform': ^3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/test_app_for_oauth_bug: specifiers: {} @@ -16176,12 +16179,12 @@ packages: kuler: 2.0.0 dev: false - /@definitelytyped/header-parser/0.2.12: - resolution: {integrity: sha512-UYtSXiLMhzRFKh7xHMkgiWsscgHxIndmjetaptZMMS0EOvfhUTuEM68GpjiCtz5shXw22Vacs1vDTAkKGDhNmg==} + /@definitelytyped/header-parser/0.2.13: + resolution: {integrity: sha512-m7YEtGhwAjmQyJQFQ7q8+hTGTiC/WrdRATvw8fyTwgW+RiWUt8MAeehuFj4txnCYXDcLO0ozuW5gNrLoYR4Ubg==} engines: {node: '>=18.18.0'} dependencies: '@definitelytyped/typescript-versions': 0.1.4 - '@definitelytyped/utils': 0.1.7 + '@definitelytyped/utils': 0.1.8 semver: 7.6.3 dev: true @@ -16190,8 +16193,8 @@ packages: engines: {node: '>=18.18.0'} dev: true - /@definitelytyped/utils/0.1.7: - resolution: {integrity: sha512-t58AeNg6+mvyMnBHyPC6JQqWMW0Iwyb+vlpBz4V0d0iDY9H8gGCnLFg9vtN1nC+JXfTXBlf9efu9unMUeaPCiA==} + /@definitelytyped/utils/0.1.8: + resolution: {integrity: sha512-4JINx4Rttha29f50PBsJo48xZXx/He5yaIWJRwVarhYAN947+S84YciHl+AIhQNRPAFkg8+5qFngEGtKxQDWXA==} engines: {node: '>=18.18.0'} dependencies: '@qiwi/npm-registry-client': 8.9.1 @@ -24553,7 +24556,7 @@ packages: peerDependencies: typescript: '*' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -24568,7 +24571,7 @@ packages: peerDependencies: typescript: '*' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 command-exists: 1.2.9 rimraf: 3.0.2 semver: 6.3.1 @@ -24584,9 +24587,9 @@ packages: peerDependencies: typescript: '>= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 '@definitelytyped/typescript-versions': 0.1.4 - '@definitelytyped/utils': 0.1.7 + '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11_typescript@5.2.2 fs-extra: 6.0.1 json-stable-stringify: 1.0.2 @@ -24604,9 +24607,9 @@ packages: peerDependencies: typescript: '>= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev' dependencies: - '@definitelytyped/header-parser': 0.2.12 + '@definitelytyped/header-parser': 0.2.13 '@definitelytyped/typescript-versions': 0.1.4 - '@definitelytyped/utils': 0.1.7 + '@definitelytyped/utils': 0.1.8 dts-critic: 3.3.11_typescript@5.5.4 fs-extra: 6.0.1 json-stable-stringify: 1.0.2