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