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