critiqs-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_SETUP.md +198 -66
- package/README.md +214 -31
- package/bin/critiqs.mjs +3 -1
- package/dist/index.js +16877 -4770
- package/dist/server/index.d.ts +1 -87
- package/dist/server/index.js +1 -4889
- package/package.json +6 -5
- package/bin/cli.d.mts +0 -21
- package/bin/cli.mjs +0 -293
- package/bin/env.d.mts +0 -41
- package/bin/env.mjs +0 -384
- package/bin/init.d.mts +0 -126
- package/bin/init.mjs +0 -965
- package/bin/mcp.d.mts +0 -20
- package/bin/mcp.mjs +0 -314
- package/bin/setup.d.mts +0 -183
- package/bin/setup.mjs +0 -1054
- package/dist/backend/convex/_generated/api.d.ts +0 -95
- package/dist/backend/convex/_generated/api.js +0 -23
- package/dist/backend/convex/_generated/dataModel.d.ts +0 -60
- package/dist/backend/convex/_generated/server.d.ts +0 -162
- package/dist/backend/convex/_generated/server.js +0 -101
- package/dist/backend/convex/ai.ts +0 -93
- package/dist/backend/convex/aiSettings.ts +0 -43
- package/dist/backend/convex/auth.config.ts +0 -18
- package/dist/backend/convex/captureHttp.ts +0 -96
- package/dist/backend/convex/captures.ts +0 -167
- package/dist/backend/convex/crons.ts +0 -14
- package/dist/backend/convex/deviceSignIn.ts +0 -151
- package/dist/backend/convex/grouping.ts +0 -41
- package/dist/backend/convex/http.ts +0 -724
- package/dist/backend/convex/lib/ai.ts +0 -6
- package/dist/backend/convex/lib/links.ts +0 -12
- package/dist/backend/convex/lib/pages.ts +0 -207
- package/dist/backend/convex/lib/r2.ts +0 -75
- package/dist/backend/convex/lib/store.ts +0 -509
- package/dist/backend/convex/lib/tokens.ts +0 -101
- package/dist/backend/convex/lib/validators.ts +0 -73
- package/dist/backend/convex/lib/vendor/aws4fetch.js +0 -289
- package/dist/backend/convex/lib/vendor/critiqs_ai.js +0 -49081
- package/dist/backend/convex/lib/vendor/critiqs_core.js +0 -385
- package/dist/backend/convex/lib/vendor/critiqs_server.js +0 -3108
- package/dist/backend/convex/notificationEmails.ts +0 -61
- package/dist/backend/convex/notifications.ts +0 -182
- package/dist/backend/convex/plans.ts +0 -67
- package/dist/backend/convex/projects.ts +0 -46
- package/dist/backend/convex/schema.ts +0 -343
- package/dist/backend/convex/search.ts +0 -26
- package/dist/backend/convex/signIn.ts +0 -368
- package/dist/backend/convex/tags.ts +0 -68
- package/dist/backend/convex/threads.ts +0 -146
- package/dist/backend/convex/users.ts +0 -13
- package/dist/server/chunks/driver-n9zpr0k3.js +0 -21
- package/dist/server/chunks/index-9bg7tmnq.js +0 -522
- package/dist/server/chunks/index-askcfn7t.js +0 -148
- package/dist/server/chunks/providers-rv184xvj.js +0 -48444
- package/dist/server/chunks/token-kzddms7r.js +0 -63
- package/dist/server/chunks/token-util-k8bee1wc.js +0 -4
package/README.md
CHANGED
|
@@ -17,7 +17,9 @@ npm install critiqs-react # or: pnpm add, yarn add, bun add
|
|
|
17
17
|
npx critiqs-react init
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
`npx critiqs-react init` runs
|
|
20
|
+
`npx critiqs-react init` runs Critiqs's setup command, `critiqs`, from the
|
|
21
|
+
shared `critiqs` package that `critiqs-react` installs (`npx critiqs init` is
|
|
22
|
+
the same command). It adds `<Critiqs />` where your app renders, signs you in through
|
|
21
23
|
your browser, creates a project on Critiqs Cloud, and connects the app to it.
|
|
22
24
|
Critiqs Cloud runs storage, sign-in, and email, so there are no keys to enter.
|
|
23
25
|
The project ID is public configuration, not a secret; reviewers never see or
|
|
@@ -52,7 +54,8 @@ locally, deployments, and what reviewers on other computers still need. Then:
|
|
|
52
54
|
the Critiqs toolbar to leave a comment.
|
|
53
55
|
2. Commit the code change (not `.env.local`). In each deployment that should
|
|
54
56
|
show Critiqs, set the variable in its build settings, and record the
|
|
55
|
-
deployed address
|
|
57
|
+
deployed address, including any path such as `/my-prototype/`, so mention
|
|
58
|
+
emails from every copy open it:
|
|
56
59
|
`npx critiqs-react init --review-url https://<deployed address>`.
|
|
57
60
|
3. `npx critiqs-react doctor` checks the setup at any time.
|
|
58
61
|
|
|
@@ -129,16 +132,18 @@ its Critiqs along.
|
|
|
129
132
|
|
|
130
133
|
Init edits one source file, and only when it can tell exactly where: it
|
|
131
134
|
previews the change with `--dry-run`, and it refuses, changing nothing, when
|
|
132
|
-
there are several roots, when Critiqs is already
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
`.env`
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
there are several roots, when Critiqs is already loaded another way
|
|
136
|
+
(re-exported, as a namespace, or at run time), or when the name `Critiqs`
|
|
137
|
+
means something else there. It then prints the line to add by hand. A
|
|
138
|
+
`<Critiqs />` imported under another name is updated like any other. It checks
|
|
139
|
+
the source and `.env` files can be written before you sign in. Running init
|
|
140
|
+
again keeps the project the code already names, through a literal ID or the
|
|
141
|
+
variable's value in your `.env` files; a missing or malformed value doesn't
|
|
142
|
+
count, so init connects one. It keeps your other `.env` lines and values, a
|
|
143
|
+
component's other properties, and wiring you wrote yourself
|
|
144
|
+
(`projectId={import.meta.env.VITE_MY_PROJECT}` is set as it is; other code is
|
|
145
|
+
left alone). A retry after an interrupted run reuses your project with the
|
|
146
|
+
same name rather than creating another. `--new-project` creates a new one.
|
|
142
147
|
|
|
143
148
|
### Signing in from another device
|
|
144
149
|
|
|
@@ -174,7 +179,7 @@ project in the matching prototype's Critiqs sidebar and set its public
|
|
|
174
179
|
| Sign-in took too long, or Setup was denied | Run init again; nothing was created. |
|
|
175
180
|
| Source became unreadable or unwritable during setup | The result keeps the created project ID and backend. Restore file access and apply the complete component snippet shown, at the indicated entry/mount, and the `.env` line it names. Preserve its backend and update an existing component rather than adding another. |
|
|
176
181
|
| The code already uses project … | Nothing was changed. Use `--new-project` to replace it, or `--review-url` to set its review address. |
|
|
177
|
-
| No review address, or one that only opens on this computer |
|
|
182
|
+
| No review address, or one that only opens on this computer or a private network (such as Tailscale) | If reviewers use a deployed copy, run `npx critiqs-react init --review-url https://<deployed address>`, or change it in the Critiqs sidebar's Project setup. |
|
|
178
183
|
| Critiqs Cloud isn't ready for this version | The hosted service runs an older backend; wait for it, or use your own Convex deployment. |
|
|
179
184
|
|
|
180
185
|
`npx critiqs-react doctor` checks the component, the backend and its version,
|
|
@@ -183,9 +188,25 @@ it read configuration or something the backend has actually done; doctor never
|
|
|
183
188
|
sends an email, uploads a screenshot, or posts a comment, so the first real
|
|
184
189
|
comment is what proves those work. AI is optional and doctor reports it as
|
|
185
190
|
information. `--json` prints init's and doctor's results for scripts and coding
|
|
186
|
-
agents. Coding agents can follow [AGENT_SETUP.md](AGENT_SETUP.md); an optional
|
|
191
|
+
agents. Coding agents can follow [AGENT_SETUP.md](../critiqs/AGENT_SETUP.md); an optional
|
|
187
192
|
MCP server (`npx critiqs-react mcp`) offers the same steps.
|
|
188
193
|
|
|
194
|
+
Coding agents can also read a project's feedback with its context, to act on
|
|
195
|
+
it: run `npx critiqs-react sign-in` once on the computer (or let the agent call
|
|
196
|
+
`critiqs_sign_in`), then the MCP server's `critiqs_comments`, `critiqs_thread`,
|
|
197
|
+
and `critiqs_screenshot` tools read threads, filtered by status, author, time,
|
|
198
|
+
tag, screen, or text, and `critiqs_reply` posts a reply as you, marked "via
|
|
199
|
+
coding agent", to ask people to check a fix. `critiqs_mockups` and
|
|
200
|
+
`critiqs_mockup` read mockups: each change Critiqs AI made to a page copy,
|
|
201
|
+
with the original element's markup and `data-critiqs-id` to find it in the
|
|
202
|
+
code, and the discussion behind it. The sign-in lasts until `npx critiqs-react sign-out`, 30
|
|
203
|
+
days without use, or 90 days. It is sent only to the backends it was approved
|
|
204
|
+
for, and to where each serves screenshots and page copies; the approval page
|
|
205
|
+
names them. For a backend other than Critiqs Cloud, sign in with
|
|
206
|
+
`npx critiqs-react sign-in --backend '<origin>'`, which needs that backend's
|
|
207
|
+
sign-in service to run the current Critiqs backend. A version of this package
|
|
208
|
+
from before this change, on the same computer, asks to sign in again. See [AGENT_SETUP.md](../critiqs/AGENT_SETUP.md#7-reading-feedback).
|
|
209
|
+
|
|
189
210
|
### Keeping feedback on your own backend
|
|
190
211
|
|
|
191
212
|
Critiqs Cloud is the default. To keep feedback on your team's own Convex
|
|
@@ -230,9 +251,26 @@ threads by words and `#tags`.
|
|
|
230
251
|
With AI, new tags are grouped automatically, searches can be plain questions,
|
|
231
252
|
and results come with insights that cite their threads. A project uses
|
|
232
253
|
Critiqs-managed AI where the deployment offers it, or its owner connects the
|
|
233
|
-
project's own OpenAI, Anthropic, Google Gemini, Vercel AI
|
|
234
|
-
OpenAI-compatible provider in the same dialog
|
|
235
|
-
|
|
254
|
+
project's own OpenAI, Anthropic, Google Gemini, OpenRouter, Vercel AI
|
|
255
|
+
Gateway, or OpenAI-compatible provider in the same dialog, in three steps:
|
|
256
|
+
the provider, the key, and the models to offer, from the provider's list or
|
|
257
|
+
typed by name. Critiqs AI may offer several models, each costing its credits
|
|
258
|
+
per request; the owner picks the project's model and which models it allows. In Mockup mode, a **Model**
|
|
259
|
+
menu beside Send chooses among the models a person's AI offers, when there
|
|
260
|
+
are several.
|
|
261
|
+
|
|
262
|
+
Everyone has Critiqs AI where the deployment offers it, with nothing to set
|
|
263
|
+
up. **Your AI** in the avatar menu chooses its model by name, shows the
|
|
264
|
+
credits used against the plan with **Upgrade** where the deployment names an
|
|
265
|
+
upgrade page, and sets up the person's own API key in three steps instead. The
|
|
266
|
+
owner's **Who pays** decides which one the requests people start use:
|
|
267
|
+
**Project pays, personal allowed** (the default: the project pays unless
|
|
268
|
+
someone chooses their own), **Project pays**, or **Each person pays** (Critiqs
|
|
269
|
+
AI on each person's own plan, or their own key). Automatic grouping always
|
|
270
|
+
uses the project's AI. Your AI is offered on backends that keep it.
|
|
271
|
+
|
|
272
|
+
Keys go to the backend once, are stored encrypted, and never return to
|
|
273
|
+
browsers. AI is optional: without
|
|
236
274
|
it, commenting, replies, mentions, and tags work as usual, search is labeled
|
|
237
275
|
basic, and grouping is manual. Nobody installing the component is asked for an
|
|
238
276
|
AI key.
|
|
@@ -242,11 +280,29 @@ random characters, such as from `openssl rand -base64 32`) so owners can save
|
|
|
242
280
|
keys, and optionally `CRITIQS_AI_PROVIDER`, `CRITIQS_AI_MODEL`, and
|
|
243
281
|
`CRITIQS_AI_API_KEY` for a provider every project uses by default.
|
|
244
282
|
`CRITIQS_AI_ALLOWED_ENDPOINTS` lists custom endpoint addresses owners may
|
|
245
|
-
enter.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
283
|
+
enter. The same encryption key lets each person connect their own Linear
|
|
284
|
+
account in **Your trackers…**, in the avatar menu, with a Linear API key; with
|
|
285
|
+
`CRITIQS_LINEAR_CLIENT_ID` and `CRITIQS_LINEAR_CLIENT_SECRET` from your own
|
|
286
|
+
Linear OAuth app, whose callback is
|
|
287
|
+
`https://<deployment>.convex.site/trackers/linear/callback`, they sign in to
|
|
288
|
+
Linear instead. GitHub Issues works the same way: people paste a fine-grained
|
|
289
|
+
personal access token, or, with `CRITIQS_GITHUB_CLIENT_ID`,
|
|
290
|
+
`CRITIQS_GITHUB_CLIENT_SECRET`, and `CRITIQS_GITHUB_APP_SLUG` from your own
|
|
291
|
+
GitHub App (callback
|
|
292
|
+
`https://<deployment>.convex.site/trackers/github/callback`), sign in through
|
|
293
|
+
it. After upgrading an existing deployment, run
|
|
294
|
+
`npx convex run tags:backfill` once so earlier comments gain their hashtags,
|
|
295
|
+
and `npx convex run projects:shortenLongNames` once so project names from
|
|
296
|
+
before the 200-character limit are shortened to fit it.
|
|
297
|
+
|
|
298
|
+
The sidebar follows the mode. In Browse mode it shows the project: its open
|
|
299
|
+
and unread threads, who has access, your email notifications, and the project
|
|
300
|
+
ID. In Comment mode it shows the
|
|
301
|
+
threads.
|
|
302
|
+
|
|
303
|
+
Keyboard shortcuts: **C** Comment mode, **V** Browse mode, **M** Mockup mode,
|
|
304
|
+
**Escape** closes what is innermost, ending with the side panel, without
|
|
305
|
+
changing the mode, and **Ctrl or Cmd + `\`** hides or shows all of Critiqs.
|
|
250
306
|
|
|
251
307
|
### For a deployment's operator: Critiqs-managed AI
|
|
252
308
|
|
|
@@ -258,16 +314,141 @@ on the command line, for example `npx convex env set CRITIQS_MANAGED_AI_API_KEY`
|
|
|
258
314
|
| Setting | Value |
|
|
259
315
|
| --- | --- |
|
|
260
316
|
| `CRITIQS_MANAGED_AI` | `enabled` |
|
|
261
|
-
| `CRITIQS_MANAGED_AI_PROVIDER` | `openai`, `anthropic`, `google`, `gateway`, or `compatible` |
|
|
262
|
-
| `
|
|
317
|
+
| `CRITIQS_MANAGED_AI_PROVIDER` | `openai`, `anthropic`, `google`, `openrouter`, `gateway`, or `compatible` |
|
|
318
|
+
| `CRITIQS_MANAGED_AI_MODELS` | The models on offer, as JSON: `[{"id":"claude-opus-5-5","label":"Claude Opus 5.5","model":"<provider's name>","price":{"input":4,"output":20}}, …]`; people choose them by `label`, and the first is the default. A model with a `price` (US dollars per million input and output tokens) charges each request by its tokens; a model with `credits` instead charges that flat amount per request |
|
|
319
|
+
| `CRITIQS_MANAGED_AI_MODEL` | Instead of `CRITIQS_MANAGED_AI_MODELS`: one model, the provider's name for it, shown as "Critiqs AI" and costing 1 credit a request |
|
|
320
|
+
| `CRITIQS_MANAGED_AI_PRICE` | Optional, with `CRITIQS_MANAGED_AI_MODEL`: its price as JSON, such as `{"input":4,"output":20}`, so requests are charged by their tokens |
|
|
263
321
|
| `CRITIQS_MANAGED_AI_API_KEY` | The provider key (optional only for `compatible`) |
|
|
264
322
|
| `CRITIQS_MANAGED_AI_BASE_URL` | Optional: the endpoint for `compatible` |
|
|
323
|
+
| `CRITIQS_UPGRADE_URL` | Optional, with plans: the https page where people upgrade, linked as **Upgrade** (with billing, **Upgrade** opens **Plan and billing** instead) |
|
|
324
|
+
|
|
325
|
+
Models from several makers share one provider, key, and address, so offer them
|
|
326
|
+
through a gateway that serves them all, such as Vercel AI Gateway
|
|
327
|
+
(`gateway`) or OpenRouter. For example, with the gateway's names for each
|
|
328
|
+
model and their list prices:
|
|
329
|
+
|
|
330
|
+
```json
|
|
331
|
+
[
|
|
332
|
+
{ "id": "claude-opus-5-5", "label": "Claude Opus 5.5", "model": "anthropic/claude-opus-5.5", "price": { "input": 4, "output": 20 } },
|
|
333
|
+
{ "id": "claude-haiku-5-5", "label": "Claude Haiku 5.5", "model": "anthropic/claude-haiku-5.5", "price": { "input": 0.1, "output": 0.5 } },
|
|
334
|
+
{ "id": "gemini-4-neon", "label": "Gemini 4 Neon", "model": "google/gemini-4-neon", "price": { "input": 3, "output": 15 } },
|
|
335
|
+
{ "id": "gpt-6-2-sol", "label": "GPT-6.2 Sol", "model": "openai/gpt-6.2-sol", "price": { "input": 2, "output": 10 } }
|
|
336
|
+
]
|
|
337
|
+
```
|
|
265
338
|
|
|
266
|
-
|
|
339
|
+
Check each `model` against the gateway's model list before deploying.
|
|
340
|
+
|
|
341
|
+
A priced request costs twice its API cost, in credits of 1 cent: `ceil(cost in
|
|
342
|
+
dollars × 200)`, at least 1. The cost is what OpenRouter or Vercel AI Gateway
|
|
343
|
+
reports charging (with a key of one's own there, the provider's charge
|
|
344
|
+
included), or otherwise the request's input tokens (cached ones included) and
|
|
345
|
+
output tokens (reasoning included) at the model's price. Before asking the
|
|
346
|
+
model, a request holds the most it could cost (each byte of its text as an
|
|
347
|
+
input token, and its longest answer) and starts only if that fits in what its
|
|
348
|
+
payer's organization may still spend this month, extra credits up to its cap
|
|
349
|
+
included, counting other requests still in flight. Once the model
|
|
350
|
+
answers, the request is counted at its real cost; one that fails costs
|
|
351
|
+
nothing. A hold lasts at most 10 minutes, so a request that never finishes
|
|
352
|
+
doesn't block its payer. People see each priced model's cost as "about N
|
|
353
|
+
credits": what a request of 2,000 input and 1,000 output tokens costs, such as
|
|
354
|
+
about 6 credits for Claude Opus 5.5 above.
|
|
355
|
+
|
|
356
|
+
Managed AI stays off until the provider, models, and key are all set. Check it
|
|
267
357
|
with `npx critiqs-react doctor` (or the backend's `/critiqs/health`, whose
|
|
268
|
-
`ai.managed` is `true
|
|
269
|
-
|
|
270
|
-
|
|
358
|
+
`ai.managed` is `true`, or whose `ai.managedProblem` says what's wrong); like
|
|
359
|
+
every health check, that reads configuration without calling the model.
|
|
360
|
+
|
|
361
|
+
### For Critiqs Cloud's operator: payment through Autumn
|
|
362
|
+
|
|
363
|
+
Critiqs Cloud takes payment for its plans through [Autumn](https://useautumn.com),
|
|
364
|
+
which runs Stripe. Other deployments leave this off: without these settings
|
|
365
|
+
nothing calls Autumn, the webhook route answers 404, and `/critiqs/config`
|
|
366
|
+
doesn't report `billing`. Billing needs plans on (`CRITIQS_PLANS=enabled`).
|
|
367
|
+
Set these on the Convex deployment, typing secret values into standard input
|
|
368
|
+
as above:
|
|
369
|
+
|
|
370
|
+
| Setting | Value |
|
|
371
|
+
| --- | --- |
|
|
372
|
+
| `CRITIQS_BILLING` | `autumn` |
|
|
373
|
+
| `AUTUMN_SECRET_KEY` | Autumn's secret key: `am_sk_test_…` for its sandbox, `am_sk_live_…` for real payments |
|
|
374
|
+
| `AUTUMN_WEBHOOK_SECRET` | The `whsec_…` secret Autumn shows once when you add the webhook below |
|
|
375
|
+
| `AUTUMN_API_URL` | Optional: another Autumn address, such as a local stand-in for testing |
|
|
376
|
+
|
|
377
|
+
In Autumn's dashboard (Developer, then Webhooks), add an endpoint at
|
|
378
|
+
`https://<deployment>.convex.site/critiqs/billing/autumn` for `billing.updated`,
|
|
379
|
+
in the same environment as the key. Each verified message makes Critiqs read
|
|
380
|
+
the organization's subscription from Autumn again before it answers, so
|
|
381
|
+
messages that arrive twice, late, or out of order change nothing more. When
|
|
382
|
+
Autumn can't be read, the webhook answers 503 and Autumn sends it again later.
|
|
383
|
+
`/critiqs/health` reports `billing` with the key's environment and whether the
|
|
384
|
+
webhook secret is set, never the keys.
|
|
385
|
+
|
|
386
|
+
Autumn's catalog needs the plans `free` (enabled for every new customer), `plus`,
|
|
387
|
+
and `pro`, the add-on `storage_100gb` granting 100 `extra_storage_gb`, and the
|
|
388
|
+
metered feature `ai_credits`. An organization is Autumn's customer, with the
|
|
389
|
+
organization's ID, its name, and the email of the admin who first opened
|
|
390
|
+
billing. Prices live in Autumn; what each plan allows stays in Critiqs's plans
|
|
391
|
+
(`plans:set`), and the page shows each plan's limits from there, through
|
|
392
|
+
`billing:status`'s `plans`, so changing a plan's limits changes the page.
|
|
393
|
+
Until the backend has read Autumn's prices, changes that would charge the card
|
|
394
|
+
on file (between Plus and Pro, adding storage) are paused; buying on Stripe
|
|
395
|
+
Checkout, which shows the price, going back to Free, and removing storage
|
|
396
|
+
still work.
|
|
397
|
+
|
|
398
|
+
People use it from **Plan and billing** in the avatar menu, which every
|
|
399
|
+
**Upgrade** button opens on such deployments, on the organization whose plan
|
|
400
|
+
it shows: the person's home organization from **Your AI**, the project's
|
|
401
|
+
elsewhere, closing the dialog it was in. Members of an organization see
|
|
402
|
+
its plan, renewal or end date, credits and images used, and the cap on extra
|
|
403
|
+
credits; its admins upgrade, switch, go back to Free, keep a plan they had
|
|
404
|
+
cancelled, set the cap, add or remove Pro's extra storage, and open Stripe's
|
|
405
|
+
portal. A change that charges the card on file or ends something says what it
|
|
406
|
+
does and costs before it is made, naming the organization. Stripe returns to
|
|
407
|
+
the same page, which waits for the payment to arrive and allows no other
|
|
408
|
+
change meanwhile. Dates are the days Autumn's periods end, in UTC.
|
|
409
|
+
|
|
410
|
+
- **Plans.** An admin buying Plus or Pro with nothing billed pays on Stripe
|
|
411
|
+
Checkout, even with a card on file. Each change names the plan the page
|
|
412
|
+
showed as billed (`from`); when Autumn bills another by then, as when a
|
|
413
|
+
payment arrived meanwhile, it is refused and nothing is charged. Between Plus
|
|
414
|
+
and Pro with a card on file, Autumn charges an upgrade at once,
|
|
415
|
+
prorated, and moves a downgrade to the end of the period. Going back to Free
|
|
416
|
+
cancels at the end of the period. A renewal that fails (`past_due`) keeps the
|
|
417
|
+
paid plan; when Stripe gives up, the organization is on Free. Free after a
|
|
418
|
+
downgrade to Plus was scheduled drops the downgrade and ends the paid plan
|
|
419
|
+
with its period. A changed plan starts from its default cap on extra credits.
|
|
420
|
+
Stripe sends people back only to the site they signed in from.
|
|
421
|
+
- **Storage.** Pro organizations can buy a 100 GB storage add-on. Autumn makes
|
|
422
|
+
each attach its own subscription, so add-ons attached elsewhere (such as
|
|
423
|
+
Autumn's dashboard) stack: two grant 200 GB. Critiqs grants 100 GB for each
|
|
424
|
+
active add-on and shows those that renew. Removing storage cancels one at the
|
|
425
|
+
end of its period; leaving Pro cancels all of them with Pro, and keeping Pro
|
|
426
|
+
before then restores those, but not one the admin removed.
|
|
427
|
+
- **Usage.** Each Critiqs AI charge to an organization on Plus or Pro is
|
|
428
|
+
queued in the same transaction and reported to Autumn's `ai_credits` at
|
|
429
|
+
once, then each minute until Autumn has it, with the time it was used, in
|
|
430
|
+
full past the plan's included credits (Critiqs enforces the cap), and with
|
|
431
|
+
its own idempotency key, so retries never count twice. Autumn counts usage
|
|
432
|
+
in the billing period current when the report arrives, whatever its time
|
|
433
|
+
says, so usage still being sent when the month turns over (UTC, when plans
|
|
434
|
+
renew) is billed in the new month, and usage held up by an Autumn outage is
|
|
435
|
+
billed in the month it gets through. Autumn remembers a key for 24 hours,
|
|
436
|
+
so a report already tried but not sent within 20 hours of use is never
|
|
437
|
+
sent again: it is kept as `failed` in the `billingUsage` table and logged.
|
|
438
|
+
A report never tried is still sent, however old.
|
|
439
|
+
`npx convex run billing:failedUsage` lists the failed reports with their
|
|
440
|
+
credits per organization, which were never billed.
|
|
441
|
+
- **Plans an operator assigns** (`plans:assign`) stay until the organization's
|
|
442
|
+
Autumn subscription next changes. `billing:status` reports the plan whose
|
|
443
|
+
limits apply as `plan` and the billed one as `subscription.plan`, so such a
|
|
444
|
+
plan has no `subscription`: the page says Critiqs set it, and buying a plan
|
|
445
|
+
starts a subscription on Checkout that replaces it.
|
|
446
|
+
|
|
447
|
+
A daily check reads every organization with an Autumn customer or a paid plan
|
|
448
|
+
from Autumn again, catching anything a lost webhook missed. Run it at any time,
|
|
449
|
+
for example after first setting the webhook, with
|
|
450
|
+
`npx convex run billing:reconcile`, or for one organization with
|
|
451
|
+
`npx convex run billing:sync '{"organizationId":"..."}'`.
|
|
271
452
|
|
|
272
453
|
## Screenshot storage on Convex
|
|
273
454
|
|
|
@@ -286,6 +467,8 @@ If your prototype has its own long-running Node or Bun server with a disk that
|
|
|
286
467
|
survives restarts, Critiqs can run inside it and keep feedback in a SQLite file.
|
|
287
468
|
No Critiqs service is involved. Static hosts and serverless platforms such as
|
|
288
469
|
Vercel can't keep the file; use Critiqs Cloud or your own Convex there.
|
|
470
|
+
`critiqs-react/server` is the shared package's `critiqs/server`; either import
|
|
471
|
+
works.
|
|
289
472
|
|
|
290
473
|
```ts
|
|
291
474
|
import { createCritiqsHandler, toNodeListener } from "critiqs-react/server";
|
|
@@ -330,13 +513,13 @@ const critiqs = await createCritiqsHandler({
|
|
|
330
513
|
});
|
|
331
514
|
```
|
|
332
515
|
|
|
333
|
-
Model requests come from this server, so
|
|
334
|
-
machine. Existing feedback gains its hashtags when the database upgrades on start.
|
|
516
|
+
Model requests and providers' model lists come from this server, so
|
|
517
|
+
`localhost` means this server's machine. Existing feedback gains its hashtags when the database upgrades on start.
|
|
335
518
|
Back up the database with SQLite's online backup
|
|
336
519
|
(`sqlite3 critiqs.sqlite ".backup backup.sqlite"`).
|
|
337
520
|
|
|
338
521
|
The first-release API and interaction choices remain provisional. See the
|
|
339
|
-
[project documentation](https://github.com/noahsjung/
|
|
522
|
+
[project documentation](https://github.com/noahsjung/critiqs/tree/main/docs)
|
|
340
523
|
for agreed behavior, proposed choices, and own-backend setup.
|
|
341
524
|
|
|
342
525
|
Critiqs is released under the [MIT license](LICENSE).
|
package/bin/critiqs.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
// `npx critiqs-react <command>` runs the shared Critiqs setup CLI from the
|
|
3
|
+
// critiqs package, the same as `npx critiqs <command>`.
|
|
4
|
+
import { runCli } from "critiqs/cli";
|
|
3
5
|
|
|
4
6
|
process.exitCode = await runCli(process.argv.slice(2));
|