( store: TaskLedgerStore, name: string, updateToolName: string, )
| 28 | } |
| 29 | |
| 30 | function buildTaskCreateTool( |
| 31 | store: TaskLedgerStore, |
| 32 | name: string, |
| 33 | updateToolName: string, |
| 34 | ): MakaTool<{ tasks: Array<{ subject: string; parent_id?: string }> }, string> { |
| 35 | return { |
| 36 | name, |
| 37 | displayName: 'Task Create', |
| 38 | description: |
| 39 | 'Add one or more tasks to the session task ledger. The full updated ledger is re-shown each turn, ' + |
| 40 | `so use this to record work you plan to do; update status with ${updateToolName} as you progress.`, |
| 41 | parameters: z.object({ |
| 42 | tasks: z |
| 43 | .array( |
| 44 | z.object({ |
| 45 | subject: z |
| 46 | .string() |
| 47 | .trim() |
| 48 | .min(1) |
| 49 | .max(TASK_SUBJECT_MAX_CHARS) |
| 50 | .describe( |
| 51 | `Short imperative description of the task (max ${TASK_SUBJECT_MAX_CHARS} characters).`, |
| 52 | ), |
| 53 | parent_id: z |
| 54 | .string() |
| 55 | .min(1) |
| 56 | .max(TASK_ID_MAX_CHARS) |
| 57 | .refine(isSafeTaskId) |
| 58 | .optional() |
| 59 | .describe('Existing parent task UUID or short key (for example T1).'), |
| 60 | }), |
| 61 | ) |
| 62 | .min(1) |
| 63 | .max(TASK_LEDGER_MAX_TASKS) |
| 64 | .describe('One or more tasks to add. Each starts in the pending state.'), |
| 65 | }), |
| 66 | impl: async (input, ctx) => { |
| 67 | const { created, total } = await store.create( |
| 68 | ctx.sessionId, |
| 69 | input.tasks.map((task) => ({ |
| 70 | subject: task.subject, |
| 71 | ...(task.parent_id ? { parentId: task.parent_id } : {}), |
| 72 | })), |
| 73 | { |
| 74 | runId: ctx.runId, |
| 75 | turnId: ctx.turnId, |
| 76 | toolCallId: ctx.toolCallId, |
| 77 | source: 'tool', |
| 78 | actor: 'main_agent', |
| 79 | }, |
| 80 | ); |
| 81 | return `Created ${created.length} task(s); ledger total: ${total}.\n${renderSafeTaskLedgerText(created)}`; |
| 82 | }, |
| 83 | }; |
| 84 | } |
| 85 | |
| 86 | function buildTaskUpdateTool( |
| 87 | store: TaskLedgerStore, |
no test coverage detected