@goodandready/dsh-key-rotation 0.7.6 → 0.7.7
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/lib/client.js +22 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -67,6 +67,8 @@ window.__ModuleLoader__.load({
|
|
|
67
67
|
importPools: 'Import',
|
|
68
68
|
importEnv: 'Import .env',
|
|
69
69
|
resetCooldown: 'Reset cooldown',
|
|
70
|
+
testAll: 'Test all keys',
|
|
71
|
+
testing: 'Testing…',
|
|
70
72
|
testKey: 'Test',
|
|
71
73
|
testOk: 'OK',
|
|
72
74
|
testFail: 'FAIL',
|
|
@@ -116,6 +118,8 @@ window.__ModuleLoader__.load({
|
|
|
116
118
|
importPools: 'Импорт',
|
|
117
119
|
importEnv: 'Импорт .env',
|
|
118
120
|
resetCooldown: 'Сбросить кулдаун',
|
|
121
|
+
testAll: 'Тест всех ключей',
|
|
122
|
+
testing: 'Тестирование…',
|
|
119
123
|
testKey: 'Тест',
|
|
120
124
|
testOk: 'OK',
|
|
121
125
|
testFail: 'FAIL',
|
|
@@ -258,6 +262,7 @@ window.__ModuleLoader__.load({
|
|
|
258
262
|
const undoTimer = React.useRef(null);
|
|
259
263
|
const [testing, setTesting] = React.useState('');
|
|
260
264
|
const [testResult, setTestResult] = React.useState({});
|
|
265
|
+
const [testAllProvider, setTestAllProvider] = React.useState('');
|
|
261
266
|
const [secretDraft, setSecretDraft] = React.useState({});
|
|
262
267
|
const [secretError, setSecretError] = React.useState('');
|
|
263
268
|
const stashUndo = (u) => { setUndo(u); if (undoTimer.current) clearTimeout(undoTimer.current); undoTimer.current = setTimeout(() => setUndo(null), 5000); };
|
|
@@ -275,6 +280,22 @@ window.__ModuleLoader__.load({
|
|
|
275
280
|
.catch((e) => setTestResult((m) => ({ ...m, [ref]: { ok: false, message: String(e?.message ?? e) } })))
|
|
276
281
|
.finally(() => setTesting(''));
|
|
277
282
|
};
|
|
283
|
+
const doTestAll = (providerId) => {
|
|
284
|
+
if (!val || !Array.isArray(val.providers)) return;
|
|
285
|
+
const entry = val.providers.find((p) => p.provider === providerId);
|
|
286
|
+
if (!entry || !Array.isArray(entry.keys)) return;
|
|
287
|
+
const refs = entry.keys.filter((k) => k && typeof k === 'string' && k.length > 0);
|
|
288
|
+
setTestAllProvider(providerId);
|
|
289
|
+
Promise.all(refs.map((ref) =>
|
|
290
|
+
fetch('/dsh-key-rotation/test', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ ref }) })
|
|
291
|
+
.then((r) => r.json())
|
|
292
|
+
.then((data) => ({ ref, data }))
|
|
293
|
+
.catch((e) => ({ ref, data: { ok: false, message: String(e?.message ?? e) } }))
|
|
294
|
+
)).then((results) => {
|
|
295
|
+
setTestResult((m) => { const nm = { ...m }; for (const { ref, data } of results) nm[ref] = data; return nm; });
|
|
296
|
+
setTestAllProvider('');
|
|
297
|
+
});
|
|
298
|
+
};
|
|
278
299
|
|
|
279
300
|
const load = React.useCallback(() => {
|
|
280
301
|
setState((s) => ({ ...s, status: 'loading', error: '' }));
|
|
@@ -569,6 +590,7 @@ window.__ModuleLoader__.load({
|
|
|
569
590
|
(providerStatus && Array.isArray(providerStatus.events) && providerStatus.events.length > 0 ? h('div', { style: { display: 'flex', gap: '2px', alignItems: 'end', height: '24px', marginTop: '4px' } }, (() => { const now = Date.now(); const buckets = Array(24).fill(0); for (const ev of providerStatus.events) { const h = Math.floor((now - ev.at) / 3600000); if (h >= 0 && h < 24) buckets[23 - h]++; } const max = Math.max(1, ...buckets); return buckets.map((c, i) => h('div', { key: i, title: c + ' switches', style: { flex: 1, background: c ? 'var(--dsw-alias-state-warning-primary)' : 'var(--dsw-alias-border-l2)', height: (c / max * 24) + 'px', minHeight: '2px', borderRadius: '2px' } })); })()) : null),
|
|
570
591
|
(providerStatus && Array.isArray(providerStatus.events) && providerStatus.events.length > 0 ? h('details', { style: { fontSize: '11px', marginTop: '6px' } }, h('summary', null, 'Recent failures ('+providerStatus.events.length+')'), h('ul', { style: { margin: '4px 0 0', paddingLeft: '16px' } }, providerStatus.events.slice().reverse().map((ev, i) => h('li', { key: i, style: ev.type === 'probe' ? { opacity: .5 } : null }, new Date(ev.at).toLocaleTimeString() + ' ' + (ev.type === 'probe' ? '[probe] ' : '') + ev.ref + ' ' + ev.reason + ' cd=' + ev.cooldownMs)) )) : null),
|
|
571
592
|
btn(t('resetCooldown'), () => doReset(entry.provider), { disabled: !(providerStatus && providerStatus.switches > 0) || resetting === entry.provider, title: t('resetCooldown') }),
|
|
593
|
+
btn(testAllProvider === entry.provider ? t('testing') : t('testAll'), () => doTestAll(entry.provider), { disabled: testAllProvider === entry.provider, title: t('testAll') }),
|
|
572
594
|
),
|
|
573
595
|
);
|
|
574
596
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-key-rotation",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
4
4
|
"description": "Per-provider API key rotation for DeepSeek Harness: a key pool per provider, auto-created clone routes, and switching to the next key on quota/rate-limit errors. Includes a Settings section (Key Rotation) to edit the key pools, cooldown and switch codes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|