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