Expand description
§Gestalt Rust SDK
Use the Rust SDK to build compiled Gestalt providers with typed routers,
serde input and output types, and schema-derived catalog metadata.
The package is published to crates.io as gestalt-sdk, while Rust code imports
the crate as gestalt.
cargo add gestalt-sdk --rename gestalt
cargo add serde --features derive
cargo add schemars --features derive§Quick start
Register typed operations on a router. The router dispatches requests and emits
catalog metadata for gestaltd.
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[derive(Default)]
struct SearchProvider;
#[gestalt::async_trait]
impl gestalt::Provider for SearchProvider {}
#[derive(Deserialize, JsonSchema)]
struct SearchInput {
#[schemars(description = "Search query")]
query: String,
}
#[derive(Serialize, JsonSchema)]
struct SearchOutput {
results: Vec<String>,
}
fn router() -> gestalt::Result<gestalt::Router<SearchProvider>> {
gestalt::Router::new().register(
gestalt::Operation::<SearchInput, SearchOutput>::new("search")
.method("GET")
.title("Search"),
|_: Arc<SearchProvider>, input, _request| async move {
Ok::<_, gestalt::Error>(gestalt::ok(SearchOutput {
results: vec![input.query],
}))
},
)
}
gestalt::export_provider!(constructor = SearchProvider::default, router = router);Fields are required unless they are modeled as Option<T> or have a serde
default. Use schemars attributes for catalog descriptions.
§Provider surfaces
Use Provider, Operation, Router, and export_provider! for integration
providers. Use the other provider traits and export macros when you are serving
a host-service backend.
| Trait | Export macro | Use it when you want to serve |
|---|---|---|
AuthenticationProvider | export_authentication_provider! | Login flows. |
CacheProvider | export_cache_provider! | Plugin-bound cache storage. |
S3Provider | export_s3_provider! | S3-compatible object storage. |
SecretsProvider | export_secrets_provider! | Secret resolution. |
WorkflowProvider | export_workflow_provider! | Workflow runs, schedules, and event triggers. |
AgentProvider | export_agent_provider! | Agent sessions, turns, events, interactions, and capabilities. |
PluginRuntimeProvider | export_plugin_runtime_provider! | Hosted plugin execution backends. |
The crate also exposes clients for sibling host services, including Cache,
S3, WorkflowHost, WorkflowManager, AgentHost, AgentManager, and
PluginInvoker.
§Codegen strategy
Bindings are checked into
src/generated
so crate consumers do not need a protobuf toolchain when building
gestalt-sdk.
Maintainers regenerate them from the shared proto definitions in
sdk/proto
with the Buf template in
sdk/proto/buf.rust.gen.yaml.
Use the same Buf CLI version as CI for deterministic remote-plugin output.
To regenerate the bindings:
sdk/rust/scripts/generate_stubs.sh§Public surface
The crate keeps generated bindings behind a higher-level authoring API:
Provider,Request,Response, andok(...)model integration providers.RouterandOperationregister typed operations and derive catalog metadata fromserdeandschemars.AuthenticationProvider,CacheProvider,S3Provider,SecretsProvider,WorkflowProvider,AgentProvider, andPluginRuntimeProvidermodel executable provider runtimes.Cache,S3,WorkflowHost,WorkflowManager,AgentHost,AgentManager, andPluginInvokercall sibling host services.RuntimeMetadatalets provider runtimes describe their display metadata and version.runtimecontains entrypoints for serving provider surfaces over the Unix socket exposed bygestaltd.proto::v1exposes generated protocol bindings for low-level integration work.
§Package layout
This package intentionally lives outside the existing gestalt/ Cargo
workspace so the SDK can evolve independently of the CLI crate graph.
Re-exports§
pub use indexeddb::Cursor;pub use indexeddb::CursorDirection;pub use indexeddb::ENV_INDEXEDDB_SOCKET;pub use indexeddb::IndexedDB;pub use indexeddb::IndexedDBError;pub use indexeddb::Transaction;pub use indexeddb::TransactionDurabilityHint;pub use indexeddb::TransactionIndexClient;pub use indexeddb::TransactionMode;pub use indexeddb::TransactionObjectStore;pub use indexeddb::TransactionOptions;pub use indexeddb::indexeddb_socket_env;pub use indexeddb::indexeddb_socket_token_env;pub use s3::ENV_S3_SOCKET;pub use s3::ENV_S3_SOCKET_TOKEN;pub use s3::S3;pub use s3::S3Error;pub use s3::S3Provider;pub use s3::s3_socket_env;pub use s3::s3_socket_token_env;
Modules§
- indexeddb
- IndexedDB-style datastore client and provider helpers.
- proto
- Generated protobuf and gRPC bindings for the Gestalt provider protocol.
- runtime
- Runtime entrypoints for serving Gestalt provider surfaces over Unix sockets.
- s3
- S3-compatible client and provider helpers.
- telemetry
- OpenTelemetry helpers for provider-authored GenAI instrumentation. OpenTelemetry helpers for provider-authored GenAI instrumentation.
Macros§
- export_
agent_ provider - Exports the agent-provider entrypoint expected by
gestaltd. - export_
authentication_ provider - Exports the authentication-provider entrypoint expected by
gestaltd. - export_
cache_ provider - Exports the cache-provider entrypoint expected by
gestaltd. - export_
plugin_ runtime_ provider - Exports the plugin-runtime-provider entrypoint expected by
gestaltd. - export_
provider - Exports the integration-provider entrypoints expected by
gestaltd. - export_
s3_ provider - Exports the S3-provider entrypoint expected by
gestaltd. - export_
secrets_ provider - Exports the secrets-provider entrypoint expected by
gestaltd. - export_
workflow_ provider - Exports the workflow-provider entrypoint expected by
gestaltd.
Structs§
- Access
- Summarizes the host-side access decision attached to an operation.
- Agent
Host - Client for the agent host service available inside agent providers.
- Agent
Manager - Client for managing agent sessions, turns, events, and interactions.
- Authenticated
User - AuthenticatedUser is the normalized user identity returned by an authentication provider after a login or token-validation flow.
- Begin
Login Request - BeginLoginRequest starts an interactive login flow.
- Begin
Login Response - BeginLoginResponse returns the provider-managed authorization URL and opaque provider state that must be preserved until completion.
- Cache
- Client for a running cache provider.
- Cache
Entry - One cache entry written through
Cache::set_many. - Cache
SetOptions - Options applied to cache writes.
- Complete
Login Request - CompleteLoginRequest finishes an interactive login flow.
- Credential
- Describes the resolved credential used to authorize an operation.
- Error
- Error returned by typed provider handlers and runtime helpers.
- Host
- Describes public host metadata attached to a request.
- Invocation
Grant - Grant included when exchanging an invocation token for a child token.
- Invoke
Options - Options that select the target connection for a plugin invocation.
- Operation
- Describes one statically declared executable operation.
- Plugin
Invoker - Client for invoking sibling plugin operations through the host.
- Request
- Carries execution-scoped metadata into typed operation handlers.
- Response
- Wraps a typed handler response plus an optional explicit HTTP status code.
- Router
- Dispatches typed operations and exposes the corresponding static catalog.
- Runtime
LogHost - Client for appending plugin-runtime logs to the host.
- Runtime
Metadata - Describes provider metadata that should be surfaced by the runtime.
- Subject
- Identifies the caller that initiated an operation.
- Workflow
Host - Client for invoking operations from workflow provider code.
- Workflow
Manager - Client for starting workflow runs and managing schedules or triggers.
Enums§
- Agent
Host Error - Errors returned by
AgentHost. - Agent
Manager Error - Errors returned by
AgentManager. - Cache
Error - Errors returned by the cache client transport.
- Plugin
Invoker Error - Errors returned by
PluginInvoker. - Runtime
LogHost Error - Errors returned by
RuntimeLogHost. - Workflow
Host Error - Errors returned by
WorkflowHost. - Workflow
Manager Error - Errors returned by
WorkflowManager.
Constants§
- CURRENT_
PROTOCOL_ VERSION - Current Gestalt provider protocol version spoken by this SDK.
- ENV_
AGENT_ HOST_ SOCKET - Environment variable containing the agent-host service target.
- ENV_
AGENT_ HOST_ SOCKET_ TOKEN - Environment variable containing the optional agent-host relay token.
- ENV_
AGENT_ MANAGER_ SOCKET - Environment variable containing the agent-manager host-service target.
- ENV_
AGENT_ MANAGER_ SOCKET_ TOKEN - Environment variable containing the optional agent-manager relay token.
- ENV_
CACHE_ SOCKET - Default Unix-socket environment variable used by
Cache::connect. - ENV_
CACHE_ SOCKET_ TOKEN - Default relay-token environment variable used by
Cache::connect. - ENV_
PLUGIN_ INVOKER_ SOCKET - Environment variable containing the plugin-invoker host-service target.
- ENV_
PLUGIN_ INVOKER_ SOCKET_ TOKEN - Environment variable containing the optional plugin-invoker relay token.
- ENV_
PROVIDER_ SOCKET - Unix socket path exposed by
gestaltdfor the main integration-provider surface. - ENV_
RUNTIME_ LOG_ HOST_ SOCKET - Environment variable containing the runtime-log host-service target.
- ENV_
RUNTIME_ LOG_ HOST_ SOCKET_ TOKEN - Environment variable containing the optional runtime-log relay token.
- ENV_
RUNTIME_ SESSION_ ID - Environment variable containing the current plugin-runtime session id.
- ENV_
WORKFLOW_ HOST_ SOCKET - Environment variable containing the workflow-host service socket path.
- ENV_
WORKFLOW_ MANAGER_ SOCKET - Environment variable containing the workflow-manager host-service target.
- ENV_
WORKFLOW_ MANAGER_ SOCKET_ TOKEN - Environment variable containing the optional workflow-manager relay token.
Traits§
- Agent
Provider - Provider trait for serving the Gestalt agent-provider protocol.
- Authentication
Provider - Lifecycle and login contract for Gestalt authentication providers.
- Cache
Provider - Lifecycle and RPC contract for cache providers.
- Plugin
Runtime Provider - Provider trait for serving hosted plugin-runtime sessions.
- Provider
- Shared lifecycle contract for Gestalt integration providers.
- Secrets
Provider - Lifecycle and lookup contract for secrets providers.
- Workflow
Provider - Provider trait for serving the Gestalt workflow-provider protocol.
Functions§
- cache_
socket_ env - Returns the environment variable used for a named cache socket.
- cache_
socket_ token_ env - Returns the environment variable used for a named cache relay token.
- ok
- Returns a successful JSON response with status code
200. - runtime_
session_ id - Returns the current runtime session id from
GESTALT_RUNTIME_SESSION_ID.
Type Aliases§
- Catalog
- Generated catalog schema used by the provider runtime.
- Catalog
Operation - Generated catalog operation schema.
- Result
- Convenient result alias for Gestalt SDK operations.
- Runtime
LogStream - Runtime log stream enum generated from the provider protocol.