Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/usecrate::{constants::{APPLICATION_NAME,CONTROL_PORT,DOCUMENTATION_URL,QUALITYLESS_PRODUCT_NAME},rpc::ResponseError,};usestd::fmt::Display;usethiserror::Error;// Wraps another error with additional info.#[derive(Debug, Clone)]pubstructWrappedError{
message:String,
original:String,}implstdfmt
f
f message original
e
message
e u
original
original message
message message
original
original message
message message
original
url
status_code
body
f
f
url status_code body
res
status_code res
url res
body res
e
url
status_code
body
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
f
exe
f
exe
_
f
f
f
f
f
f
f
error
error_description
f
f
error
error_description
makeAnyError
$
$
f
$ e ef
$
e
e
f
f
command
code
output
name bullets
e
e
// Error generated by an unsuccessful HTTP response
#[derive(Debug)]
pub
struct
StatusError
{
pub
:
String
,
pub
:
u16
,
pub
:
String
,
}
impl
std::fmt::
Display
for
StatusError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"error requesting {}: {} {}"
,
self
.
,
self
.
,
self
.
)
}
}
impl
StatusError
{
pub
async
fn
from_res
(
:
reqwest::
Response
)
->
Result
<
StatusError
,
AnyError
>
{
let
=
.
status
(
)
.
as_u16
(
)
;
let
=
.
url
(
)
.
to_string
(
)
;
let
=
.
text
(
)
.
await
.
map_err
(
|e|
{
wrap
(
,
format!
(
"failed to read response body on {status_code} code from {url}"
)
,
)
}
)
?
;
Ok
(
StatusError
{
,
,
,
}
)
}
}
// When the provided connection token doesn't match the one used to set up the original VS Code Server
// This is most likely due to a new user joining.
#[derive(Debug)]
pub
struct
MismatchConnectionToken
(
pub
String
)
;
impl
std::fmt::
Display
for
MismatchConnectionToken
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"{}"
,
self
.
0
)
}
}
// When the VS Code server has an unrecognized extension (rather than zip or gz)
#[derive(Debug)]
pub
struct
InvalidServerExtensionError
(
pub
String
)
;
impl
std::fmt::
Display
for
InvalidServerExtensionError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"invalid server extension '{}'"
,
self
.
0
)
}
}
// When the tunnel fails to open
#[derive(Debug, Clone)]
pub
struct
DevTunnelError
(
pub
String
)
;
impl
std::fmt::
Display
for
DevTunnelError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"could not open tunnel: {}"
,
self
.
0
)
}
}
impl
std::error::
Error
for
DevTunnelError
{
fn
source
(
&
self
)
->
Option
<
&
(
dyn
std::error::
Error
+
'static
)
>
{
None
}
}
// When the server was downloaded, but the entrypoint scripts don't exist.
#[derive(Debug)]
pub
struct
MissingEntrypointError
(
)
;
impl
std::fmt::
Display
for
MissingEntrypointError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Missing entrypoints in server download. Most likely this is a corrupted download. Please retry"
)
}
}
#[derive(Debug)]
pub
struct
SetupError
(
pub
String
)
;
impl
std::fmt::
Display
for
SetupError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"{}\n\nMore info at {}/remote/linux"
,
DOCUMENTATION_URL
.
unwrap_or
(
"<docs>"
)
,
self
.
0
)
}
}
#[derive(Debug)]
pub
struct
NoHomeForLauncherError
(
)
;
impl
std::fmt::
Display
for
NoHomeForLauncherError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"No $HOME variable was found in your environment. Either set it, or specify a `--data-dir` manually when invoking the launcher."
,
)
}
}
#[derive(Debug)]
pub
struct
InvalidTunnelName
(
pub
String
)
;
impl
std::fmt::
Display
for
InvalidTunnelName
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"{}"
,
&
self
.
0
)
}
}
#[derive(Debug)]
pub
struct
TunnelCreationFailed
(
pub
String
,
pub
String
)
;
impl
std::fmt::
Display
for
TunnelCreationFailed
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Could not create tunnel with name: {}\nReason: {}"
,
&
self
.
0
,
&
self
.
1
)
}
}
#[derive(Debug)]
pub
struct
TunnelHostFailed
(
pub
String
)
;
impl
std::fmt::
Display
for
TunnelHostFailed
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"{}"
,
&
self
.
0
)
}
}
#[derive(Debug)]
pub
struct
ExtensionInstallFailed
(
pub
String
)
;
impl
std::fmt::
Display
for
ExtensionInstallFailed
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Extension install failed: {}"
,
&
self
.
0
)
}
}
#[derive(Debug)]
pub
struct
MismatchedLaunchModeError
(
)
;
impl
std::fmt::
Display
for
MismatchedLaunchModeError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"A server is already running, but it was not launched in the same listening mode (port vs. socket) as this request"
)
}
}
#[derive(Debug)]
pub
struct
NoAttachedServerError
(
)
;
impl
std::fmt::
Display
for
NoAttachedServerError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"No server is running"
)
}
}
#[derive(Debug)]
pub
struct
RefreshTokenNotAvailableError
(
)
;
impl
std::fmt::
Display
for
RefreshTokenNotAvailableError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Refresh token not available, authentication is required"
)
}
}
#[derive(Debug)]
pub
struct
NoInstallInUserProvidedPath
(
pub
String
)
;
impl
std::fmt::
Display
for
NoInstallInUserProvidedPath
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"No {} installation could be found in {}. You can run `{} --use-quality=stable` to switch to the latest stable version of {}."
,
QUALITYLESS_PRODUCT_NAME
,
self
.
0
,
APPLICATION_NAME
,
QUALITYLESS_PRODUCT_NAME
)
}
}
#[derive(Debug)]
pub
struct
InvalidRequestedVersion
(
)
;
impl
std::fmt::
Display
for
InvalidRequestedVersion
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"The reqested version is invalid, expected one of 'stable', 'insiders', version number (x.y.z), or absolute path."
,
)
}
}
#[derive(Debug)]
pub
struct
UserCancelledInstallation
(
)
;
impl
std::fmt::
Display
for
UserCancelledInstallation
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Installation aborted."
)
}
}
#[derive(Debug)]
pub
struct
CannotForwardControlPort
(
)
;
impl
std::fmt::
Display
for
CannotForwardControlPort
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Cannot forward or unforward port {CONTROL_PORT}."
)
}
}
#[derive(Debug)]
pub
struct
ServerHasClosed
(
)
;
impl
std::fmt::
Display
for
ServerHasClosed
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Request cancelled because the server has closed"
)
}
}
#[derive(Debug)]
pub
struct
ServiceAlreadyRegistered
(
)
;
impl
std::fmt::
Display
for
ServiceAlreadyRegistered
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Already registered the service. Run `{APPLICATION_NAME} tunnel service uninstall` to unregister it first"
)
}
}
#[derive(Debug)]
pub
struct
WindowsNeedsElevation
(
pub
String
)
;
impl
std::fmt::
Display
for
WindowsNeedsElevation
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
writeln!
(
,
"{}"
,
self
.
0
)
?
;
writeln!
(
)
?
;
writeln!
(
,
"You may need to run this command as an administrator:"
)
?
;
writeln!
(
,
" 1. Open the start menu and search for Powershell"
)
?
;
writeln!
(
,
" 2. Right click and 'Run as administrator'"
)
?
;
if
let
Ok
(
)
=
std::env::
current_exe
(
)
{
writeln!
(
,
" 3. Run &'{}' '{}'"
,
.
display
(
)
,
std::env::
args
(
)
.
skip
(
1
)
.
collect
::
<
Vec
<
>>
(
)
.
join
(
"' '"
)
)
}
else
{
writeln!
(
,
" 3. Run the same command again"
,
)
}
}
}
#[derive(Debug)]
pub
struct
InvalidRpcDataError
(
pub
String
)
;
impl
std::fmt::
Display
for
InvalidRpcDataError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"parse error: {}"
,
self
.
0
)
}
}
#[derive(Debug)]
pub
struct
CorruptDownload
(
pub
String
)
;
impl
std::fmt::
Display
for
CorruptDownload
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Error updating the {} CLI: {}"
,
QUALITYLESS_PRODUCT_NAME
,
self
.
0
)
}
}
#[derive(Debug)]
pub
struct
MissingHomeDirectory
(
)
;
impl
std::fmt::
Display
for
MissingHomeDirectory
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Could not find your home directory. Please ensure this command is running in the context of an normal user."
)
}
}
#[derive(Debug)]
pub
struct
OAuthError
{
pub
:
String
,
pub
:
Option
<
String
>
,
}
impl
std::fmt::
Display
for
OAuthError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
write!
(
,
"Error getting authorization: {} {}"
,
self
.
,
self
.
.
as_deref
(
)
.
unwrap_or
(
""
)
)
}
}
// Makes an "AnyError" enum that contains any of the given errors, in the form
// `enum AnyError { FooError(FooError) }` (when given `makeAnyError!(FooError)`).
// Useful to easily deal with application error types without making tons of "From"
// clauses.
macro_rules!
{
(
(
$e
:
ident
)
,
*
)
=>
{
#[derive(Debug)]
#[allow(clippy::enum_variant_names)]
pub
enum
AnyError
{
(
$e
(
$e
)
,
)
*
}
impl
std::fmt::
Display
for
AnyError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
match
*
self
{
(
AnyError
::
$e
(
ref
)
=>
.
fmt
(
)
,
)
*
}
}
}
impl
std::error::
Error
for
AnyError
{
fn
source
(
&
self
)
->
Option
<
&
(
dyn
std::error::
Error
+
'static
)
>
{
None
}
}
(
impl
From
<
$e
>
for
AnyError
{
fn
from
(
:
$e
)
->
AnyError
{
AnyError
::
$e
(
)
}
}
)
*
}
;
}
#[derive(Debug)]
pub
struct
DbusConnectFailedError
(
pub
String
)
;
impl
Display
for
DbusConnectFailedError
{
fn
fmt
(
&
self
,
:
&
mut
std::fmt::
Formatter
)
->
std::fmt::
Result
{
let
mut
str
=
String
::
new
(
)
;
str
.
push_str
(
"Error creating dbus session. This command uses systemd for managing services, you should check that systemd is installed and under your user."
)
;
if
std::env::
var
(
"WSL_DISTRO_NAME"
)
.
is_ok
(
)
{
str
.
push_str
(
"\n\nTo enable systemd on WSL, check out: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/.\n\n"
)
;
}
str
.
push_str
(
"If running `systemctl status` works, systemd is ok, but your session dbus may not be. You might need to:\n\n- Install the `dbus-user-session` package, and reboot if it was not installed\n- Start the user dbus session with `systemctl --user enable dbus --now`.\n\nThe error encountered was: "
)
;
str
.
push_str
(
&
self
.
0
)
;
str
.
push
(
'\n'
)
;
write!
(
,
"{str}"
)
}
}
/// Internal errors in the VS Code CLI.
/// Note: other error should be migrated to this type gradually
#[derive(Error, Debug)]
pub
enum
CodeError
{
#[error("could not connect to socket/pipe: {0:?}")]
AsyncPipeFailed
(
std::io::
Error
)
,
#[error("could not listen on socket/pipe: {0:?}")]
AsyncPipeListenerFailed
(
std::io::
Error
)
,
#[error("could not create singleton lock file: {0:?}")]
SingletonLockfileOpenFailed
(
std::io::
Error
)
,
#[error("could not read singleton lock file: {0:?}")]
SingletonLockfileReadFailed
(
rmp_serde::decode::
Error
)
,
#[error("the process holding the singleton lock file (pid={0}) exited")]
SingletonLockedProcessExited
(
u32
)
,
#[error("no tunnel process is currently running")]
NoRunningTunnel
,
#[error("no agent host process is currently running")]
NoRunningAgentHost
,
#[error("rpc call failed: {0:?}")]
TunnelRpcCallFailed
(
ResponseError
)
,
#[cfg(windows)]
#[error("the windows app lock {0} already exists")]
AppAlreadyLocked
(
String
)
,
#[cfg(windows)]
#[error("could not get windows app lock: {0:?}")]
AppLockFailed
(
std::io::
Error
)
,
#[error("failed to run command \"{command}\" (code {code}): {output}")]
CommandFailed
{
:
String
,
:
i32
,
:
String
,
}
,
#[error("platform not currently supported: {0}")]
UnsupportedPlatform
(
String
)
,
#[error("This machine does not meet {name}'s prerequisites, expected either...\n{bullets}")]
PrerequisitesFailed
{
:
&
'static
str
,
:
String
}
,
#[error("failed to spawn process: {0:?}")]
ProcessSpawnFailed
(
std::io::
Error
)
,
#[error("failed to handshake spawned process: {0:?}")]