bdy 1.16.11-master → 1.16.11-sbs-2

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 (52) hide show
  1. package/distTs/package.json +4 -3
  2. package/distTs/src/api/client.js +78 -2
  3. package/distTs/src/command/agent/install.js +11 -17
  4. package/distTs/src/command/login.js +298 -0
  5. package/distTs/src/command/logout.js +15 -0
  6. package/distTs/src/command/package/download.js +259 -0
  7. package/distTs/src/command/package/publish.js +231 -0
  8. package/distTs/src/command/package.js +14 -0
  9. package/distTs/src/command/project/list.js +61 -0
  10. package/distTs/src/command/project/set.js +85 -0
  11. package/distTs/src/command/project.js +14 -0
  12. package/distTs/src/command/sandbox/command/kill.js +35 -0
  13. package/distTs/src/command/sandbox/command/list.js +54 -0
  14. package/distTs/src/command/sandbox/command/logs.js +133 -0
  15. package/distTs/src/command/sandbox/command/status.js +44 -0
  16. package/distTs/src/command/sandbox/command.js +18 -0
  17. package/distTs/src/command/sandbox/cp.js +123 -0
  18. package/distTs/src/command/sandbox/create.js +99 -0
  19. package/distTs/src/command/sandbox/destroy.js +35 -0
  20. package/distTs/src/command/sandbox/endpoint/add.js +91 -0
  21. package/distTs/src/command/sandbox/endpoint/delete.js +46 -0
  22. package/distTs/src/command/sandbox/endpoint/get.js +58 -0
  23. package/distTs/src/command/sandbox/endpoint/list.js +51 -0
  24. package/distTs/src/command/sandbox/endpoint/update.js +85 -0
  25. package/distTs/src/command/sandbox/endpoint.js +20 -0
  26. package/distTs/src/command/sandbox/exec.js +127 -0
  27. package/distTs/src/command/sandbox/get.js +51 -0
  28. package/distTs/src/command/sandbox/list.js +41 -0
  29. package/distTs/src/command/sandbox/restart.js +49 -0
  30. package/distTs/src/command/sandbox/snapshot/create.js +68 -0
  31. package/distTs/src/command/sandbox/snapshot/delete.js +42 -0
  32. package/distTs/src/command/sandbox/snapshot/get.js +54 -0
  33. package/distTs/src/command/sandbox/snapshot/list.js +48 -0
  34. package/distTs/src/command/sandbox/snapshot.js +18 -0
  35. package/distTs/src/command/sandbox/start.js +49 -0
  36. package/distTs/src/command/sandbox/status.js +35 -0
  37. package/distTs/src/command/sandbox/stop.js +49 -0
  38. package/distTs/src/command/sandbox.js +36 -0
  39. package/distTs/src/command/tunnel/http.js +4 -3
  40. package/distTs/src/command/tunnel/tcp.js +4 -3
  41. package/distTs/src/command/tunnel/tls.js +4 -3
  42. package/distTs/src/command/workspace/list.js +57 -0
  43. package/distTs/src/command/workspace/set.js +81 -0
  44. package/distTs/src/command/workspace.js +14 -0
  45. package/distTs/src/index.js +10 -0
  46. package/distTs/src/input.js +24 -4
  47. package/distTs/src/texts.js +164 -8
  48. package/distTs/src/tunnel/cfg.js +53 -4
  49. package/package.json +4 -3
  50. package/distTs/src/command/agent/standalone/kill.js +0 -22
  51. package/distTs/src/command/agent/standalone.js +0 -136
  52. package/distTs/src/command/vt/scrap.js +0 -193
