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