1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub struct StdlibSource {
12 pub module: &'static str,
13 pub source: &'static str,
14}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct StdlibPromptAsset {
18 pub path: &'static str,
19 pub source: &'static str,
20}
21
22macro_rules! embedded_catalog {
23 ($entry:ident, $key:ident, [$($name:literal => $path:literal),* $(,)?]) => {
24 &[
25 $($entry {
26 $key: $name,
27 source: include_str!($path),
28 },)*
29 ]
30 };
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct StdlibPublicFunction {
35 pub name: String,
36 pub signature: String,
37 pub required_params: usize,
38 pub total_params: usize,
39 pub variadic: bool,
40 pub doc: Option<String>,
41}
42
43#[derive(Debug, Clone, PartialEq, Eq)]
44pub struct StdlibEntrypointModule {
45 pub import_path: String,
46 pub category: String,
47}
48
49pub const STDLIB_SOURCES: &[StdlibSource] = embedded_catalog!(StdlibSource, module, [
50 "text" => "stdlib/stdlib_text.harn",
51 "semver" => "stdlib/stdlib_semver.harn",
52 "changelog" => "stdlib/stdlib_changelog.harn",
53 "ansi" => "stdlib/stdlib_ansi.harn",
54 "table" => "stdlib/stdlib_table.harn",
55 "diff" => "stdlib/stdlib_diff.harn",
56 "edit" => "stdlib/stdlib_edit.harn",
57 "edit/capabilities" => "stdlib/edit/capabilities.harn",
58 "edit/internal" => "stdlib/edit/internal.harn",
59 "edit/patch" => "stdlib/edit/patch.harn",
60 "edit/refactor_runtime" => "stdlib/edit/refactor_runtime.harn",
61 "edit/safe_patch" => "stdlib/edit/safe_patch.harn",
62 "edit/fast_apply" => "stdlib/edit/fast_apply.harn",
63 "ast" => "stdlib/stdlib_ast.harn",
64 "rules" => "stdlib/stdlib_rules.harn",
65 "lint" => "stdlib/stdlib_lint.harn",
66 "artifact/web" => "stdlib/artifact/web.harn",
67 "collections" => "stdlib/stdlib_collections.harn",
68 "math" => "stdlib/stdlib_math.harn",
69 "slug" => "stdlib/stdlib_slug.harn",
70 "path" => "stdlib/stdlib_path.harn",
71 "fs" => "stdlib/stdlib_fs.harn",
72 "run_artifacts" => "stdlib/stdlib_run_artifacts.harn",
73 "artifacts/typed" => "stdlib/artifacts/typed.harn",
74 "os" => "stdlib/stdlib_os.harn",
75 "json" => "stdlib/stdlib_json.harn",
76 "json/stream" => "stdlib/stdlib_json_stream.harn",
77 "xml" => "stdlib/stdlib_xml.harn",
78 "cache" => "stdlib/stdlib_cache.harn",
79 "observability" => "stdlib/stdlib_observability.harn",
80 "timing" => "stdlib/stdlib_timing.harn",
81 "verification" => "stdlib/stdlib_verification.harn",
82 "tools" => "stdlib/stdlib_tools.harn",
83 "composition" => "stdlib/stdlib_composition.harn",
84 "web" => "stdlib/stdlib_web.harn",
85 "graphql" => "stdlib/stdlib_graphql.harn",
86 "code_librarian" => "stdlib/stdlib_code_librarian.harn",
87 "schema" => "stdlib/stdlib_schema.harn",
88 "schema/contracts" => "stdlib/schema/contracts.harn",
89 "identity" => "stdlib/stdlib_identity.harn",
90 "disclosure" => "stdlib/stdlib_disclosure.harn",
91 "testing" => "stdlib/stdlib_testing.harn",
92 "files" => "stdlib/stdlib_files.harn",
93 "document" => "stdlib/stdlib_document.harn",
94 "vision" => "stdlib/stdlib_vision.harn",
95 "context" => "stdlib/stdlib_context.harn",
96 "context/artifact_types" => "stdlib/context/artifact_types.harn",
97 "context/maintenance" => "stdlib/context/maintenance.harn",
98 "context/eval" => "stdlib/context/eval.harn",
99 "eval/stats" => "stdlib/stdlib_eval_stats.harn",
100 "eval/remote_fanout" => "stdlib/eval/remote_fanout.harn",
101 "eval/sequential" => "stdlib/eval/sequential.harn",
102 "eval/experiment" => "stdlib/eval/experiment.harn",
103 "eval/experiment/contracts" => "stdlib/eval/experiment/contracts.harn",
104 "eval/experiment/assignment" => "stdlib/eval/experiment/assignment.harn",
105 "eval/experiment/decision" => "stdlib/eval/experiment/decision.harn",
106 "eval/hypothesis" => "stdlib/eval/hypothesis.harn",
107 "eval/hypothesis/capabilities" => "stdlib/eval/hypothesis/capabilities.harn",
108 "eval/hypothesis/contracts" => "stdlib/eval/hypothesis/contracts.harn",
109 "eval/hypothesis/compiler" => "stdlib/eval/hypothesis/compiler.harn",
110 "eval/hypothesis/intent_boundary" => "stdlib/eval/hypothesis/intent_boundary.harn",
111 "eval/hypothesis/ledger_contracts" => "stdlib/eval/hypothesis/ledger_contracts.harn",
112 "eval/hypothesis/ledger" => "stdlib/eval/hypothesis/ledger.harn",
113 "eval/hypothesis/planner" => "stdlib/eval/hypothesis/planner.harn",
114 "eval/hypothesis/report" => "stdlib/eval/hypothesis/report.harn",
115 "eval/hypothesis/policies" => "stdlib/eval/hypothesis/policies.harn",
116 "eval/hypothesis/workflow_contracts" => "stdlib/eval/hypothesis/workflow_contracts.harn",
117 "eval/hypothesis/workflow" => "stdlib/eval/hypothesis/workflow.harn",
118 "eval/agreement" => "stdlib/stdlib_eval_agreement.harn",
119 "runtime" => "stdlib/stdlib_runtime.harn",
120 "io" => "stdlib/stdlib_io.harn",
121 "net" => "stdlib/stdlib_net.harn",
122 "command" => "stdlib/stdlib_command.harn",
123 "command/foundation" => "stdlib/command/foundation.harn",
124 "command/output" => "stdlib/command/output.harn",
125 "command/results" => "stdlib/command/results.harn",
126 "command/shell" => "stdlib/command/shell.harn",
127 "command/step_ref" => "stdlib/command/step_ref.harn",
128 "runner_pool" => "stdlib/stdlib_runner_pool.harn",
129 "verification_types" => "stdlib/verification_types.harn",
130 "verification_core" => "stdlib/verification_core.harn",
131 "verification_targets" => "stdlib/verification_targets.harn",
132 "verification_ladder" => "stdlib/verification_ladder.harn",
133 "verification_public" => "stdlib/verification_public.harn",
134 "signal" => "stdlib/stdlib_signal.harn",
135 "net_policy" => "stdlib/stdlib_net_policy.harn",
136 "review" => "stdlib/stdlib_review.harn",
137 "experiments" => "stdlib/stdlib_experiments.harn",
138 "project" => "stdlib/stdlib_project.harn",
139 "prompt_library" => "stdlib/stdlib_prompt_library.harn",
140 "async" => "stdlib/stdlib_async.harn",
141 "poll" => "stdlib/stdlib_poll.harn",
142 "coerce" => "stdlib/stdlib_coerce.harn",
143 "settled" => "stdlib/stdlib_settled.harn",
144 "abort" => "stdlib/stdlib_abort.harn",
145 "cli" => "stdlib/stdlib_cli.harn",
146 "cli/argparse" => "stdlib/cli/argparse.harn",
147 "cli/envelope" => "stdlib/cli/envelope.harn",
148 "cli/render" => "stdlib/cli/render.harn",
149 "cli/models/batch_artifacts" => "stdlib/cli/models/batch_artifacts.harn",
150 "cli/models/batch_cancel" => "stdlib/cli/models/batch_cancel.harn",
151 "cli/models/batch_download" => "stdlib/cli/models/batch_download.harn",
152 "cli/models/batch_lifecycle" => "stdlib/cli/models/batch_lifecycle.harn",
153 "cli/models/batch_rejoin" => "stdlib/cli/models/batch_rejoin.harn",
154 "cli/models/batch_status" => "stdlib/cli/models/batch_status.harn",
155 "cli/models/batch_submit" => "stdlib/cli/models/batch_submit.harn",
156 "cli/models/batch_transport" => "stdlib/cli/models/batch_transport.harn",
157 "cli/models/lora_render" => "stdlib/cli/models/lora_render.harn",
158 "cli/paths" => "stdlib/cli/paths.harn",
159 "gha" => "stdlib/stdlib_gha.harn",
160 "tui" => "stdlib/stdlib_tui.harn",
161 "jsonl" => "stdlib/stdlib_jsonl.harn",
162 "config" => "stdlib/stdlib_config.harn",
163 "calendar" => "stdlib/stdlib_calendar.harn",
164 "external_action" => "stdlib/stdlib_external_action.harn",
165 "external_action/vocabulary" => "stdlib/external_action/vocabulary.harn",
166 "external_action/contracts" => "stdlib/external_action/contracts.harn",
167 "external_action/disclosure" => "stdlib/external_action/disclosure.harn",
168 "external_action/activity" => "stdlib/external_action/activity.harn",
169 "external_action/policy" => "stdlib/external_action/policy.harn",
170 "external_action/runtime" => "stdlib/external_action/runtime.harn",
171 "external_action/testing" => "stdlib/external_action/testing.harn",
172 "agents" => "stdlib/stdlib_agents.harn",
173 "lifecycle/pool" => "stdlib/lifecycle/pool.harn",
174 "lifecycle/combinators" => "stdlib/lifecycle/combinators.harn",
175 "lifecycle/on_budget" => "stdlib/lifecycle/on_budget.harn",
176 "lifecycle/progress" => "stdlib/lifecycle/progress.harn",
177 "agent/prompts" => "stdlib/agent/prompts.harn",
178 "llm/media" => "stdlib/llm/media.harn",
179 "media/asset" => "stdlib/media/asset.harn",
180 "media/composition" => "stdlib/media/composition.harn",
181 "model_job" => "stdlib/stdlib_model_job.harn",
182 "model_job/contracts" => "stdlib/model_job/contracts.harn",
183 "model_job/runtime" => "stdlib/model_job/runtime.harn",
184 "model_job/testing" => "stdlib/model_job/testing.harn",
185 "model_job/comfyui" => "stdlib/model_job/comfyui.harn",
186 "model_job/openai" => "stdlib/model_job/openai.harn",
187 "portable" => "stdlib/stdlib_portable.harn",
188 "ui" => "stdlib/stdlib_ui.harn",
189 "ui/contracts" => "stdlib/ui/contracts.harn",
190 "ui/renderer" => "stdlib/ui/renderer.harn",
191 "ui/testing" => "stdlib/ui/testing.harn",
192 "llm/options" => "stdlib/llm/options.harn",
193 "llm/provider_names" => "stdlib/llm/provider_names.harn",
194 "llm/catalog" => "stdlib/llm/catalog.harn",
195 "llm/safe" => "stdlib/llm/safe.harn",
196 "llm/envelope" => "stdlib/llm/envelope.harn",
197 "llm/caller" => "stdlib/llm/caller.harn",
198 "harness/policy" => "stdlib/harness/policy.harn",
199 "llm/budget" => "stdlib/llm/budget.harn",
200 "llm/economics" => "stdlib/llm/economics.harn",
201 "llm/prompts" => "stdlib/llm/prompts.harn",
202 "llm/defaults" => "stdlib/llm/defaults.harn",
203 "llm/handlers" => "stdlib/llm/handlers.harn",
204 "llm/handler_cache_events" => "stdlib/llm/handler_cache_events.harn",
205 "llm/resilience" => "stdlib/llm/resilience.harn",
206 "llm/tool_telemetry" => "stdlib/llm/tool_telemetry.harn",
207 "llm/tool_middleware" => "stdlib/llm/tool_middleware.harn",
208 "llm/tool_binder" => "stdlib/llm/tool_binder.harn",
209 "llm/structural_validator" => "stdlib/llm/structural_validator.harn",
210 "llm/missing_tool_call" => "stdlib/llm/missing_tool_call.harn",
211 "llm/call_shape" => "stdlib/llm/call_shape.harn",
212 "llm/tool_shape" => "stdlib/llm/tool_shape.harn",
213 "llm/dialects" => "stdlib/llm/dialects.harn",
214 "llm/tool_parse" => "stdlib/llm/tool_parse.harn",
215 "llm/tool_parse_body" => "stdlib/llm/tool_parse_body.harn",
216 "llm/tool_parse_envelope" => "stdlib/llm/tool_parse_envelope.harn",
217 "llm/tool_parse_json_support" => "stdlib/llm/tool_parse_json_support.harn",
218 "llm/tool_parse_protocol" => "stdlib/llm/tool_parse_protocol.harn",
219 "llm/tool_parse_provider" => "stdlib/llm/tool_parse_provider.harn",
220 "llm/tool_parse_result" => "stdlib/llm/tool_parse_result.harn",
221 "llm/tool_parse_scan_spec" => "stdlib/llm/tool_parse_scan_spec.harn",
222 "llm/scope_classifier" => "stdlib/llm/scope_classifier.harn",
223 "llm/refine" => "stdlib/llm/refine.harn",
224 "llm/ensemble" => "stdlib/llm/ensemble.harn",
225 "llm/rerank" => "stdlib/llm/rerank.harn",
226 "agent/reasoning" => "stdlib/agent/reasoning.harn",
227 "agent/caller_transport" => "stdlib/agent/caller_transport.harn",
228 "agent/options" => "stdlib/agent/options.harn",
229 "agent/options_types" => "stdlib/agent/options_types.harn",
230 "agent/options_formats" => "stdlib/agent/options_formats.harn",
231 "agent/options_validation" => "stdlib/agent/options_validation.harn",
232 "agent/options_public" => "stdlib/agent/options_public.harn",
233 "agent/llm_dispatch" => "stdlib/agent/llm_dispatch.harn",
234 "agent/prefill" => "stdlib/agent/prefill.harn",
235 "agent/retry" => "stdlib/agent/retry.harn",
236 "llm/judge" => "stdlib/llm/judge.harn",
237 "llm/faithfulness" => "stdlib/llm/faithfulness.harn",
238 "llm/optimize" => "stdlib/llm/optimize.harn",
239 "agent/events" => "stdlib/agent/events.harn",
240 "agent/feedback" => "stdlib/agent/feedback.harn",
241 "agent/transcript" => "stdlib/agent/transcript.harn",
242 "agent/artifacts" => "stdlib/agent/artifacts.harn",
243 "agent/primitives" => "stdlib/agent/primitives.harn",
244 "agent/progress" => "stdlib/agent/progress.harn",
245 "agent/required_tools" => "stdlib/agent/required_tools.harn",
246 "agent/monologue_actuation" => "stdlib/agent/monologue_actuation.harn",
247 "agent/monologue_actuation_types" => "stdlib/agent/monologue_actuation_types.harn",
248 "agent/stall_types" => "stdlib/agent/stall_types.harn",
249 "agent/stall" => "stdlib/agent/stall.harn",
250 "agent/recurring_diagnostic" => "stdlib/agent/recurring_diagnostic.harn",
251 "agent/stall_config" => "stdlib/agent/stall_config.harn",
252 "agent/stall_feedback" => "stdlib/agent/stall_feedback.harn",
253 "agent/stall_action_observation" => "stdlib/agent/stall_action_observation.harn",
254 "agent/stall_observation" => "stdlib/agent/stall_observation.harn",
255 "agent/stall_verification" => "stdlib/agent/stall_verification.harn",
256 "agent/stall_detectors" => "stdlib/agent/stall_detectors.harn",
257 "agent/governors" => "stdlib/agent/governors.harn",
258 "agent/control" => "stdlib/agent/control.harn",
259 "agent/action_graph" => "stdlib/agent/action_graph.harn",
260 "agent/result_text" => "stdlib/agent/result_text.harn",
261 "agent/best_of_n" => "stdlib/agent/best_of_n.harn",
262 "agent/loop" => "stdlib/agent/loop.harn",
263 "agent/loop_support" => "stdlib/agent/loop_support.harn",
264 "agent/loop_call_resolution" => "stdlib/agent/loop_call_resolution.harn",
265 "agent/loop_await" => "stdlib/agent/loop_await.harn",
266 "agent/loop_denial_cutoff" => "stdlib/agent/loop_denial_cutoff.harn",
267 "agent/loop_result_status" => "stdlib/agent/loop_result_status.harn",
268 "agent/loop_foundation" => "stdlib/agent/loop_foundation.harn",
269 "agent/loop_lifecycle" => "stdlib/agent/loop_lifecycle.harn",
270 "agent/loop_provider_failure" => "stdlib/agent/loop_provider_failure.harn",
271 "agent/loop_audit_flushes" => "stdlib/agent/loop_audit_flushes.harn",
272 "agent/loop_tool_calls" => "stdlib/agent/loop_tool_calls.harn",
273 "agent/loop_resource_dispatch" => "stdlib/agent/loop_resource_dispatch.harn",
274 "agent/loop_turn_options" => "stdlib/agent/loop_turn_options.harn",
275 "agent/loop_turn_scope" => "stdlib/agent/loop_turn_scope.harn",
276 "agent/loop_turn_projection" => "stdlib/agent/loop_turn_projection.harn",
277 "agent/loop_internal" => "stdlib/agent/loop_internal.harn",
278 "agent/loop_run" => "stdlib/agent/loop_run.harn",
279 "agent/loop_post_turn" => "stdlib/agent/loop_post_turn.harn",
280 "agent/loop_finalize" => "stdlib/agent/loop_finalize.harn",
281 "agent/loop_terminal" => "stdlib/agent/loop_terminal.harn",
282 "agent/user" => "stdlib/agent/user.harn",
283 "agent/tool_search" => "stdlib/agent/tool_search.harn",
284 "agent/tool_annotations" => "stdlib/agent/tool_annotations.harn",
285 "agent/tool_lifecycle" => "stdlib/agent/tool_lifecycle.harn",
286 "agent/workers" => "stdlib/agent/workers.harn",
287 "agent/introspection" => "stdlib/agent/introspection.harn",
288 "agent/resume_by" => "stdlib/agent/resume_by.harn",
289 "agent/state" => "stdlib/agent/state.harn",
290 "agent/truncation" => "stdlib/agent/truncation.harn",
291 "agent/canon" => "stdlib/agent/canon.harn",
292 "agent/skills" => "stdlib/agent/skills.harn",
293 "agent/autocompact" => "stdlib/agent/autocompact.harn",
294 "agent/mcp" => "stdlib/agent/mcp.harn",
295 "agent/command_capture" => "stdlib/agent/command_capture.harn",
296 "agent/contracts" => "stdlib/agent/contracts.harn",
297 "agent/command_ledger" => "stdlib/agent/command_ledger.harn",
298 "agent/host_tools" => "stdlib/agent/host_tools.harn",
299 "agent/host_injection" => "stdlib/agent/host_injection.harn",
300 "agent/budget" => "stdlib/agent/budget.harn",
301 "agent/daemon" => "stdlib/agent/daemon.harn",
302 "agent/preflight" => "stdlib/agent/preflight.harn",
303 "agent/postturn" => "stdlib/agent/postturn.harn",
304 "agent/tool_surface" => "stdlib/agent/tool_surface.harn",
305 "agent/stance" => "stdlib/agent/stance.harn",
306 "agent/lanes" => "stdlib/agent/lanes.harn",
307 "agent/overlays" => "stdlib/agent/overlays.harn",
308 "agent/sitrep" => "stdlib/agent/sitrep.harn",
309 "agent/verdict" => "stdlib/agent/verdict.harn",
310 "agent/judge_internals" => "stdlib/agent/judge_internals.harn",
311 "agent/completion_gate" => "stdlib/agent/completion_gate.harn",
312 "agent/completion_review" => "stdlib/agent/completion_review.harn",
313 "agent/judge" => "stdlib/agent/judge.harn",
314 "agent/guardrails" => "stdlib/agent/guardrails.harn",
315 "agent/step_judge" => "stdlib/agent/step_judge.harn",
316 "agent/scratchpad" => "stdlib/agent/scratchpad.harn",
317 "agent/fact" => "stdlib/agent/fact.harn",
318 "agent/hypothesis" => "stdlib/agent/hypothesis.harn",
319 "agent/pattern_knowledge_values" => "stdlib/agent/pattern_knowledge_values.harn",
320 "agent/pattern_knowledge_curated" => "stdlib/agent/pattern_knowledge_curated.harn",
321 "agent/pattern_knowledge_persistence" => "stdlib/agent/pattern_knowledge_persistence.harn",
322 "agent/pattern_knowledge" => "stdlib/agent/pattern_knowledge.harn",
323 "agent/crystallization_curator" => "stdlib/agent/crystallization_curator.harn",
324 "agent/probe" => "stdlib/agent/probe.harn",
325 "agent/stream" => "stdlib/agent/stream.harn",
326 "agent/presets" => "stdlib/agent/presets.harn",
327 "agent/pins" => "stdlib/agent/pins.harn",
328 "agent/goal" => "stdlib/agent/goal.harn",
329 "agent/task_plan" => "stdlib/agent/task_plan.harn",
330 "personas/compiler" => "stdlib/personas/compiler.harn",
331 "personas/prompt_compiler" => "stdlib/personas/prompt_compiler.harn",
332 "agent_state" => "stdlib/stdlib_agent_state.harn",
333 "memory" => "stdlib/stdlib_memory.harn",
334 "session-store" => "stdlib/stdlib_session_store.harn",
335 "coordination" => "stdlib/stdlib_coordination.harn",
336 "coordination/append_metadata" => "stdlib/coordination/append_metadata.harn",
337 "coordination/schema" => "stdlib/coordination/schema.harn",
338 "fleet/coordination" => "stdlib/fleet/coordination.harn",
339 "postgres" => "stdlib/stdlib_postgres.harn",
340 "postgres/query" => "stdlib/postgres/query.harn",
341 "sqlite" => "stdlib/stdlib_sqlite.harn",
342 "checkpoint" => "stdlib/stdlib_checkpoint.harn",
343 "host" => "stdlib/stdlib_host.harn",
344 "host_conditions" => "stdlib/stdlib_host_conditions.harn",
345 "host_lease" => "stdlib/stdlib_host_lease.harn",
346 "git" => "stdlib/stdlib_git.harn",
347 "git/checkout" => "stdlib/git/checkout.harn",
348 "git/contracts" => "stdlib/git/contracts.harn",
349 "hitl" => "stdlib/stdlib_hitl.harn",
350 "trust" => "stdlib/stdlib_trust.harn",
351 "corrections" => "stdlib/stdlib_corrections.harn",
352 "plan" => "stdlib/stdlib_plan.harn",
353 "waitpoint" => "stdlib/stdlib_waitpoint.harn",
354 "monitors" => "stdlib/stdlib_monitors.harn",
355 "worktree" => "stdlib/stdlib_worktree.harn",
356 "acp" => "stdlib/stdlib_acp.harn",
357 "external_agent" => "stdlib/stdlib_external_agent.harn",
358 "triggers" => "stdlib/stdlib_triggers.harn",
359 "triage" => "stdlib/stdlib_triage.harn",
360 "dashboard/jobs" => "stdlib/dashboard/jobs.harn",
361 "ui_resource" => "stdlib/stdlib_ui_resource.harn",
362 "handoffs" => "stdlib/stdlib_handoffs.harn",
363 "lifecycle" => "stdlib/stdlib_lifecycle.harn",
364 "tool_hooks_catalogues" => "stdlib/stdlib_tool_hooks_catalogues.harn",
365 "tool_hooks" => "stdlib/stdlib_tool_hooks.harn",
366 "channel_guardrails" => "stdlib/stdlib_channel_guardrails.harn",
367 "personas/prelude" => "stdlib/stdlib_personas_prelude.harn",
368 "personas/bulletins" => "stdlib/stdlib_personas_bulletins.harn",
369 "connectors/shared" => "stdlib/stdlib_connectors_shared.harn",
370 "connectors/http" => "stdlib/connectors/http.harn",
371 "connectors/setup" => "stdlib/connectors/setup.harn",
372 "oauth/providers" => "stdlib/oauth/providers.harn",
373 "oauth/token_exchange_catalog" => "stdlib/oauth/token_exchange_catalog.harn",
374 "oauth/token_exchange" => "stdlib/oauth/token_exchange.harn",
375 "oauth/storage" => "stdlib/oauth/storage.harn",
376 "oauth/client" => "stdlib/oauth/client.harn",
377 "oauth/device_flow" => "stdlib/oauth/device_flow.harn",
378 "oauth/redaction" => "stdlib/oauth/redaction.harn",
379 "oauth/dynamic_registration" => "stdlib/oauth/dynamic_registration.harn",
380 "connectors/github" => "stdlib/stdlib_connectors_github.harn",
381 "connectors/github/repository" => "stdlib/connectors/github/repository.harn",
382 "connectors/linear" => "stdlib/stdlib_connectors_linear.harn",
383 "connectors/notion" => "stdlib/stdlib_connectors_notion.harn",
384 "connectors/slack" => "stdlib/stdlib_connectors_slack.harn",
385 "workflow/prompts" => "stdlib/workflow/prompts.harn",
386 "workflow/context" => "stdlib/workflow/context.harn",
387 "workflow/options" => "stdlib/workflow/options.harn",
388 "workflow/checkpoints" => "stdlib/workflow/checkpoints.harn",
389 "workflow/patterns" => "stdlib/workflow/patterns.harn",
390 "workflow/stage" => "stdlib/workflow/stage.harn",
391 "workflow/map" => "stdlib/workflow/map.harn",
392 "workflow/schedule" => "stdlib/workflow/schedule.harn",
393 "workflow/execute" => "stdlib/workflow/execute.harn",
394 "workflow/repair" => "stdlib/workflow/repair.harn",
395 "security" => "stdlib/stdlib_security.harn",
396 "pii" => "stdlib/stdlib_pii.harn",
397 "bump/runtime" => "stdlib/bump/runtime.harn",
398 "bump/live" => "stdlib/bump/live.harn",
399]);
400
401pub const CONNECTOR_EVENT_SCHEMAS_SOURCE: &str = include_str!("stdlib/stdlib_event_schemas.harn");
411
412pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = embedded_catalog!(StdlibPromptAsset, path, [
413 "eval/hypothesis/prompts/intake.harn.prompt" => "stdlib/eval/hypothesis/prompts/intake.harn.prompt",
414 "agent/prompts/tool_contract_text.harn.prompt" => "stdlib/agent/prompts/tool_contract_text.harn.prompt",
415 "agent/prompts/tool_contract_json.harn.prompt" => "stdlib/agent/prompts/tool_contract_json.harn.prompt",
416 "agent/prompts/tool_contract_native.harn.prompt" => "stdlib/agent/prompts/tool_contract_native.harn.prompt",
417 "agent/prompts/tool_contract_text_response_protocol.harn.prompt" => "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt",
418 "agent/prompts/tool_contract_action_native.harn.prompt" => "stdlib/agent/prompts/tool_contract_action_native.harn.prompt",
419 "agent/prompts/tool_contract_action_text.harn.prompt" => "stdlib/agent/prompts/tool_contract_action_text.harn.prompt",
420 "agent/prompts/tool_contract_task_ledger.harn.prompt" => "stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt",
421 "agent/prompts/tool_contract_deferred_tools.harn.prompt" => "stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt",
422 "agent/prompts/deferred_tool_listing.harn.prompt" => "stdlib/agent/prompts/deferred_tool_listing.harn.prompt",
423 "agent/prompts/default_nudge.harn.prompt" => "stdlib/agent/prompts/default_nudge.harn.prompt",
424 "agent/prompts/agentic_user_system.harn.prompt" => "stdlib/agent/prompts/agentic_user_system.harn.prompt",
425 "agent/prompts/agentic_user_user.harn.prompt" => "stdlib/agent/prompts/agentic_user_user.harn.prompt",
426 "agent/prompts/loop_until_done_system.harn.prompt" => "stdlib/agent/prompts/loop_until_done_system.harn.prompt",
427 "agent/prompts/completion_judge_default.harn.prompt" => "stdlib/agent/prompts/completion_judge_default.harn.prompt",
428 "agent/prompts/completion_judge_feedback_fallback.harn.prompt" => "stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt",
429 "agent/prompts/completion_judge_user.harn.prompt" => "stdlib/agent/prompts/completion_judge_user.harn.prompt",
430 "agent/prompts/step_judge_system_default.harn.prompt" => "stdlib/agent/prompts/step_judge_system_default.harn.prompt",
431 "agent/prompts/step_judge_system_adversarial.harn.prompt" => "stdlib/agent/prompts/step_judge_system_adversarial.harn.prompt",
432 "agent/prompts/step_judge_user.harn.prompt" => "stdlib/agent/prompts/step_judge_user.harn.prompt",
433 "agent/prompts/parse_guidance.harn.prompt" => "stdlib/agent/prompts/parse_guidance.harn.prompt",
434 "agent/prompts/native_tool_contract_feedback.harn.prompt" => "stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt",
435 "agent/prompts/verification_gate_feedback.harn.prompt" => "stdlib/agent/prompts/verification_gate_feedback.harn.prompt",
436 "agent/prompts/daemon_watch_feedback.harn.prompt" => "stdlib/agent/prompts/daemon_watch_feedback.harn.prompt",
437 "agent/prompts/daemon_timer_feedback.harn.prompt" => "stdlib/agent/prompts/daemon_timer_feedback.harn.prompt",
438 "llm/prompts/completion_fallback_system.harn.prompt" => "stdlib/llm/prompts/completion_fallback_system.harn.prompt",
439 "llm/prompts/completion_fallback_user.harn.prompt" => "stdlib/llm/prompts/completion_fallback_user.harn.prompt",
440 "llm/prompts/transcript_summarize_user.harn.prompt" => "stdlib/llm/prompts/transcript_summarize_user.harn.prompt",
441 "llm/prompts/sitrep_user.harn.prompt" => "stdlib/llm/prompts/sitrep_user.harn.prompt",
442 "llm/prompts/structural_chain_of_draft.harn.prompt" => "stdlib/llm/prompts/structural_chain_of_draft.harn.prompt",
443 "llm/prompts/schema_recover_repair.harn.prompt" => "stdlib/llm/prompts/schema_recover_repair.harn.prompt",
444 "llm/prompts/structured_envelope_schema_contract.harn.prompt" => "stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt",
445 "llm/prompts/structured_envelope_repair.harn.prompt" => "stdlib/llm/prompts/structured_envelope_repair.harn.prompt",
446 "llm/prompts/pairwise_rerank_user.harn.prompt" => "stdlib/llm/prompts/pairwise_rerank_user.harn.prompt",
447 "llm/prompts/tool_binder_user.harn.prompt" => "stdlib/llm/prompts/tool_binder_user.harn.prompt",
448 "workflow/prompts/stage.harn.prompt" => "stdlib/workflow/prompts/stage.harn.prompt",
449 "workflow/prompts/verification_context_intro.harn.prompt" => "stdlib/workflow/prompts/verification_context_intro.harn.prompt",
450 "orchestration/prompts/compaction_summary.harn.prompt" => "stdlib/orchestration/prompts/compaction_summary.harn.prompt",
451 "orchestration/prompts/compaction_policy_extension.harn.prompt" => "stdlib/orchestration/prompts/compaction_policy_extension.harn.prompt",
452 "orchestration/prompts/compaction_policy_replacement.harn.prompt" => "stdlib/orchestration/prompts/compaction_policy_replacement.harn.prompt",
453 "orchestration/prompts/compaction_state_grounding.harn.prompt" => "stdlib/orchestration/prompts/compaction_state_grounding.harn.prompt",
454]);
455
456#[derive(Debug, Clone, Copy, PartialEq, Eq)]
460pub struct StdlibCliScript {
461 pub name: &'static str,
465 pub source: &'static str,
468}
469
470pub const STDLIB_CLI_SCRIPTS: &[StdlibCliScript] = embedded_catalog!(StdlibCliScript, name, [
471 "codemod" => "stdlib/cli/codemod.harn",
472 "canon/check" => "stdlib/cli/canon/check.harn",
473 "doctor" => "stdlib/cli/doctor.harn",
474 "echo" => "stdlib/cli/echo.harn",
475 "eval/_runner" => "stdlib/cli/eval/_runner.harn",
479 "eval/context" => "stdlib/cli/eval/context.harn",
480 "eval/model_selector" => "stdlib/cli/eval/model_selector.harn",
481 "eval/tool_calls" => "stdlib/cli/eval/tool_calls.harn",
482 "eval/coding_agent" => "stdlib/cli/eval/coding_agent.harn",
483 "eval/scope_triage" => "stdlib/cli/eval/scope_triage.harn",
484 "eval/prompt" => "stdlib/cli/eval/prompt.harn",
485 "explain" => "stdlib/cli/explain.harn",
486 "graph" => "stdlib/cli/graph.harn",
487 "personas/compile_prompt" => "stdlib/cli/personas/compile_prompt.harn",
488 "personas/materialize" => "stdlib/cli/personas/materialize.harn",
489 "models/batch_plan" => "stdlib/cli/models/batch_plan.harn",
490 "models/list" => "stdlib/cli/models/list.harn",
491 "models/lora_inspect" => "stdlib/cli/models/lora_inspect.harn",
492 "models/lora_export" => "stdlib/cli/models/lora_export.harn",
493 "models/lora_manifest" => "stdlib/cli/models/lora_manifest.harn",
494 "models/lora_preflight" => "stdlib/cli/models/lora_preflight.harn",
495 "models/lora_promote" => "stdlib/cli/models/lora_promote.harn",
496 "models/lora_plan" => "stdlib/cli/models/lora_plan.harn",
497 "models/lora_train" => "stdlib/cli/models/lora_train.harn",
498 "models/recommend" => "stdlib/cli/models/recommend.harn",
499 "models/test" => "stdlib/cli/models/test.harn",
500 "precompile" => "stdlib/cli/precompile.harn",
501 "providers/cache_probe" => "stdlib/cli/providers/cache_probe.harn",
502 "providers/catalog" => "stdlib/cli/providers/catalog.harn",
503 "providers/effort_probe" => "stdlib/cli/providers/effort_probe.harn",
504 "providers/probe" => "stdlib/cli/providers/probe.harn",
505 "providers/recommend" => "stdlib/cli/providers/recommend.harn",
506 "providers/tool_probe" => "stdlib/cli/providers/tool_probe.harn",
507 "providers/tool_scorecard" => "stdlib/cli/providers/tool_scorecard.harn",
508 "routes" => "stdlib/cli/routes.harn",
509 "runs/export_training" => "stdlib/cli/runs/export_training.harn",
510 "scan" => "stdlib/cli/scan.harn",
511 "scaffold/init" => "stdlib/cli/scaffold/init.harn",
512 "scaffold/tool_new" => "stdlib/cli/scaffold/tool_new.harn",
513 "trace_import" => "stdlib/cli/trace_import.harn",
514 "try" => "stdlib/cli/try.harn",
515 "version" => "stdlib/cli/version.harn",
516]);
517
518pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
519 STDLIB_SOURCES
520 .iter()
521 .find_map(|entry| (entry.module == module).then_some(entry.source))
522}
523
524pub fn builtin_reexports(module: &str) -> &'static [&'static str] {
544 match module {
545 "testing" => &[
546 "assert",
547 "assert_approx",
548 "assert_eq",
549 "assert_matches",
550 "assert_ne",
551 "value_diff",
552 ],
553 _ => &[],
554 }
555}
556
557pub fn find_cli_script(name: &str) -> Option<&'static str> {
561 STDLIB_CLI_SCRIPTS
562 .iter()
563 .find_map(|entry| (entry.name == name).then_some(entry.source))
564}
565
566pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
567 let path = path.strip_prefix("std/").unwrap_or(path);
568 STDLIB_PROMPT_ASSETS
569 .iter()
570 .find_map(|entry| (entry.path == path).then_some(entry.source))
571}
572
573pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
574 let Some(source) = get_stdlib_source(module) else {
575 return Vec::new();
576 };
577 public_functions_from_source(source)
578}
579
580pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
581 STDLIB_SOURCES
582 .iter()
583 .filter_map(|entry| {
584 entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
585 import_path: format!("std/{}", entry.module),
586 category,
587 })
588 })
589 .collect()
590}
591
592fn entrypoint_category_from_source(source: &str) -> Option<String> {
593 for line in source.lines() {
594 let line = line.trim();
595 if line.is_empty() {
596 continue;
597 }
598 if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
599 let category = category.trim();
600 return (!category.is_empty()).then(|| category.to_string());
601 }
602 if !line.starts_with("//") {
603 return None;
604 }
605 }
606 None
607}
608
609fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
610 let mut out = Vec::new();
611 let mut doc: Option<String> = None;
612 let lines = source.lines().collect::<Vec<_>>();
613 let mut index = 0usize;
614 while index < lines.len() {
615 let line = lines[index].trim();
616 if line.starts_with("/**") {
617 let (parsed, next) = parse_harndoc(&lines, index);
618 doc = parsed;
619 index = next;
620 continue;
621 }
622 if line.starts_with("pub fn ") {
623 let (signature_line, next) = collect_public_function_signature(&lines, index);
624 if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
625 out.push(function);
626 index = next;
627 continue;
628 }
629 }
630 if let Some(function) = parse_public_function_line(line, doc.take()) {
631 out.push(function);
632 } else if !line.is_empty() && !line.starts_with("//") {
633 doc = None;
634 }
635 index += 1;
636 }
637 out
638}
639
640fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
641 let mut parts = Vec::new();
642 let mut index = start;
643 while index < lines.len() {
644 parts.push(lines[index].trim().to_string());
645 let candidate = parts.join(" ");
646 if public_function_signature_complete(&candidate) {
647 return (candidate, index + 1);
648 }
649 index += 1;
650 }
651 (parts.join(" "), index)
652}
653
654fn public_function_signature_complete(line: &str) -> bool {
655 let Some(rest) = line.strip_prefix("pub fn ") else {
656 return false;
657 };
658 let Some((_, after_paren)) = rest.split_once('(') else {
659 return false;
660 };
661 matching_paren_len(after_paren).is_some()
662}
663
664fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
665 let mut parts = Vec::new();
666 let mut index = start;
667 while index < lines.len() {
668 let mut line = lines[index].trim();
669 if index == start {
670 line = line.trim_start_matches("/**").trim();
671 }
672 let done = line.ends_with("*/");
673 line = line.trim_end_matches("*/").trim();
674 line = line.trim_start_matches('*').trim();
675 if !line.is_empty() {
676 parts.push(line.to_string());
677 }
678 index += 1;
679 if done {
680 break;
681 }
682 }
683 let text = parts.join("\n").trim().to_string();
684 ((!text.is_empty()).then_some(text), index)
685}
686
687#[expect(
688 clippy::string_slice,
689 reason = "bounds come from str::find and char_indices"
690)]
691fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
692 let rest = line.strip_prefix("pub fn ")?.trim();
693 let name_end = rest.find('(')?;
694 let declaration_name = rest[..name_end].trim();
695 let name = declaration_name
696 .split_once('<')
697 .map_or(declaration_name, |(name, _)| name.trim());
698 if name.is_empty() {
699 return None;
700 }
701 let params_start = name_end + 1;
702 let params_len = matching_paren_len(&rest[params_start..])?;
703 let params = &rest[params_start..params_start + params_len];
704 let after = rest[params_start + params_len + 1..].trim();
705 let return_type = after
706 .strip_prefix("->")
707 .and_then(|tail| tail.split('{').next())
708 .map(str::trim)
709 .filter(|value| !value.is_empty());
710 let signature = match return_type {
711 Some(ret) => format!("{declaration_name}({params}) -> {ret}"),
712 None => format!("{declaration_name}({params})"),
713 };
714 let param_parts = split_top_level_params(params);
715 let total_params = param_parts
716 .iter()
717 .filter(|param| !param.trim().is_empty())
718 .count();
719 let variadic = param_parts
720 .iter()
721 .any(|param| param.trim_start().starts_with("..."));
722 let required_params = param_parts
723 .iter()
724 .filter(|param| {
725 let param = param.trim();
726 !param.is_empty() && !param.contains('=') && !param.starts_with("...")
727 })
728 .count();
729 Some(StdlibPublicFunction {
730 name: name.to_string(),
731 signature,
732 required_params,
733 total_params,
734 variadic,
735 doc,
736 })
737}
738
739fn matching_paren_len(input: &str) -> Option<usize> {
740 let mut depth = 1usize;
741 for (offset, ch) in input.char_indices() {
742 match ch {
743 '(' | '[' | '{' => depth += 1,
744 ')' | ']' | '}' => {
745 depth = depth.saturating_sub(1);
746 if depth == 0 {
747 return Some(offset);
748 }
749 }
750 _ => {}
751 }
752 }
753 None
754}
755
756#[expect(
757 clippy::string_slice,
758 reason = "offsets come from char_indices and 1-byte ','"
759)]
760fn split_top_level_params(params: &str) -> Vec<&str> {
761 let mut out = Vec::new();
762 let mut depth = 0isize;
763 let mut start = 0usize;
764 for (offset, ch) in params.char_indices() {
765 match ch {
766 '(' | '[' | '{' => depth += 1,
767 ')' | ']' | '}' => depth -= 1,
768 ',' if depth == 0 => {
769 out.push(¶ms[start..offset]);
770 start = offset + 1;
771 }
772 _ => {}
773 }
774 }
775 out.push(¶ms[start..]);
776 out
777}
778
779#[cfg(test)]
780mod tests {
781 use std::collections::BTreeSet;
782
783 use super::{
784 entrypoint_modules, find_cli_script, get_stdlib_prompt_asset, get_stdlib_source,
785 matching_paren_len, parse_public_function_line, public_functions_for_module,
786 STDLIB_CLI_SCRIPTS, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
787 };
788
789 #[test]
790 fn stdlib_sources_are_non_empty() {
791 for entry in STDLIB_SOURCES {
792 assert!(
793 !entry.source.trim().is_empty(),
794 "{} should have non-empty source",
795 entry.module
796 );
797 }
798 }
799
800 #[test]
801 fn cli_scripts_are_non_empty_and_uniquely_named() {
802 let mut seen = BTreeSet::new();
803 for entry in STDLIB_CLI_SCRIPTS {
804 assert!(
805 !entry.source.trim().is_empty(),
806 "cli/{} should have non-empty source",
807 entry.name
808 );
809 assert!(
810 seen.insert(entry.name),
811 "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
812 entry.name
813 );
814 }
815 }
816
817 #[test]
818 fn find_cli_script_round_trips() {
819 for entry in STDLIB_CLI_SCRIPTS {
820 assert_eq!(find_cli_script(entry.name), Some(entry.source));
821 }
822 assert!(find_cli_script("not-a-real-script").is_none());
823 }
824
825 #[test]
826 fn stdlib_source_names_are_unique() {
827 let mut names = BTreeSet::new();
828 for entry in STDLIB_SOURCES {
829 assert!(names.insert(entry.module), "duplicate {}", entry.module);
830 }
831 }
832
833 #[test]
834 fn stdlib_prompt_assets_are_non_empty() {
835 for entry in STDLIB_PROMPT_ASSETS {
836 assert!(
837 !entry.source.trim().is_empty(),
838 "{} should have non-empty prompt asset source",
839 entry.path
840 );
841 }
842 }
843
844 #[test]
845 fn stdlib_prompt_asset_paths_are_unique() {
846 let mut paths = BTreeSet::new();
847 for entry in STDLIB_PROMPT_ASSETS {
848 assert!(paths.insert(entry.path), "duplicate {}", entry.path);
849 }
850 }
851
852 #[test]
853 fn key_stdlib_modules_resolve() {
854 for module in [
855 "context",
856 "context/maintenance",
857 "context/eval",
858 "eval/stats",
859 "eval/remote_fanout",
860 "eval/agreement",
861 "edit",
862 "verification",
863 "disclosure",
864 "artifact/web",
865 "command",
866 "waitpoint",
867 "llm/handlers",
868 "media/asset",
869 "media/composition",
870 "model_job",
871 "model_job/contracts",
872 "model_job/runtime",
873 "model_job/testing",
874 "model_job/comfyui",
875 "model_job/openai",
876 "ui",
877 "ui/contracts",
878 "ui/renderer",
879 "ui/testing",
880 "llm/tool_middleware",
881 "llm/tool_binder",
882 "llm/missing_tool_call",
883 "llm/tool_shape",
884 "llm/dialects",
885 "llm/ensemble",
886 "llm/rerank",
887 "personas/prelude",
888 "personas/bulletins",
889 "agent/host_tools",
890 "agent/host_injection",
891 "agent/tool_lifecycle",
892 "agent/user",
893 "agent/governors",
894 "agent/loop_post_turn",
895 "agent/completion_gate",
896 "agent/guardrails",
897 "cli",
898 "cli/envelope",
899 "cli/models/batch_artifacts",
900 "cli/models/batch_cancel",
901 "cli/models/batch_download",
902 "cli/models/batch_lifecycle",
903 "cli/models/batch_rejoin",
904 "cli/models/batch_status",
905 "cli/models/batch_submit",
906 "cli/models/batch_transport",
907 "cli/models/lora_render",
908 "llm/optimize",
909 "llm/judge",
910 "llm/faithfulness",
911 "llm/refine",
912 "connectors/shared",
913 "connectors/github",
914 "connectors/linear",
915 "connectors/notion",
916 "connectors/slack",
917 "triage",
918 "dashboard/jobs",
919 "ui_resource",
920 "host_conditions",
921 "host_lease",
922 ] {
923 assert!(
924 get_stdlib_source(module).is_some(),
925 "std/{module} should resolve"
926 );
927 }
928 }
929
930 #[test]
931 fn key_stdlib_prompt_assets_resolve() {
932 for path in [
933 "std/agent/prompts/tool_contract_text.harn.prompt",
934 "std/agent/prompts/default_nudge.harn.prompt",
935 "std/agent/prompts/completion_judge_default.harn.prompt",
936 "std/workflow/prompts/stage.harn.prompt",
937 "std/orchestration/prompts/compaction_summary.harn.prompt",
938 "std/orchestration/prompts/compaction_policy_extension.harn.prompt",
939 "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
940 "std/orchestration/prompts/compaction_state_grounding.harn.prompt",
941 ] {
942 assert!(
943 get_stdlib_prompt_asset(path).is_some(),
944 "{path} should resolve"
945 );
946 }
947 }
948
949 #[test]
950 fn public_function_catalog_derives_signatures_from_harn_source() {
951 let exports = public_functions_for_module("workflow/execute");
952 assert_eq!(exports.len(), 1);
953 assert_eq!(exports[0].name, "workflow_execute");
954 assert_eq!(
955 exports[0].signature,
956 "workflow_execute( harness: Harness, task: string, graph: dict, artifacts: list<unknown>? = nil, options: dict? = nil, )"
957 );
958 assert_eq!(exports[0].required_params, 3);
959 assert_eq!(exports[0].total_params, 5);
960 }
961
962 #[test]
963 fn command_stdlib_module_exports_step_helpers() {
964 let exports = public_functions_for_module("command")
965 .into_iter()
966 .map(|function| function.name)
967 .collect::<BTreeSet<_>>();
968 for name in [
969 "command_run",
970 "command_wait",
971 "command_wait_for_output",
972 "command_cancel",
973 "command_run_streaming",
974 "command_output_tail",
975 "command_json",
976 "command_json_step",
977 "command_try",
978 "command_step",
979 "command_steps_append",
980 "command_last_failed_step",
981 "command_step_ref",
982 "command_output_text",
983 "argv_label",
984 "shell_command_from_argv",
985 "shell_command_from_value",
986 ] {
987 assert!(exports.contains(name), "std/command should export {name}");
988 }
989 }
990
991 #[test]
992 fn disclosure_stdlib_module_exports_render_helpers() {
993 let exports = public_functions_for_module("disclosure")
994 .into_iter()
995 .map(|function| function.name)
996 .collect::<BTreeSet<_>>();
997 assert!(
998 exports.contains("render"),
999 "std/disclosure should export render"
1000 );
1001 assert!(
1002 exports.contains("git_trailers"),
1003 "std/disclosure should export git_trailers"
1004 );
1005 assert!(
1006 exports.contains("slack_message_disclosure"),
1007 "std/disclosure should export slack_message_disclosure"
1008 );
1009 assert!(
1010 exports.contains("append_git_trailers"),
1011 "std/disclosure should export append_git_trailers"
1012 );
1013 }
1014
1015 #[test]
1016 fn async_stdlib_exports_predicate_backoff_name_only() {
1017 let exports = public_functions_for_module("async")
1018 .into_iter()
1019 .map(|function| function.name)
1020 .collect::<BTreeSet<_>>();
1021 assert!(
1022 exports.contains("retry_predicate_with_backoff"),
1023 "std/async should export retry_predicate_with_backoff"
1024 );
1025 assert!(
1026 !exports.contains("retry_with_backoff"),
1027 "std/async should not retain the old retry_with_backoff export"
1028 );
1029 }
1030
1031 #[test]
1032 fn signal_stdlib_module_exports_interrupt_helpers() {
1033 let exports = public_functions_for_module("signal")
1034 .into_iter()
1035 .map(|function| function.name)
1036 .collect::<BTreeSet<_>>();
1037 for name in [
1038 "on_interrupt",
1039 "off_interrupt",
1040 "interrupted",
1041 "with_interrupt",
1042 ] {
1043 assert!(exports.contains(name), "std/signal should export {name}");
1044 }
1045 }
1046
1047 #[test]
1048 fn git_stdlib_module_exports_local_wrappers() {
1049 let exports = public_functions_for_module("git")
1050 .into_iter()
1051 .map(|function| function.name)
1052 .collect::<BTreeSet<_>>();
1053 for name in [
1054 "git_run",
1055 "git_status",
1056 "git_current_branch",
1057 "git_log",
1058 "git_switch",
1059 "git_pull_ff_only",
1060 "git_find_tool",
1061 "git_run_tool",
1062 "git_tools",
1063 "git_toolbox_tools",
1064 ] {
1065 assert!(exports.contains(name), "std/git should export {name}");
1066 }
1067 }
1068
1069 #[test]
1070 fn agent_workers_exports_suspend_resume_wrappers() {
1071 let exports = public_functions_for_module("agent/workers");
1072 let suspend = exports
1073 .iter()
1074 .find(|function| function.name == "suspend_agent")
1075 .expect("std/agent/workers should export suspend_agent");
1076 assert_eq!(
1077 suspend.signature,
1078 "suspend_agent( agents: HarnessAgent, worker: unknown, reason: string = \"\", options: dict? = nil, ) -> unknown"
1079 );
1080 assert_eq!(suspend.required_params, 2);
1081 assert_eq!(suspend.total_params, 4);
1082
1083 let resume = exports
1084 .iter()
1085 .find(|function| function.name == "resume_agent")
1086 .expect("std/agent/workers should export resume_agent");
1087 assert_eq!(
1088 resume.signature,
1089 "resume_agent( agents: HarnessAgent, worker_or_snapshot: unknown, resume_input: unknown = nil, continue_transcript: bool = true, ) -> unknown"
1090 );
1091 assert_eq!(resume.required_params, 2);
1092 assert_eq!(resume.total_params, 4);
1093
1094 let stop = exports
1095 .iter()
1096 .find(|function| function.name == "agent_stop")
1097 .expect("std/agent/workers should export agent_stop");
1098 assert_eq!(
1099 stop.signature,
1100 "agent_stop( agents: HarnessAgent, worker: unknown, options: AgentStopOptions? = nil, ) -> unknown"
1101 );
1102 assert_eq!(stop.required_params, 2);
1103 assert_eq!(stop.total_params, 3);
1104
1105 let parse_resume = exports
1106 .iter()
1107 .find(|function| function.name == "parse_resume_conditions")
1108 .expect("std/agent/workers should export parse_resume_conditions");
1109 assert_eq!(
1110 parse_resume.signature,
1111 "parse_resume_conditions( agents: HarnessAgent, conditions: ResumeConditions? = nil, ) -> ResumeConditions?"
1112 );
1113 assert_eq!(parse_resume.required_params, 1);
1114 assert_eq!(parse_resume.total_params, 2);
1115
1116 let lifecycle = exports
1117 .iter()
1118 .find(|function| function.name == "agent_lifecycle_tools")
1119 .expect("std/agent/workers should export agent_lifecycle_tools");
1120 assert_eq!(
1121 lifecycle.signature,
1122 "agent_lifecycle_tools( agents: HarnessAgent, registry: ToolRegistry? = nil, options: AgentLifecycleToolsOptions? = nil, ) -> ToolRegistry"
1123 );
1124 assert_eq!(lifecycle.required_params, 1);
1125 assert_eq!(lifecycle.total_params, 3);
1126 }
1127
1128 #[test]
1129 fn tui_stdlib_module_exports_terminal_helpers() {
1130 let exports = public_functions_for_module("tui")
1131 .into_iter()
1132 .map(|function| function.name)
1133 .collect::<BTreeSet<_>>();
1134 for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1135 assert!(exports.contains(name), "std/tui should export {name}");
1136 }
1137 }
1138
1139 #[test]
1140 fn semver_stdlib_module_exports_release_helpers() {
1141 let exports = public_functions_for_module("semver")
1142 .into_iter()
1143 .map(|function| function.name)
1144 .collect::<BTreeSet<_>>();
1145 for name in [
1146 "strip_v",
1147 "add_v",
1148 "is_v_semver",
1149 "is_v_release_semver",
1150 "parse",
1151 "parse_release",
1152 "is_prerelease_identifier",
1153 "is_prerelease",
1154 "compare_release",
1155 "max_canonical_tag",
1156 "next",
1157 "bump_type",
1158 "version_from_release_branch",
1159 "version_from_tag",
1160 ] {
1161 assert!(exports.contains(name), "std/semver should export {name}");
1162 }
1163 }
1164
1165 #[test]
1166 fn changelog_stdlib_module_exports_typed_primitives() {
1167 let exports = public_functions_for_module("changelog")
1168 .into_iter()
1169 .map(|function| function.name)
1170 .collect::<BTreeSet<_>>();
1171 for name in [
1172 "changelog_validate_categories",
1173 "changelog_parse_fragment",
1174 "changelog_order_fragments",
1175 "changelog_normalize_fragment_body",
1176 "changelog_assemble_fragments",
1177 "changelog_parse_sections",
1178 "changelog_find_section",
1179 "changelog_merge_unreleased",
1180 ] {
1181 assert!(exports.contains(name), "std/changelog should export {name}");
1182 }
1183 }
1184
1185 #[test]
1186 fn text_stdlib_module_exports_regex_and_pad_helpers() {
1187 let exports = public_functions_for_module("text")
1188 .into_iter()
1189 .map(|function| function.name)
1190 .collect::<BTreeSet<_>>();
1191 for name in [
1192 "pad_left",
1193 "pad_right",
1194 "repeat_string",
1195 "regex_first_capture",
1196 "regex_capture_groups",
1197 "regex_all_first_captures",
1198 ] {
1199 assert!(exports.contains(name), "std/text should export {name}");
1200 }
1201 }
1202
1203 #[test]
1204 fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1205 let modules = entrypoint_modules();
1206 let entries = modules
1207 .iter()
1208 .map(|module| (module.import_path.as_str(), module.category.as_str()))
1209 .collect::<BTreeSet<_>>();
1210 for entry in [
1211 ("std/agent/loop", "agent.stdlib"),
1212 ("std/agent/primitives", "agent.stdlib"),
1213 ("std/workflow/execute", "workflow.stdlib"),
1214 ] {
1215 assert!(entries.contains(&entry), "{entry:?} should be declared");
1216 }
1217 }
1218
1219 #[test]
1220 fn matching_paren_len_closes_on_every_bracket_kind() {
1221 assert_eq!(matching_paren_len("a, b)"), Some(4));
1224 assert_eq!(matching_paren_len("x: [int])"), Some(8));
1225 assert_eq!(matching_paren_len("x: {a: int})"), Some(11));
1226 assert_eq!(matching_paren_len("x]"), Some(1));
1229 assert_eq!(matching_paren_len("x}"), Some(1));
1230 assert_eq!(matching_paren_len("unterminated"), None);
1231 }
1232
1233 #[test]
1234 fn parse_public_function_line_handles_record_typed_params() {
1235 let parsed =
1236 parse_public_function_line("pub fn configure(opts: {retries: int}) -> bool", None)
1237 .expect("signature with a record-typed parameter should parse");
1238 assert_eq!(parsed.name, "configure");
1239 assert_eq!(parsed.signature, "configure(opts: {retries: int}) -> bool");
1240 assert_eq!(parsed.total_params, 1);
1241 assert_eq!(parsed.required_params, 1);
1242 }
1243
1244 #[test]
1245 fn parse_public_function_line_indexes_generic_functions_by_base_name() {
1246 let parsed = parse_public_function_line(
1247 "pub fn map<T, U>(items: list<T>, project: fn(T) -> U) -> list<U>",
1248 None,
1249 )
1250 .expect("generic public function should parse");
1251 assert_eq!(parsed.name, "map");
1252 assert_eq!(
1253 parsed.signature,
1254 "map<T, U>(items: list<T>, project: fn(T) -> U) -> list<U>"
1255 );
1256 assert_eq!(parsed.total_params, 2);
1257 assert_eq!(parsed.required_params, 2);
1258 }
1259}