MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / readTaskMessages

Function readTaskMessages

src/core/task-persistence/taskMessages.ts:17–44  ·  view source on GitHub ↗
({
	taskId,
	globalStoragePath,
}: ReadTaskMessagesOptions)

Source from the content-addressed store, hash-verified

15}
16
17export async function readTaskMessages({
18 taskId,
19 globalStoragePath,
20}: ReadTaskMessagesOptions): Promise<ClineMessage[]> {
21 const taskDir = await getTaskDirectoryPath(globalStoragePath, taskId)
22 const filePath = path.join(taskDir, GlobalFileNames.uiMessages)
23 const fileExists = await fileExistsAtPath(filePath)
24
25 if (fileExists) {
26 try {
27 const parsedData = JSON.parse(await fs.readFile(filePath, "utf8"))
28 if (!Array.isArray(parsedData)) {
29 console.warn(
30 `[readTaskMessages] Parsed data is not an array (got ${typeof parsedData}), returning empty. TaskId: ${taskId}, Path: ${filePath}`,
31 )
32 return []
33 }
34 return parsedData
35 } catch (error) {
36 console.warn(
37 `[readTaskMessages] Failed to parse ${filePath} for task ${taskId}, returning empty: ${error instanceof Error ? error.message : String(error)}`,
38 )
39 return []
40 }
41 }
42
43 return []
44}
45
46export type SaveTaskMessagesOptions = {
47 messages: ClineMessage[]

Callers 3

getSavedClineMessagesMethod · 0.90

Calls 6

getTaskDirectoryPathFunction · 0.90
fileExistsAtPathFunction · 0.90
parseMethod · 0.80
warnMethod · 0.65
StringInterface · 0.50
readFileMethod · 0.45

Tested by

no test coverage detected