Chat (with retrieval)
- You hit
ai.cannularobotics.com. Cloudflare Access checks your Google identity. If you’re not on@cannularobotics.com, you’re rejected at the edge. (Access setup is in progress; until it lands the site is on thecr-ai-intranet.pages.devpreview URL.) - The Astro site loads. Pages and content are pre-rendered HTML.
- You open the chat panel and send a message.
- The browser POSTs to
/api/chat. The Pages Function reads thecf-access-authenticated-user-emailheader, attaches a bearer, forwards tocr-ai-proxyatcr-proxy.cannularobotics.com. cr-ai-proxy:- Calls
cr-retrieval/searchvia a service binding (internal, never exposes traffic publicly) for top-k relevant chunks across the indexed sources. - Builds a prompt with chunks as context and your message as the user turn.
- Streams the request to Anthropic via
cr-ai-gateway. If the gateway returns 401 (slug or auth misconfig), the proxy automatically falls through toapi.anthropic.comdirect so chat never breaks.
- Calls
- Anthropic returns Claude’s response (SSE). The proxy streams it back through the Pages Function to the browser.
- The chat panel renders the response and the citations from step 5.
Search (Documents / Meeting notes)
- You type a query into
/docsor/notes. - The browser POSTs to
/api/search. The Pages Function forwards tocr-retrievalwith a bearer. cr-retrievalembeds the query with Workers AI (BGE-large), runstopKqueries against the requested Vectorize indices, and returns ranked chunks with their source URLs and snippets.
Ingest
- On-demand via
POST /api/admin/ingest?source={notion|granola|drive}with theX-Admin-Tokenheader. Cron triggers are paused until a workers.dev subdomain is registered (CF requirement). cr-retrievalwalks the source (Notion search, Drive files.list, etc.), chunks each document, embeds via Workers AI, upserts to the appropriate Vectorize index.- Per-invocation cap of 10 documents (Workers free-plan subrequest limit). Repeated calls drain the queue via cursor state in KV.
Tracing
The request ID at the top of the chat response lets us cross-reference:
- CF Access logs at the edge
- AI Gateway logs in the CR dashboard
cr-ai-proxyaudit logcr-retrievalingest log