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: push update/rescan commands via WS and simplify poll cleanup
Generbfd079fb70fc
diff --git a/src/web/src/app/api/daemon/tasks/poll/route.ts b/src/web/src/app/api/daemon/tasks/poll/route.tsindex 370cd3295..039e7a4c5 100644--- a/src/web/src/app/api/daemon/tasks/poll/route.ts+++ b/src/web/src/app/api/daemon/tasks/poll/route.ts@@ -66,24 +66,16 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {ctx.workspaceId,);if (machineRow?.pendingUpdateVersion && body.cli_version) {- if (semverGte(body.cli_version, machineRow.pendingUpdateVersion)) {- await queries.machine.clearPendingUpdateVersion(db, body.daemon_id, ctx.workspaceId);- broadcastToUser(ctx.userId, {- type: "runtime.status",- daemonId: body.daemon_id,- workspaceId: ctx.workspaceId,- status: "online",- }).catch(() => {});- } else {- pendingUpdate = { version: machineRow.pendingUpdateVersion };- await queries.machine.clearPendingUpdateVersion(db, body.daemon_id, ctx.workspaceId);- broadcastToUser(ctx.userId, {- type: "runtime.status",- daemonId: body.daemon_id,- workspaceId: ctx.workspaceId,- status: "online",- }).catch(() => {});- }+ pendingUpdate = semverGte(body.cli_version, machineRow.pendingUpdateVersion)+ ? undefined+ : { version: machineRow.pendingUpdateVersion };+ await queries.machine.clearPendingUpdateVersion(db, body.daemon_id, ctx.workspaceId);+ broadcastToUser(ctx.userId, {+ type: "runtime.status",+ daemonId: body.daemon_id,+ workspaceId: ctx.workspaceId,+ status: "online",+ }).catch(() => {});}if (machineRow?.pendingRescan) {diff --git a/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.test.ts b/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.test.tsindex 132b8c15a..7fcb9dfaa 100644--- a/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.test.ts+++ b/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.test.ts@@ -56,6 +56,10 @@ vi.mock("@/lib/logger", () => ({log: { warn: vi.fn(), info: vi.fn(), error: vi.fn(), debug: vi.fn() },}));+vi.mock("@/lib/broadcast", () => ({+ broadcastToDaemon: vi.fn(() => Promise.resolve()),+}));+import { POST } from "./route";function makeReq(runtimeId: string, workspaceId: string) {diff --git a/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.ts b/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.tsindex a87e35193..7a45e91d3 100644--- a/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.ts+++ b/src/web/src/app/api/runtimes/[runtimeId]/rescan/route.ts@@ -5,6 +5,7 @@ import { getDb } from "@/lib/db"import { withAuth } from "@/lib/middleware/auth";import { withWorkspaceMember } from "@/lib/middleware/workspace";import { writeJSON, writeError } from "@/lib/middleware/helpers";+import { broadcastToDaemon } from "@/lib/broadcast";export const POST = withAuth(async (req: NextRequest, ctx) => {const ws = await withWorkspaceMember(req, ctx);@@ -25,5 +26,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {await queries.machine.setPendingRescan(db, runtime.daemonId, ws.workspaceId);+ broadcastToDaemon(runtime.daemonId, { type: "daemon.rescan" }).catch(() => {});+return writeJSON({ pending_rescan: true });});diff --git a/src/web/src/app/api/runtimes/[runtimeId]/update/route.test.ts b/src/web/src/app/api/runtimes/[runtimeId]/update/route.test.tsindex cdf607f74..3ef41a218 100644--- a/src/web/src/app/api/runtimes/[runtimeId]/update/route.test.ts+++ b/src/web/src/app/api/runtimes/[runtimeId]/update/route.test.ts@@ -59,6 +59,10 @@ vi.mock("@/lib/logger", () => ({log: { warn: vi.fn(), info: vi.fn(), error: vi.fn(), debug: vi.fn() },}));+vi.mock("@/lib/broadcast", () => ({+ broadcastToDaemon: vi.fn(() => Promise.resolve()),+}));+// Mock global fetch for npm registryconst mockFetch = vi.fn();vi.stubGlobal("fetch", mockFetch);diff --git a/src/web/src/app/api/runtimes/[runtimeId]/update/route.ts b/src/web/src/app/api/runtimes/[runtimeId]/update/route.tsindex 2bb320a45..80f7fb603 100644--- a/src/web/src/app/api/runtimes/[runtimeId]/update/route.ts+++ b/src/web/src/app/api/runtimes/[runtimeId]/update/route.ts@@ -6,6 +6,7 @@ import { withAuth } from "@/lib/middleware/auth";import { withWorkspaceMember } from "@/lib/middleware/workspace";import { writeJSON, writeError } from "@/lib/middleware/helpers";import { fetchLatestCliVersion } from "@/lib/npm";+import { broadcastToDaemon } from "@/lib/broadcast";export const POST = withAuth(async (req: NextRequest, ctx) => {const ws = await withWorkspaceMember(req, ctx);@@ -29,6 +30,8 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {await queries.machine.setPendingUpdateVersion(db, runtime.daemonId, ws.workspaceId, result.version);+ broadcastToDaemon(runtime.daemonId, { type: "daemon.update", version: result.version }).catch(() => {});+return writeJSON({ pending_update_version: result.version });});