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