@juspay/neurolink 7.0.0 → 7.2.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/CHANGELOG.md +15 -4
- package/README.md +16 -11
- package/dist/cli/commands/config.d.ts +2 -2
- package/dist/cli/commands/config.js +22 -21
- package/dist/cli/commands/mcp.d.ts +79 -0
- package/dist/cli/commands/mcp.js +916 -0
- package/dist/cli/commands/models.d.ts +63 -0
- package/dist/cli/commands/models.js +653 -0
- package/dist/cli/commands/ollama.js +56 -55
- package/dist/cli/factories/commandFactory.d.ts +67 -2
- package/dist/cli/factories/commandFactory.js +840 -92
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +42 -999
- package/dist/cli/utils/completeSetup.js +9 -8
- package/dist/cli/utils/envManager.js +7 -6
- package/dist/cli/utils/interactiveSetup.js +20 -19
- package/dist/core/analytics.js +25 -38
- package/dist/core/baseProvider.d.ts +8 -0
- package/dist/core/baseProvider.js +177 -68
- package/dist/core/constants.d.ts +11 -0
- package/dist/core/constants.js +17 -0
- package/dist/core/evaluation.js +25 -14
- package/dist/core/factory.js +21 -18
- package/dist/core/streamAnalytics.d.ts +65 -0
- package/dist/core/streamAnalytics.js +125 -0
- package/dist/factories/providerRegistry.js +3 -1
- package/dist/lib/core/analytics.js +25 -38
- package/dist/lib/core/baseProvider.d.ts +8 -0
- package/dist/lib/core/baseProvider.js +177 -68
- package/dist/lib/core/constants.d.ts +11 -0
- package/dist/lib/core/constants.js +17 -0
- package/dist/lib/core/evaluation.js +25 -14
- package/dist/lib/core/factory.js +22 -18
- package/dist/lib/core/streamAnalytics.d.ts +65 -0
- package/dist/lib/core/streamAnalytics.js +125 -0
- package/dist/lib/factories/providerRegistry.js +3 -1
- package/dist/lib/mcp/toolRegistry.d.ts +5 -0
- package/dist/lib/mcp/toolRegistry.js +60 -0
- package/dist/lib/models/modelRegistry.d.ts +132 -0
- package/dist/lib/models/modelRegistry.js +483 -0
- package/dist/lib/models/modelResolver.d.ts +115 -0
- package/dist/lib/models/modelResolver.js +467 -0
- package/dist/lib/neurolink.d.ts +4 -1
- package/dist/lib/neurolink.js +108 -69
- package/dist/lib/providers/anthropic.js +3 -0
- package/dist/lib/providers/googleAiStudio.js +13 -0
- package/dist/lib/providers/huggingFace.js +15 -3
- package/dist/lib/providers/mistral.js +19 -7
- package/dist/lib/providers/ollama.js +31 -7
- package/dist/lib/providers/openAI.js +12 -0
- package/dist/lib/sdk/toolRegistration.js +17 -0
- package/dist/lib/types/cli.d.ts +56 -1
- package/dist/lib/types/contextTypes.d.ts +110 -0
- package/dist/lib/types/contextTypes.js +176 -0
- package/dist/lib/types/index.d.ts +4 -1
- package/dist/lib/types/mcpTypes.d.ts +118 -7
- package/dist/lib/types/providers.d.ts +81 -0
- package/dist/lib/types/streamTypes.d.ts +44 -7
- package/dist/lib/types/tools.d.ts +9 -0
- package/dist/lib/types/universalProviderOptions.d.ts +3 -1
- package/dist/lib/types/universalProviderOptions.js +2 -1
- package/dist/lib/utils/logger.d.ts +7 -0
- package/dist/lib/utils/logger.js +16 -6
- package/dist/lib/utils/performance.d.ts +105 -0
- package/dist/lib/utils/performance.js +210 -0
- package/dist/lib/utils/providerUtils.js +9 -2
- package/dist/lib/utils/retryHandler.d.ts +89 -0
- package/dist/lib/utils/retryHandler.js +269 -0
- package/dist/mcp/toolRegistry.d.ts +5 -0
- package/dist/mcp/toolRegistry.js +60 -0
- package/dist/models/modelRegistry.d.ts +132 -0
- package/dist/models/modelRegistry.js +483 -0
- package/dist/models/modelResolver.d.ts +115 -0
- package/dist/models/modelResolver.js +468 -0
- package/dist/neurolink.d.ts +4 -1
- package/dist/neurolink.js +108 -69
- package/dist/providers/anthropic.js +3 -0
- package/dist/providers/googleAiStudio.js +13 -0
- package/dist/providers/huggingFace.js +15 -3
- package/dist/providers/mistral.js +19 -7
- package/dist/providers/ollama.js +31 -7
- package/dist/providers/openAI.js +12 -0
- package/dist/sdk/toolRegistration.js +17 -0
- package/dist/types/cli.d.ts +56 -1
- package/dist/types/contextTypes.d.ts +110 -0
- package/dist/types/contextTypes.js +177 -0
- package/dist/types/index.d.ts +4 -1
- package/dist/types/mcpTypes.d.ts +118 -7
- package/dist/types/providers.d.ts +81 -0
- package/dist/types/streamTypes.d.ts +44 -7
- package/dist/types/tools.d.ts +9 -0
- package/dist/types/universalProviderOptions.d.ts +3 -1
- package/dist/types/universalProviderOptions.js +3 -1
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.js +16 -6
- package/dist/utils/performance.d.ts +105 -0
- package/dist/utils/performance.js +210 -0
- package/dist/utils/providerUtils.js +9 -2
- package/dist/utils/retryHandler.d.ts +89 -0
- package/dist/utils/retryHandler.js +269 -0
- package/package.json +2 -1
|
@@ -2,6 +2,7 @@ import { execSync } from "child_process";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import ora from "ora";
|
|
4
4
|
import inquirer from "inquirer";
|
|
5
|
+
import { logger } from "../../lib/utils/logger.js";
|
|
5
6
|
export function addOllamaCommands(cli) {
|
|
6
7
|
cli.command("ollama <command>", "Manage Ollama local AI models", (yargs) => {
|
|
7
8
|
return yargs
|
|
@@ -33,33 +34,33 @@ async function listModelsHandler() {
|
|
|
33
34
|
const output = execSync("ollama list", { encoding: "utf8" });
|
|
34
35
|
spinner.succeed("Installed models:");
|
|
35
36
|
if (output.trim()) {
|
|
36
|
-
|
|
37
|
+
logger.always(output);
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
|
-
|
|
40
|
+
logger.always(chalk.yellow('No models installed. Use "neurolink ollama pull <model>" to download a model.'));
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
catch (error) {
|
|
43
44
|
spinner.fail("Failed to list models. Is Ollama installed?");
|
|
44
45
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
logger.error(chalk.red("Error:", errorMessage));
|
|
47
|
+
logger.always(chalk.blue("\nTip: Install Ollama from https://ollama.ai"));
|
|
47
48
|
process.exit(1);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
async function pullModelHandler(argv) {
|
|
51
52
|
const { model } = argv;
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
logger.always(chalk.blue(`Downloading model: ${model}`));
|
|
54
|
+
logger.always(chalk.gray("This may take several minutes..."));
|
|
54
55
|
try {
|
|
55
56
|
execSync(`ollama pull ${model}`, { stdio: "inherit" });
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
logger.always(chalk.green(`\n✅ Successfully downloaded ${model}`));
|
|
58
|
+
logger.always(chalk.blue(`\nTest it with: npx @juspay/neurolink generate "Hello!" --provider ollama --model ${model}`));
|
|
58
59
|
}
|
|
59
60
|
catch (error) {
|
|
60
|
-
|
|
61
|
+
logger.error(chalk.red(`\n❌ Failed to download ${model}`));
|
|
61
62
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
62
|
-
|
|
63
|
+
logger.error(chalk.red("Error:", errorMessage));
|
|
63
64
|
process.exit(1);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
@@ -75,7 +76,7 @@ async function removeModelHandler(argv) {
|
|
|
75
76
|
},
|
|
76
77
|
]);
|
|
77
78
|
if (!confirm) {
|
|
78
|
-
|
|
79
|
+
logger.always(chalk.yellow("Removal cancelled."));
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
82
|
const spinner = ora(`Removing model ${model}...`).start();
|
|
@@ -86,7 +87,7 @@ async function removeModelHandler(argv) {
|
|
|
86
87
|
catch (error) {
|
|
87
88
|
spinner.fail(`Failed to remove ${model}`);
|
|
88
89
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
89
|
-
|
|
90
|
+
logger.error(chalk.red("Error:", errorMessage));
|
|
90
91
|
process.exit(1);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -103,7 +104,7 @@ async function statusHandler() {
|
|
|
103
104
|
});
|
|
104
105
|
const data = JSON.parse(response);
|
|
105
106
|
if (data.models && data.models.length > 0) {
|
|
106
|
-
|
|
107
|
+
logger.always(chalk.green(`\n${data.models.length} models available`));
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
catch {
|
|
@@ -112,18 +113,18 @@ async function statusHandler() {
|
|
|
112
113
|
}
|
|
113
114
|
catch (error) {
|
|
114
115
|
spinner.fail("Ollama service is not running");
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
logger.always(chalk.yellow("\nStart Ollama with: ollama serve"));
|
|
117
|
+
logger.always(chalk.blue("Or restart the Ollama app if using the desktop version"));
|
|
117
118
|
process.exit(1);
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
async function startHandler() {
|
|
121
|
-
|
|
122
|
+
logger.always(chalk.blue("Starting Ollama service..."));
|
|
122
123
|
try {
|
|
123
124
|
// Check if already running
|
|
124
125
|
try {
|
|
125
126
|
execSync("ollama list", { encoding: "utf8" });
|
|
126
|
-
|
|
127
|
+
logger.always(chalk.yellow("Ollama service is already running!"));
|
|
127
128
|
return;
|
|
128
129
|
}
|
|
129
130
|
catch {
|
|
@@ -132,43 +133,43 @@ async function startHandler() {
|
|
|
132
133
|
// Different approaches for different platforms
|
|
133
134
|
if (process.platform === "darwin") {
|
|
134
135
|
// macOS
|
|
135
|
-
|
|
136
|
+
logger.always(chalk.gray("Starting Ollama on macOS..."));
|
|
136
137
|
try {
|
|
137
138
|
execSync("open -a Ollama");
|
|
138
|
-
|
|
139
|
+
logger.always(chalk.green("✅ Ollama app started"));
|
|
139
140
|
}
|
|
140
141
|
catch {
|
|
141
142
|
// Try service command
|
|
142
143
|
execSync("ollama serve > /dev/null 2>&1 &", { stdio: "ignore" });
|
|
143
|
-
|
|
144
|
+
logger.always(chalk.green("✅ Ollama service started"));
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
else if (process.platform === "linux") {
|
|
147
148
|
// Linux
|
|
148
|
-
|
|
149
|
+
logger.always(chalk.gray("Starting Ollama service on Linux..."));
|
|
149
150
|
try {
|
|
150
151
|
execSync("systemctl start ollama", { encoding: "utf8" });
|
|
151
|
-
|
|
152
|
+
logger.always(chalk.green("✅ Ollama service started"));
|
|
152
153
|
}
|
|
153
154
|
catch {
|
|
154
155
|
// Try direct command
|
|
155
156
|
execSync("ollama serve > /dev/null 2>&1 &", { stdio: "ignore" });
|
|
156
|
-
|
|
157
|
+
logger.always(chalk.green("✅ Ollama service started"));
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
else {
|
|
160
161
|
// Windows
|
|
161
|
-
|
|
162
|
+
logger.always(chalk.gray("Starting Ollama on Windows..."));
|
|
162
163
|
execSync("start ollama serve", { stdio: "ignore" });
|
|
163
|
-
|
|
164
|
+
logger.always(chalk.green("✅ Ollama service started"));
|
|
164
165
|
}
|
|
165
|
-
|
|
166
|
+
logger.always(chalk.blue("\nWait a few seconds for the service to initialize..."));
|
|
166
167
|
}
|
|
167
168
|
catch (error) {
|
|
168
|
-
|
|
169
|
+
logger.error(chalk.red("Failed to start Ollama service"));
|
|
169
170
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
logger.error(chalk.red("Error:", errorMessage));
|
|
172
|
+
logger.always(chalk.blue("\nTry starting Ollama manually or check installation"));
|
|
172
173
|
process.exit(1);
|
|
173
174
|
}
|
|
174
175
|
}
|
|
@@ -201,11 +202,11 @@ async function stopHandler() {
|
|
|
201
202
|
}
|
|
202
203
|
catch (error) {
|
|
203
204
|
spinner.fail("Failed to stop Ollama service");
|
|
204
|
-
|
|
205
|
+
logger.error(chalk.red("It may not be running or requires manual stop"));
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
async function setupHandler() {
|
|
208
|
-
|
|
209
|
+
logger.always(chalk.blue("🦙 Welcome to Ollama Setup!\n"));
|
|
209
210
|
// Check if Ollama is installed
|
|
210
211
|
const checkSpinner = ora("Checking Ollama installation...").start();
|
|
211
212
|
let isInstalled = false;
|
|
@@ -218,20 +219,20 @@ async function setupHandler() {
|
|
|
218
219
|
checkSpinner.fail("Ollama is not installed");
|
|
219
220
|
}
|
|
220
221
|
if (!isInstalled) {
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
logger.always(chalk.yellow("\nOllama needs to be installed first."));
|
|
223
|
+
logger.always(chalk.blue("\nInstallation instructions:"));
|
|
223
224
|
if (process.platform === "darwin") {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
logger.always("\nFor macOS:");
|
|
226
|
+
logger.always(chalk.gray(" brew install ollama"));
|
|
227
|
+
logger.always(chalk.gray(" # or download from https://ollama.ai"));
|
|
227
228
|
}
|
|
228
229
|
else if (process.platform === "linux") {
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
logger.always("\nFor Linux:");
|
|
231
|
+
logger.always(chalk.gray(" curl -fsSL https://ollama.ai/install.sh | sh"));
|
|
231
232
|
}
|
|
232
233
|
else {
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
logger.always("\nFor Windows:");
|
|
235
|
+
logger.always(chalk.gray(" Download from https://ollama.ai"));
|
|
235
236
|
}
|
|
236
237
|
const { proceedAnyway } = await inquirer.prompt([
|
|
237
238
|
{
|
|
@@ -242,7 +243,7 @@ async function setupHandler() {
|
|
|
242
243
|
},
|
|
243
244
|
]);
|
|
244
245
|
if (!proceedAnyway) {
|
|
245
|
-
|
|
246
|
+
logger.always(chalk.blue("\nInstall Ollama and run setup again!"));
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
249
|
}
|
|
@@ -251,10 +252,10 @@ async function setupHandler() {
|
|
|
251
252
|
try {
|
|
252
253
|
execSync("ollama list", { encoding: "utf8" });
|
|
253
254
|
serviceRunning = true;
|
|
254
|
-
|
|
255
|
+
logger.always(chalk.green("\n✅ Ollama service is running"));
|
|
255
256
|
}
|
|
256
257
|
catch {
|
|
257
|
-
|
|
258
|
+
logger.always(chalk.yellow("\n⚠️ Ollama service is not running"));
|
|
258
259
|
const { startService } = await inquirer.prompt([
|
|
259
260
|
{
|
|
260
261
|
type: "confirm",
|
|
@@ -270,12 +271,12 @@ async function setupHandler() {
|
|
|
270
271
|
}
|
|
271
272
|
if (serviceRunning) {
|
|
272
273
|
// List available models
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
logger.always(chalk.blue("\n📦 Popular Ollama models:"));
|
|
275
|
+
logger.always(" • llama2 (7B) - General purpose");
|
|
276
|
+
logger.always(" • codellama (7B) - Code generation");
|
|
277
|
+
logger.always(" • mistral (7B) - Fast and efficient");
|
|
278
|
+
logger.always(" • tinyllama (1B) - Lightweight");
|
|
279
|
+
logger.always(" • phi (2.7B) - Microsoft's compact model");
|
|
279
280
|
const { downloadModel } = await inquirer.prompt([
|
|
280
281
|
{
|
|
281
282
|
type: "confirm",
|
|
@@ -322,13 +323,13 @@ async function setupHandler() {
|
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
325
|
// Final instructions
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
logger.always(chalk.green("\n✅ Setup complete!\n"));
|
|
327
|
+
logger.always(chalk.blue("Next steps:"));
|
|
328
|
+
logger.always("1. List models: " + chalk.gray("neurolink ollama list-models"));
|
|
329
|
+
logger.always("2. Generate text: " +
|
|
329
330
|
chalk.gray('neurolink generate "Hello!" --provider ollama'));
|
|
330
|
-
|
|
331
|
+
logger.always("3. Use specific model: " +
|
|
331
332
|
chalk.gray('neurolink generate "Hello!" --provider ollama --model codellama'));
|
|
332
|
-
|
|
333
|
+
logger.always(chalk.gray("\nFor more information, see: https://docs.neurolink.ai/providers/ollama"));
|
|
333
334
|
}
|
|
334
335
|
export default addOllamaCommands;
|
|
@@ -1,19 +1,84 @@
|
|
|
1
1
|
import type { CommandModule } from "yargs";
|
|
2
|
-
import type { UnknownRecord } from "../../lib/types/common.js";
|
|
3
2
|
/**
|
|
4
3
|
* CLI Command Factory for generate commands
|
|
5
4
|
*/
|
|
6
5
|
export declare class CLICommandFactory {
|
|
6
|
+
private static readonly commonOptions;
|
|
7
|
+
private static buildOptions;
|
|
8
|
+
private static processOptions;
|
|
9
|
+
private static handleOutput;
|
|
10
|
+
private static isValidTokenUsage;
|
|
11
|
+
private static formatAnalyticsForTextMode;
|
|
7
12
|
/**
|
|
8
13
|
* Create the new primary 'generate' command
|
|
9
14
|
*/
|
|
10
15
|
static createGenerateCommand(): CommandModule;
|
|
16
|
+
/**
|
|
17
|
+
* Create stream command
|
|
18
|
+
*/
|
|
19
|
+
static createStreamCommand(): CommandModule;
|
|
20
|
+
/**
|
|
21
|
+
* Create batch command
|
|
22
|
+
*/
|
|
23
|
+
static createBatchCommand(): CommandModule;
|
|
24
|
+
/**
|
|
25
|
+
* Create provider commands
|
|
26
|
+
*/
|
|
27
|
+
static createProviderCommands(): CommandModule;
|
|
28
|
+
/**
|
|
29
|
+
* Create status command (alias for provider status)
|
|
30
|
+
*/
|
|
31
|
+
static createStatusCommand(): CommandModule;
|
|
32
|
+
/**
|
|
33
|
+
* Create models commands
|
|
34
|
+
*/
|
|
35
|
+
static createModelsCommands(): CommandModule;
|
|
36
|
+
/**
|
|
37
|
+
* Create MCP commands
|
|
38
|
+
*/
|
|
39
|
+
static createMCPCommands(): CommandModule;
|
|
40
|
+
/**
|
|
41
|
+
* Create discover command
|
|
42
|
+
*/
|
|
43
|
+
static createDiscoverCommand(): CommandModule;
|
|
44
|
+
/**
|
|
45
|
+
* Create config commands
|
|
46
|
+
*/
|
|
47
|
+
static createConfigCommands(): CommandModule;
|
|
48
|
+
/**
|
|
49
|
+
* Create get-best-provider command
|
|
50
|
+
*/
|
|
51
|
+
static createBestProviderCommand(): CommandModule;
|
|
52
|
+
/**
|
|
53
|
+
* Create completion command
|
|
54
|
+
*/
|
|
55
|
+
static createCompletionCommand(): CommandModule;
|
|
11
56
|
/**
|
|
12
57
|
* Execute provider status command
|
|
13
58
|
*/
|
|
14
|
-
|
|
59
|
+
private static executeProviderStatus;
|
|
15
60
|
/**
|
|
16
61
|
* Execute the generate command
|
|
17
62
|
*/
|
|
18
63
|
private static executeGenerate;
|
|
64
|
+
/**
|
|
65
|
+
* Execute the stream command
|
|
66
|
+
*/
|
|
67
|
+
private static executeStream;
|
|
68
|
+
/**
|
|
69
|
+
* Execute the batch command
|
|
70
|
+
*/
|
|
71
|
+
private static executeBatch;
|
|
72
|
+
/**
|
|
73
|
+
* Execute config export command
|
|
74
|
+
*/
|
|
75
|
+
private static executeConfigExport;
|
|
76
|
+
/**
|
|
77
|
+
* Execute get best provider command
|
|
78
|
+
*/
|
|
79
|
+
private static executeGetBestProvider;
|
|
80
|
+
/**
|
|
81
|
+
* Execute completion command
|
|
82
|
+
*/
|
|
83
|
+
private static executeCompletion;
|
|
19
84
|
}
|