Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions rust/acp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ impl Agent for TestAgent {
})
}

async fn send_message(&self, _request: SendMessageParams) -> Result<SendMessageResponse> {
Ok(SendMessageResponse)
async fn send_user_message(
&self,
_request: SendUserMessageParams,
) -> Result<SendUserMessageResponse> {
Ok(SendUserMessageResponse)
}
}

#[async_trait(?Send)]
impl Client for TestClient {
async fn stream_message_chunk(
async fn stream_assistant_message_chunk(
&self,
_request: StreamMessageChunkParams,
) -> Result<StreamMessageChunkResponse> {
Ok(StreamMessageChunkResponse {})
_request: StreamAssistantMessageChunkParams,
) -> Result<StreamAssistantMessageChunkResponse> {
Ok(StreamAssistantMessageChunkResponse {})
}

async fn request_tool_call_confirmation(
Expand Down
45 changes: 22 additions & 23 deletions rust/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ acp_peer!(
AnyClientResult,
CLIENT_METHODS,
(
stream_message_chunk,
"streamMessageChunk",
StreamMessageChunkParams,
StreamMessageChunkResponse
stream_assistant_message_chunk,
"streamAssistantMessageChunk",
StreamAssistantMessageChunkParams,
StreamAssistantMessageChunkResponse
),
(
request_tool_call_confirmation,
Expand Down Expand Up @@ -196,10 +196,10 @@ acp_peer!(
CreateThreadResponse
),
(
send_message,
"sendMessage",
SendMessageParams,
SendMessageResponse
send_user_message,
"sendUserMessage",
SendUserMessageParams,
SendUserMessageResponse
)
);

Expand All @@ -223,22 +223,21 @@ pub struct AuthenticateResponse;

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct Message {
pub role: Role,
pub chunks: Vec<MessageChunk>,
pub struct UserMessage {
pub chunks: Vec<UserMessageChunk>,
}

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum MessageChunk {
pub enum UserMessageChunk {
Text { chunk: String },
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, Eq, PartialEq)]
#[serde(rename_all = "camelCase")]
pub enum Role {
User,
Assistant,
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(tag = "type", rename_all = "camelCase")]
pub enum AssistantMessageChunk {
Text { chunk: String },
Thought { chunk: String },
}

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
Expand Down Expand Up @@ -275,25 +274,25 @@ pub struct ThreadId(pub String);

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct SendMessageParams {
pub struct SendUserMessageParams {
pub thread_id: ThreadId,
pub message: Message,
pub message: UserMessage,
}

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct SendMessageResponse;
pub struct SendUserMessageResponse;

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct StreamMessageChunkParams {
pub struct StreamAssistantMessageChunkParams {
pub thread_id: ThreadId,
pub chunk: MessageChunk,
pub chunk: AssistantMessageChunk,
}

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct StreamMessageChunkResponse;
pub struct StreamAssistantMessageChunkResponse;

#[derive(Debug, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
Expand Down
115 changes: 69 additions & 46 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"$ref": "#/$defs/CreateThreadParams"
},
{
"$ref": "#/$defs/SendMessageParams"
"$ref": "#/$defs/SendUserMessageParams"
}
]
},
Expand All @@ -43,14 +43,14 @@
"$ref": "#/$defs/CreateThreadResponse"
},
{
"$ref": "#/$defs/SendMessageResponse"
"$ref": "#/$defs/SendUserMessageResponse"
}
]
},
"AnyClientRequest": {
"anyOf": [
{
"$ref": "#/$defs/StreamMessageChunkParams"
"$ref": "#/$defs/StreamAssistantMessageChunkParams"
},
{
"$ref": "#/$defs/RequestToolCallConfirmationParams"
Expand All @@ -66,7 +66,7 @@
"AnyClientResult": {
"anyOf": [
{
"$ref": "#/$defs/StreamMessageChunkResponse"
"$ref": "#/$defs/StreamAssistantMessageChunkResponse"
},
{
"$ref": "#/$defs/RequestToolCallConfirmationResponse"
Expand All @@ -79,6 +79,36 @@
}
]
},
"AssistantMessageChunk": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "text"
},
"chunk": {
"type": "string"
}
},
"required": ["type", "chunk"]
},
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "thought"
},
"chunk": {
"type": "string"
}
},
"required": ["type", "chunk"]
}
]
},
"AuthenticateParams": {
"type": "null"
},
Expand Down Expand Up @@ -122,38 +152,6 @@
},
"required": ["isAuthenticated"]
},
"Message": {
"type": "object",
"properties": {
"chunks": {
"type": "array",
"items": {
"$ref": "#/$defs/MessageChunk"
}
},
"role": {
"$ref": "#/$defs/Role"
}
},
"required": ["role", "chunks"]
},
"MessageChunk": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "text"
},
"chunk": {
"type": "string"
}
},
"required": ["type", "chunk"]
}
]
},
"PushToolCallParams": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -228,38 +226,34 @@
},
"required": ["id", "outcome"]
},
"Role": {
"type": "string",
"enum": ["user", "assistant"]
},
"SendMessageParams": {
"SendUserMessageParams": {
"type": "object",
"properties": {
"message": {
"$ref": "#/$defs/Message"
"$ref": "#/$defs/UserMessage"
},
"threadId": {
"$ref": "#/$defs/ThreadId"
}
},
"required": ["threadId", "message"]
},
"SendMessageResponse": {
"SendUserMessageResponse": {
"type": "null"
},
"StreamMessageChunkParams": {
"StreamAssistantMessageChunkParams": {
"type": "object",
"properties": {
"chunk": {
"$ref": "#/$defs/MessageChunk"
"$ref": "#/$defs/AssistantMessageChunk"
},
"threadId": {
"$ref": "#/$defs/ThreadId"
}
},
"required": ["threadId", "chunk"]
},
"StreamMessageChunkResponse": {
"StreamAssistantMessageChunkResponse": {
"type": "null"
},
"ThreadId": {
Expand Down Expand Up @@ -437,6 +431,35 @@
},
"UpdateToolCallResponse": {
"type": "null"
},
"UserMessage": {
"type": "object",
"properties": {
"chunks": {
"type": "array",
"items": {
"$ref": "#/$defs/UserMessageChunk"
}
}
},
"required": ["chunks"]
},
"UserMessageChunk": {
"oneOf": [
{
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "text"
},
"chunk": {
"type": "string"
}
},
"required": ["type", "chunk"]
}
]
}
}
}
16 changes: 8 additions & 8 deletions typescript/acp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
PushToolCallResponse,
RequestToolCallConfirmationParams,
RequestToolCallConfirmationResponse,
SendMessageParams,
SendMessageResponse,
StreamMessageChunkParams,
StreamMessageChunkResponse,
SendUserMessageParams,
SendUserMessageResponse,
StreamAssistantMessageChunkParams,
StreamAssistantMessageChunkResponse,
UpdateToolCallParams,
UpdateToolCallResponse,
} from "./acp.js";
Expand Down Expand Up @@ -216,16 +216,16 @@ class StubAgent implements Agent {
createThread(_: CreateThreadParams): Promise<CreateThreadResponse> {
throw new Error("Method not implemented.");
}
sendMessage(_: SendMessageParams): Promise<SendMessageResponse> {
sendUserMessage(_: SendUserMessageParams): Promise<SendUserMessageResponse> {
throw new Error("Method not implemented.");
}
}

class StubClient implements Client {
constructor(private agent: Agent) {}
streamMessageChunk(
_: StreamMessageChunkParams,
): Promise<StreamMessageChunkResponse> {
streamAssistantMessageChunk(
_: StreamAssistantMessageChunkParams,
): Promise<StreamAssistantMessageChunkResponse> {
throw new Error("Method not implemented.");
}
requestToolCallConfirmation(
Expand Down
Loading