Это 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.
*--------------------------------------------------------------------------------------------*/// Immutable state types for the sessions process protocol.// See protocol.md for the full design rationale.//// Most types are imported from the auto-generated protocol layer// (synced from the agent-host-protocol repo). This file adds VS Code-specific// helpers and re-exports.import{ distinct }from'../../../../base/common/arrays.js';import{ decodeBase64, encodeBase64, VSBuffer }from'../../../../base/common/buffer.js';import{ hasKey,typeMutable}from'../../../../base/common/types.js';import{URIas ResourceURI }from'../../../../base/common/uri.js';importtype{ IProductService }from'../../../product/common/productService.js'
readToolCallMeta
readLegacyTurnError
ResponsePartKind
SessionStatus
ToolCallStatus
TurnState
SessionLifecycle
TerminalState
ToolResultContentType
ToolResultFileEditContent
ChatOriginKind
ChatInteractivity
ProtocolURI
ChangesetOperationScope ChangesetOperationStatus ChangesetStatus CustomizationLoadStatus
CustomizationType MessageAttachmentKind MessageKind
PendingMessageKind
PolicyState
ResponsePartKind
ChatInteractivity
ChatOriginKind
SessionLifecycle
SessionStatus ToolCallCancellationReason ToolCallConfirmationReason ToolCallContributorKind ToolCallRiskAssessmentKind ToolCallRiskAssessmentStatus ToolCallStatus
ToolResultContentType
TurnState
ISessionFileDiff IToolResultBinaryContent
turn Turn ActiveTurn ErrorResponsePart
turn
part turnresponseParts
partkind ResponsePartKindError part
error ErrorInfo resumable ErrorResponsePart
kind ResponsePartKindError
error
resumable resumable
previous UsageInfo current UsageInfo UsageInfo
previous
current
current
previous
previousMeta previous
currentMeta current
cost previousMetacost currentMetacost
totalNanoAiu previousMetacopilotUsagetotalNanoAiu currentMetacopilotUsagetotalNanoAiu
turnTokenTotals previousMetaturnTokenTotals currentMetaturnTokenTotals
directTotalNanoAiu previousMetadirectCopilotUsagetotalNanoAiu currentMetadirectCopilotUsagetotalNanoAiu
directTurnTokenTotals previousMetadirectTurnTokenTotals currentMetadirectTurnTokenTotals
meta previous_meta current_meta
previous_meta
current_meta
cost cost
previousMetacopilotUsage currentMetacopilotUsage
copilotUsage
previousMetacopilotUsage
currentMetacopilotUsage
totalNanoAiu totalNanoAiu
turnTokenTotals turnTokenTotals
directTotalNanoAiu directCopilotUsage totalNanoAiu directTotalNanoAiu
directTurnTokenTotals directTurnTokenTotals
previous
current
model currentmodel previousmodel
meta _meta meta
first second
first second second first first second
previous UsageInfoMeta current UsageInfoMeta UsageInfoMeta
previous current
totals
total previous current
existing totalstotalmodel
totalstotalmodel existing
model totalmodel
inputTokens existinginputTokens totalinputTokens
cachedTokens existingcachedTokens totalcachedTokens
outputTokens existingoutputTokens totaloutputTokens
total
totals
cost
autoModeResolved IAutoModeResolvedInfo
copilotUsage
totalNanoAiu
sessionTotalNanoAiu
key
quotaSnapshots
quotaType
isUnlimitedEntitlement
entitlementRequests
usedRequests
remainingPercentage
overage
overageAllowedWithExhaustedQuota
resetDate
tokenBasedBilling
overageEntitlement
contextAttribution IContextAttributionData
turnTokenTotals ITurnTokenTotal
directTurnTokenTotals ITurnTokenTotal
directCopilotUsage
totalNanoAiu
key
uri
uri
ResourceURIurischeme
uri
ResourceURIurischeme
message Message hiddenFromTranscript
meta message_meta
hiddenFromTranscript meta
message Message
messagehiddenFromTranscript
messagetext
message Message hidden Message
hidden
message
message
text messagetext messagetext messagetext
_meta
message_meta
model
inputTokens
cachedTokens
outputTokens
chosenModel
reasoningBucket
categoryScores ReadonlyRecord
predictedLabel
confidence
candidateModels
totalTokens
entries IContextAttributionEntry
compactions count
kind
id
label
tokens
parentId
attributes ReadonlyRecord
NonNullableNonNullableUsageInfoMeta
value AccountQuotaSnapshot
value value value
raw value Record
snapshot MutableAccountQuotaSnapshot
raw snapshotisUnlimitedEntitlement raw
raw snapshotentitlementRequests raw
raw snapshotusedRequests raw
raw snapshotremainingPercentage raw
raw snapshotoverage raw
raw snapshotoverageAllowedWithExhaustedQuota raw
raw snapshotresetDate raw
raw snapshottokenBasedBilling raw
raw snapshotoverageEntitlement raw
snapshot
usage UsageInfo UsageInfoMeta
meta usage_meta
meta
result MutableUsageInfoMeta
meta resultcost meta
autoModeResolved meta
autoModeResolved resultautoModeResolved autoModeResolved
copilotUsage meta
copilotUsage copilotUsage copilotUsage
rawUsage copilotUsage Record
usage MutableNonNullableUsageInfoMeta
rawUsage usagetotalNanoAiu rawUsage
rawUsage usagesessionTotalNanoAiu rawUsage
resultcopilotUsage usage
quotaSnapshots meta
quotaSnapshots quotaSnapshots quotaSnapshots
snapshots MutableNonNullableUsageInfoMeta
quotaType value ObjectquotaSnapshots Record
snapshotsquotaType value
resultquotaSnapshots snapshots
contextAttribution meta
contextAttribution
resultcontextAttribution contextAttribution
turnTokenTotals meta
turnTokenTotals
resultturnTokenTotals turnTokenTotals
directTurnTokenTotals meta
directTurnTokenTotals
resultdirectTurnTokenTotals directTurnTokenTotals
directCopilotUsage meta
directCopilotUsage directCopilotUsage directCopilotUsage
totalNanoAiu directCopilotUsage Record
totalNanoAiu
resultdirectCopilotUsage totalNanoAiu
result
value ITurnTokenTotal
value
totals ITurnTokenTotal
item value
item item item
raw item Record
raw raw
raw
raw
raw
totals
model raw
inputTokens raw
cachedTokens raw
outputTokens raw
totalslength totals
value value
value Numbervalue value
usage UsageInfo
usage
usageinputTokens usageoutputTokens
meta usage
metacopilotUsagetotalNanoAiu metacopilotUsagetotalNanoAiu
metacopilotUsagesessionTotalNanoAiu metacopilotUsagesessionTotalNanoAiu
metacost metacost
value IAutoModeResolvedInfo
value value value
raw value Record
raw
result MutableIAutoModeResolvedInfo chosenModel raw
reasoningBucket raw
reasoningBucket reasoningBucket reasoningBucket
resultreasoningBucket reasoningBucket
categoryScores raw
categoryScores categoryScores categoryScores
scores Record
category score ObjectcategoryScores Record
score
scorescategory score
resultcategoryScores scores
raw resultpredictedLabel raw
raw resultconfidence raw
raw rawcandidate candidate
resultcandidateModels raw
result
value IContextAttributionData
value value value
raw value Record
raw raw
entries IContextAttributionEntry
item raw
item item item
entry item Record
entry entry
entry entry
entries
kind entry
id entry
label entry
tokens entry
parentId entry entry
attributes entry entry entry
entry Record
compactionsRaw raw
compactions compactionsRaw compactionsRaw compactionsRaw
compactionsRaw Record
count compactionsRaw Record
count
totalTokens raw entries compactions
raw Record Record
result Record
key value Objectraw
value value
resultkey value
result
ChangesetOperationTargetKind
ChatInputAnswerState
ChatInputAnswerValueKind
ChatInputQuestionKind
ChatInputResponseKind
FileEditKind
Edit
Create
Delete
Rename
descriptor
root
recursive
excludes items
includes items
payload Record root descriptorroot
descriptorrecursive payloadrecursive
descriptorexcludes descriptorexcludesitemslength
payloadexcludes descriptorexcludesitems
descriptorincludes descriptorincludesitemslength
payloadincludes descriptorincludesitems
json VSBufferpayload
uri
root
recursive
excludes items
includes items
parsed ResourceURI
parsed ResourceURIuri
parsedscheme
encoded parsedpath
encoded
payload encoded root recursive excludes includes
payloadroot
root payloadroot
recursive payloadrecursive
payloadexcludes excludes items payloadexcludesx x x
payloadincludes includes items payloadincludesx x x
uri
ResourceURIurischeme
uri
uri
ResourceURIurischeme
uri range TextRange
range
uri
safeUri uri
ToolCallCompletedState ToolCallCancelledState
ToolCallState
result ToolCallResult
resultcontent resultcontentlength
textParts ToolResultTextContent
c resultcontent
c type ctype ToolResultContentTypeText
textPartsc
textPartslength
textPartsp ptext
toolInput ToolInput
toolInput toolInput
result ToolCallResult ToolResultFileEditContent
resultcontent resultcontentlength
edits ToolResultFileEditContent
c resultcontent
c type ctype ToolResultContentTypeFileEdit
editsc
edits
result content ToolResultContent ToolResultSubagentContent
resultcontent resultcontentlength
c resultcontent
c type ctype ToolResultContentTypeSubagent
c ToolResultSubagentContent
uri ProtocolURI ResourceURI ResourceURI
uri ResourceURIuri uri
parentSession ProtocolURI ResourceURI parent ResourceURI path
parent parentSession
parentPath parentpath parentpath parentpath
parent path
parentSession ProtocolURI ResourceURI toolCallId
parent path parentSession
parent path
uri ProtocolURI ResourceURI parentSession ResourceURI toolCallId
resource uri
match resourcepath
matchgroups
parentSession resource path matchgroupsparentPath
toolCallId matchgroupstoolCallId
uri ProtocolURI ResourceURI
uri
parentSession ProtocolURI ResourceURI
parent path parentSession
parent path
RootState
agents
activeSessions
summary SessionSummary SessionState
state SessionState
provider summaryprovider
title summarytitle
status summarystatus
lifecycle SessionLifecycleCreating
activeClients
chats
defaultChat
summaryactivity stateactivity summaryactivity
summaryproject stateproject summaryproject
summaryworkingDirectories stateworkingDirectories summaryworkingDirectories
summaryannotations stateannotations summaryannotations
summary_meta state_meta summary_meta
state
summary ChatSummary ChatState
resource summaryresource
title summarytitle
status summarystatus
activity summaryactivity
modifiedAt summarymodifiedAt
origin summaryorigin
interactivity summaryinteractivity
workingDirectories summaryworkingDirectories
turns
activeTurn
session SessionSummary chatUri ProtocolURI ChatSummary
summary ChatSummary
resource chatUri
title sessiontitle
status sessionstatus
modifiedAt sessionmodifiedAt
origin kind ChatOriginKindUser
sessionactivity summaryactivity sessionactivity
summary
state ChatState
stateactiveTurnresponsePartspart
partkind ResponsePartKindToolCall
parttoolCallstatus ToolCallStatusPendingConfirmation
parttoolCallautoApproveBySetting
state ChatState
stateactiveTurnresponsePartspart
partkind ResponsePartKindInputRequest
partresponse
partkind ResponsePartKindToolCall
status parttoolCallstatus
status ToolCallStatusPendingResultConfirmation status ToolCallStatusAuthRequired
status ToolCallStatusPendingConfirmation
parttoolCallautoApproveBySetting
state ChatState SessionStatus
status statestatus
status SessionStatusInputNeeded SessionStatusInputNeeded
status
state state
status SessionStatusInProgress
status
state ChatState ChatSummary
summary ChatSummary
resource stateresource
title statetitle
status state
modifiedAt statemodifiedAt
stateactivity summaryactivity stateactivity
stateorigin summaryorigin stateorigin
stateinteractivity summaryinteractivity stateinteractivity
stateworkingDirectories summaryworkingDirectories stateworkingDirectories
summary
interactivity ChatInteractivity sessionArchived ChatInteractivity
interactivity ChatInteractivityHidden
ChatInteractivityHidden
sessionArchived
ChatInteractivityReadOnly
interactivity ChatInteractivityFull
interactivity ChatInteractivity sessionArchived
interactivity sessionArchived ChatInteractivityReadOnly
id message Message startedAt ActiveTurn
id
startedAt
message
responseParts
usage
turn Turn ErrorInfo
turnstate TurnStateError
part turnresponsePartsturnresponsePartslength
partkind ResponsePartKindError parterror turn
StateComponents
Root
Session
Chat
Terminal
Changeset
Annotations
AutomationCatalog
AutomationRun
StateComponentsRoot RootState
StateComponentsSession SessionState
StateComponentsChat ChatState
StateComponentsTerminal TerminalState
StateComponentsChangeset ChangesetState
StateComponentsAnnotations AnnotationsState
StateComponentsAutomationCatalog AutomationState
StateComponentsAutomationRun AutomationRunState
sessionUri ProtocolURI ResourceURI chatId
session sessionUri sessionUri sessionUri
encoded VSBuffersession
sessionUri ProtocolURI ResourceURI
sessionUri
uri ProtocolURI ResourceURI
parsed uri ResourceURIuri uri
parsedscheme parsedauthority
sessionUri ProtocolURI ResourceURI toolCallId
session sessionUri sessionUri sessionUri
encoded VSBuffersession
uri ProtocolURI ResourceURI session chatId
parsed ResourceURI
parsed uri ResourceURIuri uri
parsedscheme parsedauthority
encoded parsedpath
encoded
parsedauthority
sessionPart toolCallIdParts encoded
toolCallId toolCallIdParts
sessionPart toolCallId
session sessionPart chatId
session encoded chatId parsedauthority
uri ProtocolURI ResourceURI
urisession
uri ProtocolURI ResourceURI
session uri
session
session
uri ProtocolURI ResourceURI
urichatId
state PickSessionState chats PickChatSummary chatId ProtocolURI
chatId
statedefaultChat statechatschat chatresourceresource
statechatschat chatresourcechatId chatIdresource
session ResourceURI chat ResourceURI ResourceURI
chat session chat
chatChannel ProtocolURI ResourceURI ResourceURI
parsed chatChannel
parsed
ResourceURIparsedsession ResourceURIchatChannel
uri
ResourceURIurischeme
turns Turn
activeTurn ActiveTurn
steeringMessage PendingMessage
queuedMessages PendingMessage
draft Message
session SessionState chat ChatState ISessionWithDefaultChat
session
workingDirectories chatworkingDirectories sessionworkingDirectories
turns chatturns
activeTurn chatactiveTurn
steeringMessage chatsteeringMessage
queuedMessages chatqueuedMessages
draft chatdraft
chat ChatState ActiveTurn
chatactiveTurn
session SessionState ChatSummary
sessiondefaultChat
match sessionchatsc cresource sessiondefaultChat
match
match
sessionchats
Record
Record
workspaceFile
meta SessionMeta ISessionMultiRootMetadata
meta
value ISessionMultiRootMetadata
value
value
meta SessionMeta multiRoot ISessionMultiRootMetadata SessionMeta
next SessionMeta meta
multiRoot
next multiRoot
next
Objectnextlength next
value ISessionMultiRootMetadata
value value value
raw value Record
rawworkspaceFile rawworkspaceFilelength rawworkspaceFilelength
ResourceURIrawworkspaceFile scheme
workspaceFile rawworkspaceFile
modelId
cacheExpiresAt
meta SessionMeta ISessionPromptCacheState
value meta
value value value
raw value Record
raw raw
modelId raw cacheExpiresAt raw
meta SessionMeta promptCache ISessionPromptCacheState SessionMeta
next SessionMeta meta
promptCache
next promptCache
next
Objectnextlength next
hidden
primary
meta SessionMeta ISessionFolderPickerDecision
meta
value ISessionFolderPickerDecision
value
value
value ISessionFolderPickerDecision
value value value
raw value Record
raw
primary raw
primary primary primarylength raw
primary hidden primary hidden raw
meta SessionMeta decision ISessionFolderPickerDecision SessionMeta
next SessionMeta meta
decision
next decisionprimary
hidden decisionhidden primary decisionprimary
hidden decisionhidden
next
Objectnextlength next
hasGitHubRemote
branchName
isDetachedHead
baseBranchName
upstreamBranchName
incomingChanges
outgoingChanges
uncommittedChanges
hasBaseBranchChanges
githubOwner
githubHeadOwner
githubRepo
SessionSourceControlOutcome
Merge
PullRequest
merge
commit
latestOutcome SessionSourceControlOutcome
meta SessionMeta ISessionSourceControlState
value meta
value value value
raw value Record
merge ISessionSourceControlState
rawMerge raw
rawMerge rawMerge rawMerge
commit rawMerge Record
merge commit commitlength commit
rawLatestOutcome raw
latestOutcome rawLatestOutcome SessionSourceControlOutcomeMerge rawLatestOutcome SessionSourceControlOutcomePullRequest
rawLatestOutcome
merge latestOutcome latestOutcome SessionSourceControlOutcomeMerge
merge latestOutcome
meta SessionMeta state ISessionSourceControlState SessionMeta
next SessionMeta meta
state
next state
next
Objectnextlength next
owner
repo
pullRequestUrls
initialPullRequestUrls
associatedPullRequestUrls
pullRequestBranchName
gitHubState ISessionGitHubState branchName
gitHubStatepullRequestUrlslength
gitHubStatepullRequestBranchName gitHubStatepullRequestBranchName branchName
gitHubState ISessionGitHubState
pullRequestUrls gitHubStatepullRequestUrls
initialPullRequestUrls gitHubStateinitialPullRequestUrls
initialUrls initialPullRequestUrlsurl url
associatedUrls gitHubStateassociatedPullRequestUrlsurl url
pullRequestUrlsurl initialUrlsurl associatedUrlsurl
urls
normalizedUrls urlsurl
match url
groups matchgroups
groups
url
normalizedUrls url url
gitHubState ISessionGitHubState pullRequestUrl branchName ISessionGitHubState
pullRequestUrls
pullRequestUrl
gitHubStatepullRequestUrls
pullRequestUrls
pullRequestBranchName branchName
gitHubState ISessionGitHubState pullRequestUrl branchName ISessionGitHubState
next gitHubState pullRequestUrl branchName
promotedUrl pullRequestUrl
initialPullRequestUrls gitHubStateinitialPullRequestUrls
associatedPullRequestUrls
pullRequestUrl
gitHubStateassociatedPullRequestUrls
next
associatedPullRequestUrls
initialPullRequestUrls
initialPullRequestUrls initialPullRequestUrlsurl url promotedUrl
gitHubState ISessionGitHubState pullRequestUrl ISessionGitHubState
initialPullRequestUrls
pullRequestUrl pullRequestUrl
gitHubStateinitialPullRequestUrls
meta SessionMeta ISessionGitState
value meta
value value value
raw value Record
result
hasGitHubRemote
branchName
isDetachedHead
baseBranchName
upstreamBranchName
incomingChanges
outgoingChanges
uncommittedChanges
hasBaseBranchChanges
githubOwner
githubHeadOwner
githubRepo
raw resulthasGitHubRemote raw
raw resultbranchName raw
raw resultisDetachedHead raw
raw resultbaseBranchName raw
raw resultupstreamBranchName raw
raw resultincomingChanges raw
raw resultoutgoingChanges raw
raw resultuncommittedChanges raw
raw resulthasBaseBranchChanges raw
raw resultgithubOwner raw
raw resultgithubHeadOwner raw
raw resultgithubRepo raw
result
gitState ISessionGitState
gitState gitStatebranchName gitStateisDetachedHead
meta SessionMeta gitState ISessionGitState SessionMeta
next key meta
gitState
next gitState
next
Objectnextlength next
meta SessionSummaryMeta ISessionGitHubState
value meta
value value value
raw value Record
result
owner
repo
pullRequestUrls
initialPullRequestUrls
associatedPullRequestUrls
pullRequestBranchName
raw resultowner raw
raw resultrepo raw
pullRequestUrls raw
rawurl url url
raw
raw
pullRequestUrlslength
resultpullRequestUrls pullRequestUrls
raw
resultinitialPullRequestUrls rawurl url url
raw
associatedPullRequestUrls rawurl url url
associatedPullRequestUrlslength
resultassociatedPullRequestUrls associatedPullRequestUrls
raw resultpullRequestBranchName raw
result
meta SessionSummaryMeta gitHubState ISessionGitHubState SessionSummaryMeta
next key meta
gitHubState
next gitHubState
next
Objectnextlength next
meta SessionSummaryMeta
value meta
value Numbervalue value
meta SessionSummaryMeta depth SessionSummaryMeta
meta depth
session
chat
turnId
meta SessionSummaryMeta ISessionCreationReference
meta
value ISessionCreationReference
value value
candidate value key
candidatesession
session candidatesession
candidatechat chat candidatechat
candidateturnId turnId candidateturnId
value ISessionCreationReference
value
value
meta SessionSummaryMeta creationReference ISessionCreationReference SessionSummaryMeta
meta creationReference
status SessionStatus flag SessionStatus set SessionStatus
set status flag status flag
status SessionStatus
status status SessionStatusIsRead
status SessionStatus
status status SessionStatusIsArchived
meta SessionSummaryMeta
meta
meta SessionSummaryMeta workspaceless SessionSummaryMeta
next key meta
workspaceless
next
next
Objectnextlength next
meta SessionSummaryMeta
meta
meta SessionSummaryMeta external SessionSummaryMeta
next key meta
external
next
next
Objectnextlength next
meta SessionSummaryMeta
meta
meta SessionSummaryMeta SessionSummaryMeta
meta
meta SessionSummaryMeta
meta
meta SessionSummaryMeta adopted SessionSummaryMeta
next key meta
adopted
next
next
Objectnextlength next
meta SessionSummaryMeta
meta meta
Record
version
commit
date
quality
productService IProductService IHostBuildInfo
version productServiceversion
commit productServicecommit
date productServicedate
quality productServicequality
state RootState IHostBuildInfo
meta state_meta
value meta
value value value
raw value Record
raw
result version commit date quality
version raw
raw resultcommit raw
raw resultdate raw
raw resultquality raw
result
meta RootMeta buildInfo IHostBuildInfo RootMeta
next key meta
buildInfo
next buildInfo
next
Objectnextlength next
info IHostBuildInfo
details
infocommit details
infodate detailsinfodate
infoquality detailsinfoquality
detailslength infoversion
// Re-export everything from the protocol state module
export
{
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
type
ActiveTurn
,
type
AgentCustomization
,
type
AgentCapabilities
,
type
AgentInfo
,
type
AgentSelection
,
type
Annotation
,
type
AnnotationEntry
,
type
AnnotationOrigin
,
type
AnnotationsState
,
type
AnnotationsSummary
,
type
Changeset
,
type
ChangesetFile
,
type
ChangesetOperation
,
type
ChangesetState
,
type
ChatState
,
type
ChatSummary
,
type
ChatOrigin
,
type
ChildCustomization
,
type
ClientPluginCustomization
,
type
ConfigPropertySchema
,
type
ConfigSchema
,
type
ContentRef
,
type
Customization
,
type
CustomizationDegradedState
,
type
CustomizationErrorState
,
type
CustomizationLoadedState
,
type
CustomizationLoadingState
,
type
CustomizationLoadState
,
type
DirectoryCustomization
,
type
ErrorInfo
,
type
HookCustomization
,
type
FileEdit
as
,
type
ToolResultEmbeddedResourceContent
as
,
type
MarkdownResponsePart
,
type
McpServerCustomization
,
type
MessageAttachment
,
type
MessageResourceAttachment
,
type
MessageEmbeddedResourceAttachment
,
type
MessageAnnotationsAttachment
,
type
MessageChatAttachment
,
type
ModelSelection
,
type
PendingMessage
,
type
PluginCustomization
,
type
ProjectInfo
,
type
PromptCustomization
,
type
ReasoningResponsePart
,
type
ErrorResponsePart
,
type
ResponsePart
,
type
RootState
,
type
RuleCustomization
,
type
SessionActiveClient
,
type
AutomationState
,
type
AutomationRunState
,
type
SessionConfigState
,
type
SessionModelInfo
,
type
SessionState
,
type
SessionSummary
,
type
SkillCustomization
,
type
Snapshot
,
type
StringOrMarkdown
,
type
TerminalState
,
type
TextRange
,
type
ToolAnnotations
,
type
ToolCallCancelledState
,
type
ToolCallCompletedState
,
type
ToolCallPendingConfirmationState
,
type
ToolCallPendingResultConfirmationState
,
type
ToolCallResponsePart
,
type
ToolCallResult
,
type
ToolCallRiskAssessment
,
type
ToolCallRiskAssessmentCompleteState
,
type
ToolCallRiskAssessmentLoadingState
,
type
ToolCallRunningState
,
type
ToolCallState
,
type
ToolCallStreamingState
,
type
ToolCallContributor
,
type
ToolDefinition
,
type
ToolInput
,
type
ToolResultContent
,
type
ToolResultFileEditContent
,
type
TerminalCommandResult
,
type
ToolResultSubagentContent
,
type
ToolResultTerminalContent
,
type
ToolResultTextContent
,
type
Turn
,
type
URI
,
type
UsageInfo
,
type
Message
}
from
'./protocol/state.js'
;
export
function
getErrorResponsePart
(
:
|
|
undefined
)
:
|
undefined
{
if
(
!
)
{
return
undefined
;
}
const
=
.
.
at
(
-
1
)
;
return
?.
===
.
?
:
undefined
;
}
export
function
createErrorResponsePart
(
:
,
=
false
)
:
{
return
{
:
.
,
,
...
(
?
{
:
true
}
:
{
}
)
,
}
;
}
export
function
mergeLogicalTurnUsage
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
if
(
!
)
{
return
;
}
if
(
!
)
{
return
;
}
const
=
readUsageInfoMeta
(
)
;
const
=
readUsageInfoMeta
(
)
;
const
=
sumDefined
(
.
,
.
)
;
const
=
sumDefined
(
.
?.
,
.
?.
)
;
const
=
mergeTurnTokenTotals
(
.
,
.
)
;
const
=
sumDefined
(
.
?.
,
.
?.
)
;
const
=
mergeTurnTokenTotals
(
.
,
.
)
;
const
=
.
!==
undefined
||
.
!==
undefined
?
{
...
.
,
...
.
,
...
(
!==
undefined
?
{
}
:
{
}
)
,
...
(
.
||
.
?
{
:
{
...
.
,
...
.
,
...
(
!==
undefined
?
{
}
:
{
}
)
,
}
,
}
:
{
}
)
,
...
(
?
{
}
:
{
}
)
,
...
(
!==
undefined
?
{
:
{
:
}
}
:
{
}
)
,
...
(
?
{
}
:
{
}
)
,
}
:
undefined
;
return
{
...
,
...
,
:
.
??
.
,
...
(
?
{
:
}
:
{
}
)
,
}
;
}
function
sumDefined
(
:
number
|
undefined
,
:
number
|
undefined
)
:
number
|
undefined
{
return
===
undefined
?
:
===
undefined
?
:
+
;
}
function
mergeTurnTokenTotals
(
:
[
'turnTokenTotals'
]
,
:
[
'turnTokenTotals'
]
)
:
[
'turnTokenTotals'
]
{
if
(
!
&&
!
)
{
return
undefined
;
}
const
=
new
Map<string, ITurnTokenTotal>
(
)
;
for
(
const
of
[
...
??
[
]
,
...
??
[
]
]
)
{
const
=
.
get
(
.
)
;
.
set
(
.
,
?
{
:
.
,
:
.
+
.
,
:
.
+
.
,
:
.
+
.
,
}
:
{
...
}
)
;
}
return
[
...
.
values
(
)
]
;
}
/**
* Well-known keys that may appear on {@link UsageInfo._meta}.
* Clients MAY read these to provide enhanced UI (e.g. credit cost display).
*/
export
interface
UsageInfoMeta
{
/** Per-turn credit cost reported by the backend. */
?
:
number
;
/** The concrete model selected by Copilot Auto and the routing explanation. */
?
:
;
/** Copilot-specific usage breakdown, including nano-AIU totals. */
?
:
{
/** This turn's nano-AIU cost. */
?
:
number
;
/**
* The whole session's accumulated nano-AIU cost, as reported by the
* backend rather than summed from the turns. Clients SHOULD prefer this
* over adding up per-turn totals: it is authoritative, and it also
* covers work billed outside any turn (e.g. an out-of-turn compaction).
*/
?
:
number
;
[
:
string
]
:
unknown
;
}
;
/**
* Per-category account quota snapshots from the model-call usage event. Keyed by quota type:
* `premium_models` (or `premium_interactions` on older backends), `chat`, `session`, `weekly`.
*/
?
:
{
[
:
string
]
:
{
readonly
?
:
boolean
;
readonly
?
:
number
;
readonly
?
:
number
;
readonly
?
:
number
;
readonly
?
:
number
;
readonly
?
:
boolean
;
/** ISO 8601 date when the quota resets, if applicable. */
readonly
?
:
string
;
/** Whether this snapshot is billed against an AI-credits allocation. */
readonly
?
:
boolean
;
/** Additional-usage budget cap in AI credits, when the backend reports one. */
readonly
?
:
number
;
}
|
undefined
;
}
;
/**
* Per-source context-window attribution breakdown reported by the SDK's
* `session.rpc.metadata.getContextAttribution()`. Populated asynchronously
* after each usage event and piped to the context-usage widget as
* `promptTokenDetails`.
*/
?
:
;
/**
* Per-model token totals accumulated across every model call in the turn,
* including calls made by subagents and the summarization call a compaction
* performs. Unlike {@link UsageInfo.inputTokens}, which describes only the
* most recent model call, these are whole-turn sums, so clients can report
* what a completed turn consumed in aggregate.
*/
?
:
readonly
[
]
;
/** Per-model token totals for this turn only, excluding descendant sub-agents (sum a tree without double-counting). */
?
:
readonly
[
]
;
/** Copilot usage for this turn only. The root's {@link copilotUsage} stays inclusive of descendants. */
?
:
{
readonly
?
:
number
;
}
;
[
:
string
]
:
unknown
;
}
/**
* Singleton channel containing the host-owned automation catalogue.
*/
export
const
AHP_AUTOMATIONS_SCHEME
=
'ahp-automations'
;
export
const
AUTOMATION_CATALOG_URI
=
`${AHP_AUTOMATIONS_SCHEME}://`
;
/**
* Returns whether `uri` identifies the singleton automation catalogue channel,
* including forms normalized by the workbench {@link ResourceURI} class.
*/
export
function
isAhpAutomationCatalogChannel
(
:
string
)
:
boolean
{
if
(
===
AUTOMATION_CATALOG_URI
)
{
return
true
;
}
try
{
return
.
parse
(
)
.
===
AHP_AUTOMATIONS_SCHEME
;
}
catch
{
return
false
;
}
}
/** Returns whether `uri` identifies one automation-run channel. */
export
function
isAhpAutomationRunChannel
(
:
string
)
:
boolean
{
try
{
return
.
parse
(
)
.
===
'ahp-automation-run'
;
}
catch
{
return
false
;
}
}
const
MESSAGE_HIDDEN_FROM_TRANSCRIPT_META_KEY
=
'vscode.chat.hiddenFromTranscript'
;
const
MESSAGE_HIDDEN_FROM_TRANSCRIPT_PREFIX
=
'<!-- vscode-hidden-from-transcript -->\n'
;
function
readMessageMeta
(
:
)
:
{
readonly
:
boolean
}
{
const
=
.
;
return
{
:
?.
[
MESSAGE_HIDDEN_FROM_TRANSCRIPT_META_KEY
]
===
true
,
}
;
}
export
function
isMessageHiddenFromTranscript
(
:
)
:
boolean
{
return
readMessageMeta
(
)
.
||
.
.
startsWith
(
MESSAGE_HIDDEN_FROM_TRANSCRIPT_PREFIX
)
;
}
export
function
withMessageHiddenFromTranscript
(
:
,
:
boolean
|
undefined
)
:
{
if
(
!
)
{
return
;
}
return
{
...
,
:
.
.
startsWith
(
MESSAGE_HIDDEN_FROM_TRANSCRIPT_PREFIX
)
?
.
:
MESSAGE_HIDDEN_FROM_TRANSCRIPT_PREFIX
+
.
,
:
{
...
.
,
[
MESSAGE_HIDDEN_FROM_TRANSCRIPT_META_KEY
]
:
true
,
}
,
}
;
}
/** Whole-turn token consumption attributed to a single model. */
export
interface
ITurnTokenTotal
{
readonly
:
string
;
readonly
:
number
;
readonly
:
number
;
readonly
:
number
;
}
export
interface
IAutoModeResolvedInfo
{
readonly
:
string
;
readonly
?
:
'low'
|
'medium'
|
'high'
;
readonly
?
:
<
<
string
,
number
|
undefined
>>
;
readonly
?
:
string
;
readonly
?
:
number
;
readonly
?
:
readonly
string
[
]
;
}
/**
* Mirrors the SDK's `SessionContextAttribution` shape — a flat list of
* per-source entries describing what occupies the session's context window.
*/
export
interface
IContextAttributionData
{
readonly
:
number
;
readonly
:
readonly
[
]
;
readonly
:
{
readonly
:
number
}
;
}
export
interface
IContextAttributionEntry
{
readonly
:
string
;
readonly
:
string
;
readonly
:
string
;
readonly
:
number
;
readonly
?
:
string
;
readonly
?
:
<
<
string
,
string
|
undefined
>>
;
}
type
AccountQuotaSnapshot
=
<
<
[
'quotaSnapshots'
]
>
[
string
]
>
;
function
readAccountQuotaSnapshot
(
:
unknown
)
:
|
undefined
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
const
:
<
>
=
{
}
;
if
(
typeof
[
'isUnlimitedEntitlement'
]
===
'boolean'
)
{
.
=
[
'isUnlimitedEntitlement'
]
;
}
if
(
typeof
[
'entitlementRequests'
]
===
'number'
)
{
.
=
[
'entitlementRequests'
]
;
}
if
(
typeof
[
'usedRequests'
]
===
'number'
)
{
.
=
[
'usedRequests'
]
;
}
if
(
typeof
[
'remainingPercentage'
]
===
'number'
)
{
.
=
[
'remainingPercentage'
]
;
}
if
(
typeof
[
'overage'
]
===
'number'
)
{
.
=
[
'overage'
]
;
}
if
(
typeof
[
'overageAllowedWithExhaustedQuota'
]
===
'boolean'
)
{
.
=
[
'overageAllowedWithExhaustedQuota'
]
;
}
if
(
typeof
[
'resetDate'
]
===
'string'
)
{
.
=
[
'resetDate'
]
;
}
if
(
typeof
[
'tokenBasedBilling'
]
===
'boolean'
)
{
.
=
[
'tokenBasedBilling'
]
;
}
if
(
typeof
[
'overageEntitlement'
]
===
'number'
)
{
.
=
[
'overageEntitlement'
]
;
}
return
;
}
/**
* Reads the well-known {@link UsageInfoMeta} keys from a usage report's open
* `_meta` bag, ignoring unrelated provider-specific keys and validating each
* field's type. Always read {@link UsageInfo._meta} through this helper rather
* than casting the bag to {@link UsageInfoMeta}, so a malformed or partial bag
* degrades to absent fields instead of producing values of the wrong runtime
* type. Returns an empty object when the bag is absent.
*/
export
function
readUsageInfoMeta
(
:
|
undefined
)
:
{
const
=
?.
;
if
(
!
)
{
return
{
}
;
}
const
:
<
>
=
{
}
;
if
(
typeof
[
'cost'
]
===
'number'
)
{
.
=
[
'cost'
]
;
}
const
=
readAutoModeResolvedInfo
(
[
'autoModeResolved'
]
)
;
if
(
)
{
.
=
;
}
const
=
[
'copilotUsage'
]
;
if
(
&&
typeof
===
'object'
&&
!
Array
.
isArray
(
)
)
{
const
=
as
<
string
,
unknown
>
;
const
:
<
<
[
'copilotUsage'
]
>>
=
{
}
;
if
(
typeof
[
'totalNanoAiu'
]
===
'number'
)
{
.
=
[
'totalNanoAiu'
]
;
}
if
(
typeof
[
'sessionTotalNanoAiu'
]
===
'number'
)
{
.
=
[
'sessionTotalNanoAiu'
]
;
}
.
=
;
}
const
=
[
'quotaSnapshots'
]
;
if
(
&&
typeof
===
'object'
&&
!
Array
.
isArray
(
)
)
{
const
:
<
<
[
'quotaSnapshots'
]
>>
=
{
}
;
for
(
const
[
,
]
of
.
entries
(
as
<
string
,
unknown
>
)
)
{
[
]
=
readAccountQuotaSnapshot
(
)
;
}
.
=
;
}
const
=
readContextAttribution
(
[
'contextAttribution'
]
)
;
if
(
)
{
.
=
;
}
const
=
readTurnTokenTotals
(
[
'turnTokenTotals'
]
)
;
if
(
)
{
.
=
;
}
const
=
readTurnTokenTotals
(
[
'directTurnTokenTotals'
]
)
;
if
(
)
{
.
=
;
}
const
=
[
'directCopilotUsage'
]
;
if
(
&&
typeof
===
'object'
&&
!
Array
.
isArray
(
)
)
{
const
=
(
as
<
string
,
unknown
>
)
[
'totalNanoAiu'
]
;
if
(
typeof
===
'number'
)
{
.
=
{
}
;
}
}
return
;
}
/**
* Reads whole-turn per-model token totals, dropping rows that are not fully
* formed. Returns `undefined` when no usable row survives, so callers can treat
* "absent" and "present but meaningless" identically.
*/
function
readTurnTokenTotals
(
:
unknown
)
:
readonly
[
]
|
undefined
{
if
(
!
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
:
[
]
=
[
]
;
for
(
const
of
)
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
continue
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
[
'model'
]
!==
'string'
||
!
[
'model'
]
||
!
isTokenCount
(
[
'inputTokens'
]
)
||
!
isTokenCount
(
[
'cachedTokens'
]
)
||
!
isTokenCount
(
[
'outputTokens'
]
)
)
{
continue
;
}
.
push
(
{
:
[
'model'
]
,
:
[
'inputTokens'
]
,
:
[
'cachedTokens'
]
,
:
[
'outputTokens'
]
,
}
)
;
}
return
.
>
0
?
:
undefined
;
}
function
isTokenCount
(
:
unknown
)
:
is
number
{
return
typeof
===
'number'
&&
.
isSafeInteger
(
)
&&
>=
0
;
}
/**
* Whether a usage report actually records consumption, as opposed to merely
* existing.
*
* A turn can carry a token-less {@link UsageInfo} that exists only to hold
* routing metadata — notably a Copilot Auto turn restored from the event log,
* which keeps `_meta.autoModeResolved` even though the usage event itself is
* ephemeral and was never persisted. Callers that ask "does this turn have
* usage?" almost always mean "does it have numbers to show", so route that
* question through here rather than testing the object for truthiness.
*/
export
function
hasReportedUsage
(
:
|
undefined
)
:
boolean
{
if
(
!
)
{
return
false
;
}
if
(
typeof
.
===
'number'
||
typeof
.
===
'number'
)
{
return
true
;
}
const
=
readUsageInfoMeta
(
)
;
// Negative totals are treated as absent, matching how credits are read for display.
return
(
typeof
.
?.
===
'number'
&&
.
.
>=
0
)
// A report can carry only the session total — a compaction billed while no turn
// was active advances it without any per-event billing payload — and that is
// still consumption worth showing.
||
(
typeof
.
?.
===
'number'
&&
.
.
>=
0
)
||
(
typeof
.
===
'number'
&&
.
>=
0
)
;
}
function
readAutoModeResolvedInfo
(
:
unknown
)
:
|
undefined
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
[
'chosenModel'
]
!==
'string'
)
{
return
undefined
;
}
const
:
<
>
=
{
:
[
'chosenModel'
]
}
;
const
=
[
'reasoningBucket'
]
;
if
(
===
'low'
||
===
'medium'
||
===
'high'
)
{
.
=
;
}
const
=
[
'categoryScores'
]
;
if
(
&&
typeof
===
'object'
&&
!
Array
.
isArray
(
)
)
{
const
:
<
string
,
number
>
=
{
}
;
for
(
const
[
,
]
of
.
entries
(
as
<
string
,
unknown
>
)
)
{
if
(
typeof
===
'number'
)
{
[
]
=
;
}
}
.
=
;
}
if
(
typeof
[
'predictedLabel'
]
===
'string'
)
{
.
=
[
'predictedLabel'
]
;
}
if
(
typeof
[
'confidence'
]
===
'number'
)
{
.
=
[
'confidence'
]
;
}
if
(
Array
.
isArray
(
[
'candidateModels'
]
)
&&
[
'candidateModels'
]
.
every
(
=>
typeof
===
'string'
)
)
{
.
=
[
'candidateModels'
]
;
}
return
;
}
function
readContextAttribution
(
:
unknown
)
:
|
undefined
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
[
'totalTokens'
]
!==
'number'
||
!
Array
.
isArray
(
[
'entries'
]
)
)
{
return
undefined
;
}
const
:
[
]
=
[
]
;
for
(
const
of
[
'entries'
]
)
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
continue
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
[
'kind'
]
!==
'string'
||
typeof
[
'id'
]
!==
'string'
||
typeof
[
'label'
]
!==
'string'
||
typeof
[
'tokens'
]
!==
'number'
)
{
continue
;
}
.
push
(
{
:
[
'kind'
]
,
:
[
'id'
]
,
:
[
'label'
]
,
:
[
'tokens'
]
,
:
typeof
[
'parentId'
]
===
'string'
?
[
'parentId'
]
:
undefined
,
:
[
'attributes'
]
&&
typeof
[
'attributes'
]
===
'object'
&&
!
Array
.
isArray
(
[
'attributes'
]
)
?
filterStringAttributes
(
[
'attributes'
]
as
<
string
,
unknown
>
)
:
undefined
,
}
)
;
}
const
=
[
'compactions'
]
;
const
=
&&
typeof
===
'object'
&&
!
Array
.
isArray
(
)
&&
typeof
(
as
<
string
,
unknown
>
)
[
'count'
]
===
'number'
?
{
:
(
as
<
string
,
unknown
>
)
[
'count'
]
as
number
}
:
{
:
0
}
;
return
{
:
[
'totalTokens'
]
as
number
,
,
}
;
}
function
filterStringAttributes
(
:
<
string
,
unknown
>
)
:
<
string
,
string
|
undefined
>
{
const
:
<
string
,
string
|
undefined
>
=
{
}
;
for
(
const
[
,
]
of
.
entries
(
)
)
{
if
(
typeof
===
'string'
||
===
undefined
)
{
[
]
=
;
}
}
return
;
}
export
{
,
type
ChangesetOperationFollowUp
,
type
ChangesetOperationTarget
}
from
'./protocol/commands.js'
;
// Canonical chat-input type names (the protocol renamed the former
// `SessionInput*` types to `ChatInput*` when input requests moved onto the
// chat channel). Re-exported here so consumers can import them from the glue
/** Scheme used by resource-watch channel URIs (`ahp-resource-watch:/<encoded>`). */
export
const
AHP_RESOURCE_WATCH_SCHEME
=
'ahp-resource-watch'
;
/**
* Encode a resource-watch descriptor into its canonical channel URI. The
* descriptor is serialised into the URI path so the receiver can recover
* the watch parameters without any server-side bookkeeping — subscribe is
* the only point where state is materialised (an `IFileService` watcher
* is attached on the first subscriber and held through a grace window
* after the last drops).
*/
export
function
buildResourceWatchChannelUri
(
:
{
readonly
:
string
;
readonly
?
:
boolean
;
readonly
?
:
{
:
readonly
string
[
]
}
;
readonly
?
:
{
:
readonly
string
[
]
}
;
}
)
:
string
{
const
:
<
string
,
unknown
>
=
{
:
.
}
;
if
(
.
)
{
.
=
true
;
}
if
(
.
&&
.
.
.
>
0
)
{
.
=
[
...
.
.
]
;
}
if
(
.
&&
.
.
.
>
0
)
{
.
=
[
...
.
.
]
;
}
const
=
encodeBase64
(
.
fromString
(
JSON
.
stringify
(
)
)
,
false
,
true
)
;
return
`${AHP_RESOURCE_WATCH_SCHEME}://r/${json}`
;
}
/**
* Inverse of {@link buildResourceWatchChannelUri}. Returns `undefined` if
* `uri` is not a well-formed `ahp-resource-watch:` URI — callers should
* surface that as a not-found error to the client.
*/
export
function
parseResourceWatchChannelUri
(
:
string
)
:
{
:
string
;
:
boolean
;
?
:
{
:
string
[
]
}
;
?
:
{
:
string
[
]
}
;
}
|
undefined
{
let
:
;
try
{
=
.
parse
(
)
;
}
catch
{
return
undefined
;
}
if
(
.
!==
AHP_RESOURCE_WATCH_SCHEME
)
{
return
undefined
;
}
const
=
.
.
replace
(
/^\//
,
''
)
;
if
(
!
)
{
return
undefined
;
}
try
{
const
=
JSON
.
parse
(
decodeBase64
(
)
.
toString
(
)
)
as
{
?
:
unknown
;
?
:
unknown
;
?
:
unknown
;
?
:
unknown
}
;
if
(
typeof
.
!==
'string'
)
{
return
undefined
;
}
return
{
:
.
,
:
.
===
true
,
...
(
Array
.
isArray
(
.
)
?
{
:
{
:
.
.
filter
(
(
)
:
is
string
=>
typeof
===
'string'
)
}
}
:
{
}
)
,
...
(
Array
.
isArray
(
.
)
?
{
:
{
:
.
.
filter
(
(
)
:
is
string
=>
typeof
===
'string'
)
}
}
:
{
}
)
,
}
;
}
catch
{
return
undefined
;
}
}
/** Returns `true` when `uri` identifies a resource-watch channel. */
export
function
isAhpResourceWatchChannel
(
:
string
)
:
boolean
{
try
{
return
.
parse
(
)
.
===
AHP_RESOURCE_WATCH_SCHEME
;
}
catch
{
return
false
;
}
}
/**
* Returns `true` when `uri` identifies the root channel, regardless of
* whether the caller passes the canonical wire form (`'ahp-root://'`) or a
* variant that has been round-tripped through the workbench {@link URI} class
* (which normalizes the authority-less form to `'ahp-root:'`). Always prefer
* this helper over a direct `=== ROOT_STATE_URI` comparison so the two
* spellings stay interchangeable.
*/
export
function
isAhpRootChannel
(
:
string
)
:
boolean
{
if
(
===
ROOT_STATE_URI
)
{
return
true
;
}
try
{
return
.
parse
(
)
.
===
AHP_ROOT_SCHEME
;
}
catch
{
return
false
;
}
}
/**
* Mints a session-unique opaque id for a customization, derived from its
* source URI and (when present) its `range` within the source. Plugins MAY
* declare multiple children (e.g. MCP servers, hooks) inside the same
* manifest file; including the range disambiguates them without an extra
* mapping table.
*
* The range is appended as a reserved `#range=` query-style suffix; any
* existing `#` in the URI is percent-encoded first so a source URI that
* already contains a fragment cannot collide with a ranged id.
*/
/**
* Extracts a plain-text tool output string from a tool call result's `content`
* array. Joins all text-type content parts into a single string.
*
* Returns `undefined` if there are no text content parts.
*/
/**
* Extracts file edit content entries from a tool call result's `content` array.
* Returns an empty array if there are no file edit content parts.
*/
export
function
getToolFileEdits
(
:
)
:
[
]
{
if
(
!
.
||
.
.
===
0
)
{
return
[
]
;
}
const
:
[
]
=
[
]
;
for
(
const
of
.
)
{
if
(
hasKey
(
,
{
:
true
}
)
&&
.
===
.
)
{
.
push
(
)
;
}
}
return
;
}
/**
* Extracts the first subagent content entry from a tool call's `content` array.
* Works with both completed tool call results and running tool call states.
* Returns `undefined` if there are no subagent content parts.
*/
export
function
getToolSubagentContent
(
:
{
?
:
readonly
[
]
}
)
:
|
undefined
{
if
(
!
.
||
.
.
===
0
)
{
return
undefined
;
}
for
(
const
of
.
)
{
if
(
hasKey
(
,
{
:
true
}
)
&&
.
===
.
)
{
return
as
;
}
}
return
undefined
;
}
// ---- Subagent URI helpers ---------------------------------------------------
/**
* Builds a subagent session URI from a parent session URI and tool call ID.
* Convention: `{parentSessionUri}/subagent/{toolCallId}`
*/
export
function
buildSubagentSessionUri
(
:
|
,
:
string
)
:
string
{
const
{
,
}
=
getSubagentBasePath
(
)
;
return
.
with
(
{
:
`${path}${toolCallId}`
}
)
.
toString
(
)
;
}
/**
* Parses a subagent session URI into its parent session URI and tool call ID.
* Returns `undefined` if the URI does not follow the subagent convention.
*/
export
function
parseSubagentSessionUri
(
:
|
)
:
{
:
;
:
string
}
|
undefined
{
const
=
asResourceUri
(
)
;
const
=
SUBAGENT_URI_PATH_REGEX
.
exec
(
.
)
;
if
(
!
?.
)
{
return
undefined
;
}
return
{
:
.
with
(
{
:
.
.
}
)
,
:
.
.
,
}
;
}
/**
* Returns whether a session URI represents a subagent session.
*/
export
function
isSubagentSession
(
:
|
)
:
boolean
{
return
parseSubagentSessionUri
(
)
!==
undefined
;
}
/**
* Builds the string prefix used by the state manager for cached subagent sessions.
*/
/**
* Creates the initial flat {@link SessionState} for a session from its
* root-channel {@link SessionSummary} catalog entry. Session metadata
* ({@link SessionMetadata}) — and the shared `_meta` bag — are inlined directly
* onto the state.
*/
export
function
createSessionState
(
:
)
:
{
const
:
=
{
:
.
,
:
.
,
:
.
,
:
.
,
:
[
]
,
:
[
]
,
:
undefined
,
}
;
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
return
;
}
/**
* Creates an empty {@link ChatState} for a chat. The summary fields are
* denormalized onto the chat state per the protocol contract; callers pass
* the chat's catalog summary and this seeds an empty conversation.
*/
export
function
createChatState
(
:
)
:
{
return
{
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
.
,
:
[
]
,
:
undefined
,
}
;
}
/**
* Derives the default-chat {@link ChatSummary} for a session from its
* {@link SessionSummary}. The default chat inherits the session's title,
* status, activity and working directory, and is marked as a
* {@link ChatOriginKind.User | user-originated} chat. Both the session and
* chat `modifiedAt` are ISO-8601 strings, so it is carried over directly.
*/
export
function
createDefaultChatSummary
(
:
,
:
)
:
{
const
:
=
{
:
,
:
.
,
:
.
,
:
.
,
:
{
:
.
}
,
}
;
if
(
.
!==
undefined
)
{
.
=
.
;
}
// `workingDirectories` is deliberately NOT copied: per the protocol it is a
// per-chat SUBSET override and, when absent, the chat inherits the session's
// full set of working directories (see `mergeSessionWithDefaultChat`).
// Seeding it here would denormalize the session default onto every chat as a
// fake override, which then goes stale when the session's working
// directories are resolved later (e.g. a worktree resolved at
// materialization).
return
;
}
/** Activity bits (0-4) of {@link SessionStatus}; the high bits carry orthogonal flags (IsRead / IsArchived). */
const
STATUS_ACTIVITY_MASK
=
(
1
<<
5
)
-
1
;
/** Whether the active turn has a `PendingConfirmation` tool call auto-approved by the session's bypass setting. */
function
hasAutoApprovedPendingConfirmation
(
:
)
:
boolean
{
return
!
!
.
?.
.
some
(
=>
.
===
.
&&
.
.
===
.
&&
readToolCallMeta
(
.
)
.
===
true
,
)
;
}
/** Whether the chat is genuinely blocked on user input (an open input request, an auth-required tool, or a non-auto-approved confirmation gate). */
function
chatAwaitsUserInput
(
:
)
:
boolean
{
return
!
!
.
?.
.
some
(
=>
{
// An open elicitation always awaits the user until it is answered.
if
(
.
===
.
)
{
return
.
===
undefined
;
}
if
(
.
!==
.
)
{
return
false
;
}
const
=
.
.
;
// Result-confirmation and auth-required gates always require the user; a
// parameter-confirmation gate only when it was not auto-approved.
if
(
===
.
||
===
.
)
{
return
true
;
}
return
===
.
&&
readToolCallMeta
(
.
)
.
!==
true
;
}
)
;
}
/**
* Projects a chat's status for session-summary aggregation, demoting an
* `InputNeeded` back to `InProgress` only when it is caused solely by an
* auto-approved confirmation — otherwise a session with bypass approvals flashes
* "input needed" in the sessions list while an auto-approved tool runs.
*/
function
chatSummaryStatus
(
:
)
:
{
const
=
.
;
if
(
(
&
.
)
!==
.
)
{
return
;
}
// Only demote when we can positively attribute the InputNeeded to an
// auto-approved confirmation with no genuine blocker present; otherwise (e.g.
// a restored summary whose activeTurn is not loaded) preserve the status.
if
(
hasAutoApprovedPendingConfirmation
(
)
&&
!
chatAwaitsUserInput
(
)
)
{
return
(
&
~
STATUS_ACTIVITY_MASK
)
|
.
;
}
return
;
}
/**
* Derives a {@link ChatSummary} from a fully-populated {@link ChatState} by
* projecting out the denormalized summary fields. Used to keep the parent
* session's `chats` catalog in sync with a chat's denormalized state.
*/
export
function
chatSummaryFromState
(
:
)
:
{
const
:
=
{
:
.
,
:
.
,
:
chatSummaryStatus
(
)
,
:
.
,
}
;
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
if
(
.
!==
undefined
)
{
.
=
.
;
}
return
;
}
/**
* The effective interactivity of a chat given its session's archived state.
*
* `interactivity` is the general read-only mechanism (e.g. subagent worker
* chats are `ReadOnly`). An archived session is read-only too, so its
* interactive chats are downgraded to `ReadOnly`. `Hidden` chats stay hidden —
* archiving only downgrades `Full` chats. Absent interactivity defaults to
* `Full` for backward compatibility.
*
* The host uses this to enforce read-only turns off a single signal
* ({@link isChatReadOnly}) rather than special-casing archived; the same rule
* is mirrored client-side to hide the composer.
*/
export
function
effectiveChatInteractivity
(
:
|
undefined
,
:
boolean
)
:
{
if
(
===
.
)
{
return
.
;
}
if
(
)
{
return
.
;
}
return
??
.
;
}
/**
* Whether a chat rejects user-dispatched turns, given its own interactivity and
* its session's archived state. `true` for `ReadOnly` chats (including archived
* sessions' interactive chats). See {@link effectiveChatInteractivity}.
*/
export
function
isChatReadOnly
(
:
|
undefined
,
:
boolean
)
:
boolean
{
return
effectiveChatInteractivity
(
,
)
===
.
;
}
export
function
createActiveTurn
(
:
string
,
:
,
:
string
)
:
{
return
{
,
,
,
:
[
]
,
:
undefined
,
}
;
}
export
function
getTurnError
(
:
|
undefined
)
:
|
undefined
{
if
(
?.
!==
.
)
{
return
undefined
;
}
const
=
.
[
.
.
-
1
]
;
return
?.
===
.
?
.
:
readLegacyTurnError
(
)
;
}
export
const
enum
{
,
,
,
,
,
,
,
,
}
export
type
ComponentToState
=
{
[
.
]
:
;
[
.
]
:
;
[
.
]
:
;
[
.
]
:
;
[
.
]
:
;
[
.
]
:
;
[
.
]
:
;
[
.
]
:
;
}
;
// ---- Default chat URI helpers ----------------------------------------------
/** Scheme used by chat channel URIs (`ahp-chat://...`). */
export
const
AHP_CHAT_SCHEME
=
'ahp-chat'
;
/** Chat id of the default chat that every session owns. */
export
const
DEFAULT_CHAT_ID
=
'default'
;
/**
* Derives the deterministic channel URI for a chat within a session. Every chat
* — the default chat and any additional peer chats — encodes its owning session
* URI into the path so producers and consumers can recover the session without a
* lookup table (see {@link parseChatUri}). The chat id is carried in the URI
* authority.
*
* `ahp-chat://<chatId>/<base64(sessionUri)>`
*/
export
function
buildChatUri
(
:
|
,
:
string
)
:
string
{
const
=
typeof
===
'string'
?
:
.
toString
(
)
;
const
=
encodeBase64
(
.
fromString
(
)
,
false
,
true
)
;
return
`${AHP_CHAT_SCHEME}://${chatId}/${encoded}`
;
}
/**
* Derives the deterministic default-chat channel URI for a session. While the
* protocol allows a session to contain many chats, every session always owns a
* default chat whose URI is derived from the owning session URI so producers and
* consumers can compute it without a lookup table.
*
* The session URI is encoded into the path so {@link parseChatUri} can recover
* it.
*/
/**
* Inverse of {@link buildChatUri}: recovers the owning session URI and chat id
* from any chat channel URI. Returns `undefined` when `uri` is not a well-formed
* chat URI.
*/
/**
* Inverse of {@link buildDefaultChatUri}: recovers the owning session URI from a
* chat channel URI. Returns `undefined` when `uri` is not a well-formed chat URI.
* Accepts any chat URI (default or additional) so callers that only need the
* parent session can use it uniformly.
*/
export
function
parseDefaultChatUri
(
:
|
)
:
string
|
undefined
{
return
parseChatUri
(
)
?.
;
}
export
function
parseRequiredSessionUriFromChatUri
(
:
|
)
:
string
{
const
=
parseDefaultChatUri
(
)
;
if
(
===
undefined
)
{
throw
new
Error
(
`Malformed AHP chat URI: ${typeof uri ==='string'? uri : uri.toString()}`
)
;
}
return
;
}
/** Returns `true` when `uri` is the default chat of its session. */
export
function
isDefaultChatUri
(
:
|
)
:
boolean
{
return
parseChatUri
(
)
?.
===
DEFAULT_CHAT_ID
;
}
export
function
getSessionChatResource
(
:
<
,
'defaultChat'
>
&
{
readonly
:
readonly
<
,
'resource'
>
[
]
}
,
:
string
)
:
|
undefined
{
return
===
DEFAULT_CHAT_ID
?
.
??
.
.
find
(
=>
isDefaultChatUri
(
.
)
)
?.
:
.
.
find
(
=>
parseChatUri
(
.
)
?.
===
)
?.
;
}
/**
* Resolves a feature-level `(session, chat)` pair to the single chat URI used by
* the agent session/chat surface. A session always owns a DEFAULT chat addressed
* by the session URI itself; additional (peer) chats are addressed by their own
* chat channel URIs. This is the one place default-chat resolution lives so
* agents never re-derive "is this the default chat?".
*/
export
function
resolveChatUri
(
:
,
:
)
:
{
return
isDefaultChatUri
(
)
?
:
;
}
/**
* Resolves the URI a chat's persisted data is stored under — the same
* {@link resolveChatUri} rule applied to a chat channel URI alone, recovering
* the owning session from the channel. Agents key their per-session database
* and data directory by this value, so anything reading or writing that storage
* from outside the agent must derive it the same way. Returns `undefined` when
* `chatChannel` is not a parseable chat channel URI.
*/
export
function
chatStorageUri
(
:
|
)
:
|
undefined
{
const
=
parseChatUri
(
)
;
if
(
!
)
{
return
undefined
;
}
return
resolveChatUri
(
.
parse
(
.
)
,
.
parse
(
.
toString
(
)
)
)
;
}
/** Returns `true` when `uri` identifies a chat channel. */
/**
* A single chat's effective session context: the shared {@link SessionState}
* (working directories, active clients, config, customizations/MCP scope, …)
* resolved for one chat and merged with that chat's conversation contents.
*
* The protocol moved turns and pending state off the session and onto a
* per-chat channel, and lets a chat override the session's working directories
* with a subset (e.g. {@link ChatState.workingDirectories}). This composite
* recombines the session with one of its chats — default or peer — so consumers
* read the chat's effective context and conversation through one object without
* walking back to the session to re-derive shared state. The
* {@link ISessionWithDefaultChat.workingDirectories} carry the chat's *effective*
* working directories (its own subset override when present, else the session's
* full set).
*/
export
interface
ISessionWithDefaultChat
extends
SessionState
{
/** Completed turns of this chat. */
:
[
]
;
/** Currently in-progress turn of this chat. */
?
:
;
/** Steering message pending on this chat. */
?
:
;
/** Queued messages pending on this chat. */
?
:
[
]
;
/** Draft input of this chat. */
?
:
;
}
/**
* Projects a {@link SessionState} and one of its {@link ChatState | chats}
* (default or peer) into that chat's {@link ISessionWithDefaultChat | effective
* session context}. Per-chat overrides (the working-directories subset) are
* layered over the session defaults, and the conversation fields are taken from
* the chat. When the chat state is absent (e.g. not yet hydrated) the
* conversation fields default to empty and the session defaults apply.
*/
export
function
mergeSessionWithDefaultChat
(
:
,
:
|
undefined
)
:
{
return
{
...
,
:
?.
??
.
,
:
?.
??
[
]
,
:
?.
,
:
?.
,
:
?.
,
:
?.
,
}
;
}
/**
* Resolves the active turn of a session's default chat, if any.
*/
export
function
getActiveTurn
(
:
|
undefined
)
:
|
undefined
{
return
?.
;
}
/**
* Resolves the default chat's catalog summary from a session, if present.
*/
/**
* VS Code-side alias for the protocol's open `_meta` property bag on
* {@link SessionState}. Keys SHOULD be namespaced (e.g. `git`, `vscode.foo`)
* to avoid collisions; values MUST be JSON-serializable.
*/
export
type
SessionMeta
=
<
string
,
unknown
>
;
/**
* VS Code-side alias for the protocol's open `_meta` property bag on
* {@link SessionSummary}. Keys SHOULD be namespaced (e.g. `git`, `vscode.foo`)
* to avoid collisions; values MUST be JSON-serializable.
*/
export
type
SessionSummaryMeta
=
<
string
,
unknown
>
;
/**
* Reserved key under {@link SessionMeta} for the well-known git-state
* payload. Value at this key, when present, MUST be shaped like
* {@link ISessionGitState}. This is a VS Code-specific convention layered
* on top of the protocol's generic `_meta` bag — the protocol itself does
* not know about git state.
*/
export
const
SESSION_META_GIT_KEY
=
'git'
;
/**
* Reserved key under {@link SessionMeta} for the well-known GitHub-state
* payload. Value at this key, when present, MUST be shaped like
* {@link ISessionGitHubState}. This is a VS Code-specific convention layered
* on top of the protocol's generic `_meta` bag — the protocol itself does
* not know about GitHub state.
*/
export
const
SESSION_META_GITHUB_KEY
=
'github'
;
/** Reserved key for durable source-control workflow provenance. */
export
const
SESSION_META_SOURCE_CONTROL_KEY
=
'vscode.sourceControl'
;
export
const
SESSION_META_PROMPT_CACHE_KEY
=
'vscode.promptCache'
;
export
const
SESSION_META_MULTI_ROOT_KEY
=
'multiRoot'
;
/** Reserved key for whether a session was first discovered in a provider-native catalog. */
export
const
SESSION_META_EXTERNAL_KEY
=
'vscode.external'
;
const
MAX_WORKSPACE_FILE_LENGTH
=
4096
;
/** Multi-root workspace provenance attached by the creating client. */
export
interface
ISessionMultiRootMetadata
{
readonly
:
string
;
}
/** Reads validated multi-root workspace provenance from session metadata. */
export
function
readSessionMultiRootMetadata
(
:
|
undefined
)
:
|
undefined
{
return
validateSessionMultiRootMetadata
(
?.
[
SESSION_META_MULTI_ROOT_KEY
]
)
;
}
/** Parses validated multi-root workspace provenance from its persisted JSON representation. */
export
function
parseSessionMultiRootMetadata
(
:
string
|
undefined
)
:
|
undefined
{
if
(
!
)
{
return
undefined
;
}
try
{
return
validateSessionMultiRootMetadata
(
JSON
.
parse
(
)
)
;
}
catch
{
return
undefined
;
}
}
/** Returns session metadata with the multi-root workspace provenance updated or removed. */
export
function
withSessionMultiRootMetadata
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
=
{
...
}
;
if
(
)
{
[
SESSION_META_MULTI_ROOT_KEY
]
=
;
}
else
{
delete
[
SESSION_META_MULTI_ROOT_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
function
validateSessionMultiRootMetadata
(
:
unknown
)
:
|
undefined
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
.
!==
'string'
||
.
.
===
0
||
.
.
>
MAX_WORKSPACE_FILE_LENGTH
)
{
return
undefined
;
}
try
{
if
(
!
.
parse
(
.
,
true
)
.
)
{
return
undefined
;
}
}
catch
{
return
undefined
;
}
return
{
:
.
}
;
}
/** Latest known prompt-cache state for the model active in an agent session. */
export
interface
ISessionPromptCacheState
{
readonly
:
string
;
readonly
:
string
;
}
/** Reads the latest known prompt-cache state from session metadata. */
export
function
readSessionPromptCacheState
(
:
|
undefined
)
:
|
undefined
{
const
=
?.
[
SESSION_META_PROMPT_CACHE_KEY
]
;
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
return
typeof
[
'modelId'
]
===
'string'
&&
typeof
[
'cacheExpiresAt'
]
===
'string'
?
{
:
[
'modelId'
]
,
:
[
'cacheExpiresAt'
]
}
:
undefined
;
}
/** Returns session metadata with the prompt-cache slot updated or removed. */
export
function
withSessionPromptCacheState
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
=
{
...
}
;
if
(
)
{
[
SESSION_META_PROMPT_CACHE_KEY
]
=
;
}
else
{
delete
[
SESSION_META_PROMPT_CACHE_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/** Reserved key for the harness-owned new-session folder-picker decision. */
export
const
SESSION_META_FOLDER_PICKER_KEY
=
'vscode.folderPicker'
;
/**
* Harness-owned decision about the multi-root new-session Folder picker for an
* agent-host session, carried under {@link SessionMeta} at
* {@link SESSION_META_FOLDER_PICKER_KEY}.
*
* The provider (harness) owns this because the signal differs per backend — for
* example Copilot hides the picker when at most one workspace folder carries
* hooks under `.github/hooks/` (pinning that folder as {@link primary} when
* exactly one does), since the Copilot agent only applies hooks from the primary
* working directory, and shows the picker when several folders carry hooks so
* the user resolves the ambiguity. When {@link primary} is set, it names the
* working directory the client should auto-select before the session starts.
*/
export
interface
ISessionFolderPickerDecision
{
/** Whether the client should hide the multi-root Folder picker. */
readonly
:
boolean
;
/**
* The working directory the client should auto-select as the primary, as a
* URI string. Present only when the harness pins a specific folder (it
* always accompanies `hidden: true`, but a `hidden` decision need not pin
* one — e.g. when no folder carries hooks the current selection is kept).
*/
readonly
?
:
string
;
}
/** Reads the validated folder-picker decision from session metadata. */
export
function
readSessionFolderPickerDecision
(
:
|
undefined
)
:
|
undefined
{
return
validateSessionFolderPickerDecision
(
?.
[
SESSION_META_FOLDER_PICKER_KEY
]
)
;
}
/** Parses the validated folder-picker decision from its persisted JSON representation. */
export
function
parseSessionFolderPickerDecision
(
:
string
|
undefined
)
:
|
undefined
{
if
(
!
)
{
return
undefined
;
}
try
{
return
validateSessionFolderPickerDecision
(
JSON
.
parse
(
)
)
;
}
catch
{
return
undefined
;
}
}
function
validateSessionFolderPickerDecision
(
:
unknown
)
:
|
undefined
{
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
[
'hidden'
]
!==
'boolean'
)
{
return
undefined
;
}
const
=
[
'primary'
]
;
// `primary` is only valid on a hidden, pinned decision (see
// ISessionFolderPickerDecision); reject the contradictory `{ hidden: false,
// primary }` so malformed persisted/remote metadata can't make the client
// both reveal the picker and auto-select/recreate the session.
if
(
!==
undefined
&&
(
typeof
!==
'string'
||
.
===
0
||
[
'hidden'
]
!==
true
)
)
{
return
undefined
;
}
return
!==
undefined
?
{
:
true
,
}
:
{
:
[
'hidden'
]
}
;
}
/** Returns session metadata with the folder-picker decision updated or removed. */
export
function
withSessionFolderPickerDecision
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
=
{
...
}
;
if
(
)
{
[
SESSION_META_FOLDER_PICKER_KEY
]
=
.
!==
undefined
?
{
:
.
,
:
.
}
:
{
:
.
}
;
}
else
{
delete
[
SESSION_META_FOLDER_PICKER_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* Git state of a session's working directory, carried under
* {@link SessionMeta} at {@link SESSION_META_GIT_KEY}. Used by clients to
* drive source-control affordances (e.g. PR/merge buttons in the Agents
* app).
*
* All fields are optional — agents that do not track a particular field
* should omit it rather than send a placeholder, so clients can distinguish
* "unknown" from "known to be zero".
*/
export
interface
ISessionGitState
{
/** Whether the working directory has a `github.com` git remote. */
readonly
?
:
boolean
;
/** Current branch name. */
readonly
?
:
string
;
/**
* Whether `HEAD` is detached, which is why {@link branchName} is absent.
* Distinguishes a legitimately branch-less checkout from git state left
* behind by a probe that failed before it could resolve the branch.
*/
readonly
?
:
boolean
;
/** Base branch the work targets (e.g. `main`). */
/** Number of commits the upstream branch has ahead of the local branch. */
readonly
?
:
number
;
/** Number of commits the local branch has ahead of the upstream branch. */
readonly
?
:
number
;
/** Number of files with uncommitted changes. */
readonly
?
:
number
;
/** Whether the current branch has commits not contained in its local base branch. */
readonly
?
:
boolean
;
/** GitHub repository owner parsed from the working copy's GitHub remote (preferring `origin`, falling back to the first GitHub remote). */
readonly
?
:
string
;
/** GitHub owner parsed from the current branch's upstream or push remote. */
readonly
?
:
string
;
/** GitHub repository name parsed from the working copy's GitHub remote (preferring `origin`, falling back to the first GitHub remote). */
readonly
?
:
string
;
}
export
const
enum
{
=
'merge'
,
=
'pullRequest'
,
}
/** Durable source-control workflow provenance for a session. */
export
interface
ISessionSourceControlState
{
readonly
?
:
{
/** Resulting target-branch HEAD after the most recent successful merge. */
readonly
:
string
;
}
;
readonly
?
:
;
}
/** Reads validated source-control workflow provenance from session metadata. */
export
function
readSessionSourceControlState
(
:
|
undefined
)
:
|
undefined
{
const
=
?.
[
SESSION_META_SOURCE_CONTROL_KEY
]
;
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
let
:
[
'merge'
]
;
const
=
[
'merge'
]
;
if
(
&&
typeof
===
'object'
&&
!
Array
.
isArray
(
)
)
{
const
=
(
as
<
string
,
unknown
>
)
[
'commit'
]
;
=
typeof
===
'string'
&&
.
>
0
?
{
}
:
undefined
;
}
const
=
[
'latestOutcome'
]
;
const
=
===
.
||
===
.
?
:
undefined
;
if
(
!
&&
(
!
||
===
.
)
)
{
return
undefined
;
}
return
{
,
}
;
}
/** Returns session metadata with source-control workflow provenance updated. */
export
function
withSessionSourceControlState
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
=
{
...
}
;
if
(
)
{
[
SESSION_META_SOURCE_CONTROL_KEY
]
=
;
}
else
{
delete
[
SESSION_META_SOURCE_CONTROL_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* GitHub state of a session, carried under {@link SessionMeta} at
* {@link SESSION_META_GITHUB_KEY}. Used by clients to drive GitHub-specific
* affordances (e.g. PR/merge buttons in the Agents app).
*
* All fields are optional — agents that do not track a particular field
* should omit it rather than send a placeholder, so clients can distinguish
* "unknown" from "known to be zero".
*/
export
interface
ISessionGitHubState
{
/** The owner of the GitHub repository. */
readonly
?
:
string
;
/** The name of the GitHub repository. */
readonly
?
:
string
;
/** GitHub pull request URLs found for the session's checkouts, most recent first. */
readonly
?
:
readonly
string
[
]
;
/** Pull requests that predate a folder-isolated session. An empty array is a captured baseline. */
readonly
?
:
readonly
string
[
]
;
/** Pull requests explicitly associated through user intent, most recent first. */
readonly
?
:
readonly
string
[
]
;
/**
* The name of the branch the most recent {@link pullRequestUrls} entry was found (or created) for.
* A pull request always relates to a branch: when the working copy switches
* to a different branch the host keeps reporting the known pull request but
* resumes looking for one that belongs to the newly checked out branch.
*/
readonly
?
:
string
;
}
/**
* Whether the known pull request of `gitHubState` belongs to `branchName`.
*
* State persisted before pull requests were tracked per branch has no
* {@link ISessionGitHubState.pullRequestBranchName}; such a pull request is
* optimistically treated as belonging to the given branch so existing sessions
* keep their pull request affordances until the host has verified which branch
* it actually belongs to.
*/
export
function
hasSessionPullRequestForBranch
(
:
|
undefined
,
:
string
|
undefined
)
:
boolean
{
if
(
!
?.
?.
)
{
return
false
;
}
return
.
===
undefined
||
.
===
;
}
/** Returns pull requests related to the session rather than inherited from its folder checkout. */
export
function
getSessionRelatedPullRequestUrls
(
:
|
undefined
)
:
readonly
string
[
]
{
const
=
?.
??
[
]
;
const
=
?.
;
const
=
new
Set
(
?.
map
(
=>
.
toLowerCase
(
)
)
??
[
]
)
;
const
=
new
Set
(
?.
?.
map
(
=>
.
toLowerCase
(
)
)
??
[
]
)
;
return
.
filter
(
=>
!
.
has
(
.
toLowerCase
(
)
)
||
.
has
(
.
toLowerCase
(
)
)
)
;
}
/** Maximum pull requests retained for a session. */
/** Returns GitHub state with `pullRequestUrl` moved to the front of its bounded history. */
export
function
withMostRecentSessionPullRequest
(
:
|
undefined
,
:
string
,
:
string
)
:
{
const
=
normalizeSessionPullRequestUrls
(
[
,
...
(
?.
??
[
]
)
]
)
;
return
{
,
:
,
}
;
}
/** Returns state that promotes a pull request from the folder baseline into the session. */
export
function
withMostRecentRelatedSessionPullRequest
(
:
|
undefined
,
:
string
,
:
string
)
:
{
const
=
withMostRecentSessionPullRequest
(
,
,
)
;
const
=
normalizeSessionPullRequestUrls
(
[
]
)
[
0
]
?.
toLowerCase
(
)
;
const
=
?.
;
const
=
normalizeSessionPullRequestUrls
(
[
,
...
(
?.
??
[
]
)
]
)
;
return
{
...
,
,
...
(
!==
undefined
?
{
:
.
filter
(
=>
.
toLowerCase
(
)
!==
)
}
:
{
}
)
,
}
;
}
/** Returns state that records a pull request in the folder-session baseline. */
export
function
withInitialSessionPullRequest
(
:
|
undefined
,
?
:
string
)
:
{
return
{
:
normalizeSessionPullRequestUrls
(
[
...
(
?
[
]
:
[
]
)
,
...
(
?.
??
[
]
)
]
)
}
;
}
/**
* Reads the well-known git-state payload from {@link SessionMeta}, if
* present. Returns `undefined` when the meta bag is absent or the value at
* the git key is not a plain object (e.g. an array or a primitive).
* Individual fields with wrong types are silently dropped so partial state
* still propagates.
*
* Unlike the other typed readers, this takes the raw {@link SessionMeta} value
* rather than its parent {@link SessionState}: the sessions provider stores and
* reads a detached meta snapshot without retaining the owning state.
*/
export
function
readSessionGitState
(
:
|
undefined
)
:
|
undefined
{
const
=
?.
[
SESSION_META_GIT_KEY
]
;
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
const
:
{
?
:
boolean
;
?
:
string
;
?
:
boolean
;
?
:
string
;
?
:
string
;
?
:
number
;
?
:
number
;
?
:
number
;
?
:
boolean
;
?
:
string
;
?
:
string
;
?
:
string
;
}
=
{
}
;
if
(
typeof
[
'hasGitHubRemote'
]
===
'boolean'
)
{
.
=
[
'hasGitHubRemote'
]
;
}
if
(
typeof
[
'branchName'
]
===
'string'
)
{
.
=
[
'branchName'
]
;
}
if
(
typeof
[
'isDetachedHead'
]
===
'boolean'
)
{
.
=
[
'isDetachedHead'
]
;
}
if
(
typeof
[
'baseBranchName'
]
===
'string'
)
{
.
=
[
'baseBranchName'
]
;
}
if
(
typeof
[
'upstreamBranchName'
]
===
'string'
)
{
.
=
[
'upstreamBranchName'
]
;
}
if
(
typeof
[
'incomingChanges'
]
===
'number'
)
{
.
=
[
'incomingChanges'
]
;
}
if
(
typeof
[
'outgoingChanges'
]
===
'number'
)
{
.
=
[
'outgoingChanges'
]
;
}
if
(
typeof
[
'uncommittedChanges'
]
===
'number'
)
{
.
=
[
'uncommittedChanges'
]
;
}
if
(
typeof
[
'hasBaseBranchChanges'
]
===
'boolean'
)
{
.
=
[
'hasBaseBranchChanges'
]
;
}
if
(
typeof
[
'githubOwner'
]
===
'string'
)
{
.
=
[
'githubOwner'
]
;
}
if
(
typeof
[
'githubHeadOwner'
]
===
'string'
)
{
.
=
[
'githubHeadOwner'
]
;
}
if
(
typeof
[
'githubRepo'
]
===
'string'
)
{
.
=
[
'githubRepo'
]
;
}
return
;
}
/**
* Whether a session's git state should be recomputed because it does not
* describe a usable checkout.
*
* A state that was never computed obviously qualifies. So does one that is
* missing its branch without a detached `HEAD` to explain it: `git status` is
* the only probe that reports the branch, so such a state is the residue of a
* probe that failed, and consumers that key off the branch (Agent Merge binds
* its pull request that way) stay stranded until it is recomputed. A detached
* `HEAD` is a legitimate branch-less checkout and must not be mistaken for it,
* or every caller would refresh in a loop against a repository that will never
* report a branch.
*/
export
function
needsSessionGitStateRefresh
(
:
|
undefined
)
:
boolean
{
return
===
undefined
||
(
.
===
undefined
&&
!
.
)
;
}
/**
* Returns a new {@link SessionMeta} with the git-state payload set to
* `gitState`, or with the git slot removed if `gitState` is `undefined`.
* Returns `undefined` if the result would be empty.
*/
export
function
withSessionGitState
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
{
[
:
string
]
:
unknown
}
=
{
...
}
;
if
(
!==
undefined
)
{
[
SESSION_META_GIT_KEY
]
=
;
}
else
{
delete
[
SESSION_META_GIT_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* Reads the well-known GitHub state payload from {@link SessionSummaryMeta}, if
* present. Returns `undefined` when the meta bag is absent or the value at the
* GitHub key is not a plain object (e.g. an array or a primitive).
* Individual fields with wrong types are silently dropped so partial state
* still propagates.
*
* Unlike the other typed readers, this takes the raw {@link SessionSummaryMeta}
* value rather than its parent {@link SessionState}: the sessions provider stores and
* reads a detached meta snapshot without retaining the owning state.
*/
export
function
readSessionGitHubState
(
:
|
undefined
)
:
|
undefined
{
const
=
?.
[
SESSION_META_GITHUB_KEY
]
;
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
const
:
{
?
:
string
;
?
:
string
;
?
:
readonly
string
[
]
;
?
:
readonly
string
[
]
;
?
:
readonly
string
[
]
;
?
:
string
;
}
=
{
}
;
if
(
typeof
[
'owner'
]
===
'string'
)
{
.
=
[
'owner'
]
;
}
if
(
typeof
[
'repo'
]
===
'string'
)
{
.
=
[
'repo'
]
;
}
const
=
Array
.
isArray
(
[
'pullRequestUrls'
]
)
?
[
'pullRequestUrls'
]
.
filter
(
(
)
:
is
string
=>
typeof
===
'string'
)
:
typeof
[
'pullRequestUrl'
]
===
'string'
?
[
[
'pullRequestUrl'
]
]
:
[
]
;
if
(
.
>
0
)
{
.
=
normalizeSessionPullRequestUrls
(
)
;
}
if
(
Array
.
isArray
(
[
'initialPullRequestUrls'
]
)
)
{
.
=
normalizeSessionPullRequestUrls
(
[
'initialPullRequestUrls'
]
.
filter
(
(
)
:
is
string
=>
typeof
===
'string'
)
)
;
}
if
(
Array
.
isArray
(
[
'associatedPullRequestUrls'
]
)
)
{
const
=
normalizeSessionPullRequestUrls
(
[
'associatedPullRequestUrls'
]
.
filter
(
(
)
:
is
string
=>
typeof
===
'string'
)
)
;
if
(
.
>
0
)
{
.
=
;
}
}
if
(
typeof
[
'pullRequestBranchName'
]
===
'string'
)
{
.
=
[
'pullRequestBranchName'
]
;
}
return
;
}
/**
* Returns a new {@link SessionSummaryMeta} with the GitHub-state payload set to
* `gitHubState`, or with the GitHub slot removed if `gitHubState` is `undefined`.
* Returns `undefined` if the result would be empty.
*/
export
function
withSessionGitHubState
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
{
[
:
string
]
:
unknown
}
=
{
...
}
;
if
(
!==
undefined
)
{
[
SESSION_META_GITHUB_KEY
]
=
;
}
else
{
delete
[
SESSION_META_GITHUB_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* Reserved key under {@link SessionSummaryMeta} recording how deeply a session
* was spawned via the `create_session` host tool (0 for a top-level, user-created
* session). Used to bound recursive session creation. VS Code-specific convention
* layered on top of the protocol's generic `_meta` bag.
*/
export
const
SESSION_META_SPAWN_DEPTH_KEY
=
'agentHost/sessionSpawnDepth'
;
/**
* Reads the `create_session` spawn depth from a {@link SessionSummaryMeta} bag,
* returning `0` when the key is absent or not a finite number.
*/
export
function
readSessionSpawnDepth
(
:
|
undefined
)
:
number
{
const
=
?.
[
SESSION_META_SPAWN_DEPTH_KEY
]
;
return
typeof
===
'number'
&&
.
isFinite
(
)
?
:
0
;
}
/**
* Returns a new {@link SessionSummaryMeta} with the `create_session` spawn depth
* set to `depth`, preserving any other keys in the bag.
*/
export
function
withSessionSpawnDepth
(
:
|
undefined
,
:
number
)
:
{
return
{
...
,
[
SESSION_META_SPAWN_DEPTH_KEY
]
:
}
;
}
export
const
SESSION_META_CREATED_BY_SESSION_KEY
=
'agentHost/createdBySession'
;
export
const
AH_META_CREATED_BY_SESSION_DB_KEY
=
'agentHost.createdBySession'
;
export
interface
ISessionCreationReference
{
readonly
:
string
;
readonly
?
:
string
;
readonly
?
:
string
;
}
export
function
readSessionCreationReference
(
:
|
undefined
)
:
|
undefined
{
return
parseSessionCreationReferenceValue
(
?.
[
SESSION_META_CREATED_BY_SESSION_KEY
]
)
;
}
function
parseSessionCreationReferenceValue
(
:
unknown
)
:
|
undefined
{
if
(
!
||
typeof
!==
'object'
)
{
return
undefined
;
}
const
=
as
{
[
:
string
]
:
unknown
}
;
if
(
typeof
.
!==
'string'
)
{
return
undefined
;
}
return
{
:
.
,
...
(
typeof
.
===
'string'
?
{
:
.
}
:
{
}
)
,
...
(
typeof
.
===
'string'
?
{
:
.
}
:
{
}
)
,
}
;
}
export
function
parseSessionCreationReference
(
:
string
|
undefined
)
:
|
undefined
{
if
(
!
)
{
return
undefined
;
}
try
{
return
readSessionCreationReference
(
{
[
SESSION_META_CREATED_BY_SESSION_KEY
]
:
JSON
.
parse
(
)
}
)
;
}
catch
{
return
undefined
;
}
}
export
function
withSessionCreationReference
(
:
|
undefined
,
:
)
:
{
return
{
...
,
[
SESSION_META_CREATED_BY_SESSION_KEY
]
:
}
;
}
/**
* Reserved key under {@link SessionSummaryMeta} marking a session as
* workspace-less: a session with no workspace/folder binding (surfaced in the
* UI as a "Quick Chat"). Carried on the summary bag (not the full state) so
* clients can group/style such sessions in session lists without subscribing to
* full session state. VS Code-specific convention layered on the protocol's
* generic `_meta` bag.
*/
export
const
SESSION_META_WORKSPACELESS_KEY
=
'workspaceless'
;
/**
* Session-database metadata key recording whether a session is workspace-less (a
* workspace-less chat). Owned by the AH service: `AgentService` writes it centrally at
* create/materialize and overlays it onto every agent's summary `_meta` in
* `listSessions`; agents only read it (e.g. to pick the workspace-less system prompt
* on resume) and never persist it themselves.
*/
export
const
AH_META_WORKSPACELESS_DB_KEY
=
'agentHost.workspaceless'
;
/**
* Session-database metadata key recording whether a session is archived. Written by
* the AH orchestrator (`AgentSideEffects` on `SessionIsArchivedChanged`) and read by
* both the orchestrator (`AgentService` restore/list) and agents (e.g. `CopilotAgent`
* decides whether to recreate a missing worktree vs. resume read-only for history).
* {@link AH_META_IS_DONE_DB_KEY} is the legacy name kept for sessions persisted before
* the rename; readers fall back to it when {@link AH_META_IS_ARCHIVED_DB_KEY} is absent.
*/
export
const
AH_META_IS_ARCHIVED_DB_KEY
=
'isArchived'
;
/** Legacy metadata key for the archived flag; see {@link AH_META_IS_ARCHIVED_DB_KEY}. */
export
const
AH_META_IS_DONE_DB_KEY
=
'isDone'
;
/**
* Session-database metadata key recording whether a session has been read. This is
* the only durable representation of read state; the in-memory truth is
* {@link SessionStatus.IsRead}. The host owns it — no agent SDK tracks read state.
*/
export
const
AH_META_IS_READ_DB_KEY
=
'isRead'
;
/** Returns `status` with `flag` set or cleared. */
export
function
withSessionStatusFlag
(
:
,
:
,
:
boolean
)
:
{
return
?
(
|
)
:
(
&
~
)
;
}
/** Whether the {@link SessionStatus.IsRead} flag bit is set. */
export
function
isSessionStatusRead
(
:
|
undefined
)
:
boolean
{
return
!==
undefined
&&
(
&
.
)
!==
0
;
}
/** Whether the {@link SessionStatus.IsArchived} flag bit is set. */
export
function
isSessionStatusArchived
(
:
|
undefined
)
:
boolean
{
return
!==
undefined
&&
(
&
.
)
!==
0
;
}
/**
* Reads the workspace-less marker from {@link SessionSummaryMeta}. Returns
* `true` only when the well-known key is present and set to boolean `true`.
*/
export
function
readSessionWorkspaceless
(
:
|
undefined
)
:
boolean
{
return
?.
[
SESSION_META_WORKSPACELESS_KEY
]
===
true
;
}
/**
* Returns a new {@link SessionSummaryMeta} with the workspace-less marker set,
* or with the slot removed when `workspaceless` is `false`. Returns `undefined`
* if the result would be empty.
*/
export
function
withSessionWorkspaceless
(
:
|
undefined
,
:
boolean
)
:
|
undefined
{
const
:
{
[
:
string
]
:
unknown
}
=
{
...
}
;
if
(
)
{
[
SESSION_META_WORKSPACELESS_KEY
]
=
true
;
}
else
{
delete
[
SESSION_META_WORKSPACELESS_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/** Whether the session was first discovered in a provider-native catalog. */
export
function
readSessionExternal
(
:
|
undefined
)
:
boolean
{
return
?.
[
SESSION_META_EXTERNAL_KEY
]
===
true
;
}
/** Returns a copy of `meta` with the external-session provenance marker updated. */
export
function
withSessionExternal
(
:
|
undefined
,
:
boolean
)
:
|
undefined
{
const
:
{
[
:
string
]
:
unknown
}
=
{
...
}
;
if
(
)
{
[
SESSION_META_EXTERNAL_KEY
]
=
true
;
}
else
{
delete
[
SESSION_META_EXTERNAL_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* `_meta` key marking a session as an un-adopted legacy Copilot CLI session
* surfaced (only under the migrate setting) as adoptable. Clients read it to
* avoid passively subscribing to — and thereby migrating — the session before
* the user opens it. Cleared implicitly once the session is adopted (it no
* longer surfaces as adoptable).
*/
export
const
SESSION_META_EHCLI_ADOPTABLE_KEY
=
'ehcliAdoptable'
;
/** Whether the session is an un-adopted legacy Copilot CLI session surfaced as adoptable. */
export
function
readSessionEhcliAdoptable
(
:
|
undefined
)
:
boolean
{
return
?.
[
SESSION_META_EHCLI_ADOPTABLE_KEY
]
===
true
;
}
/** Returns a new {@link SessionSummaryMeta} with the adoptable-legacy marker set. */
export
function
withSessionEhcliAdoptable
(
:
|
undefined
)
:
{
return
{
...
,
[
SESSION_META_EHCLI_ADOPTABLE_KEY
]
:
true
}
;
}
/**
* Session-DB key recording that a session was adopted from a legacy Copilot CLI
* (extension-host) chat. Unlike {@link SESSION_META_EHCLI_ADOPTABLE_KEY} this
* survives adoption, so consumers can keep treating the session as legacy for
* the rest of its life — a migrated session must not change how it is listed.
*/
export
const
AH_META_EHCLI_ADOPTED_DB_KEY
=
'agentHost.ehcliAdopted'
;
/** `_meta` key mirroring {@link AH_META_EHCLI_ADOPTED_DB_KEY} on a summary. */
export
const
SESSION_META_EHCLI_ADOPTED_KEY
=
'ehcliAdopted'
;
/** Whether the session was adopted from a legacy Copilot CLI chat. */
export
function
readSessionEhcliAdopted
(
:
|
undefined
)
:
boolean
{
return
?.
[
SESSION_META_EHCLI_ADOPTED_KEY
]
===
true
;
}
/** Returns a copy of `meta` with the adopted-legacy provenance marker updated. */
export
function
withSessionEhcliAdopted
(
:
|
undefined
,
:
boolean
)
:
|
undefined
{
const
:
{
[
:
string
]
:
unknown
}
=
{
...
}
;
if
(
)
{
[
SESSION_META_EHCLI_ADOPTED_KEY
]
=
true
;
}
else
{
delete
[
SESSION_META_EHCLI_ADOPTED_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* Whether a session should be matched against a workspace folder by its project
* (repository) root in addition to its working directories. True only for
* legacy Copilot CLI sessions, which run out of a worktree outside the
* repository; agent-host-native worktree sessions are deliberately not surfaced
* in a window opened on their source repository.
*/
/**
* VS Code-side alias for the protocol's open `_meta` property bag on
* {@link RootState}. Keys SHOULD be namespaced to avoid collisions; values MUST
* be JSON-serializable.
*/
export
type
RootMeta
=
<
string
,
unknown
>
;
/**
* Reserved key under {@link RootMeta} for the well-known host-build payload.
* Value at this key, when present, MUST be shaped like {@link IHostBuildInfo}.
* This is a VS Code-specific convention layered on top of the protocol's
* generic `_meta` bag — the protocol itself does not know about build info.
*/
export
const
ROOT_META_HOST_BUILD_KEY
=
'hostBuild'
;
/**
* Build information about the program hosting the agent host (the VS Code CLI),
* carried under {@link RootMeta} at {@link ROOT_META_HOST_BUILD_KEY}. Lets a
* client see which build is hosting it — useful when inspecting the output of a
* remote agent host.
*
* All fields except {@link version} are optional — a build that does not track
* a particular field should omit it.
*/
export
interface
IHostBuildInfo
{
/** Product version (e.g. `1.96.0`). */
readonly
:
string
;
/** Commit SHA of the build, if known. */
readonly
?
:
string
;
/** Build date (ISO 8601), if known. */
readonly
?
:
string
;
/** Release quality (e.g. `stable`, `insider`), if known. */
readonly
?
:
string
;
}
/**
* Derives {@link IHostBuildInfo} from the host's {@link IProductService}.
*/
export
function
hostBuildInfoFromProduct
(
:
)
:
{
return
{
:
.
,
:
.
,
:
.
,
:
.
,
}
;
}
/**
* Reads the well-known host-build payload from {@link RootMeta}, if present.
* Returns `undefined` when the meta bag is absent or the value at the host-build
* key is not a plain object with a string `version`. Optional fields with wrong
* types are silently dropped.
*/
export
function
readHostBuildInfo
(
:
|
undefined
)
:
|
undefined
{
const
=
?.
;
const
=
?.
[
ROOT_META_HOST_BUILD_KEY
]
;
if
(
!
||
typeof
!==
'object'
||
Array
.
isArray
(
)
)
{
return
undefined
;
}
const
=
as
<
string
,
unknown
>
;
if
(
typeof
[
'version'
]
!==
'string'
)
{
return
undefined
;
}
const
:
{
:
string
;
?
:
string
;
?
:
string
;
?
:
string
}
=
{
:
[
'version'
]
,
}
;
if
(
typeof
[
'commit'
]
===
'string'
)
{
.
=
[
'commit'
]
;
}
if
(
typeof
[
'date'
]
===
'string'
)
{
.
=
[
'date'
]
;
}
if
(
typeof
[
'quality'
]
===
'string'
)
{
.
=
[
'quality'
]
;
}
return
;
}
/**
* Returns a new {@link RootMeta} with the host-build payload set to
* `buildInfo`, or with the slot removed if `buildInfo` is `undefined`. Returns
* `undefined` if the result would be empty.
*/
export
function
withHostBuildInfo
(
:
|
undefined
,
:
|
undefined
)
:
|
undefined
{
const
:
{
[
:
string
]
:
unknown
}
=
{
...
}
;
if
(
!==
undefined
)
{
[
ROOT_META_HOST_BUILD_KEY
]
=
;
}
else
{
delete
[
ROOT_META_HOST_BUILD_KEY
]
;
}
return
.
keys
(
)
.
>
0
?
:
undefined
;
}
/**
* Formats {@link IHostBuildInfo} as a short single-line human-readable string,
* e.g. `1.96.0 (commit abc1234, 2024-01-02T03:04:05Z, insider)`.
*/