u
This commit is contained in:
@@ -169,7 +169,7 @@ Company-scoped key/value settings. Auth via selected company (`google_auth.selec
|
||||
- With `frontendOnly: true`, backend-only keys are omitted / `get` returns `undefined` (no leak via error type beyond missing).
|
||||
- `writeonly: true` → usergui gets a `"***"` scrambled version when retrieving the key (in `list`, or in `get` when `maskWriteonly` is enabled / `frontendOnly: true`). The backend receives the full value.
|
||||
- `keys.tavily`, `keys.openrouter`, and `keys.serper` default to `writeonly: true` on `set`.
|
||||
- `set` only allows a fixed allow-list of keys: `ui.theme`, `keys.tavily`, `keys.openrouter`, `keys.serper`, `systemprompt-prefix`, `systemprompt-suffix`, `default-model`.
|
||||
- `set` only allows a fixed allow-list of keys: `ui.theme`, `keys.tavily`, `keys.openrouter`, `keys.serper`, `systemprompt-prefix`, `systemprompt-suffix`, `default-model`, `modelslug`, `modelslugflag`, `modelreasoning`, `modelslugimage`.
|
||||
- No delete endpoint — settings are upsert / read only.
|
||||
|
||||
Errors: `No company selected`, `Company not found`, `Not authorized`, `Invalid setting`.
|
||||
|
||||
@@ -18,6 +18,10 @@ const ALLOWED_KEYS = new Set([
|
||||
'systemprompt-prefix',
|
||||
'systemprompt-suffix',
|
||||
'default-model',
|
||||
'modelslug',
|
||||
'modelslugflag',
|
||||
'modelreasoning',
|
||||
'modelslugimage',
|
||||
]);
|
||||
|
||||
const WRITEONLY_KEYS = new Set([
|
||||
@@ -59,6 +63,17 @@ export default function set(provider) {
|
||||
if (typeof input.value !== 'string') {
|
||||
throw new Error('Invalid setting');
|
||||
}
|
||||
const trimmedVal = input.value.trim();
|
||||
let value = input.value;
|
||||
if (key === 'modelslug' && !trimmedVal) {
|
||||
value = 'openai/gpt-6-luna';
|
||||
}
|
||||
if (key === 'modelslugflag' && !['', 'floor', 'nitro'].includes(trimmedVal)) {
|
||||
throw new Error('Invalid setting');
|
||||
}
|
||||
if (key === 'modelreasoning' && !['none', 'low', 'medium', 'high'].includes(trimmedVal)) {
|
||||
throw new Error('Invalid setting');
|
||||
}
|
||||
|
||||
const runner = makeRunner(provider, tx);
|
||||
const frontend = Boolean(input.frontend);
|
||||
@@ -71,7 +86,7 @@ export default function set(provider) {
|
||||
await runner.query(upsertSql, {
|
||||
companyId,
|
||||
key,
|
||||
value: input.value,
|
||||
value,
|
||||
frontend: isSqlite ? (frontend ? 1 : 0) : frontend,
|
||||
writeonly: isSqlite ? (writeonly ? 1 : 0) : writeonly,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user