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