Commit Graph

28271 Commits

Author SHA1 Message Date
Teknium 517f593af9 refactor(plugins/google_meet): run_bot extraction, subcommand tables, shared json-file helper, node protocol dedupe 2026-09-02 13:30:10 -07:00
Teknium 74edfe04e9 refactor(plugins/spotify): action dispatch table, single request helper 2026-09-02 13:30:10 -07:00
Teknium eb60dd519e refactor(plugins/teams_pipeline): subcommand dispatch, unified download/Graph helpers, compact models 2026-09-02 13:30:10 -07:00
Teknium 238260e6aa refactor(plugins/dashboard_auth): shared session/JWT/config helpers in _shared; compact basic/drain/nous/self_hosted 2026-09-02 13:30:10 -07:00
Teknium 191cc8d30a refactor(plugins/web): BaseWebSearchProvider + _common helpers across all search providers; keyless_mcp failover cleanup 2026-09-02 13:30:10 -07:00
Teknium e43f381b4e refactor(plugins/browser): shared BaseCloudBrowserProvider for browser_use/browserbase/firecrawl 2026-09-02 13:30:10 -07:00
Teknium 75b7e054a5 refactor(plugins/video_gen): fal/xai — shared model tables, submit/poll/download helpers, dedupe validation 2026-09-02 13:30:10 -07:00
Teknium b5b62aa83d refactor(plugins/image_gen): shared _common (config/key/save/error/picker helpers), convert all 8 providers, per-model tables 2026-09-02 13:30:10 -07:00
Teknium 994e844388 refactor(plugins/observability): langfuse — extract capture/redaction and trace-state lifecycle modules with deduped observation helpers 2026-09-02 13:30:10 -07:00
Teknium 57c35858e3 refactor(plugins/memory): holographic/supermemory/retaindb/byterover — action dispatch tables, unified HTTP helpers, dead code removal; provider registry dedupe 2026-09-02 13:30:10 -07:00
Teknium 87a450145c refactor(plugins/memory): mem0 — table-driven setup prompts, tool dispatch, compact backend 2026-09-02 13:30:10 -07:00
Teknium 64f430a051 refactor(plugins/memory): honcho — extract session context/auth/peers/migration, dialectic, client cache, tool schemas; unify _parse_* config helpers; table-driven CLI 2026-09-02 13:30:09 -07:00
Teknium 3cd4d6d69a refactor(plugins/memory): hindsight — split settings/embedded/setup modules, unify config parsing, remove dead helpers 2026-09-02 13:30:09 -07:00
Teknium 365485a9f6 refactor(plugins/memory): openviking — remove dead search/rebuild/migrate paths, extract setup/CLI with dedupe, action dispatch tables 2026-09-02 13:30:09 -07:00
Teknium b54cc716c7 refactor(plugins): shared path-based plugin loader; dedupe cron_providers/context_engine discovery; compact plugin_utils/plugin_storage 2026-09-02 13:30:09 -07:00
Teknium 3d5f9269c7 refactor(web): extract files/fs/media routes into web_routers/files.py 2026-09-02 13:30:05 -07:00
Teknium f0f7f55f76 refactor(web): dashboard_auth/web_routers/kanban dedupe + _common helpers (resume — verified partial work) 2026-09-02 13:30:05 -07:00
Teknium a53d886584 refactor(agent/transports): compact ACP/SSL/stream helper modules (copilot_acp_client, acp_openai_bridge, ssl_*, stream_*, jiter_preload) 2026-09-02 13:29:48 -07:00
Teknium 624a752e79 refactor(agent/runtime): deadline/file_safety/estop/lifecycle leaf modules — dedupe result plumbing, drop dead guard code
- deadline: _result()/_abandon() replace 7 BoundedResult constructions and 2
  cancel+callback sites; timers handled as a list; dead raise_if_timed_out removed.
- file_safety: retired classify_cross_profile_target (0 refs; get_cross_profile_warning
  stub kept for external callers), _home_and_resolved/_mirror_warning shared by
  the sandbox/container mirror guards; _find_sandbox_mirror_segments inlined.
- estop: _hermes_home/_canonical_root now the file_safety helpers;
  _reset_log_state_for_tests inlined into its only test.
