Skip to content

Commit e64f4af

Browse files
authored
Add a specific "resource not found" error with optional URI data (#116)
* Add a specific "resource not found" error with optional URI data This mirrors the MCP resource not found error. Signed-off-by: Ben Brandt <benjamin.j.brandt@gmail.com> * prep 0.4.3 release --------- Signed-off-by: Ben Brandt <benjamin.j.brandt@gmail.com>
1 parent 5d5fbda commit e64f4af

7 files changed

Lines changed: 40 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.4.3 (2025-09-25)
4+
5+
### Protocol
6+
7+
- Defined `Resource not found` error type as code `-32002` (same as MCP)
8+
9+
### Rust
10+
11+
- impl `Agent` and `Client` for `Rc<T>` and `Arc<T>` where `T` implements either trait.
12+
313
## 0.4.2 (2025-09-22)
414

515
### Rust

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "agent-client-protocol"
33
authors = ["Zed <hi@zed.dev>"]
4-
version = "0.4.2"
4+
version = "0.4.3"
55
edition = "2024"
66
license = "Apache-2.0"
77
description = "A protocol for standardizing communication between code editors and AI coding agents"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zed-industries/agent-client-protocol",
3-
"version": "0.4.2",
3+
"version": "0.4.3",
44
"publishConfig": {
55
"access": "public"
66
},

rust/error.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ impl Error {
9494
Error::new(ErrorCode::AUTH_REQUIRED)
9595
}
9696

97+
/// A given resource, such as a file, was not found.
98+
#[must_use]
99+
pub fn resource_not_found(uri: Option<String>) -> Self {
100+
let err = Error::new(ErrorCode::RESOURCE_NOT_FOUND);
101+
if let Some(uri) = uri {
102+
err.with_data(serde_json::json!({ "uri": uri }))
103+
} else {
104+
err
105+
}
106+
}
107+
97108
/// Converts a standard error into an internal JSON-RPC error.
98109
///
99110
/// The error's string representation is included as additional data.
@@ -153,6 +164,13 @@ impl ErrorCode {
153164
code: -32000,
154165
message: "Authentication required",
155166
};
167+
168+
/// A given resource, such as a file, was not found.
169+
/// This is an ACP-specific error code in the reserved range.
170+
pub const RESOURCE_NOT_FOUND: ErrorCode = ErrorCode {
171+
code: -32002,
172+
message: "Resource not found",
173+
};
156174
}
157175

158176
impl From<ErrorCode> for (i32, String) {

typescript/acp.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,13 @@ export class RequestError extends Error {
963963
return new RequestError(-32000, "Authentication required", data);
964964
}
965965

966+
/**
967+
* Resource, such as a file, was not found
968+
*/
969+
static resourceNotFound(uri?: string): RequestError {
970+
return new RequestError(-32002, "Resource not found", uri && { uri });
971+
}
972+
966973
toResult<T>(): Result<T> {
967974
return {
968975
error: {

0 commit comments

Comments
 (0)