| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Pre-flight compliance for AI agents acting on the open web.
A paid HTTP API that agents call before they act. One round-trip in, one structured verdict out, grounded in the real policy with a citation an auditor can follow. Built for autonomous agents, payable in USDC, with every decision published as a permanent, citeable record.
Built at the Agentic Engineering Hackathon (tokens&, May 23 2026)
The agentic web runs on proposed actions and prayer, not a shared compliance layer.
"Anthropic Computer Use shipped. OpenAI Operator shipped. Custom agents are scraping, posting, and transacting every minute. Each one runs into 'wait, am I allowed to do this here?' a hundred times a day, and today nobody is checking."
PolicyGuard gives agents a single compliance stack for the open web:
Agent proposes action → x402 micropayment → live policy fetch → grounded LLM verdict → decision logged → record published to cited.md
One API. One verdict schema. Four sponsor integrations in a single round-trip.
The output is built for agents, not humans. Pattern-matchable rules, executable flags, quoted citation:
{
"decision": "blocked",
"risk_level": "high",
"matched_rules": ["no_bots", "no_automated_access"],
"machine_instruction": {
"proceed": false,
"disable_target_action": true,
"requires_human_review": false,
"safe_alternative": "Use official API"
},
"citation": {
"source_url": "https://www.linkedin.com/legal/user-agreement",
"quoted_text": "Use bots or other unauthorized automated methods to access the Services...",
"policy_section": "Dos and Don'ts"
},
"cited_md_url": "https://cited.md/article/what-is-policyguard"
}| # | Agent intent | Verdict | Why it works |
|---|---|---|---|
| 1 | Scrape 100 LinkedIn profiles | blocked, high risk | LinkedIn ToS §8.2 cited word-for-word |
| 2 | Read public OpenAI / Anthropic pricing | allowed, low risk | Proves PolicyGuard is not just "block everything" |
| 3 | Bulk-store emails from about-pages in HubSpot | modify_recommended, requires human review | Handles ambiguity with a safe_alternative |
| External dependency | Failure mode | Fallback |
|---|---|---|
| x402 Base Sepolia | Faucet rate-limit, RPC flake | X402_MODE=mock returns identical response shape |
| Nimble | No API key, target site blocked | Labeled stub string so the rest of the pipeline runs |
| Senso | No API key, CLI unreachable | POLICYGUARD_DEMO_MODE=true returns deterministic fixtures |
| ClickHouse | No CLICKHOUSE_URL | [clickhouse:stub] log line, no insert |
| LLM | ANTHROPIC_API_KEY missing | Rule engine returns a verdict on rules alone |
Demo mode is a first-class architectural feature, not an emergency patch. The stage path is bulletproof.
Calling agent
│
▼
┌──────────────────────────────┐
│ x402 paywall (Base Sepolia) │
│ USDC micropayment │
└──────────────┬───────────────┘
│
▼
POST /api/evaluate (Next.js)
│
┌─────────────────┼───────────────────┐
▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌────────────┐
│ Nimble │ │ Senso │ │ Vercel AI │
│ extract │ ───► │ context │ ────► │ + Zod │
│ + search│ │ chunks │ │ generateObj│
└─────────┘ └──────────┘ └─────┬──────┘
│
▼
┌────────────────────┐
│ Rule engine (TS) │
│ override + merge │
└─────────┬──────────┘
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
┌───────────┐ ┌────────────┐ ┌───────────────┐
│ClickHouse │ │ Senso │ │ Verdict JSON │
│ decisions │ │ publish │ │ to caller │
│ table │ │ → cited.md │ └───────────────┘
└───────────┘ └────────────┘
Integrations (all env-driven, all degrade gracefully): Anthropic · Vercel AI SDK · Senso CLI · Nimble · ClickHouse · x402 (Coinbase CDP Facilitator).
Build the KB from Nimble (terms + robots per domain):
# needs NIMBLE_API_KEY + SENSO_API_KEY — ~3 min for 8 domains
npm run kb:ingest
npm run kb:ingest -- --only notion_so,linkedin # subset
npm run kb:list # target keysWrites policy-content-ids.json (gitignored). Restart npm run dev so /api/research scopes Senso search to per-vendor Nimble-ingested docs instead of the legacy OpenAI fixture id.
LLM planner (flexible steps from task text):
# .env.local: POLICYGUARD_PLANNER=llm + ANTHROPIC_API_KEY=sk-ant-...
npm run demo:research
npm run demo:research -- "Compare 3 affordable CRMs and email founders on LinkedIn"
npm run demo:research -- --task "Find HIPAA-compliant note-taking apps under $15/user" --max-vendors 3Omit the task to use the default PM-tools prompt. Claude proposes action steps from your task text; falls back to the fixed 8-step plan on error. Response includes planner_mode, planned step list, and planner_fallback.
Live vendor collection (after LLM planner):
# default on — Nimble fetches /pricing when policy allows read_pricing_page
POLICYGUARD_COLLECT_PRICING=true
POLICYGUARD_COLLECT_LLM=true # Claude extracts $/user + trial URL if regex missesVendor rows include collection_source: nimble_heuristic, nimble_llm, or catalog_fallback.
| Technology | Purpose |
|---|---|
| Next.js 15 (App Router) | Marketing site + demo UI + API in one repo |
| React 19 | Demo UI |
| TypeScript | Type safety end-to-end |
| CSS Modules | Component styling (policyguard-demo.module.css, agent-live.module.css) |
| Technology | Purpose |
|---|---|
| Next.js Route Handlers | /api/evaluate, /api/research, /api/paid-demo, /api/stats, /api/agent-run, /api/status |
| Vercel AI SDK (ai) | generateObject with Zod schemas for the verdict |
| Zod | Request and verdict schema validation |
| Plain TS rule engine | Deterministic matched_rules + override logic |
| tsx | Dev harness for demo scripts |
| Technology | Purpose |
|---|---|
| Anthropic (@ai-sdk/anthropic) | Verdict generation against grounded chunks |
| Senso CLI | Knowledge base, search context, engine publish to cited.md |
| Nimble (api.webit.live/api/v1/...) | Live extract + search for policy pages |
| ClickHouse (@clickhouse/client) | Decision ledger and /api/stats aggregation |
| x402 (@coinbase/x402, x402-next, @x402/core, @x402/evm, @x402/extensions) | HTTP 402 paywall, Base Sepolia, USDC |
Variable names only. See .env.example. Never commit real keys.
git clone https://github.com/Asyboi/agentic-hack.git
cd agentic-hack
npm install
cp .env.example .env
# Edit .env locally. Do not commit secrets.
npm run dev
# UI + API: http://localhost:3000The default .env ships with POLICYGUARD_DEMO_MODE=true and X402_MODE=mock, so you can run the full demo with zero credentials:
npm run demo # 3 compliance checks (demo fixtures)
npm run demo:research # PM-tools marketplace task (demo fixtures)# In .env, flip:
POLICYGUARD_DEMO_MODE=false
# Verify each integration in isolation:
npm run test:senso # needs SENSO_API_KEY
npm run test:senso:live # full live Senso path
npm run test:nimble # needs NIMBLE_API_KEY
npm run nimble:sample # save a Nimble fixture for offline dev
# ClickHouse table bootstrap:
CLICKHOUSE_URL=https://... npm run clickhouse:init
# Stats endpoint:
curl http://localhost:3000/api/stats# In .env:
X402_MODE=live
npm run dev
# Agent / client must satisfy the x402 challenge first:
curl http://localhost:3000/api/paid-demoagentic-hack/ ├── src/ │ ├── app/ │ │ ├── layout.tsx │ │ ├── page.tsx │ │ ├── globals.css │ │ └── api/ │ │ ├── evaluate/route.ts # Primary verdict endpoint │ │ ├── research/route.ts # Marketplace buyer / fan-out │ │ ├── paid-demo/route.ts # x402 paywalled demo route │ │ ├── agent-run/route.ts # Agent live UI driver │ │ ├── status/route.ts # Lightweight health │ │ └── stats/route.ts # ClickHouse aggregates │ ├── components/ │ │ ├── policyguard-demo.tsx # Three-scenario + "any website" UI │ │ └── agent-live.tsx # Live agent demo │ ├── lib/ │ │ ├── schemas/ # Zod request + verdict │ │ ├── pipeline.ts # Orchestration harness │ │ ├── rule-engine.ts # Deterministic matched_rules │ │ ├── verdict-llm.ts # Vercel AI SDK generateObject │ │ ├── verdict-publish.ts # cited.md publish wrapper │ │ ├── senso.ts # Senso CLI integration │ │ ├── senso-cli.ts # Low-level CLI runner │ │ ├── nimble.ts # Nimble extract + search │ │ ├── clickhouse.ts # Decision ledger insert │ │ ├── x402-payment.ts # Paywall config │ │ ├── demo-fixtures.ts # Three canonical scenarios │ │ ├── research-fixtures.ts # PM-tools marketplace task │ │ ├── research-orchestrator.ts # Multi-vendor evaluate fan-out │ │ ├── planner.ts # Step planning helpers │ │ ├── custom-site.ts # "Any website" handler │ │ ├── agent.ts # Live agent loop │ │ └── cited-md-corpus.ts # Live cited.md article registry │ └── middleware.ts # x402-next middleware mount ├── scripts/ │ ├── demo-three-actions.ts # 3-scenario harness │ ├── demo-research.ts # Marketplace harness │ ├── agent-demo.ts # Live agent CLI │ ├── test-senso.ts # Senso smoke test │ ├── test-live-senso.ts # Full live Senso path │ ├── test-nimble.ts # Nimble smoke test │ ├── save-nimble-sample.ts # Capture a Nimble fixture │ ├── init-clickhouse.ts # Run clickhouse-init.sql │ ├── clickhouse-init.sql # `decisions` table DDL │ └── load-env-local.ts # .env.local loader ├── site/ │ └── index.html # Marketing site (deployed to Vercel) ├── plans/ │ ├── HANDOFF.md # Team handoff (verdict schema, demo, owners) │ ├── STACK.md # Stack decisions │ ├── DEMO_SCRIPT.md # 3-min stage script │ ├── SENSO_INTEGRATION.md # Senso CLI call patterns │ └── TEAM_COORDINATION.md # Owners + P0 tasks ├── .env.example ├── next.config.ts ├── tsconfig.json └── README.md
Base URL: {origin}/api (local: http://localhost:3000/api).
| Area | Endpoint | Purpose |
|---|---|---|
| Evaluate | POST /api/evaluate | Primary verdict. Body: { agent, action, target_site, policy_urls?, policy_content_id? }. Returns the verdict JSON. |
| Research | POST /api/research | Marketplace fan-out. Plans vendor steps, runs evaluate per step, logs each to ClickHouse. |
| Paywalled demo | GET /api/paid-demo | x402 challenge + USDC settlement (Base Sepolia). |
| Stats | GET /api/stats | ClickHouse aggregates: blocked / allowed / modify counts. |
| Agent run | POST /api/agent-run | Drives the live agent UI through a scenario. |
| Status | GET /api/status | Lightweight health and feature-flag report. |
curl -X POST http://localhost:3000/api/evaluate \
-H 'Content-Type: application/json' \
-H 'x-demo-scenario: linkedin-scrape' \
-d '{
"agent": "sales-bot-v1",
"action": "Scrape 100 profiles matching software engineer",
"target_site": "linkedin.com",
"policy_urls": ["https://www.linkedin.com/legal/user-agreement"]
}'| Mode | Env | Behavior |
|---|---|---|
| Demo | POLICYGUARD_DEMO_MODE=true | Canned verdicts when x-demo-scenario or a matching demo key is present. Reliable for stage and video. |
| Live | POLICYGUARD_DEMO_MODE=false + keys | Senso chunks plus Claude verdict, run through rule engine, optional cited.md publish, ClickHouse insert. |
Illustrative values from the bundled fixtures and live cited.md corpus:
| Metric | Demo value | Context |
|---|---|---|
| Demo scenarios | 3 canonical + N custom | LinkedIn scrape, OpenAI pricing read, HubSpot email store |
| Live cited.md articles | 5 | "AI Agent Compliance APIs" hub |
| Sponsor integrations | 4 in one pipeline | x402, Nimble, Senso, ClickHouse |
| Pre-ingested policy docs | 3 | LinkedIn ToS, OpenAI terms, Stripe privacy |
| Rule IDs in the engine | ~12 | no_bots, no_automated_access, personal_data_consent_required, etc. |
| Verdict types | 3 | allowed, blocked, modify_recommended |
| Risk levels | 3 | low, medium, high |
/api/evaluate always returns this shape:
type Verdict = {
decision: 'allowed' | 'blocked' | 'modify_recommended';
risk_level: 'low' | 'medium' | 'high';
reason: string; // 1 to 2 sentence human summary
matched_rules: string[]; // pattern-matchable rule IDs
machine_instruction: {
proceed: boolean;
disable_target_action: boolean;
requires_human_review: boolean;
safe_alternative?: string;
};
citation: {
source_url: string;
quoted_text: string;
policy_section: string;
fetched_at: string; // ISO-8601
};
cited_md_url?: string; // present when publish succeeded
};Why this schema: matched_rules lets calling agents branch programmatically (not just read LLM prose). machine_instruction gives the agent direct executable flags. cited_md_url proves the decision was published.
PolicyGuard is one API story with four sponsor integrations in a single pipeline: pay → fetch policy → ground in Senso → verdict → log → publish.
Live articles: What is PolicyGuard? · How does PolicyGuard cite policy evidence? · How does PolicyGuard compare to hardcoded compliance logic? · plus development status and GitHub repo articles.
| Doc | Purpose |
|---|---|
| plans/HANDOFF.md | Team handoff: verdict schema, 3-action demo, owners, acceptance criteria |
| plans/STACK.md | Stack decisions and "do not use for MVP" list |
| plans/DEMO_SCRIPT.md | 3-minute stage script and backup recording checklist |
| plans/SENSO_INTEGRATION.md | Senso CLI call patterns for /evaluate |
| plans/TEAM_COORDINATION.md | Owners, P0 tasks, and risk register |
| .env.example | All environment variables with inline notes |
next.js · react · typescript · zod · vercel-ai-sdk · @ai-sdk/anthropic · @clickhouse/client · @coinbase/x402 · x402-next · @x402/core · @x402/evm · @x402/extensions · x402-fetch · senso · cited.md · nimble · base-sepolia · usdc · vercel · tsx
Built at the Agentic Engineering Hackathon (tokens&, NYC, May 23 2026).
| Person | Owns |
|---|---|
| Kyle | x402 paywall + Base Sepolia wallet |
| Aslan | Marketplace buyer flow + Nimble policy fetch |
| Aarya | API core (/evaluate, /research), pipeline, rule engine, ClickHouse, deploy |
| Candy | Senso integration (KB, search, cited.md publish), demo UI |
No LICENSE file is present in this repository root yet. Add one (e.g. MIT, Apache-2.0, or hackathon-specific terms) before public distribution.
Every unchecked agent action is a compliance failure. PolicyGuard turns "am I allowed to do this here?" into a single HTTP round-trip with a citation.
Questions or issues? Open an issue on Asyboi/agentic-hack. Also live at https://policyguard-site.vercel.app
| Back | FazBrowse Home | New Git URL |