Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* Stable command the Voice Mode "Configure Keybinding" context-menu entry targets.
* The rendered voice affordance swaps between states, but the keybinding lives on
* the start command, so target it in every state.
*/
const
VOICE_START_COMMAND_ID
=
'agentsVoice.startVoiceInChat'
;
async
function
retargetVoiceToCurrentSession
(
:
,
:
)
:
Promise
<
boolean
>
{
const
=
await
.
executeCommand<string|undefined>
(
'_chat.voice.getCurrentSession'
)
;
if
(
!
)
{
return
false
;
}
try
{
const
=
URI
.
parse
(
)
;
if
(
.
===
'sessions-voice'
)
{
.
setDraftTarget
(
)
;
}
else
{
.
setTargetSession
(
)
;
.
activateSession
(
)
;
}
return
true
;
}
catch
{
return
false
;
}
}
/** Number of strokes in the 12px `voice-mode-compact` codicon. */
const
WAVEFORM_BAR_COUNT
=
4
;
/**
* Height bounds (px) of an audio-reactive waveform bar. These mirror the
* `chat-voice-input-mode-eq` keyframes in `voiceInputMode.css`, which drive the bars
* whenever no analyser is available, so the two must be kept in sync; both are sized
* against the 12px waveform box.
*/
const
WAVEFORM_BAR_MIN_HEIGHT
=
2
;
const
WAVEFORM_BAR_MAX_HEIGHT
=
12
;
/**
* Menu placeholder action for the segmented voice input mode toggle. The actual UI is
* rendered by {@link VoiceInputModeActionViewItem}; running the action is a no-op.
*/
export
class
ChatVoiceInputModeAction
extends
Action2
{
static
readonly
ID
=
'workbench.action.chat.voiceInputMode'
;
constructor
(
)
{
super
(
{
:
.
ID
,
:
localize2
(
'voiceInputMode'
,
"Voice Input Mode"
)
,
:
.
,
:
,
:
{
:
.
,
:
.
and
(
,
.
.
isEqualTo
(
.
)
,
.
.
negate
(
)
,
)
,
:
'navigation'
,
:
-
11
,
}
,
}
)
;
}
run
(
:
)
:
void
{
// No-op — interaction handled by VoiceInputModeActionViewItem.
}
}
/**
* Hold-to-talk (walkie-talkie) keybinding for the segmented voice toggle. While the key
* is held the microphone listens; releasing it ends the turn and sends. Holding also
* interrupts the assistant to barge in. Works the same in hands-free and manual modes and
* never disconnects. Auto-connects on the first hold so a single shortcut starts talking.
*/
export
class
ChatVoiceInputModeToggleListenAction
extends
Action2
{
static
readonly
ID
=
'workbench.action.chat.voiceInputMode.holdToTalk'
;
private
=
false
;
constructor
(
)
{
super
(
{
:
.
ID
,
:
localize2
(
'voiceInputMode.holdToTalk'
,
"Voice Mode: Hold to Talk"
)
,
// A hold-only action cannot be invoked safely from the Command Palette: a
// mouse click produces no key-up (leaving the turn pending) and a keyboard
// invocation creates an immediate empty turn. Keep it keybinding-only.
:
false
,
:
AGENTS_VOICE_ENABLED
,
:
{
:
.
,
:
.
|
.
|
.
,
:
.
and
(
AGENTS_VOICE_ENABLED
,
.
,
)
,
}
,
}
)
;
}
async
run
(
:
)
:
Promise
<
void
>
{
// Ignore key-repeat re-entry while a hold is already in progress.
if
(
this
.
)
{
return
;
}
const
=
.
get
(
)
;
const
=
.
get
(
)
;
// Enforce mutual exclusion: if built-in dictation is recording, cancel it
// before starting voice capture so the two never record simultaneously.
const
=
.
get
(
)
;
if
(
.
!==
.
)
{
.
cancel
(
)
;
}
// Capture the key-hold FIRST (synchronously) — it must be requested before any await.
const
=
.
enableKeybindingHoldMode
(
.
ID
)
;
const
=
getActiveWindow
(
)
;
let
=
false
;
const
=
.
addDisposableListener
(
,
.
.
KEY_UP
,
(
)
=>
{
=
true
;
}
)
;
this
.
=
true
;
try
{
await
retargetVoiceToCurrentSession
(
.
get
(
)
,
)
;
// Auto-connect on the first hold so users can start talking with one shortcut.
if
(
!
.
.
get
(
)
&&
!
.
.
get
(
)
)
{
await
.
connect
(
)
;
}
if
(
)
{
// The shortcut was released while the connection was still being
// established, so the hold already ended. Starting push-to-talk now
// would immediately force an empty turn, so bail out instead.
return
;
}
if
(
.
.
get
(
)
)
{
.
pttDown
(
'explicit'
,
true
)
;
// force clean new turn
if
(
)
{
await
;
// wait for key release
}
else
if
(
!
)
{
await
new
Promise<void>
(
=>
{
const
=
.
addDisposableListener
(
,
.
.
KEY_UP
,
(
)
=>
{
.
dispose
(
)
;
resolve
(
)
;
}
)
;
}
)
;
}
.
pttUp
(
'explicit'
,
true
)
;
// force finish turn and send
}
}
finally
{
.
dispose
(
)
;
this
.
=
false
;
}
}
}
/**
* Dev/preview commands to force the voice-cell visual states without a live backend
* connection. Registered via {@link registerVoiceInputModeSimulateActions}.
*/
const
SIMULATE_STATES
:
{
readonly
:
string
;
readonly
:
string
;
readonly
:
|
undefined
}
[
]
=
[
{
:
'off'
,
:
'Off (Disconnected)'
,
:
'off'
}
,
{
:
'connecting'
,
:
'Connecting'
,
:
'connecting'
}
,
{
:
'idle'
,
:
'Connected (Idle)'
,
:
'idle'
}
,
{
:
'listening'
,
:
'Listening'
,
:
'listening'
}
,
{
:
'speaking'
,
:
'Speaking'
,
:
'speaking'
}
,
{
:
'dictating'
,
:
'Dictating'
,
:
'dictating'
}
,
]
;
export
function
registerVoiceInputModeSimulateActions
(
)
:
void
{
// Prototype walkthroughs — one per push-to-talk design. Each auto-plays (looping)
// through the full lifecycle with accurate bars, colors, hover previews and the real
// input-box glow, so the four interaction models can be compared side by side.
/**
* Optional host hooks for reusing {@link VoiceInputModeActionViewItem} outside the
* main chat input (e.g. the agents-window new-session composer), where dictation and
* voice must target that surface rather than the last focused chat widget.
*/
export
interface
IVoiceInputModePillOptions
{
/** Toggle dictation for the host surface (defaults to the shared toggle command). */
readonly
?
:
(
)
=>
void
;
/** Whether this is the focused or last-focused chat input that owns live state. */
readonly
?
:
<
boolean
>
;
/** Whether the dictation session belongs to this input. Defaults to `isActive`. */
readonly
?
:
<
boolean
>
;
/** Whether the shared Voice Mode transport belongs to this input. */
readonly
?
:
<
boolean
>
;
}
/**
* A single segmented control in the chat input that hosts Dictation and Voice Mode,
* including the connected-session listen or mute control. Only one input mode can be
* active at a time — activating one stops the other.
*/
export
class
VoiceInputModeActionViewItem
extends
BaseActionViewItem
{
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
|
undefined
;
private
:
[
]
=
[
]
;
private
:
number
|
undefined
;
private
=
false
;
private
=
false
;
private
:
|
undefined
;
// Hold-to-talk gesture state for the listen cell: press-and-hold records, release sends.
private
:
number
|
undefined
;
private
=
false
;
private
=
false
;
private
=
false
;
private
readonly
=
this
.
_register
(
new
MutableDisposable
(
)
)
;
// Progress ring shown over the dictation glyph during an actual on-disk
// model download (cache miss), mirroring the standalone toolbar button.
private
readonly
=
this
.
_register
(
new
MutableDisposable<DictationDownloadRing>
(
)
)
;
private
_getLabelWithKeybinding
(
:
string
,
:
string
)
:
string
{
return
this
.
.
appendKeybinding
(
,
)
;
}
private
_updateAriaLabels
(
)
:
void
{
this
.
?.
setAttribute
(
'aria-label'
,
this
.
.
.
contains
(
'preparing'
)
?
localize
(
'voiceInputMode.dictationPreparing'
,
"Preparing Speech to Text Model…"
)
:
this
.
_getLabelWithKeybinding
(
localize
(
'voiceInputMode.dictation'
,
"Dictation"
)
,
DICTATION_TOGGLE_COMMAND_ID
)
)
;
this
.
?.
setAttribute
(
'aria-label'
,
this
.
.
.
contains
(
'connecting'
)
?
localize
(
'voiceInputMode.connecting'
,
"Connecting to Voice Mode…"
)
:
this
.
.
.
contains
(
'on'
)
?
localize
(
'voiceInputMode.disconnect'
,
"Turn Off Voice Mode"
)
:
this
.
_getLabelWithKeybinding
(
localize
(
'voiceInputMode.voice'
,
"Voice Mode"
)
,
VOICE_START_COMMAND_ID
)
)
;
this
.
?.
setAttribute
(
'aria-label'
,
this
.
.
.
contains
(
'active'
)
?
this
.
_getLabelWithKeybinding
(
localize
(
'voiceInputMode.stopListening'
,
"Stop Listening"
)
,
.
ID
)
:
this
.
_getLabelWithKeybinding
(
localize
(
'voiceInputMode.startListening'
,
"Start Listening"
)
,
.
ID
)
)
;
this
.
?.
setAttribute
(
'aria-label'
,
this
.
.
.
contains
(
'active'
)
?
localize
(
'voiceInputMode.unmuteMicrophone'
,
"Unmute Microphone"
)
:
localize
(
'voiceInputMode.muteMicrophone'
,
"Mute Microphone"
)
)
;
}
constructor
(
:
,
private
readonly
:
|
undefined
,
@IVoiceInputModeService
private
readonly
:
,
@IVoiceSessionController
private
readonly
:
,
@ICommandService
private
readonly
:
,
@IConfigurationService
private
readonly
:
,
@IKeybindingService
private
readonly
:
,
@IContextMenuService
private
readonly
:
,
@IHoverService
private
readonly
:
,
@IMicCaptureService
private
readonly
:
,
@ITtsPlaybackService
private
readonly
:
,
@IChatSpeechToTextService
private
readonly
:
,
@IAccessibilityService
private
readonly
:
,
@IThemeService
private
readonly
:
,
)
{
super
(
undefined
,
)
;
}
/** Set the per-state pill/waveform colors from the theme-derived voice accent. */
private
_updateVoiceStateColors
(
:
)
:
void
{
const
=
resolveVoiceGlowColors
(
this
.
.
getColorTheme
(
)
)
;
.
.
setProperty
(
'--voice-color-listening'
,
.
.
toString
(
)
)
;
.
.
setProperty
(
'--voice-color-speaking'
,
.
.
toString
(
)
)
;
}
render
(
:
)
:
void
{
super
.
render
(
)
;
.
.
add
(
'monaco-segmented-icon-toggle-container'
,
'chat-voice-input-mode-item'
)
;
// Drive the pill + waveform colors from the same theme-derived accent as the
// input-box glow, so all three always match and adapt to the active theme.
this
.
_updateVoiceStateColors
(
)
;
this
.
_register
(
this
.
.
onDidColorThemeChange
(
(
)
=>
this
.
_updateVoiceStateColors
(
)
)
)
;
// A masked 2-slot viewport ("slot machine reel"). The reel holds four cells:
// Audio-reactive bars only while live (and not hovering the disconnect preview).
this
.
_syncBarAnimation
(
)
;
}
)
)
;
this
.
_register
(
{
dispose
:
(
)
=>
this
.
_stopBarAnimation
(
)
}
)
;
// Re-sync if the reduced-motion preference changes while the voice cell is live.
this
.
_register
(
this
.
.
onDidChangeReducedMotion
(
(
)
=>
{
this
.
_stopBarAnimation
(
)
;
this
.
_syncBarAnimation
(
)
;
}
)
)
;
}
/** Start or stop the audio-reactive bar loop based on live + hover state. */
private
_syncBarAnimation
(
)
:
void
{
if
(
this
.
&&
!
this
.
)
{
this
.
_startBarAnimation
(
)
;
}
else
{
this
.
_stopBarAnimation
(
)
;
}
}
/**
* Animate the waveform bars from live audio. Uses the mic analyser while listening
* and the TTS analyser while the assistant speaks. When no analyser is available
* (e.g. reduced motion or pre-capture), the CSS keyframe fallback drives the bars.
*/
private
_startBarAnimation
(
)
:
void
{
if
(
this
.
!==
undefined
)
{
return
;
}
// Respect reduced-motion: skip both the rAF audio-reactive loop and the CSS
// keyframe fallback, leaving the compact codicon silhouette at rest.
if
(
this
.
.
isMotionReduced
(
)
)
{
for
(
const
of
this
.
)
{
.
.
=
'none'
;
.
.
removeProperty
(
'height'
)
;
}
return
;
}
const
=
getWindow
(
this
.
)
;
const
tick
=
(
)
=>
{
this
.
=
.
requestAnimationFrame
(
)
;
// Read the live state each frame so listening<->speaking picks the right analyser.
const
=
this
.
.
.
get
(
)
===
'speaking'
?
this
.
.
:
this
.
.
;
if
(
!
)
{
// Let the CSS keyframe animation take over.
for
(
const
of
this
.
)
{
.
.
removeProperty
(
'height'
)
;
.
.
removeProperty
(
'animation'
)
;
}
return
;
}
if
(
!
this
.
||
this
.
.
!==
.
)
{
this
.
=
new
Uint8Array
(
.
)
;
}
.
getByteFrequencyData
(
this
.
as
<
>
)
;
const
=
this
.
.
;
const
=
.
max
(
1
,
.
floor
(
/
this
.
.
)
)
;
for
(
let
=
0
;
<
this
.
.
;
++
)
{
let
=
0
;
for
(
let
=
0
;
<
;
++
)
{
+=
this
.
[
.
min
(
-
1
,
*
+
)
]
;
}
const
=
.
min
(
1
,
(
/
)
/
180
)
;
const
=
WAVEFORM_BAR_MIN_HEIGHT
+
*
(
WAVEFORM_BAR_MAX_HEIGHT
-
WAVEFORM_BAR_MIN_HEIGHT
)
;
// Disable the CSS keyframe fallback while we drive heights from live audio.
this
.
[
]
.
.
=
'none'
;
this
.
[
]
.
.
=
`${heightPx}px`
;
}
}
;
this
.
=
.
requestAnimationFrame
(
)
;
}
private
_stopBarAnimation
(
)
:
void
{
if
(
this
.
!==
undefined
&&
this
.
)
{
getWindow
(
this
.
)
.
cancelAnimationFrame
(
this
.
)
;
}
this
.
=
undefined
;
for
(
const
of
this
.
)
{
.
.
removeProperty
(
'height'
)
;
.
.
removeProperty
(
'animation'
)
;
}
}
/**
* Toggle built-in on-device dictation. By default this runs the shared
* {@link DICTATION_TOGGLE_COMMAND_ID} command (which targets the last focused
* chat widget); a host that isn't an `IChatWidget` (e.g. the agents-window
* composer) can inject its own toggle via {@link IVoiceInputModePillOptions}.
*/
private
_toggleDictation
(
)
:
void
{
if
(
this
.
?.
)
{
this
.
.
toggleDictation
(
)
;
}
else
{
this
.
.
executeCommand
(
DICTATION_TOGGLE_COMMAND_ID
)
;
}
}
/**
* Activate a segmented cell from the keyboard. The cells live inside a toolbar's
* `ActionBar`, whose key handler runs the (no-op) placeholder action on Enter/Space
* and calls `preventDefault`/`stopPropagation`, which would otherwise swallow the
* native button activation. Handle Enter/Space here and stop the event before it
* bubbles to the ActionBar so the focused cell's own gesture runs.
*/
private
_registerActivationKeys
(
:
,
handler
:
(
)
=>
void
)
:
void
{
this
.
_register
(
.
addStandardDisposableListener
(
,
.
.
KEY_DOWN
,
=>
{
if
(
.
equals
(
.
)
||
.
equals
(
.
)
)
{
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
}
}
)
)
;
this
.
_register
(
.
addStandardDisposableListener
(
,
.
.
KEY_UP
,
=>
{
if
(
.
equals
(
.
)
||
.
equals
(
.
)
)
{
.
preventDefault
(
)
;
.
stopPropagation
(
)
;
handler
(
)
;
}
}
)
)
;
}
private
_onClickDictation
(
)
:
void
{
this
.
.
setSelectedMode
(
'dictation'
)
;
// Mutual exclusion: stop live Voice Mode before starting dictation.
if
(
this
.
.
.
get
(
)
||
this
.
.
.
get
(
)
)
{
this
.
.
disconnect
(
)
;
}
this
.
_toggleDictation
(
)
;
}
/** The voice button connects or disconnects; hands-free mode starts listening after connect. */
private
async
_onClickVoicePowerToggle
(
)
:
Promise
<
void
>
{
this
.
.
setSelectedMode
(
'voice'
)
;
// Mutual exclusion: stop dictation before entering Voice Mode.
if
(
this
.
.
!==
.
)
{
this
.
_toggleDictation
(
)
;
}
const
=
this
.
;
const
=
getWindow
(
this
.
)
;
if
(
.
.
get
(
)
||
.
.
get
(
)
)
{
if
(
this
.
?.
?.
get
(
)
===
false
)
{
await
retargetVoiceToCurrentSession
(
this
.
,
)
;
return
;
}
.
disconnect
(
)
;
}
else
{
await
retargetVoiceToCurrentSession
(
this
.
,
)
;
.
connect
(
)
.
catch
(
(
)
=>
{
/* connect failures are surfaced/logged by the controller */
}
)
;
}
}
/** Tap the listen cell to toggle listening on and off. */
private
_onClickListen
(
)
:
void
{
const
=
this
.
;
if
(
!
.
.
get
(
)
)
{
return
;
}
if
(
.
.
get
(
)
===
'listening'
)
{
.
stopListening
(
)
;
}
else
{
.
pttDown
(
)
;
.
pttUp
(
)
;
}
}
private
_onClickMute
(
)
:
void
{
const
=
this
.
;
if
(
.
.
get
(
)
)
{
.
setMuted
(
!
.
.
get
(
)
)
;
}
}
/** Threshold (ms) separating a quick tap (toggle) from a press-and-hold (talk). */
private
static
readonly
HOLD_THRESHOLD_MS
=
180
;
private
_onListenPointerDown
(
)
:
void
{
const
=
this
.
;
// Hold-to-talk only applies to a connected, non-listening session; otherwise let
// the trailing click drive the plain toggle.
if
(
!
.
.
get
(
)
||
.
.
get
(
)
===
'listening'
)
{
return
;
}
this
.
=
true
;
this
.
=
false
;
// Fresh gesture: clear any suppression left over from a prior hold whose release
// landed off-button (and therefore produced no trailing click to consume it).
this
.
=
false
;
const
=
getWindow
(
this
.
)
;
// Start listening only after the hold threshold, so a quick tap (toggle) does not
// briefly flash the listening state.
this
.
=
.
setTimeout
(
(
)
=>
{
this
.
=
undefined
;
if
(
.
.
get
(
)
)
{
this
.
=
true
;
.
pttDown
(
'explicit'
,
true
)
;
}
}
,
.
HOLD_THRESHOLD_MS
)
;
// End the gesture on release anywhere (in case the pointer leaves the button).
// Generic pointer-aware listener so an iOS pointer hold also finishes and sends.
this
.
.
=
.
addDisposableGenericMouseUpListener
(
,
(
:
)
=>
this
.
_endListenPointerHold
(
)
)
;
}
private
_endListenPointerHold
(
?
:
)
:
void
{
if
(
!
this
.
)
{
return
;
}
this
.
=
false
;
this
.
.
clear
(
)
;
if
(
this
.
!==
undefined
)
{
// Released before the threshold → a tap; let the trailing click toggle listening.
getWindow
(
this
.
)
.
clearTimeout
(
this
.
)
;
this
.
=
undefined
;
this
.
=
false
;
}
else
if
(
this
.
)
{
// Held past the threshold → end the turn and send. A trailing `click` only fires
// when the release lands on the button, so only arm suppression in that case —
// otherwise a stale flag would swallow the next (e.g. keyboard) activation.
this
.
=
false
;
const
=
!
!
?.
&&
this
.
!
.
contains
(
.
as
)
;
this
.
=
;
this
.
.
pttUp
(
'explicit'
,
true
)
;
}
}
dispose
(
)
:
void
{
// If disposed mid-hold (widget closed/rerendered), finalize the gesture so the
// controller does not keep recording until its max-duration timeout.