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
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,12 @@ jobs:
shell: bash
run: |
set -euo pipefail
# 0.19's TypeScript test tool runs plugins on a real rutis-host; the
# The TypeScript test tool runs plugins on a real rutis-host; the
# tests run from the repository root, so name it explicitly.
export RUTIS_HOST="$PWD/runtime/node_modules/.bin/rutis-host"
node --test runtime/plugin-sdk.test.mjs runtime/light-ocr-*.test.mjs
# The workflow plugin tests stay off: no double of a
# test's can receive the plugin definition they register, because
# 0.19.3's test tool does not take one (rutis-0.19-upgrade M10). The
# Node-backed Rust flows below still load it for real, and `tsc`
# The workflow plugin has no plugin test that needs a definition
# double; the Node-backed Rust flows load it for real, and `tsc`
# checks it.
node runtime/node_modules/typescript/bin/tsc -p runtime/plugins/workflow/tsconfig.json
export DIM_TEST_NODE="$(command -v node)"
Expand Down
22 changes: 12 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repository = "https://github.com/arcships/dim"
allow_attributes_without_reason = "warn"

[workspace.dependencies]
rutis = "0.19.3"
rutis-loader = { version = "0.19.3", features = ["node"] }
rutis-bridge = "0.19.3"
rutis = "0.23.0"
rutis-loader = { version = "0.23.0", features = ["node"] }
rutis-bridge = "0.23.0"
schemars = "1"
dim-agent-types = { path = "crates/dim-agent-types" }
dim-agent-runtime = { path = "crates/dim-agent-runtime" }
Expand Down
2 changes: 1 addition & 1 deletion crates/dim-agent-capabilities/src/auxiliary_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl HostDispatch for AuxiliaryModel {

fn invoke(&self, method: &str, args: Value) -> Reply {
if method != "complete" {
return Err(Error::Value(format!(
return Err(Error::value(format!(
"unknown auxiliaryModel method {method}"
)));
}
Expand Down
17 changes: 8 additions & 9 deletions crates/dim-agent-capabilities/src/file_storage/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,13 @@ impl HostDispatch for FsHost {

fn invoke(&self, method: &str, args: Value) -> Reply {
let [request]: [serde_json::Value; 1] = serde_json::from_value(args.json()?)
.map_err(|error| Error::Value(error.to_string()))?;
.map_err(|error| Error::value(error.to_string()))?;
if !request.is_object() {
return Err(Error::Value("fsHost request must be an object".into()));
return Err(Error::value("fsHost request must be an object"));
}
let request: Request =
serde_json::from_value(serde_json::json!({"method":method,"request":request}))
.map_err(|error| Error::Value(error.to_string()))?;
.map_err(|error| Error::value(error.to_string()))?;
let caller = rutis_bridge::session::caller_row().map(|row| row.ctx().clone());
let owner = self.clone();
Ok(Value::cancellable_future(async move {
Expand All @@ -494,8 +494,8 @@ impl HostDispatch for FsHost {
.map_err(failure)?
),
Request::Lock(request) => {
let caller = caller
.ok_or_else(|| Error::Value("fsHost.lock requires a calling row".into()))?;
let caller =
caller.ok_or_else(|| Error::value("fsHost.lock requires a calling row"))?;
let id = owner
.lock(&caller, &request.path, &cancel)
.await
Expand Down Expand Up @@ -562,14 +562,13 @@ impl HostDispatch for FsHost {
serde_json::json!({})
}
Request::OpenRead(request) => {
let caller = caller.ok_or_else(|| {
Error::Value("fsHost.openRead requires a calling row".into())
})?;
let caller = caller
.ok_or_else(|| Error::value("fsHost.openRead requires a calling row"))?;
let result = owner
.open_read(&caller, request.path, &cancel)
.await
.map_err(failure)?;
serde_json::to_value(result).map_err(|error| Error::Value(error.to_string()))?
serde_json::to_value(result).map_err(|error| Error::value(error.to_string()))?
}
Request::ReadAt(request) => {
let bytes = owner
Expand Down
19 changes: 9 additions & 10 deletions crates/dim-agent-capabilities/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ pub fn foreign_handler(call: Reference) -> Handler {
let [data]: [BridgeValue; 1] = args
.list()?
.try_into()
.map_err(|_| BridgeError::Value("progress needs one argument".into()))?;
.map_err(|_| BridgeError::value("progress needs one argument"))?;
progress.send(data.json()?);
Ok(BridgeValue::Undefined)
});
Expand All @@ -906,7 +906,7 @@ pub fn foreign_handler(call: Reference) -> Handler {
let reply = reply
.and_then(|value| {
serde_json::from_value::<ForeignReply>(value)
.map_err(|error| BridgeError::Value(error.to_string()))
.map_err(|error| BridgeError::value(error.to_string()))
})
.map_err(|error| {
rethrown(&error).unwrap_or_else(|| {
Expand Down Expand Up @@ -1099,22 +1099,21 @@ impl HostDispatch for ForeignMethods {
}
fn invoke(&self, method: &str, args: BridgeValue) -> Reply {
if method != "register" {
return Err(BridgeError::Value(format!("no method {method}")));
return Err(BridgeError::value(format!("no method {method}")));
}
let caller = rutis_bridge::session::caller_row()
.map(|row| row.ctx().clone())
.ok_or_else(|| {
BridgeError::Value(
"register needs the calling row's context: only a row of a language runtime can call it"
.into(),
BridgeError::value(
"register needs the calling row's context: only a row of a language runtime can call it",
)
})?;
let mut args = match args {
BridgeValue::Undefined => Vec::new(),
args => args.list()?,
};
if args.len() > 3 {
return Err(BridgeError::Value(format!(
return Err(BridgeError::value(format!(
"expected at most 3 arguments, received {}",
args.len()
)));
Expand All @@ -1126,15 +1125,15 @@ impl HostDispatch for ForeignMethods {
let Some(BridgeValue::Reference(call)) = args.next().filter(
|call| matches!(call, BridgeValue::Reference(reference) if reference.is_function()),
) else {
return Err(BridgeError::Value(
"register needs a namespace, its declarations and its call function".into(),
return Err(BridgeError::value(
"register needs a namespace, its declarations and its call function",
));
};
let registered = self
.0
.register_foreign(&caller, &namespace, declarations, call)
.map(|()| BridgeValue::Undefined)
.map_err(|error| BridgeError::Value(error.to_string()));
.map_err(|error| BridgeError::value(error.to_string()));
Ok(BridgeValue::future(async move { registered }))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/dim-agent-capabilities/src/port_faces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub(crate) fn invalid(port: &str, message: impl std::fmt::Display) -> BridgeErro

/// A method the port does not serve.
pub(crate) fn unknown_method(port: &str, method: &str) -> BridgeError {
BridgeError::Value(format!("{port} has no method {method}"))
BridgeError::value(format!("{port} has no method {method}"))
}

/// Runs an owner read in the caller's task. Cancelling or dropping the call
Expand Down
6 changes: 3 additions & 3 deletions crates/dim-agent-capabilities/src/prompt_guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl HostDispatch for ForeignGuideEntries {
}
fn invoke(&self, method: &str, args: Value) -> Reply {
if method != "register" {
return Err(BridgeError::Value(format!(
return Err(BridgeError::value(format!(
"guideEntries has no method {method}"
)));
}
Expand Down Expand Up @@ -305,7 +305,7 @@ fn request(args: Value) -> Result<(GuideScope, GuideEntry), BridgeError> {
args => args.list()?,
};
if args.len() > 2 {
return Err(BridgeError::Value(format!(
return Err(BridgeError::value(format!(
"expected at most 2 arguments, received {}",
args.len()
)));
Expand All @@ -315,7 +315,7 @@ fn request(args: Value) -> Result<(GuideScope, GuideEntry), BridgeError> {
let scope = args.next().expect("two arguments").json()?;
let entry = args.next().expect("two arguments").json()?;
let invalid =
|error| BridgeError::Value(format!("register takes a scope and an entry: {error}"));
|error| BridgeError::value(format!("register takes a scope and an entry: {error}"));
Ok((
serde_json::from_value(scope).map_err(invalid)?,
serde_json::from_value(entry).map_err(invalid)?,
Expand Down
6 changes: 3 additions & 3 deletions crates/dim-agent-capabilities/src/session_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ impl rutis_bridge::session::HostDispatch for SessionFiles {
}
let parameters = args.json()?;
let [mut object] = serde_json::from_value::<[serde_json::Value; 1]>(parameters)
.map_err(|e| Error::Value(e.to_string()))?;
.map_err(|e| Error::value(e.to_string()))?;
object
.as_object_mut()
.ok_or_else(|| Error::Value("Expected one request object".into()))?
.ok_or_else(|| Error::value("Expected one request object"))?
.insert("method".into(), method.into());
let operation: Operation =
serde_json::from_value(object).map_err(|e| Error::Value(e.to_string()))?;
serde_json::from_value(object).map_err(|e| Error::value(e.to_string()))?;
let files = self.0.clone();
Ok(Value::cancellable_future(async move {
let cancel = CancellationToken::new();
Expand Down
17 changes: 8 additions & 9 deletions crates/dim-agent-capabilities/src/tool_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,24 +807,23 @@ impl HostDispatch for ForeignRegistry {
}
fn invoke(&self, method: &str, args: Value) -> Reply {
if method != "register" {
return Err(BridgeError::Value(format!(
return Err(BridgeError::value(format!(
"toolRegistry has no method {method}"
)));
}
let caller = rutis_bridge::session::caller_row()
.map(|row| row.ctx().clone())
.ok_or_else(|| {
BridgeError::Value(
"register needs the calling row's context: only a row of a language runtime can call it"
.into(),
BridgeError::value(
"register needs the calling row's context: only a row of a language runtime can call it",
)
})?;
let mut args = match args {
Value::Undefined => Vec::new(),
args => args.list()?,
};
if args.len() > 3 {
return Err(BridgeError::Value(format!(
return Err(BridgeError::value(format!(
"expected at most 3 arguments, received {}",
args.len()
)));
Expand All @@ -835,20 +834,20 @@ impl HostDispatch for ForeignRegistry {
let Some(Value::Reference(execute)) = args.next().filter(
|execute| matches!(execute, Value::Reference(reference) if reference.is_function()),
) else {
return Err(BridgeError::Value(
"register needs the tool's declaration and its execute function".into(),
return Err(BridgeError::value(
"register needs the tool's declaration and its execute function",
));
};
let options = match args.next().expect("three arguments") {
Value::Undefined => None,
options => Some(options.json()?),
};
let registered = foreign_concurrency(options)
.map_err(|error| BridgeError::Value(error.to_string()))
.map_err(|error| BridgeError::value(error.to_string()))
.and_then(|concurrency| {
self.0
.register_foreign(&caller, declaration, execute, concurrency)
.map_err(|error| BridgeError::Value(error.to_string()))
.map_err(|error| BridgeError::value(error.to_string()))
})
.map(|()| Value::Undefined);
Ok(Value::future(async move { registered }))
Expand Down
Loading