@fatagnus/convex-feedback 0.2.6 → 0.2.8
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/README.md +346 -4
- package/dist/index.d.ts +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/react/BugReportButton.d.ts.map +1 -1
- package/dist/react/BugReportButton.js +7 -3
- package/dist/react/BugReportButton.js.map +1 -1
- package/package.json +12 -5
- package/src/convex/_generated/api.ts +2923 -0
- package/src/convex/_generated/component.ts +892 -0
- package/src/convex/_generated/dataModel.ts +60 -0
- package/src/convex/_generated/server.ts +161 -0
- package/src/convex/agents/bugReportAgent.ts +37 -3
- package/src/convex/agents/feedbackAgent.ts +37 -3
- package/src/convex/agents/feedbackInterviewAgent.ts +6 -12
- package/src/convex/agents/index.ts +12 -5
- package/src/convex/apiKeys.test.ts +79 -0
- package/src/convex/apiKeys.ts +223 -0
- package/src/convex/bugReports.ts +148 -9
- package/src/convex/emails/bugReportEmails.ts +6 -3
- package/src/convex/emails/feedbackEmails.ts +6 -3
- package/src/convex/feedback.ts +155 -8
- package/src/convex/http.test.ts +76 -0
- package/src/convex/http.ts +630 -0
- package/src/convex/index.ts +11 -0
- package/src/convex/prompts.test.ts +185 -0
- package/src/convex/prompts.ts +605 -0
- package/src/convex/schema.ts +52 -2
- package/src/convex/ticketNumbers.ts +4 -0
- package/src/convex/tsconfig.json +24 -0
- package/src/index.ts +49 -1
- package/src/types.ts +38 -0
|
@@ -0,0 +1,60 @@
|
|
|
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(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>;
|
|
@@ -0,0 +1,161 @@
|
|
|
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 type {
|
|
12
|
+
ActionBuilder,
|
|
13
|
+
HttpActionBuilder,
|
|
14
|
+
MutationBuilder,
|
|
15
|
+
QueryBuilder,
|
|
16
|
+
GenericActionCtx,
|
|
17
|
+
GenericMutationCtx,
|
|
18
|
+
GenericQueryCtx,
|
|
19
|
+
GenericDatabaseReader,
|
|
20
|
+
GenericDatabaseWriter,
|
|
21
|
+
} from "convex/server";
|
|
22
|
+
import {
|
|
23
|
+
actionGeneric,
|
|
24
|
+
httpActionGeneric,
|
|
25
|
+
queryGeneric,
|
|
26
|
+
mutationGeneric,
|
|
27
|
+
internalActionGeneric,
|
|
28
|
+
internalMutationGeneric,
|
|
29
|
+
internalQueryGeneric,
|
|
30
|
+
} from "convex/server";
|
|
31
|
+
import type { DataModel } from "./dataModel.js";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Define a query in this Convex app's public API.
|
|
35
|
+
*
|
|
36
|
+
* This function will be allowed to read your Convex database and will be accessible from the client.
|
|
37
|
+
*
|
|
38
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
39
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
40
|
+
*/
|
|
41
|
+
export const query: QueryBuilder<DataModel, "public"> = queryGeneric;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Define a query that is only accessible from other Convex functions (but not from the client).
|
|
45
|
+
*
|
|
46
|
+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
|
|
47
|
+
*
|
|
48
|
+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
|
|
49
|
+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
|
|
50
|
+
*/
|
|
51
|
+
export const internalQuery: QueryBuilder<DataModel, "internal"> =
|
|
52
|
+
internalQueryGeneric;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Define a mutation in this Convex app's public API.
|
|
56
|
+
*
|
|
57
|
+
* This function will be allowed to modify your Convex database and will be accessible from the client.
|
|
58
|
+
*
|
|
59
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
60
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
61
|
+
*/
|
|
62
|
+
export const mutation: MutationBuilder<DataModel, "public"> = mutationGeneric;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
|
|
66
|
+
*
|
|
67
|
+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
|
|
68
|
+
*
|
|
69
|
+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
|
|
70
|
+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
|
|
71
|
+
*/
|
|
72
|
+
export const internalMutation: MutationBuilder<DataModel, "internal"> =
|
|
73
|
+
internalMutationGeneric;
|
|
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 const action: ActionBuilder<DataModel, "public"> = actionGeneric;
|
|
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 const internalAction: ActionBuilder<DataModel, "internal"> =
|
|
95
|
+
internalActionGeneric;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Define an HTTP action.
|
|
99
|
+
*
|
|
100
|
+
* The wrapped function will be used to respond to HTTP requests received
|
|
101
|
+
* by a Convex deployment if the requests matches the path and method where
|
|
102
|
+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
|
|
103
|
+
*
|
|
104
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
|
|
105
|
+
* and a Fetch API `Request` object as its second.
|
|
106
|
+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
|
|
107
|
+
*/
|
|
108
|
+
export const httpAction: HttpActionBuilder = httpActionGeneric;
|
|
109
|
+
|
|
110
|
+
type GenericCtx =
|
|
111
|
+
| GenericActionCtx<DataModel>
|
|
112
|
+
| GenericMutationCtx<DataModel>
|
|
113
|
+
| GenericQueryCtx<DataModel>;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* A set of services for use within Convex query functions.
|
|
117
|
+
*
|
|
118
|
+
* The query context is passed as the first argument to any Convex query
|
|
119
|
+
* function run on the server.
|
|
120
|
+
*
|
|
121
|
+
* If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
|
|
122
|
+
*/
|
|
123
|
+
export type QueryCtx = GenericQueryCtx<DataModel>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A set of services for use within Convex mutation functions.
|
|
127
|
+
*
|
|
128
|
+
* The mutation context is passed as the first argument to any Convex mutation
|
|
129
|
+
* function run on the server.
|
|
130
|
+
*
|
|
131
|
+
* If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
|
|
132
|
+
*/
|
|
133
|
+
export type MutationCtx = GenericMutationCtx<DataModel>;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A set of services for use within Convex action functions.
|
|
137
|
+
*
|
|
138
|
+
* The action context is passed as the first argument to any Convex action
|
|
139
|
+
* function run on the server.
|
|
140
|
+
*/
|
|
141
|
+
export type ActionCtx = GenericActionCtx<DataModel>;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* An interface to read from the database within Convex query functions.
|
|
145
|
+
*
|
|
146
|
+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
|
|
147
|
+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
|
|
148
|
+
* building a query.
|
|
149
|
+
*/
|
|
150
|
+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* An interface to read from and write to the database within Convex mutation
|
|
154
|
+
* functions.
|
|
155
|
+
*
|
|
156
|
+
* Convex guarantees that all writes within a single mutation are
|
|
157
|
+
* executed atomically, so you never have to worry about partial writes leaving
|
|
158
|
+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
|
|
159
|
+
* for the guarantees Convex provides your functions.
|
|
160
|
+
*/
|
|
161
|
+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
|
|
@@ -16,7 +16,7 @@ import { v } from "convex/values";
|
|
|
16
16
|
import { Agent, createThread } from "@convex-dev/agent";
|
|
17
17
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
18
18
|
import { components, internal } from "../_generated/api";
|
|
19
|
-
import { internalAction, internalQuery } from "../_generated/server";
|
|
19
|
+
import { action, internalAction, internalQuery } from "../_generated/server";
|
|
20
20
|
import type { BugSeverity, Effort } from "../schema";
|
|
21
21
|
|
|
22
22
|
// Helper to create OpenRouter provider dynamically
|
|
@@ -122,14 +122,18 @@ export const getBugReportForAnalysis = internalQuery({
|
|
|
122
122
|
export const processBugReport = internalAction({
|
|
123
123
|
args: {
|
|
124
124
|
bugReportId: v.id("bugReports"),
|
|
125
|
+
// Optional API keys - passed from parent app since components don't inherit env vars
|
|
126
|
+
openRouterApiKey: v.optional(v.string()),
|
|
127
|
+
resendApiKey: v.optional(v.string()),
|
|
128
|
+
resendFromEmail: v.optional(v.string()),
|
|
125
129
|
},
|
|
126
130
|
returns: v.object({
|
|
127
131
|
success: v.boolean(),
|
|
128
132
|
error: v.optional(v.string()),
|
|
129
133
|
}),
|
|
130
134
|
handler: async (ctx, args): Promise<{ success: boolean; error?: string }> => {
|
|
131
|
-
// Check if OpenRouter API key is configured
|
|
132
|
-
const apiKey = process.env.OPENROUTER_API_KEY;
|
|
135
|
+
// Check if OpenRouter API key is configured - prefer args (from parent app), fallback to env
|
|
136
|
+
const apiKey = args.openRouterApiKey || process.env.OPENROUTER_API_KEY;
|
|
133
137
|
if (!apiKey) {
|
|
134
138
|
console.log("OPENROUTER_API_KEY not configured, skipping AI analysis");
|
|
135
139
|
// Still try to send notifications without AI analysis
|
|
@@ -137,6 +141,8 @@ export const processBugReport = internalAction({
|
|
|
137
141
|
await ctx.runAction(internal.emails.bugReportEmails.sendBugReportNotifications, {
|
|
138
142
|
reportId: args.bugReportId,
|
|
139
143
|
analysis: null,
|
|
144
|
+
resendApiKey: args.resendApiKey,
|
|
145
|
+
resendFromEmail: args.resendFromEmail,
|
|
140
146
|
});
|
|
141
147
|
} catch {
|
|
142
148
|
console.log("Email notifications not configured");
|
|
@@ -262,6 +268,8 @@ Provide your analysis in the JSON format specified.`;
|
|
|
262
268
|
suggestedFix: analysis.suggestedFix,
|
|
263
269
|
estimatedEffort: analysis.estimatedEffort,
|
|
264
270
|
},
|
|
271
|
+
resendApiKey: args.resendApiKey,
|
|
272
|
+
resendFromEmail: args.resendFromEmail,
|
|
265
273
|
});
|
|
266
274
|
|
|
267
275
|
// Mark notifications as sent
|
|
@@ -275,3 +283,29 @@ Provide your analysis in the JSON format specified.`;
|
|
|
275
283
|
return { success: true };
|
|
276
284
|
},
|
|
277
285
|
});
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Public wrapper for processBugReport that can be called from parent app.
|
|
289
|
+
* Accepts optional API keys since Convex components don't inherit parent env vars.
|
|
290
|
+
*/
|
|
291
|
+
export const processBugReportPublic = action({
|
|
292
|
+
args: {
|
|
293
|
+
bugReportId: v.id("bugReports"),
|
|
294
|
+
openRouterApiKey: v.optional(v.string()),
|
|
295
|
+
resendApiKey: v.optional(v.string()),
|
|
296
|
+
resendFromEmail: v.optional(v.string()),
|
|
297
|
+
},
|
|
298
|
+
returns: v.object({
|
|
299
|
+
success: v.boolean(),
|
|
300
|
+
error: v.optional(v.string()),
|
|
301
|
+
}),
|
|
302
|
+
handler: async (ctx, args): Promise<{ success: boolean; error?: string }> => {
|
|
303
|
+
// Delegate to the internal action
|
|
304
|
+
return await ctx.runAction(internal.agents.bugReportAgent.processBugReport, {
|
|
305
|
+
bugReportId: args.bugReportId,
|
|
306
|
+
openRouterApiKey: args.openRouterApiKey,
|
|
307
|
+
resendApiKey: args.resendApiKey,
|
|
308
|
+
resendFromEmail: args.resendFromEmail,
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
});
|
|
@@ -15,7 +15,7 @@ import { v } from "convex/values";
|
|
|
15
15
|
import { Agent, createThread } from "@convex-dev/agent";
|
|
16
16
|
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
|
17
17
|
import { components, internal } from "../_generated/api";
|
|
18
|
-
import { internalAction, internalQuery } from "../_generated/server";
|
|
18
|
+
import { action, internalAction, internalQuery } from "../_generated/server";
|
|
19
19
|
import type { FeedbackPriority, Effort } from "../schema";
|
|
20
20
|
|
|
21
21
|
// Helper to create OpenRouter provider dynamically
|
|
@@ -118,14 +118,18 @@ export const getFeedbackForAnalysis = internalQuery({
|
|
|
118
118
|
export const processFeedback = internalAction({
|
|
119
119
|
args: {
|
|
120
120
|
feedbackId: v.id("feedback"),
|
|
121
|
+
// Optional API keys - passed from parent app since components don't inherit env vars
|
|
122
|
+
openRouterApiKey: v.optional(v.string()),
|
|
123
|
+
resendApiKey: v.optional(v.string()),
|
|
124
|
+
resendFromEmail: v.optional(v.string()),
|
|
121
125
|
},
|
|
122
126
|
returns: v.object({
|
|
123
127
|
success: v.boolean(),
|
|
124
128
|
error: v.optional(v.string()),
|
|
125
129
|
}),
|
|
126
130
|
handler: async (ctx, args): Promise<{ success: boolean; error?: string }> => {
|
|
127
|
-
// Check if OpenRouter API key is configured
|
|
128
|
-
const apiKey = process.env.OPENROUTER_API_KEY;
|
|
131
|
+
// Check if OpenRouter API key is configured - prefer args (from parent app), fallback to env
|
|
132
|
+
const apiKey = args.openRouterApiKey || process.env.OPENROUTER_API_KEY;
|
|
129
133
|
if (!apiKey) {
|
|
130
134
|
console.log("OPENROUTER_API_KEY not configured, skipping AI analysis");
|
|
131
135
|
// Still try to send notifications without AI analysis
|
|
@@ -133,6 +137,8 @@ export const processFeedback = internalAction({
|
|
|
133
137
|
await ctx.runAction(internal.emails.feedbackEmails.sendFeedbackNotifications, {
|
|
134
138
|
feedbackId: args.feedbackId,
|
|
135
139
|
analysis: null,
|
|
140
|
+
resendApiKey: args.resendApiKey,
|
|
141
|
+
resendFromEmail: args.resendFromEmail,
|
|
136
142
|
});
|
|
137
143
|
} catch {
|
|
138
144
|
console.log("Email notifications not configured");
|
|
@@ -249,6 +255,8 @@ Provide your analysis in the JSON format specified.`;
|
|
|
249
255
|
estimatedEffort: analysis.estimatedEffort,
|
|
250
256
|
suggestedPriority: analysis.suggestedPriority,
|
|
251
257
|
},
|
|
258
|
+
resendApiKey: args.resendApiKey,
|
|
259
|
+
resendFromEmail: args.resendFromEmail,
|
|
252
260
|
});
|
|
253
261
|
|
|
254
262
|
// Mark notifications as sent
|
|
@@ -262,3 +270,29 @@ Provide your analysis in the JSON format specified.`;
|
|
|
262
270
|
return { success: true };
|
|
263
271
|
},
|
|
264
272
|
});
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Public wrapper for processFeedback that can be called from parent app.
|
|
276
|
+
* Accepts optional API keys since Convex components don't inherit parent env vars.
|
|
277
|
+
*/
|
|
278
|
+
export const processFeedbackPublic = action({
|
|
279
|
+
args: {
|
|
280
|
+
feedbackId: v.id("feedback"),
|
|
281
|
+
openRouterApiKey: v.optional(v.string()),
|
|
282
|
+
resendApiKey: v.optional(v.string()),
|
|
283
|
+
resendFromEmail: v.optional(v.string()),
|
|
284
|
+
},
|
|
285
|
+
returns: v.object({
|
|
286
|
+
success: v.boolean(),
|
|
287
|
+
error: v.optional(v.string()),
|
|
288
|
+
}),
|
|
289
|
+
handler: async (ctx, args): Promise<{ success: boolean; error?: string }> => {
|
|
290
|
+
// Delegate to the internal action
|
|
291
|
+
return await ctx.runAction(internal.agents.feedbackAgent.processFeedback, {
|
|
292
|
+
feedbackId: args.feedbackId,
|
|
293
|
+
openRouterApiKey: args.openRouterApiKey,
|
|
294
|
+
resendApiKey: args.resendApiKey,
|
|
295
|
+
resendFromEmail: args.resendFromEmail,
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
});
|
|
@@ -591,14 +591,12 @@ export const startBugInterview = action({
|
|
|
591
591
|
});
|
|
592
592
|
|
|
593
593
|
// Start the interview
|
|
594
|
+
// Note: Tools look up session by threadId, so we don't need to pass sessionId via customCtx
|
|
594
595
|
let result;
|
|
595
596
|
try {
|
|
596
597
|
result = await dynamicAgent.generateText(
|
|
597
598
|
ctx,
|
|
598
|
-
{
|
|
599
|
-
threadId,
|
|
600
|
-
customCtx: { sessionId },
|
|
601
|
-
},
|
|
599
|
+
{ threadId },
|
|
602
600
|
{ prompt: "Start the bug report interview. Greet the user briefly and ask what bug or issue they encountered." }
|
|
603
601
|
);
|
|
604
602
|
} catch (error) {
|
|
@@ -722,14 +720,12 @@ export const startFeedbackInterview = action({
|
|
|
722
720
|
});
|
|
723
721
|
|
|
724
722
|
// Start the interview
|
|
723
|
+
// Note: Tools look up session by threadId, so we don't need to pass sessionId via customCtx
|
|
725
724
|
let result;
|
|
726
725
|
try {
|
|
727
726
|
result = await dynamicAgent.generateText(
|
|
728
727
|
ctx,
|
|
729
|
-
{
|
|
730
|
-
threadId,
|
|
731
|
-
customCtx: { sessionId },
|
|
732
|
-
},
|
|
728
|
+
{ threadId },
|
|
733
729
|
{ prompt: "Start the feedback interview. Greet the user briefly and ask about their idea or suggestion." }
|
|
734
730
|
);
|
|
735
731
|
} catch (error) {
|
|
@@ -871,14 +867,12 @@ export const continueInterview = action({
|
|
|
871
867
|
});
|
|
872
868
|
|
|
873
869
|
// Continue the agent
|
|
870
|
+
// Note: Tools look up session by threadId, so we don't need to pass sessionId via customCtx
|
|
874
871
|
let result;
|
|
875
872
|
try {
|
|
876
873
|
result = await dynamicAgent.generateText(
|
|
877
874
|
ctx,
|
|
878
|
-
{
|
|
879
|
-
threadId: args.threadId,
|
|
880
|
-
customCtx: { sessionId: args.sessionId },
|
|
881
|
-
},
|
|
875
|
+
{ threadId: args.threadId },
|
|
882
876
|
{
|
|
883
877
|
prompt: `The user responded: ${args.response}
|
|
884
878
|
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Agent exports for the feedback component.
|
|
3
|
+
*
|
|
4
|
+
* This file exports public actions that can be called from the parent app.
|
|
3
5
|
*/
|
|
6
|
+
|
|
7
|
+
// Re-export all interview agent functions (public actions and queries)
|
|
4
8
|
export {
|
|
5
|
-
bugInterviewAgent,
|
|
6
|
-
feedbackInterviewAgent,
|
|
7
9
|
startBugInterview,
|
|
8
10
|
startFeedbackInterview,
|
|
9
11
|
continueInterview,
|
|
10
12
|
getSessionByThread,
|
|
11
|
-
createSession,
|
|
12
|
-
updateSession,
|
|
13
13
|
} from "./feedbackInterviewAgent";
|
|
14
|
+
|
|
15
|
+
// Export public processing actions (for parent app to call with API keys)
|
|
16
|
+
export { processBugReportPublic } from "./bugReportAgent";
|
|
17
|
+
export { processFeedbackPublic } from "./feedbackAgent";
|
|
18
|
+
|
|
19
|
+
// Note: createSession and updateSession are internalMutation and cannot be re-exported here.
|
|
20
|
+
// They are accessed via internal.agents.feedbackInterviewAgent.* within the component.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for API Key utilities
|
|
3
|
+
*
|
|
4
|
+
* Note: Testing Convex component packages with convex-test requires special setup.
|
|
5
|
+
* These tests verify the key format and structure expectations.
|
|
6
|
+
* Full integration tests should be run in a real Convex deployment.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it, expect } from "vitest";
|
|
9
|
+
|
|
10
|
+
describe("API Key Format", () => {
|
|
11
|
+
describe("Key Structure", () => {
|
|
12
|
+
it("key format should be fb_ followed by 32 hex chars", () => {
|
|
13
|
+
// Example of expected format
|
|
14
|
+
const validKeyPattern = /^fb_[a-f0-9]{32}$/;
|
|
15
|
+
const exampleKey = "fb_0123456789abcdef0123456789abcdef";
|
|
16
|
+
|
|
17
|
+
expect(exampleKey).toMatch(validKeyPattern);
|
|
18
|
+
expect(exampleKey.length).toBe(35); // "fb_" (3) + 32 hex chars
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("key prefix should be fb_ followed by 8 hex chars", () => {
|
|
22
|
+
const validPrefixPattern = /^fb_[a-f0-9]{8}$/;
|
|
23
|
+
const examplePrefix = "fb_01234567";
|
|
24
|
+
|
|
25
|
+
expect(examplePrefix).toMatch(validPrefixPattern);
|
|
26
|
+
expect(examplePrefix.length).toBe(11); // "fb_" (3) + 8 hex chars
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("key prefix should be the first 11 chars of the full key", () => {
|
|
30
|
+
const fullKey = "fb_0123456789abcdef0123456789abcdef";
|
|
31
|
+
const expectedPrefix = fullKey.slice(0, 11);
|
|
32
|
+
|
|
33
|
+
expect(expectedPrefix).toBe("fb_01234567");
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("Key Hashing", () => {
|
|
38
|
+
it("SHA-256 hash should produce 64 hex chars", async () => {
|
|
39
|
+
const key = "fb_0123456789abcdef0123456789abcdef";
|
|
40
|
+
|
|
41
|
+
const encoder = new TextEncoder();
|
|
42
|
+
const data = encoder.encode(key);
|
|
43
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
44
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
45
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
46
|
+
|
|
47
|
+
expect(hashHex.length).toBe(64);
|
|
48
|
+
expect(hashHex).toMatch(/^[a-f0-9]{64}$/);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("same key should always produce same hash", async () => {
|
|
52
|
+
const key = "fb_testkey123456789abcdef12345678";
|
|
53
|
+
|
|
54
|
+
const hash1 = await hashKey(key);
|
|
55
|
+
const hash2 = await hashKey(key);
|
|
56
|
+
|
|
57
|
+
expect(hash1).toBe(hash2);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("different keys should produce different hashes", async () => {
|
|
61
|
+
const key1 = "fb_testkey123456789abcdef12345678";
|
|
62
|
+
const key2 = "fb_testkey123456789abcdef12345679";
|
|
63
|
+
|
|
64
|
+
const hash1 = await hashKey(key1);
|
|
65
|
+
const hash2 = await hashKey(key2);
|
|
66
|
+
|
|
67
|
+
expect(hash1).not.toBe(hash2);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Helper function matching the implementation in apiKeys.ts
|
|
73
|
+
async function hashKey(key: string): Promise<string> {
|
|
74
|
+
const encoder = new TextEncoder();
|
|
75
|
+
const data = encoder.encode(key);
|
|
76
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", data);
|
|
77
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
78
|
+
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
79
|
+
}
|