Synced from monorepo

Synced from monorepo

Changes:
- Shell: accept target response id on rewind execute
- Shell: stamp response id on chat user message chunks
- Worktree: optional rebuild and stale git registration cleanup in auto-GC
- Worktree: kind-aware auto-GC TTLs and config knobs
- Worktree: macOS process CWD scan and Unix PID liveness for GC guards
- Worktree: automatic throttled GC on startup (Linux age-based; non-Linux dead-only)
- Pager: add `[ui].combine_queued_prompts` to batch queued follow-ups
- Shell: stop overwriting user skills
- Tools: read markdown in `skills/` directories untruncated
- `/usage` shows per-session token and dollar usage in the TUI
- Security: prompt on environment-dumping `ps` variants
- Security: always-safe `kubectl` no longer runs arbitrary kubeconfig credential plugins without permission
- Tools: make scheduler deletion durable
- Shell: add relocation storage primitives
- Shell: give side model calls their own conversation ids
- Fix five workflow-runtime bugs (budget, pause, cancel, reconnect)
- Security: peel `env -S` / `--split-string` operands in the Bash permission gate (managed deny/ask)
- Pager: expose doctor in the TUI
- Security: block unauthorized RCE via abused safe commands
- Pager idle watcher cue: "1 subagent still running" instead of "watching · 1 subagent"
- Security: block `rg --pre` arbitrary code execution in auto-mode
- Voice: diagnose silent-mic failures (macOS permission) and add doctor/terminal-setup Voice section
- App builder deployer: `allow_forking` and `show_built_with_grok`
- Pager: stop stacking duplicate "Worked for" markers on parked turns
- Shell: support `max` as a distinct reasoning effort tier
- Tools: serialize background `/loop` fires on the whole work unit
- Shell: add working-directory relocation state primitives
- Proto: `ClientToolResult` and `ChatConfig` client-side tools
- Shell: model providers
- Chat: select App Builder product on the Build path
- Shell: attach author identity to feedback when the deployment opts in
- Doctor: fix for SSH wrap setup
- Workflow authoring skills: create-workflow and import-claude-workflow docs
- Add read-only grok doctor
- Sandbox: apply Landlock without a controlling TTY
- Pager: recover image paste over grok wrap on headless remotes
- Pager: make actions screen-mode aware
- Shell: resume sessions when the working directory moves
- Pager: centralize terminal diagnostics
- Workspace: gate inline shell file access
- Pager: centralize terminal probes
- Pager: edit minimal prompts in an external editor
- Pager: standardize backgrounding on Ctrl+B
- Shell: recap rides the parent turn's prompt cache
- Tools: add scheduler lifecycle version clock

Source-Revision: 0f4d7c91b8b2b408333f6de1e8a76cb8eaa71899
This commit is contained in:
grokkybara[bot] 2026-07-21 18:10:23 +00:00
commit 3af4d5d398
556 changed files with 56609 additions and 21892 deletions

View file

