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