@@ -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