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