@@ -179,6 +179,20 @@ export interface AccountGetQuotaResult {
179179 } ;
180180}
181181
182+ export interface SessionDataStoreSetDataStoreResult {
183+ /**
184+ * Whether the data store was set successfully
185+ */
186+ success : boolean ;
187+ }
188+
189+ export interface SessionDataStoreSetDataStoreParams {
190+ /**
191+ * Opaque descriptor identifying the storage backend (e.g., 'redis://localhost/sessions')
192+ */
193+ descriptor : string ;
194+ }
195+
182196export interface SessionModelGetCurrentResult {
183197 /**
184198 * Currently active model identifier
@@ -1050,6 +1064,78 @@ export interface SessionShellKillParams {
10501064 signal ?: "SIGTERM" | "SIGKILL" | "SIGINT" ;
10511065}
10521066
1067+ export interface SessionDataStoreLoadResult {
1068+ /**
1069+ * All persisted events for the session, in order
1070+ */
1071+ events : {
1072+ [ k : string ] : unknown ;
1073+ } [ ] ;
1074+ }
1075+
1076+ export interface SessionDataStoreLoadParams {
1077+ /**
1078+ * The session to load events for
1079+ */
1080+ sessionId : string ;
1081+ }
1082+
1083+ export interface SessionDataStoreAppendParams {
1084+ /**
1085+ * The session to append events to
1086+ */
1087+ sessionId : string ;
1088+ /**
1089+ * Events to append, in order
1090+ */
1091+ events : {
1092+ [ k : string ] : unknown ;
1093+ } [ ] ;
1094+ }
1095+
1096+ export interface SessionDataStoreTruncateResult {
1097+ /**
1098+ * Number of events removed
1099+ */
1100+ eventsRemoved : number ;
1101+ /**
1102+ * Number of events kept
1103+ */
1104+ eventsKept : number ;
1105+ }
1106+
1107+ export interface SessionDataStoreTruncateParams {
1108+ /**
1109+ * The session to truncate
1110+ */
1111+ sessionId : string ;
1112+ /**
1113+ * Event ID marking the truncation boundary (excluded)
1114+ */
1115+ upToEventId : string ;
1116+ }
1117+
1118+ export interface SessionDataStoreListResult {
1119+ sessions : {
1120+ sessionId : string ;
1121+ /**
1122+ * ISO 8601 timestamp of last modification
1123+ */
1124+ mtime : string ;
1125+ /**
1126+ * ISO 8601 timestamp of creation
1127+ */
1128+ birthtime : string ;
1129+ } [ ] ;
1130+ }
1131+
1132+ export interface SessionDataStoreDeleteParams {
1133+ /**
1134+ * The session to delete
1135+ */
1136+ sessionId : string ;
1137+ }
1138+
10531139/** Create typed server-scoped RPC methods (no session required). */
10541140export function createServerRpc ( connection : MessageConnection ) {
10551141 return {
@@ -1067,6 +1153,10 @@ export function createServerRpc(connection: MessageConnection) {
10671153 getQuota : async ( ) : Promise < AccountGetQuotaResult > =>
10681154 connection . sendRequest ( "account.getQuota" , { } ) ,
10691155 } ,
1156+ sessionDataStore : {
1157+ setDataStore : async ( params : SessionDataStoreSetDataStoreParams ) : Promise < SessionDataStoreSetDataStoreResult > =>
1158+ connection . sendRequest ( "sessionDataStore.setDataStore" , params ) ,
1159+ } ,
10701160 } ;
10711161}
10721162
@@ -1188,3 +1278,40 @@ export function createSessionRpc(connection: MessageConnection, sessionId: strin
11881278 } ,
11891279 } ;
11901280}
1281+
1282+ /**
1283+ * Handler interface for the `sessionDataStore` client API group.
1284+ * Implement this to provide a custom sessionDataStore backend.
1285+ */
1286+ export interface SessionDataStoreHandler {
1287+ load ( params : SessionDataStoreLoadParams ) : Promise < SessionDataStoreLoadResult > ;
1288+ append ( params : SessionDataStoreAppendParams ) : Promise < void > ;
1289+ truncate ( params : SessionDataStoreTruncateParams ) : Promise < SessionDataStoreTruncateResult > ;
1290+ list ( ) : Promise < SessionDataStoreListResult > ;
1291+ delete ( params : SessionDataStoreDeleteParams ) : Promise < void > ;
1292+ }
1293+
1294+ /** All client API handler groups. Each group is optional. */
1295+ export interface ClientApiHandlers {
1296+ sessionDataStore ?: SessionDataStoreHandler ;
1297+ }
1298+
1299+ /**
1300+ * Register client API handlers on a JSON-RPC connection.
1301+ * The server calls these methods to delegate work to the client.
1302+ * Methods for unregistered groups will respond with a standard JSON-RPC
1303+ * method-not-found error.
1304+ */
1305+ export function registerClientApiHandlers (
1306+ connection : MessageConnection ,
1307+ handlers : ClientApiHandlers ,
1308+ ) : void {
1309+ if ( handlers . sessionDataStore ) {
1310+ const h = handlers . sessionDataStore ! ;
1311+ connection . onRequest ( "sessionDataStore.load" , ( params : SessionDataStoreLoadParams ) => h . load ( params ) ) ;
1312+ connection . onRequest ( "sessionDataStore.append" , ( params : SessionDataStoreAppendParams ) => h . append ( params ) ) ;
1313+ connection . onRequest ( "sessionDataStore.truncate" , ( params : SessionDataStoreTruncateParams ) => h . truncate ( params ) ) ;
1314+ connection . onRequest ( "sessionDataStore.list" , ( ) => h . list ( ) ) ;
1315+ connection . onRequest ( "sessionDataStore.delete" , ( params : SessionDataStoreDeleteParams ) => h . delete ( params ) ) ;
1316+ }
1317+ }
0 commit comments