- subagent_lifecycle: _validate_request driven by _UNSUPPORTED_REQUEST_FIELDS table.
- turn_liveness: dead start()/_abort_message removed, _emit_warning shared.
- process_bootstrap: _enable_happy_eyeballs reused by the client variant.
- Comment/docstring compaction across the remaining leaf modules.
2026-09-02 13:29:48 -07:00
Teknium d2b3e545cb refactor(agent/transports): shared codex turn driver, build_kwargs phase helpers, dispatch tables in projector/accumulator, base finish-reason mapping 2026-09-02 13:29:48 -07:00
Teknium 4bfc55fbf0 refactor(agent/runtime): hooks/guardrails/dispatch — unify shell-hook and webhook plumbing, table-driven guardrail thresholds
- shell_hooks is the shared home: _ToolMatcherMixin (matcher compile + matches_tool),
  _payload_fields, _forget_home_registrations, _home_key, _utc_now_iso now serve
  outbound_webhooks too (copies deleted; every log string byte-identical).
- shell_hooks: response parsing is a per-event dispatch table; _spawn diagnostic
  dict + _evaluate_result shared by the live callback and run_once;
  _locked_update_approvals POSIX/non-POSIX bodies merged via ExitStack.
- tool_guardrails: ToolCallGuardrailConfig thresholds from a _THRESHOLD_SOURCES
  table (nested-wins-over-flat preserved); _int_at_least replaces
  _positive_int/_non_negative_int; observe_identical_call (0 refs) folded into
  observe_call; _halt helper for hard-stop decisions.
- tool_dispatch_helpers: _plan_tool_batch_segments split into _batch_admission +
  close/extend helpers with the post-hoc normalization merged in.
- Comment/docstring compaction keeping every stated rule.
2026-09-02 13:29:48 -07:00
Teknium 00cd12f7e4 refactor(agent/relay): fold relay_llm attempt scaffolding into _ManagedAttempt; dedupe runtime session/scope paths; drop dead relay_runtime module-level shims 2026-09-02 13:29:48 -07:00
Teknium a7cd02d1bd refactor(agent/proxy_sources): simplify iron_proxy — unify subprocess/file/yaml helpers, extract start_proxy and env-builder phases, drop dead readers 2026-09-02 13:29:48 -07:00
Teknium 6a88ec4eb3 refactor(agent/adapters): simplify azure identity, response guards, error surface, retry utils (-603 LOC)
Drop dead read_error_body_or_default / LAYER_RUNTIME; inline single-use
_build_default_credential/_safe_close; compact incident narratives to their
invariants in the guards. Byte-cap and deadline semantics of
read_streaming_error_body verified identical.
2026-09-02 13:29:47 -07:00
Teknium 79469656e7 refactor(agent): extract pre-classification API-error recovery into agent/turn_recovery.py 2026-09-02 13:29:47 -07:00
Teknium 2ad284b473 refactor(agent/runtime): pet — shared flood/placement helpers in atlas, provider resolution loop, dead helpers removed
- atlas: _border_flood/_unvisited_components/_place/_clear_region/_remove_masked
  replace 6 hand-rolled flood + canvas-composite loops; _sever_expected_gutters
  uses channel ops instead of per-pixel writes; dead _color_distance,
  _has_slot_padding, _slot_bounds, atlas_to_webp_bytes, FRAME_COUNTS (0 refs).
- render/store: dead _open_sheet/_png_bytes/_union_alpha_bbox/_thumbs_dir removed.
- imagegen: _available() unifies 3 provider-availability checks; forced/preferred
  provider resolution collapsed into one ordered loop (same precedence).
- state: derive_pet_state as a ranked table (same priority order).
- Comment/docstring compaction keeping the pipeline invariants.
2026-09-02 13:29:47 -07:00
Teknium 63abd4d174 refactor(agent/adapters): simplify plugin_llm, backend_identity, stream hooks (-447 LOC)
PluginLlm's four public entry points share _gate/_finish/_host_kwargs; drop
dead classify_failure_scope/_REASON_SCOPES (and their tests) and unify the
three _norm_* helpers; should_skip_candidate routes through a scope predicate
table. Injected caller kwargs, audit dicts and log lines unchanged.
2026-09-02 13:29:47 -07:00
Teknium 7eb8ccc315 refactor(agent/runtime): monitoring — shared OTLP plumbing in otlp_exporter, event base class, EmitterStreamer, dedupe health export
- otlp_exporter hosts SDK loading (symbol table), header/endpoint/resource helpers
  shared with gateway_health_export; export module imports them instead of
  keeping copies (_otlp_config/_resolve_headers/_install_id/_safe_resource_attributes
  unified). _KEEP_BY_KIND attribute allowlist reused for diagnostic log attrs.
