Commit Graph

23 Commits

Author SHA1 Message Date
Teknium
a9234e9671 refactor(providers): host claims + profile_for_host, live context hook; Copilot rows move to its plugin
Generic seams (providers/base.py, lane L4 block):
- ProviderProfile.hostnames / metadata_hostnames: hosts a profile claims for URL->provider inference.
- providers.profile_for_host(url, *, metadata=False): lazy, per-home lookup over those claims
  (exact host or subdomain, never substring).
- ProviderProfile.models_dev_id (declared; consumers follow).
- ProviderProfile.live_context_length(model, *, api_key, base_url): credentialed live catalog window,
  consulted at the same step (after the persistent cache) the Copilot branch ran.

Core loses the Copilot rows in model_metadata._URL_TO_PROVIDER, the auxiliary pool/auth-refresh host
tables and the dead _STRICT_VISION_BACKENDS row (never reached: only nous and the auto-order providers
go through it). The in-tree copilot plugin claims githubcopilot.com (+ GitHub Models metadata hosts)
and answers live_context_length from its catalog; copilot-acp delegates to it.
2026-10-25 18:05:41 -07:00
Teknium
68e4c2b31a fix(startup): build version-bearing User-Agents when a request is built, not at import
Every CLI start imports all provider plugins (hermes_cli.config lists their env vars), and
fireworks/gmi/xai/router/kimi/opencode plus auth_constants, models, model_catalog,
auxiliary_client, gemini_native_adapter, web_server_messaging, slack, yuanbao and perplexity
built a `<product>/<release>` string at module level. In a source checkout the release comes
from the 7-call git provenance walk (`git tag --merged HEAD` alone is ~0.35 s in a large
clone), so `hermes sessions list` paid it for headers it never sends.

Provider profiles take a LazyHeaders mapping (resolved on first read by the client builders,
which already copy with dict()); core modules call version_info.hermes_user_agent() where the
request is built. Header values are unchanged.
2026-10-25 17:50:59 -07:00
rob-maron
15307dece7 Usage-window plan support 2026-10-20 21:04:30 -04:00
Robin Fernandes
ea45ec3936 feat(free-tier): connectors and managed tools use a connectors-only guest token
A free-tier guest who only uses connectors or managed tools no longer meets
the free-inference browser challenge. The connectors-side resolver
(resolve_nous_access_token: tool gateway, NAS connector routes, account
reads) serves whichever guest token is live (an inference one covers it) and
otherwise mints with purpose "connectors" (hermes-portal#1516), which NAS
never challenges. An inference token is minted, inside run_with_challenge,
only when the free model is called.

The connectors-only token is stored in providers.nous.connectors_token, next
to the existing inference slot, so auth.json written by current releases
loads unchanged. Which slot a token fills is read from its JWT scope claim,
so a NAS that predates #1516 (it ignores purpose and returns an inference
token, or answers 428) keeps working through today's challenge path.

Two non-chat paths no longer mint inference for a guest behind its back:
the auth keepalive skips a guest (its tokens are minted on demand, matching
the start-time guard), and the Nous model catalog and pricing reads run as
background callers, so they fall back to the curated list instead of opening
a browser challenge.
2026-10-13 00:29:04 +05:30
Maciej Lisiewski
32b70e9733 ci: FURB188, FURB192 linter fixes 2026-10-09 17:31:52 +02:00
Maciej Lisiewski
b4e436c115 ci: don't cast int to int 2026-10-08 19:28:23 +02:00
Austin Pickett
86df3224e2 fix(pricing): wire kilocode into the pricing dispatcher
Kilo Gateway models showed no prices and no Free badge because
_PRICING_FETCHERS had no kilocode branch, so get_pricing_for_provider
returned {} and _apply_pricing skipped the provider row entirely.

Add _fetch_kilocode_pricing, which reads the public OpenRouter-shaped
catalog at {kilocode profile base_url}/models (KILOCODE_BASE_URL
overrides it — the same endpoint the doctor probe uses, no second
hardcode). The Kilo catalog's explicit isFree flag is authoritative
over the rates (a free router can carry non-zero underlying pricing),
and its -1 rate sentinel (auto-router models, 'rate varies') is
skipped rather than shown as a fabricated price.

Fixes #68838
2026-10-06 17:22:46 -04:00
Brooklyn Nicholson
f59263f190 fix(nous): register the fingerprinted pricing cache key so cached_only reads hit
Review follow-up on the on-sale picker union: the Nous fetcher
registered its provider cache key as the bare base URL while
fetch_models_with_pricing writes under base + credential fingerprint,
so any logged-in account's cached_only read (the GUI/in-chat picker)
missed the rows the prewarm filled and the on-sale union always saw
{} there. Register the same key the fetch writes; the picker comment
now states the real mechanism.

The new test exercises the real path (catalog served through the
actual fetcher with an api key present, then _nous_picker_model_ids
with the pricing layer unstubbed) — red on the bare-base registration,
green with the fingerprint. Anonymous reads (empty fingerprint) are
pinned unchanged.
2026-10-05 16:41:47 -05:00
Steve Dalonzo
1daf6eb077 fix(nous): apply the on-sale union in the post-login picker too
The sign-in / re-auth picker (_pick_nous_model_after_login) built its own
paid list and skipped union_with_nous_on_sale_models, so a discounted model
the curated list and paidRecommendedModels omit never showed there. Apply
it after the paid recommendation union and before policy narrowing, as the
other two pickers do.

