Skip to content

AI agent workflow examples in TypeScript

Build useful AML workflows one task at a time

AML is easiest to learn by building a workflow with a clear job to do. This cookbook moves from a credential-free review pipeline to typed outputs, application <Tool /> capabilities, scoped <Mcp /> access, filesystem resources, durable provider composition, and operational jobs.

Type reusable components with AML.Component<Props>. Import AML as a type from @aml-jsx/sdk; add AML.PropsWithChildren<Props> for optional nested content or AML.PropsWithRequiredChildren<Props> for required children.

Start with Getting started for SDK installation, the JSX runtime configuration, and a runner. Recipes build on that setup and focus on AML component design: what belongs in the tree, what application code must validate, and who owns capabilities, resources, and results. Each recipe lists only its additional dependencies and environment requirements.

@aml-jsx/sdk/testing is an import path included in the SDK, not a separately installable package. Install zod for schema examples and vitest as a development dependency for test examples. A code block labeled “Complete source” is intended to run with its stated prerequisites; smaller blocks illustrate changes to that source or require the surrounding application’s values.

Recipes show an application entrypoint that constructs and evaluates an AmlRuntime; some separate that entrypoint from a reusable workflow file. The maintained examples also support the shared repository runner. To run a workflow with the experimental CLI instead, export the AML tree, put required providers directly on their components, and use npx aml run ./workflow.tsx. Do not wrap a second AmlRuntime inside the exported CLI entry.

Each recipe opens with its goal and, where useful, badges that tell you what to prepare:

  • No credentials needed runs without a model account. It may still use local files or Docker, as the prerequisites explain.
  • Agent authentication required needs a configured live Agent. Recipes that specifically require an API key say so.
  • Docker required needs a running Docker daemon. Other resource badges name the required service or local files.

Comparison guides may have no badges. Check each recipe’s prerequisites for the complete setup and its notes on file changes and isolation.

Recipe steps and claims are verified against the implementation and specification links in each page’s API and source links section.

RecipeStatusNeedsBest for
Pi issue triageCredentialed; optional DockerPi, ACP and MCP adapters, model credentials, issue JSONLabel proposals and maintainer reply drafts
GLM repository analysisCredentialed + DockerGLM image, Z.ai credentials, README and package manifestEvidence-backed onboarding reports
Auto-authored changelogCredentialed + repository-backedScript collector, Agent provider, schemas, and a document writerComposable Agents around deterministic release work
Code-review workflowDeterministic by default; credentialed by opt-inNode, SDK, zod; provider executable and credentials only for OpenCode/Codex modesA first useful multi-Agent workflow
Structured outputDeterministicNode, SDK, zodTyped findings and validation boundaries
ToolsDeterministicNode, SDK/testing, zodApplication-owned functions and capability scoping
RecipeStatusNeedsBest for
Testing AML workflowsDeterministicNode, SDK/testing, VitestReplacing runtime defaults and asserting capability/resource behavior
MCP capabilitiesDeterministic fixtureNode, SDK/testing; no MCP server or credentialsCapability isolation without pretending to run an external server
Tool or MCP?Deterministic Tool + credentialed MCP exampleNode and SDK; OpenCode, credentials, and an operated MCP server for the MCP pathChoosing the correct capability boundary
Sandbox imageResource-backedNode, SDK, Docker, and AML Agent SandboxUnderstanding image defaults and overrides
Sandboxes and WorkspacesDeterministic + resource-backedNode, SDK/testing, writable temp directoryLocal file materialization and execution-scope composition
Generated diagnosticsDeterministic Agent + resource-backedNode, SDK/testing, Docker, and the selected interpreter imageTreating generated code as data before explicit execution
RecipeStatusNeedsBest for
Production jobCredentialed + deployment shapeNode/ESM TSX runtime, OpenCode executable, model configuration, credentials, and a loggerBackground jobs that need bounded execution and operational controls
CLI process safetyResource-backed, credential-freePOSIX host, local Sandbox, CLI, and one terminal interruptGraceful signal handling and process-tree cleanup
Agent activityCredentialedOpenCode executable, model credentials, and an approved content-capturing terminalUnderstanding live ACP activity across Agent turns
Application observabilityDeterministicNode, SDK, and application request contextCustom phase timing and concurrent run correlation
Codex + Docker + S3Credentialed + container + durable storageCodex ACP image, Docker, model credentials, S3 bucket, and AWS identityUnderstanding the complete three-provider lifecycle
Structured routingDeterministicNode, SDK/testing, zod, and an application-owned root directorySafely turning model-shaped data into resource selection

The production-job recipe needs a configured live provider. Supply the executable, credentials, and Sandbox/Workspace providers required by your deployment before running it.

Use deliberate editorial passes with FollowUp when several authored instructions should run in one provider session. The recipe explains what AML guarantees, what conversation history remains provider-owned, and when separate evaluations are clearer.

Each page follows the same reading order:

  1. Goal — the user task and the AML shape it produces.
  2. Prerequisites — credentials, executables, packages, and resource requirements.
  3. Complete source — imports included, with provider assumptions visible.
  4. Run and expected output — what is safe to execute and what success looks like, without repeating project setup.
  5. How it works — why the components are composed this way, with links to the relevant component references, concepts, and provider or image contracts.
  6. Failure and security notes — boundaries that should affect production decisions.
  7. API and source links — public contracts and the maintained repository example.

For the repository’s current runnable catalog, use the command on the Examples page. The runner remains the source of truth; the docs recommend paths by learning goal instead of maintaining a second export inventory.