Skip to main content

harn_stdlib/
lib.rs

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