@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.
Files changed (102) hide show
  1. package/LICENSE +136 -0
  2. package/README.md +450 -0
  3. package/dist/client/api-client.js +1057 -0
  4. package/dist/client/index.js +21 -0
  5. package/dist/commands/agent.js +1280 -0
  6. package/dist/commands/ai.js +608 -0
  7. package/dist/commands/application.js +885 -0
  8. package/dist/commands/auth.js +570 -0
  9. package/dist/commands/base/BaseCommand.js +93 -0
  10. package/dist/commands/base/CommandHandler.js +7 -0
  11. package/dist/commands/base/command-wrapper.js +58 -0
  12. package/dist/commands/base/middleware.js +77 -0
  13. package/dist/commands/config.js +116 -0
  14. package/dist/commands/connectivity.js +59 -0
  15. package/dist/commands/debug.js +98 -0
  16. package/dist/commands/discover.js +144 -0
  17. package/dist/commands/examples/migrated-command-example.js +180 -0
  18. package/dist/commands/gateway.js +494 -0
  19. package/dist/commands/managedGateway.js +787 -0
  20. package/dist/commands/utils/config-validator.js +76 -0
  21. package/dist/commands/utils/gateway-prompt.js +79 -0
  22. package/dist/commands/utils/input-parser.js +120 -0
  23. package/dist/commands/utils/output-formatter.js +109 -0
  24. package/dist/config/app-config.js +99 -0
  25. package/dist/detection/SystemCapabilityDetector.js +1244 -0
  26. package/dist/detection/ToolDetector.js +305 -0
  27. package/dist/detection/WorkloadDetector.js +314 -0
  28. package/dist/di/bindings.js +99 -0
  29. package/dist/di/container.js +88 -0
  30. package/dist/di/types.js +32 -0
  31. package/dist/index.js +52 -0
  32. package/dist/interfaces/IDaemonManager.js +3 -0
  33. package/dist/repositories/config-repository.js +62 -0
  34. package/dist/repositories/gateway-repository.js +35 -0
  35. package/dist/scripts/postinstall.js +101 -0
  36. package/dist/services/AgentStatusManager.js +299 -0
  37. package/dist/services/ConnectivityTester.js +271 -0
  38. package/dist/services/DependencyInstaller.js +475 -0
  39. package/dist/services/LocalAgentManager.js +2216 -0
  40. package/dist/services/application/ApplicationService.js +299 -0
  41. package/dist/services/auth/AuthService.js +214 -0
  42. package/dist/services/aws.js +644 -0
  43. package/dist/services/daemon/DaemonManagerFactory.js +65 -0
  44. package/dist/services/daemon/DockerDaemonManager.js +395 -0
  45. package/dist/services/daemon/LaunchdDaemonManager.js +257 -0
  46. package/dist/services/daemon/PodmanDaemonManager.js +369 -0
  47. package/dist/services/daemon/SystemdDaemonManager.js +221 -0
  48. package/dist/services/daemon/WindowsServiceDaemonManager.js +210 -0
  49. package/dist/services/daemon/index.js +16 -0
  50. package/dist/services/edgible.js +3060 -0
  51. package/dist/services/gateway/GatewayService.js +334 -0
  52. package/dist/state/config.js +146 -0
  53. package/dist/types/AgentConfig.js +5 -0
  54. package/dist/types/AgentStatus.js +5 -0
  55. package/dist/types/ApiClient.js +5 -0
  56. package/dist/types/ApiRequests.js +5 -0
  57. package/dist/types/ApiResponses.js +5 -0
  58. package/dist/types/Application.js +5 -0
  59. package/dist/types/CaddyJson.js +5 -0
  60. package/dist/types/UnifiedAgentStatus.js +56 -0
  61. package/dist/types/WireGuard.js +5 -0
  62. package/dist/types/Workload.js +5 -0
  63. package/dist/types/agent.js +5 -0
  64. package/dist/types/command-options.js +5 -0
  65. package/dist/types/connectivity.js +5 -0
  66. package/dist/types/errors.js +250 -0
  67. package/dist/types/gateway-types.js +5 -0
  68. package/dist/types/index.js +48 -0
  69. package/dist/types/models/ApplicationData.js +5 -0
  70. package/dist/types/models/CertificateData.js +5 -0
  71. package/dist/types/models/DeviceData.js +5 -0
  72. package/dist/types/models/DevicePoolData.js +5 -0
  73. package/dist/types/models/OrganizationData.js +5 -0
  74. package/dist/types/models/OrganizationInviteData.js +5 -0
  75. package/dist/types/models/ProviderConfiguration.js +5 -0
  76. package/dist/types/models/ResourceData.js +5 -0
  77. package/dist/types/models/ServiceResourceData.js +5 -0
  78. package/dist/types/models/UserData.js +5 -0
  79. package/dist/types/route.js +5 -0
  80. package/dist/types/validation/schemas.js +218 -0
  81. package/dist/types/validation.js +5 -0
  82. package/dist/utils/FileIntegrityManager.js +256 -0
  83. package/dist/utils/PathMigration.js +219 -0
  84. package/dist/utils/PathResolver.js +235 -0
  85. package/dist/utils/PlatformDetector.js +277 -0
  86. package/dist/utils/console-logger.js +130 -0
  87. package/dist/utils/docker-compose-parser.js +179 -0
  88. package/dist/utils/errors.js +130 -0
  89. package/dist/utils/health-checker.js +155 -0
  90. package/dist/utils/json-logger.js +72 -0
  91. package/dist/utils/log-formatter.js +293 -0
  92. package/dist/utils/logger.js +59 -0
  93. package/dist/utils/network-utils.js +217 -0
  94. package/dist/utils/output.js +182 -0
  95. package/dist/utils/passwordValidation.js +91 -0
  96. package/dist/utils/progress.js +167 -0
  97. package/dist/utils/sudo-checker.js +22 -0
  98. package/dist/utils/urls.js +32 -0
  99. package/dist/utils/validation.js +31 -0
  100. package/dist/validation/schemas.js +175 -0
  101. package/dist/validation/validator.js +67 -0
  102. package/package.json +83 -0
