@@ -431,6 +431,21 @@ function checkedOutput(
431431 } ;
432432}
433433
434+ function recoveryCommand ( commandArgs ) {
435+ return [ binary , ...commandArgs ] . map ( recoveryCommandArgument ) . join ( " " ) ;
436+ }
437+
438+ function recoveryCommandArgument ( value ) {
439+ const text = `${ value } ` ;
440+ if ( / ^ [ A - Z a - z 0 - 9 _ . / : @ % + = , - ] + $ / u. test ( text ) ) {
441+ return text ;
442+ }
443+ if ( process . platform === "win32" ) {
444+ return `"${ text . replaceAll ( '"' , '""' ) } "` ;
445+ }
446+ return `'${ text . replaceAll ( "'" , "'\\''" ) } '` ;
447+ }
448+
434449// Probe Crabbox metadata (`--version` / `run --help`) with one generous retry.
435450// A cold Crabbox can be SIGKILLed by the snappy default timeout or emit nothing
436451// on the first call, then be instant and clean on the next. Retrying keeps the
@@ -898,6 +913,7 @@ function crabboxProviderReadiness(providerName, versionText, targetContext) {
898913 return {
899914 ready : false ,
900915 reason : `requires Crabbox >= ${ formatVersionTuple ( minimumBlacksmithCrabboxVersion ) } for Blacksmith Testbox` ,
916+ recovery : "update Crabbox, then retry" ,
901917 } ;
902918 }
903919 if (
@@ -907,10 +923,15 @@ function crabboxProviderReadiness(providerName, versionText, targetContext) {
907923 return {
908924 ready : false ,
909925 reason : `requires Crabbox >= ${ formatVersionTuple ( minimumBrokeredDaytonaCrabboxVersion ) } for brokered Daytona` ,
926+ recovery : "update Crabbox, then retry" ,
910927 } ;
911928 }
912929 if ( [ "aws" , "azure" , "daytona" ] . includes ( canonicalProvider ) && ! managedBrokerAuthConfigured ( ) ) {
913- return { ready : false , reason : "managed Crabbox broker auth unavailable" } ;
930+ return {
931+ ready : false ,
932+ reason : "managed Crabbox broker auth unavailable" ,
933+ recovery : `run \`${ recoveryCommand ( [ "login" , "--url" , "https://crabbox.openclaw.ai" ] ) } \`, then retry` ,
934+ } ;
914935 }
915936 const doctorArgs = [ "doctor" , "--provider" , canonicalProvider ] ;
916937 if ( targetContext . target ) {
@@ -922,17 +943,40 @@ function crabboxProviderReadiness(providerName, versionText, targetContext) {
922943 doctorArgs . push ( "--json" ) ;
923944 const doctor = checkedOutput ( binary , doctorArgs ) ;
924945 if ( doctor . status !== 0 ) {
925- return { ready : false , reason : `doctor exited ${ doctor . status } ` } ;
946+ const diagnostic = compactDiagnosticText ( doctor . text ) ;
947+ return {
948+ ready : false ,
949+ reason : `doctor exited ${ doctor . status } ${ diagnostic ? `: ${ diagnostic } ` : "" } ` ,
950+ recovery : `run \`${ recoveryCommand ( doctorArgs ) } \`` ,
951+ } ;
926952 }
927953 return { ready : true , reason : "doctor-ready" } ;
928954}
929955
956+ function compactDiagnosticText ( value , maxLength = 500 ) {
957+ const compact = `${ value ?? "" } ` . replace ( / \s + / gu, " " ) . trim ( ) ;
958+ if ( compact . length <= maxLength ) {
959+ return compact ;
960+ }
961+ return `${ compact . slice ( 0 , Math . max ( 0 , maxLength - 3 ) ) } ...` ;
962+ }
963+
930964function formatProviderReadiness ( readiness ) {
931965 return [ ...readiness . entries ( ) ]
932966 . map ( ( [ candidate , status ] ) => `${ candidate } :${ status . ready ? "ready" : status . reason } ` )
933967 . join ( "," ) ;
934968}
935969
970+ function providerRecoveryAdvice ( readiness ) {
971+ return [
972+ ...new Set (
973+ [ ...readiness . values ( ) ]
974+ . map ( ( status ) => status . recovery )
975+ . filter ( ( recovery ) => typeof recovery === "string" && recovery . length > 0 ) ,
976+ ) ,
977+ ] ;
978+ }
979+
936980function shouldRequireBrokeredCloud ( commandArgs , providerName , explicitProviderRequested = false ) {
937981 const canonicalProvider = canonicalProviderName ( providerName ) ;
938982 if ( ! [ "aws" , "azure" , "daytona" ] . includes ( canonicalProvider ) ) {
@@ -1012,7 +1056,7 @@ function enforceBrokeredCloud(commandArgs, providerName, explicitProviderRequest
10121056 const canonicalProvider = canonicalProviderName ( providerName ) ;
10131057 const instructions = [
10141058 `[crabbox] provider=${ canonicalProvider } requires a configured managed Crabbox broker for OpenClaw proof.` ,
1015- " [crabbox] run `crabbox login --url https://crabbox.openclaw.ai`, then retry." ,
1059+ ` [crabbox] run \` ${ recoveryCommand ( [ " login" , " --url" , " https://crabbox.openclaw.ai" ] ) } \ `, then retry.` ,
10161060 ] ;
10171061 if ( canonicalProvider !== "aws" ) {
10181062 instructions . push (
@@ -3783,13 +3827,25 @@ const version = probeCrabboxMetadata(binary, ["--version"]);
37833827const help = probeCrabboxMetadata ( binary , [ "run" , "--help" ] ) ;
37843828const providers = parseProvidersFromHelp ( help . text ) ;
37853829const displayBinary = binary === "crabbox" ? "crabbox" : relative ( repoRoot , binary ) ;
3830+
3831+ if ( version . status !== 0 || help . status !== 0 ) {
3832+ console . error (
3833+ `[crabbox] bin=${ displayBinary } version=${ version . text || "unknown" } providers=${ providers . join ( "," ) || "unknown" } ` ,
3834+ ) ;
3835+ console . error ( "[crabbox] selected binary failed basic --version/--help sanity checks" ) ;
3836+ process . exit ( 2 ) ;
3837+ }
3838+
37863839const providerSelection = selectedProvider ( args , providers , version . text ) ;
37873840if ( providerSelection . error ) {
37883841 console . error ( `[crabbox] ${ providerSelection . error } ` ) ;
37893842 if ( providerSelection . readiness ) {
37903843 console . error (
37913844 `[crabbox] provider readiness ${ formatProviderReadiness ( providerSelection . readiness ) } ` ,
37923845 ) ;
3846+ for ( const recovery of providerRecoveryAdvice ( providerSelection . readiness ) ) {
3847+ console . error ( `[crabbox] recovery: ${ recovery } ` ) ;
3848+ }
37933849 }
37943850 process . exit ( 2 ) ;
37953851}
@@ -3813,11 +3869,6 @@ if (providerSelection.source === "policy") {
38133869 ) ;
38143870}
38153871
3816- if ( version . status !== 0 || help . status !== 0 ) {
3817- console . error ( "[crabbox] selected binary failed basic --version/--help sanity checks" ) ;
3818- process . exit ( 2 ) ;
3819- }
3820-
38213872if ( provider && ! isProviderAdvertised ( provider , providers ) ) {
38223873 if ( providers . length === 0 ) {
38233874 console . error (
0 commit comments