tasks.js•3.09 kB
export const taskTools = [
{
name: "list_tasks",
description: "List tasks with optional filtering and pagination",
inputSchema: {
type: "object",
properties: {
filter: { type: "string", description: "Filter query (JSON string)" },
orderBy: { type: "string", description: "Order by field" },
limit: { type: "number", description: "Number of results (max 100)" },
depth: { type: "number", description: "Query depth for relations" },
startingAfter: { type: "string", description: "Cursor for pagination" },
endingBefore: { type: "string", description: "Cursor for pagination" }
}
}
},
{
name: "create_task",
description: "Create a new task in Twenty CRM",
inputSchema: {
type: "object",
properties: {
title: { type: "string", description: "Task title" },
body: { type: "string", description: "Task body/description" },
dueAt: { type: "string", format: "date-time", description: "Due date" },
status: { type: "string", description: "Task status" },
assigneeId: { type: "string", format: "uuid", description: "Assignee ID" },
position: { type: "number", description: "Position" }
}
}
},
{
name: "get_task",
description: "Get details of a specific task by ID",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Task ID" },
depth: { type: "number", description: "Query depth for relations" }
},
required: ["id"]
}
},
{
name: "update_task",
description: "Update an existing task's information",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Task ID" },
title: { type: "string" },
body: { type: "string" },
dueAt: { type: "string", format: "date-time" },
status: { type: "string" },
assigneeId: { type: "string", format: "uuid" },
position: { type: "number" }
},
required: ["id"]
}
},
{
name: "delete_task",
description: "Delete a task from Twenty CRM",
inputSchema: {
type: "object",
properties: {
id: { type: "string", format: "uuid", description: "Task ID" }
},
required: ["id"]
}
}
];
export async function executeTaskTool(toolName, params, apiClient) {
switch (toolName) {
case "list_tasks":
return await apiClient.makeRequest("/tasks", "GET", null, params);
case "create_task":
return await apiClient.makeRequest("/tasks", "POST", params);
case "get_task":
return await apiClient.makeRequest(`/tasks/${params.id}`, "GET", null, { depth: params.depth });
case "update_task":
const { id: taskId, ...taskData } = params;
return await apiClient.makeRequest(`/tasks/${taskId}`, "PUT", taskData);
case "delete_task":
return await apiClient.makeRequest(`/tasks/${params.id}`, "DELETE");
default:
throw new Error(`Unknown task tool: ${toolName}`);
}
}