model: runtime override via /model slash; fixes for port + bind
- runtime model override: Bus::{model,set_model} + POST /api/model
(form-encoded {model: name}). turn.rs reads bus.model() per turn
so a flip lands on the next claude invocation. /api/state grows
a model field; agent page shows a 'model · <name>' chip in the
state row. '/model <name>' slash command POSTs to the endpoint
and refreshes state.
- port regression fix: agent_web_port no longer probes forward for
*existing* agents (the previous fix shifted ports for any agent
without a port file, including legacy ones whose container was
already bound to the bare hashed port — dashboard rendered the
new port, container was still on the old one, conn errors). new
rule: port file exists → use it; absent + applied flake present
→ legacy, persist port_hash without probing; absent + no applied
flake → fresh spawn, probe forward.
- SO_REUSEADDR on both the dashboard and per-agent web UI binds
via tokio::net::TcpSocket. operator hit 12 retries failing on
manager :8000 — REUSEADDR handles the TIME_WAIT case cleanly
without a new dep; retry still covers the genuine
process-still-alive overlap.
todo: drops the model-override entry (shipped); adds two new
items — model persistence (optional, future), and custom
per-agent MCP tools (groundwork for moving bitburner-agent into
hyperhive).
This commit is contained in:
parent
7d93dd9db4
commit
6db38cf70c
9 changed files with 196 additions and 39 deletions
|
|
@ -174,8 +174,31 @@
|
|||
{ name: '/clear', desc: 'wipe the terminal panel (local-only)' },
|
||||
{ name: '/cancel', desc: 'SIGINT the in-flight claude turn' },
|
||||
{ name: '/compact', desc: 'compact the persistent claude session' },
|
||||
{ name: '/model', desc: '/model <name> — switch claude model for future turns' },
|
||||
];
|
||||
|
||||
async function postModel(name) {
|
||||
try {
|
||||
const resp = await fetch('/api/model', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams({ model: name }),
|
||||
redirect: 'manual',
|
||||
});
|
||||
const ok = resp.ok || resp.type === 'opaqueredirect'
|
||||
|| (resp.status >= 200 && resp.status < 400);
|
||||
if (!ok && termAPI) {
|
||||
const text = await resp.text().catch(() => '');
|
||||
termAPI.row('turn-end-fail', '✗ /model failed: ' + resp.status
|
||||
+ (text ? ' — ' + text : ''));
|
||||
} else {
|
||||
refreshState();
|
||||
}
|
||||
} catch (err) {
|
||||
if (termAPI) termAPI.row('turn-end-fail', '✗ /model failed: ' + err);
|
||||
}
|
||||
}
|
||||
|
||||
async function postSimple(url, label) {
|
||||
try {
|
||||
const resp = await fetch(url, { method: 'POST', redirect: 'manual' });
|
||||
|
|
@ -213,6 +236,16 @@
|
|||
case '/compact':
|
||||
postCompact();
|
||||
return true;
|
||||
case '/model': {
|
||||
const parts = trimmed.split(/\s+/);
|
||||
if (parts.length < 2 || !parts[1]) {
|
||||
termAPI.row('turn-end-fail',
|
||||
'✗ /model needs a name (e.g. /model haiku, /model sonnet, /model opus)');
|
||||
} else {
|
||||
postModel(parts[1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
termAPI.row('turn-end-fail', '✗ unknown slash command: ' + cmd + ' — try /help');
|
||||
return true;
|
||||
|
|
@ -365,6 +398,13 @@
|
|||
list.append(li);
|
||||
}
|
||||
}
|
||||
function renderModelChip(model) {
|
||||
const el_ = $('model-chip');
|
||||
if (!el_) return;
|
||||
if (!model) { el_.hidden = true; return; }
|
||||
el_.hidden = false;
|
||||
el_.textContent = 'model · ' + model;
|
||||
}
|
||||
function renderLastTurn(ms) {
|
||||
const el_ = $('last-turn');
|
||||
if (!el_) return;
|
||||
|
|
@ -424,6 +464,7 @@
|
|||
} else if (s.turn_state) {
|
||||
setStateAbs(s.turn_state, s.turn_state_since);
|
||||
}
|
||||
renderModelChip(s.model);
|
||||
// Skip the re-render if nothing structurally changed. The most
|
||||
// common case is `online` polling itself — without this guard, the
|
||||
// operator's <input value> gets clobbered every cycle.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue