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