Resolve resolves an agent file reference (local file, URL, or OCI image) to a source. If envProvider is non-nil, it will be used to look up GITHUB_TOKEN for authentication when fetching from GitHub URLs. For OCI references, always checks remote for updates but falls back to local cache if offline.
(agentFilename string, envProvider environment.Provider)
| 84 | // when fetching from GitHub URLs. |
| 85 | // For OCI references, always checks remote for updates but falls back to local cache if offline. |
| 86 | func Resolve(agentFilename string, envProvider environment.Provider) (Source, error) { |
| 87 | resolvedPath, err := resolve(agentFilename) |
| 88 | if err != nil { |
| 89 | if IsOCIReference(agentFilename) { |
| 90 | return NewOCISource(agentFilename), nil |
| 91 | } |
| 92 | return nil, err |
| 93 | } |
| 94 | |
| 95 | _, source := resolveOne(resolvedPath, envProvider) |
| 96 | return source, nil |
| 97 | } |
| 98 | |
| 99 | // resolveOne maps a resolved path to the appropriate Source and a key for use |
| 100 | // in Sources maps. The path must already be resolved via resolve(). |