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