neuronix-node 0.1.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.
- package/README.md +60 -0
- package/dist/api.d.ts +31 -0
- package/dist/api.js +68 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.js +48 -0
- package/dist/handlers/chart.d.ts +2 -0
- package/dist/handlers/chart.js +121 -0
- package/dist/handlers/expense.d.ts +2 -0
- package/dist/handlers/expense.js +102 -0
- package/dist/handlers/file-processor.d.ts +7 -0
- package/dist/handlers/file-processor.js +168 -0
- package/dist/handlers/index.d.ts +20 -0
- package/dist/handlers/index.js +36 -0
- package/dist/handlers/invoice.d.ts +2 -0
- package/dist/handlers/invoice.js +113 -0
- package/dist/handlers/pnl.d.ts +2 -0
- package/dist/handlers/pnl.js +116 -0
- package/dist/handlers/smart-route.d.ts +2 -0
- package/dist/handlers/smart-route.js +116 -0
- package/dist/hardware.d.ts +10 -0
- package/dist/hardware.js +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +279 -0
- package/dist/inference.d.ts +25 -0
- package/dist/inference.js +73 -0
- package/dist/models.d.ts +29 -0
- package/dist/models.js +141 -0
- package/dist/parsers/csv.d.ts +24 -0
- package/dist/parsers/csv.js +94 -0
- package/dist/parsers/index.d.ts +17 -0
- package/dist/parsers/index.js +101 -0
- package/dist/updater.d.ts +8 -0
- package/dist/updater.js +48 -0
- package/package.json +51 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* File parser registry.
|
|
4
|
+
* Detects file type and extracts structured data.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.parseCSV = void 0;
|
|
8
|
+
exports.parseFile = parseFile;
|
|
9
|
+
const csv_js_1 = require("./csv.js");
|
|
10
|
+
Object.defineProperty(exports, "parseCSV", { enumerable: true, get: function () { return csv_js_1.parseCSV; } });
|
|
11
|
+
/**
|
|
12
|
+
* Parse file content based on its type.
|
|
13
|
+
* Returns structured data + suggested actions the bot can take.
|
|
14
|
+
*/
|
|
15
|
+
function parseFile(fileName, fileType, content) {
|
|
16
|
+
const lower = fileName.toLowerCase();
|
|
17
|
+
// CSV files
|
|
18
|
+
if (fileType === "csv" || lower.endsWith(".csv")) {
|
|
19
|
+
const text = typeof content === "string" ? content : content.toString("utf-8");
|
|
20
|
+
const data = (0, csv_js_1.parseCSV)(text);
|
|
21
|
+
const suggestedActions = [];
|
|
22
|
+
// Detect what kind of CSV this is based on headers
|
|
23
|
+
const headersLower = data.headers.map((h) => h.toLowerCase());
|
|
24
|
+
if (headersLower.some((h) => /amount|cost|price|total|expense|debit|credit/.test(h))) {
|
|
25
|
+
suggestedActions.push("expense_report", "chart");
|
|
26
|
+
}
|
|
27
|
+
if (headersLower.some((h) => /revenue|income|sales/.test(h)) && headersLower.some((h) => /expense|cost/.test(h))) {
|
|
28
|
+
suggestedActions.push("pnl");
|
|
29
|
+
}
|
|
30
|
+
if (headersLower.some((h) => /invoice|bill|vendor|supplier/.test(h))) {
|
|
31
|
+
suggestedActions.push("invoice");
|
|
32
|
+
}
|
|
33
|
+
if (headersLower.some((h) => /quantity|stock|inventory|sku/.test(h))) {
|
|
34
|
+
suggestedActions.push("inventory_report");
|
|
35
|
+
}
|
|
36
|
+
if (data.summary.numericColumns.length > 0) {
|
|
37
|
+
suggestedActions.push("chart", "summary");
|
|
38
|
+
}
|
|
39
|
+
return { type: "csv", fileName, data, suggestedActions };
|
|
40
|
+
}
|
|
41
|
+
// Excel files (basic detection — full parsing requires xlsx library on the node)
|
|
42
|
+
if (fileType === "excel" || lower.endsWith(".xlsx") || lower.endsWith(".xls")) {
|
|
43
|
+
return {
|
|
44
|
+
type: "excel",
|
|
45
|
+
fileName,
|
|
46
|
+
data: { message: "Excel file detected. Will be parsed by the processing node." },
|
|
47
|
+
suggestedActions: ["chart", "expense_report", "summary"],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// PDF files
|
|
51
|
+
if (fileType === "pdf" || lower.endsWith(".pdf")) {
|
|
52
|
+
return {
|
|
53
|
+
type: "pdf",
|
|
54
|
+
fileName,
|
|
55
|
+
data: { message: "PDF file detected. Will be parsed by the processing node." },
|
|
56
|
+
suggestedActions: detectPDFActions(lower),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
// Text files
|
|
60
|
+
if (fileType === "text" || lower.endsWith(".txt")) {
|
|
61
|
+
const text = typeof content === "string" ? content : content.toString("utf-8");
|
|
62
|
+
return {
|
|
63
|
+
type: "text",
|
|
64
|
+
fileName,
|
|
65
|
+
data: { content: text, length: text.length },
|
|
66
|
+
suggestedActions: ["summary"],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// JSON files
|
|
70
|
+
if (fileType === "json" || lower.endsWith(".json")) {
|
|
71
|
+
const text = typeof content === "string" ? content : content.toString("utf-8");
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(text);
|
|
74
|
+
return {
|
|
75
|
+
type: "json",
|
|
76
|
+
fileName,
|
|
77
|
+
data: { content: parsed, keys: Object.keys(parsed) },
|
|
78
|
+
suggestedActions: ["summary", "chart"],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return { type: "json", fileName, data: { error: "Invalid JSON" }, suggestedActions: [] };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Unknown
|
|
86
|
+
return {
|
|
87
|
+
type: "unknown",
|
|
88
|
+
fileName,
|
|
89
|
+
data: { message: `Unrecognized file type: ${fileType}` },
|
|
90
|
+
suggestedActions: [],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function detectPDFActions(fileName) {
|
|
94
|
+
if (/invoice/i.test(fileName))
|
|
95
|
+
return ["invoice", "expense_report"];
|
|
96
|
+
if (/receipt/i.test(fileName))
|
|
97
|
+
return ["expense_report"];
|
|
98
|
+
if (/report|statement/i.test(fileName))
|
|
99
|
+
return ["summary", "chart"];
|
|
100
|
+
return ["summary"];
|
|
101
|
+
}
|
package/dist/updater.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkForUpdates = checkForUpdates;
|
|
7
|
+
const https_1 = __importDefault(require("https"));
|
|
8
|
+
const VERSION_URL = "https://neuronix-nu.vercel.app/api/node/version";
|
|
9
|
+
function compareVersions(a, b) {
|
|
10
|
+
const pa = a.split(".").map(Number);
|
|
11
|
+
const pb = b.split(".").map(Number);
|
|
12
|
+
for (let i = 0; i < 3; i++) {
|
|
13
|
+
const diff = (pb[i] || 0) - (pa[i] || 0);
|
|
14
|
+
if (diff !== 0)
|
|
15
|
+
return diff;
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
async function checkForUpdates(currentVersion) {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
https_1.default.get(VERSION_URL, { headers: { "User-Agent": `neuronix-node/${currentVersion}` } }, (res) => {
|
|
22
|
+
let body = "";
|
|
23
|
+
res.on("data", (chunk) => { body += chunk; });
|
|
24
|
+
res.on("end", () => {
|
|
25
|
+
try {
|
|
26
|
+
const data = JSON.parse(body);
|
|
27
|
+
const updateAvailable = compareVersions(currentVersion, data.version) > 0;
|
|
28
|
+
resolve({
|
|
29
|
+
updateAvailable,
|
|
30
|
+
currentVersion,
|
|
31
|
+
latestVersion: data.version,
|
|
32
|
+
downloadUrl: data.downloadUrl || "https://neuronix-nu.vercel.app/compute",
|
|
33
|
+
releaseNotes: data.releaseNotes || "",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
resolve({
|
|
38
|
+
updateAvailable: false,
|
|
39
|
+
currentVersion,
|
|
40
|
+
latestVersion: currentVersion,
|
|
41
|
+
downloadUrl: "",
|
|
42
|
+
releaseNotes: "",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}).on("error", reject);
|
|
47
|
+
});
|
|
48
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "neuronix-node",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Neuronix GPU Provider Node — earn by contributing compute to the Neuronix network",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"neuronix-node": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"start": "node dist/index.js",
|
|
12
|
+
"dev": "tsx src/index.ts",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/**/*",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"neuronix",
|
|
21
|
+
"gpu",
|
|
22
|
+
"ai",
|
|
23
|
+
"compute",
|
|
24
|
+
"provider",
|
|
25
|
+
"inference",
|
|
26
|
+
"decentralized"
|
|
27
|
+
],
|
|
28
|
+
"author": "Neuronix <contact@neuronix.io>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/n8king14/Neuronix"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=18.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"chalk": "^5.3.0",
|
|
39
|
+
"chart.js": "^4.5.1",
|
|
40
|
+
"chartjs-node-canvas": "^5.0.0",
|
|
41
|
+
"commander": "^12.0.0",
|
|
42
|
+
"node-llama-cpp": "^3.0.0",
|
|
43
|
+
"ora": "^8.0.1",
|
|
44
|
+
"systeminformation": "^5.22.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.0.0",
|
|
48
|
+
"tsx": "^4.0.0",
|
|
49
|
+
"typescript": "^5.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|