critiqs-react 0.3.0 → 0.5.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 (58) hide show
  1. package/AGENT_SETUP.md +198 -66
  2. package/README.md +214 -31
  3. package/bin/critiqs.mjs +3 -1
  4. package/dist/index.js +16877 -4770
  5. package/dist/server/index.d.ts +1 -87
  6. package/dist/server/index.js +1 -4889
  7. package/package.json +6 -5
  8. package/bin/cli.d.mts +0 -21
  9. package/bin/cli.mjs +0 -293
  10. package/bin/env.d.mts +0 -41
  11. package/bin/env.mjs +0 -384
  12. package/bin/init.d.mts +0 -126
  13. package/bin/init.mjs +0 -965
  14. package/bin/mcp.d.mts +0 -20
  15. package/bin/mcp.mjs +0 -314
  16. package/bin/setup.d.mts +0 -183
  17. package/bin/setup.mjs +0 -1054
  18. package/dist/backend/convex/_generated/api.d.ts +0 -95
  19. package/dist/backend/convex/_generated/api.js +0 -23
  20. package/dist/backend/convex/_generated/dataModel.d.ts +0 -60
  21. package/dist/backend/convex/_generated/server.d.ts +0 -162
  22. package/dist/backend/convex/_generated/server.js +0 -101
  23. package/dist/backend/convex/ai.ts +0 -93
  24. package/dist/backend/convex/aiSettings.ts +0 -43
  25. package/dist/backend/convex/auth.config.ts +0 -18
  26. package/dist/backend/convex/captureHttp.ts +0 -96
  27. package/dist/backend/convex/captures.ts +0 -167
  28. package/dist/backend/convex/crons.ts +0 -14
  29. package/dist/backend/convex/deviceSignIn.ts +0 -151
  30. package/dist/backend/convex/grouping.ts +0 -41
  31. package/dist/backend/convex/http.ts +0 -724
  32. package/dist/backend/convex/lib/ai.ts +0 -6
  33. package/dist/backend/convex/lib/links.ts +0 -12
  34. package/dist/backend/convex/lib/pages.ts +0 -207
  35. package/dist/backend/convex/lib/r2.ts +0 -75
  36. package/dist/backend/convex/lib/store.ts +0 -509
  37. package/dist/backend/convex/lib/tokens.ts +0 -101
  38. package/dist/backend/convex/lib/validators.ts +0 -73
  39. package/dist/backend/convex/lib/vendor/aws4fetch.js +0 -289
  40. package/dist/backend/convex/lib/vendor/critiqs_ai.js +0 -49081
  41. package/dist/backend/convex/lib/vendor/critiqs_core.js +0 -385
  42. package/dist/backend/convex/lib/vendor/critiqs_server.js +0 -3108
  43. package/dist/backend/convex/notificationEmails.ts +0 -61
  44. package/dist/backend/convex/notifications.ts +0 -182
  45. package/dist/backend/convex/plans.ts +0 -67
  46. package/dist/backend/convex/projects.ts +0 -46
  47. package/dist/backend/convex/schema.ts +0 -343
  48. package/dist/backend/convex/search.ts +0 -26
  49. package/dist/backend/convex/signIn.ts +0 -368
  50. package/dist/backend/convex/tags.ts +0 -68
  51. package/dist/backend/convex/threads.ts +0 -146
  52. package/dist/backend/convex/users.ts +0 -13
  53. package/dist/server/chunks/driver-n9zpr0k3.js +0 -21
  54. package/dist/server/chunks/index-9bg7tmnq.js +0 -522
  55. package/dist/server/chunks/index-askcfn7t.js +0 -148
  56. package/dist/server/chunks/providers-rv184xvj.js +0 -48444
  57. package/dist/server/chunks/token-kzddms7r.js +0 -63
  58. package/dist/server/chunks/token-util-k8bee1wc.js +0 -4
