Skip to content

Commit 41c27dd

Browse files
committed
feat(desktop): add Tauri commands to end and recover remote thread sessions
Add the backend half of explicit thread-session lifecycle control for thread-sandbox providers. Providers may advertise `ops` in `info`; `provider_stop` sends the secret-bearing `stop` request only after the same staged bytes negotiated protocol v1 and advertised `stop`. New commands `end_remote_agent_session`, `recover_remote_agent_session` and `remote_agent_session_supports_lifecycle` share the deploy path's per-agent lock, post-lock payload rebuild, tenant scope assertion, and session binding. The recovery mode rides one invocation's provider config and is never persisted on the agent record. Expose typed TypeScript bindings for the three commands. Signed-off-by: Tee8z <[email protected]>
1 parent 38a80fa commit 41c27dd

12 files changed

Lines changed: 672 additions & 75 deletions

File tree

‎crates/buzz-backend-kubernetes/src/main.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ mod tests {
253253
assert_eq!(json["ok"], true);
254254
assert_eq!(json["protocol_version"], wire::PROTOCOL_VERSION);
255255
assert!(json["config_schema"]["properties"]["namespace"].is_object());
256-
assert!(json.get("ops").is_none());
256+
assert_eq!(json["ops"], serde_json::json!(["info", "deploy", "stop"]));
257257
}
258258

259259
/// `stop` is gated like a preflight: no approved identity policy, no

‎crates/buzz-backend-kubernetes/src/wire.rs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ use std::collections::BTreeMap;
1010
/// The wire-contract version this provider speaks (spec §Info).
1111
pub const PROTOCOL_VERSION: u32 = 1;
1212

13+
/// Operations this provider answers, advertised in `info.ops`. Additive
14+
/// within protocol version 1: a desktop gates optional UI (`stop`) on it.
15+
pub const OPS: &[&str] = &["info", "deploy", "stop"];
16+
1317
/// Request envelope. `op` discriminates; unknown ops are an in-band error.
1418
///
1519
/// `request_id` is deliberately absent from every variant. The desktop sends
@@ -105,6 +109,7 @@ pub struct InfoResponse {
105109
pub name: &'static str,
106110
pub version: &'static str,
107111
pub protocol_version: u32,
112+
pub ops: &'static [&'static str],
108113
pub description: &'static str,
109114
pub config_schema: serde_json::Value,
110115
}
@@ -146,6 +151,7 @@ impl Response {
146151
name: "kubernetes",
147152
version: env!("CARGO_PKG_VERSION"),
148153
protocol_version: PROTOCOL_VERSION,
154+
ops: OPS,
149155
description: "Runs agents as pods in a Kubernetes cluster",
150156
config_schema: crate::config::config_schema(),
151157
})
@@ -205,9 +211,9 @@ mod tests {
205211
}
206212

207213
#[test]
208-
fn info_remains_compatible_until_the_desktop_accepts_ops() {
214+
fn info_advertises_stop() {
209215
let v = serde_json::to_value(Response::info()).unwrap();
210-
assert!(v.get("ops").is_none());
216+
assert_eq!(v["ops"], serde_json::json!(["info", "deploy", "stop"]));
211217
}
212218

213219
#[test]

‎crates/buzz-backend-kubernetes/tests/wire_fixtures.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn info_response_carries_the_contract_fields() {
148148
assert_eq!(info["protocol_version"], 1);
149149
assert_eq!(info["name"], "kubernetes");
150150
// Additive within protocol version 1; the desktop gates "End session" on it.
151-
assert!(info.get("ops").is_none());
151+
assert_eq!(info["ops"], serde_json::json!(["info", "deploy", "stop"]));
152152
let schema = &info["config_schema"];
153153
assert_eq!(
154154
schema["required"],

‎desktop/src-tauri/src/commands/agents.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ async fn create_managed_agent_in<R: tauri::Runtime>(
843843
build_deploy_payload(&app, state, rec)?
844844
};
845845
match deploy_to_provider(
846-
&app, state, &pubkey, id, config, agent_json, None, None, None, None, None,
846+
&app, state, &pubkey, id, config, agent_json, None, None, None, None, None, None,
847847
)
848848
.await
849849
{
@@ -1020,6 +1020,7 @@ pub async fn start_managed_agent(
10201020
expected_signer_pubkey.as_deref(),
10211021
replay_floor_unix,
10221022
session_scope.as_ref(),
1023+
None,
10231024
)
10241025
.await?;
10251026

@@ -1229,11 +1230,13 @@ pub async fn delete_managed_agent(
12291230
mod deploy;
12301231
pub(super) mod provider_access;
12311232
mod provider_deploy;
1233+
mod remote_session;
12321234
pub(super) use deploy::build_deploy_payload;
12331235
#[cfg(test)]
12341236
use deploy::{deploy_payload_json, DeployProjections};
12351237
#[cfg(test)]
12361238
use deploy::{ensure_remote_provider_supported, resolve_deploy_model_provider};
1239+
pub use remote_session::*;
12371240

12381241
#[path = "agents_profile.rs"]
12391242
mod profile;

‎desktop/src-tauri/src/commands/agents/provider_access.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ pub(crate) async fn reconcile_on_workspace_apply(
105105
None,
106106
None,
107107
None,
108+
None,
108109
)
109110
.await
110111
{

0 commit comments

Comments
 (0)