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
27 changes: 15 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exclude = ["src-tauri"]
resolver = "2"

[workspace.package]
version = "1.0.130"
version = "1.0.131"
edition = "2021"
license = "AGPL-3.0-only"
rust-version = "1.89"
Expand Down
5 changes: 5 additions & 0 deletions crates/tmgr-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 1.0.131

- New `tmgr runner switch-agent <session>` (experimental) stops a Claude Code or Codex session and continues the same task in the other agent, in the same task clone. The new agent starts with a handoff note (your messages, the final replies, files touched, git state, the open plan, the last test run) and can look up the old conversation with `tmgr session`. The old run is finished as cancelled with "handed to <agent>" and the new run records the old session as its parent. Works for tasks of local workspaces started with `tmgr run`; the new agent starts in the default permission mode, never in a riskier one.
- The runner now notices the usage-limit message of Claude Code and Codex on a running session and shows it as `limit` in the session data. Nothing is switched automatically.

## 1.0.130

- New `tmgr session turns|show|grep|files|errors <id>` read a local Claude Code or Codex session as clean text: a numbered turn list, one turn with its tool calls, matches with turn numbers, files read and edited, and failed commands. Long text is trimmed (`--full` shows everything) and secrets such as tokens, keys and passwords are masked. Nothing leaves the machine.
Expand Down
1 change: 1 addition & 0 deletions crates/tmgr-cli/src/cmd/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,7 @@ fn run_create_req(req: &StartRequest) -> RunCreateReq {
external_resume: None,
permission_cards: false,
finish_marker: req.finish_marker,
parent_session: None,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/tmgr-cli/src/cmd/runner/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5390,6 +5390,8 @@ mod tests {
SessionInfo {
agent_session_id: None,
limit: None,
handoff_from: None,
managed: false,
team: None,
id: id.into(),
name: id.into(),
Expand Down
2 changes: 2 additions & 0 deletions crates/tmgr-cli/src/cmd/runner/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ fn run_request(p: &RunPlan) -> RunCreateReq {
RunCreateReq {
team: None,
finish_marker: false,
parent_session: None,
clones: p.clones.clone(),
profile: p.profile.to_string(),
task: Some(p.task),
Expand Down Expand Up @@ -3313,6 +3314,7 @@ mod tests {
let mut r = RunCreateReq {
team: None,
finish_marker: false,
parent_session: None,
clones: Vec::new(),
profile: "claude-code".into(),
task: Some(task),
Expand Down
12 changes: 12 additions & 0 deletions crates/tmgr-cli/src/cmd/runner/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ enum Request {
session_id: Option<String>,
#[serde(default)]
role: Option<String>,
#[serde(default)]
parent_session_id: Option<String>,
},
Update {
workspace: String,
task_id: i64,
run_id: i64,
branch: Option<String>,
commits: Option<Vec<String>>,
#[serde(default)]
parent_session_id: Option<String>,
},
Finish {
workspace: String,
Expand Down Expand Up @@ -278,6 +282,7 @@ fn handle(request: Request) -> Result<Value> {
branch,
session_id,
role,
parent_session_id,
} => {
let ws = find_workspace(&workspace)?;
let task_id = positive("task_id", task_id)?;
Expand All @@ -294,6 +299,9 @@ fn handle(request: Request) -> Result<Value> {
if let Some(role) = role.as_deref() {
body["role"] = json!(word("role", role, 32, "-")?);
}
if let Some(p) = parent_session_id.as_deref() {
body["parent_session_id"] = json!(word("parent_session_id", p, 191, "_.:-")?);
}
let s = Session::open(&ws, Some(runner_actor()), true)?;
if let Some(sid) = session.as_deref() {
if let Some(run_id) = running_run_of_session(&s, task_id, sid)? {
Expand All @@ -314,10 +322,14 @@ fn handle(request: Request) -> Result<Value> {
run_id,
branch,
commits: lines,
parent_session_id,
} => {
let ws = find_workspace(&workspace)?;
let (task_id, run_id) = (positive("task_id", task_id)?, positive("run_id", run_id)?);
let mut body = json!({});
if let Some(p) = parent_session_id.as_deref() {
body["parent_session_id"] = json!(word("parent_session_id", p, 191, "_.:-")?);
}
if let Some(b) = optional("branch", branch.as_deref(), 255)? {
body["branch"] = json!(b);
}
Expand Down
16 changes: 16 additions & 0 deletions crates/tmgr-cli/src/cmd/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mod run_task;
mod service;
mod session_list;
mod session_wt;
mod switch;
mod trusted;
mod watch;

Expand Down Expand Up @@ -90,6 +91,9 @@ pub enum RunnerCommands {
Resume(ResumeArgs),
/// [experimental] Give a session a new name (the id stays the same)
Rename(RenameArgs),
/// [experimental] Stop an agent session and continue the same task in the other agent (Claude Code or Codex), with a note of what was done
#[command(name = "switch-agent")]
SwitchAgent(SwitchArgs),
/// [experimental] Work with a session's transcript
Session {
#[command(subcommand)]
Expand Down Expand Up @@ -553,6 +557,18 @@ pub struct RenameArgs {
pub name: String,
}

#[derive(Args)]
pub struct SwitchArgs {
/// Session id or name
pub session: String,
/// Agent to continue in (default: the other one)
#[arg(long, value_enum)]
pub to: Option<switch::SwitchTarget>,
/// Do not ask for confirmation
#[arg(short, long)]
pub yes: bool,
}

#[derive(Args)]
pub struct RmArgs {
/// Session id or name, or the folder of a `run --worktree` checkout whose session is gone
Expand Down
4 changes: 3 additions & 1 deletion crates/tmgr-cli/src/cmd/runner/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub fn dispatch(o: &Opts, cmd: &RunnerCommands) -> Result<i32> {
RunnerCommands::Rm(a) => rm(o, a),
RunnerCommands::Resume(a) => resume(o, a),
RunnerCommands::Rename(a) => rename(o, a),
RunnerCommands::SwitchAgent(a) => super::switch::switch(o, a),
RunnerCommands::Session {
command: super::SessionCmd::Summary(a),
} => super::attach_summary::print_summary(o, &a.session, a.plain),
Expand Down Expand Up @@ -269,6 +270,7 @@ pub(super) fn run_create_run(
RunCreateReq {
team: None,
finish_marker: false,
parent_session: None,
clones: Vec::new(),
profile,
task: None,
Expand Down Expand Up @@ -903,7 +905,7 @@ fn send(o: &Opts, a: &SendArgs) -> Result<i32> {
))
}

fn wait_exit(c: &mut Client, id: &str, limit: Duration) -> Result<bool> {
pub(super) fn wait_exit(c: &mut Client, id: &str, limit: Duration) -> Result<bool> {
let end = Instant::now() + limit;
loop {
let list = c.list().map_err(rerr)?;
Expand Down
Loading
Loading