Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
feat(web): Bots under Chat in the sidebar; Deliverables tab shows the folder, opens it, marks finals
Salman Qureshi6f1c75b0c54c
diff --git a/src/bots/open-folder.ts b/src/bots/open-folder.tsnew file mode 100644index 00000000..d62e4e65--- /dev/null+++ b/src/bots/open-folder.ts@@ -0,0 +1,23 @@+import { execFile } from 'node:child_process';+import { homedir } from 'node:os';++/** Open a folder in the OS file manager (Finder / Explorer / xdg-open). Resolves false when that is not possible (headless, Termux). */+export async function openFolder(dir: string): Promise<boolean> {+ const cmd = process.platform === 'darwin' ? ['open', [dir]]+ : process.platform === 'win32' ? ['explorer', [dir]]+ : ['xdg-open', [dir]];+ return new Promise((resolve) => {+ try {+ const child = execFile(cmd[0] as string, cmd[1] as string[], { timeout: 5000 }, (err) => resolve(!err));+ child.on('error', () => resolve(false));+ } catch {+ resolve(false);+ }+ });+}++/** ~/Documents/… instead of /Users/x/Documents/… — what a person expects to read. */+export function tildify(p: string): string {+ const home = homedir();+ return p.startsWith(home) ? '~' + p.slice(home.length) : p;+}diff --git a/src/core/commands/bots-command.ts b/src/core/commands/bots-command.tsindex a556e1a9..c1f12e7f 100644--- a/src/core/commands/bots-command.ts+++ b/src/core/commands/bots-command.ts@@ -13,6 +13,7 @@ import { refinePersona } from '../../bots/persona-template.js';import { PERMISSION_TIERS, tierPermissionsFile, isPermissionTier, type PermissionTier } from '../../bots/permission-tiers.js';import { buildBotBundle, writeBundle, readBundle, importBotBundle } from '../../bots/bundle.js';import { applyBotFieldPatch } from '../../bots/edit.js';+import { openFolder, tildify } from '../../bots/open-folder.js';export async function handleBotsCommand(agent: Agent, trimmed: string, msg: ChannelMessage, channel: any): Promise<void> {const bm = agent.botManager;@@ -883,23 +884,5 @@ async function sendBotsHelp(channel: Pick<Channel, 'send'>, channelId: string):}/** ~ for the home dir — paths shown to people, not to tools. */-function tildify(p: string): string {- const home = homedir();- return p.startsWith(home) ? '~' + p.slice(home.length) : p;-}/** Open a folder in the platform file manager; false when there is none (headless/SSH). */-async function openFolder(dir: string): Promise<boolean> {- const { execFile } = await import('node:child_process');- const cmd = process.platform === 'darwin' ? ['open', [dir]]- : process.platform === 'win32' ? ['explorer', [dir]]- : ['xdg-open', [dir]];- return new Promise((resolve) => {- try {- const child = execFile(cmd[0] as string, cmd[1] as string[], { timeout: 5000 }, (err) => resolve(!err));- child.on('error', () => resolve(false));- } catch {- resolve(false);- }- });-}diff --git a/src/web/api/bots.test.ts b/src/web/api/bots.test.tsindex 6520e6a4..5cea5660 100644--- a/src/web/api/bots.test.ts+++ b/src/web/api/bots.test.ts@@ -196,3 +196,13 @@ describe('web bots API — operations (ADR-022)', () => {expect(started.started).toBe(1);});});++describe('web bots API — deliverables folder (where results land)', () => {+ it('reports the fleet root and a bot folder with a readable path', async () => {+ const root = await jreq(await app.request('/api/bots/folder'));+ expect(typeof root.path).toBe('string');+ expect(typeof root.display).toBe('string');+ expect(typeof root.exists).toBe('boolean');+ expect((await app.request('/api/bots/ghost/folder')).status).toBe(404);+ });+});diff --git a/src/web/api/bots.ts b/src/web/api/bots.tsindex 0f771199..a368a4ba 100644--- a/src/web/api/bots.ts+++ b/src/web/api/bots.ts@@ -1,6 +1,7 @@import { Hono } from 'hono';+import { openFolder, tildify } from '../../bots/open-folder.js';import type { Context } from 'hono';-import { readFileSync } from 'node:fs';+import { readFileSync, existsSync, mkdirSync } from 'node:fs';import type { BotManager } from '../../bots/bot-manager.js';import type { BotManifest } from '../../bots/types.js';import { PERMISSION_TIERS, tierPermissionsFile, isPermissionTier, type PermissionTier } from '../../bots/permission-tiers.js';@@ -117,6 +118,39 @@ app.get('/api/bots/events', (c: any) => {});// ── Deliverables (owner-curated outputs zone — bot_deliver) ────────────────+// Where results land — the fleet root and one bot's folder (ADR-020). The+// dashboard shows the path and, since it runs on the owner's machine, can+// open the folder in the file manager.+app.get('/api/bots/folder', (c: Context) => {+ if (!botManager) return c.json({ error: 'Bots not available' }, 400);+ const dir = botManager.store.deliverablesRoot();+ return c.json({ path: dir, display: tildify(dir), exists: existsSync(dir) });+});++app.get('/api/bots/:id/folder', (c: Context) => {+ if (!botManager) return c.json({ error: 'Bots not available' }, 400);+ const id = String(c.req.param('id') ?? '');+ if (!botManager.store.exists(id)) return c.json({ error: 'Bot not found' }, 404);+ const dir = botManager.store.deliverablesDir(id);+ return c.json({ path: dir, display: tildify(dir), exists: existsSync(dir) });+});++app.post('/api/bots/folder/open', async (c: Context) => {+ if (!botManager) return c.json({ error: 'Bots not available' }, 400);+ const dir = botManager.store.deliverablesRoot();+ mkdirSync(dir, { recursive: true });+ return c.json({ ok: await openFolder(dir), path: dir });+});++app.post('/api/bots/:id/folder/open', async (c: Context) => {+ if (!botManager) return c.json({ error: 'Bots not available' }, 400);+ const id = String(c.req.param('id') ?? '');+ if (!botManager.store.exists(id)) return c.json({ error: 'Bot not found' }, 404);+ const dir = botManager.store.deliverablesDir(id);+ mkdirSync(dir, { recursive: true });+ return c.json({ ok: await openFolder(dir), path: dir });+});+// Fleet-wide inbox, newest first.app.get('/api/bots/outputs', (c: any) => {if (!botManager) return c.json({ error: 'Bots not available' }, 400);diff --git a/ui/src/components/bots/DeliverablesList.tsx b/ui/src/components/bots/DeliverablesList.tsxindex 75df374b..4a29ac92 100644--- a/ui/src/components/bots/DeliverablesList.tsx+++ b/ui/src/components/bots/DeliverablesList.tsx@@ -1,12 +1,12 @@import { useCallback, useEffect, useState } from "react";-import { Package, Download, Trash2, Eye } from "lucide-react";+import { Package, Download, Trash2, Eye, FolderOpen, FileCheck2, FileClock } from "lucide-react";import { Card, CardContent } from "@/components/ui/card";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import {Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription,} from "@/components/ui/dialog";-import api, { type DeliverableInfo } from "@/lib/api";+import api, { type DeliverableInfo, type DeliverablesFolder } from "@/lib/api";import { cn, formatDate } from "@/lib/utils";/**@@ -30,11 +30,17 @@ export function DeliverablesList({const [loading, setLoading] = useState(true);const [preview, setPreview] = useState<{ d: DeliverableInfo; content: string; truncated: boolean } | null>(null);const [error, setError] = useState<string | null>(null);+ const [folder, setFolder] = useState<DeliverablesFolder | null>(null);+ const [openState, setOpenState] = useState<"idle" | "opened" | "failed">("idle");const refresh = useCallback(async () => {try {- const data = botId ? await api.bots.botOutputs(botId) : await api.bots.outputs();+ const [data, dir] = await Promise.all([+ botId ? api.bots.botOutputs(botId) : api.bots.outputs(),+ api.bots.folder(botId),+ ]);setOutputs(data.outputs);+ setFolder(dir);setError(null);} catch (e) {setError((e as Error).message);@@ -56,6 +62,16 @@ export function DeliverablesList({}};+ const openInFinder = async () => {+ try {+ const r = await api.bots.openFolder(botId);+ setOpenState(r.ok ? "opened" : "failed");+ } catch {+ setOpenState("failed");+ }+ setTimeout(() => setOpenState("idle"), 2500);+ };+const remove = async (d: DeliverableInfo) => {try {await api.bots.deleteOutput(d.botId, d.name);@@ -76,13 +92,24 @@ export function DeliverablesList({{error && <Badge variant="destructive" className="text-xs">{error}</Badge>}</div>+ {folder && (+ <div className="flex items-center gap-2 text-xs rounded-md border border-border/60 bg-muted/30 px-3 py-2">+ <FolderOpen className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />+ <code className="truncate flex-1" title={folder.path}>{folder.display}</code>+ <Button size="sm" variant="outline" className="h-7 text-xs" onClick={() => void openInFinder()}>+ {openState === "opened" ? "Opened" : openState === "failed" ? "Couldn't open — copy the path" : "Open folder"}+ </Button>+ </div>+ )}+{loading ? (<p className="text-sm text-muted-foreground">Loading…</p>) : outputs.length === 0 ? (<Card><CardContent className={cn("py-6 text-center text-sm text-muted-foreground")}>- No deliverables yet. Bots deliver finished artifacts with their <code>bot_deliver</code> tool- (a report, export, dataset — anything final). They appear here the moment they land.+ Nothing delivered yet. When a bot finishes real work it files the result with <code>bot_deliver</code>+ into {folder ? <code>{folder.display}</code> : "its deliverables folder"} — finals on top, stage work under <code>work/</code> —+ and it appears here the moment it lands. A routine that only writes notes never shows up here; <code>/bots cost</code> and the journal tell you why.</CardContent></Card>) : (@@ -95,7 +122,11 @@ export function DeliverablesList({{botNames?.[d.botId] ?? d.botId}</Badge>)}- <span className="truncate flex-1" title={d.name}>{d.name}</span>+ {d.final+ ? <FileCheck2 className="h-3.5 w-3.5 shrink-0 text-emerald-500" aria-label="Final" />+ : <FileClock className="h-3.5 w-3.5 shrink-0 text-muted-foreground" aria-label="Stage work" />}+ <span className="truncate flex-1" title={d.path}>{d.final ? d.name : d.name.replace(/^work\//, "")}</span>+ {!d.final && <Badge variant="outline" className="text-[10px] shrink-0">work</Badge>}<span className="text-muted-foreground text-xs shrink-0">{formatBytes(d.bytes)} · {formatDate(d.mtimeMs)}</span>diff --git a/ui/src/components/bots/OnboardWizard.tsx b/ui/src/components/bots/OnboardWizard.tsxindex 3ad6d41a..047da4f2 100644--- a/ui/src/components/bots/OnboardWizard.tsx+++ b/ui/src/components/bots/OnboardWizard.tsx@@ -162,7 +162,7 @@ export function OnboardWizard({<Input placeholder="Provider (e.g. deepseek; empty = inherit)" value={provider === "inherit" ? "" : provider} onChange={(e) => { setProvider(e.target.value || "inherit"); }} /><Input placeholder="Model (e.g. deepseek-chat)" value={model} onChange={(e) => setModel(e.target.value)} /></div>- <Input placeholder="Daily token budget (optional, e.g. 500000)" value={budget} onChange={(e) => setBudget(e.target.value.replace(/[^0-9]/g, ""))} />+ <Input placeholder="Daily token budget (default 5,000,000 · light 1,000,000 · heavy 20,000,000 · 0 = unlimited)" value={budget} onChange={(e) => setBudget(e.target.value.replace(/[^0-9]/g, ""))} /></div>)}diff --git a/ui/src/components/layout/Sidebar.tsx b/ui/src/components/layout/Sidebar.tsxindex a072e146..38d32c83 100644--- a/ui/src/components/layout/Sidebar.tsx+++ b/ui/src/components/layout/Sidebar.tsx@@ -43,6 +43,7 @@ const NAV_SECTIONS = [items: [{ to: "/", icon: LayoutDashboard, label: "Status" },{ to: "/chat", icon: MessageSquare, label: "Chat" },+ { to: "/bots", icon: Bot, label: "Bots" },{ to: "/tasks", icon: ListTodo, label: "Tasks" },{ to: "/board", icon: Kanban, label: "Board" },{ to: "/workspace", icon: Code2, label: "Workspace" },@@ -64,7 +65,6 @@ const NAV_SECTIONS = [{ to: "/skills", icon: Puzzle, label: "Skills" },{ to: "/permissions", icon: Shield, label: "Permissions" },{ to: "/schedules", icon: Clock, label: "Schedules" },- { to: "/bots", icon: Bot, label: "Bots" },{ to: "/usage", icon: BarChart3, label: "Usage" },],},diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.tsindex b1ad77bc..6aac1898 100644--- a/ui/src/lib/api.ts+++ b/ui/src/lib/api.ts@@ -707,9 +707,20 @@ export interface BotActivityEvent {export interface DeliverableInfo {botId: string;+ /** File name; stage work carries a `work/` prefix. */name: string;bytes: number;mtimeMs: number;+ /** Absolute path on the owner's machine. */+ path: string;+ /** A finished result at the top of the folder (vs. a stage under work/). */+ final: boolean;+}++export interface DeliverablesFolder {+ path: string;+ display: string;+ exists: boolean;}export interface BotTierInfo {@@ -913,6 +924,8 @@ const api = {put<{ permissions: BotPermissionsFile }>(`/api/bots/${id}/permissions`, body),start: (id: string) => post<{ ok: boolean; resumed: number; message: string }>(`/api/bots/${id}/start`),run: (id: string, routine?: string) => post<{ accepted: boolean; jobId?: string; reasonCode?: string }>(`/api/bots/${id}/run`, { routine }),+ folder: (id?: string) => get<DeliverablesFolder>(id ? `/api/bots/${id}/folder` : "/api/bots/folder"),+ openFolder: (id?: string) => post<{ ok: boolean; path: string }>(id ? `/api/bots/${id}/folder/open` : "/api/bots/folder/open"),outputs: () => get<{ outputs: DeliverableInfo[] }>("/api/bots/outputs"),botOutputs: (id: string) => get<{ outputs: DeliverableInfo[] }>(`/api/bots/${id}/outputs`),outputPreview: (id: string, name: string) =>