MCPcopy
hub / github.com/coder/mux / createTaskListTool

Function createTaskListTool

src/node/services/tools/task_list.ts:206–338  ·  view source on GitHub ↗
(config: ToolConfiguration)

Source from the content-addressed store, hash-verified

204}
205
206export const createTaskListTool: ToolFactory = (config: ToolConfiguration) => {
207 return tool({
208 description: TOOL_DEFINITIONS.task_list.description,
209 inputSchema: TOOL_DEFINITIONS.task_list.schema,
210 execute: async (args): Promise<unknown> => {
211 const workspaceId = requireWorkspaceId(config, "task_list");
212 const taskService = requireTaskService(config, "task_list");
213
214 const statuses =
215 args.statuses && args.statuses.length > 0 ? args.statuses : [...DEFAULT_STATUSES];
216 const includeArchived = args.includeArchived ?? false;
217 const archiveLookup = includeArchived
218 ? null
219 : createWorkspaceArchiveLookup(config, workspaceId);
220 const agentStatuses = statuses.filter(isAgentTaskStatus);
221
222 const allAgentTasks =
223 agentStatuses.length > 0
224 ? taskService.listDescendantAgentTasks(workspaceId, {
225 statuses: agentStatuses,
226 excludeWorkflowTasks: true,
227 })
228 : [];
229 const agentTasks = allAgentTasks.filter(
230 (task) => !shouldHideArchivedAgentTask(task, archiveLookup)
231 );
232 const tasks: TaskListToolSuccessResult["tasks"] = [...agentTasks];
233
234 // Workflow runs are workspace-scoped (not parent/child workspaces), so they surface as
235 // depth-1 entries. interrupted/failed runs stay listable here because they are the
236 // resumable ones (workflow_resume).
237 if (config.workflowService?.listRuns != null) {
238 const runs = await config.workflowService.listRuns({ workspaceId });
239 for (const rawRun of runs) {
240 const parsed = WorkflowRunRecordSchema.safeParse(rawRun);
241 if (
242 !parsed.success ||
243 !statuses.includes(parsed.data.status) ||
244 isNestedWorkflowRun(parsed.data)
245 ) {
246 continue;
247 }
248 const workflowProgress = buildWorkflowProgressSummary(parsed.data);
249 tasks.push({
250 taskId: parsed.data.id,
251 status: parsed.data.status,
252 parentWorkspaceId: workspaceId,
253 title: parsed.data.workflow.name,
254 createdAt: parsed.data.createdAt,
255 ...(workflowProgress != null ? { workflowProgress } : {}),
256 depth: 1,
257 });
258 }
259 }
260
261 const workspaceTurnStatuses = statuses.filter(
262 (
263 status

Callers 3

getToolsForModelFunction · 0.90
task.bash.test.tsFile · 0.90
task_list.test.tsFile · 0.90

Calls 15

requireWorkspaceIdFunction · 0.90
requireTaskServiceFunction · 0.90
isNestedWorkflowRunFunction · 0.90
toBashTaskIdFunction · 0.90
parseToolResultFunction · 0.90

Tested by

no test coverage detected