@infosupport/huddle-cli 0.0.0-experiment-109.61.1 → 0.0.0-experiment-128.65.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/dist/index.js CHANGED
@@ -4,29 +4,23 @@ 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 logs_1 = require("./logs");
17
- const sbx_1 = require("./sbx");
18
14
  const images_1 = require("./images");
19
15
  const self_update_1 = require("./self-update");
20
16
  const utils_1 = require("./utils");
21
17
  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', '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']);
18
+ const VALUE_FLAGS = new Set(['url', 'ide', 'name', 'image', 'workspace', 'container', 'status', 'runtime', 'experiment', 'path', 'ca-path', 'output']);
19
+ const BOOLEAN_FLAGS = new Set(['help', 'h', 'empty', 'i', 'interactive', 'version', 'v', 'deny', 'docker-socket', 'force']);
20
+ const COMMANDS = new Set(['start', 'firewall', 'fw', 'init', 'experiment', 'migrate', 'help', 'version']);
25
21
  function parseArgs(argv) {
26
22
  const positional = [];
27
23
  const flags = {};
28
- const mounts = [];
29
- const folders = [];
30
24
  for (let i = 0; i < argv.length; i++) {
31
25
  const arg = argv[i];
32
26
  if (arg === '--') {
@@ -39,25 +33,6 @@ function parseArgs(argv) {
39
33
  const name = eq >= 0 ? raw.slice(0, eq) : raw;
40
34
  if (!name)
41
35
  throw new Error(`Invalid option: ${arg}`);
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';
46
- let value;
47
- if (eq >= 0) {
48
- value = raw.slice(eq + 1);
49
- }
50
- else {
51
- const next = argv[i + 1];
52
- if (next === undefined || next.startsWith('-')) {
53
- throw new Error(`Option --${name} expects a value (${expects})`);
54
- }
55
- value = next;
56
- i++;
57
- }
58
- (name === 'mount' ? mounts : folders).push(value);
59
- continue;
60
- }
61
36
  if (eq >= 0) {
62
37
  flags[name] = raw.slice(eq + 1);
63
38
  }
@@ -95,13 +70,7 @@ function parseArgs(argv) {
95
70
  }
96
71
  positional.push(arg);
97
72
  }
98
- return { positional, flags, mounts, folders };
99
- }
100
- function parseMountFlag(raw) {
101
- const eq = raw.indexOf('=');
102
- if (eq <= 0)
103
- throw new Error(`Invalid --mount value "${raw}", expected host=container`);
104
- return { hostPath: raw.slice(0, eq), containerPath: raw.slice(eq + 1) };
73
+ return { positional, flags };
105
74
  }
106
75
  function readVersion() {
107
76
  // npm always includes package.json in the published tarball, and it holds the
@@ -125,8 +94,6 @@ Usage:
125
94
  huddle start [options] [folder] Explicitly start a devcontainer
126
95
  huddle init [options] Pull the Huddle + devcontainer base images and
127
96
  start them via Docker or Podman
128
- huddle restart Recreate the gateway (e.g. after changing the
129
- team extensions folder, which loads at boot)
130
97
  huddle migrate [folder] Wire an existing docker-compose devcontainer
131
98
  behind Huddle by generating an override file
132
99
  huddle firewall list [options] Show firewall requests
@@ -135,57 +102,11 @@ Usage:
135
102
  supported: *.example.com and /path/*)
136
103
  huddle firewall delete <id> Delete a firewall rule by id (or domain;
137
104
  narrow with --container)
138
- huddle firewall export [options] Export firewall rules as JSON
139
- huddle firewall import <file> Import firewall rules from a JSON file
140
- huddle firewall group list List firewall groups (#69)
141
- huddle firewall group export <name> Export a group as JSON (--out <file>)
142
- huddle firewall group import <file> Import a group (--replace to mirror)
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
165
- huddle firewall folder set <path> Set the team-managed rules folder
166
- huddle firewall folder reload Re-read the team-managed rules folder
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.
176
105
  huddle experiment use <nr> Activate the experimental build of issue/PR <nr>
177
106
  and run init
178
107
  huddle experiment reset Back to the stable release
179
108
  huddle experiment status Show the active channel and CLI version
180
109
 
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
110
  Init options:
190
111
  --runtime <docker|podman> Container runtime (default: auto-detected;
191
112
  also via the HUDDLE_RUNTIME env var)
@@ -195,11 +116,6 @@ Init options:
195
116
  Start options:
196
117
  --ide <intellij|rider|vscode> IDE (default: intellij)
197
118
  --workspace <path> Workspace directory (default: current directory)
198
- --mount <host>=<container> Mount a host folder at an absolute container path, e.g.
199
- C:/projects/my-repo/backend=/workspace/backend
200
- (repeatable; cannot combine with --workspace/--empty)
201
- --workspace-root <path> Container path the IDE opens as project root when using
202
- --mount (default: common parent of the mount targets)
203
119
  --name <name> Container name (default: devcontainer-<foldername>)
204
120
  --image <image> Use a specific image
205
121
  --empty Empty container without a workspace
@@ -207,9 +123,8 @@ Start options:
207
123
  Migrate options:
208
124
  --ca-path <path> Where the Huddle CA lands in the container
209
125
  (NODE_EXTRA_CA_CERTS; default /home/vscode/.huddle-ca.crt)
210
- --docker-socket Also wire the filtered Docker socket + DOCKER_HOST;
211
- registers the container(s) with Huddle Node so the
212
- socket exists before "docker compose up" starts them
126
+ --docker-socket Also wire the filtered Docker socket + DOCKER_HOST
127
+ (requires gateway socket pre-provisioning; see docs)
213
128
  --output <path> Override file to write
214
129
  (default: docker-compose.huddle.yml next to the source)
215
130
  --force Overwrite an existing override file
@@ -217,8 +132,6 @@ Migrate options:
217
132
  Firewall options:
218
133
  -i, --interactive Interactively approve/deny (list)
219
134
  --container <name> Filter by (list) / scope to (add) a container
220
- (or __global__). On import: remap all rules
221
- to this scope
222
135
  --status <requested|allow|deny> Filter by status (default: requested)
223
136
 
224
137
  Firewall add options:
@@ -227,13 +140,8 @@ Firewall add options:
227
140
  (e.g. /_packaging/*/nuget/v3/*)
228
141
  --deny Create a block rule (default: allow)
229
142
 
230
- Firewall export/import options:
231
- --out <file> Write export to a file (default: stdout)
232
- --replace Import in replace mode: wipe the target
233
- scope first (default: merge/upsert)
234
-
235
143
  Global options:
236
- --url <url> Huddle URL (default: http://localhost:24842)
144
+ --url <url> Huddle URL (default: http://localhost:3000)
237
145
  Or via the HUDDLE_URL env var
238
146
  --help, -h Show help
239
147
  --version, -v Show version (as published to
@@ -250,7 +158,7 @@ async function main() {
250
158
  console.error('Run "huddle --help" for help.');
251
159
  process.exit(1);
252
160
  }
253
- const { positional, flags, mounts } = parsed;
161
+ const { positional, flags } = parsed;
254
162
  const [cmd, sub] = positional;
255
163
  if (flagBool(flags, 'version', 'v') || cmd === 'version') {
256
164
  console.log(readVersion());
@@ -260,16 +168,8 @@ async function main() {
260
168
  printHelp();
261
169
  return;
262
170
  }
263
- // Only when the operator named an address. The fallback used to be nodeUrl(),
264
- // which is the URL for a HUMAN — `http://localhost:…` — and that is the one
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);
171
+ const url = flagString(flags, 'url') ?? process.env.HUDDLE_URL ?? 'http://localhost:3000';
172
+ (0, api_1.setBaseUrl)(url);
273
173
  const startsWithExistingPath = cmd !== undefined && !COMMANDS.has(cmd) && fs_1.default.existsSync(path_1.default.resolve(cmd));
274
174
  if (!cmd || cmd === 'start' || startsWithExistingPath) {
275
175
  const startArgs = cmd === 'start' ? positional.slice(1) : startsWithExistingPath ? positional : [];
@@ -279,25 +179,12 @@ async function main() {
279
179
  await (0, start_1.runStart)({
280
180
  ide: flagString(flags, 'ide') ?? 'intellij',
281
181
  workspace: flagString(flags, 'workspace') ?? startArgs[0],
282
- mounts: mounts.length ? mounts.map(parseMountFlag) : undefined,
283
- workspaceRoot: flagString(flags, 'workspace-root'),
284
182
  name: flagString(flags, 'name'),
285
183
  image: flagString(flags, 'image'),
286
184
  empty: flagBool(flags, 'empty'),
287
185
  });
288
186
  return;
289
187
  }
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
188
  if (cmd === 'init') {
302
189
  // Shows the exact CLI build, so with experiments it's immediately visible
303
190
  // which version is running.
@@ -315,15 +202,6 @@ async function main() {
315
202
  await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
316
203
  return;
317
204
  }
318
- if (cmd === 'restart') {
319
- // Stop + recreate the gateway (runInit does `rm -f` first) so changed team
320
- // folders get mounted. The portal writes the paths straight into the mounted
321
- // ~/.huddle/config.json, so runInit already reads the latest values here.
322
- const initOpts = { runtime: flagString(flags, 'runtime') };
323
- (0, experiment_1.ensureCliForChannel)(process.argv.slice(2));
324
- await (0, init_1.runInit)(initOpts, (0, images_1.resolveImages)());
325
- return;
326
- }
327
205
  if (cmd === 'experiment') {
328
206
  const subCmd = sub ?? 'status';
329
207
  if (subCmd === 'use') {
@@ -365,92 +243,12 @@ async function main() {
365
243
  container: flagString(flags, 'container'),
366
244
  });
367
245
  }
368
- else if (subCmd === 'export') {
369
- await (0, firewall_1.runFirewallExport)({
370
- container: flagString(flags, 'container'),
371
- out: flagString(flags, 'out'),
372
- });
373
- }
374
- else if (subCmd === 'import') {
375
- const file = positional[2];
376
- if (!file) {
377
- console.error('Usage: huddle firewall import <file> [--replace] [--container <id>]');
378
- process.exit(1);
379
- }
380
- await (0, firewall_1.runFirewallImport)({
381
- file,
382
- replace: flagBool(flags, 'replace'),
383
- container: flagString(flags, 'container'),
384
- });
385
- }
386
- else if (subCmd === 'group' || subCmd === 'groups') {
387
- await (0, firewall_1.runFirewallGroup)({
388
- action: positional[2],
389
- arg: positional[3],
390
- out: flagString(flags, 'out'),
391
- replace: flagBool(flags, 'replace'),
392
- container: flagString(flags, 'container'),
393
- });
394
- }
395
- else if (subCmd === 'folder') {
396
- await (0, firewall_1.runFirewallFolder)({ action: positional[2], path: positional[3] });
397
- }
398
246
  else {
399
247
  console.error(`Unknown firewall subcommand: ${subCmd}`);
400
248
  process.exit(1);
401
249
  }
402
250
  return;
403
251
  }
404
- if (cmd === 'logs' || cmd === 'log') {
405
- await (0, logs_1.runLogs)({
406
- lines: flagString(flags, 'lines', 'n'),
407
- follow: flagBool(flags, 'follow', 'f'),
408
- node: flagBool(flags, 'node'),
409
- gateway: flagBool(flags, 'gateway'),
410
- });
411
- return;
412
- }
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
252
  if (cmd === 'migrate') {
455
253
  await (0, migrate_1.runMigrate)({
456
254
  path: positional[1],
@@ -477,13 +275,10 @@ function flagString(flags, ...names) {
477
275
  function flagBool(flags, ...names) {
478
276
  return names.some((name) => flags[name] === true);
479
277
  }
480
- // Guarded so the arg parser above can be imported by tests without the CLI
481
- // running itself as a side effect of the import.
482
- if (require.main === module)
483
- main().catch((err) => {
484
- console.error(`Error: ${err.message ?? err}`);
485
- if (err instanceof api_1.ApiError && err.message.includes('Cannot reach Huddle API')) {
486
- console.error('\nHuddle does not appear to be running. Start it with:\n huddle init');
487
- }
488
- process.exit(1);
489
- });
278
+ main().catch((err) => {
279
+ console.error(`Error: ${err.message ?? err}`);
280
+ if (err instanceof api_1.ApiError && err.message.includes('Cannot reach Huddle API')) {
281
+ console.error('\nHuddle does not appear to be running. Start it with:\n huddle init');
282
+ }
283
+ process.exit(1);
284
+ });