1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//! 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
//!
//! ```no_run
//! # async fn _example() -> strike48_connector::Result<()> {
//! 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
//! in [`ToolAdapter`], hand to [`simple::run_tool`].
//! - **Request/response** — implement [`SimpleConnector`] and call its
//! `run` method.
//! - **Web apps** — call [`simple::serve_static`] for a static directory or
//! [`simple::serve_app`] for a dynamic handler (or use [`behaviors::serve::App::builder`]
//! for full control).
//! - **Multiple connectors in one process** — use [`MultiConnectorRunner`]
//! to share a single transport (gRPC: one HTTP/2 channel, N streams).
//! - **Advanced: raw stream callbacks** — implement [`BaseConnector`] and
//! drive it with [`ConnectorRunner`]. 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` — minimal `ToolConnector` + `ToolAdapter`.
//! - `examples/simple_echo.rs` — minimal `SimpleConnector` request/response.
//! - `examples/system_command_tool.rs` — fuller TOOL example.
//! - `examples/app_connector.rs` — APP behavior with `App::builder`.
//! - `examples/auth_app.rs` — APP with custom authentication.
//! - `examples/mixed_connectors.rs` — N **distinct** tools sharing one
//! transport via `MultiConnectorRunner`.
//! - `examples/multi_connector.rs` — N copies of one connector type
//! (shared-channel vs independent-runner benchmark).
//! - `examples/echo_connector.rs` — low-level `BaseConnector` reference.
//! - `examples/one_liner.rs` — `run_connector` / `serve_static` one-liners.
// Internal modules -- not accessible to external consumers
pub
pub
pub
pub
pub
pub
pub
pub
// Public modules
// =============================================================================
// PRELUDE - The simplest way to use this SDK
// =============================================================================
//
// Just add: `use strike48_connector::prelude::*;`
//
// This gives you everything you need to build connectors quickly.
//
pub use prelude;
// Core types
pub use ;
// Multi-registration runner (additive; existing single-registration API unchanged).
pub use ;
pub use ;
pub use *;
pub use ;
// App behavior
pub use ;
pub use ;
// Source behavior
pub use ;
// Sink behavior
pub use ;
// Tool behavior
pub use ;
pub use ToolAdapter;
// PubSub behavior
pub use ;
// RequestResponse behavior
pub use ;
// Utilities
pub use ;
// Async process execution (non-blocking command runner)
pub use ;
// URL parser for auto-detecting transport from URL scheme
pub use ;
// Transport config types (re-exported from internal module)
pub use ;
// Invoke options for ConnectorHandle (re-exported from internal module)
pub use InvokeOptions;
// Logger initialization (re-exported from internal module)
pub use init_logger;
// Advanced: low-level client for connectors that manage their own gRPC streams.
// Prefer `ToolConnector`+`ToolAdapter` (tools) or `SimpleConnector`
// (request/response). `ConnectorRunner`+`BaseConnector` is for advanced cases
// that need raw stream callbacks (e.g. App connectors proxying WebSocket frames).
pub use ;
/// Authentication primitives.
///
/// [`OttProvider`] is the SDK's One-Time-Token / `private_key_jwt` auth
/// provider. It supports four deployment modes (pre-approval OTT,
/// post-approval, Kubernetes cert-manager, direct auth) selected
/// automatically from the environment — see the auth section of the
/// README and the env vars `STRIKE48_REGISTRATION_TOKEN`,
/// `STRIKE48_REGISTRATION_TOKEN_FILE`, `STRIKE48_PRIVATE_KEY_PATH`,
/// `STRIKE48_CLIENT_ID`, `STRIKE48_AUTH_URL`, and `STRIKE48_KEYS_DIR`.
/// Most connectors should not interact with `OttProvider` directly:
/// [`ConnectorRunner`] and [`MultiConnectorRunner`] manage it for you.
///
/// [`OAuthManager`] / [`OAuthError`] cover the user-facing OAuth/PKCE
/// flow used by App connectors that authenticate end users.
pub use ;
// Re-export the `metrics` crate so connector authors can use
// `strike48_connector::metrics::{counter, gauge, histogram}` without
// adding `metrics` to their own Cargo.toml.
pub use metrics;
// =============================================================================
// SIMPLIFIED API - For developers who want the easiest possible experience
// =============================================================================
// Simple connector trait and helpers
pub use ;