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