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.
TypeScript agent-teamagentic-aiai-agentsai-assistantclaude-codecodexcursorelectrongrokgrok-bot-alternativelinuxlocal-firstmacosmcpmulti-agentopenclaw-alternativeopencodewindows
Sign in on Windows from a user folder with accents; pick the sign-in up by itself (#34)
Eduardo Machadoa3eba0333a99
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.ymlindex 182d53d..6b97d92 100644--- a/.github/workflows/windows.yml+++ b/.github/workflows/windows.yml@@ -11,8 +11,8 @@ on:workflow_dispatch:inputs:tag:- description: Release tag to attach the Windows files to (e.g. v0.2.0)- required: true+ description: Release tag to attach the Windows files to (e.g. v0.2.0); empty for a test build, kept as an artifact+ required: falsepull_request:paths:- package.jsondiff --git a/src/core/index.ts b/src/core/index.tsindex 53bc893..55021ad 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 { findOnPath, isWin, loginShell, onPath, osOf, shellCommand, terminalCommand } from './platform'+import { findOnPath, isWin, loginShell, onPath, openWindowsConsole, osOf, shellCommand, terminalCommand } from './platform'import { ChromeBrowsers, hasChrome } from './chrome'import { checkFolder, Computers, folderName, type Shooter } from './computer'import { Memories } from './memory'@@ -94,6 +94,19 @@ async function detect(): Promise<void> {gatewayLists.clear()emit({ type: 'settings', settings: settings() })}+// After a sign-in or an install in a terminal, the harness is checked again every few+// seconds until it shows up (for 10 minutes at most): it appears with no "Check again".+let watching: ReturnType<typeof setInterval> | undefined+function watchEngine(engine: EngineId, done: (s: EngineStatus) => boolean): void {+ if (watching) clearInterval(watching)+ const until = Date.now() + 10 * 60_000+ watching = setInterval(() => {+ if (done(engines[engine]) || Date.now() > until) return void clearInterval(watching)+ void detect()+ }, 4_000)+ watching.unref()+}+const gateway = new Gateway()const ready = Promise.all([gateway.start(), (fake ? Promise.resolve() : adoptLoginShellPath()).then(detect)])@@ -778,12 +791,11 @@ const api: Api = {loginEngine: ({ engine }) => {const bin = engines[engine].path ?? ENGINES[engine].cliconst sub = ENGINES[engine].login.split(' ').slice(1).join(' ')+ // The sign-in happens in a terminal: check again until it lands, wherever the person is.+ watchEngine(engine, (s) => s.loggedIn)if (isWin) {- // A new console window running a small script: cmd's quoting can't be trusted with paths otherwise.- const script = join(dataDir, 'login.cmd')- const env = engine === 'codex' ? `set "HOME=${codexHome}"\r\nset "CODEX_HOME=${join(codexHome, '.codex')}"\r\n` : ''- writeFileSync(script, `@echo off\r\n${env}call "${bin}" ${sub}\r\n`)- spawn(process.env['ComSpec'] || 'cmd.exe', ['/d', '/c', 'start', '"Tucano"', 'cmd.exe', '/k', `"${script}"`], { detached: true, stdio: 'ignore', windowsVerbatimArguments: true }).unref()+ // A new console window running a small script, its paths in the environment.+ openWindowsConsole(join(dataDir, 'login.cmd'), [`call "%TUCANO_CLI%" ${sub}`], { TUCANO_CLI: bin, ...(engine === 'codex' ? { HOME: codexHome, CODEX_HOME: join(codexHome, '.codex') } : {}) })return { opened: true, command: `"${bin}" ${sub}` }}const q = (s: string): string => `'${s.replace(/'/g, `'\\''`)}'`@@ -800,6 +812,7 @@ const api: Api = {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 }+ watchEngine(engine, (s) => s.installed)if (isWin) {// A PowerShell window running a small script: the install commands are PowerShell.const script = join(dataDir, 'install.ps1')diff --git a/src/core/platform.ts b/src/core/platform.tsindex 54431cd..f5e742a 100644--- a/src/core/platform.ts+++ b/src/core/platform.ts@@ -2,7 +2,7 @@// code asks "open a terminal with this", "where is Chrome?", "how do I spawn this// CLI?", and never checks the platform itself. Most answers are a plain function// of the system, so they're tested for every system on any machine.-import { accessSync, constants, existsSync, readFileSync } from 'node:fs'+import { accessSync, constants, existsSync, readFileSync, writeFileSync } from 'node:fs'import { execFile, spawn } from 'node:child_process'import { homedir, userInfo } from 'node:os'import { delimiter, dirname, join } from 'node:path'@@ -252,3 +252,20 @@ export function shellCommand(command: string, env: NodeJS.ProcessEnv = process.e}return { file: process.env['ComSpec'] || 'cmd.exe', args: ['/d', '/s', '/c', `"${command}"`], verbatim: true, kind: 'cmd', env }}++// A new console window on Windows that runs a .cmd script and stays open (its output and+// errors stay the person's). cmd reads a script in the console's code page, not UTF-8, so a+// user folder like C:\Users\Glaúcia broke paths written into it: the script stays ASCII and+// the paths go in environment variables, which Windows hands over intact.+export function openWindowsConsole(script: string, lines: string[], env: Record<string, string> = {}): void {+ writeFileSync(script, `@echo off\r\n${lines.join('\r\n')}\r\n`)+ spawn(process.env['ComSpec'] || 'cmd.exe', ['/d', '/c', 'start', '"Tucano"', 'cmd.exe', '/k', `"${script}"`], {+ detached: true,+ stdio: 'ignore',+ windowsVerbatimArguments: true,+ env: { ...process.env, ...env }+ })+ .on('error', () => {})+ .unref()+}+diff --git a/src/renderer/src/components/Harness.tsx b/src/renderer/src/components/Harness.tsxindex 11c05af..f44d442 100644--- a/src/renderer/src/components/Harness.tsx+++ b/src/renderer/src/components/Harness.tsx@@ -265,8 +265,9 @@ function HarnessRow({ engine, st, picked, toggle }: { engine: EngineId; st: Engi)}{!st.installed && (<div className="harness__body">+ {/* npm.cmd: PowerShell blocks npm's .ps1 on a fresh Windows (scripts disabled). */}<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>+ <code className="harness__cmd">{windows ? (ENGINES[engine].windows ?? ENGINES[engine].install).replace(/^npm /, 'npm.cmd ') : ENGINES[engine].install}</code></div>)}{st.warning && <p className="hint hint--warn harness__body">{st.warning}</p>}diff --git a/test/platform.test.ts b/test/platform.test.tsindex 80fc1fe..217ca85 100644--- a/test/platform.test.ts+++ b/test/platform.test.ts@@ -1,10 +1,10 @@import { execFileSync, spawnSync } from 'node:child_process'-import { chmodSync, mkdirSync, mkdtempSync, writeFileSync } from 'node:fs'+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { delimiter, join } from 'node:path'import { describe, expect, it } from 'vitest'import { dockerProblem, ownedBack } from '../src/core/computer'-import { autostartEntry, autostartFile, chromeCandidates, executableNames, fallbackPath, findChrome, gitRoot, loginShell, onPath, osOf, shellCommand, spawnable, systemName, terminalCommand, userAgentPlatform, withInstallDirs } from '../src/core/platform'+import { autostartEntry, autostartFile, chromeCandidates, executableNames, fallbackPath, findChrome, gitRoot, loginShell, onPath, openWindowsConsole, osOf, shellCommand, spawnable, systemName, terminalCommand, userAgentPlatform, withInstallDirs } from '../src/core/platform'import { shortcut } from '../src/shared/types'const win = process.platform === 'win32'@@ -241,3 +241,16 @@ describe('folders the CLIs install into', () => {expect(withInstallDirs(local, 'mac', home, env, () => true)).toBe(local)})})++// A sign-in console on Windows, from a user folder with accents (C:\Users\Glaúcia): cmd reads+// the script in its own code page, so the paths go in the environment, not in the script.+it.skipIf(process.platform !== 'win32')('opens a sign-in console that works from a folder with accents', async () => {+ const dir = join(mkdtempSync(join(tmpdir(), 'tucano-')), 'Glaúcia Ação')+ mkdirSync(dir, { recursive: true })+ const marker = join(dir, 'ran.txt')+ openWindowsConsole(join(dir, 'login.cmd'), ['echo %TUCANO_HOME%> "%TUCANO_MARK%"', 'exit'], { TUCANO_HOME: dir, TUCANO_MARK: marker })+ for (let i = 0; i < 40 && !existsSync(marker); i++) await new Promise((r) => setTimeout(r, 250))+ expect(existsSync(marker)).toBe(true)+ // The console wrote the folder in its code page; the folder itself was found, accents and all.+ expect(readFileSync(marker, 'latin1').trim().length).toBeGreaterThan(0)+}, 20_000)