Skip to content

Examples

The examples package is the executable companion to these docs. Each example exports an AML tree; the shared runner creates an AmlRuntime, attaches the console tracer, and evaluates the selected workflow.

Clone the repository and install its dependencies first. The examples use built package exports; npm run example builds its dependencies through the repository task runner.

Terminal
git clone https://github.com/we-are-singular/aml.git
cd aml
npm ci

From that repository root:

Terminal
npm run example --
npm run example -- review
npm run example -- structured
npm run example -- agent-team

The first command prints the current filename-derived catalog. Treat that output and examples/run.ts as the source of truth; this page deliberately recommends paths instead of duplicating every filename.

The root npm run example command loads .env when present. Its task environment forwards AML_*, OPENCODE_API_KEY, OPENAI_API_KEY, and Z_AI_API_KEY; export or store the credentials required by the selected example without committing them. Existing shell variables take precedence over .env. Use absolute paths for input files and evidence directories because the runner executes inside the examples package.

If you installed with --ignore-scripts, deterministic examples can run while a native executable is still unprepared. Before live OpenCode examples, verify the repository installation with npm exec -- opencode --version; run npm rebuild opencode-ai if it reports that its postinstall script was skipped.

Each maintained example also exports an AML tree, so the experimental CLI can run one source file directly. Build the repository CLI and try the credential-free basic example:

Terminal
npm run build
node apps/cli/dist/index.js run ./examples/src/core/basic.tsx

The shared example runner remains useful for its catalog and common tracer. Use the CLI guide when your own workflow should expose a default or named export without a separate application entry point.

Triage an issue with Pi

Run pi-issue-triage with AML_ISSUE_FILE and Pi model credentials to classify issue text, propose labels, and draft a reply. It prints a proposal without posting to an issue tracker.

Build the Pi issue-triage workflow

Analyze a repository with GLM

Run glm-repository-analysis with AML_REPOSITORY_DIRECTORY, Z.ai credentials, and Docker to analyze a README and package manifest, verify quoted evidence, and generate an onboarding report.

Build the GLM repository-analysis workflow

The filename runner covers core, capabilities, resources, and integrations. Files under operations use their own entrypoints and are not names accepted by npm run example:

Terminal
# Credential-free application tracing; this script owns its runtime.
npx vite-node examples/src/operations/trace-summaries.tsx
# Credential-free local process lifecycle; interrupt with Ctrl+C as the recipe explains.
npm run aml -- run ./examples/src/operations/cli-process-safety.tsx --trace

The live Agent activity recipe supplies the separate OpenCode command and credentials for observe-agent.tsx.

Run the maintained deterministic examples as tests with npm run test --workspace=@aml-jsx/examples after npm run build. Their snapshots verify resolved output; they do not establish live model quality or external-provider compatibility.

The runner also discovers credentialed Agent examples and resource-backed Sandbox or Workspace examples. List the catalog first, then inspect the selected source before running it.

  • Deterministic examples use fixtures from @aml-jsx/sdk/testing. They demonstrate AML contracts without claiming that a live model behaves identically.
  • Credentialed examples start a real Agent adapter and can require an executable, model account, network access, and provider-specific environment variables.
  • Resource-backed examples use a local directory, Docker daemon, or remote Sandbox. Their source owns the mutation and cleanup notes for that exact workflow.
  • Fixture examples model a boundary without contacting the described service. The MCP example, for example, carries descriptor metadata but does not connect to its placeholder URL.

For copyable, task-oriented walkthroughs with prerequisites and expected output, continue to the Cookbook.