- events: _MonitoringEvent base supplies to_dict; field order (wire order) unchanged.
- redaction: redact_bounded() replaces 3 inline redact+truncate try/excepts.
- EmitterStreamer base owns the shared unsubscribe/flush/shutdown for
  OTLPStreamer and GatewayDiagnosticLogStreamer.
- gateway_health: metric construction helpers, _contains_any shared with
  cron_health, dead _allowed_logger/redact_gateway_message removed (0 refs).
- Comment/docstring compaction keeping every stated invariant.
2026-09-02 13:29:47 -07:00
Teknium 1db2452272 refactor(agent/adapters): simplify gemini, vertex, moonshot adapters (-607 LOC)
Collapse the four Gemini chat/completions wrapper classes into SimpleNamespace
shims, finish-reason/tool-choice/HTTP-error mappings become dicts, shared
_usage_from_metadata/_assistant_message between sync and streaming translation,
vertex credential loading split into _load_credentials/_needs_refresh.
Gemini request/response/schema output byte-identical against merge-base.
2026-09-02 13:29:47 -07:00
Teknium 267cdbecf3 refactor(agent/adapters): simplify anthropic adapter, message convert, endpoints (-857 LOC)
Table-driven model capability checks and beta-header assembly, shared
_cache_control_of/_block_type/_image_block_from_data_url helpers in the message
converter, extracted _apply_claude_code_identity/_base_client_kwargs.
convert_messages_to_anthropic / convert_tools_to_anthropic and request kwargs
verified byte-identical against merge-base.
2026-09-02 13:29:47 -07:00
Teknium 841d9ff4a8 refactor(agent/adapters): simplify codex responses adapter and runtime (-1080 LOC)
Split _preflight_codex_input_items into per-item-type helpers over a
_PreflightCtx; streaming assembly moves into _CodexResponseAssembler with a
per-event dispatch table; run_codex_app_server_turn loses its session/usage/
interrupt regions to _ensure_codex_session/_finish_codex_turn/
_consume_user_interrupt/_queue_token_counts (counts built lazily so stub agents
without a session DB are never touched). Responses input/normalization and
stream callback order verified byte-identical against merge-base.
2026-09-02 13:29:47 -07:00
Teknium ba8b7a4e0d refactor(agent/adapters): simplify bedrock adapter (-639 LOC)
Drop dead call_converse_stream / classify_bedrock_error / is_context_overflow_error
(zero refs) and their tests; stop-reason mapping becomes a dict; extract
_cache_point/_assistant_blocks/_append_turn/_cached_client helpers; compact
incident narratives to their invariants. Converse wire output byte-identical.
2026-09-02 13:29:47 -07:00
Teknium dd522d0f77 refactor(agent/creds): unify Anthropic credential I/O and rate-limit header helpers (-30% LOC)
- anthropic_credentials: _load_json_if_exists / _claude_oauth_record /
  _atomic_write_private_json / _post_oauth_token / _oauth_token_state shared
  by the Claude Code + hermes_pkce read/write/refresh/exchange paths;
  _fingerprint delegates to credential_persistence.fingerprint_secret_value.
- rate_limit_tracker: lower_headers / has_rate_limit_headers exported and
  reused by nous_rate_guard (header parsing, bucket exhaustion via _is_exhausted);
  format_remaining = _fmt_seconds alias (public name kept).
- _safe_int stays tolerant of non-finite values (parity with origin).
- Docstring/comment compaction; every WHY kept.
- Parity: /tmp/rf/creds_c_parity_probe.py output identical to origin baseline
  (except wall-clock 'captured N ago' text); refresh_anthropic_oauth_pure
  old-vs-new on 6 token payloads identical.
2026-09-02 13:29:46 -07:00
Teknium afcad8335a refactor(agent/creds): compact secret_scope and command_token_source
secret_scope: _environ_or helper replaces four os.environ.get/default blocks;
_is_global_env uses tuple startswith; prose essays reduced to the invariants
(resolution order, fail-closed rule, cron overlay rationale, BOM handling).
command_token_source: rationale prose compacted; expiry arithmetic flattened.
2026-09-02 13:29:46 -07:00
Teknium 4e548ce7a0 refactor(agent): compact turn-loop comments/docstrings to invariant statements (AST-identical) 2026-09-02 13:29:46 -07:00
Teknium 9989dd4f48 refactor(agent/creds): registry — _BUILTIN_SOURCES table, _merged/_section helpers, _Applier
apply_all's per-source closure becomes _Applier (same guard chain, same
messages, same provenance); builtin registration iterates a table instead of
three copy-pasted try blocks; getattr() on always-present SecretSource attrs
removed.
2026-09-02 13:29:46 -07:00
Teknium 924e290741 refactor(agent/creds): rebase bws/op/command sources onto the shared base+cache substrate
- bitwarden: drop dead apply_bitwarden_secrets (0 refs); encrypted cache uses
  atomic_write_json/entry_from_payload; fetch goes through SecretCache.lookup
  with an encrypted L2 reader; stale-fallback branches merged; _classify_bws_error
  is a rule table; token/override hooks come from the ABC.
