Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/daily-awf-spec-compiler-surfacing.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .github/workflows/daily-doc-updater.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions pkg/workflow/docker_sbx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,40 @@ func TestDockerSbxEngineCLIWiring(t *testing.T) {
execContent := strings.Join(execSteps[0], "\n")
assert.Contains(t, execContent, `export PATH="${RUNNER_TEMP}/gh-aw/engine-cli/bin:$PATH"`)
})

t.Run("pi install and execution use sbx-visible CLI path", func(t *testing.T) {
engine := NewPiEngine()
workflowData.EngineConfig = &EngineConfig{ID: "pi"}
installSteps := engine.GetInstallationSteps(workflowData)
installContent := strings.Join(flattenSteps(installSteps), "\n")
assert.Contains(t, installContent, `npm install --ignore-scripts --prefix "${RUNNER_TEMP}/gh-aw/engine-cli" @earendil-works/pi-coding-agent@`+string(constants.DefaultPiVersion))
assert.Contains(t, installContent, `ln -sf "../node_modules/.bin/pi" "${RUNNER_TEMP}/gh-aw/engine-cli/bin/pi"`)

execSteps := engine.GetExecutionSteps(workflowData, "/tmp/gh-aw/test.log")
require.NotEmpty(t, execSteps)
execContent := strings.Join(execSteps[0], "\n")
assert.Contains(t, execContent, `export PATH="${RUNNER_TEMP}/gh-aw/engine-cli/bin:$PATH"`)
})

t.Run("pi execution uses sbx-visible CLI path even with firewall disabled", func(t *testing.T) {
// sandbox.agent.runtime: docker-sbx can be configured alongside an explicit
// network.firewall: false, which takes the non-AWF execution path. The
// staged CLI PATH export must still be present so the microVM can see `pi`.
nonFirewallWorkflowData := &WorkflowData{
Name: "test-workflow",
EngineConfig: &EngineConfig{ID: "pi"},
SandboxConfig: &SandboxConfig{Agent: &AgentSandboxConfig{ID: "awf", Runtime: AgentRuntimeDockerSbx, SudoExplicitlyEnabled: true}},
NetworkPermissions: &NetworkPermissions{
Firewall: &FirewallConfig{Enabled: false},
},
}

engine := NewPiEngine()
execSteps := engine.GetExecutionSteps(nonFirewallWorkflowData, "/tmp/gh-aw/test.log")
require.NotEmpty(t, execSteps)
execContent := strings.Join(execSteps[0], "\n")
assert.Contains(t, execContent, `export PATH="${RUNNER_TEMP}/gh-aw/engine-cli/bin:$PATH"`)
})
}

// flattenSteps joins a small slice of GitHubActionStep values so docker-sbx tests can
Expand Down
22 changes: 22 additions & 0 deletions pkg/workflow/pi_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ func (e *PiEngine) GetInstallationSteps(workflowData *WorkflowData) []GitHubActi
},
)

// microVM runtimes (docker-sbx/cloud-hypervisor) cannot see the globally installed
// CLI in the hosted tool cache, so stage a second copy under RUNNER_TEMP.
if isDockerSbxRuntime(workflowData) || isCloudHypervisorRuntime(workflowData) {
npmSteps = append(npmSteps, GenerateDockerSbxNpmCLIInstallStep(
"@earendil-works/pi-coding-agent",
version,
"Install Pi CLI in docker-sbx path",
"pi",
false,
false,
))
}

steps := BuildNpmEngineInstallStepsWithAWF(npmSteps, workflowData)

// Install extensions declared in engine.extensions: [...]
Expand Down Expand Up @@ -369,6 +382,9 @@ func (e *PiEngine) buildPiCommand(workflowData *WorkflowData, commandName string
func (e *PiEngine) buildPiExecutionCommand(workflowData *WorkflowData, logFile, piCommand string, firewallEnabled, modelConfigured bool, profile universalLLMBackendProfile) string {
if firewallEnabled {
piCommandWithPath := fmt.Sprintf("%s && %s", GetNpmBinPathSetup(), piCommand)
if dockerSbxCLIPath := GetDockerSbxNpmCLIPathSetup(workflowData); dockerSbxCLIPath != "" {
piCommandWithPath = fmt.Sprintf("%s && %s", dockerSbxCLIPath, piCommandWithPath)
}
if mcpCLIPath := GetMCPCLIPathSetup(workflowData); mcpCLIPath != "" {
piCommandWithPath = fmt.Sprintf("%s && %s", mcpCLIPath, piCommandWithPath)
}
Expand All @@ -386,6 +402,12 @@ func (e *PiEngine) buildPiExecutionCommand(workflowData *WorkflowData, logFile,
ExcludeEnvVarNames: ComputeAWFExcludeEnvVarNames(workflowData, profile.coreSecretNames),
})
}
// Even without AWF, a docker-sbx/cloud-hypervisor runtime can be configured
// (e.g. network.firewall: false paired with sandbox.agent.runtime: docker-sbx),
// so the staged CLI path must still be exported for the microVM to see `pi`.
if dockerSbxCLIPath := GetDockerSbxNpmCLIPathSetup(workflowData); dockerSbxCLIPath != "" {
piCommand = fmt.Sprintf("%s && %s", dockerSbxCLIPath, piCommand)
}
return fmt.Sprintf(`set -o pipefail
printf '%%s' "$(date +%%s%%3N)" > %s
touch %s
Expand Down