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/effort_probe" => "stdlib/cli/providers/effort_probe.harn",
500 "providers/probe" => "stdlib/cli/providers/probe.harn",
501 "providers/recommend" => "stdlib/cli/providers/recommend.harn",
502 "providers/tool_probe" => "stdlib/cli/providers/tool_probe.harn",
503 "providers/tool_scorecard" => "stdlib/cli/providers/tool_scorecard.harn",
504 "routes" => "stdlib/cli/routes.harn",
505 "runs/export_training" => "stdlib/cli/runs/export_training.harn",
506 "scan" => "stdlib/cli/scan.harn",
507 "scaffold/init" => "stdlib/cli/scaffold/init.harn",
508 "scaffold/tool_new" => "stdlib/cli/scaffold/tool_new.harn",
509 "trace_import" => "stdlib/cli/trace_import.harn",
510 "try" => "stdlib/cli/try.harn",
511 "version" => "stdlib/cli/version.harn",
512]);
513
514pub fn get_stdlib_source(module: &str) -> Option<&'static str> {
515 STDLIB_SOURCES
516 .iter()
517 .find_map(|entry| (entry.module == module).then_some(entry.source))
518}
519
520pub fn builtin_reexports(module: &str) -> &'static [&'static str] {
540 match module {
541 "testing" => &[
542 "assert",
543 "assert_approx",
544 "assert_eq",
545 "assert_matches",
546 "assert_ne",
547 "value_diff",
548 ],
549 _ => &[],
550 }
551}
552
553pub fn find_cli_script(name: &str) -> Option<&'static str> {
557 STDLIB_CLI_SCRIPTS
558 .iter()
559 .find_map(|entry| (entry.name == name).then_some(entry.source))
560}
561
562pub fn get_stdlib_prompt_asset(path: &str) -> Option<&'static str> {
563 let path = path.strip_prefix("std/").unwrap_or(path);
564 STDLIB_PROMPT_ASSETS
565 .iter()
566 .find_map(|entry| (entry.path == path).then_some(entry.source))
567}
568
569pub fn public_functions_for_module(module: &str) -> Vec<StdlibPublicFunction> {
570 let Some(source) = get_stdlib_source(module) else {
571 return Vec::new();
572 };
573 public_functions_from_source(source)
574}
575
576pub fn entrypoint_modules() -> Vec<StdlibEntrypointModule> {
577 STDLIB_SOURCES
578 .iter()
579 .filter_map(|entry| {
580 entrypoint_category_from_source(entry.source).map(|category| StdlibEntrypointModule {
581 import_path: format!("std/{}", entry.module),
582 category,
583 })
584 })
585 .collect()
586}
587
588fn entrypoint_category_from_source(source: &str) -> Option<String> {
589 for line in source.lines() {
590 let line = line.trim();
591 if line.is_empty() {
592 continue;
593 }
594 if let Some(category) = line.strip_prefix("// @harn-entrypoint-category ") {
595 let category = category.trim();
596 return (!category.is_empty()).then(|| category.to_string());
597 }
598 if !line.starts_with("//") {
599 return None;
600 }
601 }
602 None
603}
604
605fn public_functions_from_source(source: &str) -> Vec<StdlibPublicFunction> {
606 let mut out = Vec::new();
607 let mut doc: Option<String> = None;
608 let lines = source.lines().collect::<Vec<_>>();
609 let mut index = 0usize;
610 while index < lines.len() {
611 let line = lines[index].trim();
612 if line.starts_with("/**") {
613 let (parsed, next) = parse_harndoc(&lines, index);
614 doc = parsed;
615 index = next;
616 continue;
617 }
618 if line.starts_with("pub fn ") {
619 let (signature_line, next) = collect_public_function_signature(&lines, index);
620 if let Some(function) = parse_public_function_line(&signature_line, doc.take()) {
621 out.push(function);
622 index = next;
623 continue;
624 }
625 }
626 if let Some(function) = parse_public_function_line(line, doc.take()) {
627 out.push(function);
628 } else if !line.is_empty() && !line.starts_with("//") {
629 doc = None;
630 }
631 index += 1;
632 }
633 out
634}
635
636fn collect_public_function_signature(lines: &[&str], start: usize) -> (String, usize) {
637 let mut parts = Vec::new();
638 let mut index = start;
639 while index < lines.len() {
640 parts.push(lines[index].trim().to_string());
641 let candidate = parts.join(" ");
642 if public_function_signature_complete(&candidate) {
643 return (candidate, index + 1);
644 }
645 index += 1;
646 }
647 (parts.join(" "), index)
648}
649
650fn public_function_signature_complete(line: &str) -> bool {
651 let Some(rest) = line.strip_prefix("pub fn ") else {
652 return false;
653 };
654 let Some((_, after_paren)) = rest.split_once('(') else {
655 return false;
656 };
657 matching_paren_len(after_paren).is_some()
658}
659
660fn parse_harndoc(lines: &[&str], start: usize) -> (Option<String>, usize) {
661 let mut parts = Vec::new();
662 let mut index = start;
663 while index < lines.len() {
664 let mut line = lines[index].trim();
665 if index == start {
666 line = line.trim_start_matches("/**").trim();
667 }
668 let done = line.ends_with("*/");
669 line = line.trim_end_matches("*/").trim();
670 line = line.trim_start_matches('*').trim();
671 if !line.is_empty() {
672 parts.push(line.to_string());
673 }
674 index += 1;
675 if done {
676 break;
677 }
678 }
679 let text = parts.join("\n").trim().to_string();
680 ((!text.is_empty()).then_some(text), index)
681}
682
683#[expect(
684 clippy::string_slice,
685 reason = "bounds come from str::find and char_indices"
686)]
687fn parse_public_function_line(line: &str, doc: Option<String>) -> Option<StdlibPublicFunction> {
688 let rest = line.strip_prefix("pub fn ")?.trim();
689 let name_end = rest.find('(')?;
690 let name = rest[..name_end].trim();
691 if name.is_empty() {
692 return None;
693 }
694 let params_start = name_end + 1;
695 let params_len = matching_paren_len(&rest[params_start..])?;
696 let params = &rest[params_start..params_start + params_len];
697 let after = rest[params_start + params_len + 1..].trim();
698 let return_type = after
699 .strip_prefix("->")
700 .and_then(|tail| tail.split('{').next())
701 .map(str::trim)
702 .filter(|value| !value.is_empty());
703 let signature = match return_type {
704 Some(ret) => format!("{name}({params}) -> {ret}"),
705 None => format!("{name}({params})"),
706 };
707 let param_parts = split_top_level_params(params);
708 let total_params = param_parts
709 .iter()
710 .filter(|param| !param.trim().is_empty())
711 .count();
712 let variadic = param_parts
713 .iter()
714 .any(|param| param.trim_start().starts_with("..."));
715 let required_params = param_parts
716 .iter()
717 .filter(|param| {
718 let param = param.trim();
719 !param.is_empty() && !param.contains('=') && !param.starts_with("...")
720 })
721 .count();
722 Some(StdlibPublicFunction {
723 name: name.to_string(),
724 signature,
725 required_params,
726 total_params,
727 variadic,
728 doc,
729 })
730}
731
732fn matching_paren_len(input: &str) -> Option<usize> {
733 let mut depth = 1usize;
734 for (offset, ch) in input.char_indices() {
735 match ch {
736 '(' | '[' | '{' => depth += 1,
737 ')' | ']' | '}' => {
738 depth = depth.saturating_sub(1);
739 if depth == 0 {
740 return Some(offset);
741 }
742 }
743 _ => {}
744 }
745 }
746 None
747}
748
749#[expect(
750 clippy::string_slice,
751 reason = "offsets come from char_indices and 1-byte ','"
752)]
753fn split_top_level_params(params: &str) -> Vec<&str> {
754 let mut out = Vec::new();
755 let mut depth = 0isize;
756 let mut start = 0usize;
757 for (offset, ch) in params.char_indices() {
758 match ch {
759 '(' | '[' | '{' => depth += 1,
760 ')' | ']' | '}' => depth -= 1,
761 ',' if depth == 0 => {
762 out.push(¶ms[start..offset]);
763 start = offset + 1;
764 }
765 _ => {}
766 }
767 }
768 out.push(¶ms[start..]);
769 out
770}
771
772#[cfg(test)]
773mod tests {
774 use std::collections::BTreeSet;
775
776 use super::{
777 entrypoint_modules, find_cli_script, get_stdlib_prompt_asset, get_stdlib_source,
778 matching_paren_len, parse_public_function_line, public_functions_for_module,
779 STDLIB_CLI_SCRIPTS, STDLIB_PROMPT_ASSETS, STDLIB_SOURCES,
780 };
781
782 #[test]
783 fn stdlib_sources_are_non_empty() {
784 for entry in STDLIB_SOURCES {
785 assert!(
786 !entry.source.trim().is_empty(),
787 "{} should have non-empty source",
788 entry.module
789 );
790 }
791 }
792
793 #[test]
794 fn cli_scripts_are_non_empty_and_uniquely_named() {
795 let mut seen = BTreeSet::new();
796 for entry in STDLIB_CLI_SCRIPTS {
797 assert!(
798 !entry.source.trim().is_empty(),
799 "cli/{} should have non-empty source",
800 entry.name
801 );
802 assert!(
803 seen.insert(entry.name),
804 "cli/{} is registered more than once in STDLIB_CLI_SCRIPTS",
805 entry.name
806 );
807 }
808 }
809
810 #[test]
811 fn find_cli_script_round_trips() {
812 for entry in STDLIB_CLI_SCRIPTS {
813 assert_eq!(find_cli_script(entry.name), Some(entry.source));
814 }
815 assert!(find_cli_script("not-a-real-script").is_none());
816 }
817
818 #[test]
819 fn stdlib_source_names_are_unique() {
820 let mut names = BTreeSet::new();
821 for entry in STDLIB_SOURCES {
822 assert!(names.insert(entry.module), "duplicate {}", entry.module);
823 }
824 }
825
826 #[test]
827 fn stdlib_prompt_assets_are_non_empty() {
828 for entry in STDLIB_PROMPT_ASSETS {
829 assert!(
830 !entry.source.trim().is_empty(),
831 "{} should have non-empty prompt asset source",
832 entry.path
833 );
834 }
835 }
836
837 #[test]
838 fn stdlib_prompt_asset_paths_are_unique() {
839 let mut paths = BTreeSet::new();
840 for entry in STDLIB_PROMPT_ASSETS {
841 assert!(paths.insert(entry.path), "duplicate {}", entry.path);
842 }
843 }
844
845 #[test]
846 fn key_stdlib_modules_resolve() {
847 for module in [
848 "context",
849 "context/maintenance",
850 "context/eval",
851 "eval/stats",
852 "eval/remote_fanout",
853 "eval/agreement",
854 "edit",
855 "verification",
856 "disclosure",
857 "artifact/web",
858 "command",
859 "waitpoint",
860 "llm/handlers",
861 "media/asset",
862 "media/composition",
863 "model_job",
864 "model_job/contracts",
865 "model_job/runtime",
866 "model_job/testing",
867 "model_job/comfyui",
868 "model_job/openai",
869 "ui",
870 "ui/contracts",
871 "ui/renderer",
872 "ui/testing",
873 "llm/tool_middleware",
874 "llm/tool_binder",
875 "llm/missing_tool_call",
876 "llm/tool_shape",
877 "llm/dialects",
878 "llm/ensemble",
879 "llm/rerank",
880 "personas/prelude",
881 "personas/bulletins",
882 "agent/host_tools",
883 "agent/host_injection",
884 "agent/tool_lifecycle",
885 "agent/user",
886 "agent/governors",
887 "agent/loop_post_turn",
888 "agent/completion_gate",
889 "agent/guardrails",
890 "cli",
891 "cli/envelope",
892 "cli/models/batch_artifacts",
893 "cli/models/batch_cancel",
894 "cli/models/batch_download",
895 "cli/models/batch_lifecycle",
896 "cli/models/batch_rejoin",
897 "cli/models/batch_status",
898 "cli/models/batch_submit",
899 "cli/models/batch_transport",
900 "cli/models/lora_render",
901 "llm/optimize",
902 "llm/judge",
903 "llm/faithfulness",
904 "llm/refine",
905 "connectors/shared",
906 "connectors/github",
907 "connectors/linear",
908 "connectors/notion",
909 "connectors/slack",
910 "triage",
911 "dashboard/jobs",
912 "ui_resource",
913 "host_conditions",
914 "host_lease",
915 ] {
916 assert!(
917 get_stdlib_source(module).is_some(),
918 "std/{module} should resolve"
919 );
920 }
921 }
922
923 #[test]
924 fn key_stdlib_prompt_assets_resolve() {
925 for path in [
926 "std/agent/prompts/tool_contract_text.harn.prompt",
927 "std/agent/prompts/default_nudge.harn.prompt",
928 "std/agent/prompts/completion_judge_default.harn.prompt",
929 "std/workflow/prompts/stage.harn.prompt",
930 "std/orchestration/prompts/compaction_summary.harn.prompt",
931 "std/orchestration/prompts/compaction_policy_extension.harn.prompt",
932 "std/orchestration/prompts/compaction_policy_replacement.harn.prompt",
933 "std/orchestration/prompts/compaction_state_grounding.harn.prompt",
934 ] {
935 assert!(
936 get_stdlib_prompt_asset(path).is_some(),
937 "{path} should resolve"
938 );
939 }
940 }
941
942 #[test]
943 fn public_function_catalog_derives_signatures_from_harn_source() {
944 let exports = public_functions_for_module("workflow/execute");
945 assert_eq!(exports.len(), 1);
946 assert_eq!(exports[0].name, "workflow_execute");
947 assert_eq!(
948 exports[0].signature,
949 "workflow_execute(harness: Harness, task, graph, artifacts = nil, options = nil)"
950 );
951 assert_eq!(exports[0].required_params, 3);
952 assert_eq!(exports[0].total_params, 5);
953 }
954
955 #[test]
956 fn command_stdlib_module_exports_step_helpers() {
957 let exports = public_functions_for_module("command")
958 .into_iter()
959 .map(|function| function.name)
960 .collect::<BTreeSet<_>>();
961 for name in [
962 "command_run",
963 "command_wait",
964 "command_wait_for_output",
965 "command_cancel",
966 "command_run_streaming",
967 "command_output_tail",
968 "command_json",
969 "command_json_step",
970 "command_try",
971 "command_step",
972 "command_steps_append",
973 "command_last_failed_step",
974 "command_step_ref",
975 "command_output_text",
976 "argv_label",
977 "shell_command_from_argv",
978 "shell_command_from_value",
979 ] {
980 assert!(exports.contains(name), "std/command should export {name}");
981 }
982 }
983
984 #[test]
985 fn disclosure_stdlib_module_exports_render_helpers() {
986 let exports = public_functions_for_module("disclosure")
987 .into_iter()
988 .map(|function| function.name)
989 .collect::<BTreeSet<_>>();
990 assert!(
991 exports.contains("render"),
992 "std/disclosure should export render"
993 );
994 assert!(
995 exports.contains("git_trailers"),
996 "std/disclosure should export git_trailers"
997 );
998 assert!(
999 exports.contains("slack_message_disclosure"),
1000 "std/disclosure should export slack_message_disclosure"
1001 );
1002 assert!(
1003 exports.contains("append_git_trailers"),
1004 "std/disclosure should export append_git_trailers"
1005 );
1006 }
1007
1008 #[test]
1009 fn async_stdlib_exports_predicate_backoff_name_only() {
1010 let exports = public_functions_for_module("async")
1011 .into_iter()
1012 .map(|function| function.name)
1013 .collect::<BTreeSet<_>>();
1014 assert!(
1015 exports.contains("retry_predicate_with_backoff"),
1016 "std/async should export retry_predicate_with_backoff"
1017 );
1018 assert!(
1019 !exports.contains("retry_with_backoff"),
1020 "std/async should not retain the old retry_with_backoff export"
1021 );
1022 }
1023
1024 #[test]
1025 fn signal_stdlib_module_exports_interrupt_helpers() {
1026 let exports = public_functions_for_module("signal")
1027 .into_iter()
1028 .map(|function| function.name)
1029 .collect::<BTreeSet<_>>();
1030 for name in [
1031 "on_interrupt",
1032 "off_interrupt",
1033 "interrupted",
1034 "with_interrupt",
1035 ] {
1036 assert!(exports.contains(name), "std/signal should export {name}");
1037 }
1038 }
1039
1040 #[test]
1041 fn git_stdlib_module_exports_local_wrappers() {
1042 let exports = public_functions_for_module("git")
1043 .into_iter()
1044 .map(|function| function.name)
1045 .collect::<BTreeSet<_>>();
1046 for name in [
1047 "git_run",
1048 "git_status",
1049 "git_current_branch",
1050 "git_log",
1051 "git_switch",
1052 "git_pull_ff_only",
1053 "git_find_tool",
1054 "git_run_tool",
1055 "git_tools",
1056 "git_toolbox_tools",
1057 ] {
1058 assert!(exports.contains(name), "std/git should export {name}");
1059 }
1060 }
1061
1062 #[test]
1063 fn agent_workers_exports_suspend_resume_wrappers() {
1064 let exports = public_functions_for_module("agent/workers");
1065 let suspend = exports
1066 .iter()
1067 .find(|function| function.name == "suspend_agent")
1068 .expect("std/agent/workers should export suspend_agent");
1069 assert_eq!(
1070 suspend.signature,
1071 "suspend_agent(agents: HarnessAgent, worker, reason = \"\", options = nil)"
1072 );
1073 assert_eq!(suspend.required_params, 2);
1074 assert_eq!(suspend.total_params, 4);
1075
1076 let resume = exports
1077 .iter()
1078 .find(|function| function.name == "resume_agent")
1079 .expect("std/agent/workers should export resume_agent");
1080 assert_eq!(
1081 resume.signature,
1082 "resume_agent( agents: HarnessAgent, worker_or_snapshot, resume_input = nil, continue_transcript = true, ) -> any"
1083 );
1084 assert_eq!(resume.required_params, 2);
1085 assert_eq!(resume.total_params, 4);
1086
1087 let stop = exports
1088 .iter()
1089 .find(|function| function.name == "agent_stop")
1090 .expect("std/agent/workers should export agent_stop");
1091 assert_eq!(
1092 stop.signature,
1093 "agent_stop(agents: HarnessAgent, worker, options: AgentStopOptions? = nil)"
1094 );
1095 assert_eq!(stop.required_params, 2);
1096 assert_eq!(stop.total_params, 3);
1097
1098 let parse_resume = exports
1099 .iter()
1100 .find(|function| function.name == "parse_resume_conditions")
1101 .expect("std/agent/workers should export parse_resume_conditions");
1102 assert_eq!(
1103 parse_resume.signature,
1104 "parse_resume_conditions(agents: HarnessAgent, conditions = nil) -> ResumeConditions?"
1105 );
1106 assert_eq!(parse_resume.required_params, 1);
1107 assert_eq!(parse_resume.total_params, 2);
1108
1109 let lifecycle = exports
1110 .iter()
1111 .find(|function| function.name == "agent_lifecycle_tools")
1112 .expect("std/agent/workers should export agent_lifecycle_tools");
1113 assert_eq!(
1114 lifecycle.signature,
1115 "agent_lifecycle_tools(agents: HarnessAgent, registry = nil, options = nil)"
1116 );
1117 assert_eq!(lifecycle.required_params, 1);
1118 assert_eq!(lifecycle.total_params, 3);
1119 }
1120
1121 #[test]
1122 fn tui_stdlib_module_exports_terminal_helpers() {
1123 let exports = public_functions_for_module("tui")
1124 .into_iter()
1125 .map(|function| function.name)
1126 .collect::<BTreeSet<_>>();
1127 for name in ["page", "terminal_width", "rule", "clear", "select_from"] {
1128 assert!(exports.contains(name), "std/tui should export {name}");
1129 }
1130 }
1131
1132 #[test]
1133 fn semver_stdlib_module_exports_release_helpers() {
1134 let exports = public_functions_for_module("semver")
1135 .into_iter()
1136 .map(|function| function.name)
1137 .collect::<BTreeSet<_>>();
1138 for name in [
1139 "strip_v",
1140 "add_v",
1141 "is_v_semver",
1142 "is_v_release_semver",
1143 "parse",
1144 "parse_release",
1145 "is_prerelease_identifier",
1146 "is_prerelease",
1147 "compare_release",
1148 "max_canonical_tag",
1149 "next",
1150 "bump_type",
1151 "version_from_release_branch",
1152 "version_from_tag",
1153 ] {
1154 assert!(exports.contains(name), "std/semver should export {name}");
1155 }
1156 }
1157
1158 #[test]
1159 fn changelog_stdlib_module_exports_typed_primitives() {
1160 let exports = public_functions_for_module("changelog")
1161 .into_iter()
1162 .map(|function| function.name)
1163 .collect::<BTreeSet<_>>();
1164 for name in [
1165 "changelog_validate_categories",
1166 "changelog_parse_fragment",
1167 "changelog_order_fragments",
1168 "changelog_normalize_fragment_body",
1169 "changelog_assemble_fragments",
1170 "changelog_parse_sections",
1171 "changelog_find_section",
1172 "changelog_merge_unreleased",
1173 ] {
1174 assert!(exports.contains(name), "std/changelog should export {name}");
1175 }
1176 }
1177
1178 #[test]
1179 fn text_stdlib_module_exports_regex_and_pad_helpers() {
1180 let exports = public_functions_for_module("text")
1181 .into_iter()
1182 .map(|function| function.name)
1183 .collect::<BTreeSet<_>>();
1184 for name in [
1185 "pad_left",
1186 "pad_right",
1187 "repeat_string",
1188 "regex_first_capture",
1189 "regex_capture_groups",
1190 "regex_all_first_captures",
1191 ] {
1192 assert!(exports.contains(name), "std/text should export {name}");
1193 }
1194 }
1195
1196 #[test]
1197 fn harn_entrypoint_catalog_is_declared_by_stdlib_sources() {
1198 let modules = entrypoint_modules();
1199 let entries = modules
1200 .iter()
1201 .map(|module| (module.import_path.as_str(), module.category.as_str()))
1202 .collect::<BTreeSet<_>>();
1203 for entry in [
1204 ("std/agent/loop", "agent.stdlib"),
1205 ("std/agent/primitives", "agent.stdlib"),
1206 ("std/workflow/execute", "workflow.stdlib"),
1207 ] {
1208 assert!(entries.contains(&entry), "{entry:?} should be declared");
1209 }
1210 }
1211
1212 #[test]
1213 fn matching_paren_len_closes_on_every_bracket_kind() {
1214 assert_eq!(matching_paren_len("a, b)"), Some(4));
1217 assert_eq!(matching_paren_len("x: [int])"), Some(8));
1218 assert_eq!(matching_paren_len("x: {a: int})"), Some(11));
1219 assert_eq!(matching_paren_len("x]"), Some(1));
1222 assert_eq!(matching_paren_len("x}"), Some(1));
1223 assert_eq!(matching_paren_len("unterminated"), None);
1224 }
1225
1226 #[test]
1227 fn parse_public_function_line_handles_record_typed_params() {
1228 let parsed =
1229 parse_public_function_line("pub fn configure(opts: {retries: int}) -> bool", None)
1230 .expect("signature with a record-typed parameter should parse");
1231 assert_eq!(parsed.name, "configure");
1232 assert_eq!(parsed.signature, "configure(opts: {retries: int}) -> bool");
1233 assert_eq!(parsed.total_params, 1);
1234 assert_eq!(parsed.required_params, 1);
1235 }
1236}