Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/web/.dev.vars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copy to .dev.vars for `pnpm dev` / `pnpm preview` (never committed).
# OPTIONAL. Without it POST /api/resources and POST /api/refresh answer 401,
# as upstream ships; with it, a request carrying
# `Authorization: Bearer <ADMIN_TOKEN>` may add or replace a page and clear
# the enriched cache. On a deployed environment it is the Orun secret of the
# same name, pushed to the Worker as a Worker secret on deploy.
ADMIN_TOKEN=
21 changes: 21 additions & 0 deletions apps/web/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018, Cloudflare, Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 30 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# apps/web — the site

Cloudflare's [Agent Visibility template](https://github.com/cloudflare/templates/tree/main/agent-visibility-template)
(MIT, `LICENSE`): one Hono Worker serving a content store to AI agents on
every surface they read, and a React dashboard previewing them, deployed as
one Worker with Static Assets.

| Path | What it is |
|---|---|
| `src/worker/index.ts` | upstream's Worker: `/llms.txt`, `/llms-full.txt`, `/index.json`, `/:slug.md`, `/:slug.jsonld`, `/jsonld`, `/robots.txt`, the dashboard's `/api/*`, the optional Web Bot Auth surface |
| `src/worker/health.ts` | not upstream's: `/api/health`, the store check the deploy smoke reads (never the model) |
| `src/enrichment/` | upstream's Workers AI enrichment and its deterministic fallback; the surfaces' renderers |
| `src/lib/` | upstream's KV store, sample content (`content.ts`), types and Web Bot Auth module |
| `src/react-app/`, `index.html` | upstream's dashboard, built by Vite into `dist/client` |
| `wrangler.template.jsonc` | the config's source; `wrangler.jsonc` is its render (`pnpm run wire:fixture`) |
| `component.yaml` | the Orun component: render, build, push the admin token, deploy, smoke |

## Scripts

| Command | What it does |
|---|---|
| `pnpm dev` | builds the dashboard, then `wrangler dev --local`: a local KV store, remote bindings off, so the model is not called and each page is enriched by upstream's fallback |
| `pnpm dev:remote` | the same with the signed-in account's Workers AI (`wrangler login` first; it may incur usage) |
| `pnpm build` | the dashboard into `dist/client` |
| `pnpm typecheck`, `pnpm lint` | the Worker and the dashboard |
| `pnpm run wire:fixture` | re-renders `wrangler.jsonc` from the template and `wiring.fixture.json` |

Writes (`POST /api/resources`, `POST /api/refresh`) need `ADMIN_TOKEN`:
copy `.dev.vars.example` to `.dev.vars` locally; deployed, it is the Orun
secret of the same name, pushed to the Worker as a Worker secret.
113 changes: 113 additions & 0 deletions apps/web/component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
apiVersion: sourceplane.io/v1
kind: Component
metadata:
name: web
description: The site — every agent surface and the dashboard, upstream's Worker on Cloudflare Workers + Static Assets, over the KV store and Workers AI, per environment
spec:
type: cloudflare-workers-assets-turbo
lifecycle: production
owner: platform
# `app`, not `web`: a domain and a component share one name space in the
# catalog, and a domain called `web` hid this component from it.
domain: app
path: apps/web
# Its own lane per environment, so each environment's deploy waits on its
# own namespace and nothing else.
lane: isolated
# INFRA BEFORE APP. The Worker binds the KV namespace by id, and the id is
# rendered into its config during the build from the wiring document the
# cloudflare-kv root lease-publishes after its apply. A job resolves its
# secrets when it STARTS, so on a merge to main this deploy waits for that
# environment's apply (enforced) and the document is there; a pull request
# deploys nothing, so nothing on one waits (advisory).
dependsOn:
- component: cloudflare-kv
mode: enforced
modeRules:
- mode: advisory
when:
triggerRef: github-pull-request
secretEnv:
WIRING_CLOUDFLARE_KV_STAGE: "secret://agent-visibility/agent-visibility/stage/WIRING_CLOUDFLARE_KV"
WIRING_CLOUDFLARE_KV_PROD: "secret://agent-visibility/agent-visibility/prod/WIRING_CLOUDFLARE_KV"
# The admin token, stored per environment as the product's secret
# ADMIN_TOKEN (README → "Adding your pages"). The Worker reads it at request
# time, so the build hands it to the Worker as a Worker SECRET and no bundle
# contains it (buildCommand below). BEST-EFFORT, wire-now-seed-later: a key
# nobody has stored yet is skipped when the job resolves its secrets (no env
# var, no failure), and the Worker without it refuses every write (401), as
# upstream ships — so a fresh product deploys and serves its surfaces before
# its owner has chosen a token at all.
optionalSecretEnv:
ADMIN_TOKEN: "secret://agent-visibility/agent-visibility/{{ .environment }}/ADMIN_TOKEN"
subscribe:
environments:
- name: dev
profile: verify
- name: stage
profile: verify
profileRules:
- profile: deploy
when:
triggerRef: github-push-main
- name: prod
profile: verify
profileRules:
- profile: deploy
when:
triggerRef: github-push-main
parameters:
nodeVersion: "22"
pnpmVersion: "10.12.1"

