Skip to main content

harn_stdlib/
lib.rs

1//! Canonical embedded Harn standard library source catalog.
2//!
3//! This crate intentionally contains only static source strings so runtime and
4//! static tooling crates can share the same stdlib modules without depending on
5//! each other.
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8pub struct StdlibSource {
9    pub module: &'static str,
10    pub source: &'static str,
11}
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub struct StdlibPromptAsset {
15    pub path: &'static str,
16    pub source: &'static str,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub struct StdlibPublicFunction {
21    pub name: String,
22    pub signature: String,
23    pub required_params: usize,
24    pub total_params: usize,
25    pub variadic: bool,
26    pub doc: Option<String>,
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct StdlibEntrypointModule {
31    pub import_path: String,
32    pub category: String,
33}
34
35pub const STDLIB_SOURCES: &[StdlibSource] = &[
36    StdlibSource {
37        module: "text",
38        source: include_str!("stdlib/stdlib_text.harn"),
39    },
40    StdlibSource {
41        module: "semver",
42        source: include_str!("stdlib/stdlib_semver.harn"),
43    },
44    StdlibSource {
45        module: "ansi",
46        source: include_str!("stdlib/stdlib_ansi.harn"),
47    },
48    StdlibSource {
49        module: "table",
50        source: include_str!("stdlib/stdlib_table.harn"),
51    },
52    StdlibSource {
53        module: "diff",
54        source: include_str!("stdlib/stdlib_diff.harn"),
55    },
56    StdlibSource {
57        module: "edit",
58        source: include_str!("stdlib/stdlib_edit.harn"),
59    },
60    StdlibSource {
61        module: "artifact/web",
62        source: include_str!("stdlib/artifact/web.harn"),
63    },
64    StdlibSource {
65        module: "collections",
66        source: include_str!("stdlib/stdlib_collections.harn"),
67    },
68    StdlibSource {
69        module: "math",
70        source: include_str!("stdlib/stdlib_math.harn"),
71    },
72    StdlibSource {
73        module: "path",
74        source: include_str!("stdlib/stdlib_path.harn"),
75    },
76    StdlibSource {
77        module: "fs",
78        source: include_str!("stdlib/stdlib_fs.harn"),
79    },
80    StdlibSource {
81        module: "run_artifacts",
82        source: include_str!("stdlib/stdlib_run_artifacts.harn"),
83    },
84    StdlibSource {
85        module: "os",
86        source: include_str!("stdlib/stdlib_os.harn"),
87    },
88    StdlibSource {
89        module: "json",
90        source: include_str!("stdlib/stdlib_json.harn"),
91    },
92    StdlibSource {
93        module: "json/stream",
94        source: include_str!("stdlib/stdlib_json_stream.harn"),
95    },
96    StdlibSource {
97        module: "xml",
98        source: include_str!("stdlib/stdlib_xml.harn"),
99    },
100    StdlibSource {
101        module: "cache",
102        source: include_str!("stdlib/stdlib_cache.harn"),
103    },
104    StdlibSource {
105        module: "observability",
106        source: include_str!("stdlib/stdlib_observability.harn"),
107    },
108    StdlibSource {
109        module: "timing",
110        source: include_str!("stdlib/stdlib_timing.harn"),
111    },
112    StdlibSource {
113        module: "tools",
114        source: include_str!("stdlib/stdlib_tools.harn"),
115    },
116    StdlibSource {
117        module: "composition",
118        source: include_str!("stdlib/stdlib_composition.harn"),
119    },
120    StdlibSource {
121        module: "web",
122        source: include_str!("stdlib/stdlib_web.harn"),
123    },
124    StdlibSource {
125        module: "graphql",
126        source: include_str!("stdlib/stdlib_graphql.harn"),
127    },
128    StdlibSource {
129        module: "code_librarian",
130        source: include_str!("stdlib/stdlib_code_librarian.harn"),
131    },
132    StdlibSource {
133        module: "schema",
134        source: include_str!("stdlib/stdlib_schema.harn"),
135    },
136    StdlibSource {
137        module: "testing",
138        source: include_str!("stdlib/stdlib_testing.harn"),
139    },
140    StdlibSource {
141        module: "files",
142        source: include_str!("stdlib/stdlib_files.harn"),
143    },
144    StdlibSource {
145        module: "mcp",
146        source: include_str!("stdlib/stdlib_mcp.harn"),
147    },
148    StdlibSource {
149        module: "vision",
150        source: include_str!("stdlib/stdlib_vision.harn"),
151    },
152    StdlibSource {
153        module: "context",
154        source: include_str!("stdlib/stdlib_context.harn"),
155    },
156    StdlibSource {
157        module: "context/maintenance",
158        source: include_str!("stdlib/context/maintenance.harn"),
159    },
160    StdlibSource {
161        module: "context/eval",
162        source: include_str!("stdlib/context/eval.harn"),
163    },
164    StdlibSource {
165        module: "runtime",
166        source: include_str!("stdlib/stdlib_runtime.harn"),
167    },
168    StdlibSource {
169        module: "io",
170        source: include_str!("stdlib/stdlib_io.harn"),
171    },
172    StdlibSource {
173        module: "command",
174        source: include_str!("stdlib/stdlib_command.harn"),
175    },
176    StdlibSource {
177        module: "signal",
178        source: include_str!("stdlib/stdlib_signal.harn"),
179    },
180    StdlibSource {
181        module: "net_policy",
182        source: include_str!("stdlib/stdlib_net_policy.harn"),
183    },
184    StdlibSource {
185        module: "review",
186        source: include_str!("stdlib/stdlib_review.harn"),
187    },
188    StdlibSource {
189        module: "experiments",
190        source: include_str!("stdlib/stdlib_experiments.harn"),
191    },
192    StdlibSource {
193        module: "project",
194        source: include_str!("stdlib/stdlib_project.harn"),
195    },
196    StdlibSource {
197        module: "prompt_library",
198        source: include_str!("stdlib/stdlib_prompt_library.harn"),
199    },
200    StdlibSource {
201        module: "async",
202        source: include_str!("stdlib/stdlib_async.harn"),
203    },
204    StdlibSource {
205        module: "poll",
206        source: include_str!("stdlib/stdlib_poll.harn"),
207    },
208    StdlibSource {
209        module: "coerce",
210        source: include_str!("stdlib/stdlib_coerce.harn"),
211    },
212    StdlibSource {
213        module: "settled",
214        source: include_str!("stdlib/stdlib_settled.harn"),
215    },
216    StdlibSource {
217        module: "cli",
218        source: include_str!("stdlib/stdlib_cli.harn"),
219    },
220    StdlibSource {
221        module: "cli/argparse",
222        source: include_str!("stdlib/cli/argparse.harn"),
223    },
224    StdlibSource {
225        module: "cli/render",
226        source: include_str!("stdlib/cli/render.harn"),
227    },
228    StdlibSource {
229        module: "cli/paths",
230        source: include_str!("stdlib/cli/paths.harn"),
231    },
232    StdlibSource {
233        module: "gha",
234        source: include_str!("stdlib/stdlib_gha.harn"),
235    },
236    StdlibSource {
237        module: "tui",
238        source: include_str!("stdlib/stdlib_tui.harn"),
239    },
240    StdlibSource {
241        module: "jsonl",
242        source: include_str!("stdlib/stdlib_jsonl.harn"),
243    },
244    StdlibSource {
245        module: "config",
246        source: include_str!("stdlib/stdlib_config.harn"),
247    },
248    StdlibSource {
249        module: "calendar",
250        source: include_str!("stdlib/stdlib_calendar.harn"),
251    },
252    StdlibSource {
253        module: "agents",
254        source: include_str!("stdlib/stdlib_agents.harn"),
255    },
256    StdlibSource {
257        module: "lifecycle/pool",
258        source: include_str!("stdlib/lifecycle/pool.harn"),
259    },
260    StdlibSource {
261        module: "lifecycle/combinators",
262        source: include_str!("stdlib/lifecycle/combinators.harn"),
263    },
264    StdlibSource {
265        module: "lifecycle/on_budget",
266        source: include_str!("stdlib/lifecycle/on_budget.harn"),
267    },
268    StdlibSource {
269        module: "agent/prompts",
270        source: include_str!("stdlib/agent/prompts.harn"),
271    },
272    StdlibSource {
273        module: "llm/media",
274        source: include_str!("stdlib/llm/media.harn"),
275    },
276    StdlibSource {
277        module: "llm/options",
278        source: include_str!("stdlib/llm/options.harn"),
279    },
280    StdlibSource {
281        module: "llm/catalog",
282        source: include_str!("stdlib/llm/catalog.harn"),
283    },
284    StdlibSource {
285        module: "llm/safe",
286        source: include_str!("stdlib/llm/safe.harn"),
287    },
288    StdlibSource {
289        module: "llm/budget",
290        source: include_str!("stdlib/llm/budget.harn"),
291    },
292    StdlibSource {
293        module: "llm/economics",
294        source: include_str!("stdlib/llm/economics.harn"),
295    },
296    StdlibSource {
297        module: "llm/prompts",
298        source: include_str!("stdlib/llm/prompts.harn"),
299    },
300    StdlibSource {
301        module: "llm/defaults",
302        source: include_str!("stdlib/llm/defaults.harn"),
303    },
304    StdlibSource {
305        module: "llm/handlers",
306        source: include_str!("stdlib/llm/handlers.harn"),
307    },
308    StdlibSource {
309        module: "llm/tool_telemetry",
310        source: include_str!("stdlib/llm/tool_telemetry.harn"),
311    },
312    StdlibSource {
313        module: "llm/tool_middleware",
314        source: include_str!("stdlib/llm/tool_middleware.harn"),
315    },
316    StdlibSource {
317        module: "llm/tool_binder",
318        source: include_str!("stdlib/llm/tool_binder.harn"),
319    },
320    StdlibSource {
321        module: "llm/structural_validator",
322        source: include_str!("stdlib/llm/structural_validator.harn"),
323    },
324    StdlibSource {
325        module: "llm/scope_classifier",
326        source: include_str!("stdlib/llm/scope_classifier.harn"),
327    },
328    StdlibSource {
329        module: "llm/refine",
330        source: include_str!("stdlib/llm/refine.harn"),
331    },
332    StdlibSource {
333        module: "llm/ensemble",
334        source: include_str!("stdlib/llm/ensemble.harn"),
335    },
336    StdlibSource {
337        module: "llm/rerank",
338        source: include_str!("stdlib/llm/rerank.harn"),
339    },
340    StdlibSource {
341        module: "agent/reasoning",
342        source: include_str!("stdlib/agent/reasoning.harn"),
343    },
344    StdlibSource {
345        module: "agent/options",
346        source: include_str!("stdlib/agent/options.harn"),
347    },
348    StdlibSource {
349        module: "llm/judge",
350        source: include_str!("stdlib/llm/judge.harn"),
351    },
352    StdlibSource {
353        module: "llm/optimize",
354        source: include_str!("stdlib/llm/optimize.harn"),
355    },
356    StdlibSource {
357        module: "agent/events",
358        source: include_str!("stdlib/agent/events.harn"),
359    },
360    StdlibSource {
361        module: "agent/primitives",
362        source: include_str!("stdlib/agent/primitives.harn"),
363    },
364    StdlibSource {
365        module: "agent/progress",
366        source: include_str!("stdlib/agent/progress.harn"),
367    },
368    StdlibSource {
369        module: "agent/required_tools",
370        source: include_str!("stdlib/agent/required_tools.harn"),
371    },
372    StdlibSource {
373        module: "agent/stall",
374        source: include_str!("stdlib/agent/stall.harn"),
375    },
376    StdlibSource {
377        module: "agent/control",
378        source: include_str!("stdlib/agent/control.harn"),
379    },
380    StdlibSource {
381        module: "agent/loop",
382        source: include_str!("stdlib/agent/loop.harn"),
383    },
384    StdlibSource {
385        module: "agent/chat",
386        source: include_str!("stdlib/agent/chat.harn"),
387    },
388    StdlibSource {
389        module: "agent/user",
390        source: include_str!("stdlib/agent/user.harn"),
391    },
392    StdlibSource {
393        module: "agent/tool_search",
394        source: include_str!("stdlib/agent/tool_search.harn"),
395    },
396    StdlibSource {
397        module: "agent/turn",
398        source: include_str!("stdlib/agent/turn.harn"),
399    },
400    StdlibSource {
401        module: "agent/workers",
402        source: include_str!("stdlib/agent/workers.harn"),
403    },
404    StdlibSource {
405        module: "agent/introspection",
406        source: include_str!("stdlib/agent/introspection.harn"),
407    },
408    StdlibSource {
409        module: "agent/resume_by",
410        source: include_str!("stdlib/agent/resume_by.harn"),
411    },
412    StdlibSource {
413        module: "agent/state",
414        source: include_str!("stdlib/agent/state.harn"),
415    },
416    StdlibSource {
417        module: "agent/skills",
418        source: include_str!("stdlib/agent/skills.harn"),
419    },
420    StdlibSource {
421        module: "agent/autocompact",
422        source: include_str!("stdlib/agent/autocompact.harn"),
423    },
424    StdlibSource {
425        module: "agent/mcp",
426        source: include_str!("stdlib/agent/mcp.harn"),
427    },
428    StdlibSource {
429        module: "agent/command_capture",
430        source: include_str!("stdlib/agent/command_capture.harn"),
431    },
432    StdlibSource {
433        module: "agent/host_tools",
434        source: include_str!("stdlib/agent/host_tools.harn"),
435    },
436    StdlibSource {
437        module: "agent/budget",
438        source: include_str!("stdlib/agent/budget.harn"),
439    },
440    StdlibSource {
441        module: "agent/daemon",
442        source: include_str!("stdlib/agent/daemon.harn"),
443    },
444    StdlibSource {
445        module: "agent/preflight",
446        source: include_str!("stdlib/agent/preflight.harn"),
447    },
448    StdlibSource {
449        module: "agent/postturn",
450        source: include_str!("stdlib/agent/postturn.harn"),
451    },
452    StdlibSource {
453        module: "agent/sitrep",
454        source: include_str!("stdlib/agent/sitrep.harn"),
455    },
456    StdlibSource {
457        module: "agent/judge_internals",
458        source: include_str!("stdlib/agent/judge_internals.harn"),
459    },
460    StdlibSource {
461        module: "agent/judge",
462        source: include_str!("stdlib/agent/judge.harn"),
463    },
464    StdlibSource {
465        module: "agent/step_judge",
466        source: include_str!("stdlib/agent/step_judge.harn"),
467    },
468    StdlibSource {
469        module: "agent/fact",
470        source: include_str!("stdlib/agent/fact.harn"),
471    },
472    StdlibSource {
473        module: "agent/probe",
474        source: include_str!("stdlib/agent/probe.harn"),
475    },
476    StdlibSource {
477        module: "agent/presets",
478        source: include_str!("stdlib/agent/presets.harn"),
479    },
480    StdlibSource {
481        module: "agent/task_plan",
482        source: include_str!("stdlib/agent/task_plan.harn"),
483    },
484    StdlibSource {
485        module: "agent_state",
486        source: include_str!("stdlib/stdlib_agent_state.harn"),
487    },
488    StdlibSource {
489        module: "memory",
490        source: include_str!("stdlib/stdlib_memory.harn"),
491    },
492    StdlibSource {
493        module: "postgres",
494        source: include_str!("stdlib/stdlib_postgres.harn"),
495    },
496    StdlibSource {
497        module: "checkpoint",
498        source: include_str!("stdlib/stdlib_checkpoint.harn"),
499    },
500    StdlibSource {
501        module: "host",
502        source: include_str!("stdlib/stdlib_host.harn"),
503    },
504    StdlibSource {
505        module: "git",
506        source: include_str!("stdlib/stdlib_git.harn"),
507    },
508    StdlibSource {
509        module: "hitl",
510        source: include_str!("stdlib/stdlib_hitl.harn"),
511    },
512    StdlibSource {
513        module: "trust",
514        source: include_str!("stdlib/stdlib_trust.harn"),
515    },
516    StdlibSource {
517        module: "corrections",
518        source: include_str!("stdlib/stdlib_corrections.harn"),
519    },
520    StdlibSource {
521        module: "plan",
522        source: include_str!("stdlib/stdlib_plan.harn"),
523    },
524    StdlibSource {
525        module: "waitpoints",
526        source: include_str!("stdlib/stdlib_waitpoints.harn"),
527    },
528    StdlibSource {
529        module: "waitpoint",
530        source: include_str!("stdlib/stdlib_waitpoint.harn"),
531    },
532    StdlibSource {
533        module: "monitors",
534        source: include_str!("stdlib/stdlib_monitors.harn"),
535    },
536    StdlibSource {
537        module: "worktree",
538        source: include_str!("stdlib/stdlib_worktree.harn"),
539    },
540    StdlibSource {
541        module: "acp",
542        source: include_str!("stdlib/stdlib_acp.harn"),
543    },
544    StdlibSource {
545        module: "external_agent",
546        source: include_str!("stdlib/stdlib_external_agent.harn"),
547    },
548    StdlibSource {
549        module: "triggers",
550        source: include_str!("stdlib/stdlib_triggers.harn"),
551    },
552    StdlibSource {
553        module: "triage",
554        source: include_str!("stdlib/stdlib_triage.harn"),
555    },
556    StdlibSource {
557        module: "dashboard/jobs",
558        source: include_str!("stdlib/dashboard/jobs.harn"),
559    },
560    StdlibSource {
561        module: "ui_resource",
562        source: include_str!("stdlib/stdlib_ui_resource.harn"),
563    },
564    StdlibSource {
565        module: "handoffs",
566        source: include_str!("stdlib/stdlib_handoffs.harn"),
567    },
568    StdlibSource {
569        module: "lifecycle",
570        source: include_str!("stdlib/stdlib_lifecycle.harn"),
571    },
572    StdlibSource {
573        module: "tool_hooks_catalogues",
574        source: include_str!("stdlib/stdlib_tool_hooks_catalogues.harn"),
575    },
576    StdlibSource {
577        module: "tool_hooks",
578        source: include_str!("stdlib/stdlib_tool_hooks.harn"),
579    },
580    StdlibSource {
581        module: "channel_guardrails",
582        source: include_str!("stdlib/stdlib_channel_guardrails.harn"),
583    },
584    StdlibSource {
585        module: "personas/prelude",
586        source: include_str!("stdlib/stdlib_personas_prelude.harn"),
587    },
588    StdlibSource {
589        module: "personas/bulletins",
590        source: include_str!("stdlib/stdlib_personas_bulletins.harn"),
591    },
592    StdlibSource {
593        module: "connectors/shared",
594        source: include_str!("stdlib/stdlib_connectors_shared.harn"),
595    },
596    StdlibSource {
597        module: "oauth/providers",
598        source: include_str!("stdlib/oauth/providers.harn"),
599    },
600    StdlibSource {
601        module: "oauth/storage",
602        source: include_str!("stdlib/oauth/storage.harn"),
603    },
604    StdlibSource {
605        module: "oauth/client",
606        source: include_str!("stdlib/oauth/client.harn"),
607    },
608    StdlibSource {
609        module: "oauth/device_flow",
610        source: include_str!("stdlib/oauth/device_flow.harn"),
611    },
612    StdlibSource {
613        module: "oauth/redaction",
614        source: include_str!("stdlib/oauth/redaction.harn"),
615    },
616    StdlibSource {
617        module: "oauth/dynamic_registration",
618        source: include_str!("stdlib/oauth/dynamic_registration.harn"),
619    },
620    StdlibSource {
621        module: "connectors/github",
622        source: include_str!("stdlib/stdlib_connectors_github.harn"),
623    },
624    StdlibSource {
625        module: "connectors/linear",
626        source: include_str!("stdlib/stdlib_connectors_linear.harn"),
627    },
628    StdlibSource {
629        module: "connectors/notion",
630        source: include_str!("stdlib/stdlib_connectors_notion.harn"),
631    },
632    StdlibSource {
633        module: "connectors/slack",
634        source: include_str!("stdlib/stdlib_connectors_slack.harn"),
635    },
636    StdlibSource {
637        module: "workflow/prompts",
638        source: include_str!("stdlib/workflow/prompts.harn"),
639    },
640    StdlibSource {
641        module: "workflow/context",
642        source: include_str!("stdlib/workflow/context.harn"),
643    },
644    StdlibSource {
645        module: "workflow/options",
646        source: include_str!("stdlib/workflow/options.harn"),
647    },
648    StdlibSource {
649        module: "workflow/checkpoints",
650        source: include_str!("stdlib/workflow/checkpoints.harn"),
651    },
652    StdlibSource {
653        module: "workflow/stage",
654        source: include_str!("stdlib/workflow/stage.harn"),
655    },
656    StdlibSource {
657        module: "workflow/map",
658        source: include_str!("stdlib/workflow/map.harn"),
659    },
660    StdlibSource {
661        module: "workflow/schedule",
662        source: include_str!("stdlib/workflow/schedule.harn"),
663    },
664    StdlibSource {
665        module: "workflow/execute",
666        source: include_str!("stdlib/workflow/execute.harn"),
667    },
668];
669
670pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = &[
671    StdlibPromptAsset {
672        path: "agent/prompts/tool_contract_text.harn.prompt",
673        source: include_str!("stdlib/agent/prompts/tool_contract_text.harn.prompt"),
674    },
675    StdlibPromptAsset {
676        path: "agent/prompts/tool_contract_native.harn.prompt",
677        source: include_str!("stdlib/agent/prompts/tool_contract_native.harn.prompt"),
678    },
679    StdlibPromptAsset {
680        path: "agent/prompts/tool_contract_text_response_protocol.harn.prompt",
681        source: include_str!(
682            "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt"
683        ),
684    },
685    StdlibPromptAsset {
686        path: "agent/prompts/tool_contract_action_native.harn.prompt",
687        source: include_str!("stdlib/agent/prompts/tool_contract_action_native.harn.prompt"),
688    },
689    StdlibPromptAsset {
690        path: "agent/prompts/tool_contract_action_text.harn.prompt",
691        source: include_str!("stdlib/agent/prompts/tool_contract_action_text.harn.prompt"),
692    },
693    StdlibPromptAsset {
694        path: "agent/prompts/tool_contract_task_ledger.harn.prompt",
695        source: include_str!("stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt"),
696    },
697    StdlibPromptAsset {
698        path: "agent/prompts/tool_contract_deferred_tools.harn.prompt",
699        source: include_str!("stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt"),
700    },
701    StdlibPromptAsset {
702        path: "agent/prompts/deferred_tool_listing.harn.prompt",
703        source: include_str!("stdlib/agent/prompts/deferred_tool_listing.harn.prompt"),
704    },
705    StdlibPromptAsset {
706        path: "agent/prompts/action_turn_nudge.harn.prompt",
707        source: include_str!("stdlib/agent/prompts/action_turn_nudge.harn.prompt"),
708    },
709    StdlibPromptAsset {
710        path: "agent/prompts/agent_turn_preamble.harn.prompt",
711        source: include_str!("stdlib/agent/prompts/agent_turn_preamble.harn.prompt"),
712    },
713    StdlibPromptAsset {
714        path: "agent/prompts/default_nudge.harn.prompt",
715        source: include_str!("stdlib/agent/prompts/default_nudge.harn.prompt"),
716    },
717    StdlibPromptAsset {
718        path: "agent/prompts/agentic_user_system.harn.prompt",
719        source: include_str!("stdlib/agent/prompts/agentic_user_system.harn.prompt"),
720    },
721    StdlibPromptAsset {
722        path: "agent/prompts/agentic_user_user.harn.prompt",
723        source: include_str!("stdlib/agent/prompts/agentic_user_user.harn.prompt"),
724    },
725    StdlibPromptAsset {
726        path: "agent/prompts/loop_until_done_system.harn.prompt",
727        source: include_str!("stdlib/agent/prompts/loop_until_done_system.harn.prompt"),
728    },
729    StdlibPromptAsset {
730        path: "agent/prompts/completion_judge_default.harn.prompt",
731        source: include_str!("stdlib/agent/prompts/completion_judge_default.harn.prompt"),
732    },
733    StdlibPromptAsset {
734        path: "agent/prompts/completion_judge_feedback_fallback.harn.prompt",
735        source: include_str!("stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt"),
736    },
737    StdlibPromptAsset {
738        path: "agent/prompts/completion_judge_user.harn.prompt",
739        source: include_str!("stdlib/agent/prompts/completion_judge_user.harn.prompt"),
740    },
741    StdlibPromptAsset {
742        path: "agent/prompts/step_judge_system_default.harn.prompt",
743        source: include_str!("stdlib/agent/prompts/step_judge_system_default.harn.prompt"),
744    },
745    StdlibPromptAsset {
746        path: "agent/prompts/step_judge_system_adversarial.harn.prompt",
747        source: include_str!("stdlib/agent/prompts/step_judge_system_adversarial.harn.prompt"),
748    },
749    StdlibPromptAsset {
750        path: "agent/prompts/step_judge_user.harn.prompt",
751        source: include_str!("stdlib/agent/prompts/step_judge_user.harn.prompt"),
752    },
753    StdlibPromptAsset {
754        path: "agent/prompts/parse_guidance.harn.prompt",
755        source: include_str!("stdlib/agent/prompts/parse_guidance.harn.prompt"),
756    },
757    StdlibPromptAsset {
758        path: "agent/prompts/protocol_violation_feedback.harn.prompt",
759        source: include_str!("stdlib/agent/prompts/protocol_violation_feedback.harn.prompt"),
760    },
761    StdlibPromptAsset {
762        path: "agent/prompts/native_tool_contract_feedback.harn.prompt",
763        source: include_str!("stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt"),
764    },
765    StdlibPromptAsset {
766        path: "agent/prompts/verification_gate_feedback.harn.prompt",
767        source: include_str!("stdlib/agent/prompts/verification_gate_feedback.harn.prompt"),
768    },
769    StdlibPromptAsset {
770        path: "agent/prompts/action_required_feedback.harn.prompt",
771        source: include_str!("stdlib/agent/prompts/action_required_feedback.harn.prompt"),
772    },
773    StdlibPromptAsset {
774        path: "agent/prompts/daemon_watch_feedback.harn.prompt",
775        source: include_str!("stdlib/agent/prompts/daemon_watch_feedback.harn.prompt"),
776    },
777    StdlibPromptAsset {
778        path: "agent/prompts/daemon_timer_feedback.harn.prompt",
779        source: include_str!("stdlib/agent/prompts/daemon_timer_feedback.harn.prompt"),
780    },
781    StdlibPromptAsset {
782        path: "llm/prompts/completion_fallback_system.harn.prompt",
783        source: include_str!("stdlib/llm/prompts/completion_fallback_system.harn.prompt"),
784    },
785    StdlibPromptAsset {
786        path: "llm/prompts/completion_fallback_user.harn.prompt",
787        source: include_str!("stdlib/llm/prompts/completion_fallback_user.harn.prompt"),
788    },
789    StdlibPromptAsset {
790        path: "llm/prompts/transcript_summarize_user.harn.prompt",
791        source: include_str!("stdlib/llm/prompts/transcript_summarize_user.harn.prompt"),
792    },
793    StdlibPromptAsset {
794        path: "llm/prompts/sitrep_user.harn.prompt",
795        source: include_str!("stdlib/llm/prompts/sitrep_user.harn.prompt"),
796    },
797    StdlibPromptAsset {
798        path: "llm/prompts/structural_chain_of_draft.harn.prompt",
799        source: include_str!("stdlib/llm/prompts/structural_chain_of_draft.harn.prompt"),
800    },
801    StdlibPromptAsset {
802        path: "llm/prompts/schema_recover_repair.harn.prompt",
803        source: include_str!("stdlib/llm/prompts/schema_recover_repair.harn.prompt"),
804    },
805    StdlibPromptAsset {
806        path: "llm/prompts/structured_envelope_schema_contract.harn.prompt",
807        source: include_str!("stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt"),
808    },
809    StdlibPromptAsset {
810        path: "llm/prompts/structured_envelope_repair.harn.prompt",
811        source: include_str!("stdlib/llm/prompts/structured_envelope_repair.harn.prompt"),
812    },
813    StdlibPromptAsset {
814        path: "llm/prompts/pairwise_rerank_user.harn.prompt",
815        source: include_str!("stdlib/llm/prompts/pairwise_rerank_user.harn.prompt"),
816    },
817    StdlibPromptAsset {
818        path: "llm/prompts/tool_binder_user.harn.prompt",
819        source: include_str!("stdlib/llm/prompts/tool_binder_user.harn.prompt"),
820    },
821    StdlibPromptAsset {
822        path: "workflow/prompts/stage.harn.prompt",
823        source: include_str!("stdlib/workflow/prompts/stage.harn.prompt"),
824    },
825    StdlibPromptAsset {
826        path: "workflow/prompts/verification_context_intro.harn.prompt",
827        source: include_str!("stdlib/workflow/prompts/verification_context_intro.harn.prompt"),
828    },
829    StdlibPromptAsset {
830        path: "orchestration/prompts/compaction_summary.harn.prompt",
831        source: include_str!("stdlib/orchestration/prompts/compaction_summary.harn.prompt"),
832    },
833    StdlibPromptAsset {
834        path: "orchestration/prompts/compaction_policy_replacement.harn.prompt",
835        source: include_str!(
836            "stdlib/orchestration/prompts/compaction_policy_replacement.harn.prompt"
837        ),
838    },
839];
840
841/// Embedded `.harn` script that backs a CLI subcommand. Looked up by
842/// the `harn-cli` dispatch wedge (see harn#2293 epic and harn#2294 G1)
843/// so subcommands can ship in Harn instead of Rust.
844#[derive(Debug, Clone, Copy, PartialEq, Eq)]
845pub struct StdlibCliScript {
846    /// Lookup name. For nested scripts this is the path under
847    /// `stdlib/cli/` without the `.harn` extension (e.g. `"eval/prompt"`
848    /// for `stdlib/cli/eval/prompt.harn`).
849    pub name: &'static str,
850    /// Embedded source. Run via the existing `harn run` codepath by the
851    /// dispatch wedge.
852    pub source: &'static str,
853}
854
855pub const STDLIB_CLI_SCRIPTS: &[StdlibCliScript] = &[
856    StdlibCliScript {
857        name: "doctor",
858        source: include_str!("stdlib/cli/doctor.harn"),
859    },
860    StdlibCliScript {
861        name: "echo",
862        source: include_str!("stdlib/cli/echo.harn"),
863    },
864    // Helper module for the embedded `eval/*` scripts. Has a stub `main`
865    // that exits non-zero — sibling scripts inline its helpers until the
866    // dispatch wedge gains a cross-script import surface (#2300 / G7).
867    StdlibCliScript {
868        name: "eval/_runner",
869        source: include_str!("stdlib/cli/eval/_runner.harn"),
870    },
871    StdlibCliScript {
872        name: "eval/context",
873        source: include_str!("stdlib/cli/eval/context.harn"),
874    },
875    StdlibCliScript {
876        name: "eval/model_selector",
877        source: include_str!("stdlib/cli/eval/model_selector.harn"),
878    },
879    StdlibCliScript {
880        name: "eval/tool_calls",
881        source: include_str!("stdlib/cli/eval/tool_calls.harn"),
882    },
883    StdlibCliScript {
884        name: "eval/coding_agent",
885        source: include_str!("stdlib/cli/eval/coding_agent.harn"),
886    },
887    StdlibCliScript {
888        name: "eval/scope_triage",
889        source: include_str!("stdlib/cli/eval/scope_triage.harn"),
890    },
891    StdlibCliScript {
892        name: "eval/prompt",
893        source: include_str!("stdlib/cli/eval/prompt.harn"),
894    },
895    StdlibCliScript {
896        name: "explain",
897        source: include_str!("stdlib/cli/explain.harn"),
898    },
899    StdlibCliScript {
900        name: "graph",
901        source: include_str!("stdlib/cli/graph.harn"),
902    },
903    StdlibCliScript {
904        name: "models/list",
905        source: include_str!("stdlib/cli/models/list.harn"),
906    },
907    StdlibCliScript {
908        name: "models/recommend",
909        source: include_str!("stdlib/cli/models/recommend.harn"),
910    },
911    StdlibCliScript {
912        name: "models/test",
913        source: include_str!("stdlib/cli/models/test.harn"),
914    },
915    StdlibCliScript {
916        name: "precompile",
917        source: include_str!("stdlib/cli/precompile.harn"),
918    },
919    StdlibCliScript {
920        name: "providers/catalog",
921        source: include_str!("stdlib/cli/providers/catalog.harn"),
922    },
923    StdlibCliScript {
924        name: "providers/probe",
925        source: include_str!("stdlib/cli/providers/probe.harn"),
926    },
927    StdlibCliScript {
928        name: "providers/recommend",
929        source: include_str!("stdlib/cli/providers/recommend.harn"),
930    },
931    StdlibCliScript {
932        name: "providers/tool_probe",
933        source: include_str!("stdlib/cli/providers/tool_probe.harn"),
934    },
935    StdlibCliScript {
936        name: "routes",
937        source: include_str!("stdlib/cli/routes.harn"),
938    },
939    StdlibCliScript {
940        name: "scaffold/init",
941        source: include_str!("stdlib/cli/scaffold/init.harn"),
942    },
943    StdlibCliScript {
944        name: "scaffold/tool_new",
945        source: include_str!("stdlib/cli/scaffold/tool_new.harn"),
946    },
947    StdlibCliScript {
948        name: "trace_import",
949        source: include_str!("stdlib/cli/trace_import.harn"),
950    },
951    StdlibCliScript {
952        name: "try",
953        source: include_str!("stdlib/cli/try.harn"),
954    },
955    StdlibCliScript {
956        name: "version",
957        source: include_str!("stdlib/cli/version.harn"),
958    },
959];
960
961pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
962    STDLIB_SOURCES
963        .iter()
964        .find_map(|entry| (entry.module == module).then_some(entry.source))
965}
966
967/// Find an embedded CLI subcommand script by name. Returns the embedded
968/// source string when present, or `None` if no script with that name is
969/// registered in [`STDLIB_CLI_SCRIPTS`].
970pub fn find_cli_script(name: &str) -> Option<&'static str> {
971    STDLIB_CLI_SCRIPTS
972        .iter()
973        .find_map(|entry| (entry.name == name).then_some(entry.source))
974}
975
976pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
977    let path = path.strip_prefix("std/").unwrap_or(path);
978    STDLIB_PROMPT_ASSETS
979        .iter()
980        .find_map(|entry| (entry.path == path).then_some(entry.source))
981}
982
983pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
984    let Some(source) = get_stdlib_source(module) else {
985        return Vec::new();
986    };
987    public_functions_from_source(source)
988}
989
990pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
991    STDLIB_SOURCES
992        .iter()
993        .filter_map(|entry| {
994            entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
995                import_path: format!("std/{}", entry.module),
996                category,
997            })
998        })
999        .collect()
1000}
1001
1002fn entrypoint_category_from_source(source: &str) -> Option<String> {
1003    for line in source.lines() {
1004        let line = line.trim();
1005        if line.is_empty() {
1006            continue;
1007        }
1008        if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
1009            let category = category.trim();
1010            return (!category.is_empty()).then(|| category.to_string());
1011        }
1012        if !line.starts_with("//") {
1013            return None;
1014        }
1015    }
1016    None
1017}
1018
1019fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
1020    let mut out = Vec::new();
1021    let mut doc: Option<String> = None;
1022    let lines = source.lines().collect::<Vec<_>>();
1023    let mut index = 0usize;
1024    while index < lines.len() {
1025        let line = lines[index].trim();
1026        if line.starts_with("/**") {
1027            let (parsed, next) = parse_harndoc(&lines, index);
1028            doc = parsed;
1029            index = next;
1030            continue;
1031        }
1032        if line.starts_with("pub fn ") {
1033            let (signature_line, next) = collect_public_function_signature(&lines, index);
1034            if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
1035                out.push(function);
1036                index = next;
1037                continue;
1038            }
1039        }
1040        if let Some(function) = parse_public_function_line(line, doc.take()) {
1041            out.push(function);
1042        } else if !line.is_empty() && !line.starts_with("//") {
1043            doc = None;
1044        }
1045        index += 1;
1046    }
1047    out
1048}
1049
1050fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
1051    let mut parts = Vec::new();
1052    let mut index = start;
1053    while index < lines.len() {
1054        parts.push(lines[index].trim().to_string());
1055        let candidate = parts.join(" ");
1056        if public_function_signature_complete(&candidate) {
1057            return (candidate, index + 1);
1058        }
1059        index += 1;
1060    }
1061    (parts.join(" "), index)
1062}
1063
1064fn public_function_signature_complete(line: &str) -> bool {
1065    let Some(rest) = line.strip_prefix("pub fn ") else {
1066        return false;
1067    };
1068    let Some(name_end) = rest.find('(') else {
1069        return false;
1070    };
1071    matching_paren_len(&rest[name_end + 1..]).is_some()
1072}
1073
1074fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
1075    let mut parts = Vec::new();
1076    let mut index = start;
1077    while index < lines.len() {
1078        let mut line = lines[index].trim();
1079        if index == start {
1080            line = line.trim_start_matches("/**").trim();
1081        }
1082        let done = line.ends_with("*/");
1083        line = line.trim_end_matches("*/").trim();
1084        line = line.trim_start_matches('*').trim();
1085        if !line.is_empty() {
1086            parts.push(line.to_string());
1087        }
1088        index += 1;
1089        if done {
1090            break;
1091        }
1092    }
1093    let text = parts.join("\n").trim().to_string();
1094    ((!text.is_empty()).then_some(text), index)
1095}
1096
1097fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
1098    let rest = line.strip_prefix("pub fn ")?.trim();
1099    let name_end = rest.find('(')?;
1100    let name = rest[..name_end].trim();
1101    if name.is_empty() {
1102        return None;
1103    }
1104    let params_start = name_end + 1;
1105    let params_len = matching_paren_len(&rest[params_start..])?;
1106    let params = &rest[params_start..params_start + params_len];
1107    let after = rest[params_start + params_len + 1..].trim();
1108    let return_type = after
1109        .strip_prefix("->")
1110        .and_then(|tail| tail.split('{').next())
1111        .map(str::trim)
1112        .filter(|value| !value.is_empty());
1113    let signature = match return_type {
1114        Some(ret) => format!("{name}({params}) -> {ret}"),
1115        None => format!("{name}({params})"),
1116    };
1117    let param_parts = split_top_level_params(params);
1118    let total_params = param_parts
1119        .iter()
1120        .filter(|param| !param.trim().is_empty())
1121        .count();
1122    let variadic = param_parts
1123        .iter()
1124        .any(|param| param.trim_start().starts_with("..."));
1125    let required_params = param_parts
1126        .iter()
1127        .filter(|param| {
1128            let param = param.trim();
1129            !param.is_empty() && !param.contains('=') && !param.starts_with("...")
1130        })
1131        .count();
1132    Some(StdlibPublicFunction {
1133        name: name.to_string(),
1134        signature,
1135        required_params,
1136        total_params,
1137        variadic,
1138        doc,
1139    })
1140}
1141
1142fn matching_paren_len(input: &str) -> Option<usize> {
1143    let mut depth = 1usize;
1144    for (offset, ch) in input.char_indices() {
1145        match ch {
1146            '(' | '[' | '{' => depth += 1,
1147            ')' => {
1148                depth = depth.saturating_sub(1);
1149                if depth == 0 {
1150                    return Some(offset);
1151                }
1152            }
1153            ']' | '}' => depth = depth.saturating_sub(1),
1154            _ => {}
1155        }
1156    }
1157    None
1158}
1159
1160fn split_top_level_params(params: &str) -> Vec<&str> {
1161    let mut out = Vec::new();
1162    let mut depth = 0isize;
1163    let mut start = 0usize;
1164    for (offset, ch) in params.char_indices() {
1165        match ch {
1166            '(' | '[' | '{' => depth += 1,
1167            ')' | ']' | '}' => depth -= 1,
1168            ',' if depth == 0 => {
1169                out.push(&params[start..offset]);
1170                start = offset + 1;
1171            }
1172            _ => {}
1173        }
1174    }
1175    out.push(&params[start..]);
1176    out
1177}
1178
1179#[cfg(test)]
1180mod tests {
1181    use std::collections::BTreeSet;
1182
1183    use super::{
1184        entrypoint_modules, find_cli_script, get_stdlib_prompt_asset, get_stdlib_source,
1185        public_functions_for_module, STDLIB_CLI_SCRIPTS, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
1186    };
1187
1188    #[test]
1189    fn stdlib_sources_are_non_empty() {
1190        for entry in STDLIB_SOURCES {
1191            assert!(
1192                !entry.source.trim().is_empty(),
1193                "{} should have non-empty source",
1194                entry.module
1195            );
1196        }
1197    }
1198
1199    #[test]
1200    fn cli_scripts_are_non_empty_and_uniquely_named() {
1201        let mut seen = BTreeSet::new();
1202        for entry in STDLIB_CLI_SCRIPTS {
1203            assert!(
1204                !entry.source.trim().is_empty(),
1205                "cli/{} should have non-empty source",
1206                entry.name
1207            );
1208            assert!(
1209                seen.insert(entry.name),
1210                "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
1211                entry.name
1212            );
1213        }
1214    }
1215
1216    #[test]
1217    fn find_cli_script_round_trips() {
1218        for entry in STDLIB_CLI_SCRIPTS {
1219            assert_eq!(find_cli_script(entry.name), Some(entry.source));
1220        }
1221        assert!(find_cli_script("not-a-real-script").is_none());
1222    }
1223
1224    #[test]
1225    fn stdlib_source_names_are_unique() {
1226        let mut names = BTreeSet::new();
1227        for entry in STDLIB_SOURCES {
1228            assert!(names.insert(entry.module), "duplicate {}", entry.module);
1229        }
1230    }
1231
1232    #[test]
1233    fn stdlib_prompt_assets_are_non_empty() {
1234        for entry in STDLIB_PROMPT_ASSETS {
1235            assert!(
1236                !entry.source.trim().is_empty(),
1237                "{} should have non-empty prompt asset source",
1238                entry.path
1239            );
1240        }
1241    }
1242
1243    #[test]
1244    fn stdlib_prompt_asset_paths_are_unique() {
1245        let mut paths = BTreeSet::new();
1246        for entry in STDLIB_PROMPT_ASSETS {
1247            assert!(paths.insert(entry.path), "duplicate {}", entry.path);
1248        }
1249    }
1250
1251    #[test]
1252    fn key_stdlib_modules_resolve() {
1253        for module in [
1254            "context",
1255            "context/maintenance",
1256            "context/eval",
1257            "edit",
1258            "artifact/web",
1259            "command",
1260            "waitpoint",
1261            "llm/handlers",
1262            "llm/tool_middleware",
1263            "llm/tool_binder",
1264            "llm/ensemble",
1265            "llm/rerank",
1266            "personas/prelude",
1267            "personas/bulletins",
1268            "agent/host_tools",
1269            "agent/user",
1270            "llm/optimize",
1271            "llm/judge",
1272            "llm/refine",
1273            "connectors/shared",
1274            "connectors/github",
1275            "connectors/linear",
1276            "connectors/notion",
1277            "connectors/slack",
1278            "triage",
1279            "dashboard/jobs",
1280            "ui_resource",
1281        ] {
1282            assert!(
1283                get_stdlib_source(module).is_some(),
1284                "std/{module} should resolve"
1285            );
1286        }
1287    }
1288
1289    #[test]
1290    fn key_stdlib_prompt_assets_resolve() {
1291        for path in [
1292            "std/agent/prompts/tool_contract_text.harn.prompt",
1293            "std/agent/prompts/action_turn_nudge.harn.prompt",
1294            "std/agent/prompts/completion_judge_default.harn.prompt",
1295            "std/workflow/prompts/stage.harn.prompt",
1296            "std/orchestration/prompts/compaction_summary.harn.prompt",
1297            "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
1298        ] {
1299            assert!(
1300                get_stdlib_prompt_asset(path).is_some(),
1301                "{path} should resolve"
1302            );
1303        }
1304    }
1305
1306    #[test]
1307    fn public_function_catalog_derives_signatures_from_harn_source() {
1308        let exports = public_functions_for_module("workflow/execute");
1309        assert_eq!(exports.len(), 1);
1310        assert_eq!(exports[0].name, "workflow_execute");
1311        assert_eq!(
1312            exports[0].signature,
1313            "workflow_execute(task, graph, artifacts = nil, options = nil)"
1314        );
1315        assert_eq!(exports[0].required_params, 2);
1316        assert_eq!(exports[0].total_params, 4);
1317    }
1318
1319    #[test]
1320    fn command_stdlib_module_exports_step_helpers() {
1321        let exports = public_functions_for_module("command")
1322            .into_iter()
1323            .map(|function| function.name)
1324            .collect::<BTreeSet<_>>();
1325        for name in [
1326            "command_run",
1327            "command_output_tail",
1328            "command_json",
1329            "command_json_step",
1330            "command_try",
1331            "command_step",
1332            "command_steps_append",
1333            "command_last_failed_step",
1334            "command_step_ref",
1335        ] {
1336            assert!(exports.contains(name), "std/command should export {name}");
1337        }
1338    }
1339
1340    #[test]
1341    fn async_stdlib_exports_predicate_backoff_name_only() {
1342        let exports = public_functions_for_module("async")
1343            .into_iter()
1344            .map(|function| function.name)
1345            .collect::<BTreeSet<_>>();
1346        assert!(
1347            exports.contains("retry_predicate_with_backoff"),
1348            "std/async should export retry_predicate_with_backoff"
1349        );
1350        assert!(
1351            !exports.contains("retry_with_backoff"),
1352            "std/async should not retain the old retry_with_backoff export"
1353        );
1354    }
1355
1356    #[test]
1357    fn signal_stdlib_module_exports_interrupt_helpers() {
1358        let exports = public_functions_for_module("signal")
1359            .into_iter()
1360            .map(|function| function.name)
1361            .collect::<BTreeSet<_>>();
1362        for name in [
1363            "on_interrupt",
1364            "off_interrupt",
1365            "interrupted",
1366            "with_interrupt",
1367        ] {
1368            assert!(exports.contains(name), "std/signal should export {name}");
1369        }
1370    }
1371
1372    #[test]
1373    fn git_stdlib_module_exports_local_wrappers() {
1374        let exports = public_functions_for_module("git")
1375            .into_iter()
1376            .map(|function| function.name)
1377            .collect::<BTreeSet<_>>();
1378        for name in [
1379            "git_run",
1380            "git_status",
1381            "git_current_branch",
1382            "git_log",
1383            "git_switch",
1384            "git_pull_ff_only",
1385            "git_find_tool",
1386            "git_run_tool",
1387            "git_tools",
1388            "git_toolbox_tools",
1389        ] {
1390            assert!(exports.contains(name), "std/git should export {name}");
1391        }
1392    }
1393
1394    #[test]
1395    fn agent_workers_exports_suspend_resume_wrappers() {
1396        let exports = public_functions_for_module("agent/workers");
1397        let suspend = exports
1398            .iter()
1399            .find(|function| function.name == "suspend_agent")
1400            .expect("std/agent/workers should export suspend_agent");
1401        assert_eq!(
1402            suspend.signature,
1403            "suspend_agent(worker, reason = \"\", options = nil)"
1404        );
1405        assert_eq!(suspend.required_params, 1);
1406        assert_eq!(suspend.total_params, 3);
1407
1408        let resume = exports
1409            .iter()
1410            .find(|function| function.name == "resume_agent")
1411            .expect("std/agent/workers should export resume_agent");
1412        assert_eq!(
1413            resume.signature,
1414            "resume_agent(worker_or_snapshot, resume_input = nil, continue_transcript = true)"
1415        );
1416        assert_eq!(resume.required_params, 1);
1417        assert_eq!(resume.total_params, 3);
1418
1419        let parse_resume = exports
1420            .iter()
1421            .find(|function| function.name == "parse_resume_conditions")
1422            .expect("std/agent/workers should export parse_resume_conditions");
1423        assert_eq!(
1424            parse_resume.signature,
1425            "parse_resume_conditions(conditions = nil) -> ResumeConditions?"
1426        );
1427        assert_eq!(parse_resume.required_params, 0);
1428        assert_eq!(parse_resume.total_params, 1);
1429
1430        let lifecycle = exports
1431            .iter()
1432            .find(|function| function.name == "agent_lifecycle_tools")
1433            .expect("std/agent/workers should export agent_lifecycle_tools");
1434        assert_eq!(
1435            lifecycle.signature,
1436            "agent_lifecycle_tools(registry = nil, options = nil)"
1437        );
1438        assert_eq!(lifecycle.required_params, 0);
1439        assert_eq!(lifecycle.total_params, 2);
1440    }
1441
1442    #[test]
1443    fn tui_stdlib_module_exports_terminal_helpers() {
1444        let exports = public_functions_for_module("tui")
1445            .into_iter()
1446            .map(|function| function.name)
1447            .collect::<BTreeSet<_>>();
1448        for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1449            assert!(exports.contains(name), "std/tui should export {name}");
1450        }
1451    }
1452
1453    #[test]
1454    fn semver_stdlib_module_exports_release_helpers() {
1455        let exports = public_functions_for_module("semver")
1456            .into_iter()
1457            .map(|function| function.name)
1458            .collect::<BTreeSet<_>>();
1459        for name in [
1460            "strip_v",
1461            "add_v",
1462            "is_v_semver",
1463            "parse",
1464            "next",
1465            "bump_type",
1466            "version_from_release_branch",
1467            "version_from_tag",
1468        ] {
1469            assert!(exports.contains(name), "std/semver should export {name}");
1470        }
1471    }
1472
1473    #[test]
1474    fn text_stdlib_module_exports_regex_and_pad_helpers() {
1475        let exports = public_functions_for_module("text")
1476            .into_iter()
1477            .map(|function| function.name)
1478            .collect::<BTreeSet<_>>();
1479        for name in [
1480            "pad_left",
1481            "pad_right",
1482            "repeat_string",
1483            "regex_first_capture",
1484            "regex_capture_groups",
1485            "regex_all_first_captures",
1486        ] {
1487            assert!(exports.contains(name), "std/text should export {name}");
1488        }
1489    }
1490
1491    #[test]
1492    fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1493        let modules = entrypoint_modules();
1494        let entries = modules
1495            .iter()
1496            .map(|module| (module.import_path.as_str(), module.category.as_str()))
1497            .collect::<BTreeSet<_>>();
1498        for entry in [
1499            ("std/agent/loop", "agent.stdlib"),
1500            ("std/agent/turn", "agent.stdlib"),
1501            ("std/agent/primitives", "agent.stdlib"),
1502            ("std/workflow/execute", "workflow.stdlib"),
1503        ] {
1504            assert!(entries.contains(&entry), "{entry:?} should be declared");
1505        }
1506    }
1507}