Skip to content

The open alternative to Salesforce, designed for AI.

Force uuids in AI workflow tools (#20010)

Thomas Trompettefa3d0cd4a62a
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/activate-workflow-version.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/activate-workflow-version.tool.ts
index d976cee5292..2c8af2d27b9 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/activate-workflow-version.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/activate-workflow-version.tool.ts
@@ -8,7 +8,8 @@ import {
const activateWorkflowVersionSchema = z.object({
workflowVersionId: z
.string()
- .describe('The ID of the workflow version to activate'),
+ .uuid()
+ .describe('The UUID of the workflow version to activate'),
});
type ActivateWorkflowVersionInput = z.infer<
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/compute-step-output-schema.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/compute-step-output-schema.tool.ts
index e7dff050518..b5a07e7c97b 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/compute-step-output-schema.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/compute-step-output-schema.tool.ts
@@ -15,7 +15,10 @@ const computeStepOutputSchemaSchema = z.object({
step: z
.union([workflowTriggerSchema, workflowActionSchema])
.describe('The workflow step configuration'),
- workflowVersionId: z.string().describe('The ID of the workflow version'),
+ workflowVersionId: z
+ .string()
+ .uuid()
+ .describe('The UUID of the workflow version'),
});
export const createComputeStepOutputSchemaTool = (
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-draft-from-workflow-version.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-draft-from-workflow-version.tool.ts
index 9b4a72296a7..642df1d192b 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-draft-from-workflow-version.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-draft-from-workflow-version.tool.ts
@@ -6,10 +6,11 @@ import {
} from 'src/modules/workflow/workflow-tools/types/workflow-tool-dependencies.type';
const createDraftFromWorkflowVersionSchema = z.object({
- workflowId: z.string().describe('The ID of the workflow'),
+ workflowId: z.string().uuid().describe('The UUID of the workflow'),
workflowVersionIdToCopy: z
.string()
- .describe('The ID of the workflow version to create a draft from'),
+ .uuid()
+ .describe('The UUID of the workflow version to create a draft from'),
});
type CreateDraftFromWorkflowVersionInput = z.infer<
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-edge.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-edge.tool.ts
index adf1e15f470..b51b2cb48c4 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-edge.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-edge.tool.ts
@@ -7,9 +7,14 @@ import {
} from 'src/modules/workflow/workflow-tools/types/workflow-tool-dependencies.type';
const createWorkflowVersionEdgeSchema = z.object({
- workflowVersionId: z.string().describe('The ID of the workflow version'),
- source: z.string().describe('The ID of the source step'),
- target: z.string().describe('The ID of the target step'),
+ workflowVersionId: z
+ .string()
+ .uuid()
+ .describe('The UUID of the workflow version'),
+ source: z
+ .union([z.literal('trigger'), z.string().uuid()])
+ .describe('The source step: "trigger" or a step UUID'),
+ target: z.string().uuid().describe('The UUID of the target step'),
sourceConnectionOptions: z
.object({
connectedStepType: z.literal(WorkflowActionType.ITERATOR),
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-step.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-step.tool.ts
index 5d6198cb558..d1212f1166a 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-step.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/create-workflow-version-step.tool.ts
@@ -13,12 +13,13 @@ import {
const baseStepFields = {
workflowVersionId: z
.string()
- .describe('The ID of the workflow version to add the step to'),
+ .uuid()
+ .describe('The UUID of the workflow version to add the step to'),
parentStepId: z
.string()
.optional()
.describe(
- 'Optional ID of the parent step this step should come after. If not provided, the step will be added at the end of the workflow.',
+ 'Optional ID of the parent step this step should come after (UUID, or "trigger" for the trigger step). If not provided, the step will be added at the end of the workflow.',
),
parentStepConnectionOptions: z
.object({
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/deactivate-workflow-version.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/deactivate-workflow-version.tool.ts
index d1298117245..23e38b42b43 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/deactivate-workflow-version.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/deactivate-workflow-version.tool.ts
@@ -8,7 +8,8 @@ import {
const deactivateWorkflowVersionSchema = z.object({
workflowVersionId: z
.string()
- .describe('The ID of the workflow version to deactivate'),
+ .uuid()
+ .describe('The UUID of the workflow version to deactivate'),
});
type DeactivateWorkflowVersionInput = z.infer<
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-edge.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-edge.tool.ts
index 1ff849c97ba..f3b0b12b4b6 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-edge.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-edge.tool.ts
@@ -7,9 +7,14 @@ import {
} from 'src/modules/workflow/workflow-tools/types/workflow-tool-dependencies.type';
const deleteWorkflowVersionEdgeSchema = z.object({
- workflowVersionId: z.string().describe('The ID of the workflow version'),
- source: z.string().describe('The ID of the source step'),
- target: z.string().describe('The ID of the target step'),
+ workflowVersionId: z
+ .string()
+ .uuid()
+ .describe('The UUID of the workflow version'),
+ source: z
+ .union([z.literal('trigger'), z.string().uuid()])
+ .describe('The source step: "trigger" or a step UUID'),
+ target: z.string().uuid().describe('The UUID of the target step'),
sourceConnectionOptions: z
.object({
connectedStepType: z.literal(WorkflowActionType.ITERATOR),
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-step.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-step.tool.ts
index 34cdf803b8e..c3cba2c0165 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-step.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/delete-workflow-version-step.tool.ts
@@ -8,8 +8,9 @@ import {
const deleteWorkflowVersionStepSchema = z.object({
workflowVersionId: z
.string()
- .describe('The ID of the workflow version containing the step'),
- stepId: z.string().describe('The ID of the step to delete'),
+ .uuid()
+ .describe('The UUID of the workflow version containing the step'),
+ stepId: z.string().uuid().describe('The UUID of the step to delete'),
});
type DeleteWorkflowVersionStepInput = z.infer<
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/get-workflow-current-version.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/get-workflow-current-version.tool.ts
index e851b1c978a..c68ee12dc06 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/get-workflow-current-version.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/get-workflow-current-version.tool.ts
@@ -15,7 +15,8 @@ import {
const getWorkflowCurrentVersionSchema = z.object({
workflowId: z
.string()
- .describe('The ID of the workflow to get the current version for'),
+ .uuid()
+ .describe('The UUID of the workflow to get the current version for'),
});
type GetWorkflowCurrentVersionInput = z.infer<
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-positions.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-positions.tool.ts
index ae2ac3dcf04..4985426f67f 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-positions.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-positions.tool.ts
@@ -7,7 +7,10 @@ import {
} from 'src/modules/workflow/workflow-tools/types/workflow-tool-dependencies.type';
const updateWorkflowVersionPositionsSchema = z.object({
- workflowVersionId: z.string().describe('The ID of the workflow version'),
+ workflowVersionId: z
+ .string()
+ .uuid()
+ .describe('The UUID of the workflow version'),
positions: z
.array(
z.object({
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-step.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-step.tool.ts
index 1d3110d7710..3236e9110aa 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-step.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-step.tool.ts
@@ -10,7 +10,8 @@ import {
const updateWorkflowVersionStepSchema = z.object({
workflowVersionId: z
.string()
- .describe('The ID of the workflow version containing the step'),
+ .uuid()
+ .describe('The UUID of the workflow version containing the step'),
step: z
.union([workflowActionSchema])
.describe('The updated step configuration'),
diff --git a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-trigger.tool.ts b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-trigger.tool.ts
index 82aee5f6b80..9c2d5eb2697 100644
--- a/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-trigger.tool.ts
+++ b/packages/twenty-server/src/modules/workflow/workflow-tools/tools/update-workflow-version-trigger.tool.ts
@@ -10,7 +10,8 @@ import {
const updateWorkflowVersionTriggerSchema = z.object({
workflowVersionId: z
.string()
- .describe('The ID of the workflow version containing the trigger'),
+ .uuid()
+ .describe('The UUID of the workflow version containing the trigger'),
trigger: workflowTriggerSchema.describe('The updated trigger configuration'),
});