workspaceDir: ../..
appDir: .

turboFilter: "@app/web"
wranglerConfig: wrangler.jsonc

# The Worker's entry is its source: `wrangler deploy` bundles it (Hono and
# upstream's surfaces) in the same command that uploads the dashboard,
# bound as ASSETS. The build only builds the dashboard.
workerEntrypoint: src/worker/index.ts
assetsDir: dist/client

# Per-env worker name: agent-visibility-web-{dev,stage,prod}.
workerName: agent-visibility-web
environmentAwareWorkerName: true

# The account's workers.dev subdomain; exported to the smoke step as
# ${WORKERS_DEV_SUBDOMAIN} and used to build ${DEPLOYED_URL}.
workersDevSubdomain: your-workers-subdomain

installCommand: pnpm install --frozen-lockfile
# Render this environment's wrangler config, then build. stage and prod
# render from the wiring document their cloudflare-kv apply published
# (secretEnv above, resolved before the job's first step); dev, which no
# root applies to and which only verifies, renders from the committed
# fixture. The committed wrangler.jsonc (the fixture render) is what the
# composition's verify-app-structure step finds before this runs. The
# admin token never reaches the build (`env -u`); then, when the
# environment has it, it goes to the Worker as a SECRET
# (tooling/wire/worker-secrets.mjs: `wrangler secret bulk`, the value over
# stdin) before the composition deploys it. Only the deploy lane holds a
# Cloudflare credential, so a verify lane builds the same and pushes
# nothing.
buildCommand: node ../../tooling/wire/live.mjs --template wrangler.template.jsonc --out wrangler.jsonc --components cloudflare-kv --env "${ORUN_ENVIRONMENT}" --fixture wiring.fixture.json --fixture-envs dev && env -u ADMIN_TOKEN pnpm exec turbo run build --filter=@app/web && node ../../tooling/wire/worker-secrets.mjs --secret ADMIN_TOKEN --worker "agent-visibility-web-${ORUN_ENVIRONMENT}" --config wrangler.jsonc

# Smoke, read-only: /api/health — answered by the Worker ahead of the
# assets (run_worker_first) — reads the store through the KV binding and
# answers `"ok":true` (an unbound or unreachable namespace is a 503). It
# never calls the model, so a deploy neither warms the cache nor spends
# Workers AI: the surfaces (/llms.txt and the rest) all read the store, and
# on a cold one the first of them enriches every page. Then the
# dashboard's page is served from Static Assets (`id="root"`, its mount
# point). Not the site's name: that is the owner's to change. Nothing is
# written. Responses are buffered before grep so an early match cannot
# SIGPIPE curl.
smokeCommand: "health=$(curl -sf \"${DEPLOYED_URL}/api/health\") && echo \"${health}\" | grep -q '\"ok\":true' && html=$(curl -sfL \"${DEPLOYED_URL}/\") && echo \"${html}\" | grep -q 'id=\"root\"'"
labels:
team: platform
layer: delivery
surface: web
runtime: cloudflare
3 changes: 3 additions & 0 deletions apps/web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import base from "../../tooling/eslint/index.js";

export default [...base, { ignores: ["dist/**", ".wrangler/**"] }];
16 changes: 16 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AI Agent Visibility — be readable on every agent surface</title>
<meta
name="description"
content="One content store, served to AI agents through llms.txt, a typed JSON index, per-page Markdown, robots.txt, Content-Signal headers, and JSON-LD — generated by Workers AI."
/>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/react-app/main.tsx"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@app/web",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "vite build",
"dev": "vite build && wrangler dev --local",
"dev:remote": "vite build && wrangler dev",
"preview": "vite build && wrangler dev --local",
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.app.json",
"lint": "eslint .",
"wire:fixture": "node ../../tooling/wire/render.mjs --template wrangler.template.jsonc --out wrangler.jsonc --map wiring.fixture.json --env stage"
},
"dependencies": {
"hono": "4.11.1",
"react": "19.2.1",
"react-dom": "19.2.1"
},
"devDependencies": {
"@app/eslint-config": "workspace:*",
"@app/tsconfig": "workspace:*",
"@cloudflare/workers-types": "^4.20260702.1",
"@types/react": "19.2.7",
"@types/react-dom": "19.2.3",
"@vitejs/plugin-react": "5.1.1",
"eslint": "^9.27.0",
"typescript": "5.9.3",
"vite": "^7.0.0",
"wrangler": "^4.151.0"
}
}
Loading
Loading