@vibetasks/core 0.5.8 → 0.5.10
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/chunk-3RG5ZIWI.js +10 -0
- package/dist/index.d.ts +828 -28
- package/dist/index.js +2248 -69
- package/dist/voyage-embeddings-VXPM2I5X.js +98 -0
- package/package.json +55 -48
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import "./chunk-3RG5ZIWI.js";
|
|
2
|
+
|
|
3
|
+
// src/voyage-embeddings.ts
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
async function generateVoyageEmbedding(text) {
|
|
6
|
+
const apiKey = process.env.VOYAGE_API_KEY;
|
|
7
|
+
if (!apiKey) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"VOYAGE_API_KEY environment variable is required. Get your API key from https://www.voyageai.com/"
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const response = await axios.post(
|
|
14
|
+
"https://api.voyageai.com/v1/embeddings",
|
|
15
|
+
{
|
|
16
|
+
input: text.substring(0, 12e3),
|
|
17
|
+
// Safe limit: 12K chars (~3K tokens)
|
|
18
|
+
model: "voyage-code-3",
|
|
19
|
+
// Optimized for code and technical content
|
|
20
|
+
input_type: "document"
|
|
21
|
+
// For storage/indexing (vs 'query' for search)
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
headers: {
|
|
25
|
+
"Authorization": `Bearer ${apiKey}`,
|
|
26
|
+
"Content-Type": "application/json"
|
|
27
|
+
},
|
|
28
|
+
timeout: 3e4
|
|
29
|
+
// 30 second timeout
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
if (!response.data || !response.data.data || !response.data.data[0]) {
|
|
33
|
+
throw new Error("Invalid response from Voyage AI API");
|
|
34
|
+
}
|
|
35
|
+
const embedding = response.data.data[0].embedding;
|
|
36
|
+
if (!Array.isArray(embedding) || embedding.length !== 1024) {
|
|
37
|
+
throw new Error(`Expected 1024-dim embedding, got ${embedding?.length || 0}`);
|
|
38
|
+
}
|
|
39
|
+
return embedding;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (axios.isAxiosError(error)) {
|
|
42
|
+
const status = error.response?.status;
|
|
43
|
+
const message = error.response?.data?.message || error.message;
|
|
44
|
+
if (status === 401) {
|
|
45
|
+
throw new Error(`Voyage AI API authentication failed. Check your VOYAGE_API_KEY.`);
|
|
46
|
+
} else if (status === 429) {
|
|
47
|
+
throw new Error(`Voyage AI API rate limit exceeded. Please retry later.`);
|
|
48
|
+
} else if (status === 400) {
|
|
49
|
+
throw new Error(`Voyage AI API error: ${message}`);
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Voyage AI API request failed: ${message}`);
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function batchGenerateVoyageEmbeddings(texts, onProgress) {
|
|
57
|
+
const results = [];
|
|
58
|
+
for (let i = 0; i < texts.length; i++) {
|
|
59
|
+
try {
|
|
60
|
+
const embedding = await generateVoyageEmbedding(texts[i]);
|
|
61
|
+
results.push(embedding);
|
|
62
|
+
if (onProgress) {
|
|
63
|
+
onProgress(i + 1, texts.length);
|
|
64
|
+
}
|
|
65
|
+
if (i < texts.length - 1) {
|
|
66
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
67
|
+
}
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`Failed to generate embedding for text ${i + 1}:`, error);
|
|
70
|
+
results.push(new Array(1024).fill(0));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
function cosineSimilarity(embedding1, embedding2) {
|
|
76
|
+
if (embedding1.length !== embedding2.length) {
|
|
77
|
+
throw new Error("Embeddings must have the same dimensions");
|
|
78
|
+
}
|
|
79
|
+
let dotProduct = 0;
|
|
80
|
+
let norm1 = 0;
|
|
81
|
+
let norm2 = 0;
|
|
82
|
+
for (let i = 0; i < embedding1.length; i++) {
|
|
83
|
+
dotProduct += embedding1[i] * embedding2[i];
|
|
84
|
+
norm1 += embedding1[i] * embedding1[i];
|
|
85
|
+
norm2 += embedding2[i] * embedding2[i];
|
|
86
|
+
}
|
|
87
|
+
const magnitude1 = Math.sqrt(norm1);
|
|
88
|
+
const magnitude2 = Math.sqrt(norm2);
|
|
89
|
+
if (magnitude1 === 0 || magnitude2 === 0) {
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
return dotProduct / (magnitude1 * magnitude2);
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
batchGenerateVoyageEmbeddings,
|
|
96
|
+
cosineSimilarity,
|
|
97
|
+
generateVoyageEmbedding
|
|
98
|
+
};
|
package/package.json
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@vibetasks/core",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Shared core logic for VibeTasks MCP server and CLI - authentication, task operations, and config management",
|
|
5
|
-
"author": "Vyas",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"main": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"type": "module",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"keywords": [
|
|
14
|
-
"vibetasks",
|
|
15
|
-
"vibe",
|
|
16
|
-
"vibecoding",
|
|
17
|
-
"mcp",
|
|
18
|
-
"task-management",
|
|
19
|
-
"supabase",
|
|
20
|
-
"authentication",
|
|
21
|
-
"productivity"
|
|
22
|
-
],
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/vyassathya/vibetasks.git",
|
|
26
|
-
"directory": "packages/mcp-core"
|
|
27
|
-
},
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"dev": "tsx src/index.ts",
|
|
33
|
-
"build": "tsup
|
|
34
|
-
"typecheck": "tsc --noEmit"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@supabase/supabase-js": "^2.
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibetasks/core",
|
|
3
|
+
"version": "0.5.10",
|
|
4
|
+
"description": "Shared core logic for VibeTasks MCP server and CLI - authentication, task operations, and config management",
|
|
5
|
+
"author": "Vyas",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"vibetasks",
|
|
15
|
+
"vibe",
|
|
16
|
+
"vibecoding",
|
|
17
|
+
"mcp",
|
|
18
|
+
"task-management",
|
|
19
|
+
"supabase",
|
|
20
|
+
"authentication",
|
|
21
|
+
"productivity"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/vyassathya/vibetasks.git",
|
|
26
|
+
"directory": "packages/mcp-core"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "tsx src/index.ts",
|
|
33
|
+
"build": "tsup",
|
|
34
|
+
"typecheck": "tsc --noEmit"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@anthropic-ai/sdk": "^0.71.2",
|
|
38
|
+
"@supabase/supabase-js": "^2.89.0",
|
|
39
|
+
"@vibetasks/ralph-engine": "workspace:*",
|
|
40
|
+
"@vibetasks/shared": "^1.4.5",
|
|
41
|
+
"axios": "^1.13.2",
|
|
42
|
+
"glob": "^10.5.0",
|
|
43
|
+
"issue-parser": "^7.0.1",
|
|
44
|
+
"keytar": "^7.9.0",
|
|
45
|
+
"openai": "^4.104.0",
|
|
46
|
+
"vm2": "^3.10.2",
|
|
47
|
+
"zod": "^3.22.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"tsup": "^8.0.0",
|
|
52
|
+
"tsx": "^4.7.0",
|
|
53
|
+
"typescript": "^5.3.3"
|
|
54
|
+
}
|
|
55
|
+
}
|