Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// Default to python language only if the Python extension is installed.
const
=
.
getExtension
(
'ms-python.python'
)
?
'python'
:
(
.
getExtension
(
'ms-dotnettools.dotnet-interactive-vscode'
)
?
'csharp'
:
'python'
)
;
// Note, whatever language is returned here, when the user selects a kernel, the cells (of blank documents) get updated based on that kernel selection.
return
translateKernelLanguageToMonaco
(
||
)
;
}
function
translateKernelLanguageToMonaco
(
:
string
)
:
string
{
=
.
toLowerCase
(
)
;
if
(
.
===
2
&&
.
endsWith
(
'#'
)
)
{
return
`${language.substring(0,1)}sharp`
;
}
return
.
get
(
)
||
;
}
const
=
[
'application/vnd.*'
,
'application/vdom.*'
,
'application/geo+json'
,
'application/x-nteract-model-debug+json'
,
'text/html'
,
'application/javascript'
,
'image/gif'
,
'text/latex'
,
'text/markdown'
,
'image/png'
,
'image/svg+xml'
,
'image/jpeg'
,
'application/json'
,
'text/plain'
]
;
function
isEmptyVendoredMimeType
(
:
)
{
if
(
.
.
startsWith
(
'application/vnd.'
)
)
{
try
{
return
.
.
===
0
||
.
from
(
.
)
.
toString
(
)
.
===
0
;
}
catch
{
}
}
return
false
;
}
function
isMimeTypeMatch
(
:
string
,
:
string
)
{
if
(
.
endsWith
(
'.*'
)
)
{
=
.
substr
(
0
,
.
indexOf
(
'.*'
)
)
;
}
return
.
startsWith
(
)
;
}
function
sortOutputItemsBasedOnDisplayOrder
(
:
[
]
)
:
[
]
{
return
.
map
(
=>
{
let
=
.
findIndex
(
(
)
=>
isMimeTypeMatch
(
,
.
)
)
;
// Sometimes we can have mime types with empty data, e.g. when using holoview we can have `application/vnd.holoviews_load.v0+json` with empty value.
// & in these cases we have HTML/JS and those take precedence.
/**
* Concatenates a multiline string or an array of strings into a single string.
* Also normalizes line endings to use LF (`\n`) instead of CRLF (`\r\n`).
* Same is done in serializer as well.
*/
function
concatMultilineCellSource
(
:
string
|
string
[
]
)
:
string
{
return
concatMultilineString
(
)
.
replace
(
/\r\n/g
,
'\n'
)
;
}
function
concatMultilineString
(
:
string
|
string
[
]
)
:
string
{
if
(
Array
.
isArray
(
)
)
{
let
=
''
;
for
(
let
=
0
;
i< str.length; i +=1){const s = str[i];if(i < str.length -1&&!s.endsWith('\n')){
result = result.concat(`${s}\n`);}else{
result = result.concat(s);}}return result;}return str.toString();}functionconvertJupyterOutputToBuffer(mime:string, value:unknown): NotebookCellOutputItem {if(!value){return NotebookCellOutputItem.text('', mime);}try{if((mime.startsWith('text/')|| textMimeTypes.includes(mime))&&(Array.isArray(value)||typeof value ==='string')){const stringValue =Array.isArray(value)?concatMultilineString(value): value;return NotebookCellOutputItem.text(stringValue, mime);}elseif(mime.startsWith('image/')&&typeof value ==='string'&& mime !=='image/svg+xml'){// Images in Jupyter are stored in base64 encoded format.// VS Code expects bytes when rendering images.if(typeof Buffer !=='undefined'&&typeof Buffer.from ==='function'){returnnewNotebookCellOutputItem(Buffer.from(value,'base64'), mime);}else{const data = Uint8Array.from(atob(value), c => c.charCodeAt(0));returnnewNotebookCellOutputItem(data, mime);}}elseif(typeof value ==='object'&& value !==null&&!Array.isArray(value)){return NotebookCellOutputItem.text(JSON.stringify(value), mime);}elseif(mime ==='application/json'){return NotebookCellOutputItem.json(value, mime);}else{// For everything else, treat the data as strings (or multi-line strings).
value =Array.isArray(value)?concatMultilineString(value): value;return NotebookCellOutputItem.text(value asstring, mime);}}catch(ex){return NotebookCellOutputItem.error(ex);}}functiongetNotebookCellMetadata(cell: nbformat.ICell):{[key:string]:any;}{// We put this only for VSC to display in diff view.// Else we don't use this.const cellMetadata: CellMetadata ={};if(cell.cell_type ==='code'){if(typeof cell['execution_count']==='number'){
cellMetadata.execution_count = cell['execution_count'];}else{
cellMetadata.execution_count =null;}}if(cell['metadata']){
cellMetadata['metadata']=JSON.parse(JSON.stringify(cell['metadata']));}if(typeof cell.id ==='string'){
cellMetadata.id = cell.id;}if(cell['attachments']){
cellMetadata.attachments =JSON.parse(JSON.stringify(cell['attachments']));}return cellMetadata;}functiongetOutputMetadata(output: nbformat.IOutput): CellOutputMetadata {// Add on transient data if we have any. This should be removed by our save functions elsewhere.const metadata: CellOutputMetadata ={
outputType: output.output_type
};if(output.transient){
metadata.transient = output.transient;}switch(output.output_type as nbformat.OutputType){case'display_data':case'execute_result':case'update_display_data':{
metadata.executionCount = output.execution_count;
metadata.metadata = output.metadata ?JSON.parse(JSON.stringify(output.metadata)):{};break;}default:break;}return metadata;}functiontranslateDisplayDataOutput(
output: nbformat.IDisplayData | nbformat.IDisplayUpdate | nbformat.IExecuteResult
): NotebookCellOutput {// Metadata could be as follows:// We'll have metadata specific to each mime type as well as generic metadata./*
IDisplayData = {
output_type: 'display_data',
data: {
'image/jpg': '/////'
'image/png': '/////'
'text/plain': '/////'
},
metadata: {
'image/png': '/////',
'background': true,
'xyz': '///
}
}
*/const metadata =getOutputMetadata(output);const items: NotebookCellOutputItem[]=[];if(output.data){for(const key in output.data){
items.push(convertJupyterOutputToBuffer(key, output.data[key]));}}returnnewNotebookCellOutput(sortOutputItemsBasedOnDisplayOrder(items), metadata);}functiontranslateErrorOutput(output?: nbformat.IError): NotebookCellOutput {
output = output ||{ output_type:'error', ename:'', evalue:'', traceback:[]};returnnewNotebookCellOutput([
NotebookCellOutputItem.error({
name: output?.ename ||'',
message: output?.evalue ||'',
stack:(output?.traceback ||[]).join('\n')})],{...getOutputMetadata(output), originalError: output });}functiontranslateStreamOutput(output: nbformat.IStream): NotebookCellOutput {const value =concatMultilineString(output.text);const item = output.name ==='stderr'? NotebookCellOutputItem.stderr(value): NotebookCellOutputItem.stdout(value);returnnewNotebookCellOutput([item],getOutputMetadata(output));}const cellOutputMappers =new Map<nbformat.OutputType,(output:any)=> NotebookCellOutput>
(
)
;
.
set
(
'display_data'
,
)
;
.
set
(
'execute_result'
,
)
;
.
set
(
'update_display_data'
,
)
;
.
set
(
'error'
,
)
;
.
set
(
'stream'
,
)
;
export
function
jupyterCellOutputToCellOutput
(
:
.
)
:
{
/**
* Stream, `application/x.notebook.stream`
* Error, `application/x.notebook.error-traceback`
* Rich, { mime: value }
*
* outputs: [
new vscode.NotebookCellOutput([
new vscode.NotebookCellOutputItem('application/x.notebook.stream', 2),
new vscode.NotebookCellOutputItem('application/x.notebook.stream', 3),
]),
new vscode.NotebookCellOutput([
new vscode.NotebookCellOutputItem('text/markdown', '## header 2'),
new vscode.NotebookCellOutputItem('image/svg+xml', [
"<svg baseProfile=\"full\" height=\"200\" version=\"1.1\" width=\"300\" xmlns=\"http://www.w3.org/2000/svg\">\n",
" <rect fill=\"blue\" height=\"100%\" width=\"100%\"/>\n",
" <circle cx=\"150\" cy=\"100\" fill=\"green\" r=\"80\"/>\n",
" <text fill=\"white\" font-size=\"60\" text-anchor=\"middle\" x=\"150\" y=\"125\">SVG</text>\n",
"</svg>"
]),
]),
]
*
*/
const
=
.
get
(
.
as
.
)
;
let
:
;
if
(
)
{
=
fn
(
)
;
}
else
{
=
translateDisplayDataOutput
(
as
unknown
as
.
|
.
|
.
)
;
}
return
;
}
function
createNotebookCellDataFromRawCell
(
:
.
)
:
{
const
=
new
NotebookCellData
(
.
,
concatMultilineCellSource
(
.
)
,
'raw'
)
;
.
=
[
]
;
.
=
getNotebookCellMetadata
(
)
;
return
;
}
function
createNotebookCellDataFromMarkdownCell
(
:
.
)
:
{
const
=
new
NotebookCellData
(
.
,
concatMultilineCellSource
(
.
)
,
'markdown'
)
;
.
=
[
]
;
.
=
getNotebookCellMetadata
(
)
;
return
;
}
function
createNotebookCellDataFromCodeCell
(
:
.
,
:
string
)
:
{
const
=
Array
.
isArray
(
.
)
?
.
:
[
]
;
const
=
.
map
(
)
;
const
=
typeof
.
===
'number'
&&
.
>
0
;
const
=
concatMultilineCellSource
(
.
)
;
const
:
=
?
{
:
.
as
number
}
:
{
}
;
const
=
.
?.
[
'vscode'
]
as
{
[
:
string
]
:
any
}
|
undefined
;
const
=
&&
.
&&
typeof
.
===
'string'
?
.
:
;
const
=
new
NotebookCellData
(
.
,
,
)
;
.
=
;
.
=
getNotebookCellMetadata
(
)
;
.
=
;
return
;
}
function
createNotebookCellDataFromJupyterCell
(
:
string
,
:
.
)
:
|
undefined
{
switch
(
.
)
{
case
'raw'
:
{
return
createNotebookCellDataFromRawCell
(
as
.
)
;
}
case
'markdown'
:
{
return
createNotebookCellDataFromMarkdownCell
(
as
.
)
;
}
case
'code'
:
{
return
createNotebookCellDataFromCodeCell
(
as
.
,
)
;
}
}
return
;
}
/**
* Converts a NotebookModel into VS Code format.
*/