pub struct PackRuntime { /* private fields */ }Implementations§
Source§impl PackRuntime
impl PackRuntime
pub fn contains_component(&self, component_ref: &str) -> bool
Sourcepub fn state_store_handle(&self) -> Option<Arc<dyn StateStore>>
pub fn state_store_handle(&self) -> Option<Arc<dyn StateStore>>
Returns a clonable handle to the pack’s state store, when one is
configured. Used by the flow engine’s built-in state.get/state.set
operators which call into the same store that WASM components read
through their state.read/state.write host imports.
pub async fn load( path: impl AsRef<Path>, config: Arc<HostConfig>, mocks: Option<Arc<MockLayer>>, archive_source: Option<&Path>, session_store: Option<Arc<dyn SessionStore>>, state_store: Option<Arc<dyn StateStore>>, wasi_policy: Arc<RunnerWasiPolicy>, secrets: Arc<dyn SecretsManager>, oauth_config: Option<OAuthBrokerConfig>, verify_archive: bool, component_resolution: ComponentResolution, ) -> Result<PackRuntime, Error>
Sourcepub fn set_runtime_config_non_secret(
&mut self,
map: Option<Arc<BTreeMap<String, Value>>>,
)
pub fn set_runtime_config_non_secret( &mut self, map: Option<Arc<BTreeMap<String, Value>>>, )
Inject the pack-config.v1.non_secret map for this pack. Called by
the producer (greentic-start, C4.3) after loading the deployed
PackConfig. Passing None clears any previously-set map.
Sourcepub fn runtime_config_non_secret(&self) -> Option<&Arc<BTreeMap<String, Value>>>
pub fn runtime_config_non_secret(&self) -> Option<&Arc<BTreeMap<String, Value>>>
Read-only accessor for the injected pack-config.v1.non_secret map.
Used by the revision loader’s tests to assert producer plumbing.
Sourcepub fn set_runtime_refs(&mut self, injection: Option<RuntimeRefsInjection>)
pub fn set_runtime_refs(&mut self, injection: Option<RuntimeRefsInjection>)
Inject the pack-config.v1.runtime_refs channel (C5): per-pack
key → URI bindings plus the env-shared resolver. Called by
greentic-start after loading the deployed PackConfig. Passing
None clears any previously-set injection.
Sourcepub fn runtime_refs(&self) -> Option<&RuntimeRefsInjection>
pub fn runtime_refs(&self) -> Option<&RuntimeRefsInjection>
Read-only accessor for the injected runtime-refs channel. Used by the revision loader’s tests to assert producer plumbing.
pub async fn list_flows(&self) -> Result<Vec<FlowDescriptor>, Error>
pub async fn run_flow( &self, flow_id: &str, input: Value, ) -> Result<Value, Error>
pub async fn invoke_component( &self, component_ref: &str, ctx: ExecCtx, operation: &str, config_json: Option<String>, input_json: String, ) -> Result<Value, Error>
pub fn resolve_provider( &self, provider_id: Option<&str>, provider_type: Option<&str>, ) -> Result<ProviderBinding, Error>
pub async fn invoke_provider( &self, binding: &ProviderBinding, ctx: ExecCtx, op: &str, input_json: Vec<u8>, ) -> Result<Value, Error>
Sourcepub async fn invoke_identify_instance(
&self,
binding: &ProviderBinding,
payload: Vec<u8>,
) -> Result<IdentifyOutcome, Error>
pub async fn invoke_identify_instance( &self, binding: &ProviderBinding, payload: Vec<u8>, ) -> Result<IdentifyOutcome, Error>
Call the provider component’s identify-instance export
(greentic:provider-instance-identity@0.1.0) with the inbound
payload bytes. Returns an IdentifyOutcome — see the variant
docs for the per-case contract.
§Payload shape (M1 IID.4d wrapper)
payload is forwarded opaque to the component. The shape is set by
the caller; the M1 IID.4d wrapper convention from greentic-start
is {headers: [{name,value}], body: <parsed-or-null>} so providers
whose discriminator lives in HTTP headers (Telegram via
x-telegram-bot-api-secret-token) can identify the instance the
same call shape that body-based providers (Teams, Slack, Webex,
etc.) use. See the docstring on
greentic:provider-instance-identity/instance-identity-api.identify-instance
for the full contract; this host method does not parse or
validate the bytes.
§Host authority on identity probes
The linker registers the full host import surface (Wasmtime
validates all imports eagerly at instantiate_pre, not just
those reachable from the invoked export). The WASI sandbox is
locked down: no preopens, no env, no stdio. Deny-shim linker
handlers (trap on call, satisfy at link time) are a follow-up
in greentic-interfaces-wasmtime. See register_identity_probe.
Sourcepub async fn invoke_describe_identify_instance(
&self,
binding: &ProviderBinding,
) -> Result<Option<IdentifyInstanceHint>, Error>
pub async fn invoke_describe_identify_instance( &self, binding: &ProviderBinding, ) -> Result<Option<IdentifyInstanceHint>, Error>
Call the provider component’s describe-identify-instance export
(greentic:provider-instance-identity/instance-identity-describe@0.1.0)
and parse the returned JSON into an IdentifyInstanceHint.
Returns Ok(None) for every “no hint available” case: the
component does not export the describe world, the export returned
none, the returned bytes are not valid JSON, or the version
gate failed. The two malformed cases are warn-logged so a typo’d
hint surfaces in operator logs without blocking ingest. Component
traps and other infrastructure errors propagate as Err.
This is the uncached probe — see resolve_identify_hint for the
cached wrapper that callers SHOULD use on the inbound hot path.
Sourcepub async fn resolve_identify_hint(
&self,
binding: &ProviderBinding,
) -> Option<IdentifyInstanceHint>
pub async fn resolve_identify_hint( &self, binding: &ProviderBinding, ) -> Option<IdentifyInstanceHint>
Cached wrapper around invoke_describe_identify_instance. The
hint for a given binding.component_ref is invariant across
inbound requests within a revision (it is a function of the
component itself, not of the payload), so we probe lazily on
first ask and reuse thereafter. ArcSwap-driven revision swaps
allocate a fresh PackRuntime, naturally invalidating the cache.
Returns None when the component does not export the describe
world, when the probe returns no hint, or when the probe fails
(trap, timeout, instantiation error). Failures are warn-logged
and cached — the same trap is logged once per revision per
component, not per request.
Sourcepub async fn describe_identify_hints_by_provider_type(
&self,
provider_types: &[&str],
) -> Result<HashMap<String, Option<IdentifyInstanceHint>>, Error>
pub async fn describe_identify_hints_by_provider_type( &self, provider_types: &[&str], ) -> Result<HashMap<String, Option<IdentifyInstanceHint>>, Error>
Fan out resolve_identify_hint over each requested provider_type.
Result map is keyed by provider_type; None value means the
pack has no binding for that type OR the binding’s component does
not export the describe world (unhinted — caller forwards input
headers unfiltered for back-compat).
provider_id-collision errors from ProviderRegistry::resolve
against a provider_type query are propagated (M1.1 invariant
violation, malformed pack).
Fan out resolve_identify_hint across requested types. None value
means the pack has no binding for that type OR the binding’s component
does not export the describe world.
The per-binding loop is inlined (rather than factored into a shared
AsyncFnMut-based helper) deliberately: routing through an
AsyncFnMut closure destabilises HRTB Send inference for the
returned future, which propagates up to host-level fan-out APIs and
from there to downstream spawned-service consumers. See the
regression test identify_futures_are_send on the host.
Sourcepub async fn identify_endpoints_by_provider_type(
&self,
provider_types: &[&str],
payload: &[u8],
) -> Result<HashMap<String, IdentifyOutcome>, Error>
pub async fn identify_endpoints_by_provider_type( &self, provider_types: &[&str], payload: &[u8], ) -> Result<HashMap<String, IdentifyOutcome>, Error>
Unscoped legacy API: fan out invoke_identify_instance with the
caller-supplied opaque payload bytes forwarded verbatim. No
describe-identify-instance hint lookup, no per-provider header
scoping. New callers should use the _scoped sibling for
per-provider header allowlist scoping (Phase D).
Loop inlined for the same reason as
describe_identify_hints_by_provider_type.
Sourcepub async fn identify_endpoints_by_provider_type_scoped(
&self,
provider_types: &[&str],
headers: &[(String, String)],
body: &Value,
) -> Result<HashMap<String, IdentifyOutcome>, Error>
pub async fn identify_endpoints_by_provider_type_scoped( &self, provider_types: &[&str], headers: &[(String, String)], body: &Value, ) -> Result<HashMap<String, IdentifyOutcome>, Error>
Per-provider scoped variant of identify_endpoints_by_provider_type.
The wrapper payload is built per-binding from (headers, body) and
the component’s cached identify-instance hint (see
resolve_identify_hint): hinted providers see only the headers
their hint declares; unhinted providers see every header passed in.
Result-map semantics match the unscoped variant.
Loop inlined for the same reason as
describe_identify_hints_by_provider_type.
pub fn load_flow(&self, flow_id: &str) -> Result<Flow, Error>
pub fn metadata(&self) -> &PackMetadata
Sourcepub fn read_asset(&self, asset_path: &str) -> Result<Vec<u8>, Error>
pub fn read_asset(&self, asset_path: &str) -> Result<Vec<u8>, Error>
Read an asset file from the pack’s assets directory.
Accepts paths like assets/cards/card-a.json or cards/card-a.json
(the assets/ prefix is stripped automatically).
pub fn component_manifest( &self, component_ref: &str, ) -> Option<&ComponentManifest>
Sourcepub fn component_manifest_entries(
&self,
) -> impl Iterator<Item = (&str, &ComponentManifest)>
pub fn component_manifest_entries( &self, ) -> impl Iterator<Item = (&str, &ComponentManifest)>
Iterate every (component_ref, manifest) this pack holds. Used by the
agentic-worker component tool source to enumerate the operations a
worker may call as tools without exposing the internal manifest map.
Sourcepub fn manifest_agent_blobs(&self) -> BTreeMap<String, Value>
pub fn manifest_agent_blobs(&self) -> BTreeMap<String, Value>
Returns the raw agent config blobs embedded in this pack’s manifest.
Only present on the New (greentic_types::PackManifest) path; Legacy
packs do not carry agent config and return an empty map. Callers
(e.g. TenantRuntime::from_packs) deserialize these blobs into
concrete AgentConfig structs via
agent_node::agent_configs_from_manifest.
Sourcepub fn read_agent_graph_sidecar(&self) -> Option<Vec<u8>>
pub fn read_agent_graph_sidecar(&self) -> Option<Vec<u8>>
Read the optional agent-graph.json sidecar embedded at the pack root.
Returns the raw bytes when present, or None when the pack carries no
sidecar (the common case). Tries the materialized pack directory first,
then the .gtpack archive — mirroring load_schema_json’s resolution.
IO/zip errors are logged and treated as “absent” so a damaged or
unreadable sidecar never aborts pack loading; the caller
(graph_node::graph_config_from_sidecar) then validates the bytes.
Sourcepub fn dw_agents_sidecar_blobs(&self) -> BTreeMap<String, Value>
pub fn dw_agents_sidecar_blobs(&self) -> BTreeMap<String, Value>
Raw agent-config blobs from the optional dw-agents.json sidecar.
Designer-built packs (old greentic-pack, which cannot populate
manifest.agents) embed their AgentConfig map here. Returns an empty
map when the sidecar is absent or unparseable (lenient, mirroring
PackRuntime::manifest_agent_blobs) so a damaged sidecar never aborts
pack loading. manifest.agents remains authoritative; callers fill only
the agent_ids the manifest did not carry.
Sourcepub fn secrets(&self) -> &Arc<dyn SecretsManager> ⓘ
pub fn secrets(&self) -> &Arc<dyn SecretsManager> ⓘ
Read a single named file from the pack by its archive-relative path,
trying the materialized pack directory first and the .gtpack archive as
a fallback. Returns None when the file is absent (or on a read error,
which is logged). Used for sidecar files (agent-graph.json) and bundled
assets (knowledge_corpus.json, assets/knowledge/*.txt).
The secrets manager this pack was built with — the HOST’s, not one
derived from the environment.
The MCP flow node needs it to resolve a pack-carried route’s credential.
Deriving its own from SECRETS_BACKEND cannot work: that only knows
env and broker, while an operator booting a bundle runs on
greentic-start’s dev store, which the runner has no variant for. So the
only manager that can read the credential is the one the host already
handed us.
Sourcepub fn mcp_routes(&self) -> Option<&PackMcpRoutes>
pub fn mcp_routes(&self) -> Option<&PackMcpRoutes>
The pack’s own MCP route sidecar, if it carries one.
A pack’s mcp node names only an opaque server id; resolving it
otherwise needs the tenant’s admin catalog, which a deployed runner has
no credentials for. Parsed once and cached; every failure path yields
None so the caller falls back to the admin catalog rather than taking
the whole pack down.
pub fn read_pack_file(&self, name: &str) -> Option<Vec<u8>>
pub fn describe_component_contract_v0_6( &self, component_ref: &str, ) -> Result<Option<Value>, Error>
pub fn load_schema_json(&self, schema_ref: &str) -> Result<Option<Value>, Error>
pub fn required_secrets(&self) -> &[SecretRequirement]
pub fn missing_secrets(&self, tenant_ctx: &TenantCtx) -> Vec<SecretRequirement>
pub fn for_component_test( components: Vec<(String, PathBuf)>, flows: HashMap<String, FlowIR>, pack_id: &str, config: Arc<HostConfig>, ) -> Result<PackRuntime, Error>
Auto Trait Implementations§
impl !Freeze for PackRuntime
impl !RefUnwindSafe for PackRuntime
impl !UnwindSafe for PackRuntime
impl Send for PackRuntime
impl Sync for PackRuntime
impl Unpin for PackRuntime
impl UnsafeUnpin for PackRuntime
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request