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 _ => None,
58 }
59}
60
61pub fn harness_env_ambient(method: &str) -> Option<&'static str> {
62 match method {
63 "get" => Some("env"),
64 "get_or" => Some("env_or"),
65 _ => None,
66 }
67}
68
69pub fn harness_random_ambient(method: &str) -> Option<&'static str> {
70 match method {
71 "gen_f64" | "f64" | "random" => Some("random"),
72 "gen_u64" | "u64" => Some("random_int"),
73 "gen_range" | "range" | "random_int" | "int" => Some("random_int"),
74 "choice" | "random_choice" => Some("random_choice"),
75 "shuffle" | "random_shuffle" => Some("random_shuffle"),
76 _ => None,
77 }
78}
79
80pub fn harness_net_ambient(method: &str) -> Option<&'static str> {
81 match method {
82 "get" | "http_get" => Some("http_get"),
83 "post" | "http_post" => Some("http_post"),
84 "put" | "http_put" => Some("http_put"),
85 "patch" | "http_patch" => Some("http_patch"),
86 "delete" | "http_delete" => Some("http_delete"),
87 "request" | "http_request" => Some("http_request"),
88 "download" | "http_download" => Some("http_download"),
89 _ => None,
90 }
91}
92
93pub fn harness_process_ambient(method: &str) -> Option<&'static str> {
94 match method {
95 "spawn_captured" => Some("spawn_captured"),
96 _ => None,
97 }
98}
99
100pub fn harness_crypto_ambient(method: &str) -> Option<&'static str> {
101 match method {
102 "sha256" => Some("sha256_hex"),
103 _ => None,
104 }
105}
106
107pub fn harness_system_ambient(method: &str) -> Option<&'static str> {
108 match method {
109 "platform" => Some("system_platform"),
110 "cpu" => Some("system_cpu"),
111 "memory" => Some("system_memory"),
112 "gpus" => Some("system_gpus"),
113 "temperature" => Some("system_temperature"),
114 "processes" => Some("system_processes"),
115 _ => None,
116 }
117}
118
119pub fn harness_llm_ambient(method: &str) -> Option<&'static str> {
120 match method {
121 "catalog" => Some("llm_catalog"),
122 "catalog_refresh" => Some("llm_catalog_refresh"),
123 "providers" => Some("llm_provider_status"),
124 _ => None,
125 }
126}
127
128pub fn harness_tenant_ambient(method: &str) -> Option<&'static str> {
129 match method {
130 "id" => Some("harness_tenant_id"),
131 "try_id" => Some("harness_tenant_try_id"),
132 _ => None,
133 }
134}
135
136pub fn harness_obs_ambient(method: &str) -> Option<&'static str> {
137 match method {
138 "span" | "start_span" => Some("__obs_start_span"),
139 "end_span" => Some("__obs_end_span"),
140 "log" => Some("__obs_emit"),
141 "counter" => Some("__obs_counter"),
142 "histogram" => Some("__obs_histogram"),
143 "gauge" => Some("__obs_gauge"),
144 "request_id" => Some("__obs_request_id"),
145 _ => None,
146 }
147}
148
149pub fn harness_sub_handle_ambient(sub_handle: &str, method: &str) -> Option<&'static str> {
150 match sub_handle {
151 "stdio" => harness_stdio_ambient(method),
152 "term" => harness_term_ambient(method),
153 "clock" => harness_clock_ambient(method),
154 "fs" => harness_fs_ambient(method),
155 "env" => harness_env_ambient(method),
156 "random" => harness_random_ambient(method),
157 "net" => harness_net_ambient(method),
158 "process" => harness_process_ambient(method),
159 "crypto" => harness_crypto_ambient(method),
160 "system" => harness_system_ambient(method),
161 "llm" => harness_llm_ambient(method),
162 "tenant" => harness_tenant_ambient(method),
163 "obs" => harness_obs_ambient(method),
164 _ => None,
165 }
166}
167
168pub fn harness_type_sub_handle(type_name: &str) -> Option<&'static str> {
169 match type_name {
170 "HarnessStdio" => Some("stdio"),
171 "HarnessTerm" => Some("term"),
172 "HarnessClock" => Some("clock"),
173 "HarnessFs" => Some("fs"),
174 "HarnessEnv" => Some("env"),
175 "HarnessRandom" => Some("random"),
176 "HarnessNet" => Some("net"),
177 "HarnessProcess" => Some("process"),
178 "HarnessCrypto" => Some("crypto"),
179 "HarnessSystem" => Some("system"),
180 "HarnessLlm" => Some("llm"),
181 "HarnessTenant" => Some("tenant"),
182 "HarnessObs" => Some("obs"),
183 _ => None,
184 }
185}
186
187pub fn harness_fs_replacement(name: &str) -> Option<&'static str> {
188 match name {
189 "read_file" => Some("harness.fs.read_text"),
190 "read_file_result" => Some("harness.fs.read_text_result"),
191 "read_file_bytes" => Some("harness.fs.read_bytes"),
192 "write_file" => Some("harness.fs.write_text"),
193 "write_file_bytes" => Some("harness.fs.write_bytes"),
194 "file_exists" => Some("harness.fs.exists"),
195 "delete_file" => Some("harness.fs.delete"),
196 "append_file" => Some("harness.fs.append"),
197 "list_dir" => Some("harness.fs.list_dir"),
198 "mkdir" => Some("harness.fs.mkdir"),
199 "copy_file" => Some("harness.fs.copy"),
200 "temp_dir" => Some("harness.fs.temp_dir"),
201 "mkdtemp" => Some("harness.fs.mkdtemp"),
202 "stat" => Some("harness.fs.stat"),
203 "move_file" => Some("harness.fs.rename"),
204 "read_lines" => Some("harness.fs.read_lines"),
205 "walk_dir" => Some("harness.fs.walk"),
206 "glob" => Some("harness.fs.glob"),
207 _ => None,
208 }
209}