Coach: ein API-Key gilt fuer die ganze Instanz, Warm-ups zaehlen nicht, Retries bei 429/5xx, sichtbare Admin-Felder
- Instanz-Modus: nur eine persoenliche Anmeldung (Setup-Token/OAuth) bindet sich an das erste Profil, ein API-Key ist gemessen und wird von allen Profilen unter den Tageslimits geteilt. Die Bindung passiert jetzt wirklich beim Einreihen eines Jobs (jobs.enqueue), vorher gab es sie nur in den Tests. - HTTP-Adapter: 429/500/502/503/504/529 werden zweimal mit kurzer Pause wiederholt, ein 4xx nie. retryDelayMs fuer Tests. - Payload: Warm-up-Saetze wie in progression.js aus readSession/stalls, done/planned, Top-Satz, setsByBodyPart und workingWeights herausgefiltert; in vollen Sessions als warmup:true markiert, common.md sagt dem Modell, was das ist. - Admin-Karte: .field im Card hat jetzt eine sichtbare Flaeche, die Limit-Zahlenfelder sind echte Felder statt weisser Browser-Boxen; Text zu 'Whose account pays' unterscheidet API-Key und persoenliche Anmeldung. - Neuer Test e2e-apikey: Key ueber die Admin-Routen einlegen, Modelle listen, Review durch die echte Queue gegen einen lokalen Anthropic/OpenAI/Gemini-Stand-in, inkl. Header, Cache-Block, Schema, Retry und Auth-Fehler. api 150, frontend 1029, mcp 45 gruen.
This commit is contained in:
1 parent
63cf1deaed
commit
02c75b320d
14 files changed
+311
-35
No files matched your search
+18
-5
@@ -18,9 +18,11 @@
|
||||
|
||||
openGym does not interpret any provider's terms on a self-hoster's behalf. It just makes
|
||||
the shape that doesn't need the interpretation available, and refuses the shape that does:
|
||||
in instance mode the credential binds to the first profile that uses it, and any other
|
||||
profile is refused rather than warned. A warning moves the decision onto whoever clicks
|
||||
past it — the same posture payload.js takes with its allowlist. */
|
||||
in instance mode a *personal* credential (a Claude Code setup token, an OAuth login) binds
|
||||
to the first profile that uses it, and any other profile is refused rather than warned. A
|
||||
warning moves the decision onto whoever clicks past it — the same posture payload.js takes
|
||||
with its allowlist. An API key is the other shape: metered, issued for exactly this kind of
|
||||
use, and shared by every profile on the instance under the daily caps. */
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
@@ -246,10 +248,21 @@ export function credentialFor(uid) {
|
||||
return { ok: true, auth, type: rec.type, account: rec.account || null, mode: 'instance' };
|
||||
}
|
||||
|
||||
/** First profile to actually spend the instance credential binds it. */
|
||||
/* Which credential types are one person's *subscription* — a Claude Code setup token or an
|
||||
OAuth login — as opposed to an API key, which is metered, pay-per-use, and issued precisely
|
||||
so that software can call the provider on behalf of many people. The binding below exists
|
||||
for the first kind: spending someone's personal subscription from another profile is what
|
||||
the provider terms forbid. An API key is what an admin pastes so their household can use the
|
||||
Coach; binding it to whoever happened to click first would just look broken, and the daily
|
||||
caps are what bound its spend. */
|
||||
export const isPersonalCredential = type => type === 'cli-token' || type === 'oauth';
|
||||
|
||||
/** First profile to actually spend the instance credential binds it — a personal credential
|
||||
* only; an API key is shared by every profile on the instance. */
|
||||
export function bindInstanceCredential(uid) {
|
||||
const cfg = load();
|
||||
if (cfg.authMode === 'instance' && !boundUidFor(cfg) && cfg.provider !== 'fixture' && authFor(cfg)) {
|
||||
const rec = authFor(cfg);
|
||||
if (cfg.authMode === 'instance' && !boundUidFor(cfg) && cfg.provider !== 'fixture' && rec && isPersonalCredential(rec.type)) {
|
||||
save({ boundUid: { ...cfg.boundUid, [cfg.provider]: uid } });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user