Commit Graph

10300 Commits

Author SHA1 Message Date
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
teknium1
0fd634f29c fix(desktop): held cold-start keys reach only the chat the handoff names
Keys typed while no composer was mounted were held per focus target, and
every chat's composer is 'main', so opening another chat from the sidebar
before the cold-start restore finished appended those keys to it. Bind the
held keys to the announced handoff's session; only the composer that adopts
that handoff takes them, and they are dropped once the handoff is abandoned.

Move the cold-start remount tests into use-composer-draft.cold-start.test.tsx
with a shared editable-composer harness (main file was over 1,000 lines).
2026-11-16 11:27:04 -08:00
teknium1
9528ba5156 fix(desktop): keep keys typed while the cold-start resume has no composer mounted
Text typed on the fresh chat during boot follows the chat that
resume-last-session restores (b8dd611d4a, #156615). In between, the
restored chat's loading view mounts no composer. Type-to-focus
(use-keybinds) preventDefaults every printable key and dispatches it to
the 'active' composer synchronously; with no composer subscribed, the
key was simply dropped. macOS packaged Desktop lost the middle of the
prompt this way ("6-d6099024e52cHello, c").

An unclaimed type-to-focus character is now held per target while a
new-session draft handoff is pending, and the next composer to mount on
that target appends the held keys after the draft it restored. Outside a
pending handoff an unclaimed key stays dropped, so stray typing is never
replayed into a later composer. Subscribers mark the request claimed.

0.23.2 release blocker: install-e2e macos desktop-installer@latest ->
open-app-update (v2026.8.13 -> HEAD) and linux installer-script+desktop.
2026-11-16 11:27:04 -08:00
teknium1
23d0650cc8 test(desktop): a draft adopted across the cold-start remount keeps the caret at its end
The cold-start resume remounts the composer and b8dd611d4a (#156615)
carries the boot-time draft onto it. The new editor is painted in the
hook's layout effect before FloatingComposerSurface (the parent)
attaches its portal host, so placeCaretEnd skips the detached node and
the later focus() collapses Chromium's caret to offset 0: keys typed
after the remount land BEFORE the carried text.

Pins the hook-level path: a remount through a parent-attached portal
host with an announced pre-session draft must leave the caret at the
draft's end. Red on main (offset 0), green with the focus fix.

0.23.2 release blocker: install-e2e linux installer-script+desktop
(v2026.8.13 -> HEAD), "The composer must hold the typed prompt before
Enter", Received "r me? Desktop smoke new <uuid>Hello, can y".
2026-11-16 11:27:04 -08:00
Chukuwebuka-2003
c8db25d4e6 fix(desktop): put the caret after the draft when a remounted composer is focused
A composer that remounts mid-turn paints its draft in a child layout effect,
before FloatingComposerSurface attaches the portal host, so placeCaretEnd bails
on the detached editor. focusComposerInput then focused a contenteditable with
no selection inside it and Chromium collapsed the caret to offset 0, so the next
keystrokes landed before the draft.

focusComposerInput now reads the selection before focusing and, when the
editor held no caret, places it at the end. An existing caret is left alone.

Fixes #140142
2026-11-16 11:27:04 -08:00
Teknium
bfc0f9a75b fix(transfer): a gateway that does not start again after the restore is reported, not hidden
If the s6 gateway failed to start after the restore, the import only printed a warning, the
action status reported success and Desktop showed "Transferred" while the agent's bots and
scheduled jobs were not running. The import now prints a GATEWAY_DOWN_LINE the action status
reads into `gateway_down`, and the Desktop done screen says the files arrived but the agent did
not start again and needs a restart (one new string, settings.backup.gatewayDown).
2026-11-16 10:29:52 -08:00
Teknium
9d70683b82 fix(transfer): name the Messaging page, not "Settings → Messaging"
Messaging is its own page (sidebar, command palette), not a Settings tab, so a user who opened
Settings looking for it would not find it. Every line this PR adds now names the Messaging page:
the confirm and done screens, the user guide, the CLI reference, the import's printed hint.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
5342a0a91f feat(import): transferred messaging bots arrive switched off on the cloud agent
A bot token answers to one running Hermes at a time. The transfer now
brings Telegram, Discord, Slack and every other messaging bot over with
its token and settings but switched off, so the computer it came from
keeps answering until the user switches each bot over by hand.

`hermes import --keep-host --messaging-off` (the Desktop transfer route
always passes it; the undo never does): in the root home and in each
profile the archive carries, every bot the archive would run (an
`enabled: true` block, or a token in that home's .env with no `enabled`
set) gets `platforms.<id>.enabled: false`, the switch Settings >
Messaging writes, inside the same merged config.yaml the keep-host
restore publishes. The explicit false sets the gateway's
_enabled_explicit marker, so the env token cannot re-enable it, and
turning the switch on in Settings > Messaging is the only step needed.

The import prints `Messaging switched off: <names>`, the action status
returns them as `messaging_off`, and the Desktop done screen names them.
The confirm note says the bots come over switched off.
2026-11-16 10:29:52 -08:00
Teknium
d2e3304016 fix(desktop): tell the user to turn local bots off only after the transfer
The confirm screen said to stop the local bots, which reads as "before".
Someone talking to Hermes through Telegram would then cut themselves off
before the cloud agent is ready. The confirm note, the done screen and
the docs now say: keep using them here until the transfer is done, then
turn them off in Settings → Messaging.
2026-11-16 10:29:52 -08:00
Teknium
98087e3d8a fix(desktop): a failed restore names the files it could not restore
Found in the live Desktop run (forced: memories/ read-only on the stand-in):
the error screen showed the import log's last three lines, an unrelated Docker
gateway hint and "see Warnings above", which the UI does not have. It now
shows the import's own Warnings list (the files it could not restore), and
falls back to the last lines for any other failure.
2026-11-16 10:29:52 -08:00
Teknium
f01a8a9e7c fix(desktop): stream the transfer, keep Undo on failure, honest Cancel, Webapp sign-in
- Transfer streams: each 8 MiB base64 chunk read off the source is posted to
  the cloud agent's /api/ops/transfer/chunk as it is (retry with backoff,
  offset_gap re-sync), then /transfer/restore. Peak memory is one chunk; no
  multipart, so a first native Cloud sign-in (cookie session only) uploads
  over the same JSON path every other call uses.
- A cloud agent without `import_keep_host` in /api/status gets "This cloud
  agent needs a Hermes update before it can receive a transfer." before
  anything is read or uploaded (BearHuddleston's finding and test idea).
- The undo point reaches the UI from the import's status as soon as it
  exists, also on failure; the error screen offers Undo next to Retry, and
  Undo always restores the FIRST undo point of that agent (a retry never
  replaces it). An import that finished without one is an error.
- Cancel is offered while backing up and copying only; once the restore is
  requested it is gone (it cannot be stopped).
- One backup implementation: hermes-cloud-agents `backup()` reuses runBackup;
  the save downloads /api/ops/backup/download from the backend that wrote the
  archive (never /api/fs/download, which an SSH backend serves remotely).
- Webapp: sign-in reuses the connection the saved-connection OAuth created
  (no duplicate save); "Sign in" sends a signed-out Webapp to Settings >
  Providers; the remote-browser paste field is mounted in the transfer card.

Co-authored-by: BearHuddleston <196404565+BearHuddleston@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
80e7764720 feat(desktop): Settings ▸ Backup & Transfer
A built-in Settings section (`/settings?tab=backup`, right after Sessions) that acts on the
profile Settings is editing on the active connection:

- Back up: `hermes backup` on the owner, then the native save of the archive.
- Transfer to Hermes Cloud (hidden on a Webapp Hermes Cloud serves, where the section is
  "Backup"): Nous sign-in, team picker, agent list (+ a New cloud agent row that opens the
  portal until hermes-portal#2160), a confirm panel listing what is replaced and what the cloud
  agent keeps, then backup → read in 8 MiB chunks → one multipart upload to
  `/api/ops/import-upload?keep_host=true` → poll the cloud agent's restore. Undo restores its
  own pre-import backup; Undone offers Start again.

`lib/agent-transfer.ts` is the pure client over an injected request; `lib/hermes-cloud-agents.ts`
holds the cloud helpers over `window.hermesDesktop.cloud`/`connections`; the Webapp's cloud
bridge (`lib/browser-cloud.ts`) discovers through `GET /api/cloud/agents`. The portal's
`hermes://open/move-to-cloud?agent=X` lands on `/settings?tab=backup&cloudAgent=X`, which
highlights that agent. ⌘K: "Back up this agent" and "Transfer to Hermes Cloud", one each.

Co-authored-by: SHL0MS <SHL0MS@users.noreply.github.com>
2026-11-16 10:29:52 -08:00
Teknium
cdbb043fef fix(desktop): carry file uploads over the OAuth bearer leg
`fetchJsonForBackend` refused every upload to an OAuth-gated backend, but its bearer leg is
`fetchJson`, which already builds multipart. Hand it the upload and refuse only on the cookie
fallback (electron.net with JSON headers), so a Hermes Cloud connection can take a file.
2026-11-16 10:29:52 -08:00
teknium1
e87a591d9b fix(desktop): an adopted reply drops its late tail by stream offset, in raw form
Review on #156611 (Greptile P1 x2):

- The covered tail was kept as RENDERED text, while late deltas carry the
  raw `MEDIA:` tag, so the tag never matched and the attachment was drawn a
  second time. The covered tail is now taken from the raw text
  (`mediaSource`), and hydrated reply parts keep their raw text in
  `mediaSource` as streamed parts already do.
- consumeStoredTail assumed no gaps: with ' dr' lost to the reconnect, 'op'
  at offset 18 was appended whole ('A8 survives the dropop'). storedTail now
  records the segment offset the adopted body reaches; stamped deltas carry
  their admitted offset through the flush queue (only contiguous chunks
  coalesce), and a chunk inside the adopted range is dropped, so only text
  past it is drawn. Unstamped deltas keep the text match.
2026-11-16 09:41:56 -08:00
Teknium
23e5e79887 fix(desktop): a live row that adopts the stored reply draws its late tail once
After a reconnect the live row takes the stored reply's body, but the
stream's tail is still queued or on the wire past the segment cursor, so
those deltas appended the body's tail a second time ('A8 survives the drop
drop'). Only message.complete repaired it, and that completion can be lost to
the same reconnect. The adopted tail part now records the stored text it shows
ahead of the stream (storedTail), and appendAssistantTextPart drops the deltas
that repeat it, applying only what extends past it. This covers both queued
deltas and in-flight ones, which a cursor advance alone would not.

The stored body is adopted only when it continues the live text between two
words: a cut inside a word ('A8' against 'A8x unrelated reply') is where an
unrelated reply sharing a short prefix looks like this one. Such a row keeps
its own bubble until its completion, as before.
2026-11-16 09:41:56 -08:00
Teknium
d5344b9895 fix(desktop): a reconnect page that stores the reply draws it once, in full
After a socket drop the re-resume reads the newest transcript page over
REST while the turn's tail and its message.complete are still on the wire.
When the page already holds the stored reply and the live stream row is
still short of it, overlayConcurrentMessageChanges kept BOTH: the committed
bubble with the whole reply and the pending stream row with its first
words, so the reply drew twice until the completion retired the live row.
Release CI caught it in transcript-integrity's "ws drop + reconnect" step
(17-assistant and assistant-stream-* both holding A8).

The keep-both rule came from d8ddf3fb14: a live row short of the stored
text may never get its tail (a completion lost to the reconnect), so
replacing the committed bubble with it would strand the reply on its first
chunk. The live row now takes the committed bubble's place AND its stored
body: one bubble, the whole reply, and the live id that the turn's late
deltas and completion still settle in place.
2026-11-16 09:41:56 -08:00
teknium1
b8dd611d4a fix(desktop): keep the boot-time draft when the cold-start resume remounts the composer
Text typed on the fresh chat while the app boots must follow the chat that
resume-last-session restores (a4b48064b1, #114122). The handoff only ran
when one composer instance saw its scope flip from the fresh key to the
restored id. The restored session's loading view mounts no composer, so the
fresh chat's composer unmounts and a new one mounts already scoped to the
restored id: its first run never saw a fresh scope, never consumed the
announcement, and the typed text vanished from the composer.

The swap effect's first run now also adopts the fresh draft when the
pending announcement names its own key; a first mount on any other session
leaves the announcement for the restored chat's composer.

0.23.2 release blocker: install-e2e linux installer-script+desktop
(v2026.8.13 -> HEAD), "The composer must hold the typed prompt before
Enter", Received "".
2026-11-16 09:36:28 -08:00
alt-glitch
6b0e9a0203 refactor(speech): drop the STT lease holder set; the route only warms
The /api/audio/stt-lease route kept a process-global set of lease names
(acquire_stt_lease, release_stt_lease, stt_lease_holders,
_reset_stt_leases_for_tests). Release never unloads anything by design, so
the set's only output was the holder count echoed as `leases` in the
response. No client reads it: the desktop typed the field in
AudioSttLeaseResponse and syncSttLease awaits the call as a readiness
barrier, ignoring the body (rg `leases` under apps/, web/, ui-tui/ hits
only that type). The set was also shared by every profile in the process.

The route now calls warm_stt_provider() under the profile scope when
`active` is true and returns the same envelope without `leases`; release
is acknowledged and does nothing. The request model is unchanged, so
older desktops still send a valid body. The TS response type drops the
unread field in the same commit.
2026-11-16 21:53:44 +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
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
Austin Pickett
89488a115a fix(desktop): read SSH timeout keys past a column-0 YAML comment
A comment line at column 0 inside the desktop: block ended the scan, so
a timeout key below it was silently ignored and kept 15s. Comments do not
close a YAML mapping; only the next real top-level key does.
2026-11-16 00:47:42 -05:00
Gille
6606ba3345 refactor(desktop): read the SSH timeout keys in their own module
The code-health check caps main.ts, config_defaults.py and
readDesktopLaunchConfig at their size and complexity on main.

The two keys are now read by desktop-ssh-budgets.ts, which main.ts calls
once with the config.yaml text it already has. The Windows env slice for
the ssh resolver moves into ssh-binary.ts so main.ts does not grow. The
launch-config reader and config_defaults.py are back to what they were.

Refs #132508
2026-11-16 00:47:42 -05:00
Gille
8a349cc3ae fix(desktop): take the SSH connect and forward timeouts from config.yaml
Moves the override from two HERMES_* environment variables to
desktop.ssh_connect_timeout and desktop.ssh_forward_timeout, in whole
seconds up to 120. These are non-secret behavior settings, so they belong
in config.yaml. They are read once before the first window, the same way
desktop.ssh_path is, and passed to every SSH connection the app opens.

The value is validated in full. Only a positive whole number counts.
Values like "45s" or "1.5" are ignored with a startup warning and the
15 second default is kept, instead of being read as a numeric prefix.

Refs #132508
2026-11-16 00:47:42 -05:00
liuhao1024
8c38811f9f fix(desktop): read the SSH connect/forward budgets from the environment
The two 15s budgets in ssh-connection.ts were hardcoded with no override,
and the connect budget reaches ssh as -o ConnectTimeout on the command
line, so the user's SSH config cannot raise it either — on lossy links
(in-flight Wi-Fi, congested hotspots) every attempt failed with
'kind=timeout ... timed out after 15000ms' and the Desktop looped on boot
failure (#132508: 137 of 155 attempts in a two-hour window).

Resolve both from HERMES_SSH_CONNECT_TIMEOUT_MS and
HERMES_SSH_FORWARD_TIMEOUT_MS following the resolveProbeTimeoutMs pattern
in backend-probes.ts: unset/invalid keeps 15s, values clamp at 120s, and
an explicit constructor option still wins.
2026-11-16 00:47:42 -05:00
Teknium
58886fc81e fix(cache): coverage deadlines, guaranteed vs estimated ends, durable generation
The clock modelled every route as "expires = last touch + tier", which is wrong for OpenAI
GPT-5.6+: a read refreshes coverage to at least 30 minutes after it and never restarts a
12h write. It also treated documented minimums as expiries and lost or revived saved state.

- Coverage deadlines per tier with per-route refresh rules: Anthropic family restarts the tier
  on read; OpenAI keeps max(existing, read + 30m) and a 12h deadline stays at write + 12h.
- Windows carry guaranteed_until (earliest deadline, so mixed tiers in one response are only as
  warm as the shorter) and estimated_until (OpenAI: last touch + 24h retention ceiling; pre-5.6
  in_memory 1h). cache_certainly_warm / cache_certainly_cold are the two consumer helpers.
  /context: warm until / may still be warm until / expired / unknown.
- Events bind to the session's durable context generation (rows a compaction or prune archived,
  SessionDB.prompt_cache_generation), kept as saved on restore; a resumed agent restores and
  validates the saved event before folding its first response.
- Route identity is provider + normalize_route_base_url (scheme, host, port, path) + model.
- Agentless session.context_breakdown reads the saved clock (stored_cache_window).
- Codex app-server activity is recorded as an explicit unknown (it sets its own cache options).
- MoA records the resolved aggregator route and the payload the MoA client sent.
- effective_cache_ttl applies the route ceiling on the measured-provider path too.
2026-11-15 12:04:54 -08:00
Teknium
4a89bc6c02 feat(cache): one prompt-cache clock per session; Nous 5m ceiling as data
Every consumer that needs "when does this session's cached prompt expire?" now reads one
answer, agent/prompt_cache_clock.py:cache_window(), instead of re-deriving it from _cache_ttl.

- Per successful attempt the clock records the tier actually on the wire (cache_control ttl,
  prompt_cache_options.ttl, prompt_cache_retention, read from the sent payload), the send time,
  and the tier the response proved: Anthropic cache_creation.ephemeral_5m/1h_input_tokens,
  OpenAI Responses cache_write_tokens_details.ttl_30m/12h_tokens. normalize_usage keeps that
  split as CanonicalUsage.cache_write_by_ttl instead of dropping it.
- Per-route rules are a dict of small handlers: native Anthropic proves via the split;
  OpenRouter Claude is declared (live-probed to honour 1h); routes with a ceiling are clamped;
  other Anthropic-wire gateways assume 5m; OpenAI GPT-5.6+ proves via ttl_30m/12h or declares
  the documented 30m minimum; pre-5.6 assumes ~30m (5m on in_memory); implicit caches are
  unknown. expires = latest read-or-write send time + the written tier. A route switch,
  fallback, session rotation or compaction makes it unknown.
- Route TTL ceiling is data: ProviderProfile.prompt_cache_max_ttl (Nous ships "5m", because
  the Portal's upstream drops 1h after ~7 min and bills 5m), overridden per provider by config
  prompt_caching.route_ttl_ceilings. effective_cache_ttl uses the same helper, so Hermes stops
  asking Nous for 1h. A custom endpoint at the Portal host gets the Nous ceiling.
- Persisted as nullable sessions.prompt_cache_clock (JSON) through the existing token batch;
  restored lazily on resume, falling back to the newest assistant row (assumed).
- Codex app-server: read cacheWriteInputTokens instead of hard-coding cache_write_tokens=0.
- /context shows "Prompt cache: warm until HH:MM (…; 1h, proven)", "expired … ago" or
  "unknown (…)". The surface is absorbed from #142387 (render/duration helpers, the
  SessionContextBreakdownResult.prompt_cache contract and translations), reworked onto the clock.

Co-authored-by: Teknium <127238744+teknium1@users.noreply.github.com>
2026-11-15 12:04:54 -08:00
Siddharth Balyan
b2c6bc4e1e fix(usage): provider limits first, Nous balance apart
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
auto-fix lint issues & formatting / Generate eslint --fix patch (push) Has been cancelled
auto-fix lint issues & formatting / Apply patch (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Build Skills Index / trigger-deploy (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
Squashed onto main (#151819). The session.usage conflict with #141859 keeps the
branch side: _usage_nous_fields already reads the Nous fields inside the
session profile scope.

main's #141859 test now stubs both Portal reads: a session off a Nous route reads
with the stored token only (stored_token_account_info).

agent.account_usage keeps the names that moved to agent.account_usage_nous (and
BP_FULL): plugin_api.json publishes the whole module, and catalog plugins import
build_credits_view and build_nous_credits_snapshot from it.
2026-11-15 08:20:26 +05:30
yoniebans
f578714e0e test: pin that an empty backup account keeps its billing card, and drop the class-name layout test
A fallback out of credits keeps its own top-up card while the reply leads with the primary's sign-in, as on main; the billing case now sits beside the rate-limit and overflow cases, and fails if billing is routed to the primary's card. The sign-in step test that asserted Tailwind class names guarded the markup, not the layout (jsdom cannot measure it); the remaining test covers the selectable command and the rendered actions.

Reported-by: alt-glitch
2026-11-15 01:58:38 +01:00
yoniebans
296d83885f fix(gateway,desktop): name the primary only when the fallback was refused, and keep the prompt out of a selection
A fallback that hit a rate limit or an oversized request keeps its own card (Retry, reset time, compress); the primary's sign-in card applies when the fallback was refused for auth too. The sign-in command's $ prompt stays unselectable, so a manual copy gets a runnable command.
2026-11-15 01:58:38 +01:00
yoniebans
1211bb999f test(gateway,desktop): the fallback's own rate-limit card survives, and only the command is selectable (currently failing) 2026-11-15 01:58:38 +01:00
yoniebans
08af1809f5 fix(desktop): keep the external sign-in command inside its card and selectable
The sign-in step is a grid item, so a one-line command set its minimum width and pushed the rest of the command, Copy, Cancel and "I've signed in" past the card's clipped edge; widening the window changed nothing. The step now shrinks to the card, the command wraps inside its box, and the text opts back into selection.
2026-11-15 01:58:38 +01:00
yoniebans
ba0fd96731 test(desktop): cover the external sign-in step overflowing its card (currently failing) 2026-11-15 01:58:38 +01:00
teknium1
7f4e5e68a8 fix(contracts): declare upstream_repo on catalog install rows; map contributor email
ConnectionOperationTarget forbids unknown keys, so the upstream_repo the
skill install row now carries made connection.update / operation.status
reject every chat-catalog install of an upstream stub (brag, brag-slim,
impeccable, archify) with extra_forbidden. Declare it, regenerate the TS
contract, and validate the row against the contract in the test.

Map milgoff@gmail.com -> dmytrodanilenkov for the repository guards.
2026-11-14 19:54:21 -05:00
Maciej Lisiewski
2483ca10ff Merge pull request #155534 from NousResearch/sec3/148835-git-for-windows-bump
fix(pm): bump the pinned Git for Windows 2.53.0.3 -> 2.56.1
2026-11-15 01:31:13 +01:00
Gille
a2c12b1b1d Merge pull request #155774 from helix4u/fix/large-paste-messaging-session
fix(desktop): keep a large paste inline in a messaging-platform chat
2026-11-14 13:40:30 -07:00
yoniebans
0a0ef57a87 test(desktop): move the Show earlier paging walks into their own file
The paging suite owns its fake server and setup, so it stands alone in
transcript-backfill.paging.test.ts. transcript-backfill.test.ts returns
to its size on main. No test changes: the suite body moves byte for
byte, and the same 54 tests run.
2026-11-14 21:40:04 +01:00
yoniebans
df2b61eff5 fix(desktop): keep the head cut sticky when the window covers the whole store
Reporting `windowed: false` at the store head also dropped the anchor, so `advanceSessionTranscriptWindow` deleted the session's memo and the next store flush recut the window from scratch, trimming the top message off screen. The anchor and memo now stay; only `windowed` changes, and retention already ignores the anchor when the window is not windowed.
2026-11-14 21:40:04 +01:00
yoniebans
038010961b fix(desktop): skip pages the store already holds when Show earlier pages back
A background refresh records its newest page as the transcript tail, which puts the "Show earlier" offset back at the first page while the user is paging back. Each later click then fetched a page the store already held, the merge added nothing, and in a large chat the walk stalled short of the start with the button still offered.

The backfill now reads past a fetched page that adds no rows to the store, up to eight such pages per click, so a click adds older rows or retires the button. It also stops when a page repeats the one before or the store is empty, and a refresh that replaces the tail mid-walk restarts the walk from that tail, at most twice. The caller passes the transcript it holds and reports whether the merge grew it; without that, one page is read and applied as before. The offset itself is left as the refresh records it: counting from the newest row, it stays correct after /undo shortens the transcript, after a released transcript reopens on its newest page, and after compaction rewrites the row ids, where keeping a deeper offset across the refresh skips rows.
2026-11-14 21:40:04 +01:00
yoniebans
6ef5ac95e5 test(desktop): cover Show earlier across refreshes, /undo, reopen and rewrite (currently failing)
Walks "Show earlier" over a fake backend that pages like `order: 'latest'`, through the real graft, merge and backfill. On main, a refresh between clicks puts paging back at the newest page: the first click after it adds nothing, a refresh between every click never reaches the first row, a refresh during a click drops that click, and a refresh that re-arms a fully loaded chat leaves the button armed. The same walk after /undo, after a released transcript reopens, after compaction rewrites the row ids, and through held pages of tool turns must still reach every row, and one click stays bounded on a backend that ignores the offset, alternates held pages, or renumbers rows, and reads one page when the store is empty.
2026-11-14 21:40:04 +01:00
DavidMetcalfe
4c2e1716a6 fix(desktop): report the transcript window unwindowed at the store head
`advanceTranscriptWindow` returned `windowed: prev.anchorId !== null` when the sticky cut sat at `start === 0`, i.e. when the window was the whole store, the opposite of the invariant documented on `TranscriptWindow`. That kept `olderAvailable` true while gating off the REST backfill branch (`expandWindow` runs it only when `!windowed`), so "Show earlier" stayed armed with only `setWindowPages(+1)` left to do, which changes nothing when the window already covers the store. Report `windowed: false` and drop the stale anchor instead.

Carved out of #133657 (the window half of its first and third commits).
2026-11-14 21:40:04 +01:00
Gille
c7a6fa7a3d fix(desktop): a messaging-chat paste over the save cap is dropped, not inlined
Keeping the paste inline skipped the size guard a local chat gets from
savePastedText, so a paste over 64 MiB went into the editor. The inline
path now honours the same byte cap. Above it the paste gets the same
error toast and is dropped.
2026-11-14 12:04:14 -07:00
Gille
ba73272db4 fix(desktop): the main composer finds its chat without growing ContribWiring
Passing the selected chat from ContribWiring pushed that function past
its code-health cap. The composer actions hook now reads the selected
chat itself when no stored chat is passed, which is what the main
composer does. A composer that passes null, a tile with no stored chat,
does not borrow the selected one.
2026-11-14 11:03:42 -07:00
Teknium
951ec09284 fix(desktop): Bot Mode list reads name the bot as request profile; cron jobs stay ambient
A Bot Mode sidebar read sent recents_profile=<bot> while the request
profile stayed ambient, so Electron added ?profile=<ambient> and the
gateway grant check refused the pair (403 profile_scope_mismatch): the
bot's recents and cron sessions never loaded. Single-profile list reads
now carry the named profile as the request scope.

Cron jobs return to the ambient profile: Run now, Manage and the jobs
overlay all write $cronJobs for $profileScope, so a bot-scoped list
was replaced by their next refresh.
2026-11-14 09:16:49 -08:00
Teknium
c516674d61 fix(desktop): Bot Mode sidebar scope stays on the window's source
Review follow-ups on the #126732 Bot Mode sidebar scope:

- The sidebar re-scopes to a selected bot only when the bot's route is on
  the connection the window's list/search reads ride; a bot on another
  source no longer paints this source's rows under its name. The watcher
  also refreshes when the window's connection moves.
- A not_scoped bot routes at the active source (host.state.connectionId),
  never a guessed `local`, so the "+" on a remote window starts the chat
  on the bot's gateway. Unknown active source stays blocked.
- Server-side search uses the same scope as the list.
- A messaging/cron row's persisted unread flag paints its dot.
- The tile pre-fetch gate reads listed slices only; a parked hidden row
  (owner stub) never refreshes, so it froze open bot tiles.
2026-11-14 09:16:49 -08:00
Teknium
ebfa8435b5 refactor(desktop): Bot Mode sidebar scope lives in its own module
botModeFetchScope, the fetch-profile ladder its callers repeated, the
Bot Mode switch watcher and the sidebar display-scope hook move to
app/session/hooks/bot-mode-fetch-scope.ts. Keeps the touched hooks and
facades inside their code-health caps; no behaviour change.
2026-11-14 09:16:49 -08:00
Brooklyn Nicholson
c9bd605507 style(desktop): sort imports and drop unused ones in the Bot Mode sidebar diff
The sort-imports and unused-imports eslint rules are part of check:lint
and the PR's changed files failed them (workspace-scope import order, six
leftover $atoms/setters after the ownerLookupSessionRows rewrite). Fixed
mechanically with eslint --fix; no behaviour change.

Co-authored-by: Jerry Liu <953639086@qq.com>
2026-11-14 09:16:49 -08:00
JerryLiu369
38d048ba7b fix(desktop): surface Telegram DM-topic threads in Bot Mode (fixes #126732)
Bot Mode opened the canonical Bot Chat (by name, never recency) while the
Sessions sidebar fetched/filtered the ambient gateway scope instead of the
selected bot's profile, so a bot's Telegram DM-topic threads (messaging
slice only, one row per thread) had no door. Every recents-only session
lookup missed messaging rows entirely, leaving even a visible Telegram row
with no working open/rename/delete.

Scope the sidebar fetch + display to the selected bot's workspace route
(logical profile for override-aware fetch, backend target for row
matching); All-profiles keeps fanning out; blocked/empty targets fall back
to ambient. Publish a route for local bots (not just scoped remotes) so
the sidebar and the '+' target resolve the bot's own profile. Resolve all
recents-only owner lookups across every slice via the shared owner index.

Preserves gateway origin scoping (profile-scoped Desktop fetch, no
cross-profile enumeration), DM-topic lane isolation (threads stay distinct
rows), and the hidden-flag contract (plumbing hidden, gateway threads
visible).
2026-11-14 09:16:49 -08:00
Maciej Lisiewski
a95f462421 fix(pm): bump the pinned Git for Windows 2.53.0.3 -> 2.56.1
2.53.0.3 predates three Git for Windows security releases: 2.56.0.3
(eMudhra CA compromise, Git LFS CVE-2026-105803), 2.56.0.4 (bundled
brotli 1.2.1, CVE-2026-111497, reachable via libcurl's br encoding) and
2.56.1 (git CVE-2026-111760 recursive-clone RCE and five others).
2.56.1 was published 2026-11-10, past the release-age window; its first
build ships as PortableGit-2.56.1-*, which the salvaged fetch_url fix
resolves.

2.56 moved the x64 MSYS2 prefix from mingw64/ to ucrt64/, so the
trampoline self-heal git-core candidates, the non-login bash coreutils
PATH dirs and the desktop bundle-arch PortableGit exemption now also
cover ucrt64 (mingw64 kept for existing installs).

Fixes #148835
2026-11-14 17:07:28 +01:00