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