@allansantos-dev/smart-tool 0.9.79 → 0.9.80
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/CHANGELOG.md +67 -0
- package/README.md +65 -18
- package/browser_control.py +10 -3
- package/browser_service_client.py +3 -32
- package/chromium_flags.py +30 -0
- package/code_health.py +180 -0
- package/code_impact.py +13 -1
- package/config.py +41 -8
- package/credential_check.py +38 -0
- package/dependency_notice.py +262 -14
- package/document_converter.py +221 -0
- package/document_read.py +100 -25
- package/document_text.py +194 -6
- package/dossier.py +35 -8
- package/embedding_cache.py +32 -8
- package/freshness.py +3 -2
- package/hook_decision.py +65 -14
- package/indexer.py +92 -3
- package/layer_check.py +57 -0
- package/local_embedder.py +114 -57
- package/locales/pt-BR.json +52 -17
- package/low_priority.py +41 -0
- package/package.json +1 -1
- package/pr_impact.py +111 -8
- package/process_limits.py +108 -0
- package/project_monitor.py +33 -7
- package/project_scheduler.py +12 -4
- package/scout.py +6 -2
- package/setup_audit.py +34 -1
- package/setup_ui.py +210 -39
- package/smart_tool_daemon.py +398 -91
- package/update_check.py +18 -0
- package/usage_meter.py +78 -0
- package/version.py +1 -1
- package/web_adapters/browser/crawl4ai_search.py +7 -3
- package/web_fetch.py +24 -0
- package/web_search_health.py +31 -0
package/setup_ui.py
CHANGED
|
@@ -32,14 +32,17 @@ import i18n
|
|
|
32
32
|
import model_catalog
|
|
33
33
|
import model_defaults
|
|
34
34
|
import model_health
|
|
35
|
+
import usage_meter
|
|
35
36
|
import model_upgrade
|
|
36
37
|
import local_embedder
|
|
37
38
|
import project_store
|
|
38
39
|
import secret_store
|
|
39
40
|
import setup_audit
|
|
41
|
+
import update_check
|
|
40
42
|
import integration_metrics
|
|
41
43
|
import version
|
|
42
44
|
import web_search_external
|
|
45
|
+
import web_search_health
|
|
43
46
|
|
|
44
47
|
SETUP_TOKEN = secrets.token_urlsafe(24)
|
|
45
48
|
|
|
@@ -204,6 +207,25 @@ def handle_health_get():
|
|
|
204
207
|
return model_health.summary()
|
|
205
208
|
|
|
206
209
|
|
|
210
|
+
def handle_usage_get():
|
|
211
|
+
"""The 30-day use of the model gateway over every project, per purpose, and the hourly volume alerts."""
|
|
212
|
+
return usage_meter.overview(30)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def handle_usage_mute(body):
|
|
216
|
+
"""Mutes the volume alert of `body["purpose"]` for 7 days and returns the refreshed overview."""
|
|
217
|
+
try:
|
|
218
|
+
usage_meter.mute_volume(body.get("purpose") if isinstance(body, dict) else None)
|
|
219
|
+
except ValueError as exc:
|
|
220
|
+
raise SetupError(str(exc))
|
|
221
|
+
return handle_usage_get()
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def handle_web_requesters_get():
|
|
225
|
+
"""Who asked the recent web searches: one row per client and project folder, never the query text."""
|
|
226
|
+
return web_search_health.by_requester()
|
|
227
|
+
|
|
228
|
+
|
|
207
229
|
def handle_notices():
|
|
208
230
|
"""What the tray should show now: the model offer (once a day until answered) and models over the failure limit
|
|
209
231
|
(once a day each). Fetching marks them announced, so each toast is shown once per reminder period. A project's
|
|
@@ -213,23 +235,40 @@ def handle_notices():
|
|
|
213
235
|
return {"upgrade": offer, "failing": model_health.alerts_due(), "check_error": upgrade["check_error"]}
|
|
214
236
|
|
|
215
237
|
|
|
216
|
-
def
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
def handle_embedder_get():
|
|
239
|
+
"""The chosen embedder and what the embeddings home answers: its model identity, whether a rerank host is
|
|
240
|
+
configured in it, or why it cannot be used."""
|
|
241
|
+
available, problem, base = None, "", None
|
|
242
|
+
try:
|
|
243
|
+
base = local_embedder.url()
|
|
244
|
+
available = local_embedder.info()
|
|
245
|
+
except local_embedder.IdentityError as exc:
|
|
246
|
+
problem = str(exc)
|
|
247
|
+
try:
|
|
248
|
+
choice = config.embedder()
|
|
249
|
+
except ValueError as exc:
|
|
250
|
+
choice, problem = None, str(exc)
|
|
251
|
+
return {"embedder": choice, "embedders": list(config.EMBEDDERS),
|
|
252
|
+
"home": {"announced": local_embedder.configured(), "announce": local_embedder.ANNOUNCE, "url": base,
|
|
253
|
+
"embedding_model": (available or {}).get("model"),
|
|
254
|
+
"rerank": bool((available or {}).get("rerank")), "error": problem}}
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def handle_embedder_save(body):
|
|
258
|
+
if not isinstance(body, dict) or body.get("embedder") not in config.EMBEDDERS:
|
|
259
|
+
raise SetupError("Invalid embedder: use home or gateway.")
|
|
221
260
|
|
|
261
|
+
def choose(cfg):
|
|
262
|
+
cfg.pop("local_models", None)
|
|
263
|
+
cfg["embedder"] = body["embedder"]
|
|
222
264
|
|
|
223
|
-
def handle_local_models_save(body):
|
|
224
|
-
if not isinstance(body, dict) or body.get("mode") not in config.LOCAL_MODEL_MODES:
|
|
225
|
-
raise SetupError("Invalid mode: use fallback, off or prefer.")
|
|
226
265
|
try:
|
|
227
|
-
config.update_config(
|
|
266
|
+
config.update_config(choose)
|
|
228
267
|
except config.ConfigCorruptedError as exc:
|
|
229
268
|
raise SetupError(str(exc))
|
|
230
269
|
except OSError as exc:
|
|
231
270
|
raise SetupError(f"Disk error while saving the configuration ({exc}); try again.")
|
|
232
|
-
return {"ok": True, **
|
|
271
|
+
return {"ok": True, **handle_embedder_get()}
|
|
233
272
|
|
|
234
273
|
|
|
235
274
|
def handle_integration_get():
|
|
@@ -266,6 +305,10 @@ def handle_integration_get():
|
|
|
266
305
|
dependency_mode, dependency_error = config.dependency_mode(), ""
|
|
267
306
|
except ValueError as exc:
|
|
268
307
|
dependency_mode, dependency_error = "", str(exc)
|
|
308
|
+
try:
|
|
309
|
+
layer_mode, layer_error = config.layer_mode(), ""
|
|
310
|
+
except ValueError as exc:
|
|
311
|
+
layer_mode, layer_error = "", str(exc)
|
|
269
312
|
try:
|
|
270
313
|
proposals_mode, proposals_error = config.pattern_proposals(), ""
|
|
271
314
|
except ValueError as exc:
|
|
@@ -281,6 +324,7 @@ def handle_integration_get():
|
|
|
281
324
|
"duplicate_mode_error": duplicate_error, "duplicate_modes": list(config.DUPLICATE_MODES),
|
|
282
325
|
"dependency_mode": dependency_mode, "dependency_mode_error": dependency_error,
|
|
283
326
|
"dependency_modes": list(config.DEPENDENCY_MODES),
|
|
327
|
+
"layer_mode": layer_mode, "layer_mode_error": layer_error, "layer_modes": list(config.LAYER_MODES),
|
|
284
328
|
"pattern_proposals": proposals_mode, "pattern_proposals_error": proposals_error,
|
|
285
329
|
"block_patterns": {"proposals": stored["proposals"], "accepted": stored["accepted"],
|
|
286
330
|
"rejected": len(stored["rejected"]), "error": patterns_error},
|
|
@@ -299,10 +343,11 @@ def handle_integration_save(body):
|
|
|
299
343
|
except (OSError, ValueError) as exc:
|
|
300
344
|
raise SetupError(str(exc))
|
|
301
345
|
return handle_integration_get()
|
|
302
|
-
if isinstance(body, dict) and body.get("action") in ("hook_mode", "doc_mode", "comment_mode", "duplicate_mode", "dependency_mode", "pattern_proposals"):
|
|
346
|
+
if isinstance(body, dict) and body.get("action") in ("hook_mode", "doc_mode", "comment_mode", "duplicate_mode", "dependency_mode", "layer_mode", "pattern_proposals"):
|
|
303
347
|
action = body["action"]
|
|
304
348
|
allowed = {"hook_mode": config.HOOK_MODES, "doc_mode": config.DOC_MODES, "comment_mode": config.COMMENT_MODES,
|
|
305
349
|
"duplicate_mode": config.DUPLICATE_MODES, "dependency_mode": config.DEPENDENCY_MODES,
|
|
350
|
+
"layer_mode": config.LAYER_MODES,
|
|
306
351
|
"pattern_proposals": config.PATTERN_PROPOSAL_MODES}[action]
|
|
307
352
|
if body.get("mode") not in allowed:
|
|
308
353
|
raise SetupError(f"Invalid mode: use {', '.join(allowed)}.")
|
|
@@ -442,6 +487,25 @@ def handle_autostart_get():
|
|
|
442
487
|
return autostart.status()
|
|
443
488
|
|
|
444
489
|
|
|
490
|
+
def handle_updates_get():
|
|
491
|
+
"""The update state for the Startup page: versions, last check, last update, a failed automatic try and the switch."""
|
|
492
|
+
return update_check.status()
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
def handle_updates_save(body):
|
|
496
|
+
"""{"enabled": bool}: the automatic update switch, the same `auto_update` key as the tray menu. Refused while the
|
|
497
|
+
environment opt-out is set, as the tray does, because the choice would have no effect."""
|
|
498
|
+
if not isinstance(body, dict) or not isinstance(body.get("enabled"), bool):
|
|
499
|
+
raise SetupError("Send {\"enabled\": true or false}.")
|
|
500
|
+
if update_check.env_opted_out():
|
|
501
|
+
raise SetupError(f"{update_check.ENV_OPT_OUT}=off is set: automatic updates stay off until it is removed.")
|
|
502
|
+
try:
|
|
503
|
+
config.update_config(lambda cfg: cfg.__setitem__("auto_update", body["enabled"]))
|
|
504
|
+
except (OSError, config.ConfigCorruptedError) as exc:
|
|
505
|
+
raise SetupError(str(exc))
|
|
506
|
+
return update_check.status()
|
|
507
|
+
|
|
508
|
+
|
|
445
509
|
def handle_autostart_action(body):
|
|
446
510
|
if not isinstance(body, dict):
|
|
447
511
|
raise SetupError("Request body must be a JSON object with 'action'.")
|
|
@@ -776,6 +840,13 @@ __I18N__
|
|
|
776
840
|
<div id="health-table"></div>
|
|
777
841
|
</div>
|
|
778
842
|
|
|
843
|
+
<div class="card" id="usage-card">
|
|
844
|
+
<div class="card-head"><h3>Model use (last 30 days)</h3><span class="pill" id="usage-pill" data-tone="busy">Checking</span></div>
|
|
845
|
+
<p class="lede">Calls, failures and, when the gateway reports them, tokens and cost, per purpose and over every project. A purpose whose calls in one hour pass twice its own busiest hour of the previous week (and at least 100) is flagged here; it never raises a notification.</p>
|
|
846
|
+
<div id="usage-table"></div>
|
|
847
|
+
<div class="msg" id="usage-msg" role="status"></div>
|
|
848
|
+
</div>
|
|
849
|
+
|
|
779
850
|
<div class="card" id="models-card">
|
|
780
851
|
<div class="card-head"><h3>2. Models</h3><span class="pill" id="models-pill" data-tone="busy">Checking</span></div>
|
|
781
852
|
<p class="lede">Any model id your gateway accepts. The gateway's catalog shows up as suggestions while you type.</p>
|
|
@@ -798,17 +869,17 @@ __I18N__
|
|
|
798
869
|
<div class="field"><label for="num-research-iterations">Maximum research rounds</label><span class="explain">How many search rounds a research may run before answering.</span><input type="number" id="num-research-iterations" step="1"><span class="hint" id="research-iterations-hint"></span></div>
|
|
799
870
|
<div class="field"><label for="num-quick-timeout">Quick search time limit (s)</label><span class="explain">How long a quick web search waits for its sources.</span><input type="number" id="num-quick-timeout" step="1"><span class="hint" id="quick-timeout-hint"></span></div>
|
|
800
871
|
</div>
|
|
801
|
-
<div class="field"><label for="num-site-memory-threshold">Per-site memory similarity</label><span class="explain">How close a new question must be to a remembered page of the same site to reuse it.</span><input type="number" id="num-site-memory-threshold" step="0.01"><span class="hint" id="site-memory-threshold-hint"></span></div>
|
|
872
|
+
<div class="field"><label for="num-site-memory-threshold">Per-site memory similarity</label><span class="explain">How close a new question must be to a remembered page of the same site to reuse it, with the gateway embedder; the embeddings home uses 0.62, measured on its model.</span><input type="number" id="num-site-memory-threshold" step="0.01"><span class="hint" id="site-memory-threshold-hint"></span></div>
|
|
802
873
|
</details>
|
|
803
874
|
<div class="actions"><button type="button" class="primary" id="btn-save-models">Save models</button></div>
|
|
804
875
|
<div class="msg" id="models-msg" role="status"></div>
|
|
805
876
|
</div>
|
|
806
877
|
</div>
|
|
807
878
|
|
|
808
|
-
<div class="card" id="
|
|
809
|
-
<div class="card-head"><h3>3.
|
|
810
|
-
<p class="lede">
|
|
811
|
-
<fieldset class="choice" id="
|
|
879
|
+
<div class="card" id="embedder-card">
|
|
880
|
+
<div class="card-head"><h3>3. Embedder</h3><span class="pill" id="embedder-pill" data-tone="busy">Checking</span></div>
|
|
881
|
+
<p class="lede">The embeddings home (casa-de-embeddings) is the embedding service of this machine, shared with other tools; its rerank connector forwards to the rerank host configured in it. Switching the embedder re-embeds each project in the background: the old index keeps answering until the new one is complete, then the old vectors are deleted.</p>
|
|
882
|
+
<fieldset class="choice" id="embedder-choice"><legend>Embedder for the project indexes</legend></fieldset>
|
|
812
883
|
</div>
|
|
813
884
|
</section>
|
|
814
885
|
|
|
@@ -820,6 +891,11 @@ __I18N__
|
|
|
820
891
|
<p class="lede">A key is tested with a real search before it is saved, and is protected by DPAPI in this Windows profile.</p>
|
|
821
892
|
<div id="provider-list"><p class="lede">Loading…</p></div>
|
|
822
893
|
</div>
|
|
894
|
+
<div class="card" id="requesters-card">
|
|
895
|
+
<h3>Who asked the searches</h3>
|
|
896
|
+
<p class="lede">The recent web search calls grouped by the client and project folder that made them. The text of a search is never recorded.</p>
|
|
897
|
+
<div id="requesters-table"></div>
|
|
898
|
+
</div>
|
|
823
899
|
<div class="card">
|
|
824
900
|
<h3>Your contact (optional)</h3>
|
|
825
901
|
<p class="lede">Wikimedia asks tools to name a contact in their User-Agent. It stays on this machine and is sent only to the search APIs.</p>
|
|
@@ -865,6 +941,13 @@ __I18N__
|
|
|
865
941
|
<div class="actions"><button type="button" id="btn-autostart-toggle" disabled>Checking</button></div>
|
|
866
942
|
<div class="msg" id="autostart-msg" role="status"></div>
|
|
867
943
|
</div>
|
|
944
|
+
<div class="card" id="updates-card">
|
|
945
|
+
<div class="card-head"><h3>Automatic updates</h3><span class="pill" id="updates-pill" data-tone="busy">Checking</span></div>
|
|
946
|
+
<p class="lede">Smart Tool checks npm at start and every 24 hours and, when this is on, installs a newer version by itself. The switch is the same as in the tray menu.</p>
|
|
947
|
+
<div id="updates-body"></div>
|
|
948
|
+
<div class="actions"><button type="button" id="btn-updates-toggle" disabled>Checking</button></div>
|
|
949
|
+
<div class="msg" id="updates-msg" role="status"></div>
|
|
950
|
+
</div>
|
|
868
951
|
<div class="card">
|
|
869
952
|
<h3>This installation</h3>
|
|
870
953
|
<dl class="facts">
|
|
@@ -880,7 +963,7 @@ __I18N__
|
|
|
880
963
|
const TOKEN = __SETUP_TOKEN__;
|
|
881
964
|
let status = __STATUS_JSON__;
|
|
882
965
|
const $ = (id) => document.getElementById(id);
|
|
883
|
-
const loaded = { integration: null, autostart: null, providers: null, audit: null };
|
|
966
|
+
const loaded = { integration: null, autostart: null, updates: null, providers: null, audit: null };
|
|
884
967
|
const failed = {};
|
|
885
968
|
let serviceDown = false;
|
|
886
969
|
|
|
@@ -1220,6 +1303,50 @@ async function loadHealth() {
|
|
|
1220
1303
|
$("health-table").textContent = "Could not read the failure log: " + error.message;
|
|
1221
1304
|
}
|
|
1222
1305
|
}
|
|
1306
|
+
function usageHtml(data) {
|
|
1307
|
+
const num = (value) => (value === null ? "-" : Number(value).toLocaleString());
|
|
1308
|
+
const cost = (value) => (value === null ? "-" : "$" + Number(value).toFixed(4));
|
|
1309
|
+
const rows = data.by_purpose.map((row) => `<tr><td>${esc(PURPOSE_LABELS[row.purpose] || row.purpose)}</td><td>${num(row.attempts)}</td><td>${num(row.errors)}</td><td>${num(row.prompt_tokens)}</td><td>${num(row.output_tokens)}</td><td>${cost(row.reported_usd)}</td></tr>`).join("");
|
|
1310
|
+
const alerts = data.volume.map((row) => `<li><strong>${esc(PURPOSE_LABELS[row.purpose] || row.purpose)}</strong>: ${row.attempts} calls this hour, limit ${row.threshold}`
|
|
1311
|
+
+ (row.muted ? " (muted)" : ` <button type="button" class="mute-volume" data-purpose="${esc(row.purpose)}">Mute for 7 days</button>`) + "</li>").join("");
|
|
1312
|
+
return (alerts ? `<h4>Volume alert</h4><ul>${alerts}</ul>` : "")
|
|
1313
|
+
+ (rows ? `<table><tr><th>Purpose</th><th>Calls</th><th>Failed</th><th>Prompt tokens</th><th>Output tokens</th><th>Reported cost</th></tr>${rows}</table>` : "<p>No model call in the last 30 days.</p>")
|
|
1314
|
+
+ data.notes.map((note) => `<p class="mono">${esc(note)}</p>`).join("");
|
|
1315
|
+
}
|
|
1316
|
+
async function loadUsage() {
|
|
1317
|
+
try {
|
|
1318
|
+
const data = await getJSON("/setup/usage");
|
|
1319
|
+
const active = data.volume.filter((row) => !row.muted).length;
|
|
1320
|
+
setPill("usage-pill", active ? "bad" : "ok", active ? plural(active, "volume alert") : plural(data.totals.attempts, "call"));
|
|
1321
|
+
$("usage-table").innerHTML = usageHtml(data);
|
|
1322
|
+
} catch (error) {
|
|
1323
|
+
setPill("usage-pill", "bad", "Unavailable");
|
|
1324
|
+
$("usage-table").textContent = "Could not read the usage meter: " + error.message;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function requestersHtml(data) {
|
|
1328
|
+
const rows = data.rows.map((row) => `<tr><td>${esc(row.client)}</td><td class="mono">${esc(row.project || "-")}</td><td>${row.sessions}</td><td>${row.calls}</td><td>${row.failed}</td><td>${esc(new Date(row.last_at * 1000).toLocaleString())}</td><td>${esc(row.sources.join(", "))}</td></tr>`).join("");
|
|
1329
|
+
return (rows ? `<table><tr><th>Client</th><th>Project</th><th>Sessions</th><th>Calls</th><th>Failed</th><th>Last</th><th>Attributed by</th></tr>${rows}</table>` : "<p>No web search recorded yet.</p>")
|
|
1330
|
+
+ (data.unattributed ? `<p class="mono">${plural(data.unattributed, "call")} came without a requester (a client that sent only its name).</p>` : "");
|
|
1331
|
+
}
|
|
1332
|
+
async function loadRequesters() {
|
|
1333
|
+
try {
|
|
1334
|
+
$("requesters-table").innerHTML = requestersHtml(await getJSON("/setup/web-search/requesters"));
|
|
1335
|
+
} catch (error) {
|
|
1336
|
+
$("requesters-table").textContent = "Could not read the search log: " + error.message;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
$("usage-table").addEventListener("click", async (event) => {
|
|
1340
|
+
const button = event.target.closest(".mute-volume");
|
|
1341
|
+
if (!button) return;
|
|
1342
|
+
try {
|
|
1343
|
+
await post("/setup/usage/mute", { purpose: button.dataset.purpose });
|
|
1344
|
+
await loadUsage();
|
|
1345
|
+
setMsg("usage-msg", "ok", "Volume alert muted for 7 days.");
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
setMsg("usage-msg", "error", error.message);
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1223
1350
|
$("btn-save-models").addEventListener("click", async () => {
|
|
1224
1351
|
if (!modelsLoaded) { setMsg("models-msg", "error", "The catalog has not loaded yet; nothing was saved."); return; }
|
|
1225
1352
|
setMsg("models-msg", "", "Saving…");
|
|
@@ -1277,34 +1404,34 @@ function checkRadio(name, value) {
|
|
|
1277
1404
|
for (const radio of document.querySelectorAll(`input[name="${name}"]`)) radio.checked = radio.value === value;
|
|
1278
1405
|
}
|
|
1279
1406
|
|
|
1280
|
-
const
|
|
1281
|
-
["
|
|
1282
|
-
["
|
|
1283
|
-
["off", "Never", "Always use the gateway."],
|
|
1407
|
+
const EMBEDDER_OPTIONS = [
|
|
1408
|
+
["home", "Embeddings home", "The embedding service of this machine; your code goes to the address it announces, not to the gateway.", true],
|
|
1409
|
+
["gateway", "Gateway", "The gateway's embedding_model and rerank_model; your code goes to the gateway."],
|
|
1284
1410
|
];
|
|
1285
|
-
let
|
|
1286
|
-
const
|
|
1287
|
-
setMsg(
|
|
1411
|
+
let embedderChoice = null;
|
|
1412
|
+
const embedderSaved = choiceGroup($("embedder-choice"), "embedder", EMBEDDER_OPTIONS, null, async (embedder) => {
|
|
1413
|
+
setMsg(embedderSaved, "", "Saving…");
|
|
1288
1414
|
try {
|
|
1289
|
-
await post("/setup/
|
|
1290
|
-
|
|
1291
|
-
setMsg(
|
|
1415
|
+
await post("/setup/embedder", { embedder });
|
|
1416
|
+
embedderChoice = embedder;
|
|
1417
|
+
setMsg(embedderSaved, "ok", "Saved. Each project is re-embedded in the background; its old index answers meanwhile.");
|
|
1292
1418
|
} catch (error) {
|
|
1293
|
-
checkRadio("
|
|
1294
|
-
setMsg(
|
|
1419
|
+
checkRadio("embedder", embedderChoice);
|
|
1420
|
+
setMsg(embedderSaved, "error", error.message);
|
|
1295
1421
|
}
|
|
1296
1422
|
});
|
|
1297
|
-
async function
|
|
1423
|
+
async function loadEmbedder() {
|
|
1298
1424
|
try {
|
|
1299
|
-
const data = await getJSON("/setup/
|
|
1300
|
-
|
|
1301
|
-
checkRadio("
|
|
1302
|
-
if (
|
|
1303
|
-
else if (data.
|
|
1304
|
-
else setPill("
|
|
1425
|
+
const data = await getJSON("/setup/embedder");
|
|
1426
|
+
embedderChoice = data.embedder;
|
|
1427
|
+
checkRadio("embedder", data.embedder);
|
|
1428
|
+
if (data.home.error) setPill("embedder-pill", "warn", data.home.error);
|
|
1429
|
+
else if (!data.home.announced) setPill("embedder-pill", "idle", "Embeddings home not running");
|
|
1430
|
+
else if (data.home.embedding_model) setPill("embedder-pill", "ok", "Embeddings home answering: " + data.home.embedding_model + (data.home.rerank ? " · rerank host configured" : ""));
|
|
1431
|
+
else setPill("embedder-pill", "warn", "Embeddings home not answering (" + data.home.url + ")");
|
|
1305
1432
|
} catch (error) {
|
|
1306
|
-
setPill("
|
|
1307
|
-
setMsg(
|
|
1433
|
+
setPill("embedder-pill", "bad", "Status unavailable");
|
|
1434
|
+
setMsg(embedderSaved, "error", error.message);
|
|
1308
1435
|
}
|
|
1309
1436
|
}
|
|
1310
1437
|
|
|
@@ -1332,6 +1459,10 @@ const RULES = [
|
|
|
1332
1459
|
intro: "Looks up the dependencies an edit of a dependency manifest adds or changes in the OSV advisory database. It never blocks.",
|
|
1333
1460
|
options: [["warn", "Warn", "The edit runs; the agent is told which added or changed dependencies have known advisories.", true],
|
|
1334
1461
|
["off", "Off", "No dependency checks and no network call."]] },
|
|
1462
|
+
{ key: "layer_mode", title: "Calls that go up the layers on edit", applies: "Applies on the next edit.",
|
|
1463
|
+
intro: "When the project has confirmed layers (.smart-tool/layers.json), warns about a call an edit adds from a lower layer to a function of a higher one. A project without layers is never checked. It never blocks.",
|
|
1464
|
+
options: [["warn", "Warn", "The edit runs; the agent is told which new calls go up the layers.", true],
|
|
1465
|
+
["off", "Off", "No layer checks."]] },
|
|
1335
1466
|
{ key: "pattern_proposals", title: "Block patterns proposed by a model", applies: "Applies to the next review.",
|
|
1336
1467
|
intro: "Afterwards, never delaying a call, the scope model (else the router model) reviews searches the fixed rule let through and may propose block patterns. Nothing blocks until you accept it on the Redirects page.",
|
|
1337
1468
|
options: [["on", "On", "Review in the background and list proposals for you.", true],
|
|
@@ -1747,6 +1878,43 @@ $("btn-autostart-toggle").addEventListener("click", async () => {
|
|
|
1747
1878
|
}
|
|
1748
1879
|
});
|
|
1749
1880
|
|
|
1881
|
+
function updatesHtml(data) {
|
|
1882
|
+
const when = (at) => esc(new Date(at * 1000).toLocaleString());
|
|
1883
|
+
const lines = [`<p>Installed: ${esc(data.installed)}.</p>`, data.checked_at ? `<p>Last check: ${when(data.checked_at)}.</p>` : "<p>Not checked yet.</p>"];
|
|
1884
|
+
if (data.available) lines.push(`<p>Version ${esc(data.latest)} is available. To update by hand, run <span class="mono">${esc(data.command)}</span></p>`);
|
|
1885
|
+
else if (data.checked_at) lines.push("<p>Smart Tool is up to date.</p>");
|
|
1886
|
+
if (data.updated) lines.push(`<p>Updated from ${esc(data.updated.from)} to ${esc(data.updated.to)} on ${when(data.updated.at)}.</p>`);
|
|
1887
|
+
if (data.failed) lines.push(`<p class="msg error">The last automatic update to ${esc(data.failed)} failed; ${esc(data.installed)} is still installed.</p>`);
|
|
1888
|
+
if (data.env_opt_out) lines.push('<p class="hint">SMART_TOOL_AUTO_UPDATE=off is set in the environment: automatic updates stay off until it is removed.</p>');
|
|
1889
|
+
return lines.join("");
|
|
1890
|
+
}
|
|
1891
|
+
async function loadUpdates() {
|
|
1892
|
+
try {
|
|
1893
|
+
loaded.updates = await getJSON("/setup/updates");
|
|
1894
|
+
const data = loaded.updates;
|
|
1895
|
+
setPill("updates-pill", data.automatic ? "ok" : "idle", data.automatic ? "On" : "Off");
|
|
1896
|
+
$("updates-body").innerHTML = updatesHtml(data);
|
|
1897
|
+
const toggle = $("btn-updates-toggle");
|
|
1898
|
+
toggle.disabled = data.env_opt_out;
|
|
1899
|
+
toggle.className = data.enabled ? "" : "primary";
|
|
1900
|
+
toggle.textContent = data.enabled ? "Turn off" : "Turn on";
|
|
1901
|
+
} catch (error) {
|
|
1902
|
+
setPill("updates-pill", "bad", "Status unavailable");
|
|
1903
|
+
setMsg("updates-msg", "error", error.message);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
$("btn-updates-toggle").addEventListener("click", async () => {
|
|
1907
|
+
$("btn-updates-toggle").disabled = true;
|
|
1908
|
+
try {
|
|
1909
|
+
await post("/setup/updates", { enabled: !loaded.updates.enabled });
|
|
1910
|
+
await loadUpdates();
|
|
1911
|
+
setMsg("updates-msg", "ok", loaded.updates.enabled ? "Automatic updates turned on." : "Automatic updates turned off.");
|
|
1912
|
+
} catch (error) {
|
|
1913
|
+
setMsg("updates-msg", "error", error.message);
|
|
1914
|
+
$("btn-updates-toggle").disabled = false;
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1917
|
+
|
|
1750
1918
|
const PROVIDER_STATES = { keyless: ["ok", "Free tier, no key"], configured: ["ok", "Your key"], unreadable: ["bad", "Key unreadable"] };
|
|
1751
1919
|
function providerRow(name, info) {
|
|
1752
1920
|
const entry = node("div", "provider-row");
|
|
@@ -1998,7 +2166,10 @@ renderGateway();
|
|
|
1998
2166
|
renderOverview();
|
|
1999
2167
|
if (status.gateway.status === "ready") { loadModels(); loadUpgrade(); }
|
|
2000
2168
|
loadHealth();
|
|
2001
|
-
|
|
2169
|
+
loadUsage();
|
|
2170
|
+
loadRequesters();
|
|
2171
|
+
loadUpdates();
|
|
2172
|
+
loadEmbedder();
|
|
2002
2173
|
loadIntegration();
|
|
2003
2174
|
loadAutostart();
|
|
2004
2175
|
loadProviders();
|