1- export type ExtMethodRequest = AuthenticationStatusRequest | AuthenticationLogoutRequest
1+ import type {
2+ ClientSideConnection ,
3+ LoadSessionResponse ,
4+ NewSessionResponse ,
5+ ResumeSessionResponse ,
6+ SessionId ,
7+ } from "@agentclientprotocol/sdk" ;
8+
9+ export const LEGACY_SET_SESSION_MODEL_METHOD = "session/set_model" ;
10+
11+ export type LegacySessionModel = {
12+ modelId : string ;
13+ name : string ;
14+ description ?: string | null ;
15+ }
16+
17+ export type LegacySessionModelState = {
18+ availableModels : Array < LegacySessionModel > ;
19+ currentModelId : string ;
20+ }
21+
22+ export type LegacySetSessionModelRequest = {
23+ sessionId : SessionId ;
24+ modelId : string ;
25+ }
26+
27+ export type LegacySetSessionModelResponse = { }
28+
29+ export type LegacyNewSessionResponse = NewSessionResponse & {
30+ models ?: LegacySessionModelState | null ;
31+ }
32+
33+ export type LegacyLoadSessionResponse = LoadSessionResponse & {
34+ models ?: LegacySessionModelState | null ;
35+ }
36+
37+ export type LegacyResumeSessionResponse = ResumeSessionResponse & {
38+ models ?: LegacySessionModelState | null ;
39+ }
40+
41+ export type ExtMethodRequest =
42+ AuthenticationStatusRequest
43+ | AuthenticationLogoutRequest
44+ | LegacySetSessionModelExtRequest
245
346export function isExtMethodRequest ( request : { method : string , params : Record < string , unknown > } ) : request is ExtMethodRequest {
4- return request . method === "authentication/status" || request . method === "authentication/logout" ;
47+ return request . method === "authentication/status"
48+ || request . method === "authentication/logout"
49+ || request . method === LEGACY_SET_SESSION_MODEL_METHOD ;
550}
651
752export type AuthenticationStatusRequest = { method : "authentication/status" , params : { } }
853export type AuthenticationStatusResponse = { type : "api-key" } | { type : "chat-gpt" , email : string } | { type : "gateway" , name : string } | { type : "unauthenticated" }
954
1055export type AuthenticationLogoutRequest = { method : "authentication/logout" , params : { } }
11- export type AuthenticationLogoutResponse = { }
56+ export type AuthenticationLogoutResponse = { }
57+
58+ export type LegacySetSessionModelExtRequest = {
59+ method : typeof LEGACY_SET_SESSION_MODEL_METHOD ;
60+ params : LegacySetSessionModelRequest ;
61+ }
62+
63+ export async function legacySetSessionModel (
64+ connection : Pick < ClientSideConnection , "extMethod" > ,
65+ params : LegacySetSessionModelRequest ,
66+ ) : Promise < LegacySetSessionModelResponse > {
67+ return await connection . extMethod ( LEGACY_SET_SESSION_MODEL_METHOD , params ) as LegacySetSessionModelResponse ;
68+ }
0 commit comments