Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Offer adding accounts when a space is created
Lin (kwant bot)a74a5d05c3ef
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex e14675ec..9daf62eb 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -82,6 +82,8 @@ export interface SpaceAppProps {space: Space;spaces: Space[];initialTarget: SpaceTarget | null;+ /** Space settings open on this tab when the space mounts (Accounts, right after creating it). */+ initialSettingsTab?: SpaceSettingsTab | null;onSwitchSpace: (id: string, to?: SpaceTarget | null) => void;onCreateSpace: () => void;onOpenArchived: () => void;@@ -116,6 +118,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({space,spaces,initialTarget,+ initialSettingsTab = null,onSwitchSpace,onCreateSpace,onOpenArchived,@@ -191,7 +194,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const [tokensUsed, setTokensUsed] = useState(0);// Space settings: open on one tab, or closed.- const [spaceSettingsTab, setSpaceSettingsTab] = useState<SpaceSettingsTab | null>(null);+ const [spaceSettingsTab, setSpaceSettingsTab] = useState<SpaceSettingsTab | null>(initialSettingsTab);// Bumped when Space settings closes, so open bot forms read account status again.const [settingsClosedCount, setSettingsClosedCount] = useState(0);// Set when Accounts opens from a "Sign in with Claude" hint, to focus that button.@@ -209,6 +212,8 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({const closeSpaceSettings = () => {setSpaceSettingsTab(null);setSettingsClosedCount((n) => n + 1);+ // Accounts may have changed: the getting-started list counts the ready ones.+ onSpacesChanged();};const [isMcpOpen, setIsMcpOpen] = useState(false);const [isSearchOpen, setIsSearchOpen] = useState(false);@@ -1936,6 +1941,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({(isChannel && currentTeam && discussionState.teamId === currentTeam.id));const needsSetup = loaded && kwants.length === 0;+ const readyAccounts = space.counts?.ready_accounts ?? 0;const setupChecklist = (<main className="flex-1 min-w-0 overflow-y-auto flex items-start sm:items-center justify-center p-4 sm:p-8" data-space-checklist><div className="w-full max-w-md rounded-2xl border border-zinc-800 bg-zinc-900/60 p-5 sm:p-6 space-y-4">@@ -1948,12 +1954,21 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({</div><ol className="space-y-2">{[- {- done: (space.counts?.ready_accounts ?? 0) > 0,- title: 'Connect an account',- detail: 'Sign in with Claude, add a key, or use this machine.',- action: { label: 'Accounts', icon: <KeyRound size={13} />, onClick: () => openSpaceSettings('accounts') },- },+ readyAccounts > 0+ ? {+ done: true,+ // Still offered once This machine is ready: more accounts and API keys go here too.+ keepAction: true,+ title: readyAccounts === 1 ? '1 account ready' : `${readyAccounts} accounts ready`,+ detail: 'Add another Claude, Codex or Grok sign-in, or an API key.',+ action: { label: 'Add an account', icon: <KeyRound size={13} />, onClick: () => openSpaceSettings('accounts') },+ }+ : {+ done: false,+ title: 'Add an account',+ detail: 'Sign in with Claude, Codex or Grok, add an API key, or use this machine.',+ action: { label: 'Add an account', icon: <KeyRound size={13} />, onClick: () => openSpaceSettings('accounts') },+ },{done: kwants.length > 0,title: 'Add your first bot',@@ -1969,7 +1984,7 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({},},{ done: false, title: 'Message #general', detail: `Laya picks who answers, only from ${space.name}'s bots.` },- ].map((step, i) => (+ ].map((step: { done: boolean; keepAction?: boolean; title: string; detail: string; action?: { label: string; icon: React.ReactNode; onClick: () => void } }, i) => (<li key={step.title} className="flex items-start gap-3 rounded-xl border border-zinc-800 bg-zinc-950/50 p-3"><spanclassName={`mt-0.5 w-5 h-5 shrink-0 rounded-full flex items-center justify-center text-[11px] font-semibold ${@@ -1980,17 +1995,19 @@ export const SpaceApp: React.FC<SpaceAppProps> = ({{step.done ? <Check size={12} /> : i + 1}</span><span className="flex-1 min-w-0">- <span className={`block text-xs font-medium ${step.done ? 'text-zinc-400 line-through' : 'text-zinc-100'}`}>+ <span className={`block text-xs font-medium ${step.done ? (step.keepAction ? 'text-zinc-300' : 'text-zinc-400 line-through') : 'text-zinc-100'}`}>{step.title}{step.done && <span className="sr-only"> (done)</span>}</span><span className="block text-[11px] text-zinc-500">{step.detail}</span></span>- {step.action && !step.done && (+ {step.action && (!step.done || step.keepAction) && (<buttontype="button"onClick={step.action.onClick}- className="shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium text-white bg-sky-600 hover:bg-sky-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-300"+ className={`shrink-0 flex items-center gap-1 px-2.5 py-1 rounded-lg text-[11px] font-medium focus-visible:outline focus-visible:outline-2 focus-visible:outline-sky-300 ${+ step.done ? 'text-zinc-200 border border-zinc-700 hover:border-sky-500/50 hover:text-sky-200' : 'text-white bg-sky-600 hover:bg-sky-500'+ }`}>{step.action.icon}{step.action.label}diff --git a/frontend/src/Shell.tsx b/frontend/src/Shell.tsxindex d3be256f..caba5829 100644--- a/frontend/src/Shell.tsx+++ b/frontend/src/Shell.tsx@@ -4,6 +4,7 @@import React, { Suspense, lazy, useCallback, useEffect, useRef, useState } from 'react';import { AlertTriangle, Loader2 } from 'lucide-react';import { SpaceApp, SpaceTarget } from './App';+import type { SpaceSettingsTab } from './components/SpaceSettings';import { ArchivedSpacesModal, NewSpaceModal, SpaceRail } from './components/Spaces';import { Toasts, Toast } from './components/Toasts';import { playSfx } from './audio/chiptune';@@ -33,6 +34,8 @@ export const App: React.FC = () => {// Where to land in the space being opened (a link, a notification, the last chat there).const [target, setTarget] = useState<SpaceTarget | null>(null);const [creating, setCreating] = useState<Space[] | null>(null);+ // Space settings tab the next space opens on: Accounts right after "Add accounts next".+ const [startTab, setStartTab] = useState<SpaceSettingsTab | null>(null);const [showArchived, setShowArchived] = useState(false);const [appSettingsOpen, setAppSettingsOpen] = useState(false);const [tokensUsed, setTokensUsed] = useState(0);@@ -57,6 +60,7 @@ export const App: React.FC = () => {/** Opens a space: the request scope changes before the new space renders. */const open = useCallback((id: string, to?: SpaceTarget | null, replace = false) => {const t = to ?? lastChat(id) ?? null;+ setStartTab(null);setCurrentSpace(id);rememberSpace(id);setTarget(t);@@ -211,6 +215,7 @@ export const App: React.FC = () => {space={current}spaces={spaces}initialTarget={target}+ initialSettingsTab={startTab}onSwitchSpace={switchTo}onCreateSpace={openCreate}onOpenArchived={() => setShowArchived(true)}@@ -236,10 +241,11 @@ export const App: React.FC = () => {<NewSpaceModalspaces={creating}onClose={() => setCreating(null)}- onCreated={(s) => {+ onCreated={(s, addAccounts) => {setCreating(null);setSpaces((prev) => (prev ? [...prev, s] : [s]));open(s.id, null);+ if (addAccounts) setStartTab('accounts');reload();}}/>diff --git a/frontend/src/components/Spaces.tsx b/frontend/src/components/Spaces.tsxindex b62eaffb..3b0dc83f 100644--- a/frontend/src/components/Spaces.tsx+++ b/frontend/src/components/Spaces.tsx@@ -1,5 +1,5 @@import React, { useEffect, useRef, useState } from 'react';-import { Archive, Check, Loader2, Plus, RotateCcw, Settings, X, AlertTriangle } from 'lucide-react';+import { Archive, Check, Loader2, Plus, RotateCcw, Settings, X, AlertTriangle, KeyRound } from 'lucide-react';import { playSfx } from '../audio/chiptune';import {SPACE_COLORS,@@ -236,7 +236,8 @@ interface NewSpaceProps {/** Every space, archived ones too, for taken names and colours. */spaces: Space[];onClose: () => void;- onCreated: (space: Space) => void;+ /** `addAccounts`: open the new space's Accounts next. */+ onCreated: (space: Space, addAccounts: boolean) => void;}export const NewSpaceModal: React.FC<NewSpaceProps> = ({ spaces, onClose, onCreated }) => {@@ -245,6 +246,7 @@ export const NewSpaceModal: React.FC<NewSpaceProps> = ({ spaces, onClose, onCreaconst [icon, setIcon] = useState(() => SPACE_ICONS.find((i) => !spaces.some((s) => s.icon === i)) ?? SPACE_ICONS[0]);const [color, setColor] = useState(() => firstUnusedColor(spaces));const [thisMachine, setThisMachine] = useState(true);+ const [addAccounts, setAddAccounts] = useState(true);const [touched, setTouched] = useState(false);const [saving, setSaving] = useState(false);const [error, setError] = useState<string | null>(null);@@ -261,7 +263,7 @@ export const NewSpaceModal: React.FC<NewSpaceProps> = ({ spaces, onClose, onCreatry {const space = await spacesApi.create({ name: name.trim(), icon, color, this_machine_enabled: thisMachine });playSfx('coin');- onCreated(space);+ onCreated(space, addAccounts);} catch (err) {setError(err instanceof Error ? err.message : 'Couldn’t create the space.');setSaving(false);@@ -350,6 +352,18 @@ export const NewSpaceModal: React.FC<NewSpaceProps> = ({ spaces, onClose, onCrea</button></div>+ <label className="flex items-start gap-3 bg-zinc-950/60 p-3 rounded-xl border border-zinc-800 cursor-pointer">+ <input type="checkbox" checked={addAccounts} onChange={(e) => setAddAccounts(e.target.checked)} className="mt-0.5 accent-sky-500" aria-describedby="space-add-accounts-detail" />+ <span className="flex-1">+ <span className="flex items-center gap-1.5 text-xs font-medium text-zinc-200">+ <KeyRound size={12} className="text-sky-400" aria-hidden="true" /> Add accounts next+ </span>+ <span id="space-add-accounts-detail" className="block text-[11px] text-zinc-500">+ Sign in to more Claude, Codex or Grok accounts, or add an Anthropic, OpenAI or xAI API key. They stay in this space.+ </span>+ </span>+ </label>+<fieldset className="space-y-1.5"><legend className="text-xs font-medium text-zinc-300 mb-1.5">Start with</legend><label className="flex items-center gap-2.5 p-2.5 rounded-lg border border-sky-500/40 bg-sky-500/5 text-xs text-zinc-200">diff --git a/frontend/src/engines.ts b/frontend/src/engines.tsindex 012a763c..e0778ab5 100644--- a/frontend/src/engines.ts+++ b/frontend/src/engines.ts@@ -88,8 +88,9 @@ export function sortEngines(list: EngineInfo[]): EngineInfo[] {.map(({ e }) => e);}-/** Engines that aren't on this computer at all, to fold away. An API engine with no key is "not installed". */-export const isAbsent = (e: EngineInfo) => e.status === 'not_installed' && e.enabled !== false && !isUsable(e);+/** Engines that aren't on this computer at all, to fold away. An API engine with no key reports "not+ * installed" too, but it stays out: adding a key on its card is how it becomes usable. */+export const isAbsent = (e: EngineInfo) => e.status === 'not_installed' && e.kind !== 'api' && e.enabled !== false && !isUsable(e);/** Whether only CLIs can run things right now (so "no API keys needed" is true). */export const onlyCliReady = (list: EngineInfo[]) => {diff --git a/frontend/tests/engines.test.mjs b/frontend/tests/engines.test.mjsindex 3916c8f8..7c943d0f 100644--- a/frontend/tests/engines.test.mjs+++ b/frontend/tests/engines.test.mjs@@ -91,7 +91,7 @@ test('the reason shows when an engine is not ready, with its command as code', (assert.match(html, /Checked 2 min ago/);});-test('ready engines come first; not-installed ones fold under "Not available on this computer"', () => {+test('ready engines come first; not-installed CLIs and Ollama fold under "Not available on this computer"', () => {const sorted = m.sortEngines([engine('ollama', { status: 'not_installed' }),engine('codex', { status: 'signed_out' }),@@ -104,8 +104,9 @@ test('ready engines come first; not-installed ones fold under "Not available onconst html = panel(live);const order = [...html.matchAll(/data-engine="([a-z_]+)"/g)].map((x) => x[1]);- assert.deepEqual(order, ['claude', 'codex', 'grok'], 'absent ones are folded away by default');- assert.match(html, /Not available on this computer \(4\)/);+ // An API engine with no key isn't absent: its card is where the key goes, so it stays out.+ assert.deepEqual(order, ['claude', 'codex', 'grok', 'anthropic_api', 'openai_api', 'xai_api'], 'only Ollama is folded away');+ assert.match(html, /Not available on this computer \(1\)/);assert.match(html, /aria-expanded="false"/);});diff --git a/frontend/tests/enginesAccounts.test.mjs b/frontend/tests/enginesAccounts.test.mjsindex d4db364c..59907d9f 100644--- a/frontend/tests/enginesAccounts.test.mjs+++ b/frontend/tests/enginesAccounts.test.mjs@@ -163,3 +163,18 @@ test('the kwant form takes Claude as ready through Personal, even with no modelconst off = [{ ...oleksOn, enabled: false, status: 'disabled', ready: false }, engine('anthropic_api', { status: 'not_installed', ready: false, detail: 'No API key: add one in Settings' })];assert.deepEqual(m.pickHealth('claude', off), { kind: 'engine_unavailable', family: 'claude', reason: 'Switched off in Settings' });});++test('a new space with no keys still offers every engine an account can be added to', () => {+ // What a fresh space sees: the CLIs signed in on this machine, no API keys, Ollama not running.+ const noKey = (id) => engine(id, { status: 'not_installed', detail: 'No API key: add one in Settings', ready: false, uses: null });+ const html = panel(+ [oleksOn, engine('codex'), noKey('anthropic_api'), noKey('openai_api'), noKey('xai_api'), engine('ollama', { status: 'not_installed', ready: false })],+ [machine],+ );+ for (const id of ['anthropic_api', 'openai_api', 'xai_api']) {+ assert.match(card(html, id), /Add an account with a key/, `${id} offers a key account without opening a fold`);+ assert.equal(summary(html, id), 'No key yet · Add a key below to use it');+ }+ assert.match(card(html, 'codex'), /> Add account</);+ assert.match(html, /Not available on this computer \(1\)/, 'only Ollama is folded away');+});