paybondpaybond
Sign in

TypeScript example projects

Runnable TypeScript examples for Paybond Kit — core SDK, agent middleware, and framework adapters.

Paybond ships runnable TypeScript examples under examples/ in the repository. Use them as reference implementations when you want a complete application structure beyond the TypeScript quickstart.

Each example uses a repo-local file:../../kit/ts dependency so SDK and example changes can be tested together. External apps should install the published package with npm install @paybond/kit instead.

Example catalog

ExamplePathWhat it demonstrates
Core Kit sessionexamples/paybond-kit-typescript/Paybond.open and verifyCapability against a hosted session
Runtime-neutral adapterexamples/paybond-kit-runtime-agent-typescript/Intent create → capability verify → guarded tool execute → evidence
Agent-agnostic middlewareexamples/paybond-kit-agent-middleware-typescript/createPaybondGenericAgentConfig with registry, bind, and auto-evidence
LangGraphexamples/paybond-kit-langgraph-typescript/paybondToolNode / paybondAwrapToolCall on the ToolNode boundary
Vercel AI SDKexamples/paybond-kit-vercel-ai-typescript/paybondVercelToolApproval and paybondVercelWrapTools with mock model
OpenAI Agents SDKexamples/paybond-kit-openai-agents-typescript/Input guardrails and wrapped invoke on function tools
Claude Agent SDKexamples/paybond-kit-claude-agents-typescript/createPaybondClaudeAgentsConfig for in-process MCP tools
MastraSmoke via CLI and templates/paybond-mastra-travel-agent/createPaybondMastraConfig on createTool execute — use paybond agent demo mastra smoke
Cloudflare AgentsSmoke via CLIcreatePaybondCloudflareAgentsConfig on AI SDK tool() execute — use paybond agent demo cloudflare-agents smoke

Choose an example

New to Paybond Kit? Start with paybond-kit-typescript for the minimal session shape, then read paybond-kit-runtime-agent-typescript for the full intent lifecycle.

Adding spend controls to an agent? Pick the row that matches your runtime:

CLI smoke commands

Most middleware examples have a matching CLI smoke check that runs without a live LLM:

paybond login   # optional for sandbox; required for real API

# Agent-agnostic
paybond agent demo generic smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# LangGraph
paybond agent demo langgraph smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Vercel AI
paybond agent demo vercel-ai smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# OpenAI Agents
paybond agent demo openai-agents smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Claude Agents
paybond agent demo claude-agents smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Mastra (requires @mastra/core)
npm install @paybond/mastra @mastra/core
paybond agent demo mastra smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

# Cloudflare Agents (requires agents and ai peers)
npm install @paybond/cloudflare-agents agents ai
paybond agent demo cloudflare-agents smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format json

For the fastest local path without an API key, use paybond dev loop --offline — see Agent quickstart.

Cloneable starter templates

For greenfield apps, use standalone templates under templates/ (published @paybond/kit only) or scaffold locally:

paybond init --template travel-agent
paybond init --template vercel-shopping-agent --force
paybond init --template mastra-travel-agent --framework mastra

Each template includes paybond.policy.yaml, .env.example, npm run smoke, and a GitHub Actions workflow. See the templates README for the full catalog.

Running from a source checkout

Each example directory includes a README with setup steps. The usual pattern:

cd examples/<example-name>
npm install
npm run build --prefix ../../kit/ts   # first time or after SDK changes
npm run build
npm start

Middleware examples typically need PAYBOND_API_KEY from paybond login or PAYBOND_API_KEY=pb_test_sandbox with a mock Gateway. The runtime-neutral example additionally documents APP_* env vars for intent create and evidence signing — see its README.

What these examples are for

  • Understanding the public SDK in a complete end-to-end flow.
  • Seeing how capability verification wraps side-effecting tools before execution.
  • Copying proven patterns for registry bind, auto-evidence, and session cleanup.
  • Validating a framework adapter in CI with the matching paybond agent demo … smoke command.

For most teams, follow the TypeScript quickstart or Agent quickstart first, then open the example that matches your stack.