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