Skip to content

Commit 1128e0e

Browse files
authored
fix(spawn): run agent directly via ssh instead of attaching tmux (#22)
1 parent f3a0c91 commit 1128e0e

2 files changed

Lines changed: 33 additions & 20 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
import * as _9 from "@effect/cli"
34
import * as _1 from "@effect/cluster"
45
import * as _2 from "@effect/experimental"
56
import * as _3 from "@effect/printer"
@@ -8,15 +9,14 @@ import * as _5 from "@effect/rpc"
89
import * as _6 from "@effect/sql"
910
import * as _7 from "@effect/typeclass"
1011
import * as _8 from "@effect/workflow"
11-
import * as _9 from "@effect/cli"
12-
13-
export const _dummyDeps = [_1, _2, _3, _4, _5, _6, _7, _8, _9]
1412

1513
import { NodeContext, NodeRuntime } from "@effect/platform-node"
1614
import { Effect } from "effect"
1715

1816
import { program } from "./program.js"
1917

18+
export const _dummyDeps = [_1, _2, _3, _4, _5, _6, _7, _8, _9]
19+
2020
// CHANGE: run docker-git CLI through the Node runtime
2121
// WHY: ensure platform services (FS, Path, Command) are available in app CLI
2222
// QUOTE(ТЗ): "CLI (отображение, фронт) это app"

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,35 @@ const buildSpawnCreateCommand = (outDir: string, force: boolean): CreateCommand
119119
}
120120
}
121121

122+
const spawnAttachDirect = (
123+
template: TemplateConfig,
124+
projectDir: string,
125+
sshKey: string | null,
126+
ipAddress: string | undefined
127+
): Effect.Effect<void, CommandFailedError | PlatformError, CommandExecutor.CommandExecutor> =>
128+
Effect.gen(function*(_) {
129+
yield* _(Effect.log("Starting opencode directly via SSH..."))
130+
yield* _(
131+
runCommandWithExitCodes(
132+
{
133+
cwd: process.cwd(),
134+
command: "ssh",
135+
args: buildSshArgs(
136+
template,
137+
sshKey,
138+
ipAddress,
139+
`cd '${projectDir}' && spawn-dock agent`
140+
).filter((arg) =>
141+
arg !== "-T" && arg !== "-o" && arg !== "BatchMode=yes" && arg !== "ConnectTimeout=2" &&
142+
arg !== "ConnectionAttempts=1"
143+
)
144+
},
145+
[0, 255], // SSH frequently exits with 255 on user disconnect, which is normal
146+
(exitCode) => new CommandFailedError({ command: "ssh agent", exitCode })
147+
)
148+
)
149+
})
150+
122151
// CHANGE: orchestrate spawn-dock spawn — creates container, runs @spawn-dock/create, opens tmux+opencode
123152
// WHY: provide one-command bootstrap from a Telegram bot pairing token
124153
// REF: spawn-command
@@ -173,21 +202,5 @@ export const spawnProject = (command: SpawnCommand) =>
173202

174203
yield* _(Effect.log(`Project bootstrapped at ${projectDir}`))
175204

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-
)
205+
yield* _(spawnAttachDirect(template, projectDir, sshKey, ipAddress))
193206
})

0 commit comments

Comments
 (0)