Expand description
Strike48 Connector SDK for Rust.
Build connectors for the Strike48 platform: tool connectors (LLM-callable functions), request/response handlers, static or dynamic web apps, or several of the above running in one process sharing a single transport.
§Quick start: a tool connector
use async_trait::async_trait;
use serde_json::{Value, json};
use strike48_connector::*;
struct Calculator;
#[async_trait]
impl ToolConnector for Calculator {
fn tools(&self) -> Vec<ToolSchema> {
vec![ToolSchema::new("add", "Add two numbers")
.param("a", ParamType::Number, "First operand", true)
.param("b", ParamType::Number, "Second operand", true)]
}
async fn execute(&self, _tool: &str, p: Value) -> ToolResult {
let a = p["a"].as_f64().unwrap_or(0.0);
let b = p["b"].as_f64().unwrap_or(0.0);
ToolResult::success(json!({ "result": a + b }))
}
}
simple::run_tool(
ToolAdapter::new("calculator", Calculator).with_version("1.0.0"),
).await§Choosing an entry point
- Tools (LLM-callable functions) — implement
ToolConnector, wrap inToolAdapter, hand tosimple::run_tool. - Request/response — implement
SimpleConnectorand call itsrunmethod. - Web apps — call
simple::serve_staticfor a static directory orsimple::serve_appfor a dynamic handler (or usebehaviors::serve::App::builderfor full control). - Multiple connectors in one process — use
MultiConnectorRunnerto share a single transport (gRPC: one HTTP/2 channel, N streams). - Advanced: raw stream callbacks — implement
BaseConnectorand drive it withConnectorRunner. Required for App connectors that proxy WebSocket frames.
§Per-request context (multi-tenant deployments)
Both runners forward the server-supplied ExecuteRequest.context map
to connectors via BaseConnector::execute_with_context (and, for
tool connectors, ToolConnector::execute_with_context). Override the
context-aware variant when your connector needs caller metadata such
as tenant_id. The default implementations delegate to the
existing execute methods, so connectors that don’t care about
context continue to work unchanged.
§Configuration
All entry points read connection settings from the environment via
ConnectorConfig::from_env. The most common variables are
STRIKE48_HOST (or STRIKE48_URL), TENANT_ID, INSTANCE_ID,
AUTH_TOKEN, and USE_TLS. See ConnectorConfig::from_env for the
full list, and the README for storage paths and TLS overrides.
§Examples in this repo
examples/calculator_tool.rs— minimalToolConnector+ToolAdapter.examples/simple_echo.rs— minimalSimpleConnectorrequest/response.examples/system_command_tool.rs— fuller TOOL example.examples/app_connector.rs— APP behavior withApp::builder.examples/auth_app.rs— APP with custom authentication.examples/mixed_connectors.rs— N distinct tools sharing one transport viaMultiConnectorRunner.examples/multi_connector.rs— N copies of one connector type (shared-channel vs independent-runner benchmark).examples/echo_connector.rs— low-levelBaseConnectorreference.examples/one_liner.rs—run_connector/serve_staticone-liners.
Re-exports§
pub use simple::prelude;pub use connector::BaseConnector;pub use connector::ConnectorConfig;pub use connector::ConnectorHandle;pub use connector::ConnectorRunner;pub use connector::InvokeCapabilityOptions;pub use connector::ShutdownHandle;pub use error::ConnectorError;pub use error::Result;pub use multi::ConnectorRegistration;pub use multi::MultiConnectorRunner;pub use multi::MultiTransportOptions;pub use multi::MultiTransportOptionsBuilder;pub use multi::RegistrationKey;pub use utils::deserialize_payload;pub use utils::error_response;pub use utils::serialize_payload;pub use utils::success_response;pub use behaviors::app::AppConnector;pub use behaviors::app::AppManifest;pub use behaviors::app::AppPageRequest;pub use behaviors::app::AppPageResponse;pub use behaviors::app::BodyEncoding;pub use behaviors::app::StaticFileConfig;pub use behaviors::serve::App;pub use behaviors::serve::AppBuilder;pub use behaviors::source::FetchRequest;pub use behaviors::source::FetchResponse;pub use behaviors::source::SourceConfig;pub use behaviors::source::SourceConnector;pub use behaviors::sink::IdempotentSink;pub use behaviors::sink::ItemError;pub use behaviors::sink::SinkConfig;pub use behaviors::sink::SinkConnector;pub use behaviors::sink::WriteResult;pub use behaviors::tool::ParamType;pub use behaviors::tool::ParameterSchema;pub use behaviors::tool::ToolConnector;pub use behaviors::tool::ToolParam;pub use behaviors::tool::ToolResult;pub use behaviors::tool::ToolSchema;pub use behaviors::tool_adapter::ToolAdapter;pub use behaviors::pubsub::InMemoryPubSub;pub use behaviors::pubsub::Message;pub use behaviors::pubsub::PubSubConfig;pub use behaviors::pubsub::PubSubConnector;pub use behaviors::pubsub::PublishOptions;pub use behaviors::pubsub::SubscribeOptions;pub use behaviors::pubsub::Subscription;pub use behaviors::pubsub::SubscriptionError;pub use behaviors::pubsub::TopicPattern;pub use behaviors::request_response::BatchRequest;pub use behaviors::request_response::BatchResponse;pub use behaviors::request_response::ConcurrentRequestHandler;pub use behaviors::request_response::RequestContext;pub use behaviors::request_response::RequestError;pub use behaviors::request_response::RequestMetrics;pub use behaviors::request_response::RequestResponseConfig;pub use behaviors::request_response::RequestResponseConnector;pub use behaviors::request_response::Response;pub use behaviors::utilities::Cache;pub use behaviors::utilities::CacheStats;pub use behaviors::utilities::OperationMetrics;pub use behaviors::utilities::RetryConfig;pub use behaviors::utilities::Timer;pub use behaviors::utilities::ValidationError;pub use behaviors::utilities::retry_async;pub use behaviors::utilities::timed;pub use behaviors::utilities::validate_against_schema;pub use behaviors::utilities::validate_json;pub use process::CommandBuilder;pub use process::CommandOptions;pub use process::CommandOutput;pub use process::run_command;pub use process::run_command_opts;pub use process::run_command_stdout;pub use process::run_command_with_timeout;pub use process::run_shell;pub use process::run_shell_with_timeout;pub use url_parser::ParsedEndpoint;pub use url_parser::get_transport_from_url;pub use url_parser::is_valid_url;pub use url_parser::parse_url;pub use simple::SimpleConnector;pub use simple::html;pub use simple::json;pub use simple::not_found;pub use simple::run_connector;pub use simple::run_tool;pub use simple::serve_app;pub use simple::serve_static;pub use metrics;pub use types::*;
Modules§
- behaviors
- Behavior-specific connectors for Strike48.
- connector
- context
- Per-request execution context surfaced via
crate::BaseConnector::execute_with_context. - error
- multi
- Multi-registration connector runner.
- process
- Async process execution utilities for connector implementations.
- simple
- Simplified API for Strike48 Connectors.
- types
- url_
parser - URL Parser for Strike48 Connector SDK.
- utils
Macros§
- serve_
app - Macro for quickly serving a static site to Strike48.
Structs§
- Client
Options - Client configuration options.
- Connector
Client - gRPC client for connector communication
- Invoke
Options - Options for invoke capability
- OAuth
Manager - Authentication primitives.
- OttProvider
- Authentication primitives.
- Transport
Options - Transport configuration options.
Enums§
- OAuth
Error - Authentication primitives.
- Transport
Type - Transport type identifier.
Functions§
- init_
logger - Initialize the logger with configurable log levels.