@@ -93,7 +93,7 @@ public CodexCliExecutor(CodexClientConfig config) {
9393 * @return a {@link CodexCliResult} describing the outcome; never {@code null}.
9494 */
9595 public CodexCliResult execute (String ... args ) {
96- return runProcess (null , args );
96+ return runProcess (null , config . getLocalTimeoutSeconds () * 1000L , args );
9797 }
9898
9999 /**
@@ -111,10 +111,14 @@ public CodexCliResult execute(String... args) {
111111 * @return a {@link CodexCliResult} describing the outcome; never {@code null}.
112112 */
113113 public CodexCliResult executeWithStdin (String stdin , String ... args ) {
114- return runProcess (stdin , args );
114+ return runProcess (stdin , config . getLocalTimeoutSeconds () * 1000L , args );
115115 }
116116
117- private CodexCliResult runProcess (String stdin , String ... args ) {
117+ private CodexCliResult executeWithTimeoutSeconds (int timeoutSeconds , String ... args ) {
118+ return runProcess (null , timeoutSeconds * 1000L , args );
119+ }
120+
121+ private CodexCliResult runProcess (String stdin , long timeoutMs , String ... args ) {
118122 CommandLine cmd = CommandLine .parse (config .getLocalExecutable ());
119123 for (String arg : args ) {
120124 if (arg != null ) {
@@ -136,7 +140,6 @@ private CodexCliResult runProcess(String stdin, String... args) {
136140 executor .setStreamHandler (new org .apache .commons .exec .PumpStreamHandler (stdout , stderr ,
137141 new ByteArrayInputStream (stdinBytes )));
138142
139- long timeoutMs = config .getLocalTimeoutSeconds () * 1000L ;
140143 ExecuteWatchdog watchdog = new ExecuteWatchdog (timeoutMs );
141144 executor .setWatchdog (watchdog );
142145
@@ -186,7 +189,7 @@ private CodexCliResult runProcess(String stdin, String... args) {
186189 */
187190 public boolean probe () {
188191 try {
189- CodexCliResult result = execute ( "--version" );
192+ CodexCliResult result = executeWithTimeoutSeconds ( config . getLocalProbeTimeoutSeconds (), "--version" );
190193 return result .isSuccess ();
191194 } catch (Exception e ) {
192195 return false ;
0 commit comments