1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub struct StdlibSource {
12 pub module: &'static str,
13 pub source: &'static str,
14}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub struct StdlibPromptAsset {
18 pub path: &'static str,
19 pub source: &'static str,
20}
21
22macro_rules! embedded_catalog {
23 ($entry:ident, $key:ident, [$($name:literal => $path:literal),* $(,)?]) => {
24 &[
25 $($entry {
26 $key: $name,
27 source: include_str!($path),
28 },)*
29 ]
30 };
31}
32
33#[derive(Debug, Clone, PartialEq, Eq)]
34pub struct StdlibPublicFunction {
35 pub name: String,
36 pub signature: String,
37 pub required_params: usize,
38 pub total_params: usize,
39 pub variadic: bool,
40 pub doc: Option<String>,
41}
42
43#[derive(Debug, Clone, PartialEq, Eq)]
44pub struct StdlibEntrypointModule {
45 pub import_path: String,
46 pub category: String,
47}
48
49pub const STDLIB_SOURCES: &[StdlibSource] = embedded_catalog!(StdlibSource, module, [
50 "text" => "stdlib/stdlib_text.harn",
51 "semver" => "stdlib/stdlib_semver.harn",
52 "changelog" => "stdlib/stdlib_changelog.harn",
53 "ansi" => "stdlib/stdlib_ansi.harn",
54 "table" => "stdlib/stdlib_table.harn",
55 "diff" => "stdlib/stdlib_diff.harn",
56 "edit" => "stdlib/stdlib_edit.harn",
57 "edit/capabilities" => "stdlib/edit/capabilities.harn",
58 "edit/internal" => "stdlib/edit/internal.harn",
59 "edit/patch" => "stdlib/edit/patch.harn",
60 "edit/refactor_runtime" => "stdlib/edit/refactor_runtime.harn",
61 "edit/safe_patch" => "stdlib/edit/safe_patch.harn",
62 "edit/fast_apply" => "stdlib/edit/fast_apply.harn",
63 "ast" => "stdlib/stdlib_ast.harn",
64 "dev/agent_gates" => "stdlib/dev/agent_gates.harn",
65 "dev/agent_gate_bindings" => "stdlib/dev/agent_gate_bindings.harn",
66 "rules" => "stdlib/stdlib_rules.harn",
67 "lint" => "stdlib/stdlib_lint.harn",
68 "artifact/web" => "stdlib/artifact/web.harn",
69 "collections" => "stdlib/stdlib_collections.harn",
70 "math" => "stdlib/stdlib_math.harn",
71 "slug" => "stdlib/stdlib_slug.harn",
72 "path" => "stdlib/stdlib_path.harn",
73 "fs" => "stdlib/stdlib_fs.harn",
74 "run_artifacts" => "stdlib/stdlib_run_artifacts.harn",
75 "artifacts/typed" => "stdlib/artifacts/typed.harn",
76 "os" => "stdlib/stdlib_os.harn",
77 "json" => "stdlib/stdlib_json.harn",
78 "json/stream" => "stdlib/stdlib_json_stream.harn",
79 "xml" => "stdlib/stdlib_xml.harn",
80 "cache" => "stdlib/stdlib_cache.harn",
81 "predicate" => "stdlib/stdlib_predicate.harn",
82 "observability" => "stdlib/stdlib_observability.harn",
83 "timing" => "stdlib/stdlib_timing.harn",
84 "verification" => "stdlib/stdlib_verification.harn",
85 "tools" => "stdlib/stdlib_tools.harn",
86 "composition" => "stdlib/stdlib_composition.harn",
87 "web" => "stdlib/stdlib_web.harn",
88 "graphql" => "stdlib/stdlib_graphql.harn",
89 "code_librarian" => "stdlib/stdlib_code_librarian.harn",
90 "schema" => "stdlib/stdlib_schema.harn",
91 "schema/contracts" => "stdlib/schema/contracts.harn",
92 "identity" => "stdlib/stdlib_identity.harn",
93 "disclosure" => "stdlib/stdlib_disclosure.harn",
94 "testing" => "stdlib/stdlib_testing.harn",
95 "files" => "stdlib/stdlib_files.harn",
96 "document" => "stdlib/stdlib_document.harn",
97 "vision" => "stdlib/stdlib_vision.harn",
98 "context" => "stdlib/stdlib_context.harn",
99 "context/artifact_types" => "stdlib/context/artifact_types.harn",
100 "context/maintenance" => "stdlib/context/maintenance.harn",
101 "context/eval" => "stdlib/context/eval.harn",
102 "context/disclosure" => "stdlib/context/disclosure.harn",
103 "eval/stats" => "stdlib/stdlib_eval_stats.harn",
104 "eval/remote_fanout" => "stdlib/eval/remote_fanout.harn",
105 "eval/sequential" => "stdlib/eval/sequential.harn",
106 "eval/calibration" => "stdlib/eval/calibration.harn",
107 "eval/selective_risk" => "stdlib/eval/selective_risk.harn",
108 "eval/experiment" => "stdlib/eval/experiment.harn",
109 "eval/experiment/contracts" => "stdlib/eval/experiment/contracts.harn",
110 "eval/experiment/assignment" => "stdlib/eval/experiment/assignment.harn",
111 "eval/experiment/decision" => "stdlib/eval/experiment/decision.harn",
112 "eval/hypothesis" => "stdlib/eval/hypothesis.harn",
113 "eval/hypothesis/capabilities" => "stdlib/eval/hypothesis/capabilities.harn",
114 "eval/hypothesis/contracts" => "stdlib/eval/hypothesis/contracts.harn",
115 "eval/hypothesis/compiler" => "stdlib/eval/hypothesis/compiler.harn",
116 "eval/hypothesis/intent_boundary" => "stdlib/eval/hypothesis/intent_boundary.harn",
117 "eval/hypothesis/ledger_contracts" => "stdlib/eval/hypothesis/ledger_contracts.harn",
118 "eval/hypothesis/ledger" => "stdlib/eval/hypothesis/ledger.harn",
119 "eval/hypothesis/planner" => "stdlib/eval/hypothesis/planner.harn",
120 "eval/hypothesis/report" => "stdlib/eval/hypothesis/report.harn",
121 "eval/hypothesis/policies" => "stdlib/eval/hypothesis/policies.harn",
122 "eval/hypothesis/workflow_contracts" => "stdlib/eval/hypothesis/workflow_contracts.harn",
123 "eval/hypothesis/workflow" => "stdlib/eval/hypothesis/workflow.harn",
124 "eval/agreement" => "stdlib/stdlib_eval_agreement.harn",
125 "runtime" => "stdlib/stdlib_runtime.harn",
126 "runtime/content_fingerprint" => "stdlib/runtime/content_fingerprint.harn",
127 "runtime/install" => "stdlib/runtime/install.harn",
128 "runtime/bootstrap" => "stdlib/runtime/bootstrap.harn",
129 "io" => "stdlib/stdlib_io.harn",
130 "net" => "stdlib/stdlib_net.harn",
131 "command" => "stdlib/stdlib_command.harn",
132 "command/foundation" => "stdlib/command/foundation.harn",
133 "command/output" => "stdlib/command/output.harn",
134 "command/results" => "stdlib/command/results.harn",
135 "command/shell" => "stdlib/command/shell.harn",
136 "command/step_ref" => "stdlib/command/step_ref.harn",
137 "runner_pool" => "stdlib/stdlib_runner_pool.harn",
138 "verification_types" => "stdlib/verification_types.harn",
139 "verification_core" => "stdlib/verification_core.harn",
140 "verification_targets" => "stdlib/verification_targets.harn",
141 "verification_ladder" => "stdlib/verification_ladder.harn",
142 "verification_public" => "stdlib/verification_public.harn",
143 "signal" => "stdlib/stdlib_signal.harn",
144 "net_policy" => "stdlib/stdlib_net_policy.harn",
145 "review" => "stdlib/stdlib_review.harn",
146 "experiments" => "stdlib/stdlib_experiments.harn",
147 "project" => "stdlib/stdlib_project.harn",
148 "prompt_library" => "stdlib/stdlib_prompt_library.harn",
149 "async" => "stdlib/stdlib_async.harn",
150 "poll" => "stdlib/stdlib_poll.harn",
151 "coerce" => "stdlib/stdlib_coerce.harn",
152 "settled" => "stdlib/stdlib_settled.harn",
153 "abort" => "stdlib/stdlib_abort.harn",
154 "cli" => "stdlib/stdlib_cli.harn",
155 "cli/argparse" => "stdlib/cli/argparse.harn",
156 "cli/envelope" => "stdlib/cli/envelope.harn",
157 "cli/render" => "stdlib/cli/render.harn",
158 "cli/models/batch_artifacts" => "stdlib/cli/models/batch_artifacts.harn",
159 "cli/models/batch_cancel" => "stdlib/cli/models/batch_cancel.harn",
160 "cli/models/batch_download" => "stdlib/cli/models/batch_download.harn",
161 "cli/models/batch_lifecycle" => "stdlib/cli/models/batch_lifecycle.harn",
162 "cli/models/batch_rejoin" => "stdlib/cli/models/batch_rejoin.harn",
163 "cli/models/batch_status" => "stdlib/cli/models/batch_status.harn",
164 "cli/models/batch_submit" => "stdlib/cli/models/batch_submit.harn",
165 "cli/models/batch_transport" => "stdlib/cli/models/batch_transport.harn",
166 "cli/models/lora_render" => "stdlib/cli/models/lora_render.harn",
167 "cli/paths" => "stdlib/cli/paths.harn",
168 "cli/providers/contracts" => "stdlib/cli/providers/contracts.harn",
169 "gha" => "stdlib/stdlib_gha.harn",
170 "tui" => "stdlib/stdlib_tui.harn",
171 "jsonl" => "stdlib/stdlib_jsonl.harn",
172 "config" => "stdlib/stdlib_config.harn",
173 "calendar" => "stdlib/stdlib_calendar.harn",
174 "external_action" => "stdlib/stdlib_external_action.harn",
175 "external_action/vocabulary" => "stdlib/external_action/vocabulary.harn",
176 "external_action/contracts" => "stdlib/external_action/contracts.harn",
177 "external_action/disclosure" => "stdlib/external_action/disclosure.harn",
178 "external_action/activity" => "stdlib/external_action/activity.harn",
179 "external_action/policy" => "stdlib/external_action/policy.harn",
180 "external_action/runtime" => "stdlib/external_action/runtime.harn",
181 "external_action/testing" => "stdlib/external_action/testing.harn",
182 "agents" => "stdlib/stdlib_agents.harn",
183 "lifecycle/pool" => "stdlib/lifecycle/pool.harn",
184 "lifecycle/combinators" => "stdlib/lifecycle/combinators.harn",
185 "lifecycle/on_budget" => "stdlib/lifecycle/on_budget.harn",
186 "lifecycle/progress" => "stdlib/lifecycle/progress.harn",
187 "agent/prompts" => "stdlib/agent/prompts.harn",
188 "llm/media" => "stdlib/llm/media.harn",
189 "media/asset" => "stdlib/media/asset.harn",
190 "media/composition" => "stdlib/media/composition.harn",
191 "model_job" => "stdlib/stdlib_model_job.harn",
192 "model_job/contracts" => "stdlib/model_job/contracts.harn",
193 "model_job/runtime" => "stdlib/model_job/runtime.harn",
194 "model_job/testing" => "stdlib/model_job/testing.harn",
195 "model_job/comfyui" => "stdlib/model_job/comfyui.harn",
196 "model_job/openai" => "stdlib/model_job/openai.harn",
197 "portable" => "stdlib/stdlib_portable.harn",
198 "ui" => "stdlib/stdlib_ui.harn",
199 "ui/contracts" => "stdlib/ui/contracts.harn",
200 "ui/renderer" => "stdlib/ui/renderer.harn",
201 "ui/testing" => "stdlib/ui/testing.harn",
202 "llm/options" => "stdlib/llm/options.harn",
203 "llm/provider_names" => "stdlib/llm/provider_names.harn",
204 "llm/catalog" => "stdlib/llm/catalog.harn",
205 "llm/cache_conformance" => "stdlib/llm/cache_conformance.harn",
206 "llm/safe" => "stdlib/llm/safe.harn",
207 "llm/envelope" => "stdlib/llm/envelope.harn",
208 "llm/speed" => "stdlib/llm/speed.harn",
209 "llm/chat_session" => "stdlib/llm/chat_session.harn",
210 "llm/caller" => "stdlib/llm/caller.harn",
211 "harness/policy" => "stdlib/harness/policy.harn",
212 "llm/budget" => "stdlib/llm/budget.harn",
213 "llm/tokenizer" => "stdlib/llm/tokenizer.harn",
214 "llm/economics" => "stdlib/llm/economics.harn",
215 "llm/prompts" => "stdlib/llm/prompts.harn",
216 "llm/defaults" => "stdlib/llm/defaults.harn",
217 "llm/handlers" => "stdlib/llm/handlers.harn",
218 "llm/handler_cache_events" => "stdlib/llm/handler_cache_events.harn",
219 "llm/resilience" => "stdlib/llm/resilience.harn",
220 "llm/tool_telemetry" => "stdlib/llm/tool_telemetry.harn",
221 "llm/tool_middleware" => "stdlib/llm/tool_middleware.harn",
222 "llm/tool_binder" => "stdlib/llm/tool_binder.harn",
223 "llm/structural_validator" => "stdlib/llm/structural_validator.harn",
224 "llm/missing_tool_call" => "stdlib/llm/missing_tool_call.harn",
225 "llm/call_shape" => "stdlib/llm/call_shape.harn",
226 "llm/tool_shape" => "stdlib/llm/tool_shape.harn",
227 "llm/dialects" => "stdlib/llm/dialects.harn",
228 "llm/tool_parse" => "stdlib/llm/tool_parse.harn",
229 "llm/tool_parse_body" => "stdlib/llm/tool_parse_body.harn",
230 "llm/tool_parse_envelope" => "stdlib/llm/tool_parse_envelope.harn",
231 "llm/tool_parse_json_support" => "stdlib/llm/tool_parse_json_support.harn",
232 "llm/tool_parse_protocol" => "stdlib/llm/tool_parse_protocol.harn",
233 "llm/tool_parse_provider" => "stdlib/llm/tool_parse_provider.harn",
234 "llm/tool_parse_result" => "stdlib/llm/tool_parse_result.harn",
235 "llm/tool_parse_scan_spec" => "stdlib/llm/tool_parse_scan_spec.harn",
236 "llm/scope_classifier" => "stdlib/llm/scope_classifier.harn",
237 "llm/refine" => "stdlib/llm/refine.harn",
238 "llm/ensemble" => "stdlib/llm/ensemble.harn",
239 "llm/rerank" => "stdlib/llm/rerank.harn",
240 "agent/reasoning" => "stdlib/agent/reasoning.harn",
241 "agent/caller_transport" => "stdlib/agent/caller_transport.harn",
242 "agent/options" => "stdlib/agent/options.harn",
243 "agent/options_types" => "stdlib/agent/options_types.harn",
244 "agent/options_formats" => "stdlib/agent/options_formats.harn",
245 "agent/options_surface" => "stdlib/agent/options_surface.harn",
246 "agent/options_validation" => "stdlib/agent/options_validation.harn",
247 "agent/options_public" => "stdlib/agent/options_public.harn",
248 "agent/llm_dispatch" => "stdlib/agent/llm_dispatch.harn",
249 "agent/prefill" => "stdlib/agent/prefill.harn",
250 "agent/retry" => "stdlib/agent/retry.harn",
251 "llm/judge" => "stdlib/llm/judge.harn",
252 "llm/faithfulness" => "stdlib/llm/faithfulness.harn",
253 "llm/optimize" => "stdlib/llm/optimize.harn",
254 "agent/events" => "stdlib/agent/events.harn",
255 "agent/feedback" => "stdlib/agent/feedback.harn",
256 "agent/transcript" => "stdlib/agent/transcript.harn",
257 "agent/artifacts" => "stdlib/agent/artifacts.harn",
258 "agent/primitives" => "stdlib/agent/primitives.harn",
259 "agent/progress" => "stdlib/agent/progress.harn",
260 "agent/required_tools" => "stdlib/agent/required_tools.harn",
261 "agent/required_artifacts" => "stdlib/agent/required_artifacts.harn",
262 "agent/loop_turn_setup" => "stdlib/agent/loop_turn_setup.harn",
263 "agent/purpose_labels" => "stdlib/agent/purpose_labels.harn",
264 "agent/loop_purpose_labels" => "stdlib/agent/loop_purpose_labels.harn",
265 "agent/monologue_actuation" => "stdlib/agent/monologue_actuation.harn",
266 "agent/monologue_actuation_types" => "stdlib/agent/monologue_actuation_types.harn",
267 "agent/stall_types" => "stdlib/agent/stall_types.harn",
268 "agent/stall" => "stdlib/agent/stall.harn",
269 "agent/recurring_diagnostic" => "stdlib/agent/recurring_diagnostic.harn",
270 "agent/stall_config" => "stdlib/agent/stall_config.harn",
271 "agent/stall_checkpoint" => "stdlib/agent/stall_checkpoint.harn",
272 "agent/stall_feedback" => "stdlib/agent/stall_feedback.harn",
273 "agent/stall_action_observation" => "stdlib/agent/stall_action_observation.harn",
274 "agent/stall_observation" => "stdlib/agent/stall_observation.harn",
275 "agent/stall_verification" => "stdlib/agent/stall_verification.harn",
276 "agent/stall_detectors" => "stdlib/agent/stall_detectors.harn",
277 "agent/run_meter" => "stdlib/agent/run_meter.harn",
278 "agent/cut_landing" => "stdlib/agent/cut_landing.harn",
279 "agent/cut_rules" => "stdlib/agent/cut_rules.harn",
280 "agent/governors" => "stdlib/agent/governors.harn",
281 "agent/control" => "stdlib/agent/control.harn",
282 "agent/action_graph" => "stdlib/agent/action_graph.harn",
283 "agent/result_text" => "stdlib/agent/result_text.harn",
284 "agent/best_of_n" => "stdlib/agent/best_of_n.harn",
285 "agent/loop" => "stdlib/agent/loop.harn",
286 "agent/loop_support" => "stdlib/agent/loop_support.harn",
287 "agent/loop_call_budget" => "stdlib/agent/loop_call_budget.harn",
288 "agent/loop_call_resolution" => "stdlib/agent/loop_call_resolution.harn",
289 "agent/loop_await" => "stdlib/agent/loop_await.harn",
290 "agent/loop_denial_cutoff" => "stdlib/agent/loop_denial_cutoff.harn",
291 "agent/loop_result_status" => "stdlib/agent/loop_result_status.harn",
292 "agent/loop_foundation" => "stdlib/agent/loop_foundation.harn",
293 "agent/loop_lifecycle" => "stdlib/agent/loop_lifecycle.harn",
294 "agent/loop_provider_failure" => "stdlib/agent/loop_provider_failure.harn",
295 "agent/loop_audit_flushes" => "stdlib/agent/loop_audit_flushes.harn",
296 "agent/loop_tool_calls" => "stdlib/agent/loop_tool_calls.harn",
297 "agent/loop_resource_dispatch" => "stdlib/agent/loop_resource_dispatch.harn",
298 "agent/loop_turn_options" => "stdlib/agent/loop_turn_options.harn",
299 "agent/loop_turn_scope" => "stdlib/agent/loop_turn_scope.harn",
300 "agent/loop_turn_projection" => "stdlib/agent/loop_turn_projection.harn",
301 "agent/loop_internal" => "stdlib/agent/loop_internal.harn",
302 "agent/loop_run" => "stdlib/agent/loop_run.harn",
303 "agent/loop_post_turn" => "stdlib/agent/loop_post_turn.harn",
304 "agent/loop_finalize" => "stdlib/agent/loop_finalize.harn",
305 "agent/loop_terminal" => "stdlib/agent/loop_terminal.harn",
306 "agent/user" => "stdlib/agent/user.harn",
307 "agent/tool_search" => "stdlib/agent/tool_search.harn",
308 "agent/tool_annotations" => "stdlib/agent/tool_annotations.harn",
309 "agent/tool_lifecycle" => "stdlib/agent/tool_lifecycle.harn",
310 "agent/workers" => "stdlib/agent/workers.harn",
311 "agent/introspection" => "stdlib/agent/introspection.harn",
312 "agent/resume_by" => "stdlib/agent/resume_by.harn",
313 "agent/state" => "stdlib/agent/state.harn",
314 "agent/truncation" => "stdlib/agent/truncation.harn",
315 "agent/canon" => "stdlib/agent/canon.harn",
316 "agent/skills" => "stdlib/agent/skills.harn",
317 "agent/workspace_guidance" => "stdlib/agent/workspace_guidance.harn",
318 "agent/autocompact" => "stdlib/agent/autocompact.harn",
319 "agent/response_compaction" => "stdlib/agent/response_compaction.harn",
320 "agent/mcp" => "stdlib/agent/mcp.harn",
321 "agent/command_capture" => "stdlib/agent/command_capture.harn",
322 "agent/contracts" => "stdlib/agent/contracts.harn",
323 "agent/command_ledger" => "stdlib/agent/command_ledger.harn",
324 "agent/host_tools" => "stdlib/agent/host_tools.harn",
325 "agent/host_injection" => "stdlib/agent/host_injection.harn",
326 "agent/budget" => "stdlib/agent/budget.harn",
327 "agent/daemon" => "stdlib/agent/daemon.harn",
328 "agent/preflight" => "stdlib/agent/preflight.harn",
329 "agent/postturn" => "stdlib/agent/postturn.harn",
330 "agent/turn_end" => "stdlib/agent/turn_end.harn",
331 "agent/tool_surface" => "stdlib/agent/tool_surface.harn",
332 "agent/stance" => "stdlib/agent/stance.harn",
333 "agent/lanes" => "stdlib/agent/lanes.harn",
334 "agent/overlays" => "stdlib/agent/overlays.harn",
335 "agent/sitrep" => "stdlib/agent/sitrep.harn",
336 "agent/verdict" => "stdlib/agent/verdict.harn",
337 "agent/judge_internals" => "stdlib/agent/judge_internals.harn",
338 "agent/judge_itemization" => "stdlib/agent/judge_itemization.harn",
339 "agent/judge_contradiction" => "stdlib/agent/judge_contradiction.harn",
340 "agent/judge_arbitration" => "stdlib/agent/judge_arbitration.harn",
341 "agent/judge_evidence" => "stdlib/agent/judge_evidence.harn",
342 "agent/loop_await_turn" => "stdlib/agent/loop_await_turn.harn",
343 "agent/loop_structural_veto" => "stdlib/agent/loop_structural_veto.harn",
344 "agent/loop_skipped_dispatch" => "stdlib/agent/loop_skipped_dispatch.harn",
345 "agent/judge_verdict" => "stdlib/agent/judge_verdict.harn",
346 "agent/completion_gate" => "stdlib/agent/completion_gate.harn",
347 "agent/completion_review" => "stdlib/agent/completion_review.harn",
348 "agent/completion_requirements" => "stdlib/agent/completion_requirements.harn",
349 "agent/completion_claim" => "stdlib/agent/completion_claim.harn",
350 "agent/completion_evidence" => "stdlib/agent/completion_evidence.harn",
351 "agent/obligations" => "stdlib/agent/obligations.harn",
352 "agent/judge" => "stdlib/agent/judge.harn",
353 "agent/approval_review" => "stdlib/agent/approval_review.harn",
354 "agent/approval_review_calibration" => "stdlib/agent/approval_review_calibration.harn",
355 "agent/guardrails" => "stdlib/agent/guardrails.harn",
356 "agent/step_judge" => "stdlib/agent/step_judge.harn",
357 "agent/scratchpad" => "stdlib/agent/scratchpad.harn",
358 "agent/fact" => "stdlib/agent/fact.harn",
359 "agent/hypothesis" => "stdlib/agent/hypothesis.harn",
360 "agent/pattern_knowledge_values" => "stdlib/agent/pattern_knowledge_values.harn",
361 "agent/pattern_knowledge_curated" => "stdlib/agent/pattern_knowledge_curated.harn",
362 "agent/pattern_knowledge_persistence" => "stdlib/agent/pattern_knowledge_persistence.harn",
363 "agent/pattern_knowledge_matching" => "stdlib/agent/pattern_knowledge_matching.harn",
364 "agent/pattern_knowledge" => "stdlib/agent/pattern_knowledge.harn",
365 "agent/crystallization_curator" => "stdlib/agent/crystallization_curator.harn",
366 "agent/probe" => "stdlib/agent/probe.harn",
367 "agent/stream" => "stdlib/agent/stream.harn",
368 "agent/presets" => "stdlib/agent/presets.harn",
369 "agent/pins" => "stdlib/agent/pins.harn",
370 "agent/goal" => "stdlib/agent/goal.harn",
371 "agent/task_plan" => "stdlib/agent/task_plan.harn",
372 "personas/compiler" => "stdlib/personas/compiler.harn",
373 "personas/prompt_compiler" => "stdlib/personas/prompt_compiler.harn",
374 "agent_state" => "stdlib/stdlib_agent_state.harn",
375 "memory" => "stdlib/stdlib_memory.harn",
376 "session-store" => "stdlib/stdlib_session_store.harn",
377 "coordination" => "stdlib/stdlib_coordination.harn",
378 "coordination/append_metadata" => "stdlib/coordination/append_metadata.harn",
379 "coordination/schema" => "stdlib/coordination/schema.harn",
380 "execution" => "stdlib/stdlib_execution.harn",
381 "fleet/coordination" => "stdlib/fleet/coordination.harn",
382 "postgres" => "stdlib/stdlib_postgres.harn",
383 "postgres/query" => "stdlib/postgres/query.harn",
384 "sqlite" => "stdlib/stdlib_sqlite.harn",
385 "checkpoint" => "stdlib/stdlib_checkpoint.harn",
386 "host" => "stdlib/stdlib_host.harn",
387 "host_conditions" => "stdlib/stdlib_host_conditions.harn",
388 "host_lease" => "stdlib/stdlib_host_lease.harn",
389 "git" => "stdlib/stdlib_git.harn",
390 "git/checkout" => "stdlib/git/checkout.harn",
391 "git/contracts" => "stdlib/git/contracts.harn",
392 "hitl" => "stdlib/stdlib_hitl.harn",
393 "trust" => "stdlib/stdlib_trust.harn",
394 "corrections" => "stdlib/stdlib_corrections.harn",
395 "plan" => "stdlib/stdlib_plan.harn",
396 "waitpoint" => "stdlib/stdlib_waitpoint.harn",
397 "monitors" => "stdlib/stdlib_monitors.harn",
398 "worktree" => "stdlib/stdlib_worktree.harn",
399 "acp" => "stdlib/stdlib_acp.harn",
400 "external_agent" => "stdlib/stdlib_external_agent.harn",
401 "triggers" => "stdlib/stdlib_triggers.harn",
402 "triage" => "stdlib/stdlib_triage.harn",
403 "dashboard/jobs" => "stdlib/dashboard/jobs.harn",
404 "ui_resource" => "stdlib/stdlib_ui_resource.harn",
405 "handoffs" => "stdlib/stdlib_handoffs.harn",
406 "lifecycle" => "stdlib/stdlib_lifecycle.harn",
407 "tool_hooks_catalogues" => "stdlib/stdlib_tool_hooks_catalogues.harn",
408 "tool_hooks" => "stdlib/stdlib_tool_hooks.harn",
409 "channel_guardrails" => "stdlib/stdlib_channel_guardrails.harn",
410 "personas/prelude" => "stdlib/stdlib_personas_prelude.harn",
411 "personas/bulletins" => "stdlib/stdlib_personas_bulletins.harn",
412 "connectors/shared" => "stdlib/stdlib_connectors_shared.harn",
413 "connectors/http" => "stdlib/connectors/http.harn",
414 "connectors/setup" => "stdlib/connectors/setup.harn",
415 "oauth/providers" => "stdlib/oauth/providers.harn",
416 "oauth/token_exchange_catalog" => "stdlib/oauth/token_exchange_catalog.harn",
417 "oauth/token_exchange" => "stdlib/oauth/token_exchange.harn",
418 "oauth/storage" => "stdlib/oauth/storage.harn",
419 "oauth/client" => "stdlib/oauth/client.harn",
420 "oauth/device_flow" => "stdlib/oauth/device_flow.harn",
421 "oauth/redaction" => "stdlib/oauth/redaction.harn",
422 "oauth/dynamic_registration" => "stdlib/oauth/dynamic_registration.harn",
423 "connectors/github" => "stdlib/stdlib_connectors_github.harn",
424 "connectors/github/repository" => "stdlib/connectors/github/repository.harn",
425 "connectors/linear" => "stdlib/stdlib_connectors_linear.harn",
426 "connectors/notion" => "stdlib/stdlib_connectors_notion.harn",
427 "connectors/slack" => "stdlib/stdlib_connectors_slack.harn",
428 "workflow/prompts" => "stdlib/workflow/prompts.harn",
429 "workflow/context" => "stdlib/workflow/context.harn",
430 "workflow/options" => "stdlib/workflow/options.harn",
431 "workflow/checkpoints" => "stdlib/workflow/checkpoints.harn",
432 "workflow/patterns" => "stdlib/workflow/patterns.harn",
433 "workflow/stage" => "stdlib/workflow/stage.harn",
434 "workflow/map" => "stdlib/workflow/map.harn",
435 "workflow/schedule" => "stdlib/workflow/schedule.harn",
436 "workflow/execute" => "stdlib/workflow/execute.harn",
437 "workflow/repair" => "stdlib/workflow/repair.harn",
438 "security" => "stdlib/stdlib_security.harn",
439 "pii" => "stdlib/stdlib_pii.harn",
440 "bump/runtime" => "stdlib/bump/runtime.harn",
441 "bump/live" => "stdlib/bump/live.harn",
442]);
443
444pub const CONNECTOR_EVENT_SCHEMAS_SOURCE: &str = include_str!("stdlib/stdlib_event_schemas.harn");
454
455pub const STDLIB_PROMPT_ASSETS: &[StdlibPromptAsset] = embedded_catalog!(StdlibPromptAsset, path, [
456 "eval/hypothesis/prompts/intake.harn.prompt" => "stdlib/eval/hypothesis/prompts/intake.harn.prompt",
457 "agent/prompts/tool_contract_text.harn.prompt" => "stdlib/agent/prompts/tool_contract_text.harn.prompt",
458 "agent/prompts/tool_contract_json.harn.prompt" => "stdlib/agent/prompts/tool_contract_json.harn.prompt",
459 "agent/prompts/tool_contract_native.harn.prompt" => "stdlib/agent/prompts/tool_contract_native.harn.prompt",
460 "agent/prompts/tool_contract_text_response_protocol.harn.prompt" => "stdlib/agent/prompts/tool_contract_text_response_protocol.harn.prompt",
461 "agent/prompts/tool_contract_action_native.harn.prompt" => "stdlib/agent/prompts/tool_contract_action_native.harn.prompt",
462 "agent/prompts/tool_contract_action_text.harn.prompt" => "stdlib/agent/prompts/tool_contract_action_text.harn.prompt",
463 "agent/prompts/tool_contract_task_ledger.harn.prompt" => "stdlib/agent/prompts/tool_contract_task_ledger.harn.prompt",
464 "agent/prompts/tool_contract_deferred_tools.harn.prompt" => "stdlib/agent/prompts/tool_contract_deferred_tools.harn.prompt",
465 "agent/prompts/deferred_tool_listing.harn.prompt" => "stdlib/agent/prompts/deferred_tool_listing.harn.prompt",
466 "agent/prompts/default_nudge.harn.prompt" => "stdlib/agent/prompts/default_nudge.harn.prompt",
467 "agent/prompts/agentic_user_system.harn.prompt" => "stdlib/agent/prompts/agentic_user_system.harn.prompt",
468 "agent/prompts/agentic_user_user.harn.prompt" => "stdlib/agent/prompts/agentic_user_user.harn.prompt",
469 "agent/prompts/loop_until_done_system.harn.prompt" => "stdlib/agent/prompts/loop_until_done_system.harn.prompt",
470 "agent/prompts/completion_judge_default.harn.prompt" => "stdlib/agent/prompts/completion_judge_default.harn.prompt",
471 "agent/prompts/completion_judge_feedback_fallback.harn.prompt" => "stdlib/agent/prompts/completion_judge_feedback_fallback.harn.prompt",
472 "agent/prompts/completion_judge_user.harn.prompt" => "stdlib/agent/prompts/completion_judge_user.harn.prompt",
473 "agent/prompts/step_judge_system_default.harn.prompt" => "stdlib/agent/prompts/step_judge_system_default.harn.prompt",
474 "agent/prompts/step_judge_system_adversarial.harn.prompt" => "stdlib/agent/prompts/step_judge_system_adversarial.harn.prompt",
475 "agent/prompts/step_judge_user.harn.prompt" => "stdlib/agent/prompts/step_judge_user.harn.prompt",
476 "agent/prompts/parse_guidance.harn.prompt" => "stdlib/agent/prompts/parse_guidance.harn.prompt",
477 "agent/prompts/native_tool_contract_feedback.harn.prompt" => "stdlib/agent/prompts/native_tool_contract_feedback.harn.prompt",
478 "agent/prompts/verification_gate_feedback.harn.prompt" => "stdlib/agent/prompts/verification_gate_feedback.harn.prompt",
479 "agent/prompts/daemon_watch_feedback.harn.prompt" => "stdlib/agent/prompts/daemon_watch_feedback.harn.prompt",
480 "agent/prompts/daemon_timer_feedback.harn.prompt" => "stdlib/agent/prompts/daemon_timer_feedback.harn.prompt",
481 "llm/prompts/completion_fallback_system.harn.prompt" => "stdlib/llm/prompts/completion_fallback_system.harn.prompt",
482 "llm/prompts/completion_fallback_user.harn.prompt" => "stdlib/llm/prompts/completion_fallback_user.harn.prompt",
483 "llm/prompts/transcript_summarize_user.harn.prompt" => "stdlib/llm/prompts/transcript_summarize_user.harn.prompt",
484 "llm/prompts/sitrep_user.harn.prompt" => "stdlib/llm/prompts/sitrep_user.harn.prompt",
485 "llm/prompts/structural_chain_of_draft.harn.prompt" => "stdlib/llm/prompts/structural_chain_of_draft.harn.prompt",
486 "llm/prompts/schema_recover_repair.harn.prompt" => "stdlib/llm/prompts/schema_recover_repair.harn.prompt",
487 "llm/prompts/structured_envelope_schema_contract.harn.prompt" => "stdlib/llm/prompts/structured_envelope_schema_contract.harn.prompt",
488 "llm/prompts/structured_envelope_repair.harn.prompt" => "stdlib/llm/prompts/structured_envelope_repair.harn.prompt",
489 "llm/prompts/directive_envelope_instructions.harn.prompt" => "stdlib/llm/prompts/directive_envelope_instructions.harn.prompt",
490 "llm/prompts/pairwise_rerank_user.harn.prompt" => "stdlib/llm/prompts/pairwise_rerank_user.harn.prompt",
491 "llm/prompts/tool_binder_user.harn.prompt" => "stdlib/llm/prompts/tool_binder_user.harn.prompt",
492 "llm/prompts/missing_tool_call_classifier.harn.prompt" => "stdlib/llm/prompts/missing_tool_call_classifier.harn.prompt",
493 "workflow/prompts/stage.harn.prompt" => "stdlib/workflow/prompts/stage.harn.prompt",
494 "workflow/prompts/verification_context_intro.harn.prompt" => "stdlib/workflow/prompts/verification_context_intro.harn.prompt",
495 "orchestration/prompts/compaction_summary.harn.prompt" => "stdlib/orchestration/prompts/compaction_summary.harn.prompt",
496 "orchestration/prompts/compaction_policy_extension.harn.prompt" => "stdlib/orchestration/prompts/compaction_policy_extension.harn.prompt",
497 "orchestration/prompts/compaction_policy_replacement.harn.prompt" => "stdlib/orchestration/prompts/compaction_policy_replacement.harn.prompt",
498 "orchestration/prompts/compaction_state_grounding.harn.prompt" => "stdlib/orchestration/prompts/compaction_state_grounding.harn.prompt",
499]);
500
501#[derive(Debug, Clone, Copy, PartialEq, Eq)]
505pub struct StdlibCliScript {
506 pub name: &'static str,
510 pub source: &'static str,
513}
514
515pub const STDLIB_CLI_SCRIPTS: &[StdlibCliScript] = embedded_catalog!(StdlibCliScript, name, [
516 "codemod" => "stdlib/cli/codemod.harn",
517 "canon/check" => "stdlib/cli/canon/check.harn",
518 "chat" => "stdlib/cli/chat.harn",
519 "doctor" => "stdlib/cli/doctor.harn",
520 "echo" => "stdlib/cli/echo.harn",
521 "eval/_runner" => "stdlib/cli/eval/_runner.harn",
525 "eval/context" => "stdlib/cli/eval/context.harn",
526 "eval/model_selector" => "stdlib/cli/eval/model_selector.harn",
527 "eval/tool_calls" => "stdlib/cli/eval/tool_calls.harn",
528 "eval/coding_agent" => "stdlib/cli/eval/coding_agent.harn",
529 "eval/scope_triage" => "stdlib/cli/eval/scope_triage.harn",
530 "eval/calibrate" => "stdlib/cli/eval/calibrate.harn",
531 "eval/prompt" => "stdlib/cli/eval/prompt.harn",
532 "explain" => "stdlib/cli/explain.harn",
533 "graph" => "stdlib/cli/graph.harn",
534 "personas/compile_prompt" => "stdlib/cli/personas/compile_prompt.harn",
535 "personas/materialize" => "stdlib/cli/personas/materialize.harn",
536 "models/batch_plan" => "stdlib/cli/models/batch_plan.harn",
537 "models/list" => "stdlib/cli/models/list.harn",
538 "models/lora_inspect" => "stdlib/cli/models/lora_inspect.harn",
539 "models/lora_export" => "stdlib/cli/models/lora_export.harn",
540 "models/lora_manifest" => "stdlib/cli/models/lora_manifest.harn",
541 "models/lora_preflight" => "stdlib/cli/models/lora_preflight.harn",
542 "models/lora_promote" => "stdlib/cli/models/lora_promote.harn",
543 "models/lora_plan" => "stdlib/cli/models/lora_plan.harn",
544 "models/lora_train" => "stdlib/cli/models/lora_train.harn",
545 "models/recommend" => "stdlib/cli/models/recommend.harn",
546 "models/test" => "stdlib/cli/models/test.harn",
547 "precompile" => "stdlib/cli/precompile.harn",
548 "providers/cache_probe" => "stdlib/cli/providers/cache_probe.harn",
549 "providers/catalog" => "stdlib/cli/providers/catalog.harn",
550 "providers/effort_probe" => "stdlib/cli/providers/effort_probe.harn",
551 "providers/option_probe" => "stdlib/cli/providers/option_probe.harn",
552 "providers/probe" => "stdlib/cli/providers/probe.harn",
553 "providers/recommend" => "stdlib/cli/providers/recommend.harn",
554 "providers/tool_probe" => "stdlib/cli/providers/tool_probe.harn",
555 "providers/tool_scorecard" => "stdlib/cli/providers/tool_scorecard.harn",
556 "routes" => "stdlib/cli/routes.harn",
557 "runs/export_training" => "stdlib/cli/runs/export_training.harn",
558 "scan" => "stdlib/cli/scan.harn",
559 "scaffold/init" => "stdlib/cli/scaffold/init.harn",
560 "scaffold/tool_new" => "stdlib/cli/scaffold/tool_new.harn",
561 "trace_import" => "stdlib/cli/trace_import.harn",
562 "try" => "stdlib/cli/try.harn",
563 "version" => "stdlib/cli/version.harn",
564]);
565
566pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
567 STDLIB_SOURCES
568 .iter()
569 .find_map(|entry| (entry.module == module).then_some(entry.source))
570}
571
572pub fn builtin_reexports(module: &str) -> &'static [&'static str] {
592 match module {
593 "testing" => &[
594 "assert",
595 "assert_approx",
596 "assert_eq",
597 "assert_matches",
598 "assert_ne",
599 "skip",
600 "value_diff",
601 ],
602 _ => &[],
603 }
604}
605
606pub fn find_cli_script(name: &str) -> Option<&'static str> {
610 STDLIB_CLI_SCRIPTS
611 .iter()
612 .find_map(|entry| (entry.name == name).then_some(entry.source))
613}
614
615pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
616 let path = path.strip_prefix("std/").unwrap_or(path);
617 STDLIB_PROMPT_ASSETS
618 .iter()
619 .find_map(|entry| (entry.path == path).then_some(entry.source))
620}
621
622pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
623 let Some(source) = get_stdlib_source(module) else {
624 return Vec::new();
625 };
626 public_functions_from_source(source)
627}
628
629pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
630 STDLIB_SOURCES
631 .iter()
632 .filter_map(|entry| {
633 entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
634 import_path: format!("std/{}", entry.module),
635 category,
636 })
637 })
638 .collect()
639}
640
641fn entrypoint_category_from_source(source: &str) -> Option<String> {
642 for line in source.lines() {
643 let line = line.trim();
644 if line.is_empty() {
645 continue;
646 }
647 if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
648 let category = category.trim();
649 return (!category.is_empty()).then(|| category.to_string());
650 }
651 if !line.starts_with("//") {
652 return None;
653 }
654 }
655 None
656}
657
658fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
659 let mut out = Vec::new();
660 let mut doc: Option<String> = None;
661 let lines = source.lines().collect::<Vec<_>>();
662 let mut index = 0usize;
663 while index < lines.len() {
664 let line = lines[index].trim();
665 if line.starts_with("/**") {
666 let (parsed, next) = parse_harndoc(&lines, index);
667 doc = parsed;
668 index = next;
669 continue;
670 }
671 if line.starts_with("pub fn ") {
672 let (signature_line, next) = collect_public_function_signature(&lines, index);
673 if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
674 out.push(function);
675 index = next;
676 continue;
677 }
678 }
679 if let Some(function) = parse_public_function_line(line, doc.take()) {
680 out.push(function);
681 } else if !line.is_empty() && !line.starts_with("//") {
682 doc = None;
683 }
684 index += 1;
685 }
686 out
687}
688
689fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
690 let mut parts = Vec::new();
691 let mut index = start;
692 while index < lines.len() {
693 parts.push(lines[index].trim().to_string());
694 let candidate = parts.join(" ");
695 if public_function_signature_complete(&candidate) {
696 return (candidate, index + 1);
697 }
698 index += 1;
699 }
700 (parts.join(" "), index)
701}
702
703fn public_function_signature_complete(line: &str) -> bool {
704 let Some(rest) = line.strip_prefix("pub fn ") else {
705 return false;
706 };
707 let Some((_, after_paren)) = rest.split_once('(') else {
708 return false;
709 };
710 matching_paren_len(after_paren).is_some()
711}
712
713fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
714 let mut parts = Vec::new();
715 let mut index = start;
716 while index < lines.len() {
717 let mut line = lines[index].trim();
718 if index == start {
719 line = line.trim_start_matches("/**").trim();
720 }
721 let done = line.ends_with("*/");
722 line = line.trim_end_matches("*/").trim();
723 line = line.trim_start_matches('*').trim();
724 if !line.is_empty() {
725 parts.push(line.to_string());
726 }
727 index += 1;
728 if done {
729 break;
730 }
731 }
732 let text = parts.join("\n").trim().to_string();
733 ((!text.is_empty()).then_some(text), index)
734}
735
736#[expect(
737 clippy::string_slice,
738 reason = "bounds come from str::find and char_indices"
739)]
740fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
741 let rest = line.strip_prefix("pub fn ")?.trim();
742 let name_end = rest.find('(')?;
743 let declaration_name = rest[..name_end].trim();
744 let name = declaration_name
745 .split_once('<')
746 .map_or(declaration_name, |(name, _)| name.trim());
747 if name.is_empty() {
748 return None;
749 }
750 let params_start = name_end + 1;
751 let params_len = matching_paren_len(&rest[params_start..])?;
752 let params = &rest[params_start..params_start + params_len];
753 let after = rest[params_start + params_len + 1..].trim();
754 let return_type = after
755 .strip_prefix("->")
756 .and_then(|tail| tail.split('{').next())
757 .map(str::trim)
758 .filter(|value| !value.is_empty());
759 let signature = match return_type {
760 Some(ret) => format!("{declaration_name}({params}) -> {ret}"),
761 None => format!("{declaration_name}({params})"),
762 };
763 let param_parts = split_top_level_params(params);
764 let total_params = param_parts
765 .iter()
766 .filter(|param| !param.trim().is_empty())
767 .count();
768 let variadic = param_parts
769 .iter()
770 .any(|param| param.trim_start().starts_with("..."));
771 let required_params = param_parts
772 .iter()
773 .filter(|param| {
774 let param = param.trim();
775 !param.is_empty() && !param.contains('=') && !param.starts_with("...")
776 })
777 .count();
778 Some(StdlibPublicFunction {
779 name: name.to_string(),
780 signature,
781 required_params,
782 total_params,
783 variadic,
784 doc,
785 })
786}
787
788fn matching_paren_len(input: &str) -> Option<usize> {
789 let mut depth = 1usize;
790 for (offset, ch) in input.char_indices() {
791 match ch {
792 '(' | '[' | '{' => depth += 1,
793 ')' | ']' | '}' => {
794 depth = depth.saturating_sub(1);
795 if depth == 0 {
796 return Some(offset);
797 }
798 }
799 _ => {}
800 }
801 }
802 None
803}
804
805#[expect(
806 clippy::string_slice,
807 reason = "offsets come from char_indices and 1-byte ','"
808)]
809fn split_top_level_params(params: &str) -> Vec<&str> {
810 let mut out = Vec::new();
811 let mut depth = 0isize;
812 let mut start = 0usize;
813 for (offset, ch) in params.char_indices() {
814 match ch {
815 '(' | '[' | '{' => depth += 1,
816 ')' | ']' | '}' => depth -= 1,
817 ',' if depth == 0 => {
818 out.push(¶ms[start..offset]);
819 start = offset + 1;
820 }
821 _ => {}
822 }
823 }
824 out.push(¶ms[start..]);
825 out
826}
827
828#[cfg(test)]
829mod tests {
830 use std::collections::BTreeSet;
831
832 use super::{
833 entrypoint_modules, get_stdlib_prompt_asset, matching_paren_len,
834 parse_public_function_line, public_functions_for_module, STDLIB_CLI_SCRIPTS,
835 STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
836 };
837
838 #[test]
839 fn stdlib_sources_are_non_empty() {
840 for entry in STDLIB_SOURCES {
841 assert!(
842 !entry.source.trim().is_empty(),
843 "{} should have non-empty source",
844 entry.module
845 );
846 }
847 }
848
849 #[test]
850 fn cli_scripts_are_non_empty_and_uniquely_named() {
851 let mut seen = BTreeSet::new();
852 for entry in STDLIB_CLI_SCRIPTS {
853 assert!(
854 !entry.source.trim().is_empty(),
855 "cli/{} should have non-empty source",
856 entry.name
857 );
858 assert!(
859 seen.insert(entry.name),
860 "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
861 entry.name
862 );
863 }
864 }
865
866 #[test]
867 fn stdlib_source_names_are_unique() {
868 let mut names = BTreeSet::new();
869 for entry in STDLIB_SOURCES {
870 assert!(names.insert(entry.module), "duplicate {}", entry.module);
871 }
872 }
873
874 #[test]
875 fn stdlib_prompt_assets_are_non_empty() {
876 for entry in STDLIB_PROMPT_ASSETS {
877 assert!(
878 !entry.source.trim().is_empty(),
879 "{} should have non-empty prompt asset source",
880 entry.path
881 );
882 }
883 }
884
885 #[test]
886 fn stdlib_prompt_asset_paths_are_unique() {
887 let mut paths = BTreeSet::new();
888 for entry in STDLIB_PROMPT_ASSETS {
889 assert!(paths.insert(entry.path), "duplicate {}", entry.path);
890 }
891 }
892
893 #[test]
894 fn key_stdlib_prompt_assets_resolve() {
895 for path in [
896 "std/agent/prompts/tool_contract_text.harn.prompt",
897 "std/agent/prompts/default_nudge.harn.prompt",
898 "std/agent/prompts/completion_judge_default.harn.prompt",
899 "std/llm/prompts/directive_envelope_instructions.harn.prompt",
900 "std/workflow/prompts/stage.harn.prompt",
901 "std/orchestration/prompts/compaction_summary.harn.prompt",
902 "std/orchestration/prompts/compaction_policy_extension.harn.prompt",
903 "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
904 "std/orchestration/prompts/compaction_state_grounding.harn.prompt",
905 ] {
906 assert!(
907 get_stdlib_prompt_asset(path).is_some(),
908 "{path} should resolve"
909 );
910 }
911 }
912
913 #[test]
914 fn public_function_catalog_derives_signatures_from_harn_source() {
915 let exports = public_functions_for_module("workflow/execute");
916 assert_eq!(exports.len(), 1);
917 assert_eq!(exports[0].name, "workflow_execute");
918 assert_eq!(
919 exports[0].signature,
920 "workflow_execute( harness: Harness, task: string, graph: dict, artifacts: list<unknown>? = nil, options: dict? = nil, )"
921 );
922 assert_eq!(exports[0].required_params, 3);
923 assert_eq!(exports[0].total_params, 5);
924 }
925
926 #[test]
927 fn tool_registry_from_catalog_includes_cli_metadata_parameter() {
928 let function = public_functions_for_module("tools")
929 .into_iter()
930 .find(|function| function.name == "tool_registry_from")
931 .expect("std/tools should export tool_registry_from");
932 assert_eq!(function.required_params, 1);
933 assert_eq!(function.total_params, 2);
934 assert!(function
935 .signature
936 .contains("options: ToolRegistryOptions? = nil"));
937 }
938
939 #[test]
940 fn soft_landing_modules_own_their_public_surface() {
941 for (module, expected) in [
945 (
946 "agent/run_meter",
947 &[
948 "meter_observation_lower",
949 "meter_observation_render",
950 "meter_observation_upper",
951 "run_meter_bounded",
952 "run_meter_charge",
953 "run_meter_digest",
954 "run_meter_exact",
955 "run_meter_field_registered",
956 "run_meter_field_spec",
957 "run_meter_fields",
958 "run_meter_new",
959 "run_meter_observe",
960 "run_meter_project_next_call",
961 "run_meter_read",
962 "run_meter_registry_digest",
963 "run_meter_unavailable",
964 ][..],
965 ),
966 (
967 "agent/cut_landing",
968 &[
969 "cut_action_allowed",
970 "cut_predicate_evaluate",
971 "cut_predicate_render",
972 "cut_predicate_validate",
973 "cut_rules_digest",
974 "cut_rules_tick",
975 "cut_rules_validate",
976 "cut_state_complete",
977 "cut_state_new",
978 "cut_state_record_admission",
979 "cut_state_record_terminal_emit",
980 "cut_terminal_emit_due",
981 "cut_terminal_evidence",
982 ][..],
983 ),
984 ] {
985 let exports = public_functions_for_module(module)
986 .into_iter()
987 .map(|function| function.name)
988 .collect::<BTreeSet<_>>();
989 for name in expected {
990 assert!(exports.contains(*name), "std/{module} should export {name}");
991 }
992 }
993 }
994
995 #[test]
996 fn pace_cut_rule_module_owns_public_functions() {
997 let cut_rule_exports = public_functions_for_module("agent/cut_rules")
998 .into_iter()
999 .map(|function| function.name)
1000 .collect::<BTreeSet<_>>();
1001 for name in [
1002 "pace_cut_rule_action_of",
1003 "pace_cut_rule_check_max_injections",
1004 "pace_cut_rule_decision",
1005 "pace_cut_rule_extend_max",
1006 ] {
1007 assert!(
1008 cut_rule_exports.contains(name),
1009 "std/agent/cut_rules should export {name}"
1010 );
1011 }
1012
1013 let governor_exports = public_functions_for_module("agent/governors")
1014 .into_iter()
1015 .map(|function| function.name)
1016 .collect::<BTreeSet<_>>();
1017 for removed in [
1018 "governor_pace_check_max_injections",
1019 "governor_pace_decision",
1020 "governor_pace_extend_max",
1021 "pace_action_of",
1022 ] {
1023 assert!(
1024 !governor_exports.contains(removed),
1025 "std/agent/governors must not retain removed export {removed}"
1026 );
1027 }
1028 }
1029
1030 #[test]
1031 fn command_stdlib_module_exports_step_helpers() {
1032 let exports = public_functions_for_module("command")
1033 .into_iter()
1034 .map(|function| function.name)
1035 .collect::<BTreeSet<_>>();
1036 for name in [
1037 "command_run",
1038 "command_wait",
1039 "command_wait_for_output",
1040 "command_cancel",
1041 "command_run_streaming",
1042 "command_output_tail",
1043 "command_json",
1044 "command_json_step",
1045 "command_try",
1046 "command_step",
1047 "command_steps_append",
1048 "command_last_failed_step",
1049 "command_step_ref",
1050 "command_output_text",
1051 "argv_label",
1052 "shell_command_from_argv",
1053 "shell_command_from_value",
1054 ] {
1055 assert!(exports.contains(name), "std/command should export {name}");
1056 }
1057 }
1058
1059 #[test]
1060 fn disclosure_stdlib_module_exports_render_helpers() {
1061 let exports = public_functions_for_module("disclosure")
1062 .into_iter()
1063 .map(|function| function.name)
1064 .collect::<BTreeSet<_>>();
1065 assert!(
1066 exports.contains("render"),
1067 "std/disclosure should export render"
1068 );
1069 assert!(
1070 exports.contains("git_trailers"),
1071 "std/disclosure should export git_trailers"
1072 );
1073 assert!(
1074 exports.contains("slack_message_disclosure"),
1075 "std/disclosure should export slack_message_disclosure"
1076 );
1077 assert!(
1078 exports.contains("append_git_trailers"),
1079 "std/disclosure should export append_git_trailers"
1080 );
1081 }
1082
1083 #[test]
1084 fn async_stdlib_exports_predicate_backoff_name_only() {
1085 let exports = public_functions_for_module("async")
1086 .into_iter()
1087 .map(|function| function.name)
1088 .collect::<BTreeSet<_>>();
1089 assert!(
1090 exports.contains("retry_predicate_with_backoff"),
1091 "std/async should export retry_predicate_with_backoff"
1092 );
1093 assert!(
1094 !exports.contains("retry_with_backoff"),
1095 "std/async should not retain the old retry_with_backoff export"
1096 );
1097 }
1098
1099 #[test]
1100 fn signal_stdlib_module_exports_interrupt_helpers() {
1101 let exports = public_functions_for_module("signal")
1102 .into_iter()
1103 .map(|function| function.name)
1104 .collect::<BTreeSet<_>>();
1105 for name in [
1106 "on_interrupt",
1107 "off_interrupt",
1108 "interrupted",
1109 "with_interrupt",
1110 ] {
1111 assert!(exports.contains(name), "std/signal should export {name}");
1112 }
1113 }
1114
1115 #[test]
1116 fn git_stdlib_module_exports_local_wrappers() {
1117 let exports = public_functions_for_module("git")
1118 .into_iter()
1119 .map(|function| function.name)
1120 .collect::<BTreeSet<_>>();
1121 for name in [
1122 "git_run",
1123 "git_status",
1124 "git_current_branch",
1125 "git_log",
1126 "git_switch",
1127 "git_pull_ff_only",
1128 "git_find_tool",
1129 "git_run_tool",
1130 "git_tools",
1131 "git_toolbox_tools",
1132 ] {
1133 assert!(exports.contains(name), "std/git should export {name}");
1134 }
1135 }
1136
1137 #[test]
1138 fn agent_workers_exports_suspend_resume_wrappers() {
1139 let exports = public_functions_for_module("agent/workers");
1140 let suspend = exports
1141 .iter()
1142 .find(|function| function.name == "suspend_agent")
1143 .expect("std/agent/workers should export suspend_agent");
1144 assert_eq!(
1145 suspend.signature,
1146 "suspend_agent( agents: HarnessAgent, worker: unknown, reason: string = \"\", options: dict? = nil, ) -> unknown"
1147 );
1148 assert_eq!(suspend.required_params, 2);
1149 assert_eq!(suspend.total_params, 4);
1150
1151 let resume = exports
1152 .iter()
1153 .find(|function| function.name == "resume_agent")
1154 .expect("std/agent/workers should export resume_agent");
1155 assert_eq!(
1156 resume.signature,
1157 "resume_agent( agents: HarnessAgent, worker_or_snapshot: unknown, resume_input: unknown = nil, continue_transcript: bool = true, ) -> unknown"
1158 );
1159 assert_eq!(resume.required_params, 2);
1160 assert_eq!(resume.total_params, 4);
1161
1162 let stop = exports
1163 .iter()
1164 .find(|function| function.name == "agent_stop")
1165 .expect("std/agent/workers should export agent_stop");
1166 assert_eq!(
1167 stop.signature,
1168 "agent_stop( agents: HarnessAgent, worker: unknown, options: AgentStopOptions? = nil, ) -> unknown"
1169 );
1170 assert_eq!(stop.required_params, 2);
1171 assert_eq!(stop.total_params, 3);
1172
1173 let parse_resume = exports
1174 .iter()
1175 .find(|function| function.name == "parse_resume_conditions")
1176 .expect("std/agent/workers should export parse_resume_conditions");
1177 assert_eq!(
1178 parse_resume.signature,
1179 "parse_resume_conditions( agents: HarnessAgent, conditions: ResumeConditions? = nil, ) -> ResumeConditions?"
1180 );
1181 assert_eq!(parse_resume.required_params, 1);
1182 assert_eq!(parse_resume.total_params, 2);
1183
1184 let lifecycle = exports
1185 .iter()
1186 .find(|function| function.name == "agent_lifecycle_tools")
1187 .expect("std/agent/workers should export agent_lifecycle_tools");
1188 assert_eq!(
1189 lifecycle.signature,
1190 "agent_lifecycle_tools( agents: HarnessAgent, registry: ToolRegistry? = nil, options: AgentLifecycleToolsOptions? = nil, ) -> ToolRegistry"
1191 );
1192 assert_eq!(lifecycle.required_params, 1);
1193 assert_eq!(lifecycle.total_params, 3);
1194 }
1195
1196 #[test]
1197 fn tui_stdlib_module_exports_terminal_helpers() {
1198 let exports = public_functions_for_module("tui")
1199 .into_iter()
1200 .map(|function| function.name)
1201 .collect::<BTreeSet<_>>();
1202 for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1203 assert!(exports.contains(name), "std/tui should export {name}");
1204 }
1205 }
1206
1207 #[test]
1208 fn semver_stdlib_module_exports_release_helpers() {
1209 let exports = public_functions_for_module("semver")
1210 .into_iter()
1211 .map(|function| function.name)
1212 .collect::<BTreeSet<_>>();
1213 for name in [
1214 "strip_v",
1215 "add_v",
1216 "is_v_semver",
1217 "is_v_release_semver",
1218 "parse",
1219 "parse_release",
1220 "is_prerelease_identifier",
1221 "is_prerelease",
1222 "compare_release",
1223 "max_canonical_tag",
1224 "next",
1225 "bump_type",
1226 "version_from_release_branch",
1227 "version_from_tag",
1228 ] {
1229 assert!(exports.contains(name), "std/semver should export {name}");
1230 }
1231 }
1232
1233 #[test]
1234 fn changelog_stdlib_module_exports_typed_primitives() {
1235 let exports = public_functions_for_module("changelog")
1236 .into_iter()
1237 .map(|function| function.name)
1238 .collect::<BTreeSet<_>>();
1239 for name in [
1240 "changelog_validate_categories",
1241 "changelog_parse_fragment",
1242 "changelog_order_fragments",
1243 "changelog_normalize_fragment_body",
1244 "changelog_assemble_fragments",
1245 "changelog_parse_sections",
1246 "changelog_find_section",
1247 "changelog_merge_unreleased",
1248 ] {
1249 assert!(exports.contains(name), "std/changelog should export {name}");
1250 }
1251 }
1252
1253 #[test]
1254 fn text_stdlib_module_exports_regex_and_pad_helpers() {
1255 let exports = public_functions_for_module("text")
1256 .into_iter()
1257 .map(|function| function.name)
1258 .collect::<BTreeSet<_>>();
1259 for name in [
1260 "pad_left",
1261 "pad_right",
1262 "repeat_string",
1263 "regex_first_capture",
1264 "regex_capture_groups",
1265 "regex_all_first_captures",
1266 ] {
1267 assert!(exports.contains(name), "std/text should export {name}");
1268 }
1269 }
1270
1271 #[test]
1272 fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1273 let modules = entrypoint_modules();
1274 let entries = modules
1275 .iter()
1276 .map(|module| (module.import_path.as_str(), module.category.as_str()))
1277 .collect::<BTreeSet<_>>();
1278 for entry in [
1279 ("std/agent/loop", "agent.stdlib"),
1280 ("std/agent/primitives", "agent.stdlib"),
1281 ("std/workflow/execute", "workflow.stdlib"),
1282 ] {
1283 assert!(entries.contains(&entry), "{entry:?} should be declared");
1284 }
1285 }
1286
1287 #[test]
1288 fn matching_paren_len_closes_on_every_bracket_kind() {
1289 assert_eq!(matching_paren_len("a, b)"), Some(4));
1292 assert_eq!(matching_paren_len("x: [int])"), Some(8));
1293 assert_eq!(matching_paren_len("x: {a: int})"), Some(11));
1294 assert_eq!(matching_paren_len("x]"), Some(1));
1297 assert_eq!(matching_paren_len("x}"), Some(1));
1298 assert_eq!(matching_paren_len("unterminated"), None);
1299 }
1300
1301 #[test]
1302 fn parse_public_function_line_handles_record_typed_params() {
1303 let parsed =
1304 parse_public_function_line("pub fn configure(opts: {retries: int}) -> bool", None)
1305 .expect("signature with a record-typed parameter should parse");
1306 assert_eq!(parsed.name, "configure");
1307 assert_eq!(parsed.signature, "configure(opts: {retries: int}) -> bool");
1308 assert_eq!(parsed.total_params, 1);
1309 assert_eq!(parsed.required_params, 1);
1310 }
1311
1312 #[test]
1313 fn parse_public_function_line_indexes_generic_functions_by_base_name() {
1314 let parsed = parse_public_function_line(
1315 "pub fn map<T, U>(items: list<T>, project: fn(T) -> U) -> list<U>",
1316 None,
1317 )
1318 .expect("generic public function should parse");
1319 assert_eq!(parsed.name, "map");
1320 assert_eq!(
1321 parsed.signature,
1322 "map<T, U>(items: list<T>, project: fn(T) -> U) -> list<U>"
1323 );
1324 assert_eq!(parsed.total_params, 2);
1325 assert_eq!(parsed.required_params, 2);
1326 }
1327}