77 "context"
88 "encoding/json"
99 "fmt"
10+ "net/url"
1011 "os"
1112 "os/signal"
1213 "strings"
@@ -112,8 +113,9 @@ func runEngine(cmd *cobra.Command, args []string) error {
112113 // Determine owner/repo and API base URL
113114 parts := strings .SplitN (repoNWO , "/" , 2 )
114115 owner , repo := parts [0 ], parts [1 ]
116+ parsedURL , _ := url .Parse (serverURL )
115117 apiBaseURL := serverURL + "/api/v3"
116- if strings . Contains ( serverURL , " github.com" ) {
118+ if parsedURL != nil && ( parsedURL . Host == "github.com" || parsedURL . Host == "www. github.com" ) {
117119 apiBaseURL = "https://api.github.com"
118120 }
119121
@@ -125,13 +127,15 @@ func runEngine(cmd *cobra.Command, args []string) error {
125127
126128 branchName := fmt .Sprintf ("engine-cli-test-%d" , time .Now ().UnixNano ())
127129
128- // Create branch with empty commit and draft PR
130+ // Create branch with empty commit and PR (best-effort — may fail if token lacks permissions)
129131 setup , err := setupBranchAndPR (apiBaseURL , githubToken , owner , repo , branchName , defaultBranch ,
130132 fmt .Sprintf ("[engine-cli] %s" , truncate (problemStatement , 60 )),
131133 fmt .Sprintf ("**Problem:** %s\n \n _Created by engine-cli test harness._" , problemStatement ),
132134 )
133135 if err != nil {
134- return fmt .Errorf ("failed to set up branch and PR: %w" , err )
136+ fmt .Fprintf (os .Stderr , " warning: could not pre-create branch/PR: %v\n " , err )
137+ fmt .Fprintf (os .Stderr , " (the engine will create the branch on push)\n " )
138+ setup = & SetupResult {BranchName : branchName }
135139 }
136140
137141 // Create mock server
@@ -168,17 +172,20 @@ func runEngine(cmd *cobra.Command, args []string) error {
168172 PRDescription string `json:"pr_description"`
169173 }
170174 if json .Unmarshal (event .Content , & ev ) == nil && (ev .PRTitle != "" || ev .PRDescription != "" ) {
171- _ = updatePullRequest (apiBaseURL , githubToken , owner , repo , prNumber , ev .PRTitle , ev .PRDescription )
175+ if err := updatePullRequest (apiBaseURL , githubToken , owner , repo , prNumber , ev .PRTitle , ev .PRDescription ); err != nil {
176+ fmt .Fprintf (os .Stderr , " warning: failed to update PR: %v\n " , err )
177+ }
172178 }
173179 }
174180
175181 if engineLogs {
182+ // Track all events as suppressed when in engine-logs mode
183+ suppressedCounts [eventKey {event .Namespace , kind }]++
176184 return
177185 }
178186
179187 // Try to print the event; if nothing was printed, track it
180188 if ! printEvent (event ) {
181- kind := resolveKind (event .Kind , event .Content )
182189 suppressedCounts [eventKey {event .Namespace , kind }]++
183190 }
184191 },
@@ -245,12 +252,18 @@ func runEngine(cmd *cobra.Command, args []string) error {
245252 },
246253 }
247254
255+ inferenceURL := os .Getenv ("GITHUB_INFERENCE_URL" )
256+ if inferenceURL == "" {
257+ inferenceURL = "https://api.githubcopilot.com"
258+ }
259+
248260 env := runner.Environment {
249261 JobID : jobID ,
250262 APIToken : githubToken ,
251263 APIURL : apiURL ,
252264 JobNonce : mockServer .Nonce (),
253265 InferenceToken : githubToken ,
266+ InferenceURL : inferenceURL ,
254267 GitToken : githubToken ,
255268 }
256269
0 commit comments