API Reference PtcRunner v#0.12.0

Copy Markdown View Source

Modules

BEAM-native Programmatic Tool Calling (PTC) library.

Text chunking utilities for RLM preprocessing.

Manages context, memory, and tools for program execution.

Loads environment variables from .env files.

Interactive trace tree widget for Livebook.

Behaviour and convenience API for LLM adapters.

Default model registry with built-in aliases for common LLM providers.

Behaviour and unified interface for model resolution.

Built-in LLM adapter using req_llm.

Execute PTC programs written in Lisp DSL (Clojure subset).

AST node types for PTC-Lisp

Validates and desugars RawAST into CoreAST.

Conditional analysis for if, if-not, when, when-not, if-let, when-let, if-some, when-some, when-first, cond, case, and condp forms.

Definition analysis for def, defonce, and defn forms.

Iteration analysis for doseq and for comprehensions.

Pattern analysis and destructuring for let bindings and function parameters.

Analyzer for short function syntax (#()).

Leaf source of env-dispatched builtin names, loaded from priv/functions.exs at compile time.

Validates PTC-Lisp programs against Babashka/Clojure.

Scope-aware helpers for determining which names a closure body references.

Core, validated AST for PTC-Lisp.

Convert Core AST (the analyzed/desugared representation) back to PTC-Lisp source strings.

Static analysis to extract data keys accessed by a PTC-Lisp program.

Local REPL-style discovery for executable PTC-Lisp capabilities.

Builds the initial environment with builtins for PTC-Lisp.

Metadata wrapper for callable environment builtins.

Evaluates CoreAST into values.

Function application dispatch for Lisp evaluation.

Evaluation context for the Lisp interpreter.

Shared helper functions for Lisp evaluation.

A shared, lock-free slot semaphore bounding the number of parallel pmap/pcalls worker processes alive at once across a whole PtcRunner.Lisp.run/2.

Heap-capped, slot-bounded parallel execution of untrusted PTC-Lisp work (pmap/pcalls).

Pattern matching for let bindings in Lisp evaluation.

Exception used to signal execution errors during Lisp evaluation.

Format PTC-Lisp values for human/LLM display.

Serialize PTC-Lisp AST to source code string.

Runtime representation for PTC-Lisp keywords that are not in the bounded atom vocabulary.

Language specification compositions for PTC-Lisp.

Parser entry point for PTC-Lisp.

Single source of truth for PTC-Lisp function metadata.

Built-in functions for PTC-Lisp.

Shared runtime argument validation for Env builtin calls.

The manifest of PTC-Lisp builtin bindings exposed by the Runtime subsystem.

Dispatch helper for calling Lisp functions from Collection operations.

Collection operations for PTC-Lisp runtime.

Predicate and collection normalization helpers for collection operations.

Selection operations for PTC-Lisp collections: filter, remove, find, some, every?, not_any?, take_while, drop_while.

Transformation operations for PTC-Lisp collections: map, mapv, mapcat, keep, map_indexed.

Flexible key access helpers for PTC-Lisp runtime.

Simulated Java interop for PTC-Lisp.

JSON parsing and generation for PTC-Lisp.

Map operations for PTC-Lisp runtime.

Arithmetic operations for PTC-Lisp runtime.

Type predicates, numeric predicates, and logic operations for PTC-Lisp runtime.

Minimal, safe Regex support for PTC-Lisp. Uses Erlang's :re directly with match limits for ReDoS protection.

Unified handling for IEEE 754 special values (Infinity, NaN) in PTC-Lisp.

String manipulation and parsing operations for PTC-Lisp runtime.

Runtime callable for effectful qualified Lisp symbols.

Bounded vocabulary — the set of names the parser is allowed to intern as atoms.

Validates PTC-Lisp specification against implementation.

Counts unique user-defined symbols and keywords in a parsed Lisp AST.

Raised by Lisp runtime functions when arguments have the wrong type.

Statistical comparison functions for benchmark results.

Extracts per-turn interaction quality metrics from SubAgent execution results.

Standalone Mustache template parser and expander.

Compile-time utilities for loading prompt templates from files.

Centralized prompt loading for PtcRunner.

Wire-format source of truth for the lisp_eval tool surface.

Executes programs in isolated BEAM processes with resource limits.

Declarative schema module that defines all DSL operations.

Stateful PTC-Lisp session for embedding applications.

Result of executing a PTC program or SubAgent mission.

Agentic loop for LLM-driven PTC-Lisp execution.

Pure functions for resolving builtin tool families into tool maps.

Chaining functions for SubAgent pipelines.

Pressure-triggered context compaction for multi-turn agents.

Read-only context passed to compaction strategies.

Deterministic pressure-triggered trimming strategy.

A compiled SubAgent with pre-derived PTC-Lisp logic.

Compilation logic for SubAgents.

Debug helpers for visualizing SubAgent execution.

Struct and type definitions for SubAgent configuration.

Pure helpers for tool exposure resolution and filtering.

Extracts JSON from LLM responses, handling common formatting quirks.

Normalizes map keys at the tool boundary.

LLM resolution and invocation for SubAgents.

LLM-powered tools for classification, evaluation, and judgment.

Core agentic loop that manages LLM↔tool cycles.

Budget checking, callback handling, and fallback recovery for SubAgent execution.

Shared JSON response handling for text mode variants.

LLM retry logic with configurable backoff strategies.

Shared builder for PtcRunner.Lisp.run/2 opts across every loop transport.

Telemetry, tracing, and usage metrics for SubAgent execution.

Build LLM-facing native tool result previews for combined-mode agents.

Native tool-call transport handler for ptc_transport: :tool_call agents.

Response parsing and validation for LLM responses.

Return type validation for SubAgent execution.

Helpers shared across the loop drivers (Loop, TextMode, PtcToolCall, JsonHandler, StepAssembler).

Typed state struct for the SubAgent execution loop.

Final step assembly for SubAgent execution.

Unified execution loop for text output mode.

Tool preparation and wrapping for SubAgent execution.

Turn feedback formatting for SubAgent execution.

Renders namespaces for the USER message (REPL with Prelude model).

Renders the data/ namespace section.

Renders tool call history and println output.

Shared sample-value formatting for namespace renderers.

Renders available tools for the USER message namespace section.

Converts Elixir values to human-readable type labels.

Renders the user/ namespace section (LLM-defined functions and values).

Renders a markdown checklist from plan steps and summaries.

Template string expansion with placeholder validation.

Internal execution boundary for %PtcRunner.SubAgent.Definition{} agents.

Sigils for SubAgent templates.

Signature parsing and validation for SubAgents.

Coerce values to expected types with warning generation.

NimbleParsec-based parser for signature strings.

Helper functions for signature parser AST building.

Renders signatures back to string representation.

Resolve paths against parsed signature types.

Validates data against signature type specifications.

Wraps a SubAgent as a callable tool for parent agents.

System prompt generation for SubAgent LLM interactions.

Expected output section generation for SubAgent prompts.

Telemetry event emission for SubAgent execution.

Converts Tool structs to OpenAI-format JSON Schema tool definitions.

Extract signature and description from Elixir function @spec and @doc.

Wraps untrusted content in data-only envelopes for LLM feedback.

Validates SubAgent options at construction time.

Exception raised by SubAgent.run!/2 and SubAgent.then!/2 when execution fails.

Represents a template with extracted placeholders.

Normalize Elixir temporal structs (DateTime, NaiveDateTime, Date, Time) to ISO 8601 strings before they cross any boundary into LLM-visible territory.

Normalized tool definition for PTC-Lisp and SubAgent.

Exception raised when a tool execution fails.

Centralizes process dictionary access for tracing context.

Captures SubAgent execution events to JSONL files for offline analysis.

Offline analysis of trace log files.

GenServer that collects trace events and writes them to a JSONL file.

Builds v2 flat event envelopes for trace logging.

Telemetry handler that captures SubAgent events for trace logging.

Immutable trace recorder for SubAgent execution.

Text-based timeline visualization for execution traces.

Captures a single LLM interaction cycle in a SubAgent execution.

High-level Lisp orchestration over the upstream runtime.

Transport-neutral upstream call result helpers.

OTP-backed upstream runtime handle for root ptc_runner callers.

Behaviour for root-owned upstream client transports.

Mix Tasks

Checks deterministic PTC-Lisp eval metrics against a committed baseline.

Run the parallel workers (LLM-orchestrated map-reduce) example.

Checks that conformance audit rows point at symbols/members that exist in local upstream runtimes.

Generates markdown reports comparing PTC-Lisp builtins against Clojure and Java namespaces.

Prints a coverage report for explicit PTC-Lisp conformance cases.

Thin wrapper around mix ex_dna that dispatches to the root project or one of the sibling Mix projects (mcp_server, ptc_viewer).

Generates documentation from priv/functions.exs (implemented + interop), priv/function_audit.exs (Clojure/Java Math parity triage notes), and priv/java_compat_audit.exs (curated Java compatibility targets)

Installs Babashka for Clojure validation.

Starts an interactive REPL for testing PTC-Lisp expressions.

Runs .clj files through both PTC-Lisp and Babashka/Clojure, comparing results.

Regenerates the spec checksums file for drift detection.

Validates PTC-Lisp specification against implementation.

Runs the local release-readiness smoke checks used before pushing a release tag.