Commit Graph

60347 Commits

Author SHA1 Message Date
Teknium
29fef14fbf fix(terminal): background commands keep spawn PATH dirs a login profile resets
Background terminal commands run `bash -lic` with no env snapshot, so a
~/.profile or distro /etc/profile that resets PATH dropped every parent-only
dir (bare `hermes` / the venv's tools: command not found), while the same
command in the foreground now resolved. spawn_local gains an opt-in
restore_login_path that prepends the SAME _append_dropped_path_entries
prelude the foreground snapshot uses, fed from the spawn env's PATH; the
terminal tool's local background spawn turns it on. The registry's shell
argv shape is unchanged.
2026-10-28 20:45:32 -07:00
Teknium
b1ee09602e test(docker): read the login-shell probe by key so a missing hermes fails on the assert 2026-10-28 20:45:32 -07:00
Teknium
6fa171ce54 fix(terminal): keep the spawn PATH's dirs a login profile resets out of the snapshot
The terminal tool's env snapshot is captured by `bash -l`, and Debian's
/etc/profile resets PATH for every login shell, so the snapshot pinned the
reset PATH over the spawn env for every later command. In the Docker image
that dropped /opt/hermes/bin and bare `hermes` exited 127 (#56634).

The snapshot bootstrap now re-appends, in parent order, every spawn-env PATH
dir the login shell dropped (not only Hermes' bin dir: the gateway's pm
runtime dirs and `docker run -e PATH=` additions too). They go after the
login PATH, so a command that resolved before resolves to the same binary
and the user's ~/.profile additions keep precedence.

The image also ships /etc/profile.d/hermes.sh, which re-adds the ENV PATH
dirs for login shells the snapshot never covers: the terminal tool's
background `bash -lic`, `docker exec <c> bash -l` and ssh.

Found on Hermes Cloud staging.
2026-10-28 20:45:32 -07:00
liuhao1024
214c3e68b0 fix(terminal): re-add managed PATH entries after login profiles reset them
Debian's /etc/profile unconditionally resets PATH for non-root shells
before sourcing /etc/profile.d/*.sh, so the login-shell env snapshot
serialised the reset PATH and dropped the venv dir the process env put
there (#56634) — bare python3/pip then resolved to the system
interpreter.

The previous approach wrapped the command with a save/restore pair,
but the restore landed after the bootstrap's export -p, so the snapshot
kept the reset PATH anyway. Restore now runs between the init-file
prelude and the command, via idempotent per-entry case guards for
_resolve_hermes_bin_dir() + _managed_runtime_path_entries(), so
restored entries survive into the snapshot and reruns stay
duplicate-free. Tests read the PATH back from a real init_session
snapshot instead of asserting on injected markers.

Rebased onto current main (the branch had gone CONFLICTING).
2026-10-28 20:45:32 -07:00
Teknium
dbde5a991a fix(kanban): the owner refuses a worker that dials into a restart wait opened after discovery
connect_gateway's restart-wait refusal read the state discovery returned. A restart that began
between discovery and the WebSocket dial still admitted the Kanban worker on its interactive
ticket into the after-turn wait, where each prompt.receipt answer refreshed its silence budget
and held `hermes update` until the forced-restart deadline.

The policy now rides the ticket: inside outside_restart_wait() the session-ticket request carries
`restart_wait: "refuse"`, the ticket store records it on the grant, and GatewayRuntimeAPI decides
admission from the grant at redeem time, so the owner closes the socket (1013) whenever its
restart wait is open by the time the worker connects. Interactive clients still attach (#139041).
An owner older than the client refuses the unknown parameter; the client re-mints without it and
keeps the pre-dial check rather than stranding the worker until that owner restarts.
2026-10-28 20:40:14 -07:00
Teknium
eace3e056e fix(kanban): a worker cut by a restart's after-turn wait waits for the next owner outside it
`hermes update` with a Kanban card in flight sat in "still draining ... waiting on 1 active
work unit(s): managed run" until agent.restart_after_turn_timeout. The restart wait cuts every
socket opened before it (d710b2e346) so its client goes to the next owner. Since c480d67e5f
the worker redials on any transport loss, and connect_gateway attaches to an owner in its
restart wait (that window admits clients so a human can answer a parked prompt, #139041).
The worker re-entered the wait and kept polling prompt.receipt. Every answer refreshed its
silence budget, so the worker never exited, `_watch_submitter` never ended the card's
managed turn, and the drain waited on that turn until its cap.

connect_gateway now refuses an owner in restart wait as `draining`/`restart_wait` inside
`outside_restart_wait()`, and the Kanban worker dials inside it. The worker waits outside the
wait like any other transient owner state. Either the turn finishes and the next owner holds
its receipt, or OWNER_WAIT_S of silence ends the worker, which ends the turn and releases the
restart. Interactive clients still attach to the wait.

Found on CI E2E dispatch (tests/e2e/core/upgrade/handoff/test_handoff_from_head.py).
2026-10-28 20:40:14 -07:00
Teknium
13461950bf test(browser): runtime-root choice and the short-dir claim, independent of the host
Covers the private XDG runtime dir being chosen (and an open, symlinked,
relative or missing one rejected), the short dir landing 0700 under it,
and an existing short dir claimed only when it is a private real dir.
2026-10-28 20:39:38 -07:00
Teknium
92e8a6398d fix(browser): browser_exec binds its daemon socket under a deep HOME
Outside a served profile, browser-harness binds
<home>/.config/browser-harness/runtime/bu-<BU_NAME>.sock. A deep HOME (a
container's profile home $HERMES_HOME/home, a long account home) or a long
session name pushed that past sun_path and every browser_exec died with
"browser-harness: fatal: AF_UNIX path too long". Only served profiles had a
short-dir fallback.

browser_exec now judges the default socket on the call's final BU_NAME and,
when it would overflow, points BH_RUNTIME_DIR at a private 0700 hbh-<hash>
dir (keyed by uid and harness home): the user's runtime dir
($XDG_RUNTIME_DIR, else /run/user/<uid>) first, the short socket temp root
only where none exists (containers, macOS). A socket that already binds keeps
its path and its live daemon; an exported BH_RUNTIME_DIR/BH_TMP_DIR is kept.
2026-10-28 20:39:38 -07:00
Teknium
882482b58a fix(compression): the active-request bridge obeys the post-handoff progress floor
When the first post-handoff tool group ends right before the active user
request, the progress floor lands on that request, and _compress_window's
assistant/tool bridge then pulled the cut back onto the group's assistant:
the window held only the handoff and compress() no-oped with
empty_post_handoff_window. The bridge now moves the cut back only down to
tail_cut_progress_floor (one rule); when the floor sits on the active request
the summary merges into that row through the existing merge path.
2026-10-28 20:39:24 -07:00
Teknium
f6a84fd6d9 fix(compression): a tail cut inside the first post-handoff tool group still compacts
After a compaction the transcript opens with the handoff followed by a tool
group. When the raw tail budget broke inside that group, the cut was aligned
back onto the group's assistant, leaving a window that held only the handoff.
The handoff scan drops standalone handoff rows, so compress() returned the
empty_post_handoff_window no-op and the session stayed over the trigger with
no warning. Since #144824 priced pre-handoff rows at zero, the whole-transcript
re-cut takes this path routinely.

The progress floor now requires one row the scan keeps: when every row before
the cut is a handoff, the cut moves past the next tool group, unless that
would take the newest row or the active user request out of the tail.

Found on the C4 e2e suite: test_good_summarizer_compacts_and_keeps_every_invariant[11]
failed deterministically since 52a01bd2f2.
2026-10-28 20:39:24 -07:00
Teknium
b435451a73 fix(webapp): picker rows resolve their menu on open; focus returns to the picker
Review follow-ups on the phone tab picker:
- A row decides whether it has a menu when the picker opens (PickerRow
  mounts then). The rows used to be built with the picker's last render,
  so the main tab stayed without its menu after it gained a session until
  something else re-rendered the zone.
- The tab menu hangs off an inert anchor, so a plain close (Escape, a
  non-dialog verb) now hands focus back to the picker button; a dialog the
  menu opened keeps it.
- Tests cover the main tab (none on a fresh draft, targets the selected
  session once it has one) and the focus hand-back.

Refs #145774
2026-10-28 20:37:58 -07:00
Teknium
c2dcdf5474 chore(i18n): regenerate the desktop key manifest for zones.tabActions
Refs #145774
2026-10-28 20:37:58 -07:00
Teknium
f0ee05c6b9 fix(webapp): the phone tab picker reaches every tab's menu (#145774)
On a narrow touch viewport the tab strip gives way to CompactTabPicker,
which only offered switch / close-current / +. A session tab's menu
(rename, archive, delete, ...) lived only on the strip's right-click, so a
phone could never archive, delete or rename a session.

Each picker row now carries a 44px "..." button that opens that tab's own
menu: a new PaneChrome.tabActions renders the SAME session verb set the
right-click menu uses (one useSessionTabActions source feeding both
SessionContextMenu and SessionActionsMenu), delete still behind its
confirm dialog. The menu stays mounted after it closes so the rename and
delete dialogs it opened survive. The wide-viewport strip is unchanged.

Fixes #145774
Refs #144648
2026-10-28 20:37:58 -07:00
Teknium
9039580d0a ci: plugin catalog entries no longer need a code-owner review
A catalog entry is data (a pinned sha, a description, a card) reviewed by the maintainer landing it.
Since #131726 /plugin-catalog/ sat in CODEOWNERS, so every entry and re-pin needed a second
hermes-agent-core approval or an admin bypass. Drop that line; the README's tier note now names
maintainer review as the gate.
2026-10-28 20:37:11 -07:00
Teknium
0911d094ea test(webapp): the Webapp attach spec expects the machine owner as the turn's principal
#145598 (8497ce9318) made every login, a loopback Webapp tab's session token
included, act as the host owner's OS subject (uid:<n>), the identity native
Desktop uses. The core-lane spec still expected the old
auth:v1 session-token principal, so 'the gateway serves the Webapp and runs every
turn its browser sends' has been red on main since that merge; the Desktop core
lane is path-gated and did not run on #145598.

Assert the owner subject instead. Locally (real `hermes webapp` gateway +
Chromium + scripted provider): unmodified spec red 2/2 on main 72ffcb9788 with
received ["uid:1000"]; this spec green, whole file 8/8 across 2 repeats.
2026-10-28 20:35:00 -07:00
Teknium
0b95c47163 test(desktop): the two-finger case where the outside finger lifts first needs the move guard
The existing case ends with a finger still down, so the touchend guard alone kept it green.
Both fingers are now down during the move and the editor finger ends last with no touches
left: removing the touchmove cancellation turns this red. (Greptile P2 on #145838.)
2026-10-28 20:24:20 -07:00
Teknium
6f43cc98df fix(desktop): a two-finger gesture no longer focuses the Webapp composer
The touch tap-focus handlers only looked at the first finger. A second
finger that lands outside the editor never fires touchstart on it, so a
gesture that started with one finger in the editor, added a second
elsewhere, moved the first under 10 px and lifted it while the second
stayed down still counted as a tap and focused the composer (opening the
iPhone keyboard mid-pinch).

touchmove now cancels the tap whenever more than one finger is on the
screen, and touchend does nothing while any finger remains.

Reported by @unsupportedpastels in the review of #145569.
Refs #145166
2026-10-28 20:24:20 -07:00
Teknium
974feef5e9 fix(desktop): Webapp preview reads say the page is unreadable; read_window_below refuses cleanly
In the browser-hosted Desktop a URL preview renders in a sandboxed iframe that
no page reader can ever register for, so desktop_preview read answered "The page
has not finished loading — retry in a moment." forever (after an 8 s wait on a
pop-out that cannot exist there). It now answers at once with surface: "iframe"
and a note pointing at web_extract / browser_exec.

read_window_below in a browser tab got an empty answer, which the tool reported
as "the desktop app did not answer". The renderer now answers the documented
{error, platform} shape saying a browser tab cannot see OS windows.

Electron behaviour is unchanged (gated on hostHas capabilities).
2026-10-28 20:23:50 -07:00
Teknium
17b539a49c test(webapp): a closed tab's paste cancel is seen wherever it lands in the write
test_closing_the_tab_during_a_waiting_paste_detaches_and_keeps_the_shell
[posix-pty-quiet] watched only the bridge's wait for room for the
CancelledError. On a loaded runner the pty's line discipline frees room after
the first wait, so the write resumes; a later full queue sets `stalled`
from the worker thread just before that thread hands back its result, and
_write_while_open cancels the write while it still awaits the thread. The
cancel is real and the shell is detached correctly, but it never passed
through _wait_writable, so `cancelled` stayed unset (main runs 40411213768,
40297653855; both passed on retry).

The fixture now records a CancelledError leaving bridge.write itself; the
wait instrument still proves the paste reached backpressure.

Sabotage (first wait drains the slave and returns, worker sleeps 0.3 s after
each report): base fails both posix params with the CI signature; fixed
passes, including every detach/retention assertion after it.
2026-10-28 20:23:19 -07:00
Teknium
fc80c939a6 plugin-catalog: ElevenLabs Music (official, hermes-official-plugins@1e326dd) 2026-10-28 20:20:12 -07:00
Teknium
eaf03cb4dc fix(desktop): profiles with no chats keep their sections when nothing else is listed
With several profiles and no chats, projects, threads or jobs anywhere,
the sidebar fell back to the blank state and hid the empty profile
sections the grouping had built. Two or more profile groups now keep the
session area; a lone empty profile still shows the blank state.
2026-10-28 20:09:13 -07:00
Teknium
47f0fc99d2 feat(desktop): show every profile as a sidebar section, chats or not
Grouped by profile (All profiles), a profile with no chats had no section,
so a new or quiet profile vanished from the sidebar. Profile groups now
also come from the profile list the profile picker reads ($profiles),
added empty under the owner that list was read from (the request
connection, `local` in a Webapp tab, the untagged primary pool natively).
An empty section shows its header, new-chat action and a muted
"No sessions yet" row. Filtered, archived and failed-load views stay as
they were. Shared by the Webapp and native Desktop sidebar.
2026-10-28 20:09:13 -07:00
Teknium
f2703ac578 fix(webapp): keep per-profile usage totals on the host's profile groups
Every Webapp row now carries connection_id 'local', and the sidebar's
usage selector refused any group with a connection id, so per-profile
cost/token totals vanished in the Webapp. A browser-hosted tab's `local`
groups are the serving host's own profiles, the gateway the totals were
read from; native registry gateways keep the guard.
2026-10-28 20:09:13 -07:00
Teknium
9562f87b56 test(webapp): a listed Webapp row resumes its own profile through local
The session-owner stamp doc said `local` is never stamped; the Webapp
REST door now tags every listed row `local`, so the doc names that
exception. A Webapp resume already routed through `local` (the tab's
connection is mode remote, connectionId local), so the tag changes no
dial: it only stops the remembered-owner hint write, and the row's
detail read is tagged the same.

New vitest: a row listed through the Webapp bridge (gateway local,
profile work) resumes on the tab's own socket with profile work, reads
work's transcript through (local, work), builds no second socket, and a
later open without the listing (no hint) routes the same. Fails with
the bridge's tag removed (checked).
2026-10-28 20:09:13 -07:00
Teknium
91cb42ee37 fix(webapp): keep one gateway's sessions in one sidebar section
The Webapp's new chats name their owner `local` (the bridge's only source), but
the session rows it lists came back untagged: Electron's main process stamps
each source's rows with their connection, and the browser bridge had no
equivalent. Grouped by profile, one gateway then split into an unowned
top-level `default` group plus a `local` gateway section holding `default`
again. The bridge's REST door now tags listed rows like Electron does, and a
`local` section no registry lists reads "Hermes host" instead of its raw id.

Found on Hermes Cloud staging.
2026-10-28 20:09:13 -07:00
Teknium
01dfee9a41 fix(webapp): a Webapp tab installs a desktop plugin from any source the CLI takes
Private plugins live behind ssh keys or in local folders. The Webapp's
host-side desktop install accepted https only; it now takes git@/ssh://,
file:// and http:// like the agent installer and native Desktop, per the
maintainer ruling on #146189.
2026-10-28 19:53:28 -07:00
Teknium
43ee1b0872 revert(plugins): Desktop, Webapp and dashboard installs take every source the CLI takes
Maintainer ruling: Desktop and the Webapp must keep installing private
plugins. The https-only source rule this branch added
(guiInstallSourceRefusal in the native install IPC, gui_install_source_refusal
in plugins.manage install and POST /api/dashboard/agent-plugins/install)
refused git@/ssh:// private repos, http:// and file:// local folders. It
goes, with its tests, and the user guide says Install from Git takes any
git source `hermes plugins install` accepts.

The symlink / plain-tree / 64 MB refusal in publishDesktopTree, the
reconcile refusal report in the install dialog and the forced-reinstall
fix stay.
2026-10-28 19:53:28 -07:00
Teknium
3dbd91639a fix(desktop): a refused forced reinstall keeps the installed desktop plugin
installDesktopPluginFromGit removed the existing folder as soon as Force
was set, before publishDesktopTree checked the new tree. A replacement
the plain-tree check refuses (a symbolic link in it, over 64 MB) then
left the user with no plugin at all. The early removal goes:
publishDesktopTree already replaces the folder after the check, the
staged copy and the marker succeed, under the same root-writer lock.
2026-10-28 19:53:28 -07:00
Teknium
009fd7caba fix(desktop): a refused desktop half is not reported once another profile published it
The reconcile walks every profile and the first one to publish a name
owns the root copy; a same-named package refused in an earlier home no
longer surfaces as the install dialog's failure.
2026-10-28 19:53:28 -07:00
Teknium
5b4468b159 fix(desktop): install dialog reports a refused desktop half as failed
A combined package's desktop half is published by the reconcile pass,
and a half that pass refuses (a symlink in its tree, over 64 MB) was only
logged. The reconcile IPC returned the published paths alone, so the
dialog toasted "Desktop plugin <name> installed" for a half that was
never copied.

The reconcile IPC now answers { published, refused: [{ name, reason }] }.
The preload keeps reconcileDesktopPlugins() returning the published paths
for its existing callers and adds reconcileDesktopPluginsReport(); the
install run reads it and puts the refusal reason in the dialog for the
package it just installed. The agent half's success toast is unchanged.
2026-10-28 19:53:28 -07:00
Teknium
5e65857799 fix(desktop): run the plain-tree check where every desktop tree is published
The symlink refusal and 64 MB cap ran only in the git installer, so a
combined agent+desktop package (agent half installed, desktop half copied
by the reconcile pass) still published a link inside its desktop/ folder.
publishDesktopTree now takes the tree's containing package and checks it
before staging; only a package folder the user symlinked in by hand (a
development checkout) is copied as it stands.
2026-10-28 19:53:28 -07:00
Teknium
12944611f0 fix(plugins): Desktop and Webapp agent-plugin installs clone https only
plugins.manage install (native Desktop, the Webapp) and the dashboard's
POST /api/dashboard/agent-plugins/install handed any identifier to
dashboard_install_plugin, so a click could clone a file:// folder, an
ssh/git@ source through the host's ssh-agent, or plain http://. Both GUI
doors now refuse a non-https custom source before cloning, through one
helper (gui_install_source_refusal). A catalog_name install clones the
catalog's own source and is unchanged; `hermes plugins install` keeps
every scheme it documents.
2026-10-28 19:53:28 -07:00
Teknium
9d4ab00f33 fix(desktop): native plugin install clones https only and refuses symlinked desktop trees
The Install button in native Desktop (hermes:plugin:installDesktop) accepted
file://, ssh://, git@ and http:// sources and copied the desktop/ tree with
fs.cp, which publishes symlinks (and copies through a symlinked desktop/
folder), so a repository could publish files from this machine as plugin
files. The IPC door now refuses any non-https source before cloning, and the
installer refuses a desktop tree with a symlink on the way to or inside it,
plus a 64 MB cap, the same policy as the Webapp's host-side desktop install.
`hermes plugins install` keeps every scheme it documents.
2026-10-28 19:53:28 -07:00
Victor Kyriazakos
a8b987aaa1 fix(bedrock): apply configured request timeouts to Bedrock clients
providers.bedrock.request_timeout_seconds and
providers.bedrock.models.<model>.timeout_seconds resolved correctly through
hermes_cli.timeouts.get_provider_request_timeout, but no Bedrock client was
built with the result. The cached boto3 bedrock-runtime client (ambient and
profile-scoped) was created with no botocore Config, so it kept botocore's
60s read / 60s connect, and the AnthropicBedrock SDK client was built with
_client_timeout(None), i.e. a fixed 900s read. The resolver (3143d32330)
landed after the cached Converse client (0cb8c51fa5) and was wired only into
the OpenAI-wire and native Anthropic builders; 611657487f documented Bedrock
as not covered instead of wiring it.

- _get_bedrock_runtime_client(region, model) resolves the model's timeout
  (model over provider) and passes Config(read_timeout=..., connect_timeout=60)
  only when one is configured; unset or invalid builds the exact
  no-Config client used before.
- Both client caches (ambient and per-profile-home) key on the effective read
  timeout, so models with different overrides in one region never share a
  client, and the same timeout reuses one client. Stale-connection eviction
  drops every timeout slot of the region.
- converse/converse_stream dispatch picks the client from the request's
  modelId, so a /model switch or a fallback to another Bedrock model uses
  that model's timeout. call_converse and the context probe pass their model.
- AnthropicBedrock: build_anthropic_bedrock_client takes the timeout; the
  bound client and the per-request client key carry the active model's
  value (connect stays 10s, unset stays 900s).
- Docs: replace "not currently wired for AWS Bedrock" with what is wired.

This closes a configuration gap only. A socket read timeout bounds each read,
not the whole call; retry policy and the stale detector are unchanged.
2026-10-28 19:51:15 -07:00
Teknium
0bb556f3a9 fix(gateway): drop a remote attachment's original name with it
_drop_remote_media (main, 538755f) strips an uncached remote URL from
media_urls/types/inlined so the rest of the message is admitted. Relay
keeps a public URL whose download failed together with its original
name, so the new media_filenames list stayed one longer than media_urls
and the length check refused the whole message again.
2026-10-28 19:49:37 -07:00
Victor Kyriazakos
25a61a6e87 fix(relay): keep original attachment filenames for the agent
Relay inbound attachments are localized to random relay_media_<x> temp
files, and that random basename was the only name left. The wire
media[].filename was dropped, Content-Disposition only contributed its
extension, and the document note showed the random basename as the
user's filename.

- MessageEvent.media_filenames: per-attachment original name, parallel
  to media_urls with the same invariant as media_types ("" = unknown).
- _event_from_wire fills it from media[].filename by URL lookup. Older
  connector payloads without the field still parse.
- RelayMediaClient.download_with_name returns (path, name). It prefers
  suggested_name, then Content-Disposition parsed with the stdlib MIME
  parser (quoted values, RFC 5987 filename* preferred over filename).
  download() keeps its path-only signature. Storage stays a random temp
  name, so duplicate names never collide.
- _localize_inbound_media carries (url, mime, name) triples, so a failed
  download never shifts a neighbour's type or name.
- Document, audio and video notes use the original name when known. A
  relay temp file with no known name is labelled
  "(original filename unknown)" instead of its random basename. Native
  cache paths (doc_<id>_<name>) render exactly as before.
- Names are untrusted: basename only, control/format characters
  dropped, 255-char cap, and the existing note regex replaces quotes
  and brackets.
- The names survive pending-message merges, text batching, /queue and
  the native admission envelope. The envelope omits the field when no
  name is known, so existing admissions keep their fingerprint.
2026-10-28 19:49:37 -07:00
Teknium
4e1a4df663 fix(cron): keep the cronjob tool schema net-small for per-job timezone
The cronjob schema is sent on every API call. Keep `timezone` (the feature)
with a one-line description and leave the catch-up window override
(`grace_minutes`) to the CLI and dashboard, where it is already settable.
The handler still accepts it, so nothing that passes it breaks.
2026-10-28 19:40:40 -07:00
Teknium
bcf7316190 chore: map yliu325@asu.edu to tyler-y-liu 2026-10-28 19:40:40 -07:00
Teknium
c70876b9fe fix(dashboard): cron create accepts timezone/grace_minutes
CronJobCreate had no such fields, so POST /api/cron/jobs silently dropped them (a bad zone returned 200 and stored an unpinned job) while PATCH validated them. Pass both to create_job, which validates.
2026-10-28 19:40:40 -07:00
Teknium
3035c0c0ec fix(cron): grace_minutes=0 skips real misses instead of every run
The ticker fires seconds after the slot, so a 0 s catch-up window classified every on-time run as missed: with cron.catch_up_missed=false the job never fired at all, and with the default it still ran late misses and stamped every normal run catch_up. Floor the override at the existing 120 s tick tolerance, and let an explicit per-job grace skip a miss past its window regardless of the global catch-up default (that is what the user asked for on that job).
2026-10-28 19:40:40 -07:00
Teknium
3dbe3ec4d8 fix(cron): every slot move honours a job's pinned timezone
Two next_run_at writers still computed in the profile zone: extra_fire.settle (new on main since this branch was cut) after a manual run, and merge_job_definition when a profile distribution changes only the timezone. Either leaves an instant that is off the job's own cron lattice, so the next scan re-anchors past it without firing: one silently skipped run.
2026-10-28 19:40:40 -07:00
yliu325
b81e71addd feat(cron): optional per-job grace_minutes override
The catch-up window (how late a missed cron occurrence may run instead of being skipped) was
half the job's period, clamped to 120s-2h, for every job. A job can now override it outright:
0-1440 minutes, `0` meaning never catch up.

`grace_minutes` is a real 0, not "unset" — and the obvious write pattern would eat it:
`v in {None, "", False}` (the `workdir` update lambda) and `if value:` both treat `0` as
False in Python. Both doors therefore share `jobs_time.normalize_grace_minutes`, reads test
`is None`, and the renderer formats before testing truthiness.

The override moves the dispatch stamp too: `_classify_dispatch_lateness` and the dispatch
health metric read the same window, so a job the scheduler calls "late" is never reported
overdue by the dashboard.

Refused on `once`/`interval` schedules: the window describes a missed wall clock, and a
duration has none.

Split from the timezone commit so it can be reverted alone.
2026-10-28 19:40:40 -07:00
yliu325
bfa67878cd fix(cron): per-job timezone drives schedule compute and due-scan
A job may pin its own IANA timezone; its cron expression is then that zone's wall clock,
independent of the profile's configured timezone. Absent/None inherits the profile, so an
existing jobs.json keeps byte-identical behaviour and needs no migration.

The dispatch path needs the pin as much as the compute does. `compute_next_run()` resolves
the zone as job pin -> profile zone -> base offset, and every site that writes `next_run_at`
now passes it (advance, claim, resume, re-arm, recovery, and the quota/unreachable
planners); one missed site re-fires or skips a slot because the stored instant and the
expression would be read in different zones.

`_evaluate_due_job()` normalizes the stored instant into the JOB's zone, which hands every
downstream cron predicate the job's clock, and a pinned job skips
`_repair_timezone_shifted_cron` outright. That repair exists for jobs that FOLLOW the profile
zone across a zone change: on a pinned job its wall-clock comparison reads a due occurrence
as still-in-the-future and re-anchors past it.

Failing shape this fixes (profile America/Los_Angeles, job 0 9 * * 1-5 pinned to
America/New_York, scanned at 09:00 New York): `get_due_jobs()` returned [] and the job was
re-anchored to the next day, i.e. job zones east of the profile zone silently never fired.
The regression test drives the public store API and asserts both the fire and the absence of
the repair, and is proven red on main ([] and a rewritten instant).

Knobs live in the new sibling `cron/jobs_time.py`; `cron/jobs.py` stays over the file-lines
ratchet and only gained the call-site plumbing.
2026-10-28 19:40:40 -07:00
Teknium
9e6d6f98a4 chore: map horizonbymuneeb contributor email 2026-10-28 19:38:41 -07:00
Teknium
67bce8c25d fix(slack): strip mention labels before emphasis parsing in rich_text
A labelled mention such as <#C1|dev_ops_alerts> or <!subteam^S1|@eng_team_x>
was split by the italic regex on its underscores before the leaf mention
split ran, so Slack showed the token literally with a stray italic run.
The label is dropped from the element anyway, so drop it up front.
2026-10-28 19:38:41 -07:00
Muneeb Anjum
a0f9c92bd7 fix(slack): render mentions as rich_text elements in rich_blocks
rich_text does not interpret mrkdwn, so <@U…>, <#C…>, <!subteam^S…> and
<!here|channel|everyone> tokens inside lists, quotes and table cells were
emitted as text and rendered literally. Split them into user/channel/
usergroup/broadcast elements at the emphasis leaf so surrounding bold/
italic/strike spans survive.

Fixes #133315. Squashed from #133323 (095821f, 53c8268, fcf7c97, 9fd0327).
2026-10-28 19:38:41 -07:00
Victor Kyriazakos
cf6623e433 fix(gateway): resolve delegation mode from configured interim and keep the pinned mode across refreshes
A scheduled heartbeat muted interim messages by rewriting the turn's display
settings, and the agent build read that muted value to freeze the session's
delegation mode. Heartbeats run under the user's session key, so on a cold
agent cache a heartbeat built (and cached, and pinned) an inline agent for an
interim-on chat, and the user's later turns ran inline. The heartbeat rewrite
no longer touches interim: TurnRunner already drops interim messages for a
heartbeat turn, and the TurnContext keeps the chat's configured value, which
is what a fresh agent's delegation.gateway_mode reads.

A fresh agent restored its session's tools[] pin (schema bytes) but kept the
build-time inline flag, so the next rebuild from fresh definitions
(compaction boundary, /reload-mcp, Bot Chat refresh) re-derived the other
variant and flipped the chat mid-conversation. restore_agent_tool_prefix now
re-freezes the flag from the restored delegate_task, making the pin
authoritative.

Docs: inline turns past the notify interval still get the long-running
notice (display.long_running_notifications); the stability sentence now
names compaction, /reload-mcp and heartbeats, and the post-update exception;
a deferred delegate_task (tool_search.defer) stays background.

Tests: heartbeat-first turn with an agent cache (interim on stays
background, control, interim off stays inline), a composed cell with agent
cache + real SessionDB pin + heartbeat + restart, and pin restore followed by
a compaction or /reload-mcp refresh in both directions.
2026-10-28 19:35:16 -07:00
Victor Kyriazakos
fa2befeed7 fix(gateway): join delegations in the turn when interim messages are off
On a messaging chat with display.interim_assistant_messages off, a top-level
delegate_task still produced two messages: a "checks are running, I don't have
the findings yet" reply and, later, the real answer. Top-level model
delegations always run in the background (ea8a8b4af8), and the tool text tells
the model to "give a one-line status and END YOUR TURN" (c89f3b8800). That
status is the turn's final answer, not interim text, so no display setting
held it back.

New key delegation.gateway_mode: auto | inline | background (alias async).
auto (default) joins the children inside the turn on a messaging chat whose
resolved interim setting is off (global, display.platforms.<p> override or
platform default). The parent waits in the tool call, gets the results there
and sends one answer. API, local and webhook surfaces keep the background
path under auto. Chats with interim messages on are unchanged: same schema
bytes, same async dispatch.

How it works:
- The gateway resolves the mode from the turn's own profile-scoped config
  when it builds a session's agent (gateway/session_execution.py), and the
  agent's first tool build freezes it (like the one-shot pin).
- An inline session carries the joined delegate_task variant the one-shot
  path already uses: "results return in this tool call", no live-control
  parameters, no END YOUR TURN.
- Dispatch follows the delegate_task schema the session carries
  (session_joins_delegation), so schema and behaviour cannot disagree. The
  schema rides the session's tools[] pin: a config change applies from the
  next session (/new), as delegation.backend does, and a cache eviction or
  restart never flips a running chat.
- Inline children run on the existing synchronous path: attached to the
  parent, so /stop and an interrupting follow-up stop them; the per-child
  heartbeat keeps the parent's activity fresh for the inactivity watchdog;
  the async completion registry is not used. Nested and one-shot delegation
  are unchanged.

Refs #95522.
2026-10-28 19:35:16 -07:00
Victor Kyriazakos
c49ecd5892 fix(gateway): a cancel during the producer start hook releases its typing and bracket
A drain cancelled while on_processing_start is awaited left the typing refresh running and the
row's bracket in producer_turns, because producer_turn's finally was not entered yet. Release both
before re-raising.
2026-10-28 19:34:43 -07:00
Victor Kyriazakos
02438db863 fix(gateway): give producer-admitted relay turns their typing and reactions back
A relay chat message has been admitted natively since the session authority shipped (e75bc52f50,
first released in 0.22.3; e3fdebbf87 moved it into gateway/relay/inbound_admission.py):
RelayAdapter._on_inbound commits it through admit_producer and the authority's drain runs it.
The typing refresh and on_processing_start/on_processing_complete only ever ran in
BasePlatformAdapter._process_message_background, which that path never enters. So a relay
message got no in-progress reaction, no typing / Slack "is working" status, and no outcome
reaction; only tool progress re-sent typing, so a turn without tools showed nothing. Slash
commands still go through handle_message and kept theirs.

The turn executor now brackets producer-admitted turns (relay and webhook deliveries; a messaging
admission's own adapter task already brackets it):

- admit_producer marks the event it commits; SessionAuthority._admitted records a freshly queued
  row in the commit's own tracked task. A re-send of a row already running or settled is not
  marked again, and a cancelled queued row drops its mark (_settle_cancelled).
- execute_admission opens the bracket when the row starts executing, not when it commits: a
  message queued behind a running turn is acknowledged when it runs, as the in-band queue does
  (run_turn_followup_ack) and as 0.22.2's drain task did. It starts the adapter typing refresh
  with the event's thread metadata and runs on_processing_start.
- Typing lives as long as execution and stops before the reply is sent (#117300 pauses it there).
- The outcome is reported once: an interrupted turn as CANCELLED and a failed one (exception, or a
  failed result) as FAILURE when execution ends; a completed one after settlement, from the
  reply's send in deliver_settled (deliver_response now reports whether it delivered), or as
  FAILURE when settlement dropped the reply.
- Adapters that render neither typing nor processing hooks (webhook) get no bracket; scheduled
  wakes and heartbeats are not producer admissions, so they stay silent.

pre_gateway_dispatch still fires once at admission, admission stays off the transport reader and
the ACK semantics are unchanged: the bracket lives entirely on the execution side.
2026-10-28 19:34:43 -07:00