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