Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/*---------------------------------------------------------------------------------------------
* API Keys — файловые инструменты для чат-агента.
* Без них BYOK-модель может только писать код текстом в чат: здесь она получает
* возможность читать, создавать и перезаписывать файлы внутри рабочей папки.
*--------------------------------------------------------------------------------------------*/import{ localize }from'../../../../nls.js';import{ CancellationToken }from'../../../../base/common/cancellation.js';import{ VSBuffer }from'../../../../base/common/buffer.js';import{URI}from'../../../../base/common/uri.js';import{ dirname, joinPath }from'../../../../base/common/resources.js';import{ IFileService }from'../../../../platform/files/common/files.js';import{ IWorkspaceContextService }from'../../../../platform/workspace/common/workspace.js';
ICommandService
CountTokensCallback IToolData IToolImpl IToolInvocation IToolResult ToolDataSource ToolProgress
workspaceContext IWorkspaceContextService rawPath
folders workspaceContextfolders
folderslength
rawPath rawPath
path rawPath
target foldersuri path
root foldersuri
targetscheme rootscheme targetauthority rootauthority targetpath rootpath targetpathrootpath rootpath rootpath
path
target
data IToolData
id
toolReferenceName
displayName
userDescription
modelDescription
source ToolDataSourceInternal
canBeReferencedInPrompt
inputSchema
type
properties
path type description
required
fileService IFileService
workspaceContext IWorkspaceContextService
invocation IToolInvocation _countTokens CountTokensCallback _progress ToolProgress _token CancellationToken IToolResult
uri workspaceContext invocationparameters path path
stat fileServiceuri
stat
invocationparameters path path
statisDirectory
invocationparameters path path
content fileServiceuri
text contentvalue
contentvaluebyteLength
text text
content kind value text
data IToolData
id
toolReferenceName
displayName
userDescription
modelDescription
source ToolDataSourceInternal
canBeReferencedInPrompt
inputSchema
type
properties
path type description
content type description
required
fileService IFileService
workspaceContext IWorkspaceContextService
invocation IToolInvocation _countTokens CountTokensCallback _progress ToolProgress _token CancellationToken IToolResult
params invocationparameters path content
uri workspaceContext paramspath
fileServiceuri
fileServiceuri VSBufferparamscontent
content kind value paramspath paramscontent length
data IToolData
id
toolReferenceName
displayName
userDescription
modelDescription
source ToolDataSourceInternal
canBeReferencedInPrompt
inputSchema
type
properties
path type description
required
fileService IFileService
workspaceContext IWorkspaceContextService
commandService ICommandService
invocation IToolInvocation _countTokens CountTokensCallback _progress ToolProgress _token CancellationToken IToolResult
raw invocationparameters path path
uri raw
fileServiceuri
folders workspaceContextfolders
foldersfolder folderuri uri
content kind value urifsPath
commandService uri forceReuseWindow
content kind value urifsPath
raw
raw raw
value raw
value value
value
folders workspaceContextfolders
folderslength
foldersuri value
root target
rootscheme targetscheme rootauthority targetauthority
base rootpath rootpath
targetpath rootpath targetpathbase
data IToolData
id
toolReferenceName
displayName
userDescription
modelDescription
source ToolDataSourceInternal
canBeReferencedInPrompt
inputSchema
type
properties
path type description
fileService IFileService
workspaceContext IWorkspaceContextService
invocation IToolInvocation _countTokens CountTokensCallback _progress ToolProgress _token CancellationToken IToolResult
uri workspaceContext invocationparameters path path
stat fileServiceuri
statisDirectory
invocationparameters path path
lines
child statchildren
lineslength lines
childisDirectory childname lines
lineschildisDirectory childname
content kind value lines
/** Инструменты не должны выходить за пределы рабочих папок и тонуть в служебных каталогах. */
const
IGNORED_DIRS
=
new
Set
(
[
'node_modules'
,
'.git'
,
'out'
,
'dist'
,
'.vscode-test'
]
)
;
const
MAX_FILE_READ_BYTES
=
100
*
1024
;
const
MAX_LIST_ENTRIES
=
400
;
/** Резолвит относительный путь модели в URI внутри рабочей папки. Пути вне workspace запрещены. */
function
resolveWorkspacePath
(
:
,
:
unknown
)
:
URI
{
const
=
.
getWorkspace
(
)
.
;
if
(
!
.
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.noWorkspace'
,
"В окне не открыта рабочая папка — инструменты файлов недоступны."
)
)
;
}
if
(
typeof
!==
'string'
||
!
.
trim
(
)
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.noPath'
,
"Параметр path обязателен."
)
)
;
}
const
=
.
trim
(
)
.
replace
(
/^[\\/]+/
,
''
)
;
const
=
URI
.
joinPath
(
[
0
]
.
,
)
;
const
=
[
0
]
.
;
// Защита от выхода за пределы workspace через ../
if
(
!
(
.
===
.
&&
.
===
.
&&
(
.
===
.
||
.
.
startsWith
(
.
.
endsWith
(
'/'
)
?
.
:
.
+
'/'
)
)
)
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.outsideWorkspace'
,
"Путь «{0}» вне рабочей папки — доступ запрещён."
,
)
)
;
}
return
;
}
export
class
AuraReadFileTool
implements
IToolImpl
{
static
readonly
:
=
{
:
AURA_READ_FILE_TOOL_ID
,
:
'read_file'
,
:
localize
(
'apiKeys.tools.readFile'
,
"Read File"
)
,
:
localize
(
'apiKeys.tools.readFileUser'
,
"Читает файл из рабочей папки"
)
,
:
'Read a text file from the workspace. Always read a file before modifying it, so edits are based on the real current content. Paths are relative to the workspace root.'
,
:
.
,
:
true
,
:
{
:
'object'
,
:
{
:
{
:
'string'
,
:
'Path to the file, relative to the workspace root (e.g. "src/app.ts").'
}
,
}
,
:
[
'path'
]
,
}
,
}
;
constructor
(
@IFileService
private
readonly
:
,
@IWorkspaceContextService
private
readonly
:
,
)
{
}
async
invoke
(
:
,
:
,
:
,
:
)
:
Promise
<
>
{
const
=
resolveWorkspacePath
(
this
.
,
(
.
as
{
?
:
string
}
)
.
)
;
const
=
await
this
.
.
resolve
(
)
.
catch
(
(
)
=>
undefined
)
;
if
(
!
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.fileNotFound'
,
"Файл не найден: {0}"
,
(
.
as
{
?
:
string
}
)
.
)
)
;
}
if
(
.
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.isDirectory'
,
"«{0}» — это папка, а не файл. Используйте list_files."
,
(
.
as
{
?
:
string
}
)
.
)
)
;
}
const
=
await
this
.
.
readFile
(
)
;
let
=
.
.
toString
(
)
;
if
(
.
.
>
MAX_FILE_READ_BYTES
)
{
=
.
slice
(
0
,
MAX_FILE_READ_BYTES
)
+
`\n… [обрезано: файл ${content.value.byteLength} байт, показаны первые ${MAX_FILE_READ_BYTES}]`
;
}
return
{
:
[
{
:
'text'
,
:
}
]
}
;
}
}
export
class
AuraWriteFileTool
implements
IToolImpl
{
static
readonly
:
=
{
:
AURA_WRITE_FILE_TOOL_ID
,
:
'write_file'
,
:
localize
(
'apiKeys.tools.writeFile'
,
"Write File"
)
,
:
localize
(
'apiKeys.tools.writeFileUser'
,
"Создаёт или перезаписывает файл в рабочей папке"
)
,
:
'Create a new file or fully overwrite an existing file in the workspace with the given content. Missing parent directories are created automatically. Use this instead of printing code in chat — the user expects real files. For large edits to existing files prefer writing the complete new file content.'
,
:
.
,
:
true
,
:
{
:
'object'
,
:
{
:
{
:
'string'
,
:
'Path to the file, relative to the workspace root.'
}
,
:
{
:
'string'
,
:
'Full file content to write.'
}
,
}
,
:
[
'path'
,
'content'
]
,
}
,
}
;
constructor
(
@IFileService
private
readonly
:
,
@IWorkspaceContextService
private
readonly
:
,
)
{
}
async
invoke
(
:
,
:
,
:
,
:
)
:
Promise
<
>
{
const
=
.
as
{
?
:
string
;
?
:
string
}
;
const
=
resolveWorkspacePath
(
this
.
,
.
)
;
await
this
.
.
createFolder
(
dirname
(
)
)
;
await
this
.
.
writeFile
(
,
.
fromString
(
.
??
''
)
)
;
return
{
:
[
{
:
'text'
,
:
localize
(
'apiKeys.tools.wroteFile'
,
"Файл записан: {0} ({1} байт)"
,
.
??
''
,
(
.
??
''
)
.
)
}
]
}
;
}
}
/**
* Открыть проект рабочей папкой окна.
*
* Зачем отдельный инструмент: `write_file` работает только внутри открытой папки,
* а чат часто просят «сделай сайт», когда папки нет вовсе. Раньше модель создавала
* файлы командой в терминале — проект появлялся на диске, но в проводнике его не
* было. Теперь путь один: создать папку и открыть её, а дальше писать файлы в неё.
*/
export
class
AuraOpenProjectTool
implements
IToolImpl
{
static
readonly
:
=
{
:
AURA_OPEN_PROJECT_TOOL_ID
,
:
'open_project'
,
:
localize
(
'apiKeys.tools.openProject'
,
"Open Project"
)
,
:
localize
(
'apiKeys.tools.openProjectUser'
,
"Создаёт папку проекта и открывает её в проводнике"
)
,
:
'Create a project folder (if it does not exist) and open it in the current window so it shows up in the Explorer. Call this FIRST when the user asks to build a new project and no folder is open: write_file only writes paths inside an opened folder. Prefer editing the folder that is already open — call this tool only when a new project is genuinely needed. Opening a folder reloads the window, so call it once, at the very beginning, and then write files. Pass an absolute path (Windows "C:\\Users\\me\\site", POSIX "/home/me/site") or a path relative to the open workspace root (relative paths need an open folder).'
,
:
.
,
:
true
,
:
{
:
'object'
,
:
{
:
{
:
'string'
,
:
'Project folder: absolute path, or relative to the open workspace root.'
}
,
}
,
:
[
'path'
]
,
}
,
}
;
constructor
(
@IFileService
private
readonly
:
,
@IWorkspaceContextService
private
readonly
:
,
@ICommandService
private
readonly
:
,
)
{
}
async
invoke
(
:
,
:
,
:
,
:
)
:
Promise
<
>
{
const
=
(
.
as
{
?
:
string
}
)
.
;
const
=
this
.
resolve
(
)
;
await
this
.
.
createFolder
(
)
;
// Папка уже открыта (или лежит внутри открытой) — окно не трогаем: новый проект
// просто окажется внутри текущего, и писать в него можно сразу.
const
=
this
.
.
getWorkspace
(
)
.
;
if
(
.
some
(
=>
this
.
contains
(
.
,
)
)
)
{
return
{
:
[
{
:
'text'
,
:
localize
(
'apiKeys.tools.projectInsideWorkspace'
,
"Папка уже в рабочей области: {0}. Пишите файлы путями относительно открытой папки."
,
.
)
}
]
}
;
}
// Папки нет — открываем штатной командой IDE: она сама переиспользует окно,
// а проект сразу появляется в проводнике. Менять рабочую область «тихо» нельзя:
// без перезагрузки окна новая папка не становится корнем Explorer'а.
await
this
.
.
executeCommand
(
'vscode.openFolder'
,
,
{
:
true
}
)
;
return
{
:
[
{
:
'text'
,
:
localize
(
'apiKeys.tools.openedProject'
,
"Проект открывается в этом окне: {0}. После перезагрузки пишите файлы путями относительно этой папки."
,
.
)
}
]
}
;
}
/** Приводит аргумент модели к URI: абсолютный путь или относительный от корня/домашней папки. */
private
resolve
(
:
unknown
)
:
URI
{
if
(
typeof
!==
'string'
||
!
.
trim
(
)
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.noProjectPath'
,
"Параметр path обязателен."
)
)
;
}
const
=
.
trim
(
)
.
replace
(
/^["']|["']$/g
,
''
)
;
// Абсолютный путь: Windows «C:\...» / UNC «\\server\share», POSIX «/...».
if
(
/^[A-Za-z]:[\\/]/
.
test
(
)
||
/^(\/|\\\\)/
.
test
(
)
)
{
return
URI
.
file
(
)
;
}
// Относительный считаем от открытой папки: без неё у нас нет надёжной базы,
// а угадывать домашний каталог нельзя — модель просто обязана дать абсолютный.
const
=
this
.
.
getWorkspace
(
)
.
;
if
(
!
.
)
{
throw
new
Error
(
localize
(
'apiKeys.tools.projectPathAbsolute'
,
"Рабочая папка не открыта — передайте абсолютный путь к папке проекта (например, «C:\\Users\\me\\site»)."
)
)
;
}
return
joinPath
(
[
0
]
.
,
...
.
replace
(
/^[\\/]+/
,
''
)
.
split
(
/[\\/]+/
)
)
;
}
/** target внутри root (или совпадает) — открывать заново не нужно. */
private
contains
(
:
URI
,
:
URI
)
:
boolean
{
if
(
.
!==
.
||
.
!==
.
)
{
return
false
;
}
const
=
.
.
endsWith
(
'/'
)
?
.
:
`${root.path}/`
;
return
.
===
.
||
.
.
startsWith
(
)
;
}
}
export
class
AuraListFilesTool
implements
IToolImpl
{
static
readonly
:
=
{
:
AURA_LIST_FILES_TOOL_ID
,
:
'list_files'
,
:
localize
(
'apiKeys.tools.listFiles'
,
"List Files"
)
,
:
localize
(
'apiKeys.tools.listFilesUser'
,
"Показывает структуру папки в рабочей области"
)
,
:
'List files and directories inside a workspace folder (non-recursive). Use it to explore the project structure before reading or writing files. Paths are relative to the workspace root; omit path to list the root.'
,
:
.
,
:
true
,
:
{
:
'object'
,
:
{
:
{
:
'string'
,
:
'Folder path relative to the workspace root. Omit for the root.'