@edgible-team/cli 1.0.1
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/LICENSE +136 -0
- package/README.md +450 -0
- package/dist/client/api-client.js +1057 -0
- package/dist/client/index.js +21 -0
- package/dist/commands/agent.js +1280 -0
- package/dist/commands/ai.js +608 -0
- package/dist/commands/application.js +885 -0
- package/dist/commands/auth.js +570 -0
- package/dist/commands/base/BaseCommand.js +93 -0
- package/dist/commands/base/CommandHandler.js +7 -0
- package/dist/commands/base/command-wrapper.js +58 -0
- package/dist/commands/base/middleware.js +77 -0
- package/dist/commands/config.js +116 -0
- package/dist/commands/connectivity.js +59 -0
- package/dist/commands/debug.js +98 -0
- package/dist/commands/discover.js +144 -0
- package/dist/commands/examples/migrated-command-example.js +180 -0
- package/dist/commands/gateway.js +494 -0
- package/dist/commands/managedGateway.js +787 -0
- package/dist/commands/utils/config-validator.js +76 -0
- package/dist/commands/utils/gateway-prompt.js +79 -0
- package/dist/commands/utils/input-parser.js +120 -0
- package/dist/commands/utils/output-formatter.js +109 -0
- package/dist/config/app-config.js +99 -0
- package/dist/detection/SystemCapabilityDetector.js +1244 -0
- package/dist/detection/ToolDetector.js +305 -0
- package/dist/detection/WorkloadDetector.js +314 -0
- package/dist/di/bindings.js +99 -0
- package/dist/di/container.js +88 -0
- package/dist/di/types.js +32 -0
- package/dist/index.js +52 -0
- package/dist/interfaces/IDaemonManager.js +3 -0
- package/dist/repositories/config-repository.js +62 -0
- package/dist/repositories/gateway-repository.js +35 -0
- package/dist/scripts/postinstall.js +101 -0
- package/dist/services/AgentStatusManager.js +299 -0
- package/dist/services/ConnectivityTester.js +271 -0
- package/dist/services/DependencyInstaller.js +475 -0
- package/dist/services/LocalAgentManager.js +2216 -0
- package/dist/services/application/ApplicationService.js +299 -0
- package/dist/services/auth/AuthService.js +214 -0
- package/dist/services/aws.js +644 -0
- package/dist/services/daemon/DaemonManagerFactory.js +65 -0
- package/dist/services/daemon/DockerDaemonManager.js +395 -0
- package/dist/services/daemon/LaunchdDaemonManager.js +257 -0
- package/dist/services/daemon/PodmanDaemonManager.js +369 -0
- package/dist/services/daemon/SystemdDaemonManager.js +221 -0
- package/dist/services/daemon/WindowsServiceDaemonManager.js +210 -0
- package/dist/services/daemon/index.js +16 -0
- package/dist/services/edgible.js +3060 -0
- package/dist/services/gateway/GatewayService.js +334 -0
- package/dist/state/config.js +146 -0
- package/dist/types/AgentConfig.js +5 -0
- package/dist/types/AgentStatus.js +5 -0
- package/dist/types/ApiClient.js +5 -0
- package/dist/types/ApiRequests.js +5 -0
- package/dist/types/ApiResponses.js +5 -0
- package/dist/types/Application.js +5 -0
- package/dist/types/CaddyJson.js +5 -0
- package/dist/types/UnifiedAgentStatus.js +56 -0
- package/dist/types/WireGuard.js +5 -0
- package/dist/types/Workload.js +5 -0
- package/dist/types/agent.js +5 -0
- package/dist/types/command-options.js +5 -0
- package/dist/types/connectivity.js +5 -0
- package/dist/types/errors.js +250 -0
- package/dist/types/gateway-types.js +5 -0
- package/dist/types/index.js +48 -0
- package/dist/types/models/ApplicationData.js +5 -0
- package/dist/types/models/CertificateData.js +5 -0
- package/dist/types/models/DeviceData.js +5 -0
- package/dist/types/models/DevicePoolData.js +5 -0
- package/dist/types/models/OrganizationData.js +5 -0
- package/dist/types/models/OrganizationInviteData.js +5 -0
- package/dist/types/models/ProviderConfiguration.js +5 -0
- package/dist/types/models/ResourceData.js +5 -0
- package/dist/types/models/ServiceResourceData.js +5 -0
- package/dist/types/models/UserData.js +5 -0
- package/dist/types/route.js +5 -0
- package/dist/types/validation/schemas.js +218 -0
- package/dist/types/validation.js +5 -0
- package/dist/utils/FileIntegrityManager.js +256 -0
- package/dist/utils/PathMigration.js +219 -0
- package/dist/utils/PathResolver.js +235 -0
- package/dist/utils/PlatformDetector.js +277 -0
- package/dist/utils/console-logger.js +130 -0
- package/dist/utils/docker-compose-parser.js +179 -0
- package/dist/utils/errors.js +130 -0
- package/dist/utils/health-checker.js +155 -0
- package/dist/utils/json-logger.js +72 -0
- package/dist/utils/log-formatter.js +293 -0
- package/dist/utils/logger.js +59 -0
- package/dist/utils/network-utils.js +217 -0
- package/dist/utils/output.js +182 -0
- package/dist/utils/passwordValidation.js +91 -0
- package/dist/utils/progress.js +167 -0
- package/dist/utils/sudo-checker.js +22 -0
- package/dist/utils/urls.js +32 -0
- package/dist/utils/validation.js +31 -0
- package/dist/validation/schemas.js +175 -0
- package/dist/validation/validator.js +67 -0
- package/package.json +83 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Command wrapper utilities
|
|
4
|
+
* Provides helpers for wrapping commands with standardized error handling
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.wrapCommand = wrapCommand;
|
|
8
|
+
exports.createCommandHandler = createCommandHandler;
|
|
9
|
+
const errors_1 = require("../../utils/errors");
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a command action with standardized error handling and validation
|
|
12
|
+
*/
|
|
13
|
+
function wrapCommand(action, wrapperOptions = {}) {
|
|
14
|
+
return async (options) => {
|
|
15
|
+
try {
|
|
16
|
+
// Validate context if required
|
|
17
|
+
if (wrapperOptions.configRepository) {
|
|
18
|
+
const { requireAuth = false, requireOrganization = false } = wrapperOptions;
|
|
19
|
+
if (requireAuth) {
|
|
20
|
+
const config = wrapperOptions.configRepository.getConfig();
|
|
21
|
+
const hasTokens = !!(config.accessToken || config.idToken);
|
|
22
|
+
const hasDeviceCreds = !!(config.deviceId && config.devicePassword);
|
|
23
|
+
if (!hasTokens && !hasDeviceCreds) {
|
|
24
|
+
throw new errors_1.ConfigError('Not authenticated. Please run "edgible login" first.');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (requireOrganization) {
|
|
28
|
+
const config = wrapperOptions.configRepository.getConfig();
|
|
29
|
+
if (!config.organizationId) {
|
|
30
|
+
throw new errors_1.ConfigError('No organization found. Please login first.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Execute the command
|
|
35
|
+
await action(options);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// Ensure all errors go through ErrorHandler
|
|
39
|
+
errors_1.ErrorHandler.handleError(error);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a command handler that automatically handles errors
|
|
45
|
+
*/
|
|
46
|
+
function createCommandHandler(action, options = {}) {
|
|
47
|
+
const wrapped = wrapCommand(action, options);
|
|
48
|
+
return (opts) => {
|
|
49
|
+
// Commander expects synchronous handlers, but we need async
|
|
50
|
+
// So we'll handle the promise and let ErrorHandler exit if needed
|
|
51
|
+
wrapped(opts).catch((error) => {
|
|
52
|
+
// This should not happen as wrapCommand handles errors,
|
|
53
|
+
// but just in case:
|
|
54
|
+
errors_1.ErrorHandler.handleError(error);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=command-wrapper.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in command middleware
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PerformanceMiddleware = exports.ValidationMiddleware = exports.LoggingMiddleware = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Logging middleware - logs command execution
|
|
9
|
+
*/
|
|
10
|
+
class LoggingMiddleware {
|
|
11
|
+
constructor(logger) {
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
}
|
|
14
|
+
async process(context, next) {
|
|
15
|
+
const commandName = context.command.name();
|
|
16
|
+
this.logger.debug(`Executing command: ${commandName}`, context.options);
|
|
17
|
+
const startTime = Date.now();
|
|
18
|
+
try {
|
|
19
|
+
await next();
|
|
20
|
+
const duration = Date.now() - startTime;
|
|
21
|
+
this.logger.debug(`Command completed: ${commandName} (${duration}ms)`);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const duration = Date.now() - startTime;
|
|
25
|
+
this.logger.error(`Command failed: ${commandName} (${duration}ms)`, error);
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.LoggingMiddleware = LoggingMiddleware;
|
|
31
|
+
/**
|
|
32
|
+
* Validation middleware - validates command context
|
|
33
|
+
*/
|
|
34
|
+
class ValidationMiddleware {
|
|
35
|
+
constructor(configRepository, requireAuth = false, requireOrganization = false) {
|
|
36
|
+
this.configRepository = configRepository;
|
|
37
|
+
this.requireAuth = requireAuth;
|
|
38
|
+
this.requireOrganization = requireOrganization;
|
|
39
|
+
}
|
|
40
|
+
async process(context, next) {
|
|
41
|
+
if (this.requireAuth) {
|
|
42
|
+
const config = this.configRepository.getConfig();
|
|
43
|
+
const hasTokens = !!(config.accessToken || config.idToken);
|
|
44
|
+
const hasDeviceCreds = !!(config.deviceId && config.devicePassword);
|
|
45
|
+
if (!hasTokens && !hasDeviceCreds) {
|
|
46
|
+
throw new Error('Not authenticated. Please run "edgible login" first.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (this.requireOrganization) {
|
|
50
|
+
const config = this.configRepository.getConfig();
|
|
51
|
+
if (!config.organizationId) {
|
|
52
|
+
throw new Error('No organization found. Please login first.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
await next();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ValidationMiddleware = ValidationMiddleware;
|
|
59
|
+
/**
|
|
60
|
+
* Performance monitoring middleware
|
|
61
|
+
*/
|
|
62
|
+
class PerformanceMiddleware {
|
|
63
|
+
constructor(logger, thresholdMs = 1000) {
|
|
64
|
+
this.logger = logger;
|
|
65
|
+
this.threshold = thresholdMs;
|
|
66
|
+
}
|
|
67
|
+
async process(context, next) {
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
await next();
|
|
70
|
+
const duration = Date.now() - startTime;
|
|
71
|
+
if (duration > this.threshold) {
|
|
72
|
+
this.logger.warn(`Slow command execution: ${context.command.name()} took ${duration}ms`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.PerformanceMiddleware = PerformanceMiddleware;
|
|
77
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1,116 @@
|
|
|
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.setupConfigCommands = setupConfigCommands;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const command_wrapper_1 = require("./base/command-wrapper");
|
|
10
|
+
const container_1 = require("../di/container");
|
|
11
|
+
const types_1 = require("../di/types");
|
|
12
|
+
const errors_1 = require("../utils/errors");
|
|
13
|
+
function setupConfigCommands(program) {
|
|
14
|
+
const configCommand = program
|
|
15
|
+
.command('config')
|
|
16
|
+
.description('Manage CLI configuration');
|
|
17
|
+
configCommand
|
|
18
|
+
.command('set <key> <value>')
|
|
19
|
+
.description('Set a configuration value')
|
|
20
|
+
.action(async (key, value) => {
|
|
21
|
+
try {
|
|
22
|
+
const container = (0, container_1.getContainer)();
|
|
23
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
24
|
+
const configRepository = container.get(types_1.TYPES.ConfigRepository);
|
|
25
|
+
const config = configRepository.getConfig();
|
|
26
|
+
if (!(key in config)) {
|
|
27
|
+
throw new Error(`Invalid config key: ${key}`);
|
|
28
|
+
}
|
|
29
|
+
configRepository.updateConfig({ [key]: value });
|
|
30
|
+
logger.info('Configuration updated', { key, value });
|
|
31
|
+
console.log(chalk_1.default.green(`ā ${key} has been set.`));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
errors_1.ErrorHandler.handleError(error);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
configCommand
|
|
38
|
+
.command('get <key>')
|
|
39
|
+
.description('Get a configuration value')
|
|
40
|
+
.action(async (key) => {
|
|
41
|
+
try {
|
|
42
|
+
const container = (0, container_1.getContainer)();
|
|
43
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
44
|
+
const configRepository = container.get(types_1.TYPES.ConfigRepository);
|
|
45
|
+
const config = configRepository.getConfig();
|
|
46
|
+
if (!(key in config)) {
|
|
47
|
+
throw new Error(`Invalid config key: ${key}`);
|
|
48
|
+
}
|
|
49
|
+
const value = config[key];
|
|
50
|
+
if (value) {
|
|
51
|
+
console.log(value);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
logger.debug('Configuration key not found', { key });
|
|
55
|
+
console.log(chalk_1.default.yellow('ā Key not found.'));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
errors_1.ErrorHandler.handleError(error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
configCommand
|
|
63
|
+
.command('list')
|
|
64
|
+
.description('List all configuration values')
|
|
65
|
+
.alias('ls')
|
|
66
|
+
.action((0, command_wrapper_1.wrapCommand)(async () => {
|
|
67
|
+
const container = (0, container_1.getContainer)();
|
|
68
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
69
|
+
const configRepository = container.get(types_1.TYPES.ConfigRepository);
|
|
70
|
+
const config = configRepository.getConfig();
|
|
71
|
+
logger.debug('Listing configuration');
|
|
72
|
+
console.log(JSON.stringify(config, null, 2));
|
|
73
|
+
}, {
|
|
74
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
75
|
+
}));
|
|
76
|
+
configCommand
|
|
77
|
+
.command('reset')
|
|
78
|
+
.description('Reset the CLI configuration')
|
|
79
|
+
.option('--non-interactive', 'Run in non-interactive mode (skip confirmation)')
|
|
80
|
+
.action((0, command_wrapper_1.wrapCommand)(async (options) => {
|
|
81
|
+
const container = (0, container_1.getContainer)();
|
|
82
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
83
|
+
const configRepository = container.get(types_1.TYPES.ConfigRepository);
|
|
84
|
+
if (options.nonInteractive) {
|
|
85
|
+
// Non-interactive mode: reset without confirmation
|
|
86
|
+
configRepository.clearConfig();
|
|
87
|
+
logger.info('Configuration reset (non-interactive)');
|
|
88
|
+
console.log(chalk_1.default.green('ā CLI state has been reset'));
|
|
89
|
+
console.log(chalk_1.default.gray('Run "edgible login" to start fresh'));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Interactive mode: ask for confirmation
|
|
93
|
+
const confirm = await inquirer_1.default.prompt([
|
|
94
|
+
{
|
|
95
|
+
type: 'confirm',
|
|
96
|
+
name: 'reset',
|
|
97
|
+
message: 'Are you sure you want to reset all CLI settings?',
|
|
98
|
+
default: false,
|
|
99
|
+
},
|
|
100
|
+
]);
|
|
101
|
+
if (confirm.reset) {
|
|
102
|
+
configRepository.clearConfig();
|
|
103
|
+
logger.info('Configuration reset (interactive)');
|
|
104
|
+
console.log(chalk_1.default.green('ā CLI state has been reset'));
|
|
105
|
+
console.log(chalk_1.default.gray('Run "edgible login" to start fresh'));
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
logger.debug('Configuration reset cancelled');
|
|
109
|
+
console.log(chalk_1.default.gray('Reset cancelled'));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
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.setupConnectivityCommands = setupConnectivityCommands;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const command_wrapper_1 = require("./base/command-wrapper");
|
|
9
|
+
const container_1 = require("../di/container");
|
|
10
|
+
const types_1 = require("../di/types");
|
|
11
|
+
const input_parser_1 = require("./utils/input-parser");
|
|
12
|
+
function setupConnectivityCommands(program) {
|
|
13
|
+
const connectivityCommand = program
|
|
14
|
+
.command('connectivity')
|
|
15
|
+
.description('Test network connectivity');
|
|
16
|
+
connectivityCommand
|
|
17
|
+
.command('test')
|
|
18
|
+
.description('Test connectivity for an application')
|
|
19
|
+
.option('-a, --application <id>', 'Application ID to test')
|
|
20
|
+
.option('-h, --host <host>', 'Host to test')
|
|
21
|
+
.option('-p, --port <port>', 'Port to test')
|
|
22
|
+
.option('-t, --timeout <timeout>', 'Timeout in milliseconds', '5000')
|
|
23
|
+
.action((0, command_wrapper_1.wrapCommand)(async (options) => {
|
|
24
|
+
const container = (0, container_1.getContainer)();
|
|
25
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
26
|
+
const connectivityTester = container.get(types_1.TYPES.ConnectivityTester);
|
|
27
|
+
if (options.application) {
|
|
28
|
+
// Test specific application
|
|
29
|
+
logger.info('Testing connectivity for application', { applicationId: options.application });
|
|
30
|
+
console.log(chalk_1.default.blue(`Testing connectivity for application: ${options.application}`));
|
|
31
|
+
// Get application details (this would need to be implemented)
|
|
32
|
+
console.log(chalk_1.default.yellow('Application testing not yet implemented'));
|
|
33
|
+
}
|
|
34
|
+
else if (options.host && options.port) {
|
|
35
|
+
// Test specific host and port
|
|
36
|
+
const port = (0, input_parser_1.parsePort)(options.port);
|
|
37
|
+
const timeout = (0, input_parser_1.parseNumber)(options.timeout, 1, 60000) || 5000;
|
|
38
|
+
logger.info('Testing port connectivity', { host: options.host, port, timeout });
|
|
39
|
+
console.log(chalk_1.default.blue(`Testing connectivity to ${options.host}:${port}`));
|
|
40
|
+
const result = await connectivityTester.testPortConnectivity(options.host, port, 'tcp', timeout);
|
|
41
|
+
if (result.success) {
|
|
42
|
+
logger.info('Connection successful', { latency: result.latency });
|
|
43
|
+
console.log(chalk_1.default.green('ā Connection successful'));
|
|
44
|
+
console.log(chalk_1.default.white(` Latency: ${result.latency}ms`));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
logger.warn('Connection failed', { error: result.error });
|
|
48
|
+
console.log(chalk_1.default.red('ā Connection failed'));
|
|
49
|
+
console.log(chalk_1.default.red(` Error: ${result.error}`));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
throw new Error('Please provide either --application or --host and --port');
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=connectivity.js.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.setupDebugCommands = setupDebugCommands;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const child_process_1 = require("child_process");
|
|
43
|
+
const command_wrapper_1 = require("./base/command-wrapper");
|
|
44
|
+
const container_1 = require("../di/container");
|
|
45
|
+
const types_1 = require("../di/types");
|
|
46
|
+
function setupDebugCommands(program) {
|
|
47
|
+
const debugCommand = program
|
|
48
|
+
.command('debug')
|
|
49
|
+
.description('Debugging commands (not for production)');
|
|
50
|
+
debugCommand
|
|
51
|
+
.command('get-start-command')
|
|
52
|
+
.description('Get the command used to start the agent')
|
|
53
|
+
.action((0, command_wrapper_1.wrapCommand)(async () => {
|
|
54
|
+
const container = (0, container_1.getContainer)();
|
|
55
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
56
|
+
const agentManager = container.get(types_1.TYPES.LocalAgentManager);
|
|
57
|
+
logger.debug('Getting agent start command');
|
|
58
|
+
const startCommand = await agentManager.getStartCommand();
|
|
59
|
+
console.log(chalk_1.default.green('Agent start command:'));
|
|
60
|
+
console.log(startCommand);
|
|
61
|
+
}, {
|
|
62
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
63
|
+
}));
|
|
64
|
+
debugCommand
|
|
65
|
+
.command('logs')
|
|
66
|
+
.description('Show agent logs')
|
|
67
|
+
.option('--watch', 'Watch for new logs')
|
|
68
|
+
.action((0, command_wrapper_1.wrapCommand)(async (options) => {
|
|
69
|
+
const container = (0, container_1.getContainer)();
|
|
70
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
71
|
+
const agentManager = container.get(types_1.TYPES.LocalAgentManager);
|
|
72
|
+
const logFilePath = agentManager.getLogFilePath();
|
|
73
|
+
if (!fs.existsSync(logFilePath)) {
|
|
74
|
+
logger.debug('Log file does not exist', { logFilePath });
|
|
75
|
+
console.log(chalk_1.default.yellow('Log file does not exist yet.'));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (options.watch) {
|
|
79
|
+
logger.debug('Watching agent logs');
|
|
80
|
+
console.log(chalk_1.default.blue('Watching agent logs (Ctrl+C to stop)...'));
|
|
81
|
+
const tail = (0, child_process_1.spawn)('tail', ['-f', logFilePath]);
|
|
82
|
+
tail.stdout.on('data', (data) => {
|
|
83
|
+
process.stdout.write(data);
|
|
84
|
+
});
|
|
85
|
+
tail.stderr.on('data', (data) => {
|
|
86
|
+
process.stderr.write(data);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
logger.debug('Reading agent logs');
|
|
91
|
+
const logs = fs.readFileSync(logFilePath, 'utf8');
|
|
92
|
+
console.log(logs);
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1,144 @@
|
|
|
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.setupDiscoverCommands = setupDiscoverCommands;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ToolDetector_1 = require("../detection/ToolDetector");
|
|
9
|
+
const WorkloadDetector_1 = require("../detection/WorkloadDetector");
|
|
10
|
+
const SystemCapabilityDetector_1 = require("../detection/SystemCapabilityDetector");
|
|
11
|
+
const command_wrapper_1 = require("./base/command-wrapper");
|
|
12
|
+
const container_1 = require("../di/container");
|
|
13
|
+
const types_1 = require("../di/types");
|
|
14
|
+
function setupDiscoverCommands(program) {
|
|
15
|
+
const discoverCommand = program
|
|
16
|
+
.command('discover')
|
|
17
|
+
.description('Discover local resources');
|
|
18
|
+
discoverCommand
|
|
19
|
+
.command('tools')
|
|
20
|
+
.description('Check available container/VM/workload management tools')
|
|
21
|
+
.action((0, command_wrapper_1.wrapCommand)(async () => {
|
|
22
|
+
const container = (0, container_1.getContainer)();
|
|
23
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
24
|
+
logger.debug('Detecting infrastructure tools');
|
|
25
|
+
console.log(chalk_1.default.blue('Detecting available infrastructure tools...\n'));
|
|
26
|
+
const detectedTools = await ToolDetector_1.ToolDetector.detectTools();
|
|
27
|
+
ToolDetector_1.ToolDetector.displayDetectedTools(detectedTools);
|
|
28
|
+
const summary = ToolDetector_1.ToolDetector.getToolSummary(detectedTools);
|
|
29
|
+
console.log(chalk_1.default.gray(`\nš Summary: ${summary}`));
|
|
30
|
+
}, {
|
|
31
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
32
|
+
}));
|
|
33
|
+
discoverCommand
|
|
34
|
+
.command('workloads')
|
|
35
|
+
.description('List all running workloads and applications')
|
|
36
|
+
.option('--json', 'Output as JSON')
|
|
37
|
+
.action((0, command_wrapper_1.wrapCommand)(async (options) => {
|
|
38
|
+
const container = (0, container_1.getContainer)();
|
|
39
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
40
|
+
logger.debug('Detecting workloads', { json: options.json });
|
|
41
|
+
if (options.json) {
|
|
42
|
+
const workloads = await WorkloadDetector_1.WorkloadDetector.detectWorkloads();
|
|
43
|
+
const running = workloads.filter((w) => w.status === 'running');
|
|
44
|
+
console.log(JSON.stringify({
|
|
45
|
+
workloads: running.map((w) => ({
|
|
46
|
+
id: w.id,
|
|
47
|
+
name: w.name,
|
|
48
|
+
type: w.type,
|
|
49
|
+
description: w.description,
|
|
50
|
+
port: w.ports?.[0]?.containerPort,
|
|
51
|
+
status: w.status,
|
|
52
|
+
})),
|
|
53
|
+
}, null, 2));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.log(chalk_1.default.blue('Detecting running workloads...\n'));
|
|
57
|
+
const workloads = await WorkloadDetector_1.WorkloadDetector.detectWorkloads();
|
|
58
|
+
WorkloadDetector_1.WorkloadDetector.displayWorkloads(workloads);
|
|
59
|
+
const summary = WorkloadDetector_1.WorkloadDetector.getWorkloadSummary(workloads);
|
|
60
|
+
console.log(chalk_1.default.gray(`\nš Summary: ${summary}`));
|
|
61
|
+
}
|
|
62
|
+
}, {
|
|
63
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
64
|
+
}));
|
|
65
|
+
discoverCommand
|
|
66
|
+
.command('capabilities')
|
|
67
|
+
.description('Detect system capabilities (CPU, RAM, GPU) and recommend LLM models')
|
|
68
|
+
.alias('caps')
|
|
69
|
+
.option('--json', 'Output as JSON')
|
|
70
|
+
.action((0, command_wrapper_1.wrapCommand)(async (options) => {
|
|
71
|
+
const container = (0, container_1.getContainer)();
|
|
72
|
+
const logger = container.get(types_1.TYPES.Logger);
|
|
73
|
+
logger.debug('Detecting system capabilities', { json: options.json });
|
|
74
|
+
if (options.json) {
|
|
75
|
+
const capabilities = await SystemCapabilityDetector_1.SystemCapabilityDetector.detectCapabilities();
|
|
76
|
+
console.log(JSON.stringify({
|
|
77
|
+
cpu: {
|
|
78
|
+
model: capabilities.cpu.model,
|
|
79
|
+
cores: capabilities.cpu.cores,
|
|
80
|
+
threads: capabilities.cpu.threads,
|
|
81
|
+
architecture: capabilities.cpu.architecture,
|
|
82
|
+
speedGHz: capabilities.cpu.speed,
|
|
83
|
+
},
|
|
84
|
+
memory: {
|
|
85
|
+
totalGB: capabilities.memory.totalGB,
|
|
86
|
+
freeGB: capabilities.memory.freeGB,
|
|
87
|
+
usedGB: capabilities.memory.usedGB,
|
|
88
|
+
},
|
|
89
|
+
gpu: capabilities.gpu ? {
|
|
90
|
+
name: capabilities.gpu.name,
|
|
91
|
+
vendor: capabilities.gpu.vendor,
|
|
92
|
+
vramGB: capabilities.gpu.vramGB,
|
|
93
|
+
driverVersion: capabilities.gpu.driverVersion,
|
|
94
|
+
available: capabilities.gpu.available,
|
|
95
|
+
} : null,
|
|
96
|
+
platform: capabilities.platform,
|
|
97
|
+
hasEnoughResources: capabilities.hasEnoughResources,
|
|
98
|
+
recommendedModels: capabilities.recommendedModels.map((m) => ({
|
|
99
|
+
modelName: m.modelName,
|
|
100
|
+
size: m.size,
|
|
101
|
+
parameters: m.parameters,
|
|
102
|
+
minRamGB: m.minRamGB,
|
|
103
|
+
minVramGB: m.minVramGB,
|
|
104
|
+
recommendedRamGB: m.recommendedRamGB,
|
|
105
|
+
recommendedVramGB: m.recommendedVramGB,
|
|
106
|
+
suitability: m.suitability,
|
|
107
|
+
reasoning: m.reasoning,
|
|
108
|
+
})),
|
|
109
|
+
gpuDriverSupport: {
|
|
110
|
+
cuda: {
|
|
111
|
+
available: capabilities.gpuDriverSupport.cuda.available,
|
|
112
|
+
version: capabilities.gpuDriverSupport.cuda.version,
|
|
113
|
+
toolkitAvailable: capabilities.gpuDriverSupport.cuda.toolkitAvailable,
|
|
114
|
+
},
|
|
115
|
+
rocm: {
|
|
116
|
+
available: capabilities.gpuDriverSupport.rocm.available,
|
|
117
|
+
version: capabilities.gpuDriverSupport.rocm.version,
|
|
118
|
+
},
|
|
119
|
+
metal: {
|
|
120
|
+
available: capabilities.gpuDriverSupport.metal.available,
|
|
121
|
+
},
|
|
122
|
+
dockerGpuSupport: {
|
|
123
|
+
available: capabilities.gpuDriverSupport.dockerGpuSupport.available,
|
|
124
|
+
runtime: capabilities.gpuDriverSupport.dockerGpuSupport.runtime,
|
|
125
|
+
nvidiaContainerRuntime: capabilities.gpuDriverSupport.dockerGpuSupport.nvidiaContainerRuntime,
|
|
126
|
+
nvidiaDocker: capabilities.gpuDriverSupport.dockerGpuSupport.nvidiaDocker,
|
|
127
|
+
},
|
|
128
|
+
ollamaGpuReady: capabilities.gpuDriverSupport.ollamaGpuReady,
|
|
129
|
+
ollamaGpuReason: capabilities.gpuDriverSupport.ollamaGpuReason,
|
|
130
|
+
},
|
|
131
|
+
}, null, 2));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
console.log(chalk_1.default.blue('Detecting system capabilities...\n'));
|
|
135
|
+
const capabilities = await SystemCapabilityDetector_1.SystemCapabilityDetector.detectCapabilities();
|
|
136
|
+
SystemCapabilityDetector_1.SystemCapabilityDetector.displayCapabilities(capabilities);
|
|
137
|
+
const summary = SystemCapabilityDetector_1.SystemCapabilityDetector.getCapabilitySummary(capabilities);
|
|
138
|
+
console.log(chalk_1.default.gray(`\nš Summary: ${summary}`));
|
|
139
|
+
}
|
|
140
|
+
}, {
|
|
141
|
+
configRepository: (0, container_1.getContainer)().get(types_1.TYPES.ConfigRepository),
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=discover.js.map
|