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