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