securegate-cli-tool 2.1.3 → 2.1.5
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/index.js +351 -351
- package/package.json +35 -35
- package/scripts/postinstall.js +37 -37
- package/src/api.js +213 -213
- package/src/commands/connect.js +102 -102
- package/src/commands/keys.js +281 -280
- package/src/commands/login.js +189 -190
- package/src/commands/providers.js +51 -51
- package/src/commands/status.js +78 -78
- package/src/config.js +85 -85
- package/src/index.js +165 -165
- package/templates/SKILL.md +59 -59
package/src/commands/connect.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* securegate connect — Create a new provider connection
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
const inquirer = require('inquirer');
|
|
7
|
-
const ora = require('ora');
|
|
8
|
-
const api = require('../api');
|
|
9
|
-
|
|
10
|
-
// Provider registry (mirrors lib/providers.ts)
|
|
11
|
-
const PROVIDERS = [
|
|
12
|
-
{ value: 'openai', name: 'OpenAI — GPT-4o, GPT-4.1, o3, DALL·E', placeholder: 'sk-...' },
|
|
13
|
-
{ value: 'anthropic', name: 'Anthropic — Claude 4, Claude 3.5 Sonnet', placeholder: 'sk-ant-...' },
|
|
14
|
-
{ value: 'google', name: 'Google AI — Gemini 2.5 Pro, Flash', placeholder: 'AIza...' },
|
|
15
|
-
{ value: 'azure', name: 'Azure OpenAI — GPT-4o via Azure', placeholder: 'Your Azure API key' },
|
|
16
|
-
{ value: 'groq', name: 'Groq — Ultra-fast LPU inference', placeholder: 'gsk_...' },
|
|
17
|
-
{ value: 'together', name: 'Together AI — Llama, Qwen, DeepSeek', placeholder: 'Your key' },
|
|
18
|
-
{ value: 'fireworks', name: 'Fireworks AI — Fast serverless inference', placeholder: 'fw_...' },
|
|
19
|
-
{ value: 'perplexity', name: 'Perplexity — Sonar models + web search', placeholder: 'pplx-...' },
|
|
20
|
-
{ value: 'mistral', name: 'Mistral AI — Mistral Large, Codestral', placeholder: 'Your key' },
|
|
21
|
-
{ value: 'deepseek', name: 'DeepSeek — V3, R1 reasoning', placeholder: 'sk-...' },
|
|
22
|
-
{ value: 'cohere', name: 'Cohere — Command R+, Embed', placeholder: 'Your key' },
|
|
23
|
-
{ value: 'replicate', name: 'Replicate — Open-source models', placeholder: 'r8_...' },
|
|
24
|
-
{ value: 'bedrock', name: 'AWS Bedrock — Managed AI on AWS', placeholder: 'Your key' },
|
|
25
|
-
{ value: 'huggingface', name: 'Hugging Face — 200k+ models', placeholder: 'hf_...' },
|
|
26
|
-
{ value: 'custom', name: 'Custom / OpenAI-Compatible — vLLM, LM Studio, Ollama', placeholder: 'Your key' },
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
async function connectCommand() {
|
|
30
|
-
console.log();
|
|
31
|
-
console.log(chalk.cyan.bold('🔗 Connect a Provider'));
|
|
32
|
-
console.log(chalk.dim('━'.repeat(50)));
|
|
33
|
-
console.log();
|
|
34
|
-
|
|
35
|
-
const answers = await inquirer.prompt([
|
|
36
|
-
{
|
|
37
|
-
type: 'list',
|
|
38
|
-
name: 'provider',
|
|
39
|
-
message: 'Select your AI provider:',
|
|
40
|
-
choices: PROVIDERS,
|
|
41
|
-
pageSize: 15,
|
|
42
|
-
},
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
const selected = PROVIDERS.find(p => p.value === answers.provider);
|
|
46
|
-
const followUp = [
|
|
47
|
-
{
|
|
48
|
-
type: 'password',
|
|
49
|
-
name: 'apiKey',
|
|
50
|
-
message: `Enter your ${selected.name.split(' — ')[0]} API key:`,
|
|
51
|
-
mask: '•',
|
|
52
|
-
validate: (v) => v.length > 5 ? true : 'API key seems too short',
|
|
53
|
-
},
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
// Custom provider needs base URL
|
|
57
|
-
if (answers.provider === 'custom') {
|
|
58
|
-
followUp.push({
|
|
59
|
-
type: 'input',
|
|
60
|
-
name: 'baseUrl',
|
|
61
|
-
message: 'Base URL (e.g., http://localhost:11434/v1):',
|
|
62
|
-
validate: (v) => v.startsWith('http') ? true : 'Must start with http:// or https://',
|
|
63
|
-
});
|
|
64
|
-
followUp.push({
|
|
65
|
-
type: 'input',
|
|
66
|
-
name: 'customName',
|
|
67
|
-
message: 'Connection name (optional):',
|
|
68
|
-
default: 'custom-endpoint',
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const details = await inquirer.prompt(followUp);
|
|
73
|
-
|
|
74
|
-
const spinner = ora('Encrypting & storing your key...').start();
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
const res = await api.createConnection({
|
|
78
|
-
provider: answers.provider,
|
|
79
|
-
apiKey: details.apiKey,
|
|
80
|
-
customName: details.customName,
|
|
81
|
-
baseUrl: details.baseUrl,
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (res.status !== 200 && res.status !== 201) {
|
|
85
|
-
throw new Error(res.data?.error || `Server returned ${res.status}`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
spinner.succeed(chalk.green('Connection created!'));
|
|
89
|
-
console.log();
|
|
90
|
-
console.log(chalk.dim(' Connection ID: ') + chalk.white.bold(res.data.connection_id));
|
|
91
|
-
console.log(chalk.dim(' Provider: ') + chalk.white(answers.provider));
|
|
92
|
-
console.log();
|
|
93
|
-
console.log(chalk.yellow(' Next step: Generate a security key'));
|
|
94
|
-
console.log(chalk.dim(` Run: ${chalk.cyan('securegate keys create')}`));
|
|
95
|
-
console.log();
|
|
96
|
-
} catch (err) {
|
|
97
|
-
spinner.fail(chalk.red(`Failed: ${err.message}`));
|
|
98
|
-
process.exitCode = 1;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
module.exports = connectCommand;
|
|
1
|
+
/**
|
|
2
|
+
* securegate connect — Create a new provider connection
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
const inquirer = require('inquirer');
|
|
7
|
+
const ora = require('ora');
|
|
8
|
+
const api = require('../api');
|
|
9
|
+
|
|
10
|
+
// Provider registry (mirrors lib/providers.ts)
|
|
11
|
+
const PROVIDERS = [
|
|
12
|
+
{ value: 'openai', name: 'OpenAI — GPT-4o, GPT-4.1, o3, DALL·E', placeholder: 'sk-...' },
|
|
13
|
+
{ value: 'anthropic', name: 'Anthropic — Claude 4, Claude 3.5 Sonnet', placeholder: 'sk-ant-...' },
|
|
14
|
+
{ value: 'google', name: 'Google AI — Gemini 2.5 Pro, Flash', placeholder: 'AIza...' },
|
|
15
|
+
{ value: 'azure', name: 'Azure OpenAI — GPT-4o via Azure', placeholder: 'Your Azure API key' },
|
|
16
|
+
{ value: 'groq', name: 'Groq — Ultra-fast LPU inference', placeholder: 'gsk_...' },
|
|
17
|
+
{ value: 'together', name: 'Together AI — Llama, Qwen, DeepSeek', placeholder: 'Your key' },
|
|
18
|
+
{ value: 'fireworks', name: 'Fireworks AI — Fast serverless inference', placeholder: 'fw_...' },
|
|
19
|
+
{ value: 'perplexity', name: 'Perplexity — Sonar models + web search', placeholder: 'pplx-...' },
|
|
20
|
+
{ value: 'mistral', name: 'Mistral AI — Mistral Large, Codestral', placeholder: 'Your key' },
|
|
21
|
+
{ value: 'deepseek', name: 'DeepSeek — V3, R1 reasoning', placeholder: 'sk-...' },
|
|
22
|
+
{ value: 'cohere', name: 'Cohere — Command R+, Embed', placeholder: 'Your key' },
|
|
23
|
+
{ value: 'replicate', name: 'Replicate — Open-source models', placeholder: 'r8_...' },
|
|
24
|
+
{ value: 'bedrock', name: 'AWS Bedrock — Managed AI on AWS', placeholder: 'Your key' },
|
|
25
|
+
{ value: 'huggingface', name: 'Hugging Face — 200k+ models', placeholder: 'hf_...' },
|
|
26
|
+
{ value: 'custom', name: 'Custom / OpenAI-Compatible — vLLM, LM Studio, Ollama', placeholder: 'Your key' },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
async function connectCommand() {
|
|
30
|
+
console.log();
|
|
31
|
+
console.log(chalk.cyan.bold('🔗 Connect a Provider'));
|
|
32
|
+
console.log(chalk.dim('━'.repeat(50)));
|
|
33
|
+
console.log();
|
|
34
|
+
|
|
35
|
+
const answers = await inquirer.prompt([
|
|
36
|
+
{
|
|
37
|
+
type: 'list',
|
|
38
|
+
name: 'provider',
|
|
39
|
+
message: 'Select your AI provider:',
|
|
40
|
+
choices: PROVIDERS,
|
|
41
|
+
pageSize: 15,
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const selected = PROVIDERS.find(p => p.value === answers.provider);
|
|
46
|
+
const followUp = [
|
|
47
|
+
{
|
|
48
|
+
type: 'password',
|
|
49
|
+
name: 'apiKey',
|
|
50
|
+
message: `Enter your ${selected.name.split(' — ')[0]} API key:`,
|
|
51
|
+
mask: '•',
|
|
52
|
+
validate: (v) => v.length > 5 ? true : 'API key seems too short',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
// Custom provider needs base URL
|
|
57
|
+
if (answers.provider === 'custom') {
|
|
58
|
+
followUp.push({
|
|
59
|
+
type: 'input',
|
|
60
|
+
name: 'baseUrl',
|
|
61
|
+
message: 'Base URL (e.g., http://localhost:11434/v1):',
|
|
62
|
+
validate: (v) => v.startsWith('http') ? true : 'Must start with http:// or https://',
|
|
63
|
+
});
|
|
64
|
+
followUp.push({
|
|
65
|
+
type: 'input',
|
|
66
|
+
name: 'customName',
|
|
67
|
+
message: 'Connection name (optional):',
|
|
68
|
+
default: 'custom-endpoint',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const details = await inquirer.prompt(followUp);
|
|
73
|
+
|
|
74
|
+
const spinner = ora('Encrypting & storing your key...').start();
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
const res = await api.createConnection({
|
|
78
|
+
provider: answers.provider,
|
|
79
|
+
apiKey: details.apiKey,
|
|
80
|
+
customName: details.customName,
|
|
81
|
+
baseUrl: details.baseUrl,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (res.status !== 200 && res.status !== 201) {
|
|
85
|
+
throw new Error(res.data?.error || `Server returned ${res.status}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
spinner.succeed(chalk.green('Connection created!'));
|
|
89
|
+
console.log();
|
|
90
|
+
console.log(chalk.dim(' Connection ID: ') + chalk.white.bold(res.data.connection_id));
|
|
91
|
+
console.log(chalk.dim(' Provider: ') + chalk.white(answers.provider));
|
|
92
|
+
console.log();
|
|
93
|
+
console.log(chalk.yellow(' Next step: Generate a security key'));
|
|
94
|
+
console.log(chalk.dim(` Run: ${chalk.cyan('securegate keys create')}`));
|
|
95
|
+
console.log();
|
|
96
|
+
} catch (err) {
|
|
97
|
+
spinner.fail(chalk.red(`Failed: ${err.message}`));
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = connectCommand;
|