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
feat: use machine to track status
Gus49f817df577a
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f5edbe64f..7ae51db37 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -26,12 +26,6 @@ importers:'@alook/shared':specifier: workspace:*version: link:../shared- '@anthropic-ai/claude-agent-sdk':- specifier: ^0.2.105- version: 0.2.105([email protected])- '@openai/codex-sdk':- specifier: ^0.120.0- version: 0.120.0citty:specifier: ^0.2.2version: 0.2.2@@ -251,21 +245,6 @@ packages:'@antfu/[email protected]':resolution: {integrity: sha512-MGQsmw10ZyI+EJo45CdSER4zEb+p31LpDAFp2Z3gkSd1yqVZGi0Ebx++YTEMonJy4oChEMLsxZ64j8FH6sSqtQ==}- '@anthropic-ai/[email protected]':- resolution: {integrity: sha512-gPn7UEX6WrnIqCclNzfER6Of0mQ1ruxcNe0jrVXR9kOG09qFfaGzd6hy2qr3envCAB/dACkS7UDJoCm4/jg5Dg==}- engines: {node: '>=18.0.0'}- peerDependencies:- zod: ^4.0.0-- '@anthropic-ai/[email protected]':- resolution: {integrity: sha512-D4K5PvEV6wPiRtVlVsJHIUhHAmOZ6IT/I9rKlTf84gR7GyyAurPJK7z9BOf/AZqC5d1DhYQGJNKRmV+q8dGhgw==}- hasBin: true- peerDependencies:- zod: ^3.25.0 || ^4.0.0- peerDependenciesMeta:- zod:- optional: true-'@ast-grep/[email protected]':resolution: {integrity: sha512-2F072fGN0WTq7KI3okuEnkGJVEHLbi56Bw1H6NAMf7j2mJJeQWsRyGOMcyNnUXZDeNdvoMH0OB2a5wwUegY/nQ==}engines: {node: '>= 10'}@@ -1598,51 +1577,6 @@ packages:'@open-draft/[email protected]':resolution: {integrity: sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==}- '@openai/[email protected]':- resolution: {integrity: sha512-Y6y3EyLpSSJjRGqIFxxb1G9X6Hod+B1CnWzGoO7qrg3URPnjBL/DLLQWdZSENU5yIlRjHEQDSu7y1rKBlx+jUA==}- engines: {node: '>=18'}-- '@openai/[email protected]':- resolution: {integrity: sha512-e2P1Gya3dwsRe9IPOiswVz5JfR700u+/sWCqDc3jkqv2QViPkNiBmZoGhFnZL5jBpKakSjehC4/Fpspg70nHTw==}- engines: {node: '>=16'}- hasBin: true-- '@openai/[email protected]':- resolution: {integrity: sha512-7CU+I5kBaMuoqfG3xisq0mUWzxoEHvfu34cB8a0KpBiIhAgu12fKpmYgZ4/DvRP6Wm9Fu6LJYKVF5apUHFp8nQ==}- engines: {node: '>=16'}- cpu: [arm64]- os: [darwin]-- '@openai/[email protected]':- resolution: {integrity: sha512-d7joNYuwrmd5iIdp/xAE5f8bZT1r82MnmU6Hzgxq3G+xClwEyhxU737ZWnstFSpnZNfxJ5zXCuFUJh4CAkHNtQ==}- engines: {node: '>=16'}- cpu: [x64]- os: [darwin]-- '@openai/[email protected]':- resolution: {integrity: sha512-sVYY25/URlpZPtb0Q0ryLh+lcq9UTEtHAkdZKa0a/R7mAdyPuhpU9V6jWmxwiUh7s53XZOEVFoKmLfH8YIDWCQ==}- engines: {node: '>=16'}- cpu: [arm64]- os: [linux]-- '@openai/[email protected]':- resolution: {integrity: sha512-VcP9B/c/O+EFEgqoetCzvHrLfAdo8vrt09Gx1lJ8ikewctqAuJ/ozj/6wuvlz7XaaK64ib5cge01pOAeCyt2Sg==}- engines: {node: '>=16'}- cpu: [x64]- os: [linux]-- '@openai/[email protected]':- resolution: {integrity: sha512-SAaTQU1XHa1qDnmQldmbyROIY5SiaspF+Cw3ziWeeTgyAET3rWusm4ELOElx6QiY1ugYW5ZD+7AFufS2z1xtpQ==}- engines: {node: '>=16'}- cpu: [arm64]- os: [win32]-- '@openai/[email protected]':- resolution: {integrity: sha512-zja1GNrbHyOUTvOy5FVMa+rAYIs3m+FOS8rAXftxMEhodMmkMw2O8zcvso657SHhZR0hIEiZ6T70lcyH2YX0mQ==}- engines: {node: '>=16'}- cpu: [x64]- os: [win32]-'@opennextjs/[email protected]':resolution: {integrity: sha512-Pn8hLuP3M9EWlsZnS/O7Bm41Nt+lIOEsCaW/QJ3KlmIbtAeixnSj1CS80Z9PlQe/LQCe0GnQ8vGJeOdg5a4iWg==}hasBin: true@@ -4390,10 +4324,6 @@ packages:resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==}- resolution: {integrity: sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==}- engines: {node: '>=16'}-resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==}@@ -5656,9 +5586,6 @@ packages:resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==}- resolution: {integrity: sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==}-resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==}engines: {node: '>=18.12'}@@ -6116,31 +6043,6 @@ snapshots:package-manager-detector: 1.6.0tinyexec: 1.1.1- '@anthropic-ai/[email protected]([email protected])':- dependencies:- '@anthropic-ai/sdk': 0.81.0([email protected])- '@modelcontextprotocol/sdk': 1.29.0([email protected])- zod: 4.3.6- optionalDependencies:- '@img/sharp-darwin-arm64': 0.34.5- '@img/sharp-darwin-x64': 0.34.5- '@img/sharp-linux-arm': 0.34.5- '@img/sharp-linux-arm64': 0.34.5- '@img/sharp-linux-x64': 0.34.5- '@img/sharp-linuxmusl-arm64': 0.34.5- '@img/sharp-linuxmusl-x64': 0.34.5- '@img/sharp-win32-arm64': 0.34.5- '@img/sharp-win32-x64': 0.34.5- transitivePeerDependencies:- - '@cfworker/json-schema'- - supports-color-- '@anthropic-ai/[email protected]([email protected])':- dependencies:- json-schema-to-ts: 3.1.1- optionalDependencies:- zod: 4.3.6-'@ast-grep/[email protected]':optional: true@@ -7065,7 +6967,7 @@ snapshots:optionalDependencies:'@types/react': 19.2.14- '@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])':+ '@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])':dependencies:'@better-auth/utils': 0.4.0'@better-fetch/fetch': 1.1.21@@ -7080,38 +6982,38 @@ snapshots:optionalDependencies:'@cloudflare/workers-types': 4.20260414.1- '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]))':+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]))':dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/utils': 0.4.0optionalDependencies:drizzle-orm: 0.45.2(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected])- '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected])':+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected])':dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/utils': 0.4.0optionalDependencies:kysely: 0.28.15- '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/utils': 0.4.0- '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/utils': 0.4.0- '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])':dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/utils': 0.4.0- '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])':+ '@better-auth/[email protected](@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])':dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])'@better-auth/utils': 0.4.0'@better-fetch/fetch': 1.1.21@@ -7638,28 +7540,6 @@ snapshots:transitivePeerDependencies:- supports-color- '@modelcontextprotocol/[email protected]([email protected])':- dependencies:- '@hono/node-server': 1.19.13([email protected])- ajv: 8.18.0- ajv-formats: 3.0.1([email protected])- content-type: 1.0.5- cors: 2.8.6- cross-spawn: 7.0.6- eventsource: 3.0.7- eventsource-parser: 3.0.6- express: 5.2.1- express-rate-limit: 8.3.2([email protected])- hono: 4.12.12- jose: 6.2.2- json-schema-typed: 8.0.2- pkce-challenge: 5.0.1- raw-body: 3.0.2- zod: 4.3.6- zod-to-json-schema: 3.25.2([email protected])- transitivePeerDependencies:- - supports-color-'@mswjs/[email protected]':dependencies:'@open-draft/deferred-promise': 2.2.0@@ -7763,37 +7643,6 @@ snapshots:'@open-draft/[email protected]': {}- '@openai/[email protected]':- dependencies:- '@openai/codex': 0.120.0-- '@openai/[email protected]':- optionalDependencies:- '@openai/codex-darwin-arm64': '@openai/[email protected]'- '@openai/codex-darwin-x64': '@openai/[email protected]'- '@openai/codex-linux-arm64': '@openai/[email protected]'- '@openai/codex-linux-x64': '@openai/[email protected]'- '@openai/codex-win32-arm64': '@openai/[email protected]'- '@openai/codex-win32-x64': '@openai/[email protected]'-- '@openai/[email protected]':- optional: true-- '@openai/[email protected]':- optional: true-- '@openai/[email protected]':- optional: true-- '@openai/[email protected]':- optional: true-- '@openai/[email protected]':- optional: true-- '@openai/[email protected]':- optional: true-'@opennextjs/[email protected]([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))':dependencies:'@ast-grep/napi': 0.40.5@@ -9105,13 +8954,13 @@ snapshots:[email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]))([email protected](@babel/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected](@opentelemetry/[email protected])(@types/[email protected])([email protected](@types/[email protected])([email protected]))([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))):dependencies:- '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])- '@better-auth/drizzle-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]))- '@better-auth/kysely-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected])- '@better-auth/memory-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])- '@better-auth/mongo-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])- '@better-auth/prisma-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])- '@better-auth/telemetry': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])+ '@better-auth/core': 1.6.2(@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected])+ '@better-auth/drizzle-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected](@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected])([email protected]))+ '@better-auth/kysely-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])([email protected])+ '@better-auth/memory-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])+ '@better-auth/mongo-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])+ '@better-auth/prisma-adapter': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])+ '@better-auth/telemetry': 1.6.2(@better-auth/[email protected](@better-auth/[email protected])(@better-fetch/[email protected])(@cloudflare/[email protected])(@opentelemetry/[email protected])([email protected]([email protected]))([email protected])([email protected])([email protected]))(@better-auth/[email protected])(@better-fetch/[email protected])'@better-auth/utils': 0.4.0'@better-fetch/fetch': 1.1.21'@noble/ciphers': 2.1.1@@ -10773,11 +10622,6 @@ snapshots:- dependencies:- '@babel/runtime': 7.29.2- ts-algebra: 2.0.0-@@ -12444,8 +12288,6 @@ snapshots:- [email protected]: {}-dependencies:typescript: 6.0.2@@ -12909,10 +12751,6 @@ snapshots:dependencies:zod: 3.25.76- dependencies:- zod: 4.3.6-dependencies:zod: 4.3.6diff --git a/src/cli/daemon/client.test.ts b/src/cli/daemon/client.test.tsindex 3dafc6366..280958545 100644--- a/src/cli/daemon/client.test.ts+++ b/src/cli/daemon/client.test.ts@@ -181,7 +181,7 @@ describe("DaemonClient.register() with mocked fetch", () => {daemon_id: "d1",device_name: "mac",cli_version: "1.0",- runtimes: [{ name: "claude", type: "claude", version: "1.0", status: "online" }],+ runtimes: [{ name: "claude", type: "claude", version: "1.0" }],});expect(resp.runtimes[0].id).toBe("rt1");});@@ -199,7 +199,7 @@ describe("DaemonClient.register() with mocked fetch", () => {daemon_id: "d1",device_name: "mac",cli_version: "1.0",- runtimes: [{ name: "claude", type: "claude", version: "1.0", status: "online" }],+ runtimes: [{ name: "claude", type: "claude", version: "1.0" }],});expect(globalThis.fetch).toHaveBeenCalledWith(diff --git a/src/cli/daemon/client.ts b/src/cli/daemon/client.tsindex f837c598b..631bfe763 100644--- a/src/cli/daemon/client.ts+++ b/src/cli/daemon/client.ts@@ -40,7 +40,6 @@ export class DaemonClient {name: string;type: string;version: string;- status: string;}[];},): Promise<RegisterResponse> {diff --git a/src/cli/daemon/daemon.ts b/src/cli/daemon/daemon.tsindex 4ef8ed18a..5898a990a 100644--- a/src/cli/daemon/daemon.ts+++ b/src/cli/daemon/daemon.ts@@ -92,16 +92,21 @@ export async function startDaemon(name: config.runtimeName || `${p.type} (${config.deviceName})`,type: p.type,version: p.version,- status: "online",}));- const resp = await client.register(ws.token, {- workspace_id: ws.id,- daemon_id: config.daemonId,- device_name: config.deviceName,- cli_version: config.cliVersion,- runtimes,- });+ let resp;+ try {+ resp = await client.register(ws.token, {+ workspace_id: ws.id,+ daemon_id: config.daemonId,+ device_name: config.deviceName,+ cli_version: config.cliVersion,+ runtimes,+ });+ } catch (e) {+ log.error(`Failed to register workspace ${ws.id}, skipping`, e);+ continue;+ }const runtimeIds = resp.runtimes.map((r: { id: string }) => r.id);workspaceStates.push({ workspaceId: ws.id, token: ws.token, runtimeIds });@@ -115,6 +120,11 @@ export async function startDaemon(}}+ if (workspaceStates.length === 0) {+ log.error("No workspaces registered successfully.");+ process.exit(1);+ }+const allRuntimeIds = workspaceStates.flatMap((ws) => ws.runtimeIds);health.setRuntimeCount(allRuntimeIds.length);log.info(diff --git a/src/cli/package.json b/src/cli/package.jsonindex b46ea7864..b3666fcd3 100644--- a/src/cli/package.json+++ b/src/cli/package.json@@ -11,8 +11,6 @@},"dependencies": {"@alook/shared": "workspace:*",- "@anthropic-ai/claude-agent-sdk": "^0.2.105",- "@openai/codex-sdk": "^0.120.0","citty": "^0.2.2","commander": "^14.0.3"},diff --git a/src/shared/src/db/queries-index.ts b/src/shared/src/db/queries-index.tsindex cb299f770..c488b7d18 100644--- a/src/shared/src/db/queries-index.ts+++ b/src/shared/src/db/queries-index.ts@@ -7,6 +7,7 @@ export * as conversation from "./queries/conversation";export * as message from "./queries/message";export * as task from "./queries/task";export * as taskMessage from "./queries/task-message";+export * as machine from "./queries/machine";export * as machineToken from "./queries/machine-token";export * as whitelist from "./queries/whitelist";export * as email from "./queries/email";diff --git a/src/shared/src/db/queries/machine.ts b/src/shared/src/db/queries/machine.tsnew file mode 100644index 000000000..9286aaf8f--- /dev/null+++ b/src/shared/src/db/queries/machine.ts@@ -0,0 +1,100 @@+import { eq, and } from "drizzle-orm";+import { machine } from "../schema";+import type { Database } from "../index";++export async function upsertMachine(+ db: Database,+ data: {+ daemonId: string;+ workspaceId: string;+ deviceInfo: string;+ lastSeenAt?: string | null;+ }+) {+ const now = new Date().toISOString();+ const lastSeenAt = data.lastSeenAt === undefined ? now : data.lastSeenAt;+ const rows = await db+ .insert(machine)+ .values({+ daemonId: data.daemonId,+ workspaceId: data.workspaceId,+ deviceInfo: data.deviceInfo,+ lastSeenAt,+ createdAt: now,+ updatedAt: now,+ })+ .onConflictDoUpdate({+ target: [machine.workspaceId, machine.daemonId],+ set: {+ deviceInfo: data.deviceInfo,+ lastSeenAt,+ updatedAt: now,+ },+ })+ .returning();+ return rows[0]!;+}++export async function updateMachineLastSeen(+ db: Database,+ daemonId: string,+ workspaceId: string+) {+ const now = new Date().toISOString();+ await db+ .update(machine)+ .set({ lastSeenAt: now, updatedAt: now })+ .where(+ and(eq(machine.daemonId, daemonId), eq(machine.workspaceId, workspaceId))+ );+}++export async function setMachineLastSeenNull(+ db: Database,+ daemonId: string,+ workspaceId: string+) {+ const now = new Date().toISOString();+ await db+ .update(machine)+ .set({ lastSeenAt: null, updatedAt: now })+ .where(+ and(eq(machine.daemonId, daemonId), eq(machine.workspaceId, workspaceId))+ );+}++export async function getMachineByDaemon(+ db: Database,+ daemonId: string,+ workspaceId: string+) {+ const rows = await db+ .select()+ .from(machine)+ .where(+ and(eq(machine.daemonId, daemonId), eq(machine.workspaceId, workspaceId))+ );+ return rows[0] ?? null;+}++export async function listMachinesForWorkspace(+ db: Database,+ workspaceId: string+) {+ return db+ .select()+ .from(machine)+ .where(eq(machine.workspaceId, workspaceId));+}++export async function deleteMachine(+ db: Database,+ daemonId: string,+ workspaceId: string+) {+ await db+ .delete(machine)+ .where(+ and(eq(machine.daemonId, daemonId), eq(machine.workspaceId, workspaceId))+ );+}diff --git a/src/shared/src/db/queries/runtime.ts b/src/shared/src/db/queries/runtime.tsindex 5c154663b..673e6cc10 100644--- a/src/shared/src/db/queries/runtime.ts+++ b/src/shared/src/db/queries/runtime.ts@@ -1,5 +1,5 @@-import { eq, and, asc, or, lt, isNull, inArray } from "drizzle-orm";-import { agentRuntime, agent, agentTaskQueue } from "../schema";+import { eq, and, asc } from "drizzle-orm";+import { agentRuntime, agent, agentTaskQueue, machine } from "../schema";import type { Database } from "../index";export async function upsertAgentRuntime(@@ -10,7 +10,6 @@ export async function upsertAgentRuntime(name: string;runtimeMode: string;provider: string;- status: string;deviceInfo: string;metadata?: unknown;}@@ -24,10 +23,8 @@ export async function upsertAgentRuntime(name: data.name,runtimeMode: data.runtimeMode,provider: data.provider,- status: data.status,deviceInfo: data.deviceInfo,metadata: data.metadata ?? null,- lastSeenAt: now,}).onConflictDoUpdate({target: [@@ -38,10 +35,8 @@ export async function upsertAgentRuntime(set: {name: data.name,runtimeMode: data.runtimeMode,- status: data.status,deviceInfo: data.deviceInfo,metadata: data.metadata ?? null,- lastSeenAt: now,updatedAt: now,},})@@ -51,8 +46,27 @@ export async function upsertAgentRuntime(export async function listAgentRuntimes(db: Database, workspaceId: string) {return db- .select()+ .select({+ id: agentRuntime.id,+ workspaceId: agentRuntime.workspaceId,+ daemonId: agentRuntime.daemonId,+ name: agentRuntime.name,+ runtimeMode: agentRuntime.runtimeMode,+ provider: agentRuntime.provider,+ deviceInfo: agentRuntime.deviceInfo,+ metadata: agentRuntime.metadata,+ createdAt: agentRuntime.createdAt,+ updatedAt: agentRuntime.updatedAt,+ machineLastSeenAt: machine.lastSeenAt,+ }).from(agentRuntime)+ .leftJoin(+ machine,+ and(+ eq(machine.daemonId, agentRuntime.daemonId),+ eq(machine.workspaceId, agentRuntime.workspaceId)+ )+ ).where(eq(agentRuntime.workspaceId, workspaceId)).orderBy(asc(agentRuntime.createdAt));}@@ -71,21 +85,33 @@ export async function getAgentRuntimeForWorkspace(workspaceId: string) {const rows = await db- .select()+ .select({+ id: agentRuntime.id,+ workspaceId: agentRuntime.workspaceId,+ daemonId: agentRuntime.daemonId,+ name: agentRuntime.name,+ runtimeMode: agentRuntime.runtimeMode,+ provider: agentRuntime.provider,+ deviceInfo: agentRuntime.deviceInfo,+ metadata: agentRuntime.metadata,+ createdAt: agentRuntime.createdAt,+ updatedAt: agentRuntime.updatedAt,+ machineLastSeenAt: machine.lastSeenAt,+ }).from(agentRuntime)+ .leftJoin(+ machine,+ and(+ eq(machine.daemonId, agentRuntime.daemonId),+ eq(machine.workspaceId, agentRuntime.workspaceId)+ )+ ).where(and(eq(agentRuntime.id, id), eq(agentRuntime.workspaceId, workspaceId)));return rows[0] ?? null;}-export async function setAgentRuntimeOffline(db: Database, id: string) {- await db- .update(agentRuntime)- .set({ status: "offline", updatedAt: new Date().toISOString() })- .where(eq(agentRuntime.id, id));-}-export async function deleteRuntimesByDaemonId(db: Database,daemonId: string,@@ -145,40 +171,3 @@ export async function getRuntimeIdsByDaemon();return rows.map((r) => r.id);}--export async function updateRuntimesLastSeen(- db: Database,- ids: string[],- workspaceId: string-) {- if (ids.length === 0) return [];- const now = new Date().toISOString();- const result = await db- .update(agentRuntime)- .set({ lastSeenAt: now, status: "online", updatedAt: now })- .where(- and(inArray(agentRuntime.id, ids), eq(agentRuntime.workspaceId, workspaceId))- )- .returning({ id: agentRuntime.id });- return result.map(r => r.id);-}--export async function markStaleRuntimesOffline(- db: Database,- workspaceId: string-) {- const threshold = new Date(Date.now() - 45 * 1000).toISOString();- await db- .update(agentRuntime)- .set({ status: "offline", updatedAt: new Date().toISOString() })- .where(- and(- eq(agentRuntime.workspaceId, workspaceId),- eq(agentRuntime.status, "online"),- or(- lt(agentRuntime.lastSeenAt, threshold),- isNull(agentRuntime.lastSeenAt)- )- )- );-}diff --git a/src/shared/src/db/schema.ts b/src/shared/src/db/schema.tsindex f9c3cdc02..2ca8a5b13 100644--- a/src/shared/src/db/schema.ts+++ b/src/shared/src/db/schema.ts@@ -92,6 +92,21 @@ export const member = sqliteTable((t) => [unique("member_workspace_user").on(t.workspaceId, t.userId)]);+export const machine = sqliteTable(+ "machine",+ {+ daemonId: text("daemon_id").notNull(),+ workspaceId: text("workspace_id")+ .notNull()+ .references(() => workspace.id, { onDelete: "cascade" }),+ deviceInfo: text("device_info").notNull().default(""),+ lastSeenAt: text("last_seen_at"),+ createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString()),+ updatedAt: text("updated_at").notNull().$defaultFn(() => new Date().toISOString()),+ },+ (t) => [primaryKey({ columns: [t.workspaceId, t.daemonId] })]+);+export const agentRuntime = sqliteTable("agent_runtime",{@@ -103,10 +118,8 @@ export const agentRuntime = sqliteTable(name: text("name").notNull().default(""),runtimeMode: text("runtime_mode").notNull().default("local"),provider: text("provider").notNull(),- status: text("status").notNull().default("offline"),deviceInfo: text("device_info").notNull().default(""),metadata: text("metadata", { mode: "json" }),- lastSeenAt: text("last_seen_at"),createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString()),updatedAt: text("updated_at").notNull().$defaultFn(() => new Date().toISOString()),},diff --git a/src/shared/src/index.ts b/src/shared/src/index.tsindex 4f2b9a943..2f9bd2360 100644--- a/src/shared/src/index.ts+++ b/src/shared/src/index.ts@@ -4,6 +4,7 @@ export type {Workspace,Agent,AgentRuntime,+ Machine,Conversation,Message,AgentTask,diff --git a/src/shared/src/types.ts b/src/shared/src/types.tsindex 90d11cf11..a434b4ce8 100644--- a/src/shared/src/types.ts+++ b/src/shared/src/types.ts@@ -101,6 +101,15 @@ export interface TaskMessage {output: string;}+export interface Machine {+ daemon_id: string;+ workspace_id: string;+ device_info: string;+ last_seen_at: string | null;+ created_at: string;+ updated_at: string;+}+export interface MachineToken {id: string;name: string;diff --git a/src/web/migrations/0005_add_machine_table.sql b/src/web/migrations/0005_add_machine_table.sqlnew file mode 100644index 000000000..d753947e8--- /dev/null+++ b/src/web/migrations/0005_add_machine_table.sql@@ -0,0 +1,25 @@+-- Migration: add machine table for machine-level liveness tracking+-- agent_runtime loses status/last_seen_at conceptually (kept as dead columns in DB)++CREATE TABLE IF NOT EXISTS machine (+ daemon_id TEXT NOT NULL,+ workspace_id TEXT NOT NULL REFERENCES workspace(id) ON DELETE CASCADE,+ device_info TEXT NOT NULL DEFAULT '',+ last_seen_at TEXT,+ created_at TEXT NOT NULL,+ updated_at TEXT NOT NULL,+ PRIMARY KEY (workspace_id, daemon_id)+);++-- Backfill from agent_runtime: one machine row per (daemon_id, workspace_id)+INSERT OR IGNORE INTO machine (daemon_id, workspace_id, device_info, last_seen_at, created_at, updated_at)+SELECT+ daemon_id,+ workspace_id,+ COALESCE(MAX(device_info), ''),+ MAX(last_seen_at),+ MIN(created_at),+ MAX(updated_at)+FROM agent_runtime+WHERE daemon_id IS NOT NULL AND daemon_id != ''+GROUP BY daemon_id, workspace_id;diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page.tsxindex 86f05c1d3..304b73958 100644--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page.tsx@@ -240,32 +240,39 @@ export default function AgentChatDetailPage() {</p>)}- {messages.map((msg) => (- <React.Fragment key={msg.id}>- {/* Show trace before the assistant message it produced */}- {activeTask && msg.role === "assistant" && msg.task_id === activeTask.id && taskMessages.length > 0 && (- <TaskStream- task={activeTask}- messages={taskMessages}- connectionLost={connectionLost}- hideText- />- )}- <div- className={`flex ${msg.role === "user" ? "justify-end" : "justify-start"}`}- >+ {messages.map((msg) => {+ const hasTaskStream =+ activeTask &&+ msg.role === "assistant" &&+ msg.task_id === activeTask.id &&+ taskMessages.length > 0;++ return (+ <React.Fragment key={msg.id}>+ {/* Show full trace (including text) for completed tasks */}+ {hasTaskStream && (+ <TaskStream+ task={activeTask}+ messages={taskMessages}+ connectionLost={connectionLost}+ />+ )}{msg.role === "user" ? (- <div className="max-w-[80%] rounded-lg px-4 py-2 bg-primary text-primary-foreground whitespace-pre-wrap">- {msg.content}+ <div className="flex justify-end">+ <div className="max-w-[80%] rounded-lg px-4 py-2 bg-primary text-primary-foreground text-base whitespace-pre-wrap">+ {msg.content}+ </div></div>- ) : (- <div className="markdown max-w-full px-1 py-1 text-base text-foreground">- <Streamdown controls={{ code: { copy: true, download: false } }}>{msg.content}</Streamdown>+ ) : !hasTaskStream ? (+ <div className="flex justify-start">+ <div className="markdown max-w-full px-1 py-1 text-base text-foreground">+ <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }}>{msg.content}</Streamdown>+ </div></div>- )}- </div>- </React.Fragment>- ))}+ ) : null}+ </React.Fragment>+ );+ })}{/* Show trace while task is in progress (no assistant message yet) */}{activeTask && activeTask.status !== "completed" && activeTask.status !== "failed" && (diff --git a/src/web/src/app/(app)/w/[slug]/runtimes/page.tsx b/src/web/src/app/(app)/w/[slug]/runtimes/page.tsxindex 7b2df7fc7..298d72296 100644--- a/src/web/src/app/(app)/w/[slug]/runtimes/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/runtimes/page.tsx@@ -23,7 +23,7 @@ import {import { ConfirmDialog } from "@/components/ui/confirm-dialog";import { toast } from "sonner";import { Skeleton } from "@/components/ui/skeleton";-import { Loader2, Monitor, Plus } from "lucide-react";+import { Monitor, Plus } from "lucide-react";import type { Runtime } from "@/lib/api";import { CLI_CMD } from "@/lib/utils";@@ -193,7 +193,7 @@ export default function RuntimesPage() {// Group runtimes by machineconst machines = new Map<string,- { deviceInfo: string; name: string; runtimes: Runtime[] }+ { deviceInfo: string; name: string; status: string; lastSeenAt: string | null; runtimes: Runtime[] }>();for (const rt of runtimes) {const key = rt.daemon_id || rt.id;@@ -201,9 +201,12 @@ export default function RuntimesPage() {machines.set(key, {deviceInfo: typeof rt.device_info === "string" ? rt.device_info : "",name: rt.name || "",+ status: rt.status,+ lastSeenAt: rt.last_seen_at,runtimes: [],});}+ // Use first runtime's status (all share the same machine status)machines.get(key)!.runtimes.push(rt);}@@ -306,6 +309,16 @@ export default function RuntimesPage() {<CardTitle className="truncate">{displayName}</CardTitle>+ <Badge+ variant={+ machine.status === "online"+ ? "default"+ : "outline"+ }+ className="shrink-0"+ >+ {machine.status}+ </Badge></div><CardAction><Button@@ -328,10 +341,15 @@ export default function RuntimesPage() {</CardHeader><CardContent><div className="space-y-2">+ <p className="text-xs text-muted-foreground tabular-nums">+ {machine.lastSeenAt ? new Date(+ machine.lastSeenAt+ ).toLocaleString() : "Never seen"}+ </p>{machine.runtimes.map((runtime) => (<divkey={runtime.id}- className="flex items-center justify-between gap-2"+ className="flex items-center gap-2"><div className="min-w-0"><p className="text-xs font-medium truncate">@@ -342,22 +360,7 @@ export default function RuntimesPage() {</span>) : null}</p>- <p className="text-xs text-muted-foreground tabular-nums">- {runtime.last_seen_at ? new Date(- runtime.last_seen_at- ).toLocaleString() : "Never"}- </p></div>- <Badge- variant={- runtime.status === "online"- ? "default"- : "outline"- }- className="shrink-0"- >- {runtime.status}- </Badge></div>))}</div>diff --git a/src/web/src/app/api/agents/route.test.ts b/src/web/src/app/api/agents/route.test.tsindex 5c6dd3ce1..8c875df34 100644--- a/src/web/src/app/api/agents/route.test.ts+++ b/src/web/src/app/api/agents/route.test.ts@@ -11,6 +11,7 @@ const mockGetAgentRuntimeForWorkspace = vi.fn();vi.mock("@alook/shared", () => ({createDb: vi.fn(() => ({})),+ isOnline: vi.fn((t: string | null) => !!t && Date.now() - new Date(t).getTime() < 9000),queries: {agent: {listAgents: (...args: unknown[]) => mockListAgents(...args),@@ -77,7 +78,7 @@ describe("POST /api/agents", () => {const validBody = { name: "New Agent", runtime_id: "r1" };it("creates agent with valid input", async () => {- mockGetAgentRuntimeForWorkspace.mockResolvedValue({ status: "offline", runtimeMode: "local" });+ mockGetAgentRuntimeForWorkspace.mockResolvedValue({ machineLastSeenAt: null, runtimeMode: "local" });mockCreateAgent.mockResolvedValue({ id: "a1", name: "New Agent" });const req = new NextRequest("http://localhost/api/agents", {@@ -130,7 +131,7 @@ describe("POST /api/agents", () => {});it("creates agent with reconcile when runtime is online", async () => {- mockGetAgentRuntimeForWorkspace.mockResolvedValue({ status: "online", runtimeMode: "local" });+ mockGetAgentRuntimeForWorkspace.mockResolvedValue({ machineLastSeenAt: new Date().toISOString(), runtimeMode: "local" });mockCreateAgent.mockResolvedValue({ id: "a1", name: "New Agent" });mockGetAgent.mockResolvedValue({ id: "a1", name: "Reconciled Agent" });@@ -147,7 +148,7 @@ describe("POST /api/agents", () => {});it("creates agent without reconcile when runtime is offline", async () => {- mockGetAgentRuntimeForWorkspace.mockResolvedValue({ status: "offline", runtimeMode: "local" });+ mockGetAgentRuntimeForWorkspace.mockResolvedValue({ machineLastSeenAt: null, runtimeMode: "local" });mockCreateAgent.mockResolvedValue({ id: "a1", name: "New Agent" });const req = new NextRequest("http://localhost/api/agents", {diff --git a/src/web/src/app/api/agents/route.ts b/src/web/src/app/api/agents/route.tsindex 8eac493dc..cce9898b2 100644--- a/src/web/src/app/api/agents/route.ts+++ b/src/web/src/app/api/agents/route.ts@@ -1,6 +1,6 @@import { NextRequest } from "next/server";import { getCloudflareContext } from "@opennextjs/cloudflare"-import { createDb, queries, isValidHandle } from "@alook/shared"+import { createDb, queries, isValidHandle, isOnline } from "@alook/shared"import { withAuth } from "@/lib/middleware/auth";import { withWorkspaceMember } from "@/lib/middleware/workspace";import { writeJSON, writeError } from "@/lib/middleware/helpers";@@ -91,7 +91,7 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {emailHandle: emailHandle || null,});- if (runtime.status === "online") {+ if (isOnline(runtime.machineLastSeenAt)) {const taskService = new TaskService(db);await taskService.reconcileAgentStatus(newAgent.id, ws.workspaceId);const updated = await queries.agent.getAgent(diff --git a/src/web/src/app/api/daemon/deregister/route.test.ts b/src/web/src/app/api/daemon/deregister/route.test.tsindex b870c1f46..d51a825bf 100644--- a/src/web/src/app/api/daemon/deregister/route.test.ts+++ b/src/web/src/app/api/daemon/deregister/route.test.ts@@ -1,8 +1,7 @@import { describe, it, expect, vi, beforeEach } from "vitest";import { NextRequest } from "next/server";-const mockGetRuntimeIdsByDaemon = vi.fn();-const mockSetAgentRuntimeOffline = vi.fn();+const mockSetMachineLastSeenNull = vi.fn();const mockBroadcastToUser = vi.fn();function sharedMocks() {@@ -13,19 +12,14 @@ function sharedMocks() {"@alook/shared": async () => ({createDb: vi.fn(() => ({})),queries: {- runtime: {- getRuntimeIdsByDaemon: (...a: any[]) =>- mockGetRuntimeIdsByDaemon(...a),- setAgentRuntimeOffline: (...a: any[]) =>- mockSetAgentRuntimeOffline(...a),+ machine: {+ setMachineLastSeenNull: (...a: any[]) =>+ mockSetMachineLastSeenNull(...a),},},DeregisterRequestSchema: (await import("@alook/shared")).DeregisterRequestSchema,}),- "@/lib/logger": {- log: { warn: vi.fn(), info: vi.fn(), error: vi.fn(), debug: vi.fn() },- },"@/lib/broadcast": {broadcastToUser: (...a: any[]) => mockBroadcastToUser(...a),},@@ -50,7 +44,6 @@ describe("POST /api/daemon/deregister", () => {vi.doMock("@opennextjs/cloudflare", () => mocks["@opennextjs/cloudflare"]);vi.doMock("@alook/shared", mocks["@alook/shared"]);- vi.doMock("@/lib/logger", () => mocks["@/lib/logger"]);vi.doMock("@/lib/broadcast", () => mocks["@/lib/broadcast"]);vi.doMock("@/lib/middleware/auth", () => ({withAuth: vi.fn((handler: any) => async (req: any, ctx?: any) => {@@ -72,11 +65,10 @@ describe("POST /api/daemon/deregister", () => {const daemonAuth = { userId: "u1", email: "[email protected]", workspaceId: "w1" };const jwtAuth = { userId: "u1", email: "[email protected]" };- it("sets all runtimes for daemon offline", async () => {+ it("sets machine last_seen_at to null", async () => {const POST = await loadRoute(daemonAuth);- mockGetRuntimeIdsByDaemon.mockResolvedValue(["rt1", "rt2"]);- mockSetAgentRuntimeOffline.mockResolvedValue(undefined);+ mockSetMachineLastSeenNull.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);const res = await POST(makeReq({ daemon_id: "d1" }));@@ -84,17 +76,15 @@ describe("POST /api/daemon/deregister", () => {expect(res.status).toBe(200);expect(body).toEqual({ status: "ok" });- expect(mockGetRuntimeIdsByDaemon).toHaveBeenCalledWith({}, "d1", "w1");- expect(mockSetAgentRuntimeOffline).toHaveBeenCalledTimes(2);- expect(mockSetAgentRuntimeOffline).toHaveBeenCalledWith({}, "rt1");- expect(mockSetAgentRuntimeOffline).toHaveBeenCalledWith({}, "rt2");+ // Single machine write instead of N runtime writes+ expect(mockSetMachineLastSeenNull).toHaveBeenCalledTimes(1);+ expect(mockSetMachineLastSeenNull).toHaveBeenCalledWith({}, "d1", "w1");});it("sends single broadcast with daemonId and workspaceId", async () => {const POST = await loadRoute(daemonAuth);- mockGetRuntimeIdsByDaemon.mockResolvedValue(["rt1", "rt2"]);- mockSetAgentRuntimeOffline.mockResolvedValue(undefined);+ mockSetMachineLastSeenNull.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);await POST(makeReq({ daemon_id: "d1" }));@@ -108,20 +98,6 @@ describe("POST /api/daemon/deregister", () => {});});- it("returns 200 with no broadcast when daemon has no runtimes", async () => {- const POST = await loadRoute(daemonAuth);-- mockGetRuntimeIdsByDaemon.mockResolvedValue([]);-- const res = await POST(makeReq({ daemon_id: "d1" }));- const body = await res.json();-- expect(res.status).toBe(200);- expect(body).toEqual({ status: "ok" });- expect(mockSetAgentRuntimeOffline).not.toHaveBeenCalled();- expect(mockBroadcastToUser).not.toHaveBeenCalled();- });-it("returns 403 when called without workspaceId", async () => {const POST = await loadRoute(jwtAuth);@@ -131,21 +107,4 @@ describe("POST /api/daemon/deregister", () => {expect(res.status).toBe(403);expect(body.error).toContain("machine token required");});-- it("continues processing remaining runtimes after DB error on one", async () => {- const POST = await loadRoute(daemonAuth);-- mockGetRuntimeIdsByDaemon.mockResolvedValue(["rt1", "rt2"]);- mockSetAgentRuntimeOffline- .mockRejectedValueOnce(new Error("DB connection lost"))- .mockResolvedValueOnce(undefined);- mockBroadcastToUser.mockResolvedValue(undefined);-- const res = await POST(makeReq({ daemon_id: "d1" }));- const body = await res.json();-- expect(res.status).toBe(200);- expect(body).toEqual({ status: "ok" });- expect(mockSetAgentRuntimeOffline).toHaveBeenCalledTimes(2);- });});diff --git a/src/web/src/app/api/daemon/deregister/route.ts b/src/web/src/app/api/daemon/deregister/route.tsindex 79245b5a3..5aa8286f4 100644--- a/src/web/src/app/api/daemon/deregister/route.ts+++ b/src/web/src/app/api/daemon/deregister/route.ts@@ -4,7 +4,6 @@ import { createDb, queries } from "@alook/shared"import { withAuth } from "@/lib/middleware/auth";import { writeJSON, writeError, parseBody } from "@/lib/middleware/helpers";import { DeregisterRequestSchema } from "@alook/shared";-import { log } from "@/lib/logger";import { broadcastToUser } from "@/lib/broadcast";export const POST = withAuth(async (req: NextRequest, ctx) => {@@ -18,30 +17,20 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {return writeError("Forbidden: machine token required", 403);}- // Look up all runtimes by (daemonId, workspaceId)- const runtimeIds = await queries.runtime.getRuntimeIdsByDaemon(+ // Set machine last_seen_at to null (single write, isOnline() returns false immediately)+ await queries.machine.setMachineLastSeenNull(db,body.daemon_id,ctx.workspaceId,);- for (const id of runtimeIds) {- try {- await queries.runtime.setAgentRuntimeOffline(db, id);- } catch (e) {- log.warn("Failed to set runtime offline", { runtimeId: id, err: e });- }- }-// Single broadcast at daemon level- if (runtimeIds.length > 0) {- broadcastToUser(ctx.userId, {- type: "runtime.status",- daemonId: body.daemon_id,- workspaceId: ctx.workspaceId,- status: "offline",- }).catch(() => {});- }+ broadcastToUser(ctx.userId, {+ type: "runtime.status",+ daemonId: body.daemon_id,+ workspaceId: ctx.workspaceId,+ status: "offline",+ }).catch(() => {});return writeJSON({ status: "ok" });});diff --git a/src/web/src/app/api/daemon/register/route.ts b/src/web/src/app/api/daemon/register/route.tsindex 24f7cac7f..2f0bb4fd8 100644--- a/src/web/src/app/api/daemon/register/route.ts+++ b/src/web/src/app/api/daemon/register/route.ts@@ -24,6 +24,13 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {return writeJSON({ error: "workspace not found" }, 404);}+ // Upsert machine row (1 write for liveness)+ await queries.machine.upsertMachine(db, {+ daemonId,+ workspaceId,+ deviceInfo: deviceName.trim(),+ });+const results = [];for (const rt of runtimes) {const provider = (rt.type || rt.provider || "unknown").trim();@@ -33,7 +40,6 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {name = deviceName ? `${provider} (${deviceName})` : provider;}const deviceInfo = deviceName.trim();- const status = rt.status === "offline" ? "offline" : "online";const metadata: Record<string, unknown> = {version: rt.version || "",cli_version: cliVersion,@@ -45,11 +51,10 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {name,runtimeMode,provider,- status,deviceInfo,metadata,});- results.push(result);+ results.push({ ...result, machineLastSeenAt: new Date().toISOString() });}return writeJSON({ runtimes: results.map(runtimeToResponse) });diff --git a/src/web/src/app/api/daemon/routes.test.ts b/src/web/src/app/api/daemon/routes.test.tsindex 082d6d147..b7d639881 100644--- a/src/web/src/app/api/daemon/routes.test.ts+++ b/src/web/src/app/api/daemon/routes.test.ts@@ -78,6 +78,9 @@ describe("daemon route body validation", () => {member: {getMemberByUserAndWorkspace: vi.fn().mockResolvedValue({ id: "m1" }),},+ machine: {+ upsertMachine: vi.fn().mockResolvedValue({ daemonId: "d1", workspaceId: "w1" }),+ },runtime: {upsertAgentRuntime: vi.fn().mockResolvedValue({ id: "rt1", workspaceId: "w1" }),},@@ -148,6 +151,9 @@ describe("daemon route body validation", () => {member: {getMemberByUserAndWorkspace: vi.fn().mockResolvedValue({ id: "m1" }),},+ machine: {+ upsertMachine: vi.fn().mockResolvedValue({ daemonId: "d1", workspaceId: "w1" }),+ },runtime: {upsertAgentRuntime: upsertMock,},@@ -194,6 +200,9 @@ describe("daemon route body validation", () => {member: {getMemberByUserAndWorkspace: vi.fn().mockResolvedValue({ id: "m1" }),},+ machine: {+ upsertMachine: vi.fn().mockResolvedValue({ daemonId: "d1", workspaceId: "w1" }),+ },runtime: {upsertAgentRuntime: upsertMock,},@@ -242,7 +251,9 @@ describe("daemon route body validation", () => {queries: {runtime: {getRuntimeIdsByDaemon: vi.fn().mockResolvedValue(["r1"]),- updateRuntimesLastSeen: vi.fn().mockResolvedValue(["r1"]),+ },+ machine: {+ updateMachineLastSeen: vi.fn().mockResolvedValue(undefined),},agent: {getAgent: vi.fn().mockResolvedValue(null),@@ -326,9 +337,8 @@ describe("daemon route body validation", () => {...real,createDb: vi.fn(() => ({})),queries: {- runtime: {- getRuntimeIdsByDaemon: vi.fn().mockResolvedValue(["rt1"]),- setAgentRuntimeOffline: vi.fn(),+ machine: {+ setMachineLastSeenNull: vi.fn().mockResolvedValue(undefined),},},};diff --git a/src/web/src/app/api/daemon/tasks/poll/route.test.ts b/src/web/src/app/api/daemon/tasks/poll/route.test.tsindex e91753823..3d6406387 100644--- a/src/web/src/app/api/daemon/tasks/poll/route.test.ts+++ b/src/web/src/app/api/daemon/tasks/poll/route.test.ts@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";import { NextRequest } from "next/server";const mockGetRuntimeIdsByDaemon = vi.fn();-const mockUpdateRuntimesLastSeen = vi.fn();+const mockUpdateMachineLastSeen = vi.fn();const mockGetAgent = vi.fn();const mockClaimTasksForRuntimes = vi.fn();const mockSweepStaleState = vi.fn();@@ -20,7 +20,9 @@ vi.mock("@alook/shared", async () => {queries: {runtime: {getRuntimeIdsByDaemon: (...args: unknown[]) => mockGetRuntimeIdsByDaemon(...args),- updateRuntimesLastSeen: (...args: unknown[]) => mockUpdateRuntimesLastSeen(...args),+ },+ machine: {+ updateMachineLastSeen: (...args: unknown[]) => mockUpdateMachineLastSeen(...args),},agent: {getAgent: (...args: unknown[]) => mockGetAgent(...args),@@ -90,13 +92,13 @@ describe("POST /api/daemon/tasks/poll", () => {expect(res.status).toBe(200);expect(body.tasks).toEqual([]);- expect(mockUpdateRuntimesLastSeen).not.toHaveBeenCalled();+ expect(mockUpdateMachineLastSeen).not.toHaveBeenCalled();expect(mockBroadcastToUser).not.toHaveBeenCalled();});- it("resolves runtime IDs from daemon_id and updates last_seen_at", async () => {+ it("resolves runtime IDs from daemon_id and updates machine last_seen_at", async () => {mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1", "r2"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1", "r2"]);+ mockUpdateMachineLastSeen.mockResolvedValue(undefined);mockSweepStaleState.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);mockClaimTasksForRuntimes.mockResolvedValue([]);@@ -104,12 +106,14 @@ describe("POST /api/daemon/tasks/poll", () => {await POST(postReq({ daemon_id: "d1" }));expect(mockGetRuntimeIdsByDaemon).toHaveBeenCalledWith({}, "d1", "w1");- expect(mockUpdateRuntimesLastSeen).toHaveBeenCalledWith({}, ["r1", "r2"], "w1");+ // 1 machine write instead of N runtime writes+ expect(mockUpdateMachineLastSeen).toHaveBeenCalledTimes(1);+ expect(mockUpdateMachineLastSeen).toHaveBeenCalledWith({}, "d1", "w1");});it("returns tasks with agent data for claimed tasks", async () => {mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1", "r2"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1", "r2"]);+ mockUpdateMachineLastSeen.mockResolvedValue(undefined);mockSweepStaleState.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);mockClaimTasksForRuntimes.mockResolvedValue([@@ -136,7 +140,7 @@ describe("POST /api/daemon/tasks/poll", () => {it("broadcasts single runtime.status with daemonId and workspaceId", async () => {mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1", "r2", "r3"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1", "r2", "r3"]);+ mockUpdateMachineLastSeen.mockResolvedValue(undefined);mockSweepStaleState.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);mockClaimTasksForRuntimes.mockResolvedValue([]);@@ -155,7 +159,7 @@ describe("POST /api/daemon/tasks/poll", () => {it("calls sweepStaleState", async () => {mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1"]);+ mockUpdateMachineLastSeen.mockResolvedValue(undefined);mockSweepStaleState.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);mockClaimTasksForRuntimes.mockResolvedValue([]);@@ -167,7 +171,7 @@ describe("POST /api/daemon/tasks/poll", () => {it("respects max_tasks parameter", async () => {mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1"]);+ mockUpdateMachineLastSeen.mockResolvedValue(undefined);mockSweepStaleState.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);mockClaimTasksForRuntimes.mockResolvedValue([]);@@ -179,7 +183,7 @@ describe("POST /api/daemon/tasks/poll", () => {it("defaults max_tasks to 1", async () => {mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1"]);+ mockUpdateMachineLastSeen.mockResolvedValue(undefined);mockSweepStaleState.mockResolvedValue(undefined);mockBroadcastToUser.mockResolvedValue(undefined);mockClaimTasksForRuntimes.mockResolvedValue([]);@@ -188,20 +192,4 @@ describe("POST /api/daemon/tasks/poll", () => {expect(mockClaimTasksForRuntimes).toHaveBeenCalledWith(["r1"], 1, "w1");});-- it("logs warning when some runtimes not found", async () => {- mockGetRuntimeIdsByDaemon.mockResolvedValue(["r1", "r2"]);- mockUpdateRuntimesLastSeen.mockResolvedValue(["r1"]); // only 1 of 2 found- mockSweepStaleState.mockResolvedValue(undefined);- mockBroadcastToUser.mockResolvedValue(undefined);- mockClaimTasksForRuntimes.mockResolvedValue([]);-- await POST(postReq({ daemon_id: "d1" }));-- const { log } = await import("@/lib/logger");- expect(log.warn).toHaveBeenCalledWith("Some runtime IDs not found in workspace", {- expected: 2,- updated: 1,- });- });});diff --git a/src/web/src/app/api/daemon/tasks/poll/route.ts b/src/web/src/app/api/daemon/tasks/poll/route.tsindex 59a9c6add..11b4a3207 100644--- a/src/web/src/app/api/daemon/tasks/poll/route.ts+++ b/src/web/src/app/api/daemon/tasks/poll/route.ts@@ -7,7 +7,6 @@ import { taskToResponse } from "@/lib/api/responses";import { TaskService } from "@/lib/services/task";import { sweepStaleState } from "@/lib/services/sweep";import { broadcastToUser } from "@/lib/broadcast";-import { log } from "@/lib/logger";export const POST = withAuth(async (req: NextRequest, ctx) => {const { env } = getCloudflareContext();@@ -31,20 +30,13 @@ export const POST = withAuth(async (req: NextRequest, ctx) => {return writeJSON({ tasks: [] });}- // 2. Liveness: bulk-update last_seen_at for all runtime IDs- const updatedIds = await queries.runtime.updateRuntimesLastSeen(+ // 2. Liveness: update machine last_seen_at (1 row write instead of N)+ await queries.machine.updateMachineLastSeen(db,- runtimeIds,+ body.daemon_id,ctx.workspaceId,);- if (updatedIds.length < runtimeIds.length) {- log.warn("Some runtime IDs not found in workspace", {- expected: runtimeIds.length,- updated: updatedIds.length,- });- }-// Single broadcast at daemon levelbroadcastToUser(ctx.userId, {type: "runtime.status",diff --git a/src/web/src/app/api/machine-tokens/activate/route.ts b/src/web/src/app/api/machine-tokens/activate/route.tsindex 4079f3d5f..aa25bf9f1 100644--- a/src/web/src/app/api/machine-tokens/activate/route.ts+++ b/src/web/src/app/api/machine-tokens/activate/route.ts@@ -34,8 +34,16 @@ export async function POST(req: NextRequest) {// Use hostname as daemonId — must match what the daemon uses (os.hostname())// so that daemon start's upsert hits the same records instead of creating duplicatesconst daemonId = hostname;- const results = [];+ // Create machine row with last_seen_at = null (offline by default until daemon starts)+ await queries.machine.upsertMachine(db, {+ daemonId,+ workspaceId: mt.workspaceId,+ deviceInfo: hostname,+ lastSeenAt: null,+ });++ const results = [];for (const rt of runtimes) {const name = `${rt.type} (${hostname})`;const result = await queries.runtime.upsertAgentRuntime(db, {@@ -44,11 +52,10 @@ export async function POST(req: NextRequest) {name,runtimeMode: "local",provider: rt.type,- status: "offline",deviceInfo: hostname,metadata: { version: rt.version },});- results.push(result);+ results.push({ ...result, machineLastSeenAt: null });}await queries.machineToken.activateMachineToken(db, mt.id);diff --git a/src/web/src/app/api/runtimes/machine/route.test.ts b/src/web/src/app/api/runtimes/machine/route.test.tsindex d07adaca6..bd41cb750 100644--- a/src/web/src/app/api/runtimes/machine/route.test.ts+++ b/src/web/src/app/api/runtimes/machine/route.test.ts@@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach } from "vitest";import { NextRequest } from "next/server";const mockDeleteRuntimesByDaemonId = vi.fn();+const mockDeleteMachine = vi.fn();const mockGetMemberByUserAndWorkspace = vi.fn();vi.mock("@opennextjs/cloudflare", () => ({@@ -14,6 +15,10 @@ vi.mock("@alook/shared", () => ({deleteRuntimesByDaemonId: (...args: any[]) =>mockDeleteRuntimesByDaemonId(...args),},+ machine: {+ deleteMachine: (...args: any[]) =>+ mockDeleteMachine(...args),+ },member: {getMemberByUserAndWorkspace: (...args: any[]) =>mockGetMemberByUserAndWorkspace(...args),@@ -46,6 +51,9 @@ vi.mock("@/lib/middleware/workspace", () => ({vi.mock("@/lib/logger", () => ({log: { warn: vi.fn(), info: vi.fn(), error: vi.fn(), debug: vi.fn() },}));+vi.mock("@/lib/broadcast", () => ({+ broadcastToUser: vi.fn().mockResolvedValue(undefined),+}));import { DELETE } from "./route";@@ -91,6 +99,7 @@ describe("DELETE /api/runtimes/machine", () => {it("returns 204 on successful delete", async () => {mockGetMemberByUserAndWorkspace.mockResolvedValue({ id: "m1" });mockDeleteRuntimesByDaemonId.mockResolvedValue(undefined);+ mockDeleteMachine.mockResolvedValue(undefined);const res = await DELETE(makeReq({ daemon_id: "d1", workspace_id: "w1" })@@ -102,6 +111,7 @@ describe("DELETE /api/runtimes/machine", () => {it("passes correct daemon_id with dots and dashes", async () => {mockGetMemberByUserAndWorkspace.mockResolvedValue({ id: "m1" });mockDeleteRuntimesByDaemonId.mockResolvedValue(undefined);+ mockDeleteMachine.mockResolvedValue(undefined);const daemonId = "my-daemon.v2.host-01";await DELETE(makeReq({ daemon_id: daemonId, workspace_id: "w1" }));@@ -116,6 +126,7 @@ describe("DELETE /api/runtimes/machine", () => {it("calls deleteRuntimesByDaemonId exactly once", async () => {mockGetMemberByUserAndWorkspace.mockResolvedValue({ id: "m1" });mockDeleteRuntimesByDaemonId.mockResolvedValue(undefined);+ mockDeleteMachine.mockResolvedValue(undefined);await DELETE(makeReq({ daemon_id: "d1", workspace_id: "w1" }));diff --git a/src/web/src/app/api/runtimes/machine/route.ts b/src/web/src/app/api/runtimes/machine/route.tsindex 78d9607bb..3e851bfd2 100644--- a/src/web/src/app/api/runtimes/machine/route.ts+++ b/src/web/src/app/api/runtimes/machine/route.ts@@ -21,6 +21,7 @@ export const DELETE = withAuth(async (req: NextRequest, ctx) => {try {await queries.runtime.deleteRuntimesByDaemonId(db, daemonId, ws.workspaceId);+ await queries.machine.deleteMachine(db, daemonId, ws.workspaceId);} catch (e) {log.error("Failed to delete machine", { err: e });return writeJSON({ error: "Failed to remove machine" }, 500);diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.cssindex 133f01dcf..a15d17d37 100644--- a/src/web/src/app/globals.css+++ b/src/web/src/app/globals.css@@ -55,7 +55,7 @@}:root {- --background: oklch(0.94 0.02 250);+ --background: oklch(0.995 0.003 80);--foreground: oklch(0.18 0.01 60);--card: oklch(1 0.003 80);--card-foreground: oklch(0.18 0.01 60);@@ -308,14 +308,14 @@font-size: 16px;line-height: 1.6;}- .dark body {- line-height: 1.65;- }h1, h2, h3, h4, h5, h6 {@apply font-heading;- line-height: 1.15;letter-spacing: -0.015em;}+ h1 { line-height: 1.15; }+ h2 { line-height: 1.2; }+ h3 { line-height: 1.25; }+ h4, h5, h6 { line-height: 1.3; }p {line-height: 1.6;}@@ -337,13 +337,12 @@.markdown h4 {font-weight: 600;letter-spacing: -0.015em;- margin-top: 1.25em;margin-bottom: 0.5em;- line-height: 1.3;}-.markdown h1 { font-size: 1.25em; }-.markdown h2 { font-size: 1.125em; }-.markdown h3 { font-size: 1em; }+.markdown h1 { font-size: 1.25em; line-height: 1.2; margin-top: 1.5em; }+.markdown h2 { font-size: 1.125em; line-height: 1.25; margin-top: 1.35em; }+.markdown h3 { font-size: 1em; line-height: 1.3; margin-top: 1.25em; }+.markdown h4 { font-size: 1em; line-height: 1.3; margin-top: 1.15em; }.markdown p {margin-top: 0.5em;margin-bottom: 0.5em;@@ -378,7 +377,7 @@border-radius: 0.5em;overflow-x: auto;font-size: 0.85em;- line-height: 1.55;+ line-height: 1.6;width: 100%;}.markdown pre:not(:has(> code)) {@@ -418,6 +417,7 @@padding: 0.4em 0.75em;border: 1px solid var(--border);text-align: left;+ line-height: 1.5;}.markdown th {font-weight: 600;@@ -510,9 +510,18 @@}/* Code body: the only visible element, owns the rounded corners */+/* Force dark bg in both modes so code blocks always look the same */[data-streamdown="code-block-body"] {padding: 0.5rem 0.75rem !important;border-radius: 0.5rem !important;+ --sdm-bg: #24292e !important;+ --sdm-fg: #e1e4e8 !important;+ background-color: #24292e !important;+ color: #e1e4e8 !important;+}+[data-streamdown="code-block-body"] pre {+ background-color: #24292e !important;+ color: #e1e4e8 !important;}/* Actions wrapper: anchor inside top-right of code body */@@ -536,6 +545,10 @@transition: opacity 150ms ease;background: oklch(0.25 0.01 60) !important;border-color: oklch(1 0.005 80 / 12%) !important;+ color: #e1e4e8 !important;+}+[data-streamdown="code-block-actions"] button:hover {+ color: #ffffff !important;}.dark [data-streamdown="code-block-actions"] {background: oklch(0.22 0.008 60) !important;@@ -544,3 +557,105 @@opacity: 1;pointer-events: auto;}++/* ── Streamdown table: strip wrapper chrome, clean rows ── */++/* Outer wrapper: strip bg-sidebar, border, padding, gap, rounded */+[data-streamdown="table-wrapper"] {+ position: relative !important;+ padding: 0 !important;+ margin-top: 0.75em !important;+ margin-bottom: 0.75em !important;+ gap: 0 !important;+ border-width: 0 !important;+ border-radius: 0 !important;+ background-color: transparent !important;+}++/* Inner scroll container: strip border, rounded, bg-background */+[data-streamdown="table-wrapper"] > div:has([data-streamdown="table"]) {+ border-width: 0 !important;+ border-radius: 0 !important;+ padding: 0 !important;+ background-color: transparent !important;+ overflow-x: auto;+ scrollbar-width: thin;+ scrollbar-color: var(--border) transparent;+}++/* Table element */+[data-streamdown="table"] {+ width: 100% !important;+ border-collapse: collapse !important;+ border-width: 0 !important;+ font-size: 0.9em;+}++[data-streamdown="table-header"],+[data-streamdown="table-body"],+[data-streamdown="table-row"] {+ border-width: 0 !important;+ border-style: none !important;+}++[data-streamdown="table-header-cell"],+[data-streamdown="table-cell"] {+ padding: 0.4em 0.75em !important;+ text-align: left !important;+ white-space: nowrap;+ border-bottom: 1px solid var(--border) !important;+}++[data-streamdown="table-header-cell"] {+ font-weight: 600 !important;+ background: var(--muted) !important;+}++[data-streamdown="table-body"] [data-streamdown="table-row"]:last-child [data-streamdown="table-cell"] {+ border-bottom: 1px solid var(--border) !important;+}++/* Actions row: anchor top-right, show on hover (outside @layer so it always applies) */+[data-streamdown="table-wrapper"] > div:first-child:not(:has([data-streamdown="table"])) {+ position: absolute !important;+ top: 0.375rem;+ right: 0.375rem;+ z-index: 10;+ margin: 0 !important;+ opacity: 0;+ pointer-events: none;+ transition: opacity 150ms ease;+}+[data-streamdown="table-wrapper"]:hover > div:first-child:not(:has([data-streamdown="table"])) {+ opacity: 1;+ pointer-events: auto;+}++/* Thin scrollbar for table container */+[data-streamdown="table-wrapper"] > div:has([data-streamdown="table"])::-webkit-scrollbar {+ height: 4px;+}+[data-streamdown="table-wrapper"] > div:has([data-streamdown="table"])::-webkit-scrollbar-track {+ background: transparent;+}+[data-streamdown="table-wrapper"] > div:has([data-streamdown="table"])::-webkit-scrollbar-thumb {+ background: var(--border);+ border-radius: 2px;+}+[data-streamdown="table-wrapper"] > div:has([data-streamdown="table"])::-webkit-scrollbar-thumb:hover {+ background: var(--muted-foreground);+}++/* ── Streamdown table fullscreen: enable horizontal scroll for wide tables ── */+[data-streamdown="table-fullscreen"] {+ overflow: hidden;+}+[data-streamdown="table-fullscreen"] .flex-1.overflow-auto {+ overflow: auto !important;+ display: flex !important;+ align-items: center;+}+[data-streamdown="table-fullscreen"] [data-streamdown="table"] {+ width: max-content !important;+ min-width: 100%;+}diff --git a/src/web/src/components/gradient-background.tsx b/src/web/src/components/gradient-background.tsxindex d10f6e223..af5e43149 100644--- a/src/web/src/components/gradient-background.tsx+++ b/src/web/src/components/gradient-background.tsx@@ -8,7 +8,7 @@ export function GradientBackground() {return (<divaria-hidden- className="pointer-events-none fixed inset-0 -z-10 overflow-hidden"+ className="pointer-events-none fixed inset-0 -z-10 overflow-hidden bg-[oklch(0.94_0.02_250)] dark:bg-transparent">{/* Blob 1 — warm amber, top-left drift */}<div className="gradient-blob gradient-blob-1" />diff --git a/src/web/src/components/task-stream.tsx b/src/web/src/components/task-stream.tsxindex 9447fade6..052f64456 100644--- a/src/web/src/components/task-stream.tsx+++ b/src/web/src/components/task-stream.tsx@@ -1,43 +1,18 @@"use client";-import { useMemo } from "react";+import { useMemo, useRef, useEffect } from "react";import { Badge } from "@/components/ui/badge";import { cn } from "@/lib/utils";import type { TaskMessage } from "@alook/shared";import type { Task } from "@/lib/api";import {- Terminal,- FileText,- Search,- Pencil,- Play,ChevronRight,Brain,AlertCircle,} from "lucide-react";import { Streamdown } from "streamdown";-/* ── Tool icon mapping ── */--const TOOL_ICONS: Record<string, React.ElementType> = {- read_file: FileText,- write_file: Pencil,- edit_file: Pencil,- search: Search,- grep: Search,- find: Search,- bash: Terminal,- execute: Terminal,- run: Play,-};--function getToolIcon(tool: string): React.ElementType {- const lower = tool.toLowerCase();- for (const [key, icon] of Object.entries(TOOL_ICONS)) {- if (lower.includes(key)) return icon;- }- return Terminal;-}+/* ── Helpers ── */function formatToolName(tool: string): string {return tool@@ -104,7 +79,6 @@ function groupMessages(messages: TaskMessage[]): StreamItem[] {if (existing) {existing.output = msg.output || msg.content;} else {- // Standalone result — attach to most recent tool-call without outputconst lastTool = [...items].reverse().find((i): i is ToolCallGroup => i.kind === "tool-call" && !i.output);@@ -136,7 +110,6 @@ function groupMessages(messages: TaskMessage[]): StreamItem[] {});break;default:- // Unknown types (e.g. future agent lifecycle events) — skip silentlybreak;}}@@ -147,7 +120,6 @@ function groupMessages(messages: TaskMessage[]): StreamItem[] {/* ── ToolCallBlock ── */function ToolCallBlock({ item, isRunning }: { item: ToolCallGroup; isRunning: boolean }) {- const Icon = getToolIcon(item.tool);const hasDetails = item.input || item.output;const inputStr = useMemo(() => {@@ -160,10 +132,10 @@ function ToolCallBlock({ item, isRunning }: { item: ToolCallGroup; isRunning: bo}, [item.input]);return (- <details className="group/tool animate-[fade-up_200ms_ease-out_both]">+ <details className="group/tool"><summaryclassName={cn(- "flex items-center gap-2 py-1.5 px-2 -mx-2 rounded-md cursor-pointer select-none",+ "flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground transition-colors duration-150","hover:bg-muted/60 hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"@@ -172,7 +144,6 @@ function ToolCallBlock({ item, isRunning }: { item: ToolCallGroup; isRunning: bo{hasDetails && (<ChevronRight className="size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/tool:rotate-90" />)}- <Icon className="size-3.5 shrink-0" /><span className="font-medium text-foreground/80">{formatToolName(item.tool)}</span>@@ -182,7 +153,7 @@ function ToolCallBlock({ item, isRunning }: { item: ToolCallGroup; isRunning: bo</summary>{hasDetails && (- <div className="mt-1 mb-2 space-y-2">+ <div className="mt-1 mb-2 ml-5 space-y-2">{inputStr && (<pre className="task-stream-pre overflow-x-auto rounded-md bg-muted/40 p-2.5 font-mono text-xs leading-relaxed text-muted-foreground max-h-48 overflow-y-auto">{inputStr}@@ -199,27 +170,62 @@ function ToolCallBlock({ item, isRunning }: { item: ToolCallGroup; isRunning: bo);}+/* ── ThinkingBlock ── */++function ThinkingBlock({ item }: { item: ThinkingItem }) {+ return (+ <details className="group/think">+ <summary+ className={cn(+ "flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none",+ "text-sm text-muted-foreground/60 italic transition-colors duration-150",+ "hover:bg-muted/60 hover:text-muted-foreground",+ "[&::-webkit-details-marker]:hidden [&::marker]:hidden"+ )}+ >+ <ChevronRight className="size-3 shrink-0 text-muted-foreground/40 transition-transform duration-150 group-open/think:rotate-90" />+ <Brain className="size-3 shrink-0" />+ <span>Thinking...</span>+ </summary>+ <div className="mt-1 mb-2 ml-5">+ <p className="text-sm italic text-muted-foreground/60 whitespace-pre-wrap">+ {item.content}+ </p>+ </div>+ </details>+ );+}+/* ── TaskStream ── */export function TaskStream({task,messages,connectionLost,- hideText,}: {task: Task;messages: TaskMessage[];connectionLost?: boolean;- /** Hide text items (final answer is rendered separately as the assistant message). */- hideText?: boolean;}) {const allItems = useMemo(() => groupMessages(messages), [messages]);- const items = hideText ? allItems.filter((i) => i.kind !== "text") : allItems;const isRunning = task.status !== "completed" && task.status !== "failed";+ const toolItems = allItems.filter((i) => i.kind !== "text");+ const textItems = allItems.filter((i): i is TextItem => i.kind === "text");++ const toolScrollRef = useRef<HTMLDivElement>(null);++ // Auto-scroll tool area to bottom while running+ useEffect(() => {+ if (isRunning && toolScrollRef.current) {+ toolScrollRef.current.scrollTop = toolScrollRef.current.scrollHeight;+ }+ }, [toolItems.length, isRunning]);+return (- <div className="space-y-1">- <div className="flex items-center gap-2 mb-1">+ <div className="space-y-3">+ {/* Status badge */}+ <div className="flex items-center gap-2">{task.status === "running" ? (<Badge variant="secondary" className="gap-1.5"><span className="size-1.5 rounded-full bg-primary animate-pulse" />@@ -230,48 +236,65 @@ export function TaskStream({)}</div>- {items.length > 0 && (- <div className="space-y-0.5">- {items.map((item) => {- switch (item.kind) {- case "tool-call":- return <ToolCallBlock key={item.id} item={item} isRunning={isRunning} />;- case "text":- return (- <div- key={item.id}- className="markdown text-sm px-1 animate-[fade-up_200ms_ease-out_both]"- >- <Streamdown controls={{ code: { copy: true, download: false } }}>{item.content}</Streamdown>- </div>- );- case "thinking":- return (- <p- key={item.id}- className="text-sm italic text-muted-foreground/60 px-1 animate-[fade-up_200ms_ease-out_both]"- >- <Brain className="inline size-3 mr-1 -mt-0.5" />- {item.content}- </p>- );- case "status":- return (- <p- key={item.id}- className="text-xs text-muted-foreground px-1 animate-[fade-up_200ms_ease-out_both]"- >- {item.type === "error" && (- <AlertCircle className="inline size-3 mr-1 -mt-0.5 text-destructive" />- )}- {item.content}- </p>- );- }- })}+ {/* Tool stream zone — foldable, height-limited, scrollable */}+ {toolItems.length > 0 && (+ <details open={isRunning || undefined} className="group/stream">+ <summary+ className={cn(+ "flex items-center gap-2 py-1 cursor-pointer select-none",+ "text-xs text-muted-foreground transition-colors duration-150",+ "hover:text-foreground",+ "[&::-webkit-details-marker]:hidden [&::marker]:hidden"+ )}+ >+ <ChevronRight className="size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/stream:rotate-90" />+ <span>{toolItems.length} step{toolItems.length !== 1 ? "s" : ""}</span>+ </summary>+ <div+ ref={toolScrollRef}+ className="mt-1 max-h-80 overflow-y-auto overflow-x-hidden thin-scrollbar space-y-0.5 pl-1"+ >+ {toolItems.map((item) => {+ switch (item.kind) {+ case "tool-call":+ return <ToolCallBlock key={item.id} item={item} isRunning={isRunning} />;+ case "thinking":+ return <ThinkingBlock key={item.id} item={item as ThinkingItem} />;+ case "status":+ return (+ <p+ key={item.id}+ className="text-xs text-muted-foreground px-1"+ >+ {item.type === "error" && (+ <AlertCircle className="inline size-3 mr-1 -mt-0.5 text-destructive" />+ )}+ {(item as StatusItem).content}+ </p>+ );+ default:+ return null;+ }+ })}+ </div>+ </details>+ )}++ {/* Text output zone */}+ {textItems.length > 0 && (+ <div className="space-y-3">+ {textItems.map((item) => (+ <div+ key={item.id}+ className="markdown max-w-full px-1 py-1 text-base text-foreground"+ >+ <Streamdown controls={{ code: { copy: true, download: false }, table: { copy: true, download: false, fullscreen: true } }}>{item.content}</Streamdown>+ </div>+ ))}</div>)}+ {/* Error display */}{task.status === "failed" && task.error && (<p className="text-sm text-destructive flex items-center gap-1.5 mt-2"><AlertCircle className="size-3.5 shrink-0" />@@ -280,7 +303,7 @@ export function TaskStream({)}{connectionLost && (- <p className="text-xs text-muted-foreground animate-pulse mt-1">+ <p className="text-sm text-muted-foreground animate-pulse mt-1">Connection lost — retrying...</p>)}diff --git a/src/web/src/lib/api/responses.test.ts b/src/web/src/lib/api/responses.test.tsindex 986231a43..d7ea4514a 100644--- a/src/web/src/lib/api/responses.test.ts+++ b/src/web/src/lib/api/responses.test.ts@@ -97,10 +97,9 @@ describe("runtimeToResponse", () => {name: "Rt",runtimeMode: "docker",provider: "local",- status: "online",deviceInfo: "mac",metadata: null,- lastSeenAt: null,+ machineLastSeenAt: null,...baseFields(),});expect(res.metadata).toEqual({});@@ -114,10 +113,9 @@ describe("runtimeToResponse", () => {name: "Rt",runtimeMode: "docker",provider: "local",- status: "online",deviceInfo: "mac",metadata: {},- lastSeenAt: null,+ machineLastSeenAt: null,...baseFields(),});expect(res.daemon_id).toBeNull();@@ -130,14 +128,62 @@ describe("runtimeToResponse", () => {name: "Rt",runtimeMode: "docker",provider: "local",- status: "online",deviceInfo: "mac",metadata: {},- lastSeenAt: null,+ machineLastSeenAt: null,...baseFields(),});expect(res.daemon_id).toBeNull();});++ it("computes status online from recent machineLastSeenAt", () => {+ const res = runtimeToResponse({+ id: "rt1",+ workspaceId: "w1",+ daemonId: "d1",+ name: "Rt",+ runtimeMode: "docker",+ provider: "local",+ deviceInfo: "mac",+ metadata: {},+ machineLastSeenAt: new Date().toISOString(),+ ...baseFields(),+ });+ expect(res.status).toBe("online");+ });++ it("computes status offline from null machineLastSeenAt", () => {+ const res = runtimeToResponse({+ id: "rt1",+ workspaceId: "w1",+ daemonId: "d1",+ name: "Rt",+ runtimeMode: "docker",+ provider: "local",+ deviceInfo: "mac",+ metadata: {},+ machineLastSeenAt: null,+ ...baseFields(),+ });+ expect(res.status).toBe("offline");+ });++ it("computes status offline from old machineLastSeenAt", () => {+ const oldTime = new Date(Date.now() - 60_000).toISOString();+ const res = runtimeToResponse({+ id: "rt1",+ workspaceId: "w1",+ daemonId: "d1",+ name: "Rt",+ runtimeMode: "docker",+ provider: "local",+ deviceInfo: "mac",+ metadata: {},+ machineLastSeenAt: oldTime,+ ...baseFields(),+ });+ expect(res.status).toBe("offline");+ });});describe("taskToResponse", () => {@@ -317,8 +363,8 @@ describe("AgentRuntimeResponse shape", () => {it("has expected keys", () => {const res = runtimeToResponse({id: "rt1", workspaceId: "w1", daemonId: "d1", name: "Rt", runtimeMode: "docker",- provider: "local", status: "online", deviceInfo: "mac", metadata: { foo: 1 },- lastSeenAt: ts, ...baseFields(),+ provider: "local", deviceInfo: "mac", metadata: { foo: 1 },+ machineLastSeenAt: new Date().toISOString(), ...baseFields(),});expect(Object.keys(res).sort()).toEqual(["created_at", "daemon_id", "device_info", "id", "last_seen_at",@@ -359,8 +405,8 @@ describe("all response mappers strip milliseconds from timestamps", () => {it("runtimeToResponse strips milliseconds", () => {const res = runtimeToResponse({id: "rt1", workspaceId: "w1", daemonId: "d1", name: "Rt", runtimeMode: "docker",- provider: "local", status: "online", deviceInfo: "mac", metadata: {},- lastSeenAt: ts, ...baseFields(),+ provider: "local", deviceInfo: "mac", metadata: {},+ machineLastSeenAt: ts, ...baseFields(),});expect(res.created_at).toBe(tsFormatted);expect(res.updated_at).toBe(tsFormatted);diff --git a/src/web/src/lib/api/responses.ts b/src/web/src/lib/api/responses.tsindex e8664f2f1..5ec15349a 100644--- a/src/web/src/lib/api/responses.ts+++ b/src/web/src/lib/api/responses.ts@@ -2,7 +2,7 @@ import {formatTimestamp,formatTimestampNullable,} from "@/lib/middleware/helpers";-import { TaskApiBaseSchema } from "@alook/shared";+import { TaskApiBaseSchema, isOnline } from "@alook/shared";/* eslint-disable @typescript-eslint/no-explicit-any */@@ -141,6 +141,10 @@ export function taskMessageToResponse(m: any) {export function runtimeToResponse(rt: any) {let metadata = rt.metadata;if (!metadata) metadata = {};+ const machineLastSeenAt = rt.machineLastSeenAt ?? null;+ const lastSeenStr = machineLastSeenAt instanceof Date+ ? machineLastSeenAt.toISOString()+ : machineLastSeenAt;return {id: rt.id,workspace_id: rt.workspaceId,@@ -148,10 +152,10 @@ export function runtimeToResponse(rt: any) {name: rt.name,runtime_mode: rt.runtimeMode,provider: rt.provider,- status: rt.status,+ status: isOnline(lastSeenStr) ? "online" : "offline",device_info: rt.deviceInfo,metadata,- last_seen_at: formatTimestampNullable(rt.lastSeenAt),+ last_seen_at: formatTimestampNullable(machineLastSeenAt),created_at: formatTimestamp(rt.createdAt),updated_at: formatTimestamp(rt.updatedAt),};diff --git a/src/web/src/lib/services/sweep.test.ts b/src/web/src/lib/services/sweep.test.tsindex 05b8e22c9..67c081040 100644--- a/src/web/src/lib/services/sweep.test.ts+++ b/src/web/src/lib/services/sweep.test.ts@@ -1,15 +1,11 @@import { describe, it, expect, vi, beforeEach } from "vitest";-const mockMarkStaleRuntimesOffline = vi.fn();const mockFailStaleDispatchedTasks = vi.fn();const mockCountRunningTasks = vi.fn();const mockUpdateAgentStatus = vi.fn();vi.mock("@alook/shared", () => ({queries: {- runtime: {- markStaleRuntimesOffline: (...args: unknown[]) => mockMarkStaleRuntimesOffline(...args),- },task: {failStaleDispatchedTasks: (...args: unknown[]) => mockFailStaleDispatchedTasks(...args),countRunningTasks: (...args: unknown[]) => mockCountRunningTasks(...args),@@ -31,17 +27,7 @@ const db = {} as any;describe("sweepStaleState", () => {beforeEach(() => vi.clearAllMocks());- it("calls markStaleRuntimesOffline with workspace", async () => {- mockMarkStaleRuntimesOffline.mockResolvedValue(undefined);- mockFailStaleDispatchedTasks.mockResolvedValue([]);-- await sweepStaleState(db, "w1");-- expect(mockMarkStaleRuntimesOffline).toHaveBeenCalledWith(db, "w1");- });-it("calls failStaleDispatchedTasks with workspace", async () => {- mockMarkStaleRuntimesOffline.mockResolvedValue(undefined);mockFailStaleDispatchedTasks.mockResolvedValue([]);await sweepStaleState(db, "w1");@@ -50,7 +36,6 @@ describe("sweepStaleState", () => {});it("reconciles agent status for each affected agent", async () => {- mockMarkStaleRuntimesOffline.mockResolvedValue(undefined);mockFailStaleDispatchedTasks.mockResolvedValue([{ agentId: "a1", workspaceId: "w1" },{ agentId: "a2", workspaceId: "w1" },@@ -65,7 +50,6 @@ describe("sweepStaleState", () => {});it("deduplicates reconcile calls by agentId:workspaceId", async () => {- mockMarkStaleRuntimesOffline.mockResolvedValue(undefined);mockFailStaleDispatchedTasks.mockResolvedValue([{ agentId: "a1", workspaceId: "w1" },{ agentId: "a1", workspaceId: "w1" },@@ -81,7 +65,6 @@ describe("sweepStaleState", () => {});it("handles zero stale tasks gracefully", async () => {- mockMarkStaleRuntimesOffline.mockResolvedValue(undefined);mockFailStaleDispatchedTasks.mockResolvedValue([]);await sweepStaleState(db, "w1");diff --git a/src/web/src/lib/services/sweep.ts b/src/web/src/lib/services/sweep.tsindex e6a404610..655fed938 100644--- a/src/web/src/lib/services/sweep.ts+++ b/src/web/src/lib/services/sweep.ts@@ -7,13 +7,10 @@ import { TaskService } from "./task";* stale state is cleaned up just calls this one function.*/export async function sweepStaleState(db: Database, workspaceId: string) {- // 1. Mark runtimes offline if no liveness update in >45s- await queries.runtime.markStaleRuntimesOffline(db, workspaceId);-- // 2. Fail tasks stuck in "dispatched" for >20s (daemon crashed between claim and start)+ // 1. Fail tasks stuck in "dispatched" for >20s (daemon crashed between claim and start)const stale = await queries.task.failStaleDispatchedTasks(db, workspaceId);- // 3. Reconcile agent status for any agents affected by step 2+ // 2. Reconcile agent status for any agents affected by step 1if (stale.length > 0) {const taskService = new TaskService(db);const seen = new Set<string>();diff --git a/src/web/src/test/e2e/daemon-lifecycle.test.ts b/src/web/src/test/e2e/daemon-lifecycle.test.tsindex 02fc3bef0..d0e454825 100644--- a/src/web/src/test/e2e/daemon-lifecycle.test.ts+++ b/src/web/src/test/e2e/daemon-lifecycle.test.ts@@ -30,7 +30,6 @@ describe("daemon lifecycle", () => {runtime_mode: "local",name: "Claude E2E",version: "4.0",- status: "online",},],}),@@ -57,7 +56,6 @@ describe("daemon lifecycle", () => {runtime_mode: "local",name: "Claude E2E Updated",version: "4.1",- status: "online",},],}),@@ -78,9 +76,9 @@ describe("daemon lifecycle", () => {const data = await res.json() as { tasks: unknown[] }expect(data.tasks).toEqual([])- // Verify last_seen_at was set in DB+ // Verify machine last_seen_at was set in DBconst rows = sqlQuery<{ last_seen_at: string }>(- `SELECT last_seen_at FROM agent_runtime WHERE id = '${registeredRuntimeId}'`+ `SELECT last_seen_at FROM machine WHERE daemon_id = '${daemonId}' AND workspace_id = '${seed.workspaceId}'`)expect(rows[0]?.last_seen_at).toBeTruthy()})@@ -95,7 +93,7 @@ describe("daemon lifecycle", () => {expect(res.status).toBe(401)})- it("POST /api/daemon/deregister sets runtime offline", async () => {+ it("POST /api/daemon/deregister sets machine offline", async () => {const res = await tokenRequest("/api/daemon/deregister", seed.machineToken, {method: "POST",headers: { "Content-Type": "application/json" },@@ -103,17 +101,18 @@ describe("daemon lifecycle", () => {})expect(res.status).toBe(200)- // Verify status is offline- const rows = sqlQuery<{ status: string }>(- `SELECT status FROM agent_runtime WHERE id = '${registeredRuntimeId}'`+ // Verify machine last_seen_at is null (offline)+ const rows = sqlQuery<{ last_seen_at: string | null }>(+ `SELECT last_seen_at FROM machine WHERE daemon_id = '${daemonId}' AND workspace_id = '${seed.workspaceId}'`)- expect(rows[0]?.status).toBe("offline")+ expect(rows[0]?.last_seen_at).toBeNull()})- // Cleanup the registered runtime+ // Cleanup the registered runtime and machineafterAll(() => {try {sql(`DELETE FROM agent_runtime WHERE daemon_id = '${daemonId}'`)+ sql(`DELETE FROM machine WHERE daemon_id = '${daemonId}'`)} catch { /* ignore */ }})})diff --git a/src/web/src/test/helpers/seed.ts b/src/web/src/test/helpers/seed.tsindex 254e330b0..7eec08866 100644--- a/src/web/src/test/helpers/seed.ts+++ b/src/web/src/test/helpers/seed.ts@@ -37,6 +37,7 @@ export function seedTestData(): TestSeed {sql(`INSERT INTO "user" (id, name, email, emailVerified, createdAt, updatedAt) VALUES ('${userId}', 'Test User', '${userId}@test.local', 1, '${now}', '${now}')`)sql(`INSERT INTO workspace (id, name, slug, created_at, updated_at) VALUES ('${workspaceId}', 'Test Workspace', '${slug}', '${now}', '${now}')`)sql(`INSERT INTO member (id, workspace_id, user_id, role, created_at) VALUES ('${memberId}', '${workspaceId}', '${userId}', 'owner', '${now}')`)+ sql(`INSERT INTO machine (daemon_id, workspace_id, device_info, last_seen_at, created_at, updated_at) VALUES ('${daemonId}', '${workspaceId}', 'test-device', '${now}', '${now}', '${now}')`)sql(`INSERT INTO agent_runtime (id, workspace_id, daemon_id, name, runtime_mode, provider, status, device_info, created_at, updated_at) VALUES ('${runtimeId}', '${workspaceId}', '${daemonId}', 'Test Runtime', 'local', 'claude', 'online', 'test-device', '${now}', '${now}')`)sql(`INSERT INTO agent (id, workspace_id, name, runtime_id, created_at, updated_at) VALUES ('${agentId}', '${workspaceId}', 'Test Agent', '${runtimeId}', '${now}', '${now}')`)sql(`INSERT INTO machine_token (id, user_id, workspace_id, token, name, status, created_at) VALUES ('${machineTokenId}', '${userId}', '${workspaceId}', '${rawToken}', 'test-token', 'active', '${now}')`)@@ -58,6 +59,7 @@ export function cleanupTestData(seed: TestSeed) {sql(`DELETE FROM agent_whitelist WHERE agent_id IN (SELECT id FROM agent WHERE workspace_id = '${ws}')`)sql(`DELETE FROM agent WHERE workspace_id = '${ws}'`)sql(`DELETE FROM agent_runtime WHERE workspace_id = '${ws}'`)+ sql(`DELETE FROM machine WHERE workspace_id = '${ws}'`)sql(`DELETE FROM machine_token WHERE workspace_id = '${ws}'`)sql(`DELETE FROM member WHERE workspace_id = '${ws}'`)sql(`DELETE FROM workspace WHERE id = '${ws}'`)