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