Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
'revokes a superseded delegate so its late writes are dropped'
,
async
(
)
=>
{
const
=
.
get
(
)
.
createInstance
(
)
;
const
=
.
get
(
)
.
;
expect
(
.
.
)
.
toBe
(
1
)
;
.
recreate
(
)
;
expect
(
.
.
)
.
toBe
(
2
)
;
const
[
,
]
=
.
;
expect
(
.
.
)
.
toBe
(
true
)
;
expect
(
.
.
)
.
toBe
(
false
)
;
// A superseded (revoked) generation's writes are dropped; the current one's land.
await
.
.
update
(
'exp.revoke.test'
,
'stale'
)
;
expect
(
.
get
(
'exp.revoke.test'
)
)
.
toBeUndefined
(
)
;
await
.
.
update
(
'exp.revoke.test'
,
'fresh'
)
;
expect
(
.
get
(
'exp.revoke.test'
)
)
.
toBe
(
'fresh'
)
;
.
dispose
(
)
;
}
)
;
it
(
'should return treatments based on copilot token'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
let
=
toExpectedTreatment
(
'a'
,
undefined
,
undefined
)
;
let
=
.
getTreatmentVariable<string>
(
'a'
)
;
expect
(
)
.
toBe
(
)
;
let
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign in as GitHub with Pro SKU
.
=
;
await
;
=
toExpectedTreatment
(
'a'
,
'github'
,
'pro'
)
;
=
.
getTreatmentVariable<string>
(
'a'
)
;
expect
(
)
.
toBe
(
)
;
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign in as GitHub and Microsoft with Enterprise SKU
.
=
;
await
;
=
toExpectedTreatment
(
'a'
,
'github'
,
'enterprise'
)
;
=
.
getTreatmentVariable<string>
(
'a'
)
;
expect
(
)
.
toBe
(
)
;
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign in as Microsoft with Enterprise SKU
.
=
;
await
;
=
toExpectedTreatment
(
'a'
,
'microsoft'
,
'enterprise'
)
;
=
.
getTreatmentVariable<string>
(
'a'
)
;
expect
(
)
.
toBe
(
)
;
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign in as NoOrg with Free SKU
.
=
;
await
;
=
toExpectedTreatment
(
'a'
,
undefined
,
'free'
)
;
=
.
getTreatmentVariable<string>
(
'a'
)
;
expect
(
)
.
toBe
(
)
;
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign out
.
=
undefined
;
await
;
=
toExpectedTreatment
(
'a'
,
undefined
,
undefined
)
;
=
.
getTreatmentVariable<string>
(
'a'
)
;
expect
(
)
.
toBe
(
)
;
}
)
;
it
(
'should trigger treatments refresh when user info changes'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Reset mock to track refresh calls
.
.
reset
(
)
;
// Change token should trigger refresh
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify refresh was called
expect
(
.
.
)
.
toBe
(
1
)
;
}
)
;
it
(
'should handle cached user info on initialization'
,
async
(
)
=>
{
// Simulate cached values in global state
await
.
.
update
(
.
INTERNAL_ORG_STORAGE_KEY
,
'github'
)
;
await
.
.
update
(
.
SKU_STORAGE_KEY
,
'pro'
)
;
// Create new service instance to test initialization
const
=
.
get
(
)
.
createInstance
(
)
;
await
.
hasTreatments
(
)
;
// Should use cached values initially
const
=
.
getTreatmentVariable<string>
(
'test'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'test'
,
'github'
,
'pro'
)
)
;
// Clean up
await
.
.
update
(
.
INTERNAL_ORG_STORAGE_KEY
,
undefined
)
;
await
.
.
update
(
.
SKU_STORAGE_KEY
,
undefined
)
;
}
)
;
it
(
'should handle multiple treatment variables'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Set up promise BEFORE token change
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Test string treatment
const
=
.
getTreatmentVariable<string>
(
'stringVar'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'stringVar'
,
'github'
,
'pro'
)
)
;
// Test different config and variable names
const
=
.
getTreatmentVariable<string>
(
'featureFlag'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'featureFlag'
,
'github'
,
'pro'
)
)
;
// Verify all requests were tracked
const
=
.
.
;
expect
(
.
some
(
=>
.
===
'stringVar'
)
)
.
toBe
(
true
)
;
expect
(
.
some
(
=>
.
===
'featureFlag'
)
)
.
toBe
(
true
)
;
}
)
;
it
(
'should not fire events when relevant user info does not change'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Query a treatment to register it for change detection
.
getTreatmentVariable<string>
(
'testTreatment'
)
;
// Set initial token with promise BEFORE token change
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Reset mock
.
.
reset
(
)
;
let
=
false
;
const
eventHandler
=
(
)
=>
{
=
true
;
}
;
.
onDidTreatmentsChange
(
)
;
// We need a separate token just to make sure we get passed the copilot token change guard
const
=
new
CopilotToken
(
createTestExtendedTokenInfo
(
{
:
'github-test'
,
:
'fake'
,
:
'pro'
,
:
'unknown'
,
:
[
'4535c7beffc844b46bb1ed4aa04d759a'
]
}
)
)
;
.
=
;
// Same token
// Wait a bit to see if event fires
await
new
Promise
(
=>
setTimeout
(
,
50
)
)
;
// Event should not have fired since user info didn't change
expect
(
)
.
toBe
(
false
)
;
expect
(
.
.
)
.
toBe
(
0
)
;
}
)
;
it
(
'should detect GitHub organization correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
const
=
.
getTreatmentVariable<string>
(
'orgTest'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'orgTest'
,
'github'
,
'pro'
)
)
;
}
)
;
it
(
'should detect GitHub and Microsoft organization correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
const
=
.
getTreatmentVariable<string>
(
'orgTest'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'orgTest'
,
'github'
,
'enterprise'
)
)
;
}
)
;
it
(
'should detect Microsoft organization correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
const
=
.
getTreatmentVariable<string>
(
'orgTest'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'orgTest'
,
'microsoft'
,
'enterprise'
)
)
;
}
)
;
it
(
'should handle no organization correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
const
=
.
getTreatmentVariable<string>
(
'orgTest'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'orgTest'
,
undefined
,
'free'
)
)
;
}
)
;
it
(
'should return undefined before initialization completes'
,
async
(
)
=>
{
// Create a fresh service that hasn't been initialized yet
const
=
.
get
(
)
.
createInstance
(
)
;
// Should return undefined before initialization
const
=
.
getTreatmentVariable<string>
(
'test'
)
;
expect
(
)
.
toBeUndefined
(
)
;
// Initialize and verify it works
await
.
hasTreatments
(
)
;
const
=
.
getTreatmentVariable<string>
(
'test'
)
;
expect
(
)
.
toBeDefined
(
)
;
}
)
;
it
(
'should persist user info to global state'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Clear any existing cached values
await
.
.
update
(
.
INTERNAL_ORG_STORAGE_KEY
,
undefined
)
;
await
.
.
update
(
.
SKU_STORAGE_KEY
,
undefined
)
;
// Set a token and wait for update
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify values were cached in global state
const
=
.
.
get<string>
(
.
INTERNAL_ORG_STORAGE_KEY
)
;
const
=
.
.
get<string>
(
.
SKU_STORAGE_KEY
)
;
expect
(
)
.
toBe
(
'github'
)
;
expect
(
)
.
toBe
(
'pro'
)
;
}
)
;
it
(
'should only include previously queried treatments in change events'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Query one treatment before sign-in
const
=
.
getTreatmentVariable<string>
(
'queriedTreatment'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'queriedTreatment'
,
undefined
,
undefined
)
)
;
// Don't query another treatment (notQueriedTreatment)
// Set up promise for treatment changes
let
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign in - this should trigger treatment changes
.
=
;
let
=
await
;
// Verify only the previously queried treatment is in the affected list
expect
(
)
.
toBeDefined
(
)
;
expect
(
.
)
.
toContain
(
'queriedTreatment'
)
;
expect
(
.
)
.
.
toContain
(
'notQueriedTreatment'
)
;
// Now query the treatment that wasn't queried before to verify it has the new value
const
=
.
getTreatmentVariable<string>
(
'notQueriedTreatment'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'notQueriedTreatment'
,
'github'
,
'pro'
)
)
;
// And verify the previously queried treatment has the updated value
const
=
.
getTreatmentVariable<string>
(
'queriedTreatment'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'queriedTreatment'
,
'github'
,
'pro'
)
)
;
// Set up promise for treatment changes
=
GetNewTreatmentsChangedPromise
(
)
;
// Sign out - this should trigger another treatment change event
.
=
undefined
;
=
await
;
// Verify both queried treatments are in the affected list now
expect
(
)
.
toBeDefined
(
)
;
expect
(
.
)
.
toContain
(
'queriedTreatment'
)
;
expect
(
.
)
.
toContain
(
'notQueriedTreatment'
)
;
// Verify both treatments have the signed-out value
const
=
.
getTreatmentVariable<string>
(
'queriedTreatment'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'queriedTreatment'
,
undefined
,
undefined
)
)
;
const
=
.
getTreatmentVariable<string>
(
'notQueriedTreatment'
)
;
expect
(
)
.
toBe
(
toExpectedTreatment
(
'notQueriedTreatment'
,
undefined
,
undefined
)
)
;
}
)
;
it
(
'should detect VS Code team member correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Sign in as VS Code team member
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify isVscodeTeamMember is set in UserInfoStore
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBe
(
true
)
;
}
)
;
it
(
'should detect non-VS Code team member correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Sign in as non VS Code team member
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify isVscodeTeamMember is set correctly in UserInfoStore
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBe
(
false
)
;
}
)
;
it
(
'should persist VS Code team member status to global state'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Clear any existing cached values
await
.
.
update
(
.
IS_VSCODE_TEAM_MEMBER_STORAGE_KEY
,
undefined
)
;
// Set a token and wait for update
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify value was cached in global state
const
=
.
.
get<boolean>
(
.
IS_VSCODE_TEAM_MEMBER_STORAGE_KEY
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'should use cached VS Code team member status on initialization'
,
async
(
)
=>
{
// Simulate cached value in global state
await
.
.
update
(
.
IS_VSCODE_TEAM_MEMBER_STORAGE_KEY
,
true
)
;
// Create new UserInfoStore instance to test initialization
const
=
new
UserInfoStore
(
,
)
;
// Should use cached value initially (when no token is present)
expect
(
.
)
.
toBe
(
true
)
;
// Clean up
await
.
.
update
(
.
IS_VSCODE_TEAM_MEMBER_STORAGE_KEY
,
undefined
)
;
}
)
;
it
(
'should track organization list for targeting'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Set a token with organizations
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify organization list is correctly tracked
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBeDefined
(
)
;
expect
(
.
)
.
toContain
(
'4535c7beffc844b46bb1ed4aa04d759a'
)
;
// GitHub org
expect
(
.
)
.
toContain
(
'a5db0bcaae94032fe715fb34a5e4bce2'
)
;
// Microsoft org
}
)
;
it
(
'should persist organization list to global state'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Clear any existing cached values
await
.
.
update
(
.
ORGANIZATION_LIST_STORAGE_KEY
,
undefined
)
;
// Set a token and wait for update
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify value was cached in global state
const
=
.
.
get<string[]>
(
.
ORGANIZATION_LIST_STORAGE_KEY
)
;
expect
(
)
.
toBeDefined
(
)
;
expect
(
)
.
toContain
(
'4535c7beffc844b46bb1ed4aa04d759a'
)
;
expect
(
)
.
toContain
(
'a5db0bcaae94032fe715fb34a5e4bce2'
)
;
}
)
;
it
(
'should use cached organization list on initialization'
,
async
(
)
=>
{
// Simulate cached value in global state
const
=
[
'org1'
,
'org2'
,
'org3'
]
;
await
.
.
update
(
.
ORGANIZATION_LIST_STORAGE_KEY
,
)
;
// Create new UserInfoStore instance to test initialization
const
=
new
UserInfoStore
(
,
)
;
// Should use cached value initially (when no token is present)
expect
(
.
)
.
toEqual
(
)
;
// Clean up
await
.
.
update
(
.
ORGANIZATION_LIST_STORAGE_KEY
,
undefined
)
;
}
)
;
it
(
'should handle empty organization list'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Set a token with no organizations
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify organization list is empty
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBeDefined
(
)
;
expect
(
.
?.
)
.
toBe
(
0
)
;
}
)
;
it
(
'should trigger treatment refresh when VS Code team membership changes'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Start as signed out
.
=
undefined
;
// Wait a bit for any pending state
await
new
Promise
(
=>
setTimeout
(
,
50
)
)
;
// Reset mock to track refresh calls
.
.
reset
(
)
;
// Sign in as VS Code team member - this will trigger a user info change (from undefined to a value)
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify refresh was called
expect
(
.
.
)
.
toBe
(
1
)
;
// Verify the UserInfoStore has the correct value
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBe
(
true
)
;
}
)
;
it
(
'should detect sn token flag correctly'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Sign in with sn=1 token
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify isSn is set in UserInfoStore
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBe
(
true
)
;
}
)
;
it
(
'should detect sn token flag as false when explicitly disabled'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Sign in with sn=0 token
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify isSn is false in UserInfoStore
const
=
new
UserInfoStore
(
,
)
;
expect
(
.
)
.
toBe
(
false
)
;
}
)
;
it
(
'should persist sn flag to global state'
,
async
(
)
=>
{
await
.
hasTreatments
(
)
;
// Clear any existing cached values
await
.
.
update
(
.
IS_SN_STORAGE_KEY
,
undefined
)
;
// Set a token and wait for update
const
=
GetNewTreatmentsChangedPromise
(
)
;
.
=
;
await
;
// Verify value was cached in global state
const
=
.
.
get<boolean>
(
.
IS_SN_STORAGE_KEY
)
;
expect
(
)
.
toBe
(
true
)
;
}
)
;
it
(
'should use cached sn flag on initialization'
,
async
(
)
=>
{
// Simulate cached value in global state
await
.
.
update
(
.
IS_SN_STORAGE_KEY
,
true
)
;
// Create new UserInfoStore instance to test initialization
const
=
new
UserInfoStore
(
,
)
;
// Should use cached value initially (when no token is present)
expect
(
.
)
.
toBe
(
true
)
;
// Clean up
await
.
.
update
(
.
IS_SN_STORAGE_KEY
,
undefined
)
;
}
)
;
}
)
;
/**
* A delegate whose initial fetch is completed manually, so tests can control ordering, and
* that records when it is disposed. Used to exercise endpoint-driven delegate recreation.
*/
'prefers the /vscode/ scoped key (new endpoint) over the bare key on collision'
,
(
)
=>
{
const
=
create
(
)
;
const
=
.
[
0
]
;
.
setTreatment
(
'config.foo'
,
'bare'
)
;
.
setTreatment
(
'/vscode/config.foo'
,
'scoped'
)
;
expect
(
.
getTreatmentVariable<string>
(
'config.foo'
)
)
.
toBe
(
'scoped'
)
;
.
dispose
(
)
;
}
)
;
}
)
;
/**
* Records every request routed through the fetcher service so a test can assert that both TAS
* endpoints go through it (proxy-aware transport) with the expected method and call site.
*/
class
RecordingFetcherService
extends
mock<IFetcherService>
(
)
{
public
readonly
:
{
:
string
;
:
string
;
:
string
;
?
:
string
}
[
]
=
[
]
;
readonly
=
.
;
readonly
=
.
;
getUserAgentLibrary
(
)
:
string
{
return
'test-fetcher'
;
}
fetch
(
:
string
,
:
)
:
Promise
<
>
{
this
.
.
push
(
{
,
:
.
??
'GET'
,
:
.
,
:
.
}
)
;
return
Promise
.
resolve
(
.
fromText
(
200
,
'OK'
,
new
HeadersImpl
(
{
}
)
,
'{}'
,
'test-stub'
)
)
;
}
}
describe
(
'TAS proxy transport adapter'
,
(
)
=>
{
it
(
'routes both the legacy GET and the assignments POST through the fetcher service with the expected call sites'