- onepassword: same substrate; _missing_binary_error, _fingerprint, _guarded
  dedupe repeated text/logic; _classify_op_error is a rule table.
- command: drop dead parse_secret_output/get_command_secret/list_command_secrets/
  apply_command_secrets (0 refs outside own test); _log helper; tests repointed
  to _run_helper / CommandSource.fetch.
2026-09-02 13:29:46 -07:00
Teknium d4f2933262 refactor(agent/creds): unify secret-source CLI/cache/error plumbing in base and _cache
- base: run_cli (shared subprocess wrapper), classify_cli_error (rule tables),
  coerce_float, source_child_env, FetchResult.fail, SecretSource.token_env /
  token_env_key / default_token_env / override_existing_default so per-backend
  override_existing/protected_env_vars overrides collapse into the ABC;
  generic remediation is a kind->template table.
- _cache: atomic_write_json (mkstemp->0600->replace) and entry_from_payload
  shared by DiskCache and the bws encrypted cache; SecretCache = L1 dict + L2
  DiskCache with lookup/store/clear.
2026-09-02 13:29:46 -07:00
Teknium b5aa16f785 refactor(agent/creds): unify auth-store OAuth removal and suppress-only steps; compact credential_sources/persistence (-35% LOC)
- credential_sources: _remove_nous_device_code/_remove_minimax_oauth/xai/codex
  share _remove_auth_store_oauth; hint-only steps (claude_code, qwen-cli,
  config:*) built by _suppress_only(); registry is a literal ordered list
  (register()/_register_all_sources() removed; order preserved, first match wins).
- credential_persistence: fold _fingerprint_value into fingerprint_secret_value;
  compact key tables and docstrings.
- Behavior parity verified old vs new: removal-step lookup + hint text for 12
  (provider, source) cases; 3000 random sanitize/fingerprint payloads.
2026-09-02 13:29:45 -07:00
Teknium 9dab23c5a6 refactor(cli): simplify hermes_cli/commands.py registry, gateway collectors and completer
- Drop dead code: _telegram_effective_priority, _prioritize_telegram_menu_commands,
  discord_skill_commands, _TG_NAME_LIMIT/_clamp_telegram_names compat aliases,
  the empty _SLACK_PRIORITY_ALIASES pinning pass (and tests that only pinned them).
- Unify the Telegram and Discord skill collectors behind _iter_gateway_skills
  (one eligibility/root-matching implementation) and _truncate_desc.
- Table-drive Telegram menu priority modes (_TELEGRAM_PRIORITY_TIERS) and the
  completer's per-command dynamic completions (_DYNAMIC_COMPLETIONS).
- Unify path and @file:/@folder: directory-listing completions (_dir_completions),
  command-completion construction (_short_desc), /tools candidate rows, the
  Slack canonical/alias passes and the derived COMMANDS/COMMANDS_BY_CATEGORY loops.
- Compact docstrings/comments, keeping every rule, invariant and rationale.
Behavior-neutral: registry-derived outputs, menus, manifests and completions
byte-identical against origin/main on a fixture sweep.
2026-09-02 13:29:45 -07:00
Teknium 150ee2a35d refactor(cli): simplify CLI mixins (billing, agent-setup, commands) — dedupe helpers, dispatch tables, god-method splits
hermes_cli/cli_billing_mixin.py (1566 -> 1173): shared _modal_choice / _step_up_remote_spending /
_print_org_line / _print_portal_line / _print_total_spendable / _try_usage_model /
_billing_patch_auto_top_up; copy tables for charge-failed / charge-error / upgrade-status.

hermes_cli/cli_agent_setup_mixin.py (962 -> 787): _current_runtime + _route_signature (3 sites),
_compression_descendant (2 sites), resume event/skin tables, _load_resumed_history_late lifted
out of _init_agent; fixes latent undefined 'logger' in _resume_history_limit_error.

