Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix: email trigger ws
Gusea76ea2e8b5c
diff --git a/src/shared/src/types.ts b/src/shared/src/types.tsindex 97b87cc9b..f54a47ada 100644--- a/src/shared/src/types.ts+++ b/src/shared/src/types.ts@@ -200,6 +200,7 @@ export interface CreateAgentRequest {runtime_config?: Record<string, unknown>;max_concurrent_tasks?: number;email_handle?: string;+ avatar_url?: string | null;}export interface AgentLink {@@ -238,6 +239,7 @@ export type WsMessage =| { type: "runtime.registered"; daemonId: string; hostname: string; workspaceId: string }| { type: "runtime.status"; daemonId: string; workspaceId: string; status: string }| { type: "runtime.deleted"; daemonId: string }+ | { type: "task.created"; conversationId: string; task: TaskApi }| { type: "task.updated"; taskId: string; agentId: string; status: string }| { type: "task.messages"; taskId: string; messages: TaskMessage[] }| { type: "email.received"; agentId: string }diff --git a/src/web/src/app/(app)/w/[slug]/agents/new/page.tsx b/src/web/src/app/(app)/w/[slug]/agents/new/page.tsxindex 5dd74fc09..d04bbe0d2 100644--- a/src/web/src/app/(app)/w/[slug]/agents/new/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/agents/new/page.tsx@@ -47,6 +47,7 @@ export default function CreateAgentPage() {runtime_id: data.runtime_id,email_handle: data.email_handle || undefined,runtime_config: data.runtime_config,+ avatar_url: data.avatar_url,});if (agent) {if (data.custom_email) {diff --git a/src/web/src/app/api/email/notify/route.ts b/src/web/src/app/api/email/notify/route.tsindex 8dd984e99..9471a37c5 100644--- a/src/web/src/app/api/email/notify/route.ts+++ b/src/web/src/app/api/email/notify/route.ts@@ -5,6 +5,7 @@ import { getDb } from "@/lib/db"import { writeJSON, parseBody } from "@/lib/middleware/helpers"import { TaskService } from "@/lib/services/task"import { broadcastToUser } from "@/lib/broadcast"+import { taskToResponse } from "@/lib/api/responses"export async function POST(req: NextRequest) {const { env } = getCloudflareContext()@@ -111,7 +112,15 @@ export async function POST(req: NextRequest) {const taskService = new TaskService(db)const context: Record<string, unknown> = { conversationType };if (dmUser) context.dmUser = dmUser;- await taskService.enqueueTask(agent.id, conversationId, agent.workspaceId, prompt, TASK_TYPES.EMAIL_NOTIFICATION, { contextKey: conversationId, context })+ const task = await taskService.enqueueTask(agent.id, conversationId, agent.workspaceId, prompt, TASK_TYPES.EMAIL_NOTIFICATION, { contextKey: conversationId, context })++ if (conversationType === TASK_TYPES.USER_DM_MESSAGE) {+ broadcastToUser(agent.ownerId, {+ type: "task.created",+ conversationId,+ task: taskToResponse(task),+ }).catch(() => {});+ }}if (agent?.ownerId) {diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsxindex e8505a6c3..30e8de8a3 100644--- a/src/web/src/components/agent-chat/agent-chat-view.tsx+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx@@ -722,6 +722,17 @@ export function AgentChatView() {lastSeqRef.current = Math.max(...incoming.map((m) => m.seq), lastSeqRef.current);}}+ if (msg.type === "task.created" && msg.conversationId === conversation?.id) {+ listMessages(msg.conversationId, workspaceId)+ .then((latest) => setMessages((prev) => mergeMessages(prev, latest)))+ .catch(() => {});+ const task = msg.task as Task;+ activeTaskIdRef.current = task.id;+ setActiveTask(task);+ setTaskMessages([]);+ lastSeqRef.current = 0;+ startPollingRef.current(task.id, msg.conversationId);+ }if (msg.type === "conversation.message" && msg.conversationId === conversation?.id) {setMessages((prev) => mergeMessages(prev, [msg.message]));}@@ -733,11 +744,11 @@ export function AgentChatView() {}if (msg.type === "followup.dispatched" && msg.conversationId === conversation?.id) {setBufferedMessages((prev) => prev.filter((m) => m.id !== msg.message.id));- // Fetch all messages so the completed task's agent response is includedlistMessages(msg.conversationId, workspaceId).then((latest) => setMessages((prev) => mergeMessages(prev, latest))).catch(() => { });const task = msg.task as Task;+ activeTaskIdRef.current = task.id;setActiveTask(task);setTaskMessages([]);startPollingRef.current(task.id, msg.conversationId);