-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathAcpExtensions.ts
More file actions
68 lines (54 loc) · 2.18 KB
/
Copy pathAcpExtensions.ts
File metadata and controls
68 lines (54 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type {
ClientContext,
LoadSessionResponse,
NewSessionResponse,
ResumeSessionResponse,
SessionId,
} from "@agentclientprotocol/sdk";
export const LEGACY_SET_SESSION_MODEL_METHOD = "session/set_model";
export type LegacySessionModel = {
modelId: string;
name: string;
description?: string | null;
}
export type LegacySessionModelState = {
availableModels: Array<LegacySessionModel>;
currentModelId: string;
}
export type LegacySetSessionModelRequest = {
sessionId: SessionId;
modelId: string;
}
export type LegacySetSessionModelResponse = {}
export type LegacyNewSessionResponse = NewSessionResponse & {
models?: LegacySessionModelState | null;
}
export type LegacyLoadSessionResponse = LoadSessionResponse & {
models?: LegacySessionModelState | null;
}
export type LegacyResumeSessionResponse = ResumeSessionResponse & {
models?: LegacySessionModelState | null;
}
export type ExtMethodRequest =
AuthenticationStatusRequest
| AuthenticationLogoutRequest
| LegacySetSessionModelExtRequest
export function isExtMethodRequest(request: { method: string, params: Record<string, unknown> }): request is ExtMethodRequest {
return request.method === "authentication/status"
|| request.method === "authentication/logout"
|| request.method === LEGACY_SET_SESSION_MODEL_METHOD;
}
export type AuthenticationStatusRequest = { method: "authentication/status", params: {} }
export type AuthenticationStatusResponse = { type: "api-key" } | { type: "chat-gpt", email: string } | { type: "gateway", name: string } | { type: "unauthenticated" }
export type AuthenticationLogoutRequest = { method: "authentication/logout", params: {} }
export type AuthenticationLogoutResponse = {}
export type LegacySetSessionModelExtRequest = {
method: typeof LEGACY_SET_SESSION_MODEL_METHOD;
params: LegacySetSessionModelRequest;
}
export async function legacySetSessionModel(
connection: Pick<ClientContext, "request">,
params: LegacySetSessionModelRequest,
): Promise<LegacySetSessionModelResponse> {
return await connection.request<LegacySetSessionModelResponse, LegacySetSessionModelRequest>(LEGACY_SET_SESSION_MODEL_METHOD, params);
}