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
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always

jobs:
check:
name: Check, Lint & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2

- name: Format
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --all-targets -- -D warnings

- name: Test
run: cargo test --all
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,3 @@ A programming language to interact with WebAssembly components deployed in runti
`wasmtime` can make use of the `rib-repl` crate to interact with WASM components. The `rib-repl` crate provides a REPL interface
to call functions and manipulate data in WASM components running in a Wasmtime environment.
This work is on it's way.

## Golem Integration

While `rib-repl` crate is primarily designed for use with runtimes such as wasmtime,
it is also compatible with other runtimes, including golem. This is proved through `rib-repl-golem`, a binary that can interact with Golem agents.

However, the recommended approach for interacting with Golem agents (implemented as WASM components) is via golem-cli.
This tool is purpose-built for Golem and provides a more native and streamlined experience aligned with Golem’s core concepts.
It also enables interaction with agents using languages such as Rust and TypeScript.

Rib, by contrast, is a WebAssembly-oriented language whose grammar adheres to the WASM-WAVE specification.
It is particularly suitable for users who are familiar with the broader WebAssembly ecosystem.
Rib can be considered a general-purpose interface for interacting with WASM components across different environments.

To interact with a Golem agent using Rib, execute the rib-repl-golem binary with the
appropriate configuration parameters required to connect to the target agent.

Refer to the Golem documentation for instructions on retrieving the necessary identifiers, such as agent-id and env-name.

```sh
cargo run -p rib-repl-golem -- --app-name agent-http-routes-rust --env-name local --agent-id "HttpAgent(test)"
```

7 changes: 3 additions & 4 deletions rib-core/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use crate::analysis::AnalysedType;
use crate::call_type::{CallType, InstanceCreationType};
use crate::call_type::CallType;
use crate::generic_type_parameter::GenericTypeParameter;
use crate::inferred_type::{DefaultType, TypeOrigin};
use crate::parser::block::block;
Expand All @@ -23,10 +23,10 @@ use crate::rib_type_error::RibTypeErrorInternal;
use crate::{
from_string, text, type_checker, type_inference, ComponentDependencies, ComponentDependencyKey,
CustomInstanceSpec, DynamicParsedFunctionName, ExprVisitor, GlobalVariableTypeSpec,
InferredType, InstanceIdentifier, ParsedFunctionName, VariableId,
InferredType, InstanceIdentifier, VariableId,
};
use crate::{IntoValueAndType, ValueAndType};
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
use bigdecimal::{BigDecimal, ToPrimitive};
use combine::parser::char::spaces;
use combine::stream::position;
use combine::Parser;
Expand All @@ -36,7 +36,6 @@ use serde_json::Value;
use std::collections::VecDeque;
use std::fmt::Display;
use std::ops::Deref;
use std::str::FromStr;

#[derive(Debug, Hash, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum Expr {
Expand Down
2 changes: 1 addition & 1 deletion rib-core/src/function_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use combine::stream::position::Stream;
use combine::{eof, EasyParser, Parser};
use semver::{BuildMetadata, Prerelease};

use serde::{Deserialize, Serialize};
use std::fmt::Display;

Expand Down
5 changes: 2 additions & 3 deletions rib-core/src/instance_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use crate::analysis::AnalysedType;
use crate::parser::{PackageName, TypeParameter};
use crate::type_parameter::InterfaceName;
use crate::FunctionName;
use crate::{
ComponentDependencies, ComponentDependencyKey, Expr, FullyQualifiedResourceConstructor,
FunctionDictionary, FunctionType, InferredType, ResourceMethodDictionary,
FunctionDictionary, FunctionType, ResourceMethodDictionary,
};
use std::collections::{BTreeMap, HashMap, HashSet};
use std::convert::TryFrom;

use std::fmt::Debug;
use std::ops::Deref;

Expand Down
1 change: 0 additions & 1 deletion rib-core/src/type_inference/rib_input_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use std::collections::HashMap;
// RibInputTypeInfo refers to the required global inputs to a RibScript
// with its type information. Example: `request` variable which should be of the type `Record`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "poem", oai(rename_all = "camelCase"))]
#[serde(rename_all = "camelCase")]
pub struct RibInputTypeInfo {
pub types: HashMap<String, AnalysedType>,
Expand Down
1 change: 0 additions & 1 deletion rib-core/src/type_inference/rib_output_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::{InferredExpr, RibCompilationError};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "poem", oai(rename_all = "camelCase"))]
#[serde(rename_all = "camelCase")]
pub struct RibOutputTypeInfo {
pub analysed_type: AnalysedType,
Expand Down
53 changes: 1 addition & 52 deletions rib-core/src/wave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::analysis::{
TypeResult, TypeTuple, TypeVariant,
};
use std::borrow::Cow;
use std::fmt::Display;
use wasm_wave::wasm::{DisplayType, WasmFunc, WasmType, WasmTypeKind};
use wasm_wave::wasm::{WasmFunc, WasmType, WasmTypeKind};

impl WasmType for AnalysedType {
fn kind(&self) -> WasmTypeKind {
Expand Down Expand Up @@ -129,53 +128,3 @@ impl WasmFunc for AnalysedFunction {
Box::new(self.result.iter().map(|r| r.typ.clone()))
}
}

pub struct DisplayNamedFunc<T: WasmFunc> {
pub name: String,
pub func: T,
}

impl<T: WasmFunc> Display for DisplayNamedFunc<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&self.name)?;
f.write_str("(")?;
let mut param_names = self.func.param_names();
for (idx, ty) in self.func.params().enumerate() {
if idx != 0 {
f.write_str(", ")?;
}
if let Some(name) = param_names.next() {
write!(f, "{name}: ")?;
}
DisplayType(&ty).fmt(f)?
}
f.write_str(")")?;

let results = self.func.results().collect::<Vec<_>>();
if results.is_empty() {
return Ok(());
}

let mut result_names = self.func.result_names();
if results.len() == 1 {
let ty = DisplayType(&results.into_iter().next().unwrap()).to_string();
if let Some(name) = result_names.next() {
write!(f, " -> ({name}: {ty})")
} else {
write!(f, " -> {ty}")
}
} else {
f.write_str(" -> (")?;
for (idx, ty) in results.into_iter().enumerate() {
if idx != 0 {
f.write_str(", ")?;
}
if let Some(name) = result_names.next() {
write!(f, "{name}: ")?;
}
DisplayType(&ty).fmt(f)?;
}
f.write_str(")")
}
}
}