Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(feedback): send product feedback to the deployed Worker (#188)
Leo9562a9a37c93
diff --git a/apps/marketing/src/pages/privacy-policy.astro b/apps/marketing/src/pages/privacy-policy.astroindex 188a2d6a6..754a1bc0e 100644--- a/apps/marketing/src/pages/privacy-policy.astro+++ b/apps/marketing/src/pages/privacy-policy.astro@@ -40,7 +40,7 @@ const sections = [its own processing and retention.</li><li>- <strong>Product feedback.</strong> Feedback you submit goes to feedback.akeru.bot and may be+ <strong>Product feedback.</strong> Feedback you submit goes to the Akeru feedback service and may bekept for up to 90 days.</li><li>diff --git a/apps/web/src/components/settings/PrivacySettings.tsx b/apps/web/src/components/settings/PrivacySettings.tsxindex 25535e1b4..18f0dc33c 100644--- a/apps/web/src/components/settings/PrivacySettings.tsx+++ b/apps/web/src/components/settings/PrivacySettings.tsx@@ -43,7 +43,7 @@ export function PrivacySettingsPanel() {/><SettingsRow{...searchableSetting("privacy-product-feedback")}- description="Send feedback you submit to feedback.akeru.bot. The service keeps submissions for up to 90 days."+ description="Send feedback you submit to the Akeru feedback service. The service keeps submissions for up to 90 days."control={<Switchchecked={settings.productFeedbackEnabled}diff --git a/docs/internals/product-feedback.md b/docs/internals/product-feedback.mdindex 3614e1950..d8a813c6d 100644--- a/docs/internals/product-feedback.md+++ b/docs/internals/product-feedback.md@@ -2,7 +2,7 @@> For maintainers. Using Akeru Bot? See [Product feedback](../user/product-feedback.md).-Product feedback uses a standalone Cloudflare Worker in `infra/feedback`. Static web clients cannot own the inbox, and each distributed Akeru Bot server belongs to one installation. The default central endpoint is `https://feedback.akeru.bot/v1/feedback`. The Worker stores no Linear issue and exposes no public inbox route.+Product feedback uses a standalone Cloudflare Worker in `infra/feedback`. Static web clients cannot own the inbox, and each distributed Akeru Bot server belongs to one installation. The default central endpoint is `https://akeru-feedback.leoisadev.workers.dev/v1/feedback`. The `akeru-bot.com` zone is on Vercel DNS, so the Worker has no custom hostname; the contracts default points at the workers.dev URL and clients post to it directly with CORS. The Worker stores no Linear issue and exposes no public inbox route.## Client boundary@@ -26,7 +26,7 @@ Before storage, the Worker:- Applies a 30-second installation cooldown and a five-second coarse-network burst cooldown.- Blocks the same content from the same coarse network for 24 hours.- Limits a coarse network to 20 accepted submissions per hour.-- Requires Turnstile only after five accepted submissions from the coarse network in one hour.+- Requires Turnstile only after five accepted submissions from the coarse network in one hour, and only when Turnstile keys are configured. Without keys the endpoint fails closed: after five accepted submissions in one hour from a coarse network, further submissions are rejected as rate limited.- Normalizes IPv4 to `/24` and IPv6 to `/64`.- HMACs the rotating installation token, coarse IP, and content fingerprint.@@ -38,6 +38,6 @@ The Cloudflare deployment trusts only `CF-Connecting-IP`. A self-host adapter mu## Operations and self-hosting-Deploy the Worker from `infra/feedback`. Configure `AKERU_FEEDBACK_HMAC_SECRET`, `AKERU_FEEDBACK_TURNSTILE_SITE_KEY`, and `AKERU_FEEDBACK_TURNSTILE_SECRET_KEY`. The central Worker returns `503` until all three values are valid.+Deploy the Worker from `infra/feedback` with `vp run --filter akeru-feedback deploy`. `AKERU_FEEDBACK_HMAC_SECRET` is required; the Worker returns `503` until it holds at least 32 bytes. `AKERU_FEEDBACK_TURNSTILE_SITE_KEY` and `AKERU_FEEDBACK_TURNSTILE_SECRET_KEY` are optional and enable the challenge step. Alchemy state is local and gitignored because the Cloudflare state store bootstrap fails on the pinned alchemy version. The Worker and D1 names are pinned, so a checkout without state recovers the existing resources with `alchemy deploy --stage production --adopt`; a plain deploy without state fails instead of creating duplicates.Maintainers inspect the inbox with authenticated local D1 tooling. Do not add a public listing route. A self-hosted Akeru Bot environment can replace the endpoint in **Settings → About**. Keep production endpoints on HTTPS.diff --git a/docs/user/privacy.md b/docs/user/privacy.mdindex 4f50461ed..6c49207ad 100644--- a/docs/user/privacy.md+++ b/docs/user/privacy.md@@ -9,7 +9,7 @@ server uses that worktree's `.akeru` directory instead.- Provider requests send the prompt, selected files, tool results, and conversation context to theprovider that you select. That provider controls its processing and retention.- Product feedback sends the text and an optional safe interface descriptor to- `feedback.akeru.bot`. The service can retain accepted feedback for up to 90 days.+ the Akeru feedback service. The service can retain accepted feedback for up to 90 days.- Voice calls send microphone audio and call state to the ChatGPT Realtime service while a call isactive.- Provider update checks contact the release source for configured providers. Signed desktop buildsdiff --git a/infra/feedback/README.md b/infra/feedback/README.mdindex 5fcf1e9b1..82e54fb01 100644--- a/infra/feedback/README.md+++ b/infra/feedback/README.md@@ -5,11 +5,11 @@ This standalone Cloudflare Worker receives anonymous Akeru Bot product feedback.Set these deployment values:- `AKERU_FEEDBACK_HMAC_SECRET`: required HMAC secret.-- `AKERU_FEEDBACK_TURNSTILE_SITE_KEY`: required Turnstile site key.-- `AKERU_FEEDBACK_TURNSTILE_SECRET_KEY`: required Turnstile secret key.+- `AKERU_FEEDBACK_TURNSTILE_SITE_KEY`: optional Turnstile site key.+- `AKERU_FEEDBACK_TURNSTILE_SECRET_KEY`: optional Turnstile secret key. Both keys together enable the challenge step; without them the endpoint rejects further submissions from a coarse network after five accepted submissions in one hour.Run the focused test with `vp test run infra/feedback/src/endpoint.test.ts`. Run the typecheck with `vp run --filter akeru-feedback typecheck`. Deploy only on direct request with `vp run --filter akeru-feedback deploy`.-The Worker binds `feedback.akeru.bot` and accepts `POST /v1/feedback`. Use authenticated D1 tooling to inspect rows in `akeru_feedback_inbox`. Do not add a public inbox route or create Linear issues from this Worker. A daily cron removes rows after 90 days.+The Worker is named `akeru-feedback`, has no custom hostname, and accepts `POST /v1/feedback` at `https://akeru-feedback.leoisadev.workers.dev`. Alchemy state is local and gitignored. The Worker and D1 names are pinned; from a checkout without state, run `alchemy deploy --stage production --adopt` to take over the existing resources. Use authenticated D1 tooling to inspect rows in `akeru_feedback_inbox`. Do not add a public inbox route or create Linear issues from this Worker. A daily cron removes rows after 90 days.Cloudflare supplies the trusted client address through `CF-Connecting-IP`. A self-host adapter must use a trusted proxy socket address and must not accept arbitrary `X-Forwarded-For` values.diff --git a/infra/feedback/alchemy.run.ts b/infra/feedback/alchemy.run.tsindex bed000082..01c3d0b96 100644--- a/infra/feedback/alchemy.run.ts+++ b/infra/feedback/alchemy.run.ts@@ -1,18 +1,21 @@import * as Alchemy from "alchemy";import * as Cloudflare from "alchemy/Cloudflare";+import * as State from "alchemy/State";import * as Config from "effect/Config";import * as Effect from "effect/Effect";import * as Redacted from "effect/Redacted";import { FeedbackDatabase } from "./src/database.ts";+// akeru-bot.com is served by Vercel DNS, so this Worker has no custom hostname.+// Clients post straight to the workers.dev URL recorded in the contracts default.export const FeedbackWorker = Cloudflare.Worker("FeedbackWorker", {+ name: "akeru-feedback",main: new URL("./src/worker.ts", import.meta.url).pathname,compatibility: {date: "2026-08-30",flags: ["nodejs_compat"],},- domain: "feedback.akeru.bot",crons: ["0 3 * * *"],env: {DB: FeedbackDatabase,@@ -32,11 +35,15 @@ export const FeedbackWorker = Cloudflare.Worker("FeedbackWorker", {export type FeedbackWorkerEnv = Cloudflare.InferEnv<typeof FeedbackWorker>;+// Alchemy's Cloudflare state store cannot be bootstrapped on this alchemy+// version (the bootstrap command overflows the stack), so state is local. The+// Worker and D1 names are pinned so a checkout without state recovers with+// `alchemy deploy --stage production --adopt` instead of creating duplicates.export default Alchemy.Stack("AkeruFeedback",{providers: Cloudflare.providers(),- state: Cloudflare.state(),+ state: State.localState(),},Effect.gen(function* () {const database = yield* FeedbackDatabase;diff --git a/infra/feedback/migrations/0002_github_issue_outbox.sql b/infra/feedback/migrations/0002_github_issue_outbox.sqlnew file mode 100644index 000000000..d06fc91b4--- /dev/null+++ b/infra/feedback/migrations/0002_github_issue_outbox.sql@@ -0,0 +1,32 @@+ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_issue_status TEXT NOT NULL DEFAULT 'pending'+ CHECK (github_issue_status IN ('pending', 'delivering', 'unknown', 'failed', 'delivered'));++ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_issue_number INTEGER;++ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_issue_url TEXT;++ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_delivery_attempts INTEGER NOT NULL DEFAULT 0;++ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_next_attempt_at TEXT;++ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_lease_expires_at TEXT;++ALTER TABLE akeru_feedback_inbox+ ADD COLUMN github_last_error_code TEXT;++CREATE INDEX idx_akeru_feedback_github_delivery+ ON akeru_feedback_inbox(+ github_issue_status,+ github_next_attempt_at,+ github_lease_expires_at,+ received_at+ );++CREATE INDEX idx_akeru_feedback_coarse_duplicate+ ON akeru_feedback_inbox(coarse_ip_hash, content_hash, received_at);diff --git a/infra/feedback/package.json b/infra/feedback/package.jsonindex e0ddf7da6..88253af49 100644--- a/infra/feedback/package.json+++ b/infra/feedback/package.json@@ -3,7 +3,7 @@"private": true,"type": "module","scripts": {- "deploy": "alchemy deploy",+ "deploy": "alchemy deploy --stage production","test": "vp test run","typecheck": "tsgo --noEmit"},diff --git a/infra/feedback/src/database.ts b/infra/feedback/src/database.tsindex 814e1c947..4d619ff85 100644--- a/infra/feedback/src/database.ts+++ b/infra/feedback/src/database.ts@@ -1,6 +1,9 @@import * as Cloudflare from "alchemy/Cloudflare";+// The pinned name matches the database from the first production deploy, so a+// checkout without prior state adopts it instead of creating a new one.export const FeedbackDatabase = Cloudflare.D1.Database("FeedbackDatabase", {+ name: "AkeruFeedback-FeedbackDatabase-production-miv7ua5r3iswqssa",migrationsDir: "./migrations",primaryLocationHint: "enam",});diff --git a/infra/feedback/src/endpoint.test.ts b/infra/feedback/src/endpoint.test.tsindex a9d022ac6..f87f92c5b 100644--- a/infra/feedback/src/endpoint.test.ts+++ b/infra/feedback/src/endpoint.test.ts@@ -240,13 +240,19 @@ describe("product feedback endpoint", () => {});expect(await reason(await limited(request(baseSubmission())))).toBe("rate_limited");+ // Without Turnstile the suspicious threshold is the hard network limit.const noChallengeMemory = makeRepository();- noChallengeMemory.setIpCount(5);+ noChallengeMemory.setIpCount(4);const noChallenge = makeProductFeedbackEndpoint({repository: noChallengeMemory.repository,hmacSecret: "test-secret-that-is-long-enough",});expect((await noChallenge(request(baseSubmission()))).status).toBe(201);+ noChallengeMemory.setIpCount(5);+ const closed = await noChallenge(request(baseSubmission()));+ expect(closed.status).toBe(429);+ expect(closed.headers.get("retry-after")).toBe("3600");+ expect(await closed.json()).toMatchObject({ reason: "rate_limited" });});it("turns repository failures into a bounded honest response", async () => {diff --git a/infra/feedback/src/endpoint.ts b/infra/feedback/src/endpoint.tsindex ad52113e1..5572a2ae5 100644--- a/infra/feedback/src/endpoint.ts+++ b/infra/feedback/src/endpoint.ts@@ -170,7 +170,7 @@ async function readBoundedBody(request: Request): Promise<string | null> {return new TextDecoder("utf-8", { fatal: true }).decode(body);}-function optionsResponse(): Response {+export function productFeedbackOptionsResponse(): Response {return new Response(null, {status: 204,headers: {@@ -190,7 +190,7 @@ export function makeProductFeedbackEndpoint(options: ProductFeedbackEndpointOptireturn async (request: Request): Promise<Response> => {try {- if (request.method === "OPTIONS") return optionsResponse();+ if (request.method === "OPTIONS") return productFeedbackOptionsResponse();if (request.method !== "POST") {return rejection(405, { reason: "malformed", message: "Use POST for feedback." });}@@ -270,7 +270,20 @@ export function makeProductFeedbackEndpoint(options: ProductFeedbackEndpointOpti);}- if (ipCount >= PRODUCT_FEEDBACK_SUSPICIOUS_AFTER && options.turnstile) {+ if (ipCount >= PRODUCT_FEEDBACK_SUSPICIOUS_AFTER) {+ // Without Turnstile there is no way to clear suspicious traffic, so the+ // suspicious threshold becomes the hard network limit.+ if (!options.turnstile) {+ return rejection(+ 429,+ {+ reason: "rate_limited",+ message: "Too many feedback submissions came from this network. Try again later.",+ retryAfterSeconds: PRODUCT_FEEDBACK_IP_WINDOW_SECONDS,+ },+ { "Retry-After": String(PRODUCT_FEEDBACK_IP_WINDOW_SECONDS) },+ );+ }if (!submission.turnstileToken) {return rejection(429, {reason: "challenge_required",diff --git a/infra/feedback/src/worker.test.ts b/infra/feedback/src/worker.test.tsindex e251695c9..ef5e2b469 100644--- a/infra/feedback/src/worker.test.ts+++ b/infra/feedback/src/worker.test.ts@@ -3,6 +3,8 @@ import { describe, expect, it, vi } from "vite-plus/test";import type { FeedbackWorkerEnv } from "../alchemy.run.ts";import worker from "./worker.ts";+const ENDPOINT = "https://akeru-feedback.leoisadev.workers.dev/v1/feedback";+function env(overrides: Partial<FeedbackWorkerEnv> = {}): FeedbackWorkerEnv {return {DB: { prepare: vi.fn() } as unknown as D1Database,@@ -13,25 +15,57 @@ function env(overrides: Partial<FeedbackWorkerEnv> = {}): FeedbackWorkerEnv {} as FeedbackWorkerEnv;}+// A D1 stub for one empty inbox: every lookup finds nothing and the insert lands.+function emptyInboxDatabase(): D1Database {+ const statement = {+ bind: () => statement,+ first: async () => null,+ run: async () => ({ meta: { changes: 1 } }),+ };+ return { prepare: () => statement } as unknown as D1Database;+}++function submission(): Request {+ return new Request(ENDPOINT, {+ method: "POST",+ headers: { "content-type": "application/json", "cf-connecting-ip": "203.0.113.41" },+ body: JSON.stringify({+ schemaVersion: 1,+ feedback: "The send button stays disabled.",+ installToken: "3f2504e0-4f89-41d3-9a0c-0305e82c3301",+ website: "",+ }),+ });+}+describe("feedback worker", () => {it("stays disabled when the HMAC secret is too short", async () => {const response = await worker.fetch(- new Request("https://feedback.akeru.bot/v1/feedback", { method: "POST" }),+ new Request(ENDPOINT, { method: "POST" }),env({ HMAC_SECRET: "short" }),);expect(response.status).toBe(503);+ expect(response.headers.get("access-control-allow-origin")).toBe("*");expect(await response.json()).toMatchObject({ reason: "disabled" });});- it("stays disabled until Turnstile is configured", async () => {+ it("accepts a direct browser submission without Turnstile keys", async () => {+ const response = await worker.fetch(submission(), env({ DB: emptyInboxDatabase() }));++ expect(response.status).toBe(201);+ expect(response.headers.get("access-control-allow-origin")).toBe("*");+ expect(await response.json()).toMatchObject({ feedbackId: expect.stringMatching(/^fb_/) });+ });++ it("answers CORS preflight before reading configuration", async () => {const response = await worker.fetch(- new Request("https://feedback.akeru.bot/v1/feedback", { method: "POST" }),- env(),+ new Request(ENDPOINT, { method: "OPTIONS" }),+ env({ HMAC_SECRET: "short" }),);- expect(response.status).toBe(503);- expect(await response.json()).toMatchObject({ reason: "disabled" });+ expect(response.status).toBe(204);+ expect(response.headers.get("access-control-allow-methods")).toBe("POST, OPTIONS");});it("deletes expired rows during the daily scheduled run", async () => {diff --git a/infra/feedback/src/worker.ts b/infra/feedback/src/worker.tsindex 0685a6378..464a956b4 100644--- a/infra/feedback/src/worker.ts+++ b/infra/feedback/src/worker.ts@@ -4,7 +4,11 @@ import * as Exit from "effect/Exit";import * as Schema from "effect/Schema";import type { FeedbackWorkerEnv } from "../alchemy.run.ts";-import { makeProductFeedbackEndpoint, type ProductFeedbackRepository } from "./endpoint.ts";+import {+ makeProductFeedbackEndpoint,+ productFeedbackOptionsResponse,+ type ProductFeedbackRepository,+} from "./endpoint.ts";interface FeedbackRow {readonly feedback_id: string;@@ -165,23 +169,23 @@ export default {if (url.pathname !== "/v1/feedback") {return new Response("Not Found", { status: 404 });}+ if (request.method === "OPTIONS") return productFeedbackOptionsResponse();if (!validHmacSecret(env.HMAC_SECRET)) {return Response.json({ reason: "disabled", message: "Product feedback is not configured." },- { status: 503, headers: { "Cache-Control": "no-store" } },+ {+ status: 503,+ headers: { "Access-Control-Allow-Origin": "*", "Cache-Control": "no-store" },+ },);}+ // Without Turnstile keys the endpoint still runs, but the suspicious-traffic+ // threshold becomes a hard network limit instead of a challenge.const turnstile = makeTurnstile(env);- if (!turnstile) {- return Response.json(- { reason: "disabled", message: "Product feedback is not configured." },- { status: 503, headers: { "Cache-Control": "no-store" } },- );- }return makeProductFeedbackEndpoint({repository: makeRepository(env.DB),hmacSecret: env.HMAC_SECRET,- turnstile,+ ...(turnstile ? { turnstile } : {}),})(request);},async scheduled(diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.tsindex 42e872005..71e46aff1 100644--- a/packages/contracts/src/settings.test.ts+++ b/packages/contracts/src/settings.test.ts@@ -48,7 +48,7 @@ describe("ServerSettings product feedback", () => {it("defaults to the Akeru endpoint and remains server patchable", () => {expect(decodeServerSettings({})).toMatchObject({productFeedbackEnabled: true,- productFeedbackEndpoint: "https://feedback.akeru-bot.com/v1/feedback",+ productFeedbackEndpoint: "https://akeru-feedback.leoisadev.workers.dev/v1/feedback",});expect(decodeServerSettingsPatch({diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.tsindex 2e6e00904..41db855ce 100644--- a/packages/contracts/src/settings.ts+++ b/packages/contracts/src/settings.ts@@ -143,7 +143,10 @@ export const DEFAULT_ENVIRONMENT_IDENTIFICATION_MODE: EnvironmentIdentificationMexport const FontFamilyPreference = Schema.String.check(Schema.isMaxLength(200));export type FontFamilyPreference = typeof FontFamilyPreference.Type;-export const DEFAULT_PRODUCT_FEEDBACK_ENDPOINT = "https://feedback.akeru-bot.com/v1/feedback";+// The Worker in infra/feedback. akeru-bot.com is on Vercel DNS, so the Worker+// cannot bind a custom hostname there and clients post to workers.dev directly.+export const DEFAULT_PRODUCT_FEEDBACK_ENDPOINT =+ "https://akeru-feedback.leoisadev.workers.dev/v1/feedback";export const AKERU_MARKETING_SITE_URL = "https://akeru.bot";export const AKERU_PRIVACY_POLICY_VERSION = "2026-08-31";export const AKERU_TERMS_VERSION = "2026-08-31";