@infosupport/huddle-cli 0.0.0-experiment-98.51.1 → 0.0.0-experiment-109.53.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/README.md +37 -32
- package/dist/api.js +45 -14
- package/dist/config.js +141 -3
- package/dist/control-address.js +148 -0
- package/dist/control-probe.js +174 -0
- package/dist/experiment.js +18 -7
- package/dist/firewall.js +11 -7
- package/dist/images.js +13 -9
- package/dist/index.js +136 -43
- package/dist/init.js +359 -89
- package/dist/logs.js +213 -0
- package/dist/migrate.js +95 -65
- package/dist/node.js +390 -0
- package/dist/sbx-host-ca.js +237 -0
- package/dist/sbx-host.js +36 -0
- package/dist/sbx.js +211 -0
- package/package.json +5 -3
- package/dist/indexfolder.js +0 -143
package/dist/experiment.js
CHANGED
|
@@ -34,6 +34,12 @@ function parseIssueNumber(raw) {
|
|
|
34
34
|
* function does not return (process.exit with the exit code of the new process).
|
|
35
35
|
*/
|
|
36
36
|
function ensureCliForChannel(relaunchArgs, opts = {}) {
|
|
37
|
+
// Escape hatch for locally-built CLIs (e.g. dev-install.sh):
|
|
38
|
+
// when we deliberately run THIS build we must not hop to the published channel
|
|
39
|
+
// CLI — that would discard local, unpublished changes. The active experiment
|
|
40
|
+
// config is left untouched; only the auto-switch is suppressed for this run.
|
|
41
|
+
if (process.env.HUDDLE_SKIP_CLI_SWITCH === '1')
|
|
42
|
+
return;
|
|
37
43
|
const wanted = (0, config_1.activeExperiment)();
|
|
38
44
|
// Normally we only switch when the experiment NUMBER differs — otherwise every
|
|
39
45
|
// command would reinstall. But `huddle experiment use <n>` must pick up a newer
|
|
@@ -57,7 +63,7 @@ function ensureCliForChannel(relaunchArgs, opts = {}) {
|
|
|
57
63
|
*/
|
|
58
64
|
async function runExperimentUse(issue, initOpts = {}) {
|
|
59
65
|
const previous = (0, config_1.readConfig)();
|
|
60
|
-
(0, config_1.
|
|
66
|
+
(0, config_1.updateConfig)({ channel: 'experiment', experiment: issue });
|
|
61
67
|
console.log((0, utils_1.green)(`Experiment ${issue} activated`) + (0, utils_1.dim)(` (${(0, config_1.configPath)()})`));
|
|
62
68
|
const relaunchArgs = ['init', ...(initOpts.runtime ? ['--runtime', initOpts.runtime] : [])];
|
|
63
69
|
try {
|
|
@@ -67,22 +73,27 @@ async function runExperimentUse(issue, initOpts = {}) {
|
|
|
67
73
|
}
|
|
68
74
|
catch (err) {
|
|
69
75
|
// Activation failed → roll back the config so a subsequent `huddle init`
|
|
70
|
-
// doesn't stay stuck on an experiment that cannot be installed.
|
|
71
|
-
|
|
76
|
+
// doesn't stay stuck on an experiment that cannot be installed. Only the two
|
|
77
|
+
// keys this function set are restored; anything the gateway wrote to the
|
|
78
|
+
// shared file meanwhile (folder mappings, resource defaults) stays put.
|
|
79
|
+
try {
|
|
80
|
+
(0, config_1.updateConfig)({ channel: previous.channel, experiment: previous.experiment });
|
|
81
|
+
}
|
|
82
|
+
catch (rollbackErr) {
|
|
83
|
+
// The rollback is a courtesy; never let it mask why activation failed.
|
|
84
|
+
console.error((0, utils_1.dim)(`Could not roll back ${(0, config_1.configPath)()}: ${rollbackErr.message}`));
|
|
85
|
+
}
|
|
72
86
|
throw err;
|
|
73
87
|
}
|
|
74
88
|
await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
|
|
75
89
|
}
|
|
76
90
|
/** Puts Huddle back on the stable release. */
|
|
77
91
|
async function runExperimentReset() {
|
|
78
|
-
const config = (0, config_1.readConfig)();
|
|
79
92
|
if ((0, config_1.activeExperiment)() === undefined && cliExperiment() === undefined) {
|
|
80
93
|
console.log('No experiment active; Huddle is already running on stable.');
|
|
81
94
|
return;
|
|
82
95
|
}
|
|
83
|
-
|
|
84
|
-
config.channel = 'stable';
|
|
85
|
-
(0, config_1.writeConfig)(config);
|
|
96
|
+
(0, config_1.updateConfig)({ channel: 'stable', experiment: undefined });
|
|
86
97
|
console.log((0, utils_1.green)('Experiment config removed') + (0, utils_1.dim)(` (${(0, config_1.configPath)()})`));
|
|
87
98
|
// If an experimental CLI is still running, this installs the stable version
|
|
88
99
|
// and the new CLI restarts itself to show the status.
|
package/dist/firewall.js
CHANGED
|
@@ -258,17 +258,19 @@ async function runFirewallFolder(opts) {
|
|
|
258
258
|
const path = (opts.path ?? '').trim();
|
|
259
259
|
if (!path)
|
|
260
260
|
throw new Error('Usage: huddle firewall folder set <path>');
|
|
261
|
-
// Config-only:
|
|
262
|
-
//
|
|
263
|
-
(0, config_1.
|
|
261
|
+
// Config-only: Huddle Node reads this file per call, so the new folder is
|
|
262
|
+
// live immediately — no remount, no restart.
|
|
263
|
+
(0, config_1.updateConfig)({ firewallRulesFolder: path });
|
|
264
264
|
console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)}`));
|
|
265
|
-
console.log((0, utils_1.dim)('
|
|
265
|
+
console.log((0, utils_1.dim)(' Read on start and on `huddle firewall folder reload`.'));
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
268
|
if (action === 'reload') {
|
|
269
269
|
const res = await (0, api_1.post)('/api/firewall-rules-folder/reload', {});
|
|
270
270
|
if (!res.mounted) {
|
|
271
|
-
console.log((0, utils_1.dim)(
|
|
271
|
+
console.log((0, utils_1.dim)(res.folder
|
|
272
|
+
? `Cannot read ${res.folder} — set an existing folder with \`huddle firewall folder set <path>\`.`
|
|
273
|
+
: 'No firewall rules folder configured. Set one with `huddle firewall folder set <path>`.'));
|
|
272
274
|
return;
|
|
273
275
|
}
|
|
274
276
|
console.log((0, utils_1.green)(`[OK] Reloaded: ${res.groups} group(s), ${res.imported} rule(s), ${res.errors.length} error(s)`));
|
|
@@ -280,11 +282,13 @@ async function runFirewallFolder(opts) {
|
|
|
280
282
|
// Write the portal's groups back out to the folder (app → files).
|
|
281
283
|
const res = await (0, api_1.post)('/api/firewall-rules-folder/sync', {});
|
|
282
284
|
if (!res.mounted) {
|
|
283
|
-
console.log((0, utils_1.dim)(
|
|
285
|
+
console.log((0, utils_1.dim)(res.folder
|
|
286
|
+
? `Cannot read ${res.folder} — set an existing folder with \`huddle firewall folder set <path>\`.`
|
|
287
|
+
: 'No firewall rules folder configured. Set one with `huddle firewall folder set <path>`.'));
|
|
284
288
|
return;
|
|
285
289
|
}
|
|
286
290
|
if (res.written === 0 && res.errors.length > 0) {
|
|
287
|
-
console.error((0, utils_1.red)('[!] Could not write to the folder —
|
|
291
|
+
console.error((0, utils_1.red)('[!] Could not write to the folder — check that Huddle Node may write there.'));
|
|
288
292
|
for (const e of res.errors)
|
|
289
293
|
console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
|
|
290
294
|
return;
|
package/dist/images.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveImages = resolveImages;
|
|
4
|
-
exports.
|
|
4
|
+
exports.baseImageEnv = baseImageEnv;
|
|
5
5
|
const config_1 = require("./config");
|
|
6
6
|
function resolveImages() {
|
|
7
7
|
const experiment = (0, config_1.activeExperiment)();
|
|
@@ -19,17 +19,21 @@ function resolveImages() {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* with an explicit override)
|
|
24
|
-
* base images the CLI just pulled.
|
|
25
|
-
*
|
|
22
|
+
* Base-image overrides for HUDDLE NODE's environment. During an experiment (or
|
|
23
|
+
* with an explicit override) Huddle Node must start devcontainers from the same
|
|
24
|
+
* base images the CLI just pulled.
|
|
25
|
+
*
|
|
26
|
+
* These went to the gateway container as `-e` pairs until Docker orchestration
|
|
27
|
+
* moved to the host (docs/ADR-huddle-node-split.md). The gateway does not create
|
|
28
|
+
* containers any more, so it has no use for them — and giving the network-facing
|
|
29
|
+
* half env vars it does not read is how stale coupling survives a split.
|
|
26
30
|
*/
|
|
27
|
-
function
|
|
28
|
-
const
|
|
31
|
+
function baseImageEnv(resolved) {
|
|
32
|
+
const env = {};
|
|
29
33
|
for (const b of resolved.baseImages) {
|
|
30
34
|
if (b.gatewayEnv && (resolved.experiment !== undefined || process.env[b.gatewayEnv])) {
|
|
31
|
-
|
|
35
|
+
env[b.gatewayEnv] = b.image;
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
|
-
return
|
|
38
|
+
return env;
|
|
35
39
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,25 +4,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.parseArgs = parseArgs;
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const api_1 = require("./api");
|
|
10
11
|
const start_1 = require("./start");
|
|
11
12
|
const firewall_1 = require("./firewall");
|
|
12
13
|
const init_1 = require("./init");
|
|
14
|
+
const node_1 = require("./node");
|
|
13
15
|
const migrate_1 = require("./migrate");
|
|
14
|
-
const
|
|
16
|
+
const logs_1 = require("./logs");
|
|
17
|
+
const sbx_1 = require("./sbx");
|
|
15
18
|
const images_1 = require("./images");
|
|
16
19
|
const self_update_1 = require("./self-update");
|
|
17
20
|
const utils_1 = require("./utils");
|
|
18
21
|
const experiment_1 = require("./experiment");
|
|
19
|
-
const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', '
|
|
20
|
-
const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', '
|
|
21
|
-
const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', '
|
|
22
|
+
const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', 'agent', 'entry', 'port', 'data-dir', 'lines', 'n']);
|
|
23
|
+
const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'dry-run', 'follow', 'f', 'node', 'gateway']);
|
|
24
|
+
const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'sbx', 'node', 'logs', 'log', 'help', 'version']);
|
|
22
25
|
function parseArgs(argv) {
|
|
23
26
|
const positional = [];
|
|
24
27
|
const flags = {};
|
|
25
28
|
const mounts = [];
|
|
29
|
+
const folders = [];
|
|
26
30
|
for (let i = 0; i < argv.length; i++) {
|
|
27
31
|
const arg = argv[i];
|
|
28
32
|
if (arg === '--') {
|
|
@@ -35,8 +39,10 @@ function parseArgs(argv) {
|
|
|
35
39
|
const name = eq >= 0 ? raw.slice(0, eq) : raw;
|
|
36
40
|
if (!name)
|
|
37
41
|
throw new Error(`Invalid option: ${arg}`);
|
|
38
|
-
// Repeatable, unlike every other value flag (one `--mount host=container`
|
|
39
|
-
|
|
42
|
+
// Repeatable, unlike every other value flag (one `--mount host=container` or
|
|
43
|
+
// one `--folder <host path>` per folder).
|
|
44
|
+
if (name === 'mount' || name === 'folder') {
|
|
45
|
+
const expects = name === 'mount' ? 'host=container' : 'a host path';
|
|
40
46
|
let value;
|
|
41
47
|
if (eq >= 0) {
|
|
42
48
|
value = raw.slice(eq + 1);
|
|
@@ -44,12 +50,12 @@ function parseArgs(argv) {
|
|
|
44
50
|
else {
|
|
45
51
|
const next = argv[i + 1];
|
|
46
52
|
if (next === undefined || next.startsWith('-')) {
|
|
47
|
-
throw new Error(
|
|
53
|
+
throw new Error(`Option --${name} expects a value (${expects})`);
|
|
48
54
|
}
|
|
49
55
|
value = next;
|
|
50
56
|
i++;
|
|
51
57
|
}
|
|
52
|
-
mounts.push(value);
|
|
58
|
+
(name === 'mount' ? mounts : folders).push(value);
|
|
53
59
|
continue;
|
|
54
60
|
}
|
|
55
61
|
if (eq >= 0) {
|
|
@@ -89,7 +95,7 @@ function parseArgs(argv) {
|
|
|
89
95
|
}
|
|
90
96
|
positional.push(arg);
|
|
91
97
|
}
|
|
92
|
-
return { positional, flags, mounts };
|
|
98
|
+
return { positional, flags, mounts, folders };
|
|
93
99
|
}
|
|
94
100
|
function parseMountFlag(raw) {
|
|
95
101
|
const eq = raw.indexOf('=');
|
|
@@ -119,14 +125,10 @@ Usage:
|
|
|
119
125
|
huddle start [options] [folder] Explicitly start a devcontainer
|
|
120
126
|
huddle init [options] Pull the Huddle + devcontainer base images and
|
|
121
127
|
start them via Docker or Podman
|
|
122
|
-
huddle restart Recreate the gateway (e.g.
|
|
123
|
-
team
|
|
128
|
+
huddle restart Recreate the gateway (e.g. after changing the
|
|
129
|
+
team extensions folder, which loads at boot)
|
|
124
130
|
huddle migrate [folder] Wire an existing docker-compose devcontainer
|
|
125
131
|
behind Huddle by generating an override file
|
|
126
|
-
huddle indexfolder [folder] Index the folders under this one so the portal
|
|
127
|
-
can offer them where a host path is needed
|
|
128
|
-
(the portal runs in a container and cannot
|
|
129
|
-
browse your host)
|
|
130
132
|
huddle firewall list [options] Show firewall requests
|
|
131
133
|
huddle fw list [options] Alias for firewall list
|
|
132
134
|
huddle firewall add <domain> Add a custom firewall rule (wildcards
|
|
@@ -139,14 +141,51 @@ Usage:
|
|
|
139
141
|
huddle firewall group export <name> Export a group as JSON (--out <file>)
|
|
140
142
|
huddle firewall group import <file> Import a group (--replace to mirror)
|
|
141
143
|
huddle firewall group apply <name> Apply a group (--container <id> or global)
|
|
144
|
+
huddle sbx status Show Docker Sandboxes (sbx) mode status:
|
|
145
|
+
host-agent pipe, upstream proxy, sbx version
|
|
146
|
+
huddle sbx list List sandboxes the host sbx daemon knows
|
|
147
|
+
huddle sbx start [name] [options] Start a microVM sandbox with Huddle as its
|
|
148
|
+
upstream proxy (--agent <name> --workspace <path>)
|
|
149
|
+
--folder <host path>[:ro] adds another folder
|
|
150
|
+
(repeatable); Huddle's folder mappings are
|
|
151
|
+
mounted automatically
|
|
152
|
+
huddle sbx rm <name> [--force] Remove a sandbox
|
|
153
|
+
huddle sbx reconcile [--dry-run] Set every Huddle sandbox to allow-all in sbx
|
|
154
|
+
(Huddle's proxy enforces the rules)
|
|
155
|
+
huddle sbx trust-ca <name> Install Huddle's CA in a sandbox so HTTPS
|
|
156
|
+
works (needed for VS Code / JetBrains backends)
|
|
157
|
+
huddle sbx trust-host Trust Huddle's CA on the HOST, where the sbx
|
|
158
|
+
daemon runs — sbx terminates TLS itself for
|
|
159
|
+
some hosts (platform.claude.com) and then
|
|
160
|
+
validates Huddle against the host store; without
|
|
161
|
+
this those calls fail with "Empty reply from
|
|
162
|
+
server". Run by 'huddle init'; idempotent.
|
|
163
|
+
huddle sbx ssh-setup Enable the SSH bridge (<name>.sbx) for
|
|
164
|
+
VS Code / JetBrains remote development
|
|
142
165
|
huddle firewall folder set <path> Set the team-managed rules folder
|
|
143
166
|
huddle firewall folder reload Re-read the team-managed rules folder
|
|
144
167
|
huddle firewall folder sync Write the portal's groups back to the folder
|
|
168
|
+
huddle logs [options] Show both halves' output: Huddle Node's log
|
|
169
|
+
file on this host and the gateway container
|
|
170
|
+
(-n <lines>, -f to follow, --node/--gateway
|
|
171
|
+
for one half)
|
|
172
|
+
huddle node [options] Run Huddle Node (portal + API + orchestration)
|
|
173
|
+
directly on this host instead of in the
|
|
174
|
+
gateway container. The firewall stays in
|
|
175
|
+
huddle-gateway. Foreground; Ctrl-C to stop.
|
|
145
176
|
huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
|
|
146
177
|
and run init
|
|
147
178
|
huddle experiment reset Back to the stable release
|
|
148
179
|
huddle experiment status Show the active channel and CLI version
|
|
149
180
|
|
|
181
|
+
Node options:
|
|
182
|
+
--entry <path> Path to the built Huddle Node entrypoint
|
|
183
|
+
(default: the gateway build in this checkout;
|
|
184
|
+
also via HUDDLE_NODE_ENTRY)
|
|
185
|
+
--port <port> Portal + API port (default: 24842)
|
|
186
|
+
--data-dir <path> Database, CA and config location
|
|
187
|
+
(default: ~/.huddle)
|
|
188
|
+
|
|
150
189
|
Init options:
|
|
151
190
|
--runtime <docker|podman> Container runtime (default: auto-detected;
|
|
152
191
|
also via the HUDDLE_RUNTIME env var)
|
|
@@ -174,16 +213,6 @@ Migrate options:
|
|
|
174
213
|
(default: docker-compose.huddle.yml next to the source)
|
|
175
214
|
--force Overwrite an existing override file
|
|
176
215
|
|
|
177
|
-
Indexfolder options:
|
|
178
|
-
--depth <n> How deep to walk (default: 2, max 8)
|
|
179
|
-
--all Also index build folders (node_modules, dist,
|
|
180
|
-
target, ...); hidden folders stay skipped
|
|
181
|
-
--replace Drop the earlier entries under this folder
|
|
182
|
-
first, instead of merging
|
|
183
|
-
--list Show the current index and exit
|
|
184
|
-
--clear Empty the index (or, with a folder, only the
|
|
185
|
-
entries under it)
|
|
186
|
-
|
|
187
216
|
Firewall options:
|
|
188
217
|
-i, --interactive Interactively approve/deny (list)
|
|
189
218
|
--container <name> Filter by (list) / scope to (add) a container
|
|
@@ -203,7 +232,7 @@ Firewall export/import options:
|
|
|
203
232
|
scope first (default: merge/upsert)
|
|
204
233
|
|
|
205
234
|
Global options:
|
|
206
|
-
--url <url> Huddle URL (default: http://localhost:
|
|
235
|
+
--url <url> Huddle URL (default: http://localhost:24842)
|
|
207
236
|
Or via the HUDDLE_URL env var
|
|
208
237
|
--help, -h Show help
|
|
209
238
|
--version, -v Show version (as published to
|
|
@@ -230,8 +259,16 @@ async function main() {
|
|
|
230
259
|
printHelp();
|
|
231
260
|
return;
|
|
232
261
|
}
|
|
233
|
-
|
|
234
|
-
|
|
262
|
+
// Only when the operator named an address. The fallback used to be nodeUrl(),
|
|
263
|
+
// which is the URL for a HUMAN — `http://localhost:…` — and that is the one
|
|
264
|
+
// spelling the CLI must not use: Node binds a single literal, `localhost` is
|
|
265
|
+
// two, and on Windows it resolves to ::1 first. A browser papers over that,
|
|
266
|
+
// fetch() does not, so every command failed with "Huddle does not appear to be
|
|
267
|
+
// running" against a healthy process the portal was talking to happily.
|
|
268
|
+
// Leaving this unset lets api.ts try the loopback literals instead.
|
|
269
|
+
const url = flagString(flags, 'url') ?? process.env.HUDDLE_URL;
|
|
270
|
+
if (url)
|
|
271
|
+
(0, api_1.setBaseUrl)(url);
|
|
235
272
|
const startsWithExistingPath = cmd !== undefined && !COMMANDS.has(cmd) && fs_1.default.existsSync(path_1.default.resolve(cmd));
|
|
236
273
|
if (!cmd || cmd === 'start' || startsWithExistingPath) {
|
|
237
274
|
const startArgs = cmd === 'start' ? positional.slice(1) : startsWithExistingPath ? positional : [];
|
|
@@ -249,6 +286,17 @@ async function main() {
|
|
|
249
286
|
});
|
|
250
287
|
return;
|
|
251
288
|
}
|
|
289
|
+
if (cmd === 'node') {
|
|
290
|
+
// Runs Huddle Node in the FOREGROUND on this host — the shape you want
|
|
291
|
+
// while working on Huddle itself. `huddle init` starts the same process
|
|
292
|
+
// detached, alongside the gateway container.
|
|
293
|
+
await (0, node_1.runNode)({
|
|
294
|
+
entry: flagString(flags, 'entry'),
|
|
295
|
+
port: flagString(flags, 'port'),
|
|
296
|
+
dataDir: flagString(flags, 'data-dir'),
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
252
300
|
if (cmd === 'init') {
|
|
253
301
|
// Shows the exact CLI build, so with experiments it's immediately visible
|
|
254
302
|
// which version is running.
|
|
@@ -352,17 +400,59 @@ async function main() {
|
|
|
352
400
|
}
|
|
353
401
|
return;
|
|
354
402
|
}
|
|
355
|
-
if (cmd === '
|
|
356
|
-
await (0,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
clear: flagBool(flags, 'clear'),
|
|
362
|
-
list: flagBool(flags, 'list'),
|
|
403
|
+
if (cmd === 'logs' || cmd === 'log') {
|
|
404
|
+
await (0, logs_1.runLogs)({
|
|
405
|
+
lines: flagString(flags, 'lines', 'n'),
|
|
406
|
+
follow: flagBool(flags, 'follow', 'f'),
|
|
407
|
+
node: flagBool(flags, 'node'),
|
|
408
|
+
gateway: flagBool(flags, 'gateway'),
|
|
363
409
|
});
|
|
364
410
|
return;
|
|
365
411
|
}
|
|
412
|
+
if (cmd === 'sbx') {
|
|
413
|
+
const subCmd = sub ?? 'status';
|
|
414
|
+
if (subCmd === 'status') {
|
|
415
|
+
await (0, sbx_1.runSbxStatus)();
|
|
416
|
+
}
|
|
417
|
+
else if (subCmd === 'list' || subCmd === 'ls') {
|
|
418
|
+
await (0, sbx_1.runSbxList)();
|
|
419
|
+
}
|
|
420
|
+
else if (subCmd === 'start' || subCmd === 'create') {
|
|
421
|
+
await (0, sbx_1.runSbxStart)({
|
|
422
|
+
name: positional[2] ?? flagString(flags, 'name'),
|
|
423
|
+
agent: flagString(flags, 'agent'),
|
|
424
|
+
workspace: flagString(flags, 'workspace'),
|
|
425
|
+
folders: parsed.folders,
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
else if (subCmd === 'rm' || subCmd === 'remove' || subCmd === 'delete') {
|
|
429
|
+
await (0, sbx_1.runSbxRemove)({ name: positional[2] ?? flagString(flags, 'name'), force: flagBool(flags, 'force') });
|
|
430
|
+
}
|
|
431
|
+
else if (subCmd === 'reconcile' || subCmd === 'sync') {
|
|
432
|
+
await (0, sbx_1.runSbxReconcile)({ dryRun: flagBool(flags, 'dry-run') });
|
|
433
|
+
}
|
|
434
|
+
else if (subCmd === 'trust-ca' || subCmd === 'ca') {
|
|
435
|
+
await (0, sbx_1.runSbxTrustCa)({ name: positional[2] ?? flagString(flags, 'name') });
|
|
436
|
+
}
|
|
437
|
+
else if (subCmd === 'trust-host' || subCmd === 'host-ca') {
|
|
438
|
+
await (0, sbx_1.runSbxTrustHost)({ runtime: flagString(flags, 'runtime') });
|
|
439
|
+
}
|
|
440
|
+
else if (subCmd === 'log') {
|
|
441
|
+
await (0, sbx_1.runSbxLog)({ name: positional[2] ?? flagString(flags, 'name') });
|
|
442
|
+
}
|
|
443
|
+
else if (subCmd === 'ingest') {
|
|
444
|
+
await (0, sbx_1.runSbxIngest)();
|
|
445
|
+
}
|
|
446
|
+
else if (subCmd === 'ssh-setup' || subCmd === 'ssh') {
|
|
447
|
+
await (0, sbx_1.runSbxSshSetup)();
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
console.error(`Unknown sbx subcommand: ${subCmd}`);
|
|
451
|
+
console.error('Usage: huddle sbx <status|list|start|rm|reconcile|trust-ca|trust-host|ssh-setup|log|ingest>');
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
366
456
|
if (cmd === 'migrate') {
|
|
367
457
|
await (0, migrate_1.runMigrate)({
|
|
368
458
|
path: positional[1],
|
|
@@ -389,10 +479,13 @@ function flagString(flags, ...names) {
|
|
|
389
479
|
function flagBool(flags, ...names) {
|
|
390
480
|
return names.some((name) => flags[name] === true);
|
|
391
481
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
482
|
+
// Guarded so the arg parser above can be imported by tests without the CLI
|
|
483
|
+
// running itself as a side effect of the import.
|
|
484
|
+
if (require.main === module)
|
|
485
|
+
main().catch((err) => {
|
|
486
|
+
console.error(`Error: ${err.message ?? err}`);
|
|
487
|
+
if (err instanceof api_1.ApiError && err.message.includes('Cannot reach Huddle API')) {
|
|
488
|
+
console.error('\nHuddle does not appear to be running. Start it with:\n huddle init');
|
|
489
|
+
}
|
|
490
|
+
process.exit(1);
|
|
491
|
+
});
|