package/LICENSE ADDED
@@ -0,0 +1,136 @@
1
+ PolyForm Noncommercial License 1.0.0
2
+
3
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
4
+
5
+ Copyright (c) 2025 Edgible Team. All Rights Reserved.
6
+
7
+ Required Notice: Copyright (c) 2025 Edgible Team. All Rights Reserved.
8
+
9
+ ## Acceptance
10
+
11
+ In order to get any license under these terms, you must agree
12
+ to them as both strict obligations and conditions to all
13
+ your licenses.
14
+
15
+ ## Copyright License
16
+
17
+ The licensor grants you a copyright license for the
18
+ software to do everything you might do with the software
19
+ that would otherwise infringe the licensor's copyright
20
+ in it for any permitted purpose. However, you may
21
+ only distribute the software according to Distribution
22
+ License and make changes or new works
23
+ based on the software according to Changes and New Works
24
+ License.
25
+
26
+ ## Distribution License
27
+
28
+ The licensor grants you an additional copyright license
29
+ to distribute copies of the software. Your license
30
+ to distribute covers distributing the software with
31
+ changes and new works permitted by Changes and New Works
32
+ License.
33
+
34
+ ## Notices
35
+
36
+ You must ensure that anyone who gets a copy of any part of
37
+ the software from you also gets a copy of these terms or the
38
+ URL for them above, as well as copies of any plain-text lines
39
+ beginning with `Required Notice:` that the licensor provided
40
+ with the software. For example:
41
+
42
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
43
+
44
+ ## Changes and New Works License
45
+
46
+ The licensor grants you an additional copyright license to
47
+ make changes and new works based on the software for any
48
+ permitted purpose.
49
+
50
+ ## Patent License
51
+
52
+ The licensor grants you a patent license for the software that
53
+ covers patent claims the licensor can license, or becomes able
54
+ to license, that you would infringe by using the software.
55
+
56
+ ## Noncommercial Purposes
57
+
58
+ Any noncommercial purpose is a permitted purpose.
59
+
60
+ ## Personal Uses
61
+
62
+ Personal use for research, experiment, and testing for
63
+ the benefit of public knowledge, personal study, private
64
+ entertainment, hobby projects, amateur pursuits, or religious
65
+ observance, without any anticipated commercial application,
66
+ is use for a permitted purpose.
67
+
68
+ ## Noncommercial Organizations
69
+
70
+ Use by any charitable organization, educational institution,
71
+ public research organization, public safety or health
72
+ organization, environmental protection organization,
73
+ or government institution is use for a permitted purpose
74
+ regardless of the source of funding or obligations resulting
75
+ from the funding.
76
+
77
+ ## Fair Use
78
+
79
+ You may have "fair use" rights for the software under the
80
+ law. These terms do not limit them.
81
+
82
+ ## No Other Rights
83
+
84
+ These terms do not allow you to sublicense or transfer any of
85
+ your licenses to anyone else, or prevent the licensor from
86
+ granting licenses to anyone else. These terms do not imply
87
+ any other licenses.
88
+
89
+ ## Patent Defense
90
+
91
+ If you make any written claim that the software infringes or
92
+ contributes to infringement of any patent, your patent license
93
+ for the software granted under these terms ends immediately. If
94
+ your company makes such a claim, your patent license ends
95
+ immediately for work on behalf of your company.
96
+
97
+ ## Violations
98
+
99
+ The first time you are notified in writing that you have
100
+ violated any of these terms, or done anything with the software
101
+ not covered by your licenses, your licenses can nonetheless
102
+ continue if you come into full compliance with these terms,
103
+ and take practical steps to correct past violations, within
104
+ 32 days of receiving notice. Otherwise, all your licenses
105
+ end immediately.
106
+
107
+ ## No Liability
108
+
109
+ ***As far as the law allows, the software comes as is, without
110
+ any warranty or condition, and the licensor will not be liable
111
+ to you for any damages arising out of these terms or the use
112
+ or nature of the software, under any kind of legal claim.***
113
+
114
+ ## Definitions
115
+
116
+ The **licensor** is the individual or entity offering these
117
+ terms, and the **software** is the software the licensor makes
118
+ available under these terms.
119
+
120
+ **You** refers to the individual or entity agreeing to these
121
+ terms.
122
+
123
+ **Your company** is any legal entity, sole proprietorship,
124
+ or other kind of organization that you work for, plus all
125
+ organizations that have control over, are under the control of,
126
+ or are under common control with that organization. **Control**
127
+ means ownership of substantially all the assets of an entity,
128
+ or the power to direct its management and policies by vote,
129
+ contract, or otherwise. Control can be direct or indirect.
130
+
131
+ **Your licenses** are all the licenses granted to you for the
132
+ software under these terms.
133
+
134
+ **Use** means anything you do with the software requiring one
135
+ of your licenses.
136
+
package/README.md ADDED
@@ -0,0 +1,450 @@
1
+ # Edgible CLI
2
+
3
+ A command-line tool for managing your Edgible private network, applications, and gateways.
4
+
5
+ ## Quick Start
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ npm install -g @edgible-team/cli
11
+ ```
12
+
13
+ After installation, you'll see a welcome message with quick start instructions.
14
+
15
+ ### First Steps
16
+
17
+ 1. **Login to your account:**
18
+ ```bash
19
+ edgible auth login
20
+ ```
21
+
22
+ 2. **Check your configuration:**
23
+ ```bash
24
+ edgible config list
25
+ ```
26
+
27
+ 3. **Get help:**
28
+ ```bash
29
+ edgible --help
30
+ ```
31
+
32
+ That's it! The CLI is ready to use. No configuration files or environment variables needed.
33
+
34
+ ## Getting Started
35
+
36
+ ### Login Options
37
+
38
+ When you run `edgible auth login` for the first time, you'll see:
39
+
40
+ - **User Login**: Sign in with your existing Edgible account email and password
41
+ - **Device Login**: Create a device without an account (an invite email will be sent)
42
+
43
+ The CLI automatically detects your infrastructure tools (Docker, Kubernetes, etc.) and saves your preferences for future use.
44
+
45
+ ### Check Your Setup
46
+
47
+ ```bash
48
+ # View your configuration
49
+ edgible config list
50
+
51
+ # Discover available tools on your system
52
+ edgible discover tools
53
+
54
+ # List running workloads (Docker containers, processes, etc.)
55
+ edgible discover workloads
56
+ ```
57
+
58
+ ## Common Commands
59
+
60
+ ### Authentication
61
+
62
+ ```bash
63
+ # Login to your account
64
+ edgible auth login
65
+
66
+ # Logout
67
+ edgible auth logout
68
+
69
+ # Select active organization
70
+ edgible auth select-org
71
+ ```
72
+
73
+ ### Applications
74
+
75
+ ```bash
76
+ # List all your applications
77
+ edgible application list
78
+ # or use alias
79
+ edgible app ls
80
+
81
+ # Create an application for an existing service
82
+ edgible application create existing --name myapp --port 3000
83
+
84
+ # Create an application interactively
85
+ edgible application create existing
86
+
87
+ # Get application status/details
88
+ edgible application get --app-id <id>
89
+ # or use alias
90
+ edgible app status --app-id <id>
91
+
92
+ # Update an application
93
+ edgible application update --app-id <id>
94
+
95
+ # Delete an application
96
+ edgible application delete --app-id <id>
97
+ # or use alias
98
+ edgible app rm --app-id <id>
99
+ ```
100
+
101
+ ### Gateways
102
+
103
+ Gateways provide internet access for your applications.
104
+
105
+ ```bash
106
+ # List all gateways
107
+ edgible gateway list
108
+ # or use alias
109
+ edgible gw ls
110
+
111
+ # Create a new gateway
112
+ edgible gateway create --name mygateway
113
+
114
+ # Get gateway status
115
+ edgible gateway get --id <gateway-id>
116
+ # or use alias
117
+ edgible gw status --id <gateway-id>
118
+
119
+ # Update a gateway
120
+ edgible gateway update --id <gateway-id>
121
+
122
+ # Delete a gateway
123
+ edgible gateway delete --id <gateway-id>
124
+ # or use alias
125
+ edgible gw rm --id <gateway-id>
126
+
127
+ # View gateway logs
128
+ edgible gateway logs --id <gateway-id>
129
+
130
+ # Follow gateway logs in real-time
131
+ edgible gateway logs --id <gateway-id> --follow
132
+
133
+ # Connect to gateway via SSH
134
+ edgible gateway ssh --id <gateway-id>
135
+
136
+ # Resync gateway agent
137
+ edgible gateway resync --id <gateway-id>
138
+
139
+ # Clear gateway logs
140
+ edgible gateway wipe-logs --id <gateway-id>
141
+ ```
142
+
143
+ ### Agent Management
144
+
145
+ The agent runs on your serving devices to manage connectivity.
146
+
147
+ ```bash
148
+ # Check agent status
149
+ edgible agent status
150
+
151
+ # Setup agent dependencies and configure
152
+ edgible agent setup
153
+
154
+ # Install the agent
155
+ edgible agent install
156
+
157
+ # Start the agent
158
+ edgible agent start
159
+
160
+ # Stop the agent
161
+ edgible agent stop
162
+
163
+ # Restart the agent
164
+ edgible agent restart
165
+
166
+ # View agent logs
167
+ edgible agent logs
168
+
169
+ # Follow agent logs
170
+ edgible agent logs --follow
171
+
172
+ # Set agent log level
173
+ edgible agent set-log-level <level>
174
+
175
+ # Uninstall the agent
176
+ edgible agent uninstall
177
+ ```
178
+
179
+ ### Discovery & Tools
180
+
181
+ ```bash
182
+ # Discover available infrastructure tools
183
+ edgible discover tools
184
+
185
+ # Discover running workloads
186
+ edgible discover workloads
187
+
188
+ # Check system capabilities (CPU, RAM, GPU)
189
+ edgible discover capabilities
190
+ # or use alias
191
+ edgible discover caps
192
+ ```
193
+
194
+ ### Configuration
195
+
196
+ ```bash
197
+ # List all configuration values
198
+ edgible config list
199
+ # or use alias
200
+ edgible config ls
201
+
202
+ # Get a specific configuration value
203
+ edgible config get <key>
204
+
205
+ # Set a configuration value
206
+ edgible config set <key> <value>
207
+
208
+ # Reset CLI configuration
209
+ edgible config reset
210
+ ```
211
+
212
+ ### Connectivity Testing
213
+
214
+ ```bash
215
+ # Test connectivity for an application
216
+ edgible connectivity test --app-id <id>
217
+ ```
218
+
219
+ ### AI Service Management
220
+
221
+ ```bash
222
+ # Setup Ollama AI service
223
+ edgible ai setup
224
+
225
+ # Stop Ollama service
226
+ edgible ai stop
227
+ ```
228
+
229
+ ## Command Reference
230
+
231
+ ### Authentication Commands
232
+
233
+ | Command | Description |
234
+ |---------|-------------|
235
+ | `edgible auth login` | Login with user account or create device login |
236
+ | `edgible auth logout` | Log out of the Edgible service |
237
+ | `edgible auth select-org` | Select active organization |
238
+
239
+ ### Application Commands
240
+
241
+ | Command | Description |
242
+ |---------|-------------|
243
+ | `edgible application list` or `edgible app ls` | List all applications |
244
+ | `edgible application create existing` | Create app for existing service |
245
+ | `edgible application get --app-id <id>` or `edgible app status --app-id <id>` | Get application status/details |
246
+ | `edgible application update --app-id <id>` | Update an existing application |
247
+ | `edgible application delete --app-id <id>` or `edgible app rm --app-id <id>` | Delete an application |
248
+
249
+ ### Gateway Commands
250
+
251
+ | Command | Description |
252
+ |---------|-------------|
253
+ | `edgible gateway list` or `edgible gw ls` | List all gateways |
254
+ | `edgible gateway create` | Create a new gateway |
255
+ | `edgible gateway get --id <id>` or `edgible gw status --id <id>` | Get gateway status |
256
+ | `edgible gateway update --id <id>` | Update a gateway |
257
+ | `edgible gateway delete --id <id>` or `edgible gw rm --id <id>` | Delete a gateway |
258
+ | `edgible gateway logs --id <id>` | View gateway logs |
259
+ | `edgible gateway resync --id <id>` | Resync gateway agent |
260
+ | `edgible gateway ssh --id <id>` | Connect to gateway via SSH |
261
+ | `edgible gateway wipe-logs --id <id>` | Clear gateway logs |
262
+
263
+ ### Agent Commands
264
+
265
+ | Command | Description |
266
+ |---------|-------------|
267
+ | `edgible agent status` | Check agent status |
268
+ | `edgible agent setup` | Setup agent dependencies and configure |
269
+ | `edgible agent install` | Install the agent |
270
+ | `edgible agent start` | Start the agent |
271
+ | `edgible agent stop` | Stop the agent |
272
+ | `edgible agent restart` | Restart the agent |
273
+ | `edgible agent logs` | View agent logs |
274
+ | `edgible agent set-log-level <level>` | Set agent log level |
275
+ | `edgible agent uninstall` | Uninstall the agent |
276
+
277
+ ### Discovery Commands
278
+
279
+ | Command | Description |
280
+ |---------|-------------|
281
+ | `edgible discover tools` | Detect available tools |
282
+ | `edgible discover workloads` | Find running workloads |
283
+ | `edgible discover capabilities` or `edgible discover caps` | Check system capabilities |
284
+
285
+ ### Configuration Commands
286
+
287
+ | Command | Description |
288
+ |---------|-------------|
289
+ | `edgible config list` or `edgible config ls` | List all configuration values |
290
+ | `edgible config get <key>` | Get a configuration value |
291
+ | `edgible config set <key> <value>` | Set a configuration value |
292
+ | `edgible config reset` | Reset CLI configuration |
293
+
294
+ ### Connectivity Commands
295
+
296
+ | Command | Description |
297
+ |---------|-------------|
298
+ | `edgible connectivity test --app-id <id>` | Test connectivity for an application |
299
+
300
+ ### AI Commands
301
+
302
+ | Command | Description |
303
+ |---------|-------------|
304
+ | `edgible ai setup` | Setup Ollama AI service |
305
+ | `edgible ai stop` | Stop Ollama service |
306
+
307
+ ## Examples
308
+
309
+ ### Create and Deploy an Application
310
+
311
+ ```bash
312
+ # 1. Login to your account
313
+ edgible auth login
314
+
315
+ # 2. Discover what's running on your system
316
+ edgible discover workloads
317
+
318
+ # 3. Create an application for a service on port 3000
319
+ edgible application create existing --name myapp --port 3000
320
+
321
+ # 4. Check application status
322
+ edgible application get --app-id <app-id>
323
+ ```
324
+
325
+ ### Set Up Internet Access
326
+
327
+ ```bash
328
+ # 1. Create a gateway (requires AWS credentials)
329
+ edgible gateway create --name mygateway --region us-east-1
330
+
331
+ # 2. List your gateways
332
+ edgible gateway list
333
+
334
+ # 3. Create an application with gateway access
335
+ edgible application create existing --name myapp --port 3000 --gateway-ids <gateway-id>
336
+ ```
337
+
338
+ ### Manage Your Agent
339
+
340
+ ```bash
341
+ # Install and start the agent
342
+ edgible agent install
343
+ edgible agent start
344
+
345
+ # Check if it's running
346
+ edgible agent status
347
+
348
+ # View logs
349
+ edgible agent logs --follow
350
+ ```
351
+
352
+ ## Output Options
353
+
354
+ The CLI supports several output options:
355
+
356
+ ```bash
357
+ # Disable colored output
358
+ edgible --no-color status
359
+
360
+ # Plain text output (no colors, no emojis)
361
+ edgible --plain status
362
+
363
+ # JSON output (for some commands)
364
+ edgible application list --json
365
+ ```
366
+
367
+ ## Getting Help
368
+
369
+ ```bash
370
+ # General help
371
+ edgible --help
372
+
373
+ # Command-specific help
374
+ edgible auth --help
375
+ edgible application --help
376
+ edgible gateway --help
377
+ edgible agent --help
378
+ edgible config --help
379
+ edgible discover --help
380
+
381
+ # Version information
382
+ edgible --version
383
+ ```
384
+
385
+ ## Requirements
386
+
387
+ - **Node.js**: Version 16.0.0 or higher
388
+ - **npm**: For installation
389
+
390
+ ## Troubleshooting
391
+
392
+ ### Agent Not Starting
393
+
394
+ ```bash
395
+ # Check agent status
396
+ edgible agent status
397
+
398
+ # View agent logs
399
+ edgible agent logs
400
+
401
+ # Reinstall the agent
402
+ edgible agent install
403
+ ```
404
+
405
+ ### Application Not Accessible
406
+
407
+ ```bash
408
+ # Check application status
409
+ edgible application get --app-id <id>
410
+
411
+ # Test connectivity
412
+ edgible connectivity test --app-id <id>
413
+
414
+ # Verify the service is running on the specified port
415
+ edgible discover workloads
416
+ ```
417
+
418
+ ### Gateway Issues
419
+
420
+ ```bash
421
+ # Check gateway status
422
+ edgible gateway list
423
+
424
+ # View gateway logs
425
+ edgible gateway logs --id <gateway-id> --follow
426
+
427
+ # Resync the gateway
428
+ edgible gateway resync --id <gateway-id>
429
+ ```
430
+
431
+ ## Advanced Configuration
432
+
433
+ The CLI works out of the box with sensible defaults. Advanced users can configure behavior using environment variables:
434
+
435
+ - `STAGE` or `SST_STAGE`: Environment stage (`dev`, `staging`, `prod`). Default: `prod`
436
+ - `LOG_LEVEL`: Log verbosity (`DEBUG`, `INFO`, `WARN`, `ERROR`). Default: `INFO`
437
+ - `NO_COLOR`: Disable colored output (set to `1` or `true`)
438
+ - `PLAIN_OUTPUT`: Plain text output (set to `1` or `true`)
439
+
440
+ **Note**: Most users don't need to set these. The CLI works with production defaults.
441
+
442
+ ## License
443
+
444
+ PolyForm Noncommercial License 1.0.0 - see LICENSE file for details.
445
+
446
+ This software is licensed under the PolyForm Noncommercial License 1.0.0, which allows free use for personal and non-commercial purposes. Commercial use is prohibited. For commercial licensing, please contact the copyright holder.
447
+
448
+ ## Support
449
+
450
+ For issues, questions, or feature requests, please contact the Edgible team.