Skip to main content

agentmux_srv/server/app_api/
workspace_import.rs

1// Copyright 2026, AgentMux Corp.
2// SPDX-License-Identifier: Apache-2.0
3
4//! `workspace.importuserworkspace`: open a saved workspace file as a new workspace. Whether the file's terminal commands
5//! run and its agents start is the person's answer in the import preview, so only the person's own window may call it
6//! (an agent's connection, and any connection that is not the window, is refused). The HTTP service route no longer
7//! imports (`service::user_workspace_files::handle_import`): it cannot tell the window from any other caller. The tests
8//! are beside the import's own, in `service/user_workspace_files_tests.rs`.
9
10use super::*;
11use crate::backend::rpc_types::{CommandWorkspaceImportUserWorkspaceData, COMMAND_WORKSPACE_IMPORT_USER_WORKSPACE};
12
13pub fn register(engine: &Arc<WshRpcEngine>, state: &AppState) {
14    let state = state.clone();
15    engine.register_typed(COMMAND_WORKSPACE_IMPORT_USER_WORKSPACE, move |req: CommandWorkspaceImportUserWorkspaceData, ctx| {
16        let state = state.clone();
17        async move {
18            ctx.operator_only("importing a workspace is the person's own action: ask the person to import the workspace file from the AgentMux window")?;
19            crate::server::service::user_workspace_files::import_for_window(&state, req).await
20        }
21    });
22}