@@ -135,6 +135,22 @@ const owpenbotTargetName = owpenbotTargetTriple
135135 : null ;
136136const owpenbotTargetPath = owpenbotTargetName ? join ( sidecarDir , owpenbotTargetName ) : null ;
137137const owpenbotDir = resolve ( __dirname , ".." , ".." , "owpenbot" ) ;
138+
139+ // openwrk paths
140+ const openwrkBaseName = "openwrk" ;
141+ const openwrkName = process . platform === "win32" ? `${ openwrkBaseName } .exe` : openwrkBaseName ;
142+ const openwrkPath = join ( sidecarDir , openwrkName ) ;
143+ const openwrkBuildName = bunTarget
144+ ? `${ openwrkBaseName } -${ bunTarget } ${ bunTarget . includes ( "windows" ) ? ".exe" : "" } `
145+ : openwrkName ;
146+ const openwrkBuildPath = join ( sidecarDir , openwrkBuildName ) ;
147+ const openwrkTargetTriple = resolvedTargetTriple ;
148+ const openwrkTargetName = openwrkTargetTriple
149+ ? `${ openwrkBaseName } -${ openwrkTargetTriple } ${ openwrkTargetTriple . includes ( "windows" ) ? ".exe" : "" } `
150+ : null ;
151+ const openwrkTargetPath = openwrkTargetName ? join ( sidecarDir , openwrkTargetName ) : null ;
152+ const openwrkDir = resolve ( __dirname , ".." , ".." , "headless" ) ;
153+
138154const readHeader = ( filePath , length = 256 ) => {
139155 const fd = openSync ( filePath , "r" ) ;
140156 try {
@@ -485,6 +501,57 @@ if (existsSync(owpenbotBuildPath)) {
485501 }
486502}
487503
504+ // Build openwrk sidecar
505+ const shouldBuildOpenwrk = ! existsSync ( openwrkBuildPath ) || isStubBinary ( openwrkBuildPath ) ;
506+ if ( shouldBuildOpenwrk ) {
507+ mkdirSync ( sidecarDir , { recursive : true } ) ;
508+ if ( existsSync ( openwrkBuildPath ) ) {
509+ try {
510+ unlinkSync ( openwrkBuildPath ) ;
511+ } catch {
512+ // ignore
513+ }
514+ }
515+ // openwrk uses bun build --compile directly
516+ const openwrkCliPath = resolve ( openwrkDir , "src" , "cli.ts" ) ;
517+ if ( ! existsSync ( openwrkCliPath ) ) {
518+ console . error ( `Openwrk CLI source not found at ${ openwrkCliPath } ` ) ;
519+ process . exit ( 1 ) ;
520+ }
521+ const openwrkArgs = [ "build" , "--compile" , openwrkCliPath , "--outfile" , openwrkBuildPath ] ;
522+ if ( bunTarget ) {
523+ openwrkArgs . push ( "--target" , bunTarget ) ;
524+ }
525+ const result = spawnSync ( "bun" , openwrkArgs , { cwd : openwrkDir , stdio : "inherit" } ) ;
526+ if ( result . status !== 0 ) {
527+ process . exit ( result . status ?? 1 ) ;
528+ }
529+ }
530+
531+ if ( existsSync ( openwrkBuildPath ) ) {
532+ const shouldCopyCanonical = ! existsSync ( openwrkPath ) || isStubBinary ( openwrkPath ) ;
533+ if ( shouldCopyCanonical && openwrkBuildPath !== openwrkPath ) {
534+ try {
535+ if ( existsSync ( openwrkPath ) ) unlinkSync ( openwrkPath ) ;
536+ } catch {
537+ // ignore
538+ }
539+ copyFileSync ( openwrkBuildPath , openwrkPath ) ;
540+ }
541+
542+ if ( openwrkTargetPath ) {
543+ const shouldCopyTarget = ! existsSync ( openwrkTargetPath ) || isStubBinary ( openwrkTargetPath ) ;
544+ if ( shouldCopyTarget && openwrkBuildPath !== openwrkTargetPath ) {
545+ try {
546+ if ( existsSync ( openwrkTargetPath ) ) unlinkSync ( openwrkTargetPath ) ;
547+ } catch {
548+ // ignore
549+ }
550+ copyFileSync ( openwrkBuildPath , openwrkTargetPath ) ;
551+ }
552+ }
553+ }
554+
488555const openworkServerVersion = ( ( ) => {
489556 try {
490557 const raw = readFileSync ( resolve ( openworkServerDir , "package.json" ) , "utf8" ) ;
@@ -494,6 +561,15 @@ const openworkServerVersion = (() => {
494561 }
495562} ) ( ) ;
496563
564+ const openwrkVersion = ( ( ) => {
565+ try {
566+ const raw = readFileSync ( resolve ( openwrkDir , "package.json" ) , "utf8" ) ;
567+ return String ( JSON . parse ( raw ) . version ?? "" ) . trim ( ) ;
568+ } catch {
569+ return null ;
570+ }
571+ } ) ( ) ;
572+
497573const versions = {
498574 opencode : {
499575 version : normalizedOpencodeVersion ,
@@ -507,6 +583,10 @@ const versions = {
507583 version : expectedOwpenbotVersion ,
508584 sha256 : existsSync ( owpenbotPath ) ? sha256File ( owpenbotPath ) : null ,
509585 } ,
586+ openwrk : {
587+ version : openwrkVersion ,
588+ sha256 : existsSync ( openwrkPath ) ? sha256File ( openwrkPath ) : null ,
589+ } ,
510590} ;
511591
512592const missing = Object . entries ( versions )
0 commit comments