MCPcopy Create free account
hub / github.com/Xyntopia/taskyon / taskChain

Function taskChain

src/modules/taskManager.ts:117–138  ·  view source on GitHub ↗
(lastTaskId: string, tasks: Record<string, LLMTask>)

Source from the content-addressed store, hash-verified

115}
116
117export function taskChain(lastTaskId: string, tasks: Record<string, LLMTask>) {
118 // Start with the selected task
119 let currentTaskID = lastTaskId;
120 const conversationList: string[] = [];
121
122 // Trace back the parentIDs to the original task in the chain
123 while (currentTaskID) {
124 // Get the current task
125 const currentTask = tasks[currentTaskID];
126 if (!currentTask) break; // Break if we reach a task that doesn't exist
127
128 // Prepend the current task to the conversation list so the selected task ends up being the last in the list
129 conversationList.unshift(currentTaskID);
130
131 // Move to the parent task
132 if (currentTask.parentID) {
133 currentTaskID = currentTask.parentID; // This can now be string | undefined
134 } else break; // Break if we reach an "initial" task
135 }
136
137 return conversationList;
138}
139
140function base64Uuid() {
141 // Generate a UUID

Callers 2

buildChatFromTaskFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected