@artinet/sdk
Version:
A TypeScript SDK for building collaborative AI agents.
14 lines (13 loc) • 509 B
JavaScript
import { TASK_NOT_FOUND, INTERNAL_ERROR } from "../../../utils/index.js";
import { getLatestHistory } from "../helpers/index.js";
export const getTask = async ({ id: taskId, historyLength }, context) => {
if (!context) {
throw INTERNAL_ERROR({ error: { message: "Context is required" } });
}
const task = await context.service.tasks.get(taskId);
if (!task) {
throw TASK_NOT_FOUND({ taskId });
}
task.history = getLatestHistory(task, historyLength);
return task;
};