@fatagnus/convex-feedback 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fatagnus/convex-feedback",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Bug reports and feedback collection component for Convex applications with AI analysis and email notifications",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -19,14 +19,17 @@ import { action, query, mutation, internalMutation } from "../_generated/server"
19
19
  import type { Id } from "../_generated/dataModel";
20
20
  import type { BugSeverity, FeedbackType, FeedbackPriority } from "../schema";
21
21
 
22
- // Create OpenRouter provider
23
- const openrouter = createOpenAICompatible({
24
- name: "openrouter",
25
- baseURL: "https://openrouter.ai/api/v1",
26
- headers: {
27
- Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
28
- },
29
- });
22
+ // Helper to create OpenRouter provider with a specific API key
23
+ // This is created dynamically because Convex components don't inherit parent env vars
24
+ function createOpenRouterProvider(apiKey: string) {
25
+ return createOpenAICompatible({
26
+ name: "openrouter",
27
+ baseURL: "https://openrouter.ai/api/v1",
28
+ headers: {
29
+ Authorization: `Bearer ${apiKey}`,
30
+ },
31
+ });
32
+ }
30
33
 
31
34
  // Agent name constant
32
35
  const AGENT_NAME = "Feedback Interview Agent";
@@ -186,101 +189,6 @@ const generateFeedback = createTool({
186
189
  },
187
190
  });
188
191
 
189
- // ============================================================================
190
- // Agent Definition
191
- // ============================================================================
192
-
193
- /**
194
- * Bug Report Interview Agent
195
- */
196
- export const bugInterviewAgent = new Agent(components.agent, {
197
- name: "Bug Report Interview Agent",
198
- languageModel: openrouter.languageModel("anthropic/claude-sonnet-4"),
199
-
200
- instructions: `You are a helpful assistant that interviews users to gather detailed information about bugs they've encountered.
201
-
202
- Your goal is to understand the bug thoroughly and generate a high-quality bug report.
203
-
204
- ## Interview Flow
205
-
206
- 1. **Greet briefly** and ask what went wrong (the bug they encountered).
207
-
208
- 2. **Understand the bug**:
209
- - What happened? (the actual behavior)
210
- - What did they expect to happen? (expected behavior)
211
- - How often does this occur? (always, sometimes, once)
212
-
213
- 3. **Get reproduction info**:
214
- - What steps led to this bug?
215
- - Can they reliably reproduce it?
216
-
217
- 4. **Assess impact**:
218
- - How does this affect their work?
219
- - How urgent is this for them?
220
-
221
- 5. **Generate the report** using the generateBugReport tool when you have enough information.
222
-
223
- ## Guidelines
224
- - Be conversational but efficient - aim for 3-5 exchanges
225
- - Use choice inputs when there are clear options
226
- - Use text inputs for open-ended questions
227
- - Don't ask for technical details the user might not know
228
- - Focus on understanding the user experience
229
- - Generate the report as soon as you have enough info`,
230
-
231
- tools: {
232
- requestUserInput,
233
- generateBugReport,
234
- },
235
-
236
- maxSteps: 30,
237
- });
238
-
239
- /**
240
- * Feedback Interview Agent
241
- */
242
- export const feedbackInterviewAgent = new Agent(components.agent, {
243
- name: "Feedback Interview Agent",
244
- languageModel: openrouter.languageModel("anthropic/claude-sonnet-4"),
245
-
246
- instructions: `You are a helpful assistant that interviews users to gather detailed feedback and suggestions.
247
-
248
- Your goal is to understand their idea thoroughly and generate well-structured feedback.
249
-
250
- ## Interview Flow
251
-
252
- 1. **Greet briefly** and ask about their idea or suggestion.
253
-
254
- 2. **Understand the need**:
255
- - What problem does this solve?
256
- - What's their current workaround (if any)?
257
-
258
- 3. **Clarify the request**:
259
- - What would the ideal solution look like?
260
- - Is this a new feature, change to existing, or general feedback?
261
-
262
- 4. **Assess importance**:
263
- - How important is this to them?
264
- - Who else might benefit?
265
-
266
- 5. **Generate the feedback** using the generateFeedback tool when you have enough information.
267
-
268
- ## Guidelines
269
- - Be conversational but efficient - aim for 3-5 exchanges
270
- - Use choice inputs when there are clear options
271
- - Use text inputs for open-ended questions
272
- - Help users articulate their ideas clearly
273
- - Focus on understanding the value and impact
274
- - Generate the feedback as soon as you have enough info`,
275
-
276
- tools: {
277
- requestUserInput,
278
- generateFeedback,
279
- },
280
-
281
- maxSteps: 30,
282
- });
283
-
284
192
  // ============================================================================
285
193
  // Internal Mutations
286
194
  // ============================================================================
@@ -570,6 +478,7 @@ Your goal is to understand their idea thoroughly and generate well-structured fe
570
478
  */
571
479
  export const startBugInterview = action({
572
480
  args: {
481
+ openRouterApiKey: v.string(),
573
482
  reporterType: v.union(v.literal("staff"), v.literal("customer")),
574
483
  reporterId: v.string(),
575
484
  reporterEmail: v.string(),
@@ -605,10 +514,8 @@ export const startBugInterview = action({
605
514
  })),
606
515
  }),
607
516
  handler: async (ctx, args) => {
608
- // Check if OpenRouter API key is configured
609
- if (!process.env.OPENROUTER_API_KEY) {
610
- throw new Error("OPENROUTER_API_KEY not configured. Interview mode requires AI.");
611
- }
517
+ // Create OpenRouter provider with the passed API key
518
+ const openrouter = createOpenRouterProvider(args.openRouterApiKey);
612
519
 
613
520
  // Create a thread for the interview
614
521
  const threadId = await createThread(ctx, components.agent, {
@@ -702,6 +609,7 @@ export const startBugInterview = action({
702
609
  */
703
610
  export const startFeedbackInterview = action({
704
611
  args: {
612
+ openRouterApiKey: v.string(),
705
613
  reporterType: v.union(v.literal("staff"), v.literal("customer")),
706
614
  reporterId: v.string(),
707
615
  reporterEmail: v.string(),
@@ -737,10 +645,8 @@ export const startFeedbackInterview = action({
737
645
  })),
738
646
  }),
739
647
  handler: async (ctx, args) => {
740
- // Check if OpenRouter API key is configured
741
- if (!process.env.OPENROUTER_API_KEY) {
742
- throw new Error("OPENROUTER_API_KEY not configured. Interview mode requires AI.");
743
- }
648
+ // Create OpenRouter provider with the passed API key
649
+ const openrouter = createOpenRouterProvider(args.openRouterApiKey);
744
650
 
745
651
  // Create a thread for the interview
746
652
  const threadId = await createThread(ctx, components.agent, {
@@ -834,6 +740,7 @@ export const startFeedbackInterview = action({
834
740
  */
835
741
  export const continueInterview = action({
836
742
  args: {
743
+ openRouterApiKey: v.string(),
837
744
  threadId: v.string(),
838
745
  sessionId: v.string(),
839
746
  requestId: v.id("feedbackInputRequests"),
@@ -891,6 +798,9 @@ export const continueInterview = action({
891
798
  })),
892
799
  }),
893
800
  handler: async (ctx, args) => {
801
+ // Create OpenRouter provider with the passed API key
802
+ const openrouter = createOpenRouterProvider(args.openRouterApiKey);
803
+
894
804
  // Submit the response
895
805
  await ctx.runMutation(
896
806
  api.inputRequests.submitResponse,