@@ -19,40 +19,56 @@ import { extract } from "tar";
1919const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
2020const DEST_DIR = join ( __dirname , ".." , "resources" , "codex-acp" ) ;
2121
22- const BINARIES = [
23- {
24- name : "codex" ,
25- version : "0.144.0" ,
26- getUrl : ( version , target ) => {
27- if ( target . includes ( "windows" ) ) {
28- return `https://github.com/openai/codex/releases/download/rust-v ${ version } /codex- ${ target } .exe.zip` ;
29- }
30- return `https://github.com/openai/codex/releases/download/rust-v ${ version } /codex- ${ target } .tar.gz` ;
22+ const CODEX_VERSION = "0.144.0" ;
23+
24+ function nativeTarget ( ) {
25+ const { platform , arch } = process ;
26+ const targets = {
27+ darwin : { arm64 : "aarch64-apple-darwin" , x64 : "x86_64-apple-darwin" } ,
28+ linux : {
29+ arm64 : "aarch64-unknown-linux-musl" ,
30+ x64 : "x86_64-unknown-linux-musl" ,
3131 } ,
32- getTarget : ( ) => {
33- const { platform, arch } = process ;
34- const targets = {
35- darwin : { arm64 : "aarch64-apple-darwin" , x64 : "x86_64-apple-darwin" } ,
36- linux : {
37- arm64 : "aarch64-unknown-linux-musl" ,
38- x64 : "x86_64-unknown-linux-musl" ,
39- } ,
40- win32 : {
41- arm64 : "aarch64-pc-windows-msvc" ,
42- x64 : "x86_64-pc-windows-msvc" ,
43- } ,
44- } ;
45- const platformTargets = targets [ platform ] ;
46- if ( ! platformTargets )
47- throw new Error ( `Unsupported platform: ${ platform } ` ) ;
48- const target = platformTargets [ arch ] ;
49- if ( ! target ) throw new Error ( `Unsupported arch: ${ arch } ` ) ;
50- return target ;
32+ win32 : {
33+ arm64 : "aarch64-pc-windows-msvc" ,
34+ x64 : "x86_64-pc-windows-msvc" ,
5135 } ,
52- // The codex release archive contains a target-suffixed binary
53- // (e.g. `codex-aarch64-apple-darwin`); rename it to `codex` after extract.
54- archiveBinaryName : ( target ) =>
55- process . platform === "win32" ? `codex-${ target } .exe` : `codex-${ target } ` ,
36+ } ;
37+ const target = targets [ platform ] ?. [ arch ] ;
38+ if ( ! target ) throw new Error ( `Unsupported platform: ${ platform } /${ arch } ` ) ;
39+ return target ;
40+ }
41+
42+ function codexReleaseUrl ( binary , version , target ) {
43+ const suffix = target . includes ( "windows" ) ? ".exe.zip" : ".tar.gz" ;
44+ return `https://github.com/openai/codex/releases/download/rust-v${ version } /${ binary } -${ target } ${ suffix } ` ;
45+ }
46+
47+ // Codex release archives contain a target-suffixed binary
48+ // (e.g. `codex-aarch64-apple-darwin`); rename it after extract.
49+ const codexArchiveBinaryName = ( binary ) => ( target ) =>
50+ target . includes ( "windows" )
51+ ? `${ binary } -${ target } .exe`
52+ : `${ binary } -${ target } ` ;
53+
54+ export const BINARIES = [
55+ {
56+ name : "codex" ,
57+ version : CODEX_VERSION ,
58+ getUrl : ( version , target ) => codexReleaseUrl ( "codex" , version , target ) ,
59+ getTarget : nativeTarget ,
60+ archiveBinaryName : codexArchiveBinaryName ( "codex" ) ,
61+ } ,
62+ {
63+ // codex resolves this host as a sibling of its own executable and routes
64+ // all command execution through it for code-mode models (gpt-5.6+). It is
65+ // released per codex version, so it must stay in lockstep with `codex`.
66+ name : "codex-code-mode-host" ,
67+ version : CODEX_VERSION ,
68+ getUrl : ( version , target ) =>
69+ codexReleaseUrl ( "codex-code-mode-host" , version , target ) ,
70+ getTarget : nativeTarget ,
71+ archiveBinaryName : codexArchiveBinaryName ( "codex-code-mode-host" ) ,
5672 } ,
5773 {
5874 name : "rg" ,
@@ -61,26 +77,7 @@ const BINARIES = [
6177 const ext = target . includes ( "windows" ) ? "zip" : "tar.gz" ;
6278 return `https://github.com/microsoft/ripgrep-prebuilt/releases/download/v${ version } /ripgrep-v${ version } -${ target } .${ ext } ` ;
6379 } ,
64- getTarget : ( ) => {
65- const { platform, arch } = process ;
66- const targets = {
67- darwin : { arm64 : "aarch64-apple-darwin" , x64 : "x86_64-apple-darwin" } ,
68- linux : {
69- arm64 : "aarch64-unknown-linux-musl" ,
70- x64 : "x86_64-unknown-linux-musl" ,
71- } ,
72- win32 : {
73- arm64 : "aarch64-pc-windows-msvc" ,
74- x64 : "x86_64-pc-windows-msvc" ,
75- } ,
76- } ;
77- const platformTargets = targets [ platform ] ;
78- if ( ! platformTargets )
79- throw new Error ( `Unsupported platform: ${ platform } ` ) ;
80- const target = platformTargets [ arch ] ;
81- if ( ! target ) throw new Error ( `Unsupported arch: ${ arch } ` ) ;
82- return target ;
83- } ,
80+ getTarget : nativeTarget ,
8481 } ,
8582] ;
8683
@@ -143,10 +140,10 @@ function signForMacOS(binaryPath) {
143140 execSync ( `codesign --force --sign - "${ binaryPath } "` , { stdio : "pipe" } ) ;
144141}
145142
146- async function downloadBinary ( binary ) {
143+ export async function downloadBinary ( binary , destDir = DEST_DIR ) {
147144 const binaryName =
148145 process . platform === "win32" ? `${ binary . name } .exe` : binary . name ;
149- const binaryPath = join ( DEST_DIR , binaryName ) ;
146+ const binaryPath = join ( destDir , binaryName ) ;
150147
151148 console . log ( `\n[${ binary . name } ] v${ binary . version } ` ) ;
152149
@@ -158,16 +155,16 @@ async function downloadBinary(binary) {
158155 const target = binary . getTarget ( ) ;
159156 const url = binary . getUrl ( binary . version , target ) ;
160157 const archiveName = `${ binary . name } -archive${ url . endsWith ( ".zip" ) ? ".zip" : ".tar.gz" } ` ;
161- const archivePath = join ( DEST_DIR , archiveName ) ;
158+ const archivePath = join ( destDir , archiveName ) ;
162159
163160 console . log ( ` Platform: ${ process . platform } /${ process . arch } -> ${ target } ` ) ;
164161
165162 await downloadFile ( url , archivePath ) ;
166- await extractArchive ( archivePath , DEST_DIR ) ;
163+ await extractArchive ( archivePath , destDir ) ;
167164 rmSync ( archivePath ) ;
168165
169166 if ( binary . archiveBinaryName ) {
170- const extractedPath = join ( DEST_DIR , binary . archiveBinaryName ( target ) ) ;
167+ const extractedPath = join ( destDir , binary . archiveBinaryName ( target ) ) ;
171168 if ( extractedPath !== binaryPath && existsSync ( extractedPath ) ) {
172169 renameSync ( extractedPath , binaryPath ) ;
173170 }
0 commit comments