Teknium
44982309b8
refactor(agent/prompt): dispatch tables and helper extraction in display, context refs, breakdown, compaction
...
build_tool_preview -> _PREVIEW_BUILDERS per-tool table; git @refs -> _GIT_REFERENCE_ARGS; context_breakdown
_skills_block/_append_overflow dedupe; prune_pre_checkpoint_items summary retention folded into one closure;
build_skill_invocation_message reuses _render_skill_block; ruff SIM collapses; restored two compacted
cache-policy invariant comments.
2026-09-02 13:53:58 -07:00
Teknium
593c8e9146
refactor(agent/prompt): split build_system_prompt_parts into tier helpers; unify model-gate resolver
...
_tool_guidance_block, _skills_prompt, _bot_mode_parts, _active_profile_line, _platform_hint, _memory_parts,
_zone_bits, _timestamp_line lifted out of the 600-line builder; tool_use_enforcement and execution_guidance
gates share _model_gate. Emitted prompt text is byte-identical.
2026-09-02 13:53:57 -07:00
Teknium
be5c6a2fd8
refactor(agent/prompt): remove dead code, unify duplicated helpers, compact docstrings across prompt/skill/redaction modules
...
Dead (zero refs): coding_system_blocks, get_friendly_tool_labels, get_scan_ordered_skills_dirs,
_project_quarantine_cache_clear, clear_stable_prefixes, _redact_http_request_target_query_params,
_has_http_method_substring, PromptCachePlan.marker_count, display _diff_* colour thunks (-> _diff_ansi),
pass-through RedactingFormatter.__init__.
Unified: _slugify -> slugify_skill_name; reload diff -> diff_command_snapshots; _is_summary_item ->
is_compaction_summary_message alias; sanitizer walkers -> _sanitize_messages/_sanitize_structure;
assignment redaction passes -> _redact_assignments/_should_redact_assignment; quiet-mode tool lines -> _CUTE_LINES table.
2026-09-02 13:53:57 -07:00
Teknium
96e952a4f8
refactor(agent/providers): one ProviderRegistry engine behind every *_registry module
...
- provider_registry.py: ProviderRegistry (global + per-scope maps, lock,
generation counters, register/list/get/snapshot/restore/reset) with
export() binding the historical module-level names and _providers/
_scoped_providers/_lock test hooks into each *_registry module
- is_available_safe / configured_provider_name replace the 4 nested
_is_available_safe closures and 2 config-reading blocks
- browser/image_gen/video_gen/web_search/terminal_env/tts/transcription
registries keep their public API, log strings, error strings, builtin
collision policy (warn vs raise) and key normalization (strip vs lower)
2026-09-02 13:53:28 -07:00
Teknium
8dcb2b6ada
refactor(agent/providers): shared ProviderBase/CatalogProviderBase and provider_media; compact contract docs
...
- provider_base.py: ProviderBase (name/display_name/get_setup_schema) and
CatalogProviderBase (default_model/list_models/is_available) replace the
identical default-method bodies duplicated across 7 provider ABCs
- provider_media.py: one save_b64/save_bytes/save_url/cache_dir implementation
behind image_gen_provider and video_gen_provider
- memory_manager.py: _each_provider fan-out helper replaces per-hook
try/except loops; _signature_params/_has_var_kwargs unify signature probes
- image_routing.py: _resolve_inference_value shared by base_url/api_key
resolution; _dict_or_empty/_clean_str/_custom_provider_entries helpers
- MemoryProvider/ContextEngine/TTS/browser/web/terminal-env ABC docstrings
compacted to their invariants; method names and signatures unchanged
2026-09-02 13:53:28 -07:00
Teknium
b6e1037730
refactor(agent/lsp): table-driven server registry, shared client/manager helpers, compact docs
...
- servers.py: per-language _root_*/_spawn_* functions collapsed into declarative
ServerDef entries built by _make_spec/_simple_spawn/_markers_root (-707 LOC)
- client.py: _write/_send_reply/_cancel_task helpers replace repeated
try/except blocks; handler dispatch tables for server->client requests
- manager.py: _broken_key unifies the (server_id, root) key derivation
- install.py/cli.py/eventlog.py/workspace.py/protocol.py/range_shift.py/
reporter.py: dedupe helpers (_find_binary, _link_into_bin, _run_installer,
_emit_once, _walk_up), drop dead log_no_server_configured, compact docs
2026-09-02 13:53:27 -07:00
Teknium
2273f2bd20
refactor(agent/models): unify model_metadata TTL disk memos
...
_ttl_memo_get/_ttl_memo_put back both the local-probe and endpoint-metadata
disk caches (file layout, key order and log strings verified identical).
2026-09-02 13:52:52 -07:00
Teknium
684e8322ff
refactor(agent/models): extract LM Studio and llama.cpp /props branches from fetch_endpoint_model_metadata
...
_lmstudio_native_models and _apply_llamacpp_props; the router-mode child probe
shares one /v1/props -> /props fallback helper. HTTP call sequence verified
identical old vs new across 10 fake-endpoint scenarios.
2026-09-02 13:52:52 -07:00
Teknium
771045655b
refactor(agent/models): table-driven credits header parsing, unified account-usage fetchers
...
- credits_tracker: _MICROS_FIELDS/_USD_FIELDS/_BOOL_FIELDS drive parse_credits_headers;
_sticky_notice() replaces repeated AgentNotice literals; collapsed defensive layers
- account_usage: _USAGE_FETCHERS dispatch table replaces provider if/elif; shared
fetch/parse helpers across the codex/anthropic/openrouter fetchers; drop dead
_resolve_codex_usage_url
- billing_links, fast_mode: compacted docstrings, collapsed if/return chains
- model_metadata: fold effective_provider inference into one expression
Notice keys, header names, URLs, log strings and dataclass defaults unchanged.
2026-09-02 13:52:52 -07:00
Teknium
d465b45f38
refactor(agent/models): compact model_metadata comment essays to their invariants
...
Every non-obvious rule, ordering, failure mode and WHY is kept (1-3 lines);
issue numbers, dates and narrative dropped. Data tables unchanged.
2026-09-02 13:52:51 -07:00
Teknium
4a65e98f50
refactor(agent/models): extract get_model_context_length steps into helpers
...
_validate_cached_context_length (step 1), _resolve_bedrock_context_length (1b),
_resolve_custom_endpoint_context_length (2-3); resolution order and every log
message unchanged. Compact the per-step comment essays to their invariants.
2026-09-02 13:52:51 -07:00
Teknium
f3a46eb5d0
refactor(agent/models): dedupe model_metadata probe helpers
...
- _server_root / _ollama_show_context / _longest_key_match / _probe_local_context_length /
_endpoint_model_entry replace 5 copies of the same local-probe and lookup bodies
- detect_local_server_type waterfall as an ordered (name, probe) table
- output-cap error classification via phrase-group tables shared by
is_output_cap_error and parse_available_output_tokens_from_error
- endpoint-scoped context overrides as a data table
- drop dead _fetch_codex_oauth_context_lengths, _resolve_codex_oauth_context_length,
_estimate_message_chars (zero refs repo-wide)
Verified with a differential harness (old vs new module, ~700 pure-function probes, 0 mismatches).
2026-09-02 13:52:51 -07:00
Teknium
77743eac8a
refactor(agent/models): compact pricing snapshot, billing/subscription views, reasoning helpers
...
- usage_pricing: _snap() builder for official-docs pricing entries (table values identical, verified by dump), shared source/version dicts, drop dead DEFAULT_PRICING
- models_dev: _registry_models/_iter_model_entries/_extract_limit helpers replace repeated registry walking; drop dead ModelInfo.format_cost
- billing_view/subscription_view: OrgRoleCapability mixin replaces duplicated is_admin/can_change_plan; shared fetch_portal_state/parse_org_fields
- reasoning_effort/timeouts/summaries, thinking_timeout_guidance, portal_tags: dispatch tables and compacted comment essays; drop dead CODEX_RESPONSES_EFFORTS alias and _match_any
2026-09-02 13:52:51 -07:00
Teknium
beb56b6a00
refactor(web): re-export list_credential_pool from web_server for off-loop tests
2026-09-02 13:49:24 -07:00
Teknium
449f8c954d
test(agent): repoint send-path clone AST contract at turn_context.build_api_messages
2026-09-02 13:41:27 -07:00
Teknium
7c0d8f2c6f
refactor(web): second-pass compaction of local_models/profiles/web_git (helpers, dict literals, docstrings)
2026-09-02 13:35:48 -07:00
Teknium
15aaa359bf
refactor(web): strip web_models provenance banners, compact field comments (schema byte-identical)
2026-09-02 13:35:24 -07:00
Teknium
bdf1d8b0cf
refactor(web): dedupe web_git subprocess/ref-list plumbing, drop dead _MAX_BUFFER
2026-09-02 13:35:24 -07:00
Teknium
de626c5a36
refactor(web): unify profiles router error mapping, target enumeration and row tagging
2026-09-02 13:34:56 -07:00
Teknium
8c5af5733a
refactor(web): collapse local_models job/download/server boilerplate into shared helpers
2026-09-02 13:33:24 -07:00
Teknium
0af4d3682f
refactor(web): kanban plugin_api — unify status dispatch, run/board helpers, _errors_to_500
2026-09-02 13:33:24 -07:00
Teknium
800648ddc0
refactor(web): achievements plugin_api — table-driven catalog builder, shared json/session helpers
2026-09-02 13:33:24 -07:00
Teknium
7d28a33bd9
refactor(web): simplify dashboard_procs/dashboard_register (dedupe home/profile helpers, drop _HEX16 alias, compact docs)
2026-09-02 13:33:23 -07:00
Teknium
5c7096e7cf
refactor(web): delete dead web_server helpers (_demo, _ws_request_reason, _TERMINAL_BACKEND_NAMES, _mcp_oauth_callback_url_from_base)
2026-09-02 13:33:23 -07:00
Teknium
4fd970c62f
refactor(web): absorb single-router web_server helpers into their routers (75 defs); drop dead imports
2026-09-02 13:33:22 -07:00
Teknium
95177359f8
refactor(agent/aux): ruff SIM cleanups; compact vision custom-runtime recovery
2026-09-02 13:33:04 -07:00
Teknium
05d1136dea
refactor(agent/aux): fallback reason via ordered predicate table; single loop for stale-credential re-walk
2026-09-02 13:33:01 -07:00
Teknium
d8ef59a415
refactor(agent/aux): recovery-ladder rungs via one _rung() generator helper with named accept predicates
2026-09-02 13:33:01 -07:00
Teknium
da388692e4
refactor(agent/aux): one _field accessor for dict/object wire payloads
2026-09-02 13:32:58 -07:00
Teknium
6320c54552
refactor(agent/aux): _to_async_client header selection via _endpoint_default_headers
2026-09-02 13:32:56 -07:00
Teknium
0d41e9bdbc
refactor(agent/aux): shared pool loader; restore @_relay_auxiliary_call placement on call_llm
2026-09-02 13:32:55 -07:00
Teknium
14ec5874a5
refactor(agent/aux): collapse cancel-check readers and Codex-route model predicates
2026-09-02 13:32:53 -07:00
Teknium
c90af45f57
refactor(web): unify the three post-config gateway auto-restart helpers
2026-09-02 13:32:52 -07:00
Teknium
b40d76823f
refactor(agent/aux): shared creds-pair and Nous pool entry-state helpers
2026-09-02 13:32:51 -07:00
Teknium
f2c506845b
refactor(web): unify device-code poller lifecycle into _oauth_poller decorator
2026-09-02 13:32:49 -07:00
Teknium
9001ed2365
refactor(agent/aux): shared _prepare_aux_request head for call_llm/async_call_llm
2026-09-02 13:32:49 -07:00
Teknium
ba4f4b8161
refactor(web): collapse try/except-HTTPException/log/raise boilerplate into _common.http_failure; trim unused fastapi imports
2026-09-02 13:32:46 -07:00
Teknium
d46aa77cde
refactor(agent/aux): extract named-custom credential resolution, Bedrock and Vertex client builders out of resolve_provider_client
2026-09-02 13:32:45 -07:00
Teknium
8ac12223bb
refactor(web): late() proxies replace per-handler lazy web_server imports in extracted routers
2026-09-02 13:32:45 -07:00
Teknium
e3d352872b
refactor(agent/aux): shared chain-label aliases, context-window screen, event-loop helper
2026-09-02 13:32:41 -07:00
Teknium
575cd5f34e
refactor(agent/aux): shared hook ticker and _is_specialized_aux_client predicate
2026-09-02 13:32:41 -07:00
Teknium
ba91166b1c
refactor(web): hoist stdlib imports in extracted routers; drop unused web_server imports
2026-09-02 13:32:28 -07:00
Teknium
ff660354f3
refactor(kanban): CLI micro-helpers, action dispatch tables, shared triage helpers; active_sessions dedupe
...
hermes_cli/kanban.py 3,565 -> 2,912; kanban_diagnostics 1,216 -> 996;
kanban_decompose 468 -> 393; kanban_transfer 478 -> 443; kanban_specify
264 -> 229; kanban_swarm 390 -> 378; active_sessions 871 -> 775. `hermes kanban
[sub] --help` byte-identical for all 55 parsers.
- kanban.py: _err / _print_json / _json_out / _fmt_counts / _bulk_apply /
_obj_dict field tuples replace repeated print/JSON/exit-code blocks; action
and board subcommand routing via dict dispatch; shared run-state and
triage-sweep argparse blocks; argparse declarations re-packed (AST-identical).
- specify/decompose: one _run_triage_sweep driver, shared _extract_json_blob /
_truncate / _profile_author / _title_body / _resolve_profile_from_cfg.
- diagnostics: rule helpers (_first_field / _latest_event_ts / _log_hint_action
/ _error_snippet), _rows_by_task fleet fetch; unreferenced DIAGNOSTIC_KINDS dropped.
- swarm: graph nodes share one create_task kwarg set.
- active_sessions: one _flock per platform, _pid_alive via _pid_liveness,
shared _read_live_entries / _without_lease / _clean_metadata, table-driven
strict registry validation.
- Docstrings/comments hand-compacted (AST-identical), invariants kept.
2026-09-02 13:32:14 -07:00
Teknium
841c975d43
refactor(kanban): unify kanban_db SQL/row/JSON/env/git boilerplate; table-drive migrations
...
hermes_cli/kanban_db.py 12,153 -> 11,157 LOC, behavior-neutral.
- _row_get / _json_or / _json_dict / _env_int / _git_out applied at every
duplicate site; Event/Comment/Attachment.from_row row mapping.
- Scalar-read helpers (_task_status, _latest_event, _scratch_workspace,
_has_spawnable, _current_run_id, _parents_satisfied) replace repeated
conn.execute(...).fetchone() blocks.
- _migrate_add_optional_columns and add_notify_sub column refreshes are
table-driven (same statements, same order).
- _dispatch_lane_task unifies the ready/review lane tails; _claim_and_open_run
and _reclaim_dangling_run shared by claim paths; block_task's three UPDATE
branches and complete_task's UPDATEs collapsed to one statement each.
- connect() PRAGMA/WAL setup shared via _open_configured; _probe_integrity
shared by the health guard and repair; _try_lock_nb/_unlock shared by the
init and dispatch file locks; _insert_comment for in-transaction audit rows.
- Dead: parent_results (zero refs).
- Long docstrings hand-compacted, every invariant kept. Schema SQL untouched.
2026-09-02 13:32:14 -07:00
Teknium
d15c61b5dc
refactor(state): split SessionDB into domain mixins and free-function modules; unify SQL boilerplate
...
hermes_state.py 17,220 -> 6,442 LOC. Behavior-neutral: every moved body is
AST-identical to the original, verified per extraction.
SessionDB core
- _write_sql / _write_rowcount / _read_one / _read_all replace ~120 copies of
the `def _do(conn): conn.execute(...)` + `_execute_write(_do)` and
`with self._read_ctx() as conn: row = conn.execute(...).fetchone()` shapes.
- _set_lineage_column replaces four copies of the recursive compression-lineage
UPDATE (archived / pinned / hidden / last_read_at).
- _read_session_number unifies the three compression counter readers.
- Dead (zero refs repo-wide): restore_rewound, delete_gateway_routing_entries,
_is_duplicate_replayed_user_message, SessionPortabilityMixin.get_first_assistant_text.
New mixins bound onto SessionDB via the MRO (logger name stays "hermes_state"):
hermes_state_messages SessionMessagesMixin 48 methods
hermes_state_compression SessionCompressionMixin 30
hermes_state_gateway SessionGatewayMixin 26
hermes_state_maintenance SessionMaintenanceMixin 13
hermes_state_usage SessionUsageMixin 12
hermes_state_titles SessionTitlesMixin 13
hermes_state_telegram SessionTelegramTopicsMixin 11
Origin-internal symbols resolve through a lazy `from hermes_state import ...`
inside the few methods that need them (no import cycle).
New free-function modules, every name re-imported into hermes_state so
`hermes_state.<name>` (and test monkeypatches on it) keep working; intra-module
calls to patched helpers go through the lazy origin import:
hermes_state_repair repair/backup/preflight (43 defs)
hermes_state_wal journal-mode / PRAGMA policy (33 defs)
hermes_state_dbfile header probes, zeroed-db quarantine, stats, holders (21 defs)
Existing mixins: search — shared FTS MATCH/LIKE builders, unified rebuild
status/step/finish engines, state_meta helpers; schema — one legacy/v23 FTS init
branch, shared _live_pk_columns, Row/tuple dual access dropped; portability —
shared _PREVIEW_RAW_SUBQUERY_SQL and _rich_row; common — single
stat_db_file_identity (was 3 copies), AUTO_VACUUM_MIN_FREELIST_RATIO.
Docstrings/comments hand-compacted (AST-identical) keeping every invariant,
ordering rule, failure mode and WHY. Schema SQL, migration order and PRAGMAs
untouched. test_repair_path_has_no_bare_connects repointed to hermes_state_repair.
2026-09-02 13:32:13 -07:00
Teknium
5dfda6a615
refactor(agent/aux): compact _fallback_destination
2026-09-02 13:32:12 -07:00
Teknium
28c3cb1561
refactor(agent/aux): shared _endpoint_default_headers, single primary-attempt closure in call_llm impls, vision tail dedupe
2026-09-02 13:32:09 -07:00
Teknium
e4d8a78967
refactor(web): move /api/logs into web_routers/status.py (logs_router)
2026-09-02 13:32:08 -07:00
Teknium
936c8bb626
refactor(agent/aux): split _CodexCompletionsAdapter.create into request build / final-response parse; dedupe stream/client close paths
2026-09-02 13:32:07 -07:00
Teknium
de109d4097
refactor(web): extract chat-tab WebSocket routes into web_routers/chat_ws.py
2026-09-02 13:32:06 -07:00