Expand description
Rust bindings and WASI Preview 1 trampolines for Torana Plugin ABI v1.
The SDK deliberately exposes only the host calls granted by Torana. A plugin cannot gain a capability by importing a function that the operator did not grant.
Modules§
Macros§
- export_
plugin_ v1 - Exports the two functions required by ABI v1:
supported_hooksandrun_hook. The handler receives the typed HookInput and returnsOk(None)for pass-through or one hook-appropriate HookResult.
Structs§
- Assembled
Tool Call - Http
Conversation Binding - Host-owned MCP evidence. A session identity is not a plugin’s thread/state key.
- Http
Result - Native
Host Guard - Installs a native transport for the duration of a test. The guard restores the previous transport on drop and storage is thread-local.
- Request
Result - Response
Result - Route
Applied Info - Host observation for a plugin route verdict. The selected route and the eventual upstream can differ after failover.
- Stream
Assembler - Stream
Feed - Stream
Handler - Stream
Result - Suggestion
Outcome - Tick
Result
Enums§
- Host
Call Error - Error returned by an ABI-v1 host call.
- LogLevel
- Metric
Kind
Constants§
- ABI_
VERSION - Runtime ABI contract identifier. The high 32 bits are the ABI epoch and the low 32 bits are the contract revision within that epoch.
- HOOK_
AFTER_ RESPONSE - HOOK_
BEFORE_ REQUEST - ABI-v1 hook bitmap bits. Bit N corresponds to
pbv1::Hookvalue N. - HOOK_
ON_ HTTP_ REQUEST - HOOK_
ON_ STREAM_ CHUNK - HOOK_
ON_ TICK - LOG_
DEBUG - LOG_
INFO - METRIC_
COUNTER - METRIC_
GAUGE - METRIC_
HISTOGRAM
Traits§
- Plugin
- Typed plugin callbacks cannot return another hook family’s result:
Functions§
- __
plugin_ dispatch - abi_
version - alloc
- Allocates
sizebytes and returns a host-visible pointer. - append_
file - block_
request - cache_
delete - cache_
get - cache_
set - counter
- dealloc
- Frees a buffer previously returned by
alloc.sizemust be the size that was passed toalloc. - debug
- decode_
host_ call_ result - delete_
file - emit_
events - emit_
metric - Emits a metric on a best-effort void host import.
- execution
- extension_
call - Calls one catalogued JSON extension through the same ABI transport as typed protobuf helpers. Both arguments and JSON results use strict object shape.
- gauge
- get_
credential - Resolves one operator-bound credential slot. Treat the returned bytes as a secret and do not place them in logs or diagnostic errors.
- get_
model_ capabilities - Read capabilities for an operator-declared model; unknown models receive a typed host refusal.
- get_
model_ pricing - Resolves one operator-bound pricing resource.
Nonemeans an unknown rate;Some(0.0)is an explicitly free rate. - get_
prompt_ cache_ policy - Resolves one operator-bound prompt-cache-policy resource. The plugin names only its declared slot; provider, model, routing, prices, and lifetime semantics are owned by the binding.
- get_
resource_ info - histogram
- hook_of
- Returns the hook selected by a valid ABI-v1 input envelope.
- host_
call - Invokes a host command with protobuf arguments and decodes the ABI-v1
HostCallResultenvelope. Empty successful values remain distinguishable from typed refusals; callers must branch onHostCallError::Refused’s code, never its diagnostic message. - http_
conversation - Read only from the request supplied to Plugin::on_http. This validates the envelope, not provenance; model arguments and caller-created headers are not trusted evidence. None means ordinary HTTP; Some with bound=false means MCP explicitly reported an unbound call. Neither authorizes scoped state access.
- http_
request - info
- install_
native_ host - list_
files - log
- Logs a bounded diagnostic string when the host granted
env.log. Delivery is best effort: the void ABI import cannot report refusal. - meta_
append - meta_
get - meta_
set - model_
complete - Invokes one operator-bound model-service slot. Provider, URL, model, credentials, and hard budgets are owned by the binding, not by the plugin.
- model_
complete_ text - move_
cache_ breakpoint - pass_
event - pass_
http - pass_
request - pass_
response - pass_
tick - plugin_
config - read_
file - replace_
request - replace_
response - replace_
tool_ result_ text - replace_
tool_ result_ with_ error - Replaces a tool result with one safe text arm per cache-delimited segment and marks the result as an explicit tool error. Cache markers are preserved byte-for-byte and in their original relative order. Validation completes before mutation.
- request_
id - respond_
request - respond_
text - route_
applied - Read the optional host-owned route observation on an after-response hook.
- route_
request - route_
request_ with_ effort - Route with an explicitly operator-authorized effort. UNSPECIFIED leaves the harness’s effort untouched. The route is atomic: if the host refuses the effort, it does not apply the provider or model change either. Handle a refusal explicitly, for example by retrying with route_request (no effort) or passing. Return the error only if the request should fail under the plugin’s failure_mode.
- serve_
http - set_
cache_ breakpoint - set_
identity - set_
text_ at - shared_
cache_ delete - shared_
cache_ get - shared_
cache_ set - state_
compare_ and_ delete - state_
compare_ and_ set - state_
delete - state_
get - state_
get_ versioned - state_
keys - state_
scan - state_
set - suggest
- Submit a conversation-scoped suggestion; the host returns its ID and keeps the confirmation code in the user-delivery channel.
- suggestions
- Read host-owned outcomes scoped to this plugin, never provider-visible.
- tick_
outcome - torana_
mcp - Read the host’s MCP-connection observation when one has been published.
- write_
file