@@ -2,11 +2,7 @@ package workflow
22
33import (
44 "fmt"
5- "os"
6- "path/filepath"
75 "strings"
8-
9- "github.com/githubnext/gh-aw/pkg/console"
106)
117
128// needsProxy determines if a tool configuration requires proxy setup
@@ -93,92 +89,7 @@ func generateAllowedDomainsFile(domains []string) string {
9389}
9490
9591// generateProxyFiles generates Squid proxy configuration files for a tool
96- func (c * Compiler ) generateProxyFiles (markdownPath string , toolName string , toolConfig map [string ]any ) error {
97- needsProxySetup , allowedDomains := needsProxy (toolConfig )
98- if ! needsProxySetup {
99- return nil
100- }
101-
102- // Get the directory of the markdown file
103- markdownDir := filepath .Dir (markdownPath )
104-
105- // Generate squid.conf
106- squidConfig := generateSquidConfig ()
107- squidPath := filepath .Join (markdownDir , "squid.conf" )
108- if err := os .WriteFile (squidPath , []byte (squidConfig ), 0644 ); err != nil {
109- return fmt .Errorf ("failed to write squid.conf: %w" , err )
110- }
111-
112- if c .fileTracker != nil {
113- c .fileTracker .TrackCreated (squidPath )
114- }
115-
116- // Generate allowed_domains.txt
117- domainsConfig := generateAllowedDomainsFile (allowedDomains )
118- domainsPath := filepath .Join (markdownDir , "allowed_domains.txt" )
119- if err := os .WriteFile (domainsPath , []byte (domainsConfig ), 0644 ); err != nil {
120- return fmt .Errorf ("failed to write allowed_domains.txt: %w" , err )
121- }
122-
123- if c .fileTracker != nil {
124- c .fileTracker .TrackCreated (domainsPath )
125- }
126-
127- // Get container image and environment variables from MCP config
128- mcpConfig , err := getMCPConfig (toolConfig , toolName )
129- if err != nil {
130- return fmt .Errorf ("failed to get MCP config: %w" , err )
131- }
132-
133- containerImage , hasContainer := mcpConfig ["container" ]
134- if ! hasContainer {
135- return fmt .Errorf ("proxy-enabled tool '%s' missing container configuration" , toolName )
136- }
137-
138- containerStr , ok := containerImage .(string )
139- if ! ok {
140- return fmt .Errorf ("container image must be a string" )
141- }
142-
143- var envVars map [string ]any
144- if env , hasEnv := mcpConfig ["env" ]; hasEnv {
145- if envMap , ok := env .(map [string ]any ); ok {
146- envVars = envMap
147- }
148- }
149-
150- // Extract custom proxy args from MCP config if present
151- var customProxyArgs []string
152- if proxyArgsInterface , hasProxyArgs := mcpConfig ["proxy_args" ]; hasProxyArgs {
153- if proxyArgsSlice , ok := proxyArgsInterface .([]any ); ok {
154- for _ , arg := range proxyArgsSlice {
155- if argStr , ok := arg .(string ); ok {
156- customProxyArgs = append (customProxyArgs , argStr )
157- }
158- }
159- }
160- }
161-
162- // Generate docker-compose.yml
163- composeConfig := generateDockerCompose (containerStr , envVars , toolName , customProxyArgs )
164- composePath := filepath .Join (markdownDir , fmt .Sprintf ("docker-compose-%s.yml" , toolName ))
165- if err := os .WriteFile (composePath , []byte (composeConfig ), 0644 ); err != nil {
166- return fmt .Errorf ("failed to write docker-compose.yml: %w" , err )
167- }
168-
169- if c .fileTracker != nil {
170- c .fileTracker .TrackCreated (composePath )
171- }
172-
173- if c .verbose {
174- fmt .Println (console .FormatInfoMessage (fmt .Sprintf ("Generated proxy configuration files for tool '%s'" , toolName )))
175- fmt .Println (console .FormatInfoMessage (fmt .Sprintf (" - Squid config: %s" , console .ToRelativePath (squidPath ))))
176- fmt .Println (console .FormatInfoMessage (fmt .Sprintf (" - Allowed domains: %s" , console .ToRelativePath (domainsPath ))))
177- fmt .Println (console .FormatInfoMessage (fmt .Sprintf (" - Docker Compose: %s" , console .ToRelativePath (composePath ))))
178- }
179-
180- return nil
181- }
92+ // Removed unused generateProxyFiles; inline generation is used instead.
18293
18394// generateInlineProxyConfig generates proxy configuration files inline in the workflow
18495func (c * Compiler ) generateInlineProxyConfig (yaml * strings.Builder , toolName string , toolConfig map [string ]any ) {
0 commit comments