@@ -1,95 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Generated `api` utility.
4
- *
5
- * THIS CODE IS AUTOMATICALLY GENERATED.
6
- *
7
- * To regenerate, run `npx convex dev`.
8
- * @module
9
- */
10
-
11
- import type * as ai from "../ai.js";
12
- import type * as aiSettings from "../aiSettings.js";
13
- import type * as captureHttp from "../captureHttp.js";
14
- import type * as captures from "../captures.js";
15
- import type * as crons from "../crons.js";
16
- import type * as deviceSignIn from "../deviceSignIn.js";
17
- import type * as grouping from "../grouping.js";
18
- import type * as http from "../http.js";
19
- import type * as lib_ai from "../lib/ai.js";
20
- import type * as lib_links from "../lib/links.js";
21
- import type * as lib_pages from "../lib/pages.js";
22
- import type * as lib_r2 from "../lib/r2.js";
23
- import type * as lib_store from "../lib/store.js";
24
- import type * as lib_tokens from "../lib/tokens.js";
25
- import type * as lib_validators from "../lib/validators.js";
26
- import type * as notificationEmails from "../notificationEmails.js";
27
- import type * as notifications from "../notifications.js";
28
- import type * as plans from "../plans.js";
29
- import type * as projects from "../projects.js";
30
- import type * as search from "../search.js";
31
- import type * as signIn from "../signIn.js";
32
- import type * as tags from "../tags.js";
33
- import type * as threads from "../threads.js";
34
- import type * as users from "../users.js";
35
-
36
- import type {
37
- ApiFromModules,
38
- FilterApi,
39
- FunctionReference,
40
- } from "convex/server";
41
-
42
- declare const fullApi: ApiFromModules<{
43
- ai: typeof ai;
44
- aiSettings: typeof aiSettings;
45
- captureHttp: typeof captureHttp;
46
- captures: typeof captures;
47
- crons: typeof crons;
48
- deviceSignIn: typeof deviceSignIn;
49
- grouping: typeof grouping;
50
- http: typeof http;
51
- "lib/ai": typeof lib_ai;
52
- "lib/links": typeof lib_links;
53
- "lib/pages": typeof lib_pages;
54
- "lib/r2": typeof lib_r2;
55
- "lib/store": typeof lib_store;
56
- "lib/tokens": typeof lib_tokens;
57
- "lib/validators": typeof lib_validators;
58
- notificationEmails: typeof notificationEmails;
59
- notifications: typeof notifications;
60
- plans: typeof plans;
61
- projects: typeof projects;
62
- search: typeof search;
63
- signIn: typeof signIn;
64
- tags: typeof tags;
65
- threads: typeof threads;
66
- users: typeof users;
67
- }>;
68
-
69
- /**
70
- * A utility for referencing Convex functions in your app's public API.
71
- *
72
- * Usage:
73
- * ```js
74
- * const myFunctionReference = api.myModule.myFunction;
75
- * ```
76
- */
77
- export declare const api: FilterApi<
78
- typeof fullApi,
79
- FunctionReference<any, "public">
80
- >;
81
-
82
- /**
83
- * A utility for referencing Convex functions in your app's internal API.
84
- *
85
- * Usage:
86
- * ```js
87
- * const myFunctionReference = internal.myModule.myFunction;
88
- * ```
89
- */
90
- export declare const internal: FilterApi<
91
- typeof fullApi,
92
- FunctionReference<any, "internal">
93
- >;
94
-
95
- export declare const components: {};
@@ -1,23 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Generated `api` utility.
4
- *
5
- * THIS CODE IS AUTOMATICALLY GENERATED.
6
- *
7
- * To regenerate, run `npx convex dev`.
8
- * @module
9
- */
10
-
11
- import { anyApi, componentsGeneric } from "convex/server";
12
-
13
- /**
14
- * A utility for referencing Convex functions in your app's API.
15
- *
16
- * Usage:
17
- * ```js
18
- * const myFunctionReference = api.myModule.myFunction;
19
- * ```
20
- */
21
- export const api = anyApi;
22
- export const internal = anyApi;
23
- export const components = componentsGeneric();
@@ -1,60 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Generated data model types.
4
- *
5
- * THIS CODE IS AUTOMATICALLY GENERATED.
6
- *
7
- * To regenerate, run `npx convex dev`.
8
- * @module
9
- */
10
-
11
- import type {
12
- DataModelFromSchemaDefinition,
13
- DocumentByName,
14
- TableNamesInDataModel,
15
- SystemTableNames,
16
- } from "convex/server";
17
- import type { GenericId } from "convex/values";
18
- import schema from "../schema.js";
19
-
20
- /**
21
- * The names of all of your Convex tables.
22
- */
23
- export type TableNames = TableNamesInDataModel<DataModel>;
24
-
25
- /**
26
- * The type of a document stored in Convex.
27
- *
28
- * @typeParam TableName - A string literal type of the table name (like "users").
29
- */
30
- export type Doc<TableName extends TableNames> = DocumentByName<
31
- DataModel,
32
- TableName
33
- >;
34
-
35
- /**
36
- * An identifier for a document in Convex.
37
- *
38
- * Convex documents are uniquely identified by their `Id`, which is accessible
39
- * on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
40
- *
41
- * Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
42
- *
43
- * IDs are just strings at runtime, but this type can be used to distinguish them from other
44
- * strings when type checking.
45
- *
46
- * @typeParam TableName - A string literal type of the table name (like "users").
47
- */
48
- export type Id<TableName extends TableNames | SystemTableNames> =
49
- GenericId<TableName>;
50
-
51
- /**
52
- * A type describing your Convex data model.
53
- *
54
- * This type includes information about what tables you have, the type of
55
- * documents stored in those tables, and the indexes defined on them.
56
- *
57
- * This type is used to parameterize methods like `queryGeneric` and
58
- * `mutationGeneric` to make them type-safe.
59
- */
60
- export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
@@ -1,162 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Generated utilities for implementing server-side Convex query and mutation functions.
4
- *
5
- * THIS CODE IS AUTOMATICALLY GENERATED.
6
- *
7
- * To regenerate, run `npx convex dev`.
8
- * @module
9
- */
10
-
11
- import {
12
- ActionBuilder,
13
- HttpActionBuilder,
14
- MutationBuilder,
15
- QueryBuilder,
16
- GenericActionCtx,
17
- GenericMutationCtx,
18
- GenericQueryCtx,
19
- GenericDatabaseReader,
20
- GenericDatabaseWriter,
21
- } from "convex/server";
22
- import type { DataModel } from "./dataModel.js";
23
-
24
- /**
25
- * Typesafe environment variables.
26
- *
27
- * This includes platform-provided env vars and any variables declared in
28
- * `convex.config.ts`.
29
- */
30
- type Env = {
31
- readonly CONVEX_CLOUD_URL: string;
32
- readonly CONVEX_SITE_URL: string;
33
- };
34
-
35
- /**
36
- * Define a query in this Convex app's public API.
37
- *
38
- * This function will be allowed to read your Convex database and will be accessible from the client.
39
- *
40
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
41
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
42
- */
43
- export declare const query: QueryBuilder<DataModel, "public">;
44
-
45
- /**
46
- * Define a query that is only accessible from other Convex functions (but not from the client).
47
- *
48
- * This function will be allowed to read from your Convex database. It will not be accessible from the client.
49
- *
50
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
51
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
52
- */
53
- export declare const internalQuery: QueryBuilder<DataModel, "internal">;
54
-
55
- /**
56
- * Define a mutation in this Convex app's public API.
57
- *
58
- * This function will be allowed to modify your Convex database and will be accessible from the client.
59
- *
60
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
61
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
62
- */
63
- export declare const mutation: MutationBuilder<DataModel, "public">;
64
-
65
- /**
66
- * Define a mutation that is only accessible from other Convex functions (but not from the client).
67
- *
68
- * This function will be allowed to modify your Convex database. It will not be accessible from the client.
69
- *
70
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
71
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
72
- */
73
- export declare const internalMutation: MutationBuilder<DataModel, "internal">;
74
-
75
- /**
76
- * Define an action in this Convex app's public API.
77
- *
78
- * An action is a function which can execute any JavaScript code, including non-deterministic
79
- * code and code with side-effects, like calling third-party services.
80
- * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
81
- * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
82
- *
83
- * @param func - The action. It receives an {@link ActionCtx} as its first argument.
84
- * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
85
- */
86
- export declare const action: ActionBuilder<DataModel, "public">;
87
-
88
- /**
89
- * Define an action that is only accessible from other Convex functions (but not from the client).
90
- *
91
- * @param func - The function. It receives an {@link ActionCtx} as its first argument.
92
- * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
93
- */
94
- export declare const internalAction: ActionBuilder<DataModel, "internal">;
95
-
96
- /**
97
- * Define an HTTP action.
98
- *
99
- * The wrapped function will be used to respond to HTTP requests received
100
- * by a Convex deployment if the requests matches the path and method where
101
- * this action is routed. Be sure to route your httpAction in `convex/http.js`.
102
- *
103
- * @param func - The function. It receives an {@link ActionCtx} as its first argument
104
- * and a Fetch API `Request` object as its second.
105
- * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
106
- */
107
- export declare const httpAction: HttpActionBuilder;
108
-
109
- /**
110
- * Typesafe environment variables.
111
- *
112
- * This includes platform-provided env vars and any variables declared in
113
- * `convex.config.ts`.
114
- */
115
- export declare const env: Env;
116
-
117
- /**
118
- * A set of services for use within Convex query functions.
119
- *
120
- * The query context is passed as the first argument to any Convex query
121
- * function run on the server.
122
- *
123
- * This differs from the {@link MutationCtx} because all of the services are
124
- * read-only.
125
- */
126
- export type QueryCtx = GenericQueryCtx<DataModel>;
127
-
128
- /**
129
- * A set of services for use within Convex mutation functions.
130
- *
131
- * The mutation context is passed as the first argument to any Convex mutation
132
- * function run on the server.
133
- */
134
- export type MutationCtx = GenericMutationCtx<DataModel>;
135
-
136
- /**
137
- * A set of services for use within Convex action functions.
138
- *
139
- * The action context is passed as the first argument to any Convex action
140
- * function run on the server.
141
- */
142
- export type ActionCtx = GenericActionCtx<DataModel>;
143
-
144
- /**
145
- * An interface to read from the database within Convex query functions.
146
- *
147
- * The two entry points are {@link DatabaseReader.get}, which fetches a single
148
- * document by its {@link Id}, or {@link DatabaseReader.query}, which starts
149
- * building a query.
150
- */
151
- export type DatabaseReader = GenericDatabaseReader<DataModel>;
152
-
153
- /**
154
- * An interface to read from and write to the database within Convex mutation
155
- * functions.
156
- *
157
- * Convex guarantees that all writes within a single mutation are
158
- * executed atomically, so you never have to worry about partial writes leaving
159
- * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
160
- * for the guarantees Convex provides your functions.
161
- */
162
- export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
@@ -1,101 +0,0 @@
1
- /* eslint-disable */
2
- /**
3
- * Generated utilities for implementing server-side Convex query and mutation functions.
4
- *
5
- * THIS CODE IS AUTOMATICALLY GENERATED.
6
- *
7
- * To regenerate, run `npx convex dev`.
8
- * @module
9
- */
10
-
11
- import {
12
- actionGeneric,
13
- httpActionGeneric,
14
- queryGeneric,
15
- mutationGeneric,
16
- internalActionGeneric,
17
- internalMutationGeneric,
18
- internalQueryGeneric,
19
- } from "convex/server";
20
-
21
- /**
22
- * Define a query in this Convex app's public API.
23
- *
24
- * This function will be allowed to read your Convex database and will be accessible from the client.
25
- *
26
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
27
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
28
- */
29
- export const query = queryGeneric;
30
-
31
- /**
32
- * Define a query that is only accessible from other Convex functions (but not from the client).
33
- *
34
- * This function will be allowed to read from your Convex database. It will not be accessible from the client.
35
- *
36
- * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
37
- * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
38
- */
39
- export const internalQuery = internalQueryGeneric;
40
-
41
- /**
42
- * Define a mutation in this Convex app's public API.
43
- *
44
- * This function will be allowed to modify your Convex database and will be accessible from the client.
45
- *
46
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
47
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
48
- */
49
- export const mutation = mutationGeneric;
50
-
51
- /**
52
- * Define a mutation that is only accessible from other Convex functions (but not from the client).
53
- *
54
- * This function will be allowed to modify your Convex database. It will not be accessible from the client.
55
- *
56
- * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
57
- * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
58
- */
59
- export const internalMutation = internalMutationGeneric;
60
-
61
- /**
62
- * Define an action in this Convex app's public API.
63
- *
64
- * An action is a function which can execute any JavaScript code, including non-deterministic
65
- * code and code with side-effects, like calling third-party services.
66
- * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
67
- * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
68
- *
69
- * @param func - The action. It receives an {@link ActionCtx} as its first argument.
70
- * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
71
- */
72
- export const action = actionGeneric;
73
-
74
- /**
75
- * Define an action that is only accessible from other Convex functions (but not from the client).
76
- *
77
- * @param func - The function. It receives an {@link ActionCtx} as its first argument.
78
- * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
79
- */
80
- export const internalAction = internalActionGeneric;
81
-
82
- /**
83
- * Define an HTTP action.
84
- *
85
- * The wrapped function will be used to respond to HTTP requests received
86
- * by a Convex deployment if the requests matches the path and method where
87
- * this action is routed. Be sure to route your httpAction in `convex/http.js`.
88
- *
89
- * @param func - The function. It receives an {@link ActionCtx} as its first argument
90
- * and a Fetch API `Request` object as its second.
91
- * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
92
- */
93
- export const httpAction = httpActionGeneric;
94
-
95
- /**
96
- * Typesafe environment variables.
97
- *
98
- * This includes platform-provided env vars and any variables declared in
99
- * `convex.config.ts`.
100
- */
101
- export const env = process.env;
@@ -1,93 +0,0 @@
1
- "use node";
2
-
3
- import type { AiSettingsInput, AiSettingsView, AiTestResult, SearchResponse } from "./lib/vendor/critiqs_core.js";
4
- import { groupDueTags, prepareSettings, type ResolvedConnection, runSearch, sealKey, testConnection } from "./lib/vendor/critiqs_server.js";
5
- import { createStructuredModel } from "./lib/vendor/critiqs_ai.js";
6
- import { v } from "convex/values";
7
- import { internal } from "./_generated/api";
8
- import { action, internalAction } from "./_generated/server";
9
- import { deployment } from "./lib/ai";
10
- import { run } from "./lib/store";
11
-
12
- // Critiqs's model calls: natural-language search with insights, saving and
13
- // testing a project's AI connection, and automatic tag grouping. They run in
14
- // Convex's Node runtime, where the AI SDK and provider packages load; every
15
- // read and write is a separate transaction, with authorization checked in
16
- // each before any model call.
17
-
18
- const model = (connection: Extract<ResolvedConnection, { ready: true }>) => createStructuredModel(connection);
19
-
20
- const scope = v.object({ status: v.union(v.literal("open"), v.literal("resolved"), v.literal("all")), screen: v.union(v.string(), v.null()) });
21
- const settingsInput = {
22
- projectId: v.id("projects"),
23
- enabled: v.boolean(),
24
- mode: v.union(v.literal("managed"), v.literal("own")),
25
- provider: v.optional(v.union(v.null(), v.literal("openai"), v.literal("anthropic"), v.literal("google"), v.literal("gateway"), v.literal("compatible"))),
26
- model: v.optional(v.union(v.string(), v.null())),
27
- baseUrl: v.optional(v.union(v.string(), v.null())),
28
- apiKey: v.optional(v.string()),
29
- };
30
-
31
- /** Searches a project's feedback: AI interpretation and cited insights when the project has AI, basic search otherwise. */
32
- export const search = action({
33
- args: { projectId: v.id("projects"), question: v.string(), scope },
34
- handler: async (ctx, args): Promise<SearchResponse> =>
35
- run(() =>
36
- runSearch({
37
- prepare: () => ctx.runMutation(internal.search.prepare, args),
38
- retrieve: (query, groups) => ctx.runQuery(internal.search.retrieve, { projectId: args.projectId, query, groups }),
39
- finalize: (response) => ctx.runQuery(internal.search.finalize, { projectId: args.projectId, response }),
40
- model,
41
- deployment: deployment(),
42
- now: Date.now(),
43
- }),
44
- ),
45
- });
46
-
47
- /** Saves a project's AI settings. A new key is encrypted here and only its ciphertext is stored. */
48
- export const saveSettings = action({
49
- args: settingsInput,
50
- handler: async (ctx, input): Promise<AiSettingsView> =>
51
- run(async () => {
52
- await ctx.runQuery(internal.aiSettings.requireOwner, { projectId: input.projectId });
53
- const config = deployment();
54
- const prepared = await sealKey(await prepareSettings(input as AiSettingsInput, config), input.projectId, config);
55
- return await ctx.runMutation(internal.aiSettings.apply, { projectId: input.projectId, prepared });
56
- }),
57
- });
58
-
59
- /** Tests the saved connection, or a draft before saving it. */
60
- export const testSettings = action({
61
- args: { projectId: v.id("projects"), draft: v.optional(v.object(settingsInput)) },
62
- handler: async (ctx, { projectId, draft }): Promise<AiTestResult> =>
63
- run(() =>
64
- testConnection(
65
- {
66
- prepare: () => ctx.runMutation(internal.aiSettings.prepareTest, { projectId }),
67
- record: async (epoch, result) => void (await ctx.runMutation(internal.aiSettings.recordTest, { projectId, epoch, result })),
68
- charge: async () => void (await ctx.runMutation(internal.aiSettings.chargeTest, { projectId })),
69
- model,
70
- deployment: deployment(),
71
- },
72
- draft === undefined ? undefined : ({ ...draft, projectId } as AiSettingsInput),
73
- ),
74
- ),
75
- });
76
-
77
- /** Groups tags waiting for automatic grouping, a project at a time. Runs every minute. */
78
- export const groupTags = internalAction({
79
- args: {},
80
- handler: async (ctx) => {
81
- await groupDueTags({
82
- claim: (claimToken) => ctx.runMutation(internal.grouping.claim, { claimToken }),
83
- apply: (claim, answer) =>
84
- ctx.runMutation(internal.grouping.apply, {
85
- claim,
86
- assignments: [...answer.assignments].map(([key, assignment]) => ({ key, ...assignment })),
87
- }),
88
- fail: async (claim, message) => void (await ctx.runMutation(internal.grouping.fail, { claim, message })),
89
- model,
90
- deployment: deployment(),
91
- });
92
- },
93
- });
@@ -1,43 +0,0 @@
1
- import { applyAiSettings, chargeTest as chargeTestOp, getAiSettings, prepareTest as prepareTestOp, recordTest as recordTestOp } from "./lib/vendor/critiqs_server.js";
2
- import { v } from "convex/values";
3
- import { internalMutation, internalQuery, query } from "./_generated/server";
4
- import { deployment } from "./lib/ai";
5
- import { convexStore, identityOf, run } from "./lib/store";
6
-
7
- // A project's AI settings, for its owner only. Keys are encrypted in the
8
- // `ai` actions before they reach these functions, and never returned.
9
-
10
- /** The project's AI settings as its owner sees them: never a key, only a hint. */
11
- export const get = query({
12
- args: { projectId: v.id("projects") },
13
- handler: async (ctx, args) => run(async () => getAiSettings(convexStore(ctx), await identityOf(ctx), args, deployment())),
14
- });
15
-
16
- /** Refuses anyone but the owner, before a key is even encrypted. */
17
- export const requireOwner = internalQuery({
18
- args: { projectId: v.string() },
19
- handler: async (ctx, args) => run(async () => void (await getAiSettings(convexStore(ctx), await identityOf(ctx), args, deployment()))),
20
- });
21
-
22
- /** Stores settings already checked, with any key already sealed. */
23
- export const apply = internalMutation({
24
- args: { projectId: v.string(), prepared: v.any() },
25
- handler: async (ctx, args) =>
26
- run(async () => applyAiSettings(convexStore(ctx), await identityOf(ctx), args, deployment(), Date.now())),
27
- });
28
-
29
- export const prepareTest = internalMutation({
30
- args: { projectId: v.string() },
31
- handler: async (ctx, args) => run(async () => prepareTestOp(convexStore(ctx), await identityOf(ctx), args, deployment(), Date.now())),
32
- });
33
-
34
- /** Counts a test of Critiqs-managed AI against the project's allowance. */
35
- export const chargeTest = internalMutation({
36
- args: { projectId: v.string() },
37
- handler: async (ctx, args) => run(async () => chargeTestOp(convexStore(ctx), await identityOf(ctx), args, Date.now())),
38
- });
39
-
40
- export const recordTest = internalMutation({
41
- args: { projectId: v.string(), epoch: v.number(), result: v.any() },
42
- handler: async (ctx, args) => await recordTestOp(convexStore(ctx), args, Date.now()),
43
- });
@@ -1,18 +0,0 @@
1
- // Every Critiqs deployment trusts tokens from Critiqs's sign-in service, which
2
- // verifies reviewers' email addresses with one-time codes and issues its own short-lived
3
- // tokens (see http.ts and lib/tokens.ts). CRITIQS_AUTH_ISSUER is that service's
4
- // site URL: the hosted deployment names itself, and own deployments name the
5
- // hosted one, so they need no sign-in setup of their own.
6
- const issuer = (process.env.CRITIQS_AUTH_ISSUER ?? "").replace(/\/$/, "");
7
-
8
- export default {
9
- providers: [
10
- {
11
- type: "customJwt",
12
- issuer,
13
- jwks: `${issuer}/.well-known/jwks.json`,
14
- algorithm: "ES256",
15
- applicationID: "critiqs",
16
- },
17
- ],
18
- };