opencode prices and Go limits, settings out of .env
- Fetch prices for opencode (Zen and Go) incl. limits, image input, reasoning,
long-context tiers and peak-hour/date factors; costs apply them per request
- Record the cost opencode reports per response; track Go allowance in 5h/7d/month
windows against a provider plan limit (budget table, status overlay)
- Settings → Config file: move values of ${NAME} references into the config
- Examples, presets and forms keep keys in the config instead of .env
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
70367211c1
commit
bfa1f641d7
23 files changed
+723
-69
No files matched your search
@@ -66,6 +66,7 @@ pub fn router(app: AppState) -> Router {
|
||||
.route("/folders/{id}/access", put(set_folder_access))
|
||||
.route("/config", get(get_config).patch(patch_config))
|
||||
.route("/config/raw", get(get_config_raw).put(put_config_raw))
|
||||
.route("/config/inline-env", get(inline_env_preview).post(inline_env_apply))
|
||||
.route("/providers/reload", post(reload_providers))
|
||||
.route("/models", get(models))
|
||||
.route("/agents", get(agents))
|
||||
@@ -289,6 +290,24 @@ struct RawBody {
|
||||
text: String,
|
||||
}
|
||||
|
||||
/// Which ${VAR} references the config still has (and whether they are set).
|
||||
async fn inline_env_preview(Extension(user): Extension<User>, State(app): State<AppState>) -> ApiResult {
|
||||
require_admin(&user)?;
|
||||
let (_, set, unset) = config::inline_env(&app.config_text()?)?;
|
||||
Ok(Json(json!({"set": set, "unset": unset})))
|
||||
}
|
||||
|
||||
/// Move the values of set environment variables into the config file.
|
||||
async fn inline_env_apply(Extension(user): Extension<User>, State(app): State<AppState>) -> ApiResult {
|
||||
require_admin(&user)?;
|
||||
let (text, set, unset) = config::inline_env(&app.config_text()?)?;
|
||||
if !set.is_empty() {
|
||||
app.save_config(&text).await?;
|
||||
app.audit(Some(&user), "config.inline_env", set.join(", "), "");
|
||||
}
|
||||
Ok(Json(json!({"set": set, "unset": unset})))
|
||||
}
|
||||
|
||||
async fn put_config_raw(Extension(user): Extension<User>, State(app): State<AppState>, Json(body): Json<RawBody>) -> ApiResult {
|
||||
require_admin(&user)?;
|
||||
app.save_config(&body.text).await?;
|
||||
@@ -1192,6 +1211,10 @@ async fn status_overview(Extension(user): Extension<User>, State(app): State<App
|
||||
}),
|
||||
None => json!({"state": "unknown", "models": models}),
|
||||
};
|
||||
let mut v = v;
|
||||
if let Some(limit) = cfg.providers.get(name).and_then(|p| p.plan_limit).filter(|l| *l > 0.0) {
|
||||
v["plan"] = crate::budget::plan_usage(&app, name, limit).unwrap_or(Value::Null);
|
||||
}
|
||||
(name.clone(), v)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Reference in new issue
Block a user