MCPcopy Create free account
hub / github.com/Noumena-Network/code / createTask

Function createTask

src/utils/tasks.ts:285–309  ·  view source on GitHub ↗
(
  taskListId: string,
  taskData: Omit<Task, 'id'>,
)

Source from the content-addressed store, hash-verified

283 * create tasks concurrently.
284 */
285export async function createTask(
286 taskListId: string,
287 taskData: Omit<Task, 'id'>,
288): Promise<string> {
289 const lockPath = await ensureTaskListLockFile(taskListId)
290
291 let release: (() => Promise<void>) | undefined
292 try {
293 // Acquire exclusive lock on the task list
294 release = await lockfile.lock(lockPath, LOCK_OPTIONS)
295
296 // Read highest ID from disk while holding the lock
297 const highestId = await findHighestTaskId(taskListId)
298 const id = String(highestId + 1)
299 const task: Task = { id, ...taskData }
300 const path = getTaskPath(taskListId, id)
301 await writeFile(path, jsonStringify(task, null, 2))
302 notifyTasksUpdated()
303 return id
304 } finally {
305 if (release) {
306 await release()
307 }
308 }
309}
310
311export async function getTask(
312 taskListId: string,

Callers 2

callFunction · 0.85
taskCreateHandlerFunction · 0.85

Calls 6

ensureTaskListLockFileFunction · 0.85
findHighestTaskIdFunction · 0.85
getTaskPathFunction · 0.85
jsonStringifyFunction · 0.85
notifyTasksUpdatedFunction · 0.85
releaseFunction · 0.50

Tested by

no test coverage detected