Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

Fix Windows agent spawn (error 193): route .cmd/script shims through cmd.exe

Jason Choplinaadffacf797b
diff --git a/src/main/assistant.ts b/src/main/assistant.ts
index ffe1ba15..ecc1363f 100644
--- a/src/main/assistant.ts
+++ b/src/main/assistant.ts
@@ -123,7 +123,17 @@ export function enrichMessage(req: EnrichRequest): Promise<EnrichResult> {
let child;
try {
- child = spawn(exe, args, {
+ // Windows: route the npm `.cmd`/extensionless `claude` shim through cmd.exe;
+ // CreateProcess can't exec it directly (EINVAL on modern Node / error 193).
+ // The prompt rides in `args`; cmd leaves quoted args intact aside from %VAR%
+ // expansion (a follow-up could pass the prompt via stdin to avoid even that).
+ let spawnFile = exe;
+ let spawnArgs = args;
+ if (process.platform === 'win32' && !/\.(exe|com)$/i.test(exe)) {
+ spawnFile = process.env.ComSpec || 'cmd.exe';
+ spawnArgs = ['/c', exe, ...args];
+ }
+ child = spawn(spawnFile, spawnArgs, {
cwd: req.cwd,
env: {
...process.env,
diff --git a/src/main/pty.ts b/src/main/pty.ts
index 801ff911..03162cdc 100644
--- a/src/main/pty.ts
+++ b/src/main/pty.ts
@@ -130,7 +130,18 @@ export class PtyManager {
}
})();
- const proc = pty.spawn(resolved, opts.args ?? [], {
+ // Windows: node-pty's CreateProcess can't run the npm `.cmd`/extensionless
+ // `claude` shim directly (ERROR_BAD_EXE_FORMAT, error 193). Route non-.exe
+ // targets through cmd.exe so PATHEXT resolves the shim. This also covers the
+ // auto-spawned GOD agent's hardcoded command. A real claude.exe (WinGet)
+ // matches the .exe guard and still launches directly.
+ let file = resolved;
+ let spawnArgs = opts.args ?? [];
+ if (process.platform === 'win32' && !/\.(exe|com)$/i.test(resolved)) {
+ file = process.env.ComSpec || 'cmd.exe';
+ spawnArgs = ['/c', opts.command, ...(opts.args ?? [])];
+ }
+ const proc = pty.spawn(file, spawnArgs, {
name: 'xterm-256color',
cols: opts.cols ?? 100,
rows: opts.rows ?? 30,
diff --git a/src/main/reflect.ts b/src/main/reflect.ts
index 10222336..a3e84e34 100644
--- a/src/main/reflect.ts
+++ b/src/main/reflect.ts
@@ -291,7 +291,17 @@ export class MemoryReflector {
let child;
try {
- child = spawn(exe, args, {
+ // Windows: route the npm `.cmd`/extensionless `claude` shim through cmd.exe;
+ // CreateProcess can't exec it directly (EINVAL on modern Node / error 193).
+ // The prompt rides in `args`; cmd leaves quoted args intact aside from %VAR%
+ // expansion (a follow-up could pass the prompt via stdin to avoid even that).
+ let spawnFile = exe;
+ let spawnArgs = args;
+ if (process.platform === 'win32' && !/\.(exe|com)$/i.test(exe)) {
+ spawnFile = process.env.ComSpec || 'cmd.exe';
+ spawnArgs = ['/c', exe, ...args];
+ }
+ child = spawn(spawnFile, spawnArgs, {
cwd: home,
env: { ...process.env, PATH: userShellPath(), ...this.getMemoryEnv() } as Record<string, string>,
stdio: ['ignore', 'pipe', 'pipe']