Skip to content

Commit f3a0c91

Browse files
authored
fix(spawn): run agent directly via ssh instead of attaching tmux (#20)
* fix(spawn): run agent directly via ssh instead of attaching tmux * chore: version bump for spawn-dock tmux fix
1 parent 695eaaa commit f3a0c91

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

.changeset/remove-tmux.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@spawn-dock/cli": patch
3+
---
4+
5+
fix: execute agent directly via ssh instead of attaching tmux in spawn command

packages/app/src/docker-git/spawn.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import {
1111
type TemplateConfig
1212
} from "@effect-template/lib/core/domain"
1313
import type { SpawnCommand } from "@effect-template/lib/core/spawn-domain"
14-
import { runCommandCapture, runCommandExitCode } from "@effect-template/lib/shell/command-runner"
14+
import { runCommandCapture, runCommandExitCode, runCommandWithExitCodes } from "@effect-template/lib/shell/command-runner"
1515
import { readProjectConfig } from "@effect-template/lib/shell/config"
1616
import { CommandFailedError, SpawnProjectDirError, SpawnSetupError } from "@effect-template/lib/shell/errors"
1717
import { createProject } from "@effect-template/lib/usecases/actions"
1818
import { findSshPrivateKey } from "@effect-template/lib/usecases/path-helpers"
1919
import { getContainerIpIfInsideContainer } from "@effect-template/lib/usecases/projects-core"
2020

21-
import { spawnAttachTmux } from "./tmux.js"
22-
2321
const SPAWNDOCK_REPO_URL = "https://github.com/SpawnDock/tma-project"
2422
const SPAWNDOCK_REPO_REF = "main"
2523

@@ -174,5 +172,22 @@ export const spawnProject = (command: SpawnCommand) =>
174172
}
175173

176174
yield* _(Effect.log(`Project bootstrapped at ${projectDir}`))
177-
yield* _(spawnAttachTmux(template, projectDir, sshKey))
175+
176+
yield* _(Effect.log("Starting opencode directly via SSH..."))
177+
yield* _(
178+
runCommandWithExitCodes(
179+
{
180+
cwd: process.cwd(),
181+
command: "ssh",
182+
args: buildSshArgs(
183+
template,
184+
sshKey,
185+
ipAddress,
186+
`cd '${projectDir}' && spawn-dock agent`
187+
).filter((arg) => arg !== "-T" && arg !== "-o" && arg !== "BatchMode=yes" && arg !== "ConnectTimeout=2" && arg !== "ConnectionAttempts=1")
188+
},
189+
[0, 255], // SSH frequently exits with 255 on user disconnect, which is normal
190+
(exitCode) => new CommandFailedError({ command: "ssh agent", exitCode })
191+
)
192+
)
178193
})

0 commit comments

Comments
 (0)