Это 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.
*--------------------------------------------------------------------------------------------*/import{ IChatDebugEvent }from'../../common/chatDebugService.js';import{ FlowLayout, FlowNode, LayoutEdge, LayoutNode, SubgraphRect, FlowChartRenderResult }from'./chatDebugFlowGraph.js';// ---- Layout constants ----constNODE_HEIGHT=36;constMESSAGE_NODE_HEIGHT=52;constNODE_MIN_WIDTH=140;constNODE_MAX_WIDTH=320;constNODE_PADDING_H=16;constNODE_PADDING_V=6;
nodes LayoutNode
edges LayoutEdge
subgraphs SubgraphRect
width
height
entryNode LayoutNode
exitNodes LayoutNode
type
children FlowNode
mergedNode LayoutNode
children FlowNode
children FlowNode ChildGroup
subagentIndices
i i childrenlength i
childrenikind
subagentIndicesi
subagentIndiceslength
type children
parallelClusters
cluster subagentIndices
k k subagentIndiceslength k
prevCreated childrensubagentIndicesk created
currCreated childrensubagentIndiceskcreated
MathcurrCreated prevCreated
clustersubagentIndicesk
clusterlength
parallelClusterscluster
cluster subagentIndicesk
clusterlength
parallelClusterscluster
parallelClusterslength
type children
parallelIndices
c parallelClusters
idx c
parallelIndicesidx
groups ChildGroup
clusterIdx
i
i childrenlength
clusterIdx parallelClusterslength i parallelClustersclusterIdx
cl parallelClustersclusterIdx
lastIdx clcllength
setup FlowNode
subagents FlowNode
j cl j lastIdx j
parallelIndicesj
subagentschildrenj
setupchildrenj
setuplength
groups type children setup
groups type children subagents
i lastIdx
clusterIdx
start i
nextStart clusterIdx parallelClusterslength parallelClustersclusterIdx childrenlength
i nextStart parallelIndicesi
i
i start
groups type children childrenstart i
groups
kind IChatDebugEvent
kind kind
label sublabel
charWidth
labelWidth labellength charWidth
sublabelWidth sublabel sublabellength charWidth
Math Math labelWidth sublabelWidth
node FlowNode
nodekind
nodelabel
nodedescription nodedescription nodelabel
nodelabel
headerLabel
headerLabellength
node FlowNode
count nodechildrenlength
child nodechildren
count child
count
groups ChildGroup
startX
startY
depth
prevExitNodes LayoutNode
result nodes LayoutNode edges LayoutEdge subgraphs SubgraphRect
collapsedIds ReadonlySet
expandedMergedIds ReadonlySet
pendingExpansions PendingExpansion
exitNodes LayoutNode maxWidth endY
currentY startY
maxWidth
exitNodes prevExitNodes
group groups
grouptype
pg groupchildren startX currentY depth collapsedIds expandedMergedIds pendingExpansions
resultnodespgnodes
resultedgespgedges
resultsubgraphspgsubgraphs
prev exitNodes
entry pgentryNodes
resultedgesprev entry
exitNodes pgexitNodes
maxWidth MathmaxWidth pgwidth
currentY pgheight
child groupchildren
sub child startX currentY depth collapsedIds expandedMergedIds pendingExpansions
resultnodessubnodes
resultedgessubedges
resultsubgraphssubsubgraphs
prev exitNodes
resultedgesprev subentryNode
exitNodes subexitNodes
maxWidth MathmaxWidth subwidth
currentY subheight
exitNodes maxWidth endY currentY
from LayoutNode to LayoutNode LayoutEdge
fromId fromid
toId toid
fromX fromx fromwidth
fromY fromy fromheight
toX tox towidth
toY toy
roots FlowNode options collapsedIds ReadonlySet expandedMergedIds ReadonlySet FlowLayout
rootslength
nodes edges subgraphs width height
collapsedIds optionscollapsedIds
expandedMergedIds optionsexpandedMergedIds
groups roots
pendingExpansions PendingExpansion
result nodes LayoutNode edges LayoutEdge subgraphs SubgraphRect
nodes
edges
subgraphs
maxWidth endY groups result collapsedIds expandedMergedIds pendingExpansions
pendingExpansions result
width maxWidth
height endY
n resultnodes
width Mathwidth nx nwidth
height Mathheight ny nheight
result FlowLayout nodes LayoutNode edges LayoutEdge subgraphs SubgraphRect width
nodes resultnodes edges resultedges subgraphs resultsubgraphs width height
pendingExpansions PendingExpansion
result nodes LayoutNode edges LayoutEdge subgraphs SubgraphRect
expansion pendingExpansions
mergedNode children expansion
childrenTotalHeight childrenlength childrenlength
rangeTop mergedNodey
rangeBottom mergedNodey childrenTotalHeight
maxRightX mergedNodex mergedNodewidth
n resultnodes
ny nheight rangeTop ny rangeBottom
maxRightX MathmaxRightX nx nwidth
sg resultsubgraphs
sgy sgheight rangeTop sg n x nx dx
offsetEdges subtreeedgese
fromId efromId toId etoId
fromX efromX dx fromY efromY
toX etoX dx toY etoY
offsetSubgraphs subtreesubgraphss s x sx dx
nodesoffsetNodes
edgesoffsetEdges
subgraphsoffsetSubgraphs
entryNodesoffsetNodesn nid subtreeentryNodeid
exitIds subtreeexitNodesn nid
exitNodesoffsetNodesn exitIdsnid
currentX subtreewidth
nodes edges subgraphs entryNodes exitNodes width totalWidth height maxHeight
layout nodes LayoutNode edges LayoutEdge subgraphs SubgraphRect centerX
layoutnodeslength
minX
maxX
node layoutnodes
minX MathminX nodex
maxX MathmaxX nodex nodewidth
dx centerX minX maxX
i i layoutnodeslength i
n layoutnodesi
layoutnodes LayoutNodei n x nx dx
i i layoutedgeslength i
e layoutedgesi
layoutedges LayoutEdgei fromId efromId toId etoId fromX efromX dx fromY efromY toX etoX dx toY etoY
i i layoutsubgraphslength i
s layoutsubgraphsi
layoutsubgraphs SubgraphRecti s x sx dx
tag attrs Record SVGElementTagNameMap
el document tag
k v Objectattrs
elk v
el
kind IChatDebugEvent isError
isError
kind
layout FlowLayout FlowChartRenderResult
focusableElements
svg
width layoutwidth
height layoutheight
viewBox
role
svgclassList
svg layoutsubgraphs focusableElements
svg layoutedges
svg layoutnodes focusableElements
positionByKey
sg layoutsubgraphs
positionByKey y sgy x sgx
node layoutnodes
positionByKeynodeid y nodey x nodex
sortedFocusable
focusableElementsa b
posA positionByKeya
posB positionByKeyb
posA posB
posAy posBy posAy posBy posAx posBx
adjacency
edge layoutedges
edgefromId edgetoId
fromEntry adjacencyedgefromId
fromEntry
fromEntry next prev
adjacencyedgefromId fromEntry
fromEntrynextedgetoId
toEntry adjacencyedgetoId
toEntry
toEntry next prev
adjacencyedgetoId toEntry
toEntryprevedgefromId
svg focusableElements sortedFocusable adjacency positions positionByKey
svg SVGElement subgraphs SubgraphRect focusableElements Map SVGElement
sgIdx sgIdx subgraphslength sgIdx
sg subgraphssgIdx
color sgdepth length
isCollapsed sgcollapsedChildCount
g document
gclassList
rectAttrs x sgx y sgy width sgwidth height sgheight rx ry
clipId
clipPath id clipId
clipPath rectAttrs
svgclipPath
g rectAttrs fill color opacity sgdepth
g rectAttrs fill stroke color opacity
g x sgx y sgy width height sgheight fill color opacity
headerGroup document
headerGroup sgnodeId
headerGroupclassList
headerGroup
headerGroup
headerGroup isCollapsed
headerGroup
headerBar x sgx y sgy width sgwidth height fill color opacity
headerGroupheaderBar
chevron isCollapsed
headerText
x sgx
y sgy
fill color
headerTexttextContent
headerGroupheaderText
gheaderGroup
focusableElements headerGroup SVGElement
isCollapsed sgcollapsedChildCount
badgeText
x sgx sgwidth
y sgy
fill
badgeTexttextContent
gbadgeText
svgg
svg SVGElement edges LayoutEdge
strokeAttrs fill stroke
r
edge edges
midY edgefromY edgetoY
d
isHorizontal edgefromY edgetoY
isHorizontal
d
edgefromX edgetoX
d
dx edgetoX edgefromX
signX dx
absDx Mathdx
cr Mathr absDx edgetoY edgefromY
d
svg strokeAttrs d
a
arrowD
isHorizontal
signX edgetoX edgefromX
arrowD
arrowD
svg
strokeAttrs
d arrowD
svg SVGElement nodes LayoutNode focusableElements Map SVGElement
fontFamily
nodeFill
node nodes
g document
gclassList
g nodeid
g
g
ariaLabel nodesublabel nodelabel
g ariaLabel
focusableElementsnodeid g SVGElement
nodetooltip
title document
titletextContent nodetooltip
gtitle
color nodekind nodeisError
safeId nodeid
rectAttrs x nodex y nodey width nodewidth height nodeheight rx ry
clipId
clipPath id clipId
clipPath rectAttrs
svgclipPath
focusOffset
g
x nodex focusOffset
y nodey focusOffset
width nodewidth focusOffset
height nodeheight focusOffset
rx focusOffset
ry focusOffset
fill
stroke
g rectAttrs fill nodeFill stroke color nodeisError
g x nodex y nodey width height nodeheight fill color
textX nodex
isMessage nodekind
isMessage nodesublabel
header x textX y nodey fill fontFamily
headertextContent nodelabel
gheader
msg x textX y nodey nodeheight fill fontFamily
msgtextContent nodesublabel
gmsg
nodesublabel
label x textX y nodey fill fontFamily
labeltextContent nodelabel
glabel
sub x textX y nodey nodeheight fill fontFamily
subtextContent nodesublabel
gsub
label x textX y nodey nodeheight fill fontFamily
labeltextContent nodelabel
glabel
nodemergedCount
g
g node color fontFamily
svgg
g Element node LayoutNode color fontFamily
toggleX nodex nodewidth
toggleGroup document
toggleGroupclassList
toggleGroup nodeid
toggleGroup
x1 toggleX y1 nodey
x2 toggleX y2 nodey nodeheight
stroke
opacity
chevronX toggleX
chevronY nodey nodeheight
chevron
x chevronX
y chevronY
fill color
fontFamily
cursor
chevrontextContent nodeisMergedExpanded
toggleGroupchevron
toggleGroup
x toggleX
y nodey
width
height nodeheight
fill
cursor
gtoggleGroup
/** Deferred expansion of a merged-discovery node, resolved in pass 2. */
interface
PendingExpansion
{
/** The merged summary LayoutNode (already placed). */
readonly
:
;
/** The individual FlowNodes to expand to the right. */
readonly
:
readonly
[
]
;
}
// ---- Parallel detection ----
/** Max time gap (ms) between subagent `created` timestamps to consider them parallel. */
const
PARALLEL_TIME_THRESHOLD_MS
=
5_000
;
/**
* Groups a list of sibling nodes into sequential and parallel segments.
*
* Subagent invocations whose `created` timestamps fall within
* {@link PARALLEL_TIME_THRESHOLD_MS} of each other are clustered as parallel.
* Non-subagent nodes interleaved within a cluster are emitted as a sequential
* group before the parallel fork. When fewer than 2 subagents exist,
* everything is sequential.
*/
function
groupChildren
(
:
[
]
)
:
[
]
{
const
:
number
[
]
=
[
]
;
for
(
let
=
0
;
<
.
;
++
)
{
if
(
[
]
.
===
'subagentInvocation'
)
{
.
push
(
)
;
}
}
if
(
.
<
2
)
{
return
[
{
:
'sequential'
,
}
]
;
}
// Cluster subagents whose created timestamps are within the threshold.
const
:
number
[
]
[
]
=
[
]
;
let
:
number
[
]
=
[
[
0
]
]
;
for
(
let
=
1
;
<
.
;
++
)
{
const
=
[
[
-
1
]
]
.
;
const
=
[
[
]
]
.
;
if
(
.
abs
(
-
)
<=
PARALLEL_TIME_THRESHOLD_MS
)
{
.
push
(
[
]
)
;
}
else
{
if
(
.
>=
2
)
{
.
push
(
)
;
}
=
[
[
]
]
;
}
}
if
(
.
>=
2
)
{
.
push
(
)
;
}
if
(
.
===
0
)
{
return
[
{
:
'sequential'
,
}
]
;
}
// Build groups from the timestamp-derived clusters.
const
=
new
Set<number>
(
)
;
for
(
const
of
)
{
for
(
const
of
)
{
.
add
(
)
;
}
}
const
:
[
]
=
[
]
;
let
=
0
;
let
=
0
;
while
(
<
.
)
{
if
(
<
.
&&
===
[
]
[
0
]
)
{
const
=
[
]
;
const
=
[
.
-
1
]
;
const
:
[
]
=
[
]
;
const
:
[
]
=
[
]
;
for
(
let
=
[
0
]
;
<=
;
++
)
{
if
(
.
has
(
)
)
{
.
push
(
[
]
)
;
}
else
{
.
push
(
[
]
)
;
}
}
if
(
.
>
0
)
{
.
push
(
{
:
'sequential'
,
:
}
)
;
}
.
push
(
{
:
'parallel'
,
:
}
)
;
=
+
1
;
++
;
}
else
{
const
=
;
const
=
<
.
?
[
]
[
0
]
:
.
;
while
(
<
&&
!
.
has
(
)
)
{
++
;
}
if
(
>
)
{
.
push
(
{
:
'sequential'
,
:
.
slice
(
,
)
}
)
;
}
}
}
return
;
}
// ---- Layout engine ----
function
isMessageKind
(
:
[
'kind'
]
)
:
boolean
{
return
===
'userMessage'
||
===
'agentResponse'
;
}
function
measureNodeWidth
(
:
string
,
?
:
string
)
:
number
{
const
=
7
;
const
=
.
*
+
NODE_PADDING_H
*
2
;
const
=
?
.
*
(
-
1
)
+
NODE_PADDING_H
*
2
:
0
;
return
.
min
(
NODE_MAX_WIDTH
,
.
max
(
NODE_MIN_WIDTH
,
,
)
)
;
}
function
subgraphHeaderLabel
(
:
)
:
string
{
// For subagent nodes, the label already includes the description
// (e.g. "Subagent: Count markdown files"), so don't append it again.
if
(
.
===
'subagentInvocation'
)
{
return
.
;
}
if
(
.
&&
.
!==
.
)
{
return
`${node.label}: ${node.description}`
;
}
return
.
;
}
function
measureSubgraphHeaderWidth
(
:
string
)
:
number
{
return
.
*
6
+
SUBGRAPH_PADDING
*
2
+
20
;
// 20 for chevron
}
function
countDescendants
(
:
)
:
number
{
let
=
.
.
;
for
(
const
of
.
)
{
+=
countDescendants
(
)
;
}
return
;
}
/**
* Lays out grouped children (sequential or parallel) and connects edges.
* Shared by both root-level layout and subtree-level layout.
*
* @returns The final exit nodes, max width, and the y position after the last node.
*/
function
layoutGroups
(
:
[
]
,
:
number
,
:
number
,
:
number
,
:
[
]
,
:
{
:
[
]
;
:
[
]
;
:
[
]
}
,
?
:
<
string
>
,
?
:
<
string
>
,
?
:
[
]
,
)
:
{
:
[
]
;
:
number
;
:
number
}
{
let
=
;
let
=
0
;
let
=
;
for
(
const
of
)
{
if
(
.
===
'parallel'
)
{
const
=
layoutParallelGroup
(
.
,
,
,
,
,
,
)
;
.
.
push
(
...
.
)
;
.
.
push
(
...
.
)
;
.
.
push
(
...
.
)
;
for
(
const
of
)
{
for
(
const
of
.
)
{
.
.
push
(
makeEdge
(
,
)
)
;
}
}
=
.
;
=
.
max
(
,
.
)
;
+=
.
+
NODE_GAP_Y
;
}
else
{
for
(
const
of
.
)
{
const
=
layoutSubtree
(
,
,
,
,
,
,
)
;
.
.
push
(
...
.
)
;
.
.
push
(
...
.
)
;
.
.
push
(
...
.
)
;
for
(
const
of
)
{
.
.
push
(
makeEdge
(
,
.
)
)
;
}
=
.
;
=
.
max
(
,
.
)
;
+=
.
+
NODE_GAP_Y
;
}
}
}
return
{
,
,
:
}
;
}
function
makeEdge
(
:
,
:
)
:
{
return
{
:
.
,
:
.
,
:
.
+
.
/
2
,
:
.
+
.
,
:
.
+
.
/
2
,
:
.
,
}
;
}
/**
* Lays out a list of flow nodes in a top-down vertical flow.
* Parallel subagent invocations are arranged side by side.
*/
export
function
layoutFlowGraph
(
:
[
]
,
?
:
{
?
:
<
string
>
;
?
:
<
string
>
}
)
:
{
if
(
.
===
0
)
{
return
{
:
[
]
,
:
[
]
,
:
[
]
,
:
0
,
:
0
}
;
}
const
=
?.
;
const
=
?.
;
const
=
groupChildren
(
)
;
const
:
[
]
=
[
]
;
const
:
{
:
[
]
;
:
[
]
;
:
[
]
}
=
{
:
[
]
,
:
[
]
,
:
[
]
,
}
;
// Pass 1: layout the main vertical flow; expanded merged nodes only
// place their summary node and defer children to pendingExpansions.
const
{
,
}
=
layoutGroups
(
,
CANVAS_PADDING
,
CANVAS_PADDING
,
0
,
[
]
,
,
,
,
)
;
// Pass 2: resolve deferred expansions — place children to the right,
// far enough to clear all existing nodes/subgraphs in the Y range.
resolvePendingExpansions
(
,
)
;
let
=
+
CANVAS_PADDING
*
2
;
let
=
-
NODE_GAP_Y
+
CANVAS_PADDING
;
// Expand canvas to cover any nodes that float outside the main flow.
for
(
const
of
.
)
{
=
.
max
(
,
.
+
.
+
CANVAS_PADDING
)
;
=
.
max
(
,
.
+
.
+
CANVAS_PADDING
)
;
}
centerLayout
(
as
&
{
:
[
]
;
:
[
]
;
:
[
]
}
,
/
2
)
;
return
{
:
.
,
:
.
,
:
.
,
,
}
;
}
/**
* Pass 2: For each pending expansion, compute the Y range the children
* will occupy, scan all already-placed nodes and subgraphs for the max
* right edge overlapping that range, and place the entire column of
* children to the right of that edge.
*/
function
resolvePendingExpansions
(
:
[
]
,
:
{
:
[
]
;
:
[
]
;
:
[
]
}
,
)
:
void
{
for
(
const
of
)
{
const
{
,
}
=
;
// Compute the Y range the children will occupy.
const
=
.
*
NODE_HEIGHT
+
(
.
-
1
)
*
NODE_GAP_Y
;
const
=
.
;
const
=
.
+
;
// Find the max right edge of any existing node or subgraph