Repository navigation
Let each adapter decide which actions m4code takes with its agent - #153
Merged
Merged
Conversation
Adds Capabilities to Adapter and checks it before rewind, fork, fresh sessions, compaction fallback, text generation, handoffs and subagents. Moves sign-in, usage sources, text-generation launches and other per-harness branches out of the core into the adapters. Every adapter still allows everything, so behavior is unchanged. Part of #152.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Adds NativeSessions (statuses, name writes, transcripts), SessionReport readers and a tidy hook to Adapter, and replaces claude_exe with each adapter's discovered executable. The store reads usage per harness through one accessor, keeping the keys older versions read.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #152. Before m4code can follow Google's Antigravity terms, it needs one place where an adapter says which actions m4code may take with its agent. Rules for one harness were scattered through
src/app,src/panelsandsrc/threadasmatch harnessbranches.This PR moves them into the adapters and changes no behavior: every adapter still allows everything. The Antigravity rules from #152 come in a follow-up PR as declarations in its adapter.
Capabilities
src/harness/capabilities.rsaddsCapabilitiestoAdapter. Each field is one action: rewind, fork, continue in a fresh session, m4code's compaction fallback, text generation, handoff in and out, running as a subagent, and starting subagents. A refusal carries the reason the user sees.The core asks before each of those actions:
dynamic_handoff,rewind_session,fork_thread,compact_session,continue_in_fresh_session,set_model,best_fallback_model,spawn_subagent, the review subagent,thread_startfor a resumed subagent, the Claude plugin's agent types and the--acprunner.HandoffhasAnyandNeverfor now.Initiatoralready tells the user from the agent, so the follow-up can add a rule that allows only switches the user starts without changing the call sites.Moved into the adapters
SignIn: the sign-in command and the signed-out hints. This replacesacp::login_hint, the table ingithub_pane.rs, the Claude branch inrunner.rsandProvider.sign_in.UsageSourceandLiveUsage: where limits come from, how often m4code asks, whether a turn's end asks again, and Codex's log watcher. They replaceProvider.limitsand the Claude and Codex branches iningest.rsand the sidebar. The Antigravity reader stays off, now commented in its adapter.text_generation_launch: each adapter's tool-free launch for text generation, which was amatchintext_generation.rs.probe_session_meta,copies_skills, and the worktreefollowedhook, which was a Claude branch inswitch.rs.Providernow lives in its adapter module. Theopencodemodule is always compiled, ascodexandantigravityalready were.antigravity_full_accessis nowlaunched_full_accessin code. It is saved under the old key, so state files stay compatible both ways.Claude Code's own records
The second commit moves the Claude Code code that was still in the core:
NativeSessions: an agent's own record of its sessions. The busy, idle and waiting statuses the activity poll and pending worktree switches read, the session names m4code writes, and the transcript check for resuming. Claude Code's registry cache now lives in its adapter.reports: the figures sessions report outside ACP. Claude Code's mod snapshots are nowSessionReports, andingest.rsapplies any adapter's reports.tidy: each adapter's start-up cleanup of its old files in m4code's data folder.claude_exeis nowexecutables, each adapter's discovered executable. An adapter withcustom_path(Claude Code's) is found at once, as before. The others are found in the background, because looking can start a login shell. Each adapter's probes now get its own executable instead of Claude Code's.Settings::executable_path,Data::usage_poolsandData::merge_usage_pools.Two small behavior changes. A harness whose CLI is on the PATH now counts as available for auto-handoff without a cached model list. Startup no longer looks for the other agents' executables on the UI thread.
Still in the core: the Claude Code pages of the setup window and Settings (its path field, output limits, costly-settings findings, advisor and background-compaction switches) and the sidebar's Claude usage row. They are Claude Code features with their own UI, not rules about actions.
Verification
cargo clippy --locked --all-targets -- -D warningsis clean.cargo test: 605 unit tests passed on the final commit, including new ones for the handoff rules.cargo test -- --ignored --test-threads=1) on the final commit: 41 passed, 5 failed. Four start the real Claude Code, Codex and OpenCode CLIs, and each stops with "The adapter did not discover m4code's MCP tools before the startup deadline." Undercargo test,current_exe()is the test binary, which has no--mcp-titleentry point, so the agent can't reach m4code's MCP server. The fifth,github::e2e, hit a GitHub GraphQL server error while creating a pull request; it passed on the first commit. I didn't rerun these onmain.Risk
Low. Every real adapter declares
Capabilities::ALL, so every new check passes. The most likely place for a regression is the usage-limit move iningest.rs. Reading, merging and storing now go throughstored_poolsandstore_pools, which keep Claude's usage inclaude_usageand every other agent's under its key, as before.