FEATURE: variable reference
right now in eca config we have:
urlEnv string Environment variable name containing the API URL No*
url string Direct API URL (use instead of urlEnv) No*
keyEnv string Environment variable name containing the API key No*
keyRc string Lookup specification to read the API key from Unix RC [credential files](https://eca.dev/models/#credential-file-authentication) No*
key string Direct API key (use instead of keyEnv) No*
They are limit to provider config, and is probably duplicated and inflexible, it'd be good if we can migrate to a variable reference model for example:
{
"providers": {
"openai": {
"key": "${env:MY_OPENAI_KEY}"
}
}
}
{
"providers": {
"openai": {
"key": "${keyRc:api.openai.com}"
}
}
}
{
"providers": {
"openai": {
"key": "myplaintextkey"
}
}
}
notice we only have key as name, and it'd be more flexible to add more type of variable references later. syntax is taken from https://code.visualstudio.com/docs/reference/variables-reference
Another benefit would be to reuse the stuff in other section of configs: for example in mcp server I can have this without worry about put plain cred in config.
{
"mcpServers": {
"brave-search": {
"command": "npx",
"args": ["-y", "@brave/brave-search-mcp-server", "--transport", "http"],
"env": {
"BRAVE_API_KEY": "${keyRc:brave.com}",
"SOMTHING": "{env:MY_ANOTHER_ENV}",
}
}
}
}
Interesting, I never saw that standard before, I wonder if that adds a new layer of complexity to user, what before was just json with fields and values, now have values with special values. I liked the idea of extending to other fields too tho, so not sure
Any thoughts @editor-code-assistant/maintainers ?
Hey @sg-qwt I started to support that!
But we do support now for every string value in config, for now only ${file:path} and ${env:value}, but it's flexible to add others like keyRc!
I will update configs deprecating the ones that mention fileor env and leave documentation only pointing to this new style
@ericdallo I think you missed two parse-dynamic-string-values in L216 and L224 Or wrap that into one function in case forget
Not sure I got, those lines are just the path to the file, it's used in functions that then use the parse-dynamic, am I missing something?
Also, I don't want to wrap in the final config function as it's not memoized, maybe a improvement for the future to memorize the final config
Does dynamic string get parsed with custom config file or ECA_CONFIG? Looks like you only parsed dynamic string in global/local config? That's what I understand from the code, maybe I'm wrong.
Ah got it, yeah, I missed those 2 places, will do!
Done! also added support for ${netrc:...}, thank you for the help and suggestion