@mastra/core
Version:
178 lines • 6.46 kB
TypeScript
import { z } from 'zod/v4';
import type { RequestContext } from '../../request-context/index.js';
/** RequestContext key under which the current working task list is surfaced within a turn. */
export declare const TASKS_REQUEST_CONTEXT_KEY = "mastra:tasks";
/** State-signal lane id used for the task list. */
export declare const TASKS_STATE_ID = "tasks";
/** `threadState` storage `type` namespace under which the task list is stored. */
export declare const TASK_STATE_TYPE = "task";
declare const taskItemInputSchema: z.ZodObject<{
id: z.ZodOptional<z.ZodString>;
content: z.ZodString;
status: z.ZodEnum<{
pending: "pending";
completed: "completed";
in_progress: "in_progress";
}>;
activeForm: z.ZodString;
}, z.core.$strip>;
declare const taskItemSchema: z.ZodObject<{
content: z.ZodString;
status: z.ZodEnum<{
pending: "pending";
completed: "completed";
in_progress: "in_progress";
}>;
activeForm: z.ZodString;
id: z.ZodString;
}, z.core.$strip>;
export type TaskItemInput = z.infer<typeof taskItemInputSchema>;
export type TaskItem = z.infer<typeof taskItemSchema>;
export type TaskItemSnapshot = TaskItem;
declare const taskCheckSummarySchema: z.ZodObject<{
total: z.ZodNumber;
completed: z.ZodNumber;
inProgress: z.ZodNumber;
pending: z.ZodNumber;
incomplete: z.ZodNumber;
hasTasks: z.ZodBoolean;
allCompleted: z.ZodBoolean;
}, z.core.$strip>;
declare const taskCheckResultSchema: z.ZodObject<{
content: z.ZodString;
tasks: z.ZodArray<z.ZodObject<{
content: z.ZodString;
status: z.ZodEnum<{
pending: "pending";
completed: "completed";
in_progress: "in_progress";
}>;
activeForm: z.ZodString;
id: z.ZodString;
}, z.core.$strip>>;
isError: z.ZodBoolean;
summary: z.ZodObject<{
total: z.ZodNumber;
completed: z.ZodNumber;
inProgress: z.ZodNumber;
pending: z.ZodNumber;
incomplete: z.ZodNumber;
hasTasks: z.ZodBoolean;
allCompleted: z.ZodBoolean;
}, z.core.$strip>;
incompleteTasks: z.ZodArray<z.ZodObject<{
content: z.ZodString;
status: z.ZodEnum<{
pending: "pending";
completed: "completed";
in_progress: "in_progress";
}>;
activeForm: z.ZodString;
id: z.ZodString;
}, z.core.$strip>>;
}, z.core.$strip>;
export type TaskCheckSummary = z.infer<typeof taskCheckSummarySchema>;
export type TaskCheckResult = z.infer<typeof taskCheckResultSchema>;
export declare function assignTaskIds(tasks: TaskItemInput[], previousTasks?: TaskItemSnapshot[]): TaskItemSnapshot[];
export declare function formatTaskListResult(tasks: TaskItemSnapshot[]): string;
export declare function summarizeTaskCheck(tasks: TaskItemSnapshot[]): {
summary: TaskCheckSummary;
inProgressTasks: TaskItemSnapshot[];
pendingTasks: TaskItemSnapshot[];
incompleteTasks: TaskItemSnapshot[];
};
export declare function hasMultipleInProgress(tasks: TaskItemSnapshot[]): boolean;
export declare function demoteExtraInProgress(tasks: TaskItemSnapshot[], preferredIndex?: number): TaskItemSnapshot[];
/**
* Built-in, agent-agnostic tool: manage a structured task list for the run.
* Full-replacement semantics: each call replaces the entire task list.
* Prefer task_update or task_complete for changing existing tasks by ID.
*/
export declare const taskWriteTool: import("..").Tool<{
tasks: {
content: string;
status: "pending" | "completed" | "in_progress";
activeForm: string;
id?: string | undefined;
}[];
}, {
content: string;
tasks: {
content: string;
status: "pending" | "completed" | "in_progress";
activeForm: string;
id: string;
}[];
isError: boolean;
}, unknown, unknown, import("..").ToolExecutionContext<unknown, unknown, unknown>, "task_write", unknown>;
/**
* Built-in, agent-agnostic tool: update one tracked task by stable ID.
*/
export declare const taskUpdateTool: import("..").Tool<{
id: string;
content?: string | undefined;
status?: "pending" | "completed" | "in_progress" | undefined;
activeForm?: string | undefined;
}, {
content: string;
tasks: {
content: string;
status: "pending" | "completed" | "in_progress";
activeForm: string;
id: string;
}[];
isError: boolean;
}, unknown, unknown, import("..").ToolExecutionContext<unknown, unknown, unknown>, "task_update", unknown>;
/**
* Built-in, agent-agnostic tool: mark one tracked task completed by stable ID.
*/
export declare const taskCompleteTool: import("..").Tool<{
id: string;
}, {
content: string;
tasks: {
content: string;
status: "pending" | "completed" | "in_progress";
activeForm: string;
id: string;
}[];
isError: boolean;
}, unknown, unknown, import("..").ToolExecutionContext<unknown, unknown, unknown>, "task_complete", unknown>;
/**
* Built-in, agent-agnostic tool: check the completion status of the task list.
* Helps the agent determine if all tasks are completed before ending work.
*/
export declare const taskCheckTool: import("..").Tool<Record<string, never>, {
content: string;
tasks: {
content: string;
status: "pending" | "completed" | "in_progress";
activeForm: string;
id: string;
}[];
isError: boolean;
summary: {
total: number;
completed: number;
inProgress: number;
pending: number;
incomplete: number;
hasTasks: boolean;
allCompleted: boolean;
};
incompleteTasks: {
content: string;
status: "pending" | "completed" | "in_progress";
activeForm: string;
id: string;
}[];
}, unknown, unknown, import("..").ToolExecutionContext<unknown, unknown, unknown>, "task_check", unknown>;
/**
* Read the within-turn task list carried on the `RequestContext` by the task
* tools (used by the task state processor to build the snapshot for the current
* step). Returns `undefined` when no task tool ran this turn, so the processor
* can fall back to the durable task store.
*/
export declare function getTasksFromRequestContext(requestContext: RequestContext | undefined): TaskItemSnapshot[] | undefined;
export {};
//# sourceMappingURL=task-tools.d.ts.map