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: "triggers",
546        source: include_str!("stdlib/stdlib_triggers.harn"),
547    },
548    StdlibSource {
549        module: "triage",
550        source: include_str!("stdlib/stdlib_triage.harn"),
551    },
552    StdlibSource {
553        module: "dashboard/jobs",
554        source: include_str!("stdlib/dashboard/jobs.harn"),
555    },
556    StdlibSource {
557        module: "ui_resource",
558        source: include_str!("stdlib/stdlib_ui_resource.harn"),
559    },
560    StdlibSource {
561        module: "handoffs",
562        source: include_str!("stdlib/stdlib_handoffs.harn"),
563    },
564    StdlibSource {
565        module: "lifecycle",
566        source: include_str!("stdlib/stdlib_lifecycle.harn"),
567    },
568    StdlibSource {
569        module: "tool_hooks_catalogues",
570        source: include_str!("stdlib/stdlib_tool_hooks_catalogues.harn"),
571    },
572    StdlibSource {
573        module: "tool_hooks",
574        source: include_str!("stdlib/stdlib_tool_hooks.harn"),
575    },
576    StdlibSource {
577        module: "channel_guardrails",
578        source: include_str!("stdlib/stdlib_channel_guardrails.harn"),
579    },
580    StdlibSource {
581        module: "personas/prelude",
582        source: include_str!("stdlib/stdlib_personas_prelude.harn"),
583    },
584    StdlibSource {
585        module: "personas/bulletins",
586        source: include_str!("stdlib/stdlib_personas_bulletins.harn"),
587    },
588    StdlibSource {
589        module: "connectors/shared",
590        source: include_str!("stdlib/stdlib_connectors_shared.harn"),
591    },
592    StdlibSource {
593        module: "oauth/providers",
594        source: include_str!("stdlib/oauth/providers.harn"),
595    },
596    StdlibSource {
597        module: "oauth/storage",
598        source: include_str!("stdlib/oauth/storage.harn"),
599    },
600    StdlibSource {
601        module: "oauth/client",
602        source: include_str!("stdlib/oauth/client.harn"),
603    },
604    StdlibSource {
605        module: "oauth/device_flow",
606        source: include_str!("stdlib/oauth/device_flow.harn"),
607    },
608    StdlibSource {
609        module: "oauth/redaction",
610        source: include_str!("stdlib/oauth/redaction.harn"),
611    },
612    StdlibSource {
613        module: "oauth/dynamic_registration",
614        source: include_str!("stdlib/oauth/dynamic_registration.harn"),
615    },
616    StdlibSource {
617        module: "connectors/github",
618        source: include_str!("stdlib/stdlib_connectors_github.harn"),
619    },
620    StdlibSource {
621        module: "connectors/linear",
622        source: include_str!("stdlib/stdlib_connectors_linear.harn"),
623    },
624    StdlibSource {
625        module: "connectors/notion",
626        source: include_str!("stdlib/stdlib_connectors_notion.harn"),
627    },
628    StdlibSource {
629        module: "connectors/slack",
630        source: include_str!("stdlib/stdlib_connectors_slack.harn"),
631    },
632    StdlibSource {
633        module: "workflow/prompts",
634        source: include_str!("stdlib/workflow/prompts.harn"),
635    },
636    StdlibSource {
637        module: "workflow/context",
638        source: include_str!("stdlib/workflow/context.harn"),
639    },
640    StdlibSource {
641        module: "workflow/options",
642        source: include_str!("stdlib/workflow/options.harn"),
643    },
644    StdlibSource {
645        module: "workflow/checkpoints",
646        source: include_str!("stdlib/workflow/checkpoints.harn"),
647    },
648    StdlibSource {
649        module: "workflow/stage",
650        source: include_str!("stdlib/workflow/stage.harn"),
651    },
652    StdlibSource {
653        module: "workflow/map",
654        source: include_str!("stdlib/workflow/map.harn"),
655    },
656    StdlibSource {
657        module: "workflow/schedule",
658        source: include_str!("stdlib/workflow/schedule.harn"),
659    },
660    StdlibSource {
661        module: "workflow/execute",
662        source: include_str!("stdlib/workflow/execute.harn"),
663    },
664];
665
666pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = &[
667    StdlibPromptAsset {
668        path: "agent/prompts/tool_contract_text.harn.prompt",
669        source: include_str!("stdlib/agent/prompts/tool_contract_text.harn.prompt"),
670    },
671    StdlibPromptAsset {
672        path: "agent/prompts/tool_contract_native.harn.prompt",
673        source: include_str!("stdlib/agent/prompts/tool_contract_native.harn.prompt"),
674    },
675    StdlibPromptAsset {
676        path: "agent/prompts/tool_contract_text_response_protocol.harn.prompt",
677        source: include_str!(
678            "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt"
679        ),
680    },
681    StdlibPromptAsset {
682        path: "agent/prompts/tool_contract_action_native.harn.prompt",
683        source: include_str!("stdlib/agent/prompts/tool_contract_action_native.harn.prompt"),
684    },
685    StdlibPromptAsset {
686        path: "agent/prompts/tool_contract_action_text.harn.prompt",
687        source: include_str!("stdlib/agent/prompts/tool_contract_action_text.harn.prompt"),
688    },
689    StdlibPromptAsset {
690        path: "agent/prompts/tool_contract_task_ledger.harn.prompt",
691        source: include_str!("stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt"),
692    },
693    StdlibPromptAsset {
694        path: "agent/prompts/tool_contract_deferred_tools.harn.prompt",
695        source: include_str!("stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt"),
696    },
697    StdlibPromptAsset {
698        path: "agent/prompts/deferred_tool_listing.harn.prompt",
699        source: include_str!("stdlib/agent/prompts/deferred_tool_listing.harn.prompt"),
700    },
701    StdlibPromptAsset {
702        path: "agent/prompts/action_turn_nudge.harn.prompt",
703        source: include_str!("stdlib/agent/prompts/action_turn_nudge.harn.prompt"),
704    },
705    StdlibPromptAsset {
706        path: "agent/prompts/agent_turn_preamble.harn.prompt",
707        source: include_str!("stdlib/agent/prompts/agent_turn_preamble.harn.prompt"),
708    },
709    StdlibPromptAsset {
710        path: "agent/prompts/default_nudge.harn.prompt",
711        source: include_str!("stdlib/agent/prompts/default_nudge.harn.prompt"),
712    },
713    StdlibPromptAsset {
714        path: "agent/prompts/agentic_user_system.harn.prompt",
715        source: include_str!("stdlib/agent/prompts/agentic_user_system.harn.prompt"),
716    },
717    StdlibPromptAsset {
718        path: "agent/prompts/agentic_user_user.harn.prompt",
719        source: include_str!("stdlib/agent/prompts/agentic_user_user.harn.prompt"),
720    },
721    StdlibPromptAsset {
722        path: "agent/prompts/loop_until_done_system.harn.prompt",
723        source: include_str!("stdlib/agent/prompts/loop_until_done_system.harn.prompt"),
724    },
725    StdlibPromptAsset {
726        path: "agent/prompts/completion_judge_default.harn.prompt",
727        source: include_str!("stdlib/agent/prompts/completion_judge_default.harn.prompt"),
728    },
729    StdlibPromptAsset {
730        path: "agent/prompts/completion_judge_feedback_fallback.harn.prompt",
731        source: include_str!("stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt"),
732    },
733    StdlibPromptAsset {
734        path: "agent/prompts/completion_judge_user.harn.prompt",
735        source: include_str!("stdlib/agent/prompts/completion_judge_user.harn.prompt"),
736    },
737    StdlibPromptAsset {
738        path: "agent/prompts/step_judge_system_default.harn.prompt",
739        source: include_str!("stdlib/agent/prompts/step_judge_system_default.harn.prompt"),
740    },
741    StdlibPromptAsset {
742        path: "agent/prompts/step_judge_system_adversarial.harn.prompt",
743        source: include_str!("stdlib/agent/prompts/step_judge_system_adversarial.harn.prompt"),
744    },
745    StdlibPromptAsset {
746        path: "agent/prompts/step_judge_user.harn.prompt",
747        source: include_str!("stdlib/agent/prompts/step_judge_user.harn.prompt"),
748    },
749    StdlibPromptAsset {
750        path: "agent/prompts/parse_guidance.harn.prompt",
751        source: include_str!("stdlib/agent/prompts/parse_guidance.harn.prompt"),
752    },
753    StdlibPromptAsset {
754        path: "agent/prompts/protocol_violation_feedback.harn.prompt",
755        source: include_str!("stdlib/agent/prompts/protocol_violation_feedback.harn.prompt"),
756    },
757    StdlibPromptAsset {
758        path: "agent/prompts/native_tool_contract_feedback.harn.prompt",
759        source: include_str!("stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt"),
760    },
761    StdlibPromptAsset {
762        path: "agent/prompts/verification_gate_feedback.harn.prompt",
763        source: include_str!("stdlib/agent/prompts/verification_gate_feedback.harn.prompt"),
764    },
765    StdlibPromptAsset {
766        path: "agent/prompts/action_required_feedback.harn.prompt",
767        source: include_str!("stdlib/agent/prompts/action_required_feedback.harn.prompt"),
768    },
769    StdlibPromptAsset {
770        path: "agent/prompts/daemon_watch_feedback.harn.prompt",
771        source: include_str!("stdlib/agent/prompts/daemon_watch_feedback.harn.prompt"),
772    },
773    StdlibPromptAsset {
774        path: "agent/prompts/daemon_timer_feedback.harn.prompt",
775        source: include_str!("stdlib/agent/prompts/daemon_timer_feedback.harn.prompt"),
776    },
777    StdlibPromptAsset {
778        path: "llm/prompts/completion_fallback_system.harn.prompt",
779        source: include_str!("stdlib/llm/prompts/completion_fallback_system.harn.prompt"),
780    },
781    StdlibPromptAsset {
782        path: "llm/prompts/completion_fallback_user.harn.prompt",
783        source: include_str!("stdlib/llm/prompts/completion_fallback_user.harn.prompt"),
784    },
785    StdlibPromptAsset {
786        path: "llm/prompts/transcript_summarize_user.harn.prompt",
787        source: include_str!("stdlib/llm/prompts/transcript_summarize_user.harn.prompt"),
788    },
789    StdlibPromptAsset {
790        path: "llm/prompts/sitrep_user.harn.prompt",
791        source: include_str!("stdlib/llm/prompts/sitrep_user.harn.prompt"),
792    },
793    StdlibPromptAsset {
794        path: "llm/prompts/structural_chain_of_draft.harn.prompt",
795        source: include_str!("stdlib/llm/prompts/structural_chain_of_draft.harn.prompt"),
796    },
797    StdlibPromptAsset {
798        path: "llm/prompts/schema_recover_repair.harn.prompt",
799        source: include_str!("stdlib/llm/prompts/schema_recover_repair.harn.prompt"),
800    },
801    StdlibPromptAsset {
802        path: "llm/prompts/structured_envelope_schema_contract.harn.prompt",
803        source: include_str!("stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt"),
804    },
805    StdlibPromptAsset {
806        path: "llm/prompts/structured_envelope_repair.harn.prompt",
807        source: include_str!("stdlib/llm/prompts/structured_envelope_repair.harn.prompt"),
808    },
809    StdlibPromptAsset {
810        path: "llm/prompts/pairwise_rerank_user.harn.prompt",
811        source: include_str!("stdlib/llm/prompts/pairwise_rerank_user.harn.prompt"),
812    },
813    StdlibPromptAsset {
814        path: "llm/prompts/tool_binder_user.harn.prompt",
815        source: include_str!("stdlib/llm/prompts/tool_binder_user.harn.prompt"),
816    },
817    StdlibPromptAsset {
818        path: "workflow/prompts/stage.harn.prompt",
819        source: include_str!("stdlib/workflow/prompts/stage.harn.prompt"),
820    },
821    StdlibPromptAsset {
822        path: "workflow/prompts/verification_context_intro.harn.prompt",
823        source: include_str!("stdlib/workflow/prompts/verification_context_intro.harn.prompt"),
824    },
825    StdlibPromptAsset {
826        path: "orchestration/prompts/compaction_summary.harn.prompt",
827        source: include_str!("stdlib/orchestration/prompts/compaction_summary.harn.prompt"),
828    },
829    StdlibPromptAsset {
830        path: "orchestration/prompts/compaction_policy_replacement.harn.prompt",
831        source: include_str!(
832            "stdlib/orchestration/prompts/compaction_policy_replacement.harn.prompt"
833        ),
834    },
835];
836
837/// Embedded `.harn` script that backs a CLI subcommand. Looked up by
838/// the `harn-cli` dispatch wedge (see harn#2293 epic and harn#2294 G1)
839/// so subcommands can ship in Harn instead of Rust.
840#[derive(Debug, Clone, Copy, PartialEq, Eq)]
841pub struct StdlibCliScript {
842    /// Lookup name. For nested scripts this is the path under
843    /// `stdlib/cli/` without the `.harn` extension (e.g. `"eval/prompt"`
844    /// for `stdlib/cli/eval/prompt.harn`).
845    pub name: &'static str,
846    /// Embedded source. Run via the existing `harn run` codepath by the
847    /// dispatch wedge.
848    pub source: &'static str,
849}
850
851pub const STDLIB_CLI_SCRIPTS: &[StdlibCliScript] = &[
852    StdlibCliScript {
853        name: "doctor",
854        source: include_str!("stdlib/cli/doctor.harn"),
855    },
856    StdlibCliScript {
857        name: "echo",
858        source: include_str!("stdlib/cli/echo.harn"),
859    },
860    // Helper module for the embedded `eval/*` scripts. Has a stub `main`
861    // that exits non-zero — sibling scripts inline its helpers until the
862    // dispatch wedge gains a cross-script import surface (#2300 / G7).
863    StdlibCliScript {
864        name: "eval/_runner",
865        source: include_str!("stdlib/cli/eval/_runner.harn"),
866    },
867    StdlibCliScript {
868        name: "eval/context",
869        source: include_str!("stdlib/cli/eval/context.harn"),
870    },
871    StdlibCliScript {
872        name: "eval/model_selector",
873        source: include_str!("stdlib/cli/eval/model_selector.harn"),
874    },
875    StdlibCliScript {
876        name: "eval/tool_calls",
877        source: include_str!("stdlib/cli/eval/tool_calls.harn"),
878    },
879    StdlibCliScript {
880        name: "eval/coding_agent",
881        source: include_str!("stdlib/cli/eval/coding_agent.harn"),
882    },
883    StdlibCliScript {
884        name: "eval/scope_triage",
885        source: include_str!("stdlib/cli/eval/scope_triage.harn"),
886    },
887    StdlibCliScript {
888        name: "eval/prompt",
889        source: include_str!("stdlib/cli/eval/prompt.harn"),
890    },
891    StdlibCliScript {
892        name: "explain",
893        source: include_str!("stdlib/cli/explain.harn"),
894    },
895    StdlibCliScript {
896        name: "graph",
897        source: include_str!("stdlib/cli/graph.harn"),
898    },
899    StdlibCliScript {
900        name: "models/list",
901        source: include_str!("stdlib/cli/models/list.harn"),
902    },
903    StdlibCliScript {
904        name: "models/recommend",
905        source: include_str!("stdlib/cli/models/recommend.harn"),
906    },
907    StdlibCliScript {
908        name: "models/test",
909        source: include_str!("stdlib/cli/models/test.harn"),
910    },
911    StdlibCliScript {
912        name: "precompile",
913        source: include_str!("stdlib/cli/precompile.harn"),
914    },
915    StdlibCliScript {
916        name: "providers/catalog",
917        source: include_str!("stdlib/cli/providers/catalog.harn"),
918    },
919    StdlibCliScript {
920        name: "providers/probe",
921        source: include_str!("stdlib/cli/providers/probe.harn"),
922    },
923    StdlibCliScript {
924        name: "providers/recommend",
925        source: include_str!("stdlib/cli/providers/recommend.harn"),
926    },
927    StdlibCliScript {
928        name: "providers/tool_probe",
929        source: include_str!("stdlib/cli/providers/tool_probe.harn"),
930    },
931    StdlibCliScript {
932        name: "routes",
933        source: include_str!("stdlib/cli/routes.harn"),
934    },
935    StdlibCliScript {
936        name: "scaffold/init",
937        source: include_str!("stdlib/cli/scaffold/init.harn"),
938    },
939    StdlibCliScript {
940        name: "scaffold/tool_new",
941        source: include_str!("stdlib/cli/scaffold/tool_new.harn"),
942    },
943    StdlibCliScript {
944        name: "trace_import",
945        source: include_str!("stdlib/cli/trace_import.harn"),
946    },
947    StdlibCliScript {
948        name: "try",
949        source: include_str!("stdlib/cli/try.harn"),
950    },
951    StdlibCliScript {
952        name: "version",
953        source: include_str!("stdlib/cli/version.harn"),
954    },
955];
956
957pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
958    STDLIB_SOURCES
959        .iter()
960        .find_map(|entry| (entry.module == module).then_some(entry.source))
961}
962
963/// Find an embedded CLI subcommand script by name. Returns the embedded
964/// source string when present, or `None` if no script with that name is
965/// registered in [`STDLIB_CLI_SCRIPTS`].
966pub fn find_cli_script(name: &str) -> Option<&'static str> {
967    STDLIB_CLI_SCRIPTS
968        .iter()
969        .find_map(|entry| (entry.name == name).then_some(entry.source))
970}
971
972pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
973    let path = path.strip_prefix("std/").unwrap_or(path);
974    STDLIB_PROMPT_ASSETS
975        .iter()
976        .find_map(|entry| (entry.path == path).then_some(entry.source))
977}
978
979pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
980    let Some(source) = get_stdlib_source(module) else {
981        return Vec::new();
982    };
983    public_functions_from_source(source)
984}
985
986pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
987    STDLIB_SOURCES
988        .iter()
989        .filter_map(|entry| {
990            entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
991                import_path: format!("std/{}", entry.module),
992                category,
993            })
994        })
995        .collect()
996}
997
998fn entrypoint_category_from_source(source: &str) -> Option<String> {
999    for line in source.lines() {
1000        let line = line.trim();
1001        if line.is_empty() {
1002            continue;
1003        }
1004        if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
1005            let category = category.trim();
1006            return (!category.is_empty()).then(|| category.to_string());
1007        }
1008        if !line.starts_with("//") {
1009            return None;
1010        }
1011    }
1012    None
1013}
1014
1015fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
1016    let mut out = Vec::new();
1017    let mut doc: Option<String> = None;
1018    let lines = source.lines().collect::<Vec<_>>();
1019    let mut index = 0usize;
1020    while index < lines.len() {
1021        let line = lines[index].trim();
1022        if line.starts_with("/**") {
1023            let (parsed, next) = parse_harndoc(&lines, index);
1024            doc = parsed;
1025            index = next;
1026            continue;
1027        }
1028        if line.starts_with("pub fn ") {
1029            let (signature_line, next) = collect_public_function_signature(&lines, index);
1030            if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
1031                out.push(function);
1032                index = next;
1033                continue;
1034            }
1035        }
1036        if let Some(function) = parse_public_function_line(line, doc.take()) {
1037            out.push(function);
1038        } else if !line.is_empty() && !line.starts_with("//") {
1039            doc = None;
1040        }
1041        index += 1;
1042    }
1043    out
1044}
1045
1046fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
1047    let mut parts = Vec::new();
1048    let mut index = start;
1049    while index < lines.len() {
1050        parts.push(lines[index].trim().to_string());
1051        let candidate = parts.join(" ");
1052        if public_function_signature_complete(&candidate) {
1053            return (candidate, index + 1);
1054        }
1055        index += 1;
1056    }
1057    (parts.join(" "), index)
1058}
1059
1060fn public_function_signature_complete(line: &str) -> bool {
1061    let Some(rest) = line.strip_prefix("pub fn ") else {
1062        return false;
1063    };
1064    let Some(name_end) = rest.find('(') else {
1065        return false;
1066    };
1067    matching_paren_len(&rest[name_end + 1..]).is_some()
1068}
1069
1070fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
1071    let mut parts = Vec::new();
1072    let mut index = start;
1073    while index < lines.len() {
1074        let mut line = lines[index].trim();
1075        if index == start {
1076            line = line.trim_start_matches("/**").trim();
1077        }
1078        let done = line.ends_with("*/");
1079        line = line.trim_end_matches("*/").trim();
1080        line = line.trim_start_matches('*').trim();
1081        if !line.is_empty() {
1082            parts.push(line.to_string());
1083        }
1084        index += 1;
1085        if done {
1086            break;
1087        }
1088    }
1089    let text = parts.join("\n").trim().to_string();
1090    ((!text.is_empty()).then_some(text), index)
1091}
1092
1093fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
1094    let rest = line.strip_prefix("pub fn ")?.trim();
1095    let name_end = rest.find('(')?;
1096    let name = rest[..name_end].trim();
1097    if name.is_empty() {
1098        return None;
1099    }
1100    let params_start = name_end + 1;
1101    let params_len = matching_paren_len(&rest[params_start..])?;
1102    let params = &rest[params_start..params_start + params_len];
1103    let after = rest[params_start + params_len + 1..].trim();
1104    let return_type = after
1105        .strip_prefix("->")
1106        .and_then(|tail| tail.split('{').next())
1107        .map(str::trim)
1108        .filter(|value| !value.is_empty());
1109    let signature = match return_type {
1110        Some(ret) => format!("{name}({params}) -> {ret}"),
1111        None => format!("{name}({params})"),
1112    };
1113    let param_parts = split_top_level_params(params);
1114    let total_params = param_parts
1115        .iter()
1116        .filter(|param| !param.trim().is_empty())
1117        .count();
1118    let variadic = param_parts
1119        .iter()
1120        .any(|param| param.trim_start().starts_with("..."));
1121    let required_params = param_parts
1122        .iter()
1123        .filter(|param| {
1124            let param = param.trim();
1125            !param.is_empty() && !param.contains('=') && !param.starts_with("...")
1126        })
1127        .count();
1128    Some(StdlibPublicFunction {
1129        name: name.to_string(),
1130        signature,
1131        required_params,
1132        total_params,
1133        variadic,
1134        doc,
1135    })
1136}
1137
1138fn matching_paren_len(input: &str) -> Option<usize> {
1139    let mut depth = 1usize;
1140    for (offset, ch) in input.char_indices() {
1141        match ch {
1142            '(' | '[' | '{' => depth += 1,
1143            ')' => {
1144                depth = depth.saturating_sub(1);
1145                if depth == 0 {
1146                    return Some(offset);
1147                }
1148            }
1149            ']' | '}' => depth = depth.saturating_sub(1),
1150            _ => {}
1151        }
1152    }
1153    None
1154}
1155
1156fn split_top_level_params(params: &str) -> Vec<&str> {
1157    let mut out = Vec::new();
1158    let mut depth = 0isize;
1159    let mut start = 0usize;
1160    for (offset, ch) in params.char_indices() {
1161        match ch {
1162            '(' | '[' | '{' => depth += 1,
1163            ')' | ']' | '}' => depth -= 1,
1164            ',' if depth == 0 => {
1165                out.push(&params[start..offset]);
1166                start = offset + 1;
1167            }
1168            _ => {}
1169        }
1170    }
1171    out.push(&params[start..]);
1172    out
1173}
1174
1175#[cfg(test)]
1176mod tests {
1177    use std::collections::BTreeSet;
1178
1179    use super::{
1180        entrypoint_modules, find_cli_script, get_stdlib_prompt_asset, get_stdlib_source,
1181        public_functions_for_module, STDLIB_CLI_SCRIPTS, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
1182    };
1183
1184    #[test]
1185    fn stdlib_sources_are_non_empty() {
1186        for entry in STDLIB_SOURCES {
1187            assert!(
1188                !entry.source.trim().is_empty(),
1189                "{} should have non-empty source",
1190                entry.module
1191            );
1192        }
1193    }
1194
1195    #[test]
1196    fn cli_scripts_are_non_empty_and_uniquely_named() {
1197        let mut seen = BTreeSet::new();
1198        for entry in STDLIB_CLI_SCRIPTS {
1199            assert!(
1200                !entry.source.trim().is_empty(),
1201                "cli/{} should have non-empty source",
1202                entry.name
1203            );
1204            assert!(
1205                seen.insert(entry.name),
1206                "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
1207                entry.name
1208            );
1209        }
1210    }
1211
1212    #[test]
1213    fn find_cli_script_round_trips() {
1214        for entry in STDLIB_CLI_SCRIPTS {
1215            assert_eq!(find_cli_script(entry.name), Some(entry.source));
1216        }
1217        assert!(find_cli_script("not-a-real-script").is_none());
1218    }
1219
1220    #[test]
1221    fn stdlib_source_names_are_unique() {
1222        let mut names = BTreeSet::new();
1223        for entry in STDLIB_SOURCES {
1224            assert!(names.insert(entry.module), "duplicate {}", entry.module);
1225        }
1226    }
1227
1228    #[test]
1229    fn stdlib_prompt_assets_are_non_empty() {
1230        for entry in STDLIB_PROMPT_ASSETS {
1231            assert!(
1232                !entry.source.trim().is_empty(),
1233                "{} should have non-empty prompt asset source",
1234                entry.path
1235            );
1236        }
1237    }
1238
1239    #[test]
1240    fn stdlib_prompt_asset_paths_are_unique() {
1241        let mut paths = BTreeSet::new();
1242        for entry in STDLIB_PROMPT_ASSETS {
1243            assert!(paths.insert(entry.path), "duplicate {}", entry.path);
1244        }
1245    }
1246
1247    #[test]
1248    fn key_stdlib_modules_resolve() {
1249        for module in [
1250            "context",
1251            "context/maintenance",
1252            "context/eval",
1253            "edit",
1254            "artifact/web",
1255            "command",
1256            "waitpoint",
1257            "llm/handlers",
1258            "llm/tool_middleware",
1259            "llm/tool_binder",
1260            "llm/ensemble",
1261            "llm/rerank",
1262            "personas/prelude",
1263            "personas/bulletins",
1264            "agent/host_tools",
1265            "agent/user",
1266            "llm/optimize",
1267            "llm/judge",
1268            "llm/refine",
1269            "connectors/shared",
1270            "connectors/github",
1271            "connectors/linear",
1272            "connectors/notion",
1273            "connectors/slack",
1274            "triage",
1275            "dashboard/jobs",
1276            "ui_resource",
1277        ] {
1278            assert!(
1279                get_stdlib_source(module).is_some(),
1280                "std/{module} should resolve"
1281            );
1282        }
1283    }
1284
1285    #[test]
1286    fn key_stdlib_prompt_assets_resolve() {
1287        for path in [
1288            "std/agent/prompts/tool_contract_text.harn.prompt",
1289            "std/agent/prompts/action_turn_nudge.harn.prompt",
1290            "std/agent/prompts/completion_judge_default.harn.prompt",
1291            "std/workflow/prompts/stage.harn.prompt",
1292            "std/orchestration/prompts/compaction_summary.harn.prompt",
1293            "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
1294        ] {
1295            assert!(
1296                get_stdlib_prompt_asset(path).is_some(),
1297                "{path} should resolve"
1298            );
1299        }
1300    }
1301
1302    #[test]
1303    fn public_function_catalog_derives_signatures_from_harn_source() {
1304        let exports = public_functions_for_module("workflow/execute");
1305        assert_eq!(exports.len(), 1);
1306        assert_eq!(exports[0].name, "workflow_execute");
1307        assert_eq!(
1308            exports[0].signature,
1309            "workflow_execute(task, graph, artifacts = nil, options = nil)"
1310        );
1311        assert_eq!(exports[0].required_params, 2);
1312        assert_eq!(exports[0].total_params, 4);
1313    }
1314
1315    #[test]
1316    fn command_stdlib_module_exports_step_helpers() {
1317        let exports = public_functions_for_module("command")
1318            .into_iter()
1319            .map(|function| function.name)
1320            .collect::<BTreeSet<_>>();
1321        for name in [
1322            "command_run",
1323            "command_output_tail",
1324            "command_json",
1325            "command_json_step",
1326            "command_try",
1327            "command_step",
1328            "command_steps_append",
1329            "command_last_failed_step",
1330            "command_step_ref",
1331        ] {
1332            assert!(exports.contains(name), "std/command should export {name}");
1333        }
1334    }
1335
1336    #[test]
1337    fn async_stdlib_exports_predicate_backoff_name_only() {
1338        let exports = public_functions_for_module("async")
1339            .into_iter()
1340            .map(|function| function.name)
1341            .collect::<BTreeSet<_>>();
1342        assert!(
1343            exports.contains("retry_predicate_with_backoff"),
1344            "std/async should export retry_predicate_with_backoff"
1345        );
1346        assert!(
1347            !exports.contains("retry_with_backoff"),
1348            "std/async should not retain the old retry_with_backoff export"
1349        );
1350    }
1351
1352    #[test]
1353    fn signal_stdlib_module_exports_interrupt_helpers() {
1354        let exports = public_functions_for_module("signal")
1355            .into_iter()
1356            .map(|function| function.name)
1357            .collect::<BTreeSet<_>>();
1358        for name in [
1359            "on_interrupt",
1360            "off_interrupt",
1361            "interrupted",
1362            "with_interrupt",
1363        ] {
1364            assert!(exports.contains(name), "std/signal should export {name}");
1365        }
1366    }
1367
1368    #[test]
1369    fn git_stdlib_module_exports_local_wrappers() {
1370        let exports = public_functions_for_module("git")
1371            .into_iter()
1372            .map(|function| function.name)
1373            .collect::<BTreeSet<_>>();
1374        for name in [
1375            "git_run",
1376            "git_status",
1377            "git_current_branch",
1378            "git_log",
1379            "git_switch",
1380            "git_pull_ff_only",
1381            "git_find_tool",
1382            "git_run_tool",
1383            "git_tools",
1384            "git_toolbox_tools",
1385        ] {
1386            assert!(exports.contains(name), "std/git should export {name}");
1387        }
1388    }
1389
1390    #[test]
1391    fn agent_workers_exports_suspend_resume_wrappers() {
1392        let exports = public_functions_for_module("agent/workers");
1393        let suspend = exports
1394            .iter()
1395            .find(|function| function.name == "suspend_agent")
1396            .expect("std/agent/workers should export suspend_agent");
1397        assert_eq!(
1398            suspend.signature,
1399            "suspend_agent(worker, reason = \"\", options = nil)"
1400        );
1401        assert_eq!(suspend.required_params, 1);
1402        assert_eq!(suspend.total_params, 3);
1403
1404        let resume = exports
1405            .iter()
1406            .find(|function| function.name == "resume_agent")
1407            .expect("std/agent/workers should export resume_agent");
1408        assert_eq!(
1409            resume.signature,
1410            "resume_agent(worker_or_snapshot, resume_input = nil, continue_transcript = true)"
1411        );
1412        assert_eq!(resume.required_params, 1);
1413        assert_eq!(resume.total_params, 3);
1414
1415        let parse_resume = exports
1416            .iter()
1417            .find(|function| function.name == "parse_resume_conditions")
1418            .expect("std/agent/workers should export parse_resume_conditions");
1419        assert_eq!(
1420            parse_resume.signature,
1421            "parse_resume_conditions(conditions = nil) -> ResumeConditions?"
1422        );
1423        assert_eq!(parse_resume.required_params, 0);
1424        assert_eq!(parse_resume.total_params, 1);
1425
1426        let lifecycle = exports
1427            .iter()
1428            .find(|function| function.name == "agent_lifecycle_tools")
1429            .expect("std/agent/workers should export agent_lifecycle_tools");
1430        assert_eq!(
1431            lifecycle.signature,
1432            "agent_lifecycle_tools(registry = nil, options = nil)"
1433        );
1434        assert_eq!(lifecycle.required_params, 0);
1435        assert_eq!(lifecycle.total_params, 2);
1436    }
1437
1438    #[test]
1439    fn tui_stdlib_module_exports_terminal_helpers() {
1440        let exports = public_functions_for_module("tui")
1441            .into_iter()
1442            .map(|function| function.name)
1443            .collect::<BTreeSet<_>>();
1444        for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1445            assert!(exports.contains(name), "std/tui should export {name}");
1446        }
1447    }
1448
1449    #[test]
1450    fn semver_stdlib_module_exports_release_helpers() {
1451        let exports = public_functions_for_module("semver")
1452            .into_iter()
1453            .map(|function| function.name)
1454            .collect::<BTreeSet<_>>();
1455        for name in [
1456            "strip_v",
1457            "add_v",
1458            "is_v_semver",
1459            "parse",
1460            "next",
1461            "bump_type",
1462            "version_from_release_branch",
1463            "version_from_tag",
1464        ] {
1465            assert!(exports.contains(name), "std/semver should export {name}");
1466        }
1467    }
1468
1469    #[test]
1470    fn text_stdlib_module_exports_regex_and_pad_helpers() {
1471        let exports = public_functions_for_module("text")
1472            .into_iter()
1473            .map(|function| function.name)
1474            .collect::<BTreeSet<_>>();
1475        for name in [
1476            "pad_left",
1477            "pad_right",
1478            "repeat_string",
1479            "regex_first_capture",
1480            "regex_capture_groups",
1481            "regex_all_first_captures",
1482        ] {
1483            assert!(exports.contains(name), "std/text should export {name}");
1484        }
1485    }
1486
1487    #[test]
1488    fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1489        let modules = entrypoint_modules();
1490        let entries = modules
1491            .iter()
1492            .map(|module| (module.import_path.as_str(), module.category.as_str()))
1493            .collect::<BTreeSet<_>>();
1494        for entry in [
1495            ("std/agent/loop", "agent.stdlib"),
1496            ("std/agent/turn", "agent.stdlib"),
1497            ("std/agent/primitives", "agent.stdlib"),
1498            ("std/workflow/execute", "workflow.stdlib"),
1499        ] {
1500            assert!(entries.contains(&entry), "{entry:?} should be declared");
1501        }
1502    }
1503}