@ -10,6 +10,7 @@ use xai_grok_shell::sampling::error::{
RATE_LIMITED_ERROR_CODE, error_detail_from_data, format_rate_limited_user_message,
};
use xai_grok_shell::session::ExtMethodResult;
use xai_grok_shell::session::unified_list::ListScope;
/// Typed progress message for session restore.
/// Keeps the progress channel from accepting arbitrary `TaskResult` variants.
pub(crate) struct RestoreProgressMsg {
@ -446,6 +447,18 @@ pub(super) fn parse_session_list_partial(
},
)
}
/// Reads `_meta["x.ai/listScope"]` from a session-list payload.
pub(super) fn parse_session_list_scope(payload: &serde_json::Value) -> ListScope {
match payload
.get("_meta")
.and_then(|m| m.get("x.ai/listScope"))
.and_then(|v| v.as_str())
{
Some("repo") => ListScope::Repo,
Some("all") => ListScope::All,
_ => ListScope::Cwd,
}
}
/// Parse the `x.ai/session/list` response payload (the unwrapped
/// `{ "sessions": [...] }` object) into [`SessionPickerEntry`] rows.
///
@ -800,6 +813,14 @@ pub(crate) async fn persist_setting(
.await
.map_err(|e| e.to_string())
}
"combine_queued_prompts" => {
let SettingValue::Bool(b) = value else {
return Err(kind_mismatch("combine_queued_prompts", "Bool", &value));
};
xai_grok_shell::util::config::set_combine_queued_prompts(b)
.await
.map_err(|e| e.to_string())
}
"show_timeline" => {
let SettingValue::Bool(b) = value else {
return Err(kind_mismatch("show_timeline", "Bool", &value));

View file

@ -702,6 +702,8 @@ pub(crate) fn execute(
);
if let Some(q) = &query {
params["query"] = serde_json::Value::String(q.clone());
} else {
params["allowRelax"] = serde_json::Value::Bool(true);
}
let request = acp::ExtRequest::new(
"x.ai/session/list",
@ -726,9 +728,11 @@ pub(crate) fn execute(
let payload = wrapper.get("result").unwrap_or(&wrapper);
let sessions = parse_session_picker_entries(payload);
let partial = parse_session_list_partial(payload);
let scope = parse_session_list_scope(payload);
TaskResult::SessionListLoaded {
sessions,
partial,
scope,
seq,
query,
}
@ -1349,6 +1353,48 @@ pub(crate) fn execute(
TaskResult::CancelComplete
});
}
Effect::QueueHoldEdit { session_id, id } => {
let tx = acp_tx.clone();
tasks
.spawn(async move {
let params = serde_json::json!(
{ "sessionId" : session_id.0.to_string(), "id" : id, }
);
let notification = acp::ExtNotification::new(
"x.ai/queue/hold_edit",
serde_json::value::to_raw_value(&params)
.expect("serialize queue/hold_edit params")
.into(),
);
if let Err(e) = acp_send(notification, &tx).await {
tracing::warn!(
"Failed to send queue/hold_edit notification: {e}"
);
}
TaskResult::CancelComplete
});
}
Effect::QueueReleaseEdit { session_id, id } => {
let tx = acp_tx.clone();
tasks
.spawn(async move {
let params = serde_json::json!(
{ "sessionId" : session_id.0.to_string(), "id" : id, }
);
let notification = acp::ExtNotification::new(
"x.ai/queue/release_edit",
serde_json::value::to_raw_value(&params)
.expect("serialize queue/release_edit params")
.into(),
);
if let Err(e) = acp_send(notification, &tx).await {
tracing::warn!(
"Failed to send queue/release_edit notification: {e}"
);
}
TaskResult::CancelComplete
});
}
Effect::QueueInterject { session_id, id, expected_version, new_text } => {
let tx = acp_tx.clone();
tasks
@ -2404,6 +2450,44 @@ pub(crate) fn execute(
}
});
}
Effect::FetchWorkflowsList { agent_id, session_id } => {
let tx = acp_tx.clone();
tasks
.spawn(async move {
let params = serde_json::json!({ "sessionId" : session_id });
let req = acp::ExtRequest::new(
"x.ai/workflows/list",
serde_json::value::to_raw_value(&params)
.expect("serialize workflows/list params")
.into(),
);
let result = match acp_send(req, &tx).await {
Ok(resp) => {
let wrapper: serde_json::Value = serde_json::from_str(
resp.0.get(),
)
.unwrap_or_default();
let inner = wrapper.get("result").unwrap_or(&wrapper);
serde_json::from_value::<
Vec<crate::views::extensions_modal::WorkflowInfo>,
>(inner.get("workflows").cloned().unwrap_or_default())
.map_err(|_| "couldn't load workflows".to_string())
}
Err(e) => {
Err(
sanitize_user_error(
&format!("couldn't load workflows: {e}"),
),
)
}
};
TaskResult::WorkflowsListLoaded {
agent_id,
session_id,
result,
}
});
}
Effect::ToggleSkill { agent_id, session_id: _, skill_name, enabled } => {
let tx = acp_tx.clone();
tasks
@ -3176,6 +3260,28 @@ pub(crate) fn execute(
}
});
}
Effect::FetchSessionUsage { agent_id, session_id } => {
let tx = acp_tx.clone();
tasks
.spawn(async move {
match fetch_session_usage(&session_id, &tx).await {
Ok(usage) => {
TaskResult::SessionUsageComplete {
agent_id,
session_id,
usage: Box::new(usage),
}
}
Err(error) => {
TaskResult::SessionUsageFailed {
agent_id,
session_id,
error,
}
}
}
});
}
Effect::SendFeedback { agent_id, session_id, feedback_text } => {
use xai_grok_shell::session::ClientType;
use xai_grok_shell::session::acp_types::ClientFeedbackInput;
@ -3537,11 +3643,11 @@ pub(crate) fn execute(
}
});
}
Effect::RefreshAvailableCommands { agent_id, cwd } => {
Effect::RefreshAvailableCommands { agent_id, session_id } => {
let tx = acp_tx.clone();
tasks
.spawn(async move {
let params = serde_json::json!({ "cwd" : cwd });
let params = serde_json::json!({ "sessionId" : session_id });
let req = acp::ExtRequest::new(
"x.ai/commands/list",
serde_json::value::to_raw_value(&params)
@ -4198,6 +4304,37 @@ async fn fetch_session_info(
}
envelope.result.ok_or_else(|| "session info response missing result".to_string())
}
/// `x.ai/session/usage` → [`PromptUsage`] (bare response, no envelope).
async fn fetch_session_usage(
session_id: &acp::SessionId,
tx: &AcpAgentTx,
) -> Result<xai_grok_shell::extensions::notification::PromptUsage, String> {
let request = acp::ExtRequest::new(
"x.ai/session/usage",
serde_json::value::to_raw_value(
&serde_json::json!({ "sessionId" : session_id.0.to_string() }),
)
.expect("serialize session/usage params")
.into(),
);
let resp = acp_send(request, tx)
.await
.map_err(|e| {
if i32::from(e.code) == i32::from(acp::Error::method_not_found().code) {
"not supported by this agent version".to_string()
} else {
sanitize_user_error(&e.to_string())
}
})?;
let parsed: xai_grok_shell::extensions::usage::SessionUsageResponse = serde_json::from_str(
resp.0.get(),
)
.map_err(|e| {
tracing::debug!("session usage deser failed: {e}");
"invalid session usage response".to_string()
})?;
Ok(parsed.usage)
}
/// Look up the session title/summary from local persistence.
async fn lookup_session_title(session_id: &acp::SessionId) -> Option<String> {
let summaries = xai_grok_shell::session::persistence::list_summaries(None)

View file

@ -249,8 +249,7 @@ fn parse_subagent_kill_outcome_reads_typed_outcome() {
);
assert!(
matches!(parse_subagent_kill_outcome(r#"{"result":{"subagentId":"sa-1","cancelled":false,"outcome":{"kind":"already_finished","status":"completed"}}}"#),
SubagentKillOutcome::NothingLive { status : Some(s) }
if s == "completed")
SubagentKillOutcome::NothingLive { status : Some(s) } if s == "completed")
);
assert!(
matches!(parse_subagent_kill_outcome(r#"{"result":{"subagentId":"sa-1","cancelled":false,"outcome":{"kind":"not_found"}}}"#),
@ -303,8 +302,7 @@ fn parse_subagent_kill_outcome_round_trips_agent_serialization() {
.unwrap();
assert!(
matches!(parse_subagent_kill_outcome(& wire), SubagentKillOutcome::NothingLive {
status : Some(s) }
if s == "failed")
status : Some(s) } if s == "failed")
);
}
/// A top-level payload (no `result` envelope), error envelopes, and
@ -724,6 +722,20 @@ async fn persist_setting_type_mismatch_errors_page_flip_on_send() {
err.contains("persist_setting(page_flip_on_send) expected Bool"), "got: {err}",
);
}
#[tokio::test]
async fn persist_setting_type_mismatch_errors_combine_queued_prompts() {
use crate::settings::SettingValue;
let r = persist_setting(
"combine_queued_prompts",
SettingValue::String("nope".into()),
)
.await;
let err = r.expect_err("combine_queued_prompts with String payload must return Err");
assert!(
err.contains("persist_setting(combine_queued_prompts) expected Bool"),
"got: {err}",
);
}
/// Type-mismatch for `simple_mode`.
#[tokio::test]
async fn persist_setting_type_mismatch_errors_simple_mode() {
@ -1362,10 +1374,9 @@ async fn foreign_resume_detection_runs_as_task_result() {
other => panic!("expected ForeignResumeHintDetected, got {other:?}"),
}
}
/// `Effect::FetchSessionList` wire shape + echoes: a search fetch puts
/// `query` into the outgoing params, a plain fetch keeps the key ABSENT,
/// and every outcome echoes `seq`/`query` (the stale-drop guard and the
/// fetch-query stamp depend on the echoes).
/// `FetchSessionList` wire shape: search sends `query` (no `allowRelax`);
/// browse opts into `allowRelax` and parses `x.ai/listScope`; all
/// outcomes echo `seq`/`query`.
#[tokio::test]
async fn fetch_session_list_pushes_query_and_echoes_seq() {
use std::sync::{Arc, Mutex};
@ -1383,9 +1394,15 @@ async fn fetch_session_list_pushes_query_and_echoes_seq() {
.expect("params JSON");
let fail = params.get("query").and_then(|q| q.as_str())
== Some("fail-me");
let browse = params.get("query").is_none();
captured_for_task.lock().unwrap().push(params);
let body = if fail {
serde_json::json!({ "error" : "boom" })
} else if browse {
serde_json::json!(
{ "result" : { "sessions" : [], "_meta" : { "x.ai/listScope" :
"repo" }, } }
)
} else {
serde_json::json!({ "result" : { "sessions" : [] } })
};
@ -1413,10 +1430,11 @@ async fn fetch_session_list_pushes_query_and_echoes_seq() {
seq: 7,
});
match tasks.join_next().await.expect("task").expect("no panic") {
TaskResult::SessionListLoaded { sessions, seq, query, .. } => {
TaskResult::SessionListLoaded { sessions, scope, seq, query, .. } => {
assert!(sessions.is_empty());
assert_eq!(seq, 7, "seq must be echoed, not reconstructed");
assert_eq!(query.as_deref(), Some("hit"), "query must be echoed");
assert!(! scope.is_relaxed(), "search responses carry no relaxed scope");
}
other => panic!("expected SessionListLoaded, got {other:?}"),
}
@ -1425,9 +1443,13 @@ async fn fetch_session_list_pushes_query_and_echoes_seq() {
seq: 8,
});
match tasks.join_next().await.expect("task").expect("no panic") {
TaskResult::SessionListLoaded { seq, query, .. } => {
TaskResult::SessionListLoaded { scope, seq, query, .. } => {
assert_eq!(seq, 8);
assert_eq!(query, None);
assert!(
scope.is_relaxed(),
"_meta[\"x.ai/listScope\"] must parse into the task result"
);
}
other => panic!("expected SessionListLoaded, got {other:?}"),
}
@ -1451,12 +1473,71 @@ async fn fetch_session_list_pushes_query_and_echoes_seq() {
assert_eq!(captured[0] ["query"], "hit");
assert_eq!(captured[0] ["limit"], 30);
assert!(captured[0] ["cwd"].is_string());
assert!(
captured[0].get("allowRelax").is_none(),
"search fetches must not opt into relaxing: {:?}", captured[0]
);
assert!(
captured[1].get("query").is_none(),
"plain fetch must not send a query key: {:?}", captured[1]
);
assert_eq!(captured[1] ["allowRelax"], true, "browse fetches opt into relaxing");
assert_eq!(captured[2] ["query"], "fail-me");
}
#[tokio::test]
async fn fetch_workflows_list_sends_session_id() {
use std::sync::{Arc, Mutex};
use xai_acp_lib::AcpAgentMessage;
let captured: Arc<Mutex<Vec<serde_json::Value>>> = Arc::default();
let captured_for_task = captured.clone();
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();
tokio::spawn(async move {
while let Some(msg) = rx.recv().await {
if let AcpAgentMessage::ExtMethod(args) = msg {
assert_eq!(args.request.method.as_ref(), "x.ai/workflows/list");
let params: serde_json::Value = serde_json::from_str(
args.request.params.get(),
)
.expect("params JSON");
captured_for_task.lock().unwrap().push(params);
let body = serde_json::json!({ "result" : { "workflows" : [] } });
let raw = serde_json::value::RawValue::from_string(body.to_string())
.expect("serialize workflows response");
let _ = args.response_tx.send(Ok(acp::ExtResponse::new(Arc::from(raw))));
}
}
});
let session_id = acp::SessionId::new(Arc::from("test-session"));
let mut tasks = JoinSet::new();
let (progress_tx, _progress_rx) = tokio::sync::mpsc::unbounded_channel();
execute(
Effect::FetchWorkflowsList {
agent_id: AgentId(3),
session_id: session_id.clone(),
},
&mut tasks,
&tx,
Path::new("."),
&SessionFlags::default(),
&progress_tx,
);
match tasks.join_next().await.expect("task").expect("no panic") {
TaskResult::WorkflowsListLoaded {
agent_id,
session_id: result_session_id,
result,
} => {
assert_eq!(agent_id, AgentId(3));
assert_eq!(result_session_id, session_id);
assert!(result.expect("workflows load").is_empty());
}
other => panic!("expected WorkflowsListLoaded, got {other:?}"),
}
let captured = captured.lock().unwrap();
assert_eq!(captured.len(), 1);
assert_eq!(captured[0] ["sessionId"], "test-session");
assert!(captured[0].get("cwd").is_none());
}
/// The debounce arm must echo `query` and `seq` exactly. Awaits the real
/// 250 ms debounce (tokio's paused clock needs `test-util`, not enabled
/// in this crate).