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
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[registries.vtuber-registry]
index = "http://kellnr.cntm.labs:31500/api/v1/crates"
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@vtuber:registry=http://kellnr.cntm.labs:31500/api/v1/npm/
//kellnr.cntm.labs:31500/api/v1/npm/:_authToken=${SHARED_TOKEN}
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ repository = "https://github.com/echo-layer/vtuber-contracts"
readme = "README.md"
keywords = ["vtuber", "grpc", "protobuf", "contracts"]
categories = ["api-bindings"]
publish = ["vtuber-registry"]

[dependencies]
prost = "0.13"
prost-types = "0.13"
tonic = { version = "0.12", default-features = false, features = ["codegen", "prost"] }
serde = { version = "1.0", features = ["derive"] }
pbjson = "0.7"
pbjson-types = "0.7"

[build-dependencies]
tonic-build = { version = "0.12", default-features = false, features = ["prost"] }
pbjson-build = "0.7"

[dev-dependencies]
serde_yaml = "0.9"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0"
25 changes: 16 additions & 9 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
use std::env;
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let descriptor_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("proto_descriptor.bin");

let protos = &[
"proto/vtuber/v1/persona.proto",
"proto/vtuber/v1/voice_profile.proto",
"proto/vtuber/v1/conversation.proto",
"proto/vtuber/v1/voice_profile.proto",
"proto/vtuber/v1/persona.proto",
"proto/vtuber/v1/tool_call.proto",
"proto/vtuber/v1/assets.proto",
];

for p in protos {
println!("cargo:rerun-if-changed={p}");
}
println!("cargo:rerun-if-changed=build.rs");

tonic_build::configure()
.build_server(true)
.build_client(true)
.file_descriptor_set_path(&descriptor_path)
.extern_path(".google.protobuf.Timestamp", "::pbjson_types::Timestamp")
.extern_path(".google.protobuf.Struct", "::pbjson_types::Struct")
.compile_protos(protos, &["proto"])?;

let descriptor_set = std::fs::read(&descriptor_path)?;
pbjson_build::Builder::new()
.register_descriptors(&descriptor_set)?
.build(&[".vtuber.v1"])?;

Ok(())
}
3 changes: 3 additions & 0 deletions pip.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[global]
extra-index-url = http://kellnr.cntm.labs:31500/api/v1/pypi/simple
trusted-host = kellnr.cntm.labs
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
pub mod vtuber {
pub mod v1 {
tonic::include_proto!("vtuber.v1");
include!(concat!(env!("OUT_DIR"), "/vtuber.v1.serde.rs"));
}
}

Expand Down
20 changes: 20 additions & 0 deletions tests/serde_roundtrip.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use vtuber_contracts::vtuber::v1::ConversationDirective;

#[test]
fn test_directive_serde_json() {
let directive = ConversationDirective {
directive_id: "test-123".to_string(),
text_prompt: "Hello".to_string(),
..Default::default()
};

// Serialize to JSON
let json = serde_json::to_string(&directive).expect("Failed to serialize");
println!("Serialized JSON: {}", json);

// Deserialize back to struct
let decoded: ConversationDirective = serde_json::from_str(&json).expect("Failed to deserialize");

assert_eq!(directive.directive_id, decoded.directive_id);
assert_eq!(directive.text_prompt, decoded.text_prompt);
}
Loading