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