Documentation

Learn the concepts and tools behind Pod-OS

Rust SDK

The pod-os-rust-client crate is an async Tokio client with wire-compatible framing to the Go SDK, concurrent response dispatch, opt-in validation, and embedded knowledge prompts for coding agents.

Repository: github.com/PointOfData/pod-os-rust-client

The podos CLI is built on this crate.

Install

# Cargo.toml
[dependencies]
pod-os-client = { git = "https://github.com/PointOfData/pod-os-rust-client" }
tokio = { version = "1", features = ["full"] }

Connect and send

use pod_os_client::{
    client::Client,
    config::Config,
    message::{intents, get_timestamp, types::{Envelope, EventFields, Message}},
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cfg = Config {
        host:               "gateway-nlb.example.com".to_string(),
        port:               "62312".to_string(),
        client_name:        "my-agent".to_string(),
        gateway_actor_name: "zeroth.customer.example.com".to_string(),
        enable_concurrent_mode: true,
        ..Default::default()
    };

    let client = Client::new(cfg.clone()).await?;

    let mut msg = Message {
        envelope: Envelope {
            to:     "Foobar@zeroth.customer.example.com".to_string(),
            from:   format!("{}@{}", cfg.client_name, cfg.gateway_actor_name),
            intent: intents::STORE_EVENT.clone(),
            ..Default::default()
        },
        event: Some(EventFields {
            id:        "evt-001".to_string(),
            owner:     "owner-001".to_string(),
            timestamp: get_timestamp(),
            r#type:    "observation".to_string(),
            ..Default::default()
        }),
        ..Default::default()
    };

    let resp = client.send_message(&mut msg).await?;
    println!("status: {}", resp.processing_status());
    Ok(())
}

Intents

use pod_os_client::message::intents;

// Neural Memory (messageType 1000 / 1001)
intents::STORE_EVENT
intents::STORE_DATA
intents::STORE_BATCH_EVENTS
intents::STORE_BATCH_TAGS
intents::GET_EVENT
intents::GET_EVENTS_FOR_TAGS
intents::LINK_EVENT
intents::UNLINK_EVENT
intents::STORE_BATCH_LINKS

// Gateway / Actor
intents::GATEWAY_ID
intents::GATEWAY_STREAM_ON
intents::ACTOR_ECHO
intents::STATUS_REQUEST
intents::STATUS

Validation and knowledge

export PODOS_VALIDATE=1
let errs = msg.validate();
if !errs.is_empty() {
    eprintln!("{}", pod_os_client::message::ValidationReport(errs));
}

use pod_os_client::knowledge;
let doc = knowledge::get_document("neural-memory")?;

Socket Actor health

use pod_os_client::respond_to_health_checks;

let client = Client::new(Config {
    enable_concurrent_mode: true,
    ..Default::default()
}).await?;
respond_to_health_checks(client.clone());

Reading links

GetEvent and GetEventsForTags put Linked on response.event_records[].links. strength is the returned or matched object toward its neighbor. StoreBatchLinks and LinkEvent still send LinkFields (strength_a, strength_b). Walkthrough: Query data.

Mapping to Go

Go Rust
podos.Client client::Client
config.Config config::Config
message.IntentType.StoreEvent message::intents::STORE_EVENT
msg.Validate() msg.validate()
knowledge.GetDocument() knowledge::get_document()
podos.RespondToHealthChecks() respond_to_health_checks()

Related