Inspiration

AI agents now shop and pay on our behalf, and every listing, chat and article they read can carry hidden instructions. One planted line in a product description can turn a $60 birthday gift into a $419.96 cart. We wanted a setup where the person writes the limits in plain words, PayPal holds the money, and a check that no prompt can talk past decides every move the agent makes.

The first version of the idea was a single "Permission Slip" for a shopping agent. It grew into seven pipelines on the same engine, and PaySmart became the front door: you say what you need, and it does the shopping.

What it does

PaySmart turns an ask like "a dinosaur gift and a birthday card, under $60" into carts a guard has checked.

  1. Say it. Type the ask or dictate it with the browser's Web Speech API.
  2. Search. PaySmart runs one visible search per need. Each search shows its query, where it ran (Channel3 or an offline catalog), how many listings came back, how many the screens dropped, and why.
  3. Screen. Every result passes an integrity screen (hidden instructions in listing text), a seller screen (scam tactics in seller text) and a slip screen (your own clauses) before the agent sees it.
  4. Pick. An agent builds up to 3 carts from the screened pool. The guard stamps each one WITHIN, OUTSIDE or ASK, and you choose. The default demo cart is Clockwork Rex plus a Pop-Up T-Rex Birthday Card at $47.17.
  5. Pay. PayPal holds exactly that cart's total and captures it. A delivery photo that breaks a clause triggers a refund.

The engine inside is Permission Slip. Your plain-words mandate is compiled into numbered clauses (c1, c2, ...) of 10 kinds, such as budget_max, deliver_by and exclude_attribute. You sign the slip with PayPal. A deterministic guard then checks every proposal against the clauses, and every verdict and PayPal call goes into a hash-chained ledger, one chain per slip, that anyone can re-verify. In the browser, Guard Lab re-runs the guard on edited facts and Chain Lab re-hashes the ledger, so a tampered event turns the chain red.

Asks that are not shopping go to the pipeline built for them, with no slip and no PayPal call: Second Look (a scam interceptor that offers a protected payment), Bounty Board (photo-verified payouts for small jobs), Cash Weather (a 13-week forecast and invoice reminders), Toll Road (HTTP 402 pay-per-fetch for research agents) and Dispute Desk (dispute answers drafted from slip evidence).

How we built it

  • Stack: Next.js 16, React 19, Tailwind 4, TypeScript, SQLite through node:sqlite, zod for validation, Vitest for tests. Node 22.13 or newer.
  • Guard: a pure function from (slip, proposal, spent, now) to a verdict. It does no I/O and calls no model. Untrusted text (listings, chats, articles, buyer messages) goes through an extractor or a tool-less structured AI call that returns facts only, checked by zod. The guard decides on those facts, so the worst an injected listing can do is produce wrong facts that the clauses then reject.
  • Ledger: each event stores sha256(prevHash + canonical JSON). The server and the browser use the same canonical form, and tests check that the browser hashes match the stored ones.
  • PayPal: our own typed REST client against the sandbox. Orders v2 with AUTHORIZE for the chosen cart, Payments v2 capture with final_capture, void and refund, Payouts v1, order tracking, Reporting v1 transaction search, Invoicing v2, Disputes v1, webhook signature verification and the PayPal JS SDK v6 button for approving the hold.
  • AI: Claude through @anthropic-ai/sdk. Claude Sonnet 5.5 (claude-sonnet-5-5) does the smart tier and Claude Haiku 5.5 (claude-haiku-5-5) the fast tier. Calls use structured output through one submit tool, a manual tool-use loop for the agents, and image input for delivery and bounty photo checks.
  • Mock mode by default: a stateful mock of the PayPal REST API and a scripted AI that replays its choices through the real tools, guard and rail. Judges can run the whole thing offline with no keys.
  • Orchestrator: each pipeline is a list of named steps that can wait on a person (PayPal approval, confirm, upload, external event) and resume through POST /api/runs/<id>/resume. State lives in SQLite.
  • Channel3 supplies live product search. Render hosts it from a Blueprint (render.yaml): one web service with a persistent disk and a cron job for the bounty deadline sweep.
  • Specs and tests: 12 OpenSpec changes drove the build. The repo has 784 passing tests in 109 files, and a red-team script that runs 11 attack fixtures (a hijacked listing, a scam chat, a bounty description telling the AI to pay an attacker, and more) through the real pipelines.

Challenges we ran into

  • Prompt injection. The guard has to judge listings without obeying them. Raw text now goes through a facts-only extraction step first. The one raw string the guard reads is the item title, in a fail-safe multi-pack check that can only move a verdict to ASK.
  • Holding only what the cart costs. PaySmart authorizes the chosen cart's total, not the slip limit, so the rest of the budget is never held. Capture uses final_capture and anything unused is released.
  • PayPal text limits. PayPal truncates some free-text fields at 127 characters, so a word-boundary clipper sits in front of the services and both rails.
  • Channel3 filters. The price filter is filters.price.max_price. Our first guess, max, returned HTTP 422 on every live search, so the cap is now also enforced locally.
  • Stale links. An old PayPal return or cancel link could resume a run that had moved past approval. Those routes now resume only a run that is waiting on paypal_approval.
  • Hosting. A Render disk attaches to one service and cron jobs cannot mount it, so the bounty sweep calls an authenticated HTTP route on the web service.

Accomplishments we're proud of

  • A guard that calls no model, so a prompt-injected listing cannot talk past it.
  • A ledger you can check yourself: tamper with one event in Chain Lab and your browser shows the broken link and every later one.
  • All 11 red-team attacks are blocked, and $0.00 moves in every one of them.
  • One orchestrator runs seven pipelines to the end in mock mode, with every chain verified (npm run demo:seed).
  • PaySmart works with scripting off: the home page ask box is a plain form that opens /p/paysmart?ask=....

What we learned

  • Putting the safety check outside the model is simpler to reason about than prompting the model to behave.
  • Showing the search funnel (found, clean, trusted, within the slip, in a cart) tells a user more than a final answer does.
  • An offline mock of the PayPal API that keeps state is worth building early. It let us test authorize, capture, void and refund paths hundreds of times without touching the sandbox.
  • Writing specs first, one OpenSpec change per pipeline, kept seven pipelines consistent with one contract.

What's next

  • Run the two-need demo ask against a live Channel3 response (the tests cover it with fixtures only).
  • Exercise the PayPal popup approval end to end with a sandbox buyer account.
  • Decide how affiliate links work with Channel3, whose live offer URLs are buy.trychannel3.com redirects.
  • Add more pipelines to the front door's router.

Built With

  • anthropic-api
  • channel3
  • claude
  • claude-haiku-5.5
  • claude-sonnet-5.5
  • next.js
  • node.js
  • openspec
  • paypal-disputes-api
  • paypal-invoicing-api
  • paypal-js-sdk
  • paypal-orders-api
  • paypal-payments-api
  • paypal-payouts-api
  • paypal-webhooks
  • react
  • render
  • sqlite
  • tailwind-css
  • typescript
  • vitest
  • web-crypto-api
  • web-speech-api
  • zod
Share this project:

Updates

Submission history