create-walle 0.4.5 → 0.4.6
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
|
@@ -313,16 +313,21 @@ function handleApi(req, res, url) {
|
|
|
313
313
|
// Accept any non-empty key (Anthropic, Portkey, or other providers)
|
|
314
314
|
const envPath = path.resolve(__dirname, '..', '.env');
|
|
315
315
|
const lines = [];
|
|
316
|
-
// Build set of keys
|
|
316
|
+
// Build set of keys to strip — API key and gateway are mutually exclusive
|
|
317
317
|
const keysToReplace = new Set();
|
|
318
318
|
if (ownerName) keysToReplace.add('WALLE_OWNER_NAME');
|
|
319
|
-
if (apiKey)
|
|
320
|
-
|
|
319
|
+
if (apiKey || gw) {
|
|
320
|
+
// Always strip both — they're mutually exclusive
|
|
321
|
+
keysToReplace.add('ANTHROPIC_API_KEY');
|
|
322
|
+
keysToReplace.add('ANTHROPIC_BASE_URL');
|
|
323
|
+
keysToReplace.add('ANTHROPIC_AUTH_TOKEN');
|
|
324
|
+
keysToReplace.add('ANTHROPIC_CUSTOM_HEADERS_B64');
|
|
325
|
+
}
|
|
321
326
|
// Read existing .env, keep lines that aren't being replaced
|
|
322
327
|
try {
|
|
323
328
|
const existing = fs.readFileSync(envPath, 'utf8');
|
|
324
329
|
for (const line of existing.split('\n')) {
|
|
325
|
-
const m = line.match(/^\s*#?\s*([A-
|
|
330
|
+
const m = line.match(/^\s*#?\s*([A-Z0-9_]+)\s*=/);
|
|
326
331
|
if (m && keysToReplace.has(m[1])) continue; // skip — will re-add below
|
|
327
332
|
lines.push(line);
|
|
328
333
|
}
|
|
@@ -336,16 +341,21 @@ function handleApi(req, res, url) {
|
|
|
336
341
|
process.env.WALLE_OWNER_NAME = ownerName;
|
|
337
342
|
}
|
|
338
343
|
if (gw) {
|
|
339
|
-
// Gateway setup: save
|
|
344
|
+
// Gateway setup: save gateway vars, clear direct API key
|
|
340
345
|
lines.push(`ANTHROPIC_BASE_URL=${gw.base_url}`);
|
|
341
346
|
lines.push(`ANTHROPIC_AUTH_TOKEN=${gw.auth_token}`);
|
|
342
347
|
lines.push(`ANTHROPIC_CUSTOM_HEADERS_B64=${gw.custom_headers_b64}`);
|
|
343
348
|
process.env.ANTHROPIC_BASE_URL = gw.base_url;
|
|
344
349
|
process.env.ANTHROPIC_AUTH_TOKEN = gw.auth_token;
|
|
345
350
|
process.env.ANTHROPIC_CUSTOM_HEADERS_B64 = gw.custom_headers_b64;
|
|
351
|
+
delete process.env.ANTHROPIC_API_KEY;
|
|
346
352
|
} else if (apiKey) {
|
|
353
|
+
// Direct API key: save key, clear gateway vars
|
|
347
354
|
lines.push(`ANTHROPIC_API_KEY=${apiKey}`);
|
|
348
355
|
process.env.ANTHROPIC_API_KEY = apiKey;
|
|
356
|
+
delete process.env.ANTHROPIC_BASE_URL;
|
|
357
|
+
delete process.env.ANTHROPIC_AUTH_TOKEN;
|
|
358
|
+
delete process.env.ANTHROPIC_CUSTOM_HEADERS_B64;
|
|
349
359
|
}
|
|
350
360
|
fs.writeFileSync(envPath, lines.join('\n') + '\n', { mode: 0o600 });
|
|
351
361
|
setup.clearSetupCache(); // so next / request goes to dashboard
|