@infosupport/huddle-cli 0.0.0-experiment-109.61.1 → 0.0.0-experiment-98.63.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 +32 -37
- package/dist/api.js +14 -52
- package/dist/experiment.js +0 -6
- package/dist/firewall.js +26 -10
- package/dist/images.js +9 -13
- package/dist/index.js +45 -136
- package/dist/indexfolder.js +167 -0
- package/dist/init.js +89 -354
- package/dist/migrate.js +17 -53
- package/package.json +3 -11
- package/dist/control-address.js +0 -160
- package/dist/control-probe.js +0 -174
- package/dist/logs.js +0 -213
- package/dist/node.js +0 -667
- package/dist/sbx-host-ca.js +0 -237
- package/dist/sbx-host.js +0 -36
- package/dist/sbx.js +0 -206
package/README.md
CHANGED
|
@@ -42,49 +42,45 @@ huddle --ide vscode \
|
|
|
42
42
|
--workspace-root /workspaces --name corpa-dev
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Default API URL: `http://localhost:
|
|
46
|
-
`--url` or `HUDDLE_URL`.
|
|
45
|
+
Default API URL: `http://localhost:3000`. Override it with `--url` or `HUDDLE_URL`.
|
|
47
46
|
|
|
48
|
-
##
|
|
47
|
+
## Making host folders selectable in the portal
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
nothing to index and no CLI command to run first. Hidden (dot) folders are listed too,
|
|
59
|
-
and every input keeps accepting a path you type or paste.
|
|
60
|
-
|
|
61
|
-
Windows paths may be typed either way (`T:\projects\app` or `T:/projects/app`) —
|
|
62
|
-
Huddle stores one canonical form, so the two spellings are the same folder.
|
|
63
|
-
|
|
64
|
-
## Starting sandboxes (Docker Sandboxes / sbx)
|
|
49
|
+
Huddle's portal runs inside a container, so it cannot open a folder dialog on your
|
|
50
|
+
host: every host path had to be typed from memory. `huddle indexfolder` scans your
|
|
51
|
+
host once and stores what it finds, and every host-path field in the portal grows a
|
|
52
|
+
**Browse** button that opens those folders as a tree — starting a devcontainer, the
|
|
53
|
+
folder mappings, and the team-managed folders. Starting a devcontainer, Ctrl-click picks
|
|
54
|
+
several folders at once and each becomes its own worktree. Typing a path by hand keeps working:
|
|
55
|
+
the index is a snapshot, so a folder created after the last scan must not be
|
|
56
|
+
unreachable.
|
|
65
57
|
|
|
66
58
|
```bash
|
|
67
|
-
|
|
68
|
-
huddle
|
|
69
|
-
huddle
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
cd T:/projects
|
|
60
|
+
huddle indexfolder # this folder + 2 levels below it
|
|
61
|
+
huddle indexfolder T:/projects --depth 3
|
|
62
|
+
huddle indexfolder --all # also index node_modules, dist, target, ...
|
|
63
|
+
huddle indexfolder --replace # re-scan: drop the earlier entries under this folder first
|
|
64
|
+
huddle indexfolder --list # show what is indexed
|
|
65
|
+
huddle indexfolder --clear # empty the index (with a folder: only that subtree)
|
|
73
66
|
```
|
|
74
67
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
Hidden (dot) folders and the usual build folders (`node_modules`, `dist`, `target`,
|
|
69
|
+
`obj`, …) are skipped, which is what keeps a scan of a projects folder in the
|
|
70
|
+
hundreds instead of the tens of thousands; `--all` turns that off. The scan stops
|
|
71
|
+
at 1500 folders and the index holds at most 2000 — index a more specific folder if
|
|
72
|
+
you hit that.
|
|
73
|
+
|
|
74
|
+
The index is a **snapshot**, not a live view: the gateway cannot read your host, so
|
|
75
|
+
re-run the command after adding projects. Every input keeps accepting a typed path,
|
|
76
|
+
so a folder you created a minute ago works without re-indexing first. Windows paths
|
|
77
|
+
may be typed either way (`T:\projects\app` or `T:/projects/app`) — they are stored
|
|
78
|
+
in one canonical form, and the two spellings are the same entry.
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
so the agent credentials sbx manages itself stay untouched. Mappings that cannot
|
|
86
|
-
travel (a Docker volume, or a `~`/relative host path) are reported per sandbox
|
|
87
|
-
instead of silently dropped.
|
|
80
|
+
Individual folders can also be added or removed under **Settings > Indexed
|
|
81
|
+
folders** in the portal. The index lives in Huddle's database, not in
|
|
82
|
+
`~/.huddle/config.json`: it describes this machine, so unlike the team-managed
|
|
83
|
+
settings it is not something to share in version control.
|
|
88
84
|
|
|
89
85
|
## Experiments
|
|
90
86
|
|
|
@@ -116,7 +112,6 @@ Main flags:
|
|
|
116
112
|
--workspace <path>
|
|
117
113
|
--mount <host>=<container> (repeatable, container path must be absolute)
|
|
118
114
|
--workspace-root <path> (container path the IDE opens; requires --mount)
|
|
119
|
-
--folder <host path>[:ro] (repeatable; extra sandbox folder for `huddle sbx start`)
|
|
120
115
|
--name <name>
|
|
121
116
|
--image <image>
|
|
122
117
|
--empty
|
package/dist/api.js
CHANGED
|
@@ -4,29 +4,7 @@ exports.del = exports.put = exports.post = exports.get = exports.ApiError = void
|
|
|
4
4
|
exports.setBaseUrl = setBaseUrl;
|
|
5
5
|
exports.apiCall = apiCall;
|
|
6
6
|
const config_1 = require("./config");
|
|
7
|
-
|
|
8
|
-
// Huddle Node, on the host, on loopback. Not 3000 and not a container address:
|
|
9
|
-
// after the Node/Gateway split the API this talks to is the host process, and
|
|
10
|
-
// the gateway container has no API at all (docs/ADR-huddle-node-split.md).
|
|
11
|
-
//
|
|
12
|
-
// The loopback LITERALS, not `localhost` — nodeProbeUrls() is where that reason
|
|
13
|
-
// is written down. Both are kept, not just the first: Node binds one address and
|
|
14
|
-
// which one depends on the host, so the only honest default is to try each and
|
|
15
|
-
// keep whichever answers.
|
|
16
|
-
//
|
|
17
|
-
// An explicit --url or HUDDLE_URL replaces the list entirely — the operator named
|
|
18
|
-
// an address, and silently talking to a different one would be worse than failing.
|
|
19
|
-
//
|
|
20
|
-
// HUDDLE_PORT, when set, still has to flow through here: it is the same env var
|
|
21
|
-
// `huddle init`/`huddle node` read for a custom port (init.ts's HOST_PORT), so a
|
|
22
|
-
// custom port that stuck for the command that started Huddle Node must also
|
|
23
|
-
// stick for every command that talks to it afterwards — otherwise every command
|
|
24
|
-
// after `HUDDLE_PORT=<n> huddle init` probes the default port and never finds it.
|
|
25
|
-
const port = process.env.HUDDLE_PORT?.trim() || node_1.DEFAULT_NODE_PORT;
|
|
26
|
-
let candidates = (process.env.HUDDLE_URL
|
|
27
|
-
? [process.env.HUDDLE_URL]
|
|
28
|
-
: (0, node_1.nodeProbeUrls)(port)).map(normalizeBaseUrl);
|
|
29
|
-
let baseUrl = candidates[0];
|
|
7
|
+
let baseUrl = normalizeBaseUrl(process.env.HUDDLE_URL ?? 'http://localhost:3000');
|
|
30
8
|
class ApiError extends Error {
|
|
31
9
|
status;
|
|
32
10
|
constructor(message, status) {
|
|
@@ -37,30 +15,7 @@ class ApiError extends Error {
|
|
|
37
15
|
}
|
|
38
16
|
exports.ApiError = ApiError;
|
|
39
17
|
function setBaseUrl(url) {
|
|
40
|
-
|
|
41
|
-
baseUrl = candidates[0];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The first candidate that answers, remembered for the rest of the process.
|
|
45
|
-
*
|
|
46
|
-
* A refused connection is not a failure here — it is how we find out which
|
|
47
|
-
* loopback address Node bound. Anything the server actually answers, including a
|
|
48
|
-
* 500, ends the search: it proves we found Huddle.
|
|
49
|
-
*/
|
|
50
|
-
async function reachHuddle(path, init) {
|
|
51
|
-
const order = [baseUrl, ...candidates.filter((c) => c !== baseUrl)];
|
|
52
|
-
let detail = '';
|
|
53
|
-
for (const candidate of order) {
|
|
54
|
-
try {
|
|
55
|
-
const res = await fetch(`${candidate}${path}`, init);
|
|
56
|
-
baseUrl = candidate;
|
|
57
|
-
return res;
|
|
58
|
-
}
|
|
59
|
-
catch (err) {
|
|
60
|
-
detail = err instanceof Error ? err.message : String(err);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
throw new ApiError(`Cannot reach Huddle API at ${order.join(' or ')}: ${detail}`);
|
|
18
|
+
baseUrl = normalizeBaseUrl(url);
|
|
64
19
|
}
|
|
65
20
|
async function apiCall(method, path, body) {
|
|
66
21
|
const headers = {};
|
|
@@ -71,11 +26,18 @@ async function apiCall(method, path, body) {
|
|
|
71
26
|
const token = (0, config_1.operatorToken)();
|
|
72
27
|
if (token)
|
|
73
28
|
headers['authorization'] = `Bearer ${token}`;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
29
|
+
let res;
|
|
30
|
+
try {
|
|
31
|
+
res = await fetch(`${baseUrl}${path}`, {
|
|
32
|
+
method,
|
|
33
|
+
headers,
|
|
34
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
39
|
+
throw new ApiError(`Cannot reach Huddle API at ${baseUrl}: ${detail}`);
|
|
40
|
+
}
|
|
79
41
|
const raw = await res.text();
|
|
80
42
|
const payload = parsePayload(raw);
|
|
81
43
|
if (!res.ok) {
|
package/dist/experiment.js
CHANGED
|
@@ -34,12 +34,6 @@ 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;
|
|
43
37
|
const wanted = (0, config_1.activeExperiment)();
|
|
44
38
|
// Normally we only switch when the experiment NUMBER differs — otherwise every
|
|
45
39
|
// command would reinstall. But `huddle experiment use <n>` must pick up a newer
|
package/dist/firewall.js
CHANGED
|
@@ -177,9 +177,29 @@ function readJsonFile(file) {
|
|
|
177
177
|
throw new Error(`${file} is not valid JSON`);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
// The name of the group a document describes, or null when it is a plain rules
|
|
181
|
+
// export. A group envelope carries it under `group`, or at the top level in the
|
|
182
|
+
// documented bare form.
|
|
183
|
+
function groupNameOf(doc) {
|
|
184
|
+
const meta = (doc['group'] && typeof doc['group'] === 'object' && !Array.isArray(doc['group']) ? doc['group'] : doc);
|
|
185
|
+
const name = typeof meta['name'] === 'string' ? meta['name'].trim() : '';
|
|
186
|
+
return name || null;
|
|
187
|
+
}
|
|
180
188
|
async function runFirewallImport(opts) {
|
|
181
189
|
const doc = readJsonFile(opts.file);
|
|
182
190
|
const mode = opts.replace ? 'replace' : 'merge';
|
|
191
|
+
// A group envelope handed to the flat importer used to import its rules and
|
|
192
|
+
// silently drop the group (#98). Send it where it belongs instead — unless
|
|
193
|
+
// --container asks for a scope remap, which only the flat importer does.
|
|
194
|
+
const groupName = groupNameOf(doc);
|
|
195
|
+
if (groupName && !opts.container) {
|
|
196
|
+
console.error((0, utils_1.dim)(`[i] ${opts.file} is the group "${groupName}" — importing it as a group.`));
|
|
197
|
+
await runFirewallGroup({ action: 'import', arg: opts.file, replace: opts.replace });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (groupName) {
|
|
201
|
+
console.error((0, utils_1.dim)(`[i] ${opts.file} is the group "${groupName}"; --container imports its rules into that scope without the group.`));
|
|
202
|
+
}
|
|
183
203
|
const qs = new URLSearchParams();
|
|
184
204
|
if (opts.container)
|
|
185
205
|
qs.set('container', opts.container);
|
|
@@ -258,19 +278,17 @@ async function runFirewallFolder(opts) {
|
|
|
258
278
|
const path = (opts.path ?? '').trim();
|
|
259
279
|
if (!path)
|
|
260
280
|
throw new Error('Usage: huddle firewall folder set <path>');
|
|
261
|
-
// Config-only:
|
|
262
|
-
//
|
|
281
|
+
// Config-only: the gateway reads the folder at the fixed mount point the CLI
|
|
282
|
+
// binds it to; there is no DB setting. Persist here and mount on restart.
|
|
263
283
|
(0, config_1.updateConfig)({ firewallRulesFolder: path });
|
|
264
284
|
console.log((0, utils_1.green)(`[OK] Firewall rules folder set to ${(0, utils_1.cyan)(path)}`));
|
|
265
|
-
console.log((0, utils_1.dim)('
|
|
285
|
+
console.log((0, utils_1.dim)(' Run `huddle restart` to mount it into the gateway; it is then read on start & reload.'));
|
|
266
286
|
return;
|
|
267
287
|
}
|
|
268
288
|
if (action === 'reload') {
|
|
269
289
|
const res = await (0, api_1.post)('/api/firewall-rules-folder/reload', {});
|
|
270
290
|
if (!res.mounted) {
|
|
271
|
-
console.log((0, utils_1.dim)(
|
|
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>`.'));
|
|
291
|
+
console.log((0, utils_1.dim)('No firewall rules folder mounted. Set one with `huddle firewall folder set <path>` and run `huddle restart`.'));
|
|
274
292
|
return;
|
|
275
293
|
}
|
|
276
294
|
console.log((0, utils_1.green)(`[OK] Reloaded: ${res.groups} group(s), ${res.imported} rule(s), ${res.errors.length} error(s)`));
|
|
@@ -282,13 +300,11 @@ async function runFirewallFolder(opts) {
|
|
|
282
300
|
// Write the portal's groups back out to the folder (app → files).
|
|
283
301
|
const res = await (0, api_1.post)('/api/firewall-rules-folder/sync', {});
|
|
284
302
|
if (!res.mounted) {
|
|
285
|
-
console.log((0, utils_1.dim)(
|
|
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>`.'));
|
|
303
|
+
console.log((0, utils_1.dim)('No firewall rules folder mounted. Set one with `huddle firewall folder set <path>` and run `huddle restart`.'));
|
|
288
304
|
return;
|
|
289
305
|
}
|
|
290
306
|
if (res.written === 0 && res.errors.length > 0) {
|
|
291
|
-
console.error((0, utils_1.red)('[!] Could not write to the folder —
|
|
307
|
+
console.error((0, utils_1.red)('[!] Could not write to the folder — it may still be mounted read-only. Run `huddle restart` to remount it writable.'));
|
|
292
308
|
for (const e of res.errors)
|
|
293
309
|
console.error((0, utils_1.red)(` [!] ${e.file}: ${e.message}`));
|
|
294
310
|
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.gatewayEnvArgs = gatewayEnvArgs;
|
|
5
5
|
const config_1 = require("./config");
|
|
6
6
|
function resolveImages() {
|
|
7
7
|
const experiment = (0, config_1.activeExperiment)();
|
|
@@ -19,21 +19,17 @@ function resolveImages() {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* with an explicit override)
|
|
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.
|
|
22
|
+
* `-e KEY=val` argv pairs for the gateway container. During an experiment (or
|
|
23
|
+
* with an explicit override) the gateway must start devcontainers from the same
|
|
24
|
+
* base images the CLI just pulled. Returned as an argv array (not a shell
|
|
25
|
+
* string) so init can spawn `docker run` without a shell.
|
|
30
26
|
*/
|
|
31
|
-
function
|
|
32
|
-
const
|
|
27
|
+
function gatewayEnvArgs(resolved) {
|
|
28
|
+
const args = [];
|
|
33
29
|
for (const b of resolved.baseImages) {
|
|
34
30
|
if (b.gatewayEnv && (resolved.experiment !== undefined || process.env[b.gatewayEnv])) {
|
|
35
|
-
|
|
31
|
+
args.push('-e', `${b.gatewayEnv}=${b.image}`);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
|
-
return
|
|
34
|
+
return args;
|
|
39
35
|
}
|
package/dist/index.js
CHANGED
|
@@ -4,29 +4,25 @@ 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;
|
|
8
7
|
const fs_1 = __importDefault(require("fs"));
|
|
9
8
|
const path_1 = __importDefault(require("path"));
|
|
10
9
|
const api_1 = require("./api");
|
|
11
10
|
const start_1 = require("./start");
|
|
12
11
|
const firewall_1 = require("./firewall");
|
|
13
12
|
const init_1 = require("./init");
|
|
14
|
-
const node_1 = require("./node");
|
|
15
13
|
const migrate_1 = require("./migrate");
|
|
16
|
-
const
|
|
17
|
-
const sbx_1 = require("./sbx");
|
|
14
|
+
const indexfolder_1 = require("./indexfolder");
|
|
18
15
|
const images_1 = require("./images");
|
|
19
16
|
const self_update_1 = require("./self-update");
|
|
20
17
|
const utils_1 = require("./utils");
|
|
21
18
|
const experiment_1 = require("./experiment");
|
|
22
|
-
const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', '
|
|
23
|
-
const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', '
|
|
24
|
-
const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', '
|
|
19
|
+
const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output', 'out', 'workspace-root', 'depth']);
|
|
20
|
+
const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force', 'replace', 'all', 'list', 'clear']);
|
|
21
|
+
const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'restart', 'experiment', 'migrate', 'indexfolder', 'indexfolders', 'help', 'version']);
|
|
25
22
|
function parseArgs(argv) {
|
|
26
23
|
const positional = [];
|
|
27
24
|
const flags = {};
|
|
28
25
|
const mounts = [];
|
|
29
|
-
const folders = [];
|
|
30
26
|
for (let i = 0; i < argv.length; i++) {
|
|
31
27
|
const arg = argv[i];
|
|
32
28
|
if (arg === '--') {
|
|
@@ -39,10 +35,8 @@ function parseArgs(argv) {
|
|
|
39
35
|
const name = eq >= 0 ? raw.slice(0, eq) : raw;
|
|
40
36
|
if (!name)
|
|
41
37
|
throw new Error(`Invalid option: ${arg}`);
|
|
42
|
-
// Repeatable, unlike every other value flag (one `--mount host=container`
|
|
43
|
-
|
|
44
|
-
if (name === 'mount' || name === 'folder') {
|
|
45
|
-
const expects = name === 'mount' ? 'host=container' : 'a host path';
|
|
38
|
+
// Repeatable, unlike every other value flag (one `--mount host=container` per folder).
|
|
39
|
+
if (name === 'mount') {
|
|
46
40
|
let value;
|
|
47
41
|
if (eq >= 0) {
|
|
48
42
|
value = raw.slice(eq + 1);
|
|
@@ -50,12 +44,12 @@ function parseArgs(argv) {
|
|
|
50
44
|
else {
|
|
51
45
|
const next = argv[i + 1];
|
|
52
46
|
if (next === undefined || next.startsWith('-')) {
|
|
53
|
-
throw new Error(
|
|
47
|
+
throw new Error('Option --mount expects a value (host=container)');
|
|
54
48
|
}
|
|
55
49
|
value = next;
|
|
56
50
|
i++;
|
|
57
51
|
}
|
|
58
|
-
|
|
52
|
+
mounts.push(value);
|
|
59
53
|
continue;
|
|
60
54
|
}
|
|
61
55
|
if (eq >= 0) {
|
|
@@ -95,7 +89,7 @@ function parseArgs(argv) {
|
|
|
95
89
|
}
|
|
96
90
|
positional.push(arg);
|
|
97
91
|
}
|
|
98
|
-
return { positional, flags, mounts
|
|
92
|
+
return { positional, flags, mounts };
|
|
99
93
|
}
|
|
100
94
|
function parseMountFlag(raw) {
|
|
101
95
|
const eq = raw.indexOf('=');
|
|
@@ -125,10 +119,14 @@ Usage:
|
|
|
125
119
|
huddle start [options] [folder] Explicitly start a devcontainer
|
|
126
120
|
huddle init [options] Pull the Huddle + devcontainer base images and
|
|
127
121
|
start them via Docker or Podman
|
|
128
|
-
huddle restart Recreate the gateway (e.g.
|
|
129
|
-
team
|
|
122
|
+
huddle restart Recreate the gateway (e.g. to mount a changed
|
|
123
|
+
team firewall-rules folder)
|
|
130
124
|
huddle migrate [folder] Wire an existing docker-compose devcontainer
|
|
131
125
|
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)
|
|
132
130
|
huddle firewall list [options] Show firewall requests
|
|
133
131
|
huddle fw list [options] Alias for firewall list
|
|
134
132
|
huddle firewall add <domain> Add a custom firewall rule (wildcards
|
|
@@ -141,51 +139,14 @@ Usage:
|
|
|
141
139
|
huddle firewall group export <name> Export a group as JSON (--out <file>)
|
|
142
140
|
huddle firewall group import <file> Import a group (--replace to mirror)
|
|
143
141
|
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
|
|
165
142
|
huddle firewall folder set <path> Set the team-managed rules folder
|
|
166
143
|
huddle firewall folder reload Re-read the team-managed rules folder
|
|
167
144
|
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.
|
|
176
145
|
huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
|
|
177
146
|
and run init
|
|
178
147
|
huddle experiment reset Back to the stable release
|
|
179
148
|
huddle experiment status Show the active channel and CLI version
|
|
180
149
|
|
|
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
|
-
|
|
189
150
|
Init options:
|
|
190
151
|
--runtime <docker|podman> Container runtime (default: auto-detected;
|
|
191
152
|
also via the HUDDLE_RUNTIME env var)
|
|
@@ -207,13 +168,22 @@ Start options:
|
|
|
207
168
|
Migrate options:
|
|
208
169
|
--ca-path <path> Where the Huddle CA lands in the container
|
|
209
170
|
(NODE_EXTRA_CA_CERTS; default /home/vscode/.huddle-ca.crt)
|
|
210
|
-
--docker-socket Also wire the filtered Docker socket + DOCKER_HOST
|
|
211
|
-
|
|
212
|
-
socket exists before "docker compose up" starts them
|
|
171
|
+
--docker-socket Also wire the filtered Docker socket + DOCKER_HOST
|
|
172
|
+
(requires gateway socket pre-provisioning; see docs)
|
|
213
173
|
--output <path> Override file to write
|
|
214
174
|
(default: docker-compose.huddle.yml next to the source)
|
|
215
175
|
--force Overwrite an existing override file
|
|
216
176
|
|
|
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
|
+
|
|
217
187
|
Firewall options:
|
|
218
188
|
-i, --interactive Interactively approve/deny (list)
|
|
219
189
|
--container <name> Filter by (list) / scope to (add) a container
|
|
@@ -233,7 +203,7 @@ Firewall export/import options:
|
|
|
233
203
|
scope first (default: merge/upsert)
|
|
234
204
|
|
|
235
205
|
Global options:
|
|
236
|
-
--url <url> Huddle URL (default: http://localhost:
|
|
206
|
+
--url <url> Huddle URL (default: http://localhost:3000)
|
|
237
207
|
Or via the HUDDLE_URL env var
|
|
238
208
|
--help, -h Show help
|
|
239
209
|
--version, -v Show version (as published to
|
|
@@ -260,16 +230,8 @@ async function main() {
|
|
|
260
230
|
printHelp();
|
|
261
231
|
return;
|
|
262
232
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
// spelling the CLI must not use: Node binds a single literal, `localhost` is
|
|
266
|
-
// two, and on Windows it resolves to ::1 first. A browser papers over that,
|
|
267
|
-
// fetch() does not, so every command failed with "Huddle does not appear to be
|
|
268
|
-
// running" against a healthy process the portal was talking to happily.
|
|
269
|
-
// Leaving this unset lets api.ts try the loopback literals instead.
|
|
270
|
-
const url = flagString(flags, 'url') ?? process.env.HUDDLE_URL;
|
|
271
|
-
if (url)
|
|
272
|
-
(0, api_1.setBaseUrl)(url);
|
|
233
|
+
const url = flagString(flags, 'url') ?? process.env.HUDDLE_URL ?? 'http://localhost:3000';
|
|
234
|
+
(0, api_1.setBaseUrl)(url);
|
|
273
235
|
const startsWithExistingPath = cmd !== undefined && !COMMANDS.has(cmd) && fs_1.default.existsSync(path_1.default.resolve(cmd));
|
|
274
236
|
if (!cmd || cmd === 'start' || startsWithExistingPath) {
|
|
275
237
|
const startArgs = cmd === 'start' ? positional.slice(1) : startsWithExistingPath ? positional : [];
|
|
@@ -287,17 +249,6 @@ async function main() {
|
|
|
287
249
|
});
|
|
288
250
|
return;
|
|
289
251
|
}
|
|
290
|
-
if (cmd === 'node') {
|
|
291
|
-
// Runs Huddle Node in the FOREGROUND on this host — the shape you want
|
|
292
|
-
// while working on Huddle itself. `huddle init` starts the same process
|
|
293
|
-
// detached, alongside the gateway container.
|
|
294
|
-
await (0, node_1.runNode)({
|
|
295
|
-
entry: flagString(flags, 'entry'),
|
|
296
|
-
port: flagString(flags, 'port'),
|
|
297
|
-
dataDir: flagString(flags, 'data-dir'),
|
|
298
|
-
});
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
252
|
if (cmd === 'init') {
|
|
302
253
|
// Shows the exact CLI build, so with experiments it's immediately visible
|
|
303
254
|
// which version is running.
|
|
@@ -401,56 +352,17 @@ async function main() {
|
|
|
401
352
|
}
|
|
402
353
|
return;
|
|
403
354
|
}
|
|
404
|
-
if (cmd === '
|
|
405
|
-
await (0,
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
355
|
+
if (cmd === 'indexfolder' || cmd === 'indexfolders') {
|
|
356
|
+
await (0, indexfolder_1.runIndexFolder)({
|
|
357
|
+
path: positional[1],
|
|
358
|
+
depth: flagString(flags, 'depth'),
|
|
359
|
+
all: flagBool(flags, 'all'),
|
|
360
|
+
replace: flagBool(flags, 'replace'),
|
|
361
|
+
clear: flagBool(flags, 'clear'),
|
|
362
|
+
list: flagBool(flags, 'list'),
|
|
410
363
|
});
|
|
411
364
|
return;
|
|
412
365
|
}
|
|
413
|
-
if (cmd === 'sbx') {
|
|
414
|
-
const subCmd = sub ?? 'status';
|
|
415
|
-
if (subCmd === 'status') {
|
|
416
|
-
await (0, sbx_1.runSbxStatus)();
|
|
417
|
-
}
|
|
418
|
-
else if (subCmd === 'list' || subCmd === 'ls') {
|
|
419
|
-
await (0, sbx_1.runSbxList)();
|
|
420
|
-
}
|
|
421
|
-
else if (subCmd === 'start' || subCmd === 'create') {
|
|
422
|
-
await (0, sbx_1.runSbxStart)({
|
|
423
|
-
name: positional[2] ?? flagString(flags, 'name'),
|
|
424
|
-
agent: flagString(flags, 'agent'),
|
|
425
|
-
workspace: flagString(flags, 'workspace'),
|
|
426
|
-
folders: parsed.folders,
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
else if (subCmd === 'rm' || subCmd === 'remove' || subCmd === 'delete') {
|
|
430
|
-
await (0, sbx_1.runSbxRemove)({ name: positional[2] ?? flagString(flags, 'name'), force: flagBool(flags, 'force') });
|
|
431
|
-
}
|
|
432
|
-
else if (subCmd === 'reconcile' || subCmd === 'sync') {
|
|
433
|
-
await (0, sbx_1.runSbxReconcile)({ dryRun: flagBool(flags, 'dry-run') });
|
|
434
|
-
}
|
|
435
|
-
else if (subCmd === 'trust-ca' || subCmd === 'ca') {
|
|
436
|
-
await (0, sbx_1.runSbxTrustCa)({ name: positional[2] ?? flagString(flags, 'name') });
|
|
437
|
-
}
|
|
438
|
-
else if (subCmd === 'trust-host' || subCmd === 'host-ca') {
|
|
439
|
-
await (0, sbx_1.runSbxTrustHost)({ runtime: flagString(flags, 'runtime') });
|
|
440
|
-
}
|
|
441
|
-
else if (subCmd === 'log') {
|
|
442
|
-
await (0, sbx_1.runSbxLog)({ name: positional[2] ?? flagString(flags, 'name') });
|
|
443
|
-
}
|
|
444
|
-
else if (subCmd === 'ssh-setup' || subCmd === 'ssh') {
|
|
445
|
-
await (0, sbx_1.runSbxSshSetup)();
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
console.error(`Unknown sbx subcommand: ${subCmd}`);
|
|
449
|
-
console.error('Usage: huddle sbx <status|list|start|rm|reconcile|trust-ca|trust-host|ssh-setup|log>');
|
|
450
|
-
process.exit(1);
|
|
451
|
-
}
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
366
|
if (cmd === 'migrate') {
|
|
455
367
|
await (0, migrate_1.runMigrate)({
|
|
456
368
|
path: positional[1],
|
|
@@ -477,13 +389,10 @@ function flagString(flags, ...names) {
|
|
|
477
389
|
function flagBool(flags, ...names) {
|
|
478
390
|
return names.some((name) => flags[name] === true);
|
|
479
391
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
if (
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
process.exit(1);
|
|
489
|
-
});
|
|
392
|
+
main().catch((err) => {
|
|
393
|
+
console.error(`Error: ${err.message ?? err}`);
|
|
394
|
+
if (err instanceof api_1.ApiError && err.message.includes('Cannot reach Huddle API')) {
|
|
395
|
+
console.error('\nHuddle does not appear to be running. Start it with:\n huddle init');
|
|
396
|
+
}
|
|
397
|
+
process.exit(1);
|
|
398
|
+
});
|