Skip to content

Your team of AI agents, on your Mac, Windows or Linux. Agents that talk in channels, write code, review each other and use your tools, on the Claude Code, Codex, OpenCode or Pi you already have. Anything that touches the real world waits for your yes.

Install a harness from the app (#26)

Eduardo Machadoc8b2bc47b9ae
diff --git a/src/core/index.ts b/src/core/index.ts
index 464604b..bb2f476 100644
--- a/src/core/index.ts
+++ b/src/core/index.ts
@@ -33,7 +33,7 @@ import { backup, backupIfDue, exportTeam, importTeam } from './team'
import { Telegram } from './telegram'
import { mainCipher, plainCipher, Secrets } from './secrets'
import { Browser, type BrowserHost } from './browser'
-import { isWin, loginShell, onPath, osOf, shellCommand, terminalCommand } from './platform'
+import { findOnPath, isWin, loginShell, onPath, osOf, shellCommand, terminalCommand } from './platform'
import { ChromeBrowsers, hasChrome } from './chrome'
import { checkFolder, Computers, folderName, type Shooter } from './computer'
import { Memories } from './memory'
@@ -771,6 +771,24 @@ const api: Api = {
// Its own process, so the terminal outlives the app if the person quits it mid-login.
if (term) spawn(term.bin, term.args, { detached: true, stdio: 'ignore' }).on('error', () => {}).unref()
return { opened: !!term, command: cmd }
+ },
+
+ // The harness's own installer, in a terminal the person sees: its progress, its
+ // questions and its errors stay theirs. Detection picks the CLI up once it lands.
+ installEngine: ({ engine }) => {
+ const command = (isWin && ENGINES[engine].windows) || ENGINES[engine].install
+ // An npm package needs Node.js first; without it the command would only fail.
+ if (/^npm\s/.test(command) && !findOnPath('npm')) return { opened: false, command, needsNode: true }
+ if (isWin) {
+ // A PowerShell window running a small script: the install commands are PowerShell.
+ const script = join(dataDir, 'install.ps1')
+ writeFileSync(script, `${command}\r\n`)
+ spawn(process.env['ComSpec'] || 'cmd.exe', ['/d', '/c', 'start', '"Tucano"', 'powershell.exe', '-NoProfile', '-NoExit', '-ExecutionPolicy', 'Bypass', '-File', `"${script}"`], { detached: true, stdio: 'ignore', windowsVerbatimArguments: true }).unref()
+ return { opened: true, command }
+ }
+ const term = terminalCommand(command, osOf(), onPath)
+ if (term) spawn(term.bin, term.args, { detached: true, stdio: 'ignore' }).on('error', () => {}).unref()
+ return { opened: !!term, command }
}
}
diff --git a/src/core/platform.ts b/src/core/platform.ts
index 7991103..54431cd 100644
--- a/src/core/platform.ts
+++ b/src/core/platform.ts
@@ -137,7 +137,7 @@ function cmdArg(arg: string, twice: boolean): string {
}
// The program on PATH with this name, as cmd.exe would find it.
-function findOnPath(cmd: string): string | undefined {
+export function findOnPath(cmd: string): string | undefined {
for (const dir of pathDirs()) for (const name of executableNames(cmd)) if (existsSync(join(dir, name))) return join(dir, name)
return undefined
}
diff --git a/src/renderer/src/components/Harness.tsx b/src/renderer/src/components/Harness.tsx
index acf5eb9..2849a54 100644
--- a/src/renderer/src/components/Harness.tsx
+++ b/src/renderer/src/components/Harness.tsx
@@ -13,8 +13,10 @@ import {
engineModels,
harnessMcps,
importHarnessMcp,
+ installEngine,
loginEngine,
modelInfo,
+ openExternal,
testEngine,
updateSettings,
useStore,
@@ -173,6 +175,8 @@ function HarnessRow({ engine, st, picked, toggle }: { engine: EngineId; st: Engi
const [result, setResult] = useState<{ ok: boolean; message: string } | null>(null)
// No terminal could be opened: the command, for the person to run.
const [manual, setManual] = useState<string | null>(null)
+ // The install: started in a terminal, or blocked on Node.js for an npm package.
+ const [install, setInstall] = useState<'started' | 'node' | null>(null)
const windows = useStore((s) => s.platform === 'windows')
const ready = st.loggedIn
const found = st.installed && !!st.route // what its setup says, picked or not
@@ -210,6 +214,15 @@ function HarnessRow({ engine, st, picked, toggle }: { engine: EngineId; st: Engi
{L('Testar', 'Test')}
</button>
)}
+ {!st.installed && !st.soon && (
+ <button
+ className="btn btn--sm btn--primary"
+ title={L('Abre um terminal que instala pra você', 'Opens a terminal that installs it for you')}
+ onClick={() => void installEngine(engine).then((r) => setInstall(r.needsNode ? 'node' : r.opened ? 'started' : null))}
+ >
+ {L('Instalar', 'Install')}
+ </button>
+ )}
{st.installed && !st.loggedIn && !st.soon && (
<button
className="btn btn--sm btn--primary"
@@ -226,9 +239,18 @@ function HarnessRow({ engine, st, picked, toggle }: { engine: EngineId; st: Engi
<code className="harness__cmd">{manual}</code>
</div>
)}
+ {!st.installed && install === 'started' && <p className="hint harness__body">{L('Instalando no terminal que abriu. Quando terminar, ele aparece aqui sozinho.', 'Installing in the terminal that opened. Once it finishes, it shows up here on its own.')}</p>}
+ {!st.installed && install === 'node' && (
+ <p className="hint hint--warn harness__body">
+ {L(`O ${ENGINES[engine].label} precisa do Node.js. Instale o Node.js e depois clique em Instalar de novo.`, `${ENGINES[engine].label} needs Node.js. Install Node.js, then click Install again.`)}{' '}
+ <button className="btn btn--ghost btn--sm" onClick={() => openExternal('https://nodejs.org/')}>
+ {L('Baixar o Node.js', 'Get Node.js')}
+ </button>
+ </p>
+ )}
{!st.installed && (
<div className="harness__body">
- <span className="hint">{windows ? L('Pra instalar, cole no PowerShell:', 'To install, paste in PowerShell:') : L('Pra instalar, cole no terminal:', 'To install, paste in a terminal:')}</span>
+ <span className="hint">{windows ? L('Ou cole no PowerShell:', 'Or paste in PowerShell:') : L('Ou cole no terminal:', 'Or paste in a terminal:')}</span>
<code className="harness__cmd">{(windows && ENGINES[engine].windows) || ENGINES[engine].install}</code>
</div>
)}
diff --git a/src/renderer/src/store.ts b/src/renderer/src/store.ts
index 3dab229..11bbc9a 100644
--- a/src/renderer/src/store.ts
+++ b/src/renderer/src/store.ts
@@ -310,6 +310,7 @@ export function updateSettings(patch: Partial<Omit<Settings, 'engines'>>): void
export const refreshEngines = (): void => void call('refreshEngines')
export const loginEngine = (engine: keyof Settings['engines']): Promise<{ opened: boolean; command: string }> => call('loginEngine', { engine })
+export const installEngine = (engine: keyof Settings['engines']): Promise<{ opened: boolean; command: string; needsNode?: boolean }> => call('installEngine', { engine })
export function saveAgent(agent: Agent, channelIds: string[]): Promise<void> {
return call('saveAgent', { agent, channelIds })
diff --git a/src/shared/rpc.ts b/src/shared/rpc.ts
index c1b5377..bc78fee 100644
--- a/src/shared/rpc.ts
+++ b/src/shared/rpc.ts
@@ -40,6 +40,7 @@ export interface Api {
updateSettings(p: { patch: Partial<Omit<Settings, 'engines'>> }): void
refreshEngines(): void
loginEngine(p: { engine: EngineId }): { opened: boolean; command: string } // not opened: no terminal to open, the person runs the command
+ installEngine(p: { engine: EngineId }): { opened: boolean; command: string; needsNode?: boolean } // needsNode: an npm install with no npm here
addConnector(p: { input: ConnectorInput }): Promise<string>
removeConnector(p: { id: string }): void
reconnectConnector(p: { id: string }): void