@agenticmail/enterprise 0.5.12 → 0.5.14
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/dist/chunk-LNWVYHWX.js +1987 -0
- package/dist/chunk-VBKWGYN3.js +889 -0
- package/dist/cli.js +1 -1
- package/dist/dashboard/pages/agents.js +66 -5
- package/dist/dashboard/pages/settings.js +24 -0
- package/dist/index.js +2 -2
- package/dist/server-JRXIBDTH.js +11 -0
- package/dist/setup-UH5AXHZX.js +20 -0
- package/package.json +1 -1
- package/src/admin/routes.ts +25 -0
- package/src/dashboard/pages/agents.js +66 -5
- package/src/dashboard/pages/settings.js +24 -0
- package/src/server.ts +23 -0
package/dist/cli.js
CHANGED
|
@@ -244,12 +244,20 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
|
|
|
244
244
|
const [selectedSoul, setSelectedSoul] = useState(null);
|
|
245
245
|
const [previewOpen, setPreviewOpen] = useState(false);
|
|
246
246
|
const [loading, setLoading] = useState(false);
|
|
247
|
+
const [showSetupGuide, setShowSetupGuide] = useState(false);
|
|
248
|
+
const [setupChecked, setSetupChecked] = useState(false);
|
|
247
249
|
|
|
248
250
|
useEffect(() => {
|
|
249
251
|
engineCall('/skills/by-category').then(d => setAllSkills(d.categories || {})).catch(() => {});
|
|
250
252
|
engineCall('/profiles/presets').then(d => setPresets(d.presets || [])).catch(() => {});
|
|
251
253
|
engineCall('/souls/by-category').then(d => { setSoulCategories(d.categories || {}); setSoulMeta(d.categoryMeta || {}); }).catch(() => {});
|
|
252
|
-
apiCall('/providers').then(function(d) {
|
|
254
|
+
apiCall('/providers').then(function(d) {
|
|
255
|
+
var provList = d.providers || [];
|
|
256
|
+
setProviders(provList);
|
|
257
|
+
var hasConfigured = provList.some(function(p) { return p.configured; });
|
|
258
|
+
if (!hasConfigured) { setShowSetupGuide(true); }
|
|
259
|
+
setSetupChecked(true);
|
|
260
|
+
}).catch(function() { setShowSetupGuide(true); setSetupChecked(true); });
|
|
253
261
|
}, []);
|
|
254
262
|
|
|
255
263
|
// Fetch models when provider changes
|
|
@@ -452,6 +460,59 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
|
|
|
452
460
|
|
|
453
461
|
const stepIcons = ['soul', 'basics', 'skills', 'perms', 'deploy', 'review'];
|
|
454
462
|
|
|
463
|
+
// ─── Setup Guide Modal ───────────────────────────────────
|
|
464
|
+
if (showSetupGuide) {
|
|
465
|
+
return h('div', { className: 'modal-overlay', onClick: e => { if (e.target === e.currentTarget) onClose(); } },
|
|
466
|
+
h('div', { className: 'modal', style: { maxWidth: 600 } },
|
|
467
|
+
h('div', { className: 'modal-header' },
|
|
468
|
+
h('div', null,
|
|
469
|
+
h('h2', null, '⚡ Setup Required'),
|
|
470
|
+
h('p', { style: { fontSize: 12, color: 'var(--text-muted)', margin: '2px 0 0', fontWeight: 400 } }, 'Complete these steps before creating your first agent')
|
|
471
|
+
),
|
|
472
|
+
h('button', { className: 'btn btn-ghost btn-icon', onClick: onClose }, I.x())
|
|
473
|
+
),
|
|
474
|
+
h('div', { className: 'modal-body', style: { padding: '24px' } },
|
|
475
|
+
h('p', { style: { marginBottom: 20, color: 'var(--text-secondary)', lineHeight: 1.6 } },
|
|
476
|
+
'Your agents need an LLM provider (like Anthropic or OpenAI) to think and act. Set up at least one provider with an API key before creating agents.'
|
|
477
|
+
),
|
|
478
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 16 } },
|
|
479
|
+
h('div', { style: { padding: 16, borderRadius: 'var(--radius-lg)', border: '1px solid var(--border)', background: 'var(--bg-secondary)' } },
|
|
480
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 } },
|
|
481
|
+
h('div', { style: { width: 28, height: 28, borderRadius: '50%', background: 'var(--accent)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 14, flexShrink: 0 } }, '1'),
|
|
482
|
+
h('strong', null, 'Add an LLM Provider API Key')
|
|
483
|
+
),
|
|
484
|
+
h('p', { style: { margin: 0, color: 'var(--text-muted)', fontSize: 13, paddingLeft: 40, lineHeight: 1.5 } },
|
|
485
|
+
'Go to Settings → LLM Providers and add your API key for at least one provider. Recommended: Anthropic (Claude) or OpenAI (GPT).'
|
|
486
|
+
)
|
|
487
|
+
),
|
|
488
|
+
h('div', { style: { padding: 16, borderRadius: 'var(--radius-lg)', border: '1px solid var(--border)', background: 'var(--bg-secondary)' } },
|
|
489
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 } },
|
|
490
|
+
h('div', { style: { width: 28, height: 28, borderRadius: '50%', background: 'var(--accent)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 14, flexShrink: 0 } }, '2'),
|
|
491
|
+
h('strong', null, 'Configure Email Domain (Optional)')
|
|
492
|
+
),
|
|
493
|
+
h('p', { style: { margin: 0, color: 'var(--text-muted)', fontSize: 13, paddingLeft: 40, lineHeight: 1.5 } },
|
|
494
|
+
'Set up your email domain in Settings → Domain so agents can send and receive emails as agent@yourdomain.com.'
|
|
495
|
+
)
|
|
496
|
+
),
|
|
497
|
+
h('div', { style: { padding: 16, borderRadius: 'var(--radius-lg)', border: '1px solid var(--border)', background: 'var(--bg-secondary)' } },
|
|
498
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 } },
|
|
499
|
+
h('div', { style: { width: 28, height: 28, borderRadius: '50%', background: 'var(--accent)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 14, flexShrink: 0 } }, '3'),
|
|
500
|
+
h('strong', null, 'Set Security Policies (Optional)')
|
|
501
|
+
),
|
|
502
|
+
h('p', { style: { margin: 0, color: 'var(--text-muted)', fontSize: 13, paddingLeft: 40, lineHeight: 1.5 } },
|
|
503
|
+
'Review Settings → Guardrails to set tool approval policies, rate limits, and data loss prevention rules.'
|
|
504
|
+
)
|
|
505
|
+
)
|
|
506
|
+
),
|
|
507
|
+
h('div', { style: { display: 'flex', gap: 12, marginTop: 24, justifyContent: 'flex-end' } },
|
|
508
|
+
h('button', { className: 'btn btn-ghost', onClick: function() { setShowSetupGuide(false); } }, 'Skip for Now'),
|
|
509
|
+
h('a', { href: '#/settings', className: 'btn btn-primary', onClick: function() { onClose(); } }, 'Go to Settings')
|
|
510
|
+
)
|
|
511
|
+
)
|
|
512
|
+
)
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
455
516
|
return h('div', { className: 'modal-overlay', onClick: e => { if (e.target === e.currentTarget) onClose(); } },
|
|
456
517
|
h('div', { className: 'modal modal-xl' },
|
|
457
518
|
h('div', { className: 'modal-header' },
|
|
@@ -669,14 +730,14 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
|
|
|
669
730
|
value: form.provider || 'anthropic',
|
|
670
731
|
onChange: function(e) { setForm(Object.assign({}, form, { provider: e.target.value })); },
|
|
671
732
|
},
|
|
672
|
-
providers.length > 0
|
|
733
|
+
providers.length > 0 && providers.some(function(p) { return p.configured; })
|
|
673
734
|
? providers.filter(function(p) { return p.configured; }).map(function(p) {
|
|
674
735
|
return h('option', { key: p.id, value: p.id }, p.name + (p.isLocal ? ' (Local)' : ''));
|
|
675
736
|
})
|
|
676
737
|
: [
|
|
677
|
-
h('option', { value: 'anthropic' }, 'Anthropic'),
|
|
678
|
-
h('option', { value: 'openai' }, 'OpenAI'),
|
|
679
|
-
h('option', { value: 'google' }, 'Google'),
|
|
738
|
+
h('option', { value: 'anthropic' }, 'Anthropic (Claude)'),
|
|
739
|
+
h('option', { value: 'openai' }, 'OpenAI (GPT)'),
|
|
740
|
+
h('option', { value: 'google' }, 'Google (Gemini)'),
|
|
680
741
|
h('option', { value: 'deepseek' }, 'DeepSeek'),
|
|
681
742
|
h('option', { value: 'xai' }, 'xAI (Grok)'),
|
|
682
743
|
h('option', { value: 'mistral' }, 'Mistral'),
|
|
@@ -1310,6 +1310,30 @@ function ProvidersSection(props) {
|
|
|
1310
1310
|
}, isConfigured ? 'Connected' : 'Not Configured')
|
|
1311
1311
|
),
|
|
1312
1312
|
isLocal && p.baseUrl && h('div', { style: { fontSize: 12, color: '#6b7280', marginBottom: 8, wordBreak: 'break-all' } }, p.baseUrl),
|
|
1313
|
+
!isLocal && !p.isCustom && p.requiresApiKey && h('div', { style: { marginTop: 8 } },
|
|
1314
|
+
isConfigured
|
|
1315
|
+
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 12 } },
|
|
1316
|
+
h('span', { style: { color: 'var(--success, #16a34a)' } }, '✓ API key configured via environment'),
|
|
1317
|
+
h('button', { className: 'btn btn-sm btn-ghost', style: { padding: '2px 8px', fontSize: 11 }, onClick: function() {
|
|
1318
|
+
var key = prompt('Enter new API key for ' + p.name + ' (leave empty to keep current):');
|
|
1319
|
+
if (key && key.trim()) {
|
|
1320
|
+
apiCall('/providers/' + p.id + '/api-key', { method: 'POST', body: JSON.stringify({ apiKey: key.trim() }) })
|
|
1321
|
+
.then(function() { toast('API key updated for ' + p.name + '. Restart required.', 'success'); window.location.reload(); })
|
|
1322
|
+
.catch(function(e) { toast(e.message || 'Failed to save', 'error'); });
|
|
1323
|
+
}
|
|
1324
|
+
}}, 'Update Key')
|
|
1325
|
+
)
|
|
1326
|
+
: h('div', null,
|
|
1327
|
+
h('button', { className: 'btn btn-sm btn-primary', onClick: function() {
|
|
1328
|
+
var key = prompt('Enter your ' + p.name + ' API key:');
|
|
1329
|
+
if (key && key.trim()) {
|
|
1330
|
+
apiCall('/providers/' + p.id + '/api-key', { method: 'POST', body: JSON.stringify({ apiKey: key.trim() }) })
|
|
1331
|
+
.then(function() { toast('API key saved for ' + p.name + '!', 'success'); window.location.reload(); })
|
|
1332
|
+
.catch(function(e) { toast(e.message || 'Failed to save', 'error'); });
|
|
1333
|
+
}
|
|
1334
|
+
}}, '🔑 Add API Key')
|
|
1335
|
+
)
|
|
1336
|
+
),
|
|
1313
1337
|
h('div', { style: { display: 'flex', gap: 6, marginTop: 8 } },
|
|
1314
1338
|
isLocal && h('button', {
|
|
1315
1339
|
className: 'btn btn-sm',
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
requireRole,
|
|
27
27
|
securityHeaders,
|
|
28
28
|
validate
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-LNWVYHWX.js";
|
|
30
30
|
import {
|
|
31
31
|
PROVIDER_REGISTRY,
|
|
32
32
|
listAllProviders,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import {
|
|
37
37
|
provision,
|
|
38
38
|
runSetupWizard
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-VBKWGYN3.js";
|
|
40
40
|
import {
|
|
41
41
|
ENGINE_TABLES,
|
|
42
42
|
ENGINE_TABLES_POSTGRES,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-VBKWGYN3.js";
|
|
10
|
+
import "./chunk-6TDW6ZNI.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
package/package.json
CHANGED
package/src/admin/routes.ts
CHANGED
|
@@ -629,6 +629,31 @@ export function createAdminRoutes(db: DatabaseAdapter) {
|
|
|
629
629
|
return c.json({ ok: true, provider: body });
|
|
630
630
|
});
|
|
631
631
|
|
|
632
|
+
// ─── Provider API Key Management ────────────────────────
|
|
633
|
+
api.post('/providers/:id/api-key', requireRole('admin'), async (c) => {
|
|
634
|
+
var id = c.req.param('id');
|
|
635
|
+
var provider = PROVIDER_REGISTRY[id];
|
|
636
|
+
if (!provider) {
|
|
637
|
+
return c.json({ error: 'Unknown provider' }, 404);
|
|
638
|
+
}
|
|
639
|
+
var body = await c.req.json();
|
|
640
|
+
if (!body.apiKey || typeof body.apiKey !== 'string' || body.apiKey.trim().length < 5) {
|
|
641
|
+
return c.json({ error: 'Valid API key required' }, 400);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
// Store API key in company settings (encrypted field)
|
|
645
|
+
var settings = await db.getSettings();
|
|
646
|
+
var config = (settings as any)?.modelPricingConfig || { models: [], currency: 'USD' };
|
|
647
|
+
config.providerApiKeys = config.providerApiKeys || {};
|
|
648
|
+
config.providerApiKeys[id] = body.apiKey.trim();
|
|
649
|
+
await db.updateSettings({ modelPricingConfig: config } as any);
|
|
650
|
+
|
|
651
|
+
// Also set in process.env so it takes effect immediately
|
|
652
|
+
process.env[provider.envKey] = body.apiKey.trim();
|
|
653
|
+
|
|
654
|
+
return c.json({ ok: true, message: 'API key saved for ' + provider.name });
|
|
655
|
+
});
|
|
656
|
+
|
|
632
657
|
api.put('/providers/:id', requireRole('admin'), async (c) => {
|
|
633
658
|
var id = c.req.param('id');
|
|
634
659
|
if (PROVIDER_REGISTRY[id]) {
|
|
@@ -244,12 +244,20 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
|
|
|
244
244
|
const [selectedSoul, setSelectedSoul] = useState(null);
|
|
245
245
|
const [previewOpen, setPreviewOpen] = useState(false);
|
|
246
246
|
const [loading, setLoading] = useState(false);
|
|
247
|
+
const [showSetupGuide, setShowSetupGuide] = useState(false);
|
|
248
|
+
const [setupChecked, setSetupChecked] = useState(false);
|
|
247
249
|
|
|
248
250
|
useEffect(() => {
|
|
249
251
|
engineCall('/skills/by-category').then(d => setAllSkills(d.categories || {})).catch(() => {});
|
|
250
252
|
engineCall('/profiles/presets').then(d => setPresets(d.presets || [])).catch(() => {});
|
|
251
253
|
engineCall('/souls/by-category').then(d => { setSoulCategories(d.categories || {}); setSoulMeta(d.categoryMeta || {}); }).catch(() => {});
|
|
252
|
-
apiCall('/providers').then(function(d) {
|
|
254
|
+
apiCall('/providers').then(function(d) {
|
|
255
|
+
var provList = d.providers || [];
|
|
256
|
+
setProviders(provList);
|
|
257
|
+
var hasConfigured = provList.some(function(p) { return p.configured; });
|
|
258
|
+
if (!hasConfigured) { setShowSetupGuide(true); }
|
|
259
|
+
setSetupChecked(true);
|
|
260
|
+
}).catch(function() { setShowSetupGuide(true); setSetupChecked(true); });
|
|
253
261
|
}, []);
|
|
254
262
|
|
|
255
263
|
// Fetch models when provider changes
|
|
@@ -452,6 +460,59 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
|
|
|
452
460
|
|
|
453
461
|
const stepIcons = ['soul', 'basics', 'skills', 'perms', 'deploy', 'review'];
|
|
454
462
|
|
|
463
|
+
// ─── Setup Guide Modal ───────────────────────────────────
|
|
464
|
+
if (showSetupGuide) {
|
|
465
|
+
return h('div', { className: 'modal-overlay', onClick: e => { if (e.target === e.currentTarget) onClose(); } },
|
|
466
|
+
h('div', { className: 'modal', style: { maxWidth: 600 } },
|
|
467
|
+
h('div', { className: 'modal-header' },
|
|
468
|
+
h('div', null,
|
|
469
|
+
h('h2', null, '⚡ Setup Required'),
|
|
470
|
+
h('p', { style: { fontSize: 12, color: 'var(--text-muted)', margin: '2px 0 0', fontWeight: 400 } }, 'Complete these steps before creating your first agent')
|
|
471
|
+
),
|
|
472
|
+
h('button', { className: 'btn btn-ghost btn-icon', onClick: onClose }, I.x())
|
|
473
|
+
),
|
|
474
|
+
h('div', { className: 'modal-body', style: { padding: '24px' } },
|
|
475
|
+
h('p', { style: { marginBottom: 20, color: 'var(--text-secondary)', lineHeight: 1.6 } },
|
|
476
|
+
'Your agents need an LLM provider (like Anthropic or OpenAI) to think and act. Set up at least one provider with an API key before creating agents.'
|
|
477
|
+
),
|
|
478
|
+
h('div', { style: { display: 'flex', flexDirection: 'column', gap: 16 } },
|
|
479
|
+
h('div', { style: { padding: 16, borderRadius: 'var(--radius-lg)', border: '1px solid var(--border)', background: 'var(--bg-secondary)' } },
|
|
480
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 } },
|
|
481
|
+
h('div', { style: { width: 28, height: 28, borderRadius: '50%', background: 'var(--accent)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 14, flexShrink: 0 } }, '1'),
|
|
482
|
+
h('strong', null, 'Add an LLM Provider API Key')
|
|
483
|
+
),
|
|
484
|
+
h('p', { style: { margin: 0, color: 'var(--text-muted)', fontSize: 13, paddingLeft: 40, lineHeight: 1.5 } },
|
|
485
|
+
'Go to Settings → LLM Providers and add your API key for at least one provider. Recommended: Anthropic (Claude) or OpenAI (GPT).'
|
|
486
|
+
)
|
|
487
|
+
),
|
|
488
|
+
h('div', { style: { padding: 16, borderRadius: 'var(--radius-lg)', border: '1px solid var(--border)', background: 'var(--bg-secondary)' } },
|
|
489
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 } },
|
|
490
|
+
h('div', { style: { width: 28, height: 28, borderRadius: '50%', background: 'var(--accent)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 14, flexShrink: 0 } }, '2'),
|
|
491
|
+
h('strong', null, 'Configure Email Domain (Optional)')
|
|
492
|
+
),
|
|
493
|
+
h('p', { style: { margin: 0, color: 'var(--text-muted)', fontSize: 13, paddingLeft: 40, lineHeight: 1.5 } },
|
|
494
|
+
'Set up your email domain in Settings → Domain so agents can send and receive emails as agent@yourdomain.com.'
|
|
495
|
+
)
|
|
496
|
+
),
|
|
497
|
+
h('div', { style: { padding: 16, borderRadius: 'var(--radius-lg)', border: '1px solid var(--border)', background: 'var(--bg-secondary)' } },
|
|
498
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginBottom: 8 } },
|
|
499
|
+
h('div', { style: { width: 28, height: 28, borderRadius: '50%', background: 'var(--accent)', color: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', fontWeight: 700, fontSize: 14, flexShrink: 0 } }, '3'),
|
|
500
|
+
h('strong', null, 'Set Security Policies (Optional)')
|
|
501
|
+
),
|
|
502
|
+
h('p', { style: { margin: 0, color: 'var(--text-muted)', fontSize: 13, paddingLeft: 40, lineHeight: 1.5 } },
|
|
503
|
+
'Review Settings → Guardrails to set tool approval policies, rate limits, and data loss prevention rules.'
|
|
504
|
+
)
|
|
505
|
+
)
|
|
506
|
+
),
|
|
507
|
+
h('div', { style: { display: 'flex', gap: 12, marginTop: 24, justifyContent: 'flex-end' } },
|
|
508
|
+
h('button', { className: 'btn btn-ghost', onClick: function() { setShowSetupGuide(false); } }, 'Skip for Now'),
|
|
509
|
+
h('a', { href: '#/settings', className: 'btn btn-primary', onClick: function() { onClose(); } }, 'Go to Settings')
|
|
510
|
+
)
|
|
511
|
+
)
|
|
512
|
+
)
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
|
|
455
516
|
return h('div', { className: 'modal-overlay', onClick: e => { if (e.target === e.currentTarget) onClose(); } },
|
|
456
517
|
h('div', { className: 'modal modal-xl' },
|
|
457
518
|
h('div', { className: 'modal-header' },
|
|
@@ -669,14 +730,14 @@ export function CreateAgentWizard({ onClose, onCreated, toast }) {
|
|
|
669
730
|
value: form.provider || 'anthropic',
|
|
670
731
|
onChange: function(e) { setForm(Object.assign({}, form, { provider: e.target.value })); },
|
|
671
732
|
},
|
|
672
|
-
providers.length > 0
|
|
733
|
+
providers.length > 0 && providers.some(function(p) { return p.configured; })
|
|
673
734
|
? providers.filter(function(p) { return p.configured; }).map(function(p) {
|
|
674
735
|
return h('option', { key: p.id, value: p.id }, p.name + (p.isLocal ? ' (Local)' : ''));
|
|
675
736
|
})
|
|
676
737
|
: [
|
|
677
|
-
h('option', { value: 'anthropic' }, 'Anthropic'),
|
|
678
|
-
h('option', { value: 'openai' }, 'OpenAI'),
|
|
679
|
-
h('option', { value: 'google' }, 'Google'),
|
|
738
|
+
h('option', { value: 'anthropic' }, 'Anthropic (Claude)'),
|
|
739
|
+
h('option', { value: 'openai' }, 'OpenAI (GPT)'),
|
|
740
|
+
h('option', { value: 'google' }, 'Google (Gemini)'),
|
|
680
741
|
h('option', { value: 'deepseek' }, 'DeepSeek'),
|
|
681
742
|
h('option', { value: 'xai' }, 'xAI (Grok)'),
|
|
682
743
|
h('option', { value: 'mistral' }, 'Mistral'),
|
|
@@ -1310,6 +1310,30 @@ function ProvidersSection(props) {
|
|
|
1310
1310
|
}, isConfigured ? 'Connected' : 'Not Configured')
|
|
1311
1311
|
),
|
|
1312
1312
|
isLocal && p.baseUrl && h('div', { style: { fontSize: 12, color: '#6b7280', marginBottom: 8, wordBreak: 'break-all' } }, p.baseUrl),
|
|
1313
|
+
!isLocal && !p.isCustom && p.requiresApiKey && h('div', { style: { marginTop: 8 } },
|
|
1314
|
+
isConfigured
|
|
1315
|
+
? h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, fontSize: 12 } },
|
|
1316
|
+
h('span', { style: { color: 'var(--success, #16a34a)' } }, '✓ API key configured via environment'),
|
|
1317
|
+
h('button', { className: 'btn btn-sm btn-ghost', style: { padding: '2px 8px', fontSize: 11 }, onClick: function() {
|
|
1318
|
+
var key = prompt('Enter new API key for ' + p.name + ' (leave empty to keep current):');
|
|
1319
|
+
if (key && key.trim()) {
|
|
1320
|
+
apiCall('/providers/' + p.id + '/api-key', { method: 'POST', body: JSON.stringify({ apiKey: key.trim() }) })
|
|
1321
|
+
.then(function() { toast('API key updated for ' + p.name + '. Restart required.', 'success'); window.location.reload(); })
|
|
1322
|
+
.catch(function(e) { toast(e.message || 'Failed to save', 'error'); });
|
|
1323
|
+
}
|
|
1324
|
+
}}, 'Update Key')
|
|
1325
|
+
)
|
|
1326
|
+
: h('div', null,
|
|
1327
|
+
h('button', { className: 'btn btn-sm btn-primary', onClick: function() {
|
|
1328
|
+
var key = prompt('Enter your ' + p.name + ' API key:');
|
|
1329
|
+
if (key && key.trim()) {
|
|
1330
|
+
apiCall('/providers/' + p.id + '/api-key', { method: 'POST', body: JSON.stringify({ apiKey: key.trim() }) })
|
|
1331
|
+
.then(function() { toast('API key saved for ' + p.name + '!', 'success'); window.location.reload(); })
|
|
1332
|
+
.catch(function(e) { toast(e.message || 'Failed to save', 'error'); });
|
|
1333
|
+
}
|
|
1334
|
+
}}, '🔑 Add API Key')
|
|
1335
|
+
)
|
|
1336
|
+
),
|
|
1313
1337
|
h('div', { style: { display: 'flex', gap: 6, marginTop: 8 } },
|
|
1314
1338
|
isLocal && h('button', {
|
|
1315
1339
|
className: 'btn btn-sm',
|
package/src/server.ts
CHANGED
|
@@ -391,6 +391,29 @@ export function createServer(config: ServerConfig): ServerInstance {
|
|
|
391
391
|
// Start health monitoring
|
|
392
392
|
healthMonitor.start();
|
|
393
393
|
|
|
394
|
+
// Load saved provider API keys from DB into process.env
|
|
395
|
+
config.db.getSettings().then((settings: any) => {
|
|
396
|
+
const keys = settings?.modelPricingConfig?.providerApiKeys;
|
|
397
|
+
if (keys && typeof keys === 'object') {
|
|
398
|
+
// Map of provider IDs to their env var names
|
|
399
|
+
const envMap: Record<string, string> = {
|
|
400
|
+
anthropic: 'ANTHROPIC_API_KEY', openai: 'OPENAI_API_KEY',
|
|
401
|
+
google: 'GOOGLE_API_KEY', deepseek: 'DEEPSEEK_API_KEY',
|
|
402
|
+
xai: 'XAI_API_KEY', mistral: 'MISTRAL_API_KEY',
|
|
403
|
+
groq: 'GROQ_API_KEY', together: 'TOGETHER_API_KEY',
|
|
404
|
+
fireworks: 'FIREWORKS_API_KEY', perplexity: 'PERPLEXITY_API_KEY',
|
|
405
|
+
cohere: 'COHERE_API_KEY',
|
|
406
|
+
};
|
|
407
|
+
for (const [providerId, apiKey] of Object.entries(keys)) {
|
|
408
|
+
const envVar = envMap[providerId];
|
|
409
|
+
if (envVar && apiKey && !process.env[envVar]) {
|
|
410
|
+
process.env[envVar] = apiKey as string;
|
|
411
|
+
console.log(` 🔑 Loaded API key for ${providerId}`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}).catch(() => {});
|
|
416
|
+
|
|
394
417
|
// Graceful shutdown
|
|
395
418
|
const shutdown = () => {
|
|
396
419
|
console.log('\n⏳ Shutting down gracefully...');
|