|
1 | 1 | import type { |
2 | 2 | ClientContext, |
| 3 | + ContentBlock, |
3 | 4 | LoadSessionResponse, |
4 | 5 | NewSessionResponse, |
5 | 6 | ResumeSessionResponse, |
6 | 7 | SessionId, |
7 | 8 | } from "@agentclientprotocol/sdk"; |
8 | 9 |
|
9 | 10 | export const LEGACY_SET_SESSION_MODEL_METHOD = "session/set_model"; |
| 11 | +export const SESSION_STEERING_METHOD = "_session/steering"; |
10 | 12 | export const GOAL_CONTROL_METHOD = "_codex/session/goal_control"; |
11 | 13 |
|
12 | 14 | export type LegacySessionModel = { |
@@ -43,13 +45,15 @@ export type ExtMethodRequest = |
43 | 45 | AuthenticationStatusRequest |
44 | 46 | | AuthenticationLogoutRequest |
45 | 47 | | LegacySetSessionModelExtRequest |
| 48 | + | SessionSteeringExtRequest |
46 | 49 | | GoalControlExtRequest |
47 | 50 |
|
48 | 51 | export function isExtMethodRequest(request: { method: string, params: Record<string, unknown> }): request is ExtMethodRequest { |
49 | 52 | return request.method === "authentication/status" |
50 | 53 | || request.method === "authentication/logout" |
51 | 54 | || request.method === LEGACY_SET_SESSION_MODEL_METHOD |
52 | | - || request.method === GOAL_CONTROL_METHOD; |
| 55 | + || request.method === GOAL_CONTROL_METHOD |
| 56 | + || request.method === SESSION_STEERING_METHOD; |
53 | 57 | } |
54 | 58 |
|
55 | 59 | export type AuthenticationStatusRequest = { method: "authentication/status", params: {} } |
@@ -79,3 +83,24 @@ export async function legacySetSessionModel( |
79 | 83 | ): Promise<LegacySetSessionModelResponse> { |
80 | 84 | return await connection.request<LegacySetSessionModelResponse, LegacySetSessionModelRequest>(LEGACY_SET_SESSION_MODEL_METHOD, params); |
81 | 85 | } |
| 86 | + |
| 87 | +export type SessionSteerRequest = { |
| 88 | + sessionId: SessionId; |
| 89 | + prompt: ContentBlock[]; |
| 90 | +} |
| 91 | + |
| 92 | +export type SessionSteeringResponse = { |
| 93 | + outcome: "injected" | "startedNewTurn" | "failed"; |
| 94 | +} |
| 95 | + |
| 96 | +export type SessionSteeringExtRequest = { |
| 97 | + method: typeof SESSION_STEERING_METHOD; |
| 98 | + params: SessionSteerRequest; |
| 99 | +} |
| 100 | + |
| 101 | +export async function steerSessionWithFallback( |
| 102 | + connection: Pick<ClientContext, "request">, |
| 103 | + params: SessionSteerRequest, |
| 104 | +): Promise<SessionSteeringResponse> { |
| 105 | + return await connection.request<SessionSteeringResponse, SessionSteerRequest>(SESSION_STEERING_METHOD, params); |
| 106 | +} |
0 commit comments