systemprompt_models/mcp/
execution_source.rs1use schemars::JsonSchema;
14use serde::{Deserialize, Serialize};
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
23#[serde(rename_all = "snake_case")]
24pub enum ExecutionSource {
25 InProcess,
26 Proxy,
27 Gateway,
28 HookClaudeCode,
29 HookOpenCode,
30}
31
32impl ExecutionSource {
33 pub const ALL: [Self; 5] = [
34 Self::InProcess,
35 Self::Proxy,
36 Self::Gateway,
37 Self::HookClaudeCode,
38 Self::HookOpenCode,
39 ];
40
41 #[must_use]
42 pub const fn as_str(self) -> &'static str {
43 match self {
44 Self::InProcess => "in_process",
45 Self::Proxy => "proxy",
46 Self::Gateway => "gateway",
47 Self::HookClaudeCode => "hook_claude_code",
48 Self::HookOpenCode => "hook_opencode",
49 }
50 }
51
52 #[must_use]
53 pub fn parse(value: &str) -> Option<Self> {
54 Self::ALL.into_iter().find(|s| s.as_str() == value)
55 }
56
57 #[must_use]
58 pub const fn is_server_observed(self) -> bool {
59 matches!(self, Self::InProcess | Self::Proxy)
60 }
61
62 #[must_use]
63 pub const fn from_hook_host(host: crate::bridge::host::HostKind) -> Self {
64 match host.product() {
65 crate::bridge::host::HostProduct::OpenCode => Self::HookOpenCode,
66 crate::bridge::host::HostProduct::Claude
67 | crate::bridge::host::HostProduct::Codex
68 | crate::bridge::host::HostProduct::Hermes => Self::HookClaudeCode,
69 }
70 }
71}
72
73impl std::fmt::Display for ExecutionSource {
74 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
75 f.write_str(self.as_str())
76 }
77}
78
79#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]
85#[serde(rename_all = "snake_case")]
86pub enum Correlation {
87 Exact,
88 Inferred,
89}
90
91impl Correlation {
92 #[must_use]
93 pub const fn as_str(self) -> &'static str {
94 match self {
95 Self::Exact => "exact",
96 Self::Inferred => "inferred",
97 }
98 }
99
100 #[must_use]
101 pub fn parse(value: &str) -> Option<Self> {
102 match value {
103 "exact" => Some(Self::Exact),
104 "inferred" => Some(Self::Inferred),
105 _ => None,
106 }
107 }
108}
109
110impl std::fmt::Display for Correlation {
111 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
112 f.write_str(self.as_str())
113 }
114}