1pub fn harness_stdio_ambient(method: &str) -> Option<&'static str> {
6 match method {
7 "print" => Some("print"),
8 "println" => Some("println"),
9 "eprint" => Some("eprint"),
10 "eprintln" => Some("eprintln"),
11 "read_line" => Some("read_line"),
12 "prompt" => Some("prompt_user"),
13 _ => None,
14 }
15}
16
17pub fn harness_term_ambient(method: &str) -> Option<&'static str> {
18 match method {
19 "width" => Some("term_width"),
20 "height" => Some("term_height"),
21 "read_password" => Some("read_password"),
22 _ => None,
23 }
24}
25
26pub fn harness_clock_ambient(method: &str) -> Option<&'static str> {
27 match method {
28 "now_ms" => Some("now_ms"),
29 "monotonic_ms" | "elapsed" => Some("monotonic_ms"),
30 "sleep_ms" => Some("sleep_ms"),
31 "timestamp" => Some("timestamp"),
32 _ => None,
33 }
34}
35
36pub fn harness_fs_ambient(method: &str) -> Option<&'static str> {
37 match method {
38 "read_text" | "read" | "read_file" => Some("read_file"),
39 "read_text_result" | "read_result" => Some("read_file_result"),
40 "read_bytes" | "read_file_bytes" => Some("read_file_bytes"),
41 "write_text" | "write" | "write_file" => Some("write_file"),
42 "write_bytes" | "write_file_bytes" => Some("write_file_bytes"),
43 "exists" | "file_exists" => Some("file_exists"),
44 "delete" | "delete_file" | "remove" => Some("delete_file"),
45 "append" | "append_file" => Some("append_file"),
46 "list_dir" | "list" => Some("list_dir"),
47 "mkdir" | "create_dir" => Some("mkdir"),
48 "path_join" => Some("path_join"),
49 "copy" | "copy_file" => Some("copy_file"),
50 "temp_dir" => Some("temp_dir"),
51 "mkdtemp" => Some("mkdtemp"),
52 "stat" => Some("stat"),
53 "rename" | "move" | "move_file" => Some("move_file"),
54 "read_lines" => Some("read_lines"),
55 "walk" | "walk_dir" => Some("walk_dir"),
56 "glob" => Some("glob"),
57 "find_text" => Some("find_text"),
58 _ => None,
59 }
60}
61
62pub fn harness_env_ambient(method: &str) -> Option<&'static str> {
63 match method {
64 "get" => Some("env"),
65 "get_or" => Some("env_or"),
66 _ => None,
67 }
68}
69
70pub fn harness_random_ambient(method: &str) -> Option<&'static str> {
71 match method {
72 "gen_f64" | "f64" | "random" => Some("random"),
73 "gen_u64" | "u64" => Some("random_int"),
74 "gen_range" | "range" | "random_int" | "int" => Some("random_int"),
75 "choice" | "random_choice" => Some("random_choice"),
76 "shuffle" | "random_shuffle" => Some("random_shuffle"),
77 _ => None,
78 }
79}
80
81pub fn harness_net_ambient(method: &str) -> Option<&'static str> {
82 match method {
83 "get" | "http_get" => Some("http_get"),
84 "post" | "http_post" => Some("http_post"),
85 "put" | "http_put" => Some("http_put"),
86 "patch" | "http_patch" => Some("http_patch"),
87 "delete" | "http_delete" => Some("http_delete"),
88 "request" | "http_request" => Some("http_request"),
89 "download" | "http_download" => Some("http_download"),
90 _ => None,
91 }
92}
93
94pub fn harness_process_ambient(method: &str) -> Option<&'static str> {
95 match method {
96 "spawn_captured" => Some("spawn_captured"),
97 _ => None,
98 }
99}
100
101pub fn harness_crypto_ambient(method: &str) -> Option<&'static str> {
102 match method {
103 "sha256" => Some("sha256_hex"),
104 _ => None,
105 }
106}
107
108pub fn harness_system_ambient(method: &str) -> Option<&'static str> {
109 match method {
110 "platform" => Some("system_platform"),
111 "cpu" => Some("system_cpu"),
112 "memory" => Some("system_memory"),
113 "gpus" => Some("system_gpus"),
114 "temperature" => Some("system_temperature"),
115 "processes" => Some("system_processes"),
116 _ => None,
117 }
118}
119
120pub fn harness_llm_ambient(method: &str) -> Option<&'static str> {
121 match method {
122 "catalog" => Some("llm_catalog"),
123 "catalog_refresh" => Some("llm_catalog_refresh"),
124 "providers" => Some("llm_provider_status"),
125 _ => None,
126 }
127}
128
129pub fn harness_tenant_ambient(method: &str) -> Option<&'static str> {
130 match method {
131 "id" => Some("harness_tenant_id"),
132 "try_id" => Some("harness_tenant_try_id"),
133 _ => None,
134 }
135}
136
137pub fn harness_auth_ambient(method: &str) -> Option<&'static str> {
138 match method {
139 "is_authenticated" => Some("harness_auth_is_authenticated"),
140 "subject" => Some("harness_auth_subject"),
141 "try_subject" => Some("harness_auth_try_subject"),
142 "scheme" => Some("harness_auth_scheme"),
143 "try_scheme" => Some("harness_auth_try_scheme"),
144 "kind" => Some("harness_auth_kind"),
145 "scopes" => Some("harness_auth_scopes"),
146 "has_scope" => Some("harness_auth_has_scope"),
147 _ => None,
148 }
149}
150
151pub fn harness_obs_ambient(method: &str) -> Option<&'static str> {
152 match method {
153 "span" | "start_span" => Some("__obs_start_span"),
154 "end_span" => Some("__obs_end_span"),
155 "log" => Some("__obs_emit"),
156 "counter" => Some("__obs_counter"),
157 "histogram" => Some("__obs_histogram"),
158 "gauge" => Some("__obs_gauge"),
159 "request_id" => Some("__obs_request_id"),
160 _ => None,
161 }
162}
163
164pub fn harness_sub_handle_ambient(sub_handle: &str, method: &str) -> Option<&'static str> {
165 match sub_handle {
166 "stdio" => harness_stdio_ambient(method),
167 "term" => harness_term_ambient(method),
168 "clock" => harness_clock_ambient(method),
169 "fs" => harness_fs_ambient(method),
170 "env" => harness_env_ambient(method),
171 "random" => harness_random_ambient(method),
172 "net" => harness_net_ambient(method),
173 "process" => harness_process_ambient(method),
174 "crypto" => harness_crypto_ambient(method),
175 "system" => harness_system_ambient(method),
176 "llm" => harness_llm_ambient(method),
177 "tenant" => harness_tenant_ambient(method),
178 "auth" => harness_auth_ambient(method),
179 "obs" => harness_obs_ambient(method),
180 _ => None,
181 }
182}
183
184pub fn harness_type_sub_handle(type_name: &str) -> Option<&'static str> {
185 match type_name {
186 "HarnessStdio" => Some("stdio"),
187 "HarnessTerm" => Some("term"),
188 "HarnessClock" => Some("clock"),
189 "HarnessFs" => Some("fs"),
190 "HarnessEnv" => Some("env"),
191 "HarnessRandom" => Some("random"),
192 "HarnessNet" => Some("net"),
193 "HarnessProcess" => Some("process"),
194 "HarnessCrypto" => Some("crypto"),
195 "HarnessSystem" => Some("system"),
196 "HarnessLlm" => Some("llm"),
197 "HarnessTenant" => Some("tenant"),
198 "HarnessAuth" => Some("auth"),
199 "HarnessObs" => Some("obs"),
200 _ => None,
201 }
202}
203
204pub fn harness_fs_replacement(name: &str) -> Option<&'static str> {
205 match name {
206 "read_file" => Some("harness.fs.read_text"),
207 "read_file_result" => Some("harness.fs.read_text_result"),
208 "read_file_bytes" => Some("harness.fs.read_bytes"),
209 "write_file" => Some("harness.fs.write_text"),
210 "write_file_bytes" => Some("harness.fs.write_bytes"),
211 "file_exists" => Some("harness.fs.exists"),
212 "delete_file" => Some("harness.fs.delete"),
213 "append_file" => Some("harness.fs.append"),
214 "list_dir" => Some("harness.fs.list_dir"),
215 "mkdir" => Some("harness.fs.mkdir"),
216 "copy_file" => Some("harness.fs.copy"),
217 "temp_dir" => Some("harness.fs.temp_dir"),
218 "mkdtemp" => Some("harness.fs.mkdtemp"),
219 "stat" => Some("harness.fs.stat"),
220 "move_file" => Some("harness.fs.rename"),
221 "read_lines" => Some("harness.fs.read_lines"),
222 "walk_dir" => Some("harness.fs.walk"),
223 "glob" => Some("harness.fs.glob"),
224 "find_text" => Some("harness.fs.find_text"),
225 _ => None,
226 }
227}