Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

refactor: remove agent CLI commands, manage agents via web only

Gener534caf1475f0
diff --git a/src/cli/commands/agent.test.ts b/src/cli/commands/agent.test.ts
deleted file mode 100644
index a0e59fd62..000000000
--- a/src/cli/commands/agent.test.ts
+++ /dev/null
@@ -1,257 +0,0 @@
-import { describe, it, expect, vi, beforeEach } from "vitest";
-import type { WatchedWorkspace, ProfileConfig } from "../lib/config.js";
-
-// ── mocks ──────────────────────────────────────────────────────────
-let mockProfileConfig: ProfileConfig;
-
-vi.mock("../lib/config.js", () => ({
- loadCLIConfigForProfile: vi.fn(() => mockProfileConfig),
- saveCLIConfigForProfile: vi.fn(),
-}));
-
-// Stub the Commander parent chain so resolveClientOpts can read --profile/--server
-function fakeCommand(workspaceOpt?: string) {
- return {
- parent: { parent: { opts: () => ({}) } },
- opts: () => ({ workspace: workspaceOpt }),
- };
-}
-
-import { loadCLIConfigForProfile, saveCLIConfigForProfile } from "../lib/config.js";
-import { APIClient } from "../lib/client.js";
-
-// ── helpers ────────────────────────────────────────────────────────
-function makeWorkspace(overrides?: Partial<WatchedWorkspace>): WatchedWorkspace {
- return {
- id: "ws_1",
- name: "Test",
- token: "al_test",
- agent_ids: [],
- ...overrides,
- };
-}
-
-function mockFetchJSON(body: unknown, status = 200) {
- return vi.fn().mockResolvedValue({
- ok: status >= 200 && status < 300,
- status,
- json: async () => body,
- text: async () => JSON.stringify(body),
- });
-}
-
-// ── tests ──────────────────────────────────────────────────────────
-
-describe("agent list — config sync", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it("syncs agent_ids to local config after listing agents", async () => {
- const ws = makeWorkspace({ agent_ids: [] });
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [ws] };
-
- const agents = [
- { id: "ag_1", name: "Agent 1", runtime: "claude", status: "active", created_at: "2024-01-01" },
- { id: "ag_2", name: "Agent 2", runtime: "codex", status: "active", created_at: "2024-01-02" },
- ];
- globalThis.fetch = mockFetchJSON(agents);
-
- const client = new APIClient("http://localhost", "al_test", "ws_1");
- const result = await client.getJSON<typeof agents>("/api/agents?workspace_id=ws_1");
-
- // Simulate the sync logic from the list action
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_1");
- if (configWs) {
- configWs.agent_ids = result.map((a) => a.id);
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- expect(saveCLIConfigForProfile).toHaveBeenCalledOnce();
- const savedConfig = vi.mocked(saveCLIConfigForProfile).mock.calls[0][1] as ProfileConfig;
- expect(savedConfig.watched_workspaces![0].agent_ids).toEqual(["ag_1", "ag_2"]);
- });
-
- it("replaces stale agent_ids with current server state", async () => {
- const ws = makeWorkspace({ agent_ids: ["ag_old", "ag_deleted"] });
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [ws] };
-
- const agents = [
- { id: "ag_new", name: "New Agent", runtime: "claude", status: "active", created_at: "2024-01-01" },
- ];
- globalThis.fetch = mockFetchJSON(agents);
-
- const client = new APIClient("http://localhost", "al_test", "ws_1");
- const result = await client.getJSON<typeof agents>("/api/agents?workspace_id=ws_1");
-
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_1");
- if (configWs) {
- configWs.agent_ids = result.map((a) => a.id);
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- const savedConfig = vi.mocked(saveCLIConfigForProfile).mock.calls[0][1] as ProfileConfig;
- expect(savedConfig.watched_workspaces![0].agent_ids).toEqual(["ag_new"]);
- expect(savedConfig.watched_workspaces![0].agent_ids).not.toContain("ag_old");
- expect(savedConfig.watched_workspaces![0].agent_ids).not.toContain("ag_deleted");
- });
-
- it("handles empty agent list from server", async () => {
- const ws = makeWorkspace({ agent_ids: ["ag_stale"] });
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [ws] };
-
- globalThis.fetch = mockFetchJSON([]);
-
- const client = new APIClient("http://localhost", "al_test", "ws_1");
- const result = await client.getJSON<{ id: string }[]>("/api/agents?workspace_id=ws_1");
-
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_1");
- if (configWs) {
- configWs.agent_ids = result.map((a) => a.id);
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- const savedConfig = vi.mocked(saveCLIConfigForProfile).mock.calls[0][1] as ProfileConfig;
- expect(savedConfig.watched_workspaces![0].agent_ids).toEqual([]);
- });
-
- it("does not save if workspace is not found in config", async () => {
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [] };
-
- const agents = [{ id: "ag_1", name: "A", runtime: "claude", status: "active", created_at: "" }];
- globalThis.fetch = mockFetchJSON(agents);
-
- const client = new APIClient("http://localhost", "al_test", "ws_missing");
- const result = await client.getJSON<typeof agents>("/api/agents?workspace_id=ws_missing");
-
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_missing");
- if (configWs) {
- configWs.agent_ids = result.map((a) => a.id);
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- expect(saveCLIConfigForProfile).not.toHaveBeenCalled();
- });
-});
-
-describe("agent create — config sync", () => {
- beforeEach(() => {
- vi.clearAllMocks();
- });
-
- it("appends new agent ID to config after creation", async () => {
- const ws = makeWorkspace({ agent_ids: ["ag_existing"] });
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [ws] };
-
- const created = { id: "ag_new", name: "New", runtime: "claude", status: "active", created_at: "" };
- globalThis.fetch = mockFetchJSON(created);
-
- const client = new APIClient("http://localhost", "al_test", "ws_1");
- const agent = await client.postJSON<typeof created>("/api/agents", {
- name: "New",
- runtime: "claude",
- workspace_id: "ws_1",
- });
-
- // Simulate the create action's config sync logic
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_1");
- if (configWs) {
- if (!configWs.agent_ids) configWs.agent_ids = [];
- if (!configWs.agent_ids.includes(agent.id)) {
- configWs.agent_ids.push(agent.id);
- }
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- const savedConfig = vi.mocked(saveCLIConfigForProfile).mock.calls[0][1] as ProfileConfig;
- expect(savedConfig.watched_workspaces![0].agent_ids).toEqual(["ag_existing", "ag_new"]);
- });
-
- it("does not duplicate agent ID if already in config", async () => {
- const ws = makeWorkspace({ agent_ids: ["ag_1"] });
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [ws] };
-
- const created = { id: "ag_1", name: "Dup", runtime: "claude", status: "active", created_at: "" };
- globalThis.fetch = mockFetchJSON(created);
-
- const client = new APIClient("http://localhost", "al_test", "ws_1");
- const agent = await client.postJSON<typeof created>("/api/agents", {
- name: "Dup",
- runtime: "claude",
- workspace_id: "ws_1",
- });
-
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_1");
- if (configWs) {
- if (!configWs.agent_ids) configWs.agent_ids = [];
- if (!configWs.agent_ids.includes(agent.id)) {
- configWs.agent_ids.push(agent.id);
- }
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- const savedConfig = vi.mocked(saveCLIConfigForProfile).mock.calls[0][1] as ProfileConfig;
- expect(savedConfig.watched_workspaces![0].agent_ids).toEqual(["ag_1"]);
- });
-
- it("initializes agent_ids when undefined in config", async () => {
- const ws = makeWorkspace();
- delete (ws as any).agent_ids;
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [ws] };
-
- const created = { id: "ag_first", name: "First", runtime: "claude", status: "active", created_at: "" };
- globalThis.fetch = mockFetchJSON(created);
-
- const client = new APIClient("http://localhost", "al_test", "ws_1");
- const agent = await client.postJSON<typeof created>("/api/agents", {
- name: "First",
- runtime: "claude",
- workspace_id: "ws_1",
- });
-
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_1");
- if (configWs) {
- if (!configWs.agent_ids) configWs.agent_ids = [];
- if (!configWs.agent_ids.includes(agent.id)) {
- configWs.agent_ids.push(agent.id);
- }
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- const savedConfig = vi.mocked(saveCLIConfigForProfile).mock.calls[0][1] as ProfileConfig;
- expect(savedConfig.watched_workspaces![0].agent_ids).toEqual(["ag_first"]);
- });
-
- it("does not save if workspace is not found in config", async () => {
- mockProfileConfig = { server_url: "http://localhost", watched_workspaces: [] };
-
- const created = { id: "ag_1", name: "A", runtime: "claude", status: "active", created_at: "" };
- globalThis.fetch = mockFetchJSON(created);
-
- const client = new APIClient("http://localhost", "al_test", "ws_missing");
- const agent = await client.postJSON<typeof created>("/api/agents", {
- name: "A",
- runtime: "claude",
- workspace_id: "ws_missing",
- });
-
- const profileCfg = loadCLIConfigForProfile(undefined);
- const configWs = profileCfg.watched_workspaces?.find((w) => w.id === "ws_missing");
- if (configWs) {
- if (!configWs.agent_ids) configWs.agent_ids = [];
- if (!configWs.agent_ids.includes(agent.id)) {
- configWs.agent_ids.push(agent.id);
- }
- saveCLIConfigForProfile(undefined, profileCfg);
- }
-
- expect(saveCLIConfigForProfile).not.toHaveBeenCalled();
- });
-});
diff --git a/src/cli/commands/agent.ts b/src/cli/commands/agent.ts
deleted file mode 100644
index a2904488e..000000000
--- a/src/cli/commands/agent.ts
+++ /dev/null
@@ -1,134 +0,0 @@
-import { Command } from "commander";
-import { APIClient } from "../lib/client.js";
-import { loadCLIConfigForProfile, saveCLIConfigForProfile } from "../lib/config.js";
-import { printTable, printJSON } from "../lib/output.js";
-import { cmdPrefix } from "../lib/env.js";
-
-interface Agent {
- id: string;
- name: string;
- runtime: string;
- status: string;
- created_at: string;
-}
-
-function resolveClientOpts(command: Command, workspaceOpt?: string) {
- const parentOpts = command.parent?.parent?.opts() || {};
- const profile: string | undefined = parentOpts.profile;
- const cfg = loadCLIConfigForProfile(profile);
- const serverUrl = parentOpts.server || cfg.server_url;
-
- const ws = workspaceOpt
- ? cfg.watched_workspaces?.find((w) => w.id === workspaceOpt)
- : cfg.watched_workspaces?.[0];
- const token = ws?.token;
-
- if (!token) {
- console.error(
- `Error: not registered. Run '${cmdPrefix()} register --token <token>' first.`,
- );
- process.exit(1);
- }
-
- return { serverUrl, token, cfg, profile, workspaceId: ws?.id };
-}
-
-export function agentCommand(): Command {
- const cmd = new Command("agent").description("Manage agents");
-
- cmd
- .command("list")
- .description("List agents")
- .option("--workspace <id>", "Workspace ID")
- .option("--json", "Output as JSON")
- .action(async (opts, command) => {
- const { serverUrl, token, workspaceId, profile } = resolveClientOpts(command, opts.workspace);
- const client = new APIClient(serverUrl, token, workspaceId);
-
- try {
- const queryParam = workspaceId
- ? `?workspace_id=${workspaceId}`
- : "";
- const agents = await client.getJSON<Agent[]>(
- `/api/agents${queryParam}`,
- );
-
- // Sync agent_ids to local config
- const profileCfg = loadCLIConfigForProfile(profile);
- const ws = profileCfg.watched_workspaces?.find((w) => w.id === workspaceId);
- if (ws) {
- ws.agent_ids = agents.map((a) => a.id);
- saveCLIConfigForProfile(profile, profileCfg);
- }
-
- if (opts.json) {
- printJSON(agents);
- return;
- }
-
- if (!agents.length) {
- console.log("No agents found.");
- return;
- }
-
- printTable(
- ["ID", "Name", "Runtime", "Status"],
- agents.map((a) => [a.id, a.name, a.runtime, a.status]),
- );
- } catch (err) {
- console.error(
- `Error: ${err instanceof Error ? err.message : err}`,
- );
- process.exit(1);
- }
- });
-
- cmd
- .command("create")
- .description("Create a new agent")
- .requiredOption("--name <name>", "Agent name")
- .requiredOption("--runtime <runtime>", "Agent runtime")
- .option("--workspace <id>", "Workspace ID")
- .action(async (opts, command) => {
- const { serverUrl, token, workspaceId, profile } = resolveClientOpts(command, opts.workspace);
- const client = new APIClient(serverUrl, token, workspaceId);
-
- if (!opts.name) {
- console.error("Error: --name is required");
- process.exit(1);
- }
- if (!opts.runtime) {
- console.error("Error: --runtime is required");
- process.exit(1);
- }
-
- try {
- const agent = await client.postJSON<Agent>("/api/agents", {
- name: opts.name,
- runtime: opts.runtime,
- workspace_id: workspaceId,
- });
-
- // Update local config with new agent ID
- const profileCfg = loadCLIConfigForProfile(profile);
- const watched = profileCfg.watched_workspaces || [];
- const ws = watched.find((w) => w.id === workspaceId);
- if (ws) {
- if (!ws.agent_ids) ws.agent_ids = [];
- if (!ws.agent_ids.includes(agent.id)) {
- ws.agent_ids.push(agent.id);
- }
- saveCLIConfigForProfile(profile, profileCfg);
- }
-
- console.log(`Agent created: ${agent.name} (${agent.id})`);
- } catch (err) {
- console.error(
- `Error: ${err instanceof Error ? err.message : err}`,
- );
- process.exit(1);
- }
- });
-
- return cmd;
-}
diff --git a/src/cli/src/index.ts b/src/cli/src/index.ts
index dbd9873ee..e2c61b02a 100644
--- a/src/cli/src/index.ts
+++ b/src/cli/src/index.ts
@@ -2,7 +2,6 @@
import { Command } from "commander";
import { registerCommand } from "../commands/register.js";
import { statusCommand } from "../commands/status.js";
-import { agentCommand } from "../commands/agent.js";
import { daemonCommand } from "../commands/daemon.js";
import { configCommand } from "../commands/config.js";
import { emailCommand } from "../commands/email.js";
@@ -18,7 +17,6 @@ program
program.addCommand(registerCommand());
program.addCommand(statusCommand());
-program.addCommand(agentCommand());
program.addCommand(daemonCommand());
program.addCommand(emailCommand());
program.addCommand(configCommand());
diff --git a/src/web/src/components/home/feature-showcase.tsx b/src/web/src/components/home/feature-showcase.tsx
index 18e33c8f6..9d75952a1 100644
--- a/src/web/src/components/home/feature-showcase.tsx
+++ b/src/web/src/components/home/feature-showcase.tsx
@@ -36,10 +36,10 @@ const features: Feature[] = [
description:
"Every agent gets a real email address. Forward it a bug report. CC it on a thread. It reads, reasons, and replies — like a teammate.",
terminal: [
- "$ alook agent list",
- " NAME STATUS EMAIL",
- " jarvis online [email protected]",
- " Tasks completed: 312",
+ "$ alook email pull --agent_id jarvis",
+ " Downloaded 3 emails to /tmp/alook-emails/",
+ " From: [email protected] — Bug in checkout",
+ " From: [email protected] — Deploy review",
],
},
{
@@ -49,10 +49,10 @@ const features: Feature[] = [
description:
"Your machine. Your environment. The agent runs where your code lives — full context, no cloud sandbox, no latency.",
terminal: [
- "$ alook agent create \\",
- " --name jarvis --runtime claude",
- "✓ Agent created",
- "✓ Email: [email protected]",
+ "$ alook daemon start --foreground",
+ "✓ Detected providers: [email protected]",
+ "✓ Daemon started — 1 runtime(s)",
+ "✓ Polling for tasks...",
],
},
{