Skip to main content

agent_hub_runtime/core/preview/
execution.rs

1//! Immutable execution location captured from the runtime configuration.
2use super::runtime::BrowserProfile;
3use serde::Serialize;
4#[derive(Clone, Copy, Serialize)]
5#[serde(rename_all = "snake_case")]
6/// Chromium process selected by the profile; external endpoints are not host attestation.
7pub enum Renderer {
8    Client,
9    Server,
10}
11#[derive(Clone, Copy, Serialize)]
12#[serde(rename_all = "snake_case")]
13/// Explicit proxy routing or the selected browser host's default network policy.
14pub enum Network {
15    ClientDefault,
16    ServerDefault,
17    Proxy,
18}
19#[derive(Clone, Copy, Serialize)]
20/// Location snapshot retained by the native page for its runtime lifetime.
21pub struct Execution {
22    pub render: Renderer,
23    pub network: Network,
24}
25impl Execution {
26    /// Capture a configuration after runtime startup validates the profile.
27    pub fn from_profile(profile: &BrowserProfile) -> Self {
28        Self {
29            render: if profile.endpoint.is_some() {
30                Renderer::Server
31            } else {
32                Renderer::Client
33            },
34            network: if profile.proxy.is_some() {
35                Network::Proxy
36            } else if profile.endpoint.is_some() {
37                Network::ServerDefault
38            } else {
39                Network::ClientDefault
40            },
41        }
42    }
43}
44
45#[cfg(test)]
46mod tests;