critiqs-react 0.0.0-stage → 0.3.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.
Files changed (64) hide show
  1. package/AGENT_SETUP.md +190 -0
  2. package/LICENSE +21 -0
  3. package/README.md +341 -2
  4. package/bin/cli.d.mts +21 -0
  5. package/bin/cli.mjs +293 -0
  6. package/bin/critiqs.mjs +4 -0
  7. package/bin/env.d.mts +41 -0
  8. package/bin/env.mjs +384 -0
  9. package/bin/init.d.mts +126 -0
  10. package/bin/init.mjs +965 -0
  11. package/bin/mcp.d.mts +20 -0
  12. package/bin/mcp.mjs +314 -0
  13. package/bin/setup.d.mts +183 -0
  14. package/bin/setup.mjs +1054 -0
  15. package/dist/Critiqs.d.ts +9 -0
  16. package/dist/backend/convex/_generated/api.d.ts +95 -0
  17. package/dist/backend/convex/_generated/api.js +23 -0
  18. package/dist/backend/convex/_generated/dataModel.d.ts +60 -0
  19. package/dist/backend/convex/_generated/server.d.ts +162 -0
  20. package/dist/backend/convex/_generated/server.js +101 -0
  21. package/dist/backend/convex/ai.ts +93 -0
  22. package/dist/backend/convex/aiSettings.ts +43 -0
  23. package/dist/backend/convex/auth.config.ts +18 -0
  24. package/dist/backend/convex/captureHttp.ts +96 -0
  25. package/dist/backend/convex/captures.ts +167 -0
  26. package/dist/backend/convex/crons.ts +14 -0
  27. package/dist/backend/convex/deviceSignIn.ts +151 -0
  28. package/dist/backend/convex/grouping.ts +41 -0
  29. package/dist/backend/convex/http.ts +724 -0
  30. package/dist/backend/convex/lib/ai.ts +6 -0
  31. package/dist/backend/convex/lib/links.ts +12 -0
  32. package/dist/backend/convex/lib/pages.ts +207 -0
  33. package/dist/backend/convex/lib/r2.ts +75 -0
  34. package/dist/backend/convex/lib/store.ts +509 -0
  35. package/dist/backend/convex/lib/tokens.ts +101 -0
  36. package/dist/backend/convex/lib/validators.ts +73 -0
  37. package/dist/backend/convex/lib/vendor/aws4fetch.js +289 -0
  38. package/dist/backend/convex/lib/vendor/critiqs_ai.js +49081 -0
  39. package/dist/backend/convex/lib/vendor/critiqs_core.js +385 -0
  40. package/dist/backend/convex/lib/vendor/critiqs_server.js +3108 -0
  41. package/dist/backend/convex/notificationEmails.ts +61 -0
  42. package/dist/backend/convex/notifications.ts +182 -0
  43. package/dist/backend/convex/plans.ts +67 -0
  44. package/dist/backend/convex/projects.ts +46 -0
  45. package/dist/backend/convex/schema.ts +343 -0
  46. package/dist/backend/convex/search.ts +26 -0
  47. package/dist/backend/convex/signIn.ts +368 -0
  48. package/dist/backend/convex/tags.ts +68 -0
  49. package/dist/backend/convex/threads.ts +146 -0
  50. package/dist/backend/convex/users.ts +13 -0
  51. package/dist/constants.d.ts +4 -0
  52. package/dist/core/types.d.ts +72 -0
  53. package/dist/host.d.ts +66 -0
  54. package/dist/index.d.ts +4 -0
  55. package/dist/index.js +8076 -0
  56. package/dist/server/chunks/driver-n9zpr0k3.js +21 -0
  57. package/dist/server/chunks/index-9bg7tmnq.js +522 -0
  58. package/dist/server/chunks/index-askcfn7t.js +148 -0
  59. package/dist/server/chunks/providers-rv184xvj.js +48444 -0
  60. package/dist/server/chunks/token-kzddms7r.js +63 -0
  61. package/dist/server/chunks/token-util-k8bee1wc.js +4 -0
  62. package/dist/server/index.d.ts +87 -0
  63. package/dist/server/index.js +4889 -0
  64. package/package.json +77 -4
