Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remove-tmux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spawn-dock/cli": patch
---

fix: execute agent directly via ssh instead of attaching tmux in spawn command
23 changes: 19 additions & 4 deletions packages/app/src/docker-git/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ import {
type TemplateConfig
} from "@effect-template/lib/core/domain"
import type { SpawnCommand } from "@effect-template/lib/core/spawn-domain"
import { runCommandCapture, runCommandExitCode } from "@effect-template/lib/shell/command-runner"
import { runCommandCapture, runCommandExitCode, runCommandWithExitCodes } from "@effect-template/lib/shell/command-runner"
import { readProjectConfig } from "@effect-template/lib/shell/config"
import { CommandFailedError, SpawnProjectDirError, SpawnSetupError } from "@effect-template/lib/shell/errors"
import { createProject } from "@effect-template/lib/usecases/actions"
import { findSshPrivateKey } from "@effect-template/lib/usecases/path-helpers"
import { getContainerIpIfInsideContainer } from "@effect-template/lib/usecases/projects-core"

import { spawnAttachTmux } from "./tmux.js"

const SPAWNDOCK_REPO_URL = "https://github.com/SpawnDock/tma-project"
const SPAWNDOCK_REPO_REF = "main"

Expand Down Expand Up @@ -174,5 +172,22 @@ export const spawnProject = (command: SpawnCommand) =>
}

yield* _(Effect.log(`Project bootstrapped at ${projectDir}`))
yield* _(spawnAttachTmux(template, projectDir, sshKey))

yield* _(Effect.log("Starting opencode directly via SSH..."))
yield* _(
runCommandWithExitCodes(
{
cwd: process.cwd(),
command: "ssh",
args: buildSshArgs(
template,
sshKey,
ipAddress,
`cd '${projectDir}' && spawn-dock agent`
).filter((arg) => arg !== "-T" && arg !== "-o" && arg !== "BatchMode=yes" && arg !== "ConnectTimeout=2" && arg !== "ConnectionAttempts=1")
},
[0, 255], // SSH frequently exits with 255 on user disconnect, which is normal
(exitCode) => new CommandFailedError({ command: "ssh agent", exitCode })
)
)
})
Loading