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