🔧 feat: Share Assistant Actions between Users (#2116)

* fix: remove unique field from assistant_id, which can be shared between different users

* refactor: remove unique user fields from actions/assistant queries

* feat: only allow user who saved action to delete it

* refactor: allow deletions for anyone with builder access

* refactor: update user.id when updating assistants/actions records, instead of searching with it

* fix: stringify response data in case it's an object

* fix: correctly handle path input

* fix(decryptV2): handle edge case where value is already decrypted
This commit is contained in:
Danny Avila 2024-03-16 16:49:11 -04:00 committed by GitHub
parent 2f90c8764a
commit a8cdd3460c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 65 additions and 16 deletions

View file

@ -6,13 +6,13 @@ const { logger } = require('~/config');
/**
* Loads action sets based on the user and assistant ID.
*
* @param {Object} params - The parameters for loading action sets.
* @param {string} params.user - The user identifier.
* @param {string} params.assistant_id - The assistant identifier.
* @param {Object} searchParams - The parameters for loading action sets.
* @param {string} searchParams.user - The user identifier.
* @param {string} searchParams.assistant_id - The assistant identifier.
* @returns {Promise<Action[] | null>} A promise that resolves to an array of actions or `null` if no match.
*/
async function loadActionSets({ user, assistant_id }) {
return await getActions({ user, assistant_id }, true);
async function loadActionSets(searchParams) {
return await getActions(searchParams, true);
}
/**
@ -40,7 +40,9 @@ function createActionTool({ action, requestBuilder }) {
logger.error(`API call to ${action.metadata.domain} failed`, error);
if (error.response) {
const { status, data } = error.response;
return `API call to ${action.metadata.domain} failed with status ${status}: ${data}`;
return `API call to ${
action.metadata.domain
} failed with status ${status}: ${JSON.stringify(data)}`;
}
return `API call to ${action.metadata.domain} failed.`;