Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ Every session runs in m4code's native chat view over the [Agent Client Protocol]
| **Claude Code** | `claude` CLI, Node, npm | Runs through the [Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/overview) (installed into m4code's data folder on first run) using whatever sign-in your `claude` has (subscription, API key, Bedrock, or Vertex). Disables `claude.ai`-only tools (scheduled tasks, push notifications, connectors) for m4code sessions only. Includes a Claude in Chrome toggle. |
| **Codex** | Node, `codex login` | Runs through its ACP adapter from npm (downloaded on first run). |
| **OpenCode** | `opencode` on `PATH` | Uses the providers configured in OpenCode. |
| **Google Antigravity** | `agy` CLI, signed in | Opt-in for subagent use. |
| **Google Antigravity** | `agy` CLI, signed in | Interactive only: see the terms note below. Opt-in for subagent use. |

When upgrading from a version with multiple Claude accounts, resumed sessions use the login configured for the Claude CLI. Expired logins offer **Sign in** and **Retry session** in the conversation. Failed sessions retain their history and queued messages. A session that stops reporting progress offers Stop and Reconnect; reconnecting does not automatically repeat the last prompt.

> **Antigravity terms note**: Google's [Antigravity terms](https://antigravity.google/terms) and [FAQ](https://antigravity.google/docs/faq) forbid using another company's agent (such as Claude Code) with a personal Google sign-in (Free, AI Plus, Pro, or Ultra), and Google can suspend or terminate accounts that do. Turn Antigravity subagents on at your own risk.
> **Antigravity terms note**: Google's [Antigravity terms](https://antigravity.google/terms) and [FAQ](https://antigravity.google/docs/faq) forbid using another company's agent (such as Claude Code) with a personal Google sign-in (Free, AI Plus, Pro, or Ultra), and Google can suspend or terminate accounts that do. m4code keeps Antigravity to sessions you type in:
>
> - Rewind and fork are off in Antigravity sessions, and m4code doesn't compact one itself. Only Antigravity's own `/compact` runs, when Antigravity lists it.
> - Conversations from other models can't be handed to Antigravity. You can hand an Antigravity conversation to another model yourself, but auto-handoff and an agent's `set_model` can't.
> - Antigravity can't be the text generation model. A saved choice switches back to the local summary.
> - **Allow subagent delegation** and **Allow cross-harness subagents** start off for Antigravity. Turn them on at your own risk.
> - Antigravity sessions don't get `start_code_session` or `read_code_session`, so they can't start sessions or read other ones.
> - Antigravity's usage meter updates only when you press refresh.

## Features

Expand Down Expand Up @@ -57,13 +64,14 @@ When upgrading from a version with multiple Claude accounts, resumed sessions us
- Right sidebar with cards for actions, the turn outline, session status, subagents, GitHub issues and pull requests, and linked sessions, plus inline visual cards agents draw in chat.
- GitHub labels, assignees, edits, and comments update immediately while saving. Failed edits restore the previous content and retain the draft. If a comment posts but closing the item fails, retry close/reopen separately to avoid posting twice.
- **Ask Agent** in the GitHub pane sends the request to the active agent if it is running in the repository. When it starts a new session, it uses the model selected in the Welcome composer.
- Usage meters in the sidebar footer for connected harnesses with a limits adapter (Claude Code and Codex 5-hour/7-day limits). Usage dashboard links for OpenCode and Antigravity are shown only when their harnesses are enabled.
- Configurable text generation model (**Settings → General**) for automatic new-session titles, Regenerate title and Commit & Push—pick any enabled model or keep local summary.
- Usage meters in the sidebar footer for connected harnesses with a limits adapter (Claude Code, Codex and Antigravity 5-hour/7-day limits). Antigravity's meter updates only when you press refresh. The usage dashboard link for OpenCode is shown only when its harness is enabled.
- Configurable text generation model (**Settings → General**) for automatic new-session titles, Regenerate title and Commit & Push—pick any enabled model except Antigravity, or keep local summary.

### Cross-agent subagents

- **Shared MCP subagent tools**: Sessions across all harnesses share `spawn_subagent`, `list_subagents`, `send_subagent_message`, `wait_subagent`, and `stop_subagent` (targeting adapters enabled for subagent use in Settings). Children run in the parent's working folder without stealing focus, appear in the right sidebar, and fold their report back into the parent chat. Follow-ups reuse the child session, stopping a parent stops its children, and a read-only parent cannot grant edits. Sessions are conversations for the user and are created only when the user wants one. Subagents are workers the model uses to delegate work within its current session.
- **Claude Code native subagents**: Claude Code can also start Codex, OpenCode, and (opt-in) Antigravity subagents directly. These plugin-run children receive the shared workspace context tool. Desktop-managed children have their own records and can use the session tools. Each streams its work in its own task view with configurable effort (`max` maps to Codex's `xhigh`; Antigravity caps at the model's highest thinking level) and supports live or queued follow-ups.
- **Cross-harness subagents**: **Allow cross-harness subagents** (**Settings → Harnesses**) decides whether other harnesses can run a harness as a subagent and whether its sessions can start subagents or sessions on other harnesses, or move a conversation to them on their own, through `set_model` or auto-handoff. A subagent on another harness needs it on for both. It starts on for every harness except Antigravity.
- **Edit permissions**: With **Allow edits** enabled, a subagent acts without Claude Code's permission rules. Read-only Antigravity runs in an isolated folder under m4code's data directory with a hook that permits only reading and searching (your personal Antigravity rules, skills, and MCP servers do not load there).

### Skills
Expand Down
2 changes: 1 addition & 1 deletion src/app/act.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ impl Workspace {
let list_focus = cx.focus_handle();
window.focus(&list_focus, cx);
let custom = &self.store.data.settings.custom_subagents;
let form = |c: &harness::subagents::AgentChoice| AgentForm { on: c.on, models: c.models.clone(), edits: c.edits };
let form = |c: &harness::subagents::AgentChoice| AgentForm { on: c.on, models: c.models.clone(), edits: c.edits, cross_harness: c.cross_harness };
let subagents = Box::new(HarnessesForm {
enabled: self.store.data.settings.enabled_harnesses_list(),
agents: harness::subagents::AgentMap::from_fn(|agent| form(custom.get(agent))),
Expand Down
6 changes: 5 additions & 1 deletion src/app/agent_handoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ impl Workspace {
let refusal = if !self.store.data.settings.harness_enabled(to) {
Some(format!("{} is unavailable for this session.", to.name()))
} else {
capabilities::handoff(thread.read(cx).harness, to, initiator).refusal().map(String::from)
let from = thread.read(cx).harness;
// An agent's switch checks "Allow cross-harness subagents" again here: either may have been turned off since
// `set_model` accepted it.
let crossing = if by_agent { capabilities::crossing(&self.store.data.settings, from, to) } else { capabilities::Capability::Allowed };
capabilities::handoff(from, to, initiator).refusal().or(crossing.refusal()).map(String::from)
};
if let Some(refusal) = refusal {
if !by_agent {
Expand Down
17 changes: 16 additions & 1 deletion src/app/cross.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ impl Workspace {

/// Check what the request needs. A new session's folder, or the worktree to switch to, is resolved into `req.args["folder"]`.
fn prepare(&self, req: &mut Request, cx: &App) -> Result<(), String> {
// The tool isn't offered to such a session at all; this refuses a call that reaches m4code anyway.
let asking = req.from.split_once(':').map_or(req.from.as_str(), |(_, id)| id);
if let Some(harness) = self.store.session(asking).and_then(SessionRecord::harness)
&& harness.adapter().mcp_off.contains(&req.tool.as_str())
{
return Err(format!("{} sessions can't use {}.", harness.name(), req.tool));
}
if req.tool == "switch_worktree" {
return self.prepare_switch(req);
}
Expand Down Expand Up @@ -305,6 +312,12 @@ impl Workspace {
"start_code_session" => {
let cwd = folder.ok_or("No folder.")?;
let harness = req.args["harness"].as_str().and_then(|key| crate::harness::Harness::registered().find(|h| h.key() == key)).unwrap_or_else(|| self.store.data.settings.default_model().harness);
let asking = req.from.split_once(':').map_or(req.from.as_str(), |(_, id)| id);
if let Some(from) = self.store.session(asking).and_then(SessionRecord::harness)
&& let Some(refusal) = crate::harness::capabilities::crossing(&self.store.data.settings, from, harness).refusal()
{
return Err(refusal.into());
}
// The model may pick the model and effort; the permission mode stays the user's default for new
// sessions (`Starter::OtherSession` never starts with full access).
let mut options = vec![];
Expand Down Expand Up @@ -349,7 +362,9 @@ impl Workspace {
match model {
Some(model) if req.args["cross"].as_bool() == Some(true) => {
let from = thread.read(cx).harness;
if let Some(refusal) = crate::harness::capabilities::handoff(from, model.harness, crate::harness::capabilities::Initiator::Automatic).refusal() {
let handoff = crate::harness::capabilities::handoff(from, model.harness, crate::harness::capabilities::Initiator::Automatic);
let crossing = crate::harness::capabilities::crossing(&self.store.data.settings, from, model.harness);
if let Some(refusal) = handoff.refusal().or(crossing.refusal()) {
return Err(refusal.into());
}
let message = req.args["message"].as_str().map(str::trim).filter(|m| !m.is_empty()).map_or_else(|| "Carry on with the task from where the conversation left off.".into(), String::from);
Expand Down
41 changes: 27 additions & 14 deletions src/app/headless/agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,29 @@ r#" send({"jsonrpc": "2.0", "id": i, "result": {"modes": session_modes()}
assert!(ws.new_session_from_home(Harness::Claude, None, work.path().to_path_buf(), Some("initial task".into()), None, Some(Permission::Auto), window, cx));
});
let id = ws.read_with(&cx, |ws, _| ws.active_id().unwrap().clone());
let wait = |cx: &mut TestAppContext, harness| {
let wait = |cx: &mut TestAppContext, id: &str, harness| {
let until = std::time::Instant::now() + Duration::from_secs(10);
loop {
cx.run_until_parked();
if ws.read_with(cx, |ws, app| {
ws.pending_handoffs.is_empty() && ws.live_view(&id).and_then(|v| v.thread()).is_some_and(|view| {
ws.pending_handoffs.is_empty() && ws.live_view(id).and_then(|v| v.thread()).is_some_and(|view| {
let view = view.read(app);
view.harness == harness && !view.is_loading() && !view.is_working() && view.thread.entries.iter().any(|e| matches!(e, Entry::Agent(text) if text == "ok"))
})
}) { break; }
if std::time::Instant::now() >= until {
ws.read_with(cx, |ws, app| {
let view = ws.live_view(&id).and_then(SessionView::thread).map(|view| view.read(app));
let view = ws.live_view(id).and_then(SessionView::thread).map(|view| view.read(app));
panic!("handoff to {harness:?} never settled: pending={}, view={:?}, toast={:?}",
ws.pending_handoffs.contains_key(&id),
ws.pending_handoffs.contains_key(id),
view.map(|view| (view.harness, view.is_loading(), view.is_working(), view.start_error(), &view.thread.entries)),
ws.toast.as_ref().map(|toast| &toast.text));
});
}
std::thread::yield_now();
}
};
wait(&mut cx, Harness::Claude);
wait(&mut cx, &id, Harness::Claude);
for (harness, message, expected) in [
(Harness::OpenCode, "continue on B", Permission::FullAccess),
(Harness::Claude, "continue on A", Permission::Auto),
Expand All @@ -99,7 +99,7 @@ r#" send({"jsonrpc": "2.0", "id": i, "result": {"modes": session_modes()}
cx.update_window(window, |_, window, app| window.draw(app).clear(app)).unwrap();
let mut visual = VisualTestContext::from_window(window, &cx);
assert!(visual.debug_bounds("thread-mode").is_some(), "the permission chip stays visible through the handoff");
wait(&mut cx, harness);
wait(&mut cx, &id, harness);
ws.read_with(&cx, |ws, app| {
let view = ws.live_view(&id).unwrap().thread().unwrap().read(app);
assert_eq!(view.permission(), Some(expected));
Expand Down Expand Up @@ -144,7 +144,7 @@ r#" send({"jsonrpc": "2.0", "id": i, "result": {"modes": session_modes()}
ws.acp_server = Some(failed_server.clone());
ws.dynamic_handoff(&id, Harness::Codex, None, "keep this draft".into(), false, None, window, cx);
});
wait(&mut cx, Harness::Claude);
wait(&mut cx, &id, Harness::Claude);
ws.read_with(&cx, |ws, app| {
assert_eq!(ws.store.session(&id).unwrap().agent.as_ref().unwrap().harness, Harness::Claude);
let view = ws.live_view(&id).unwrap().thread().unwrap().read(app);
Expand All @@ -154,30 +154,43 @@ r#" send({"jsonrpc": "2.0", "id": i, "result": {"modes": session_modes()}
Entry::Notice { text, error: true, .. } if text.contains("handshake failed"))).count(), 1);
assert!(view.thread.active_notice(crate::harness::thread::NoticeKind::Handoff).is_none());
});
// Antigravity takes no conversation from another model (Google's terms), so the session stays on Claude Code.
step(&mut cx, &|ws, window, cx| {
ws.acp_server = Some(server_for("antigravity"));
ws.dynamic_handoff(&id, Harness::Antigravity, None, "continue on C".into(), false, None, window, cx);
});
wait(&mut cx, Harness::Antigravity);
wait(&mut cx, &id, Harness::Claude);
ws.read_with(&cx, |ws, app| {
assert_eq!(ws.store.session(&id).unwrap().agent.as_ref().unwrap().harness, Harness::Claude);
let view = ws.live_view(&id).unwrap().thread().unwrap().read(app);
assert!(view.thread.entries.iter().any(|entry| matches!(entry,
Entry::Notice { text, error: true, .. } if text.contains("Antigravity terms"))), "the refusal says why");
});
// A session that starts on Antigravity relaunches it for a permission change and keeps its provider session.
step(&mut cx, &|ws, window, cx| {
assert!(ws.new_session_from_home(Harness::Antigravity, None, work.path().to_path_buf(), Some("continue on C".into()), None, Some(Permission::Auto), window, cx));
});
let antigravity = ws.read_with(&cx, |ws, _| ws.active_id().unwrap().clone());
wait(&mut cx, &antigravity, Harness::Antigravity);
for permission in [Permission::FullAccess, Permission::ReadOnly] {
step(&mut cx, &|ws, _, cx| {
let view = ws.live_view(&id).unwrap().thread().unwrap().clone();
let view = ws.live_view(&antigravity).unwrap().thread().unwrap().clone();
view.update(cx, |view, cx| view.set_permission(permission, cx));
});
wait(&mut cx, Harness::Antigravity);
wait(&mut cx, &antigravity, Harness::Antigravity);
step(&mut cx, &|ws, window, cx| {
let meta = ws.store.session(&id).unwrap().agent.as_ref().unwrap();
let meta = ws.store.session(&antigravity).unwrap().agent.as_ref().unwrap();
assert_eq!(meta.session_id, "fake-session");
assert_eq!(meta.launched_full_access, permission == Permission::FullAccess);
let view = ws.live_view(&id).unwrap().thread().unwrap().clone();
let view = ws.live_view(&antigravity).unwrap().thread().unwrap().clone();
assert_eq!(view.read(cx).permission(), Some(permission));
assert_eq!(view.read(cx).draft(cx), "keep this draft");
view.update(cx, |view, cx| view.send("check permission".into(), window, cx));
});
wait(&mut cx, Harness::Antigravity);
wait(&mut cx, &antigravity, Harness::Antigravity);
}
let permissions = std::fs::read_to_string(work.path().join("fake_agent.py.permissions")).unwrap();
assert!(permissions.ends_with("antigravity:auto:False\nantigravity:default:True\nantigravity:plan:False\n"));
step(&mut cx, &|ws, window, cx| ws.end_live(&antigravity, window, cx));
step(&mut cx, &|ws, window, cx| ws.end_live(&id, window, cx));
}

Expand Down
Loading
Loading