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