pub struct ExtensionRuntime { /* private fields */ }Implementations§
Source§impl ExtensionRuntime
impl ExtensionRuntime
pub fn new(config: RuntimeConfig) -> Result<Self, RuntimeError>
Sourcepub fn for_test() -> Self
pub fn for_test() -> Self
Construct a runtime with no extensions loaded, for downstream
unit tests that need an ExtensionRuntime instance but do not
exercise real WASM dispatch.
Uses production-safe HostOverrides::default() and a throwaway
discovery path that is never read (no extension is ever loaded).
list_tools returns empty; invoke_tool returns a not-found error.
This exists so crates like greentic-aw-runtime can build an
Arc<ExtensionRuntime> in --features test-mock unit tests
without a live extension directory. Do NOT use in production.
Sourcepub fn with_host_overrides(self, host_overrides: HostOverrides) -> Self
pub fn with_host_overrides(self, host_overrides: HostOverrides) -> Self
Replace the HostOverrides bundle used for every dispatch. Call
once at startup with adapters that wrap real backends (i18n
catalogue, secrets store, allow-listed HTTP client). Without this,
host fns resolve through HostOverrides::default — fine for unit
tests, not for production: i18n returns the key, secrets are empty,
http allow-list is empty.
This is a thin ergonomic wrapper over
RuntimeConfig::with_host_overrides for callers that already hold
an ExtensionRuntime instance:
let runtime = ExtensionRuntime::new(config)?
.with_host_overrides(production_overrides);pub fn engine(&self) -> &Engine
pub fn subscribe(&self) -> Receiver<RuntimeEvent>
pub fn config(&self) -> &RuntimeConfig
pub fn loaded(&self) -> Arc<HashMap<ExtensionId, LoadedExtensionRef>> ⓘ
pub fn capability_registry(&self) -> Arc<CapabilityRegistry> ⓘ
pub fn register_loaded_from_dir( &mut self, dir: &Path, ) -> Result<(), RuntimeError>
Sourcepub fn start_watcher(self: Arc<Self>) -> Result<WatcherGuard, RuntimeError>
pub fn start_watcher(self: Arc<Self>) -> Result<WatcherGuard, RuntimeError>
Spawns a watcher background thread. Events trigger reload of the
affected extension’s directory. Returns a stop sender — dropping or
sending on it signals the watcher thread to exit. Also returns the
thread JoinHandle for callers that want to wait for clean shutdown.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn invoke_tool(
&self,
ext_id: &str,
tool_name: &str,
args_json: &str,
) -> Result<String, RuntimeError>
pub fn invoke_tool( &self, ext_id: &str, tool_name: &str, args_json: &str, ) -> Result<String, RuntimeError>
Invoke a named tool on a loaded extension.
Builds a fresh wasmtime Store + Instance, calls
greentic:extension-design/tools::invoke-tool (resolved
newest-first across 0.3.0/0.2.0/0.1.0; WIT errors surface as
RuntimeError::Extension), and returns the JSON result string.
Sourcepub fn invoke_tool_ctx(
&self,
ext_id: &str,
tool_name: &str,
args_json: &str,
ctx: &HostCallContext,
) -> Result<String, RuntimeError>
pub fn invoke_tool_ctx( &self, ext_id: &str, tool_name: &str, args_json: &str, ctx: &HostCallContext, ) -> Result<String, RuntimeError>
Like Self::invoke_tool but threads a per-call
crate::host_ports::HostCallContext (e.g. the caller’s tenant slug)
into the host ports for this dispatch. Multi-tenant hosts (the
designer) use this so the LLM port can resolve roles per-tenant.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn evaluate_guardrail(
&self,
ext_id: &str,
input_json: &str,
) -> Result<String, RuntimeError>
pub fn evaluate_guardrail( &self, ext_id: &str, input_json: &str, ) -> Result<String, RuntimeError>
Evaluate a guardrail extension against input_json and return the
verdict as a JSON string.
Loads the extension identified by ext_id, resolves the
greentic:extension-design/guardrail@0.3.0 interface, calls the
evaluate export, and maps the returned verdict variant to
crate::GuardrailVerdictWire serialised as JSON.
input_json must be a JSON object with fields matching the WIT
guardrail-input record:
{
"direction": "inbound",
"content": "…",
"agent_id": "…",
"session_id": "…",
"tenant_id": "…",
"env_id": "…",
"context": null
}Returns the verdict as JSON, e.g. {"kind":"accept"} or
{"kind":"deny","code":"…","message":"…","details":null}.
§Errors
RuntimeError::NotFoundwhen no extension is loaded atext_id.RuntimeError::Wasmtimewhen store/instance construction fails, the interface is not exported, the typed-func call fails, orinput_jsoncannot be deserialised.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn validate_content(
&self,
ext_id: &str,
content_type: &str,
content_json: &str,
) -> Result<ValidateResult, RuntimeError>
pub fn validate_content( &self, ext_id: &str, content_type: &str, content_json: &str, ) -> Result<ValidateResult, RuntimeError>
Validate extension-specific content against the extension’s schema.
Calls greentic:extension-design/validation::validate-content
(resolved against @0.2.0 first, then @0.1.0).
content_type is an extension-defined label (e.g. "AdaptiveCard"
for the adaptive-cards extension); content_json is the content
payload as a JSON string.
Returns a [types::ValidateResult] with a valid flag and a list of
diagnostics (error/warning/info/hint severities). Extensions that
don’t export this interface surface a Wasmtime error — callers
that want graceful degradation should treat “interface not exported”
as “no validation available” rather than a hard failure.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn list_tools(
&self,
ext_id: &str,
) -> Result<Vec<ToolDefinition>, RuntimeError>
pub fn list_tools( &self, ext_id: &str, ) -> Result<Vec<ToolDefinition>, RuntimeError>
List all tools exposed by a loaded design extension.
Calls greentic:extension-design/tools::list-tools (resolved
against @0.2.0 first, then @0.1.0) for v1-contract
extensions. v2 contract (apiVersion == "greentic.ai/v2")
reads the tools from describe.contributions.tools[] — the
runtime WIT no longer exports list-tools in that contract.
The declarative v2 entries only carry name + export, so
description / input_schema_json come back empty; callers
that need full schemas must introspect the named WIT export.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn prompt_fragments(
&self,
ext_id: &str,
) -> Result<Vec<PromptFragment>, RuntimeError>
pub fn prompt_fragments( &self, ext_id: &str, ) -> Result<Vec<PromptFragment>, RuntimeError>
Retrieve system prompt fragments from a loaded design extension.
Calls greentic:extension-design/prompting::system-prompt-fragments
(resolved against @0.2.0 first, then @0.1.0).
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn knowledge_list(
&self,
ext_id: &str,
category_filter: Option<&str>,
) -> Result<Vec<KnowledgeEntrySummary>, RuntimeError>
pub fn knowledge_list( &self, ext_id: &str, category_filter: Option<&str>, ) -> Result<Vec<KnowledgeEntrySummary>, RuntimeError>
List knowledge entries, optionally filtered by category.
Calls greentic:extension-design/knowledge::list-entries
(resolved against @0.2.0 first, then @0.1.0).
Sourcepub fn knowledge_get(
&self,
ext_id: &str,
entry_id: &str,
) -> Result<KnowledgeEntry, RuntimeError>
pub fn knowledge_get( &self, ext_id: &str, entry_id: &str, ) -> Result<KnowledgeEntry, RuntimeError>
Retrieve a single knowledge entry by ID.
Calls greentic:extension-design/knowledge::get-entry, resolving the
interface newest-first across @0.3.0/@0.2.0/@0.1.0. The matched
version selects which extension-error ABI to deserialize (6-variant
base at @0.3.0, 4-variant base at @0.2.0/@0.1.0); WIT errors
surface as RuntimeError::Extension.
Sourcepub fn knowledge_suggest(
&self,
ext_id: &str,
query: &str,
limit: u32,
) -> Result<Vec<KnowledgeEntrySummary>, RuntimeError>
pub fn knowledge_suggest( &self, ext_id: &str, query: &str, limit: u32, ) -> Result<Vec<KnowledgeEntrySummary>, RuntimeError>
Suggest knowledge entries matching a query.
Calls greentic:extension-design/knowledge::suggest-entries
(resolved against @0.2.0 first, then @0.1.0).
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn validate_credentials(
&self,
ext_id: &str,
target_id: &str,
credentials_json: &str,
) -> Result<Vec<Diagnostic>, RuntimeError>
pub fn validate_credentials( &self, ext_id: &str, target_id: &str, credentials_json: &str, ) -> Result<Vec<Diagnostic>, RuntimeError>
Ask a deploy extension to validate a credentials JSON payload for the given target. Returns diagnostics; empty slice means valid.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn credential_schema(
&self,
ext_id: &str,
target_id: &str,
) -> Result<String, RuntimeError>
pub fn credential_schema( &self, ext_id: &str, target_id: &str, ) -> Result<String, RuntimeError>
Return the JSON Schema (as a string) describing credentials required by the given deploy target.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn list_targets(
&self,
ext_id: &str,
) -> Result<Vec<TargetSummary>, RuntimeError>
pub fn list_targets( &self, ext_id: &str, ) -> Result<Vec<TargetSummary>, RuntimeError>
Enumerate targets exported by a loaded deploy extension.
Returns the list-targets output as host-side TargetSummary values.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn render_bundle(
&self,
ext_id: &str,
recipe_id: &str,
config_json: &str,
session: BundleSession,
) -> Result<BundleArtifact, RuntimeError>
pub fn render_bundle( &self, ext_id: &str, recipe_id: &str, config_json: &str, session: BundleSession, ) -> Result<BundleArtifact, RuntimeError>
Render a bundle artefact by dispatching to a loaded bundle
extension’s bundling.render export.
Mirrors the in-process call site that replaces the legacy
greentic-bundle ext render subprocess pipeline. The host
passes the designer session (flow JSON, content JSON, asset
blobs, capability list) and a recipe-specific config string;
the extension’s WASM returns the rendered bytes (typically a
.gtpack zip) plus the canonical filename and sha256 the
extension wants written.
Returns RuntimeError::NotFound when no extension is loaded
at ext_id. The bundling interface is resolved newest-first
across @0.2.0/@0.1.0; host-level failures surface as
RuntimeError::Wasmtime, while the extension’s WIT-level error
surfaces as RuntimeError::Extension (6-variant base at @0.2.0,
4-variant base at @0.1.0).
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn deploy(
&self,
ext_id: &str,
req: DeployRequest,
) -> Result<DeployJob, RuntimeError>
pub fn deploy( &self, ext_id: &str, req: DeployRequest, ) -> Result<DeployJob, RuntimeError>
Start a deployment inside the extension. Returns the initial job.
Calls greentic:extension-deploy/deployment::deploy, resolving the
interface newest-first across @0.2.0/@0.1.0. The matched version
selects the extension-error ABI (6-variant base at @0.2.0,
4-variant base at @0.1.0). The call is synchronous and may take up
to ~2 minutes for network-bound extensions (artifact upload); run it
on a blocking thread.
Sourcepub fn deploy_poll(
&self,
ext_id: &str,
job_id: &str,
) -> Result<DeployJob, RuntimeError>
pub fn deploy_poll( &self, ext_id: &str, job_id: &str, ) -> Result<DeployJob, RuntimeError>
Poll a previously started deployment job.
Sourcepub fn deploy_rollback(
&self,
ext_id: &str,
job_id: &str,
) -> Result<(), RuntimeError>
pub fn deploy_rollback( &self, ext_id: &str, job_id: &str, ) -> Result<(), RuntimeError>
Roll back a previously started deployment job.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn invoke_composer_metadata(
&self,
ext_id: &str,
) -> Result<String, RuntimeError>
pub fn invoke_composer_metadata( &self, ext_id: &str, ) -> Result<String, RuntimeError>
Call greentic:dw-composer/composer::metadata and return the JSON
descriptor string.
The designer parses the returned JSON into its own ComposerDescriptor
type. No input argument is required — the function takes no parameters.
§Errors
Returns RuntimeError::NotFound when no extension is loaded at
ext_id, and RuntimeError::Wasmtime for any host-level failure
(missing interface, trap, type mismatch).
Sourcepub fn invoke_composer_compose(
&self,
ext_id: &str,
intent_json: &str,
) -> Result<Result<String, HostExtensionError>, RuntimeError>
pub fn invoke_composer_compose( &self, ext_id: &str, intent_json: &str, ) -> Result<Result<String, HostExtensionError>, RuntimeError>
Call greentic:dw-composer/composer::compose(intent_json) and return
the rendered manifest JSON on success or a canonical
crate::types::HostExtensionError on failure.
intent_json is a JSON-serialised ComposeIntent whose schema is
defined by the specific composer extension. The Ok variant carries
the rendered manifest JSON; the Err variant carries a
HostExtensionError (v0.1.0 bare strings map to Internal).
§Errors
Returns RuntimeError::NotFound when no extension is loaded at
ext_id, and RuntimeError::Wasmtime for any host-level failure
(missing interface, trap, type mismatch). A business-logic failure
inside the composer is NOT a RuntimeError — it is the
Err(HostExtensionError) inside the returned
Ok(Result<String, HostExtensionError>).
Sourcepub fn invoke_composer_validate(
&self,
ext_id: &str,
manifest_json: &str,
) -> Result<String, RuntimeError>
pub fn invoke_composer_validate( &self, ext_id: &str, manifest_json: &str, ) -> Result<String, RuntimeError>
Call greentic:dw-composer/composer::validate(manifest_json) and
return the JSON validation report string.
The returned string is a JSON-serialised ValidationReport (exact
schema is defined by the composer extension — typically an array of
diagnostic objects or an object with a valid boolean field).
§Errors
Returns RuntimeError::NotFound when no extension is loaded at
ext_id, and RuntimeError::Wasmtime for host-level failures.
Sourcepub fn invoke_composer_templates(
&self,
ext_id: &str,
) -> Result<String, RuntimeError>
pub fn invoke_composer_templates( &self, ext_id: &str, ) -> Result<String, RuntimeError>
Call greentic:dw-composer/composer::templates and return the JSON
array string of ComposerTemplate objects.
§Errors
Returns RuntimeError::NotFound when no extension is loaded at
ext_id, and RuntimeError::Wasmtime for host-level failures.
Source§impl ExtensionRuntime
impl ExtensionRuntime
Sourcepub fn list_roles(&self, ext_id: &str) -> Result<Vec<RoleSpec>, RuntimeError>
pub fn list_roles(&self, ext_id: &str) -> Result<Vec<RoleSpec>, RuntimeError>
List all roles exposed by a loaded design extension.
Calls greentic:extension-design/roles::list-roles (resolved against
@0.3.0 first, then @0.2.0).
Returns an empty vec when the extension does not export the
roles interface (older 0.1.0 extensions, for example) so
callers can treat it as “no roles published” without reaching
for RuntimeError::Wasmtime.
Sourcepub fn validate_role(
&self,
ext_id: &str,
name: &str,
entry_json: &str,
) -> Result<Vec<Diagnostic>, RuntimeError>
pub fn validate_role( &self, ext_id: &str, name: &str, entry_json: &str, ) -> Result<Vec<Diagnostic>, RuntimeError>
Run the cheap-path validator for a role’s DSL entry.
Calls greentic:extension-design/roles::validate-role (resolved
against @0.3.0 first, then @0.2.0).
Returns the diagnostic list verbatim (empty = valid, mirrors the
WIT contract). RuntimeError is reserved for host failures —
missing extension, missing interface, wasmtime trap.
Sourcepub fn compile_role(
&self,
ext_id: &str,
name: &str,
target: TargetKind,
entry_json: &str,
ctx: Option<&CompileContext>,
) -> Result<String, RoleError>
pub fn compile_role( &self, ext_id: &str, name: &str, target: TargetKind, entry_json: &str, ctx: Option<&CompileContext>, ) -> Result<String, RoleError>
Compile a single DSL entry to its target representation.
Calls greentic:extension-design/roles::compile-role (resolved against
@0.3.0 first, then @0.2.0). A missing extension surfaces as
RoleError::UnknownRole(ext_id) (the registry can’t tell “no
extension” apart from “no role” from the LLM’s perspective and both
should retry with a hint). Host failures (wasmtime trap, missing
interface) surface as RoleError::Host(HostExtensionError::Internal(_))
so the caller can match exhaustively without juggling two error types.
Auto Trait Implementations§
impl !Freeze for ExtensionRuntime
impl !RefUnwindSafe for ExtensionRuntime
impl !UnwindSafe for ExtensionRuntime
impl Send for ExtensionRuntime
impl Sync for ExtensionRuntime
impl Unpin for ExtensionRuntime
impl UnsafeUnpin for ExtensionRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more