Skip to content

Commit b02fee8

Browse files
committed
Add unstable model selection to TS SDK
Signed-off-by: Ben Brandt <benjamin.j.brandt@gmail.com>
1 parent 1b3366c commit b02fee8

4 files changed

Lines changed: 24 additions & 6 deletions

File tree

rust/agent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ pub struct AgentMethodNames {
820820
pub session_cancel: &'static str,
821821
/// Method for selecting a model for a given session.
822822
#[cfg(feature = "unstable")]
823-
pub model_select: &'static str,
823+
pub session_set_model: &'static str,
824824
}
825825

826826
/// Constant containing all agent method names.
@@ -833,7 +833,7 @@ pub const AGENT_METHOD_NAMES: AgentMethodNames = AgentMethodNames {
833833
session_prompt: SESSION_PROMPT_METHOD_NAME,
834834
session_cancel: SESSION_CANCEL_METHOD_NAME,
835835
#[cfg(feature = "unstable")]
836-
model_select: SESSION_SET_MODEL_METHOD_NAME,
836+
session_set_model: SESSION_SET_MODEL_METHOD_NAME,
837837
};
838838

839839
/// Method name for the initialize request.

schema/meta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"agentMethods": {
33
"authenticate": "authenticate",
44
"initialize": "initialize",
5-
"model_select": "session/set_model",
65
"session_cancel": "session/cancel",
76
"session_load": "session/load",
87
"session_new": "session/new",
98
"session_prompt": "session/prompt",
10-
"session_set_mode": "session/set_mode"
9+
"session_set_mode": "session/set_mode",
10+
"session_set_model": "session/set_model"
1111
},
1212
"clientMethods": {
1313
"fs_read_text_file": "fs/read_text_file",

typescript/acp.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ export class AgentSideConnection {
7979
}
8080
case schema.AGENT_METHODS.session_prompt: {
8181
const validatedParams = schema.promptRequestSchema.parse(params);
82-
return agent.prompt(validatedParams as schema.PromptRequest);
82+
return agent.prompt(validatedParams);
83+
}
84+
case schema.AGENT_METHODS.session_set_model: {
85+
if (!agent.setSessionModel) {
86+
throw RequestError.methodNotFound(method);
87+
}
88+
const validatedParams =
89+
schema.setSessionModelRequestSchema.parse(params);
90+
return agent.setSessionModel(validatedParams);
8391
}
8492
default:
8593
if (method.startsWith("_")) {
@@ -1191,6 +1199,16 @@ export interface Agent {
11911199
setSessionMode?(
11921200
params: schema.SetSessionModeRequest,
11931201
): Promise<schema.SetSessionModeResponse | void>;
1202+
/**
1203+
* **UNSTABLE**
1204+
*
1205+
* This capability is not part of the spec yet, and may be removed or changed at any point.
1206+
*
1207+
* Select a model for a given session.
1208+
*/
1209+
setSessionModel?(
1210+
params: schema.SetSessionModelRequest,
1211+
): Promise<schema.SetSessionModelResponse | void>;
11941212
/**
11951213
* Authenticates the client using the specified authentication method.
11961214
*

typescript/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export const AGENT_METHODS = {
22
authenticate: "authenticate",
33
initialize: "initialize",
4-
model_select: "session/set_model",
54
session_cancel: "session/cancel",
65
session_load: "session/load",
76
session_new: "session/new",
87
session_prompt: "session/prompt",
98
session_set_mode: "session/set_mode",
9+
session_set_model: "session/set_model",
1010
} as const;
1111

1212
export const CLIENT_METHODS = {

0 commit comments

Comments
 (0)