@agenticmail/api 0.5.34 → 0.5.35

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -2
  2. 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 } = req.body || {};
2783
+ const { assignee, taskType, payload, expiresInSeconds, autoRun } = req.body || {};
2784
2784
  if (!assignee) {
2785
2785
  res.status(400).json({ error: "assignee (agent name) is required" });
2786
2786
  return;
@@ -2806,6 +2806,23 @@ function createTaskRoutes(db, accountManager, config) {
2806
2806
  if (!pushEventToAgent(target.id, taskEvent)) {
2807
2807
  broadcastEvent(taskEvent);
2808
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
+ }
2825
+ }
2809
2826
  if (req.agent) {
2810
2827
  const notifSender = new MailSender4({
2811
2828
  host: config.smtp.host,
@@ -2829,7 +2846,7 @@ Please check your pending tasks.`
2829
2846
  notifSender.close();
2830
2847
  });
2831
2848
  }
2832
- res.status(201).json({ id, assignee: target.name, assigneeId: target.id, status: "pending" });
2849
+ res.status(201).json({ id, assignee: target.name, assigneeId: target.id, status: autoRun ? "pending (auto-run)" : "pending" });
2833
2850
  } catch (err) {
2834
2851
  next(err);
2835
2852
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/api",
3
- "version": "0.5.34",
3
+ "version": "0.5.35",
4
4
  "description": "REST API server for AgenticMail \u2014 email and SMS endpoints for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",