Also keep image/video generation rows out of the on-sale union: the Nous
pricing fetch flags them with the chat-catalog rule from 296ec08dcf.
2026-10-05 16:41:47 -05:00
Steve Dalonzo
d31a2cc684 fix(nous): list on-sale models in the paid-tier picker
A Nous sale exists only in the live /v1/models pricing.original. The paid
picker unions the curated manifest with the Portal's paidRecommendedModels,
so a model missing from both never appears even while it is the deepest
discount on the gateway (inception/mercury-2.5 at -80%); sale chrome only
badged rows that were already listed.

Paid-tier Nous pickers (hermes model and the GUI/in-chat picker) now append
every discounted, tool-capable, non-free row from the cached catalog,
deepest discount first, before org policy narrows the list. Free tier is
unchanged (freeRecommendedModels). The Nous pricing fetch marks rows whose
supported_parameters omit tools so the union can skip them.
2026-10-05 16:41:47 -05:00
KoNit-K
ddc8c2dcb6 fix(pricing): verify custom upstream identity 2026-10-02 22:58:26 -05:00
KoNit-K
fffd5486c9 fix(pricing): resolve configured provider slugs 2026-10-02 22:58:26 -05:00
kshitijk4poor
59f9ff8dbc refactor(credits): gate the re-warm on the pricing cache's own failure window
The started_at throttle kept a second clock for a deadline the cache
already holds: a failed fetch caches {} with _pricing_cache_retry_after,
and the two clocks drift by the fetch duration. pricing_fetch_suppressed
reads that state directly, so the tracker drops the ad-hoc Thread
attribute and the private-constant import; the guard test now fails the
way the real fetch does (cached {}) instead of a bare no-op.
2026-09-20 14:02:17 +05:30
Robin Fernandes
a76e491660 feat(nous): unlock subscription-billed models for free-tier accounts
The Nous gateway can bill a catalog row to a subscription the account
holds instead of to credits, and marks such rows with
`billing_mode: "subscription"` on GET /v1/models. A free-tier account
can run them, but the picker locked every row not priced at $0.

Carry the marker into the Nous pricing entry and count it in
`_is_model_free`, which already feeds the tier partition and the
credits-depleted notice. The silent default for a free-tier account
still prefers a genuinely free model.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-20 14:02:17 +05:30
Teknium
7b8c11bcf7 simplify(compat): models — drop 52 re-exports from hermes_cli.models, repoint 16 callers + 41 test files 2026-09-03 13:48:49 -07:00
Teknium
b8f99bfc43 review-fix(seams): late-bind facade-patched names in models_pricing, hermes_state_repair, approval_detection
Reviewer P2 (kshitijk4poor): tests patch hermes_cli.models.get_cached_nous_inference_base_url
but models_pricing.pricing_cache_scope read its own module global, so the patch never reached
the call and the test passed on the default-endpoint fallback. Same seam-erosion class audited
across /tmp/rf/patch_traps.json (777 candidates) with an AST reachability check + a per-test
call-count probe (facade vs defining module) against BASE 63279301bcb; three seams actually
bypassed their patch on HEAD but not on BASE:

- hermes_cli.models.get_cached_nous_inference_base_url  <- models_pricing.pricing_cache_scope
- hermes_state._connect_repair_durable                  <- hermes_state_repair._open_exclusive/_repair_conn/_db_opens_cleanly
- tools.approval._command_detection_variants            <- approval_detection.detect_{dangerous,hardline}_command

Each now looks the name up through its facade at call time (the pattern hermes_state_repair
already used in live_writer_holds_db), restoring BASE's patchability.
2026-09-03 09:43:13 -07:00
Teknium
0071ba9965 Merge origin/main (561b053f79) into simp/forwardport: forward-port 220 main commits into the simplified tree 2026-09-03 03:31:03 -07:00
Teknium
c64a1fbd6c refactor(hermes_cli): repack literal tables, one-line trivial branches, share _drop_authorization 2026-09-02 21:57:37 -07:00
Teknium
b30c4f1667 refactor(hermes_cli): fold match verdicts into _Match.verdict, ordered validation ladder table, tighter local/pricing bodies and docstrings 2026-09-02 21:34:59 -07:00
Teknium
07904249a3 refactor(hermes_cli): dispatch-table pricing fetchers, shared price parsing, slot accessors on _CapsSource 2026-09-02 21:12:47 -07:00
Teknium
5c9580c696 refactor(models): dedupe ollama probe failure/ollama-config lookups, pricing fetch/entry helpers; logger parity in models_local 2026-09-02 16:35:42 -07:00
Teknium
64cf496ca5 refactor(models): collapse deepinfra/custom-cache/provider-list helpers; module docstrings 2026-09-02 16:24:19 -07:00
Teknium
ade1c5a746 refactor(models): extract models_local + models_pricing; unify json disk-cache I/O, portal recommendation union, live-catalog index, copilot token exchange, probe/cache-entry builders 2026-09-02 16:06:33 -07:00