@@ -0,0 +1,46 @@
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
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_DELETE);
12
+ commandSandboxEndpointDelete.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointDelete.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointDelete.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointDelete.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointDelete.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
19
+ commandSandboxEndpointDelete.action(async (identifier, endpointName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ // Find sandbox by identifier
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ // Get current sandbox to get existing endpoints
33
+ const sandbox = await client.getSandbox(workspace, found.id);
34
+ const endpoints = sandbox.endpoints || [];
35
+ // Find endpoint by name
36
+ const endpointIndex = endpoints.findIndex((ep) => ep.name === endpointName);
37
+ if (endpointIndex === -1) {
38
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
39
+ }
40
+ // Remove the endpoint from the list
41
+ const updatedEndpoints = endpoints.filter((ep) => ep.name !== endpointName);
42
+ // Update sandbox with new endpoints list
43
+ await client.updateSandbox(workspace, found.id, { endpoints: updatedEndpoints });
44
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_DELETED)(endpointName));
45
+ });
46
+ exports.default = commandSandboxEndpointDelete;
@@ -0,0 +1,58 @@
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
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_GET);
12
+ commandSandboxEndpointGet.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointGet.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointGet.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointGet.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
19
+ commandSandboxEndpointGet.action(async (identifier, endpointName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ // Find sandbox by identifier
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ // Get sandbox to find endpoint
33
+ const sandbox = await client.getSandbox(workspace, found.id);
34
+ const endpoints = sandbox.endpoints || [];
35
+ const endpoint = endpoints.find((ep) => ep.name === endpointName);
36
+ if (!endpoint) {
37
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
38
+ }
39
+ const url = endpoint.url || '-';
40
+ const whitelist = endpoint.whitelist?.join(', ') || '-';
41
+ const authType = endpoint.http?.auth_type || '-';
42
+ const authLogin = endpoint.http?.login || '-';
43
+ const data = [
44
+ ['Property', 'Value'],
45
+ ['Name', endpoint.name || '-'],
46
+ ['Port', endpoint.endpoint || '-'],
47
+ ['Type', endpoint.type || '-'],
48
+ ['Region', endpoint.region || '-'],
49
+ ['URL', url],
50
+ ['Whitelist', whitelist],
51
+ ['Timeout', endpoint.timeout?.toString() || '-'],
52
+ ['Auth Type', authType],
53
+ ['Auth Login', authLogin],
54
+ ];
55
+ output_1.default.table(data);
56
+ output_1.default.exitNormal();
57
+ });
58
+ exports.default = commandSandboxEndpointGet;
@@ -0,0 +1,51 @@
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
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_LIST);
12
+ commandSandboxEndpointList.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointList.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointList.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointList.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointList.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ // Find sandbox by identifier
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ const sandbox = await client.getSandbox(workspace, found.id);
32
+ const endpoints = sandbox.endpoints || [];
33
+ if (endpoints.length === 0) {
34
+ output_1.default.normal('No endpoints found');
35
+ output_1.default.exitNormal();
36
+ }
37
+ const data = [['Name', 'Port', 'Type', 'Region', 'URL']];
38
+ for (const ep of endpoints) {
39
+ const url = ep.url || '-';
40
+ data.push([
41
+ ep.name || '-',
42
+ ep.endpoint || '-',
43
+ ep.type || '-',
44
+ ep.region || '-',
45
+ url,
46
+ ]);
47
+ }
48
+ output_1.default.table(data);
49
+ output_1.default.exitNormal();
50
+ });
51
+ exports.default = commandSandboxEndpointList;
@@ -0,0 +1,85 @@
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
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxEndpointUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT_UPDATE);
12
+ commandSandboxEndpointUpdate.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxEndpointUpdate.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxEndpointUpdate.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxEndpointUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxEndpointUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxEndpointUpdate.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxEndpointUpdate.argument('<endpoint-name>', texts_1.OPTION_SANDBOX_ENDPOINT_NAME_ARG);
19
+ commandSandboxEndpointUpdate.option('--port <port>', texts_1.OPTION_SANDBOX_ENDPOINT_PORT);
20
+ commandSandboxEndpointUpdate.option('-t, --type <type>', texts_1.OPTION_SANDBOX_ENDPOINT_TYPE);
21
+ commandSandboxEndpointUpdate.option('--ep-region <region>', texts_1.OPTION_SANDBOX_ENDPOINT_REGION);
22
+ commandSandboxEndpointUpdate.option('--whitelist <cidrs...>', texts_1.OPTION_SANDBOX_ENDPOINT_WHITELIST);
23
+ commandSandboxEndpointUpdate.option('--auth <type>', texts_1.OPTION_SANDBOX_ENDPOINT_AUTH);
24
+ commandSandboxEndpointUpdate.option('--username <username>', texts_1.OPTION_SANDBOX_ENDPOINT_USERNAME);
25
+ commandSandboxEndpointUpdate.option('--password <password>', texts_1.OPTION_SANDBOX_ENDPOINT_PASSWORD);
26
+ commandSandboxEndpointUpdate.action(async (identifier, endpointName, options) => {
27
+ const token = input_1.default.restApiToken(options.token);
28
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
29
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
30
+ const project = input_1.default.restApiProject(options.project);
31
+ const client = new client_1.default(baseUrl, token);
32
+ // Find sandbox by identifier
33
+ const result = await client.listSandboxes(workspace, project);
34
+ const sandboxes = result.sandboxes || [];
35
+ const found = sandboxes.find((s) => s.identifier === identifier);
36
+ if (!found) {
37
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
38
+ }
39
+ // Get current sandbox to get existing endpoints
40
+ const sandbox = await client.getSandbox(workspace, found.id);
41
+ const endpoints = sandbox.endpoints || [];
42
+ // Find endpoint by name
43
+ const endpointIndex = endpoints.findIndex((ep) => ep.name === endpointName);
44
+ if (endpointIndex === -1) {
45
+ output_1.default.exitError(texts_1.ERR_SANDBOX_ENDPOINT_NOT_FOUND);
46
+ }
47
+ // Update endpoint with provided values
48
+ const endpoint = { ...endpoints[endpointIndex] };
49
+ if (options.port) {
50
+ endpoint.endpoint = options.port;
51
+ }
52
+ if (options.type) {
53
+ endpoint.type = options.type.toUpperCase();
54
+ }
55
+ if (options.epRegion) {
56
+ endpoint.region = options.epRegion.toUpperCase();
57
+ }
58
+ if (options.whitelist) {
59
+ endpoint.whitelist = options.whitelist;
60
+ }
61
+ // Update HTTP-specific options (auth)
62
+ if (options.auth || options.username || options.password) {
63
+ endpoint.http = endpoint.http || {};
64
+ // Auto-set BASIC auth if username/password provided
65
+ if (options.username || options.password) {
66
+ endpoint.http.auth_type = 'BASIC';
67
+ if (options.username) {
68
+ endpoint.http.login = options.username;
69
+ }
70
+ if (options.password) {
71
+ endpoint.http.password = options.password;
72
+ }
73
+ }
74
+ else if (options.auth) {
75
+ endpoint.http.auth_type = options.auth.toUpperCase();
76
+ }
77
+ }
78
+ // Replace endpoint in the list
79
+ const updatedEndpoints = [...endpoints];
80
+ updatedEndpoints[endpointIndex] = endpoint;
81
+ // Update sandbox with new endpoints list
82
+ await client.updateSandbox(workspace, found.id, { endpoints: updatedEndpoints });
83
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_ENDPOINT_UPDATED)(endpointName));
84
+ });
85
+ exports.default = commandSandboxEndpointUpdate;
@@ -0,0 +1,20 @@
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
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const list_1 = __importDefault(require("./endpoint/list"));
9
+ const get_1 = __importDefault(require("./endpoint/get"));
10
+ const add_1 = __importDefault(require("./endpoint/add"));
11
+ const update_1 = __importDefault(require("./endpoint/update"));
12
+ const delete_1 = __importDefault(require("./endpoint/delete"));
13
+ const commandSandboxEndpoint = (0, utils_1.newCommand)('endpoint', texts_1.DESC_COMMAND_SANDBOX_ENDPOINT);
14
+ commandSandboxEndpoint.alias('ep');
15
+ commandSandboxEndpoint.addCommand(list_1.default);
16
+ commandSandboxEndpoint.addCommand(get_1.default);
17
+ commandSandboxEndpoint.addCommand(add_1.default);
18
+ commandSandboxEndpoint.addCommand(update_1.default);
19
+ commandSandboxEndpoint.addCommand(delete_1.default);
20
+ exports.default = commandSandboxEndpoint;
@@ -0,0 +1,127 @@
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
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const VALID_RUNTIMES = ['BASH', 'JAVASCRIPT', 'TYPESCRIPT', 'PYTHON'];
12
+ const commandSandboxExec = (0, utils_1.newCommand)('exec', texts_1.DESC_COMMAND_SANDBOX_EXEC);
13
+ commandSandboxExec.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
14
+ commandSandboxExec.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
15
+ commandSandboxExec.option('--region <region>', texts_1.OPTION_REST_API_REGION);
16
+ commandSandboxExec.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandSandboxExec.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandSandboxExec.option('--runtime <runtime>', texts_1.OPTION_SANDBOX_RUNTIME);
19
+ commandSandboxExec.option('-d, --detached', texts_1.OPTION_SANDBOX_DETACHED);
20
+ commandSandboxExec.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
21
+ commandSandboxExec.argument('<command>', texts_1.OPTION_SANDBOX_COMMAND);
22
+ commandSandboxExec.action(async (identifier, command, options) => {
23
+ const token = input_1.default.restApiToken(options.token);
24
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
25
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
26
+ const project = input_1.default.restApiProject(options.project);
27
+ const client = new client_1.default(baseUrl, token);
28
+ // Validate runtime if provided
29
+ const runtime = options.runtime?.toUpperCase() || 'BASH';
30
+ if (!VALID_RUNTIMES.includes(runtime)) {
31
+ output_1.default.exitError((0, texts_1.ERR_SANDBOX_INVALID_RUNTIME)(options.runtime));
32
+ }
33
+ // First list sandboxes to find by identifier
34
+ const result = await client.listSandboxes(workspace, project);
35
+ const sandboxes = result.sandboxes || [];
36
+ const found = sandboxes.find((s) => s.identifier === identifier);
37
+ if (!found) {
38
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
39
+ }
40
+ // Execute command
41
+ const body = {
42
+ command,
43
+ };
44
+ if (runtime !== 'BASH') {
45
+ body.runtime = runtime;
46
+ }
47
+ const cmdResult = await client.executeSandboxCommand(workspace, found.id, body);
48
+ const commandId = cmdResult.id;
49
+ // If detached, return immediately with command ID
50
+ if (options.detached) {
51
+ output_1.default.exitSuccess(`Command started in background: ${commandId}`);
52
+ }
53
+ // Stream logs in real-time
54
+ const logsUrl = await client.getSandboxCommandLogsUrl(workspace, found.id, commandId);
55
+ try {
56
+ const response = await fetch(logsUrl, {
57
+ method: 'GET',
58
+ headers: {
59
+ Accept: 'application/jsonl',
60
+ Authorization: `Bearer ${token}`,
61
+ },
62
+ });
63
+ if (response.ok && response.body) {
64
+ const reader = response.body.getReader();
65
+ const decoder = new TextDecoder();
66
+ let buffer = '';
67
+ while (true) {
68
+ const { done, value } = await reader.read();
69
+ if (done)
70
+ break;
71
+ buffer += decoder.decode(value, { stream: true });
72
+ const lines = buffer.split('\n');
73
+ buffer = lines.pop() || '';
74
+ for (const line of lines) {
75
+ if (!line.trim())
76
+ continue;
77
+ try {
78
+ const logEntry = JSON.parse(line);
79
+ const content = logEntry.data ?? logEntry.message ?? '';
80
+ if (content) {
81
+ if (logEntry.stream === 'stderr' || logEntry.type === 'STDERR') {
82
+ process.stderr.write(content + '\n');
83
+ }
84
+ else {
85
+ process.stdout.write(content + '\n');
86
+ }
87
+ }
88
+ }
89
+ catch {
90
+ process.stdout.write(line + '\n');
91
+ }
92
+ }
93
+ }
94
+ // Process remaining buffer
95
+ if (buffer.trim()) {
96
+ try {
97
+ const logEntry = JSON.parse(buffer);
98
+ const content = logEntry.data ?? logEntry.message ?? '';
99
+ if (content) {
100
+ process.stdout.write(content + '\n');
101
+ }
102
+ }
103
+ catch {
104
+ process.stdout.write(buffer + '\n');
105
+ }
106
+ }
107
+ }
108
+ }
109
+ catch {
110
+ // Streaming failed, fall back to polling
111
+ }
112
+ // Poll for command completion and get exit code
113
+ while (true) {
114
+ const cmd = await client.getSandboxCommand(workspace, found.id, commandId);
115
+ if (cmd.status === 'SUCCESSFUL' || cmd.status === 'FAILED') {
116
+ const exitCode = cmd.exit_code ?? (cmd.status === 'SUCCESSFUL' ? 0 : 1);
117
+ // Print summary
118
+ process.stdout.write('\n');
119
+ process.stdout.write('---\n');
120
+ process.stdout.write(`Command ID: ${commandId}\n`);
121
+ process.stdout.write(`Exit code: ${exitCode}\n`);
122
+ process.exit(exitCode);
123
+ }
124
+ await new Promise((resolve) => setTimeout(resolve, 1000));
125
+ }
126
+ });
127
+ exports.default = commandSandboxExec;
@@ -0,0 +1,51 @@
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
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_SANDBOX_GET);
12
+ commandSandboxGet.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxGet.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxGet.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxGet.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ // First list sandboxes to find by identifier
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ // Get full sandbox details
32
+ const sandbox = await client.getSandbox(workspace, found.id);
33
+ const data = [
34
+ ['Property', 'Value'],
35
+ ['ID', sandbox.id || '-'],
36
+ ['Identifier', sandbox.identifier || '-'],
37
+ ['Name', sandbox.name || '-'],
38
+ ['Status', sandbox.status || '-'],
39
+ ['Setup Status', sandbox.setup_status || '-'],
40
+ ['App Status', sandbox.app_status || '-'],
41
+ ['OS', sandbox.os || '-'],
42
+ ['Resources', sandbox.resources || '-'],
43
+ ['URL', sandbox.html_url || '-'],
44
+ ];
45
+ if (sandbox.endpoints && sandbox.endpoints.length > 0) {
46
+ data.push(['Endpoints', sandbox.endpoints.map((e) => `${e.name}: ${e.endpoint}`).join('\n')]);
47
+ }
48
+ output_1.default.table(data);
49
+ output_1.default.exitNormal();
50
+ });
51
+ exports.default = commandSandboxGet;
@@ -0,0 +1,41 @@
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
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_SANDBOX_LIST);
12
+ commandSandboxList.alias('ls');
13
+ commandSandboxList.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
14
+ commandSandboxList.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
15
+ commandSandboxList.option('--region <region>', texts_1.OPTION_REST_API_REGION);
16
+ commandSandboxList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandSandboxList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandSandboxList.action(async (options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ const result = await client.listSandboxes(workspace, project);
25
+ const sandboxes = result.sandboxes || [];
26
+ if (sandboxes.length === 0) {
27
+ output_1.default.exitNormal('No sandboxes found');
28
+ }
29
+ const data = [['IDENTIFIER', 'NAME', 'STATUS', 'ID']];
30
+ for (const sandbox of sandboxes) {
31
+ data.push([
32
+ sandbox.identifier || '-',
33
+ sandbox.name || '-',
34
+ sandbox.status || '-',
35
+ sandbox.id || '-',
36
+ ]);
37
+ }
38
+ output_1.default.table(data);
39
+ output_1.default.exitNormal();
40
+ });
41
+ exports.default = commandSandboxList;
@@ -0,0 +1,49 @@
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
+ const utils_1 = require("../../utils");
7
+ const texts_1 = require("../../texts");
8
+ const output_1 = __importDefault(require("../../output"));
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const client_1 = __importDefault(require("../../api/client"));
11
+ const commandSandboxRestart = (0, utils_1.newCommand)('restart', texts_1.DESC_COMMAND_SANDBOX_RESTART);
12
+ commandSandboxRestart.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxRestart.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxRestart.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxRestart.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxRestart.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxRestart.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxRestart.action(async (identifier, options) => {
19
+ const token = input_1.default.restApiToken(options.token);
20
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const client = new client_1.default(baseUrl, token);
24
+ // First list sandboxes to find by identifier
25
+ const result = await client.listSandboxes(workspace, project);
26
+ const sandboxes = result.sandboxes || [];
27
+ const found = sandboxes.find((s) => s.identifier === identifier);
28
+ if (!found) {
29
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
30
+ }
31
+ await client.restartSandbox(workspace, found.id);
32
+ // Wait for sandbox to be running
33
+ const startTime = Date.now();
34
+ const maxWaitMs = 60000;
35
+ while (true) {
36
+ const sandbox = await client.getSandbox(workspace, found.id);
37
+ if (sandbox.status === 'RUNNING' && (sandbox.setup_status === 'SUCCESS' || sandbox.setup_status === 'DONE')) {
38
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_RESTARTED)(identifier));
39
+ }
40
+ if (sandbox.status === 'FAILED' || sandbox.setup_status === 'FAILED') {
41
+ output_1.default.exitError(texts_1.ERR_SANDBOX_START_TIMEOUT);
42
+ }
43
+ if (Date.now() - startTime > maxWaitMs) {
44
+ output_1.default.exitError(texts_1.ERR_SANDBOX_START_TIMEOUT);
45
+ }
46
+ await new Promise((resolve) => setTimeout(resolve, 1000));
47
+ }
48
+ });
49
+ exports.default = commandSandboxRestart;
@@ -0,0 +1,68 @@
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
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const human_id_1 = __importDefault(require("human-id"));
12
+ const commandSandboxSnapshotCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_CREATE);
13
+ commandSandboxSnapshotCreate.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
14
+ commandSandboxSnapshotCreate.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
15
+ commandSandboxSnapshotCreate.option('--region <region>', texts_1.OPTION_REST_API_REGION);
16
+ commandSandboxSnapshotCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandSandboxSnapshotCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandSandboxSnapshotCreate.option('-n, --name <name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME);
19
+ commandSandboxSnapshotCreate.option('-d, --description <description>', texts_1.OPTION_SANDBOX_SNAPSHOT_DESCRIPTION);
20
+ commandSandboxSnapshotCreate.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
21
+ commandSandboxSnapshotCreate.action(async (identifier, options) => {
22
+ const token = input_1.default.restApiToken(options.token);
23
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
24
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
25
+ const project = input_1.default.restApiProject(options.project);
26
+ const client = new client_1.default(baseUrl, token);
27
+ // Find sandbox by identifier
28
+ const result = await client.listSandboxes(workspace, project);
29
+ const sandboxes = result.sandboxes || [];
30
+ const found = sandboxes.find((s) => s.identifier === identifier);
31
+ if (!found) {
32
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
33
+ }
34
+ const defaultName = 'snapshot-' + (0, human_id_1.default)({ separator: '-', capitalize: false });
35
+ const snapshotName = options.name || defaultName;
36
+ const body = {
37
+ name: snapshotName,
38
+ };
39
+ if (options.description) {
40
+ body.description = options.description;
41
+ }
42
+ output_1.default.normal(`Creating snapshot: ${snapshotName}`);
43
+ const snapshot = await client.createSandboxSnapshot(workspace, found.id, body);
44
+ const snapshotId = snapshot.id;
45
+ // If already ready, exit immediately
46
+ if (snapshot.status === 'CREATED') {
47
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_CREATED)(snapshotName));
48
+ }
49
+ // Wait for snapshot to be ready
50
+ output_1.default.normal(texts_1.TXT_SANDBOX_SNAPSHOT_WAITING);
51
+ // Poll until status is CREATED or FAILED (max 5 minutes)
52
+ const maxWaitMs = 5 * 60 * 1000;
53
+ const startTime = Date.now();
54
+ while (true) {
55
+ const snap = await client.getSandboxSnapshot(workspace, found.id, snapshotId);
56
+ if (snap.status === 'CREATED') {
57
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_CREATED)(snapshotName));
58
+ }
59
+ if (snap.status === 'FAILED') {
60
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_FAILED);
61
+ }
62
+ if (Date.now() - startTime > maxWaitMs) {
63
+ output_1.default.exitError('Timeout waiting for snapshot creation');
64
+ }
65
+ await new Promise((resolve) => setTimeout(resolve, 2000));
66
+ }
67
+ });
68
+ exports.default = commandSandboxSnapshotCreate;
@@ -0,0 +1,42 @@
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
+ const utils_1 = require("../../../utils");
7
+ const texts_1 = require("../../../texts");
8
+ const output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const client_1 = __importDefault(require("../../../api/client"));
11
+ const commandSandboxSnapshotDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_SANDBOX_SNAPSHOT_DELETE);
12
+ commandSandboxSnapshotDelete.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
13
+ commandSandboxSnapshotDelete.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
14
+ commandSandboxSnapshotDelete.option('--region <region>', texts_1.OPTION_REST_API_REGION);
15
+ commandSandboxSnapshotDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
16
+ commandSandboxSnapshotDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
17
+ commandSandboxSnapshotDelete.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
18
+ commandSandboxSnapshotDelete.argument('<snapshot-name>', texts_1.OPTION_SANDBOX_SNAPSHOT_NAME_ARG);
19
+ commandSandboxSnapshotDelete.action(async (identifier, snapshotName, options) => {
20
+ const token = input_1.default.restApiToken(options.token);
21
+ const baseUrl = input_1.default.restApiBaseUrl(options.api, options.region);
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project);
24
+ const client = new client_1.default(baseUrl, token);
25
+ // Find sandbox by identifier
26
+ const result = await client.listSandboxes(workspace, project);
27
+ const sandboxes = result.sandboxes || [];
28
+ const found = sandboxes.find((s) => s.identifier === identifier);
29
+ if (!found) {
30
+ output_1.default.exitError(texts_1.ERR_SANDBOX_NOT_FOUND);
31
+ }
32
+ // Find snapshot by name
33
+ const snapshotsResult = await client.listSandboxSnapshots(workspace, found.id);
34
+ const snapshots = snapshotsResult.snapshots || [];
35
+ const foundSnapshot = snapshots.find((s) => s.name === snapshotName);
36
+ if (!foundSnapshot) {
37
+ output_1.default.exitError(texts_1.ERR_SANDBOX_SNAPSHOT_NOT_FOUND);
38
+ }
39
+ await client.deleteSandboxSnapshot(workspace, found.id, foundSnapshot.id);
40
+ output_1.default.exitSuccess((0, texts_1.TXT_SANDBOX_SNAPSHOT_DELETED)(snapshotName));
41
+ });
42
+ exports.default = commandSandboxSnapshotDelete;