@@ -222,6 +222,117 @@ it.layer(layer)("OpenCodeDriver runtime selection", (it) => {
222222 } ) . pipe ( Effect . scoped ) ,
223223 ) ;
224224
225+ it . effect . each ( [
226+ "1.18.32" ,
227+ "opencode v2.0.18" ,
228+ "opencode v2.2.4" ,
229+ "opencode v2.2.5" ,
230+ "opencode v2.2.6" ,
231+ ] ) ( "advertises native goal support only for supported OpenCode versions: %s" , ( version ) =>
232+ Effect . gen ( function * ( ) {
233+ const fs = yield * FileSystem . FileSystem ;
234+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "opencode-goal-capability-" } ) ;
235+ const binaryPath = NodePath . join (
236+ root ,
237+ "lib" ,
238+ "node_modules" ,
239+ "@opencode" ,
240+ "cli" ,
241+ "bin" ,
242+ "opencode" ,
243+ ) ;
244+ yield * fs . makeDirectory ( NodePath . dirname ( binaryPath ) , { recursive : true } ) ;
245+ yield * fs . writeFileString ( binaryPath , "" ) ;
246+ const instance = yield * create ( { binaryPath } , noHttp ) . pipe (
247+ Effect . provideService ( OpenCodeRuntime . OpenCodeRuntime , {
248+ ...openCode2Runtime ,
249+ runOpenCodeCommand : ( ) => Effect . succeed ( { stdout : version , stderr : "" , code : 0 } ) ,
250+ } ) ,
251+ ) ;
252+ yield * instance . snapshot . resolveMaintenance ( { fresh : true } ) ;
253+ const capabilities = yield * instance . orchestrationAdapter . getCapabilities ( ) ;
254+ assert . equal (
255+ capabilities . turns . supportsNativeGoals === true ,
256+ version . endsWith ( "2.2.5" ) || version . endsWith ( "2.2.6" ) ,
257+ ) ;
258+ } ) . pipe ( Effect . scoped ) ,
259+ ) ;
260+
261+ it . effect ( "uses the connected OpenCode version for goal support after an upgrade" , ( ) =>
262+ Effect . gen ( function * ( ) {
263+ const fs = yield * FileSystem . FileSystem ;
264+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "opencode-upgraded-goals-" } ) ;
265+ const binaryPath = NodePath . join (
266+ root ,
267+ "lib" ,
268+ "node_modules" ,
269+ "@opencode" ,
270+ "cli" ,
271+ "bin" ,
272+ "opencode" ,
273+ ) ;
274+ yield * fs . makeDirectory ( NodePath . dirname ( binaryPath ) , { recursive : true } ) ;
275+ yield * fs . writeFileString ( binaryPath , "" ) ;
276+ const http = HttpClient . make ( ( request ) => {
277+ const path = new URL ( request . url ) . pathname ;
278+ if ( path === "/api/info" )
279+ return Effect . succeed (
280+ HttpClientResponse . fromWeb (
281+ request ,
282+ Response . json ( {
283+ ...JSON . parse ( OPENCODE_2_RESPONSES [ "/api/info" ] . body ) ,
284+ version : "2.2.5" ,
285+ } ) ,
286+ ) ,
287+ ) ;
288+ if ( path === "/api/model" )
289+ return Effect . succeed (
290+ HttpClientResponse . fromWeb (
291+ request ,
292+ Response . json ( { location : { directory : "/work" } , data : [ ] } ) ,
293+ ) ,
294+ ) ;
295+ if ( path === "/api/event" )
296+ return Effect . succeed (
297+ HttpClientResponse . fromWeb (
298+ request ,
299+ new Response ( new ReadableStream ( ) , {
300+ headers : { "content-type" : "text/event-stream" } ,
301+ } ) ,
302+ ) ,
303+ ) ;
304+ return Effect . die ( `Unexpected request: ${ path } ` ) ;
305+ } ) ;
306+ const instance = yield * create ( { binaryPath } , http ) . pipe (
307+ Effect . provideService ( OpenCodeRuntime . OpenCodeRuntime , {
308+ ...openCode2Runtime ,
309+ runOpenCodeCommand : ( ) =>
310+ Effect . succeed ( { stdout : "opencode v2.2.4" , stderr : "" , code : 0 } ) ,
311+ startOpenCodeServerProcess : ( { verify } ) =>
312+ Effect . gen ( function * ( ) {
313+ const url = "http://127.0.0.1:4096" ;
314+ const version = verify ? yield * verify ( url ) : "2.2.5" ;
315+ return { url, version, isRunning : Effect . succeed ( true ) , exitCode : Effect . never } ;
316+ } ) ,
317+ } ) ,
318+ ) ;
319+ yield * instance . snapshot . resolveMaintenance ( { fresh : true } ) ;
320+ assert . isFalse (
321+ ( yield * instance . orchestrationAdapter . getCapabilities ( ) ) . turns . supportsNativeGoals ,
322+ ) ;
323+ const session = yield * instance . orchestrationAdapter . openSession ( {
324+ threadId : ThreadId . make ( "upgraded-goal" ) ,
325+ providerSessionId : ProviderSessionId . make ( "upgraded-goal" ) ,
326+ modelSelection : { instanceId : instance . instanceId , model : "opencode/big-pickle" } ,
327+ runtimePolicy : { runtimeMode : "full-access" , interactionMode : "default" , cwd : null } ,
328+ } ) ;
329+ assert . isTrue ( session . providerSession . capabilities . turns . supportsNativeGoals ) ;
330+ assert . isTrue (
331+ ( yield * instance . orchestrationAdapter . getCapabilities ( ) ) . turns . supportsNativeGoals ,
332+ ) ;
333+ } ) . pipe ( Effect . scoped ) ,
334+ ) ;
335+
225336 it . effect ( "answers capability reads without waiting on an unreachable server" , ( ) =>
226337 Effect . gen ( function * ( ) {
227338 const hang = HttpClient . make ( ( ) => Effect . never ) ;
0 commit comments