@@ -0,0 +1,63 @@
1
+ import {
2
+ __commonJS,
3
+ require_token_error,
4
+ require_token_util
5
+ } from "./index-9bg7tmnq.js";
6
+
7
+ // ../../node_modules/.bun/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/token.js
8
+ var require_token = __commonJS(function(exports, module) {
9
+ var __defProp = Object.defineProperty;
10
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11
+ var __getOwnPropNames = Object.getOwnPropertyNames;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __export = (target, all) => {
14
+ for (var name in all)
15
+ __defProp(target, name, { get: all[name], enumerable: true });
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
+ var token_exports = {};
27
+ __export(token_exports, {
28
+ refreshToken: () => refreshToken
29
+ });
30
+ module.exports = __toCommonJS(token_exports);
31
+ var import_token_error = require_token_error();
32
+ var import_token_util = require_token_util();
33
+ async function refreshToken(options) {
34
+ let projectId = options?.project;
35
+ let teamId = options?.team;
36
+ if (!projectId && !teamId) {
37
+ const projectInfo = (0, import_token_util.findProjectInfo)();
38
+ projectId = projectInfo.projectId;
39
+ teamId = projectInfo.teamId;
40
+ } else if (!projectId || !teamId) {
41
+ const projectInfo = (0, import_token_util.findProjectInfo)();
42
+ projectId = projectId ?? projectInfo.projectId;
43
+ teamId = teamId ?? projectInfo.teamId;
44
+ }
45
+ if (!projectId) {
46
+ throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
47
+ }
48
+ let maybeToken = (0, import_token_util.loadToken)(projectId);
49
+ if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
50
+ const authToken = await (0, import_token_util.getVercelToken)({
51
+ expirationBufferMs: options?.expirationBufferMs
52
+ });
53
+ maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
54
+ if (!maybeToken) {
55
+ throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
56
+ }
57
+ (0, import_token_util.saveToken)(maybeToken, projectId);
58
+ }
59
+ process.env.VERCEL_OIDC_TOKEN = maybeToken.token;
60
+ return;
61
+ }
62
+ });
63
+ export default require_token();
@@ -0,0 +1,4 @@
1
+ import {
2
+ require_token_util
3
+ } from "./index-9bg7tmnq.js";
4
+ export default require_token_util();
@@ -0,0 +1,87 @@
1
+ // Public types for `critiqs-react/server`: Critiqs's server inside the host
2
+ // app's own Node or Bun server, storing feedback in a SQLite file.
3
+ // Built-in SQLite requires Node.js 22.13 or later, or Bun; the setup CLI also supports Node.js 20.
4
+
5
+ /** Someone the host app has already signed in. */
6
+ export interface HostUser {
7
+ /** The host app's permanent ID for them. */
8
+ id: string;
9
+ name: string;
10
+ /** Where mention emails go; the host app vouches that it is theirs. */
11
+ email: string;
12
+ pictureUrl?: string | null;
13
+ }
14
+
15
+ /** The few calls Critiqs needs from a SQLite library. */
16
+ export interface SqlDriver {
17
+ exec(sql: string): void;
18
+ run(sql: string, params?: unknown[]): void;
19
+ get<T>(sql: string, params?: unknown[]): T | undefined;
20
+ all<T>(sql: string, params?: unknown[]): T[];
21
+ }
22
+
23
+ export interface CritiqsHandlerOptions {
24
+ /** A SQLite file path (Bun's SQLite under Bun, node:sqlite under Node), or a driver. */
25
+ database: string | SqlDriver;
26
+ /** Where the handler is mounted; the component's `backend` is this path. Default `/critiqs`. */
27
+ basePath?: string;
28
+ /** Resend key and sender, for sign-in codes and mention emails. */
29
+ email?: { resendApiKey: string; from: string };
30
+ /**
31
+ * Uses the host app's own sign-in instead of Critiqs's email codes: returns
32
+ * who made the request, or null when nobody is signed in to the app.
33
+ */
34
+ identify?: (request: Request) => HostUser | null | Promise<HostUser | null>;
35
+ /**
36
+ * Shows sign-in codes on screen instead of emailing them, only for requests
37
+ * whose connection comes from this computer (see `fetch`'s `remoteAddress`).
38
+ */
39
+ developmentSignIn?: boolean;
40
+ /**
41
+ * AI for automatic tag grouping, natural-language search, and insights. The
42
+ * provider here is the default for every project; with `encryptionKey`,
43
+ * project owners can also connect their own provider in Critiqs, whose keys
44
+ * are stored encrypted. Read these from your server's environment; never
45
+ * put keys in browser code. Search and grouping still work without AI.
46
+ */
47
+ ai?: CritiqsAiOptions;
48
+ }
49
+
50
+ export interface CritiqsAiOptions {
51
+ provider?: "openai" | "anthropic" | "google" | "gateway" | "compatible";
52
+ model?: string;
53
+ apiKey?: string;
54
+ /** The provider's address; required for an OpenAI-compatible endpoint, such as `http://localhost:11434/v1` for Ollama. */
55
+ baseURL?: string;
56
+ /** At least 32 random characters, such as from `openssl rand -base64 32`; lets owners store their own keys, encrypted. */
57
+ encryptionKey?: string;
58
+ /** Endpoint addresses owners may enter, such as `https://llm.example.com/v1`. */
59
+ allowedEndpoints?: string[];
60
+ /** Allows `http://` and private-network addresses among `allowedEndpoints`, for providers on your own network. */
61
+ allowLocalEndpoints?: boolean;
62
+ /** Longest a model request may take. Default 30 seconds. */
63
+ timeoutMs?: number;
64
+ }
65
+
66
+ export interface CritiqsHandler {
67
+ /**
68
+ * Answers requests under `basePath`; others get 404. `remoteAddress` is the
69
+ * connection's address (Bun: `server.requestIP(request)?.address`), which
70
+ * development sign-in needs to know a request comes from this computer.
71
+ */
72
+ fetch(request: Request, connection?: { remoteAddress?: string }): Promise<Response>;
73
+ /** Sends due mention emails now; this also runs every minute. */
74
+ deliverMentionEmails(): Promise<void>;
75
+ /** Groups tags waiting for automatic grouping now; this also runs every minute. */
76
+ groupTags(): Promise<void>;
77
+ /** Stops the mention email and grouping timer. */
78
+ close(): void;
79
+ }
80
+
81
+ /** Creates Critiqs's request handler for a host app's server. */
82
+ export declare function createCritiqsHandler(options: CritiqsHandlerOptions): Promise<CritiqsHandler>;
83
+
84
+ /** The handler as a Node `(req, res)` listener, for `http.createServer` or Express. */
85
+ export declare function toNodeListener(
86
+ handler: CritiqsHandler,
87
+ ): (request: import("node:http").IncomingMessage, response: import("node:http").ServerResponse) => Promise<void>;