hermes-agent/tests/agent
Siddharth Balyan 7ba5df0d52
feat(billing): /credits command — balance + portal top-up handoff (#44776)
* feat(billing): /usage → portal top-up browser handoff

Add the terminal side of the billing slice (phase 2a): start a top-up by
throwing the user to the portal billing page with the top-up modal open. The
terminal does not confirm, poll, or track payment — checkout completes in the
browser and the next /usage shows the new balance.

- nous_account.py: parse organisation.slug/name from /api/oauth/account into
  NousPortalAccountInfo; add nous_portal_topup_url() building the org-pinned
  {base}/orgs/{slug}/billing?topup=open with a null-slug fallback to the legacy
  {base}/billing?topup=open (never /orgs/None/...).
- portal_cli.py: 'hermes portal topup' — fresh account fetch, identity line
  (Topping up as <email> / org <name>), browser open with printed-URL fallback,
  no-wait closing copy. No polling/confirmation (deferred to 2b).
- account_usage.py: the shared /usage credits block now links the org-pinned
  top-up URL (auto-opens the modal) + points to the command.

Depends on NAS #409 (organisation.slug/name + ?topup=open). Do not merge until
that is live on the target env; until then /api/oauth/account returns
organisation: { id } only and the URL falls back to legacy.

* feat(billing): /credits command for balance + top-up handoff

Replace the standalone `hermes portal topup` subcommand with an in-session
/credits slash command — a focused money surface (balance in, top-up out) that
works in the CLI, TUI, and every messaging platform from one registry entry.

- commands.py: register /credits (Info category). Slack is at its 50-slash cap,
  so /credits is routed via /hermes credits on Slack only (new
  _SLACK_VIA_HERMES_ONLY set) to avoid clamping a canonical command off the
  native list and breaking Telegram parity; native everywhere else.
- account_usage.py: build_credits_view() — one portal fetch → balance lines +
  identity line + org-pinned top-up URL + depleted flag, consumed by all
  surfaces. Reuses the same snapshot/URL builder as /usage so numbers match.
- cli.py: _show_credits() — balance block + identity line + 3-button panel
  (Open top-up / Copy link / Cancel) via the existing prompt_toolkit modal.
  ASK, never auto-launch; headless falls back to printing the URL.
- gateway/slash_commands.py: _handle_credits_command() — renders the block +
  tappable top-up URL + no-wait copy; works on button and plain-text platforms.
- /usage credits line now points to /credits.
- Retire `hermes portal topup` (portal_cli.py back to baseline); the engine
  (slug/name parse + nous_portal_topup_url) stays as the shared core.

No polling, no payment confirmation (billing phase 2a). Depends on NAS #409.

* fix(credits): /credits works in the TUI slash-worker (non-interactive)

In the TUI, /credits runs in the slash-worker subprocess where there is no
live prompt_toolkit app and stdin is the JSON-RPC pipe. _show_credits called
the 3-button modal unconditionally, which fell back to reading stdin →
exception → slash.exec rejected → the command produced no output (only the
pre-existing 'Credit access paused' banner showed).

- _show_credits: when self._app is None (TUI worker / piped / non-interactive),
  render the text variant — balance block + tappable top-up URL + no-wait line,
  same affordance as the messaging surfaces — and skip the modal entirely. The
  3-button panel still renders in the interactive CLI.
- Depleted banner copy: 'run /usage for balance' → 'run /credits to top up'
  now that /credits is the dedicated money surface (+ tests).
- Regression tests: _show_credits with self._app=None renders text and never
  invokes the modal; logged-out path.

* feat(tui): credits.view RPC for the /credits tappable top-up button

Add a credits.view JSON-RPC method returning the structured CreditsView
(logged_in, balance_lines, identity_line, topup_url, depleted) so the TUI can
render a clickable <Link> top-up button instead of plain text. Account-
independent (portal fetch gated on a logged-in Nous account), fail-open to
{logged_in: false} on any hiccup. Mirrors session.usage's credits-block pattern.

Frontend (TUI-local /credits command + Ink component) lands separately.

* feat(tui): /credits command with keyboard-driven top-up confirm

TUI-local /credits: fetches the structured balance via the credits.view RPC,
prints the balance + identity + top-up URL, then arms the EXISTING confirm
overlay (Enter = open top-up in browser via openExternalUrl, Esc = cancel).
Reuses ConfirmReq — no new overlay component/state/input handler. Headless
(openExternalUrl returns false) falls back to printing the URL.

- gatewayTypes.ts: CreditsViewResponse.
- commands/credits.ts: the command (mirrors /status's rpc+guarded pattern).
- registry.ts: register creditsCommands.
- test: balance+overlay armed, headless fallback, no-url, logged-out (4 cases).

Matches the CLI /credits 'Enter to open' affordance. Phase 2a: no polling.
2026-06-12 08:51:10 +00:00
..
lsp fix(lsp): detect Windows wrapper binaries in installer probes 2026-05-30 02:08:36 -07:00
transports fix(codex): record app-server token usage in session accounting 2026-06-09 02:46:04 -07:00
__init__.py
test_anthropic_adapter.py fix(anthropic): default new Claude models to the modern thinking contract (#42991) 2026-06-09 23:37:23 +05:30
test_anthropic_keychain.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_anthropic_kwargs_sanitize.py fix(anthropic): strip Responses-only kwargs before Messages SDK call (#31673) (#42155) 2026-06-08 09:36:38 -07:00
test_anthropic_mcp_prefix_strip.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_anthropic_oauth_pkce.py fix(auth): don't launch a text-mode browser inside the terminal for OAuth (#34479) 2026-05-29 01:23:06 -07:00
test_anthropic_output_field_leak.py fix(anthropic): strip output-only SDK fields from replayed content blocks 2026-06-10 20:45:16 -07:00
test_anthropic_thinking_block_order.py refactor: keep anthropic_content_blocks in-memory only (no state.db column) 2026-06-10 20:45:16 -07:00
test_arcee_trinity_overrides.py feat(compression): raise compaction trigger to 85% for gpt-5.5 on Codex OAuth (#40957) 2026-06-07 01:40:50 -07:00
test_async_utils.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_auxiliary_client.py fix(params): send max_completion_tokens for newer OpenAI families on custom endpoints 2026-06-09 23:22:10 -07:00
test_auxiliary_client_anthropic_custom.py fix(anthropic): complete third-party Anthropic-compatible provider support (#12846) 2026-04-19 22:43:09 -07:00
test_auxiliary_client_azure_foundry.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_auxiliary_client_xai_oauth_recovery.py fix(auxiliary): detect xAI OAuth 403 bad-credentials as auth error 2026-05-29 00:28:02 -07:00
test_auxiliary_config_bridge.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_auxiliary_main_first.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_auxiliary_named_custom_providers.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_auxiliary_transport_autodetect.py fix(auxiliary): auto-detect Anthropic Messages transport for all aux clients (#17027) 2026-04-28 06:50:14 -07:00
test_auxiliary_user_default_headers.py fix(aux): honor model.default_headers on auxiliary client too (#40033) 2026-06-07 02:02:40 -07:00
test_azure_identity_adapter.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_bedrock_1m_context.py feat(azure-foundry): add Microsoft Entra ID auth 2026-05-18 10:14:38 -07:00
test_bedrock_adapter.py fix(bedrock): fall back to non-streaming InvokeModel when IAM denies InvokeModelWithResponseStream (#44293) 2026-06-11 07:15:30 -07:00
test_bedrock_integration.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_cascading_interrupt_6600.py fix(agent): don't retry interrupt-induced transport errors (cascading-interrupt hang) 2026-06-08 02:19:13 -07:00
test_codex_cloudflare_headers.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_codex_responses_adapter.py feat(prompt): universal task-completion guidance + local Python toolchain probe (#34340) 2026-05-28 22:26:09 -07:00
test_codex_ttfb_watchdog.py fix(codex): relax no-byte TTFB watchdog default from 12s to 120s 2026-05-29 02:02:25 -07:00
test_coding_context.py fix(coding): teach agents terminal env state persists 2026-06-11 19:50:08 -05:00
test_compress_focus.py refactor(agent): drop unused tail_start param from _derive_auto_focus_topic 2026-06-11 23:03:52 -07:00
test_compression_concurrent_fork.py fix(compression): disable compression on background-review fork to prevent cross-turn stale-parent fork (#41708) 2026-06-07 22:06:48 -07:00
test_compression_logging_session_context.py fix(agent): sync logging session context on compaction id rotation 2026-06-07 22:30:02 -07:00
test_compressor_historical_media.py Port from Kilo-Org/kilocode#9434: strip historical media after compression (#27189) 2026-05-16 17:18:25 -07:00
test_compressor_image_tokens.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_compressor_media_stripping.py fix(agent): strip MEDIA directives from compressor summarizer input (#14665) 2026-06-12 01:14:28 -07:00
test_context_compressor.py fix(agent): frame compaction handoff sections as historical context 2026-06-11 13:57:13 -07:00
test_context_compressor_cross_session_guard.py fix(compression): guard against cross-session stale _previous_summary contamination 2026-06-07 22:09:45 -07:00
test_context_compressor_summary_continuity.py test: cover ci-unblocker production regressions 2026-05-27 22:14:53 -07:00
test_context_compressor_temporal_anchoring.py fix(agent): frame compaction handoff sections as historical context 2026-06-11 13:57:13 -07:00
test_context_engine.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_context_engine_host_contract.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_context_references.py fix(agent): make a binary @file: reference actionable instead of a dead end 2026-06-09 19:16:46 -05:00
test_copilot_acp_client.py fix(ci): recover 38 failing tests on main (#17642) 2026-04-29 20:05:32 -07:00
test_copilot_acp_deprecation.py fix(copilot-acp): tighten deprecation detection + sharpen GitHub Models 413 hint 2026-05-16 02:24:48 -07:00
test_credential_pool.py fix(auth): address Nous JWT fallback review 2026-05-29 02:24:48 -07:00
test_credential_pool_routing.py refactor: remove smart_model_routing feature (#12732) 2026-04-19 18:12:55 -07:00
test_credits_cold_start.py fix(credits): suppress usage gauge when top-up funds exist + add display.credits_notices toggle (#44716) 2026-06-12 01:06:46 -07:00
test_credits_fixture_snapshot.py feat(credits): usage-aware credits — in-session notices, /usage view, dev readout (#40011) 2026-06-06 13:18:18 +05:30
test_credits_policy.py feat(billing): /credits command — balance + portal top-up handoff (#44776) 2026-06-12 08:51:10 +00:00
test_credits_tracker.py feat(credits): usage-aware credits — in-session notices, /usage view, dev readout (#40011) 2026-06-06 13:18:18 +05:30
test_credits_view.py feat(billing): /credits command — balance + portal top-up handoff (#44776) 2026-06-12 08:51:10 +00:00
test_crossloop_client_cache.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_curator.py fix(curator): use shared atomic state writer 2026-06-10 03:04:54 -07:00
test_curator_activity.py fix: use skill activity in curator status 2026-04-30 10:31:47 -07:00
test_curator_backup.py fix(curator): authoritative absorbed_into on delete + restore cron skill links on rollback (#18671) (#18731) 2026-05-02 01:29:57 -07:00
test_curator_classification.py feat(curator): hint at hermes curator pin in the rename block (#23212) 2026-05-10 06:44:53 -07:00
test_curator_reports.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_custom_provider_extra_body.py fix(custom): pass custom provider extra body 2026-05-21 07:48:53 -07:00
test_custom_providers_vision.py fix(vision): honor custom_providers per-model supports_vision (#41036) 2026-06-07 21:50:57 -07:00
test_deepseek_anthropic_thinking.py chore: ruff auto-fix PLR6201 resweep — tuple → set in membership tests (#27355) 2026-05-17 02:29:41 -07:00
test_direct_provider_url_detection.py fix: restrict provider URL detection to exact hostname matches 2026-04-20 22:14:29 -07:00
test_display.py feat(web): Parallel-backed web search & extract — free Search MCP when keyless, v1 REST when keyed 2026-06-10 19:54:38 -07:00
test_display_emoji.py
test_display_todo_progress.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_display_tool_failure.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_error_classifier.py fix(agent): route 'thinking blocks cannot be modified' 400 to recovery 2026-06-10 12:39:44 -07:00
test_external_skills.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_external_skills_dirs_cache.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_file_safety.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_file_safety_container_mirror.py fix(file-safety): extend sandbox-mirror guard to cover inner-container path (#32049) (#32407) 2026-06-02 14:03:37 +10:00
test_file_safety_credentials.py fix(security): block read_file on project-local .env files 2026-05-25 03:40:47 -07:00
test_file_safety_cross_profile.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_file_safety_sandbox_mirror.py fix(file-safety): add sandbox-mirror soft guard for writes to per-task .hermes mirrors (#32213) 2026-06-02 11:29:24 +10:00
test_gemini_cloudcode.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_gemini_fast_fallback.py fix: wrap _pool_may_recover_from_rate_limit call through run_agent namespace 2026-05-18 20:04:57 -07:00
test_gemini_free_tier_gate.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_gemini_native_adapter.py fix(gemini): default native maxOutputTokens + strip OpenAI extra_body on Gemini endpoints (#39730) 2026-06-05 03:53:59 -07:00
test_gemini_schema.py fix(gemini): drop integer/number/boolean enums from tool schemas (#15082) 2026-04-24 03:40:00 -07:00
test_i18n.py fix(packaging): ship locales/ i18n catalogs in wheel, sdist, and Nix (#38383) 2026-06-03 12:00:27 -07:00
test_image_gen_registry.py feat(plugins): pluggable image_gen backends + OpenAI provider (#13799) 2026-04-21 21:30:10 -07:00
test_image_routing.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_insights.py refactor(insights): drop dead pricing/duration wrappers, call usage_pricing directly (#40618) 2026-06-07 18:33:20 -07:00
test_jiter_preload.py fix(agent): preload jiter native parser 2026-05-28 00:20:11 -07:00
test_kimi_coding_anthropic_thinking.py fix(anthropic): broaden Kimi thinking-suppression to custom endpoints (#17455) 2026-04-29 06:35:42 -07:00
test_last_total_tokens.py fix(compressor): ABC compliance — total_tokens, api_mode, logger consistency 2026-05-23 17:38:19 -07:00
test_local_stream_timeout.py fix(local): recognize unqualified hostnames as local endpoints (#9248) 2026-06-05 10:18:10 +10:00
test_markdown_tables.py fix(cli): vertical fallback for markdown tables wider than terminal (#23948) 2026-05-11 16:49:13 -07:00
test_memory_async_sync.py fix(memory): run end-of-turn sync off the turn thread (#41945) 2026-06-08 02:18:59 -07:00
test_memory_provider.py refactor(memory): reuse _summarize_user_message_for_log instead of forking it 2026-06-12 12:49:18 +05:30
test_memory_session_switch.py fix(memory): run end-of-turn sync off the turn thread (#41945) 2026-06-08 02:18:59 -07:00
test_memory_user_id.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_minimax_auxiliary_url.py
test_minimax_provider.py polish(minimax): address Copilot review comments on M3 default-aux fix 2026-06-04 05:53:35 -07:00
test_model_metadata.py fix(models): read OpenRouter live context_length before hardcoded catch-all (#42986) 2026-06-09 10:49:32 -07:00
test_model_metadata_local_ctx.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_model_metadata_ssl.py fix(auth): honor SSL CA env vars across httpx + requests callsites 2026-04-24 03:00:33 -07:00
test_models_dev.py test: remove low-value model-catalog mirror tests 2026-05-29 23:45:05 -07:00
test_moonshot_schema.py Add Hermes desktop app (#20059) 2026-05-31 17:46:56 -05:00
test_non_stream_stale_timeout.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_nous_credits_gauge.py feat(credits): usage-aware credits — in-session notices, /usage view, dev readout (#40011) 2026-06-06 13:18:18 +05:30
test_nous_credits_snapshot.py feat(billing): /credits command — balance + portal top-up handoff (#44776) 2026-06-12 08:51:10 +00:00
test_nous_oauth_401_guidance.py feat(cli): make hermes portal the human-readable Portal onboarding alias 2026-06-04 01:19:28 +05:30
test_nous_rate_guard.py fix(nous): don't trip cross-session rate breaker on upstream-capacity 429s (#15898) 2026-04-26 04:53:42 -07:00
test_onboarding.py feat(onboarding): opt-in structured profile-build path on first contact (#41114) 2026-06-07 08:36:48 -07:00
test_openrouter_response_cache.py fix(openrouter): use canonical X-Title attribution header 2026-05-05 10:13:34 -07:00
test_plugin_llm.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_portal_tags.py feat(nous): unified client=hermes-client-v<version> tag on every Portal request (#24779) 2026-05-12 20:49:20 -07:00
test_prompt_builder.py Merge pull request #44331 from NousResearch/hermes/hermes-6b48295e 2026-06-11 22:48:06 -07:00
test_prompt_caching.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_proxy_and_url_validation.py fix(agent): normalize socks:// env proxies for httpx/anthropic 2026-04-21 05:52:46 -07:00
test_rate_limit_tracker.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_redact.py test(redact): assert Discord mentions pass through unchanged 2026-05-30 20:48:41 -07:00
test_resume_stale_active_task.py fix(agent): strengthen compression preamble against stale task execution (#41607) 2026-06-11 13:57:13 -07:00
test_runtime_cwd.py fix(desktop): stabilize project folder sessions (#37586) 2026-06-02 20:23:09 +00:00
test_save_url_image.py fix(image_gen): cache xAI ephemeral URL responses to disk (#26942) (#31759) 2026-05-24 18:10:47 -07:00
test_set_runtime_main_custom_provider.py test(auxiliary): e2e routing assertions for custom-provider aux resolution 2026-05-30 02:38:59 -07:00
test_shell_hooks.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_shell_hooks_consent.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_skill_bundles.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_skill_commands.py test: use subprocesses for each test file (#29016) 2026-05-21 16:40:04 +05:30
test_skill_commands_reload.py refactor(reload-skills): queue note for next turn, drop cache invalidation + agent tool 2026-04-29 21:07:47 -07:00
test_skill_utils.py fix(skills): load Linux-tagged skills on Termux (android sys.platform) 2026-05-21 19:08:38 -07:00
test_stream_read_timeout_floor.py fix(streaming): stop socket read timeout from preempting stale-stream detector (#43570) 2026-06-10 20:21:38 -05:00
test_streaming_context_scrubber.py 🐛 fix(memory): require newline after context tag 2026-05-18 10:53:08 -07:00
test_subagent_progress.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_subagent_stop_hook.py feat: shell hooks — wire shell scripts as Hermes hook callbacks 2026-04-20 20:53:51 -07:00
test_subdirectory_hints.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_summary_prefix_semantics.py fix(agent): freeze carveout-era SUMMARY_PREFIX for renormalization 2026-06-11 13:57:13 -07:00
test_system_prompt.py feat(agent): coding-context posture across CLI/TUI/desktop/ACP (#43316) 2026-06-10 23:06:44 -05:00
test_system_prompt_restore.py perf(prompt-cache): date-only timestamp + loud gateway-DB roundtrip logging 2026-05-17 23:20:37 -07:00
test_think_scrubber.py fix(agent): stateful streaming scrubber for reasoning-block leaks (#17924) (#20184) 2026-05-05 04:33:38 -07:00
test_title_generator.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_tool_dispatch_helpers.py feat(security): promptware defense — shared threat patterns + memory load-time scan + tool-result delimiters (#32269) 2026-05-25 14:52:24 -07:00
test_tool_guardrails.py fix: add recovery hints to loop guard warnings 2026-05-19 00:12:12 -07:00
test_tool_result_classification.py fix: classify landed file mutations with diagnostics 2026-05-13 06:46:23 -07:00
test_transcription_registry.py feat(stt): add register_transcription_provider() plugin hook 2026-05-25 01:41:19 -07:00
test_tts_registry.py feat(tts): add register_tts_provider() plugin hook (closes #30398) 2026-05-24 18:04:54 -07:00
test_turn_context.py refactor(agent): extract run_conversation prologue into agent/turn_context.py 2026-06-07 22:17:35 -07:00
test_turn_retry_state.py refactor(agent): consolidate inner-retry-loop recovery flags into TurnRetryState (god-file Phase 1b) 2026-06-07 22:42:05 -07:00
test_unsupported_parameter_retry.py test: remove 50 stale/broken tests to unblock CI (#22098) 2026-05-08 14:55:40 -07:00
test_unsupported_temperature_retry.py fix(auxiliary): stop capping output with max_tokens by default (#34530) (#34845) 2026-05-29 17:24:30 -07:00
test_usage_pricing.py fix(model): require confirmation for expensive model selections 2026-06-10 00:24:06 -07:00
test_video_gen_registry.py feat(video_gen): unified video_generate tool with pluggable provider backends (#25126) 2026-05-13 16:39:41 -07:00
test_vision_resolved_args.py fix(vision): preserve explicit provider auth with custom base_url 2026-05-04 05:05:43 -07:00
test_vision_routing_31179.py fix(vision): route auxiliary.vision.provider=openai to api.openai.com, skip text-only main (#31452) 2026-05-24 15:01:28 -07:00