MCPcopy Create free account
hub / github.com/apache/maka / buildTaskListTool

Function buildTaskListTool

packages/runtime/src/task-ledger-tools.ts:224–280  ·  view source on GitHub ↗
(store: TaskLedgerStore)

Source from the content-addressed store, hash-verified

222}
223
224function buildTaskListTool(store: TaskLedgerStore): MakaTool<
225 {
226 status?: (typeof TASK_STATUSES)[number];
227 include_terminal?: boolean;
228 include_archived?: boolean;
229 },
230 string
231> {
232 return {
233 name: TASK_LIST_TOOL_NAME,
234 displayName: 'Task List',
235 description: 'List the current session task ledger in compact form.',
236 parameters: z
237 .object({
238 status: z.enum(TASK_STATUSES).optional().describe('Optional exact status filter.'),
239 include_terminal: z
240 .boolean()
241 .optional()
242 .describe('Include terminal tasks. Defaults to true for compatibility.'),
243 include_archived: z
244 .boolean()
245 .optional()
246 .describe(
247 'Include terminal tasks older than seven days. Defaults to true for compatibility.',
248 ),
249 })
250 .superRefine((input, ctx) => {
251 if (
252 input.status &&
253 isTerminalTaskStatus(input.status) &&
254 input.include_terminal === false
255 ) {
256 ctx.addIssue({
257 code: z.ZodIssueCode.custom,
258 path: ['include_terminal'],
259 message: 'A terminal status filter conflicts with include_terminal=false.',
260 });
261 }
262 }),
263 impl: async (input, ctx) => {
264 const tasks = filterModelVisibleTaskLedgerTasks(
265 await store.list(ctx.sessionId, {
266 ...(input.status ? { status: input.status } : {}),
267 ...(input.include_terminal !== undefined
268 ? { includeTerminal: input.include_terminal }
269 : {}),
270 ...(input.include_archived !== undefined
271 ? { includeArchived: input.include_archived }
272 : {}),
273 }),
274 );
275 return tasks.length === 0
276 ? 'Task ledger is empty.'
277 : `Task ledger total: ${tasks.length}.\n${renderSafeTaskLedgerText(tasks)}`;
278 },
279 };
280}
281

Callers 1

buildTaskLedgerToolsFunction · 0.85

Calls 4

isTerminalTaskStatusFunction · 0.90
renderSafeTaskLedgerTextFunction · 0.90
listMethod · 0.65

Tested by

no test coverage detected