Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(harness): Tasks/Watches/Runs read-only page + REST endpoints

cyha656117b40f9
diff --git a/ui/src/components/workbench/HarnessPage.tsx b/ui/src/components/workbench/HarnessPage.tsx
index b2f1990c3..8520540ac 100644
--- a/ui/src/components/workbench/HarnessPage.tsx
+++ b/ui/src/components/workbench/HarnessPage.tsx
@@ -1,6 +1,718 @@
-import { Activity } from 'lucide-react';
-import { WorkbenchModulePlaceholder } from './WorkbenchModulePlaceholder';
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import {
+ Activity,
+ Calendar,
+ Eye,
+ Webhook,
+ History,
+ RefreshCw,
+ AlertTriangle,
+ CheckCircle2,
+ XCircle,
+ Loader2,
+ Clock,
+ PauseCircle,
+} from 'lucide-react';
+import clsx from 'clsx';
-export const HarnessPage: React.FC = () => (
- <WorkbenchModulePlaceholder icon={<Activity className="size-6" />} i18nPrefix="workbench.modules.harness" />
+import { useApi } from '../../context/ApiContext';
+import type {
+ HarnessRun,
+ HarnessRunStatus,
+ HarnessTask,
+ HarnessWatch,
+} from '../../context/ApiContext';
+
+type TabKey = 'tasks' | 'watches' | 'webhooks' | 'runs';
+
+const TAB_ORDER: TabKey[] = ['tasks', 'watches', 'webhooks', 'runs'];
+
+type Selection =
+ | { kind: 'task'; id: string }
+ | { kind: 'watch'; id: string }
+ | { kind: 'run'; id: string }
+ | null;
+
+export const HarnessPage: React.FC = () => {
+ const { t } = useTranslation();
+ const api = useApi();
+ const [tab, setTab] = useState<TabKey>('tasks');
+ const [tasks, setTasks] = useState<HarnessTask[]>([]);
+ const [watches, setWatches] = useState<HarnessWatch[]>([]);
+ const [runs, setRuns] = useState<HarnessRun[]>([]);
+ const [runsHasMore, setRunsHasMore] = useState(false);
+ const [runsPage, setRunsPage] = useState(1);
+ const [selection, setSelection] = useState<Selection>(null);
+ const [selectedRun, setSelectedRun] = useState<HarnessRun | null>(null);
+ const [loading, setLoading] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ const refresh = useCallback(async () => {
+ setLoading(true);
+ setError(null);
+ try {
+ if (tab === 'tasks') {
+ const result = await api.listHarnessTasks();
+ setTasks(result.tasks);
+ } else if (tab === 'watches') {
+ const result = await api.listHarnessWatches();
+ setWatches(result.watches);
+ } else if (tab === 'runs') {
+ const result = await api.listHarnessRuns({ page: runsPage, limit: 30 });
+ setRuns(result.runs);
+ setRunsHasMore(result.has_more);
+ }
+ } catch (err: any) {
+ setError(err?.message ?? String(err));
+ } finally {
+ setLoading(false);
+ }
+ }, [api, tab, runsPage]);
+
+ useEffect(() => {
+ refresh();
+ }, [refresh]);
+
+ // Fetch run detail (stdout/stderr) whenever a run is selected so the
+ // detail panel always shows the full body, not just the list excerpt.
+ useEffect(() => {
+ if (selection?.kind !== 'run') {
+ setSelectedRun(null);
+ return;
+ }
+ let cancelled = false;
+ api
+ .getHarnessRun(selection.id)
+ .then((result) => {
+ if (!cancelled && result.ok) setSelectedRun(result.run);
+ })
+ .catch((err) => {
+ if (!cancelled) setError(err?.message ?? String(err));
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [api, selection]);
+
+ const counts = useMemo(
+ () => ({
+ tasks: tasks.length,
+ watches: watches.length,
+ webhooks: 0,
+ runs: runs.length + (runsHasMore ? 1 : 0),
+ }),
+ [tasks.length, watches.length, runs.length, runsHasMore],
+ );
+
+ const selectedTask = useMemo(
+ () => (selection?.kind === 'task' ? tasks.find((task) => task.id === selection.id) ?? null : null),
+ [selection, tasks],
+ );
+ const selectedWatch = useMemo(
+ () => (selection?.kind === 'watch' ? watches.find((watch) => watch.id === selection.id) ?? null : null),
+ [selection, watches],
+ );
+
+ return (
+ <div className="mx-auto flex w-full max-w-[1180px] flex-col gap-5 py-2">
+ {/* Header */}
+ <div className="flex items-center gap-4">
+ <div className="flex size-12 shrink-0 items-center justify-center rounded-2xl border border-violet/30 bg-violet/[0.08] text-violet shadow-[0_0_24px_-6px_rgba(124,91,255,0.5)]">
+ <Activity className="size-5" />
+ </div>
+ <div className="flex flex-1 flex-col">
+ <h1 className="text-2xl font-bold text-foreground">{t('harness.title')}</h1>
+ <p className="text-[13px] text-muted">{t('harness.subtitle')}</p>
+ </div>
+ <button
+ type="button"
+ onClick={() => refresh()}
+ disabled={loading}
+ className={clsx(
+ 'flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-[12px] font-medium transition',
+ loading
+ ? 'cursor-wait border-border bg-foreground/[0.02] text-muted'
+ : 'border-border-strong text-foreground hover:bg-foreground/[0.04]',
+ )}
+ >
+ <RefreshCw className={clsx('size-3.5', loading && 'animate-spin')} />
+ {t('common.refresh')}
+ </button>
+ </div>
+
+ {/* Tab row */}
+ <div className="flex items-center gap-0 border-b border-border">
+ {TAB_ORDER.map((key) => {
+ const active = tab === key;
+ const count = counts[key];
+ return (
+ <button
+ key={key}
+ type="button"
+ onClick={() => {
+ setTab(key);
+ setSelection(null);
+ }}
+ className={clsx(
+ 'flex items-center gap-2 px-4 py-3 text-[13px] transition',
+ active ? 'border-b-2 border-violet font-bold text-violet' : 'font-medium text-muted hover:text-foreground',
+ )}
+ >
+ <HarnessTabIcon tab={key} active={active} />
+ {t(`harness.tabs.${key}`)}
+ {key !== 'webhooks' && (
+ <span
+ className={clsx(
+ 'rounded-full border px-1.5 py-0 font-mono text-[9px] font-bold',
+ active
+ ? 'border-violet/30 bg-violet/[0.10] text-violet'
+ : 'border-border-strong bg-foreground/[0.04] text-muted',
+ )}
+ >
+ {count}
+ </span>
+ )}
+ {key === 'webhooks' && (
+ <span className="font-mono text-[9px] text-muted">{t('harness.soon')}</span>
+ )}
+ </button>
+ );
+ })}
+ </div>
+
+ {error && (
+ <div className="rounded-md border border-destructive/40 bg-destructive/[0.06] px-3 py-2 text-[12px] text-destructive">
+ {error}
+ </div>
+ )}
+
+ {/* Body: list + detail */}
+ <div className="grid grid-cols-[1fr_440px] gap-5">
+ <div className="flex flex-col gap-2">
+ {tab === 'tasks' && (
+ <TasksList tasks={tasks} loading={loading} selectedId={selection?.kind === 'task' ? selection.id : null} onSelect={(id) => setSelection({ kind: 'task', id })} />
+ )}
+ {tab === 'watches' && (
+ <WatchesList watches={watches} loading={loading} selectedId={selection?.kind === 'watch' ? selection.id : null} onSelect={(id) => setSelection({ kind: 'watch', id })} />
+ )}
+ {tab === 'webhooks' && <WebhooksEmpty />}
+ {tab === 'runs' && (
+ <RunsList
+ runs={runs}
+ loading={loading}
+ selectedId={selection?.kind === 'run' ? selection.id : null}
+ onSelect={(id) => setSelection({ kind: 'run', id })}
+ page={runsPage}
+ hasMore={runsHasMore}
+ onPageChange={setRunsPage}
+ />
+ )}
+ </div>
+
+ <div className="flex flex-col gap-3 self-start rounded-xl border border-border-strong bg-surface p-5">
+ {selectedTask ? (
+ <TaskDetail task={selectedTask} />
+ ) : selectedWatch ? (
+ <WatchDetail watch={selectedWatch} />
+ ) : selectedRun ? (
+ <RunDetail run={selectedRun} />
+ ) : (
+ <div className="flex flex-col items-center justify-center gap-3 py-12 text-center text-[12px] text-muted">
+ <Activity className="size-6 text-muted" />
+ {t('harness.selectPrompt')}
+ </div>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+};
+
+interface TabIconProps {
+ tab: TabKey;
+ active: boolean;
+}
+
+const HarnessTabIcon: React.FC<TabIconProps> = ({ tab, active }) => {
+ const cls = clsx('size-3.5', active ? 'text-violet' : 'text-muted');
+ if (tab === 'tasks') return <Calendar className={cls} />;
+ if (tab === 'watches') return <Eye className={cls} />;
+ if (tab === 'webhooks') return <Webhook className={cls} />;
+ return <History className={cls} />;
+};
+
+// ---------------------------------------------------------------------------
+// Tasks tab
+// ---------------------------------------------------------------------------
+
+interface TasksListProps {
+ tasks: HarnessTask[];
+ loading: boolean;
+ selectedId: string | null;
+ onSelect: (id: string) => void;
+}
+
+const TasksList: React.FC<TasksListProps> = ({ tasks, loading, selectedId, onSelect }) => {
+ const { t } = useTranslation();
+ if (tasks.length === 0 && !loading) return <EmptyState i18nKey="harness.emptyTasks" />;
+ return (
+ <>
+ {tasks.map((task) => {
+ const active = selectedId === task.id;
+ const scheduleLabel = task.cron
+ ? `cron · ${task.cron}`
+ : task.run_at
+ ? `one-shot · ${task.run_at}`
+ : task.schedule_type || t('harness.unknownSchedule');
+ return (
+ <button
+ key={task.id}
+ type="button"
+ onClick={() => onSelect(task.id)}
+ className={clsx(
+ 'flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition',
+ active ? 'border-violet/40 bg-violet/[0.05]' : 'border-border bg-surface hover:bg-foreground/[0.03]',
+ )}
+ >
+ <div className="flex flex-1 flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="text-[14px] font-semibold text-foreground">{task.name || task.id}</span>
+ {!task.enabled && (
+ <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] text-muted">
+ DISABLED
+ </span>
+ )}
+ </div>
+ <div className="flex items-center gap-3 text-[11px] text-muted">
+ <span className="inline-flex items-center gap-1 font-mono">
+ <Clock className="size-3" />
+ {scheduleLabel}
+ </span>
+ {task.agent_name && <span>· {task.agent_name}</span>}
+ </div>
+ </div>
+ {task.last_run_at && (
+ <span className="font-mono text-[10px] text-muted">{formatRelative(task.last_run_at)}</span>
+ )}
+ </button>
+ );
+ })}
+ </>
+ );
+};
+
+interface TaskDetailProps {
+ task: HarnessTask;
+}
+
+const TaskDetail: React.FC<TaskDetailProps> = ({ task }) => {
+ const { t } = useTranslation();
+ return (
+ <div className="flex flex-col gap-4">
+ <div className="flex items-center gap-2">
+ <Calendar className="size-4 text-violet" />
+ <div className="flex-1 truncate text-[15px] font-bold text-foreground">{task.name || task.id}</div>
+ <StatusPill enabled={task.enabled} />
+ </div>
+ <DetailField label={t('harness.detail.schedule')}>
+ <span className="font-mono text-[12px] text-foreground">
+ {task.cron ?? task.run_at ?? task.schedule_type ?? '—'}
+ </span>
+ {task.timezone && <span className="ml-2 text-[10px] text-muted">{task.timezone}</span>}
+ </DetailField>
+ <DetailField label={t('harness.detail.agent')}>
+ <span className="text-[12px] text-foreground">{task.agent_name || '—'}</span>
+ </DetailField>
+ <DetailField label={t('harness.detail.message')}>
+ <pre className="max-h-44 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[11px] text-foreground">
+ {task.message || task.prompt || '—'}
+ </pre>
+ </DetailField>
+ {task.last_run_at && (
+ <DetailField label={t('harness.detail.lastRun')}>
+ <span className="font-mono text-[11px] text-muted">{task.last_run_at}</span>
+ {task.last_error && (
+ <div className="mt-1 rounded-md border border-destructive/40 bg-destructive/[0.06] px-2 py-1 text-[11px] text-destructive">
+ {task.last_error}
+ </div>
+ )}
+ </DetailField>
+ )}
+ <DetailField label={t('harness.detail.id')}>
+ <code className="font-mono text-[11px] text-muted">{task.id}</code>
+ </DetailField>
+ </div>
+ );
+};
+
+// ---------------------------------------------------------------------------
+// Watches tab
+// ---------------------------------------------------------------------------
+
+interface WatchesListProps {
+ watches: HarnessWatch[];
+ loading: boolean;
+ selectedId: string | null;
+ onSelect: (id: string) => void;
+}
+
+const WatchesList: React.FC<WatchesListProps> = ({ watches, loading, selectedId, onSelect }) => {
+ const { t } = useTranslation();
+ if (watches.length === 0 && !loading) return <EmptyState i18nKey="harness.emptyWatches" />;
+ return (
+ <>
+ {watches.map((watch) => {
+ const active = selectedId === watch.id;
+ const cmd = watch.shell_command || (Array.isArray(watch.command) ? watch.command.join(' ') : '') || '—';
+ return (
+ <button
+ key={watch.id}
+ type="button"
+ onClick={() => onSelect(watch.id)}
+ className={clsx(
+ 'flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition',
+ active ? 'border-violet/40 bg-violet/[0.05]' : 'border-border bg-surface hover:bg-foreground/[0.03]',
+ )}
+ >
+ <div className="flex flex-1 flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="text-[14px] font-semibold text-foreground">{watch.name || watch.id}</span>
+ {watch.runtime.running ? (
+ <span className="inline-flex items-center gap-1 rounded-full border border-mint/30 bg-mint/[0.08] px-2 py-0 font-mono text-[9px] font-bold text-mint">
+ <span className="size-1.5 rounded-full bg-mint" />
+ RUNNING
+ </span>
+ ) : !watch.enabled ? (
+ <span className="inline-flex items-center gap-1 rounded-full border border-border-strong bg-foreground/[0.04] px-2 py-0 font-mono text-[9px] text-muted">
+ <PauseCircle className="size-2.5" />
+ PAUSED
+ </span>
+ ) : (
+ <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] text-muted">
+ IDLE
+ </span>
+ )}
+ </div>
+ <div className="truncate font-mono text-[11px] text-muted">{cmd}</div>
+ </div>
+ {watch.last_event_at && (
+ <span className="font-mono text-[10px] text-muted">{formatRelative(watch.last_event_at)}</span>
+ )}
+ </button>
+ );
+ })}
+ {watches.length === 0 && loading && <div className="px-4 py-6 text-[12px] text-muted">{t('common.loading')}</div>}
+ </>
+ );
+};
+
+interface WatchDetailProps {
+ watch: HarnessWatch;
+}
+
+const WatchDetail: React.FC<WatchDetailProps> = ({ watch }) => {
+ const { t } = useTranslation();
+ const cmd = watch.shell_command || (Array.isArray(watch.command) ? watch.command.join(' ') : '') || '—';
+ return (
+ <div className="flex flex-col gap-4">
+ <div className="flex items-center gap-2">
+ <Eye className="size-4 text-violet" />
+ <div className="flex-1 truncate text-[15px] font-bold text-foreground">{watch.name || watch.id}</div>
+ <StatusPill enabled={watch.enabled} runtimeRunning={watch.runtime.running} />
+ </div>
+ <DetailField label={t('harness.detail.command')}>
+ <pre className="max-h-32 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[11px] text-foreground">
+ {cmd}
+ </pre>
+ </DetailField>
+ <DetailField label={t('harness.detail.agent')}>
+ <span className="text-[12px] text-foreground">{watch.agent_name || '—'}</span>
+ </DetailField>
+ <DetailField label={t('harness.detail.cwd')}>
+ <code className="font-mono text-[11px] text-muted">{watch.cwd || '—'}</code>
+ </DetailField>
+ <DetailField label={t('harness.detail.mode')}>
+ <span className="font-mono text-[11px] text-muted">{watch.mode}</span>
+ </DetailField>
+ <DetailField label={t('harness.detail.followUp')}>
+ <pre className="max-h-32 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[11px] text-foreground">
+ {watch.message || watch.prefix || '—'}
+ </pre>
+ </DetailField>
+ {watch.runtime.running && watch.runtime.pid != null && (
+ <DetailField label={t('harness.detail.runtime')}>
+ <span className="font-mono text-[11px] text-muted">
+ pid {watch.runtime.pid} · started {watch.runtime.started_at}
+ </span>
+ </DetailField>
+ )}
+ {watch.last_error && (
+ <DetailField label={t('harness.detail.lastError')}>
+ <div className="rounded-md border border-destructive/40 bg-destructive/[0.06] px-2 py-1 text-[11px] text-destructive">
+ {watch.last_error}
+ </div>
+ </DetailField>
+ )}
+ <DetailField label={t('harness.detail.id')}>
+ <code className="font-mono text-[11px] text-muted">{watch.id}</code>
+ </DetailField>
+ </div>
+ );
+};
+
+// ---------------------------------------------------------------------------
+// Webhooks tab — coming soon
+// ---------------------------------------------------------------------------
+
+const WebhooksEmpty: React.FC = () => {
+ const { t } = useTranslation();
+ return (
+ <div className="flex flex-col items-center gap-3 rounded-xl border border-dashed border-border bg-surface px-6 py-16 text-center">
+ <Webhook className="size-8 text-muted" />
+ <div className="text-[14px] font-semibold text-foreground">{t('harness.webhooksSoon')}</div>
+ <div className="max-w-md text-[12px] text-muted">{t('harness.webhooksSoonBody')}</div>
+ </div>
+ );
+};
+
+// ---------------------------------------------------------------------------
+// Runs tab
+// ---------------------------------------------------------------------------
+
+interface RunsListProps {
+ runs: HarnessRun[];
+ loading: boolean;
+ selectedId: string | null;
+ onSelect: (id: string) => void;
+ page: number;
+ hasMore: boolean;
+ onPageChange: (page: number) => void;
+}
+
+const RunsList: React.FC<RunsListProps> = ({ runs, loading, selectedId, onSelect, page, hasMore, onPageChange }) => {
+ const { t } = useTranslation();
+ if (runs.length === 0 && !loading) return <EmptyState i18nKey="harness.emptyRuns" />;
+ return (
+ <>
+ {runs.map((run) => {
+ const active = selectedId === run.id;
+ return (
+ <button
+ key={run.id}
+ type="button"
+ onClick={() => onSelect(run.id)}
+ className={clsx(
+ 'flex items-center gap-3 rounded-lg border px-4 py-3 text-left transition',
+ active ? 'border-violet/40 bg-violet/[0.05]' : 'border-border bg-surface hover:bg-foreground/[0.03]',
+ )}
+ >
+ <RunStatusIcon status={run.status} />
+ <div className="flex flex-1 flex-col gap-1">
+ <div className="flex items-center gap-2">
+ <span className="font-mono text-[12px] font-semibold text-foreground">{run.id}</span>
+ <span className="rounded border border-border-strong bg-foreground/[0.04] px-1.5 py-0 font-mono text-[9px] text-muted">
+ {run.run_type || 'run'}
+ </span>
+ </div>
+ <div className="flex items-center gap-3 text-[11px] text-muted">
+ <span>{run.agent_name || '—'}</span>
+ {run.created_at && <span>· {formatRelative(run.created_at)}</span>}
+ </div>
+ </div>
+ </button>
+ );
+ })}
+ {(page > 1 || hasMore) && (
+ <div className="mt-2 flex items-center justify-end gap-2 px-1">
+ <button
+ type="button"
+ disabled={page <= 1}
+ onClick={() => onPageChange(page - 1)}
+ className="rounded border border-border-strong px-2 py-1 font-mono text-[10px] text-muted hover:text-foreground disabled:opacity-40"
+ >
+ {t('common.previous')}
+ </button>
+ <span className="font-mono text-[10px] text-muted">{t('harness.pageLabel', { page })}</span>
+ <button
+ type="button"
+ disabled={!hasMore}
+ onClick={() => onPageChange(page + 1)}
+ className="rounded border border-border-strong px-2 py-1 font-mono text-[10px] text-muted hover:text-foreground disabled:opacity-40"
+ >
+ {t('common.next')}
+ </button>
+ </div>
+ )}
+ </>
+ );
+};
+
+interface RunDetailProps {
+ run: HarnessRun;
+}
+
+const RunDetail: React.FC<RunDetailProps> = ({ run }) => {
+ const { t } = useTranslation();
+ return (
+ <div className="flex flex-col gap-4">
+ <div className="flex items-center gap-2">
+ <RunStatusIcon status={run.status} />
+ <code className="flex-1 truncate font-mono text-[13px] font-bold text-foreground">{run.id}</code>
+ <span
+ className={clsx(
+ 'rounded border px-2 py-0 font-mono text-[9px] font-bold uppercase',
+ STATUS_PILL_CLASS[run.status as HarnessRunStatus] ?? 'border-border-strong bg-foreground/[0.04] text-muted',
+ )}
+ >
+ {run.status}
+ </span>
+ </div>
+ <DetailField label={t('harness.detail.type')}>
+ <span className="font-mono text-[11px] text-muted">{run.run_type || run.request_type || '—'}</span>
+ </DetailField>
+ <DetailField label={t('harness.detail.agent')}>
+ <span className="text-[12px] text-foreground">{run.agent_name || '—'}</span>
+ {run.agent_backend && <span className="ml-2 font-mono text-[10px] text-muted">{run.agent_backend}</span>}
+ {run.model && <span className="ml-2 font-mono text-[10px] text-muted">{run.model}</span>}
+ </DetailField>
+ {run.definition_id && (
+ <DetailField label={t('harness.detail.definition')}>
+ <code className="font-mono text-[11px] text-muted">{run.definition_id}</code>
+ </DetailField>
+ )}
+ {(run.message || run.prompt) && (
+ <DetailField label={t('harness.detail.message')}>
+ <pre className="max-h-32 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[11px] text-foreground">
+ {run.message || run.prompt}
+ </pre>
+ </DetailField>
+ )}
+ {run.result_text && (
+ <DetailField label={t('harness.detail.result')}>
+ <pre className="max-h-44 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[11px] text-foreground">
+ {run.result_text}
+ </pre>
+ </DetailField>
+ )}
+ {run.error && (
+ <DetailField label={t('harness.detail.error')}>
+ <pre className="max-h-32 overflow-auto whitespace-pre-wrap rounded-md border border-destructive/40 bg-destructive/[0.06] p-2 font-mono text-[11px] text-destructive">
+ {run.error}
+ </pre>
+ </DetailField>
+ )}
+ {run.stdout && (
+ <DetailField label="stdout">
+ <pre className="max-h-32 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[10px] text-foreground">
+ {run.stdout}
+ </pre>
+ </DetailField>
+ )}
+ {run.stderr && (
+ <DetailField label="stderr">
+ <pre className="max-h-32 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-3 p-2 font-mono text-[10px] text-foreground">
+ {run.stderr}
+ </pre>
+ </DetailField>
+ )}
+ <DetailField label={t('harness.detail.timing')}>
+ <div className="flex flex-col gap-0.5 font-mono text-[10px] text-muted">
+ <span>created {run.created_at ?? '—'}</span>
+ {run.started_at && <span>started {run.started_at}</span>}
+ {run.completed_at && <span>completed {run.completed_at}</span>}
+ {run.exit_code != null && <span>exit_code {run.exit_code}</span>}
+ {run.pid != null && <span>pid {run.pid}</span>}
+ </div>
+ </DetailField>
+ </div>
+ );
+};
+
+// ---------------------------------------------------------------------------
+// Shared helpers
+// ---------------------------------------------------------------------------
+
+const STATUS_PILL_CLASS: Record<HarnessRunStatus, string> = {
+ queued: 'border-cyan/30 bg-cyan/[0.08] text-cyan',
+ running: 'border-violet/30 bg-violet/[0.08] text-violet',
+ succeeded: 'border-mint/30 bg-mint/[0.08] text-mint',
+ failed: 'border-pink/30 bg-pink/[0.08] text-pink',
+ canceled: 'border-border-strong bg-foreground/[0.04] text-muted',
+};
+
+const RunStatusIcon: React.FC<{ status: HarnessRunStatus }> = ({ status }) => {
+ const cls = 'size-4 shrink-0';
+ if (status === 'succeeded') return <CheckCircle2 className={clsx(cls, 'text-mint')} />;
+ if (status === 'failed') return <XCircle className={clsx(cls, 'text-pink')} />;
+ if (status === 'running') return <Loader2 className={clsx(cls, 'animate-spin text-violet')} />;
+ if (status === 'queued') return <Clock className={clsx(cls, 'text-cyan')} />;
+ if (status === 'canceled') return <AlertTriangle className={clsx(cls, 'text-muted')} />;
+ return <Activity className={clsx(cls, 'text-muted')} />;
+};
+
+interface StatusPillProps {
+ enabled: boolean;
+ runtimeRunning?: boolean;
+}
+
+const StatusPill: React.FC<StatusPillProps> = ({ enabled, runtimeRunning }) => {
+ if (runtimeRunning) {
+ return (
+ <span className="inline-flex items-center gap-1 rounded-full border border-mint/30 bg-mint/[0.08] px-2 py-0 font-mono text-[9px] font-bold text-mint">
+ <span className="size-1.5 rounded-full bg-mint" />
+ RUNNING
+ </span>
+ );
+ }
+ if (!enabled) {
+ return (
+ <span className="rounded-full border border-border-strong bg-foreground/[0.04] px-2 py-0 font-mono text-[9px] text-muted">
+ DISABLED
+ </span>
+ );
+ }
+ return (
+ <span className="rounded-full border border-border-strong bg-foreground/[0.04] px-2 py-0 font-mono text-[9px] text-muted">
+ ENABLED
+ </span>
+ );
+};
+
+interface DetailFieldProps {
+ label: string;
+ children: React.ReactNode;
+}
+
+const DetailField: React.FC<DetailFieldProps> = ({ label, children }) => (
+ <div className="flex flex-col gap-1.5">
+ <div className="font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-muted">{label}</div>
+ <div>{children}</div>
+ </div>
);
+
+const EmptyState: React.FC<{ i18nKey: string }> = ({ i18nKey }) => {
+ const { t } = useTranslation();
+ return (
+ <div className="flex flex-col items-center gap-2 rounded-xl border border-dashed border-border bg-surface px-6 py-12 text-center">
+ <Activity className="size-6 text-muted" />
+ <div className="text-[13px] text-muted">{t(i18nKey)}</div>
+ </div>
+ );
+};
+
+function formatRelative(value: string | null | undefined): string {
+ if (!value) return '—';
+ const dt = new Date(value);
+ if (Number.isNaN(dt.valueOf())) return value;
+ const diffMs = Date.now() - dt.valueOf();
+ const secs = Math.round(diffMs / 1000);
+ if (secs < 60) return `${secs}s ago`;
+ const mins = Math.round(secs / 60);
+ if (mins < 60) return `${mins}m ago`;
+ const hours = Math.round(mins / 60);
+ if (hours < 24) return `${hours}h ago`;
+ const days = Math.round(hours / 24);
+ if (days < 7) return `${days}d ago`;
+ return dt.toISOString().slice(0, 10);
+}
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 927c2b7c8..df5ba99e3 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -112,6 +112,10 @@ export type ApiContextType = {
updateVibeAgent: (name: string, payload: VibeAgentUpdatePayload) => Promise<{ ok: boolean; agent: VibeAgentFull }>;
setDefaultVibeAgent: (name: string) => Promise<{ ok: boolean; default_agent_name: string; agent: VibeAgentBrief }>;
removeVibeAgent: (name: string) => Promise<{ ok: boolean; code?: string; message?: string; references?: Record<string, number>; removed_agent?: string }>;
+ listHarnessTasks: () => Promise<{ tasks: HarnessTask[] }>;
+ listHarnessWatches: () => Promise<{ watches: HarnessWatch[] }>;
+ listHarnessRuns: (params?: HarnessRunsParams) => Promise<{ runs: HarnessRun[]; page: number; limit: number; has_more: boolean }>;
+ getHarnessRun: (runId: string) => Promise<{ ok: boolean; run: HarnessRun }>;
remoteAccessStatus: () => Promise<any>;
pairVibeCloudRemoteAccess: (payload: { backend_url: string; pairing_key: string; device_name?: string }) => Promise<any>;
startRemoteAccess: () => Promise<any>;
@@ -264,6 +268,125 @@ export type WorkbenchMessage = {
read_at: string | null;
};
+// =============================================================================
+// Harness (scheduled tasks / watches / runs)
+// =============================================================================
+
+export type HarnessTask = {
+ id: string;
+ name: string | null;
+ agent_name: string | null;
+ session_policy: string | null;
+ session_id: string | null;
+ session_key: string;
+ prompt: string;
+ message: string;
+ message_payload: Record<string, unknown> | null;
+ schedule_type: string;
+ cron: string | null;
+ run_at: string | null;
+ timezone: string;
+ post_to: string | null;
+ deliver_key: string | null;
+ enabled: boolean;
+ created_at: string | null;
+ updated_at: string | null;
+ last_run_at: string | null;
+ last_run_id: string | null;
+ last_error: string | null;
+};
+
+export type HarnessWatchRuntime = {
+ running: boolean;
+ pid?: number | null;
+ started_at?: string | null;
+ updated_at?: string | null;
+};
+
+export type HarnessWatch = {
+ id: string;
+ name: string | null;
+ agent_name: string | null;
+ session_policy: string | null;
+ session_id: string | null;
+ session_key: string;
+ command: unknown[];
+ shell_command: string | null;
+ prefix: string | null;
+ message: string | null;
+ message_payload: Record<string, unknown> | null;
+ cwd: string | null;
+ mode: string;
+ timeout_seconds: number;
+ lifetime_timeout_seconds: number;
+ retry_exit_codes: number[];
+ retry_delay_seconds: number;
+ post_to: string | null;
+ deliver_key: string | null;
+ enabled: boolean;
+ created_at: string | null;
+ updated_at: string | null;
+ last_started_at: string | null;
+ last_finished_at: string | null;
+ last_event_at: string | null;
+ last_error: string | null;
+ last_exit_code: number | null;
+ runtime: HarnessWatchRuntime;
+};
+
+export type HarnessRunStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'canceled' | (string & {});
+
+export type HarnessRun = {
+ id: string;
+ request_type: string | null;
+ run_type: string | null;
+ status: HarnessRunStatus;
+ definition_id: string | null;
+ task_id: string | null;
+ source_kind: string | null;
+ source_actor: string | null;
+ parent_run_id: string | null;
+ agent_name: string | null;
+ agent_id: string | null;
+ agent_backend: string | null;
+ model: string | null;
+ reasoning_effort: string | null;
+ session_policy: string | null;
+ session_key: string | null;
+ session_id: string | null;
+ post_to: string | null;
+ deliver_key: string | null;
+ prompt: string | null;
+ message: string | null;
+ message_payload: Record<string, unknown> | null;
+ result_text: string | null;
+ result_payload: Record<string, unknown> | null;
+ message_ids: string[];
+ cancel_requested: boolean;
+ cancel_requested_at: string | null;
+ pid: number | null;
+ exit_code: number | null;
+ error: string | null;
+ stdout: string | null;
+ stderr: string | null;
+ created_at: string | null;
+ started_at: string | null;
+ completed_at: string | null;
+ updated_at: string | null;
+ metadata: Record<string, unknown>;
+ ok: boolean | null;
+};
+
+export type HarnessRunsParams = {
+ status?: HarnessRunStatus;
+ runType?: string;
+ agentName?: string;
+ definitionId?: string;
+ query?: string;
+ page?: number;
+ limit?: number;
+};
+
export type SessionInfo =
| { remote: false }
| { remote: true; authenticated: false }
@@ -854,6 +977,21 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children
},
setDefaultVibeAgent: (name) => postJson('/agents/default', { name }),
removeVibeAgent: (name) => deleteJson(`/agents/${encodeURIComponent(name)}`),
+ listHarnessTasks: () => getJson('/api/harness/tasks'),
+ listHarnessWatches: () => getJson('/api/harness/watches'),
+ listHarnessRuns: (params) => {
+ const search = new URLSearchParams();
+ if (params?.status) search.set('status', params.status);
+ if (params?.runType) search.set('run_type', params.runType);
+ if (params?.agentName) search.set('agent_name', params.agentName);
+ if (params?.definitionId) search.set('definition_id', params.definitionId);
+ if (params?.query) search.set('query', params.query);
+ if (params?.page) search.set('page', String(params.page));
+ if (params?.limit) search.set('limit', String(params.limit));
+ const qs = search.toString();
+ return getJson(qs ? `/api/harness/runs?${qs}` : '/api/harness/runs');
+ },
+ getHarnessRun: (runId) => getJson(`/api/harness/runs/${encodeURIComponent(runId)}`),
connectWorkbenchEvents: (handlers) => {
// EventSource auto-reconnects on transient drops, so callers don't
// have to implement their own retry. Returns a `disconnect` thunk so
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index a12698e55..4d2398bb5 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -48,6 +48,8 @@
"remove": "Remove",
"removing": "Removing…",
"delete": "Delete",
+ "previous": "Previous",
+ "next": "Next",
"test": "Test",
"testing": "Testing…",
"themeSystem": "System theme",
@@ -1214,5 +1216,42 @@
"systemPromptPlaceholder": "Optional. Prepended to every conversation that uses this agent.",
"submit": "Create agent"
}
+ },
+ "harness": {
+ "title": "Harness",
+ "subtitle": "Scheduled tasks, watches, webhooks, and the run history of all three.",
+ "soon": "soon",
+ "selectPrompt": "Select a row to view its full configuration.",
+ "emptyTasks": "No scheduled tasks. Ask an agent to create one in chat.",
+ "emptyWatches": "No watches running. Ask an agent to start one in chat.",
+ "emptyRuns": "No runs yet. They appear here once a task or watch fires.",
+ "webhooksSoon": "Webhooks are coming soon",
+ "webhooksSoonBody": "Inbound HTTP triggers will land in a follow-up release. Tasks and watches cover scheduled and event-driven runs today.",
+ "unknownSchedule": "unknown schedule",
+ "pageLabel": "page {{page}}",
+ "tabs": {
+ "tasks": "Tasks",
+ "watches": "Watches",
+ "webhooks": "Webhooks",
+ "runs": "Runs"
+ },
+ "detail": {
+ "schedule": "Schedule",
+ "agent": "Agent",
+ "message": "Message",
+ "lastRun": "Last run",
+ "id": "ID",
+ "command": "Command",
+ "cwd": "Working directory",
+ "mode": "Mode",
+ "followUp": "Follow-up message",
+ "runtime": "Runtime",
+ "lastError": "Last error",
+ "type": "Type",
+ "definition": "Definition",
+ "result": "Result",
+ "error": "Error",
+ "timing": "Timing"
+ }
}
}
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 84b42f1f4..331e91ddd 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -48,6 +48,8 @@
"remove": "移除",
"removing": "移除中…",
"delete": "删除",
+ "previous": "上一页",
+ "next": "下一页",
"test": "测试",
"testing": "测试中…",
"themeSystem": "跟随系统主题",
@@ -1214,5 +1216,42 @@
"systemPromptPlaceholder": "可选。会拼接到使用本 Agent 的每一段对话前。",
"submit": "创建 Agent"
}
+ },
+ "harness": {
+ "title": "Harness",
+ "subtitle": "定时任务、Watch、Webhook 及其运行历史。",
+ "soon": "敬请期待",
+ "selectPrompt": "选择左侧条目查看完整配置。",
+ "emptyTasks": "暂无定时任务。在 Chat 中让 Agent 创建一个。",
+ "emptyWatches": "没有正在运行的 Watch。在 Chat 中让 Agent 开启一个。",
+ "emptyRuns": "暂无运行记录。任务或 Watch 触发后会出现在这里。",
+ "webhooksSoon": "Webhook 即将上线",
+ "webhooksSoonBody": "入站 HTTP 触发将在后续版本中落地。Tasks 和 Watches 已覆盖定时与事件驱动的运行。",
+ "unknownSchedule": "未知计划",
+ "pageLabel": "第 {{page}} 页",
+ "tabs": {
+ "tasks": "Tasks",
+ "watches": "Watches",
+ "webhooks": "Webhooks",
+ "runs": "Runs"
+ },
+ "detail": {
+ "schedule": "计划",
+ "agent": "Agent",
+ "message": "消息",
+ "lastRun": "上次运行",
+ "id": "ID",
+ "command": "命令",
+ "cwd": "工作目录",
+ "mode": "模式",
+ "followUp": "跟进消息",
+ "runtime": "运行时",
+ "lastError": "上次错误",
+ "type": "类型",
+ "definition": "定义",
+ "result": "结果",
+ "error": "错误",
+ "timing": "时间线"
+ }
}
}
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index ceb578efd..649ee77a6 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -2732,6 +2732,84 @@ def inbox_list():
return jsonify(result)
+# =============================================================================
+# Harness Endpoints (read-only v1)
+# =============================================================================
+#
+# Workbench Harness page reads scheduled tasks, watches, and agent runs out
+# of the same SQLite store the scheduler writes to. Mutations (delete /
+# cancel / pause-resume) need to talk to the live ScheduledTaskService and
+# WatchSupervisor so the in-memory schedule stays consistent — that wiring
+# lands in a follow-up commit.
+
+
+def _harness_store():
+ from storage.background import SQLiteBackgroundTaskStore
+
+ return SQLiteBackgroundTaskStore()
+
+
[email protected]("/api/harness/tasks", methods=["GET"])
+def harness_tasks_list():
+ return jsonify({"tasks": _harness_store().list_scheduled_tasks()})
+
+
[email protected]("/api/harness/watches", methods=["GET"])
+def harness_watches_list():
+ store = _harness_store()
+ watches = store.list_watches()
+ runtime = store.load_watch_runtime().get("watches") or {}
+ for watch in watches:
+ watch["runtime"] = runtime.get(watch["id"]) or {"running": False}
+ return jsonify({"watches": watches})
+
+
[email protected]("/api/harness/runs", methods=["GET"])
+def harness_runs_list():
+ from storage.pagination import make_page_request
+
+ try:
+ limit = int(request.args.get("limit") or 30)
+ except (TypeError, ValueError):
+ limit = 30
+ try:
+ page = int(request.args.get("page") or 1)
+ except (TypeError, ValueError):
+ page = 1
+ status = request.args.get("status") or None
+ run_type = request.args.get("run_type") or None
+ agent_name = request.args.get("agent_name") or None
+ definition_id = request.args.get("definition_id") or None
+ query = request.args.get("query") or None
+
+ page_request = make_page_request(page=page, limit=limit)
+ page_result = _harness_store().list_runs_page(
+ status=status,
+ run_type=run_type,
+ agent_name=agent_name,
+ definition_id=definition_id,
+ query=query,
+ page_request=page_request,
+ newest_first=True,
+ )
+ return jsonify(
+ {
+ "runs": page_result.items,
+ "page": page_result.page,
+ "limit": page_result.limit,
+ "has_more": page_result.has_more,
+ }
+ )
+
+
[email protected]("/api/harness/runs/<run_id>", methods=["GET"])
+def harness_run_detail(run_id: str):
+ run = _harness_store().get_run(run_id)
+ if not run:
+ return jsonify({"ok": False, "code": "run_not_found"}), 404
+ return jsonify({"ok": True, "run": run})
+
+
# =============================================================================
# User & Bind Code Endpoints
# =============================================================================