MCPcopy Create free account
hub / github.com/github/gh-aw / buildCopilotExecPrefix

Method buildCopilotExecPrefix

pkg/workflow/copilot_engine_execution.go:304–329  ·  view source on GitHub ↗
(workflowData *WorkflowData, commandName string)

Source from the content-addressed store, hash-verified

302}
303
304func (e *CopilotEngine) buildCopilotExecPrefix(workflowData *WorkflowData, commandName string) string {
305 // Build the command - model is always passed via COPILOT_MODEL env var (see env block below).
306 // The --add-dir "${GITHUB_WORKSPACE}" arg is appended raw (not through shellJoinArgs)
307 // because it contains a shell variable reference that must expand at runtime.
308 //
309 // When a harness script is provided (GetHarnessScriptName), wrap the copilot invocation with
310 // `node <harness> <commandName> <args>` to enable retry logic for transient CAPIError 400 errors.
311 //
312 // Resolve node dynamically at runtime:
313 // - Prefer GH_AW_NODE_BIN when set and executable.
314 // - Fall back to `command -v node` if GH_AW_NODE_BIN points to a non-mounted toolcache path.
315 // This prevents agent startup failures when host toolcache paths are not present in the AWF container.
316 harnessScriptName := e.GetHarnessScriptName()
317 if workflowData.EngineConfig != nil && workflowData.EngineConfig.HarnessScript != "" {
318 harnessScriptName = workflowData.EngineConfig.HarnessScript
319 }
320 if harnessScriptName == "" {
321 return commandName
322 }
323 runtimeResolutionCommand := nodeRuntimeResolutionCommand
324 if workflowData.EngineConfig != nil && workflowData.EngineConfig.CopilotSDK {
325 runtimeResolutionCommand = nodeRuntimeResolutionCommandForCopilotSDK
326 return e.buildCopilotSDKExecPrefix(workflowData, commandName, harnessScriptName, runtimeResolutionCommand)
327 }
328 return fmt.Sprintf(`%s %s/%s %s`, runtimeResolutionCommand, SetupActionDestinationShell, harnessScriptName, commandName)
329}
330
331func (e *CopilotEngine) buildCopilotSDKExecPrefix(workflowData *WorkflowData, commandName, harnessScriptName, runtimeResolutionCommand string) string {
332 sdkDriverScriptName := "copilot_sdk_driver.cjs"

Callers 1

GetExecutionStepsMethod · 0.95

Calls 2

GetHarnessScriptNameMethod · 0.95

Tested by

no test coverage detected