Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/** Last observed provider modification time; defaults to {@link startTime}. */
readonly
?
:
number
;
readonly
:
;
}
export
interface
IAgentHostDatabaseRegisterOptions
{
readonly
:
boolean
;
}
export
interface
IAgentHostDatabaseExternalUpdate
{
readonly
:
string
;
readonly
:
boolean
;
}
export
interface
IAgentHostDatabase
extends
IDisposable
{
/**
* Records a session with source-aware provenance. When requested, the
* tombstone check and registration are atomic.
*/
registerSession
(
:
string
,
:
,
:
)
:
Promise
<
boolean
>
;
unregisterSession
(
:
string
)
:
Promise
<
void
>
;
/** Atomically tombstones and removes a session so concurrent backfill cannot re-register it. */
tombstoneAndUnregisterSession
(
:
string
)
:
Promise
<
void
>
;
updateSessionExternal
(
:
readonly
[
]
)
:
Promise
<
void
>
;
/** Advances the durable last-observed modification time. */
updateSessionModifiedTime
(
:
string
,
:
number
)
:
Promise
<
boolean
>
;
getSession
(
:
string
)
:
Promise
<
|
undefined
>
;
listSessions
(
)
:
Promise
<
readonly
[
]
>
;
isSessionRegistryEmpty
(
)
:
Promise
<
boolean
>
;
/**
* @deprecated superseded by per-provider {@link isProviderBackfilled}.
* Retained only for reading databases written by pre-per-provider code.
* Neither this marker nor per-provider markers gate native discovery.
*/
isSessionRegistryBackfilled
(
)
:
Promise
<
boolean
>
;
/** @deprecated see {@link isSessionRegistryBackfilled}. */
markSessionRegistryBackfilled
(
)
:
Promise
<
void
>
;
/** Whether `provider` has completed native discovery at least once (for compatibility/diagnostics). */
isProviderBackfilled
(
:
)
:
Promise
<
boolean
>
;
/** Durably records a completed provider-native discovery pass. */
markProviderBackfilled
(
:
)
:
Promise
<
void
>
;
/** Whether `session` was explicitly deleted and must not be resurrected by backfill. */
isSessionTombstoned
(
:
string
)
:
Promise
<
boolean
>
;
/** Durably records that `session` was explicitly deleted. */
markSessionTombstoned
(
:
string
)
:
Promise
<
void
>
;
/** Clears a session's deletion tombstone (used on explicit create/restore). */
clearSessionTombstone
(
:
string
)
:
Promise
<
void
>
;
/**
* Records whether Agent Merge is enabled for `session`. This host-owned index
* lets startup find the few monitored sessions without opening every session
* database.
*/
setSessionAgentMergeEnabled
(
:
string
,
:
boolean
)
:
Promise
<
void
>
;
/** Session URIs currently marked Agent-Merge-enabled. */
listAgentMergeEnabledSessions
(
)
:
Promise
<
readonly
string
[
]
>
;
close
(
)
:
Promise
<
void
>
;
}
const
=
[
{
:
1
,
:
[
`CREATE TABLE IF NOT EXISTS sessions (
session_uri TEXT PRIMARY KEY NOT NULL,
provider TEXT NOT NULL,
start_time INTEGER NOT NULL
)`
,
`CREATE TABLE IF NOT EXISTS metadata (
key TEXT PRIMARY KEY NOT NULL,
value TEXT NOT NULL
)`
/** Like {@link run}, but resolves with the number of rows the statement actually affected. */
function
runReturningChanges
(
:
,
:
string
,
:
readonly
unknown
[
]
)
:
Promise
<
number
>
{
return
new
Promise
(
(
,
)
=>
{
.
run
(
,
,
function
(
this
:
,
:
|
null
)
{
?
reject
(
)
:
resolve
(
this
.
)
;
}
)
;
}
)
;
}
function
get
(
:
,
:
string
,
:
readonly
unknown
[
]
)
:
Promise
<
<
string
,
unknown
>
|
undefined
>
{
return
new
Promise
(
(
,
)
=>
{
.
get
(
,
,
(
:
|
null
,
:
<
string
,
unknown
>
|
undefined
)
=>
?
reject
(
)
:
resolve
(
)
)
;
}
)
;
}
function
all
(
:
,
:
string
,
:
readonly
unknown
[
]
)
:
Promise
<
<
string
,
unknown
>
[
]
>
{
return
new
Promise
(
(
,
)
=>
{
.
all
(
,
,
(
:
|
null
,
:
<
string
,
unknown
>
[
]
)
=>
?
reject
(
)
:
resolve
(
)
)
;
}
)
;
}
/** Metadata key for the durable per-provider backfill-completion marker. */
function
providerBackfillKey
(
:
)
:
string
{
return
`sessionRegistryBackfilled:${provider}`
;
}
/** Metadata key for a session's durable "explicitly deleted" tombstone. */
function
tombstoneKey
(
:
string
)
:
string
{
return
`sessionTombstone:${session}`
;
}
const
=
'agentMergeEnabled:'
;
/** Metadata key marking a session as Agent-Merge-enabled. */
function
agentMergeEnabledKey
(
:
string
)
:
string
{
return
`${agentMergeEnabledKeyPrefix}${session}`
;
}
function
quoteSqlString
(
:
string
)
:
string
{
return
`'${value.replaceAll('\'','\'\'')}'`
;
}
function
close
(
:
)
:
Promise
<
void
>
{
return
new
Promise
(
(
,
)
=>
.
close
(
=>
?
reject
(
)
:
resolve
(
)
)
)
;
}
export
class
AgentHostDatabase
implements
IAgentHostDatabase
{
private
:
Promise
<
>
|
undefined
;
private
:
Promise
<
void
>
|
true
|
undefined
;
constructor
(
private
readonly
:
string
)
{
}
async
registerSession
(
:
string
,
:
,
:
)
:
Promise
<
boolean
>
{
const
{
,
,
=
,
}
=
;
const
=
await
runReturningChanges
(
await
this
.
_ensureDatabase
(
)
,
`INSERT INTO sessions (session_uri, provider, start_time, modified_time, external, registration_source)
SELECT ?, ?, ?, ?, CASE WHEN ? = 'discovery' THEN 1 ELSE 0 END, ?
WHERE ? = 0 OR NOT EXISTS (SELECT 1 FROM metadata WHERE key = ? AND value = 'true')
ON CONFLICT(session_uri) DO UPDATE SET
provider = CASE WHEN excluded.registration_source = 'explicit' THEN excluded.provider ELSE sessions.provider END,
modified_time = MAX(sessions.modified_time, excluded.modified_time),
external = CASE
WHEN excluded.registration_source = 'explicit' THEN 0
WHEN excluded.registration_source = 'restore' THEN 0
WHEN sessions.registration_source = 'explicit' THEN sessions.external
ELSE 1
END,
registration_source = CASE
WHEN excluded.registration_source = 'explicit' THEN 'explicit'
WHEN sessions.registration_source = 'explicit' THEN 'explicit'
ELSE excluded.registration_source
END`
,
[
,
,
,
,
,
,
.
?
1
:
0
,
tombstoneKey
(
)
]
,
)
;
if
(
!
.
)
{
await
this
.
clearSessionTombstone
(
)
;
}
return
>
0
;
}
async
unregisterSession
(
:
string
)
:
Promise
<
void
>
{
const
=
await
this
.
_ensureDatabase
(
)
;
try
{
await
exec
(
,
`BEGIN IMMEDIATE;
DELETE FROM sessions WHERE session_uri = ${quoteSqlString(session)};
DELETE FROM metadata WHERE key = ${quoteSqlString(agentMergeEnabledKey(session))};
COMMIT;`
,
)
;
}
catch
(
)
{
try
{
await
exec
(
,
'ROLLBACK'
)
;
}
catch
(
)
{
throw
new
AggregateError
(
[
,
]
,
`Failed to unregister session ${session}`
)
;
}
throw
;
}
}
async
tombstoneAndUnregisterSession
(
:
string
)
:
Promise
<
void
>
{
const
=
await
this
.
_ensureDatabase
(
)
;
const
=
quoteSqlString
(
)
;
const
=
quoteSqlString
(
tombstoneKey
(
)
)
;
try
{
await
exec
(
,
`BEGIN IMMEDIATE;
INSERT INTO metadata (key, value) VALUES (${tombstoneValue}, 'true')
ON CONFLICT(key) DO UPDATE SET value = excluded.value;
DELETE FROM metadata WHERE key = ${quoteSqlString(agentMergeEnabledKey(session))};
DELETE FROM sessions WHERE session_uri = ${sessionValue};
COMMIT;`
,
)
;
}
catch
(
)
{
try
{
await
exec
(
,
'ROLLBACK'
)
;
}
catch
(
)
{
throw
new
AggregateError
(
[
,
]
,
`Failed to tombstone session ${session}`
)
;
}
throw
;
}
}
async
updateSessionExternal
(
:
readonly
[
]
)
:
Promise
<
void
>
{
if
(
.
===
0
)
{
return
;
}
const
=
await
this
.
_ensureDatabase
(
)
;
const
=
.
map
(
(
{
,
}
)
=>
{
const
=
?
1
:
0
;
const
=
?
`'discovery'`
:
`CASE WHEN registration_source = 'explicit' THEN 'explicit' ELSE 'restore' END`
;
return
`UPDATE sessions SET external = ${externalValue}, registration_source = ${source} WHERE session_uri = ${quoteSqlString(session)} AND external IS NULL`