qefro-backend-sdk
Qefro backend framework for Business Tool handlers and customer authorization (Rust).
Organizations expose one signed webhook (typically POST /qefro). Qefro Runtime calls ping, capabilities.list, tool.invoke, and tool.resume. Authentication stays in your handlers — Qefro only relays challenges.
Companion TypeScript package: @qefro-ai/backend (feature-parity target).
Install
[]
= "1"
= { = "1", = ["macros", "rt-multi-thread", "signal"] }
Quick start
use ;
use json;
async
Set the same signing secret in Admin Console → Business Tools → SDK Connections, then Sync Tools.
Customer Hub (optional)
When QEFRO_CUSTOMER_HUB_ENABLED=true, tools can call Hub via
platform.customer on tool.invoke (or QEFRO_CUSTOMER_HUB_URL + service
token). Hub is optional — defaults keep existing apps working
(ENABLED=false, OPTIONAL=true). Soft-skip returns None / no-ops when
Hub is off or unreachable; set QEFRO_CUSTOMER_HUB_OPTIONAL=false to hard-fail.
app.tool;
Storage bindings (when present in your stack) remain independent — Hub is never
the sole path. External CRM auth via app.customer(provider) is unchanged.
Business Flows
Flows describe how your Business Tools are orchestrated. They are metadata only — the SDK advertises them through capabilities.list and the Qefro Runtime discovers, validates, versions, and executes them. Nothing runs inside the SDK. A flow with a duplicate/empty id (flow or step) is excluded from capabilities.list and surfaced through FlowError instead of panicking.
use BusinessFlowMetadata;
app.flow?
.ask
.tool
.tool
.complete?;
Every step needs a unique id; tool steps reference an existing Business Tool by tool_ref. Step builders: .ask() .tool() .challenge() .upload() .condition() .delay() .approval() .complete_step() .complete() — complete_step() adds a branch terminal mid-chain (e.g. a condition else-target), complete() finishes the flow and surfaces any FlowError. See examples/basic and examples/order-approval (condition + approval + OTP-authenticated tool).
Docs
Protocol
| Message | Purpose |
|---|---|
ping |
Health / Test Connection |
capabilities.list |
Discover tools and business flows for Sync Tools (includes lookup) |
tools.list |
Legacy tool-only discovery (still supported) |
tool.invoke |
Run a handler |
tool.resume |
Continue after a customer challenge reply |
Requests are HMAC-SHA256 signed (X-Qefro-Signature / X-Qefro-Timestamp). Responses include X-Qefro-Protocol, X-Qefro-SDK, and X-Qefro-Version.
Build
Publishing (maintainers)
CI publishes to crates.io via .github/workflows/publish-crates.yml.
- Create a crates.io API token at https://crates.io/settings/tokens (scopes: publish-new / publish-update).
- In GitHub → Settings → Secrets and variables → Actions, add secret
CARGO_REGISTRY_TOKENwith that token value. - Publish either:
- Actions → Publish crates → Run workflow, or
- Create a GitHub Release (triggers publish automatically).
Bump version in Cargo.toml before publishing a new release.
License
MIT