@tokagent/tokagentos 2.0.32 → 2.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -149,6 +149,47 @@ function readDotenv() {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
const env = readDotenv();
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Shell-env vs .env conflict check.
|
|
155
|
+
*
|
|
156
|
+
* Failure mode observed in the field: user rotates an API key in .env, but
|
|
157
|
+
* an old value is still exported in their shell from a prior `export` or a
|
|
158
|
+
* line in ~/.zshrc / ~/.bashrc. dotenv defaults to `override: false`, which
|
|
159
|
+
* means existing process.env values are NOT overwritten by .env. The agent
|
|
160
|
+
* sees the stale shell value, OpenRouter returns 401 "User not found", and
|
|
161
|
+
* the AI SDK surfaces the opaque `AI_NoOutputGeneratedError`. Changing the
|
|
162
|
+
* .env does nothing because the shell value still wins.
|
|
163
|
+
*
|
|
164
|
+
* We don't flip dotenv's `override` flag — that breaks legitimate CI/devops
|
|
165
|
+
* setups that intentionally pass secrets via env vars. Instead we detect
|
|
166
|
+
* the mismatch and tell the user which value will actually be used and how
|
|
167
|
+
* to fix it.
|
|
168
|
+
*/
|
|
169
|
+
const SHADOWED_KEYS = [
|
|
170
|
+
"OPENROUTER_API_KEY",
|
|
171
|
+
"ANTHROPIC_API_KEY",
|
|
172
|
+
"OPENAI_API_KEY",
|
|
173
|
+
"GOOGLE_GENERATIVE_AI_API_KEY",
|
|
174
|
+
"GROQ_API_KEY",
|
|
175
|
+
"TAVILY_API_KEY",
|
|
176
|
+
];
|
|
177
|
+
for (const key of SHADOWED_KEYS) {
|
|
178
|
+
const dotenvValue = env[key];
|
|
179
|
+
const shellValue = process.env[key];
|
|
180
|
+
if (dotenvValue && shellValue && dotenvValue !== shellValue) {
|
|
181
|
+
fail(
|
|
182
|
+
`${key} differs between your shell environment and .env.\n` +
|
|
183
|
+
` shell : ${shellValue.slice(0, 12)}…${shellValue.slice(-4)} (this is what the agent reads)\n` +
|
|
184
|
+
` .env : ${dotenvValue.slice(0, 12)}…${dotenvValue.slice(-4)} (this is what you probably edited)\n` +
|
|
185
|
+
` dotenv runs with override:false by default, so the shell value wins. To fix:\n` +
|
|
186
|
+
` unset ${key} # remove from the current shell\n` +
|
|
187
|
+
` grep -n ${key} ~/.zshrc ~/.zprofile ~/.bashrc ~/.bash_profile 2>/dev/null\n` +
|
|
188
|
+
` # delete any matching lines, restart the shell, then re-run \`bun run dev\``,
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
152
193
|
if (env.OPENROUTER_API_KEY) {
|
|
153
194
|
const MODEL_KEYS = [
|
|
154
195
|
"OPENROUTER_SMALL_MODEL",
|