======================================== Safe Output Call Workflow Handling ======================================== This file contains functions for managing call-workflow safe output configurations: mapping workflow names to their relative file paths so the compiler can generate the correct `uses
(data *WorkflowData, markdownPath string)
| 22 | // |
| 23 | // Priority order: .lock.yml > .yml > .md (same-batch compilation target → .lock.yml) |
| 24 | func populateCallWorkflowFiles(data *WorkflowData, markdownPath string) { |
| 25 | if data.SafeOutputs == nil || data.SafeOutputs.CallWorkflow == nil { |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | if len(data.SafeOutputs.CallWorkflow.Workflows) == 0 { |
| 30 | return |
| 31 | } |
| 32 | |
| 33 | callWorkflowLog.Printf("Populating workflow files for %d call workflows", len(data.SafeOutputs.CallWorkflow.Workflows)) |
| 34 | |
| 35 | // Initialize WorkflowFiles map if not already initialized |
| 36 | if data.SafeOutputs.CallWorkflow.WorkflowFiles == nil { |
| 37 | data.SafeOutputs.CallWorkflow.WorkflowFiles = make(map[string]string) |
| 38 | } |
| 39 | |
| 40 | for _, workflowName := range data.SafeOutputs.CallWorkflow.Workflows { |
| 41 | fileResult, err := findWorkflowFile(workflowName, markdownPath) |
| 42 | if err != nil { |
| 43 | callWorkflowLog.Printf("Warning: error finding workflow %s: %v", workflowName, err) |
| 44 | continue |
| 45 | } |
| 46 | |
| 47 | // Determine which file to use - priority: .lock.yml > .yml > .md (batch target) |
| 48 | extension, found := resolveWorkflowExtension(fileResult) |
| 49 | if !found { |
| 50 | callWorkflowLog.Printf("Warning: no workflow file found for %s (checked .lock.yml, .yml, .md)", workflowName) |
| 51 | continue |
| 52 | } |
| 53 | |
| 54 | // Store the relative path for runtime/compile-time use (e.g. ./.github/workflows/worker.lock.yml) |
| 55 | relativePath := fmt.Sprintf("./.github/workflows/%s%s", workflowName, extension) |
| 56 | data.SafeOutputs.CallWorkflow.WorkflowFiles[workflowName] = relativePath |
| 57 | callWorkflowLog.Printf("Mapped workflow %s to path %s", workflowName, relativePath) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // generateCallWorkflowTool generates an MCP tool definition for a specific call-workflow target. |
| 62 | // The tool will be named after the workflow (normalized to underscores) and accept |