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

Function addTask2Tree

src/modules/taskManager.ts:223–258  ·  view source on GitHub ↗
(
  task: partialTaskDraft,
  parent: LLMTask | undefined,
  chatState: ChatStateType,
  execute = true
)

Source from the content-addressed store, hash-verified

221}
222
223export function addTask2Tree(
224 task: partialTaskDraft,
225 parent: LLMTask | undefined,
226 chatState: ChatStateType,
227 execute = true
228) {
229 const uuid = base64Uuid();
230
231 const newTask: LLMTask = {
232 role: task.role,
233 parentID: parent?.id,
234 content: task.content || null,
235 state: task.state || 'Open',
236 childrenIDs: [],
237 debugging: task.debugging || {},
238 id: uuid,
239 created_at: Date.now(),
240 context: task.context,
241 allowedTools: task.allowedTools || parent?.allowedTools,
242 };
243
244 console.log('create new Task:', newTask.id);
245
246 // connect task to task tree
247 chatState.Tasks[newTask.id] = newTask;
248 if (parent) {
249 parent.childrenIDs.push(newTask.id);
250 }
251 // Push the new function task to processTasksQueue
252 if (execute) {
253 processTasksQueue.push(chatState.Tasks[newTask.id]);
254 chatState.Tasks[newTask.id].state = 'Queued';
255 }
256 chatState.selectedTaskId = newTask.id;
257 return newTask.id;
258}

Callers 1

Calls 2

base64UuidFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected