@rigstate/mcp 0.5.2 → 0.5.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/dist/index.js CHANGED
@@ -974,19 +974,30 @@ architecture rules, decisions, and constraints.`,
974
974
  }
975
975
  });
976
976
  async function generateQueryEmbedding(query) {
977
- const apiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY;
978
- if (!apiKey) {
979
- console.warn("GOOGLE_GENERATIVE_AI_API_KEY not found, skipping vector search.");
977
+ const openRouterKey = process.env.OPENROUTER_API_KEY;
978
+ const googleKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY;
979
+ if (!openRouterKey && !googleKey) {
980
+ console.warn("Neither OPENROUTER_API_KEY nor GOOGLE_GENERATIVE_AI_API_KEY found, skipping vector search.");
980
981
  return null;
981
982
  }
982
983
  try {
983
- const { google } = await import("@ai-sdk/google");
984
984
  const { embed } = await import("ai");
985
- const { embedding } = await embed({
986
- model: google.embedding("text-embedding-004"),
987
- value: query.replace(/\n/g, " ")
988
- });
989
- return embedding;
985
+ if (openRouterKey) {
986
+ const { createOpenRouter } = await import("@openrouter/ai-sdk-provider");
987
+ const openrouter = createOpenRouter({ apiKey: openRouterKey });
988
+ const { embedding } = await embed({
989
+ model: openrouter.embedding("google/text-embedding-004"),
990
+ value: query.replace(/\n/g, " ")
991
+ });
992
+ return embedding;
993
+ } else {
994
+ const { google } = await import("@ai-sdk/google");
995
+ const { embedding } = await embed({
996
+ model: google.embedding("text-embedding-004"),
997
+ value: query.replace(/\n/g, " ")
998
+ });
999
+ return embedding;
1000
+ }
990
1001
  } catch (error) {
991
1002
  console.error("Failed to generate embedding for search:", error);
992
1003
  return null;