hermes_cli/cli_commands_mixin.py (4175 -> 3634): _end_current_session + _sync_agent_to_session
(/resume + /branch), _print_side_result_panel (/bg + /btw), _queue_prompt_turn (/learn /plan /init),
_toggle_target + _command_arg (/footer /timestamps /focus /voice /wake), _print_diff_body,
_summarize_paths, _split_scope_flags + _scope_outcome (/reasoning /fast); dispatch tables for /cron
flags + subcommands, /busy, /fast, /voice; /browser, /cron, /goal god-methods split into helpers.
Docstrings/comments compacted by hand; rationale kept.
2026-09-02 13:29:44 -07:00
Teknium ab2fb71b23 refactor(cli): drop 18 update_cmd lazy re-exports with zero references outside update_cmd itself 2026-09-02 13:29:44 -07:00
Teknium 5c125d3bf6 refactor(cli): lift cmd_gui's install+build+stage/swap region into _build_desktop_app; drop 2 unused imports
Zero-back-ref region (inputs desktop_dir/source_mode/npm/env, single output
packaged_executable) becomes a helper returning the swapped-in executable.
Removes the unused functools/_add_accept_hooks_flag imports left by the
parser-builder migration.
2026-09-02 13:29:44 -07:00
Teknium 64f301dfc0 refactor(cli): dedupe the 3x --oneshot dispatch block and chat-arg defaults into helpers
_run_oneshot_from_args replaces three identical confirm+run_and_exit blocks
(main, fast chat, Termux fast cli); _default_to_chat reuses the existing
_set_chat_arg_defaults instead of a second attr table. Also restores the
'bare hermes profile' note as _profile_status's docstring.
2026-09-02 13:29:44 -07:00
Teknium ed8aa5e3e4 refactor(cli): move session browse/status/relative-time helpers from main.py into sessions_cmd.py
_relative_time, _session_status_tag, _annotate_session_statuses,
_session_browse_picker and _size_delta_label (410 LOC) replace the
call-time delegating wrappers in sessions_cmd; main.py re-exports them via
_LAZY_COMMAND_EXPORTS so hermes_cli.main.<name> imports/patches still work.
2026-09-02 13:29:44 -07:00
Teknium 277d51bbc9 refactor(cli): route select_provider_and_model flows through a _PROVIDER_MODEL_FLOWS table
The 20-way if/elif on selected_provider becomes a dict of uniform
flow(config, current_model, args) lambdas plus a _GENERIC_API_KEY_PROVIDERS
frozenset; custom-slug / remove-custom / api-key fallthroughs keep their
order. Lambdas resolve _model_flow_* by name at call time so existing
hermes_cli.main monkeypatches still intercept.
2026-09-02 13:29:44 -07:00
Teknium 853646f143 refactor(cli): move cmd_profile to hermes_cli/profile_cmd.py as a PROFILE_ACTIONS dispatch table
The 604-line 14-way if/elif on profile_action becomes one _profile_<action>
handler each, with per-handler imports derived from the branch's free names.
main.py re-exports cmd_profile and _render_distribution_plan so existing
imports/monkeypatches resolve unchanged.
2026-09-02 13:29:44 -07:00
Teknium 41b658d2b4 refactor(cli): unify duplicate reasoning-effort config helpers into hermes_cli.setup 2026-09-02 13:29:44 -07:00
Teknium 060039d169 refactor(cli): split main() into _build_cli_parser/_parse_cli_args/_default_to_chat helpers
main() is now a ~110-line orchestrator: startup prologue, parser build,
container routing, bpo-9338-safe parse, --version/--yolo/--oneshot, chat
default, dispatch. The two identical plugin add_parser blocks collapse into
_attach_plugin_cli_command; the two default-to-chat attr loops merge. Parser
tree, --help output and set_defaults are unchanged (399 parsers byte-diffed).
2026-09-02 13:29:44 -07:00
Teknium b81ab901f3 refactor(cli): extract the last 16 inline parser groups from main() into hermes_cli/subcommands/
moa, fallback, worktree, browser, secrets, egress, migrate, whatsapp-cloud,
checkpoints, bundles, curator, pets, journey, computer-use, sessions and
completion each become a build_<group>_parser() builder. Closure handlers
that only closed over their own parser moved verbatim; sessions/completion
take the handler by injection. --help/usage/defaults byte-identical for all
399 parsers in the tree (in-process dump before/after).
2026-09-02 13:29:44 -07:00