* docs(agy): say request-review follows agy's toolPermission setting
On agy acp, HAPI's request-review is agy's default mode, which asks only
as agy's own toolPermission setting says. With toolPermission set to
always-proceed, agy runs commands and edits without asking, so HAPI shows
no approval prompts, and HAPI cannot override that per session. The
guide now says so, and says what acceptEdits and plan do on agy.
It also notes that always-proceed approves a request a PreToolUse hook
marks force_ask: agy sends it as an ordinary approval request, with
nothing that says it came from a hook.
* feat(acp): carry the agent's own tool name and args on tool calls
Some ACP agents send their own tool name and args next to the standard
title, kind and rawInput (agy: name, args). Pass them through as
nativeName and nativeArgs so a launcher can pick a card by the real tool
instead of a free-text title. Agents that send no name are unaffected.
* feat(agy): show agy ACP tool calls as the canonical tool cards
Map agy's own tool names to the cards the other flavors use: run_command
to Bash (with a clean stdout result), read_file to Read, edit_file to an
Edit diff, write_file to Write, search_web to WebSearch, invoke_subagent
to Task and call_mcp_tool to the mcp card. A write_file artifact (plan or
task list) is shown as a plan instead of a hidden brain-directory path.
A command agy moves to the background gets no further update after
end_turn, so its card spun until the next message. Show it as running in
the background at end_turn; the real result replaces that when agy reports
it in a later prompt's stream.
* fix(cli): keep LAN access for sessions that outlive their runner on macOS
macOS attributes Local Network decisions to a process's responsible
process, which a child inherits from its spawner. Sessions spawned by a
runner that launchd started (directly, or through the npm launcher
bin/hapi.cjs) inherit the runner's or the launcher's pid. Once that
process exits (upgrade, version handoff) while the sessions are kept,
every new process in their trees that connects to a LAN address fails
with EHOSTUNREACH.
When the spawner may hand its responsibility on, detached spawnHappyCLI
children (sessions, runner handoff, runner start) are started with
HAPI_DISCLAIM_RESPONSIBILITY=<spawner pid>. In a direct child of that
pid, the entry hook removes the variable from the libc environment and
re-executes process.execPath in place via posix_spawn(POSIX_SPAWN_SETEXEC)
with responsibility_spawnattrs_setdisclaim, so the child becomes its own
responsible process. The pid, stdio, process group, cwd and the rest of
the environment are unchanged, so the runner's ChildProcess tracking keeps
working.
The spawner may hand its responsibility on when it is its own responsible
process, or when its responsible process is its direct parent, is the npm
launcher (which now passes HAPI_LAUNCHER_PID) and is itself its own
responsible process. A spawner started from Terminal or over SSH keeps the
inherited responsibility and with it the implicit LAN allowance macOS
grants there. The lookup uses responsibility_get_pid_responsible_for_pid
through bun:ffi; when it is unavailable the spawn is not disclaimed and
this is logged once.
Binaries without the hook ignore the variable, and a copy that leaks into
a rolled-back tree is ignored because its parent is not the spawner. The
private disclaim symbol may disappear: the hook then execs without it, and
any other failure continues in-process; the reason is written to the hapi
log.
* fix(cli): print --help and --version when HAPI_HOME cannot be created
The entry point imported runtime/responsibility to read the npm launcher's
pid. That module imports the logger, whose configuration creates HAPI_HOME,
so `hapi --help` and `hapi --version` failed before printing when that
directory could not be created.
Move the launcher pid into a dependency-free module, read it from there, and
make the optional disclaim fallback note best effort. Add an entry point test
that runs both flags with an unwritable HAPI_HOME.
* refactor(agy): isolate the stream-json transport in its own module
Move everything only the stream-json driver uses into
cli/src/agy/legacyStreamJson/: the driver and stream process, the NDJSON
parser, the conversation-DB model and title readers, the transcript entry
types, and the agy transcript producer that lived on ApiSessionClient as
sendAgySessionMessage. The driver now registers its own queued-message
cancel handler for batches held in its retry backoff instead of reaching
through AgySession.
The loop runs the remote session through agyRemoteLauncher, the one place
that picks a transport; it is the only importer of the new module. No
behavior change.
* feat(acp): report soft-steer usage and prompt timing to the caller
Antigravity ends a steered session/prompt request early and reports each
request's share of the turn in its own response. Let soft-steer callers
receive that usage so they can total it for the turn.
prompt() waits for earlier output before it sends and for late output
after the answer. Callers can now learn when the request was sent and
answered, and a soft steer exposes when it was answered, so they can time
the agent itself and run their own timers on its answers.
* fix(acp): keep the JSON-RPC error code on failed requests
A rejected request lost the agent's error code, and the soft-steer failure
log printed the Error as {}. The rejection now carries code and data, and
the log keeps the message and code.
* feat(agy): run Antigravity on agy acp when agy supports it
agy 1.5.0 added an ACP server. When `agy --version` reports 1.5.0 or
newer, agyRemoteLauncher runs the session on a new ACP launcher over the
shared AcpSdkBackend; older agy, or a version that cannot be read
(pre-release of 1.5.0, missing binary, no answer), keeps the stream-json
driver and says why in the session. The check and the stream-json
launcher live in legacyStreamJson/, behind one call.
On ACP, one agy acp process serves the session. The agy conversation id is
the ACP session id, so stored agySessionId values resume through
session/resume without replay, whichever transport started them. The
launcher marks the session with agyProtocol 'acp' in metadata; the
stream-json launcher removes a stale marker.
- Model and effort apply per turn through session/set_model with agy's
<model>-<effort> ids; clearing the model returns to agy's default. The
mode is sent every turn, since agy can change it on its own.
- A queued message counts as delivered once agy takes it (its echo,
output, or answer), or when it goes back to the composer.
- Permission modes map to ACP session modes. agy approval requests reach
HAPI through the shared ACP permission handler. agy titles a
run_command request with the command line, so the handler's name hints
for HAPI's own MCP tools (change_title, think, ...) are turned off for
agy; otherwise a command such as `grep think notes.md` would skip the
approval prompt. Automatic approvals pick a one-time option, because the
agy process outlives mode switches, and agy question requests always
wait for the user.
- Titles come from session_info_update, and each turn reports one usage
total built from the prompt responses.
- If the agy process dies, the next turn restarts it and resumes the
conversation (the transport now reports whether its process is alive).
A restart that fails part way leaves no half-started process in use;
the next turn tries again. A prompt agy never started is restored to
the composer.
* feat(agy): add accept-edits and plan permission modes
agy has default, accept-edits, and plan execution modes. Expose
accept-edits and plan as acceptEdits and plan next to request-review
(agy's default mode) and always-proceed. On agy acp they switch per turn
through session/set_mode without restarting agy; the stream-json driver
passes them as --mode, so a change restarts its process like other
launch settings. The iOS and Android catalogs mirror the new list.
* feat(agy): steer queued messages into the running turn
agy acp folds a second session/prompt into the running turn. Register the
SteerQueuedMessage handler in the agy ACP launcher and open the steering
gate for agy sessions whose metadata says agyProtocol 'acp'; stream-json
sessions stay queue-only. The launcher publishes the marker and registers
the handler before it starts agy, so the hub knows the protocol before any
turn can take a steer; until then the hub tells a steer on an agy session
that Steer is not available yet, rather than listing other flavors.
agy answers the request a steer interrupts at once (end_turn) while the
turn continues under the steer, and it lets a running tool call finish.
So the launcher keeps the turn, its steeringActive state, and thinking
until every open prompt request settles, and totals usage across them;
usage from a steer answered after its turn ended is not reported again.
agy echoes a steer as a user_message_chunk when it folds it in. The ACP
backend now reports those echoes after flushing the output before them,
and the launcher commits the steer when the echo text that follows the
prompt's own echo matches it (whitespace-insensitive; the longest steer
text wins when one contains another), so the message lands in the transcript where
it entered the turn rather than after the final answer. Each steer
resolves once (echoed or answered, held, or put back). agy rejects a
prompt while an approval is open, so a steer is refused then and the
message stays queued.
Stop applies to the whole turn lifetime. It withdraws Steer at once and
refuses steers that arrive after it. The turn is registered before agy
restarts or switches settings, so a Stop before the prompt is sent puts
it back in the composer, and a prompt still waiting to send is cancelled
as soon as it reaches agy. agy answers a cancelled prompt with a normal
`cancelled` result; when it produced no output, the prompt also goes back
to the composer. agy answers open requests with `cancelled` and
ends open tool calls; the turn's handler stays active so those final tool
updates still render. A steer cancelled before its echo is held for an
explicit Retry or Cancel, as for Cursor. A steer agy never answers is
dropped after a grace period: its row is held the same way and the agy
process is stopped (late permission requests are cancelled, not
approved), and the next turn restarts it. If agy ignores the cancel, its
process is stopped after a timeout in the same way.
* feat(agy): report and fall back when agy acp fails to start
An agy older than 1.5.0 never reaches this path: the version check in the
selection seam already runs it on stream-json. On 1.5.0 or newer, agy acp
can still fail to start or to open the conversation, for example when agy
is not signed in, the ACP install is broken, or the process exits during
start-up. The session used to end as crashed, without the reason.
The launcher now sends the reason to the chat, and the selection seam runs
the session on the stream-json driver instead, saying in the session that
Steer is not available. Only start failures fall back: errors after agy
acp is up end the session as before, and a kill during start-up is
neither reported as a failure nor falls back. The fallback stays in the
selection seam and legacyStreamJson/.
* feat(agy): show per-turn usage in the response footer
On agy acp each turn ends with a round summary: input, output, thinking,
cache-read and total tokens (summed across the requests of a steered
turn), the model, and agy's own time from sending the prompt to its last answer
(HAPI's waits before sending and for late output are left out), and
tok/s. agy reports no per-step timing, so generation time is that round
time minus the spans spent running tools or waiting for the user
(overlaps counted once), and generated tokens are output plus thinking,
as for OpenCode. The web footer renders it like the
other round summaries.
agy's usage adds up every model call of a request and agy sends no
usage_update, so it is not a context size. The turn's usage therefore no
longer goes out as a token_count for the context indicator, which stays
empty as it is for agy on stream-json.
* fix(agy): keep the session when Stop arrives while no turn is running
Stop aborts the queue wait and replaces the abort controller. The main
loop then checked the new controller's signal, found it not aborted, and
left the loop, so a late or repeated Stop after a turn had ended closed
the session and disconnected agy. The loop now checks the signal its
wait used and keeps waiting for the next message.
* fix(agy): confirm a steer only at its echo
A later steer makes agy answer an earlier steer's request at once
(end_turn) while the tool call and the turn go on, before agy has folded
the earlier steer in. Taking that answer as delivery marked the message
consumed, so a Stop before its echo left it without Retry or Cancel.
A steer is now confirmed when agy echoes it. An answer without an echo
counts only when the turn ends: confirmed if the turn ended without a
Stop, held for Retry or Cancel after one.
* fix(agy): hold unechoed steers when agy is lost mid-turn
An early-answered steer was confirmed when its turn ended without a Stop.
If agy exited before echoing it (for example when a later steer answered
its request and then the process died), the turn still ended without a
Stop, so the steer was marked consumed although agy may never have folded
it in, and Retry or Cancel was gone.
A steer request that fails with a lost transport now marks agy as lost
for the turn, and an early-answered steer without an echo is confirmed
only when the turn ends cleanly: no Stop and no lost agy process.
Otherwise it is held for Retry or Cancel.
* test(agy): pin how each steer outcome is decided
Cover the steer paths that had no test: a control command or a message
that left the queue is refused; a steer whose delivery state cannot be
recorded, or whose request agy loses while starting or writing it, is
held for Retry or Cancel; a steer sent while agy restarts stays queued
and runs next; an early-answered steer echoed before a Stop stays
confirmed; a steer agy rejects after a Stop goes back to the queue; the
main prompt stays delivered when Stop leaves a steer agy may have taken;
and an open steer is held when agy ignores the cancel or the session is
killed.
* fix(agy): confirm every steer that one echo chunk carries
When agy echoed two pending steers in one user_message_chunk, the first
match cleared every steer's echo text, so the other steer was not
confirmed at its echo. It was confirmed only when the turn ended, and a
Stop before then held it for Retry although agy had taken it. A match now
uses up only its own text, and the remaining steers keep matching.
* fix(agy): keep matching the prompt's echo after a stray echo
An echo chunk that did not continue the prompt (for example a late echo
from the previous turn) ended the wait for the prompt's own echo. The
prompt's echo that followed was then matched against the steers, so a
steer whose text the prompt contains could be confirmed before agy took
it. Such a chunk is now checked against the steers only, and the prompt's
echo is still recognized when it comes.
* fix(agy): settle the running turn before a kill returns
The runner ends the session and closes the client as soon as kill()
returns. kill() only cancelled the turn and disconnected agy, so a prompt
that was still waiting to send, or whose cancelled answer was still
draining, put itself back in the composer (or was confirmed) only after
that, and those events were lost; the session end could then record the
prompt as delivered without restoring it.
kill() now waits for the running turn to settle after disconnecting agy,
bounded to a few seconds so an agy that never settles cannot hold the
session end. Archive and runner stop both end the session through kill();
leaving remote mode does not apply to agy, and a normal exit waits for
the turn in the main loop.
* fix(web): choose the Antigravity permission mode when creating a session
The create form still showed Antigravity's old YOLO toggle, so a new
session could only start in request-review or always-proceed, although
the session mode picker offers request-review, acceptEdits, plan and
always-proceed. Antigravity now uses the same native permission select
as the other agents, filled from the shared mode catalog, and the chosen
mode is sent with the spawn.
The default stays as before: a stored YOLO toggle carries over
(on → always-proceed, off → request-review), otherwise the hub's default
applies, mapped onto agy's modes. Fallbacks that used the literal
'default' mode, which agy does not have, now ask the shared catalog for
the flavor's default instead.
* refactor(shared): describe steering support with a per-flavor capability table
Replace the flavor comparison chains in isSteeringSupportedForFlavor and
isSteeringSupportedForSession with a table keyed by flavor, so a protocol
restriction such as legacy Cursor sessions sits next to the flavor it applies
to. Results are unchanged for every flavor and Cursor session shape.
* feat(cli): auto-steer ping-peer messages into active peer turns
Peer messages in auto mode only steered Codex turns. Record each flavor's
active-turn signal in the steering capability table, expose it as
hasActiveSteeringTurn(), and use it in both the peer sender and the waiting
queue's Steer gate, so remote Claude, Pi, OpenCode and Cursor ACP targets with
an active, steerable turn also get the queued message steered into it.
Auto still stores one ordinary queued message first and attempts the existing
steer action at most once. A steer that the hub rejects or that stays
unconfirmed keeps the accepted message without resending, and the receipt now
says which of "not attempted", "rejected by hub" or "not confirmed" applied.
Inactive targets, --wake, explicit steer and explicit queue are unchanged.
* fix(cli): keep ping-peer steer notes accurate when delivery is unresolved
Auto receipts reported every unsuccessful steer response as "rejected by hub"
and promised the message stays queued. Only a refusal before any native steer
is dispatched (an HTTP 4xx, or a Hub failure without a localId) is definitive.
A failure that carries a localId, such as an RPC timeout or an OpenCode steer
that is still being reconciled, now reads "steer not confirmed; delivery
unresolved" without promising queued delivery.
Auto notes for a skipped steer used the explicit-steer refusal text, so an
accepted receipt could say "no message sent". They now use separate reasons
(for example "target is idle"); explicit steer wording is unchanged.
* refactor(acp): extract tool result output selection
* fix(acp): use content as tool output when rawOutput has only metadata
OpenCode v2 sends the real tool output in the ACP content array and puts
only metadata in rawOutput. rawOutput won unconditionally, so every tool
result card showed just the metadata or no output.
When rawOutput is an object whose only key is metadata and content
normalizes, report the normalized content as the output and keep the
metadata next to it. rawOutput that carries a body is left untouched.
* fix(web): render OpenCode lowercase tool names with their dedicated result views
OpenCode reports built-in tools by lowercase id (bash, glob, grep, ...),
but the result view registry is keyed by Claude-style names. Only read had
an alias, so the rest fell back to the generic markdown view: shell output
lost its line breaks and file names rendered like links.
Resolve a small set of OpenCode ids to the matching registered view after
the exact-name lookup, so exact names keep their current views. Tools whose
dedicated view reads Claude-shaped fields (skill, todowrite, patch,
question) stay on the generic view.
* fix(opencode): describe display tools via Code Mode execute for OpenCode v2
OpenCode v2 can list MCP tools only in a Code Mode catalog whose entries
are callable as JavaScript inside the execute tool, so the hapi_display_*
names and aliases HAPI advertised may not exist there. Replace the three
per-tool display hints used by the OpenCode instructions with one block
that prefers a direct tool and otherwise calls tools.hapi.<tool>({ path })
through execute. The block appears once in both the ACP first prompt and
the local hapi-instructions.md. Hints for other agents are unchanged.
* fix(opencode): do not re-display user-provided files unless asked
Agents sometimes called the display tools on a file the user had just
attached or asked them to read, which only echoes it back. Say in the
display tools block that the tools are for files the user has not been
shown, and that files the user attached, pasted, or pointed to are not
displayed again unless the user asks.
* feat(acp): re-enable change_title for ACP launchers with manual title precedence
opencode/cursor/kimi disabled the hapi change_title MCP tool (#1028),
relying solely on native ACP session-title sync. When the agent never
generates a native title there was no way to set one short of hub API
calls.
Re-enable change_title on those launchers. The shared title-sync
controller marks manual titles, so later native sessionInfoUpdate
titles no longer overwrite them.
* fix(acp): include copilot in change_title re-enable and harden tests
Copilot has the same ACP title-sync shape as opencode/cursor/kimi, so it
gets the same shared controller wiring. Add a cursor regression test
asserting one controller instance is shared across backend (re)creation
paths and cover the onChangeTitle failure path.
* fix(acp): persist manual title precedence in session metadata
The manual flag lived only in one controller closure, so a recreated
remote launcher or a resumed session started fresh and let the next
native ACP sessionInfoUpdate overwrite a change_title rename. Store
acpManualTitle in session metadata and initialize new controllers from
it.
* fix(agent): preserve acpManualTitle through existing-session bootstrap
bootstrapExistingSession rebuilds metadata through an allowlist, so the
manual-title marker was dropped on process resume and native ACP title
sync could overwrite a change_title rename.
* fix(cursor): preserve manual title precedence across live relaunch
ping_peer resumed any inactive target by default, and list_peers returned
the whole namespace (including offline sessions) with no machine or cwd, so
agents re-woke finished collaborators and broadcast exclusive-work notices
to every listed peer.
- ping_peer refuses inactive targets unless wake=true (CLI --wake, exit 5);
spawn_peer keeps waking its own fresh child.
- list_peers lists active sessions only (hub GET /api/sessions?active=true)
unless includeInactive (CLI --list --all); rows show busy/idle, machine,
cwd, and same-machine/same-cwd marks relative to the caller.
- inspect_peer reports the peer's machine.
- Prompts and tool descriptions: message only task-related peers, inspect
unfamiliar peers first, never broadcast, never wake for FYI/status.
* fix(codex): reuse local model catalogs by default
* fix(codex): verify catalog provenance and native schema before reuse
* fix(codex): keep refresh credentials out of discovery homes
* refactor(codex): reduce catalog support to explicit configuration
* fix(codex): invalidate selected catalogs and resolve shim names
* fix(cli): silence Cursor post-done harness "Briefly inform" turns
After AGENT_NOTIFY_SUMMARY status:done, drop notify_on_output resume
speech/tools/thinking until the next HAPI user prompt so the competing
finished-shell system ping cannot force a second user-visible reply.
Fixes#2267
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): narrow post-done silence to speech; keep soft-steer active
Address cold review + Codex P2: suppress only text/reasoning after
status:done, treat outstanding soft-steer as an active turn, and add a
launcher regression for harness-resume drops.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): discard suppressed harness buffers before next prompt
After a done close, idle-flushed harness speech stays buffered. Clear it
before reopening the silence gate so prompt()'s pre-swap drain cannot
resurrect the redundant reply (Codex P2 on #307).
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): keep post-done silence through drain and handler swap
Address upstream bot Minors on #2268: suppress speech after done even
during promptInFlight drain windows, and reopen the gate only once when
promptGeneration advances after the handler swap (not before prompt()).
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): seal done footer before quiet-drain harness coalescing
Address #2268 Minor: Cursor can append finished-shell speech during the
post-prompt quiet window onto the same buffer as AGENT_NOTIFY_SUMMARY
done, which hid the end-anchored footer. Seal the done segment when
flavor=cursor at native response return, and truncate buried harness
prose in the launcher as defense in depth.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): harden post-done seal against queue race and false closes
Await sessionUpdateQueue before sealing a Cursor done footer; keep note()
end-anchored; fence-aware truncate with soft-steer exemption and same-line
glue handling so examples and steered speech are not cut (#2268 Minors).
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): keep seal end-anchored; harden footer scan edges
Seal only flushes end-anchored done footers (soft-steer truncate stays in
the launcher). Footer scan skips inline-code examples and tracks JSON
string/escape state so braces inside summary values do not break glue
detection (#2268 Minors).
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): ignore tilde-fenced done-footer documentation examples
Recognize ~~~ fences with matching opener length alongside ``` so
truncate/seal defense does not treat tilde-fenced footer examples as a
real post-close (#2268 Minor).
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(opencode): support mid-turn steering
Register the per-message Queue/Steer RPC on the OpenCode remote launcher so
a waiting-queue row can be delivered into the active turn as a concurrent
ACP session/prompt (soft inject, no cancel, no mode/model/effort mutation),
reusing the existing reservation/delivery-state protocol shared with Codex
and Cursor ACP.
The steer gate is closed synchronously by every cancelling or terminal path
(normal-prompt finally, abort, switch/exit, teardown, stderr stall cancel),
each steer operation is tracked from the moment its reservation is taken
until completion plus all restore/consumed bookkeeping settles, and the
foreground prompt drains those operations — abort-aware through the original
turn signal — before ready, thinking=false or the next batch. steerability is
published through the existing agentState.steeringActive flag so the web's
queued Steer button is reachable.
Gate the feature on the shared steering flavors (now including opencode) and
update the hub's supported-flavor wording.
* fix(opencode): acknowledge native steering acceptance
* fix(opencode): preserve steering delivery outcomes
* docs(opencode): remove obsolete abort-race comment
* fix(opencode): preserve steering resolution ownership
* fix(opencode): isolate ambiguous steering attempts
* fix(opencode): compare resolved steering settings
* fix(opencode): reconcile steering receipts after dispatch
* fix(opencode): distinguish pending steering delivery outcomes
* fix(opencode): restore receipts after successful native responses
Track native input requests separately from detached steer operations. Resume receipt correlation after inputs quarantined by cancellation return their own successful responses, while keeping uncertain writes on completion-based confirmation.
* fix(opencode): bound receipt proof to unambiguous native inputs
* feat(opencode): steer v2 inputs through native inbox
* fix(opencode): preserve v2 restoration and cancellation ownership
* docs(opencode): describe v2 inbox steering confirmation
* fix(steer): expire Claude confirmation with its owning worker
Adds an opt-in content search over session messages, alongside the
existing metadata search. An FTS5 index covers visible user and assistant
prose; the sidebar gains a scope toggle, and selecting a result opens the
matching message rather than the session tail.
Search scope is a two-state toggle rather than a dropdown: a 48x48 target
matching the clear endcap, distinct glyphs for session details vs message
text, tooltips naming the real scopes, and the active mode kept on the
collapsed chip (tiann/hapi#2081).
Dogfooded on a live 1178-session fleet. The scope toggle and reading
forward from a search result were both click-tested on that install —
the latter walking six bounded pages through a 1,507-message session and
stopping correctly at the session head.
The per-commit history does not survive this squash; the review trail —
including which commit closed which finding — is on the PR threads.
Fixes#1554Fixes#2081
* fix(dsh): resume DSH ACP sessions after HAPI restart
* fix(dsh): register active session handoff
* fix(dsh): preserve native id in summaries
* fix(dsh): keep native resume on recorded machine
* test: refresh CI checks
* feat(cli): switch Claude effort without restarting the process
Changing effort in a remote Claude session made the next prompt restart
Claude with --resume and a new --effort flag, so the switch cost a
process start and a slower first reply. Claude Code's apply_flag_settings
control request changes the session effort in place (null restores the
model default), the same way set_permission_mode already changes modes.
The launcher now applies an effort-only change to the running process
before delivering the prompt. Any other process-level change, a refused
request, or no reply within 5 seconds keeps the existing restart path,
so Claude Code builds without the request still work.
via [HAPI](https://hapi.run)
Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(cli): keep the prompt when Claude exits during a live effort change
The launcher awaited the effort control request with the dequeued batch
held only in a local. If Claude exited before replying, the attempt
ended, and the late continuation handed the batch to the closed
claudeRemote, which dropped it.
Park the batch in `pending` before awaiting and take it back only when
Claude applied the change and its process is still open. Otherwise the
next attempt delivers it, starting with the new effort.
via [HAPI](https://hapi.run)
Co-Authored-By: HAPI <noreply@hapi.run>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: HAPI <noreply@hapi.run>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(cli): spawn-peer with required remit and MCP spawn_peer
Machine spawn creates an empty composer; stuffing message into that
JSON is stripped. Add hapi spawn-peer and MCP spawn_peer that spawn,
rename, deliver via the ping-peer path, and fail closed unless the
remit is on the new session. Reject message/prompt/text on machine
spawn with 400. Do not auto-approve spawn_peer in default/read-only.
Fixes#1509
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): reject overlong spawn-peer names before spawn
Hub rename max is 255; continuing past PATCH 400 left a live session under a different title. MCP/steer copy now says the hub 400s a spawn-body remit instead of stripping it.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): wait for fresh spawn-peer child instead of resuming it
Machine spawn can return while the hub row is still inactive. ping-peer then POSTed /resume, which can launch a second agent because the original spawn has no existingSessionId for runner dedupe.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): reject flavor-illegal permissionMode before spawn-peer
Codex + bypassPermissions (and Pi + any mode) used to reach the runner and fail after a child existed, or silently drop the mode. Check isPermissionModeAllowedForFlavor when both agent and mode are explicit.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): treat omitted spawn-peer agent as Claude for permissionMode
Hub and runner default agent to claude when spawn omits it. Validate permissionMode against that effective flavor so yolo/read-only fail closed before a child starts.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): resolve spawn-peer dir locally and archive failed children
Relative --dir values were forwarded unchanged, so the runner resolved them against daemon cwd. Remit delivery failures also left the new session running, so a retry spawned a duplicate. Resolve in the caller and best-effort archive the child before rethrowing.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): verify remit before archiving a failed spawn-peer child
A timed-out ping-peer POST can still land the remit. Check the transcript before archive, and only say the child was archived when the hub returns ok.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): swallow spawn-peer transcript GET errors and skip unapplied names
A thrown messages GET after spawn skipped archive and leaked a live child. Treat transport errors as a miss so the verify loop can retry, then clean up. Also do not return a requested name the hub never applied.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(spawn-peer): hub peerSpawnDefaults + model/effort spawn surface
Add hub settings peerSpawnDefaults (agent, permissionMode, per-flavor models)
with stock claude/yolo/sonnet fallbacks. spawnPeer resolves explicit args →
hub settings → stock, maps yolo to flavor equivalents, and forwards model/effort
into machine spawn. Settings UI under General → Agents; MCP/CLI optional overrides.
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(hub): use cursor-valid permission mode in peer spawn defaults test
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): teach spawn_peer that omit permissionMode means yolo
MCP copy said "pass permissionMode only when the operator asked", so agents
omitted it and got hub/stock whatever was stored — often approval-gated
default. Clarify omit = yolo via peerSpawnDefaults/stock; pass only to tighten.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(hub,web): apply peerSpawnDefaults to machine spawn and New Session
POST /api/machines/:id/spawn now resolves omitted agent/permissionMode/model
from hub Settings, and New Session seeds from the same peerSpawnDefaults so
UI create and peer spawn share one authoritative default (stock yolo).
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): NewSession hub seed respects sticky prefs + QueryClient in tests
Sticky localStorage last-used agent wins over hub seed; machine spawn still
applies peerSpawnDefaults server-side. Tests provide QueryClientProvider.
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(web): mock CREATABLE_AGENT_FLAVORS for settings general peerSpawn UI
Co-authored-by: Cursor <cursoragent@cursor.com>
* test(web): stabilize NewSession tests after hub peerSpawnDefaults seed
Wrap remaining mounts in QueryClientProvider, pre-seed hub settings so a
late useQuery resolve cannot wipe in-test model picks, and use neutral
stock permission defaults in the fixture.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): address tip Codex Majors for peerSpawnDefaults
Preserve explicit yolo booleans on machine spawn, fail closed when hub
defaults cannot load, validate permission modes against the resolved
agent, remap auto-approval across flavors, and stop late hub settings
from wiping New Session edits. Reject retired agents in spawn defaults
and restore the CLI executable build docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): address follow-up tip Codex Majors
Stop absent Yolo localStorage from beating hub defaults, track New Session
edits before late hub seed, reject incompatible machine-spawn permissions,
resolve MCP spawn_peer paths against the session working directory, and
hide unsupported Codex safe-yolo from Settings spawn defaults.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): clear tip-2 CI and follow-up Codex Majors
Omit permissionMode for Pi/DSH, preserve explicit Yolo-off across delayed
hub seed, fix settings test mocks for launch permission helpers, and
restore unrelated CLI README lifecycle/ACP docs.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): tip-3 Majors for seed edits and launchable modes
Skip hub agent seed after permission edits, resolve inherited modes via
the launch catalog (AGY request-review fallback), preserve hub Cursor
models through preference restore, and restore Codex auth README nuance.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): tip Minors for Cursor/Grok hub permission seeding
Give Cursor the native permission select so Plan/Ask survive machine
spawn, and re-apply Grok hub permissions after agent-init resets.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): tip Minors for Cursor select and hub seed remap
Map hub permission through resolvePermissionModeForFlavor, keep native
Default when agent is explicit without a model, and assert Cursor Plan/Ask Mode labels.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): tip Minors for delayed hub seed and Default model
Apply hub permission/model to unset fields even with a sticky agent,
preserve explicitly saved auto models, and seed OpenCode/AGY selectors
from hub defaults.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): tip Minors for model edit sticky and clear override
Mark OpenCode/AGY model picks as edited so delayed hub seed cannot
overwrite them, and treat empty hub model values as clear sentinels.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): tip Majors for models patch typing and remit page scan
Type the models patch as NonNullable and paginate transcript verification
oldest-ward so a busy child is not archived when the remit leaves page 1.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): tip Minor — keep agent after explicit model pick
Do not apply a late hub default agent when the operator already chose a
model; otherwise preference restore drops that selection.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(spawn-peer): tip Cursor YOLO migrate and Codex effort map
Bridge Cursor's saved YOLO toggle (incl. false) into native Default over
hub yolo, and send Codex/OpenCode --effort as modelReasoningEffort.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): tip Majors — scoped YOLO bridge and catalog fallback
Keep unsupported saved permission modes at Default instead of hub yolo,
and apply delayed YOLO migration only when the sticky bridge agent matches.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(cli): drop rebase conflict markers in startHappyServer
Both sessionDisplayRename and spawnPeer imports are required after
rebasing onto upstream rename work; markers had slipped into tip.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): wrap Kimi NewSession tests in QueryClientProvider
Hub settings useQuery requires a provider; upstream Kimi catalog tests
rendered bare and broke after the spawn-peer rebase onto main.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(peer): rename-proof Parent UUID stamp on spawn remits
Orchestrated spawn_peer / spawn-peer remits now auto-stamp a durable
[title](/sessions/<uuid>) Parent chip (fail-closed in-session). MCP copy
forbids inventing titles; UUID stays identity after parent rename.
Refs heavygee/hapi#175
Co-authored-by: Cursor <cursoragent@cursor.com>
* style(peer): plain hyphen in Parent-stamp warning and test comment
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): reject blank remit before Parent stamp
Codex review on #1922: stamping first turned empty remits non-empty and
bypassed the idle-session guard. Also only treat ## Parent blocks as
already-present so bare /sessions citations still get the chip.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): gate New Session Create on hub defaults; require Parent chip
Codex tip review on #1922: block Create while getHubSettings is pending so
stock mount defaults cannot bypass restrictive hub peerSpawnDefaults; skip
Parent stamp only when ## Parent already has a markdown session chip; clarify
codex resume takes a native thread id.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): resolve MCP spawn cwd; Agents settings section
Codex Major on #1922: spawn_peer relative directories now prefer the
launcher cwd (Codex --cd), then skillLookup, then session metadata.path.
Move peerSpawnDefaults UI into the unused Agents settings section.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): pass session cwd to MCP spawn_peer; Agents settings section
Codex tip review on #1922: resolve relative spawn_peer directories from the
launcher working directory (Codex --cd), skillLookup, then metadata.path;
move peerSpawnDefaults UI into the Agents settings section.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): skip archive on unread transcript; validate startingMode after hub agent
Codex tip review: do not archive a child when remit verification cannot read
the transcript; run AGY/DSH remote-only startingMode checks against the
resolved hub agent; update MCP bridge test expectations for workingDirectory.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): treat exhausted remit pagination as unverifiable
Hitting the messages page cap with hasMore still true must not count as an
observed-empty transcript — that would archive a child whose remit may still
exist on older pages.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(cli): list HAPI_API_URL as optional with localhost default
Codex tip review: the README had moved HAPI_API_URL under Required even
though configuration defaults it to http://localhost:3006 (and settings can
supply a URL). Also drop trailing whitespace flagged by git diff --check.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): re-verify empty transcript before archiving failed spawn
An earlier observed-absent page plus later unread GETs must not archive a
child whose remit may have landed after the first empty read.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): never auto-archive on spawnPeer failure path
Timed-out remit POSTs and empty-read/archive TOCTOU races can still land
work on the child. Leave the session running with its id for inspection
instead of terminating an in-flight peer.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): classify empty_session from final remit verify
An earlier empty transcript read must not stick as empty_session once
later message GETs become unavailable — report verify_failed instead.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): recognize escaped brackets in Parent chip labels
Titles with ] were escaped in the chip label but the idempotency regex
stopped at the first raw bracket and re-stamped a second Parent block.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): avoid Parent chip regex backtracking on backslashes
Exclude \\ from the single-char label alternative so escaped pairs have
one parse path — long nonmatching backslash runs no longer explode.
Co-authored-by: Cursor <cursoragent@cursor.com>
* feat(cli): MCP/CLI spawn_peer --machine for cross-host remits
Wire optional machine (UUID or hostname via GET /api/machines) through
MCP spawn_peer and hapi spawn-peer into existing spawnPeer({ machineId }).
Skip local directory existence checks for cross-host targets to match the
estate wrapper; keep fail-closed remit verify.
Fixestiann/hapi#1931
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): reject ambiguous spawn --machine label matches
Tip bot Major on #1922: hostname/displayName selectors that match more
than one online runner now fail closed with ambiguous + UUID guidance.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): preserve cross-OS absolute dirs for spawn --machine
path.resolve on the caller OS was rewriting foreign absolute roots
(C:\… on Linux, /srv/… on Windows) before the hub spawn POST. Detect
POSIX or Windows absolute paths and only resolve relative directories.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(peer): resolve spawn dirs after local vs remote is known
Defer directory resolution until the target machine is selected. Remote
spawns still preserve foreign absolute roots; local spawns use native
path.resolve so Windows drive-less paths like \repo bind to the caller
drive.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(web): apply delayed DSH model defaults without replacing edits
* fix(web): preserve hub permission defaults across form remounts
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: weishu <twsxtd@gmail.com>
* feat(claude): mid-turn Steer for remote Claude sessions
Queued messages can now be steered into a running Claude turn, the same as
Ctrl+X Ctrl+S in the Claude TUI. The row is written to the live stream-json
stdin and Claude folds it in at its next tool boundary.
- Spawn Claude with --replay-user-messages and tag every stdin message with
a uuid; the echo acks pickup and is never relayed to chat
- A result that arrives while a steer is still unacked does not end the
turn: Claude runs a follow-up turn for it, so ready waits for that result
- Launcher registers steer-queued-message: reserve the row, reject control
commands and mode mismatches, ack the hub after the write, mark consumed
(steered) on the echo; abort before pickup holds the row indeterminate,
an unprompted exit requeues it
- Open the shared steer gate and peer/hub wording to Claude (remote only)
* fix(claude): retire completed input before a steer follow-up turn
- Generalize onCompactResultAccepted to onResultAccepted and fire it when a
result arrives with a steer still unacked, so a stream failure during the
follow-up turn recovers only the steer instead of replaying the finished
prompt
- Close the steer target and settle pending steers when query() setup
throws, so a retry backoff cannot accept a steer nobody will read
Codex view_image (app-server imageView items) and Claude Code tool results
with image blocks (Read of an image, screenshot tools) now emit
generated-image messages tied to the tool call, so web/iOS/Android render
what the agent looked at instead of only a path. Claude transcript lines
forwarded to the hub drop the duplicated base64 payloads.
* feat(web): fork active and archived sessions from the session list
* fix(codex): preserve fork titles during history replay
* fix(web): limit list forks to supported Codex sessions
* fix(claude): drop the obsolete 1M model presets
The opus, sonnet and fable aliases now resolve to models with a native 1M
window (Opus 5.5, Sonnet 5.5, Fable 5.1), so Claude Code documents the
"[1m]" suffix as having no effect on them and its own /model picker no
longer lists 1M rows. Remove Sonnet 1M / Opus 1M / Fable 1M from the
shared, Android and iOS catalogs.
Sessions stored with a "[1m]" value keep working: the composer keeps
the current model selectable, and the context-budget fallback treats any
"[1m]" model and the remaining aliases as 1M, so local-mode sessions on
plain opus/sonnet no longer show a 200k budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(cli): seed a 1M turn-1 context window for bare Claude aliases
With the 1M presets gone, a session on plain fable/opus/sonnet must not
seed 200k before its first result: those aliases now resolve to models
with a native 1M window. Seed 1M when the selected model is a preset
alias; an explicit full id still seeds conservatively until its result
arrives.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(claude): offer the four current Claude models as presets
The Claude presets now mirror the aliases Claude Code's /model lists, in
its order: Opus, Fable, Sonnet, Haiku. Each alias resolves to the newest
model of its family, and all four have a native 1M window, so neither
1M variants nor pinned older versions are offered. Haiku was missing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(claude): read the effective context window from get_context_usage
The 1M seed for the aliases is wrong for users who disable 1M
(CLAUDE_CODE_DISABLE_1M_CONTEXT) or cap it with autoCompactWindow. In
remote mode, ask Claude via the get_context_usage control request after
each system/init and use its maxTokens, which is what /context shows.
A result's raw contextWindow no longer overwrites that value. Older CLIs
that reject the request keep the existing seed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: weishu <twsxtd@gmail.com>
* fix(runner): recover sessions after host reboot
* fix(runner): settle startup when process generation changes
* test(runner): wait for Hub RPC readiness before resume
* fix(web): show session mentions without waiting for remote file search
* fix(web): preserve selected files during mention refresh
* test(runner): avoid fixture PID collision with test process
Default peer CLI and MCP messages to auto, steering eligible Codex turns and queueing otherwise. Preserve explicit delivery modes and uncertain-send safety, and clarify steer guidance for important time-sensitive findings.
Persist and backfill the last user-message timestamp, and use it for deterministic session ordering across web and native clients while preserving manual pins.
Remove the fixed-order setting and guard ordering against transcript echoes, replayed messages, and stale REST/SSE updates. Add regression coverage and regenerate the SSE fixture.
Pin the build toolchain to Bun 1.4.4 so CI includes the darwin-arm64 signing fix required by macOS 27.
Reject stale optional platform packages before launching, document clean reinstall recovery, and add launcher regression coverage.