@agenticmail/api 0.5.35 → 0.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2780,7 +2780,7 @@ function createTaskRoutes(db, accountManager, config) {
|
|
|
2780
2780
|
const router = Router9();
|
|
2781
2781
|
router.post("/tasks/assign", requireAuth, async (req, res, next) => {
|
|
2782
2782
|
try {
|
|
2783
|
-
const { assignee, taskType, payload, expiresInSeconds
|
|
2783
|
+
const { assignee, taskType, payload, expiresInSeconds } = req.body || {};
|
|
2784
2784
|
if (!assignee) {
|
|
2785
2785
|
res.status(400).json({ error: "assignee (agent name) is required" });
|
|
2786
2786
|
return;
|
|
@@ -2796,32 +2796,20 @@ function createTaskRoutes(db, accountManager, config) {
|
|
|
2796
2796
|
db.prepare(
|
|
2797
2797
|
"INSERT INTO agent_tasks (id, assigner_id, assignee_id, task_type, payload, expires_at) VALUES (?, ?, ?, ?, ?, ?)"
|
|
2798
2798
|
).run(id, assignerId, target.id, taskType || "generic", JSON.stringify(payload || {}), expiresAt);
|
|
2799
|
-
const
|
|
2799
|
+
const taskDescription = payload?.task || payload?.description || JSON.stringify(payload || {});
|
|
2800
|
+
const spawnEvent = {
|
|
2800
2801
|
type: "task",
|
|
2801
2802
|
taskId: id,
|
|
2802
|
-
taskType:
|
|
2803
|
+
taskType: "rpc",
|
|
2804
|
+
task: `You have a pending task (ID: ${id}). Check your pending tasks, claim it, process it, and submit the result.
|
|
2805
|
+
|
|
2806
|
+
Type: ${taskType || "generic"}
|
|
2807
|
+
Task: ${taskDescription}`,
|
|
2803
2808
|
assignee: target.name,
|
|
2804
2809
|
from: req.agent?.name ?? "system"
|
|
2805
2810
|
};
|
|
2806
|
-
if (!pushEventToAgent(target.id,
|
|
2807
|
-
broadcastEvent(
|
|
2808
|
-
}
|
|
2809
|
-
if (autoRun) {
|
|
2810
|
-
const taskDescription = payload?.task || payload?.description || `Process ${taskType || "generic"} task`;
|
|
2811
|
-
const spawnEvent = {
|
|
2812
|
-
type: "task",
|
|
2813
|
-
taskId: id,
|
|
2814
|
-
taskType: "rpc",
|
|
2815
|
-
task: `You have a pending task (ID: ${id}). Check your pending tasks, claim it, process it, and submit the result.
|
|
2816
|
-
|
|
2817
|
-
Task: ${taskDescription}`,
|
|
2818
|
-
assignee: target.name,
|
|
2819
|
-
from: req.agent?.name ?? "system",
|
|
2820
|
-
_autoRun: true
|
|
2821
|
-
};
|
|
2822
|
-
if (!pushEventToAgent(target.id, spawnEvent)) {
|
|
2823
|
-
broadcastEvent(spawnEvent);
|
|
2824
|
-
}
|
|
2811
|
+
if (!pushEventToAgent(target.id, spawnEvent)) {
|
|
2812
|
+
broadcastEvent(spawnEvent);
|
|
2825
2813
|
}
|
|
2826
2814
|
if (req.agent) {
|
|
2827
2815
|
const notifSender = new MailSender4({
|
|
@@ -2846,7 +2834,7 @@ Please check your pending tasks.`
|
|
|
2846
2834
|
notifSender.close();
|
|
2847
2835
|
});
|
|
2848
2836
|
}
|
|
2849
|
-
res.status(201).json({ id, assignee: target.name, assigneeId: target.id, status:
|
|
2837
|
+
res.status(201).json({ id, assignee: target.name, assigneeId: target.id, status: "pending" });
|
|
2850
2838
|
} catch (err) {
|
|
2851
2839
|
next(err);
|
|
2852
2840
|
}
|