mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-29 23:41:35 +08:00
Compare commits
3 Commits
fix/plugin
...
bb/tui-rel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
059652d11a | ||
|
|
fac81a30df | ||
|
|
faafa6d375 |
@@ -2721,6 +2721,8 @@ def test_session_most_recent_handles_db_unavailable(monkeypatch):
|
||||
)
|
||||
|
||||
assert resp["result"]["session_id"] is None
|
||||
|
||||
|
||||
# ── browser.manage ───────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -3010,3 +3012,39 @@ def test_browser_manage_disconnect_drops_env_and_cleans(monkeypatch):
|
||||
assert "BROWSER_CDP_URL" not in os.environ
|
||||
# Two cleanups: once before env removal, once after, matching connect.
|
||||
assert cleanup_count["n"] == 2
|
||||
|
||||
|
||||
# ── reload.env ───────────────────────────────────────────────────────
|
||||
|
||||
|
||||
def test_reload_env_rpc_calls_hermes_cli_reload_env(monkeypatch):
|
||||
"""reload.env mirrors classic CLI's `/reload` — re-reads ~/.hermes/.env
|
||||
into the gateway process and reports the count of vars updated."""
|
||||
calls = {"n": 0}
|
||||
|
||||
def _fake_reload():
|
||||
calls["n"] += 1
|
||||
return 7
|
||||
|
||||
fake = types.SimpleNamespace(reload_env=_fake_reload)
|
||||
with patch.dict(sys.modules, {"hermes_cli.config": fake}):
|
||||
resp = server.handle_request(
|
||||
{"id": "1", "method": "reload.env", "params": {}}
|
||||
)
|
||||
|
||||
assert resp["result"] == {"updated": 7}
|
||||
assert calls["n"] == 1
|
||||
|
||||
|
||||
def test_reload_env_rpc_surfaces_errors(monkeypatch):
|
||||
def _broken():
|
||||
raise RuntimeError("env path locked")
|
||||
|
||||
fake = types.SimpleNamespace(reload_env=_broken)
|
||||
with patch.dict(sys.modules, {"hermes_cli.config": fake}):
|
||||
resp = server.handle_request(
|
||||
{"id": "1", "method": "reload.env", "params": {}}
|
||||
)
|
||||
|
||||
assert "error" in resp
|
||||
assert "env path locked" in resp["error"]["message"]
|
||||
|
||||
@@ -3383,6 +3383,27 @@ def _(rid, params: dict) -> dict:
|
||||
return _err(rid, 5015, str(e))
|
||||
|
||||
|
||||
@method("reload.env")
|
||||
def _(rid, params: dict) -> dict:
|
||||
"""Re-read ``~/.hermes/.env`` into the gateway process via
|
||||
``hermes_cli.config.reload_env``, matching classic CLI's ``/reload``
|
||||
handler. Newly added API keys take effect on the next agent call
|
||||
without restarting the TUI.
|
||||
|
||||
The credential pool / provider routing for any *already-constructed*
|
||||
agent does not auto-rebuild — that's the same behaviour as classic
|
||||
CLI's ``/reload``. Users who want a brand-new credential resolution
|
||||
should follow with ``/new``.
|
||||
"""
|
||||
try:
|
||||
from hermes_cli.config import reload_env
|
||||
|
||||
count = reload_env()
|
||||
return _ok(rid, {"updated": int(count)})
|
||||
except Exception as e:
|
||||
return _err(rid, 5015, str(e))
|
||||
|
||||
|
||||
_TUI_HIDDEN: frozenset[str] = frozenset(
|
||||
{
|
||||
"sethome",
|
||||
|
||||
@@ -193,6 +193,7 @@ describe('createSlashHandler', () => {
|
||||
it.each([
|
||||
['/browser status', 'browser.manage', { action: 'status' }],
|
||||
['/reload-mcp', 'reload.mcp', { session_id: null }],
|
||||
['/reload', 'reload.env', {}],
|
||||
['/stop', 'process.stop', {}],
|
||||
['/fast status', 'config.get', { key: 'fast', session_id: null }],
|
||||
['/busy status', 'config.get', { key: 'busy' }]
|
||||
|
||||
@@ -2,6 +2,7 @@ import type {
|
||||
BrowserManageResponse,
|
||||
DelegationPauseResponse,
|
||||
ProcessStopResponse,
|
||||
ReloadEnvResponse,
|
||||
ReloadMcpResponse,
|
||||
RollbackDiffResponse,
|
||||
RollbackListResponse,
|
||||
@@ -89,6 +90,24 @@ export const opsCommands: SlashCommand[] = [
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
help: 're-read ~/.hermes/.env into the running gateway (CLI parity)',
|
||||
name: 'reload',
|
||||
run: (_arg, ctx) => {
|
||||
ctx.gateway
|
||||
.rpc<ReloadEnvResponse>('reload.env', {})
|
||||
.then(
|
||||
ctx.guarded<ReloadEnvResponse>(r => {
|
||||
const n = Number(r.updated ?? 0)
|
||||
const noun = n === 1 ? 'var' : 'vars'
|
||||
|
||||
ctx.transcript.sys(`reloaded .env (${n} ${noun} updated)`)
|
||||
})
|
||||
)
|
||||
.catch(ctx.guardedErr)
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
help: 'manage browser CDP connection [connect|disconnect|status]',
|
||||
name: 'browser',
|
||||
|
||||
@@ -300,6 +300,10 @@ export interface ReloadMcpResponse {
|
||||
status?: string
|
||||
}
|
||||
|
||||
export interface ReloadEnvResponse {
|
||||
updated?: number
|
||||
}
|
||||
|
||||
export interface ProcessStopResponse {
|
||||
killed?: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user