MCPcopy Index your code
hub / github.com/Noumena-Network/code / getTask

Function getTask

src/utils/tasks.ts:311–351  ·  view source on GitHub ↗
(
  taskListId: string,
  taskId: string,
)

Source from the content-addressed store, hash-verified

309}
310
311export async function getTask(
312 taskListId: string,
313 taskId: string,
314): Promise<Task | null> {
315 const path = getTaskPath(taskListId, taskId)
316 try {
317 const content = await readFile(path, 'utf-8')
318 const data = jsonParse(content) as { status?: string }
319
320 // TEMPORARY: Migrate old status names for existing sessions (ant-only)
321 if (isInternalBuild()) {
322 if (data.status === 'open') data.status = 'pending'
323 else if (data.status === 'resolved') data.status = 'completed'
324 // Migrate development task statuses to in_progress
325 else if (
326 data.status &&
327 ['planning', 'implementing', 'reviewing', 'verifying'].includes(
328 data.status,
329 )
330 ) {
331 data.status = 'in_progress'
332 }
333 }
334 const parsed = TaskSchema().safeParse(data)
335 if (!parsed.success) {
336 logForDebugging(
337 `[Tasks] Task ${taskId} failed schema validation: ${parsed.error.message}`,
338 )
339 return null
340 }
341 return parsed.data
342 } catch (e) {
343 const code = getErrnoCode(e)
344 if (code === 'ENOENT') {
345 return null
346 }
347 logForDebugging(`[Tasks] Failed to read task ${taskId}: ${errorMessage(e)}`)
348 logError(e)
349 return null
350 }
351}
352
353// Internal: no lock. Callers already holding a lock on taskPath must use this
354// to avoid deadlock (claimTask, deleteTask cascade, etc.).

Callers 9

callFunction · 0.85
callFunction · 0.85
updateTaskUnsafeFunction · 0.85
updateTaskFunction · 0.85
listTasksFunction · 0.85
blockTaskFunction · 0.85
claimTaskFunction · 0.85
taskCreateHandlerFunction · 0.85
taskGetHandlerFunction · 0.85

Calls 8

getTaskPathFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85
isInternalBuildFunction · 0.85
getErrnoCodeFunction · 0.85
logForDebuggingFunction · 0.70
errorMessageFunction · 0.70
logErrorFunction · 0.70

Tested by

no test coverage detected