collectSampleEntries walks the safe-outputs config and flattens every configured `samples` entry into the order they will be sent to the MCP server. Iteration order is deterministic (sorted by struct field name) so that compiled YAML is stable across runs.
(config *SafeOutputsConfig)
| 26 | // server. Iteration order is deterministic (sorted by struct field name) so |
| 27 | // that compiled YAML is stable across runs. |
| 28 | func collectSampleEntries(config *SafeOutputsConfig) []SampleEntry { |
| 29 | if config == nil { |
| 30 | return nil |
| 31 | } |
| 32 | |
| 33 | fieldNames := sliceutil.SortedKeys(safeOutputFieldMapping) |
| 34 | |
| 35 | var entries []SampleEntry |
| 36 | for _, fieldName := range fieldNames { |
| 37 | toolName := safeOutputFieldMapping[fieldName] |
| 38 | base := extractBaseSafeOutputConfig(config, fieldName) |
| 39 | if base == nil || len(base.Samples) == 0 { |
| 40 | continue |
| 41 | } |
| 42 | sidecarKeys := sampleSidecarFields[toolName] |
| 43 | for _, sample := range base.Samples { |
| 44 | args := make(map[string]any, len(sample)) |
| 45 | var sidecars map[string]any |
| 46 | for k, v := range sample { |
| 47 | if sidecarKeys[k] { |
| 48 | if sidecars == nil { |
| 49 | sidecars = make(map[string]any) |
| 50 | } |
| 51 | sidecars[k] = v |
| 52 | continue |
| 53 | } |
| 54 | args[k] = v |
| 55 | } |
| 56 | entries = append(entries, SampleEntry{ |
| 57 | Tool: toolName, |
| 58 | Arguments: args, |
| 59 | Sidecars: sidecars, |
| 60 | }) |
| 61 | } |
| 62 | } |
| 63 | return entries |
| 64 | } |
| 65 | |
| 66 | // collectSampleRepoTokens walks the workflow's checkout configs and returns |
| 67 | // a map of "owner/repo" -> token expression so that apply_samples.cjs can |