Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/** Runtime information needed to launch the sandbox-runtime CLI. */
export
interface
ITerminalSandboxRuntimeInfo
{
/** Directory that contains `node_modules/@vscode/sandbox-runtime` and `node_modules/@vscode/ripgrep`. */
:
string
;
/**
* Name of the directory (relative to {@link appRoot}) that holds the native
* binaries `ripgrep-universal` and `@microsoft/mxc-sdk`. In a packaged desktop
* build these are unpacked from the archive into `node_modules.asar.unpacked`;
* in dev and on remote they live in plain `node_modules`. Defaults to
* `node_modules`. Note the sandbox-runtime CLI itself is always resolved from
* plain `node_modules` (it is duplicated out of the archive) because it is
* spawned as a standalone Node subprocess without the ASAR resolution hook.
*/
?
:
string
;
/** Path of the node/electron executable used to run sandbox-runtime. */
?
:
string
;
/**
* When true the engine prefixes the wrapped command with `ELECTRON_RUN_AS_NODE=1`
* so the Electron binary acts as a Node.js executable. Set by hosts that resolve
* an Electron-based exec path (the local workbench); leave undefined / false when
* `execPath` already points at a real `node` binary (remote, agent host).
*/
?
:
boolean
;
/** CPU architecture of the environment that runs the sandbox runtime. */
?
:
string
;
}
/**
* Host adapter that supplies the engine with environment/workspace data the
* platform layer cannot resolve on its own. Hosts (workbench, agent host)
* implement this to bridge their per-environment services (`IRemoteAgentService`,
* `IWorkspaceContextService`, `IEnvironmentService`, `IProductService`,
* `ISandboxHelperService`, …) into the engine.
*/
export
interface
ITerminalSandboxEngineHost
{
/** Effective OS used by sandbox decisions. May be the remote OS in workbench. */
getOS
(
)
:
Promise
<
>
;
/** Resolves app root + node/electron exec path (after the remote env is known, if applicable). */
getRuntimeInfo
(
)
:
Promise
<
>
;
/** Resolves the user home used for `~`-expansion and the default deny-read entry. */
getUserHome
(
)
:
Promise
<
URI
|
undefined
>
;
/**
* Resolves the directory the engine creates and uses as its sandbox temp dir
* (sandbox-settings JSON file lives here). May return undefined when no
* suitable location exists, in which case sandboxing is disabled.
*/
getSandboxTempDir
(
)
:
Promise
<
URI
|
undefined
>
;
/** Path added to `allowRead` and `allowWrite` for the engine's workspace/session storage area. */
getWorkspaceStorageReadRoot
(
)
:
Promise
<
URI
|
undefined
>
;
/** Additional paths that hosts require sandboxed commands to read. */
?
(
)
:
readonly
URI
[
]
;
/** Roots that must be writable inside the sandbox (workspace folders / session cwds). */
getWriteRoots
(
)
:
readonly
URI
[
]
;
/** Fires when host read roots, write roots, or workspace storage roots change. */
readonly
:
<
void
>
;
/** Resolves the installed sandbox-dependency status (bubblewrap, socat). */
checkSandboxDependencies
(
)
:
Promise
<
|
undefined
>
;
/** Resolves host filesystem policy fragments needed by the Windows MXC process container. */
getWindowsMxcFilesystemPolicy
(
)
:
Promise
<
|
undefined
>
;
/** Resolves host environment variables needed by the Windows MXC process container. */
getWindowsMxcEnvironment
(
)
:
Promise
<
string
[
]
|
undefined
>
;
/** Builds a Windows MXC payload from a target-environment MXC sandbox policy. */
buildWindowsMxcSandboxPayload
(
:
string
,
:
,
?
:
string
,
?
:
string
,
?
:
)
:
Promise
<
|
undefined
>
;
/**
* Returns the effective value of a sandbox-related configuration setting,
* or `undefined` when the setting is not configured.
*/
getSandboxSetting<T>
(
:
|
)
:
T
|
undefined
;
/**
* Fires when any value returned by {@link getSandboxSetting} may have
* changed. The engine invalidates its sandbox-config file on each event.
* Implementations should pre-filter to sandbox-relevant keys.
*/
readonly
:
<
void
>
;
}
/**
* Core sandbox engine. Encapsulates the platform-agnostic logic for wrapping
* commands in a sandbox runtime: enabledness checks, command-line wrapping,
* sandbox-config generation, network-domain extraction and prerequisite checks.
*
* Hosts (workbench / agent host) construct an engine with a host adapter that
* supplies workspace/remote-specific data, then forward their public service
* methods to the engine and add their own host-specific concerns
* (chat elicitation, lifecycle hooks, …) on top.
*/
/**
* Deletes the sandbox temp directory if one was created. Hosts are expected
* to invoke this from their shutdown / disposal path; the engine itself does
* not delete the directory on `dispose()
` because shutdown joiners need to
* be coordinated externally.
*/
async cleanupTempDir(): Promise<void> {
if (!this._tempDir) {
return;
}
try {
await this._fileService.del(this._tempDir, { recursive: true, useTrash: false });
} catch (error) {
this._logService.warn('TerminalSandboxEngine: Failed to delete sandbox temp dir', error);
}
}
// ---- private helpers ----------------------------------------------------
private async _checkSandboxDependencies(forceRefresh = false): Promise<boolean> {
const os = await this.getOS();
if (os === OperatingSystem.Windows) {
return true;
}
if (!forceRefresh && this._sandboxDependencyStatus) {
return this._sandboxDependencyStatus.bubblewrapInstalled && this._sandboxDependencyStatus.bubblewrapUsable && this._sandboxDependencyStatus.socatInstalled;
}
const status = await this._host.checkSandboxDependencies();
this._sandboxDependencyStatus = status;
if (status && !status.bubblewrapInstalled) {
this._logService.warn('TerminalSandboxEngine: bubblewrap (bwrap) is not installed');
} else if (status && !status.bubblewrapUsable) {
this._logService.warn('TerminalSandboxEngine: bubblewrap (bwrap) is installed but failed its capability check', status.bubblewrapError);
}
if (status && !status.socatInstalled) {
this._logService.warn('TerminalSandboxEngine: socat is not installed');
}
return status ? status.bubblewrapInstalled && status.bubblewrapUsable && status.socatInstalled : true;
}
private _getBubblewrapRemediations(): readonly TerminalSandboxPreCheckRemediation[] | undefined {
return [TerminalSandboxPreCheckRemediation.DisableUnprivilagedusernamespaceRestriction];
}
private _quoteShellArgument(value: string): string {
return `
` because matching is
* case-insensitive and backslashes are normalized to `
/
`.
* - Glob: `
/
/
/
package
.
` matches `
/
/
/*.json`.
*/
private
_matchesFileSystemPath
(
:
string
,
:
string
)
:
boolean
{
const
=
this
.
_normalizeFileSystemAccessPath
(
)
;
const
=
this
.
_normalizeFileSystemAccessPath
(
,
true
)
;
const
=
this
.
===
.
;
if
(
this
.
_containsGlobPattern
(
)
)
{
return
globMatch
(
,
,
{
}
)
;
}
return
this
.
.
isEqualOrParent
(
this
.
_toFileSystemAccessUri
(
)
,
this
.
_toFileSystemAccessUri
(
)
)
;
}
/**
* Converts a normalized sandbox filesystem path into a pseudo URI so the common
* `ExtUri.isEqualOrParent` comparer can be used instead of deprecated string
* path helpers. A non-`file` scheme is intentional: it keeps comparison on the
* URI path component and avoids converting through the host OS' native `fsPath`
* rules, which may differ from the sandbox target OS.
*
* Examples:
* - `/workspace/project` becomes `terminal-sandbox-path:/workspace/project`.
* - `C:/Repo` becomes `terminal-sandbox-path:/C:/Repo` so Windows drive paths
* are still valid URI paths for comparison.
*/
private
_toFileSystemAccessUri
(
:
string
)
:
URI
{
return
URI
.
from
(
{
:
'terminal-sandbox-path'
,
:
.
startsWith
(
'/'
)
?
:
`/${path}`
}
)
;
}
/**
* Normalizes a path or matcher into the form used for sandbox access checks.
* On Windows, backslashes are converted to `/` and URI-shaped drive paths like
* `/C:/Users/me` are converted to `C:/Users/me`. Unless `preserveGlob` is true
* for a glob matcher, the path is POSIX-normalized to remove redundant `.`/`..`
* segments. Trailing slashes are removed except for filesystem roots.
*
* Examples:
* - Linux/macOS: `/workspace/../workspace/app/` becomes `/workspace/app`.
* - Windows: `C:\Users\me\project\` becomes `C:/Users/me/project`.
* - Windows: `/C:/Users/me/project` becomes `C:/Users/me/project`.
* - Glob with `preserveGlob=true`: `/workspace/project/*.json` keeps the glob
* pattern intact for `globMatch`.
*/
private
_normalizeFileSystemAccessPath
(
:
string
,
:
boolean
=
false
)
:
string
{
let
=
this
.
===
.
?
.
replace
(
/\\/g
,
'/'
)
:
;
if
(
this
.
===
.
&&
/^\/[a-zA-Z]:($|\/)/
.
test
(
)
)
{
=
.
slice
(
1
)
;
}
if
(
!
||
!
this
.
_containsGlobPattern
(
)
)
{
=
.
normalize
(
)
;
}
if
(
.
>
1
&&
.
endsWith
(
'/'
)
&&
!
/^[a-zA-Z]:\/$/
.
test
(
)
)
{
=
.
replace
(
/\/+$/
,
''
)
;
}
return
;
}
private
_containsGlobPattern
(
:
string
)
:
boolean
{
return
/[*?{\[]/
.
test
(
)
;
}
private
readonly
=
(
:
string
,
:
,
?
:
string
,
?
:
string
,
?
:
)
:
Promise
<
|
undefined
>
=>
{
return
this
.
.
buildWindowsMxcSandboxPayload
(
,
,
,
,
)
;
}
;
private
_getCommandRuntimeFileSystemPaths
(
:
<
string
,
unknown
>
,
:
'allowRead'
|
'allowWrite'
)
:
string
[
]
{
const
=
.
;
if
(
!
this
.
_isObjectForSandboxConfigMerge
(
)
)
{
return
[
]
;
}
const
=
[
]
;
if
(
!
Array
.
isArray
(
)
)
{
return
[
]
;
}
return
.
filter
(
(
)
:
is
string
=>
typeof
===
'string'
)
;
}
private
_mergeAdditionalSandboxConfigProperties
(
:
<
string
,
unknown
>
,
:
<
string
,
unknown
>
)
:
void
{
for
(
const
[
,
]
of
.
entries
(
)
)
{
if
(
!
.
.
hasOwnProperty
.
call
(
,
)
)
{
[
]
=
;
continue
;
}
const
=
[
]
;
if
(
this
.
_isObjectForSandboxConfigMerge
(
)
&&
this
.
_isObjectForSandboxConfigMerge
(
)
)
{
this
.
_mergeAdditionalSandboxConfigProperties
(
,
)
;
}
}
}
private
_isObjectForSandboxConfigMerge
(
:
unknown
)
:
is
<
string
,
unknown
>
{
return
typeof
===
'object'
&&
!==
null
&&
!
Array
.
isArray
(
)
;
}
private
async
_getWindowsMxcFilesystemPolicy
(
)
:
Promise
<
>
{
if
(
!
this
.
)
{
this
.
=
await
this
.
.
getWindowsMxcFilesystemPolicy
(
)
??
{
:
[
]
,
:
[
]
}
;
}
return
this
.
;
}
private
async
_getWindowsMxcEnvironment
(
)
:
Promise
<
string
[
]
>
{
if
(
!
this
.
)
{
this
.
=
await
this
.
.
getWindowsMxcEnvironment
(
)
??
[
]
;
}
return
this
.
;
}
private
_pathJoin
=
(
...
:
string
[
]
)
=>
{
const
=
this
.
===
.
?
:
;
return
.
join
(
...
)
;
}
;
private
_pathDirname
(
:
string
)
:
string
{
return
(
this
.
===
.
?
:
)
.
dirname
(
)
;
}
private
_getUriPath
(
:
URI
)
:
string
{
return
this
.
===
.
?
this
.
.
toWindowsPath
(
)
:
.
;
}
private
async
_initTempDir
(
)
:
Promise
<
void
>
{
if
(
!
(
await
this
.
isEnabled
(
)
)
)
{
return
;
}
this
.
=
true
;
this
.
=
await
this
.
.
getSandboxTempDir
(
)
;
if
(
this
.
)
{
await
this
.
.
createFolder
(
this
.
)
;
this
.
.
push
(
this
.
_getUriPath
(
this
.
)
)
;
}
else
{
this
.
.
warn
(
'TerminalSandboxEngine: Cannot create sandbox settings file because no tmpDir is available in this environment'
)
;
}
}
private
async
_updateAllowWritePathsWithWorkspaceFolders
(
:
string
[
]
|
undefined
,
:
string
[
]
=
[
]
)
:
Promise
<
string
[
]
>
{
const
=
this
.
.
getWriteRoots
(
)
.
map
(
=>
this
.
_getUriPath
(
)
)
;
return
[
...
new
Set
(
[
...
,
...
this
.
,
...
await
this
.
_getWorkspaceStorageReadPaths
(
)
,
...
(
??
[
]
)
,
...
]
)
]
;
}
private
_updateDenyReadPathsWithHome
(
:
string
[
]
|
undefined
)
:
string
[
]
{
// TODO: On Windows, deny read on home directory.
if
(
this
.
===
.
)
{
return
[
...
new
Set
(
??
[
]
)
]
;
}
const
=
this
.
?
this
.
_getUriPath
(
this
.
)
:
undefined
;
return
[
...
new
Set
(
[
...
(
??
[
]
)
,
...
(
?
[
]
:
[
]
)
]
)
]
;
}
private
async
_updateAllowReadPathsWithAllowWrite
(
:
string
[
]
|
undefined
,
:
string
[
]
,
:
string
[
]
=
[
]
)
:
Promise
<
string
[
]
>
{
const
=
this
.
.
?.
(
)
.
map
(
=>
this
.
_getUriPath
(
)
)
??
[
]
;
return
[
...
new
Set
(
[
...
(
??
[
]
)
,
...
getTerminalSandboxReadAllowListForCommands
(
this
.
,
this
.
,
this
.
)
,
...
,
...
this
.
_getSandboxRuntimeReadPaths
(
)
,
...
await
this
.
_getWorkspaceStorageReadPaths
(
)
,
...
,
...
]
)
]
;
}
private
async
_resolveFileSystemPaths
(
:
string
[
]
|
undefined
)
:
Promise
<
string
[
]
>
{
const
=
await
Promise
.
all
(
(
??
[
]
)
.
map
(
=>
this
.
_resolveFileSystemPath
(
)
)
)
;
const
=
new
Set<string>
(
)
;
return
.
flat
(
)
.
filter
(
=>
{
const
=
this
.
_getFileSystemPathComparisonKey
(
)
;
if
(
.
has
(
)
)
{
return
false
;
}
.
add
(
)
;
return
true
;
}
)
;
}
private
_getFileSystemPathComparisonKey
(
:
string
)
:
string
{
return
this
.
===
.
?
.
replace
(
/\//g
,
'\\'
)
.
toLowerCase
(
)
:
;
}
private
async
_resolveFileSystemPath
(
:
string
)
:
Promise
<
string
[
]
>
{
const
=
this
.
===
.
?
this
.
_expandHomePath
(
)
:
;
if
(
!
this
.
_isAbsoluteFileSystemPath
(
)
)
{
return
[
]
;
}
try
{
const
=
await
this
.
.
realpath
(
this
.
_toFileSystemResource
(
)
)
;
const
=
?
this
.
_getUriPath
(
)
:
undefined
;
// Keep the expanded path (the configured path after home expansion) so permissions apply when accessed through the symlink.
// Also include the resolved path (the canonical symlink target) so the same permissions apply when accessed directly.
return
&&
!==
?
[
,
]
:
[
]
;
}
catch
{
return
[
]
;
}
}
private
_isAbsoluteFileSystemPath
(
:
string
)
:
boolean
{
return
(
this
.
===
.
?
:
)
.
isAbsolute
(
)
;
}
private
_toFileSystemResource
(
:
string
)
:
URI
{
if
(
this
.
===
.
)
{
return
this
.
_toWindowsFileSystemResource
(
)
;
}
return
this
.
?.
with
(
{
}
)
??
this
.
?.
with
(
{
}
)
??
this
.
.
getWriteRoots
(
)
[
0
]
?.
with
(
{
}
)
??
URI
.
file
(
)
;
}
private
_toWindowsFileSystemResource
(
:
string
)
:
URI
{
// Normalize Windows separators for URI parsing, e.g. `C:\Users\me` becomes `C:/Users/me`.
const
=
.
replace
(
/\\/g
,
'/'
)
;
// Match UNC paths, e.g. `//server/share/folder` becomes `file://server/share/folder`.
if
(
/^\/\/[^/]/
.
test
(
)
)
{
const
=
.
indexOf
(
'/'
,
2
)
;
if
(
===
-
1
)
{
return
URI
.
from
(
{
:
'file'
,
:
.
slice
(
2
)
,
:
'/'
}
)
;
}
return
URI
.
from
(
{
:
'file'
,
:
.
slice
(
2
,
)
,
:
.
slice
(
)
||
'/'
}
)
;
}
// Match drive-letter paths, e.g. `C:/Users/me` becomes `file:///c:/Users/me`.